@uploadista/server 0.0.20 → 0.1.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.cjs +1 -1
- package/dist/auth/index.d.cts +80 -2
- package/dist/auth/index.d.cts.map +1 -0
- package/dist/auth/index.d.mts +80 -2
- package/dist/auth/index.d.mts.map +1 -0
- package/dist/auth/index.mjs +2 -1
- package/dist/auth/index.mjs.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
- package/src/core/http-handlers/flow-http-handlers.ts +1 -1
- package/src/core/plugin-types.ts +1 -2
- package/tests/core/http-handlers/flow-handlers.test.ts +83 -51
- package/tests/core/http-handlers/health-handlers.test.ts +11 -10
- package/dist/auth-Ck4gisA2.cjs +0 -1
- package/dist/auth-DG0enyjj.mjs +0 -2
- package/dist/auth-DG0enyjj.mjs.map +0 -1
- package/dist/index-BXLtlr98.d.mts +0 -80
- package/dist/index-BXLtlr98.d.mts.map +0 -1
- package/dist/index-mMP18lsw.d.cts +0 -80
- package/dist/index-mMP18lsw.d.cts.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadista/server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.1.0-beta.5",
|
|
5
5
|
"description": "Core Server package for Uploadista",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Uploadista",
|
|
@@ -20,23 +20,23 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@uploadista/core": "0.0.
|
|
24
|
-
"@uploadista/
|
|
25
|
-
"@uploadista/event-
|
|
26
|
-
"@uploadista/
|
|
23
|
+
"@uploadista/core": "0.1.0-beta.5",
|
|
24
|
+
"@uploadista/event-emitter-websocket": "0.1.0-beta.5",
|
|
25
|
+
"@uploadista/event-broadcaster-memory": "0.1.0-beta.5",
|
|
26
|
+
"@uploadista/observability": "0.1.0-beta.5"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@cloudflare/workers-types": "4.
|
|
29
|
+
"@cloudflare/workers-types": "4.20260115.0",
|
|
30
30
|
"@effect/vitest": "0.27.0",
|
|
31
31
|
"@types/express": "^5.0.0",
|
|
32
|
-
"@types/node": "24.10.
|
|
33
|
-
"effect": "3.19.
|
|
32
|
+
"@types/node": "24.10.8",
|
|
33
|
+
"effect": "3.19.14",
|
|
34
34
|
"tsd": "0.33.0",
|
|
35
|
-
"tsdown": "0.
|
|
35
|
+
"tsdown": "0.19.0",
|
|
36
36
|
"typescript": "5.9.3",
|
|
37
|
-
"vitest": "4.0.
|
|
38
|
-
"zod": "4.
|
|
39
|
-
"@uploadista/typescript-config": "0.0.
|
|
37
|
+
"vitest": "4.0.17",
|
|
38
|
+
"zod": "4.3.5",
|
|
39
|
+
"@uploadista/typescript-config": "0.1.0-beta.5"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"effect": "^3.0.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"format": "biome format --write ./src",
|
|
50
50
|
"lint": "biome lint --write ./src",
|
|
51
51
|
"check": "biome check --write ./src",
|
|
52
|
-
"test": "vitest",
|
|
52
|
+
"test": "vitest run",
|
|
53
53
|
"test:run": "vitest run",
|
|
54
54
|
"test:watch": "vitest --watch",
|
|
55
55
|
"clean": "rimraf -rf dist && rimraf -rf .turbo && rimraf tsconfig.tsbuildinfo"
|
|
@@ -94,7 +94,7 @@ export const handleRunFlow = <TRequirements>({
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// Run flow returns immediately with jobId
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
yield* Effect.logInfo(`[Flow] Calling flowServer.runFlow...`);
|
|
99
99
|
const result = yield* flowEngine
|
|
100
100
|
.runFlow<TRequirements>({
|
package/src/core/plugin-types.ts
CHANGED
|
@@ -186,9 +186,8 @@ export type ExtractFlowPluginRequirements<
|
|
|
186
186
|
flowId: string,
|
|
187
187
|
clientId: string | null,
|
|
188
188
|
) => Effect.Effect<unknown, unknown, unknown>,
|
|
189
|
-
// biome-ignore lint/suspicious/noExplicitAny: Conditional type inference requires any for error and requirements parameters
|
|
190
189
|
> =
|
|
191
|
-
ReturnType<TFlowFn> extends Effect.Effect<infer TFlow,
|
|
190
|
+
ReturnType<TFlowFn> extends Effect.Effect<infer TFlow, unknown, unknown>
|
|
192
191
|
? // biome-ignore lint/suspicious/noExplicitAny: Conditional type inference requires any for input and output schema parameters
|
|
193
192
|
TFlow extends Flow<any, any, infer TRequirements>
|
|
194
193
|
? Exclude<TRequirements, never> // Exclude UploadEngine is handled by FlowPluginRequirements in core
|
|
@@ -13,10 +13,14 @@
|
|
|
13
13
|
|
|
14
14
|
import { it } from "@effect/vitest";
|
|
15
15
|
import type { FlowData, FlowJob } from "@uploadista/core";
|
|
16
|
-
import {
|
|
16
|
+
import { FlowEngine } from "@uploadista/core/flow";
|
|
17
17
|
import { Effect, Layer } from "effect";
|
|
18
18
|
import { describe, expect } from "vitest";
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
AuthCacheServiceLive,
|
|
21
|
+
AuthContextServiceLive,
|
|
22
|
+
NoUsageHookServiceLive,
|
|
23
|
+
} from "../../../src";
|
|
20
24
|
import {
|
|
21
25
|
handleCancelFlow,
|
|
22
26
|
handleGetFlow,
|
|
@@ -26,8 +30,8 @@ import {
|
|
|
26
30
|
handleRunFlow,
|
|
27
31
|
} from "../../../src/core/http-handlers/flow-http-handlers";
|
|
28
32
|
|
|
29
|
-
// Mock
|
|
30
|
-
const
|
|
33
|
+
// Mock FlowEngine implementation for testing
|
|
34
|
+
const mockFlowEngineMethods = {
|
|
31
35
|
getFlowData: (flowId: string, _clientId: string | null) =>
|
|
32
36
|
Effect.succeed<FlowData>({
|
|
33
37
|
id: flowId,
|
|
@@ -113,13 +117,13 @@ const mockFlowServerMethods = {
|
|
|
113
117
|
updatedAt: new Date(),
|
|
114
118
|
}),
|
|
115
119
|
|
|
116
|
-
// Mock methods required by
|
|
120
|
+
// Mock methods required by FlowEngineShape but not used in tests
|
|
117
121
|
getFlow: () => Effect.die("getFlow not implemented in test"),
|
|
118
122
|
subscribeToFlowEvents: () => Effect.void,
|
|
119
123
|
unsubscribeFromFlowEvents: () => Effect.void,
|
|
120
124
|
};
|
|
121
125
|
|
|
122
|
-
const
|
|
126
|
+
const FlowEngineTest = Layer.succeed(FlowEngine, mockFlowEngineMethods);
|
|
123
127
|
|
|
124
128
|
describe("HTTP Flow Handlers", () => {
|
|
125
129
|
describe("handleGetFlow", () => {
|
|
@@ -134,9 +138,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
134
138
|
expect(result.body.id).toBe("flow-123");
|
|
135
139
|
expect(result.body.name).toBe("Flow flow-123");
|
|
136
140
|
}).pipe(
|
|
137
|
-
Effect.provide(
|
|
141
|
+
Effect.provide(FlowEngineTest),
|
|
142
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
138
143
|
Effect.provide(AuthCacheServiceLive()),
|
|
139
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
144
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
140
145
|
),
|
|
141
146
|
);
|
|
142
147
|
|
|
@@ -150,13 +155,17 @@ describe("HTTP Flow Handlers", () => {
|
|
|
150
155
|
expect(result.status).toBe(200);
|
|
151
156
|
expect(result.body.id).toBe("flow-456");
|
|
152
157
|
}).pipe(
|
|
153
|
-
Effect.provide(
|
|
158
|
+
Effect.provide(FlowEngineTest),
|
|
159
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
154
160
|
Effect.provide(AuthCacheServiceLive()),
|
|
155
161
|
Effect.provide(
|
|
156
|
-
AuthContextServiceLive(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
162
|
+
AuthContextServiceLive(
|
|
163
|
+
{
|
|
164
|
+
clientId: "user-123",
|
|
165
|
+
metadata: { role: "admin" },
|
|
166
|
+
},
|
|
167
|
+
{ bypassAuth: true },
|
|
168
|
+
),
|
|
160
169
|
),
|
|
161
170
|
),
|
|
162
171
|
);
|
|
@@ -175,9 +184,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
175
184
|
expect(result.body).toHaveProperty("edges");
|
|
176
185
|
expect(result.body.id).toBe("flow-789");
|
|
177
186
|
}).pipe(
|
|
178
|
-
Effect.provide(
|
|
187
|
+
Effect.provide(FlowEngineTest),
|
|
188
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
179
189
|
Effect.provide(AuthCacheServiceLive()),
|
|
180
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
190
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
181
191
|
),
|
|
182
192
|
);
|
|
183
193
|
});
|
|
@@ -198,9 +208,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
198
208
|
expect(result.body.storageId).toBe("storage-1");
|
|
199
209
|
expect(result.body.status).toBe("running");
|
|
200
210
|
}).pipe(
|
|
201
|
-
Effect.provide(
|
|
211
|
+
Effect.provide(FlowEngineTest),
|
|
212
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
202
213
|
Effect.provide(AuthCacheServiceLive()),
|
|
203
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
214
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
204
215
|
),
|
|
205
216
|
);
|
|
206
217
|
|
|
@@ -217,13 +228,17 @@ describe("HTTP Flow Handlers", () => {
|
|
|
217
228
|
expect(result.body.clientId).toBe("user-123");
|
|
218
229
|
// Auth context is cached internally by the handler
|
|
219
230
|
}).pipe(
|
|
220
|
-
Effect.provide(
|
|
231
|
+
Effect.provide(FlowEngineTest),
|
|
232
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
221
233
|
Effect.provide(AuthCacheServiceLive()),
|
|
222
234
|
Effect.provide(
|
|
223
|
-
AuthContextServiceLive(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
235
|
+
AuthContextServiceLive(
|
|
236
|
+
{
|
|
237
|
+
clientId: "user-123",
|
|
238
|
+
metadata: { plan: "premium" },
|
|
239
|
+
},
|
|
240
|
+
{ bypassAuth: true },
|
|
241
|
+
),
|
|
227
242
|
),
|
|
228
243
|
),
|
|
229
244
|
);
|
|
@@ -240,9 +255,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
240
255
|
expect(result.status).toBe(200);
|
|
241
256
|
expect(result.body.clientId).toBeNull();
|
|
242
257
|
}).pipe(
|
|
243
|
-
Effect.provide(
|
|
258
|
+
Effect.provide(FlowEngineTest),
|
|
259
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
244
260
|
Effect.provide(AuthCacheServiceLive()),
|
|
245
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
261
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
246
262
|
),
|
|
247
263
|
);
|
|
248
264
|
|
|
@@ -259,9 +275,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
259
275
|
expect(result.body.id).toContain("job-");
|
|
260
276
|
expect(result.body.status).toBe("running");
|
|
261
277
|
}).pipe(
|
|
262
|
-
Effect.provide(
|
|
278
|
+
Effect.provide(FlowEngineTest),
|
|
279
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
263
280
|
Effect.provide(AuthCacheServiceLive()),
|
|
264
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
281
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
265
282
|
),
|
|
266
283
|
);
|
|
267
284
|
});
|
|
@@ -279,17 +296,18 @@ describe("HTTP Flow Handlers", () => {
|
|
|
279
296
|
expect(result.body.flowId).toBe("flow-123");
|
|
280
297
|
expect(result.body).toHaveProperty("status");
|
|
281
298
|
}).pipe(
|
|
282
|
-
Effect.provide(
|
|
299
|
+
Effect.provide(FlowEngineTest),
|
|
300
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
283
301
|
Effect.provide(AuthCacheServiceLive()),
|
|
284
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
302
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
285
303
|
),
|
|
286
304
|
);
|
|
287
305
|
|
|
288
306
|
it.effect("should clear cache when flow completes", () =>
|
|
289
307
|
Effect.gen(function* () {
|
|
290
|
-
// Create
|
|
308
|
+
// Create FlowEngine that returns completed status
|
|
291
309
|
const completedMethods = {
|
|
292
|
-
...
|
|
310
|
+
...mockFlowEngineMethods,
|
|
293
311
|
getJobStatus: (jobId: string) =>
|
|
294
312
|
Effect.succeed<FlowJob>({
|
|
295
313
|
id: jobId,
|
|
@@ -307,9 +325,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
307
325
|
type: "job-status",
|
|
308
326
|
jobId: "job-completed",
|
|
309
327
|
}).pipe(
|
|
310
|
-
Effect.provide(Layer.succeed(
|
|
328
|
+
Effect.provide(Layer.succeed(FlowEngine, completedMethods)),
|
|
329
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
311
330
|
Effect.provide(AuthCacheServiceLive()),
|
|
312
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
331
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
313
332
|
);
|
|
314
333
|
|
|
315
334
|
expect(result.status).toBe(200);
|
|
@@ -327,9 +346,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
327
346
|
expect(result.status).toBe(200);
|
|
328
347
|
expect(result.body.status).toBe("running");
|
|
329
348
|
}).pipe(
|
|
330
|
-
Effect.provide(
|
|
349
|
+
Effect.provide(FlowEngineTest),
|
|
350
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
331
351
|
Effect.provide(AuthCacheServiceLive()),
|
|
332
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
352
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
333
353
|
),
|
|
334
354
|
);
|
|
335
355
|
});
|
|
@@ -347,9 +367,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
347
367
|
expect(result.status).toBe(200);
|
|
348
368
|
expect(result.body.id).toBe("job-cached");
|
|
349
369
|
}).pipe(
|
|
350
|
-
Effect.provide(
|
|
370
|
+
Effect.provide(FlowEngineTest),
|
|
371
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
351
372
|
Effect.provide(AuthCacheServiceLive()),
|
|
352
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
373
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
353
374
|
),
|
|
354
375
|
);
|
|
355
376
|
});
|
|
@@ -366,9 +387,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
366
387
|
expect(result.body.id).toBe("job-pause");
|
|
367
388
|
expect(result.body.status).toBe("paused");
|
|
368
389
|
}).pipe(
|
|
369
|
-
Effect.provide(
|
|
390
|
+
Effect.provide(FlowEngineTest),
|
|
391
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
370
392
|
Effect.provide(AuthCacheServiceLive()),
|
|
371
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
393
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
372
394
|
),
|
|
373
395
|
);
|
|
374
396
|
|
|
@@ -383,9 +405,12 @@ describe("HTTP Flow Handlers", () => {
|
|
|
383
405
|
expect(result.body.status).toBe("paused");
|
|
384
406
|
expect(result.body.clientId).toBe("user-pause");
|
|
385
407
|
}).pipe(
|
|
386
|
-
Effect.provide(
|
|
408
|
+
Effect.provide(FlowEngineTest),
|
|
409
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
387
410
|
Effect.provide(AuthCacheServiceLive()),
|
|
388
|
-
Effect.provide(
|
|
411
|
+
Effect.provide(
|
|
412
|
+
AuthContextServiceLive({ clientId: "user-pause" }, { bypassAuth: true }),
|
|
413
|
+
),
|
|
389
414
|
),
|
|
390
415
|
);
|
|
391
416
|
});
|
|
@@ -402,9 +427,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
402
427
|
expect(result.body.id).toBe("job-cancel");
|
|
403
428
|
expect(result.body.status).toBe("cancelled");
|
|
404
429
|
}).pipe(
|
|
405
|
-
Effect.provide(
|
|
430
|
+
Effect.provide(FlowEngineTest),
|
|
431
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
406
432
|
Effect.provide(AuthCacheServiceLive()),
|
|
407
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
433
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
408
434
|
),
|
|
409
435
|
);
|
|
410
436
|
|
|
@@ -419,13 +445,17 @@ describe("HTTP Flow Handlers", () => {
|
|
|
419
445
|
expect(result.body.status).toBe("cancelled");
|
|
420
446
|
expect(result.body.clientId).toBe("user-cancel-auth");
|
|
421
447
|
}).pipe(
|
|
422
|
-
Effect.provide(
|
|
448
|
+
Effect.provide(FlowEngineTest),
|
|
449
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
423
450
|
Effect.provide(AuthCacheServiceLive()),
|
|
424
451
|
Effect.provide(
|
|
425
|
-
AuthContextServiceLive(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
452
|
+
AuthContextServiceLive(
|
|
453
|
+
{
|
|
454
|
+
clientId: "user-cancel-auth",
|
|
455
|
+
metadata: { reason: "manual" },
|
|
456
|
+
},
|
|
457
|
+
{ bypassAuth: true },
|
|
458
|
+
),
|
|
429
459
|
),
|
|
430
460
|
),
|
|
431
461
|
);
|
|
@@ -454,9 +484,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
454
484
|
});
|
|
455
485
|
expect(statusResult.status).toBe(200);
|
|
456
486
|
}).pipe(
|
|
457
|
-
Effect.provide(
|
|
487
|
+
Effect.provide(FlowEngineTest),
|
|
488
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
458
489
|
Effect.provide(AuthCacheServiceLive()),
|
|
459
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
490
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
460
491
|
),
|
|
461
492
|
);
|
|
462
493
|
});
|
|
@@ -486,9 +517,10 @@ describe("HTTP Flow Handlers", () => {
|
|
|
486
517
|
});
|
|
487
518
|
expect(statusResult.status).toBe(200);
|
|
488
519
|
}).pipe(
|
|
489
|
-
Effect.provide(
|
|
520
|
+
Effect.provide(FlowEngineTest),
|
|
521
|
+
Effect.provide(NoUsageHookServiceLive),
|
|
490
522
|
Effect.provide(AuthCacheServiceLive()),
|
|
491
|
-
Effect.provide(AuthContextServiceLive(null)),
|
|
523
|
+
Effect.provide(AuthContextServiceLive(null, { bypassAuth: true })),
|
|
492
524
|
),
|
|
493
525
|
);
|
|
494
526
|
});
|
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
} from "@uploadista/core/types";
|
|
17
17
|
import { Effect } from "effect";
|
|
18
18
|
import { describe, expect } from "vitest";
|
|
19
|
+
import { AuthContextServiceLive } from "../../../src";
|
|
19
20
|
import {
|
|
20
21
|
handleHealthComponents,
|
|
21
22
|
handleHealthLiveness,
|
|
@@ -133,7 +134,7 @@ describe("HTTP Health Check Handlers", () => {
|
|
|
133
134
|
|
|
134
135
|
expect(response.status).toBe(200);
|
|
135
136
|
expect(response.type).toBe("health-ready");
|
|
136
|
-
}),
|
|
137
|
+
}).pipe(Effect.provide(AuthContextServiceLive(null, { bypassAuth: true }))),
|
|
137
138
|
);
|
|
138
139
|
|
|
139
140
|
it.effect("should include component status in response", () =>
|
|
@@ -147,7 +148,7 @@ describe("HTTP Health Check Handlers", () => {
|
|
|
147
148
|
const body = response.body as HealthResponseBody;
|
|
148
149
|
|
|
149
150
|
expect(body.components).toBeDefined();
|
|
150
|
-
}),
|
|
151
|
+
}).pipe(Effect.provide(AuthContextServiceLive(null, { bypassAuth: true }))),
|
|
151
152
|
);
|
|
152
153
|
|
|
153
154
|
it.effect("should return plain text when Accept: text/plain", () =>
|
|
@@ -161,7 +162,7 @@ describe("HTTP Health Check Handlers", () => {
|
|
|
161
162
|
|
|
162
163
|
expect(response.headers["Content-Type"]).toBe("text/plain");
|
|
163
164
|
expect(typeof response.body).toBe("string");
|
|
164
|
-
}),
|
|
165
|
+
}).pipe(Effect.provide(AuthContextServiceLive(null, { bypassAuth: true }))),
|
|
165
166
|
);
|
|
166
167
|
|
|
167
168
|
it.effect("should respect checkStorage config option", () =>
|
|
@@ -177,7 +178,7 @@ describe("HTTP Health Check Handlers", () => {
|
|
|
177
178
|
|
|
178
179
|
// Storage should be checked when enabled
|
|
179
180
|
expect(body.components?.storage).toBeDefined();
|
|
180
|
-
}),
|
|
181
|
+
}).pipe(Effect.provide(AuthContextServiceLive(null, { bypassAuth: true }))),
|
|
181
182
|
);
|
|
182
183
|
|
|
183
184
|
it.effect("should skip storage check when disabled", () =>
|
|
@@ -193,7 +194,7 @@ describe("HTTP Health Check Handlers", () => {
|
|
|
193
194
|
|
|
194
195
|
// Storage should not be present when disabled
|
|
195
196
|
expect(body.components?.storage).toBeUndefined();
|
|
196
|
-
}),
|
|
197
|
+
}).pipe(Effect.provide(AuthContextServiceLive(null, { bypassAuth: true }))),
|
|
197
198
|
);
|
|
198
199
|
});
|
|
199
200
|
|
|
@@ -210,7 +211,7 @@ describe("HTTP Health Check Handlers", () => {
|
|
|
210
211
|
// Components endpoint always returns 200 for debugging
|
|
211
212
|
expect(response.status).toBe(200);
|
|
212
213
|
expect(response.type).toBe("health-components");
|
|
213
|
-
}),
|
|
214
|
+
}).pipe(Effect.provide(AuthContextServiceLive(null, { bypassAuth: true }))),
|
|
214
215
|
);
|
|
215
216
|
|
|
216
217
|
it.effect("should include detailed component status", () =>
|
|
@@ -224,7 +225,7 @@ describe("HTTP Health Check Handlers", () => {
|
|
|
224
225
|
const body = response.body as HealthResponseBody;
|
|
225
226
|
|
|
226
227
|
expect(body.components).toBeDefined();
|
|
227
|
-
}),
|
|
228
|
+
}).pipe(Effect.provide(AuthContextServiceLive(null, { bypassAuth: true }))),
|
|
228
229
|
);
|
|
229
230
|
|
|
230
231
|
it.effect("should include timestamp and uptime", () =>
|
|
@@ -239,7 +240,7 @@ describe("HTTP Health Check Handlers", () => {
|
|
|
239
240
|
|
|
240
241
|
expect(body.timestamp).toBeDefined();
|
|
241
242
|
expect(body.uptime).toBeDefined();
|
|
242
|
-
}),
|
|
243
|
+
}).pipe(Effect.provide(AuthContextServiceLive(null, { bypassAuth: true }))),
|
|
243
244
|
);
|
|
244
245
|
|
|
245
246
|
it.effect("should return plain text when Accept: text/plain", () =>
|
|
@@ -253,7 +254,7 @@ describe("HTTP Health Check Handlers", () => {
|
|
|
253
254
|
|
|
254
255
|
expect(response.headers["Content-Type"]).toBe("text/plain");
|
|
255
256
|
expect(typeof response.body).toBe("string");
|
|
256
|
-
}),
|
|
257
|
+
}).pipe(Effect.provide(AuthContextServiceLive(null, { bypassAuth: true }))),
|
|
257
258
|
);
|
|
258
259
|
});
|
|
259
260
|
|
|
@@ -345,7 +346,7 @@ describe("HTTP Health Check Handlers", () => {
|
|
|
345
346
|
"unhealthy",
|
|
346
347
|
];
|
|
347
348
|
expect(validStatuses).toContain(body.status);
|
|
348
|
-
}),
|
|
349
|
+
}).pipe(Effect.provide(AuthContextServiceLive(null, { bypassAuth: true }))),
|
|
349
350
|
);
|
|
350
351
|
});
|
|
351
352
|
});
|
package/dist/auth-Ck4gisA2.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=async({uploadistaClientId:e,uploadistaApiKey:t,baseUrl:n=`https://api.uploadista.com`})=>{let r=await fetch(`${n}/uploadista/auth/jwt?apiKey=${t}&clientId=${e}`,{method:`GET`,headers:{"Content-Type":`application/json`}});return r.ok===!0?{isValid:!0,data:await r.json()}:{isValid:!1,error:`Failed to get auth credentials`}};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
package/dist/auth-DG0enyjj.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=async({uploadistaClientId:e,uploadistaApiKey:t,baseUrl:n=`https://api.uploadista.com`})=>{let r=await fetch(`${n}/uploadista/auth/jwt?apiKey=${t}&clientId=${e}`,{method:`GET`,headers:{"Content-Type":`application/json`}});return r.ok===!0?{isValid:!0,data:await r.json()}:{isValid:!1,error:`Failed to get auth credentials`}};export{e as t};
|
|
2
|
-
//# sourceMappingURL=auth-DG0enyjj.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-DG0enyjj.mjs","names":[],"sources":["../src/auth/get-auth-credentials.ts"],"sourcesContent":["/**\n * Response type for authentication credential requests.\n * - `isValid: true` with token and expiration\n * - `isValid: false` with error message\n *\n * @example\n * ```typescript\n * const response = await getAuthCredentials({\n * uploadistaClientId: \"my-client\",\n * uploadistaApiKey: \"sk_...\"\n * });\n * if (response.isValid) {\n * console.log(`Token: ${response.data.token}`);\n * } else {\n * console.error(`Auth failed: ${response.error}`);\n * }\n * ```\n */\nexport type AuthCredentialsResponse =\n | {\n isValid: true;\n data: { token: string; expiresIn: number };\n }\n | {\n isValid: false;\n error: string;\n };\n\n/**\n * Retrieve JWT authentication credentials from the Uploadista server.\n * This function exchanges client credentials (ID + API key) for a signed JWT token.\n *\n * The JWT token is then used in subsequent API requests via the Authorization header.\n * Tokens are time-limited and should be refreshed before expiration.\n *\n * @param params - Credential exchange parameters\n * @param params.uploadistaClientId - Your Uploadista client ID\n * @param params.uploadistaApiKey - Your Uploadista API key (secret)\n * @param params.baseUrl - Uploadista server base URL (default: https://api.uploadista.com)\n * @returns Promise resolving to authentication response with token or error\n *\n * @example\n * ```typescript\n * import { getAuthCredentials } from \"@uploadista/server\";\n *\n * // Get JWT token for API requests\n * const response = await getAuthCredentials({\n * uploadistaClientId: process.env.UPLOADISTA_CLIENT_ID,\n * uploadistaApiKey: process.env.UPLOADISTA_API_KEY,\n * });\n *\n * if (response.isValid) {\n * // Use token in API requests\n * const headers = {\n * Authorization: `Bearer ${response.data.token}`,\n * };\n *\n * // Token expires in response.data.expiresIn seconds\n * setTimeout(\n * () => {\n * // Refresh token before expiration\n * },\n * response.data.expiresIn * 1000,\n * );\n * }\n * ```\n */\nexport const getAuthCredentials = async ({\n uploadistaClientId,\n uploadistaApiKey,\n baseUrl = \"https://api.uploadista.com\",\n}: {\n uploadistaClientId: string;\n uploadistaApiKey: string;\n baseUrl?: string;\n}): Promise<AuthCredentialsResponse> => {\n const response = await fetch(\n `${baseUrl}/uploadista/auth/jwt?apiKey=${uploadistaApiKey}&clientId=${uploadistaClientId}`,\n {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n },\n );\n\n if (response.ok !== true) {\n return { isValid: false, error: \"Failed to get auth credentials\" };\n }\n\n const data = (await response.json()) as { token: string; expiresIn: number };\n\n return {\n isValid: true,\n data,\n };\n};\n"],"mappings":"AAmEA,MAAa,EAAqB,MAAO,CACvC,qBACA,mBACA,UAAU,gCAK4B,CACtC,IAAM,EAAW,MAAM,MACrB,GAAG,EAAQ,8BAA8B,EAAiB,YAAY,IACtE,CACE,OAAQ,MACR,QAAS,CACP,eAAgB,mBACjB,CACF,CACF,CAQD,OANI,EAAS,KAAO,GAMb,CACL,QAAS,GACT,KAJY,MAAM,EAAS,MAAM,CAKlC,CARQ,CAAE,QAAS,GAAO,MAAO,iCAAkC"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
//#region src/auth/get-auth-credentials.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Response type for authentication credential requests.
|
|
4
|
-
* - `isValid: true` with token and expiration
|
|
5
|
-
* - `isValid: false` with error message
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const response = await getAuthCredentials({
|
|
10
|
-
* uploadistaClientId: "my-client",
|
|
11
|
-
* uploadistaApiKey: "sk_..."
|
|
12
|
-
* });
|
|
13
|
-
* if (response.isValid) {
|
|
14
|
-
* console.log(`Token: ${response.data.token}`);
|
|
15
|
-
* } else {
|
|
16
|
-
* console.error(`Auth failed: ${response.error}`);
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
type AuthCredentialsResponse = {
|
|
21
|
-
isValid: true;
|
|
22
|
-
data: {
|
|
23
|
-
token: string;
|
|
24
|
-
expiresIn: number;
|
|
25
|
-
};
|
|
26
|
-
} | {
|
|
27
|
-
isValid: false;
|
|
28
|
-
error: string;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Retrieve JWT authentication credentials from the Uploadista server.
|
|
32
|
-
* This function exchanges client credentials (ID + API key) for a signed JWT token.
|
|
33
|
-
*
|
|
34
|
-
* The JWT token is then used in subsequent API requests via the Authorization header.
|
|
35
|
-
* Tokens are time-limited and should be refreshed before expiration.
|
|
36
|
-
*
|
|
37
|
-
* @param params - Credential exchange parameters
|
|
38
|
-
* @param params.uploadistaClientId - Your Uploadista client ID
|
|
39
|
-
* @param params.uploadistaApiKey - Your Uploadista API key (secret)
|
|
40
|
-
* @param params.baseUrl - Uploadista server base URL (default: https://api.uploadista.com)
|
|
41
|
-
* @returns Promise resolving to authentication response with token or error
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* import { getAuthCredentials } from "@uploadista/server";
|
|
46
|
-
*
|
|
47
|
-
* // Get JWT token for API requests
|
|
48
|
-
* const response = await getAuthCredentials({
|
|
49
|
-
* uploadistaClientId: process.env.UPLOADISTA_CLIENT_ID,
|
|
50
|
-
* uploadistaApiKey: process.env.UPLOADISTA_API_KEY,
|
|
51
|
-
* });
|
|
52
|
-
*
|
|
53
|
-
* if (response.isValid) {
|
|
54
|
-
* // Use token in API requests
|
|
55
|
-
* const headers = {
|
|
56
|
-
* Authorization: `Bearer ${response.data.token}`,
|
|
57
|
-
* };
|
|
58
|
-
*
|
|
59
|
-
* // Token expires in response.data.expiresIn seconds
|
|
60
|
-
* setTimeout(
|
|
61
|
-
* () => {
|
|
62
|
-
* // Refresh token before expiration
|
|
63
|
-
* },
|
|
64
|
-
* response.data.expiresIn * 1000,
|
|
65
|
-
* );
|
|
66
|
-
* }
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
declare const getAuthCredentials: ({
|
|
70
|
-
uploadistaClientId,
|
|
71
|
-
uploadistaApiKey,
|
|
72
|
-
baseUrl
|
|
73
|
-
}: {
|
|
74
|
-
uploadistaClientId: string;
|
|
75
|
-
uploadistaApiKey: string;
|
|
76
|
-
baseUrl?: string;
|
|
77
|
-
}) => Promise<AuthCredentialsResponse>;
|
|
78
|
-
//#endregion
|
|
79
|
-
export { getAuthCredentials as n, AuthCredentialsResponse as t };
|
|
80
|
-
//# sourceMappingURL=index-BXLtlr98.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BXLtlr98.d.mts","names":[],"sources":["../src/auth/get-auth-credentials.ts"],"sourcesContent":[],"mappings":";;AAkBA;AAiDA;;;;;;;;;;;;;;;;KAjDY,uBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiDC;;;;;;;;MAQT,QAAQ"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
//#region src/auth/get-auth-credentials.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Response type for authentication credential requests.
|
|
4
|
-
* - `isValid: true` with token and expiration
|
|
5
|
-
* - `isValid: false` with error message
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const response = await getAuthCredentials({
|
|
10
|
-
* uploadistaClientId: "my-client",
|
|
11
|
-
* uploadistaApiKey: "sk_..."
|
|
12
|
-
* });
|
|
13
|
-
* if (response.isValid) {
|
|
14
|
-
* console.log(`Token: ${response.data.token}`);
|
|
15
|
-
* } else {
|
|
16
|
-
* console.error(`Auth failed: ${response.error}`);
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
type AuthCredentialsResponse = {
|
|
21
|
-
isValid: true;
|
|
22
|
-
data: {
|
|
23
|
-
token: string;
|
|
24
|
-
expiresIn: number;
|
|
25
|
-
};
|
|
26
|
-
} | {
|
|
27
|
-
isValid: false;
|
|
28
|
-
error: string;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Retrieve JWT authentication credentials from the Uploadista server.
|
|
32
|
-
* This function exchanges client credentials (ID + API key) for a signed JWT token.
|
|
33
|
-
*
|
|
34
|
-
* The JWT token is then used in subsequent API requests via the Authorization header.
|
|
35
|
-
* Tokens are time-limited and should be refreshed before expiration.
|
|
36
|
-
*
|
|
37
|
-
* @param params - Credential exchange parameters
|
|
38
|
-
* @param params.uploadistaClientId - Your Uploadista client ID
|
|
39
|
-
* @param params.uploadistaApiKey - Your Uploadista API key (secret)
|
|
40
|
-
* @param params.baseUrl - Uploadista server base URL (default: https://api.uploadista.com)
|
|
41
|
-
* @returns Promise resolving to authentication response with token or error
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* import { getAuthCredentials } from "@uploadista/server";
|
|
46
|
-
*
|
|
47
|
-
* // Get JWT token for API requests
|
|
48
|
-
* const response = await getAuthCredentials({
|
|
49
|
-
* uploadistaClientId: process.env.UPLOADISTA_CLIENT_ID,
|
|
50
|
-
* uploadistaApiKey: process.env.UPLOADISTA_API_KEY,
|
|
51
|
-
* });
|
|
52
|
-
*
|
|
53
|
-
* if (response.isValid) {
|
|
54
|
-
* // Use token in API requests
|
|
55
|
-
* const headers = {
|
|
56
|
-
* Authorization: `Bearer ${response.data.token}`,
|
|
57
|
-
* };
|
|
58
|
-
*
|
|
59
|
-
* // Token expires in response.data.expiresIn seconds
|
|
60
|
-
* setTimeout(
|
|
61
|
-
* () => {
|
|
62
|
-
* // Refresh token before expiration
|
|
63
|
-
* },
|
|
64
|
-
* response.data.expiresIn * 1000,
|
|
65
|
-
* );
|
|
66
|
-
* }
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
declare const getAuthCredentials: ({
|
|
70
|
-
uploadistaClientId,
|
|
71
|
-
uploadistaApiKey,
|
|
72
|
-
baseUrl
|
|
73
|
-
}: {
|
|
74
|
-
uploadistaClientId: string;
|
|
75
|
-
uploadistaApiKey: string;
|
|
76
|
-
baseUrl?: string;
|
|
77
|
-
}) => Promise<AuthCredentialsResponse>;
|
|
78
|
-
//#endregion
|
|
79
|
-
export { getAuthCredentials as n, AuthCredentialsResponse as t };
|
|
80
|
-
//# sourceMappingURL=index-mMP18lsw.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-mMP18lsw.d.cts","names":[],"sources":["../src/auth/get-auth-credentials.ts"],"sourcesContent":[],"mappings":";;AAkBA;AAiDA;;;;;;;;;;;;;;;;KAjDY,uBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiDC;;;;;;;;MAQT,QAAQ"}
|