@effect-uai/core 0.18.0 → 0.19.0-dev-20261110065930
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 +4 -4
- package/dist/Content-D_Qfn8Ja.d.mts +48 -0
- package/dist/Content-D_Qfn8Ja.d.mts.map +1 -0
- package/dist/File-B923KvZ9.d.mts +46 -0
- package/dist/File-B923KvZ9.d.mts.map +1 -0
- package/dist/{Image-Cv6iBLTy.d.mts → Image-Bzc1H_UK.d.mts} +19 -8
- package/dist/Image-Bzc1H_UK.d.mts.map +1 -0
- package/dist/{Items-C7MyrYPX.d.mts → Items-Bvx8s9QH.d.mts} +109 -16
- package/dist/Items-Bvx8s9QH.d.mts.map +1 -0
- package/dist/{Loop-ChpaO-ya.d.mts → Loop-CeA0AelN.d.mts} +7 -6
- package/dist/Loop-CeA0AelN.d.mts.map +1 -0
- package/dist/Tool-Bkryw6-h.d.mts +206 -0
- package/dist/Tool-Bkryw6-h.d.mts.map +1 -0
- package/dist/ToolEvent-9inLx5cI.d.mts +22 -0
- package/dist/ToolEvent-9inLx5cI.d.mts.map +1 -0
- package/dist/ToolOutput-BNTIQgGB.d.mts +151 -0
- package/dist/ToolOutput-BNTIQgGB.d.mts.map +1 -0
- package/dist/Toolkit-D2VGeD5R.d.mts +212 -0
- package/dist/Toolkit-D2VGeD5R.d.mts.map +1 -0
- package/dist/browser/BrowserTool.d.mts +84 -22
- package/dist/browser/BrowserTool.d.mts.map +1 -1
- package/dist/browser/BrowserTool.mjs +5 -0
- package/dist/browser/BrowserTool.mjs.map +1 -1
- package/dist/capabilities/Capabilities.d.mts +1 -1
- package/dist/decision-model/Decision.test.mjs +1 -1
- package/dist/{dist-C8RmtoR8.mjs → dist-B5K-y4Be.mjs} +51 -32
- package/dist/dist-B5K-y4Be.mjs.map +1 -0
- package/dist/domain/File.d.mts +2 -0
- package/dist/domain/File.mjs +51 -0
- package/dist/domain/File.mjs.map +1 -0
- package/dist/domain/Image.d.mts +2 -2
- package/dist/domain/Image.mjs +12 -2
- package/dist/domain/Image.mjs.map +1 -1
- package/dist/domain/Items.d.mts +2 -2
- package/dist/domain/Items.mjs +65 -4
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Realtime.d.mts +72 -490
- package/dist/domain/Realtime.d.mts.map +1 -1
- package/dist/domain/Research.d.mts +1 -1
- package/dist/domain/Transcript.test.mjs +1 -1
- package/dist/domain/Turn.d.mts +57 -262
- package/dist/domain/Turn.d.mts.map +1 -1
- package/dist/domain/Turn.mjs +1 -1
- package/dist/embedding-model/Embedding.d.mts +1 -1
- package/dist/image-generator/ImageGenerator.d.mts +10 -66
- package/dist/image-generator/ImageGenerator.d.mts.map +1 -1
- package/dist/index.d.mts +10 -9
- package/dist/index.mjs +7 -6
- package/dist/language-model/LanguageModel.d.mts +2 -2
- package/dist/loop/Loop.d.mts +1 -1
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/messenger/Messenger.d.mts +43 -289
- package/dist/messenger/Messenger.d.mts.map +1 -1
- package/dist/messenger/MessengerAdapter.test.mjs +1 -1
- package/dist/observability/Metrics.d.mts +1 -1
- package/dist/observability/Metrics.test.mjs +1 -1
- package/dist/observability/Telemetry.test.mjs +1 -1
- package/dist/realtime/RealtimeSession.d.mts +1 -1
- package/dist/realtime/RealtimeSession.test.mjs +1 -1
- package/dist/sandbox/Sandbox.d.mts +32 -237
- package/dist/sandbox/Sandbox.d.mts.map +1 -1
- package/dist/streaming/Multipart.mjs +2 -1
- package/dist/streaming/Multipart.mjs.map +1 -1
- package/dist/streaming/Multipart.test.mjs +28 -0
- package/dist/streaming/Multipart.test.mjs.map +1 -0
- package/dist/streaming/Settle.test.mjs +1 -1
- package/dist/streaming/WebSocketSession.test.mjs +1 -1
- package/dist/testing/MockMessenger.d.mts +19 -134
- package/dist/testing/MockMessenger.d.mts.map +1 -1
- package/dist/testing/MockProvider.d.mts +1 -1
- package/dist/testing/MockSandbox.d.mts +65 -446
- package/dist/testing/MockSandbox.d.mts.map +1 -1
- package/dist/tool/Content.d.mts +2 -0
- package/dist/tool/Content.mjs +46 -0
- package/dist/tool/Content.mjs.map +1 -0
- package/dist/tool/Content.test.d.mts +1 -0
- package/dist/tool/Content.test.mjs +48 -0
- package/dist/tool/Content.test.mjs.map +1 -0
- package/dist/tool/HistoryCheck.d.mts +6 -15
- package/dist/tool/HistoryCheck.d.mts.map +1 -1
- package/dist/tool/HistoryCheck.mjs +10 -24
- package/dist/tool/HistoryCheck.mjs.map +1 -1
- package/dist/tool/Tool.d.mts +2 -2
- package/dist/tool/Tool.mjs +55 -130
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/Tool.test.mjs +220 -176
- package/dist/tool/Tool.test.mjs.map +1 -1
- package/dist/tool/ToolDecision.d.mts +164 -0
- package/dist/tool/ToolDecision.d.mts.map +1 -0
- package/dist/tool/ToolDecision.mjs +146 -0
- package/dist/tool/ToolDecision.mjs.map +1 -0
- package/dist/tool/ToolDecision.test.d.mts +1 -0
- package/dist/tool/ToolDecision.test.mjs +330 -0
- package/dist/tool/ToolDecision.test.mjs.map +1 -0
- package/dist/tool/ToolEvent.d.mts +2 -2
- package/dist/tool/ToolEvent.mjs +2 -34
- package/dist/tool/ToolEvent.mjs.map +1 -1
- package/dist/tool/ToolOutput.d.mts +2 -0
- package/dist/tool/ToolOutput.mjs +128 -0
- package/dist/tool/ToolOutput.mjs.map +1 -0
- package/dist/tool/ToolOutput.test.d.mts +1 -0
- package/dist/tool/ToolOutput.test.mjs +153 -0
- package/dist/tool/ToolOutput.test.mjs.map +1 -0
- package/dist/tool/Toolkit.d.mts +2 -2
- package/dist/tool/Toolkit.mjs +230 -165
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.mjs +431 -389
- package/dist/tool/Toolkit.test.mjs.map +1 -1
- package/dist/web-read/WebReadTool.d.mts +2 -2
- package/dist/web-read/WebReadTool.mjs +1 -0
- package/dist/web-read/WebReadTool.mjs.map +1 -1
- package/dist/web-search/WebSearchTool.d.mts +2 -2
- package/dist/web-search/WebSearchTool.mjs +1 -0
- package/dist/web-search/WebSearchTool.mjs.map +1 -1
- package/package.json +17 -9
- package/src/browser/BrowserTool.ts +5 -0
- package/src/domain/File.ts +79 -0
- package/src/domain/Image.ts +14 -4
- package/src/domain/Items.ts +39 -3
- package/src/index.ts +3 -2
- package/src/loop/Loop.ts +24 -13
- package/src/streaming/Multipart.test.ts +26 -0
- package/src/streaming/Multipart.ts +5 -4
- package/src/tool/Content.test.ts +40 -0
- package/src/tool/Content.ts +38 -0
- package/src/tool/HistoryCheck.ts +21 -26
- package/src/tool/Tool.test.ts +240 -241
- package/src/tool/Tool.ts +203 -308
- package/src/tool/ToolDecision.test.ts +301 -0
- package/src/tool/ToolDecision.ts +360 -0
- package/src/tool/ToolEvent.ts +21 -41
- package/src/tool/ToolOutput.test.ts +132 -0
- package/src/tool/ToolOutput.ts +198 -0
- package/src/tool/Toolkit.test.ts +594 -454
- package/src/tool/Toolkit.ts +631 -356
- package/src/web-read/WebReadTool.ts +2 -1
- package/src/web-search/WebSearchTool.ts +2 -1
- package/dist/Image-Cv6iBLTy.d.mts.map +0 -1
- package/dist/Items-C7MyrYPX.d.mts.map +0 -1
- package/dist/Loop-ChpaO-ya.d.mts.map +0 -1
- package/dist/Tool-BF78QWtn.d.mts +0 -314
- package/dist/Tool-BF78QWtn.d.mts.map +0 -1
- package/dist/ToolEvent-Di4a723B.d.mts +0 -144
- package/dist/ToolEvent-Di4a723B.d.mts.map +0 -1
- package/dist/ToolResult-BsYQRjmW.d.mts +0 -152
- package/dist/ToolResult-BsYQRjmW.d.mts.map +0 -1
- package/dist/Toolkit-tlL0F2YR.d.mts +0 -193
- package/dist/Toolkit-tlL0F2YR.d.mts.map +0 -1
- package/dist/dist-C8RmtoR8.mjs.map +0 -1
- package/dist/tool/Approval.d.mts +0 -113
- package/dist/tool/Approval.d.mts.map +0 -1
- package/dist/tool/Approval.mjs +0 -80
- package/dist/tool/Approval.mjs.map +0 -1
- package/dist/tool/Approval.test.mjs +0 -371
- package/dist/tool/Approval.test.mjs.map +0 -1
- package/dist/tool/ToolResult.d.mts +0 -2
- package/dist/tool/ToolResult.mjs +0 -85
- package/dist/tool/ToolResult.mjs.map +0 -1
- package/src/tool/Approval.test.ts +0 -400
- package/src/tool/Approval.ts +0 -181
- package/src/tool/ToolResult.ts +0 -114
- /package/dist/{tool/Approval.test.d.mts → streaming/Multipart.test.d.mts} +0 -0
|
@@ -71,452 +71,71 @@ type Call = Data.TaggedEnum<{
|
|
|
71
71
|
readonly id: VolumeId;
|
|
72
72
|
};
|
|
73
73
|
}>;
|
|
74
|
-
declare const Call: {
|
|
75
|
-
readonly
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
readonly _tag: "FileWrite";
|
|
140
|
-
readonly id: SandboxId;
|
|
141
|
-
readonly path: string;
|
|
142
|
-
readonly contents: Uint8Array | string;
|
|
143
|
-
}, {
|
|
144
|
-
readonly _tag: Tag;
|
|
145
|
-
}> | Extract<{
|
|
146
|
-
readonly _tag: "SnapshotCreate";
|
|
147
|
-
readonly id: SandboxId;
|
|
148
|
-
readonly name?: string;
|
|
149
|
-
}, {
|
|
150
|
-
readonly _tag: Tag;
|
|
151
|
-
}> | Extract<{
|
|
152
|
-
readonly _tag: "SnapshotDestroy";
|
|
153
|
-
readonly id: SnapshotId;
|
|
154
|
-
}, {
|
|
155
|
-
readonly _tag: Tag;
|
|
156
|
-
}> | Extract<{
|
|
157
|
-
readonly _tag: "Spawn";
|
|
158
|
-
readonly id: SandboxId;
|
|
159
|
-
readonly request: CommonSpawnRequest;
|
|
160
|
-
}, {
|
|
161
|
-
readonly _tag: Tag;
|
|
162
|
-
}> | Extract<{
|
|
163
|
-
readonly _tag: "VolumeCreate";
|
|
164
|
-
readonly name: string;
|
|
165
|
-
readonly quotaBytes?: number;
|
|
166
|
-
}, {
|
|
167
|
-
readonly _tag: Tag;
|
|
168
|
-
}> | Extract<{
|
|
169
|
-
readonly _tag: "VolumeDestroy";
|
|
170
|
-
readonly id: VolumeId;
|
|
171
|
-
}, {
|
|
172
|
-
readonly _tag: Tag;
|
|
173
|
-
}>;
|
|
174
|
-
readonly $match: {
|
|
175
|
-
<Cases extends { readonly [Tag in "Attach" | "Create" | "Destroy" | "Exec" | "ExecStream" | "ExposePort" | "FileExists" | "FileList" | "FileMkdir" | "FileRead" | "FileRemove" | "FileWrite" | "SnapshotCreate" | "SnapshotDestroy" | "Spawn" | "VolumeCreate" | "VolumeDestroy"]: (args: Extract<{
|
|
176
|
-
readonly _tag: "Attach";
|
|
177
|
-
readonly id: SandboxId;
|
|
178
|
-
} | {
|
|
179
|
-
readonly _tag: "Create";
|
|
180
|
-
readonly request: CommonCreateRequest;
|
|
181
|
-
} | {
|
|
182
|
-
readonly _tag: "Destroy";
|
|
183
|
-
readonly id: SandboxId;
|
|
184
|
-
} | {
|
|
185
|
-
readonly _tag: "Exec";
|
|
186
|
-
readonly id: SandboxId;
|
|
187
|
-
readonly request: CommonExecRequest;
|
|
188
|
-
} | {
|
|
189
|
-
readonly _tag: "ExecStream";
|
|
190
|
-
readonly id: SandboxId;
|
|
191
|
-
readonly request: CommonExecRequest;
|
|
192
|
-
} | {
|
|
193
|
-
readonly _tag: "ExposePort";
|
|
194
|
-
readonly id: SandboxId;
|
|
195
|
-
readonly port: number;
|
|
196
|
-
} | {
|
|
197
|
-
readonly _tag: "FileExists";
|
|
198
|
-
readonly id: SandboxId;
|
|
199
|
-
readonly path: string;
|
|
200
|
-
} | {
|
|
201
|
-
readonly _tag: "FileList";
|
|
202
|
-
readonly id: SandboxId;
|
|
203
|
-
readonly path: string;
|
|
204
|
-
} | {
|
|
205
|
-
readonly _tag: "FileMkdir";
|
|
206
|
-
readonly id: SandboxId;
|
|
207
|
-
readonly path: string;
|
|
208
|
-
} | {
|
|
209
|
-
readonly _tag: "FileRead";
|
|
210
|
-
readonly id: SandboxId;
|
|
211
|
-
readonly path: string;
|
|
212
|
-
} | {
|
|
213
|
-
readonly _tag: "FileRemove";
|
|
214
|
-
readonly id: SandboxId;
|
|
215
|
-
readonly path: string;
|
|
216
|
-
} | {
|
|
217
|
-
readonly _tag: "FileWrite";
|
|
218
|
-
readonly id: SandboxId;
|
|
219
|
-
readonly path: string;
|
|
220
|
-
readonly contents: Uint8Array | string;
|
|
221
|
-
} | {
|
|
222
|
-
readonly _tag: "SnapshotCreate";
|
|
223
|
-
readonly id: SandboxId;
|
|
224
|
-
readonly name?: string;
|
|
225
|
-
} | {
|
|
226
|
-
readonly _tag: "SnapshotDestroy";
|
|
227
|
-
readonly id: SnapshotId;
|
|
228
|
-
} | {
|
|
229
|
-
readonly _tag: "Spawn";
|
|
230
|
-
readonly id: SandboxId;
|
|
231
|
-
readonly request: CommonSpawnRequest;
|
|
232
|
-
} | {
|
|
233
|
-
readonly _tag: "VolumeCreate";
|
|
234
|
-
readonly name: string;
|
|
235
|
-
readonly quotaBytes?: number;
|
|
236
|
-
} | {
|
|
237
|
-
readonly _tag: "VolumeDestroy";
|
|
238
|
-
readonly id: VolumeId;
|
|
239
|
-
}, {
|
|
240
|
-
readonly _tag: Tag;
|
|
241
|
-
}>) => any; }>(cases: Cases): (value: {
|
|
242
|
-
readonly _tag: "Attach";
|
|
243
|
-
readonly id: SandboxId;
|
|
244
|
-
} | {
|
|
245
|
-
readonly _tag: "Create";
|
|
246
|
-
readonly request: CommonCreateRequest;
|
|
247
|
-
} | {
|
|
248
|
-
readonly _tag: "Destroy";
|
|
249
|
-
readonly id: SandboxId;
|
|
250
|
-
} | {
|
|
251
|
-
readonly _tag: "Exec";
|
|
252
|
-
readonly id: SandboxId;
|
|
253
|
-
readonly request: CommonExecRequest;
|
|
254
|
-
} | {
|
|
255
|
-
readonly _tag: "ExecStream";
|
|
256
|
-
readonly id: SandboxId;
|
|
257
|
-
readonly request: CommonExecRequest;
|
|
258
|
-
} | {
|
|
259
|
-
readonly _tag: "ExposePort";
|
|
260
|
-
readonly id: SandboxId;
|
|
261
|
-
readonly port: number;
|
|
262
|
-
} | {
|
|
263
|
-
readonly _tag: "FileExists";
|
|
264
|
-
readonly id: SandboxId;
|
|
265
|
-
readonly path: string;
|
|
266
|
-
} | {
|
|
267
|
-
readonly _tag: "FileList";
|
|
268
|
-
readonly id: SandboxId;
|
|
269
|
-
readonly path: string;
|
|
270
|
-
} | {
|
|
271
|
-
readonly _tag: "FileMkdir";
|
|
272
|
-
readonly id: SandboxId;
|
|
273
|
-
readonly path: string;
|
|
274
|
-
} | {
|
|
275
|
-
readonly _tag: "FileRead";
|
|
276
|
-
readonly id: SandboxId;
|
|
277
|
-
readonly path: string;
|
|
278
|
-
} | {
|
|
279
|
-
readonly _tag: "FileRemove";
|
|
280
|
-
readonly id: SandboxId;
|
|
281
|
-
readonly path: string;
|
|
282
|
-
} | {
|
|
283
|
-
readonly _tag: "FileWrite";
|
|
284
|
-
readonly id: SandboxId;
|
|
285
|
-
readonly path: string;
|
|
286
|
-
readonly contents: Uint8Array | string;
|
|
287
|
-
} | {
|
|
288
|
-
readonly _tag: "SnapshotCreate";
|
|
289
|
-
readonly id: SandboxId;
|
|
290
|
-
readonly name?: string;
|
|
291
|
-
} | {
|
|
292
|
-
readonly _tag: "SnapshotDestroy";
|
|
293
|
-
readonly id: SnapshotId;
|
|
294
|
-
} | {
|
|
295
|
-
readonly _tag: "Spawn";
|
|
296
|
-
readonly id: SandboxId;
|
|
297
|
-
readonly request: CommonSpawnRequest;
|
|
298
|
-
} | {
|
|
299
|
-
readonly _tag: "VolumeCreate";
|
|
300
|
-
readonly name: string;
|
|
301
|
-
readonly quotaBytes?: number;
|
|
302
|
-
} | {
|
|
303
|
-
readonly _tag: "VolumeDestroy";
|
|
304
|
-
readonly id: VolumeId;
|
|
305
|
-
}) => import("effect/Unify").Unify<ReturnType<Cases["Attach" | "Create" | "Destroy" | "Exec" | "ExecStream" | "ExposePort" | "FileExists" | "FileList" | "FileMkdir" | "FileRead" | "FileRemove" | "FileWrite" | "SnapshotCreate" | "SnapshotDestroy" | "Spawn" | "VolumeCreate" | "VolumeDestroy"]>>;
|
|
306
|
-
<Cases extends { readonly [Tag in "Attach" | "Create" | "Destroy" | "Exec" | "ExecStream" | "ExposePort" | "FileExists" | "FileList" | "FileMkdir" | "FileRead" | "FileRemove" | "FileWrite" | "SnapshotCreate" | "SnapshotDestroy" | "Spawn" | "VolumeCreate" | "VolumeDestroy"]: (args: Extract<{
|
|
307
|
-
readonly _tag: "Attach";
|
|
308
|
-
readonly id: SandboxId;
|
|
309
|
-
} | {
|
|
310
|
-
readonly _tag: "Create";
|
|
311
|
-
readonly request: CommonCreateRequest;
|
|
312
|
-
} | {
|
|
313
|
-
readonly _tag: "Destroy";
|
|
314
|
-
readonly id: SandboxId;
|
|
315
|
-
} | {
|
|
316
|
-
readonly _tag: "Exec";
|
|
317
|
-
readonly id: SandboxId;
|
|
318
|
-
readonly request: CommonExecRequest;
|
|
319
|
-
} | {
|
|
320
|
-
readonly _tag: "ExecStream";
|
|
321
|
-
readonly id: SandboxId;
|
|
322
|
-
readonly request: CommonExecRequest;
|
|
323
|
-
} | {
|
|
324
|
-
readonly _tag: "ExposePort";
|
|
325
|
-
readonly id: SandboxId;
|
|
326
|
-
readonly port: number;
|
|
327
|
-
} | {
|
|
328
|
-
readonly _tag: "FileExists";
|
|
329
|
-
readonly id: SandboxId;
|
|
330
|
-
readonly path: string;
|
|
331
|
-
} | {
|
|
332
|
-
readonly _tag: "FileList";
|
|
333
|
-
readonly id: SandboxId;
|
|
334
|
-
readonly path: string;
|
|
335
|
-
} | {
|
|
336
|
-
readonly _tag: "FileMkdir";
|
|
337
|
-
readonly id: SandboxId;
|
|
338
|
-
readonly path: string;
|
|
339
|
-
} | {
|
|
340
|
-
readonly _tag: "FileRead";
|
|
341
|
-
readonly id: SandboxId;
|
|
342
|
-
readonly path: string;
|
|
343
|
-
} | {
|
|
344
|
-
readonly _tag: "FileRemove";
|
|
345
|
-
readonly id: SandboxId;
|
|
346
|
-
readonly path: string;
|
|
347
|
-
} | {
|
|
348
|
-
readonly _tag: "FileWrite";
|
|
349
|
-
readonly id: SandboxId;
|
|
350
|
-
readonly path: string;
|
|
351
|
-
readonly contents: Uint8Array | string;
|
|
352
|
-
} | {
|
|
353
|
-
readonly _tag: "SnapshotCreate";
|
|
354
|
-
readonly id: SandboxId;
|
|
355
|
-
readonly name?: string;
|
|
356
|
-
} | {
|
|
357
|
-
readonly _tag: "SnapshotDestroy";
|
|
358
|
-
readonly id: SnapshotId;
|
|
359
|
-
} | {
|
|
360
|
-
readonly _tag: "Spawn";
|
|
361
|
-
readonly id: SandboxId;
|
|
362
|
-
readonly request: CommonSpawnRequest;
|
|
363
|
-
} | {
|
|
364
|
-
readonly _tag: "VolumeCreate";
|
|
365
|
-
readonly name: string;
|
|
366
|
-
readonly quotaBytes?: number;
|
|
367
|
-
} | {
|
|
368
|
-
readonly _tag: "VolumeDestroy";
|
|
369
|
-
readonly id: VolumeId;
|
|
370
|
-
}, {
|
|
371
|
-
readonly _tag: Tag;
|
|
372
|
-
}>) => any; }>(value: {
|
|
373
|
-
readonly _tag: "Attach";
|
|
374
|
-
readonly id: SandboxId;
|
|
375
|
-
} | {
|
|
376
|
-
readonly _tag: "Create";
|
|
377
|
-
readonly request: CommonCreateRequest;
|
|
378
|
-
} | {
|
|
379
|
-
readonly _tag: "Destroy";
|
|
380
|
-
readonly id: SandboxId;
|
|
381
|
-
} | {
|
|
382
|
-
readonly _tag: "Exec";
|
|
383
|
-
readonly id: SandboxId;
|
|
384
|
-
readonly request: CommonExecRequest;
|
|
385
|
-
} | {
|
|
386
|
-
readonly _tag: "ExecStream";
|
|
387
|
-
readonly id: SandboxId;
|
|
388
|
-
readonly request: CommonExecRequest;
|
|
389
|
-
} | {
|
|
390
|
-
readonly _tag: "ExposePort";
|
|
391
|
-
readonly id: SandboxId;
|
|
392
|
-
readonly port: number;
|
|
393
|
-
} | {
|
|
394
|
-
readonly _tag: "FileExists";
|
|
395
|
-
readonly id: SandboxId;
|
|
396
|
-
readonly path: string;
|
|
397
|
-
} | {
|
|
398
|
-
readonly _tag: "FileList";
|
|
399
|
-
readonly id: SandboxId;
|
|
400
|
-
readonly path: string;
|
|
401
|
-
} | {
|
|
402
|
-
readonly _tag: "FileMkdir";
|
|
403
|
-
readonly id: SandboxId;
|
|
404
|
-
readonly path: string;
|
|
405
|
-
} | {
|
|
406
|
-
readonly _tag: "FileRead";
|
|
407
|
-
readonly id: SandboxId;
|
|
408
|
-
readonly path: string;
|
|
409
|
-
} | {
|
|
410
|
-
readonly _tag: "FileRemove";
|
|
411
|
-
readonly id: SandboxId;
|
|
412
|
-
readonly path: string;
|
|
413
|
-
} | {
|
|
414
|
-
readonly _tag: "FileWrite";
|
|
415
|
-
readonly id: SandboxId;
|
|
416
|
-
readonly path: string;
|
|
417
|
-
readonly contents: Uint8Array | string;
|
|
418
|
-
} | {
|
|
419
|
-
readonly _tag: "SnapshotCreate";
|
|
420
|
-
readonly id: SandboxId;
|
|
421
|
-
readonly name?: string;
|
|
422
|
-
} | {
|
|
423
|
-
readonly _tag: "SnapshotDestroy";
|
|
424
|
-
readonly id: SnapshotId;
|
|
425
|
-
} | {
|
|
426
|
-
readonly _tag: "Spawn";
|
|
427
|
-
readonly id: SandboxId;
|
|
428
|
-
readonly request: CommonSpawnRequest;
|
|
429
|
-
} | {
|
|
430
|
-
readonly _tag: "VolumeCreate";
|
|
431
|
-
readonly name: string;
|
|
432
|
-
readonly quotaBytes?: number;
|
|
433
|
-
} | {
|
|
434
|
-
readonly _tag: "VolumeDestroy";
|
|
435
|
-
readonly id: VolumeId;
|
|
436
|
-
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Attach" | "Create" | "Destroy" | "Exec" | "ExecStream" | "ExposePort" | "FileExists" | "FileList" | "FileMkdir" | "FileRead" | "FileRemove" | "FileWrite" | "SnapshotCreate" | "SnapshotDestroy" | "Spawn" | "VolumeCreate" | "VolumeDestroy"]>>;
|
|
437
|
-
};
|
|
438
|
-
readonly Attach: Data.TaggedEnum.ConstructorFrom<{
|
|
439
|
-
readonly _tag: "Attach";
|
|
440
|
-
readonly id: SandboxId;
|
|
441
|
-
}, "_tag">;
|
|
442
|
-
readonly Create: Data.TaggedEnum.ConstructorFrom<{
|
|
443
|
-
readonly _tag: "Create";
|
|
444
|
-
readonly request: CommonCreateRequest;
|
|
445
|
-
}, "_tag">;
|
|
446
|
-
readonly Destroy: Data.TaggedEnum.ConstructorFrom<{
|
|
447
|
-
readonly _tag: "Destroy";
|
|
448
|
-
readonly id: SandboxId;
|
|
449
|
-
}, "_tag">;
|
|
450
|
-
readonly Exec: Data.TaggedEnum.ConstructorFrom<{
|
|
451
|
-
readonly _tag: "Exec";
|
|
452
|
-
readonly id: SandboxId;
|
|
453
|
-
readonly request: CommonExecRequest;
|
|
454
|
-
}, "_tag">;
|
|
455
|
-
readonly ExecStream: Data.TaggedEnum.ConstructorFrom<{
|
|
456
|
-
readonly _tag: "ExecStream";
|
|
457
|
-
readonly id: SandboxId;
|
|
458
|
-
readonly request: CommonExecRequest;
|
|
459
|
-
}, "_tag">;
|
|
460
|
-
readonly ExposePort: Data.TaggedEnum.ConstructorFrom<{
|
|
461
|
-
readonly _tag: "ExposePort";
|
|
462
|
-
readonly id: SandboxId;
|
|
463
|
-
readonly port: number;
|
|
464
|
-
}, "_tag">;
|
|
465
|
-
readonly FileExists: Data.TaggedEnum.ConstructorFrom<{
|
|
466
|
-
readonly _tag: "FileExists";
|
|
467
|
-
readonly id: SandboxId;
|
|
468
|
-
readonly path: string;
|
|
469
|
-
}, "_tag">;
|
|
470
|
-
readonly FileList: Data.TaggedEnum.ConstructorFrom<{
|
|
471
|
-
readonly _tag: "FileList";
|
|
472
|
-
readonly id: SandboxId;
|
|
473
|
-
readonly path: string;
|
|
474
|
-
}, "_tag">;
|
|
475
|
-
readonly FileMkdir: Data.TaggedEnum.ConstructorFrom<{
|
|
476
|
-
readonly _tag: "FileMkdir";
|
|
477
|
-
readonly id: SandboxId;
|
|
478
|
-
readonly path: string;
|
|
479
|
-
}, "_tag">;
|
|
480
|
-
readonly FileRead: Data.TaggedEnum.ConstructorFrom<{
|
|
481
|
-
readonly _tag: "FileRead";
|
|
482
|
-
readonly id: SandboxId;
|
|
483
|
-
readonly path: string;
|
|
484
|
-
}, "_tag">;
|
|
485
|
-
readonly FileRemove: Data.TaggedEnum.ConstructorFrom<{
|
|
486
|
-
readonly _tag: "FileRemove";
|
|
487
|
-
readonly id: SandboxId;
|
|
488
|
-
readonly path: string;
|
|
489
|
-
}, "_tag">;
|
|
490
|
-
readonly FileWrite: Data.TaggedEnum.ConstructorFrom<{
|
|
491
|
-
readonly _tag: "FileWrite";
|
|
492
|
-
readonly id: SandboxId;
|
|
493
|
-
readonly path: string;
|
|
494
|
-
readonly contents: Uint8Array | string;
|
|
495
|
-
}, "_tag">;
|
|
496
|
-
readonly SnapshotCreate: Data.TaggedEnum.ConstructorFrom<{
|
|
497
|
-
readonly _tag: "SnapshotCreate";
|
|
498
|
-
readonly id: SandboxId;
|
|
499
|
-
readonly name?: string;
|
|
500
|
-
}, "_tag">;
|
|
501
|
-
readonly SnapshotDestroy: Data.TaggedEnum.ConstructorFrom<{
|
|
502
|
-
readonly _tag: "SnapshotDestroy";
|
|
503
|
-
readonly id: SnapshotId;
|
|
504
|
-
}, "_tag">;
|
|
505
|
-
readonly Spawn: Data.TaggedEnum.ConstructorFrom<{
|
|
506
|
-
readonly _tag: "Spawn";
|
|
507
|
-
readonly id: SandboxId;
|
|
508
|
-
readonly request: CommonSpawnRequest;
|
|
509
|
-
}, "_tag">;
|
|
510
|
-
readonly VolumeCreate: Data.TaggedEnum.ConstructorFrom<{
|
|
511
|
-
readonly _tag: "VolumeCreate";
|
|
512
|
-
readonly name: string;
|
|
513
|
-
readonly quotaBytes?: number;
|
|
514
|
-
}, "_tag">;
|
|
515
|
-
readonly VolumeDestroy: Data.TaggedEnum.ConstructorFrom<{
|
|
516
|
-
readonly _tag: "VolumeDestroy";
|
|
517
|
-
readonly id: VolumeId;
|
|
518
|
-
}, "_tag">;
|
|
519
|
-
};
|
|
74
|
+
declare const Call: Data.TaggedEnum.Constructor<{
|
|
75
|
+
readonly _tag: "Attach";
|
|
76
|
+
readonly id: SandboxId;
|
|
77
|
+
} | {
|
|
78
|
+
readonly _tag: "Create";
|
|
79
|
+
readonly request: CommonCreateRequest;
|
|
80
|
+
} | {
|
|
81
|
+
readonly _tag: "Destroy";
|
|
82
|
+
readonly id: SandboxId;
|
|
83
|
+
} | {
|
|
84
|
+
readonly _tag: "Exec";
|
|
85
|
+
readonly id: SandboxId;
|
|
86
|
+
readonly request: CommonExecRequest;
|
|
87
|
+
} | {
|
|
88
|
+
readonly _tag: "ExecStream";
|
|
89
|
+
readonly id: SandboxId;
|
|
90
|
+
readonly request: CommonExecRequest;
|
|
91
|
+
} | {
|
|
92
|
+
readonly _tag: "ExposePort";
|
|
93
|
+
readonly id: SandboxId;
|
|
94
|
+
readonly port: number;
|
|
95
|
+
} | {
|
|
96
|
+
readonly _tag: "FileExists";
|
|
97
|
+
readonly id: SandboxId;
|
|
98
|
+
readonly path: string;
|
|
99
|
+
} | {
|
|
100
|
+
readonly _tag: "FileList";
|
|
101
|
+
readonly id: SandboxId;
|
|
102
|
+
readonly path: string;
|
|
103
|
+
} | {
|
|
104
|
+
readonly _tag: "FileMkdir";
|
|
105
|
+
readonly id: SandboxId;
|
|
106
|
+
readonly path: string;
|
|
107
|
+
} | {
|
|
108
|
+
readonly _tag: "FileRead";
|
|
109
|
+
readonly id: SandboxId;
|
|
110
|
+
readonly path: string;
|
|
111
|
+
} | {
|
|
112
|
+
readonly _tag: "FileRemove";
|
|
113
|
+
readonly id: SandboxId;
|
|
114
|
+
readonly path: string;
|
|
115
|
+
} | {
|
|
116
|
+
readonly _tag: "FileWrite";
|
|
117
|
+
readonly id: SandboxId;
|
|
118
|
+
readonly path: string;
|
|
119
|
+
readonly contents: Uint8Array | string;
|
|
120
|
+
} | {
|
|
121
|
+
readonly _tag: "SnapshotCreate";
|
|
122
|
+
readonly id: SandboxId;
|
|
123
|
+
readonly name?: string;
|
|
124
|
+
} | {
|
|
125
|
+
readonly _tag: "SnapshotDestroy";
|
|
126
|
+
readonly id: SnapshotId;
|
|
127
|
+
} | {
|
|
128
|
+
readonly _tag: "Spawn";
|
|
129
|
+
readonly id: SandboxId;
|
|
130
|
+
readonly request: CommonSpawnRequest;
|
|
131
|
+
} | {
|
|
132
|
+
readonly _tag: "VolumeCreate";
|
|
133
|
+
readonly name: string;
|
|
134
|
+
readonly quotaBytes?: number;
|
|
135
|
+
} | {
|
|
136
|
+
readonly _tag: "VolumeDestroy";
|
|
137
|
+
readonly id: VolumeId;
|
|
138
|
+
}>;
|
|
520
139
|
type MockSandboxRecorder = {
|
|
521
140
|
readonly calls: ReadonlyArray<Call>;
|
|
522
141
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MockSandbox.d.mts","names":[],"sources":["../../src/testing/MockSandbox.ts"],"mappings":";;;;;;;KAoCY,OAAO,KAAK;EACtB;aAAmB,SAAS;;EAC5B;aAAmB,IAAI;;EACvB;aAAoB,IAAI;;EACxB;aAAiB,IAAI;aAAoB,SAAS;;EAClD;aAAuB,IAAI;aAAoB,SAAS;;EACxD;aAAkB,IAAI;aAAoB,SAAS;;EACnD;aAAqB,IAAI;aAAoB;;EAC7C;aACW,IAAI;aACJ;aACA,UAAU;;EAErB;aAAuB,IAAI;aAAoB;;EAC/C;aAAsB,IAAI;aAAoB;;EAC9C;aAAqB,IAAI;aAAoB;;EAC7C;aAAuB,IAAI;aAAoB;;EAC/C;aAAuB,IAAI;aAAoB;;EAC/C;aAA2B,IAAI;aAAoB;;EACnD;aAA4B,IAAI;;EAChC;aAAyB;aAAuB;;EAChD;aAA0B,IAAI;;;cAGnB
|
|
1
|
+
{"version":3,"file":"MockSandbox.d.mts","names":[],"sources":["../../src/testing/MockSandbox.ts"],"mappings":";;;;;;;KAoCY,OAAO,KAAK;EACtB;aAAmB,SAAS;;EAC5B;aAAmB,IAAI;;EACvB;aAAoB,IAAI;;EACxB;aAAiB,IAAI;aAAoB,SAAS;;EAClD;aAAuB,IAAI;aAAoB,SAAS;;EACxD;aAAkB,IAAI;aAAoB,SAAS;;EACnD;aAAqB,IAAI;aAAoB;;EAC7C;aACW,IAAI;aACJ;aACA,UAAU;;EAErB;aAAuB,IAAI;aAAoB;;EAC/C;aAAsB,IAAI;aAAoB;;EAC9C;aAAqB,IAAI;aAAoB;;EAC7C;aAAuB,IAAI;aAAoB;;EAC/C;aAAuB,IAAI;aAAoB;;EAC/C;aAA2B,IAAI;aAAoB;;EACnD;aAA4B,IAAI;;EAChC;aAAyB;aAAuB;;EAChD;aAA0B,IAAI;;;cAGnB,MAAI,KAAA,WAAA;;WAtBQ,IAAA;;;WADK,SAAA;;;WAEJ,IAAA;;;WACH,IAAA;WAA6B,SAAA;;;WACvB,IAAA;WAA6B,SAAA;;;WAY7B,IAAA;WAA0B;;;WAD1B,IAAA;WAA0B;;;WAD5B,IAAA;WAA0B;;;WADzB,IAAA;WAA0B;;;WAP3B,IAAA;WAA0B;;;WAMxB,IAAA;WAA0B;;;WAJtC,IAAA;WACE;WACI,UAAA;;;WAOU,IAAA;WAA2B;;;WAC1B,IAAA;;;WAbV,IAAA;WAA6B,SAAA;;;WAcpB;WAA8B;;;WAC/B,IAAA;;KAKpB;WACD,OAAO,cAAc;;;;;;;KAYpB;WACD;WACA,QAAQ,cAAc;WACtB,UAAU,cAAc,cAAc;WACtC,SAAS,cAAc;WACvB,QAAQ,SAAS,eAAe;WAChC,YAAY,cAAc;WAC1B,YAAY;aAAyB,IAAI;aAAqB;;WAC9D,UAAU;aAAyB,IAAI;aAAmB;;WAC1D,WAAW;;;;;;;cAqOT,QAAK,SAAY;;;;;;;;;cAajB,2BAAwB,SAAY;;;;;cASpC,OAAI,SAAY"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
|
|
2
|
+
import { FileSourceJson } from "../domain/File.mjs";
|
|
3
|
+
import { ImageSourceJson } from "../domain/Image.mjs";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
//#region src/tool/Content.ts
|
|
6
|
+
/**
|
|
7
|
+
* What a tool's `run` may return without an `outputSchema`. Plain values stay
|
|
8
|
+
* plain (a string is text, anything else JSON); only media is marked, by class,
|
|
9
|
+
* so it is told apart from JSON by `instanceof`, never by shape.
|
|
10
|
+
*/
|
|
11
|
+
var Content_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
File: () => File,
|
|
13
|
+
Image: () => Image,
|
|
14
|
+
Media: () => Media,
|
|
15
|
+
Value: () => Value,
|
|
16
|
+
file: () => file,
|
|
17
|
+
image: () => image,
|
|
18
|
+
isMedia: () => isMedia
|
|
19
|
+
});
|
|
20
|
+
var Image = class extends Schema.TaggedClass()("Image", { source: ImageSourceJson }) {};
|
|
21
|
+
var File = class extends Schema.TaggedClass()("File", {
|
|
22
|
+
source: FileSourceJson,
|
|
23
|
+
filename: Schema.optionalKey(Schema.String)
|
|
24
|
+
}) {};
|
|
25
|
+
const Media = Schema.Union([Image, File]);
|
|
26
|
+
const image = (source) => new Image({ source });
|
|
27
|
+
const file = (source, filename) => new File(filename === void 0 ? { source } : {
|
|
28
|
+
source,
|
|
29
|
+
filename
|
|
30
|
+
});
|
|
31
|
+
const isMedia = (u) => u instanceof Image || u instanceof File;
|
|
32
|
+
/**
|
|
33
|
+
* Text, JSON, one medium, or a top-level array mixing JSON and media. Encodes to
|
|
34
|
+
* JSON (bytes as base64), so it also serves as the UI codec for tools without
|
|
35
|
+
* an `outputSchema`.
|
|
36
|
+
*/
|
|
37
|
+
const Value = Schema.Union([
|
|
38
|
+
Schema.String,
|
|
39
|
+
Media,
|
|
40
|
+
Schema.Array(Schema.Union([Media, Schema.Json])),
|
|
41
|
+
Schema.Json
|
|
42
|
+
]);
|
|
43
|
+
//#endregion
|
|
44
|
+
export { File, Image, Media, Value, file, image, isMedia, Content_exports as t };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=Content.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.mjs","names":[],"sources":["../../src/tool/Content.ts"],"sourcesContent":["/**\n * What a tool's `run` may return without an `outputSchema`. Plain values stay\n * plain (a string is text, anything else JSON); only media is marked, by class,\n * so it is told apart from JSON by `instanceof`, never by shape.\n */\nimport { Schema } from \"effect\"\nimport { type FileSource, FileSourceJson } from \"../domain/File.js\"\nimport { type ImageSource, ImageSourceJson } from \"../domain/Image.js\"\n\nexport class Image extends Schema.TaggedClass<Image>()(\"Image\", { source: ImageSourceJson }) {}\n\nexport class File extends Schema.TaggedClass<File>()(\"File\", {\n source: FileSourceJson,\n filename: Schema.optionalKey(Schema.String),\n}) {}\n\nexport const Media = Schema.Union([Image, File])\nexport type Media = typeof Media.Type\n\nexport const image = (source: ImageSource): Image => new Image({ source })\n\nexport const file = (source: FileSource, filename?: string): File =>\n new File(filename === undefined ? { source } : { source, filename })\n\nexport const isMedia = (u: unknown): u is Media => u instanceof Image || u instanceof File\n\n/**\n * Text, JSON, one medium, or a top-level array mixing JSON and media. Encodes to\n * JSON (bytes as base64), so it also serves as the UI codec for tools without\n * an `outputSchema`.\n */\nexport const Value = Schema.Union([\n Schema.String,\n Media,\n Schema.Array(Schema.Union([Media, Schema.Json])),\n Schema.Json,\n])\nexport type Value = typeof Value.Type\n"],"mappings":";;;;;;;;;;;;;;;;;;;AASA,IAAa,QAAb,cAA2B,OAAO,YAAmB,CAAC,CAAC,SAAS,EAAE,QAAQ,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAE9F,IAAa,OAAb,cAA0B,OAAO,YAAkB,CAAC,CAAC,QAAQ;CAC3D,QAAQ;CACR,UAAU,OAAO,YAAY,OAAO,MAAM;AAC5C,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAa,QAAQ,OAAO,MAAM,CAAC,OAAO,IAAI,CAAC;AAG/C,MAAa,SAAS,WAA+B,IAAI,MAAM,EAAE,OAAO,CAAC;AAEzE,MAAa,QAAQ,QAAoB,aACvC,IAAI,KAAK,aAAa,KAAA,IAAY,EAAE,OAAO,IAAI;CAAE;CAAQ;AAAS,CAAC;AAErE,MAAa,WAAW,MAA2B,aAAa,SAAS,aAAa;;;;;;AAOtF,MAAa,QAAQ,OAAO,MAAM;CAChC,OAAO;CACP;CACA,OAAO,MAAM,OAAO,MAAM,CAAC,OAAO,OAAO,IAAI,CAAC,CAAC;CAC/C,OAAO;AACT,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { imageBytes } from "../domain/Image.mjs";
|
|
2
|
+
import { Image, Value, file, image, isMedia } from "./Content.mjs";
|
|
3
|
+
import { m as describe } from "../dist-DzeSyeYF.mjs";
|
|
4
|
+
import { n as globalExpect } from "../index.C4tKZ0yW-LuFnBtmu.mjs";
|
|
5
|
+
import { t as import_dist } from "../dist-DNeuh84d.mjs";
|
|
6
|
+
import { t as it } from "../dist-B5K-y4Be.mjs";
|
|
7
|
+
import { Effect, Schema } from "effect";
|
|
8
|
+
//#region src/tool/Content.test.ts
|
|
9
|
+
const bytes = new Uint8Array([
|
|
10
|
+
137,
|
|
11
|
+
80,
|
|
12
|
+
78,
|
|
13
|
+
71
|
|
14
|
+
]);
|
|
15
|
+
const encode = Schema.encodeUnknownEffect(Value);
|
|
16
|
+
const decode = Schema.decodeUnknownEffect(Value);
|
|
17
|
+
describe("Content.Value", () => {
|
|
18
|
+
it("encodes to JSON", () => {
|
|
19
|
+
(0, import_dist.expectTypeOf)().toExtend();
|
|
20
|
+
});
|
|
21
|
+
it.effect("round-trips image bytes through JSON as base64", () => Effect.gen(function* () {
|
|
22
|
+
const encoded = yield* encode(image(imageBytes(bytes, "image/png")));
|
|
23
|
+
globalExpect(encoded).toEqual({
|
|
24
|
+
_tag: "Image",
|
|
25
|
+
source: {
|
|
26
|
+
_tag: "bytes",
|
|
27
|
+
bytes: "iVBORw==",
|
|
28
|
+
mimeType: "image/png"
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const decoded = yield* decode(JSON.parse(JSON.stringify(encoded)));
|
|
32
|
+
globalExpect(decoded).toBeInstanceOf(Image);
|
|
33
|
+
globalExpect(decoded).toEqual(image(imageBytes(bytes, "image/png")));
|
|
34
|
+
}));
|
|
35
|
+
it.effect("keeps plain objects plain and media as classes in a mixed array", () => Effect.gen(function* () {
|
|
36
|
+
const value = [{ title: "Home" }, file({
|
|
37
|
+
_tag: "url",
|
|
38
|
+
url: "https://x/a.pdf"
|
|
39
|
+
}, "a.pdf")];
|
|
40
|
+
const decoded = yield* decode(yield* encode(value));
|
|
41
|
+
globalExpect(decoded).toEqual(value);
|
|
42
|
+
globalExpect(Array.isArray(decoded) && decoded.map(isMedia)).toEqual([false, true]);
|
|
43
|
+
}));
|
|
44
|
+
});
|
|
45
|
+
//#endregion
|
|
46
|
+
export {};
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=Content.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.test.mjs","names":["Content.Value","Content.image","Content.Image","Content.file","Content.isMedia"],"sources":["../../src/tool/Content.test.ts"],"sourcesContent":["import { describe, expect, expectTypeOf, it } from \"@effect/vitest\"\nimport { Effect, Schema } from \"effect\"\nimport { imageBytes } from \"../domain/Image.js\"\nimport * as Content from \"./Content.js\"\n\nconst bytes = new Uint8Array([137, 80, 78, 71])\nconst encode = Schema.encodeUnknownEffect(Content.Value)\nconst decode = Schema.decodeUnknownEffect(Content.Value)\n\ndescribe(\"Content.Value\", () => {\n it(\"encodes to JSON\", () => {\n expectTypeOf<typeof Content.Value.Encoded>().toExtend<Schema.Json>()\n })\n\n it.effect(\"round-trips image bytes through JSON as base64\", () =>\n Effect.gen(function* () {\n const encoded = yield* encode(Content.image(imageBytes(bytes, \"image/png\")))\n expect(encoded).toEqual({\n _tag: \"Image\",\n source: { _tag: \"bytes\", bytes: \"iVBORw==\", mimeType: \"image/png\" },\n })\n\n const decoded = yield* decode(JSON.parse(JSON.stringify(encoded)))\n expect(decoded).toBeInstanceOf(Content.Image)\n expect(decoded).toEqual(Content.image(imageBytes(bytes, \"image/png\")))\n }),\n )\n\n it.effect(\"keeps plain objects plain and media as classes in a mixed array\", () =>\n Effect.gen(function* () {\n const value = [\n { title: \"Home\" },\n Content.file({ _tag: \"url\", url: \"https://x/a.pdf\" }, \"a.pdf\"),\n ]\n const decoded = yield* decode(yield* encode(value))\n expect(decoded).toEqual(value)\n expect(Array.isArray(decoded) && decoded.map(Content.isMedia)).toEqual([false, true])\n }),\n )\n})\n"],"mappings":";;;;;;;;AAKA,MAAM,QAAQ,IAAI,WAAW;CAAC;CAAK;CAAI;CAAI;AAAE,CAAC;AAC9C,MAAM,SAAS,OAAO,oBAAoBA,KAAa;AACvD,MAAM,SAAS,OAAO,oBAAoBA,KAAa;AAEvD,SAAS,uBAAuB;CAC9B,GAAG,yBAAyB;EAC1B,CAAA,GAAA,YAAA,aAAA,CAA2C,CAAC,CAAC,SAAsB;CACrE,CAAC;CAED,GAAG,OAAO,wDACR,OAAO,IAAI,aAAa;EACtB,MAAM,UAAU,OAAO,OAAOC,MAAc,WAAW,OAAO,WAAW,CAAC,CAAC;EAC3E,aAAO,OAAO,CAAC,CAAC,QAAQ;GACtB,MAAM;GACN,QAAQ;IAAE,MAAM;IAAS,OAAO;IAAY,UAAU;GAAY;EACpE,CAAC;EAED,MAAM,UAAU,OAAO,OAAO,KAAK,MAAM,KAAK,UAAU,OAAO,CAAC,CAAC;EACjE,aAAO,OAAO,CAAC,CAAC,eAAeC,KAAa;EAC5C,aAAO,OAAO,CAAC,CAAC,QAAQD,MAAc,WAAW,OAAO,WAAW,CAAC,CAAC;CACvE,CAAC,CACH;CAEA,GAAG,OAAO,yEACR,OAAO,IAAI,aAAa;EACtB,MAAM,QAAQ,CACZ,EAAE,OAAO,OAAO,GAChBE,KAAa;GAAE,MAAM;GAAO,KAAK;EAAkB,GAAG,OAAO,CAC/D;EACA,MAAM,UAAU,OAAO,OAAO,OAAO,OAAO,KAAK,CAAC;EAClD,aAAO,OAAO,CAAC,CAAC,QAAQ,KAAK;EAC7B,aAAO,MAAM,QAAQ,OAAO,KAAK,QAAQ,IAAIC,OAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC;CACtF,CAAC,CACH;AACF,CAAC"}
|