t3code-cli 0.7.0 → 0.9.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.
Files changed (82) hide show
  1. package/README.md +90 -35
  2. package/dist/application.js +1 -1
  3. package/dist/auth.js +1 -2
  4. package/dist/bin.js +241 -45
  5. package/dist/cli.js +1 -1
  6. package/dist/config.js +1 -3
  7. package/dist/connection.js +1 -4
  8. package/dist/index.js +1 -4
  9. package/dist/layout.js +1 -1
  10. package/dist/orchestration.js +1 -1
  11. package/dist/rpc.js +1 -1
  12. package/dist/runtime.js +1 -2
  13. package/dist/scope.js +1 -1
  14. package/dist/shared.js +85492 -0
  15. package/dist/src/application/layer.d.ts +86 -2
  16. package/dist/src/application/models.d.ts +1 -0
  17. package/dist/src/application/projects.d.ts +10 -1
  18. package/dist/src/application/service.d.ts +30 -1
  19. package/dist/src/application/shell-sequence.d.ts +9 -0
  20. package/dist/src/application/thread-commands.d.ts +27 -1
  21. package/dist/src/application/thread-wait.d.ts +9 -0
  22. package/dist/src/application/threads.d.ts +102 -2
  23. package/dist/src/cli-path/layer.d.ts +3 -0
  24. package/dist/src/cli-path/service.d.ts +8 -0
  25. package/dist/src/domain/helpers.d.ts +9 -0
  26. package/dist/src/domain/model-config.d.ts +3 -0
  27. package/dist/src/domain/thread-activities.d.ts +14 -0
  28. package/dist/src/domain/thread-lifecycle.d.ts +10 -0
  29. package/dist/src/orchestration/layer.d.ts +215 -0
  30. package/dist/src/rpc/layer.d.ts +466 -0
  31. package/dist/src/rpc/ws-group.d.ts +142 -0
  32. package/dist/src/runtime/layer.d.ts +1 -1
  33. package/dist/t3tools.js +2 -2
  34. package/dist/upstream-t3code/packages/contracts/src/environmentHttp.d.ts +33 -10
  35. package/dist/upstream-t3code/packages/contracts/src/ipc.d.ts +6 -0
  36. package/dist/upstream-t3code/packages/contracts/src/orchestration.d.ts +657 -1
  37. package/dist/upstream-t3code/packages/contracts/src/provider.d.ts +14 -0
  38. package/dist/upstream-t3code/packages/contracts/src/providerRuntime.d.ts +175 -1
  39. package/dist/upstream-t3code/packages/contracts/src/rpc.d.ts +492 -0
  40. package/dist/upstream-t3code/packages/contracts/src/server.d.ts +45 -0
  41. package/dist/upstream-t3code/packages/contracts/src/settings.d.ts +21 -0
  42. package/dist/upstream-t3code/packages/contracts/src/terminal.d.ts +6 -3
  43. package/package.json +2 -2
  44. package/src/application/service.ts +32 -0
  45. package/src/application/thread-commands.ts +45 -0
  46. package/src/application/threads.ts +100 -1
  47. package/src/cli/error.ts +15 -0
  48. package/src/cli/message-input.ts +30 -0
  49. package/src/cli/thread-format.ts +47 -0
  50. package/src/cli/thread.ts +8 -0
  51. package/src/cli/threads/approve.ts +61 -0
  52. package/src/cli/threads/archive.ts +18 -3
  53. package/src/cli/threads/callback.ts +92 -0
  54. package/src/cli/threads/respond.ts +70 -0
  55. package/src/cli/threads/show.ts +43 -0
  56. package/src/cli-path/layer.ts +10 -0
  57. package/src/cli-path/service.ts +7 -0
  58. package/src/domain/thread-activities.test.ts +321 -0
  59. package/src/domain/thread-activities.ts +244 -0
  60. package/src/domain/thread-lifecycle.ts +2 -0
  61. package/src/runtime/layer.ts +2 -0
  62. package/dist/Context-DueQ9iMH.js +0 -4916
  63. package/dist/Path-D8WPdPwR.js +0 -11406
  64. package/dist/Schema-DsQxYh6_.js +0 -13581
  65. package/dist/UrlParams-BA6gBvaY.js +0 -205
  66. package/dist/base-dir-R12OMDso.js +0 -20
  67. package/dist/error-B2t1bAP9.js +0 -169
  68. package/dist/error-BHRnjLux.js +0 -15
  69. package/dist/error-jwMt3VoW.js +0 -54
  70. package/dist/flags-CM7_iGdA.js +0 -13371
  71. package/dist/layer-CfC5qZol.js +0 -1508
  72. package/dist/layer-DHhKS5jd.js +0 -13
  73. package/dist/layer-DUv99vsS.js +0 -72
  74. package/dist/layer-DvHnKBYj.js +0 -29466
  75. package/dist/layer-MqCKkIGD.js +0 -1206
  76. package/dist/scope-GycYiJ54.js +0 -29
  77. package/dist/service-CLmRO2Dp.js +0 -8
  78. package/dist/service-ybOWV9pL.js +0 -5
  79. package/dist/src-KdbHqrex.js +0 -8874
  80. package/dist/transport-D3zBdZ1h.js +0 -539
  81. package/dist/url-SlsaG8nY.js +0 -165
  82. /package/dist/{chunk-B5meny8j.js → rolldown-runtime.js} +0 -0
