@sixb/server 0.1.2 → 0.1.3
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/experience.d.ts +33 -0
- package/dist/auth/experience.d.ts.map +1 -0
- package/dist/auth/public-routes.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1891 -1337
- package/dist/index.js.map +17 -14
- package/dist/openapi/tags.d.ts +6 -2
- package/dist/openapi/tags.d.ts.map +1 -1
- package/dist/registerRoutes.d.ts.map +1 -1
- package/dist/routes/action-runs.d.ts +6 -6
- package/dist/routes/actions.d.ts +3 -3
- package/dist/routes/agents.d.ts +149 -77
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/ai-accounting.d.ts +31 -0
- package/dist/routes/ai-accounting.d.ts.map +1 -0
- package/dist/routes/auth.d.ts +110 -53
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/connector-connection-runs.d.ts +56 -56
- package/dist/routes/connector-connections.d.ts +14 -14
- package/dist/routes/datasets.d.ts +12 -12
- package/dist/routes/events.d.ts +1 -1
- package/dist/routes/files.d.ts +8 -8
- package/dist/routes/links.d.ts +9 -9
- package/dist/routes/logs.d.ts +2 -2
- package/dist/routes/objects.d.ts +3 -3
- package/dist/routes/pipelines.d.ts +10 -10
- package/dist/routes/projections.d.ts +62 -50
- package/dist/routes/projections.d.ts.map +1 -1
- package/dist/routes/syncs.d.ts +6 -6
- package/dist/routes/telemetry.d.ts +7 -7
- package/dist/routes/webhook-runs.d.ts +2 -2
- package/dist/routes/workflows.d.ts +142 -57
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/ws/logs.d.ts +10 -10
- package/dist/schemas/actions.d.ts +16 -16
- package/dist/schemas/agents.d.ts +459 -142
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/ai-accounting.d.ts +2393 -0
- package/dist/schemas/ai-accounting.d.ts.map +1 -0
- package/dist/schemas/auth.d.ts +96 -96
- package/dist/schemas/connectors.d.ts +24 -24
- package/dist/schemas/event-payloads.d.ts +6 -6
- package/dist/schemas/events.d.ts +6 -6
- package/dist/schemas/links.d.ts +2 -2
- package/dist/schemas/logs.d.ts +18 -18
- package/dist/schemas/pipelines.d.ts +20 -20
- package/dist/schemas/projections.d.ts +400 -288
- package/dist/schemas/projections.d.ts.map +1 -1
- package/dist/schemas/status.d.ts +2 -2
- package/dist/schemas/syncs.d.ts +10 -10
- package/dist/schemas/webhook-runs.d.ts +12 -12
- package/dist/schemas/workflows.d.ts +833 -162
- package/dist/schemas/workflows.d.ts.map +1 -1
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/auth/experience.ts +190 -0
- package/src/auth/public-routes.ts +7 -0
- package/src/index.ts +1 -0
- package/src/openapi/tags.ts +4 -0
- package/src/registerRoutes.ts +2 -0
- package/src/routes/agents.ts +1 -0
- package/src/routes/ai-accounting.ts +166 -0
- package/src/routes/auth.ts +188 -32
- package/src/routes/projections.ts +18 -4
- package/src/routes/workflows.ts +16 -0
- package/src/schemas/agents.ts +4 -9
- package/src/schemas/ai-accounting.ts +182 -0
- package/src/schemas/projections.ts +6 -0
- package/src/schemas/workflows.ts +8 -3
- package/src/server.ts +10 -0
package/dist/index.js
CHANGED
|
@@ -317,6 +317,9 @@ function isPublicRoute(pathname, method) {
|
|
|
317
317
|
if (pathname === "/api/auth/sign-out" && normalizedMethod === "POST") {
|
|
318
318
|
return true;
|
|
319
319
|
}
|
|
320
|
+
if (pathname.startsWith("/auth/assets/") && (normalizedMethod === "GET" || normalizedMethod === "HEAD")) {
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
320
323
|
if (pathname === "/auth/sign-in" && (normalizedMethod === "GET" || normalizedMethod === "POST")) {
|
|
321
324
|
return true;
|
|
322
325
|
}
|
|
@@ -584,6 +587,10 @@ var OPENAPI_TAGS = {
|
|
|
584
587
|
name: "Status",
|
|
585
588
|
description: "Runtime status"
|
|
586
589
|
},
|
|
590
|
+
aiAccounting: {
|
|
591
|
+
name: "AI Accounting",
|
|
592
|
+
description: "Project AI token usage, cost analytics, and model-call accounting"
|
|
593
|
+
},
|
|
587
594
|
ontology: {
|
|
588
595
|
name: "Ontology",
|
|
589
596
|
description: "Object type definitions"
|
|
@@ -2451,14 +2458,18 @@ import { publishAgentRunCancel, publishAgentRunFinished } from "@sixb/core/inter
|
|
|
2451
2458
|
import {
|
|
2452
2459
|
AgentStorageError
|
|
2453
2460
|
} from "@sixb/core/storage";
|
|
2454
|
-
import { ZodError as ZodError2, z as
|
|
2461
|
+
import { ZodError as ZodError2, z as z9 } from "zod";
|
|
2455
2462
|
|
|
2456
2463
|
// src/schemas/agents.ts
|
|
2457
2464
|
import { AGENT_REASONING_LEVELS, MAX_AGENT_CONTEXT_ENTRIES } from "@sixb/core";
|
|
2458
2465
|
import {
|
|
2459
2466
|
AGENT_RUN_DIAGNOSTIC_CODES,
|
|
2460
|
-
AGENT_RUN_FAILURE_CODES
|
|
2467
|
+
AGENT_RUN_FAILURE_CODES,
|
|
2468
|
+
AGENT_RUN_FINISH_REASONS
|
|
2461
2469
|
} from "@sixb/core/storage";
|
|
2470
|
+
import { z as z8 } from "zod";
|
|
2471
|
+
|
|
2472
|
+
// src/schemas/ai-accounting.ts
|
|
2462
2473
|
import { z as z7 } from "zod";
|
|
2463
2474
|
|
|
2464
2475
|
// src/schemas/ai-usage.ts
|
|
@@ -2476,140 +2487,295 @@ var AiUsageSummarySchema = z6.object({
|
|
|
2476
2487
|
reportingStatus: z6.enum(["complete", "partial", "unavailable"])
|
|
2477
2488
|
});
|
|
2478
2489
|
|
|
2490
|
+
// src/schemas/ai-accounting.ts
|
|
2491
|
+
var IntegerStringSchema = z7.string().regex(/^\d+$/);
|
|
2492
|
+
var IsoDateSchema = z7.string().datetime({ offset: true });
|
|
2493
|
+
var AiAccountingBucketSchema = z7.enum(["hour", "day", "week"]);
|
|
2494
|
+
var AiValuationStatusSchema = z7.enum(["rated", "unpriceable", "unvalued"]);
|
|
2495
|
+
var AiAccountingRangeQuerySchema = z7.object({
|
|
2496
|
+
from: IsoDateSchema,
|
|
2497
|
+
to: IsoDateSchema,
|
|
2498
|
+
providerId: z7.string().trim().min(1).optional(),
|
|
2499
|
+
modelId: z7.string().trim().min(1).optional()
|
|
2500
|
+
});
|
|
2501
|
+
var AiAccountingOverviewQuerySchema = AiAccountingRangeQuerySchema.extend({
|
|
2502
|
+
bucket: AiAccountingBucketSchema
|
|
2503
|
+
});
|
|
2504
|
+
var AiModelCallAccountingListQuerySchema = AiAccountingRangeQuerySchema.extend({
|
|
2505
|
+
executionId: z7.string().trim().min(1).optional(),
|
|
2506
|
+
valuationStatus: AiValuationStatusSchema.optional(),
|
|
2507
|
+
limit: IntegerStringSchema.optional(),
|
|
2508
|
+
offset: IntegerStringSchema.optional()
|
|
2509
|
+
});
|
|
2510
|
+
var AiMoneySchema = z7.object({
|
|
2511
|
+
currency: z7.string().regex(/^[A-Z]{3}$/),
|
|
2512
|
+
amountNanos: IntegerStringSchema
|
|
2513
|
+
});
|
|
2514
|
+
var AiCostSummarySchema = z7.object({
|
|
2515
|
+
amounts: z7.array(AiMoneySchema),
|
|
2516
|
+
ratedCallCount: z7.number().int().nonnegative(),
|
|
2517
|
+
unpriceableCallCount: z7.number().int().nonnegative(),
|
|
2518
|
+
unvaluedCallCount: z7.number().int().nonnegative()
|
|
2519
|
+
});
|
|
2520
|
+
var AiAccountingAggregateSchema = z7.object({
|
|
2521
|
+
modelCallCount: z7.number().int().nonnegative(),
|
|
2522
|
+
usage: AiUsageSummarySchema,
|
|
2523
|
+
costs: AiCostSummarySchema
|
|
2524
|
+
});
|
|
2525
|
+
var AiAccountingOverviewResponseSchema = z7.object({
|
|
2526
|
+
range: z7.object({ from: IsoDateSchema, to: IsoDateSchema }),
|
|
2527
|
+
bucket: AiAccountingBucketSchema,
|
|
2528
|
+
totals: AiAccountingAggregateSchema,
|
|
2529
|
+
series: z7.array(AiAccountingAggregateSchema.extend({
|
|
2530
|
+
start: IsoDateSchema,
|
|
2531
|
+
end: IsoDateSchema
|
|
2532
|
+
})),
|
|
2533
|
+
models: z7.array(AiAccountingAggregateSchema.extend({
|
|
2534
|
+
providerId: z7.string(),
|
|
2535
|
+
modelId: z7.string()
|
|
2536
|
+
})),
|
|
2537
|
+
agents: z7.array(AiAccountingAggregateSchema.extend({
|
|
2538
|
+
agentId: z7.string()
|
|
2539
|
+
})),
|
|
2540
|
+
workflows: z7.array(AiAccountingAggregateSchema.extend({
|
|
2541
|
+
workflowId: z7.string()
|
|
2542
|
+
}))
|
|
2543
|
+
});
|
|
2544
|
+
var AiPricingContextSchema = z7.object({
|
|
2545
|
+
serviceTier: z7.string().optional(),
|
|
2546
|
+
batch: z7.boolean().optional(),
|
|
2547
|
+
region: z7.string().optional(),
|
|
2548
|
+
inferenceGeo: z7.string().optional(),
|
|
2549
|
+
routedProviderId: z7.string().optional(),
|
|
2550
|
+
deploymentId: z7.string().optional(),
|
|
2551
|
+
inferenceProfileId: z7.string().optional(),
|
|
2552
|
+
cacheWriteTtlSeconds: z7.number().int().positive().optional(),
|
|
2553
|
+
mode: z7.string().optional()
|
|
2554
|
+
});
|
|
2555
|
+
var AiCostComponentSchema = z7.object({
|
|
2556
|
+
meter: z7.enum([
|
|
2557
|
+
"tokens.input.total",
|
|
2558
|
+
"tokens.input.uncached",
|
|
2559
|
+
"tokens.input.cacheRead",
|
|
2560
|
+
"tokens.input.cacheWrite",
|
|
2561
|
+
"tokens.output.total",
|
|
2562
|
+
"tokens.output.text",
|
|
2563
|
+
"tokens.output.reasoning"
|
|
2564
|
+
]),
|
|
2565
|
+
quantity: IntegerStringSchema,
|
|
2566
|
+
rateAmountNanosPerMillion: IntegerStringSchema,
|
|
2567
|
+
chargeAmountNanos: IntegerStringSchema
|
|
2568
|
+
});
|
|
2569
|
+
var AiBillingIdentitySchema = z7.object({
|
|
2570
|
+
providerId: z7.string(),
|
|
2571
|
+
modelId: z7.string()
|
|
2572
|
+
});
|
|
2573
|
+
var AiPriceSourceSchema = z7.object({
|
|
2574
|
+
sourceId: z7.string(),
|
|
2575
|
+
sourceEntryId: z7.string(),
|
|
2576
|
+
sourceVersion: z7.string(),
|
|
2577
|
+
sourceUrl: z7.string().url(),
|
|
2578
|
+
observedAt: IsoDateSchema
|
|
2579
|
+
});
|
|
2580
|
+
var AiModelCallCostSchema = z7.discriminatedUnion("status", [
|
|
2581
|
+
z7.object({
|
|
2582
|
+
status: z7.literal("rated"),
|
|
2583
|
+
billingIdentity: AiBillingIdentitySchema,
|
|
2584
|
+
pricingContext: AiPricingContextSchema,
|
|
2585
|
+
priceSource: AiPriceSourceSchema,
|
|
2586
|
+
money: AiMoneySchema,
|
|
2587
|
+
components: z7.array(AiCostComponentSchema),
|
|
2588
|
+
ratedAt: IsoDateSchema
|
|
2589
|
+
}),
|
|
2590
|
+
z7.object({
|
|
2591
|
+
status: z7.literal("unpriceable"),
|
|
2592
|
+
billingIdentity: AiBillingIdentitySchema.optional(),
|
|
2593
|
+
pricingContext: AiPricingContextSchema,
|
|
2594
|
+
priceSource: AiPriceSourceSchema,
|
|
2595
|
+
reason: z7.enum([
|
|
2596
|
+
"missingBillingIdentity",
|
|
2597
|
+
"missingCatalogEntry",
|
|
2598
|
+
"missingUsageMeter",
|
|
2599
|
+
"unsupportedPricingDimension",
|
|
2600
|
+
"invalidUsageForFormula"
|
|
2601
|
+
]),
|
|
2602
|
+
missingMeters: z7.array(AiCostComponentSchema.shape.meter).optional(),
|
|
2603
|
+
ratedAt: IsoDateSchema
|
|
2604
|
+
})
|
|
2605
|
+
]);
|
|
2606
|
+
var AiModelCallUsageRecordSchema = z7.object({
|
|
2607
|
+
id: z7.string(),
|
|
2608
|
+
executionId: z7.string(),
|
|
2609
|
+
attempt: z7.number().int().positive(),
|
|
2610
|
+
callId: z7.string(),
|
|
2611
|
+
providerId: z7.string(),
|
|
2612
|
+
requestedModelId: z7.string(),
|
|
2613
|
+
responseModelId: z7.string().optional(),
|
|
2614
|
+
responseId: z7.string(),
|
|
2615
|
+
usage: AiUsageSummarySchema,
|
|
2616
|
+
occurredAt: IsoDateSchema,
|
|
2617
|
+
recordedAt: IsoDateSchema
|
|
2618
|
+
});
|
|
2619
|
+
var AiModelCallAccountingItemSchema = z7.object({
|
|
2620
|
+
usage: AiModelCallUsageRecordSchema,
|
|
2621
|
+
attribution: z7.discriminatedUnion("kind", [
|
|
2622
|
+
z7.object({
|
|
2623
|
+
kind: z7.literal("agent"),
|
|
2624
|
+
agentId: z7.string(),
|
|
2625
|
+
agentRunId: z7.string(),
|
|
2626
|
+
threadId: z7.string()
|
|
2627
|
+
}),
|
|
2628
|
+
z7.object({
|
|
2629
|
+
kind: z7.literal("workflowAgent"),
|
|
2630
|
+
agentId: z7.string(),
|
|
2631
|
+
nodeRunId: z7.string(),
|
|
2632
|
+
workflowId: z7.string(),
|
|
2633
|
+
workflowRunId: z7.string()
|
|
2634
|
+
})
|
|
2635
|
+
]).optional(),
|
|
2636
|
+
cost: AiModelCallCostSchema.optional(),
|
|
2637
|
+
valuationStatus: AiValuationStatusSchema
|
|
2638
|
+
});
|
|
2639
|
+
var AiModelCallAccountingListResponseSchema = z7.object({
|
|
2640
|
+
items: z7.array(AiModelCallAccountingItemSchema),
|
|
2641
|
+
hasMore: z7.boolean(),
|
|
2642
|
+
total: z7.number().int().nonnegative()
|
|
2643
|
+
});
|
|
2644
|
+
|
|
2479
2645
|
// src/schemas/agents.ts
|
|
2480
2646
|
var AgentRunFailureSchema = sixbFailureSchema(AGENT_RUN_FAILURE_CODES);
|
|
2481
|
-
var AgentIdParamsSchema =
|
|
2482
|
-
agentId:
|
|
2647
|
+
var AgentIdParamsSchema = z8.object({
|
|
2648
|
+
agentId: z8.string().min(1)
|
|
2483
2649
|
});
|
|
2484
|
-
var AgentThreadParamsSchema =
|
|
2485
|
-
threadId:
|
|
2650
|
+
var AgentThreadParamsSchema = z8.object({
|
|
2651
|
+
threadId: z8.string().min(1)
|
|
2486
2652
|
});
|
|
2487
|
-
var AgentRunParamsSchema =
|
|
2488
|
-
runId:
|
|
2653
|
+
var AgentRunParamsSchema = z8.object({
|
|
2654
|
+
runId: z8.string().min(1)
|
|
2489
2655
|
});
|
|
2490
2656
|
var AgentMessageFileContentParamsSchema = AgentThreadParamsSchema.extend({
|
|
2491
|
-
messageId:
|
|
2657
|
+
messageId: z8.string().min(1)
|
|
2492
2658
|
});
|
|
2493
|
-
var AgentPrincipalSchema =
|
|
2494
|
-
type:
|
|
2495
|
-
id:
|
|
2659
|
+
var AgentPrincipalSchema = z8.object({
|
|
2660
|
+
type: z8.enum(["user", "serviceAccount", "system"]),
|
|
2661
|
+
id: z8.string().min(1)
|
|
2496
2662
|
});
|
|
2497
|
-
var AgentAuthorizablePrincipalSchema =
|
|
2498
|
-
type:
|
|
2499
|
-
id:
|
|
2663
|
+
var AgentAuthorizablePrincipalSchema = z8.object({
|
|
2664
|
+
type: z8.enum(["user", "serviceAccount"]),
|
|
2665
|
+
id: z8.string().min(1)
|
|
2500
2666
|
});
|
|
2501
|
-
var AgentObjectContextSchema =
|
|
2502
|
-
kind:
|
|
2503
|
-
ref:
|
|
2504
|
-
objectTypeId:
|
|
2505
|
-
primaryId:
|
|
2667
|
+
var AgentObjectContextSchema = z8.object({
|
|
2668
|
+
kind: z8.literal("object"),
|
|
2669
|
+
ref: z8.object({
|
|
2670
|
+
objectTypeId: z8.string().min(1),
|
|
2671
|
+
primaryId: z8.string().min(1)
|
|
2506
2672
|
})
|
|
2507
2673
|
});
|
|
2508
|
-
var AgentAppStateContextSchema =
|
|
2509
|
-
kind:
|
|
2510
|
-
id:
|
|
2511
|
-
label:
|
|
2512
|
-
description:
|
|
2674
|
+
var AgentAppStateContextSchema = z8.object({
|
|
2675
|
+
kind: z8.literal("app-state"),
|
|
2676
|
+
id: z8.string().min(1),
|
|
2677
|
+
label: z8.string().min(1),
|
|
2678
|
+
description: z8.string().min(1),
|
|
2513
2679
|
value: JsonValueSchema
|
|
2514
2680
|
});
|
|
2515
|
-
var AgentContextInputSchema =
|
|
2681
|
+
var AgentContextInputSchema = z8.discriminatedUnion("kind", [
|
|
2516
2682
|
AgentObjectContextSchema,
|
|
2517
2683
|
AgentAppStateContextSchema
|
|
2518
2684
|
]);
|
|
2519
|
-
var AgentContextOriginSchema =
|
|
2520
|
-
var AgentContextEntryInputSchema =
|
|
2685
|
+
var AgentContextOriginSchema = z8.enum(["ambient", "explicit"]);
|
|
2686
|
+
var AgentContextEntryInputSchema = z8.object({
|
|
2521
2687
|
context: AgentContextInputSchema,
|
|
2522
2688
|
origin: AgentContextOriginSchema
|
|
2523
2689
|
});
|
|
2524
2690
|
var AgentContextPartSchema = AgentContextEntryInputSchema.extend({
|
|
2525
|
-
type:
|
|
2691
|
+
type: z8.literal("context")
|
|
2526
2692
|
});
|
|
2527
|
-
var AgentLoopConfigSchema =
|
|
2528
|
-
stopWhen:
|
|
2529
|
-
maxSteps:
|
|
2693
|
+
var AgentLoopConfigSchema = z8.object({
|
|
2694
|
+
stopWhen: z8.object({
|
|
2695
|
+
maxSteps: z8.number().int().positive().optional()
|
|
2530
2696
|
}).optional()
|
|
2531
2697
|
});
|
|
2532
|
-
var AgentReasoningLevelSchema =
|
|
2533
|
-
var AgentCatalogItemSchema =
|
|
2534
|
-
id:
|
|
2535
|
-
name:
|
|
2536
|
-
description:
|
|
2537
|
-
modelId:
|
|
2698
|
+
var AgentReasoningLevelSchema = z8.enum(AGENT_REASONING_LEVELS);
|
|
2699
|
+
var AgentCatalogItemSchema = z8.object({
|
|
2700
|
+
id: z8.string(),
|
|
2701
|
+
name: z8.string(),
|
|
2702
|
+
description: z8.string().optional(),
|
|
2703
|
+
modelId: z8.string().optional(),
|
|
2538
2704
|
reasoning: AgentReasoningLevelSchema.optional(),
|
|
2539
|
-
groupIds:
|
|
2705
|
+
groupIds: z8.array(z8.string()),
|
|
2540
2706
|
loop: AgentLoopConfigSchema.optional()
|
|
2541
2707
|
});
|
|
2542
|
-
var AgentThreadStatusSchema =
|
|
2543
|
-
var AgentThreadListQuerySchema =
|
|
2544
|
-
agentId:
|
|
2708
|
+
var AgentThreadStatusSchema = z8.enum(["active", "archived"]);
|
|
2709
|
+
var AgentThreadListQuerySchema = z8.object({
|
|
2710
|
+
agentId: z8.string().optional(),
|
|
2545
2711
|
status: AgentThreadStatusSchema.optional(),
|
|
2546
|
-
limit:
|
|
2547
|
-
offset:
|
|
2548
|
-
order:
|
|
2549
|
-
});
|
|
2550
|
-
var CreateAgentThreadBodySchema =
|
|
2551
|
-
agentId:
|
|
2552
|
-
title:
|
|
2553
|
-
threadId:
|
|
2554
|
-
});
|
|
2555
|
-
var AgentThreadSchema =
|
|
2556
|
-
id:
|
|
2557
|
-
projectId:
|
|
2558
|
-
agentId:
|
|
2712
|
+
limit: z8.string().optional(),
|
|
2713
|
+
offset: z8.string().optional(),
|
|
2714
|
+
order: z8.enum(["asc", "desc"]).optional()
|
|
2715
|
+
});
|
|
2716
|
+
var CreateAgentThreadBodySchema = z8.object({
|
|
2717
|
+
agentId: z8.string().min(1),
|
|
2718
|
+
title: z8.string().trim().min(1).optional(),
|
|
2719
|
+
threadId: z8.string().trim().min(1).optional()
|
|
2720
|
+
});
|
|
2721
|
+
var AgentThreadSchema = z8.object({
|
|
2722
|
+
id: z8.string(),
|
|
2723
|
+
projectId: z8.string(),
|
|
2724
|
+
agentId: z8.string(),
|
|
2559
2725
|
ownerPrincipal: AgentPrincipalSchema,
|
|
2560
|
-
title:
|
|
2726
|
+
title: z8.string().optional(),
|
|
2561
2727
|
status: AgentThreadStatusSchema,
|
|
2562
|
-
activeRunId:
|
|
2563
|
-
lastMessageAt:
|
|
2564
|
-
messageCount:
|
|
2565
|
-
createdAt:
|
|
2566
|
-
updatedAt:
|
|
2567
|
-
});
|
|
2568
|
-
var AgentThreadListResponseSchema =
|
|
2569
|
-
threads:
|
|
2570
|
-
hasMore:
|
|
2571
|
-
total:
|
|
2572
|
-
});
|
|
2573
|
-
var CreateAgentThreadResponseSchema =
|
|
2728
|
+
activeRunId: z8.string().nullable(),
|
|
2729
|
+
lastMessageAt: z8.string().optional(),
|
|
2730
|
+
messageCount: z8.number(),
|
|
2731
|
+
createdAt: z8.string(),
|
|
2732
|
+
updatedAt: z8.string()
|
|
2733
|
+
});
|
|
2734
|
+
var AgentThreadListResponseSchema = z8.object({
|
|
2735
|
+
threads: z8.array(AgentThreadSchema),
|
|
2736
|
+
hasMore: z8.boolean(),
|
|
2737
|
+
total: z8.number()
|
|
2738
|
+
});
|
|
2739
|
+
var CreateAgentThreadResponseSchema = z8.object({
|
|
2574
2740
|
thread: AgentThreadSchema
|
|
2575
2741
|
});
|
|
2576
|
-
var AgentMessageRoleSchema =
|
|
2577
|
-
var AgentTextPartSchema =
|
|
2578
|
-
type:
|
|
2579
|
-
text:
|
|
2742
|
+
var AgentMessageRoleSchema = z8.enum(["system", "user", "assistant"]);
|
|
2743
|
+
var AgentTextPartSchema = z8.object({
|
|
2744
|
+
type: z8.literal("text"),
|
|
2745
|
+
text: z8.string(),
|
|
2580
2746
|
providerMetadata: JsonValueSchema.optional()
|
|
2581
2747
|
});
|
|
2582
|
-
var AgentReasoningPartSchema =
|
|
2583
|
-
type:
|
|
2584
|
-
text:
|
|
2748
|
+
var AgentReasoningPartSchema = z8.object({
|
|
2749
|
+
type: z8.literal("reasoning"),
|
|
2750
|
+
text: z8.string(),
|
|
2585
2751
|
providerMetadata: JsonValueSchema.optional()
|
|
2586
2752
|
});
|
|
2587
|
-
var AgentStepStartPartSchema =
|
|
2588
|
-
type:
|
|
2753
|
+
var AgentStepStartPartSchema = z8.object({
|
|
2754
|
+
type: z8.literal("step-start")
|
|
2589
2755
|
});
|
|
2590
|
-
var AgentFilePartSchema =
|
|
2591
|
-
type:
|
|
2756
|
+
var AgentFilePartSchema = z8.object({
|
|
2757
|
+
type: z8.literal("file"),
|
|
2592
2758
|
fileRef: FileRefSchema,
|
|
2593
2759
|
providerMetadata: JsonValueSchema.optional()
|
|
2594
2760
|
});
|
|
2595
|
-
var AgentToolCallBaseSchema =
|
|
2596
|
-
type:
|
|
2597
|
-
toolCallId:
|
|
2598
|
-
toolName:
|
|
2599
|
-
dynamic:
|
|
2600
|
-
providerExecuted:
|
|
2761
|
+
var AgentToolCallBaseSchema = z8.object({
|
|
2762
|
+
type: z8.literal("tool-call"),
|
|
2763
|
+
toolCallId: z8.string(),
|
|
2764
|
+
toolName: z8.string(),
|
|
2765
|
+
dynamic: z8.boolean().optional(),
|
|
2766
|
+
providerExecuted: z8.boolean().optional(),
|
|
2601
2767
|
input: JsonValueSchema,
|
|
2602
2768
|
providerMetadata: JsonValueSchema.optional()
|
|
2603
2769
|
});
|
|
2604
2770
|
var AgentToolCallOutputSchema = AgentToolCallBaseSchema.extend({
|
|
2605
|
-
state:
|
|
2771
|
+
state: z8.literal("output-available"),
|
|
2606
2772
|
output: JsonValueSchema
|
|
2607
2773
|
});
|
|
2608
2774
|
var AgentToolCallErrorSchema = AgentToolCallBaseSchema.extend({
|
|
2609
|
-
state:
|
|
2610
|
-
errorText:
|
|
2775
|
+
state: z8.literal("output-error"),
|
|
2776
|
+
errorText: z8.string()
|
|
2611
2777
|
});
|
|
2612
|
-
var AgentMessagePartSchema =
|
|
2778
|
+
var AgentMessagePartSchema = z8.union([
|
|
2613
2779
|
AgentTextPartSchema,
|
|
2614
2780
|
AgentReasoningPartSchema,
|
|
2615
2781
|
AgentStepStartPartSchema,
|
|
@@ -2618,107 +2784,100 @@ var AgentMessagePartSchema = z7.union([
|
|
|
2618
2784
|
AgentToolCallOutputSchema,
|
|
2619
2785
|
AgentToolCallErrorSchema
|
|
2620
2786
|
]);
|
|
2621
|
-
var AgentRunDiagnosticSchema =
|
|
2622
|
-
code:
|
|
2623
|
-
severity:
|
|
2624
|
-
scope:
|
|
2625
|
-
path:
|
|
2626
|
-
message:
|
|
2627
|
-
});
|
|
2628
|
-
var AgentMessageSchema =
|
|
2629
|
-
id:
|
|
2630
|
-
projectId:
|
|
2631
|
-
threadId:
|
|
2632
|
-
runId:
|
|
2787
|
+
var AgentRunDiagnosticSchema = z8.object({
|
|
2788
|
+
code: z8.enum(AGENT_RUN_DIAGNOSTIC_CODES),
|
|
2789
|
+
severity: z8.enum(["warning", "error"]),
|
|
2790
|
+
scope: z8.literal("output"),
|
|
2791
|
+
path: z8.string().optional(),
|
|
2792
|
+
message: z8.string()
|
|
2793
|
+
});
|
|
2794
|
+
var AgentMessageSchema = z8.object({
|
|
2795
|
+
id: z8.string(),
|
|
2796
|
+
projectId: z8.string(),
|
|
2797
|
+
threadId: z8.string(),
|
|
2798
|
+
runId: z8.string().nullable(),
|
|
2633
2799
|
role: AgentMessageRoleSchema,
|
|
2634
2800
|
authorPrincipal: AgentPrincipalSchema.optional(),
|
|
2635
|
-
seq:
|
|
2636
|
-
parts:
|
|
2637
|
-
annotations:
|
|
2801
|
+
seq: z8.number(),
|
|
2802
|
+
parts: z8.array(AgentMessagePartSchema),
|
|
2803
|
+
annotations: z8.array(AgentRunDiagnosticSchema),
|
|
2638
2804
|
metadata: JsonValueSchema.optional(),
|
|
2639
|
-
contentVersion:
|
|
2640
|
-
createdAt:
|
|
2641
|
-
completedAt:
|
|
2805
|
+
contentVersion: z8.number(),
|
|
2806
|
+
createdAt: z8.string(),
|
|
2807
|
+
completedAt: z8.string().optional()
|
|
2642
2808
|
});
|
|
2643
|
-
var AgentMessagesQuerySchema =
|
|
2809
|
+
var AgentMessagesQuerySchema = z8.object({
|
|
2644
2810
|
role: AgentMessageRoleSchema.optional(),
|
|
2645
|
-
limit:
|
|
2646
|
-
offset:
|
|
2647
|
-
order:
|
|
2811
|
+
limit: z8.string().optional(),
|
|
2812
|
+
offset: z8.string().optional(),
|
|
2813
|
+
order: z8.enum(["asc", "desc"]).optional()
|
|
2648
2814
|
});
|
|
2649
|
-
var AgentMessageListResponseSchema =
|
|
2650
|
-
messages:
|
|
2651
|
-
hasMore:
|
|
2652
|
-
total:
|
|
2815
|
+
var AgentMessageListResponseSchema = z8.object({
|
|
2816
|
+
messages: z8.array(AgentMessageSchema),
|
|
2817
|
+
hasMore: z8.boolean(),
|
|
2818
|
+
total: z8.number()
|
|
2653
2819
|
});
|
|
2654
|
-
var PostAgentMessageBodySchema =
|
|
2655
|
-
text:
|
|
2656
|
-
attachments:
|
|
2657
|
-
context:
|
|
2658
|
-
messageId:
|
|
2820
|
+
var PostAgentMessageBodySchema = z8.object({
|
|
2821
|
+
text: z8.string().trim().min(1),
|
|
2822
|
+
attachments: z8.array(FileRefSchema).optional(),
|
|
2823
|
+
context: z8.array(AgentContextEntryInputSchema).max(MAX_AGENT_CONTEXT_ENTRIES).optional(),
|
|
2824
|
+
messageId: z8.string().trim().min(1).optional()
|
|
2659
2825
|
});
|
|
2660
|
-
var CancelAgentRunBodySchema =
|
|
2661
|
-
runId:
|
|
2826
|
+
var CancelAgentRunBodySchema = z8.object({
|
|
2827
|
+
runId: z8.string().trim().min(1)
|
|
2662
2828
|
});
|
|
2663
|
-
var AgentRunStatusSchema =
|
|
2829
|
+
var AgentRunStatusSchema = z8.enum([
|
|
2664
2830
|
"queued",
|
|
2665
2831
|
"running",
|
|
2666
2832
|
"succeeded",
|
|
2667
2833
|
"failed",
|
|
2668
2834
|
"cancelled"
|
|
2669
2835
|
]);
|
|
2670
|
-
var AgentRunFinishReasonSchema =
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
"unknown"
|
|
2678
|
-
]);
|
|
2679
|
-
var AgentRunSchema = z7.object({
|
|
2680
|
-
id: z7.string(),
|
|
2681
|
-
projectId: z7.string(),
|
|
2682
|
-
threadId: z7.string(),
|
|
2683
|
-
agentId: z7.string(),
|
|
2684
|
-
triggerMessageId: z7.string(),
|
|
2836
|
+
var AgentRunFinishReasonSchema = z8.enum(AGENT_RUN_FINISH_REASONS);
|
|
2837
|
+
var AgentRunSchema = z8.object({
|
|
2838
|
+
id: z8.string(),
|
|
2839
|
+
projectId: z8.string(),
|
|
2840
|
+
threadId: z8.string(),
|
|
2841
|
+
agentId: z8.string(),
|
|
2842
|
+
triggerMessageId: z8.string(),
|
|
2685
2843
|
requestedBy: AgentAuthorizablePrincipalSchema.optional(),
|
|
2686
2844
|
status: AgentRunStatusSchema,
|
|
2687
|
-
modelId:
|
|
2845
|
+
modelId: z8.string().optional(),
|
|
2688
2846
|
finishReason: AgentRunFinishReasonSchema.optional(),
|
|
2689
2847
|
usage: AiUsageSummarySchema.optional(),
|
|
2690
|
-
|
|
2848
|
+
cost: AiCostSummarySchema.optional(),
|
|
2849
|
+
diagnostics: z8.array(AgentRunDiagnosticSchema).optional(),
|
|
2691
2850
|
error: AgentRunFailureSchema.optional(),
|
|
2692
|
-
attempt:
|
|
2693
|
-
streamId:
|
|
2694
|
-
createdAt:
|
|
2695
|
-
startedAt:
|
|
2696
|
-
completedAt:
|
|
2851
|
+
attempt: z8.number(),
|
|
2852
|
+
streamId: z8.string(),
|
|
2853
|
+
createdAt: z8.string(),
|
|
2854
|
+
startedAt: z8.string().optional(),
|
|
2855
|
+
completedAt: z8.string().optional()
|
|
2697
2856
|
});
|
|
2698
|
-
var PostAgentMessageResponseSchema =
|
|
2857
|
+
var PostAgentMessageResponseSchema = z8.object({
|
|
2699
2858
|
run: AgentRunSchema
|
|
2700
2859
|
});
|
|
2701
|
-
var CancelAgentRunResponseSchema =
|
|
2860
|
+
var CancelAgentRunResponseSchema = z8.object({
|
|
2702
2861
|
run: AgentRunSchema
|
|
2703
2862
|
});
|
|
2704
|
-
var RetryAgentRunResponseSchema =
|
|
2863
|
+
var RetryAgentRunResponseSchema = z8.object({
|
|
2705
2864
|
run: AgentRunSchema
|
|
2706
2865
|
});
|
|
2707
|
-
var AgentRunListQuerySchema =
|
|
2866
|
+
var AgentRunListQuerySchema = z8.object({
|
|
2708
2867
|
status: AgentRunStatusSchema.optional(),
|
|
2709
|
-
limit:
|
|
2710
|
-
offset:
|
|
2711
|
-
order:
|
|
2868
|
+
limit: z8.string().optional(),
|
|
2869
|
+
offset: z8.string().optional(),
|
|
2870
|
+
order: z8.enum(["asc", "desc"]).optional()
|
|
2712
2871
|
});
|
|
2713
|
-
var AgentRunListResponseSchema =
|
|
2714
|
-
runs:
|
|
2715
|
-
hasMore:
|
|
2716
|
-
total:
|
|
2872
|
+
var AgentRunListResponseSchema = z8.object({
|
|
2873
|
+
runs: z8.array(AgentRunSchema),
|
|
2874
|
+
hasMore: z8.boolean(),
|
|
2875
|
+
total: z8.number()
|
|
2717
2876
|
});
|
|
2718
2877
|
|
|
2719
2878
|
// src/routes/agents.ts
|
|
2720
2879
|
var AgentMessageFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
2721
|
-
path:
|
|
2880
|
+
path: z9.string().min(1).regex(/^\/parts(?:\/|$)/, "Agent message file content paths must start with /parts/")
|
|
2722
2881
|
});
|
|
2723
2882
|
function serializeAgent(agent) {
|
|
2724
2883
|
return AgentCatalogItemSchema.parse({
|
|
@@ -2775,6 +2934,7 @@ function serializeAgentRun(run) {
|
|
|
2775
2934
|
modelId: run.modelId,
|
|
2776
2935
|
finishReason: run.finishReason,
|
|
2777
2936
|
usage: run.usage,
|
|
2937
|
+
cost: run.cost,
|
|
2778
2938
|
diagnostics: run.diagnostics,
|
|
2779
2939
|
error: run.error,
|
|
2780
2940
|
attempt: run.attempt,
|
|
@@ -3239,7 +3399,7 @@ function registerAgentRoutes(app, host) {
|
|
|
3239
3399
|
return handleAgentRouteError(error, set);
|
|
3240
3400
|
}
|
|
3241
3401
|
}, {
|
|
3242
|
-
params: AgentRunParamsSchema.extend({ threadId:
|
|
3402
|
+
params: AgentRunParamsSchema.extend({ threadId: z9.string().trim().min(1) }),
|
|
3243
3403
|
response: {
|
|
3244
3404
|
202: RetryAgentRunResponseSchema,
|
|
3245
3405
|
400: ErrorResponseSchema,
|
|
@@ -3327,6 +3487,143 @@ function registerAgentRoutes(app, host) {
|
|
|
3327
3487
|
});
|
|
3328
3488
|
}
|
|
3329
3489
|
|
|
3490
|
+
// src/routes/ai-accounting.ts
|
|
3491
|
+
function serializeAggregate(aggregate) {
|
|
3492
|
+
return {
|
|
3493
|
+
modelCallCount: aggregate.modelCallCount,
|
|
3494
|
+
usage: aggregate.usage,
|
|
3495
|
+
costs: aggregate.costs
|
|
3496
|
+
};
|
|
3497
|
+
}
|
|
3498
|
+
function serializeOverview(overview) {
|
|
3499
|
+
return AiAccountingOverviewResponseSchema.parse({
|
|
3500
|
+
range: {
|
|
3501
|
+
from: overview.range.from.toISOString(),
|
|
3502
|
+
to: overview.range.to.toISOString()
|
|
3503
|
+
},
|
|
3504
|
+
bucket: overview.bucket,
|
|
3505
|
+
totals: serializeAggregate(overview.totals),
|
|
3506
|
+
series: overview.series.map((period) => ({
|
|
3507
|
+
start: period.start.toISOString(),
|
|
3508
|
+
end: period.end.toISOString(),
|
|
3509
|
+
...serializeAggregate(period)
|
|
3510
|
+
})),
|
|
3511
|
+
models: overview.models.map((model) => ({
|
|
3512
|
+
providerId: model.providerId,
|
|
3513
|
+
modelId: model.modelId,
|
|
3514
|
+
...serializeAggregate(model)
|
|
3515
|
+
})),
|
|
3516
|
+
agents: overview.agents.map((agent) => ({
|
|
3517
|
+
agentId: agent.agentId,
|
|
3518
|
+
...serializeAggregate(agent)
|
|
3519
|
+
})),
|
|
3520
|
+
workflows: overview.workflows.map((workflow) => ({
|
|
3521
|
+
workflowId: workflow.workflowId,
|
|
3522
|
+
...serializeAggregate(workflow)
|
|
3523
|
+
}))
|
|
3524
|
+
});
|
|
3525
|
+
}
|
|
3526
|
+
function serializeModelCall(item) {
|
|
3527
|
+
return AiModelCallAccountingListResponseSchema.shape.items.element.parse({
|
|
3528
|
+
usage: {
|
|
3529
|
+
id: item.usage.id,
|
|
3530
|
+
executionId: item.usage.executionId,
|
|
3531
|
+
attempt: item.usage.attempt,
|
|
3532
|
+
callId: item.usage.callId,
|
|
3533
|
+
providerId: item.usage.providerId,
|
|
3534
|
+
requestedModelId: item.usage.requestedModelId,
|
|
3535
|
+
responseModelId: item.usage.responseModelId,
|
|
3536
|
+
responseId: item.usage.responseId,
|
|
3537
|
+
usage: item.usage.usage,
|
|
3538
|
+
occurredAt: item.usage.occurredAt.toISOString(),
|
|
3539
|
+
recordedAt: item.usage.recordedAt.toISOString()
|
|
3540
|
+
},
|
|
3541
|
+
attribution: item.attribution,
|
|
3542
|
+
cost: item.cost === undefined ? undefined : {
|
|
3543
|
+
...item.cost,
|
|
3544
|
+
priceSource: {
|
|
3545
|
+
...item.cost.priceSource,
|
|
3546
|
+
observedAt: item.cost.priceSource.observedAt.toISOString()
|
|
3547
|
+
},
|
|
3548
|
+
ratedAt: item.cost.ratedAt.toISOString()
|
|
3549
|
+
},
|
|
3550
|
+
valuationStatus: item.valuationStatus
|
|
3551
|
+
});
|
|
3552
|
+
}
|
|
3553
|
+
function registerAiAccountingRoutes(app, host) {
|
|
3554
|
+
app.get("/api/ai/accounting/overview", async ({ query, set }) => {
|
|
3555
|
+
try {
|
|
3556
|
+
const parsed = AiAccountingOverviewQuerySchema.parse(query);
|
|
3557
|
+
const storage = host.storage.aiCosts;
|
|
3558
|
+
if (!storage)
|
|
3559
|
+
return unconfiguredStorageResponse2(set, "AI cost storage");
|
|
3560
|
+
const overview = await storage.queryProjectOverview({
|
|
3561
|
+
projectId: host.id,
|
|
3562
|
+
from: new Date(parsed.from),
|
|
3563
|
+
to: new Date(parsed.to),
|
|
3564
|
+
bucket: parsed.bucket,
|
|
3565
|
+
providerId: parsed.providerId,
|
|
3566
|
+
modelId: parsed.modelId
|
|
3567
|
+
});
|
|
3568
|
+
return serializeOverview(overview);
|
|
3569
|
+
} catch (error) {
|
|
3570
|
+
return handleRouteError(error, set);
|
|
3571
|
+
}
|
|
3572
|
+
}, {
|
|
3573
|
+
query: AiAccountingOverviewQuerySchema,
|
|
3574
|
+
response: {
|
|
3575
|
+
200: AiAccountingOverviewResponseSchema,
|
|
3576
|
+
400: ErrorResponseSchema,
|
|
3577
|
+
501: ErrorResponseSchema
|
|
3578
|
+
},
|
|
3579
|
+
detail: {
|
|
3580
|
+
summary: "Get project AI usage and cost analytics",
|
|
3581
|
+
tags: [OPENAPI_TAGS.aiAccounting.name],
|
|
3582
|
+
operationId: "getAiAccountingOverview"
|
|
3583
|
+
}
|
|
3584
|
+
});
|
|
3585
|
+
app.get("/api/ai/model-calls", async ({ query, set }) => {
|
|
3586
|
+
try {
|
|
3587
|
+
const parsed = AiModelCallAccountingListQuerySchema.parse(query);
|
|
3588
|
+
const storage = host.storage.aiCosts;
|
|
3589
|
+
if (!storage)
|
|
3590
|
+
return unconfiguredStorageResponse2(set, "AI cost storage");
|
|
3591
|
+
const result = await storage.listModelCalls({
|
|
3592
|
+
projectId: host.id,
|
|
3593
|
+
from: new Date(parsed.from),
|
|
3594
|
+
to: new Date(parsed.to),
|
|
3595
|
+
providerId: parsed.providerId,
|
|
3596
|
+
modelId: parsed.modelId,
|
|
3597
|
+
executionId: parsed.executionId,
|
|
3598
|
+
valuationStatus: parsed.valuationStatus,
|
|
3599
|
+
limit: parseOptionalInt(parsed.limit),
|
|
3600
|
+
offset: parseOptionalInt(parsed.offset)
|
|
3601
|
+
});
|
|
3602
|
+
const items = result.items.map(serializeModelCall);
|
|
3603
|
+
return AiModelCallAccountingListResponseSchema.parse({
|
|
3604
|
+
items,
|
|
3605
|
+
hasMore: result.hasMore,
|
|
3606
|
+
total: result.total
|
|
3607
|
+
});
|
|
3608
|
+
} catch (error) {
|
|
3609
|
+
return handleRouteError(error, set);
|
|
3610
|
+
}
|
|
3611
|
+
}, {
|
|
3612
|
+
query: AiModelCallAccountingListQuerySchema,
|
|
3613
|
+
response: {
|
|
3614
|
+
200: AiModelCallAccountingListResponseSchema,
|
|
3615
|
+
400: ErrorResponseSchema,
|
|
3616
|
+
501: ErrorResponseSchema
|
|
3617
|
+
},
|
|
3618
|
+
detail: {
|
|
3619
|
+
summary: "List project AI model-call accounting records",
|
|
3620
|
+
tags: [OPENAPI_TAGS.aiAccounting.name],
|
|
3621
|
+
operationId: "listAiModelCalls"
|
|
3622
|
+
}
|
|
3623
|
+
});
|
|
3624
|
+
return app;
|
|
3625
|
+
}
|
|
3626
|
+
|
|
3330
3627
|
// src/routes/connector-connection-runs.ts
|
|
3331
3628
|
import { getConnectorConnectionCallbackProcess } from "@sixb/core/internal/connector-connections";
|
|
3332
3629
|
|
|
@@ -3406,7 +3703,7 @@ import { createSixbError as createSixbError2 } from "@sixb/core/internal/errors"
|
|
|
3406
3703
|
import {
|
|
3407
3704
|
CONNECTOR_CONNECTION_RUN_FAILURE_CODES
|
|
3408
3705
|
} from "@sixb/core/storage";
|
|
3409
|
-
import { z as
|
|
3706
|
+
import { z as z10 } from "zod";
|
|
3410
3707
|
var CONNECTOR_HTTP_ERROR_CODES = [
|
|
3411
3708
|
"internal.unexpected",
|
|
3412
3709
|
"connector.adapter_invalid",
|
|
@@ -3447,114 +3744,114 @@ var ConnectorUnavailableResponseSchema = connectorRouteErrorResponseSchema([
|
|
|
3447
3744
|
"connector.credentials_unavailable",
|
|
3448
3745
|
"connector.provider_unavailable"
|
|
3449
3746
|
]);
|
|
3450
|
-
var ConnectorParamsSchema =
|
|
3451
|
-
connectorId:
|
|
3747
|
+
var ConnectorParamsSchema = z10.object({
|
|
3748
|
+
connectorId: z10.string().min(1)
|
|
3452
3749
|
});
|
|
3453
3750
|
var ConnectorConnectionParamsSchema = ConnectorParamsSchema.extend({
|
|
3454
|
-
connectionId:
|
|
3751
|
+
connectionId: z10.string().min(1)
|
|
3455
3752
|
});
|
|
3456
3753
|
var ConnectorConnectionRunParamsSchema = ConnectorParamsSchema.extend({
|
|
3457
|
-
runId:
|
|
3458
|
-
});
|
|
3459
|
-
var ConnectorWebhookSchema =
|
|
3460
|
-
id:
|
|
3461
|
-
method:
|
|
3462
|
-
route:
|
|
3463
|
-
bodyFormat:
|
|
3464
|
-
hasVerify:
|
|
3465
|
-
hasIdempotency:
|
|
3466
|
-
});
|
|
3467
|
-
var ConnectorSchema =
|
|
3468
|
-
id:
|
|
3469
|
-
type:
|
|
3470
|
-
connection:
|
|
3471
|
-
syncIds:
|
|
3472
|
-
webhooks:
|
|
3473
|
-
});
|
|
3474
|
-
var ConnectorAccountSchema =
|
|
3475
|
-
id:
|
|
3476
|
-
label:
|
|
3477
|
-
description:
|
|
3478
|
-
avatarUrl:
|
|
3479
|
-
});
|
|
3480
|
-
var ConnectorConnectionSchema =
|
|
3481
|
-
id:
|
|
3482
|
-
connectorId:
|
|
3483
|
-
owner:
|
|
3484
|
-
slot:
|
|
3754
|
+
runId: z10.string().min(1)
|
|
3755
|
+
});
|
|
3756
|
+
var ConnectorWebhookSchema = z10.object({
|
|
3757
|
+
id: z10.string(),
|
|
3758
|
+
method: z10.literal("POST"),
|
|
3759
|
+
route: z10.string(),
|
|
3760
|
+
bodyFormat: z10.enum(["json", "text", "raw"]),
|
|
3761
|
+
hasVerify: z10.boolean(),
|
|
3762
|
+
hasIdempotency: z10.boolean()
|
|
3763
|
+
});
|
|
3764
|
+
var ConnectorSchema = z10.object({
|
|
3765
|
+
id: z10.string(),
|
|
3766
|
+
type: z10.string(),
|
|
3767
|
+
connection: z10.object({ authentication: z10.literal("oauth2") }).nullable(),
|
|
3768
|
+
syncIds: z10.array(z10.string()),
|
|
3769
|
+
webhooks: z10.array(ConnectorWebhookSchema)
|
|
3770
|
+
});
|
|
3771
|
+
var ConnectorAccountSchema = z10.object({
|
|
3772
|
+
id: z10.string(),
|
|
3773
|
+
label: z10.string(),
|
|
3774
|
+
description: z10.string().optional(),
|
|
3775
|
+
avatarUrl: z10.string().url().optional()
|
|
3776
|
+
});
|
|
3777
|
+
var ConnectorConnectionSchema = z10.object({
|
|
3778
|
+
id: z10.string(),
|
|
3779
|
+
connectorId: z10.string(),
|
|
3780
|
+
owner: z10.object({ type: z10.literal("project") }),
|
|
3781
|
+
slot: z10.string(),
|
|
3485
3782
|
account: ConnectorAccountSchema,
|
|
3486
|
-
status:
|
|
3783
|
+
status: z10.enum(["connected", "needs_reauthorization", "disconnected"])
|
|
3487
3784
|
});
|
|
3488
3785
|
var ConnectorConnectionRunFailureSchema = sixbFailureSchema(CONNECTOR_CONNECTION_RUN_FAILURE_CODES);
|
|
3489
|
-
var ConnectorConnectionRunBaseSchema =
|
|
3490
|
-
id:
|
|
3491
|
-
connectorId:
|
|
3492
|
-
kind:
|
|
3493
|
-
owner:
|
|
3494
|
-
slot:
|
|
3495
|
-
createdAt:
|
|
3496
|
-
updatedAt:
|
|
3497
|
-
});
|
|
3498
|
-
var ConnectorConnectionRunSchema =
|
|
3786
|
+
var ConnectorConnectionRunBaseSchema = z10.object({
|
|
3787
|
+
id: z10.string(),
|
|
3788
|
+
connectorId: z10.string(),
|
|
3789
|
+
kind: z10.enum(["connect", "reauthorize"]),
|
|
3790
|
+
owner: z10.object({ type: z10.literal("project") }),
|
|
3791
|
+
slot: z10.string(),
|
|
3792
|
+
createdAt: z10.string().datetime(),
|
|
3793
|
+
updatedAt: z10.string().datetime()
|
|
3794
|
+
});
|
|
3795
|
+
var ConnectorConnectionRunSchema = z10.union([
|
|
3499
3796
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3500
|
-
status:
|
|
3501
|
-
waitingFor:
|
|
3502
|
-
expiresAt:
|
|
3797
|
+
status: z10.literal("waiting"),
|
|
3798
|
+
waitingFor: z10.literal("provider_authorization"),
|
|
3799
|
+
expiresAt: z10.string().datetime()
|
|
3503
3800
|
}),
|
|
3504
3801
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3505
|
-
status:
|
|
3802
|
+
status: z10.literal("running")
|
|
3506
3803
|
}),
|
|
3507
3804
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3508
|
-
status:
|
|
3509
|
-
waitingFor:
|
|
3510
|
-
accounts:
|
|
3511
|
-
expiresAt:
|
|
3805
|
+
status: z10.literal("waiting"),
|
|
3806
|
+
waitingFor: z10.literal("account_selection"),
|
|
3807
|
+
accounts: z10.array(ConnectorAccountSchema),
|
|
3808
|
+
expiresAt: z10.string().datetime()
|
|
3512
3809
|
}),
|
|
3513
3810
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3514
|
-
status:
|
|
3515
|
-
connections:
|
|
3516
|
-
finishedAt:
|
|
3811
|
+
status: z10.literal("succeeded"),
|
|
3812
|
+
connections: z10.array(ConnectorConnectionSchema),
|
|
3813
|
+
finishedAt: z10.string().datetime()
|
|
3517
3814
|
}),
|
|
3518
3815
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3519
|
-
status:
|
|
3816
|
+
status: z10.literal("failed"),
|
|
3520
3817
|
error: ConnectorConnectionRunFailureSchema,
|
|
3521
|
-
finishedAt:
|
|
3818
|
+
finishedAt: z10.string().datetime()
|
|
3522
3819
|
}),
|
|
3523
3820
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3524
|
-
status:
|
|
3525
|
-
finishedAt:
|
|
3821
|
+
status: z10.enum(["cancelled", "expired"]),
|
|
3822
|
+
finishedAt: z10.string().datetime()
|
|
3526
3823
|
})
|
|
3527
3824
|
]);
|
|
3528
|
-
var StartConnectorConnectionRunBodySchema =
|
|
3529
|
-
slot:
|
|
3530
|
-
returnTo:
|
|
3531
|
-
});
|
|
3532
|
-
var AddConnectorConnectionBodySchema =
|
|
3533
|
-
slot:
|
|
3534
|
-
});
|
|
3535
|
-
var StartConnectorReauthorizationBodySchema =
|
|
3536
|
-
returnTo:
|
|
3537
|
-
});
|
|
3538
|
-
var StartConnectorConnectionRunResponseSchema =
|
|
3539
|
-
runId:
|
|
3540
|
-
authorizationUrl:
|
|
3541
|
-
affectedConnections:
|
|
3542
|
-
});
|
|
3543
|
-
var SelectConnectorConnectionRunAccountBodySchema =
|
|
3544
|
-
accountId:
|
|
3545
|
-
replace:
|
|
3546
|
-
});
|
|
3547
|
-
var ConnectorOAuthCallbackQuerySchema =
|
|
3548
|
-
state:
|
|
3549
|
-
code:
|
|
3550
|
-
auth_code:
|
|
3551
|
-
error:
|
|
3825
|
+
var StartConnectorConnectionRunBodySchema = z10.object({
|
|
3826
|
+
slot: z10.string().trim().min(1),
|
|
3827
|
+
returnTo: z10.string().url()
|
|
3828
|
+
});
|
|
3829
|
+
var AddConnectorConnectionBodySchema = z10.object({
|
|
3830
|
+
slot: z10.string().trim().min(1)
|
|
3831
|
+
});
|
|
3832
|
+
var StartConnectorReauthorizationBodySchema = z10.object({
|
|
3833
|
+
returnTo: z10.string().url()
|
|
3834
|
+
});
|
|
3835
|
+
var StartConnectorConnectionRunResponseSchema = z10.object({
|
|
3836
|
+
runId: z10.string(),
|
|
3837
|
+
authorizationUrl: z10.string().url(),
|
|
3838
|
+
affectedConnections: z10.array(ConnectorConnectionSchema)
|
|
3839
|
+
});
|
|
3840
|
+
var SelectConnectorConnectionRunAccountBodySchema = z10.object({
|
|
3841
|
+
accountId: z10.string().trim().min(1),
|
|
3842
|
+
replace: z10.boolean().optional()
|
|
3843
|
+
});
|
|
3844
|
+
var ConnectorOAuthCallbackQuerySchema = z10.object({
|
|
3845
|
+
state: z10.string().min(1),
|
|
3846
|
+
code: z10.string().min(1).optional(),
|
|
3847
|
+
auth_code: z10.string().min(1).optional(),
|
|
3848
|
+
error: z10.string().min(1).optional()
|
|
3552
3849
|
}).refine((query) => [query.code, query.auth_code, query.error].filter(Boolean).length === 1, {
|
|
3553
3850
|
message: "OAuth callback must contain exactly one of code, auth_code, or error."
|
|
3554
3851
|
}).transform(({ auth_code, ...query }) => ({ ...query, code: query.code ?? auth_code }));
|
|
3555
3852
|
function connectorRouteErrorResponseSchema(codes) {
|
|
3556
3853
|
return ErrorResponseSchema.extend({
|
|
3557
|
-
code:
|
|
3854
|
+
code: z10.enum(codes).optional().describe("Stable machine-readable failure code for programmatic handling.")
|
|
3558
3855
|
});
|
|
3559
3856
|
}
|
|
3560
3857
|
|
|
@@ -3998,25 +4295,25 @@ function registerConnectorRoutes(app, host) {
|
|
|
3998
4295
|
import { createSixbError as createSixbError3 } from "@sixb/core/internal/errors";
|
|
3999
4296
|
|
|
4000
4297
|
// src/schemas/datasets.ts
|
|
4001
|
-
import { z as
|
|
4002
|
-
var DatasetParamsSchema =
|
|
4003
|
-
datasetId:
|
|
4298
|
+
import { z as z11 } from "zod";
|
|
4299
|
+
var DatasetParamsSchema = z11.object({
|
|
4300
|
+
datasetId: z11.string().min(1)
|
|
4004
4301
|
});
|
|
4005
4302
|
var DatasetVersionParamsSchema = DatasetParamsSchema.extend({
|
|
4006
|
-
versionId:
|
|
4303
|
+
versionId: z11.string().min(1)
|
|
4007
4304
|
});
|
|
4008
|
-
var DatasetVersionsQuerySchema =
|
|
4009
|
-
limit:
|
|
4305
|
+
var DatasetVersionsQuerySchema = z11.object({
|
|
4306
|
+
limit: z11.string().optional()
|
|
4010
4307
|
});
|
|
4011
|
-
var DatasetRowsQuerySchema =
|
|
4012
|
-
versionId:
|
|
4013
|
-
columns:
|
|
4014
|
-
limit:
|
|
4015
|
-
offset:
|
|
4308
|
+
var DatasetRowsQuerySchema = z11.object({
|
|
4309
|
+
versionId: z11.string().optional(),
|
|
4310
|
+
columns: z11.string().optional(),
|
|
4311
|
+
limit: z11.string().optional(),
|
|
4312
|
+
offset: z11.string().optional()
|
|
4016
4313
|
});
|
|
4017
|
-
var DatasetColumnSchema =
|
|
4018
|
-
name:
|
|
4019
|
-
type:
|
|
4314
|
+
var DatasetColumnSchema = z11.object({
|
|
4315
|
+
name: z11.string(),
|
|
4316
|
+
type: z11.enum([
|
|
4020
4317
|
"string",
|
|
4021
4318
|
"boolean",
|
|
4022
4319
|
"int64",
|
|
@@ -4027,70 +4324,70 @@ var DatasetColumnSchema = z10.object({
|
|
|
4027
4324
|
"json",
|
|
4028
4325
|
"fileRef"
|
|
4029
4326
|
]),
|
|
4030
|
-
nullable:
|
|
4327
|
+
nullable: z11.boolean().optional()
|
|
4031
4328
|
});
|
|
4032
|
-
var DatasetSchema =
|
|
4033
|
-
columns:
|
|
4329
|
+
var DatasetSchema = z11.object({
|
|
4330
|
+
columns: z11.array(DatasetColumnSchema)
|
|
4034
4331
|
});
|
|
4035
|
-
var DatasetDefinitionSchema =
|
|
4036
|
-
id:
|
|
4037
|
-
description:
|
|
4038
|
-
primaryKey:
|
|
4039
|
-
partitionBy:
|
|
4332
|
+
var DatasetDefinitionSchema = z11.object({
|
|
4333
|
+
id: z11.string(),
|
|
4334
|
+
description: z11.string().optional(),
|
|
4335
|
+
primaryKey: z11.union([z11.string(), z11.array(z11.string()).min(2)]).optional(),
|
|
4336
|
+
partitionBy: z11.array(z11.string()).optional(),
|
|
4040
4337
|
schema: DatasetSchema
|
|
4041
4338
|
});
|
|
4042
|
-
var DatasetVersionRefSchema =
|
|
4043
|
-
datasetId:
|
|
4044
|
-
versionId:
|
|
4045
|
-
});
|
|
4046
|
-
var DatasetProducerSchema =
|
|
4047
|
-
kind:
|
|
4048
|
-
id:
|
|
4049
|
-
runId:
|
|
4050
|
-
});
|
|
4051
|
-
var DatasetVersionSchema =
|
|
4052
|
-
datasetId:
|
|
4053
|
-
versionId:
|
|
4054
|
-
parentVersionId:
|
|
4055
|
-
mode:
|
|
4056
|
-
createdAt:
|
|
4339
|
+
var DatasetVersionRefSchema = z11.object({
|
|
4340
|
+
datasetId: z11.string(),
|
|
4341
|
+
versionId: z11.string()
|
|
4342
|
+
});
|
|
4343
|
+
var DatasetProducerSchema = z11.object({
|
|
4344
|
+
kind: z11.enum(["sync", "pipeline"]),
|
|
4345
|
+
id: z11.string().optional(),
|
|
4346
|
+
runId: z11.string().optional()
|
|
4347
|
+
});
|
|
4348
|
+
var DatasetVersionSchema = z11.object({
|
|
4349
|
+
datasetId: z11.string(),
|
|
4350
|
+
versionId: z11.string(),
|
|
4351
|
+
parentVersionId: z11.string().optional(),
|
|
4352
|
+
mode: z11.enum(["snapshot", "append", "merge", "schema"]),
|
|
4353
|
+
createdAt: z11.string(),
|
|
4057
4354
|
schema: DatasetSchema,
|
|
4058
4355
|
producer: DatasetProducerSchema.optional(),
|
|
4059
|
-
inputs:
|
|
4060
|
-
rowCount:
|
|
4061
|
-
sizeBytes:
|
|
4356
|
+
inputs: z11.array(DatasetVersionRefSchema).optional(),
|
|
4357
|
+
rowCount: z11.number().optional(),
|
|
4358
|
+
sizeBytes: z11.number().optional()
|
|
4062
4359
|
});
|
|
4063
|
-
var DatasetLatestVersionSummarySchema =
|
|
4064
|
-
datasetId:
|
|
4065
|
-
versionId:
|
|
4066
|
-
mode:
|
|
4067
|
-
createdAt:
|
|
4068
|
-
rowCount:
|
|
4360
|
+
var DatasetLatestVersionSummarySchema = z11.object({
|
|
4361
|
+
datasetId: z11.string(),
|
|
4362
|
+
versionId: z11.string(),
|
|
4363
|
+
mode: z11.enum(["snapshot", "append", "merge", "schema"]),
|
|
4364
|
+
createdAt: z11.string(),
|
|
4365
|
+
rowCount: z11.number().optional()
|
|
4069
4366
|
});
|
|
4070
4367
|
var DatasetCatalogItemSchema = DatasetDefinitionSchema.extend({
|
|
4071
|
-
kind:
|
|
4072
|
-
materialized:
|
|
4368
|
+
kind: z11.literal("dataset"),
|
|
4369
|
+
materialized: z11.boolean(),
|
|
4073
4370
|
latestVersion: DatasetLatestVersionSummarySchema.nullable(),
|
|
4074
|
-
syncIds:
|
|
4075
|
-
sourcePipelineIds:
|
|
4076
|
-
targetPipelineIds:
|
|
4077
|
-
projectionIds:
|
|
4078
|
-
});
|
|
4079
|
-
var DatasetVersionListResponseSchema =
|
|
4080
|
-
versions:
|
|
4081
|
-
count:
|
|
4082
|
-
});
|
|
4083
|
-
var DatasetRowsResponseSchema =
|
|
4084
|
-
datasetId:
|
|
4085
|
-
versionId:
|
|
4371
|
+
syncIds: z11.array(z11.string()),
|
|
4372
|
+
sourcePipelineIds: z11.array(z11.string()),
|
|
4373
|
+
targetPipelineIds: z11.array(z11.string()),
|
|
4374
|
+
projectionIds: z11.array(z11.string())
|
|
4375
|
+
});
|
|
4376
|
+
var DatasetVersionListResponseSchema = z11.object({
|
|
4377
|
+
versions: z11.array(DatasetVersionSchema),
|
|
4378
|
+
count: z11.number()
|
|
4379
|
+
});
|
|
4380
|
+
var DatasetRowsResponseSchema = z11.object({
|
|
4381
|
+
datasetId: z11.string(),
|
|
4382
|
+
versionId: z11.string(),
|
|
4086
4383
|
version: DatasetVersionSchema,
|
|
4087
|
-
columns:
|
|
4088
|
-
rows:
|
|
4089
|
-
count:
|
|
4090
|
-
limit:
|
|
4091
|
-
offset:
|
|
4092
|
-
total:
|
|
4093
|
-
hasMore:
|
|
4384
|
+
columns: z11.array(z11.string()),
|
|
4385
|
+
rows: z11.array(z11.record(z11.unknown())),
|
|
4386
|
+
count: z11.number(),
|
|
4387
|
+
limit: z11.number(),
|
|
4388
|
+
offset: z11.number(),
|
|
4389
|
+
total: z11.number().optional(),
|
|
4390
|
+
hasMore: z11.boolean()
|
|
4094
4391
|
});
|
|
4095
4392
|
|
|
4096
4393
|
// src/routes/datasets.ts
|
|
@@ -4393,44 +4690,44 @@ import {
|
|
|
4393
4690
|
EVENT_DEFINITIONS,
|
|
4394
4691
|
isOntologyFactType
|
|
4395
4692
|
} from "@sixb/core/internal/events";
|
|
4396
|
-
import { z as
|
|
4693
|
+
import { z as z13 } from "zod";
|
|
4397
4694
|
|
|
4398
4695
|
// src/schemas/event-payloads.ts
|
|
4399
|
-
import { z as
|
|
4400
|
-
var PropertyChangeSchema =
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
operation:
|
|
4696
|
+
import { z as z12 } from "zod";
|
|
4697
|
+
var PropertyChangeSchema = z12.discriminatedUnion("operation", [
|
|
4698
|
+
z12.object({ operation: z12.literal("created"), after: JsonValueSchema }),
|
|
4699
|
+
z12.object({
|
|
4700
|
+
operation: z12.literal("updated"),
|
|
4404
4701
|
before: JsonValueSchema,
|
|
4405
4702
|
after: JsonValueSchema
|
|
4406
4703
|
}),
|
|
4407
|
-
|
|
4408
|
-
operation:
|
|
4704
|
+
z12.object({
|
|
4705
|
+
operation: z12.literal("cleared"),
|
|
4409
4706
|
before: JsonValueSchema,
|
|
4410
4707
|
after: JsonNullSchema
|
|
4411
4708
|
})
|
|
4412
4709
|
]);
|
|
4413
|
-
var PropertyChangesSchema =
|
|
4414
|
-
var ObjectMutationPayloadSchema =
|
|
4415
|
-
objectTypeId:
|
|
4416
|
-
primaryId:
|
|
4417
|
-
properties:
|
|
4710
|
+
var PropertyChangesSchema = z12.record(PropertyChangeSchema);
|
|
4711
|
+
var ObjectMutationPayloadSchema = z12.object({
|
|
4712
|
+
objectTypeId: z12.string(),
|
|
4713
|
+
primaryId: z12.string(),
|
|
4714
|
+
properties: z12.record(JsonValueSchema),
|
|
4418
4715
|
propertyChanges: PropertyChangesSchema
|
|
4419
4716
|
});
|
|
4420
|
-
var ObjectDeletedPayloadSchema =
|
|
4421
|
-
objectTypeId:
|
|
4422
|
-
primaryId:
|
|
4717
|
+
var ObjectDeletedPayloadSchema = z12.object({
|
|
4718
|
+
objectTypeId: z12.string(),
|
|
4719
|
+
primaryId: z12.string(),
|
|
4423
4720
|
propertyChanges: PropertyChangesSchema
|
|
4424
4721
|
});
|
|
4425
|
-
var LinkSubjectSchema =
|
|
4426
|
-
sourceTypeId:
|
|
4427
|
-
sourceId:
|
|
4428
|
-
linkId:
|
|
4429
|
-
targetTypeId:
|
|
4430
|
-
targetId:
|
|
4722
|
+
var LinkSubjectSchema = z12.object({
|
|
4723
|
+
sourceTypeId: z12.string(),
|
|
4724
|
+
sourceId: z12.string(),
|
|
4725
|
+
linkId: z12.string(),
|
|
4726
|
+
targetTypeId: z12.string(),
|
|
4727
|
+
targetId: z12.string()
|
|
4431
4728
|
});
|
|
4432
4729
|
var LinkMutationPayloadSchema = LinkSubjectSchema.extend({
|
|
4433
|
-
properties:
|
|
4730
|
+
properties: z12.record(JsonValueSchema).optional(),
|
|
4434
4731
|
propertyChanges: PropertyChangesSchema
|
|
4435
4732
|
});
|
|
4436
4733
|
var LinkDeletedPayloadSchema = LinkSubjectSchema.extend({
|
|
@@ -4443,91 +4740,91 @@ var ONTOLOGY_EVENT_PAYLOAD_SCHEMAS = {
|
|
|
4443
4740
|
"link.created": LinkMutationPayloadSchema,
|
|
4444
4741
|
"link.updated": LinkMutationPayloadSchema,
|
|
4445
4742
|
"link.deleted": LinkDeletedPayloadSchema,
|
|
4446
|
-
"telemetry.appended":
|
|
4447
|
-
objectTypeId:
|
|
4448
|
-
objectId:
|
|
4449
|
-
propertyId:
|
|
4743
|
+
"telemetry.appended": z12.object({
|
|
4744
|
+
objectTypeId: z12.string(),
|
|
4745
|
+
objectId: z12.string(),
|
|
4746
|
+
propertyId: z12.string(),
|
|
4450
4747
|
value: JsonValueSchema,
|
|
4451
|
-
unit:
|
|
4452
|
-
at:
|
|
4748
|
+
unit: z12.string().optional(),
|
|
4749
|
+
at: z12.string()
|
|
4453
4750
|
})
|
|
4454
4751
|
};
|
|
4455
4752
|
|
|
4456
4753
|
// src/schemas/events.ts
|
|
4457
4754
|
var EVENT_TOPICS = CORE_EVENT_TOPICS;
|
|
4458
4755
|
var EVENT_TYPES = CORE_EVENT_TYPES;
|
|
4459
|
-
var EventTopicSchema =
|
|
4460
|
-
var EventTypeSchema =
|
|
4461
|
-
var ProjectionEventOriginSchema =
|
|
4462
|
-
kind:
|
|
4463
|
-
projectionId:
|
|
4464
|
-
projectionRunId:
|
|
4465
|
-
datasetId:
|
|
4466
|
-
datasetVersionId:
|
|
4467
|
-
});
|
|
4468
|
-
var EventOriginSchema =
|
|
4469
|
-
|
|
4470
|
-
kind:
|
|
4471
|
-
actionId:
|
|
4472
|
-
runId:
|
|
4756
|
+
var EventTopicSchema = z13.enum(EVENT_TOPICS);
|
|
4757
|
+
var EventTypeSchema = z13.enum(EVENT_TYPES);
|
|
4758
|
+
var ProjectionEventOriginSchema = z13.object({
|
|
4759
|
+
kind: z13.literal("projection"),
|
|
4760
|
+
projectionId: z13.string(),
|
|
4761
|
+
projectionRunId: z13.string(),
|
|
4762
|
+
datasetId: z13.string(),
|
|
4763
|
+
datasetVersionId: z13.string()
|
|
4764
|
+
});
|
|
4765
|
+
var EventOriginSchema = z13.union([
|
|
4766
|
+
z13.object({
|
|
4767
|
+
kind: z13.literal("action"),
|
|
4768
|
+
actionId: z13.string(),
|
|
4769
|
+
runId: z13.string()
|
|
4473
4770
|
}),
|
|
4474
|
-
|
|
4771
|
+
z13.object({ kind: z13.literal("runtime"), requestId: z13.string() }),
|
|
4475
4772
|
ProjectionEventOriginSchema,
|
|
4476
|
-
|
|
4477
|
-
kind:
|
|
4478
|
-
source:
|
|
4479
|
-
|
|
4480
|
-
ProjectionEventOriginSchema.extend({ batchOrdinal:
|
|
4773
|
+
z13.object({
|
|
4774
|
+
kind: z13.literal("telemetry"),
|
|
4775
|
+
source: z13.union([
|
|
4776
|
+
z13.object({ kind: z13.literal("runtime"), requestId: z13.string() }),
|
|
4777
|
+
ProjectionEventOriginSchema.extend({ batchOrdinal: z13.number() })
|
|
4481
4778
|
])
|
|
4482
4779
|
})
|
|
4483
4780
|
]);
|
|
4484
|
-
var EventsQuerySchema =
|
|
4781
|
+
var EventsQuerySchema = z13.object({
|
|
4485
4782
|
topic: EventTopicSchema.optional(),
|
|
4486
4783
|
type: EventTypeSchema.optional(),
|
|
4487
|
-
afterCursor:
|
|
4488
|
-
limit:
|
|
4489
|
-
});
|
|
4490
|
-
var StoredEventBaseSchema =
|
|
4491
|
-
id:
|
|
4492
|
-
cursor:
|
|
4493
|
-
schemaVersion:
|
|
4494
|
-
projectId:
|
|
4495
|
-
occurredAt:
|
|
4496
|
-
actor:
|
|
4497
|
-
type:
|
|
4498
|
-
id:
|
|
4784
|
+
afterCursor: z13.string().optional(),
|
|
4785
|
+
limit: z13.string().optional()
|
|
4786
|
+
});
|
|
4787
|
+
var StoredEventBaseSchema = z13.object({
|
|
4788
|
+
id: z13.string(),
|
|
4789
|
+
cursor: z13.string(),
|
|
4790
|
+
schemaVersion: z13.literal(1),
|
|
4791
|
+
projectId: z13.string(),
|
|
4792
|
+
occurredAt: z13.string(),
|
|
4793
|
+
actor: z13.object({
|
|
4794
|
+
type: z13.enum(["user", "serviceAccount", "system"]),
|
|
4795
|
+
id: z13.string()
|
|
4499
4796
|
}).optional(),
|
|
4500
|
-
partitionKey:
|
|
4797
|
+
partitionKey: z13.string()
|
|
4501
4798
|
});
|
|
4502
4799
|
var StoredAuthorableEventBaseSchema = StoredEventBaseSchema.extend({
|
|
4503
|
-
correlationId:
|
|
4504
|
-
causationId:
|
|
4505
|
-
idempotencyKey:
|
|
4800
|
+
correlationId: z13.string().optional(),
|
|
4801
|
+
causationId: z13.string().optional(),
|
|
4802
|
+
idempotencyKey: z13.string().optional(),
|
|
4506
4803
|
origin: EventOriginSchema.optional(),
|
|
4507
|
-
metadata:
|
|
4804
|
+
metadata: z13.record(JsonValueSchema).optional()
|
|
4508
4805
|
});
|
|
4509
4806
|
var StoredOntologyEventBaseSchema = StoredEventBaseSchema.extend({
|
|
4510
4807
|
origin: EventOriginSchema,
|
|
4511
|
-
commitId:
|
|
4512
|
-
commitOrdinal:
|
|
4808
|
+
commitId: z13.string(),
|
|
4809
|
+
commitOrdinal: z13.number().int().nonnegative()
|
|
4513
4810
|
});
|
|
4514
4811
|
var ontologyEventTypes = EVENT_TYPES.filter(isOntologyFactType);
|
|
4515
4812
|
var ontologyEventSchemas = ontologyEventTypes.map((type) => StoredOntologyEventBaseSchema.extend({
|
|
4516
|
-
type:
|
|
4517
|
-
topic:
|
|
4813
|
+
type: z13.literal(type),
|
|
4814
|
+
topic: z13.literal(EVENT_DEFINITIONS[type].topic),
|
|
4518
4815
|
payload: ONTOLOGY_EVENT_PAYLOAD_SCHEMAS[type]
|
|
4519
4816
|
}));
|
|
4520
4817
|
var authorableEventTypes = EVENT_TYPES.filter((type) => !isOntologyFactType(type));
|
|
4521
4818
|
var StoredAuthorableEventSchema = StoredAuthorableEventBaseSchema.extend({
|
|
4522
|
-
type:
|
|
4819
|
+
type: z13.enum(authorableEventTypes),
|
|
4523
4820
|
topic: EventTopicSchema,
|
|
4524
|
-
payload:
|
|
4821
|
+
payload: z13.record(z13.unknown())
|
|
4525
4822
|
});
|
|
4526
|
-
var StoredOntologyEventSchema =
|
|
4527
|
-
var EventSchema =
|
|
4528
|
-
var EventsResponseSchema =
|
|
4529
|
-
count:
|
|
4530
|
-
events:
|
|
4823
|
+
var StoredOntologyEventSchema = z13.discriminatedUnion("type", ontologyEventSchemas);
|
|
4824
|
+
var EventSchema = z13.union([StoredOntologyEventSchema, StoredAuthorableEventSchema]);
|
|
4825
|
+
var EventsResponseSchema = z13.object({
|
|
4826
|
+
count: z13.number(),
|
|
4827
|
+
events: z13.array(EventSchema)
|
|
4531
4828
|
});
|
|
4532
4829
|
|
|
4533
4830
|
// src/routes/events.ts
|
|
@@ -4573,37 +4870,37 @@ function registerEventRoutes(app, _host) {
|
|
|
4573
4870
|
}
|
|
4574
4871
|
|
|
4575
4872
|
// src/schemas/links.ts
|
|
4576
|
-
import { z as
|
|
4577
|
-
var LinkSourceParamsSchema =
|
|
4578
|
-
objectTypeId:
|
|
4579
|
-
objectId:
|
|
4873
|
+
import { z as z14 } from "zod";
|
|
4874
|
+
var LinkSourceParamsSchema = z14.object({
|
|
4875
|
+
objectTypeId: z14.string().min(1),
|
|
4876
|
+
objectId: z14.string().min(1)
|
|
4580
4877
|
});
|
|
4581
4878
|
var LinkParamsSchema = LinkSourceParamsSchema.extend({
|
|
4582
|
-
linkId:
|
|
4583
|
-
});
|
|
4584
|
-
var LinkQuerySchema =
|
|
4585
|
-
linkId:
|
|
4586
|
-
direction:
|
|
4587
|
-
});
|
|
4588
|
-
var RemoveLinkQuerySchema =
|
|
4589
|
-
targetTypeId:
|
|
4590
|
-
targetId:
|
|
4591
|
-
});
|
|
4592
|
-
var UpsertLinkBodySchema =
|
|
4593
|
-
targetTypeId:
|
|
4594
|
-
targetId:
|
|
4595
|
-
properties:
|
|
4596
|
-
});
|
|
4597
|
-
var ObjectLinkSchema =
|
|
4598
|
-
projectId:
|
|
4599
|
-
sourceTypeId:
|
|
4600
|
-
sourceId:
|
|
4601
|
-
linkId:
|
|
4602
|
-
targetTypeId:
|
|
4603
|
-
targetId:
|
|
4604
|
-
properties:
|
|
4605
|
-
createdAt:
|
|
4606
|
-
updatedAt:
|
|
4879
|
+
linkId: z14.string().min(1)
|
|
4880
|
+
});
|
|
4881
|
+
var LinkQuerySchema = z14.object({
|
|
4882
|
+
linkId: z14.string().optional(),
|
|
4883
|
+
direction: z14.enum(["outgoing", "incoming", "both"]).default("outgoing")
|
|
4884
|
+
});
|
|
4885
|
+
var RemoveLinkQuerySchema = z14.object({
|
|
4886
|
+
targetTypeId: z14.string().min(1),
|
|
4887
|
+
targetId: z14.string().min(1)
|
|
4888
|
+
});
|
|
4889
|
+
var UpsertLinkBodySchema = z14.object({
|
|
4890
|
+
targetTypeId: z14.string().min(1),
|
|
4891
|
+
targetId: z14.string().min(1),
|
|
4892
|
+
properties: z14.record(z14.unknown()).optional()
|
|
4893
|
+
});
|
|
4894
|
+
var ObjectLinkSchema = z14.object({
|
|
4895
|
+
projectId: z14.string(),
|
|
4896
|
+
sourceTypeId: z14.string(),
|
|
4897
|
+
sourceId: z14.string(),
|
|
4898
|
+
linkId: z14.string(),
|
|
4899
|
+
targetTypeId: z14.string(),
|
|
4900
|
+
targetId: z14.string(),
|
|
4901
|
+
properties: z14.record(z14.unknown()).optional(),
|
|
4902
|
+
createdAt: z14.string(),
|
|
4903
|
+
updatedAt: z14.string()
|
|
4607
4904
|
});
|
|
4608
4905
|
|
|
4609
4906
|
// src/routes/links.ts
|
|
@@ -4709,71 +5006,71 @@ import { logLevelsAtOrAbove } from "@sixb/core";
|
|
|
4709
5006
|
|
|
4710
5007
|
// src/schemas/logs.ts
|
|
4711
5008
|
import { LOG_LEVELS, SIXB_RUN_KINDS } from "@sixb/core";
|
|
4712
|
-
import { z as
|
|
4713
|
-
var SixbRunKindSchema =
|
|
4714
|
-
var LogLevelSchema =
|
|
4715
|
-
var LogRunIdSchema =
|
|
5009
|
+
import { z as z15 } from "zod";
|
|
5010
|
+
var SixbRunKindSchema = z15.enum(SIXB_RUN_KINDS);
|
|
5011
|
+
var LogLevelSchema = z15.enum(LOG_LEVELS);
|
|
5012
|
+
var LogRunIdSchema = z15.string().regex(/\S/, "run id must not be blank");
|
|
4716
5013
|
var DEFAULT_LOGS_PAGE_LIMIT = 200;
|
|
4717
5014
|
var MAX_LOGS_PAGE_LIMIT = 1000;
|
|
4718
|
-
var LogsLimitSchema =
|
|
4719
|
-
var LogsQuerySchema =
|
|
5015
|
+
var LogsLimitSchema = z15.coerce.number().int().positive().max(MAX_LOGS_PAGE_LIMIT);
|
|
5016
|
+
var LogsQuerySchema = z15.object({
|
|
4720
5017
|
kind: SixbRunKindSchema.optional(),
|
|
4721
5018
|
runId: LogRunIdSchema.optional(),
|
|
4722
5019
|
level: LogLevelSchema.optional(),
|
|
4723
|
-
direction:
|
|
4724
|
-
afterCursor:
|
|
4725
|
-
beforeCursor:
|
|
5020
|
+
direction: z15.enum(["forward", "backward"]).optional(),
|
|
5021
|
+
afterCursor: z15.string().optional(),
|
|
5022
|
+
beforeCursor: z15.string().optional(),
|
|
4726
5023
|
limit: LogsLimitSchema.optional()
|
|
4727
5024
|
}).superRefine((query, context) => {
|
|
4728
5025
|
if (query.runId !== undefined && query.kind === undefined) {
|
|
4729
5026
|
context.addIssue({
|
|
4730
|
-
code:
|
|
5027
|
+
code: z15.ZodIssueCode.custom,
|
|
4731
5028
|
path: ["runId"],
|
|
4732
5029
|
message: "kind is required when runId is provided"
|
|
4733
5030
|
});
|
|
4734
5031
|
}
|
|
4735
5032
|
if (query.afterCursor && query.beforeCursor) {
|
|
4736
5033
|
context.addIssue({
|
|
4737
|
-
code:
|
|
5034
|
+
code: z15.ZodIssueCode.custom,
|
|
4738
5035
|
message: "afterCursor and beforeCursor are mutually exclusive"
|
|
4739
5036
|
});
|
|
4740
5037
|
}
|
|
4741
5038
|
if (query.direction === "backward" && query.afterCursor) {
|
|
4742
5039
|
context.addIssue({
|
|
4743
|
-
code:
|
|
5040
|
+
code: z15.ZodIssueCode.custom,
|
|
4744
5041
|
path: ["afterCursor"],
|
|
4745
5042
|
message: "afterCursor cannot be used with backward reads"
|
|
4746
5043
|
});
|
|
4747
5044
|
}
|
|
4748
5045
|
if (query.direction !== "backward" && query.beforeCursor) {
|
|
4749
5046
|
context.addIssue({
|
|
4750
|
-
code:
|
|
5047
|
+
code: z15.ZodIssueCode.custom,
|
|
4751
5048
|
path: ["beforeCursor"],
|
|
4752
5049
|
message: "beforeCursor requires direction=backward"
|
|
4753
5050
|
});
|
|
4754
5051
|
}
|
|
4755
5052
|
});
|
|
4756
|
-
var LogLineSchema =
|
|
5053
|
+
var LogLineSchema = z15.object({
|
|
4757
5054
|
level: LogLevelSchema,
|
|
4758
|
-
message:
|
|
4759
|
-
fields:
|
|
4760
|
-
at:
|
|
4761
|
-
context:
|
|
4762
|
-
run:
|
|
5055
|
+
message: z15.string(),
|
|
5056
|
+
fields: z15.record(z15.unknown()).optional(),
|
|
5057
|
+
at: z15.string(),
|
|
5058
|
+
context: z15.object({
|
|
5059
|
+
run: z15.object({
|
|
4763
5060
|
kind: SixbRunKindSchema,
|
|
4764
|
-
id:
|
|
5061
|
+
id: z15.string()
|
|
4765
5062
|
}),
|
|
4766
|
-
stepId:
|
|
4767
|
-
phase:
|
|
4768
|
-
attempt:
|
|
5063
|
+
stepId: z15.string().optional(),
|
|
5064
|
+
phase: z15.string().optional(),
|
|
5065
|
+
attempt: z15.number().optional()
|
|
4769
5066
|
}),
|
|
4770
|
-
cursor:
|
|
5067
|
+
cursor: z15.string()
|
|
4771
5068
|
});
|
|
4772
|
-
var LogsResponseSchema =
|
|
4773
|
-
count:
|
|
4774
|
-
lines:
|
|
4775
|
-
cursor:
|
|
4776
|
-
hasMore:
|
|
5069
|
+
var LogsResponseSchema = z15.object({
|
|
5070
|
+
count: z15.number(),
|
|
5071
|
+
lines: z15.array(LogLineSchema),
|
|
5072
|
+
cursor: z15.string().optional(),
|
|
5073
|
+
hasMore: z15.boolean()
|
|
4777
5074
|
});
|
|
4778
5075
|
|
|
4779
5076
|
// src/routes/logs.ts
|
|
@@ -4824,35 +5121,35 @@ import {
|
|
|
4824
5121
|
ObjectQueryPlanningError,
|
|
4825
5122
|
ObjectQueryValidationError
|
|
4826
5123
|
} from "@sixb/core";
|
|
4827
|
-
import { ZodError as ZodError3, z as
|
|
5124
|
+
import { ZodError as ZodError3, z as z17 } from "zod";
|
|
4828
5125
|
|
|
4829
5126
|
// src/schemas/objects.ts
|
|
4830
|
-
import { z as
|
|
4831
|
-
var ObjectParamsSchema =
|
|
4832
|
-
objectTypeId:
|
|
4833
|
-
objectId:
|
|
4834
|
-
});
|
|
4835
|
-
var ObjectSearchQuerySchema =
|
|
4836
|
-
q:
|
|
4837
|
-
limit:
|
|
4838
|
-
});
|
|
4839
|
-
var ObjectSearchResponseSchema =
|
|
4840
|
-
items:
|
|
4841
|
-
ref:
|
|
4842
|
-
objectTypeId:
|
|
4843
|
-
primaryId:
|
|
5127
|
+
import { z as z16 } from "zod";
|
|
5128
|
+
var ObjectParamsSchema = z16.object({
|
|
5129
|
+
objectTypeId: z16.string().min(1),
|
|
5130
|
+
objectId: z16.string().min(1)
|
|
5131
|
+
});
|
|
5132
|
+
var ObjectSearchQuerySchema = z16.object({
|
|
5133
|
+
q: z16.string().trim().min(1).max(200),
|
|
5134
|
+
limit: z16.string().regex(/^\d+$/).optional()
|
|
5135
|
+
});
|
|
5136
|
+
var ObjectSearchResponseSchema = z16.object({
|
|
5137
|
+
items: z16.array(z16.object({
|
|
5138
|
+
ref: z16.object({
|
|
5139
|
+
objectTypeId: z16.string(),
|
|
5140
|
+
primaryId: z16.string()
|
|
4844
5141
|
}),
|
|
4845
|
-
label:
|
|
5142
|
+
label: z16.string()
|
|
4846
5143
|
}))
|
|
4847
5144
|
});
|
|
4848
5145
|
var OBJECT_LIST_MAX_LIMIT = 1000;
|
|
4849
|
-
var Rfc3339DateSchema =
|
|
5146
|
+
var Rfc3339DateSchema = z16.string().datetime({ offset: true });
|
|
4850
5147
|
function objectListDateSchema(parameter) {
|
|
4851
|
-
return
|
|
5148
|
+
return z16.string().refine((value) => Rfc3339DateSchema.safeParse(value).success, {
|
|
4852
5149
|
message: `Invalid query parameter '${parameter}': expected an RFC 3339 timestamp.`
|
|
4853
5150
|
}).transform((value) => new Date(value));
|
|
4854
5151
|
}
|
|
4855
|
-
var ObjectListLimitSchema =
|
|
5152
|
+
var ObjectListLimitSchema = z16.string().refine((value) => {
|
|
4856
5153
|
if (!/^\d+$/.test(value))
|
|
4857
5154
|
return false;
|
|
4858
5155
|
const parsed = Number(value);
|
|
@@ -4860,25 +5157,25 @@ var ObjectListLimitSchema = z15.string().refine((value) => {
|
|
|
4860
5157
|
}, {
|
|
4861
5158
|
message: `Invalid query parameter 'limit': expected an integer between 0 and ${OBJECT_LIST_MAX_LIMIT}.`
|
|
4862
5159
|
}).transform(Number);
|
|
4863
|
-
var ObjectListOffsetSchema =
|
|
5160
|
+
var ObjectListOffsetSchema = z16.string().refine((value) => /^\d+$/.test(value) && Number.isSafeInteger(Number(value)), {
|
|
4864
5161
|
message: "Invalid query parameter 'offset': expected a non-negative safe integer."
|
|
4865
5162
|
}).transform(Number);
|
|
4866
|
-
var ObjectsQuerySchema =
|
|
4867
|
-
objectTypeId:
|
|
4868
|
-
idPrefix:
|
|
4869
|
-
idSuffix:
|
|
5163
|
+
var ObjectsQuerySchema = z16.object({
|
|
5164
|
+
objectTypeId: z16.string().optional(),
|
|
5165
|
+
idPrefix: z16.string().optional(),
|
|
5166
|
+
idSuffix: z16.string().optional(),
|
|
4870
5167
|
updatedAfter: objectListDateSchema("updatedAfter").optional(),
|
|
4871
5168
|
updatedBefore: objectListDateSchema("updatedBefore").optional(),
|
|
4872
5169
|
createdAfter: objectListDateSchema("createdAfter").optional(),
|
|
4873
5170
|
createdBefore: objectListDateSchema("createdBefore").optional(),
|
|
4874
5171
|
limit: ObjectListLimitSchema.optional(),
|
|
4875
5172
|
offset: ObjectListOffsetSchema.optional(),
|
|
4876
|
-
orderBy:
|
|
5173
|
+
orderBy: z16.enum(["createdAt", "updatedAt", "primaryId"], {
|
|
4877
5174
|
errorMap: () => ({
|
|
4878
5175
|
message: "Invalid query parameter 'orderBy': expected one of createdAt, updatedAt, or primaryId."
|
|
4879
5176
|
})
|
|
4880
5177
|
}).optional(),
|
|
4881
|
-
order:
|
|
5178
|
+
order: z16.enum(["asc", "desc"], {
|
|
4882
5179
|
errorMap: () => ({
|
|
4883
5180
|
message: "Invalid query parameter 'order': expected 'asc' or 'desc'."
|
|
4884
5181
|
})
|
|
@@ -4886,163 +5183,163 @@ var ObjectsQuerySchema = z15.object({
|
|
|
4886
5183
|
}).superRefine((query, context) => {
|
|
4887
5184
|
if (query.updatedAfter && query.updatedBefore && query.updatedAfter > query.updatedBefore) {
|
|
4888
5185
|
context.addIssue({
|
|
4889
|
-
code:
|
|
5186
|
+
code: z16.ZodIssueCode.custom,
|
|
4890
5187
|
path: ["updatedAfter"],
|
|
4891
5188
|
message: "Invalid query parameter range: 'updatedAfter' must be before or equal to 'updatedBefore'."
|
|
4892
5189
|
});
|
|
4893
5190
|
}
|
|
4894
5191
|
if (query.createdAfter && query.createdBefore && query.createdAfter > query.createdBefore) {
|
|
4895
5192
|
context.addIssue({
|
|
4896
|
-
code:
|
|
5193
|
+
code: z16.ZodIssueCode.custom,
|
|
4897
5194
|
path: ["createdAfter"],
|
|
4898
5195
|
message: "Invalid query parameter range: 'createdAfter' must be before or equal to 'createdBefore'."
|
|
4899
5196
|
});
|
|
4900
5197
|
}
|
|
4901
5198
|
});
|
|
4902
|
-
var UpsertObjectBodySchema =
|
|
4903
|
-
properties:
|
|
5199
|
+
var UpsertObjectBodySchema = z16.object({
|
|
5200
|
+
properties: z16.record(z16.unknown())
|
|
4904
5201
|
});
|
|
4905
|
-
var ObjectQueryPredicateSchema =
|
|
4906
|
-
|
|
4907
|
-
op:
|
|
4908
|
-
items:
|
|
5202
|
+
var ObjectQueryPredicateSchema = z16.lazy(() => z16.union([
|
|
5203
|
+
z16.object({
|
|
5204
|
+
op: z16.enum(["and", "or"]),
|
|
5205
|
+
items: z16.array(ObjectQueryPredicateSchema)
|
|
4909
5206
|
}).strict(),
|
|
4910
|
-
|
|
4911
|
-
op:
|
|
5207
|
+
z16.object({
|
|
5208
|
+
op: z16.literal("not"),
|
|
4912
5209
|
item: ObjectQueryPredicateSchema
|
|
4913
5210
|
}).strict(),
|
|
4914
|
-
|
|
4915
|
-
op:
|
|
4916
|
-
propertyId:
|
|
5211
|
+
z16.object({
|
|
5212
|
+
op: z16.enum(["eq", "neq", "lt", "lte", "gt", "gte"]),
|
|
5213
|
+
propertyId: z16.string().min(1),
|
|
4917
5214
|
value: JsonValueSchema
|
|
4918
5215
|
}).strict(),
|
|
4919
|
-
|
|
4920
|
-
op:
|
|
4921
|
-
propertyId:
|
|
4922
|
-
values:
|
|
5216
|
+
z16.object({
|
|
5217
|
+
op: z16.literal("in"),
|
|
5218
|
+
propertyId: z16.string().min(1),
|
|
5219
|
+
values: z16.array(JsonValueSchema)
|
|
4923
5220
|
}).strict(),
|
|
4924
|
-
|
|
4925
|
-
op:
|
|
4926
|
-
propertyId:
|
|
4927
|
-
value:
|
|
5221
|
+
z16.object({
|
|
5222
|
+
op: z16.literal("exists"),
|
|
5223
|
+
propertyId: z16.string().min(1),
|
|
5224
|
+
value: z16.boolean()
|
|
4928
5225
|
}).strict(),
|
|
4929
|
-
|
|
4930
|
-
op:
|
|
4931
|
-
propertyId:
|
|
5226
|
+
z16.object({
|
|
5227
|
+
op: z16.literal("contains"),
|
|
5228
|
+
propertyId: z16.string().min(1),
|
|
4932
5229
|
value: JsonValueSchema
|
|
4933
5230
|
}).strict()
|
|
4934
5231
|
]));
|
|
4935
|
-
var ObjectQuerySortFieldSchema =
|
|
4936
|
-
|
|
4937
|
-
kind:
|
|
4938
|
-
propertyId:
|
|
4939
|
-
direction:
|
|
5232
|
+
var ObjectQuerySortFieldSchema = z16.union([
|
|
5233
|
+
z16.object({
|
|
5234
|
+
kind: z16.literal("property"),
|
|
5235
|
+
propertyId: z16.string().min(1),
|
|
5236
|
+
direction: z16.enum(["asc", "desc"]).optional()
|
|
4940
5237
|
}).strict(),
|
|
4941
|
-
|
|
4942
|
-
kind:
|
|
4943
|
-
direction:
|
|
5238
|
+
z16.object({
|
|
5239
|
+
kind: z16.literal("relevance"),
|
|
5240
|
+
direction: z16.enum(["asc", "desc"]).optional()
|
|
4944
5241
|
}).strict()
|
|
4945
5242
|
]);
|
|
4946
|
-
var ObjectExpansionSchema =
|
|
4947
|
-
linkId:
|
|
4948
|
-
direction:
|
|
4949
|
-
sourceObjectTypeId:
|
|
4950
|
-
limit:
|
|
4951
|
-
orderBy:
|
|
4952
|
-
expand:
|
|
5243
|
+
var ObjectExpansionSchema = z16.lazy(() => z16.object({
|
|
5244
|
+
linkId: z16.string().min(1),
|
|
5245
|
+
direction: z16.enum(["outgoing", "incoming"]),
|
|
5246
|
+
sourceObjectTypeId: z16.string().min(1).optional(),
|
|
5247
|
+
limit: z16.number().int().nonnegative().optional(),
|
|
5248
|
+
orderBy: z16.array(ObjectQuerySortFieldSchema).optional(),
|
|
5249
|
+
expand: z16.array(ObjectExpansionSchema).optional()
|
|
4953
5250
|
}).strict());
|
|
4954
|
-
var ObjectQuerySchema =
|
|
4955
|
-
|
|
4956
|
-
kind:
|
|
4957
|
-
objectTypeId:
|
|
4958
|
-
includeSubtypes:
|
|
5251
|
+
var ObjectQuerySchema = z16.lazy(() => z16.discriminatedUnion("kind", [
|
|
5252
|
+
z16.object({
|
|
5253
|
+
kind: z16.literal("start"),
|
|
5254
|
+
objectTypeId: z16.string().min(1),
|
|
5255
|
+
includeSubtypes: z16.boolean().optional()
|
|
4959
5256
|
}).strict(),
|
|
4960
|
-
|
|
4961
|
-
kind:
|
|
5257
|
+
z16.object({
|
|
5258
|
+
kind: z16.literal("filter"),
|
|
4962
5259
|
input: ObjectQuerySchema,
|
|
4963
5260
|
predicate: ObjectQueryPredicateSchema
|
|
4964
5261
|
}).strict(),
|
|
4965
|
-
|
|
4966
|
-
kind:
|
|
5262
|
+
z16.object({
|
|
5263
|
+
kind: z16.literal("text"),
|
|
4967
5264
|
input: ObjectQuerySchema,
|
|
4968
|
-
query:
|
|
4969
|
-
fields:
|
|
5265
|
+
query: z16.string(),
|
|
5266
|
+
fields: z16.array(z16.string().min(1)).optional()
|
|
4970
5267
|
}).strict(),
|
|
4971
|
-
|
|
4972
|
-
kind:
|
|
5268
|
+
z16.object({
|
|
5269
|
+
kind: z16.literal("vector"),
|
|
4973
5270
|
input: ObjectQuerySchema,
|
|
4974
|
-
vector:
|
|
4975
|
-
propertyId:
|
|
4976
|
-
k:
|
|
5271
|
+
vector: z16.array(z16.number().finite()),
|
|
5272
|
+
propertyId: z16.string().min(1),
|
|
5273
|
+
k: z16.number().int().positive()
|
|
4977
5274
|
}).strict(),
|
|
4978
|
-
|
|
4979
|
-
kind:
|
|
5275
|
+
z16.object({
|
|
5276
|
+
kind: z16.literal("traverse"),
|
|
4980
5277
|
input: ObjectQuerySchema,
|
|
4981
|
-
linkId:
|
|
4982
|
-
direction:
|
|
4983
|
-
sourceObjectTypeId:
|
|
5278
|
+
linkId: z16.string().min(1),
|
|
5279
|
+
direction: z16.enum(["outgoing", "incoming"]),
|
|
5280
|
+
sourceObjectTypeId: z16.string().min(1).optional()
|
|
4984
5281
|
}).strict(),
|
|
4985
|
-
|
|
4986
|
-
kind:
|
|
4987
|
-
op:
|
|
4988
|
-
inputs:
|
|
5282
|
+
z16.object({
|
|
5283
|
+
kind: z16.literal("set"),
|
|
5284
|
+
op: z16.enum(["union", "intersect", "subtract"]),
|
|
5285
|
+
inputs: z16.array(ObjectQuerySchema)
|
|
4989
5286
|
}).strict(),
|
|
4990
|
-
|
|
4991
|
-
kind:
|
|
5287
|
+
z16.object({
|
|
5288
|
+
kind: z16.literal("sort"),
|
|
4992
5289
|
input: ObjectQuerySchema,
|
|
4993
|
-
fields:
|
|
5290
|
+
fields: z16.array(ObjectQuerySortFieldSchema)
|
|
4994
5291
|
}).strict(),
|
|
4995
|
-
|
|
4996
|
-
kind:
|
|
5292
|
+
z16.object({
|
|
5293
|
+
kind: z16.literal("limit"),
|
|
4997
5294
|
input: ObjectQuerySchema,
|
|
4998
|
-
limit:
|
|
5295
|
+
limit: z16.number().int().nonnegative()
|
|
4999
5296
|
}).strict(),
|
|
5000
|
-
|
|
5001
|
-
kind:
|
|
5297
|
+
z16.object({
|
|
5298
|
+
kind: z16.literal("page"),
|
|
5002
5299
|
input: ObjectQuerySchema,
|
|
5003
|
-
pageSize:
|
|
5004
|
-
pageToken:
|
|
5300
|
+
pageSize: z16.number().int().positive(),
|
|
5301
|
+
pageToken: z16.string().optional()
|
|
5005
5302
|
}).strict(),
|
|
5006
|
-
|
|
5007
|
-
kind:
|
|
5303
|
+
z16.object({
|
|
5304
|
+
kind: z16.literal("project"),
|
|
5008
5305
|
input: ObjectQuerySchema,
|
|
5009
|
-
properties:
|
|
5306
|
+
properties: z16.array(z16.string().min(1)).optional()
|
|
5010
5307
|
}).strict(),
|
|
5011
|
-
|
|
5012
|
-
kind:
|
|
5308
|
+
z16.object({
|
|
5309
|
+
kind: z16.literal("expand"),
|
|
5013
5310
|
input: ObjectQuerySchema,
|
|
5014
|
-
expansions:
|
|
5311
|
+
expansions: z16.array(ObjectExpansionSchema)
|
|
5015
5312
|
}).strict()
|
|
5016
5313
|
]));
|
|
5017
|
-
var ObjectQueryRequestSchema =
|
|
5314
|
+
var ObjectQueryRequestSchema = z16.object({
|
|
5018
5315
|
query: ObjectQuerySchema,
|
|
5019
|
-
includeTotal:
|
|
5316
|
+
includeTotal: z16.boolean().optional()
|
|
5020
5317
|
}).strict();
|
|
5021
|
-
var ObjectQueryCountRequestSchema =
|
|
5318
|
+
var ObjectQueryCountRequestSchema = z16.object({
|
|
5022
5319
|
query: ObjectQuerySchema
|
|
5023
5320
|
}).strict();
|
|
5024
|
-
var ObjectQueryExistsRequestSchema =
|
|
5321
|
+
var ObjectQueryExistsRequestSchema = z16.object({
|
|
5025
5322
|
query: ObjectQuerySchema
|
|
5026
5323
|
}).strict();
|
|
5027
|
-
var ObjectQueryFacetRequestSchema =
|
|
5028
|
-
propertyId:
|
|
5029
|
-
limit:
|
|
5324
|
+
var ObjectQueryFacetRequestSchema = z16.object({
|
|
5325
|
+
propertyId: z16.string().min(1),
|
|
5326
|
+
limit: z16.number().int().positive()
|
|
5030
5327
|
}).strict();
|
|
5031
|
-
var ObjectQueryFacetsRequestSchema =
|
|
5328
|
+
var ObjectQueryFacetsRequestSchema = z16.object({
|
|
5032
5329
|
query: ObjectQuerySchema,
|
|
5033
|
-
facets:
|
|
5330
|
+
facets: z16.array(ObjectQueryFacetRequestSchema).min(1)
|
|
5034
5331
|
}).strict();
|
|
5035
|
-
var TwinObjectSchema =
|
|
5036
|
-
primaryId:
|
|
5037
|
-
objectTypeId:
|
|
5038
|
-
properties:
|
|
5039
|
-
createdAt:
|
|
5040
|
-
updatedAt:
|
|
5041
|
-
});
|
|
5042
|
-
var ObjectListResponseSchema =
|
|
5043
|
-
objects:
|
|
5044
|
-
hasMore:
|
|
5045
|
-
total:
|
|
5332
|
+
var TwinObjectSchema = z16.object({
|
|
5333
|
+
primaryId: z16.string(),
|
|
5334
|
+
objectTypeId: z16.string(),
|
|
5335
|
+
properties: z16.record(z16.unknown()),
|
|
5336
|
+
createdAt: z16.string(),
|
|
5337
|
+
updatedAt: z16.string()
|
|
5338
|
+
});
|
|
5339
|
+
var ObjectListResponseSchema = z16.object({
|
|
5340
|
+
objects: z16.array(TwinObjectSchema),
|
|
5341
|
+
hasMore: z16.boolean(),
|
|
5342
|
+
total: z16.number()
|
|
5046
5343
|
});
|
|
5047
5344
|
var anyJsonValueSchema = {};
|
|
5048
5345
|
var stringArraySchema = { type: "array", items: { type: "string", minLength: 1 } };
|
|
@@ -5472,7 +5769,7 @@ var ObjectQueryOpenApiSchemas = {
|
|
|
5472
5769
|
|
|
5473
5770
|
// src/routes/objects.ts
|
|
5474
5771
|
var ObjectFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
5475
|
-
path:
|
|
5772
|
+
path: z17.string().min(1).regex(/^\/properties(?:\/|$)/, "Object file content paths must start with /properties/")
|
|
5476
5773
|
});
|
|
5477
5774
|
function serializeObject(row) {
|
|
5478
5775
|
return {
|
|
@@ -6129,111 +6426,111 @@ function registerOntologyRoutes(app, _host) {
|
|
|
6129
6426
|
import {
|
|
6130
6427
|
PIPELINE_RUN_FAILURE_CODES
|
|
6131
6428
|
} from "@sixb/core/storage";
|
|
6132
|
-
import { z as
|
|
6429
|
+
import { z as z18 } from "zod";
|
|
6133
6430
|
var PipelineRunFailureSchema = sixbFailureSchema(PIPELINE_RUN_FAILURE_CODES);
|
|
6134
|
-
var PipelineParamsSchema =
|
|
6135
|
-
pipelineId:
|
|
6431
|
+
var PipelineParamsSchema = z18.object({
|
|
6432
|
+
pipelineId: z18.string().min(1)
|
|
6136
6433
|
});
|
|
6137
|
-
var PipelineRunParamsSchema =
|
|
6138
|
-
runId:
|
|
6434
|
+
var PipelineRunParamsSchema = z18.object({
|
|
6435
|
+
runId: z18.string().min(1)
|
|
6139
6436
|
});
|
|
6140
|
-
var PipelineRunStatusSchema =
|
|
6437
|
+
var PipelineRunStatusSchema = z18.enum([
|
|
6141
6438
|
"queued",
|
|
6142
6439
|
"running",
|
|
6143
6440
|
"succeeded",
|
|
6144
6441
|
"failed",
|
|
6145
6442
|
"cancelled"
|
|
6146
6443
|
]);
|
|
6147
|
-
var PipelineStepRunStatusSchema =
|
|
6148
|
-
var PipelineRunsQuerySchema =
|
|
6149
|
-
pipelineId:
|
|
6444
|
+
var PipelineStepRunStatusSchema = z18.enum(["running", "succeeded", "failed", "cancelled"]);
|
|
6445
|
+
var PipelineRunsQuerySchema = z18.object({
|
|
6446
|
+
pipelineId: z18.string().optional(),
|
|
6150
6447
|
status: PipelineRunStatusSchema.optional(),
|
|
6151
|
-
startedAfter:
|
|
6152
|
-
startedBefore:
|
|
6153
|
-
limit:
|
|
6154
|
-
offset:
|
|
6155
|
-
order:
|
|
6156
|
-
});
|
|
6157
|
-
var DatasetVersionRefSchema2 =
|
|
6158
|
-
datasetId:
|
|
6159
|
-
versionId:
|
|
6160
|
-
});
|
|
6161
|
-
var PipelineTriggerSchema =
|
|
6162
|
-
type:
|
|
6163
|
-
scheduleId:
|
|
6164
|
-
});
|
|
6165
|
-
var PipelineStepExecutorSchema =
|
|
6166
|
-
|
|
6167
|
-
kind:
|
|
6168
|
-
dialect:
|
|
6448
|
+
startedAfter: z18.string().optional(),
|
|
6449
|
+
startedBefore: z18.string().optional(),
|
|
6450
|
+
limit: z18.string().optional(),
|
|
6451
|
+
offset: z18.string().optional(),
|
|
6452
|
+
order: z18.enum(["asc", "desc"]).optional()
|
|
6453
|
+
});
|
|
6454
|
+
var DatasetVersionRefSchema2 = z18.object({
|
|
6455
|
+
datasetId: z18.string(),
|
|
6456
|
+
versionId: z18.string()
|
|
6457
|
+
});
|
|
6458
|
+
var PipelineTriggerSchema = z18.object({
|
|
6459
|
+
type: z18.literal("schedule"),
|
|
6460
|
+
scheduleId: z18.string()
|
|
6461
|
+
});
|
|
6462
|
+
var PipelineStepExecutorSchema = z18.union([
|
|
6463
|
+
z18.object({
|
|
6464
|
+
kind: z18.literal("sql"),
|
|
6465
|
+
dialect: z18.literal("duckdb")
|
|
6169
6466
|
}),
|
|
6170
|
-
|
|
6171
|
-
kind:
|
|
6467
|
+
z18.object({
|
|
6468
|
+
kind: z18.literal("run")
|
|
6172
6469
|
})
|
|
6173
6470
|
]);
|
|
6174
|
-
var PipelineRunSchema =
|
|
6175
|
-
id:
|
|
6176
|
-
projectId:
|
|
6177
|
-
pipelineId:
|
|
6471
|
+
var PipelineRunSchema = z18.object({
|
|
6472
|
+
id: z18.string(),
|
|
6473
|
+
projectId: z18.string(),
|
|
6474
|
+
pipelineId: z18.string(),
|
|
6178
6475
|
status: PipelineRunStatusSchema,
|
|
6179
|
-
queuedAt:
|
|
6180
|
-
startedAt:
|
|
6181
|
-
finishedAt:
|
|
6476
|
+
queuedAt: z18.string(),
|
|
6477
|
+
startedAt: z18.string().optional(),
|
|
6478
|
+
finishedAt: z18.string().optional(),
|
|
6182
6479
|
output: DatasetVersionRefSchema2.optional(),
|
|
6183
6480
|
error: PipelineRunFailureSchema.optional()
|
|
6184
6481
|
});
|
|
6185
|
-
var PipelineStepRunSchema =
|
|
6186
|
-
id:
|
|
6187
|
-
projectId:
|
|
6188
|
-
pipelineRunId:
|
|
6189
|
-
pipelineId:
|
|
6190
|
-
stepId:
|
|
6191
|
-
datasetId:
|
|
6192
|
-
mode:
|
|
6482
|
+
var PipelineStepRunSchema = z18.object({
|
|
6483
|
+
id: z18.string(),
|
|
6484
|
+
projectId: z18.string(),
|
|
6485
|
+
pipelineRunId: z18.string(),
|
|
6486
|
+
pipelineId: z18.string(),
|
|
6487
|
+
stepId: z18.string(),
|
|
6488
|
+
datasetId: z18.string(),
|
|
6489
|
+
mode: z18.enum(["snapshot", "append"]),
|
|
6193
6490
|
status: PipelineStepRunStatusSchema,
|
|
6194
|
-
startedAt:
|
|
6195
|
-
finishedAt:
|
|
6196
|
-
inputs:
|
|
6491
|
+
startedAt: z18.string(),
|
|
6492
|
+
finishedAt: z18.string().optional(),
|
|
6493
|
+
inputs: z18.array(DatasetVersionRefSchema2),
|
|
6197
6494
|
output: DatasetVersionRefSchema2.optional(),
|
|
6198
|
-
rowsWritten:
|
|
6495
|
+
rowsWritten: z18.number().optional(),
|
|
6199
6496
|
error: PipelineRunFailureSchema.optional()
|
|
6200
6497
|
});
|
|
6201
|
-
var PipelineStepSchema =
|
|
6202
|
-
id:
|
|
6203
|
-
mode:
|
|
6498
|
+
var PipelineStepSchema = z18.object({
|
|
6499
|
+
id: z18.string(),
|
|
6500
|
+
mode: z18.enum(["snapshot", "append"]),
|
|
6204
6501
|
executor: PipelineStepExecutorSchema,
|
|
6205
|
-
inputs:
|
|
6206
|
-
name:
|
|
6502
|
+
inputs: z18.array(z18.object({
|
|
6503
|
+
name: z18.string(),
|
|
6207
6504
|
dataset: DatasetDefinitionSchema
|
|
6208
6505
|
})),
|
|
6209
6506
|
output: DatasetDefinitionSchema
|
|
6210
6507
|
});
|
|
6211
|
-
var PipelineSchema =
|
|
6212
|
-
id:
|
|
6213
|
-
triggers:
|
|
6214
|
-
graph:
|
|
6215
|
-
kind:
|
|
6216
|
-
nodes:
|
|
6217
|
-
kind:
|
|
6508
|
+
var PipelineSchema = z18.object({
|
|
6509
|
+
id: z18.string(),
|
|
6510
|
+
triggers: z18.array(PipelineTriggerSchema),
|
|
6511
|
+
graph: z18.object({
|
|
6512
|
+
kind: z18.literal("sequence"),
|
|
6513
|
+
nodes: z18.array(z18.object({
|
|
6514
|
+
kind: z18.literal("step"),
|
|
6218
6515
|
step: PipelineStepSchema
|
|
6219
6516
|
}))
|
|
6220
6517
|
}),
|
|
6221
6518
|
latestRun: PipelineRunSchema.nullable()
|
|
6222
6519
|
});
|
|
6223
|
-
var PipelineRunListResponseSchema =
|
|
6224
|
-
runs:
|
|
6225
|
-
hasMore:
|
|
6226
|
-
total:
|
|
6520
|
+
var PipelineRunListResponseSchema = z18.object({
|
|
6521
|
+
runs: z18.array(PipelineRunSchema),
|
|
6522
|
+
hasMore: z18.boolean(),
|
|
6523
|
+
total: z18.number()
|
|
6227
6524
|
});
|
|
6228
|
-
var PipelineRunDetailResponseSchema =
|
|
6525
|
+
var PipelineRunDetailResponseSchema = z18.object({
|
|
6229
6526
|
run: PipelineRunSchema,
|
|
6230
|
-
steps:
|
|
6527
|
+
steps: z18.array(PipelineStepRunSchema)
|
|
6231
6528
|
});
|
|
6232
|
-
var RequestPipelineRunResponseSchema =
|
|
6233
|
-
runId:
|
|
6234
|
-
jobId:
|
|
6235
|
-
pipelineId:
|
|
6236
|
-
queuedAt:
|
|
6529
|
+
var RequestPipelineRunResponseSchema = z18.object({
|
|
6530
|
+
runId: z18.string(),
|
|
6531
|
+
jobId: z18.string(),
|
|
6532
|
+
pipelineId: z18.string(),
|
|
6533
|
+
queuedAt: z18.string()
|
|
6237
6534
|
});
|
|
6238
6535
|
|
|
6239
6536
|
// src/routes/pipelines.ts
|
|
@@ -6455,9 +6752,9 @@ function registerPipelineRoutes(app, host) {
|
|
|
6455
6752
|
}
|
|
6456
6753
|
|
|
6457
6754
|
// src/schemas/project.ts
|
|
6458
|
-
import { z as
|
|
6459
|
-
var ProjectInfoResponseSchema =
|
|
6460
|
-
id:
|
|
6755
|
+
import { z as z19 } from "zod";
|
|
6756
|
+
var ProjectInfoResponseSchema = z19.object({
|
|
6757
|
+
id: z19.string()
|
|
6461
6758
|
});
|
|
6462
6759
|
|
|
6463
6760
|
// src/routes/project.ts
|
|
@@ -6475,141 +6772,146 @@ function registerProjectRoutes(app, host) {
|
|
|
6475
6772
|
|
|
6476
6773
|
// src/schemas/projections.ts
|
|
6477
6774
|
import { PROJECTION_RUN_FAILURE_CODES } from "@sixb/core/storage";
|
|
6478
|
-
import { z as
|
|
6775
|
+
import { z as z20 } from "zod";
|
|
6479
6776
|
var ProjectionRunFailureSchema = sixbFailureSchema(PROJECTION_RUN_FAILURE_CODES);
|
|
6480
|
-
var ProjectionKindSchema =
|
|
6481
|
-
var ProjectionRunStatusSchema =
|
|
6777
|
+
var ProjectionKindSchema = z20.enum(["object", "link", "telemetry"]);
|
|
6778
|
+
var ProjectionRunStatusSchema = z20.enum([
|
|
6482
6779
|
"queued",
|
|
6483
6780
|
"running",
|
|
6484
6781
|
"succeeded",
|
|
6485
6782
|
"failed",
|
|
6486
6783
|
"cancelled"
|
|
6487
6784
|
]);
|
|
6488
|
-
var ProjectionRunIdentityBaseSchema =
|
|
6489
|
-
projectionId:
|
|
6490
|
-
datasetVersion:
|
|
6491
|
-
datasetId:
|
|
6492
|
-
versionId:
|
|
6493
|
-
createdAt:
|
|
6785
|
+
var ProjectionRunIdentityBaseSchema = z20.object({
|
|
6786
|
+
projectionId: z20.string(),
|
|
6787
|
+
datasetVersion: z20.object({
|
|
6788
|
+
datasetId: z20.string(),
|
|
6789
|
+
versionId: z20.string(),
|
|
6790
|
+
createdAt: z20.string()
|
|
6494
6791
|
}),
|
|
6495
|
-
ontologyRevision:
|
|
6496
|
-
projectionRevision:
|
|
6497
|
-
ownershipHash:
|
|
6498
|
-
});
|
|
6499
|
-
var ProjectionRunBaseSchema =
|
|
6500
|
-
id:
|
|
6501
|
-
projectId:
|
|
6502
|
-
executionId:
|
|
6792
|
+
ontologyRevision: z20.string(),
|
|
6793
|
+
projectionRevision: z20.string(),
|
|
6794
|
+
ownershipHash: z20.string()
|
|
6795
|
+
});
|
|
6796
|
+
var ProjectionRunBaseSchema = z20.object({
|
|
6797
|
+
id: z20.string(),
|
|
6798
|
+
projectId: z20.string(),
|
|
6799
|
+
executionId: z20.string(),
|
|
6503
6800
|
status: ProjectionRunStatusSchema,
|
|
6504
|
-
attempt:
|
|
6505
|
-
progress:
|
|
6506
|
-
sourceRowsRead:
|
|
6507
|
-
sourceRowsSkipped:
|
|
6801
|
+
attempt: z20.number(),
|
|
6802
|
+
progress: z20.object({
|
|
6803
|
+
sourceRowsRead: z20.number(),
|
|
6804
|
+
sourceRowsSkipped: z20.number()
|
|
6508
6805
|
}),
|
|
6509
|
-
queuedAt:
|
|
6510
|
-
startedAt:
|
|
6511
|
-
finishedAt:
|
|
6806
|
+
queuedAt: z20.string(),
|
|
6807
|
+
startedAt: z20.string().optional(),
|
|
6808
|
+
finishedAt: z20.string().optional(),
|
|
6512
6809
|
error: ProjectionRunFailureSchema.optional()
|
|
6513
6810
|
});
|
|
6514
6811
|
var ObjectProjectionRunSchema = ProjectionRunBaseSchema.extend({
|
|
6515
6812
|
identity: ProjectionRunIdentityBaseSchema.extend({
|
|
6516
|
-
projectionKind:
|
|
6517
|
-
protocol:
|
|
6813
|
+
projectionKind: z20.literal("object"),
|
|
6814
|
+
protocol: z20.literal("replacement")
|
|
6518
6815
|
}),
|
|
6519
|
-
target:
|
|
6816
|
+
target: z20.object({ objectTypeId: z20.string() })
|
|
6520
6817
|
});
|
|
6521
6818
|
var LinkProjectionRunSchema = ProjectionRunBaseSchema.extend({
|
|
6522
6819
|
identity: ProjectionRunIdentityBaseSchema.extend({
|
|
6523
|
-
projectionKind:
|
|
6524
|
-
protocol:
|
|
6820
|
+
projectionKind: z20.literal("link"),
|
|
6821
|
+
protocol: z20.literal("replacement")
|
|
6525
6822
|
}),
|
|
6526
|
-
target:
|
|
6527
|
-
sourceObjectTypeId:
|
|
6528
|
-
targetObjectTypeId:
|
|
6823
|
+
target: z20.object({
|
|
6824
|
+
sourceObjectTypeId: z20.string(),
|
|
6825
|
+
targetObjectTypeId: z20.string()
|
|
6529
6826
|
})
|
|
6530
6827
|
});
|
|
6531
6828
|
var TelemetryProjectionRunSchema = ProjectionRunBaseSchema.extend({
|
|
6532
6829
|
identity: ProjectionRunIdentityBaseSchema.extend({
|
|
6533
|
-
projectionKind:
|
|
6534
|
-
protocol:
|
|
6830
|
+
projectionKind: z20.literal("telemetry"),
|
|
6831
|
+
protocol: z20.literal("telemetry")
|
|
6535
6832
|
}),
|
|
6536
|
-
target:
|
|
6833
|
+
target: z20.object({ objectTypeId: z20.string() })
|
|
6537
6834
|
});
|
|
6538
|
-
var ProjectionRunSchema =
|
|
6835
|
+
var ProjectionRunSchema = z20.union([
|
|
6539
6836
|
ObjectProjectionRunSchema,
|
|
6540
6837
|
LinkProjectionRunSchema,
|
|
6541
6838
|
TelemetryProjectionRunSchema
|
|
6542
6839
|
]);
|
|
6543
|
-
var ForeignKeyDescriptorSchema =
|
|
6544
|
-
linkId:
|
|
6545
|
-
sourcePropertyId:
|
|
6546
|
-
sourceField:
|
|
6547
|
-
targetObjectTypeId:
|
|
6548
|
-
});
|
|
6549
|
-
var
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6840
|
+
var ForeignKeyDescriptorSchema = z20.object({
|
|
6841
|
+
linkId: z20.string(),
|
|
6842
|
+
sourcePropertyId: z20.string().optional(),
|
|
6843
|
+
sourceField: z20.string().optional(),
|
|
6844
|
+
targetObjectTypeId: z20.string()
|
|
6845
|
+
});
|
|
6846
|
+
var SourceEditConflictResolutionSchema = z20.union([
|
|
6847
|
+
z20.object({ strategy: z20.literal("editsWin") }),
|
|
6848
|
+
z20.object({ strategy: z20.literal("mostRecent"), sourceTimestamp: z20.string() })
|
|
6849
|
+
]);
|
|
6850
|
+
var ObjectProjectionSchema = z20.object({
|
|
6851
|
+
_tag: z20.literal("ObjectProjectionDefinition"),
|
|
6852
|
+
id: z20.string(),
|
|
6853
|
+
objectTypeId: z20.string(),
|
|
6854
|
+
datasetId: z20.string(),
|
|
6855
|
+
properties: z20.record(z20.string()),
|
|
6856
|
+
links: z20.record(ForeignKeyDescriptorSchema),
|
|
6857
|
+
conflictResolution: SourceEditConflictResolutionSchema,
|
|
6556
6858
|
latestRun: ProjectionRunSchema.nullable()
|
|
6557
6859
|
});
|
|
6558
|
-
var LinkProjectionSchema =
|
|
6559
|
-
_tag:
|
|
6560
|
-
id:
|
|
6561
|
-
linkId:
|
|
6562
|
-
sourceObjectTypeId:
|
|
6563
|
-
targetObjectTypeId:
|
|
6564
|
-
datasetId:
|
|
6565
|
-
sourceField:
|
|
6566
|
-
targetField:
|
|
6860
|
+
var LinkProjectionSchema = z20.object({
|
|
6861
|
+
_tag: z20.literal("LinkProjectionDefinition"),
|
|
6862
|
+
id: z20.string(),
|
|
6863
|
+
linkId: z20.string(),
|
|
6864
|
+
sourceObjectTypeId: z20.string(),
|
|
6865
|
+
targetObjectTypeId: z20.string(),
|
|
6866
|
+
datasetId: z20.string(),
|
|
6867
|
+
sourceField: z20.string(),
|
|
6868
|
+
targetField: z20.string(),
|
|
6567
6869
|
latestRun: ProjectionRunSchema.nullable()
|
|
6568
6870
|
});
|
|
6569
|
-
var TelemetryProjectionSchema =
|
|
6570
|
-
_tag:
|
|
6571
|
-
id:
|
|
6572
|
-
objectTypeId:
|
|
6573
|
-
propertyId:
|
|
6574
|
-
datasetId:
|
|
6575
|
-
objectIdField:
|
|
6576
|
-
atField:
|
|
6577
|
-
valueField:
|
|
6578
|
-
unitField:
|
|
6871
|
+
var TelemetryProjectionSchema = z20.object({
|
|
6872
|
+
_tag: z20.literal("TelemetryProjectionDefinition"),
|
|
6873
|
+
id: z20.string(),
|
|
6874
|
+
objectTypeId: z20.string(),
|
|
6875
|
+
propertyId: z20.string(),
|
|
6876
|
+
datasetId: z20.string(),
|
|
6877
|
+
objectIdField: z20.string(),
|
|
6878
|
+
atField: z20.string(),
|
|
6879
|
+
valueField: z20.string(),
|
|
6880
|
+
unitField: z20.string().optional(),
|
|
6579
6881
|
latestRun: ProjectionRunSchema.nullable()
|
|
6580
6882
|
});
|
|
6581
|
-
var ProjectionListResponseSchema =
|
|
6582
|
-
objectProjections:
|
|
6583
|
-
linkProjections:
|
|
6584
|
-
telemetryProjections:
|
|
6883
|
+
var ProjectionListResponseSchema = z20.object({
|
|
6884
|
+
objectProjections: z20.array(ObjectProjectionSchema),
|
|
6885
|
+
linkProjections: z20.array(LinkProjectionSchema),
|
|
6886
|
+
telemetryProjections: z20.array(TelemetryProjectionSchema)
|
|
6585
6887
|
});
|
|
6586
|
-
var ProjectionParamsSchema =
|
|
6587
|
-
projectionId:
|
|
6888
|
+
var ProjectionParamsSchema = z20.object({
|
|
6889
|
+
projectionId: z20.string().min(1)
|
|
6588
6890
|
});
|
|
6589
|
-
var ProjectionResponseSchema =
|
|
6891
|
+
var ProjectionResponseSchema = z20.union([
|
|
6590
6892
|
ObjectProjectionSchema,
|
|
6591
6893
|
LinkProjectionSchema,
|
|
6592
6894
|
TelemetryProjectionSchema
|
|
6593
6895
|
]);
|
|
6594
|
-
var ProjectionRunParamsSchema =
|
|
6595
|
-
runId:
|
|
6896
|
+
var ProjectionRunParamsSchema = z20.object({
|
|
6897
|
+
runId: z20.string().min(1)
|
|
6596
6898
|
});
|
|
6597
|
-
var ProjectionRunsQuerySchema =
|
|
6598
|
-
projectionId:
|
|
6899
|
+
var ProjectionRunsQuerySchema = z20.object({
|
|
6900
|
+
projectionId: z20.string().optional(),
|
|
6599
6901
|
projectionKind: ProjectionKindSchema.optional(),
|
|
6600
|
-
datasetId:
|
|
6601
|
-
datasetVersionId:
|
|
6902
|
+
datasetId: z20.string().optional(),
|
|
6903
|
+
datasetVersionId: z20.string().optional(),
|
|
6602
6904
|
status: ProjectionRunStatusSchema.optional(),
|
|
6603
|
-
startedAfter:
|
|
6604
|
-
startedBefore:
|
|
6605
|
-
limit:
|
|
6606
|
-
offset:
|
|
6607
|
-
order:
|
|
6905
|
+
startedAfter: z20.string().optional(),
|
|
6906
|
+
startedBefore: z20.string().optional(),
|
|
6907
|
+
limit: z20.string().optional(),
|
|
6908
|
+
offset: z20.string().optional(),
|
|
6909
|
+
order: z20.enum(["asc", "desc"]).optional()
|
|
6608
6910
|
});
|
|
6609
|
-
var ProjectionRunListResponseSchema =
|
|
6610
|
-
runs:
|
|
6611
|
-
hasMore:
|
|
6612
|
-
total:
|
|
6911
|
+
var ProjectionRunListResponseSchema = z20.object({
|
|
6912
|
+
runs: z20.array(ProjectionRunSchema),
|
|
6913
|
+
hasMore: z20.boolean(),
|
|
6914
|
+
total: z20.number()
|
|
6613
6915
|
});
|
|
6614
6916
|
|
|
6615
6917
|
// src/routes/projections.ts
|
|
@@ -6651,10 +6953,15 @@ function projectionCatalogIds(catalog) {
|
|
|
6651
6953
|
].map((projection) => projection.id);
|
|
6652
6954
|
}
|
|
6653
6955
|
function serializeProjection(projection, latestRuns) {
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6956
|
+
const latestRun = latestRuns.get(projection.id) ?? null;
|
|
6957
|
+
if (projection._tag === "ObjectProjectionDefinition") {
|
|
6958
|
+
return {
|
|
6959
|
+
...projection,
|
|
6960
|
+
conflictResolution: projection.conflictResolution ?? { strategy: "editsWin" },
|
|
6961
|
+
latestRun
|
|
6962
|
+
};
|
|
6963
|
+
}
|
|
6964
|
+
return { ...projection, latestRun };
|
|
6658
6965
|
}
|
|
6659
6966
|
function serializeProjectionCatalog(catalog, latestRuns) {
|
|
6660
6967
|
return {
|
|
@@ -6772,88 +7079,88 @@ function registerProjectionRoutes(app, host) {
|
|
|
6772
7079
|
import { deriveRuleEventDependencies } from "@sixb/core/internal/rules";
|
|
6773
7080
|
|
|
6774
7081
|
// src/schemas/rules.ts
|
|
6775
|
-
import { z as
|
|
6776
|
-
var RuleParamsSchema =
|
|
6777
|
-
ruleId:
|
|
6778
|
-
});
|
|
6779
|
-
var RuleStatesQuerySchema =
|
|
6780
|
-
ruleId:
|
|
6781
|
-
objectTypeId:
|
|
6782
|
-
primaryId:
|
|
6783
|
-
limit:
|
|
6784
|
-
offset:
|
|
6785
|
-
order:
|
|
6786
|
-
});
|
|
6787
|
-
var RuleValueSchema =
|
|
6788
|
-
var RuleSubjectSchema =
|
|
6789
|
-
kind:
|
|
6790
|
-
objectTypeId:
|
|
6791
|
-
});
|
|
6792
|
-
var RuleEventSubjectSchema =
|
|
6793
|
-
kind:
|
|
6794
|
-
objectTypeId:
|
|
6795
|
-
primaryId:
|
|
6796
|
-
});
|
|
6797
|
-
var RulePropertyPredicateSchema =
|
|
6798
|
-
kind:
|
|
6799
|
-
propertyId:
|
|
6800
|
-
op:
|
|
7082
|
+
import { z as z21 } from "zod";
|
|
7083
|
+
var RuleParamsSchema = z21.object({
|
|
7084
|
+
ruleId: z21.string().min(1)
|
|
7085
|
+
});
|
|
7086
|
+
var RuleStatesQuerySchema = z21.object({
|
|
7087
|
+
ruleId: z21.string().optional(),
|
|
7088
|
+
objectTypeId: z21.string().optional(),
|
|
7089
|
+
primaryId: z21.string().optional(),
|
|
7090
|
+
limit: z21.string().optional(),
|
|
7091
|
+
offset: z21.string().optional(),
|
|
7092
|
+
order: z21.enum(["asc", "desc"]).optional()
|
|
7093
|
+
});
|
|
7094
|
+
var RuleValueSchema = z21.union([z21.string(), z21.number(), z21.boolean()]).nullable();
|
|
7095
|
+
var RuleSubjectSchema = z21.object({
|
|
7096
|
+
kind: z21.literal("object"),
|
|
7097
|
+
objectTypeId: z21.string()
|
|
7098
|
+
});
|
|
7099
|
+
var RuleEventSubjectSchema = z21.object({
|
|
7100
|
+
kind: z21.literal("object"),
|
|
7101
|
+
objectTypeId: z21.string(),
|
|
7102
|
+
primaryId: z21.string()
|
|
7103
|
+
});
|
|
7104
|
+
var RulePropertyPredicateSchema = z21.object({
|
|
7105
|
+
kind: z21.literal("property"),
|
|
7106
|
+
propertyId: z21.string(),
|
|
7107
|
+
op: z21.enum(["eq", "notEq", "gt", "gte", "lt", "lte", "isPresent", "isMissing"]),
|
|
6801
7108
|
value: RuleValueSchema.optional()
|
|
6802
7109
|
});
|
|
6803
|
-
var RuleLinkPredicateSchema =
|
|
6804
|
-
kind:
|
|
6805
|
-
linkId:
|
|
6806
|
-
op:
|
|
7110
|
+
var RuleLinkPredicateSchema = z21.object({
|
|
7111
|
+
kind: z21.literal("link"),
|
|
7112
|
+
linkId: z21.string(),
|
|
7113
|
+
op: z21.enum(["exists", "isMissing"])
|
|
6807
7114
|
});
|
|
6808
7115
|
function createRulePredicateSchema(childPredicateSchema) {
|
|
6809
|
-
return
|
|
6810
|
-
|
|
6811
|
-
kind:
|
|
6812
|
-
predicates:
|
|
7116
|
+
return z21.union([
|
|
7117
|
+
z21.object({
|
|
7118
|
+
kind: z21.literal("all"),
|
|
7119
|
+
predicates: z21.array(childPredicateSchema)
|
|
6813
7120
|
}),
|
|
6814
|
-
|
|
6815
|
-
kind:
|
|
6816
|
-
predicates:
|
|
7121
|
+
z21.object({
|
|
7122
|
+
kind: z21.literal("any"),
|
|
7123
|
+
predicates: z21.array(childPredicateSchema)
|
|
6817
7124
|
}),
|
|
6818
|
-
|
|
6819
|
-
kind:
|
|
7125
|
+
z21.object({
|
|
7126
|
+
kind: z21.literal("not"),
|
|
6820
7127
|
predicate: childPredicateSchema
|
|
6821
7128
|
}),
|
|
6822
7129
|
RulePropertyPredicateSchema,
|
|
6823
7130
|
RuleLinkPredicateSchema
|
|
6824
7131
|
]);
|
|
6825
7132
|
}
|
|
6826
|
-
var DeepRulePredicateSchema = createRulePredicateSchema(
|
|
7133
|
+
var DeepRulePredicateSchema = createRulePredicateSchema(z21.unknown());
|
|
6827
7134
|
var NestedRulePredicateSchema = createRulePredicateSchema(DeepRulePredicateSchema);
|
|
6828
7135
|
var RulePredicateSchema = NestedRulePredicateSchema;
|
|
6829
|
-
var RuleEventDependencySchema =
|
|
6830
|
-
|
|
6831
|
-
type:
|
|
6832
|
-
objectTypeId:
|
|
7136
|
+
var RuleEventDependencySchema = z21.union([
|
|
7137
|
+
z21.object({
|
|
7138
|
+
type: z21.enum(["object.created", "object.updated", "object.deleted"]),
|
|
7139
|
+
objectTypeId: z21.string()
|
|
6833
7140
|
}),
|
|
6834
|
-
|
|
6835
|
-
type:
|
|
6836
|
-
sourceTypeId:
|
|
6837
|
-
linkId:
|
|
7141
|
+
z21.object({
|
|
7142
|
+
type: z21.enum(["link.created", "link.updated", "link.deleted"]),
|
|
7143
|
+
sourceTypeId: z21.string(),
|
|
7144
|
+
linkId: z21.string()
|
|
6838
7145
|
})
|
|
6839
7146
|
]);
|
|
6840
|
-
var RuleSchema =
|
|
6841
|
-
kind:
|
|
6842
|
-
id:
|
|
7147
|
+
var RuleSchema = z21.object({
|
|
7148
|
+
kind: z21.literal("rule"),
|
|
7149
|
+
id: z21.string(),
|
|
6843
7150
|
subject: RuleSubjectSchema,
|
|
6844
7151
|
predicate: RulePredicateSchema,
|
|
6845
|
-
dependencies:
|
|
7152
|
+
dependencies: z21.array(RuleEventDependencySchema)
|
|
6846
7153
|
});
|
|
6847
|
-
var RuleStateSchema =
|
|
6848
|
-
projectId:
|
|
6849
|
-
ruleId:
|
|
7154
|
+
var RuleStateSchema = z21.object({
|
|
7155
|
+
projectId: z21.string(),
|
|
7156
|
+
ruleId: z21.string(),
|
|
6850
7157
|
subject: RuleEventSubjectSchema,
|
|
6851
|
-
triggeredAt:
|
|
7158
|
+
triggeredAt: z21.string()
|
|
6852
7159
|
});
|
|
6853
|
-
var RuleStateListResponseSchema =
|
|
6854
|
-
states:
|
|
6855
|
-
hasMore:
|
|
6856
|
-
total:
|
|
7160
|
+
var RuleStateListResponseSchema = z21.object({
|
|
7161
|
+
states: z21.array(RuleStateSchema),
|
|
7162
|
+
hasMore: z21.boolean(),
|
|
7163
|
+
total: z21.number()
|
|
6857
7164
|
});
|
|
6858
7165
|
|
|
6859
7166
|
// src/routes/rules.ts
|
|
@@ -6933,44 +7240,44 @@ function registerRuleRoutes(app, host) {
|
|
|
6933
7240
|
}
|
|
6934
7241
|
|
|
6935
7242
|
// src/schemas/status.ts
|
|
6936
|
-
import { z as
|
|
6937
|
-
var HealthResponseSchema =
|
|
6938
|
-
var StorageReadinessSchema =
|
|
6939
|
-
reachable:
|
|
6940
|
-
schemaValid:
|
|
7243
|
+
import { z as z22 } from "zod";
|
|
7244
|
+
var HealthResponseSchema = z22.object({ status: z22.literal("ok") });
|
|
7245
|
+
var StorageReadinessSchema = z22.object({
|
|
7246
|
+
reachable: z22.boolean(),
|
|
7247
|
+
schemaValid: z22.boolean()
|
|
6941
7248
|
});
|
|
6942
|
-
var ReadinessResponseSchema =
|
|
6943
|
-
status:
|
|
7249
|
+
var ReadinessResponseSchema = z22.object({
|
|
7250
|
+
status: z22.enum(["ready", "unready"]),
|
|
6944
7251
|
storage: StorageReadinessSchema,
|
|
6945
|
-
reason:
|
|
6946
|
-
});
|
|
6947
|
-
var MaintenanceSummarySchema =
|
|
6948
|
-
running:
|
|
6949
|
-
intervalMs:
|
|
6950
|
-
lastStartedAt:
|
|
6951
|
-
lastCompletedAt:
|
|
6952
|
-
lastDurationMs:
|
|
6953
|
-
consecutiveFailures:
|
|
6954
|
-
lastError:
|
|
6955
|
-
outbox:
|
|
6956
|
-
pendingCount:
|
|
6957
|
-
oldestPendingAt:
|
|
6958
|
-
retryingCount:
|
|
6959
|
-
maxAttempts:
|
|
7252
|
+
reason: z22.string().optional()
|
|
7253
|
+
});
|
|
7254
|
+
var MaintenanceSummarySchema = z22.object({
|
|
7255
|
+
running: z22.boolean(),
|
|
7256
|
+
intervalMs: z22.number().int().positive(),
|
|
7257
|
+
lastStartedAt: z22.string().nullable(),
|
|
7258
|
+
lastCompletedAt: z22.string().nullable(),
|
|
7259
|
+
lastDurationMs: z22.number().nonnegative().nullable(),
|
|
7260
|
+
consecutiveFailures: z22.number().int().nonnegative(),
|
|
7261
|
+
lastError: z22.string().nullable(),
|
|
7262
|
+
outbox: z22.object({
|
|
7263
|
+
pendingCount: z22.number().int().nonnegative(),
|
|
7264
|
+
oldestPendingAt: z22.string().nullable(),
|
|
7265
|
+
retryingCount: z22.number().int().nonnegative(),
|
|
7266
|
+
maxAttempts: z22.number().int().nonnegative()
|
|
6960
7267
|
}).nullable(),
|
|
6961
|
-
terminalSources:
|
|
6962
|
-
count:
|
|
6963
|
-
oldestTerminalAt:
|
|
7268
|
+
terminalSources: z22.object({
|
|
7269
|
+
count: z22.number().int().nonnegative(),
|
|
7270
|
+
oldestTerminalAt: z22.string().nullable()
|
|
6964
7271
|
}).nullable(),
|
|
6965
|
-
cleanup:
|
|
6966
|
-
publishedOutboxRowsDeleted:
|
|
6967
|
-
terminalSourceRowsDeleted:
|
|
6968
|
-
terminalSourceMaterializationsDeleted:
|
|
7272
|
+
cleanup: z22.object({
|
|
7273
|
+
publishedOutboxRowsDeleted: z22.number().int().nonnegative(),
|
|
7274
|
+
terminalSourceRowsDeleted: z22.number().int().nonnegative(),
|
|
7275
|
+
terminalSourceMaterializationsDeleted: z22.number().int().nonnegative()
|
|
6969
7276
|
}).nullable()
|
|
6970
7277
|
});
|
|
6971
|
-
var StatusResponseSchema =
|
|
6972
|
-
status:
|
|
6973
|
-
objectTypes:
|
|
7278
|
+
var StatusResponseSchema = z22.object({
|
|
7279
|
+
status: z22.enum(["ok", "degraded"]),
|
|
7280
|
+
objectTypes: z22.number().int().nonnegative(),
|
|
6974
7281
|
maintenance: MaintenanceSummarySchema
|
|
6975
7282
|
});
|
|
6976
7283
|
|
|
@@ -7016,74 +7323,74 @@ function registerStatusRoutes(app, host) {
|
|
|
7016
7323
|
import {
|
|
7017
7324
|
SYNC_RUN_FAILURE_CODES
|
|
7018
7325
|
} from "@sixb/core/storage";
|
|
7019
|
-
import { z as
|
|
7326
|
+
import { z as z23 } from "zod";
|
|
7020
7327
|
var SyncRunFailureSchema = sixbFailureSchema(SYNC_RUN_FAILURE_CODES);
|
|
7021
|
-
var SyncParamsSchema =
|
|
7022
|
-
syncId:
|
|
7023
|
-
});
|
|
7024
|
-
var SyncRunStatusSchema =
|
|
7025
|
-
var SyncModeSchema =
|
|
7026
|
-
var SyncRunsQuerySchema =
|
|
7027
|
-
syncId:
|
|
7028
|
-
datasetId:
|
|
7328
|
+
var SyncParamsSchema = z23.object({
|
|
7329
|
+
syncId: z23.string().min(1)
|
|
7330
|
+
});
|
|
7331
|
+
var SyncRunStatusSchema = z23.enum(["queued", "running", "succeeded", "failed", "cancelled"]);
|
|
7332
|
+
var SyncModeSchema = z23.enum(["snapshot", "append", "merge"]);
|
|
7333
|
+
var SyncRunsQuerySchema = z23.object({
|
|
7334
|
+
syncId: z23.string().optional(),
|
|
7335
|
+
datasetId: z23.string().optional(),
|
|
7029
7336
|
status: SyncRunStatusSchema.optional(),
|
|
7030
|
-
startedAfter:
|
|
7031
|
-
startedBefore:
|
|
7032
|
-
limit:
|
|
7033
|
-
offset:
|
|
7034
|
-
order:
|
|
7035
|
-
});
|
|
7036
|
-
var RequestSyncRunBodySchema =
|
|
7037
|
-
expectedLatestVersionId:
|
|
7038
|
-
commitMessage:
|
|
7039
|
-
});
|
|
7040
|
-
var SyncTriggerSchema =
|
|
7041
|
-
type:
|
|
7042
|
-
scheduleId:
|
|
7043
|
-
});
|
|
7044
|
-
var SyncRunSchema =
|
|
7045
|
-
id:
|
|
7046
|
-
projectId:
|
|
7047
|
-
syncId:
|
|
7048
|
-
datasetId:
|
|
7337
|
+
startedAfter: z23.string().optional(),
|
|
7338
|
+
startedBefore: z23.string().optional(),
|
|
7339
|
+
limit: z23.string().optional(),
|
|
7340
|
+
offset: z23.string().optional(),
|
|
7341
|
+
order: z23.enum(["asc", "desc"]).optional()
|
|
7342
|
+
});
|
|
7343
|
+
var RequestSyncRunBodySchema = z23.object({
|
|
7344
|
+
expectedLatestVersionId: z23.string().optional(),
|
|
7345
|
+
commitMessage: z23.string().optional()
|
|
7346
|
+
});
|
|
7347
|
+
var SyncTriggerSchema = z23.object({
|
|
7348
|
+
type: z23.literal("schedule"),
|
|
7349
|
+
scheduleId: z23.string()
|
|
7350
|
+
});
|
|
7351
|
+
var SyncRunSchema = z23.object({
|
|
7352
|
+
id: z23.string(),
|
|
7353
|
+
projectId: z23.string(),
|
|
7354
|
+
syncId: z23.string(),
|
|
7355
|
+
datasetId: z23.string(),
|
|
7049
7356
|
mode: SyncModeSchema,
|
|
7050
7357
|
status: SyncRunStatusSchema,
|
|
7051
|
-
queuedAt:
|
|
7052
|
-
startedAt:
|
|
7053
|
-
finishedAt:
|
|
7054
|
-
rowsRead:
|
|
7055
|
-
output:
|
|
7056
|
-
datasetId:
|
|
7057
|
-
versionId:
|
|
7358
|
+
queuedAt: z23.string(),
|
|
7359
|
+
startedAt: z23.string().optional(),
|
|
7360
|
+
finishedAt: z23.string().optional(),
|
|
7361
|
+
rowsRead: z23.number().optional(),
|
|
7362
|
+
output: z23.object({
|
|
7363
|
+
datasetId: z23.string(),
|
|
7364
|
+
versionId: z23.string()
|
|
7058
7365
|
}).optional(),
|
|
7059
|
-
expectedLatestVersionId:
|
|
7060
|
-
commitMessage:
|
|
7366
|
+
expectedLatestVersionId: z23.string().optional(),
|
|
7367
|
+
commitMessage: z23.string().optional(),
|
|
7061
7368
|
error: SyncRunFailureSchema.optional()
|
|
7062
7369
|
});
|
|
7063
|
-
var SyncSchema =
|
|
7064
|
-
id:
|
|
7370
|
+
var SyncSchema = z23.object({
|
|
7371
|
+
id: z23.string(),
|
|
7065
7372
|
mode: SyncModeSchema,
|
|
7066
|
-
connector:
|
|
7067
|
-
id:
|
|
7068
|
-
type:
|
|
7373
|
+
connector: z23.object({
|
|
7374
|
+
id: z23.string(),
|
|
7375
|
+
type: z23.string()
|
|
7069
7376
|
}),
|
|
7070
|
-
target:
|
|
7071
|
-
kind:
|
|
7377
|
+
target: z23.object({
|
|
7378
|
+
kind: z23.literal("dataset"),
|
|
7072
7379
|
dataset: DatasetDefinitionSchema
|
|
7073
7380
|
}),
|
|
7074
|
-
triggers:
|
|
7381
|
+
triggers: z23.array(SyncTriggerSchema),
|
|
7075
7382
|
latestRun: SyncRunSchema.nullable()
|
|
7076
7383
|
});
|
|
7077
|
-
var SyncRunListResponseSchema =
|
|
7078
|
-
runs:
|
|
7079
|
-
hasMore:
|
|
7080
|
-
total:
|
|
7384
|
+
var SyncRunListResponseSchema = z23.object({
|
|
7385
|
+
runs: z23.array(SyncRunSchema),
|
|
7386
|
+
hasMore: z23.boolean(),
|
|
7387
|
+
total: z23.number()
|
|
7081
7388
|
});
|
|
7082
|
-
var RequestSyncRunResponseSchema =
|
|
7083
|
-
runId:
|
|
7084
|
-
jobId:
|
|
7085
|
-
syncId:
|
|
7086
|
-
queuedAt:
|
|
7389
|
+
var RequestSyncRunResponseSchema = z23.object({
|
|
7390
|
+
runId: z23.string(),
|
|
7391
|
+
jobId: z23.string(),
|
|
7392
|
+
syncId: z23.string(),
|
|
7393
|
+
queuedAt: z23.string()
|
|
7087
7394
|
});
|
|
7088
7395
|
|
|
7089
7396
|
// src/routes/syncs.ts
|
|
@@ -7237,52 +7544,52 @@ function registerSyncRoutes(app, host) {
|
|
|
7237
7544
|
}
|
|
7238
7545
|
|
|
7239
7546
|
// src/schemas/telemetry.ts
|
|
7240
|
-
import { z as
|
|
7241
|
-
var TelemetryParamsSchema =
|
|
7242
|
-
objectTypeId:
|
|
7243
|
-
objectId:
|
|
7244
|
-
propertyId:
|
|
7245
|
-
});
|
|
7246
|
-
var TelemetryHistoryQuerySchema =
|
|
7247
|
-
from:
|
|
7248
|
-
to:
|
|
7249
|
-
limit:
|
|
7250
|
-
order:
|
|
7547
|
+
import { z as z24 } from "zod";
|
|
7548
|
+
var TelemetryParamsSchema = z24.object({
|
|
7549
|
+
objectTypeId: z24.string().min(1),
|
|
7550
|
+
objectId: z24.string().min(1),
|
|
7551
|
+
propertyId: z24.string().min(1)
|
|
7552
|
+
});
|
|
7553
|
+
var TelemetryHistoryQuerySchema = z24.object({
|
|
7554
|
+
from: z24.string().optional(),
|
|
7555
|
+
to: z24.string().optional(),
|
|
7556
|
+
limit: z24.string().optional(),
|
|
7557
|
+
order: z24.enum(["asc", "desc"]).optional()
|
|
7251
7558
|
});
|
|
7252
|
-
var BulkTelemetryHistorySeriesInputSchema =
|
|
7253
|
-
objectTypeId:
|
|
7254
|
-
objectId:
|
|
7255
|
-
propertyId:
|
|
7559
|
+
var BulkTelemetryHistorySeriesInputSchema = z24.object({
|
|
7560
|
+
objectTypeId: z24.string().min(1),
|
|
7561
|
+
objectId: z24.string().min(1),
|
|
7562
|
+
propertyId: z24.string().min(1)
|
|
7256
7563
|
}).strict();
|
|
7257
|
-
var BulkTelemetryHistoryBodySchema =
|
|
7258
|
-
series:
|
|
7259
|
-
from:
|
|
7260
|
-
to:
|
|
7261
|
-
limitPerSeries:
|
|
7262
|
-
order:
|
|
7564
|
+
var BulkTelemetryHistoryBodySchema = z24.object({
|
|
7565
|
+
series: z24.array(BulkTelemetryHistorySeriesInputSchema).min(1),
|
|
7566
|
+
from: z24.string().optional(),
|
|
7567
|
+
to: z24.string().optional(),
|
|
7568
|
+
limitPerSeries: z24.number().int().nonnegative().optional(),
|
|
7569
|
+
order: z24.enum(["asc", "desc"]).optional()
|
|
7263
7570
|
}).strict();
|
|
7264
|
-
var AppendTelemetryBodySchema =
|
|
7265
|
-
value:
|
|
7266
|
-
unit:
|
|
7267
|
-
at:
|
|
7571
|
+
var AppendTelemetryBodySchema = z24.object({
|
|
7572
|
+
value: z24.unknown(),
|
|
7573
|
+
unit: z24.string().optional(),
|
|
7574
|
+
at: z24.string().optional()
|
|
7268
7575
|
});
|
|
7269
|
-
var TelemetryPointSchema =
|
|
7270
|
-
projectId:
|
|
7271
|
-
objectTypeId:
|
|
7272
|
-
objectId:
|
|
7273
|
-
propertyId:
|
|
7274
|
-
value:
|
|
7275
|
-
unit:
|
|
7276
|
-
at:
|
|
7277
|
-
});
|
|
7278
|
-
var BulkTelemetryHistorySeriesSchema =
|
|
7279
|
-
objectTypeId:
|
|
7280
|
-
objectId:
|
|
7281
|
-
propertyId:
|
|
7282
|
-
points:
|
|
7283
|
-
});
|
|
7284
|
-
var BulkTelemetryHistoryResponseSchema =
|
|
7285
|
-
series:
|
|
7576
|
+
var TelemetryPointSchema = z24.object({
|
|
7577
|
+
projectId: z24.string(),
|
|
7578
|
+
objectTypeId: z24.string(),
|
|
7579
|
+
objectId: z24.string(),
|
|
7580
|
+
propertyId: z24.string(),
|
|
7581
|
+
value: z24.unknown(),
|
|
7582
|
+
unit: z24.string().optional(),
|
|
7583
|
+
at: z24.string()
|
|
7584
|
+
});
|
|
7585
|
+
var BulkTelemetryHistorySeriesSchema = z24.object({
|
|
7586
|
+
objectTypeId: z24.string(),
|
|
7587
|
+
objectId: z24.string(),
|
|
7588
|
+
propertyId: z24.string(),
|
|
7589
|
+
points: z24.array(TelemetryPointSchema)
|
|
7590
|
+
});
|
|
7591
|
+
var BulkTelemetryHistoryResponseSchema = z24.object({
|
|
7592
|
+
series: z24.array(BulkTelemetryHistorySeriesSchema)
|
|
7286
7593
|
});
|
|
7287
7594
|
|
|
7288
7595
|
// src/routes/telemetry.ts
|
|
@@ -7440,40 +7747,40 @@ function registerTelemetryRoutes(app, _host) {
|
|
|
7440
7747
|
|
|
7441
7748
|
// src/schemas/webhook-runs.ts
|
|
7442
7749
|
import { WEBHOOK_RUN_FAILURE_CODES } from "@sixb/core/storage";
|
|
7443
|
-
import { z as
|
|
7750
|
+
import { z as z25 } from "zod";
|
|
7444
7751
|
var WebhookRunFailureSchema = sixbFailureSchema(WEBHOOK_RUN_FAILURE_CODES);
|
|
7445
|
-
var WebhookRunStatusSchema =
|
|
7446
|
-
var WebhookRunsQuerySchema =
|
|
7447
|
-
connectorId:
|
|
7448
|
-
webhookId:
|
|
7752
|
+
var WebhookRunStatusSchema = z25.enum(["running", "succeeded", "failed"]);
|
|
7753
|
+
var WebhookRunsQuerySchema = z25.object({
|
|
7754
|
+
connectorId: z25.string().optional(),
|
|
7755
|
+
webhookId: z25.string().optional(),
|
|
7449
7756
|
status: WebhookRunStatusSchema.optional(),
|
|
7450
|
-
idempotencyKey:
|
|
7451
|
-
startedAfter:
|
|
7452
|
-
startedBefore:
|
|
7453
|
-
limit:
|
|
7454
|
-
offset:
|
|
7455
|
-
order:
|
|
7757
|
+
idempotencyKey: z25.string().optional(),
|
|
7758
|
+
startedAfter: z25.string().optional(),
|
|
7759
|
+
startedBefore: z25.string().optional(),
|
|
7760
|
+
limit: z25.string().optional(),
|
|
7761
|
+
offset: z25.string().optional(),
|
|
7762
|
+
order: z25.enum(["asc", "desc"]).optional()
|
|
7456
7763
|
});
|
|
7457
|
-
var WebhookRunSchema =
|
|
7458
|
-
id:
|
|
7459
|
-
projectId:
|
|
7460
|
-
executionId:
|
|
7461
|
-
connectorId:
|
|
7462
|
-
webhookId:
|
|
7764
|
+
var WebhookRunSchema = z25.object({
|
|
7765
|
+
id: z25.string(),
|
|
7766
|
+
projectId: z25.string(),
|
|
7767
|
+
executionId: z25.string(),
|
|
7768
|
+
connectorId: z25.string(),
|
|
7769
|
+
webhookId: z25.string(),
|
|
7463
7770
|
status: WebhookRunStatusSchema,
|
|
7464
|
-
method:
|
|
7465
|
-
route:
|
|
7466
|
-
startedAt:
|
|
7467
|
-
finishedAt:
|
|
7468
|
-
requestBodyBytes:
|
|
7469
|
-
responseStatus:
|
|
7470
|
-
idempotencyKey:
|
|
7771
|
+
method: z25.string(),
|
|
7772
|
+
route: z25.string(),
|
|
7773
|
+
startedAt: z25.string(),
|
|
7774
|
+
finishedAt: z25.string().optional(),
|
|
7775
|
+
requestBodyBytes: z25.number(),
|
|
7776
|
+
responseStatus: z25.number().optional(),
|
|
7777
|
+
idempotencyKey: z25.string().optional(),
|
|
7471
7778
|
error: WebhookRunFailureSchema.optional()
|
|
7472
7779
|
});
|
|
7473
|
-
var WebhookRunListResponseSchema =
|
|
7474
|
-
runs:
|
|
7475
|
-
hasMore:
|
|
7476
|
-
total:
|
|
7780
|
+
var WebhookRunListResponseSchema = z25.object({
|
|
7781
|
+
runs: z25.array(WebhookRunSchema),
|
|
7782
|
+
hasMore: z25.boolean(),
|
|
7783
|
+
total: z25.number()
|
|
7477
7784
|
});
|
|
7478
7785
|
|
|
7479
7786
|
// src/routes/webhook-runs.ts
|
|
@@ -7548,25 +7855,25 @@ import {
|
|
|
7548
7855
|
snapshotWorkflowInterventionResponse
|
|
7549
7856
|
} from "@sixb/core/internal/workflows";
|
|
7550
7857
|
import { AGENT_RUN_FAILURE_CODES as AGENT_RUN_FAILURE_CODES2, WORKFLOW_RUN_FAILURE_CODES as WORKFLOW_RUN_FAILURE_CODES2 } from "@sixb/core/storage";
|
|
7551
|
-
import { z as
|
|
7858
|
+
import { z as z27 } from "zod";
|
|
7552
7859
|
|
|
7553
7860
|
// src/schemas/workflows.ts
|
|
7554
7861
|
import {
|
|
7555
7862
|
WORKFLOW_RUN_FAILURE_CODES
|
|
7556
7863
|
} from "@sixb/core/storage";
|
|
7557
|
-
import { z as
|
|
7558
|
-
var WorkflowIOSnapshotSchema =
|
|
7864
|
+
import { z as z26 } from "zod";
|
|
7865
|
+
var WorkflowIOSnapshotSchema = z26.record(JsonValueSchema);
|
|
7559
7866
|
var WorkflowRunFailureSchema = sixbFailureSchema(WORKFLOW_RUN_FAILURE_CODES);
|
|
7560
|
-
var WorkflowParamsSchema =
|
|
7561
|
-
workflowId:
|
|
7867
|
+
var WorkflowParamsSchema = z26.object({
|
|
7868
|
+
workflowId: z26.string().min(1)
|
|
7562
7869
|
});
|
|
7563
|
-
var WorkflowRunParamsSchema =
|
|
7564
|
-
runId:
|
|
7870
|
+
var WorkflowRunParamsSchema = z26.object({
|
|
7871
|
+
runId: z26.string().min(1)
|
|
7565
7872
|
});
|
|
7566
|
-
var WorkflowInterventionParamsSchema =
|
|
7567
|
-
interventionId:
|
|
7873
|
+
var WorkflowInterventionParamsSchema = z26.object({
|
|
7874
|
+
interventionId: z26.string().min(1)
|
|
7568
7875
|
});
|
|
7569
|
-
var WorkflowRunStatusSchema =
|
|
7876
|
+
var WorkflowRunStatusSchema = z26.enum([
|
|
7570
7877
|
"queued",
|
|
7571
7878
|
"running",
|
|
7572
7879
|
"waiting",
|
|
@@ -7574,91 +7881,91 @@ var WorkflowRunStatusSchema = z25.enum([
|
|
|
7574
7881
|
"failed",
|
|
7575
7882
|
"cancelled"
|
|
7576
7883
|
]);
|
|
7577
|
-
var WorkflowInterventionStatusSchema =
|
|
7884
|
+
var WorkflowInterventionStatusSchema = z26.enum([
|
|
7578
7885
|
"pending",
|
|
7579
7886
|
"submitted",
|
|
7580
7887
|
"cancelled",
|
|
7581
7888
|
"expired"
|
|
7582
7889
|
]);
|
|
7583
|
-
var WorkflowRunsQuerySchema =
|
|
7584
|
-
workflowId:
|
|
7890
|
+
var WorkflowRunsQuerySchema = z26.object({
|
|
7891
|
+
workflowId: z26.string().optional(),
|
|
7585
7892
|
status: WorkflowRunStatusSchema.optional(),
|
|
7586
|
-
startedAfter:
|
|
7587
|
-
startedBefore:
|
|
7588
|
-
limit:
|
|
7589
|
-
offset:
|
|
7590
|
-
order:
|
|
7591
|
-
});
|
|
7592
|
-
var WorkflowInterventionsQuerySchema =
|
|
7593
|
-
workflowId:
|
|
7594
|
-
workflowRunId:
|
|
7595
|
-
nodeRunId:
|
|
7596
|
-
nodeId:
|
|
7597
|
-
nodeKey:
|
|
7598
|
-
interventionId:
|
|
7893
|
+
startedAfter: z26.string().optional(),
|
|
7894
|
+
startedBefore: z26.string().optional(),
|
|
7895
|
+
limit: z26.string().optional(),
|
|
7896
|
+
offset: z26.string().optional(),
|
|
7897
|
+
order: z26.enum(["asc", "desc"]).optional()
|
|
7898
|
+
});
|
|
7899
|
+
var WorkflowInterventionsQuerySchema = z26.object({
|
|
7900
|
+
workflowId: z26.string().optional(),
|
|
7901
|
+
workflowRunId: z26.string().optional(),
|
|
7902
|
+
nodeRunId: z26.string().optional(),
|
|
7903
|
+
nodeId: z26.string().optional(),
|
|
7904
|
+
nodeKey: z26.string().optional(),
|
|
7905
|
+
interventionId: z26.string().optional(),
|
|
7599
7906
|
status: WorkflowInterventionStatusSchema.optional(),
|
|
7600
|
-
requestedAfter:
|
|
7601
|
-
requestedBefore:
|
|
7602
|
-
limit:
|
|
7603
|
-
offset:
|
|
7604
|
-
order:
|
|
7907
|
+
requestedAfter: z26.string().optional(),
|
|
7908
|
+
requestedBefore: z26.string().optional(),
|
|
7909
|
+
limit: z26.string().optional(),
|
|
7910
|
+
offset: z26.string().optional(),
|
|
7911
|
+
order: z26.enum(["asc", "desc"]).optional()
|
|
7605
7912
|
});
|
|
7606
|
-
var RequestWorkflowRunBodySchema =
|
|
7913
|
+
var RequestWorkflowRunBodySchema = z26.object({
|
|
7607
7914
|
input: WorkflowIOSnapshotSchema.optional()
|
|
7608
7915
|
}).default({});
|
|
7609
|
-
var WorkflowInterventionActorSchema =
|
|
7610
|
-
principalType:
|
|
7611
|
-
principalId:
|
|
7916
|
+
var WorkflowInterventionActorSchema = z26.object({
|
|
7917
|
+
principalType: z26.enum(["user", "serviceAccount", "system"]),
|
|
7918
|
+
principalId: z26.string().min(1)
|
|
7612
7919
|
});
|
|
7613
|
-
var CancelWorkflowRunBodySchema =
|
|
7614
|
-
var SubmitWorkflowInterventionBodySchema =
|
|
7920
|
+
var CancelWorkflowRunBodySchema = z26.object({}).default({});
|
|
7921
|
+
var SubmitWorkflowInterventionBodySchema = z26.object({
|
|
7615
7922
|
response: WorkflowIOSnapshotSchema
|
|
7616
7923
|
});
|
|
7617
|
-
var CancelWorkflowInterventionBodySchema =
|
|
7618
|
-
var WorkflowTriggerSchema =
|
|
7619
|
-
type:
|
|
7620
|
-
scheduleId:
|
|
7924
|
+
var CancelWorkflowInterventionBodySchema = z26.object({}).default({});
|
|
7925
|
+
var WorkflowTriggerSchema = z26.object({
|
|
7926
|
+
type: z26.literal("schedule"),
|
|
7927
|
+
scheduleId: z26.string()
|
|
7621
7928
|
});
|
|
7622
|
-
var WorkflowNodeSchema =
|
|
7623
|
-
|
|
7624
|
-
type:
|
|
7625
|
-
id:
|
|
7626
|
-
key:
|
|
7929
|
+
var WorkflowNodeSchema = z26.union([
|
|
7930
|
+
z26.object({
|
|
7931
|
+
type: z26.literal("step"),
|
|
7932
|
+
id: z26.string(),
|
|
7933
|
+
key: z26.string(),
|
|
7627
7934
|
input: WorkflowIOSnapshotSchema,
|
|
7628
7935
|
output: WorkflowIOSnapshotSchema
|
|
7629
7936
|
}),
|
|
7630
|
-
|
|
7631
|
-
type:
|
|
7632
|
-
id:
|
|
7633
|
-
key:
|
|
7634
|
-
objectTypeId:
|
|
7937
|
+
z26.object({
|
|
7938
|
+
type: z26.literal("action"),
|
|
7939
|
+
id: z26.string(),
|
|
7940
|
+
key: z26.string(),
|
|
7941
|
+
objectTypeId: z26.string().optional(),
|
|
7635
7942
|
params: WorkflowIOSnapshotSchema
|
|
7636
7943
|
}),
|
|
7637
|
-
|
|
7638
|
-
type:
|
|
7639
|
-
id:
|
|
7640
|
-
key:
|
|
7944
|
+
z26.object({
|
|
7945
|
+
type: z26.literal("intervention"),
|
|
7946
|
+
id: z26.string(),
|
|
7947
|
+
key: z26.string(),
|
|
7641
7948
|
input: WorkflowIOSnapshotSchema,
|
|
7642
7949
|
response: WorkflowIOSnapshotSchema,
|
|
7643
|
-
description:
|
|
7950
|
+
description: z26.string().optional()
|
|
7644
7951
|
}),
|
|
7645
|
-
|
|
7646
|
-
type:
|
|
7647
|
-
id:
|
|
7648
|
-
key:
|
|
7649
|
-
agentId:
|
|
7952
|
+
z26.object({
|
|
7953
|
+
type: z26.literal("agent"),
|
|
7954
|
+
id: z26.string(),
|
|
7955
|
+
key: z26.string(),
|
|
7956
|
+
agentId: z26.string(),
|
|
7650
7957
|
input: WorkflowIOSnapshotSchema,
|
|
7651
7958
|
output: WorkflowIOSnapshotSchema
|
|
7652
7959
|
})
|
|
7653
7960
|
]);
|
|
7654
|
-
var WorkflowRunSummarySchema =
|
|
7655
|
-
id:
|
|
7656
|
-
projectId:
|
|
7657
|
-
workflowId:
|
|
7961
|
+
var WorkflowRunSummarySchema = z26.object({
|
|
7962
|
+
id: z26.string(),
|
|
7963
|
+
projectId: z26.string(),
|
|
7964
|
+
workflowId: z26.string(),
|
|
7658
7965
|
status: WorkflowRunStatusSchema,
|
|
7659
|
-
queuedAt:
|
|
7660
|
-
startedAt:
|
|
7661
|
-
finishedAt:
|
|
7966
|
+
queuedAt: z26.string().optional(),
|
|
7967
|
+
startedAt: z26.string(),
|
|
7968
|
+
finishedAt: z26.string().optional(),
|
|
7662
7969
|
error: WorkflowRunFailureSchema.optional(),
|
|
7663
7970
|
requestedBy: WorkflowInterventionActorSchema
|
|
7664
7971
|
});
|
|
@@ -7666,108 +7973,111 @@ var WorkflowRunDetailSchema = WorkflowRunSummarySchema.extend({
|
|
|
7666
7973
|
input: WorkflowIOSnapshotSchema,
|
|
7667
7974
|
output: WorkflowIOSnapshotSchema.optional()
|
|
7668
7975
|
});
|
|
7669
|
-
var WorkflowAgentNodeExecutionSummarySchema =
|
|
7670
|
-
agentId:
|
|
7671
|
-
status:
|
|
7672
|
-
attempt:
|
|
7673
|
-
modelId:
|
|
7674
|
-
finishReason:
|
|
7976
|
+
var WorkflowAgentNodeExecutionSummarySchema = z26.object({
|
|
7977
|
+
agentId: z26.string(),
|
|
7978
|
+
status: z26.enum(["queued", "running", "succeeded", "failed", "cancelled"]),
|
|
7979
|
+
attempt: z26.number().int().nonnegative(),
|
|
7980
|
+
modelId: z26.string().optional(),
|
|
7981
|
+
finishReason: z26.string().optional(),
|
|
7675
7982
|
usage: AiUsageSummarySchema.optional(),
|
|
7676
|
-
|
|
7677
|
-
|
|
7983
|
+
cost: AiCostSummarySchema.optional(),
|
|
7984
|
+
startedAt: z26.string().optional(),
|
|
7985
|
+
completedAt: z26.string().optional()
|
|
7678
7986
|
});
|
|
7987
|
+
var WorkflowAgentFailurePhaseSchema = z26.enum(["agent-loop", "structured-finalizer"]);
|
|
7679
7988
|
var WorkflowAgentNodeExecutionSchema = WorkflowAgentNodeExecutionSummarySchema.extend({
|
|
7680
|
-
nodeRunId:
|
|
7681
|
-
prompt:
|
|
7682
|
-
trace:
|
|
7683
|
-
diagnostics:
|
|
7989
|
+
nodeRunId: z26.string(),
|
|
7990
|
+
prompt: z26.string(),
|
|
7991
|
+
trace: z26.array(AgentMessagePartSchema).optional(),
|
|
7992
|
+
diagnostics: z26.array(JsonValueSchema).optional(),
|
|
7993
|
+
failurePhase: WorkflowAgentFailurePhaseSchema.optional(),
|
|
7684
7994
|
error: AgentRunFailureSchema.optional(),
|
|
7685
|
-
createdAt:
|
|
7686
|
-
});
|
|
7687
|
-
var WorkflowNodeRunSchema =
|
|
7688
|
-
id:
|
|
7689
|
-
projectId:
|
|
7690
|
-
workflowRunId:
|
|
7691
|
-
workflowId:
|
|
7692
|
-
nodeIndex:
|
|
7693
|
-
nodeType:
|
|
7694
|
-
nodeId:
|
|
7695
|
-
nodeKey:
|
|
7696
|
-
status:
|
|
7995
|
+
createdAt: z26.string()
|
|
7996
|
+
});
|
|
7997
|
+
var WorkflowNodeRunSchema = z26.object({
|
|
7998
|
+
id: z26.string(),
|
|
7999
|
+
projectId: z26.string(),
|
|
8000
|
+
workflowRunId: z26.string(),
|
|
8001
|
+
workflowId: z26.string(),
|
|
8002
|
+
nodeIndex: z26.number(),
|
|
8003
|
+
nodeType: z26.enum(["step", "action", "intervention", "agent"]),
|
|
8004
|
+
nodeId: z26.string(),
|
|
8005
|
+
nodeKey: z26.string(),
|
|
8006
|
+
status: z26.enum(["running", "waiting", "succeeded", "failed", "cancelled"]),
|
|
7697
8007
|
input: WorkflowIOSnapshotSchema,
|
|
7698
|
-
startedAt:
|
|
7699
|
-
finishedAt:
|
|
8008
|
+
startedAt: z26.string(),
|
|
8009
|
+
finishedAt: z26.string().optional(),
|
|
7700
8010
|
output: WorkflowIOSnapshotSchema.optional(),
|
|
7701
8011
|
error: WorkflowRunFailureSchema.optional(),
|
|
7702
8012
|
agentExecution: WorkflowAgentNodeExecutionSummarySchema.optional()
|
|
7703
8013
|
});
|
|
7704
|
-
var WorkflowInterventionSchema =
|
|
7705
|
-
id:
|
|
7706
|
-
projectId:
|
|
7707
|
-
workflowId:
|
|
7708
|
-
workflowRunId:
|
|
7709
|
-
nodeRunId:
|
|
7710
|
-
nodeIndex:
|
|
7711
|
-
nodeId:
|
|
7712
|
-
nodeKey:
|
|
7713
|
-
interventionId:
|
|
8014
|
+
var WorkflowInterventionSchema = z26.object({
|
|
8015
|
+
id: z26.string(),
|
|
8016
|
+
projectId: z26.string(),
|
|
8017
|
+
workflowId: z26.string(),
|
|
8018
|
+
workflowRunId: z26.string(),
|
|
8019
|
+
nodeRunId: z26.string(),
|
|
8020
|
+
nodeIndex: z26.number(),
|
|
8021
|
+
nodeId: z26.string(),
|
|
8022
|
+
nodeKey: z26.string(),
|
|
8023
|
+
interventionId: z26.string(),
|
|
7714
8024
|
input: WorkflowIOSnapshotSchema,
|
|
7715
8025
|
defaultResponse: WorkflowIOSnapshotSchema,
|
|
7716
8026
|
status: WorkflowInterventionStatusSchema,
|
|
7717
|
-
requestedAt:
|
|
7718
|
-
expiresAt:
|
|
7719
|
-
submittedAt:
|
|
8027
|
+
requestedAt: z26.string(),
|
|
8028
|
+
expiresAt: z26.string().optional(),
|
|
8029
|
+
submittedAt: z26.string().optional(),
|
|
7720
8030
|
submittedBy: WorkflowInterventionActorSchema.optional(),
|
|
7721
8031
|
response: WorkflowIOSnapshotSchema.optional(),
|
|
7722
|
-
cancelledAt:
|
|
8032
|
+
cancelledAt: z26.string().optional(),
|
|
7723
8033
|
cancelledBy: WorkflowInterventionActorSchema.optional(),
|
|
7724
|
-
expiredAt:
|
|
8034
|
+
expiredAt: z26.string().optional()
|
|
7725
8035
|
});
|
|
7726
|
-
var WorkflowSchema =
|
|
7727
|
-
id:
|
|
8036
|
+
var WorkflowSchema = z26.object({
|
|
8037
|
+
id: z26.string(),
|
|
7728
8038
|
input: WorkflowIOSnapshotSchema,
|
|
7729
|
-
triggers:
|
|
7730
|
-
nodes:
|
|
8039
|
+
triggers: z26.array(WorkflowTriggerSchema),
|
|
8040
|
+
nodes: z26.array(WorkflowNodeSchema),
|
|
7731
8041
|
latestRun: WorkflowRunSummarySchema.nullable()
|
|
7732
8042
|
});
|
|
7733
|
-
var WorkflowRunListResponseSchema =
|
|
7734
|
-
runs:
|
|
7735
|
-
hasMore:
|
|
7736
|
-
total:
|
|
8043
|
+
var WorkflowRunListResponseSchema = z26.object({
|
|
8044
|
+
runs: z26.array(WorkflowRunSummarySchema),
|
|
8045
|
+
hasMore: z26.boolean(),
|
|
8046
|
+
total: z26.number()
|
|
7737
8047
|
});
|
|
7738
|
-
var WorkflowRunDetailResponseSchema =
|
|
8048
|
+
var WorkflowRunDetailResponseSchema = z26.object({
|
|
7739
8049
|
run: WorkflowRunDetailSchema,
|
|
7740
|
-
nodes:
|
|
8050
|
+
nodes: z26.array(WorkflowNodeRunSchema)
|
|
7741
8051
|
});
|
|
7742
8052
|
var CancelWorkflowRunResponseSchema = WorkflowRunDetailResponseSchema;
|
|
7743
|
-
var WorkflowInterventionListResponseSchema =
|
|
7744
|
-
interventions:
|
|
7745
|
-
hasMore:
|
|
7746
|
-
total:
|
|
8053
|
+
var WorkflowInterventionListResponseSchema = z26.object({
|
|
8054
|
+
interventions: z26.array(WorkflowInterventionSchema),
|
|
8055
|
+
hasMore: z26.boolean(),
|
|
8056
|
+
total: z26.number()
|
|
7747
8057
|
});
|
|
7748
|
-
var SubmitWorkflowInterventionResponseSchema =
|
|
8058
|
+
var SubmitWorkflowInterventionResponseSchema = z26.object({
|
|
7749
8059
|
intervention: WorkflowInterventionSchema,
|
|
7750
|
-
jobId:
|
|
8060
|
+
jobId: z26.string()
|
|
7751
8061
|
});
|
|
7752
|
-
var CancelWorkflowInterventionResponseSchema =
|
|
8062
|
+
var CancelWorkflowInterventionResponseSchema = z26.object({
|
|
7753
8063
|
intervention: WorkflowInterventionSchema
|
|
7754
8064
|
});
|
|
7755
|
-
var RequestWorkflowRunResponseSchema =
|
|
7756
|
-
runId:
|
|
7757
|
-
jobId:
|
|
7758
|
-
workflowId:
|
|
7759
|
-
queuedAt:
|
|
8065
|
+
var RequestWorkflowRunResponseSchema = z26.object({
|
|
8066
|
+
runId: z26.string(),
|
|
8067
|
+
jobId: z26.string(),
|
|
8068
|
+
workflowId: z26.string(),
|
|
8069
|
+
queuedAt: z26.string()
|
|
7760
8070
|
});
|
|
7761
8071
|
|
|
7762
8072
|
// src/routes/workflows.ts
|
|
7763
8073
|
var WorkflowRunFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
7764
|
-
path:
|
|
8074
|
+
path: z27.string().min(1).regex(/^\/(?:input|output)(?:\/|$)/, "Workflow run file content paths must start with /input/ or /output/")
|
|
7765
8075
|
});
|
|
7766
8076
|
var WorkflowNodeFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
7767
|
-
path:
|
|
8077
|
+
path: z27.string().min(1).regex(/^\/(?:input|output)(?:\/|$)/, "Workflow node file content paths must start with /input/ or /output/")
|
|
7768
8078
|
});
|
|
7769
8079
|
var WorkflowNodeFileContentParamsSchema = WorkflowRunParamsSchema.extend({
|
|
7770
|
-
nodeKey:
|
|
8080
|
+
nodeKey: z27.string().min(1)
|
|
7771
8081
|
});
|
|
7772
8082
|
function serializeWorkflowRunSummary(run) {
|
|
7773
8083
|
return {
|
|
@@ -7819,6 +8129,7 @@ function serializeWorkflowAgentExecutionSummary(execution) {
|
|
|
7819
8129
|
modelId: execution.modelId,
|
|
7820
8130
|
finishReason: execution.finishReason,
|
|
7821
8131
|
usage: execution.usage,
|
|
8132
|
+
cost: execution.cost,
|
|
7822
8133
|
startedAt: execution.startedAt ? toIsoString(execution.startedAt) : undefined,
|
|
7823
8134
|
completedAt: execution.completedAt ? toIsoString(execution.completedAt) : undefined
|
|
7824
8135
|
};
|
|
@@ -7830,10 +8141,21 @@ function serializeWorkflowAgentExecution(execution) {
|
|
|
7830
8141
|
prompt: execution.prompt,
|
|
7831
8142
|
trace: execution.trace,
|
|
7832
8143
|
diagnostics: execution.diagnostics,
|
|
8144
|
+
failurePhase: workflowAgentFailurePhase(execution),
|
|
7833
8145
|
error: execution.error,
|
|
7834
8146
|
createdAt: toIsoString(execution.createdAt)
|
|
7835
8147
|
};
|
|
7836
8148
|
}
|
|
8149
|
+
function workflowAgentFailurePhase(execution) {
|
|
8150
|
+
const details = execution.error?.details;
|
|
8151
|
+
if (!isRecord(details))
|
|
8152
|
+
return;
|
|
8153
|
+
const phase = details.failurePhase;
|
|
8154
|
+
return phase === "agent-loop" || phase === "structured-finalizer" ? phase : undefined;
|
|
8155
|
+
}
|
|
8156
|
+
function isRecord(value) {
|
|
8157
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8158
|
+
}
|
|
7837
8159
|
function principalForExecution(sixb) {
|
|
7838
8160
|
return sixb.execution.requestedBy ?? SYSTEM_PRINCIPAL2;
|
|
7839
8161
|
}
|
|
@@ -8780,6 +9102,7 @@ function registerWorkflowRoutes(app, host) {
|
|
|
8780
9102
|
// src/registerRoutes.ts
|
|
8781
9103
|
function registerHttpRoutes(app, host, options) {
|
|
8782
9104
|
registerAgentApiGatewayRoutes(app, host);
|
|
9105
|
+
registerAiAccountingRoutes(app, host);
|
|
8783
9106
|
registerProjectRoutes(app, host);
|
|
8784
9107
|
registerStatusRoutes(app, host);
|
|
8785
9108
|
registerConnectorRoutes(app, host);
|
|
@@ -8826,275 +9149,405 @@ import {
|
|
|
8826
9149
|
} from "@sixb/core/storage";
|
|
8827
9150
|
import { t } from "elysia";
|
|
8828
9151
|
|
|
9152
|
+
// src/auth/experience.ts
|
|
9153
|
+
import { resolve } from "path";
|
|
9154
|
+
var AUTH_BOOTSTRAP_PLACEHOLDER = "__SIXB_AUTH_BOOTSTRAP__";
|
|
9155
|
+
var AUTH_ASSET_PREFIX = "/auth/assets/";
|
|
9156
|
+
async function customAuthExperienceResponse(options, input) {
|
|
9157
|
+
if (!options || input.audience !== (options.audience ?? "app")) {
|
|
9158
|
+
return null;
|
|
9159
|
+
}
|
|
9160
|
+
const template = Bun.file(resolve(options.outdir, "index.html"));
|
|
9161
|
+
if (!await template.exists()) {
|
|
9162
|
+
return null;
|
|
9163
|
+
}
|
|
9164
|
+
const html = await template.text();
|
|
9165
|
+
if (!html.includes(AUTH_BOOTSTRAP_PLACEHOLDER)) {
|
|
9166
|
+
console.warn(`[SixbServer] Custom auth experience in ${options.outdir} is missing its bootstrap placeholder. Using the generic page.`);
|
|
9167
|
+
return null;
|
|
9168
|
+
}
|
|
9169
|
+
const bootstrap = Buffer.from(JSON.stringify({
|
|
9170
|
+
state: input.state,
|
|
9171
|
+
signInUrl: input.signInUrl,
|
|
9172
|
+
...input.submission ? { submission: input.submission } : {}
|
|
9173
|
+
})).toString("base64url");
|
|
9174
|
+
const formAction = ["'self'", ...(input.formActionOrigins ?? []).map(normalizeCspOrigin)].join(" ");
|
|
9175
|
+
return new Response(html.replace(AUTH_BOOTSTRAP_PLACEHOLDER, bootstrap), {
|
|
9176
|
+
status: input.status ?? 200,
|
|
9177
|
+
headers: {
|
|
9178
|
+
"content-type": "text/html; charset=utf-8",
|
|
9179
|
+
"cache-control": "no-store",
|
|
9180
|
+
"content-security-policy": [
|
|
9181
|
+
"default-src 'none'",
|
|
9182
|
+
"script-src 'self'",
|
|
9183
|
+
"style-src 'self' 'unsafe-inline'",
|
|
9184
|
+
"img-src 'self' data:",
|
|
9185
|
+
"font-src 'self'",
|
|
9186
|
+
"base-uri 'none'",
|
|
9187
|
+
`form-action ${formAction}`,
|
|
9188
|
+
"frame-ancestors 'none'"
|
|
9189
|
+
].join("; "),
|
|
9190
|
+
"referrer-policy": input.referrerPolicy ?? "no-referrer",
|
|
9191
|
+
"x-content-type-options": "nosniff"
|
|
9192
|
+
}
|
|
9193
|
+
});
|
|
9194
|
+
}
|
|
9195
|
+
function normalizeCspOrigin(value) {
|
|
9196
|
+
let url;
|
|
9197
|
+
try {
|
|
9198
|
+
url = new URL(value);
|
|
9199
|
+
} catch {
|
|
9200
|
+
throw new Error(`[SixbServer] Invalid custom auth form-action origin: '${value}'.`);
|
|
9201
|
+
}
|
|
9202
|
+
if (url.protocol !== "http:" && url.protocol !== "https:" || url.origin !== value) {
|
|
9203
|
+
throw new Error(`[SixbServer] Invalid custom auth form-action origin: '${value}'.`);
|
|
9204
|
+
}
|
|
9205
|
+
return url.origin;
|
|
9206
|
+
}
|
|
9207
|
+
async function customAuthExperienceAssetResponse(options, request) {
|
|
9208
|
+
const method = request.method.toUpperCase();
|
|
9209
|
+
if (!options || method !== "GET" && method !== "HEAD") {
|
|
9210
|
+
return notFoundResponse();
|
|
9211
|
+
}
|
|
9212
|
+
const url = new URL(request.url);
|
|
9213
|
+
if (!url.pathname.startsWith(AUTH_ASSET_PREFIX)) {
|
|
9214
|
+
return notFoundResponse();
|
|
9215
|
+
}
|
|
9216
|
+
let fileName;
|
|
9217
|
+
try {
|
|
9218
|
+
fileName = decodeURIComponent(url.pathname.slice(AUTH_ASSET_PREFIX.length));
|
|
9219
|
+
} catch {
|
|
9220
|
+
return notFoundResponse();
|
|
9221
|
+
}
|
|
9222
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(fileName)) {
|
|
9223
|
+
return notFoundResponse();
|
|
9224
|
+
}
|
|
9225
|
+
const path = resolve(options.outdir, "assets", fileName);
|
|
9226
|
+
const source = Bun.file(path);
|
|
9227
|
+
if (!await source.exists()) {
|
|
9228
|
+
return notFoundResponse();
|
|
9229
|
+
}
|
|
9230
|
+
const encoding = await resolvePrecompressedAsset(request, path);
|
|
9231
|
+
const body = encoding ? Bun.file(`${path}.${encoding === "br" ? "br" : "gz"}`) : source;
|
|
9232
|
+
const headers = new Headers({
|
|
9233
|
+
"content-type": source.type || "application/octet-stream",
|
|
9234
|
+
"cache-control": "public, max-age=31536000, immutable",
|
|
9235
|
+
"x-content-type-options": "nosniff"
|
|
9236
|
+
});
|
|
9237
|
+
if (encoding) {
|
|
9238
|
+
headers.set("content-encoding", encoding);
|
|
9239
|
+
headers.set("vary", "Accept-Encoding");
|
|
9240
|
+
}
|
|
9241
|
+
return new Response(method === "HEAD" ? null : body, { headers });
|
|
9242
|
+
}
|
|
9243
|
+
async function resolvePrecompressedAsset(request, sourcePath) {
|
|
9244
|
+
for (const encoding of acceptedPrecompressedEncodings(request)) {
|
|
9245
|
+
const suffix = encoding === "br" ? "br" : "gz";
|
|
9246
|
+
if (await Bun.file(`${sourcePath}.${suffix}`).exists()) {
|
|
9247
|
+
return encoding;
|
|
9248
|
+
}
|
|
9249
|
+
}
|
|
9250
|
+
return null;
|
|
9251
|
+
}
|
|
9252
|
+
function acceptedPrecompressedEncodings(request) {
|
|
9253
|
+
const header = request.headers.get("accept-encoding");
|
|
9254
|
+
if (!header)
|
|
9255
|
+
return [];
|
|
9256
|
+
const qualities = new Map;
|
|
9257
|
+
for (const item of header.split(",")) {
|
|
9258
|
+
const [rawName, ...parameters] = item.trim().split(";");
|
|
9259
|
+
const name = rawName.toLowerCase();
|
|
9260
|
+
let quality = 1;
|
|
9261
|
+
for (const parameter of parameters) {
|
|
9262
|
+
const match = parameter.trim().match(/^q=(0(?:\.\d+)?|1(?:\.0+)?)$/);
|
|
9263
|
+
if (match)
|
|
9264
|
+
quality = Number(match[1]);
|
|
9265
|
+
}
|
|
9266
|
+
qualities.set(name, quality);
|
|
9267
|
+
}
|
|
9268
|
+
const wildcard = qualities.get("*") ?? 0;
|
|
9269
|
+
return ["br", "gzip"].map((encoding, preference) => ({
|
|
9270
|
+
encoding,
|
|
9271
|
+
preference,
|
|
9272
|
+
quality: qualities.get(encoding) ?? wildcard
|
|
9273
|
+
})).filter((candidate) => candidate.quality > 0).sort((left, right) => right.quality - left.quality || left.preference - right.preference).map((candidate) => candidate.encoding);
|
|
9274
|
+
}
|
|
9275
|
+
function notFoundResponse() {
|
|
9276
|
+
return new Response("Not Found", {
|
|
9277
|
+
status: 404,
|
|
9278
|
+
headers: { "content-type": "text/plain; charset=utf-8" }
|
|
9279
|
+
});
|
|
9280
|
+
}
|
|
9281
|
+
|
|
8829
9282
|
// src/schemas/auth.ts
|
|
8830
|
-
import { z as
|
|
8831
|
-
var AuthInvitationStatusSchema =
|
|
8832
|
-
var AuthGroupOptionSchema =
|
|
8833
|
-
id:
|
|
8834
|
-
label:
|
|
8835
|
-
description:
|
|
8836
|
-
});
|
|
8837
|
-
var AuthInvitationSchema =
|
|
8838
|
-
id:
|
|
8839
|
-
email:
|
|
8840
|
-
groupIds:
|
|
9283
|
+
import { z as z28 } from "zod";
|
|
9284
|
+
var AuthInvitationStatusSchema = z28.enum(["pending", "accepted", "revoked"]);
|
|
9285
|
+
var AuthGroupOptionSchema = z28.object({
|
|
9286
|
+
id: z28.string(),
|
|
9287
|
+
label: z28.string().optional(),
|
|
9288
|
+
description: z28.string().optional()
|
|
9289
|
+
});
|
|
9290
|
+
var AuthInvitationSchema = z28.object({
|
|
9291
|
+
id: z28.string(),
|
|
9292
|
+
email: z28.string(),
|
|
9293
|
+
groupIds: z28.array(z28.string()),
|
|
8841
9294
|
status: AuthInvitationStatusSchema,
|
|
8842
|
-
createdAt:
|
|
8843
|
-
updatedAt:
|
|
8844
|
-
expiresAt:
|
|
8845
|
-
acceptedAt:
|
|
8846
|
-
revokedAt:
|
|
9295
|
+
createdAt: z28.string(),
|
|
9296
|
+
updatedAt: z28.string(),
|
|
9297
|
+
expiresAt: z28.string(),
|
|
9298
|
+
acceptedAt: z28.string().optional(),
|
|
9299
|
+
revokedAt: z28.string().optional()
|
|
8847
9300
|
});
|
|
8848
|
-
var AuthInvitationDeliverySchema =
|
|
8849
|
-
status:
|
|
9301
|
+
var AuthInvitationDeliverySchema = z28.object({
|
|
9302
|
+
status: z28.enum(["sent", "skipped", "rate_limited", "not_supported"])
|
|
8850
9303
|
});
|
|
8851
9304
|
var AuthInvitationGroupOptionSchema = AuthGroupOptionSchema;
|
|
8852
|
-
var AuthAccessTokenKindSchema =
|
|
8853
|
-
var AuthAccessTokenSubjectTypeSchema =
|
|
8854
|
-
var AuthAccessTokenStatusSchema =
|
|
8855
|
-
var AuthServiceAccountStatusSchema =
|
|
8856
|
-
var AuthUserStatusSchema =
|
|
8857
|
-
var AuthAccessTokenSchema =
|
|
8858
|
-
id:
|
|
8859
|
-
name:
|
|
9305
|
+
var AuthAccessTokenKindSchema = z28.enum(["personal", "serviceAccount"]);
|
|
9306
|
+
var AuthAccessTokenSubjectTypeSchema = z28.enum(["user", "serviceAccount"]);
|
|
9307
|
+
var AuthAccessTokenStatusSchema = z28.enum(["active", "expired", "revoked"]);
|
|
9308
|
+
var AuthServiceAccountStatusSchema = z28.enum(["active", "suspended"]);
|
|
9309
|
+
var AuthUserStatusSchema = z28.enum(["active", "suspended"]);
|
|
9310
|
+
var AuthAccessTokenSchema = z28.object({
|
|
9311
|
+
id: z28.string(),
|
|
9312
|
+
name: z28.string(),
|
|
8860
9313
|
kind: AuthAccessTokenKindSchema,
|
|
8861
9314
|
status: AuthAccessTokenStatusSchema,
|
|
8862
9315
|
subjectType: AuthAccessTokenSubjectTypeSchema,
|
|
8863
|
-
subjectId:
|
|
8864
|
-
subjectLabel:
|
|
8865
|
-
groupIds:
|
|
8866
|
-
createdAt:
|
|
8867
|
-
expiresAt:
|
|
8868
|
-
revokedAt:
|
|
8869
|
-
lastUsedAt:
|
|
8870
|
-
lastUsedUserAgent:
|
|
8871
|
-
lastUsedIpAddress:
|
|
8872
|
-
});
|
|
8873
|
-
var AuthServiceAccountSchema =
|
|
8874
|
-
id:
|
|
8875
|
-
name:
|
|
8876
|
-
description:
|
|
9316
|
+
subjectId: z28.string(),
|
|
9317
|
+
subjectLabel: z28.string().optional(),
|
|
9318
|
+
groupIds: z28.array(z28.string()).optional(),
|
|
9319
|
+
createdAt: z28.string(),
|
|
9320
|
+
expiresAt: z28.string(),
|
|
9321
|
+
revokedAt: z28.string().optional(),
|
|
9322
|
+
lastUsedAt: z28.string().optional(),
|
|
9323
|
+
lastUsedUserAgent: z28.string().optional(),
|
|
9324
|
+
lastUsedIpAddress: z28.string().optional()
|
|
9325
|
+
});
|
|
9326
|
+
var AuthServiceAccountSchema = z28.object({
|
|
9327
|
+
id: z28.string(),
|
|
9328
|
+
name: z28.string(),
|
|
9329
|
+
description: z28.string().optional(),
|
|
8877
9330
|
status: AuthServiceAccountStatusSchema,
|
|
8878
|
-
groupIds:
|
|
8879
|
-
createdAt:
|
|
8880
|
-
updatedAt:
|
|
8881
|
-
});
|
|
8882
|
-
var AuthMemberUserSchema =
|
|
8883
|
-
id:
|
|
8884
|
-
email:
|
|
8885
|
-
displayName:
|
|
8886
|
-
avatarUrl:
|
|
9331
|
+
groupIds: z28.array(z28.string()),
|
|
9332
|
+
createdAt: z28.string(),
|
|
9333
|
+
updatedAt: z28.string()
|
|
9334
|
+
});
|
|
9335
|
+
var AuthMemberUserSchema = z28.object({
|
|
9336
|
+
id: z28.string(),
|
|
9337
|
+
email: z28.string(),
|
|
9338
|
+
displayName: z28.string().optional(),
|
|
9339
|
+
avatarUrl: z28.string().optional(),
|
|
8887
9340
|
status: AuthUserStatusSchema,
|
|
8888
|
-
createdAt:
|
|
8889
|
-
updatedAt:
|
|
9341
|
+
createdAt: z28.string(),
|
|
9342
|
+
updatedAt: z28.string()
|
|
8890
9343
|
});
|
|
8891
|
-
var AuthManagedMemberSchema =
|
|
9344
|
+
var AuthManagedMemberSchema = z28.object({
|
|
8892
9345
|
user: AuthMemberUserSchema,
|
|
8893
|
-
groupIds:
|
|
9346
|
+
groupIds: z28.array(z28.string())
|
|
8894
9347
|
});
|
|
8895
|
-
var AuthMemberCapabilitiesSchema =
|
|
8896
|
-
assignGroups:
|
|
8897
|
-
suspend:
|
|
8898
|
-
reactivate:
|
|
9348
|
+
var AuthMemberCapabilitiesSchema = z28.object({
|
|
9349
|
+
assignGroups: z28.boolean(),
|
|
9350
|
+
suspend: z28.boolean(),
|
|
9351
|
+
reactivate: z28.boolean()
|
|
8899
9352
|
});
|
|
8900
9353
|
var AuthMemberSchema = AuthManagedMemberSchema.extend({
|
|
8901
9354
|
capabilities: AuthMemberCapabilitiesSchema
|
|
8902
9355
|
});
|
|
8903
|
-
var GetAuthAccessManagementOptionsResponseSchema =
|
|
8904
|
-
groups:
|
|
9356
|
+
var GetAuthAccessManagementOptionsResponseSchema = z28.object({
|
|
9357
|
+
groups: z28.array(AuthGroupOptionSchema)
|
|
8905
9358
|
});
|
|
8906
|
-
var ListAuthAccessTokensResponseSchema =
|
|
8907
|
-
accessTokens:
|
|
9359
|
+
var ListAuthAccessTokensResponseSchema = z28.object({
|
|
9360
|
+
accessTokens: z28.array(AuthAccessTokenSchema)
|
|
8908
9361
|
});
|
|
8909
|
-
var CreateAuthPersonalAccessTokenBodySchema =
|
|
8910
|
-
name:
|
|
8911
|
-
expiresAt:
|
|
8912
|
-
groupIds:
|
|
9362
|
+
var CreateAuthPersonalAccessTokenBodySchema = z28.object({
|
|
9363
|
+
name: z28.string().trim().min(1),
|
|
9364
|
+
expiresAt: z28.string().min(1),
|
|
9365
|
+
groupIds: z28.array(z28.string().min(1)).optional()
|
|
8913
9366
|
});
|
|
8914
|
-
var CreateAuthPersonalAccessTokenResponseSchema =
|
|
9367
|
+
var CreateAuthPersonalAccessTokenResponseSchema = z28.object({
|
|
8915
9368
|
accessToken: AuthAccessTokenSchema,
|
|
8916
|
-
tokenValue:
|
|
9369
|
+
tokenValue: z28.string()
|
|
8917
9370
|
});
|
|
8918
|
-
var RevokeAuthAccessTokenParamsSchema =
|
|
8919
|
-
tokenId:
|
|
9371
|
+
var RevokeAuthAccessTokenParamsSchema = z28.object({
|
|
9372
|
+
tokenId: z28.string().min(1)
|
|
8920
9373
|
});
|
|
8921
|
-
var RevokeAuthAccessTokenResponseSchema =
|
|
9374
|
+
var RevokeAuthAccessTokenResponseSchema = z28.object({
|
|
8922
9375
|
accessToken: AuthAccessTokenSchema
|
|
8923
9376
|
});
|
|
8924
|
-
var ListAuthServiceAccountsResponseSchema =
|
|
8925
|
-
serviceAccounts:
|
|
9377
|
+
var ListAuthServiceAccountsResponseSchema = z28.object({
|
|
9378
|
+
serviceAccounts: z28.array(AuthServiceAccountSchema)
|
|
8926
9379
|
});
|
|
8927
|
-
var CreateAuthServiceAccountBodySchema =
|
|
8928
|
-
id:
|
|
8929
|
-
name:
|
|
8930
|
-
description:
|
|
8931
|
-
groupIds:
|
|
9380
|
+
var CreateAuthServiceAccountBodySchema = z28.object({
|
|
9381
|
+
id: z28.string().trim().min(1).optional(),
|
|
9382
|
+
name: z28.string().trim().min(1),
|
|
9383
|
+
description: z28.string().trim().optional(),
|
|
9384
|
+
groupIds: z28.array(z28.string().min(1)).optional()
|
|
8932
9385
|
});
|
|
8933
|
-
var CreateAuthServiceAccountResponseSchema =
|
|
9386
|
+
var CreateAuthServiceAccountResponseSchema = z28.object({
|
|
8934
9387
|
serviceAccount: AuthServiceAccountSchema
|
|
8935
9388
|
});
|
|
8936
|
-
var AuthServiceAccountParamsSchema =
|
|
8937
|
-
serviceAccountId:
|
|
9389
|
+
var AuthServiceAccountParamsSchema = z28.object({
|
|
9390
|
+
serviceAccountId: z28.string().min(1)
|
|
8938
9391
|
});
|
|
8939
|
-
var DisableAuthServiceAccountResponseSchema =
|
|
9392
|
+
var DisableAuthServiceAccountResponseSchema = z28.object({
|
|
8940
9393
|
serviceAccount: AuthServiceAccountSchema
|
|
8941
9394
|
});
|
|
8942
|
-
var ListAuthServiceAccountAccessTokensResponseSchema =
|
|
8943
|
-
accessTokens:
|
|
9395
|
+
var ListAuthServiceAccountAccessTokensResponseSchema = z28.object({
|
|
9396
|
+
accessTokens: z28.array(AuthAccessTokenSchema)
|
|
8944
9397
|
});
|
|
8945
|
-
var CreateAuthServiceAccountAccessTokenBodySchema =
|
|
8946
|
-
name:
|
|
8947
|
-
expiresAt:
|
|
8948
|
-
groupIds:
|
|
9398
|
+
var CreateAuthServiceAccountAccessTokenBodySchema = z28.object({
|
|
9399
|
+
name: z28.string().trim().min(1),
|
|
9400
|
+
expiresAt: z28.string().min(1),
|
|
9401
|
+
groupIds: z28.array(z28.string().min(1)).optional()
|
|
8949
9402
|
});
|
|
8950
|
-
var CreateAuthServiceAccountAccessTokenResponseSchema =
|
|
9403
|
+
var CreateAuthServiceAccountAccessTokenResponseSchema = z28.object({
|
|
8951
9404
|
accessToken: AuthAccessTokenSchema,
|
|
8952
|
-
tokenValue:
|
|
9405
|
+
tokenValue: z28.string()
|
|
8953
9406
|
});
|
|
8954
9407
|
var RevokeAuthServiceAccountAccessTokenParamsSchema = AuthServiceAccountParamsSchema.extend({
|
|
8955
|
-
tokenId:
|
|
9408
|
+
tokenId: z28.string().min(1)
|
|
8956
9409
|
});
|
|
8957
|
-
var RevokeAuthServiceAccountAccessTokenResponseSchema =
|
|
9410
|
+
var RevokeAuthServiceAccountAccessTokenResponseSchema = z28.object({
|
|
8958
9411
|
accessToken: AuthAccessTokenSchema
|
|
8959
9412
|
});
|
|
8960
|
-
var AuthCreateInvitationCapabilitySchema =
|
|
8961
|
-
|
|
8962
|
-
state:
|
|
9413
|
+
var AuthCreateInvitationCapabilitySchema = z28.union([
|
|
9414
|
+
z28.object({
|
|
9415
|
+
state: z28.literal("enabled")
|
|
8963
9416
|
}),
|
|
8964
|
-
|
|
8965
|
-
state:
|
|
8966
|
-
reason:
|
|
9417
|
+
z28.object({
|
|
9418
|
+
state: z28.literal("disabled"),
|
|
9419
|
+
reason: z28.enum(["missing_membership_policy", "invitation_delivery_not_supported"])
|
|
8967
9420
|
})
|
|
8968
9421
|
]);
|
|
8969
|
-
var AuthInvitationDestinationSchema =
|
|
8970
|
-
id:
|
|
8971
|
-
label:
|
|
8972
|
-
});
|
|
8973
|
-
var GetAuthInvitationOptionsResponseSchema =
|
|
8974
|
-
groups:
|
|
8975
|
-
destinations:
|
|
8976
|
-
defaultDestinationId:
|
|
8977
|
-
canInviteWithoutGroups:
|
|
8978
|
-
capabilities:
|
|
9422
|
+
var AuthInvitationDestinationSchema = z28.object({
|
|
9423
|
+
id: z28.enum(["atlas", "app"]),
|
|
9424
|
+
label: z28.string()
|
|
9425
|
+
});
|
|
9426
|
+
var GetAuthInvitationOptionsResponseSchema = z28.object({
|
|
9427
|
+
groups: z28.array(AuthInvitationGroupOptionSchema),
|
|
9428
|
+
destinations: z28.array(AuthInvitationDestinationSchema),
|
|
9429
|
+
defaultDestinationId: z28.enum(["atlas", "app"]).optional(),
|
|
9430
|
+
canInviteWithoutGroups: z28.boolean(),
|
|
9431
|
+
capabilities: z28.object({
|
|
8979
9432
|
createInvitation: AuthCreateInvitationCapabilitySchema
|
|
8980
9433
|
})
|
|
8981
9434
|
});
|
|
8982
|
-
var GetAuthMembershipOptionsResponseSchema =
|
|
8983
|
-
groups:
|
|
8984
|
-
capabilities:
|
|
8985
|
-
invite:
|
|
8986
|
-
assignGroups:
|
|
8987
|
-
suspend:
|
|
9435
|
+
var GetAuthMembershipOptionsResponseSchema = z28.object({
|
|
9436
|
+
groups: z28.array(AuthGroupOptionSchema),
|
|
9437
|
+
capabilities: z28.object({
|
|
9438
|
+
invite: z28.boolean(),
|
|
9439
|
+
assignGroups: z28.boolean(),
|
|
9440
|
+
suspend: z28.boolean()
|
|
8988
9441
|
})
|
|
8989
9442
|
});
|
|
8990
|
-
var ListAuthMembersQuerySchema =
|
|
8991
|
-
limit:
|
|
8992
|
-
offset:
|
|
8993
|
-
order:
|
|
9443
|
+
var ListAuthMembersQuerySchema = z28.object({
|
|
9444
|
+
limit: z28.string().optional(),
|
|
9445
|
+
offset: z28.string().optional(),
|
|
9446
|
+
order: z28.enum(["asc", "desc"]).optional()
|
|
8994
9447
|
});
|
|
8995
|
-
var ListAuthMembersResponseSchema =
|
|
8996
|
-
members:
|
|
8997
|
-
hasMore:
|
|
8998
|
-
total:
|
|
9448
|
+
var ListAuthMembersResponseSchema = z28.object({
|
|
9449
|
+
members: z28.array(AuthMemberSchema),
|
|
9450
|
+
hasMore: z28.boolean(),
|
|
9451
|
+
total: z28.number()
|
|
8999
9452
|
});
|
|
9000
|
-
var AuthMemberParamsSchema =
|
|
9001
|
-
userId:
|
|
9453
|
+
var AuthMemberParamsSchema = z28.object({
|
|
9454
|
+
userId: z28.string().min(1)
|
|
9002
9455
|
});
|
|
9003
|
-
var UpdateAuthMemberGroupsBodySchema =
|
|
9004
|
-
groupIds:
|
|
9456
|
+
var UpdateAuthMemberGroupsBodySchema = z28.object({
|
|
9457
|
+
groupIds: z28.array(z28.string().min(1))
|
|
9005
9458
|
});
|
|
9006
|
-
var UpdateAuthMemberGroupsResponseSchema =
|
|
9459
|
+
var UpdateAuthMemberGroupsResponseSchema = z28.object({
|
|
9007
9460
|
member: AuthManagedMemberSchema
|
|
9008
9461
|
});
|
|
9009
|
-
var SuspendAuthMemberResponseSchema =
|
|
9462
|
+
var SuspendAuthMemberResponseSchema = z28.object({
|
|
9010
9463
|
member: AuthManagedMemberSchema
|
|
9011
9464
|
});
|
|
9012
|
-
var ReactivateAuthMemberResponseSchema =
|
|
9465
|
+
var ReactivateAuthMemberResponseSchema = z28.object({
|
|
9013
9466
|
member: AuthManagedMemberSchema
|
|
9014
9467
|
});
|
|
9015
|
-
var CreateAuthInvitationBodySchema =
|
|
9016
|
-
email:
|
|
9017
|
-
groupIds:
|
|
9018
|
-
destinationId:
|
|
9019
|
-
expiresAt:
|
|
9020
|
-
returnTo:
|
|
9468
|
+
var CreateAuthInvitationBodySchema = z28.object({
|
|
9469
|
+
email: z28.string().min(1),
|
|
9470
|
+
groupIds: z28.array(z28.string().min(1)).optional(),
|
|
9471
|
+
destinationId: z28.enum(["atlas", "app"]).optional(),
|
|
9472
|
+
expiresAt: z28.string().optional(),
|
|
9473
|
+
returnTo: z28.string().optional()
|
|
9021
9474
|
});
|
|
9022
|
-
var CreateAuthInvitationResponseSchema =
|
|
9475
|
+
var CreateAuthInvitationResponseSchema = z28.object({
|
|
9023
9476
|
invitation: AuthInvitationSchema,
|
|
9024
9477
|
delivery: AuthInvitationDeliverySchema
|
|
9025
9478
|
});
|
|
9026
|
-
var ListAuthInvitationsQuerySchema =
|
|
9027
|
-
email:
|
|
9479
|
+
var ListAuthInvitationsQuerySchema = z28.object({
|
|
9480
|
+
email: z28.string().optional(),
|
|
9028
9481
|
status: AuthInvitationStatusSchema.optional(),
|
|
9029
|
-
limit:
|
|
9030
|
-
offset:
|
|
9031
|
-
order:
|
|
9482
|
+
limit: z28.string().optional(),
|
|
9483
|
+
offset: z28.string().optional(),
|
|
9484
|
+
order: z28.enum(["asc", "desc"]).optional()
|
|
9032
9485
|
});
|
|
9033
|
-
var ListAuthInvitationsResponseSchema =
|
|
9034
|
-
invitations:
|
|
9035
|
-
hasMore:
|
|
9036
|
-
total:
|
|
9486
|
+
var ListAuthInvitationsResponseSchema = z28.object({
|
|
9487
|
+
invitations: z28.array(AuthInvitationSchema),
|
|
9488
|
+
hasMore: z28.boolean(),
|
|
9489
|
+
total: z28.number()
|
|
9037
9490
|
});
|
|
9038
|
-
var RevokeAuthInvitationParamsSchema =
|
|
9039
|
-
invitationId:
|
|
9491
|
+
var RevokeAuthInvitationParamsSchema = z28.object({
|
|
9492
|
+
invitationId: z28.string().min(1)
|
|
9040
9493
|
});
|
|
9041
|
-
var RevokeAuthInvitationResponseSchema =
|
|
9494
|
+
var RevokeAuthInvitationResponseSchema = z28.object({
|
|
9042
9495
|
invitation: AuthInvitationSchema
|
|
9043
9496
|
});
|
|
9044
|
-
var AuthSessionResponseSchema =
|
|
9045
|
-
|
|
9046
|
-
authenticated:
|
|
9497
|
+
var AuthSessionResponseSchema = z28.union([
|
|
9498
|
+
z28.object({
|
|
9499
|
+
authenticated: z28.literal(false)
|
|
9047
9500
|
}),
|
|
9048
|
-
|
|
9049
|
-
authenticated:
|
|
9050
|
-
csrfToken:
|
|
9051
|
-
applicationAccess:
|
|
9052
|
-
allowed:
|
|
9053
|
-
audience:
|
|
9501
|
+
z28.object({
|
|
9502
|
+
authenticated: z28.literal(true),
|
|
9503
|
+
csrfToken: z28.string(),
|
|
9504
|
+
applicationAccess: z28.object({
|
|
9505
|
+
allowed: z28.boolean(),
|
|
9506
|
+
audience: z28.enum(["atlas", "app"])
|
|
9054
9507
|
}),
|
|
9055
|
-
user:
|
|
9056
|
-
id:
|
|
9057
|
-
email:
|
|
9058
|
-
displayName:
|
|
9059
|
-
avatarUrl:
|
|
9060
|
-
groupIds:
|
|
9508
|
+
user: z28.object({
|
|
9509
|
+
id: z28.string(),
|
|
9510
|
+
email: z28.string(),
|
|
9511
|
+
displayName: z28.string().optional(),
|
|
9512
|
+
avatarUrl: z28.string().optional(),
|
|
9513
|
+
groupIds: z28.array(z28.string())
|
|
9061
9514
|
}),
|
|
9062
|
-
session:
|
|
9063
|
-
id:
|
|
9064
|
-
expiresAt:
|
|
9515
|
+
session: z28.object({
|
|
9516
|
+
id: z28.string(),
|
|
9517
|
+
expiresAt: z28.string()
|
|
9065
9518
|
})
|
|
9066
9519
|
})
|
|
9067
9520
|
]);
|
|
9068
|
-
var AuthSignOutResponseSchema =
|
|
9069
|
-
success:
|
|
9521
|
+
var AuthSignOutResponseSchema = z28.object({
|
|
9522
|
+
success: z28.boolean()
|
|
9070
9523
|
});
|
|
9071
|
-
var AuthSessionSummarySchema =
|
|
9072
|
-
id:
|
|
9073
|
-
audience:
|
|
9074
|
-
current:
|
|
9075
|
-
createdAt:
|
|
9076
|
-
expiresAt:
|
|
9077
|
-
lastSeenAt:
|
|
9078
|
-
userAgent:
|
|
9079
|
-
ipAddress:
|
|
9524
|
+
var AuthSessionSummarySchema = z28.object({
|
|
9525
|
+
id: z28.string(),
|
|
9526
|
+
audience: z28.enum(["atlas", "app"]),
|
|
9527
|
+
current: z28.boolean(),
|
|
9528
|
+
createdAt: z28.string(),
|
|
9529
|
+
expiresAt: z28.string(),
|
|
9530
|
+
lastSeenAt: z28.string().optional(),
|
|
9531
|
+
userAgent: z28.string().optional(),
|
|
9532
|
+
ipAddress: z28.string().optional()
|
|
9080
9533
|
});
|
|
9081
|
-
var ListAuthSessionsResponseSchema =
|
|
9082
|
-
sessions:
|
|
9534
|
+
var ListAuthSessionsResponseSchema = z28.object({
|
|
9535
|
+
sessions: z28.array(AuthSessionSummarySchema)
|
|
9083
9536
|
});
|
|
9084
|
-
var RevokeAuthSessionParamsSchema =
|
|
9085
|
-
sessionId:
|
|
9537
|
+
var RevokeAuthSessionParamsSchema = z28.object({
|
|
9538
|
+
sessionId: z28.string().min(1)
|
|
9086
9539
|
});
|
|
9087
|
-
var RevokeAuthSessionResponseSchema =
|
|
9088
|
-
success:
|
|
9540
|
+
var RevokeAuthSessionResponseSchema = z28.object({
|
|
9541
|
+
success: z28.boolean()
|
|
9089
9542
|
});
|
|
9090
|
-
var SignOutAllResponseSchema =
|
|
9091
|
-
success:
|
|
9092
|
-
revokedCount:
|
|
9543
|
+
var SignOutAllResponseSchema = z28.object({
|
|
9544
|
+
success: z28.boolean(),
|
|
9545
|
+
revokedCount: z28.number()
|
|
9093
9546
|
});
|
|
9094
9547
|
|
|
9095
9548
|
// src/routes/auth.ts
|
|
9096
9549
|
function registerAuthRoutes(app, host, options) {
|
|
9097
|
-
return app.get("/api/auth/session", async ({ request }) => {
|
|
9550
|
+
return app.get("/auth/assets/*", async ({ request }) => customAuthExperienceAssetResponse(options.authExperience, request), { detail: { hide: true } }).head("/auth/assets/*", async ({ request }) => customAuthExperienceAssetResponse(options.authExperience, request), { detail: { hide: true } }).get("/api/auth/session", async ({ request }) => {
|
|
9098
9551
|
const authOptions = resolveAuthOptions(options, request);
|
|
9099
9552
|
let session = await host.auth.getSession(request, authOptions);
|
|
9100
9553
|
if (!session.authenticated) {
|
|
@@ -9888,7 +10341,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
9888
10341
|
requestOrigin: authRedirect.requestOrigin,
|
|
9889
10342
|
requesterHash: pending.hash
|
|
9890
10343
|
});
|
|
9891
|
-
const response =
|
|
10344
|
+
const response = await magicLinkRequestedResponse(options, authRedirect);
|
|
9892
10345
|
const existingPending = getCookie3(request, MAGIC_LINK_PENDING_COOKIE_NAME)?.trim();
|
|
9893
10346
|
response.headers.append("set-cookie", magicLinkPendingCookieHeader({
|
|
9894
10347
|
request,
|
|
@@ -9928,7 +10381,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
9928
10381
|
return authRedirect;
|
|
9929
10382
|
}
|
|
9930
10383
|
if (isMagicLinkAuthStrategy(strategy)) {
|
|
9931
|
-
return signInFormResponse(authRedirect);
|
|
10384
|
+
return await signInFormResponse(options, authRedirect);
|
|
9932
10385
|
}
|
|
9933
10386
|
if (isOidcAuthStrategy(strategy)) {
|
|
9934
10387
|
const result = await strategy.startOidcSignIn({
|
|
@@ -9947,8 +10400,9 @@ function registerAuthRoutes(app, host, options) {
|
|
|
9947
10400
|
const url = new URL(request.url);
|
|
9948
10401
|
const magicLinkId = url.searchParams.get("magicLinkId")?.trim();
|
|
9949
10402
|
const token = url.searchParams.get("token")?.trim();
|
|
10403
|
+
const authRedirectHint = resolveAuthExperienceRedirectHint(options, request, url.searchParams.get("audience"));
|
|
9950
10404
|
if (!magicLinkId || !token) {
|
|
9951
|
-
return
|
|
10405
|
+
return await invalidMagicLinkResponse(options, authRedirectHint);
|
|
9952
10406
|
}
|
|
9953
10407
|
let email;
|
|
9954
10408
|
if (strategy.peekMagicLink) {
|
|
@@ -9960,11 +10414,12 @@ function registerAuthRoutes(app, host, options) {
|
|
|
9960
10414
|
token
|
|
9961
10415
|
});
|
|
9962
10416
|
if (!peeked) {
|
|
9963
|
-
return
|
|
10417
|
+
return await invalidMagicLinkResponse(options, authRedirectHint);
|
|
9964
10418
|
}
|
|
9965
10419
|
email = peeked.email;
|
|
9966
|
-
} catch {
|
|
9967
|
-
|
|
10420
|
+
} catch (error) {
|
|
10421
|
+
logAuthCallbackError("Magic-link", error);
|
|
10422
|
+
return await authExperienceErrorResponse(options, authRedirectHint);
|
|
9968
10423
|
}
|
|
9969
10424
|
}
|
|
9970
10425
|
const requesterHash = url.searchParams.get("requester")?.trim();
|
|
@@ -9977,10 +10432,16 @@ function registerAuthRoutes(app, host, options) {
|
|
|
9977
10432
|
request,
|
|
9978
10433
|
magicLinkId,
|
|
9979
10434
|
token,
|
|
9980
|
-
clearPendingCookie: true
|
|
10435
|
+
clearPendingCookie: true,
|
|
10436
|
+
authRedirectHint
|
|
9981
10437
|
});
|
|
9982
10438
|
}
|
|
9983
|
-
return magicLinkConfirmResponse(
|
|
10439
|
+
return await magicLinkConfirmResponse(options, {
|
|
10440
|
+
magicLinkId,
|
|
10441
|
+
token,
|
|
10442
|
+
email,
|
|
10443
|
+
authRedirect: authRedirectHint
|
|
10444
|
+
});
|
|
9984
10445
|
}
|
|
9985
10446
|
if (isOidcAuthStrategy(strategy)) {
|
|
9986
10447
|
const now = new Date;
|
|
@@ -10024,14 +10485,24 @@ function registerAuthRoutes(app, host, options) {
|
|
|
10024
10485
|
}
|
|
10025
10486
|
const magicLinkId = body.magicLinkId?.trim();
|
|
10026
10487
|
const token = body.token?.trim();
|
|
10488
|
+
const authRedirectHint = resolveAuthExperienceRedirectHint(options, request, body.audience);
|
|
10027
10489
|
if (!magicLinkId || !token) {
|
|
10028
|
-
return
|
|
10490
|
+
return await invalidMagicLinkResponse(options, authRedirectHint);
|
|
10029
10491
|
}
|
|
10030
|
-
return completeMagicLinkCallback({
|
|
10492
|
+
return completeMagicLinkCallback({
|
|
10493
|
+
host,
|
|
10494
|
+
strategy,
|
|
10495
|
+
options,
|
|
10496
|
+
request,
|
|
10497
|
+
magicLinkId,
|
|
10498
|
+
token,
|
|
10499
|
+
authRedirectHint
|
|
10500
|
+
});
|
|
10031
10501
|
}, {
|
|
10032
10502
|
body: t.Object({
|
|
10033
10503
|
magicLinkId: t.Optional(t.String()),
|
|
10034
|
-
token: t.Optional(t.String())
|
|
10504
|
+
token: t.Optional(t.String()),
|
|
10505
|
+
audience: t.Optional(t.String())
|
|
10035
10506
|
}),
|
|
10036
10507
|
parse: "urlencoded",
|
|
10037
10508
|
detail: { hide: true }
|
|
@@ -10106,7 +10577,7 @@ async function completeMagicLinkCallback(input) {
|
|
|
10106
10577
|
}
|
|
10107
10578
|
return response;
|
|
10108
10579
|
} catch {
|
|
10109
|
-
return
|
|
10580
|
+
return await invalidMagicLinkResponse(input.options, input.authRedirectHint);
|
|
10110
10581
|
}
|
|
10111
10582
|
}
|
|
10112
10583
|
function resolveSessionDevice(request) {
|
|
@@ -10377,8 +10848,18 @@ function authPageResponse(body, status = 200) {
|
|
|
10377
10848
|
}
|
|
10378
10849
|
});
|
|
10379
10850
|
}
|
|
10380
|
-
function signInFormResponse(context) {
|
|
10381
|
-
return
|
|
10851
|
+
async function signInFormResponse(options, context) {
|
|
10852
|
+
return await customAuthExperienceResponse(options.authExperience, {
|
|
10853
|
+
audience: context.audience,
|
|
10854
|
+
state: { kind: "signIn" },
|
|
10855
|
+
signInUrl: authExperienceSignInUrl(context),
|
|
10856
|
+
submission: {
|
|
10857
|
+
kind: "requestMagicLink",
|
|
10858
|
+
action: "/auth/sign-in",
|
|
10859
|
+
fields: { audience: context.audience, returnTo: context.returnTo }
|
|
10860
|
+
},
|
|
10861
|
+
referrerPolicy: "same-origin"
|
|
10862
|
+
}) ?? authPageResponse([
|
|
10382
10863
|
"<h1>Sign in</h1>",
|
|
10383
10864
|
"<p>We'll email you a sign-in link.</p>",
|
|
10384
10865
|
'<form method="post" action="/auth/sign-in">',
|
|
@@ -10389,13 +10870,80 @@ function signInFormResponse(context) {
|
|
|
10389
10870
|
"</form>"
|
|
10390
10871
|
].join(""));
|
|
10391
10872
|
}
|
|
10392
|
-
function
|
|
10873
|
+
async function magicLinkRequestedResponse(options, context) {
|
|
10874
|
+
return await customAuthExperienceResponse(options.authExperience, {
|
|
10875
|
+
audience: context.audience,
|
|
10876
|
+
state: { kind: "checkEmail" },
|
|
10877
|
+
signInUrl: authExperienceSignInUrl(context)
|
|
10878
|
+
}) ?? htmlMessageResponse("If this email can sign in, we sent a link. Check your inbox to continue.", 200, "Check your email");
|
|
10879
|
+
}
|
|
10880
|
+
async function invalidMagicLinkResponse(options, context) {
|
|
10881
|
+
if (context) {
|
|
10882
|
+
const custom = await customAuthExperienceResponse(options.authExperience, {
|
|
10883
|
+
audience: context.audience,
|
|
10884
|
+
state: { kind: "invalidLink" },
|
|
10885
|
+
signInUrl: authExperienceSignInUrl(context),
|
|
10886
|
+
status: 400
|
|
10887
|
+
});
|
|
10888
|
+
if (custom)
|
|
10889
|
+
return custom;
|
|
10890
|
+
}
|
|
10891
|
+
return htmlMessageResponse("This sign-in link is invalid or expired.", 400);
|
|
10892
|
+
}
|
|
10893
|
+
async function authExperienceErrorResponse(options, context) {
|
|
10894
|
+
if (context) {
|
|
10895
|
+
const custom = await customAuthExperienceResponse(options.authExperience, {
|
|
10896
|
+
audience: context.audience,
|
|
10897
|
+
state: { kind: "error" },
|
|
10898
|
+
signInUrl: authExperienceSignInUrl(context),
|
|
10899
|
+
status: 500
|
|
10900
|
+
});
|
|
10901
|
+
if (custom)
|
|
10902
|
+
return custom;
|
|
10903
|
+
}
|
|
10904
|
+
return await invalidMagicLinkResponse(options, undefined);
|
|
10905
|
+
}
|
|
10906
|
+
function authExperienceSignInUrl(context) {
|
|
10907
|
+
const params = new URLSearchParams({ audience: context.audience, returnTo: context.returnTo });
|
|
10908
|
+
return `/auth/sign-in?${params.toString()}`;
|
|
10909
|
+
}
|
|
10910
|
+
function resolveAuthExperienceRedirectHint(options, request, audience) {
|
|
10911
|
+
if (audience !== "app" && audience !== "atlas") {
|
|
10912
|
+
return;
|
|
10913
|
+
}
|
|
10914
|
+
const context = resolveInvitationDeliveryContext(options, request, { destinationId: audience });
|
|
10915
|
+
return context instanceof Response ? undefined : context;
|
|
10916
|
+
}
|
|
10917
|
+
async function magicLinkConfirmResponse(options, input) {
|
|
10918
|
+
if (input.authRedirect) {
|
|
10919
|
+
const custom = await customAuthExperienceResponse(options.authExperience, {
|
|
10920
|
+
audience: input.authRedirect.audience,
|
|
10921
|
+
state: { kind: "confirm", ...input.email ? { email: input.email } : {} },
|
|
10922
|
+
signInUrl: authExperienceSignInUrl(input.authRedirect),
|
|
10923
|
+
submission: {
|
|
10924
|
+
kind: "confirmSignIn",
|
|
10925
|
+
action: "/auth/callback",
|
|
10926
|
+
fields: {
|
|
10927
|
+
magicLinkId: input.magicLinkId,
|
|
10928
|
+
token: input.token,
|
|
10929
|
+
audience: input.authRedirect.audience
|
|
10930
|
+
}
|
|
10931
|
+
},
|
|
10932
|
+
referrerPolicy: "same-origin",
|
|
10933
|
+
formActionOrigins: [new URL(input.authRedirect.returnTo).origin]
|
|
10934
|
+
});
|
|
10935
|
+
if (custom)
|
|
10936
|
+
return custom;
|
|
10937
|
+
}
|
|
10393
10938
|
const response = authPageResponse([
|
|
10394
10939
|
"<h1>Sign in</h1>",
|
|
10395
10940
|
input.email ? `<p>You're signing in as <strong>${escapeHtml(input.email)}</strong>.</p>` : "<p>Click continue to finish signing in.</p>",
|
|
10396
10941
|
'<form method="post" action="/auth/callback" id="confirm">',
|
|
10397
10942
|
`<input type="hidden" name="magicLinkId" value="${escapeHtml(input.magicLinkId)}">`,
|
|
10398
10943
|
`<input type="hidden" name="token" value="${escapeHtml(input.token)}">`,
|
|
10944
|
+
...input.authRedirect ? [
|
|
10945
|
+
`<input type="hidden" name="audience" value="${escapeHtml(input.authRedirect.audience)}">`
|
|
10946
|
+
] : [],
|
|
10399
10947
|
'<button type="submit" id="confirm-button">Continue</button>',
|
|
10400
10948
|
"</form>",
|
|
10401
10949
|
"<script>",
|
|
@@ -10876,7 +11424,7 @@ import {
|
|
|
10876
11424
|
isAgentRunActivityEvent
|
|
10877
11425
|
} from "@sixb/core/agents/streams";
|
|
10878
11426
|
import { BrokerCursorExpiredError } from "@sixb/core/broker";
|
|
10879
|
-
import { z as
|
|
11427
|
+
import { z as z29 } from "zod";
|
|
10880
11428
|
|
|
10881
11429
|
// src/utils/ws.ts
|
|
10882
11430
|
function safeSend(target, payload) {
|
|
@@ -10924,25 +11472,25 @@ async function decodeWsMessage(message) {
|
|
|
10924
11472
|
}
|
|
10925
11473
|
|
|
10926
11474
|
// src/routes/ws/agents.ts
|
|
10927
|
-
var SubscribeSchema =
|
|
10928
|
-
type:
|
|
10929
|
-
runId:
|
|
10930
|
-
afterCursor:
|
|
11475
|
+
var SubscribeSchema = z29.object({
|
|
11476
|
+
type: z29.literal("subscribe"),
|
|
11477
|
+
runId: z29.string().min(1),
|
|
11478
|
+
afterCursor: z29.string().min(1).optional()
|
|
10931
11479
|
});
|
|
10932
|
-
var SubscribeActivitySchema =
|
|
10933
|
-
type:
|
|
11480
|
+
var SubscribeActivitySchema = z29.object({
|
|
11481
|
+
type: z29.literal("subscribe.activity")
|
|
10934
11482
|
});
|
|
10935
|
-
var ReplaySchema =
|
|
10936
|
-
type:
|
|
10937
|
-
runId:
|
|
10938
|
-
afterCursor:
|
|
10939
|
-
limit:
|
|
11483
|
+
var ReplaySchema = z29.object({
|
|
11484
|
+
type: z29.literal("replay"),
|
|
11485
|
+
runId: z29.string().min(1),
|
|
11486
|
+
afterCursor: z29.string().min(1).optional(),
|
|
11487
|
+
limit: z29.number().int().positive().max(500).optional()
|
|
10940
11488
|
});
|
|
10941
|
-
var UnsubscribeSchema =
|
|
10942
|
-
type:
|
|
10943
|
-
runId:
|
|
11489
|
+
var UnsubscribeSchema = z29.object({
|
|
11490
|
+
type: z29.literal("unsubscribe"),
|
|
11491
|
+
runId: z29.string().min(1).optional()
|
|
10944
11492
|
});
|
|
10945
|
-
var AgentStreamMessageSchema =
|
|
11493
|
+
var AgentStreamMessageSchema = z29.union([
|
|
10946
11494
|
SubscribeSchema,
|
|
10947
11495
|
SubscribeActivitySchema,
|
|
10948
11496
|
ReplaySchema,
|
|
@@ -11228,22 +11776,22 @@ function errorMessage(error) {
|
|
|
11228
11776
|
|
|
11229
11777
|
// src/routes/ws/events.ts
|
|
11230
11778
|
import { scopeKeysForEvent } from "@sixb/core/events/scope";
|
|
11231
|
-
import { z as
|
|
11232
|
-
var SubscribeSchema2 =
|
|
11233
|
-
type:
|
|
11234
|
-
topic:
|
|
11235
|
-
types:
|
|
11236
|
-
objectTypeId:
|
|
11237
|
-
primaryId:
|
|
11238
|
-
actionId:
|
|
11239
|
-
runId:
|
|
11240
|
-
afterCursor:
|
|
11241
|
-
limit:
|
|
11242
|
-
});
|
|
11243
|
-
var UnsubscribeSchema2 =
|
|
11244
|
-
type:
|
|
11245
|
-
});
|
|
11246
|
-
var SubscriptionMessageSchema =
|
|
11779
|
+
import { z as z30 } from "zod";
|
|
11780
|
+
var SubscribeSchema2 = z30.object({
|
|
11781
|
+
type: z30.literal("subscribe"),
|
|
11782
|
+
topic: z30.enum(EVENT_TOPICS).optional(),
|
|
11783
|
+
types: z30.array(z30.enum(EVENT_TYPES)).optional(),
|
|
11784
|
+
objectTypeId: z30.string().optional(),
|
|
11785
|
+
primaryId: z30.string().optional(),
|
|
11786
|
+
actionId: z30.string().optional(),
|
|
11787
|
+
runId: z30.string().optional(),
|
|
11788
|
+
afterCursor: z30.string().optional(),
|
|
11789
|
+
limit: z30.number().int().positive().max(500).optional()
|
|
11790
|
+
});
|
|
11791
|
+
var UnsubscribeSchema2 = z30.object({
|
|
11792
|
+
type: z30.literal("unsubscribe")
|
|
11793
|
+
});
|
|
11794
|
+
var SubscriptionMessageSchema = z30.union([SubscribeSchema2, UnsubscribeSchema2]);
|
|
11247
11795
|
function parseSubscriptionMessage(payload) {
|
|
11248
11796
|
if (!payload || typeof payload !== "object") {
|
|
11249
11797
|
return { ok: false, error: "Message must be a JSON object." };
|
|
@@ -11433,7 +11981,7 @@ function eventMatchesScope(event, filter) {
|
|
|
11433
11981
|
}
|
|
11434
11982
|
|
|
11435
11983
|
// src/routes/ws/logs.ts
|
|
11436
|
-
import { z as
|
|
11984
|
+
import { z as z31 } from "zod";
|
|
11437
11985
|
|
|
11438
11986
|
// src/routes/ws/log-subscription-hub.ts
|
|
11439
11987
|
import { BrokerCursorExpiredError as BrokerCursorExpiredError2 } from "@sixb/core/broker";
|
|
@@ -11683,13 +12231,13 @@ class LogSubscriptionHub {
|
|
|
11683
12231
|
this.scheduleFlush(state);
|
|
11684
12232
|
}
|
|
11685
12233
|
waitForQueueProgress(state) {
|
|
11686
|
-
return new Promise((
|
|
12234
|
+
return new Promise((resolve2) => state.queueProgressWaiters.add(resolve2));
|
|
11687
12235
|
}
|
|
11688
12236
|
notifyQueueProgress(state) {
|
|
11689
12237
|
const waiters = [...state.queueProgressWaiters];
|
|
11690
12238
|
state.queueProgressWaiters.clear();
|
|
11691
|
-
for (const
|
|
11692
|
-
|
|
12239
|
+
for (const resolve2 of waiters)
|
|
12240
|
+
resolve2();
|
|
11693
12241
|
}
|
|
11694
12242
|
send(state, payload) {
|
|
11695
12243
|
if (state.closed)
|
|
@@ -11746,26 +12294,26 @@ function socketBufferedAmount(ws) {
|
|
|
11746
12294
|
}
|
|
11747
12295
|
|
|
11748
12296
|
// src/routes/ws/logs.ts
|
|
11749
|
-
var SubscribeSchema3 =
|
|
11750
|
-
type:
|
|
11751
|
-
kinds:
|
|
11752
|
-
levels:
|
|
11753
|
-
run:
|
|
11754
|
-
kind:
|
|
12297
|
+
var SubscribeSchema3 = z31.object({
|
|
12298
|
+
type: z31.literal("subscribe"),
|
|
12299
|
+
kinds: z31.array(z31.enum(SIXB_RUN_KINDS)).min(1).optional(),
|
|
12300
|
+
levels: z31.array(z31.enum(LOG_LEVELS)).min(1).optional(),
|
|
12301
|
+
run: z31.object({
|
|
12302
|
+
kind: z31.enum(SIXB_RUN_KINDS),
|
|
11755
12303
|
id: LogRunIdSchema
|
|
11756
12304
|
}).optional(),
|
|
11757
|
-
afterCursor:
|
|
12305
|
+
afterCursor: z31.string().optional()
|
|
11758
12306
|
}).superRefine((value, context) => {
|
|
11759
12307
|
if (value.run && value.kinds && !value.kinds.includes(value.run.kind)) {
|
|
11760
12308
|
context.addIssue({
|
|
11761
|
-
code:
|
|
12309
|
+
code: z31.ZodIssueCode.custom,
|
|
11762
12310
|
path: ["run"],
|
|
11763
12311
|
message: "run.kind must be included in kinds"
|
|
11764
12312
|
});
|
|
11765
12313
|
}
|
|
11766
12314
|
});
|
|
11767
|
-
var UnsubscribeSchema3 =
|
|
11768
|
-
var SubscriptionMessageSchema2 =
|
|
12315
|
+
var UnsubscribeSchema3 = z31.object({ type: z31.literal("unsubscribe") });
|
|
12316
|
+
var SubscriptionMessageSchema2 = z31.union([SubscribeSchema3, UnsubscribeSchema3]);
|
|
11769
12317
|
function parseLogSubscriptionMessage(payload) {
|
|
11770
12318
|
if (!payload || typeof payload !== "object") {
|
|
11771
12319
|
return { ok: false, error: "Message must be a JSON object." };
|
|
@@ -11866,6 +12414,7 @@ class SixbServer {
|
|
|
11866
12414
|
apiBrowserPolicy;
|
|
11867
12415
|
authContextResolver;
|
|
11868
12416
|
authRedirectContextResolver;
|
|
12417
|
+
authExperience;
|
|
11869
12418
|
app = null;
|
|
11870
12419
|
bunServer = null;
|
|
11871
12420
|
maintenance = null;
|
|
@@ -11877,6 +12426,7 @@ class SixbServer {
|
|
|
11877
12426
|
this.apiBrowserPolicy = resolveApiBrowserPolicy(options.browser);
|
|
11878
12427
|
this.authContextResolver = createApiBrowserAuthContextResolver(this.apiBrowserPolicy);
|
|
11879
12428
|
this.authRedirectContextResolver = createApiBrowserAuthRedirectContextResolver(this.apiBrowserPolicy);
|
|
12429
|
+
this.authExperience = options.authExperience;
|
|
11880
12430
|
}
|
|
11881
12431
|
getHost() {
|
|
11882
12432
|
return this.hostRuntime;
|
|
@@ -11902,6 +12452,9 @@ class SixbServer {
|
|
|
11902
12452
|
getApiBrowserPolicy() {
|
|
11903
12453
|
return this.apiBrowserPolicy;
|
|
11904
12454
|
}
|
|
12455
|
+
getAuthExperience() {
|
|
12456
|
+
return this.authExperience;
|
|
12457
|
+
}
|
|
11905
12458
|
async start() {
|
|
11906
12459
|
if (this.app !== null || this.bunServer !== null || this.maintenance !== null) {
|
|
11907
12460
|
throw new Error("[SixbServer] Server is already running.");
|
|
@@ -12051,6 +12604,7 @@ function createSixbApi(server) {
|
|
|
12051
12604
|
resolveAuthRedirectContext: (request, input) => server.resolveAuthRedirectContext(request, input),
|
|
12052
12605
|
getInvitationDestinationOptions: (request) => server.getInvitationDestinationOptions(request),
|
|
12053
12606
|
resolveAuthRequestOrigin: (request) => server.resolveAuthRequestOrigin(request),
|
|
12607
|
+
authExperience: server.getAuthExperience(),
|
|
12054
12608
|
resolveInvitationRedirectContext: (request, input) => server.resolveInvitationRedirectContext(request, input)
|
|
12055
12609
|
});
|
|
12056
12610
|
registerHttpRoutes(app, host, {
|
|
@@ -12142,4 +12696,4 @@ export {
|
|
|
12142
12696
|
SixbServer
|
|
12143
12697
|
};
|
|
12144
12698
|
|
|
12145
|
-
//# debugId=
|
|
12699
|
+
//# debugId=16E192D0EFF3C5F064756E2164756E21
|