@@ -1,539 +0,0 @@
1
- import { An as identity, Cn as constFalse, Ft as BaseProto, Lt as NodeInspectSymbol, On as dual, Pn as pipeArguments, Rt as toJson, S as getOrUndefined, it as PipeInspectableProto, n as Service, p as merge, t as Reference, wn as constTrue } from "./Context-DueQ9iMH.js";
2
- import { A as failCause, Bt as useSpan, Ot as suspend, P as fn, Rt as uninterruptibleMask, Tt as succeed, Ut as withFiber, Wt as withParentSpan, X as map, b as catchTags, gn as hasInterrupts, j as flatMap, k as fail, kn as effect, kt as sync, ot as onInterrupt, tt as matchCauseEffect, ui as isFailure, w as contextWith, zr as DisablePropagation, zt as updateContext } from "./Path-D8WPdPwR.js";
3
- import { In as add, L as fromJsonString, Ln as formatIso, P as decodeUnknownEffect, Rn as now, Xt as suspend$1, b as Struct, bt as ensuring, d as Literals, et as optionalKey, g as Number$1, n as Boolean, u as Literal, y as String$1 } from "./Schema-DsQxYh6_.js";
4
- import { Dl as HttpClientErrorSchema, El as HttpClientError, Il as redact, Lu as allShort, Ml as CurrentRedactedNames, Ol as InvalidUrlError, Sl as setHeaders, _l as bearerToken, bl as make$2, dl as TypeId$2, fl as filterStatusOk$1, gl as acceptJson, iu as AuthAccessTokenType, ku as AuthTokenExchangeGrantType, ml as TypeId$3, mu as AuthEnvironmentBootstrapTokenType, rl as toHeaders, vl as bodyUrlParams, xl as post, yl as get } from "./src-KdbHqrex.js";
5
- import { r as makeUrl } from "./UrlParams-BA6gBvaY.js";
6
- import { n as toHttpEndpointUrl } from "./url-SlsaG8nY.js";
7
- import { s as AuthTransportError } from "./error-jwMt3VoW.js";
8
- //#region node_modules/.pnpm/effect@4.0.0-beta.78/node_modules/effect/dist/MutableRef.js
9
- const TypeId$1 = "~effect/MutableRef";
10
- const MutableRefProto = {
11
- [TypeId$1]: TypeId$1,
12
- ...PipeInspectableProto,
13
- toJSON() {
14
- return {
15
- _id: "MutableRef",
16
- current: toJson(this.current)
17
- };
18
- }
19
- };
20
- /**
21
- * Creates a new MutableRef with the specified initial value.
22
- *
23
- * **When to use**
24
- *
25
- * Use to create a synchronous `MutableRef` initialized with a value.
26
- *
27
- * **Example** (Creating mutable refs)
28
- *
29
- * ```ts
30
- * import { MutableRef } from "effect"
31
- *
32
- * // Create a counter reference
33
- * const counter = MutableRef.make(0)
34
- * console.log(MutableRef.get(counter)) // 0
35
- *
36
- * // Create a configuration reference
37
- * const config = MutableRef.make({ debug: false, timeout: 5000 })
38
- * console.log(MutableRef.get(config)) // { debug: false, timeout: 5000 }
39
- *
40
- * // Create a string reference
41
- * const status = MutableRef.make("idle")
42
- * MutableRef.set(status, "running")
43
- * console.log(MutableRef.get(status)) // "running"
44
- * ```
45
- *
46
- * @category constructors
47
- * @since 2.0.0
48
- */
49
- const make$1 = (value) => {
50
- const ref = Object.create(MutableRefProto);
51
- ref.current = value;
52
- return ref;
53
- };
54
- //#endregion
55
- //#region node_modules/.pnpm/effect@4.0.0-beta.78/node_modules/effect/dist/Ref.js
56
- /**
57
- * The `Ref` module provides fiber-safe mutable references for state inside
58
- * Effect programs. A `Ref<A>` holds one value of type `A` and exposes reads,
59
- * writes, and atomic transformations as effects, so state changes compose with
60
- * Effect's concurrency model.
61
- *
62
- * **Mental model**
63
- *
64
- * - {@link make} creates a reference with an initial value
65
- * - {@link get} reads the current value, and {@link set} replaces it
66
- * - {@link update}, {@link updateAndGet}, and {@link getAndUpdate} transform
67
- * the current value atomically
68
- * - {@link modify} updates the value and returns a separate result computed
69
- * from the previous value
70
- * - The `Some` variants use `Option` to leave the value unchanged when a
71
- * partial update does not apply
72
- *
73
- * **Common tasks**
74
- *
75
- * - Create refs: {@link make}, {@link makeUnsafe}
76
- * - Read and write: {@link get}, {@link set}, {@link getAndSet},
77
- * {@link setAndGet}
78
- * - Update state: {@link update}, {@link updateAndGet}, {@link getAndUpdate}
79
- * - Update conditionally: {@link updateSome}, {@link updateSomeAndGet},
80
- * {@link getAndUpdateSome}, {@link modifySome}
81
- * - Compute while updating: {@link modify}
82
- *
83
- * **Example** (Updating shared state)
84
- *
85
- * ```ts
86
- * import { Effect, Ref } from "effect"
87
- *
88
- * const program = Effect.gen(function*() {
89
- * const counter = yield* Ref.make(0)
90
- *
91
- * const next = yield* Ref.updateAndGet(counter, (n) => n + 1)
92
- * const label = yield* Ref.modify(counter, (n) => [`count=${n}`, n + 1])
93
- *
94
- * return { label, next }
95
- * })
96
- * ```
97
- *
98
- * **Gotchas**
99
- *
100
- * - Each `Ref` operation is atomic for that reference, but multiple refs are
101
- * not updated transactionally as a group
102
- * - If the new value depends on the old value, prefer {@link update} or
103
- * {@link modify} over a separate {@link get} followed by {@link set}
104
- * - Unsafe operations are synchronous low-level accessors; prefer effectful
105
- * operations in application code
106
- *
107
- * @since 2.0.0
108
- */
109
- const RefProto = {
110
- ["~effect/Ref"]: { _A: identity },
111
- ...PipeInspectableProto,
112
- toJSON() {
113
- return {
114
- _id: "Ref",
115
- ref: this.ref
116
- };
117
- }
118
- };
119
- /**
120
- * Creates a new Ref with the specified initial value (unsafe version).
121
- *
122
- * **When to use**
123
- *
124
- * Use when you need immediate synchronous construction and can guarantee
125
- * that creating the `Ref` outside of `Effect` is safe.
126
- *
127
- * **Gotchas**
128
- *
129
- * Prefer `Ref.make` for Effect-wrapped creation in Effect programs.
130
- *
131
- * **Example** (Creating a ref unsafely)
132
- *
133
- * ```ts
134
- * import { Ref } from "effect"
135
- *
136
- * // Create a ref directly without Effect
137
- * const counter = Ref.makeUnsafe(0)
138
- *
139
- * // Get the current value
140
- * const value = Ref.getUnsafe(counter)
141
- * console.log(value) // 0
142
- *
143
- * // Note: This is unsafe and should be used carefully
144
- * // Prefer Ref.make for Effect-wrapped creation
145
- * ```
146
- *
147
- * @category constructors
148
- * @since 4.0.0
149
- */
150
- const makeUnsafe = (value) => {
151
- const self = Object.create(RefProto);
152
- self.ref = make$1(value);
153
- return self;
154
- };
155
- /**
156
- * Gets the current value of the Ref, sets it to the specified value, and returns the previous value atomically.
157
- *
158
- * **When to use**
159
- *
160
- * Use to replace a plain `Ref` value while returning the previous value.
161
- *
162
- * **Example** (Replacing a value atomically)
163
- *
164
- * ```ts
165
- * import { Effect, Ref } from "effect"
166
- *
167
- * const program = Effect.gen(function*() {
168
- * const ref = yield* Ref.make("initial")
169
- *
170
- * // Get current value and set new value atomically
171
- * const previous = yield* Ref.getAndSet(ref, "updated")
172
- * console.log(previous) // "initial"
173
- *
174
- * const current = yield* Ref.get(ref)
175
- * console.log(current) // "updated"
176
- * })
177
- * ```
178
- *
179
- * @see {@link set} for setting without returning the previous value
180
- * @see {@link getAndUpdate} for deriving the new value from the previous value
181
- *
182
- * @category mutations
183
- * @since 2.0.0
184
- */
185
- const getAndSet = /*#__PURE__*/ dual(2, (self, value) => sync(() => {
186
- const current = self.ref.current;
187
- self.ref.current = value;
188
- return current;
189
- }));
190
- //#endregion
191
- //#region node_modules/.pnpm/effect@4.0.0-beta.78/node_modules/effect/dist/unstable/http/HttpClient.js
192
- const TypeId = "~effect/http/HttpClient";
193
- /**
194
- * Service tag for the default outgoing HTTP client service.
195
- *
196
- * **When to use**
197
- *
198
- * Use to provide the default outgoing HTTP client service used by request
199
- * accessors such as `execute`, `get`, and `post`.
200
- *
201
- * @category services
202
- * @since 4.0.0
203
- */
204
- const HttpClient = /*#__PURE__*/ Service("effect/HttpClient");
205
- /**
206
- * Transforms a client by applying an effectful transformation to each response effect.
207
- *
208
- * @category mapping & sequencing
209
- * @since 4.0.0
210
- */
211
- const transformResponse = /*#__PURE__*/ dual(2, (self, f) => makeWith((request) => f(self.postprocess(request)), self.preprocess));
212
- /**
213
- * Filters responses that return a 2xx status code.
214
- *
215
- * @category filters
216
- * @since 4.0.0
217
- */
218
- const filterStatusOk = /*#__PURE__*/ transformResponse(/*#__PURE__*/ flatMap(filterStatusOk$1));
219
- /**
220
- * Constructs an `HttpClient.With` from a preprocessing function and a postprocessing function.
221
- *
222
- * **Details**
223
- *
224
- * `execute` applies preprocessing to the request and then passes the resulting request effect to postprocessing.
225
- *
226
- * @category constructors
227
- * @since 4.0.0
228
- */
229
- const makeWith = (postprocess, preprocess) => {
230
- const self = Object.create(Proto);
231
- self.preprocess = preprocess;
232
- self.postprocess = postprocess;
233
- self.execute = function(request) {
234
- return postprocess(preprocess(request));
235
- };
236
- return self;
237
- };
238
- const Proto = {
239
- [TypeId]: TypeId,
240
- pipe() {
241
- return pipeArguments(this, arguments);
242
- },
243
- ...BaseProto,
244
- toJSON() {
245
- return { _id: "effect/HttpClient" };
246
- },
247
- .../*#__PURE__*/ Object.fromEntries(/*#__PURE__*/ allShort.map(([fullMethod, method]) => [method, function(url, options) {
248
- return this.execute(make$2(fullMethod)(url, options));
249
- }]))
250
- };
251
- /**
252
- * Constructs an `HttpClient` from a low-level request runner.
253
- *
254
- * **Details**
255
- *
256
- * The runner receives the request, resolved URL, abort signal, and current fiber. The client wrapper handles URL construction failures, tracing and propagation, header redaction, and aborting non-scoped requests on interruption.
257
- *
258
- * @category constructors
259
- * @since 4.0.0
260
- */
261
- const make = (f) => makeWith((effect) => flatMap(effect, (request) => withFiber((fiber) => {
262
- const scopedController = scopedRequests.get(request);
263
- const controller = scopedController ?? new AbortController();
264
- const urlResult = makeUrl(request.url, request.urlParams, getOrUndefined(request.hash));
265
- if (isFailure(urlResult)) return fail(new HttpClientError({ reason: new InvalidUrlError({
266
- request,
267
- cause: urlResult.failure
268
- }) }));
269
- const url = urlResult.success;
270
- if (fiber.getRef(DisablePropagation) || fiber.getRef(TracerDisabledWhen)(request)) {
271
- const effect = f(request, url, controller.signal, fiber);
272
- if (scopedController) return effect;
273
- return uninterruptibleMask((restore) => matchCauseEffect(restore(effect), {
274
- onSuccess(response) {
275
- responseRegistry.register(response, controller);
276
- return succeed(new InterruptibleResponse(response, controller));
277
- },
278
- onFailure(cause) {
279
- if (hasInterrupts(cause)) controller.abort();
280
- return failCause(cause);
281
- }
282
- }));
283
- }
284
- return useSpan(fiber.getRef(SpanNameGenerator)(request), { kind: "client" }, (span) => {
285
- span.attribute("http.request.method", request.method);
286
- span.attribute("server.address", url.origin);
287
- if (url.port !== "") span.attribute("server.port", +url.port);
288
- span.attribute("url.full", url.toString());
289
- span.attribute("url.path", url.pathname);
290
- span.attribute("url.scheme", url.protocol.slice(0, -1));
291
- const query = url.search.slice(1);
292
- if (query !== "") span.attribute("url.query", query);
293
- const redactedHeaderNames = fiber.getRef(CurrentRedactedNames);
294
- const redactedHeaders = redact(request.headers, redactedHeaderNames);
295
- for (const name in redactedHeaders) span.attribute(`http.request.header.${name}`, String(redactedHeaders[name]));
296
- request = fiber.getRef(TracerPropagationEnabled) ? setHeaders(request, toHeaders(span)) : request;
297
- return uninterruptibleMask((restore) => restore(f(request, url, controller.signal, fiber)).pipe(withParentSpan(span, { captureStackTrace: false }), matchCauseEffect({
298
- onSuccess: (response) => {
299
- span.attribute("http.response.status_code", response.status);
300
- const redactedHeaders = redact(response.headers, redactedHeaderNames);
301
- for (const name in redactedHeaders) span.attribute(`http.response.header.${name}`, String(redactedHeaders[name]));
302
- if (scopedController) return succeed(response);
303
- responseRegistry.register(response, controller);
304
- return succeed(new InterruptibleResponse(response, controller));
305
- },
306
- onFailure(cause) {
307
- if (!scopedController && hasInterrupts(cause)) controller.abort();
308
- return failCause(cause);
309
- }
310
- })));
311
- });
312
- })), succeed);
313
- /**
314
- * Context reference for a predicate that disables client-side tracing for matching outgoing requests.
315
- *
316
- * @category references
317
- * @since 4.0.0
318
- */
319
- const TracerDisabledWhen = /*#__PURE__*/ Reference("effect/http/HttpClient/TracerDisabledWhen", { defaultValue: () => constFalse });
320
- /**
321
- * Context reference that controls whether outgoing client spans are propagated to request headers.
322
- *
323
- * @category references
324
- * @since 4.0.0
325
- */
326
- const TracerPropagationEnabled = /*#__PURE__*/ Reference("effect/HttpClient/TracerPropagationEnabled", { defaultValue: constTrue });
327
- /**
328
- * Context reference for generating the span name used for outgoing client request spans.
329
- *
330
- * @category references
331
- * @since 4.0.0
332
- */
333
- const SpanNameGenerator = /*#__PURE__*/ Reference("effect/http/HttpClient/SpanNameGenerator", { defaultValue: () => (request) => `http.client ${request.method}` });
334
- /**
335
- * Creates an `HttpClient` layer and merges the layer construction context into client response effects.
336
- *
337
- * @category layers
338
- * @since 4.0.0
339
- */
340
- const layerMergedContext = (effect$1) => effect(HttpClient)(contextWith((context) => map(effect$1, (client) => transformResponse(client, updateContext((input) => merge(context, input))))));
341
- const responseRegistry = /*#__PURE__*/ (() => {
342
- if ("FinalizationRegistry" in globalThis && globalThis.FinalizationRegistry) {
343
- const registry = /*#__PURE__*/ new FinalizationRegistry((controller) => {
344
- controller.abort();
345
- });
346
- return {
347
- register(response, controller) {
348
- registry.register(response, controller, response);
349
- },
350
- unregister(response) {
351
- registry.unregister(response);
352
- }
353
- };
354
- }
355
- const timers = /*#__PURE__*/ new Map();
356
- return {
357
- register(response, controller) {
358
- timers.set(response, setTimeout(() => controller.abort(), 5e3));
359
- },
360
- unregister(response) {
361
- const timer = timers.get(response);
362
- if (timer === void 0) return;
363
- clearTimeout(timer);
364
- timers.delete(response);
365
- }
366
- };
367
- })();
368
- const scopedRequests = /*#__PURE__*/ new WeakMap();
369
- var InterruptibleResponse = class {
370
- original;
371
- controller;
372
- constructor(original, controller) {
373
- this.original = original;
374
- this.controller = controller;
375
- }
376
- [TypeId$2] = TypeId$2;
377
- [TypeId$3] = TypeId$3;
378
- applyInterrupt(effect) {
379
- return suspend(() => {
380
- responseRegistry.unregister(this.original);
381
- return onInterrupt(effect, () => sync(() => {
382
- this.controller.abort();
383
- }));
384
- });
385
- }
386
- get request() {
387
- return this.original.request;
388
- }
389
- get status() {
390
- return this.original.status;
391
- }
392
- get headers() {
393
- return this.original.headers;
394
- }
395
- get cookies() {
396
- return this.original.cookies;
397
- }
398
- get remoteAddress() {
399
- return this.original.remoteAddress;
400
- }
401
- get formData() {
402
- return this.applyInterrupt(this.original.formData);
403
- }
404
- get text() {
405
- return this.applyInterrupt(this.original.text);
406
- }
407
- get json() {
408
- return this.applyInterrupt(this.original.json);
409
- }
410
- get urlParamsBody() {
411
- return this.applyInterrupt(this.original.urlParamsBody);
412
- }
413
- get arrayBuffer() {
414
- return this.applyInterrupt(this.original.arrayBuffer);
415
- }
416
- get stream() {
417
- return suspend$1(() => {
418
- responseRegistry.unregister(this.original);
419
- return ensuring(this.original.stream, sync(() => {
420
- this.controller.abort();
421
- }));
422
- });
423
- }
424
- toJSON() {
425
- return this.original.toJSON();
426
- }
427
- [NodeInspectSymbol]() {
428
- return this.original[NodeInspectSymbol]();
429
- }
430
- pipe() {
431
- return pipeArguments(this, arguments);
432
- }
433
- };
434
- //#endregion
435
- //#region src/auth/schema.ts
436
- const AuthAccessTokenResultSchema = Struct({
437
- access_token: String$1,
438
- issued_token_type: String$1,
439
- token_type: Literal("Bearer"),
440
- expires_in: Number$1,
441
- scope: String$1
442
- });
443
- const AuthSessionStateSchema = Struct({
444
- authenticated: Boolean,
445
- role: optionalKey(Literals(["owner", "client"])),
446
- sessionMethod: optionalKey(String$1),
447
- expiresAt: optionalKey(String$1)
448
- });
449
- const AuthWebSocketTicketResultSchema = Struct({
450
- ticket: String$1,
451
- expiresAt: String$1
452
- });
453
- const AuthLocalRuntimeStateSchema = Struct({
454
- version: Literal(1),
455
- origin: String$1
456
- });
457
- const decodeAuthAccessTokenResult = decodeUnknownEffect(AuthAccessTokenResultSchema);
458
- const decodeAuthSessionState = decodeUnknownEffect(AuthSessionStateSchema);
459
- const decodeAuthWebSocketTicketResult = decodeUnknownEffect(AuthWebSocketTicketResultSchema);
460
- decodeUnknownEffect(AuthLocalRuntimeStateSchema);
461
- const decodeAuthLocalRuntimeStateFromJson = decodeUnknownEffect(fromJsonString(AuthLocalRuntimeStateSchema));
462
- //#endregion
463
- //#region src/auth/transport.ts
464
- var T3AuthTransport = class extends Service()("t3cli/T3AuthTransport") {};
465
- const T3AuthTransportLive = effect(T3AuthTransport, fn("makeT3AuthTransport")(function* () {
466
- const client = filterStatusOk(yield* HttpClient);
467
- return {
468
- bootstrapBearer: fn("AuthTransport.bootstrapBearer")(function* (input) {
469
- const request = post(yield* makeHttpEndpointUrl(input.baseUrl, "/oauth/token")).pipe(acceptJson, bodyUrlParams({
470
- grant_type: AuthTokenExchangeGrantType,
471
- subject_token: input.credential,
472
- subject_token_type: AuthEnvironmentBootstrapTokenType,
473
- requested_token_type: AuthAccessTokenType
474
- }));
475
- const result = yield* (yield* client.execute(request).pipe(catchTags({ HttpClientError: (error) => fail(new AuthTransportError({
476
- message: "auth request failed",
477
- cause: HttpClientErrorSchema.fromHttpClientError(error)
478
- })) }))).json.pipe(flatMap(decodeAuthAccessTokenResult), catchTags({
479
- HttpClientError: (error) => fail(new AuthTransportError({
480
- message: "auth request failed",
481
- cause: HttpClientErrorSchema.fromHttpClientError(error)
482
- })),
483
- SchemaError: (error) => fail(new AuthTransportError({
484
- message: "auth response decode failed",
485
- cause: error
486
- }))
487
- }));
488
- const now$1 = yield* now;
489
- return {
490
- authenticated: true,
491
- role: result.scope.split(/\s+/u).includes("access:write") ? "owner" : "client",
492
- sessionMethod: "bearer-access-token",
493
- expiresAt: formatIso(add(now$1, { seconds: result.expires_in })),
494
- sessionToken: result.access_token
495
- };
496
- }),
497
- getSession: fn("AuthTransport.getSession")(function* (connection) {
498
- const request = get(yield* makeHttpEndpointUrl(connection.url, "/api/auth/session")).pipe(authenticatedRequest(connection));
499
- return yield* (yield* client.execute(request).pipe(catchTags({ HttpClientError: (error) => fail(new AuthTransportError({
500
- message: "auth request failed",
501
- cause: HttpClientErrorSchema.fromHttpClientError(error)
502
- })) }))).json.pipe(flatMap(decodeAuthSessionState), catchTags({
503
- HttpClientError: (error) => fail(new AuthTransportError({
504
- message: "auth request failed",
505
- cause: HttpClientErrorSchema.fromHttpClientError(error)
506
- })),
507
- SchemaError: (error) => fail(new AuthTransportError({
508
- message: "auth response decode failed",
509
- cause: error
510
- }))
511
- }));
512
- }),
513
- issueWebSocketTicket: fn("AuthTransport.issueWebSocketTicket")(function* (connection) {
514
- const request = post(yield* makeHttpEndpointUrl(connection.url, "/api/auth/websocket-ticket")).pipe(authenticatedRequest(connection));
515
- return yield* (yield* client.execute(request).pipe(catchTags({ HttpClientError: (error) => fail(new AuthTransportError({
516
- message: "auth request failed",
517
- cause: HttpClientErrorSchema.fromHttpClientError(error)
518
- })) }))).json.pipe(flatMap(decodeAuthWebSocketTicketResult), catchTags({
519
- HttpClientError: (error) => fail(new AuthTransportError({
520
- message: "auth request failed",
521
- cause: HttpClientErrorSchema.fromHttpClientError(error)
522
- })),
523
- SchemaError: (error) => fail(new AuthTransportError({
524
- message: "auth response decode failed",
525
- cause: error
526
- }))
527
- }));
528
- })
529
- };
530
- })());
531
- const authenticatedRequest = (connection) => (request) => request.pipe(acceptJson, bearerToken(connection.token));
532
- function makeHttpEndpointUrl(baseUrl, path) {
533
- return toHttpEndpointUrl(baseUrl, path).pipe(catchTags({ UrlError: (error) => fail(new AuthTransportError({
534
- message: "auth request failed",
535
- cause: error
536
- })) }));
537
- }
538
- //#endregion
539
- export { make as a, make$1 as c, layerMergedContext as i, T3AuthTransportLive as n, getAndSet as o, decodeAuthLocalRuntimeStateFromJson as r, makeUnsafe as s, T3AuthTransport as t };
@@ -1,165 +0,0 @@
1
- import { On as dual } from "./Context-DueQ9iMH.js";
2
- import { H as fromResult, Tt as succeed, b as catchTags, cn as IllegalArgumentError, j as flatMap, k as fail, mi as try_ } from "./Path-D8WPdPwR.js";
3
- import { n as UrlError } from "./error-BHRnjLux.js";
4
- //#region node_modules/.pnpm/effect@4.0.0-beta.78/node_modules/effect/dist/unstable/http/Url.js
5
- /**
6
- * Immutable helpers for parsing and editing platform `URL` values.
7
- *
8
- * This module keeps the WHATWG `URL` object as the URL representation used by
9
- * HTTP clients and servers, then adds safe parsing and pipeable setters for
10
- * credentials, host, path, protocol, query, and hash components. Query strings
11
- * can be read, replaced, or transformed through `UrlParams` so repeated keys and
12
- * key/value encoding stay explicit.
13
- *
14
- * **Mental model**
15
- *
16
- * `fromString` returns a `Result` instead of throwing when URL construction
17
- * fails. Setters never mutate the original `URL`; each one clones the input and
18
- * assigns the requested component on the clone. Use `mutate` when several
19
- * component assignments should happen on the same clone.
20
- *
21
- * **Common tasks**
22
- *
23
- * - Parse absolute URLs, or resolve relative URL strings against a base URL.
24
- * - Pipe setters to adjust host, protocol, path, credentials, search, or hash.
25
- * - Extract query parameters with `urlParams`.
26
- * - Replace or transform query parameters with `setUrlParams` and
27
- * `modifyUrlParams`.
28
- *
29
- * **Gotchas**
30
- *
31
- * Relative input needs an explicit base. Component assignment and serialization
32
- * follow platform `URL` rules, so values may be normalized or percent-encoded.
33
- * `setPassword` accepts `Redacted` input, but the resulting `URL` still contains
34
- * the actual credential and should be treated as sensitive when serialized.
35
- *
36
- * @since 4.0.0
37
- */
38
- /**
39
- * Parses a URL string safely into a `URL` object, returning a `Result` type for
40
- * error handling.
41
- *
42
- * **Details**
43
- *
44
- * This function converts a string into a `URL` object, enabling safe URL
45
- * parsing with built-in error handling. If the string is invalid or fails to
46
- * parse, this function does not throw an error; instead, it wraps the error in
47
- * a `IllegalArgumentError` and returns it as the `Failure` value of an
48
- * `Result`. The `Success` value contains the successfully parsed `URL`.
49
- *
50
- * An optional `base` parameter can be provided to resolve relative URLs. If
51
- * specified, the function interprets the input `url` as relative to this
52
- * `base`. This is especially useful when dealing with URLs that might not be
53
- * fully qualified.
54
- *
55
- * **Example** (Parsing absolute and relative URLs)
56
- *
57
- * ```ts
58
- * import { Result } from "effect"
59
- * import { Url } from "effect/unstable/http"
60
- *
61
- * // Parse an absolute URL
62
- * //
63
- * // ┌─── Result<URL, IllegalArgumentError>
64
- * // ▼
65
- * const parsed = Url.fromString("https://example.com/path")
66
- *
67
- * if (Result.isSuccess(parsed)) {
68
- * console.log("Parsed URL:", parsed.success.toString())
69
- * } else {
70
- * console.log("Error:", parsed.failure.message)
71
- * }
72
- * // Output: Parsed URL: https://example.com/path
73
- *
74
- * // Parse a relative URL with a base
75
- * const relativeParsed = Url.fromString("/relative-path", "https://example.com")
76
- *
77
- * if (Result.isSuccess(relativeParsed)) {
78
- * console.log("Parsed relative URL:", relativeParsed.success.toString())
79
- * } else {
80
- * console.log("Error:", relativeParsed.failure.message)
81
- * }
82
- * // Output: Parsed relative URL: https://example.com/relative-path
83
- * ```
84
- *
85
- * @category constructors
86
- * @since 4.0.0
87
- */
88
- const fromString = (url, base) => try_({
89
- try: () => new URL(url, base),
90
- catch: () => new IllegalArgumentError(`Invalid URL: "${url}"${base !== void 0 ? ` with base "${base}"` : ""}`)
91
- });
92
- /**
93
- * Updates a cloned `URL` with a callback, allowing multiple changes at once.
94
- *
95
- * **Example** (Mutating URL credentials)
96
- *
97
- * ```ts
98
- * import { Url } from "effect/unstable/http"
99
- *
100
- * const myUrl = new URL("https://example.com")
101
- *
102
- * const mutatedUrl = Url.mutate(myUrl, (url) => {
103
- * url.username = "user"
104
- * url.password = "pass"
105
- * })
106
- *
107
- * console.log("Mutated:", mutatedUrl.toString())
108
- * // Output: Mutated: https://user:pass@example.com/
109
- * ```
110
- *
111
- * @category modifiers
112
- * @since 4.0.0
113
- */
114
- const mutate = /*#__PURE__*/ dual(2, (self, f) => {
115
- const copy = new URL(self);
116
- f(copy);
117
- return copy;
118
- });
119
- //#endregion
120
- //#region src/config/url.ts
121
- function normalizeHttpBaseUrl(value) {
122
- return parseUrl(value).pipe(flatMap((url) => succeed(normalizeBaseUrl(url))));
123
- }
124
- function toHttpEndpointUrl(httpBaseUrl, pathname) {
125
- return parseUrl(httpBaseUrl).pipe(flatMap((url) => succeed(withPathname(url, pathname).toString())));
126
- }
127
- function toWebSocketEndpointUrl(httpBaseUrl, pathname) {
128
- return parseUrl(httpBaseUrl).pipe(flatMap((url) => {
129
- if (url.protocol === "http:") return succeed(withPathname(url, pathname, "ws:").toString());
130
- if (url.protocol === "https:") return succeed(withPathname(url, pathname, "wss:").toString());
131
- return fail(new UrlError({
132
- message: `unsupported server url protocol: ${url.protocol}`,
133
- protocol: url.protocol
134
- }));
135
- }));
136
- }
137
- function parseUrl(value) {
138
- return fromResult(fromString(value)).pipe(catchTags({ IllegalArgumentError: (error) => fail(new UrlError({
139
- message: "invalid url",
140
- cause: error
141
- })) }));
142
- }
143
- function normalizeBaseUrl(url) {
144
- return mutate(url, (current) => {
145
- current.hash = "";
146
- current.search = "";
147
- current.pathname = normalizePathname(current.pathname);
148
- }).toString().replace(/\/$/, "");
149
- }
150
- function withPathname(url, pathname, protocol) {
151
- return mutate(url, (current) => {
152
- if (protocol !== void 0) current.protocol = protocol;
153
- current.pathname = appendPathname(current.pathname, pathname);
154
- current.search = "";
155
- current.hash = "";
156
- });
157
- }
158
- function normalizePathname(pathname) {
159
- return pathname === "/" ? "" : pathname.replace(/\/+$/u, "");
160
- }
161
- function appendPathname(basePathname, pathname) {
162
- return `${normalizePathname(basePathname)}${pathname.startsWith("/") ? pathname : `/${pathname}`}`;
163
- }
164
- //#endregion
165
- export { mutate as a, fromString as i, toHttpEndpointUrl as n, toWebSocketEndpointUrl as r, normalizeHttpBaseUrl as t };
File without changes