@sixb/server 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- 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 +2122 -1391
- package/dist/index.js.map +24 -19
- package/dist/openapi/tags.d.ts +10 -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 +164 -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 +6 -57
- package/dist/routes/links.d.ts.map +1 -1
- package/dist/routes/logs.d.ts +3 -3
- package/dist/routes/models.d.ts +60 -0
- package/dist/routes/models.d.ts.map +1 -0
- package/dist/routes/objects.d.ts +51 -3
- package/dist/routes/objects.d.ts.map +1 -1
- package/dist/routes/pipelines.d.ts +10 -10
- package/dist/routes/projections.d.ts +150 -136
- package/dist/routes/projections.d.ts.map +1 -1
- package/dist/routes/syncs.d.ts +38 -38
- 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 +586 -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 +35 -25
- package/dist/schemas/connectors.d.ts.map +1 -1
- package/dist/schemas/event-payloads.d.ts +6 -6
- package/dist/schemas/events.d.ts +6 -6
- package/dist/schemas/links.d.ts +0 -41
- package/dist/schemas/links.d.ts.map +1 -1
- package/dist/schemas/logs.d.ts +22 -22
- package/dist/schemas/models.d.ts +50 -0
- package/dist/schemas/models.d.ts.map +1 -0
- package/dist/schemas/objects.d.ts +22 -0
- package/dist/schemas/objects.d.ts.map +1 -1
- package/dist/schemas/pipelines.d.ts +20 -20
- package/dist/schemas/projections.d.ts +947 -806
- package/dist/schemas/projections.d.ts.map +1 -1
- package/dist/schemas/status.d.ts +2 -2
- package/dist/schemas/syncs.d.ts +33 -33
- 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 +8 -0
- package/src/registerRoutes.ts +4 -0
- package/src/routes/agents.ts +22 -3
- package/src/routes/ai-accounting.ts +166 -0
- package/src/routes/auth.ts +188 -32
- package/src/routes/links.ts +2 -53
- package/src/routes/models.ts +31 -0
- package/src/routes/objects.ts +103 -0
- package/src/routes/projections.ts +18 -4
- package/src/routes/workflows.ts +16 -0
- package/src/schemas/agents.ts +19 -9
- package/src/schemas/ai-accounting.ts +182 -0
- package/src/schemas/connectors.ts +13 -3
- package/src/schemas/links.ts +0 -17
- package/src/schemas/models.ts +15 -0
- package/src/schemas/objects.ts +104 -0
- package/src/schemas/projections.ts +12 -3
- 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"
|
|
@@ -680,6 +687,10 @@ var OPENAPI_TAGS = {
|
|
|
680
687
|
name: "Agents",
|
|
681
688
|
description: "Agent catalog"
|
|
682
689
|
},
|
|
690
|
+
models: {
|
|
691
|
+
name: "Models",
|
|
692
|
+
description: "Project model catalog"
|
|
693
|
+
},
|
|
683
694
|
agentThreads: {
|
|
684
695
|
name: "Agent Threads",
|
|
685
696
|
description: "Agent conversation threads and messages"
|
|
@@ -2451,14 +2462,18 @@ import { publishAgentRunCancel, publishAgentRunFinished } from "@sixb/core/inter
|
|
|
2451
2462
|
import {
|
|
2452
2463
|
AgentStorageError
|
|
2453
2464
|
} from "@sixb/core/storage";
|
|
2454
|
-
import { ZodError as ZodError2, z as
|
|
2465
|
+
import { ZodError as ZodError2, z as z9 } from "zod";
|
|
2455
2466
|
|
|
2456
2467
|
// src/schemas/agents.ts
|
|
2457
2468
|
import { AGENT_REASONING_LEVELS, MAX_AGENT_CONTEXT_ENTRIES } from "@sixb/core";
|
|
2458
2469
|
import {
|
|
2459
2470
|
AGENT_RUN_DIAGNOSTIC_CODES,
|
|
2460
|
-
AGENT_RUN_FAILURE_CODES
|
|
2471
|
+
AGENT_RUN_FAILURE_CODES,
|
|
2472
|
+
AGENT_RUN_FINISH_REASONS
|
|
2461
2473
|
} from "@sixb/core/storage";
|
|
2474
|
+
import { z as z8 } from "zod";
|
|
2475
|
+
|
|
2476
|
+
// src/schemas/ai-accounting.ts
|
|
2462
2477
|
import { z as z7 } from "zod";
|
|
2463
2478
|
|
|
2464
2479
|
// src/schemas/ai-usage.ts
|
|
@@ -2476,140 +2491,300 @@ var AiUsageSummarySchema = z6.object({
|
|
|
2476
2491
|
reportingStatus: z6.enum(["complete", "partial", "unavailable"])
|
|
2477
2492
|
});
|
|
2478
2493
|
|
|
2494
|
+
// src/schemas/ai-accounting.ts
|
|
2495
|
+
var IntegerStringSchema = z7.string().regex(/^\d+$/);
|
|
2496
|
+
var IsoDateSchema = z7.string().datetime({ offset: true });
|
|
2497
|
+
var AiAccountingBucketSchema = z7.enum(["hour", "day", "week"]);
|
|
2498
|
+
var AiValuationStatusSchema = z7.enum(["rated", "unpriceable", "unvalued"]);
|
|
2499
|
+
var AiAccountingRangeQuerySchema = z7.object({
|
|
2500
|
+
from: IsoDateSchema,
|
|
2501
|
+
to: IsoDateSchema,
|
|
2502
|
+
providerId: z7.string().trim().min(1).optional(),
|
|
2503
|
+
modelId: z7.string().trim().min(1).optional()
|
|
2504
|
+
});
|
|
2505
|
+
var AiAccountingOverviewQuerySchema = AiAccountingRangeQuerySchema.extend({
|
|
2506
|
+
bucket: AiAccountingBucketSchema
|
|
2507
|
+
});
|
|
2508
|
+
var AiModelCallAccountingListQuerySchema = AiAccountingRangeQuerySchema.extend({
|
|
2509
|
+
executionId: z7.string().trim().min(1).optional(),
|
|
2510
|
+
valuationStatus: AiValuationStatusSchema.optional(),
|
|
2511
|
+
limit: IntegerStringSchema.optional(),
|
|
2512
|
+
offset: IntegerStringSchema.optional()
|
|
2513
|
+
});
|
|
2514
|
+
var AiMoneySchema = z7.object({
|
|
2515
|
+
currency: z7.string().regex(/^[A-Z]{3}$/),
|
|
2516
|
+
amountNanos: IntegerStringSchema
|
|
2517
|
+
});
|
|
2518
|
+
var AiCostSummarySchema = z7.object({
|
|
2519
|
+
amounts: z7.array(AiMoneySchema),
|
|
2520
|
+
ratedCallCount: z7.number().int().nonnegative(),
|
|
2521
|
+
unpriceableCallCount: z7.number().int().nonnegative(),
|
|
2522
|
+
unvaluedCallCount: z7.number().int().nonnegative()
|
|
2523
|
+
});
|
|
2524
|
+
var AiAccountingAggregateSchema = z7.object({
|
|
2525
|
+
modelCallCount: z7.number().int().nonnegative(),
|
|
2526
|
+
usage: AiUsageSummarySchema,
|
|
2527
|
+
costs: AiCostSummarySchema
|
|
2528
|
+
});
|
|
2529
|
+
var AiAccountingOverviewResponseSchema = z7.object({
|
|
2530
|
+
range: z7.object({ from: IsoDateSchema, to: IsoDateSchema }),
|
|
2531
|
+
bucket: AiAccountingBucketSchema,
|
|
2532
|
+
totals: AiAccountingAggregateSchema,
|
|
2533
|
+
series: z7.array(AiAccountingAggregateSchema.extend({
|
|
2534
|
+
start: IsoDateSchema,
|
|
2535
|
+
end: IsoDateSchema
|
|
2536
|
+
})),
|
|
2537
|
+
models: z7.array(AiAccountingAggregateSchema.extend({
|
|
2538
|
+
providerId: z7.string(),
|
|
2539
|
+
modelId: z7.string()
|
|
2540
|
+
})),
|
|
2541
|
+
agents: z7.array(AiAccountingAggregateSchema.extend({
|
|
2542
|
+
agentId: z7.string()
|
|
2543
|
+
})),
|
|
2544
|
+
workflows: z7.array(AiAccountingAggregateSchema.extend({
|
|
2545
|
+
workflowId: z7.string()
|
|
2546
|
+
}))
|
|
2547
|
+
});
|
|
2548
|
+
var AiPricingContextSchema = z7.object({
|
|
2549
|
+
serviceTier: z7.string().optional(),
|
|
2550
|
+
batch: z7.boolean().optional(),
|
|
2551
|
+
region: z7.string().optional(),
|
|
2552
|
+
inferenceGeo: z7.string().optional(),
|
|
2553
|
+
routedProviderId: z7.string().optional(),
|
|
2554
|
+
deploymentId: z7.string().optional(),
|
|
2555
|
+
inferenceProfileId: z7.string().optional(),
|
|
2556
|
+
cacheWriteTtlSeconds: z7.number().int().positive().optional(),
|
|
2557
|
+
mode: z7.string().optional()
|
|
2558
|
+
});
|
|
2559
|
+
var AiCostComponentSchema = z7.object({
|
|
2560
|
+
meter: z7.enum([
|
|
2561
|
+
"tokens.input.total",
|
|
2562
|
+
"tokens.input.uncached",
|
|
2563
|
+
"tokens.input.cacheRead",
|
|
2564
|
+
"tokens.input.cacheWrite",
|
|
2565
|
+
"tokens.output.total",
|
|
2566
|
+
"tokens.output.text",
|
|
2567
|
+
"tokens.output.reasoning"
|
|
2568
|
+
]),
|
|
2569
|
+
quantity: IntegerStringSchema,
|
|
2570
|
+
rateAmountNanosPerMillion: IntegerStringSchema,
|
|
2571
|
+
chargeAmountNanos: IntegerStringSchema
|
|
2572
|
+
});
|
|
2573
|
+
var AiBillingIdentitySchema = z7.object({
|
|
2574
|
+
providerId: z7.string(),
|
|
2575
|
+
modelId: z7.string()
|
|
2576
|
+
});
|
|
2577
|
+
var AiPriceSourceSchema = z7.object({
|
|
2578
|
+
sourceId: z7.string(),
|
|
2579
|
+
sourceEntryId: z7.string(),
|
|
2580
|
+
sourceVersion: z7.string(),
|
|
2581
|
+
sourceUrl: z7.string().url(),
|
|
2582
|
+
observedAt: IsoDateSchema
|
|
2583
|
+
});
|
|
2584
|
+
var AiModelCallCostSchema = z7.discriminatedUnion("status", [
|
|
2585
|
+
z7.object({
|
|
2586
|
+
status: z7.literal("rated"),
|
|
2587
|
+
billingIdentity: AiBillingIdentitySchema,
|
|
2588
|
+
pricingContext: AiPricingContextSchema,
|
|
2589
|
+
priceSource: AiPriceSourceSchema,
|
|
2590
|
+
money: AiMoneySchema,
|
|
2591
|
+
components: z7.array(AiCostComponentSchema),
|
|
2592
|
+
ratedAt: IsoDateSchema
|
|
2593
|
+
}),
|
|
2594
|
+
z7.object({
|
|
2595
|
+
status: z7.literal("unpriceable"),
|
|
2596
|
+
billingIdentity: AiBillingIdentitySchema.optional(),
|
|
2597
|
+
pricingContext: AiPricingContextSchema,
|
|
2598
|
+
priceSource: AiPriceSourceSchema,
|
|
2599
|
+
reason: z7.enum([
|
|
2600
|
+
"missingBillingIdentity",
|
|
2601
|
+
"missingCatalogEntry",
|
|
2602
|
+
"missingUsageMeter",
|
|
2603
|
+
"unsupportedPricingDimension",
|
|
2604
|
+
"invalidUsageForFormula"
|
|
2605
|
+
]),
|
|
2606
|
+
missingMeters: z7.array(AiCostComponentSchema.shape.meter).optional(),
|
|
2607
|
+
ratedAt: IsoDateSchema
|
|
2608
|
+
})
|
|
2609
|
+
]);
|
|
2610
|
+
var AiModelCallUsageRecordSchema = z7.object({
|
|
2611
|
+
id: z7.string(),
|
|
2612
|
+
executionId: z7.string(),
|
|
2613
|
+
attempt: z7.number().int().positive(),
|
|
2614
|
+
callId: z7.string(),
|
|
2615
|
+
providerId: z7.string(),
|
|
2616
|
+
requestedModelId: z7.string(),
|
|
2617
|
+
responseModelId: z7.string().optional(),
|
|
2618
|
+
responseId: z7.string(),
|
|
2619
|
+
usage: AiUsageSummarySchema,
|
|
2620
|
+
occurredAt: IsoDateSchema,
|
|
2621
|
+
recordedAt: IsoDateSchema
|
|
2622
|
+
});
|
|
2623
|
+
var AiModelCallAccountingItemSchema = z7.object({
|
|
2624
|
+
usage: AiModelCallUsageRecordSchema,
|
|
2625
|
+
attribution: z7.discriminatedUnion("kind", [
|
|
2626
|
+
z7.object({
|
|
2627
|
+
kind: z7.literal("agent"),
|
|
2628
|
+
agentId: z7.string(),
|
|
2629
|
+
agentRunId: z7.string(),
|
|
2630
|
+
threadId: z7.string()
|
|
2631
|
+
}),
|
|
2632
|
+
z7.object({
|
|
2633
|
+
kind: z7.literal("workflowAgent"),
|
|
2634
|
+
agentId: z7.string(),
|
|
2635
|
+
nodeRunId: z7.string(),
|
|
2636
|
+
workflowId: z7.string(),
|
|
2637
|
+
workflowRunId: z7.string()
|
|
2638
|
+
})
|
|
2639
|
+
]).optional(),
|
|
2640
|
+
cost: AiModelCallCostSchema.optional(),
|
|
2641
|
+
valuationStatus: AiValuationStatusSchema
|
|
2642
|
+
});
|
|
2643
|
+
var AiModelCallAccountingListResponseSchema = z7.object({
|
|
2644
|
+
items: z7.array(AiModelCallAccountingItemSchema),
|
|
2645
|
+
hasMore: z7.boolean(),
|
|
2646
|
+
total: z7.number().int().nonnegative()
|
|
2647
|
+
});
|
|
2648
|
+
|
|
2479
2649
|
// src/schemas/agents.ts
|
|
2480
2650
|
var AgentRunFailureSchema = sixbFailureSchema(AGENT_RUN_FAILURE_CODES);
|
|
2481
|
-
var AgentIdParamsSchema =
|
|
2482
|
-
agentId:
|
|
2651
|
+
var AgentIdParamsSchema = z8.object({
|
|
2652
|
+
agentId: z8.string().min(1)
|
|
2483
2653
|
});
|
|
2484
|
-
var AgentThreadParamsSchema =
|
|
2485
|
-
threadId:
|
|
2654
|
+
var AgentThreadParamsSchema = z8.object({
|
|
2655
|
+
threadId: z8.string().min(1)
|
|
2486
2656
|
});
|
|
2487
|
-
var AgentRunParamsSchema =
|
|
2488
|
-
runId:
|
|
2657
|
+
var AgentRunParamsSchema = z8.object({
|
|
2658
|
+
runId: z8.string().min(1)
|
|
2489
2659
|
});
|
|
2490
2660
|
var AgentMessageFileContentParamsSchema = AgentThreadParamsSchema.extend({
|
|
2491
|
-
messageId:
|
|
2661
|
+
messageId: z8.string().min(1)
|
|
2492
2662
|
});
|
|
2493
|
-
var AgentPrincipalSchema =
|
|
2494
|
-
type:
|
|
2495
|
-
id:
|
|
2663
|
+
var AgentPrincipalSchema = z8.object({
|
|
2664
|
+
type: z8.enum(["user", "serviceAccount", "system"]),
|
|
2665
|
+
id: z8.string().min(1)
|
|
2496
2666
|
});
|
|
2497
|
-
var AgentAuthorizablePrincipalSchema =
|
|
2498
|
-
type:
|
|
2499
|
-
id:
|
|
2667
|
+
var AgentAuthorizablePrincipalSchema = z8.object({
|
|
2668
|
+
type: z8.enum(["user", "serviceAccount"]),
|
|
2669
|
+
id: z8.string().min(1)
|
|
2500
2670
|
});
|
|
2501
|
-
var AgentObjectContextSchema =
|
|
2502
|
-
kind:
|
|
2503
|
-
ref:
|
|
2504
|
-
objectTypeId:
|
|
2505
|
-
primaryId:
|
|
2671
|
+
var AgentObjectContextSchema = z8.object({
|
|
2672
|
+
kind: z8.literal("object"),
|
|
2673
|
+
ref: z8.object({
|
|
2674
|
+
objectTypeId: z8.string().min(1),
|
|
2675
|
+
primaryId: z8.string().min(1)
|
|
2506
2676
|
})
|
|
2507
2677
|
});
|
|
2508
|
-
var AgentAppStateContextSchema =
|
|
2509
|
-
kind:
|
|
2510
|
-
id:
|
|
2511
|
-
label:
|
|
2512
|
-
description:
|
|
2678
|
+
var AgentAppStateContextSchema = z8.object({
|
|
2679
|
+
kind: z8.literal("app-state"),
|
|
2680
|
+
id: z8.string().min(1),
|
|
2681
|
+
label: z8.string().min(1),
|
|
2682
|
+
description: z8.string().min(1),
|
|
2513
2683
|
value: JsonValueSchema
|
|
2514
2684
|
});
|
|
2515
|
-
var AgentContextInputSchema =
|
|
2685
|
+
var AgentContextInputSchema = z8.discriminatedUnion("kind", [
|
|
2516
2686
|
AgentObjectContextSchema,
|
|
2517
2687
|
AgentAppStateContextSchema
|
|
2518
2688
|
]);
|
|
2519
|
-
var AgentContextOriginSchema =
|
|
2520
|
-
var AgentContextEntryInputSchema =
|
|
2689
|
+
var AgentContextOriginSchema = z8.enum(["ambient", "explicit"]);
|
|
2690
|
+
var AgentContextEntryInputSchema = z8.object({
|
|
2521
2691
|
context: AgentContextInputSchema,
|
|
2522
2692
|
origin: AgentContextOriginSchema
|
|
2523
2693
|
});
|
|
2524
2694
|
var AgentContextPartSchema = AgentContextEntryInputSchema.extend({
|
|
2525
|
-
type:
|
|
2695
|
+
type: z8.literal("context")
|
|
2526
2696
|
});
|
|
2527
|
-
var AgentLoopConfigSchema =
|
|
2528
|
-
stopWhen:
|
|
2529
|
-
maxSteps:
|
|
2697
|
+
var AgentLoopConfigSchema = z8.object({
|
|
2698
|
+
stopWhen: z8.object({
|
|
2699
|
+
maxSteps: z8.number().int().positive().optional()
|
|
2700
|
+
}).optional(),
|
|
2701
|
+
context: z8.object({
|
|
2702
|
+
windowTokens: z8.number().int().positive().optional(),
|
|
2703
|
+
reserveTokens: z8.number().int().positive().optional(),
|
|
2704
|
+
keepRecentTokens: z8.number().int().positive().optional()
|
|
2530
2705
|
}).optional()
|
|
2531
2706
|
});
|
|
2532
|
-
var AgentReasoningLevelSchema =
|
|
2533
|
-
var AgentCatalogItemSchema =
|
|
2534
|
-
id:
|
|
2535
|
-
name:
|
|
2536
|
-
description:
|
|
2537
|
-
modelId:
|
|
2707
|
+
var AgentReasoningLevelSchema = z8.enum(AGENT_REASONING_LEVELS);
|
|
2708
|
+
var AgentCatalogItemSchema = z8.object({
|
|
2709
|
+
id: z8.string(),
|
|
2710
|
+
name: z8.string(),
|
|
2711
|
+
description: z8.string().optional(),
|
|
2712
|
+
modelId: z8.string().optional(),
|
|
2538
2713
|
reasoning: AgentReasoningLevelSchema.optional(),
|
|
2539
|
-
groupIds:
|
|
2714
|
+
groupIds: z8.array(z8.string()),
|
|
2540
2715
|
loop: AgentLoopConfigSchema.optional()
|
|
2541
2716
|
});
|
|
2542
|
-
var AgentThreadStatusSchema =
|
|
2543
|
-
var AgentThreadListQuerySchema =
|
|
2544
|
-
agentId:
|
|
2717
|
+
var AgentThreadStatusSchema = z8.enum(["active", "archived"]);
|
|
2718
|
+
var AgentThreadListQuerySchema = z8.object({
|
|
2719
|
+
agentId: z8.string().optional(),
|
|
2545
2720
|
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:
|
|
2721
|
+
limit: z8.string().optional(),
|
|
2722
|
+
offset: z8.string().optional(),
|
|
2723
|
+
order: z8.enum(["asc", "desc"]).optional()
|
|
2724
|
+
});
|
|
2725
|
+
var CreateAgentThreadBodySchema = z8.object({
|
|
2726
|
+
agentId: z8.string().min(1),
|
|
2727
|
+
title: z8.string().trim().min(1).optional(),
|
|
2728
|
+
threadId: z8.string().trim().min(1).optional()
|
|
2729
|
+
});
|
|
2730
|
+
var AgentThreadSchema = z8.object({
|
|
2731
|
+
id: z8.string(),
|
|
2732
|
+
projectId: z8.string(),
|
|
2733
|
+
agentId: z8.string(),
|
|
2559
2734
|
ownerPrincipal: AgentPrincipalSchema,
|
|
2560
|
-
title:
|
|
2735
|
+
title: z8.string().optional(),
|
|
2561
2736
|
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 =
|
|
2737
|
+
activeRunId: z8.string().nullable(),
|
|
2738
|
+
lastMessageAt: z8.string().optional(),
|
|
2739
|
+
messageCount: z8.number(),
|
|
2740
|
+
createdAt: z8.string(),
|
|
2741
|
+
updatedAt: z8.string()
|
|
2742
|
+
});
|
|
2743
|
+
var AgentThreadListResponseSchema = z8.object({
|
|
2744
|
+
threads: z8.array(AgentThreadSchema),
|
|
2745
|
+
hasMore: z8.boolean(),
|
|
2746
|
+
total: z8.number()
|
|
2747
|
+
});
|
|
2748
|
+
var CreateAgentThreadResponseSchema = z8.object({
|
|
2574
2749
|
thread: AgentThreadSchema
|
|
2575
2750
|
});
|
|
2576
|
-
var AgentMessageRoleSchema =
|
|
2577
|
-
var AgentTextPartSchema =
|
|
2578
|
-
type:
|
|
2579
|
-
text:
|
|
2751
|
+
var AgentMessageRoleSchema = z8.enum(["system", "user", "assistant"]);
|
|
2752
|
+
var AgentTextPartSchema = z8.object({
|
|
2753
|
+
type: z8.literal("text"),
|
|
2754
|
+
text: z8.string(),
|
|
2580
2755
|
providerMetadata: JsonValueSchema.optional()
|
|
2581
2756
|
});
|
|
2582
|
-
var AgentReasoningPartSchema =
|
|
2583
|
-
type:
|
|
2584
|
-
text:
|
|
2757
|
+
var AgentReasoningPartSchema = z8.object({
|
|
2758
|
+
type: z8.literal("reasoning"),
|
|
2759
|
+
text: z8.string(),
|
|
2585
2760
|
providerMetadata: JsonValueSchema.optional()
|
|
2586
2761
|
});
|
|
2587
|
-
var AgentStepStartPartSchema =
|
|
2588
|
-
type:
|
|
2762
|
+
var AgentStepStartPartSchema = z8.object({
|
|
2763
|
+
type: z8.literal("step-start")
|
|
2589
2764
|
});
|
|
2590
|
-
var AgentFilePartSchema =
|
|
2591
|
-
type:
|
|
2765
|
+
var AgentFilePartSchema = z8.object({
|
|
2766
|
+
type: z8.literal("file"),
|
|
2592
2767
|
fileRef: FileRefSchema,
|
|
2593
2768
|
providerMetadata: JsonValueSchema.optional()
|
|
2594
2769
|
});
|
|
2595
|
-
var AgentToolCallBaseSchema =
|
|
2596
|
-
type:
|
|
2597
|
-
toolCallId:
|
|
2598
|
-
toolName:
|
|
2599
|
-
dynamic:
|
|
2600
|
-
providerExecuted:
|
|
2770
|
+
var AgentToolCallBaseSchema = z8.object({
|
|
2771
|
+
type: z8.literal("tool-call"),
|
|
2772
|
+
toolCallId: z8.string(),
|
|
2773
|
+
toolName: z8.string(),
|
|
2774
|
+
dynamic: z8.boolean().optional(),
|
|
2775
|
+
providerExecuted: z8.boolean().optional(),
|
|
2601
2776
|
input: JsonValueSchema,
|
|
2602
2777
|
providerMetadata: JsonValueSchema.optional()
|
|
2603
2778
|
});
|
|
2604
2779
|
var AgentToolCallOutputSchema = AgentToolCallBaseSchema.extend({
|
|
2605
|
-
state:
|
|
2780
|
+
state: z8.literal("output-available"),
|
|
2606
2781
|
output: JsonValueSchema
|
|
2607
2782
|
});
|
|
2608
2783
|
var AgentToolCallErrorSchema = AgentToolCallBaseSchema.extend({
|
|
2609
|
-
state:
|
|
2610
|
-
errorText:
|
|
2784
|
+
state: z8.literal("output-error"),
|
|
2785
|
+
errorText: z8.string()
|
|
2611
2786
|
});
|
|
2612
|
-
var AgentMessagePartSchema =
|
|
2787
|
+
var AgentMessagePartSchema = z8.union([
|
|
2613
2788
|
AgentTextPartSchema,
|
|
2614
2789
|
AgentReasoningPartSchema,
|
|
2615
2790
|
AgentStepStartPartSchema,
|
|
@@ -2618,107 +2793,106 @@ var AgentMessagePartSchema = z7.union([
|
|
|
2618
2793
|
AgentToolCallOutputSchema,
|
|
2619
2794
|
AgentToolCallErrorSchema
|
|
2620
2795
|
]);
|
|
2621
|
-
var AgentRunDiagnosticSchema =
|
|
2622
|
-
code:
|
|
2623
|
-
severity:
|
|
2624
|
-
scope:
|
|
2625
|
-
path:
|
|
2626
|
-
message:
|
|
2627
|
-
});
|
|
2628
|
-
var
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2796
|
+
var AgentRunDiagnosticSchema = z8.object({
|
|
2797
|
+
code: z8.enum(AGENT_RUN_DIAGNOSTIC_CODES),
|
|
2798
|
+
severity: z8.enum(["warning", "error"]),
|
|
2799
|
+
scope: z8.literal("output"),
|
|
2800
|
+
path: z8.string().optional(),
|
|
2801
|
+
message: z8.string()
|
|
2802
|
+
});
|
|
2803
|
+
var AgentMessageCompactionSchema = z8.object({
|
|
2804
|
+
checkpointId: z8.string(),
|
|
2805
|
+
summary: z8.string(),
|
|
2806
|
+
createdAt: z8.string()
|
|
2807
|
+
});
|
|
2808
|
+
var AgentMessageSchema = z8.object({
|
|
2809
|
+
id: z8.string(),
|
|
2810
|
+
projectId: z8.string(),
|
|
2811
|
+
threadId: z8.string(),
|
|
2812
|
+
runId: z8.string().nullable(),
|
|
2633
2813
|
role: AgentMessageRoleSchema,
|
|
2634
2814
|
authorPrincipal: AgentPrincipalSchema.optional(),
|
|
2635
|
-
seq:
|
|
2636
|
-
parts:
|
|
2637
|
-
annotations:
|
|
2815
|
+
seq: z8.number(),
|
|
2816
|
+
parts: z8.array(AgentMessagePartSchema),
|
|
2817
|
+
annotations: z8.array(AgentRunDiagnosticSchema),
|
|
2818
|
+
compaction: AgentMessageCompactionSchema.optional(),
|
|
2638
2819
|
metadata: JsonValueSchema.optional(),
|
|
2639
|
-
contentVersion:
|
|
2640
|
-
createdAt:
|
|
2641
|
-
completedAt:
|
|
2820
|
+
contentVersion: z8.number(),
|
|
2821
|
+
createdAt: z8.string(),
|
|
2822
|
+
completedAt: z8.string().optional()
|
|
2642
2823
|
});
|
|
2643
|
-
var AgentMessagesQuerySchema =
|
|
2824
|
+
var AgentMessagesQuerySchema = z8.object({
|
|
2644
2825
|
role: AgentMessageRoleSchema.optional(),
|
|
2645
|
-
limit:
|
|
2646
|
-
offset:
|
|
2647
|
-
order:
|
|
2826
|
+
limit: z8.string().optional(),
|
|
2827
|
+
offset: z8.string().optional(),
|
|
2828
|
+
order: z8.enum(["asc", "desc"]).optional()
|
|
2648
2829
|
});
|
|
2649
|
-
var AgentMessageListResponseSchema =
|
|
2650
|
-
messages:
|
|
2651
|
-
hasMore:
|
|
2652
|
-
total:
|
|
2830
|
+
var AgentMessageListResponseSchema = z8.object({
|
|
2831
|
+
messages: z8.array(AgentMessageSchema),
|
|
2832
|
+
hasMore: z8.boolean(),
|
|
2833
|
+
total: z8.number()
|
|
2653
2834
|
});
|
|
2654
|
-
var PostAgentMessageBodySchema =
|
|
2655
|
-
text:
|
|
2656
|
-
attachments:
|
|
2657
|
-
context:
|
|
2658
|
-
messageId:
|
|
2835
|
+
var PostAgentMessageBodySchema = z8.object({
|
|
2836
|
+
text: z8.string().trim().min(1),
|
|
2837
|
+
attachments: z8.array(FileRefSchema).optional(),
|
|
2838
|
+
context: z8.array(AgentContextEntryInputSchema).max(MAX_AGENT_CONTEXT_ENTRIES).optional(),
|
|
2839
|
+
messageId: z8.string().trim().min(1).optional()
|
|
2659
2840
|
});
|
|
2660
|
-
var CancelAgentRunBodySchema =
|
|
2661
|
-
runId:
|
|
2841
|
+
var CancelAgentRunBodySchema = z8.object({
|
|
2842
|
+
runId: z8.string().trim().min(1)
|
|
2662
2843
|
});
|
|
2663
|
-
var AgentRunStatusSchema =
|
|
2844
|
+
var AgentRunStatusSchema = z8.enum([
|
|
2664
2845
|
"queued",
|
|
2665
2846
|
"running",
|
|
2666
2847
|
"succeeded",
|
|
2667
2848
|
"failed",
|
|
2668
2849
|
"cancelled"
|
|
2669
2850
|
]);
|
|
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(),
|
|
2851
|
+
var AgentRunFinishReasonSchema = z8.enum(AGENT_RUN_FINISH_REASONS);
|
|
2852
|
+
var AgentRunSchema = z8.object({
|
|
2853
|
+
id: z8.string(),
|
|
2854
|
+
projectId: z8.string(),
|
|
2855
|
+
threadId: z8.string(),
|
|
2856
|
+
agentId: z8.string(),
|
|
2857
|
+
triggerMessageId: z8.string(),
|
|
2685
2858
|
requestedBy: AgentAuthorizablePrincipalSchema.optional(),
|
|
2686
2859
|
status: AgentRunStatusSchema,
|
|
2687
|
-
modelId:
|
|
2860
|
+
modelId: z8.string().optional(),
|
|
2688
2861
|
finishReason: AgentRunFinishReasonSchema.optional(),
|
|
2689
2862
|
usage: AiUsageSummarySchema.optional(),
|
|
2690
|
-
|
|
2863
|
+
cost: AiCostSummarySchema.optional(),
|
|
2864
|
+
diagnostics: z8.array(AgentRunDiagnosticSchema).optional(),
|
|
2691
2865
|
error: AgentRunFailureSchema.optional(),
|
|
2692
|
-
attempt:
|
|
2693
|
-
streamId:
|
|
2694
|
-
createdAt:
|
|
2695
|
-
startedAt:
|
|
2696
|
-
completedAt:
|
|
2866
|
+
attempt: z8.number(),
|
|
2867
|
+
streamId: z8.string(),
|
|
2868
|
+
createdAt: z8.string(),
|
|
2869
|
+
startedAt: z8.string().optional(),
|
|
2870
|
+
completedAt: z8.string().optional()
|
|
2697
2871
|
});
|
|
2698
|
-
var PostAgentMessageResponseSchema =
|
|
2872
|
+
var PostAgentMessageResponseSchema = z8.object({
|
|
2699
2873
|
run: AgentRunSchema
|
|
2700
2874
|
});
|
|
2701
|
-
var CancelAgentRunResponseSchema =
|
|
2875
|
+
var CancelAgentRunResponseSchema = z8.object({
|
|
2702
2876
|
run: AgentRunSchema
|
|
2703
2877
|
});
|
|
2704
|
-
var RetryAgentRunResponseSchema =
|
|
2878
|
+
var RetryAgentRunResponseSchema = z8.object({
|
|
2705
2879
|
run: AgentRunSchema
|
|
2706
2880
|
});
|
|
2707
|
-
var AgentRunListQuerySchema =
|
|
2881
|
+
var AgentRunListQuerySchema = z8.object({
|
|
2708
2882
|
status: AgentRunStatusSchema.optional(),
|
|
2709
|
-
limit:
|
|
2710
|
-
offset:
|
|
2711
|
-
order:
|
|
2883
|
+
limit: z8.string().optional(),
|
|
2884
|
+
offset: z8.string().optional(),
|
|
2885
|
+
order: z8.enum(["asc", "desc"]).optional()
|
|
2712
2886
|
});
|
|
2713
|
-
var AgentRunListResponseSchema =
|
|
2714
|
-
runs:
|
|
2715
|
-
hasMore:
|
|
2716
|
-
total:
|
|
2887
|
+
var AgentRunListResponseSchema = z8.object({
|
|
2888
|
+
runs: z8.array(AgentRunSchema),
|
|
2889
|
+
hasMore: z8.boolean(),
|
|
2890
|
+
total: z8.number()
|
|
2717
2891
|
});
|
|
2718
2892
|
|
|
2719
2893
|
// src/routes/agents.ts
|
|
2720
2894
|
var AgentMessageFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
2721
|
-
path:
|
|
2895
|
+
path: z9.string().min(1).regex(/^\/parts(?:\/|$)/, "Agent message file content paths must start with /parts/")
|
|
2722
2896
|
});
|
|
2723
2897
|
function serializeAgent(agent) {
|
|
2724
2898
|
return AgentCatalogItemSchema.parse({
|
|
@@ -2746,7 +2920,7 @@ function serializeThread(thread) {
|
|
|
2746
2920
|
updatedAt: toIsoString(thread.updatedAt)
|
|
2747
2921
|
});
|
|
2748
2922
|
}
|
|
2749
|
-
function serializeMessage(message, annotations = []) {
|
|
2923
|
+
function serializeMessage(message, annotations = [], checkpoint) {
|
|
2750
2924
|
return AgentMessageSchema.parse({
|
|
2751
2925
|
id: message.id,
|
|
2752
2926
|
projectId: message.projectId,
|
|
@@ -2757,6 +2931,11 @@ function serializeMessage(message, annotations = []) {
|
|
|
2757
2931
|
seq: message.seq,
|
|
2758
2932
|
parts: message.parts,
|
|
2759
2933
|
annotations,
|
|
2934
|
+
compaction: checkpoint ? {
|
|
2935
|
+
checkpointId: checkpoint.id,
|
|
2936
|
+
summary: checkpoint.summary,
|
|
2937
|
+
createdAt: toIsoString(checkpoint.createdAt)
|
|
2938
|
+
} : undefined,
|
|
2760
2939
|
metadata: message.metadata,
|
|
2761
2940
|
contentVersion: message.contentVersion,
|
|
2762
2941
|
createdAt: toIsoString(message.createdAt),
|
|
@@ -2775,6 +2954,7 @@ function serializeAgentRun(run) {
|
|
|
2775
2954
|
modelId: run.modelId,
|
|
2776
2955
|
finishReason: run.finishReason,
|
|
2777
2956
|
usage: run.usage,
|
|
2957
|
+
cost: run.cost,
|
|
2778
2958
|
diagnostics: run.diagnostics,
|
|
2779
2959
|
error: run.error,
|
|
2780
2960
|
attempt: run.attempt,
|
|
@@ -3040,10 +3220,14 @@ function registerAgentRoutes(app, host) {
|
|
|
3040
3220
|
order: parsed.order
|
|
3041
3221
|
});
|
|
3042
3222
|
const runIds = result.messages.flatMap((message) => message.runId === null ? [] : [message.runId]);
|
|
3043
|
-
const runs = await
|
|
3223
|
+
const [runs, checkpoints] = await Promise.all([
|
|
3224
|
+
storage.runs.getByIds({ projectId: host.id, ids: runIds }),
|
|
3225
|
+
storage.checkpoints.getByRunIds({ projectId: host.id, runIds })
|
|
3226
|
+
]);
|
|
3044
3227
|
const diagnosticsByRunId = new Map(runs.filter((run) => run.threadId === thread.id).map((run) => [run.id, run.diagnostics ?? []]));
|
|
3228
|
+
const checkpointsByRunId = new Map(checkpoints.filter((checkpoint) => checkpoint.threadId === thread.id).map((checkpoint) => [checkpoint.createdByRunId, checkpoint]));
|
|
3045
3229
|
return AgentMessageListResponseSchema.parse({
|
|
3046
|
-
messages: result.messages.map((message) => serializeMessage(message, message.runId === null ? [] : diagnosticsByRunId.get(message.runId) ?? [])),
|
|
3230
|
+
messages: result.messages.map((message) => serializeMessage(message, message.runId === null ? [] : diagnosticsByRunId.get(message.runId) ?? [], message.runId === null ? undefined : checkpointsByRunId.get(message.runId))),
|
|
3047
3231
|
hasMore: result.hasMore,
|
|
3048
3232
|
total: result.total
|
|
3049
3233
|
});
|
|
@@ -3239,7 +3423,7 @@ function registerAgentRoutes(app, host) {
|
|
|
3239
3423
|
return handleAgentRouteError(error, set);
|
|
3240
3424
|
}
|
|
3241
3425
|
}, {
|
|
3242
|
-
params: AgentRunParamsSchema.extend({ threadId:
|
|
3426
|
+
params: AgentRunParamsSchema.extend({ threadId: z9.string().trim().min(1) }),
|
|
3243
3427
|
response: {
|
|
3244
3428
|
202: RetryAgentRunResponseSchema,
|
|
3245
3429
|
400: ErrorResponseSchema,
|
|
@@ -3327,6 +3511,143 @@ function registerAgentRoutes(app, host) {
|
|
|
3327
3511
|
});
|
|
3328
3512
|
}
|
|
3329
3513
|
|
|
3514
|
+
// src/routes/ai-accounting.ts
|
|
3515
|
+
function serializeAggregate(aggregate) {
|
|
3516
|
+
return {
|
|
3517
|
+
modelCallCount: aggregate.modelCallCount,
|
|
3518
|
+
usage: aggregate.usage,
|
|
3519
|
+
costs: aggregate.costs
|
|
3520
|
+
};
|
|
3521
|
+
}
|
|
3522
|
+
function serializeOverview(overview) {
|
|
3523
|
+
return AiAccountingOverviewResponseSchema.parse({
|
|
3524
|
+
range: {
|
|
3525
|
+
from: overview.range.from.toISOString(),
|
|
3526
|
+
to: overview.range.to.toISOString()
|
|
3527
|
+
},
|
|
3528
|
+
bucket: overview.bucket,
|
|
3529
|
+
totals: serializeAggregate(overview.totals),
|
|
3530
|
+
series: overview.series.map((period) => ({
|
|
3531
|
+
start: period.start.toISOString(),
|
|
3532
|
+
end: period.end.toISOString(),
|
|
3533
|
+
...serializeAggregate(period)
|
|
3534
|
+
})),
|
|
3535
|
+
models: overview.models.map((model) => ({
|
|
3536
|
+
providerId: model.providerId,
|
|
3537
|
+
modelId: model.modelId,
|
|
3538
|
+
...serializeAggregate(model)
|
|
3539
|
+
})),
|
|
3540
|
+
agents: overview.agents.map((agent) => ({
|
|
3541
|
+
agentId: agent.agentId,
|
|
3542
|
+
...serializeAggregate(agent)
|
|
3543
|
+
})),
|
|
3544
|
+
workflows: overview.workflows.map((workflow) => ({
|
|
3545
|
+
workflowId: workflow.workflowId,
|
|
3546
|
+
...serializeAggregate(workflow)
|
|
3547
|
+
}))
|
|
3548
|
+
});
|
|
3549
|
+
}
|
|
3550
|
+
function serializeModelCall(item) {
|
|
3551
|
+
return AiModelCallAccountingListResponseSchema.shape.items.element.parse({
|
|
3552
|
+
usage: {
|
|
3553
|
+
id: item.usage.id,
|
|
3554
|
+
executionId: item.usage.executionId,
|
|
3555
|
+
attempt: item.usage.attempt,
|
|
3556
|
+
callId: item.usage.callId,
|
|
3557
|
+
providerId: item.usage.providerId,
|
|
3558
|
+
requestedModelId: item.usage.requestedModelId,
|
|
3559
|
+
responseModelId: item.usage.responseModelId,
|
|
3560
|
+
responseId: item.usage.responseId,
|
|
3561
|
+
usage: item.usage.usage,
|
|
3562
|
+
occurredAt: item.usage.occurredAt.toISOString(),
|
|
3563
|
+
recordedAt: item.usage.recordedAt.toISOString()
|
|
3564
|
+
},
|
|
3565
|
+
attribution: item.attribution,
|
|
3566
|
+
cost: item.cost === undefined ? undefined : {
|
|
3567
|
+
...item.cost,
|
|
3568
|
+
priceSource: {
|
|
3569
|
+
...item.cost.priceSource,
|
|
3570
|
+
observedAt: item.cost.priceSource.observedAt.toISOString()
|
|
3571
|
+
},
|
|
3572
|
+
ratedAt: item.cost.ratedAt.toISOString()
|
|
3573
|
+
},
|
|
3574
|
+
valuationStatus: item.valuationStatus
|
|
3575
|
+
});
|
|
3576
|
+
}
|
|
3577
|
+
function registerAiAccountingRoutes(app, host) {
|
|
3578
|
+
app.get("/api/ai/accounting/overview", async ({ query, set }) => {
|
|
3579
|
+
try {
|
|
3580
|
+
const parsed = AiAccountingOverviewQuerySchema.parse(query);
|
|
3581
|
+
const storage = host.storage.aiCosts;
|
|
3582
|
+
if (!storage)
|
|
3583
|
+
return unconfiguredStorageResponse2(set, "AI cost storage");
|
|
3584
|
+
const overview = await storage.queryProjectOverview({
|
|
3585
|
+
projectId: host.id,
|
|
3586
|
+
from: new Date(parsed.from),
|
|
3587
|
+
to: new Date(parsed.to),
|
|
3588
|
+
bucket: parsed.bucket,
|
|
3589
|
+
providerId: parsed.providerId,
|
|
3590
|
+
modelId: parsed.modelId
|
|
3591
|
+
});
|
|
3592
|
+
return serializeOverview(overview);
|
|
3593
|
+
} catch (error) {
|
|
3594
|
+
return handleRouteError(error, set);
|
|
3595
|
+
}
|
|
3596
|
+
}, {
|
|
3597
|
+
query: AiAccountingOverviewQuerySchema,
|
|
3598
|
+
response: {
|
|
3599
|
+
200: AiAccountingOverviewResponseSchema,
|
|
3600
|
+
400: ErrorResponseSchema,
|
|
3601
|
+
501: ErrorResponseSchema
|
|
3602
|
+
},
|
|
3603
|
+
detail: {
|
|
3604
|
+
summary: "Get project AI usage and cost analytics",
|
|
3605
|
+
tags: [OPENAPI_TAGS.aiAccounting.name],
|
|
3606
|
+
operationId: "getAiAccountingOverview"
|
|
3607
|
+
}
|
|
3608
|
+
});
|
|
3609
|
+
app.get("/api/ai/model-calls", async ({ query, set }) => {
|
|
3610
|
+
try {
|
|
3611
|
+
const parsed = AiModelCallAccountingListQuerySchema.parse(query);
|
|
3612
|
+
const storage = host.storage.aiCosts;
|
|
3613
|
+
if (!storage)
|
|
3614
|
+
return unconfiguredStorageResponse2(set, "AI cost storage");
|
|
3615
|
+
const result = await storage.listModelCalls({
|
|
3616
|
+
projectId: host.id,
|
|
3617
|
+
from: new Date(parsed.from),
|
|
3618
|
+
to: new Date(parsed.to),
|
|
3619
|
+
providerId: parsed.providerId,
|
|
3620
|
+
modelId: parsed.modelId,
|
|
3621
|
+
executionId: parsed.executionId,
|
|
3622
|
+
valuationStatus: parsed.valuationStatus,
|
|
3623
|
+
limit: parseOptionalInt(parsed.limit),
|
|
3624
|
+
offset: parseOptionalInt(parsed.offset)
|
|
3625
|
+
});
|
|
3626
|
+
const items = result.items.map(serializeModelCall);
|
|
3627
|
+
return AiModelCallAccountingListResponseSchema.parse({
|
|
3628
|
+
items,
|
|
3629
|
+
hasMore: result.hasMore,
|
|
3630
|
+
total: result.total
|
|
3631
|
+
});
|
|
3632
|
+
} catch (error) {
|
|
3633
|
+
return handleRouteError(error, set);
|
|
3634
|
+
}
|
|
3635
|
+
}, {
|
|
3636
|
+
query: AiModelCallAccountingListQuerySchema,
|
|
3637
|
+
response: {
|
|
3638
|
+
200: AiModelCallAccountingListResponseSchema,
|
|
3639
|
+
400: ErrorResponseSchema,
|
|
3640
|
+
501: ErrorResponseSchema
|
|
3641
|
+
},
|
|
3642
|
+
detail: {
|
|
3643
|
+
summary: "List project AI model-call accounting records",
|
|
3644
|
+
tags: [OPENAPI_TAGS.aiAccounting.name],
|
|
3645
|
+
operationId: "listAiModelCalls"
|
|
3646
|
+
}
|
|
3647
|
+
});
|
|
3648
|
+
return app;
|
|
3649
|
+
}
|
|
3650
|
+
|
|
3330
3651
|
// src/routes/connector-connection-runs.ts
|
|
3331
3652
|
import { getConnectorConnectionCallbackProcess } from "@sixb/core/internal/connector-connections";
|
|
3332
3653
|
|
|
@@ -3406,7 +3727,7 @@ import { createSixbError as createSixbError2 } from "@sixb/core/internal/errors"
|
|
|
3406
3727
|
import {
|
|
3407
3728
|
CONNECTOR_CONNECTION_RUN_FAILURE_CODES
|
|
3408
3729
|
} from "@sixb/core/storage";
|
|
3409
|
-
import { z as
|
|
3730
|
+
import { z as z10 } from "zod";
|
|
3410
3731
|
var CONNECTOR_HTTP_ERROR_CODES = [
|
|
3411
3732
|
"internal.unexpected",
|
|
3412
3733
|
"connector.adapter_invalid",
|
|
@@ -3447,114 +3768,116 @@ var ConnectorUnavailableResponseSchema = connectorRouteErrorResponseSchema([
|
|
|
3447
3768
|
"connector.credentials_unavailable",
|
|
3448
3769
|
"connector.provider_unavailable"
|
|
3449
3770
|
]);
|
|
3450
|
-
var ConnectorParamsSchema =
|
|
3451
|
-
connectorId:
|
|
3771
|
+
var ConnectorParamsSchema = z10.object({
|
|
3772
|
+
connectorId: z10.string().min(1)
|
|
3452
3773
|
});
|
|
3453
3774
|
var ConnectorConnectionParamsSchema = ConnectorParamsSchema.extend({
|
|
3454
|
-
connectionId:
|
|
3775
|
+
connectionId: z10.string().min(1)
|
|
3455
3776
|
});
|
|
3456
3777
|
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:
|
|
3778
|
+
runId: z10.string().min(1)
|
|
3779
|
+
});
|
|
3780
|
+
var ConnectorWebhookSchema = z10.object({
|
|
3781
|
+
id: z10.string(),
|
|
3782
|
+
method: z10.literal("POST"),
|
|
3783
|
+
route: z10.string(),
|
|
3784
|
+
bodyFormat: z10.enum(["json", "text", "raw"]),
|
|
3785
|
+
hasVerify: z10.boolean(),
|
|
3786
|
+
hasIdempotency: z10.boolean()
|
|
3787
|
+
});
|
|
3788
|
+
var ConnectorSchema = z10.object({
|
|
3789
|
+
id: z10.string(),
|
|
3790
|
+
type: z10.string(),
|
|
3791
|
+
connection: z10.object({ authentication: z10.literal("oauth2") }).nullable(),
|
|
3792
|
+
syncIds: z10.array(z10.string()),
|
|
3793
|
+
webhooks: z10.array(ConnectorWebhookSchema)
|
|
3794
|
+
});
|
|
3795
|
+
var ConnectorAccountSchema = z10.object({
|
|
3796
|
+
id: z10.string(),
|
|
3797
|
+
label: z10.string(),
|
|
3798
|
+
description: z10.string().optional(),
|
|
3799
|
+
avatarUrl: z10.string().url().optional()
|
|
3800
|
+
});
|
|
3801
|
+
var ConnectorConnectionSchema = z10.object({
|
|
3802
|
+
id: z10.string(),
|
|
3803
|
+
connectorId: z10.string(),
|
|
3804
|
+
owner: z10.object({ type: z10.literal("project") }),
|
|
3805
|
+
slot: z10.string(),
|
|
3485
3806
|
account: ConnectorAccountSchema,
|
|
3486
|
-
status:
|
|
3807
|
+
status: z10.enum(["connected", "needs_reauthorization", "disconnected"])
|
|
3487
3808
|
});
|
|
3488
3809
|
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 =
|
|
3810
|
+
var ConnectorConnectionRunBaseSchema = z10.object({
|
|
3811
|
+
id: z10.string(),
|
|
3812
|
+
connectorId: z10.string(),
|
|
3813
|
+
kind: z10.enum(["connect", "reauthorize"]),
|
|
3814
|
+
owner: z10.object({ type: z10.literal("project") }),
|
|
3815
|
+
slot: z10.string(),
|
|
3816
|
+
createdAt: z10.string().datetime(),
|
|
3817
|
+
updatedAt: z10.string().datetime()
|
|
3818
|
+
});
|
|
3819
|
+
var ConnectorConnectionRunSchema = z10.union([
|
|
3499
3820
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3500
|
-
status:
|
|
3501
|
-
waitingFor:
|
|
3502
|
-
expiresAt:
|
|
3821
|
+
status: z10.literal("waiting"),
|
|
3822
|
+
waitingFor: z10.literal("provider_authorization"),
|
|
3823
|
+
expiresAt: z10.string().datetime()
|
|
3503
3824
|
}),
|
|
3504
3825
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3505
|
-
status:
|
|
3826
|
+
status: z10.literal("running")
|
|
3506
3827
|
}),
|
|
3507
3828
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3508
|
-
status:
|
|
3509
|
-
waitingFor:
|
|
3510
|
-
accounts:
|
|
3511
|
-
expiresAt:
|
|
3829
|
+
status: z10.literal("waiting"),
|
|
3830
|
+
waitingFor: z10.literal("account_selection"),
|
|
3831
|
+
accounts: z10.array(ConnectorAccountSchema),
|
|
3832
|
+
expiresAt: z10.string().datetime()
|
|
3512
3833
|
}),
|
|
3513
3834
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3514
|
-
status:
|
|
3515
|
-
connections:
|
|
3516
|
-
finishedAt:
|
|
3835
|
+
status: z10.literal("succeeded"),
|
|
3836
|
+
connections: z10.array(ConnectorConnectionSchema),
|
|
3837
|
+
finishedAt: z10.string().datetime()
|
|
3517
3838
|
}),
|
|
3518
3839
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3519
|
-
status:
|
|
3840
|
+
status: z10.literal("failed"),
|
|
3520
3841
|
error: ConnectorConnectionRunFailureSchema,
|
|
3521
|
-
finishedAt:
|
|
3842
|
+
finishedAt: z10.string().datetime()
|
|
3522
3843
|
}),
|
|
3523
3844
|
ConnectorConnectionRunBaseSchema.extend({
|
|
3524
|
-
status:
|
|
3525
|
-
finishedAt:
|
|
3845
|
+
status: z10.enum(["cancelled", "expired"]),
|
|
3846
|
+
finishedAt: z10.string().datetime()
|
|
3526
3847
|
})
|
|
3527
3848
|
]);
|
|
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:
|
|
3552
|
-
}).refine((query) =>
|
|
3553
|
-
|
|
3554
|
-
|
|
3849
|
+
var StartConnectorConnectionRunBodySchema = z10.object({
|
|
3850
|
+
slot: z10.string().trim().min(1),
|
|
3851
|
+
returnTo: z10.string().url()
|
|
3852
|
+
});
|
|
3853
|
+
var AddConnectorConnectionBodySchema = z10.object({
|
|
3854
|
+
slot: z10.string().trim().min(1)
|
|
3855
|
+
});
|
|
3856
|
+
var StartConnectorReauthorizationBodySchema = z10.object({
|
|
3857
|
+
returnTo: z10.string().url()
|
|
3858
|
+
});
|
|
3859
|
+
var StartConnectorConnectionRunResponseSchema = z10.object({
|
|
3860
|
+
runId: z10.string(),
|
|
3861
|
+
authorizationUrl: z10.string().url(),
|
|
3862
|
+
affectedConnections: z10.array(ConnectorConnectionSchema)
|
|
3863
|
+
});
|
|
3864
|
+
var SelectConnectorConnectionRunAccountBodySchema = z10.object({
|
|
3865
|
+
accountId: z10.string().trim().min(1),
|
|
3866
|
+
replace: z10.boolean().optional()
|
|
3867
|
+
});
|
|
3868
|
+
var ConnectorOAuthCallbackQuerySchema = z10.object({
|
|
3869
|
+
state: z10.string().min(1),
|
|
3870
|
+
code: z10.string().min(1).optional(),
|
|
3871
|
+
auth_code: z10.string().min(1).optional(),
|
|
3872
|
+
error: z10.string().min(1).optional()
|
|
3873
|
+
}).refine((query) => {
|
|
3874
|
+
const hasAuthorizationCode = query.code !== undefined || query.auth_code !== undefined;
|
|
3875
|
+
const hasProviderError = query.error !== undefined;
|
|
3876
|
+
return hasAuthorizationCode !== hasProviderError;
|
|
3877
|
+
}, { message: "OAuth callback must contain exactly one of an authorization code or error." }).refine((query) => query.code === undefined || query.auth_code === undefined || query.code === query.auth_code, { message: "OAuth callback code and auth_code must match when both are present." }).transform(({ auth_code, ...query }) => ({ ...query, code: query.code ?? auth_code }));
|
|
3555
3878
|
function connectorRouteErrorResponseSchema(codes) {
|
|
3556
3879
|
return ErrorResponseSchema.extend({
|
|
3557
|
-
code:
|
|
3880
|
+
code: z10.enum(codes).optional().describe("Stable machine-readable failure code for programmatic handling.")
|
|
3558
3881
|
});
|
|
3559
3882
|
}
|
|
3560
3883
|
|
|
@@ -3998,25 +4321,25 @@ function registerConnectorRoutes(app, host) {
|
|
|
3998
4321
|
import { createSixbError as createSixbError3 } from "@sixb/core/internal/errors";
|
|
3999
4322
|
|
|
4000
4323
|
// src/schemas/datasets.ts
|
|
4001
|
-
import { z as
|
|
4002
|
-
var DatasetParamsSchema =
|
|
4003
|
-
datasetId:
|
|
4324
|
+
import { z as z11 } from "zod";
|
|
4325
|
+
var DatasetParamsSchema = z11.object({
|
|
4326
|
+
datasetId: z11.string().min(1)
|
|
4004
4327
|
});
|
|
4005
4328
|
var DatasetVersionParamsSchema = DatasetParamsSchema.extend({
|
|
4006
|
-
versionId:
|
|
4329
|
+
versionId: z11.string().min(1)
|
|
4007
4330
|
});
|
|
4008
|
-
var DatasetVersionsQuerySchema =
|
|
4009
|
-
limit:
|
|
4331
|
+
var DatasetVersionsQuerySchema = z11.object({
|
|
4332
|
+
limit: z11.string().optional()
|
|
4010
4333
|
});
|
|
4011
|
-
var DatasetRowsQuerySchema =
|
|
4012
|
-
versionId:
|
|
4013
|
-
columns:
|
|
4014
|
-
limit:
|
|
4015
|
-
offset:
|
|
4334
|
+
var DatasetRowsQuerySchema = z11.object({
|
|
4335
|
+
versionId: z11.string().optional(),
|
|
4336
|
+
columns: z11.string().optional(),
|
|
4337
|
+
limit: z11.string().optional(),
|
|
4338
|
+
offset: z11.string().optional()
|
|
4016
4339
|
});
|
|
4017
|
-
var DatasetColumnSchema =
|
|
4018
|
-
name:
|
|
4019
|
-
type:
|
|
4340
|
+
var DatasetColumnSchema = z11.object({
|
|
4341
|
+
name: z11.string(),
|
|
4342
|
+
type: z11.enum([
|
|
4020
4343
|
"string",
|
|
4021
4344
|
"boolean",
|
|
4022
4345
|
"int64",
|
|
@@ -4027,70 +4350,70 @@ var DatasetColumnSchema = z10.object({
|
|
|
4027
4350
|
"json",
|
|
4028
4351
|
"fileRef"
|
|
4029
4352
|
]),
|
|
4030
|
-
nullable:
|
|
4353
|
+
nullable: z11.boolean().optional()
|
|
4031
4354
|
});
|
|
4032
|
-
var DatasetSchema =
|
|
4033
|
-
columns:
|
|
4355
|
+
var DatasetSchema = z11.object({
|
|
4356
|
+
columns: z11.array(DatasetColumnSchema)
|
|
4034
4357
|
});
|
|
4035
|
-
var DatasetDefinitionSchema =
|
|
4036
|
-
id:
|
|
4037
|
-
description:
|
|
4038
|
-
primaryKey:
|
|
4039
|
-
partitionBy:
|
|
4358
|
+
var DatasetDefinitionSchema = z11.object({
|
|
4359
|
+
id: z11.string(),
|
|
4360
|
+
description: z11.string().optional(),
|
|
4361
|
+
primaryKey: z11.union([z11.string(), z11.array(z11.string()).min(2)]).optional(),
|
|
4362
|
+
partitionBy: z11.array(z11.string()).optional(),
|
|
4040
4363
|
schema: DatasetSchema
|
|
4041
4364
|
});
|
|
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:
|
|
4365
|
+
var DatasetVersionRefSchema = z11.object({
|
|
4366
|
+
datasetId: z11.string(),
|
|
4367
|
+
versionId: z11.string()
|
|
4368
|
+
});
|
|
4369
|
+
var DatasetProducerSchema = z11.object({
|
|
4370
|
+
kind: z11.enum(["sync", "pipeline"]),
|
|
4371
|
+
id: z11.string().optional(),
|
|
4372
|
+
runId: z11.string().optional()
|
|
4373
|
+
});
|
|
4374
|
+
var DatasetVersionSchema = z11.object({
|
|
4375
|
+
datasetId: z11.string(),
|
|
4376
|
+
versionId: z11.string(),
|
|
4377
|
+
parentVersionId: z11.string().optional(),
|
|
4378
|
+
mode: z11.enum(["snapshot", "append", "merge", "schema"]),
|
|
4379
|
+
createdAt: z11.string(),
|
|
4057
4380
|
schema: DatasetSchema,
|
|
4058
4381
|
producer: DatasetProducerSchema.optional(),
|
|
4059
|
-
inputs:
|
|
4060
|
-
rowCount:
|
|
4061
|
-
sizeBytes:
|
|
4382
|
+
inputs: z11.array(DatasetVersionRefSchema).optional(),
|
|
4383
|
+
rowCount: z11.number().optional(),
|
|
4384
|
+
sizeBytes: z11.number().optional()
|
|
4062
4385
|
});
|
|
4063
|
-
var DatasetLatestVersionSummarySchema =
|
|
4064
|
-
datasetId:
|
|
4065
|
-
versionId:
|
|
4066
|
-
mode:
|
|
4067
|
-
createdAt:
|
|
4068
|
-
rowCount:
|
|
4386
|
+
var DatasetLatestVersionSummarySchema = z11.object({
|
|
4387
|
+
datasetId: z11.string(),
|
|
4388
|
+
versionId: z11.string(),
|
|
4389
|
+
mode: z11.enum(["snapshot", "append", "merge", "schema"]),
|
|
4390
|
+
createdAt: z11.string(),
|
|
4391
|
+
rowCount: z11.number().optional()
|
|
4069
4392
|
});
|
|
4070
4393
|
var DatasetCatalogItemSchema = DatasetDefinitionSchema.extend({
|
|
4071
|
-
kind:
|
|
4072
|
-
materialized:
|
|
4394
|
+
kind: z11.literal("dataset"),
|
|
4395
|
+
materialized: z11.boolean(),
|
|
4073
4396
|
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:
|
|
4397
|
+
syncIds: z11.array(z11.string()),
|
|
4398
|
+
sourcePipelineIds: z11.array(z11.string()),
|
|
4399
|
+
targetPipelineIds: z11.array(z11.string()),
|
|
4400
|
+
projectionIds: z11.array(z11.string())
|
|
4401
|
+
});
|
|
4402
|
+
var DatasetVersionListResponseSchema = z11.object({
|
|
4403
|
+
versions: z11.array(DatasetVersionSchema),
|
|
4404
|
+
count: z11.number()
|
|
4405
|
+
});
|
|
4406
|
+
var DatasetRowsResponseSchema = z11.object({
|
|
4407
|
+
datasetId: z11.string(),
|
|
4408
|
+
versionId: z11.string(),
|
|
4086
4409
|
version: DatasetVersionSchema,
|
|
4087
|
-
columns:
|
|
4088
|
-
rows:
|
|
4089
|
-
count:
|
|
4090
|
-
limit:
|
|
4091
|
-
offset:
|
|
4092
|
-
total:
|
|
4093
|
-
hasMore:
|
|
4410
|
+
columns: z11.array(z11.string()),
|
|
4411
|
+
rows: z11.array(z11.record(z11.unknown())),
|
|
4412
|
+
count: z11.number(),
|
|
4413
|
+
limit: z11.number(),
|
|
4414
|
+
offset: z11.number(),
|
|
4415
|
+
total: z11.number().optional(),
|
|
4416
|
+
hasMore: z11.boolean()
|
|
4094
4417
|
});
|
|
4095
4418
|
|
|
4096
4419
|
// src/routes/datasets.ts
|
|
@@ -4393,44 +4716,44 @@ import {
|
|
|
4393
4716
|
EVENT_DEFINITIONS,
|
|
4394
4717
|
isOntologyFactType
|
|
4395
4718
|
} from "@sixb/core/internal/events";
|
|
4396
|
-
import { z as
|
|
4719
|
+
import { z as z13 } from "zod";
|
|
4397
4720
|
|
|
4398
4721
|
// src/schemas/event-payloads.ts
|
|
4399
|
-
import { z as
|
|
4400
|
-
var PropertyChangeSchema =
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
operation:
|
|
4722
|
+
import { z as z12 } from "zod";
|
|
4723
|
+
var PropertyChangeSchema = z12.discriminatedUnion("operation", [
|
|
4724
|
+
z12.object({ operation: z12.literal("created"), after: JsonValueSchema }),
|
|
4725
|
+
z12.object({
|
|
4726
|
+
operation: z12.literal("updated"),
|
|
4404
4727
|
before: JsonValueSchema,
|
|
4405
4728
|
after: JsonValueSchema
|
|
4406
4729
|
}),
|
|
4407
|
-
|
|
4408
|
-
operation:
|
|
4730
|
+
z12.object({
|
|
4731
|
+
operation: z12.literal("cleared"),
|
|
4409
4732
|
before: JsonValueSchema,
|
|
4410
4733
|
after: JsonNullSchema
|
|
4411
4734
|
})
|
|
4412
4735
|
]);
|
|
4413
|
-
var PropertyChangesSchema =
|
|
4414
|
-
var ObjectMutationPayloadSchema =
|
|
4415
|
-
objectTypeId:
|
|
4416
|
-
primaryId:
|
|
4417
|
-
properties:
|
|
4736
|
+
var PropertyChangesSchema = z12.record(PropertyChangeSchema);
|
|
4737
|
+
var ObjectMutationPayloadSchema = z12.object({
|
|
4738
|
+
objectTypeId: z12.string(),
|
|
4739
|
+
primaryId: z12.string(),
|
|
4740
|
+
properties: z12.record(JsonValueSchema),
|
|
4418
4741
|
propertyChanges: PropertyChangesSchema
|
|
4419
4742
|
});
|
|
4420
|
-
var ObjectDeletedPayloadSchema =
|
|
4421
|
-
objectTypeId:
|
|
4422
|
-
primaryId:
|
|
4743
|
+
var ObjectDeletedPayloadSchema = z12.object({
|
|
4744
|
+
objectTypeId: z12.string(),
|
|
4745
|
+
primaryId: z12.string(),
|
|
4423
4746
|
propertyChanges: PropertyChangesSchema
|
|
4424
4747
|
});
|
|
4425
|
-
var LinkSubjectSchema =
|
|
4426
|
-
sourceTypeId:
|
|
4427
|
-
sourceId:
|
|
4428
|
-
linkId:
|
|
4429
|
-
targetTypeId:
|
|
4430
|
-
targetId:
|
|
4748
|
+
var LinkSubjectSchema = z12.object({
|
|
4749
|
+
sourceTypeId: z12.string(),
|
|
4750
|
+
sourceId: z12.string(),
|
|
4751
|
+
linkId: z12.string(),
|
|
4752
|
+
targetTypeId: z12.string(),
|
|
4753
|
+
targetId: z12.string()
|
|
4431
4754
|
});
|
|
4432
4755
|
var LinkMutationPayloadSchema = LinkSubjectSchema.extend({
|
|
4433
|
-
properties:
|
|
4756
|
+
properties: z12.record(JsonValueSchema).optional(),
|
|
4434
4757
|
propertyChanges: PropertyChangesSchema
|
|
4435
4758
|
});
|
|
4436
4759
|
var LinkDeletedPayloadSchema = LinkSubjectSchema.extend({
|
|
@@ -4443,91 +4766,91 @@ var ONTOLOGY_EVENT_PAYLOAD_SCHEMAS = {
|
|
|
4443
4766
|
"link.created": LinkMutationPayloadSchema,
|
|
4444
4767
|
"link.updated": LinkMutationPayloadSchema,
|
|
4445
4768
|
"link.deleted": LinkDeletedPayloadSchema,
|
|
4446
|
-
"telemetry.appended":
|
|
4447
|
-
objectTypeId:
|
|
4448
|
-
objectId:
|
|
4449
|
-
propertyId:
|
|
4769
|
+
"telemetry.appended": z12.object({
|
|
4770
|
+
objectTypeId: z12.string(),
|
|
4771
|
+
objectId: z12.string(),
|
|
4772
|
+
propertyId: z12.string(),
|
|
4450
4773
|
value: JsonValueSchema,
|
|
4451
|
-
unit:
|
|
4452
|
-
at:
|
|
4774
|
+
unit: z12.string().optional(),
|
|
4775
|
+
at: z12.string()
|
|
4453
4776
|
})
|
|
4454
4777
|
};
|
|
4455
4778
|
|
|
4456
4779
|
// src/schemas/events.ts
|
|
4457
4780
|
var EVENT_TOPICS = CORE_EVENT_TOPICS;
|
|
4458
4781
|
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:
|
|
4782
|
+
var EventTopicSchema = z13.enum(EVENT_TOPICS);
|
|
4783
|
+
var EventTypeSchema = z13.enum(EVENT_TYPES);
|
|
4784
|
+
var ProjectionEventOriginSchema = z13.object({
|
|
4785
|
+
kind: z13.literal("projection"),
|
|
4786
|
+
projectionId: z13.string(),
|
|
4787
|
+
projectionRunId: z13.string(),
|
|
4788
|
+
datasetId: z13.string(),
|
|
4789
|
+
datasetVersionId: z13.string()
|
|
4790
|
+
});
|
|
4791
|
+
var EventOriginSchema = z13.union([
|
|
4792
|
+
z13.object({
|
|
4793
|
+
kind: z13.literal("action"),
|
|
4794
|
+
actionId: z13.string(),
|
|
4795
|
+
runId: z13.string()
|
|
4473
4796
|
}),
|
|
4474
|
-
|
|
4797
|
+
z13.object({ kind: z13.literal("runtime"), requestId: z13.string() }),
|
|
4475
4798
|
ProjectionEventOriginSchema,
|
|
4476
|
-
|
|
4477
|
-
kind:
|
|
4478
|
-
source:
|
|
4479
|
-
|
|
4480
|
-
ProjectionEventOriginSchema.extend({ batchOrdinal:
|
|
4799
|
+
z13.object({
|
|
4800
|
+
kind: z13.literal("telemetry"),
|
|
4801
|
+
source: z13.union([
|
|
4802
|
+
z13.object({ kind: z13.literal("runtime"), requestId: z13.string() }),
|
|
4803
|
+
ProjectionEventOriginSchema.extend({ batchOrdinal: z13.number() })
|
|
4481
4804
|
])
|
|
4482
4805
|
})
|
|
4483
4806
|
]);
|
|
4484
|
-
var EventsQuerySchema =
|
|
4807
|
+
var EventsQuerySchema = z13.object({
|
|
4485
4808
|
topic: EventTopicSchema.optional(),
|
|
4486
4809
|
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:
|
|
4810
|
+
afterCursor: z13.string().optional(),
|
|
4811
|
+
limit: z13.string().optional()
|
|
4812
|
+
});
|
|
4813
|
+
var StoredEventBaseSchema = z13.object({
|
|
4814
|
+
id: z13.string(),
|
|
4815
|
+
cursor: z13.string(),
|
|
4816
|
+
schemaVersion: z13.literal(1),
|
|
4817
|
+
projectId: z13.string(),
|
|
4818
|
+
occurredAt: z13.string(),
|
|
4819
|
+
actor: z13.object({
|
|
4820
|
+
type: z13.enum(["user", "serviceAccount", "system"]),
|
|
4821
|
+
id: z13.string()
|
|
4499
4822
|
}).optional(),
|
|
4500
|
-
partitionKey:
|
|
4823
|
+
partitionKey: z13.string()
|
|
4501
4824
|
});
|
|
4502
4825
|
var StoredAuthorableEventBaseSchema = StoredEventBaseSchema.extend({
|
|
4503
|
-
correlationId:
|
|
4504
|
-
causationId:
|
|
4505
|
-
idempotencyKey:
|
|
4826
|
+
correlationId: z13.string().optional(),
|
|
4827
|
+
causationId: z13.string().optional(),
|
|
4828
|
+
idempotencyKey: z13.string().optional(),
|
|
4506
4829
|
origin: EventOriginSchema.optional(),
|
|
4507
|
-
metadata:
|
|
4830
|
+
metadata: z13.record(JsonValueSchema).optional()
|
|
4508
4831
|
});
|
|
4509
4832
|
var StoredOntologyEventBaseSchema = StoredEventBaseSchema.extend({
|
|
4510
4833
|
origin: EventOriginSchema,
|
|
4511
|
-
commitId:
|
|
4512
|
-
commitOrdinal:
|
|
4834
|
+
commitId: z13.string(),
|
|
4835
|
+
commitOrdinal: z13.number().int().nonnegative()
|
|
4513
4836
|
});
|
|
4514
4837
|
var ontologyEventTypes = EVENT_TYPES.filter(isOntologyFactType);
|
|
4515
4838
|
var ontologyEventSchemas = ontologyEventTypes.map((type) => StoredOntologyEventBaseSchema.extend({
|
|
4516
|
-
type:
|
|
4517
|
-
topic:
|
|
4839
|
+
type: z13.literal(type),
|
|
4840
|
+
topic: z13.literal(EVENT_DEFINITIONS[type].topic),
|
|
4518
4841
|
payload: ONTOLOGY_EVENT_PAYLOAD_SCHEMAS[type]
|
|
4519
4842
|
}));
|
|
4520
4843
|
var authorableEventTypes = EVENT_TYPES.filter((type) => !isOntologyFactType(type));
|
|
4521
4844
|
var StoredAuthorableEventSchema = StoredAuthorableEventBaseSchema.extend({
|
|
4522
|
-
type:
|
|
4845
|
+
type: z13.enum(authorableEventTypes),
|
|
4523
4846
|
topic: EventTopicSchema,
|
|
4524
|
-
payload:
|
|
4847
|
+
payload: z13.record(z13.unknown())
|
|
4525
4848
|
});
|
|
4526
|
-
var StoredOntologyEventSchema =
|
|
4527
|
-
var EventSchema =
|
|
4528
|
-
var EventsResponseSchema =
|
|
4529
|
-
count:
|
|
4530
|
-
events:
|
|
4849
|
+
var StoredOntologyEventSchema = z13.discriminatedUnion("type", ontologyEventSchemas);
|
|
4850
|
+
var EventSchema = z13.union([StoredOntologyEventSchema, StoredAuthorableEventSchema]);
|
|
4851
|
+
var EventsResponseSchema = z13.object({
|
|
4852
|
+
count: z13.number(),
|
|
4853
|
+
events: z13.array(EventSchema)
|
|
4531
4854
|
});
|
|
4532
4855
|
|
|
4533
4856
|
// src/routes/events.ts
|
|
@@ -4573,80 +4896,27 @@ function registerEventRoutes(app, _host) {
|
|
|
4573
4896
|
}
|
|
4574
4897
|
|
|
4575
4898
|
// src/schemas/links.ts
|
|
4576
|
-
import { z as
|
|
4577
|
-
var LinkSourceParamsSchema =
|
|
4578
|
-
objectTypeId:
|
|
4579
|
-
objectId:
|
|
4899
|
+
import { z as z14 } from "zod";
|
|
4900
|
+
var LinkSourceParamsSchema = z14.object({
|
|
4901
|
+
objectTypeId: z14.string().min(1),
|
|
4902
|
+
objectId: z14.string().min(1)
|
|
4580
4903
|
});
|
|
4581
4904
|
var LinkParamsSchema = LinkSourceParamsSchema.extend({
|
|
4582
|
-
linkId:
|
|
4583
|
-
});
|
|
4584
|
-
var LinkQuerySchema = z13.object({
|
|
4585
|
-
linkId: z13.string().optional(),
|
|
4586
|
-
direction: z13.enum(["outgoing", "incoming", "both"]).default("outgoing")
|
|
4587
|
-
});
|
|
4588
|
-
var RemoveLinkQuerySchema = z13.object({
|
|
4589
|
-
targetTypeId: z13.string().min(1),
|
|
4590
|
-
targetId: z13.string().min(1)
|
|
4905
|
+
linkId: z14.string().min(1)
|
|
4591
4906
|
});
|
|
4592
|
-
var
|
|
4593
|
-
targetTypeId:
|
|
4594
|
-
targetId:
|
|
4595
|
-
properties: z13.record(z13.unknown()).optional()
|
|
4907
|
+
var RemoveLinkQuerySchema = z14.object({
|
|
4908
|
+
targetTypeId: z14.string().min(1),
|
|
4909
|
+
targetId: z14.string().min(1)
|
|
4596
4910
|
});
|
|
4597
|
-
var
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
linkId: z13.string(),
|
|
4602
|
-
targetTypeId: z13.string(),
|
|
4603
|
-
targetId: z13.string(),
|
|
4604
|
-
properties: z13.record(z13.unknown()).optional(),
|
|
4605
|
-
createdAt: z13.string(),
|
|
4606
|
-
updatedAt: z13.string()
|
|
4911
|
+
var UpsertLinkBodySchema = z14.object({
|
|
4912
|
+
targetTypeId: z14.string().min(1),
|
|
4913
|
+
targetId: z14.string().min(1),
|
|
4914
|
+
properties: z14.record(z14.unknown()).optional()
|
|
4607
4915
|
});
|
|
4608
4916
|
|
|
4609
4917
|
// src/routes/links.ts
|
|
4610
4918
|
function registerLinkRoutes(app, _host) {
|
|
4611
|
-
return app.
|
|
4612
|
-
const { params, query, set } = context;
|
|
4613
|
-
try {
|
|
4614
|
-
const sixb = requireRequestSixb(context);
|
|
4615
|
-
if (!sixb.objects.getTypeById(params.objectTypeId)) {
|
|
4616
|
-
set.status = 404;
|
|
4617
|
-
return { error: "Object not found" };
|
|
4618
|
-
}
|
|
4619
|
-
const parsedQuery = LinkQuerySchema.parse(query);
|
|
4620
|
-
const links = await sixb.objects.listLinks({
|
|
4621
|
-
objectTypeId: params.objectTypeId,
|
|
4622
|
-
objectId: params.objectId,
|
|
4623
|
-
linkId: parsedQuery.linkId,
|
|
4624
|
-
direction: parsedQuery.direction
|
|
4625
|
-
});
|
|
4626
|
-
return links.map((link) => ({
|
|
4627
|
-
...link,
|
|
4628
|
-
createdAt: toIsoString(link.createdAt),
|
|
4629
|
-
updatedAt: toIsoString(link.updatedAt)
|
|
4630
|
-
}));
|
|
4631
|
-
} catch (error) {
|
|
4632
|
-
set.status = 400;
|
|
4633
|
-
return { error: error instanceof Error ? error.message : String(error) };
|
|
4634
|
-
}
|
|
4635
|
-
}, {
|
|
4636
|
-
params: LinkSourceParamsSchema,
|
|
4637
|
-
query: LinkQuerySchema,
|
|
4638
|
-
response: {
|
|
4639
|
-
200: ObjectLinkSchema.array(),
|
|
4640
|
-
400: ErrorResponseSchema,
|
|
4641
|
-
404: ErrorResponseSchema
|
|
4642
|
-
},
|
|
4643
|
-
detail: {
|
|
4644
|
-
summary: "List object links",
|
|
4645
|
-
tags: [OPENAPI_TAGS.links.name],
|
|
4646
|
-
operationId: "listObjectLinks",
|
|
4647
|
-
security: bearerSecurityRequirement("listObjectLinks")
|
|
4648
|
-
}
|
|
4649
|
-
}).put("/api/objects/:objectTypeId/:objectId/links/:linkId", async (context) => {
|
|
4919
|
+
return app.put("/api/objects/:objectTypeId/:objectId/links/:linkId", async (context) => {
|
|
4650
4920
|
const { params, body, set } = context;
|
|
4651
4921
|
try {
|
|
4652
4922
|
const parsedBody = UpsertLinkBodySchema.parse(body);
|
|
@@ -4709,71 +4979,71 @@ import { logLevelsAtOrAbove } from "@sixb/core";
|
|
|
4709
4979
|
|
|
4710
4980
|
// src/schemas/logs.ts
|
|
4711
4981
|
import { LOG_LEVELS, SIXB_RUN_KINDS } from "@sixb/core";
|
|
4712
|
-
import { z as
|
|
4713
|
-
var SixbRunKindSchema =
|
|
4714
|
-
var LogLevelSchema =
|
|
4715
|
-
var LogRunIdSchema =
|
|
4982
|
+
import { z as z15 } from "zod";
|
|
4983
|
+
var SixbRunKindSchema = z15.enum(SIXB_RUN_KINDS);
|
|
4984
|
+
var LogLevelSchema = z15.enum(LOG_LEVELS);
|
|
4985
|
+
var LogRunIdSchema = z15.string().regex(/\S/, "run id must not be blank");
|
|
4716
4986
|
var DEFAULT_LOGS_PAGE_LIMIT = 200;
|
|
4717
4987
|
var MAX_LOGS_PAGE_LIMIT = 1000;
|
|
4718
|
-
var LogsLimitSchema =
|
|
4719
|
-
var LogsQuerySchema =
|
|
4988
|
+
var LogsLimitSchema = z15.coerce.number().int().positive().max(MAX_LOGS_PAGE_LIMIT);
|
|
4989
|
+
var LogsQuerySchema = z15.object({
|
|
4720
4990
|
kind: SixbRunKindSchema.optional(),
|
|
4721
4991
|
runId: LogRunIdSchema.optional(),
|
|
4722
4992
|
level: LogLevelSchema.optional(),
|
|
4723
|
-
direction:
|
|
4724
|
-
afterCursor:
|
|
4725
|
-
beforeCursor:
|
|
4993
|
+
direction: z15.enum(["forward", "backward"]).optional(),
|
|
4994
|
+
afterCursor: z15.string().optional(),
|
|
4995
|
+
beforeCursor: z15.string().optional(),
|
|
4726
4996
|
limit: LogsLimitSchema.optional()
|
|
4727
4997
|
}).superRefine((query, context) => {
|
|
4728
4998
|
if (query.runId !== undefined && query.kind === undefined) {
|
|
4729
4999
|
context.addIssue({
|
|
4730
|
-
code:
|
|
5000
|
+
code: z15.ZodIssueCode.custom,
|
|
4731
5001
|
path: ["runId"],
|
|
4732
5002
|
message: "kind is required when runId is provided"
|
|
4733
5003
|
});
|
|
4734
5004
|
}
|
|
4735
5005
|
if (query.afterCursor && query.beforeCursor) {
|
|
4736
5006
|
context.addIssue({
|
|
4737
|
-
code:
|
|
5007
|
+
code: z15.ZodIssueCode.custom,
|
|
4738
5008
|
message: "afterCursor and beforeCursor are mutually exclusive"
|
|
4739
5009
|
});
|
|
4740
5010
|
}
|
|
4741
5011
|
if (query.direction === "backward" && query.afterCursor) {
|
|
4742
5012
|
context.addIssue({
|
|
4743
|
-
code:
|
|
5013
|
+
code: z15.ZodIssueCode.custom,
|
|
4744
5014
|
path: ["afterCursor"],
|
|
4745
5015
|
message: "afterCursor cannot be used with backward reads"
|
|
4746
5016
|
});
|
|
4747
5017
|
}
|
|
4748
5018
|
if (query.direction !== "backward" && query.beforeCursor) {
|
|
4749
5019
|
context.addIssue({
|
|
4750
|
-
code:
|
|
5020
|
+
code: z15.ZodIssueCode.custom,
|
|
4751
5021
|
path: ["beforeCursor"],
|
|
4752
5022
|
message: "beforeCursor requires direction=backward"
|
|
4753
5023
|
});
|
|
4754
5024
|
}
|
|
4755
5025
|
});
|
|
4756
|
-
var LogLineSchema =
|
|
5026
|
+
var LogLineSchema = z15.object({
|
|
4757
5027
|
level: LogLevelSchema,
|
|
4758
|
-
message:
|
|
4759
|
-
fields:
|
|
4760
|
-
at:
|
|
4761
|
-
context:
|
|
4762
|
-
run:
|
|
5028
|
+
message: z15.string(),
|
|
5029
|
+
fields: z15.record(z15.unknown()).optional(),
|
|
5030
|
+
at: z15.string(),
|
|
5031
|
+
context: z15.object({
|
|
5032
|
+
run: z15.object({
|
|
4763
5033
|
kind: SixbRunKindSchema,
|
|
4764
|
-
id:
|
|
5034
|
+
id: z15.string()
|
|
4765
5035
|
}),
|
|
4766
|
-
stepId:
|
|
4767
|
-
phase:
|
|
4768
|
-
attempt:
|
|
5036
|
+
stepId: z15.string().optional(),
|
|
5037
|
+
phase: z15.string().optional(),
|
|
5038
|
+
attempt: z15.number().optional()
|
|
4769
5039
|
}),
|
|
4770
|
-
cursor:
|
|
5040
|
+
cursor: z15.string()
|
|
4771
5041
|
});
|
|
4772
|
-
var LogsResponseSchema =
|
|
4773
|
-
count:
|
|
4774
|
-
lines:
|
|
4775
|
-
cursor:
|
|
4776
|
-
hasMore:
|
|
5042
|
+
var LogsResponseSchema = z15.object({
|
|
5043
|
+
count: z15.number(),
|
|
5044
|
+
lines: z15.array(LogLineSchema),
|
|
5045
|
+
cursor: z15.string().optional(),
|
|
5046
|
+
hasMore: z15.boolean()
|
|
4777
5047
|
});
|
|
4778
5048
|
|
|
4779
5049
|
// src/routes/logs.ts
|
|
@@ -4817,6 +5087,37 @@ function registerLogRoutes(app, _host) {
|
|
|
4817
5087
|
});
|
|
4818
5088
|
}
|
|
4819
5089
|
|
|
5090
|
+
// src/schemas/models.ts
|
|
5091
|
+
import { z as z16 } from "zod";
|
|
5092
|
+
var LanguageModelSchema = z16.object({
|
|
5093
|
+
provider: z16.string(),
|
|
5094
|
+
modelId: z16.string(),
|
|
5095
|
+
isDefault: z16.boolean()
|
|
5096
|
+
});
|
|
5097
|
+
var ModelCatalogSchema = z16.object({
|
|
5098
|
+
language: z16.array(LanguageModelSchema)
|
|
5099
|
+
});
|
|
5100
|
+
|
|
5101
|
+
// src/routes/models.ts
|
|
5102
|
+
function serializeLanguageModel(entry, defaultRef) {
|
|
5103
|
+
return { provider: entry.provider, modelId: entry.modelId, isDefault: entry.ref === defaultRef };
|
|
5104
|
+
}
|
|
5105
|
+
function registerModelRoutes(app, host) {
|
|
5106
|
+
return app.get("/api/models", () => {
|
|
5107
|
+
const language = host.definitions.models?.language;
|
|
5108
|
+
return ModelCatalogSchema.parse({
|
|
5109
|
+
language: language === undefined ? [] : language.list().map((entry) => serializeLanguageModel(entry, language.default.ref))
|
|
5110
|
+
});
|
|
5111
|
+
}, {
|
|
5112
|
+
response: { 200: ModelCatalogSchema },
|
|
5113
|
+
detail: {
|
|
5114
|
+
summary: "List the project model catalog",
|
|
5115
|
+
tags: [OPENAPI_TAGS.models.name],
|
|
5116
|
+
operationId: "listModels"
|
|
5117
|
+
}
|
|
5118
|
+
});
|
|
5119
|
+
}
|
|
5120
|
+
|
|
4820
5121
|
// src/routes/objects.ts
|
|
4821
5122
|
import {
|
|
4822
5123
|
AuthorizationError as AuthorizationError3,
|
|
@@ -4824,35 +5125,35 @@ import {
|
|
|
4824
5125
|
ObjectQueryPlanningError,
|
|
4825
5126
|
ObjectQueryValidationError
|
|
4826
5127
|
} from "@sixb/core";
|
|
4827
|
-
import { ZodError as ZodError3, z as
|
|
5128
|
+
import { ZodError as ZodError3, z as z18 } from "zod";
|
|
4828
5129
|
|
|
4829
5130
|
// 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:
|
|
5131
|
+
import { z as z17 } from "zod";
|
|
5132
|
+
var ObjectParamsSchema = z17.object({
|
|
5133
|
+
objectTypeId: z17.string().min(1),
|
|
5134
|
+
objectId: z17.string().min(1)
|
|
5135
|
+
});
|
|
5136
|
+
var ObjectSearchQuerySchema = z17.object({
|
|
5137
|
+
q: z17.string().trim().min(1).max(200),
|
|
5138
|
+
limit: z17.string().regex(/^\d+$/).optional()
|
|
5139
|
+
});
|
|
5140
|
+
var ObjectSearchResponseSchema = z17.object({
|
|
5141
|
+
items: z17.array(z17.object({
|
|
5142
|
+
ref: z17.object({
|
|
5143
|
+
objectTypeId: z17.string(),
|
|
5144
|
+
primaryId: z17.string()
|
|
4844
5145
|
}),
|
|
4845
|
-
label:
|
|
5146
|
+
label: z17.string()
|
|
4846
5147
|
}))
|
|
4847
5148
|
});
|
|
4848
5149
|
var OBJECT_LIST_MAX_LIMIT = 1000;
|
|
4849
|
-
var Rfc3339DateSchema =
|
|
5150
|
+
var Rfc3339DateSchema = z17.string().datetime({ offset: true });
|
|
4850
5151
|
function objectListDateSchema(parameter) {
|
|
4851
|
-
return
|
|
5152
|
+
return z17.string().refine((value) => Rfc3339DateSchema.safeParse(value).success, {
|
|
4852
5153
|
message: `Invalid query parameter '${parameter}': expected an RFC 3339 timestamp.`
|
|
4853
5154
|
}).transform((value) => new Date(value));
|
|
4854
5155
|
}
|
|
4855
|
-
var ObjectListLimitSchema =
|
|
5156
|
+
var ObjectListLimitSchema = z17.string().refine((value) => {
|
|
4856
5157
|
if (!/^\d+$/.test(value))
|
|
4857
5158
|
return false;
|
|
4858
5159
|
const parsed = Number(value);
|
|
@@ -4860,25 +5161,25 @@ var ObjectListLimitSchema = z15.string().refine((value) => {
|
|
|
4860
5161
|
}, {
|
|
4861
5162
|
message: `Invalid query parameter 'limit': expected an integer between 0 and ${OBJECT_LIST_MAX_LIMIT}.`
|
|
4862
5163
|
}).transform(Number);
|
|
4863
|
-
var ObjectListOffsetSchema =
|
|
5164
|
+
var ObjectListOffsetSchema = z17.string().refine((value) => /^\d+$/.test(value) && Number.isSafeInteger(Number(value)), {
|
|
4864
5165
|
message: "Invalid query parameter 'offset': expected a non-negative safe integer."
|
|
4865
5166
|
}).transform(Number);
|
|
4866
|
-
var ObjectsQuerySchema =
|
|
4867
|
-
objectTypeId:
|
|
4868
|
-
idPrefix:
|
|
4869
|
-
idSuffix:
|
|
5167
|
+
var ObjectsQuerySchema = z17.object({
|
|
5168
|
+
objectTypeId: z17.string().optional(),
|
|
5169
|
+
idPrefix: z17.string().optional(),
|
|
5170
|
+
idSuffix: z17.string().optional(),
|
|
4870
5171
|
updatedAfter: objectListDateSchema("updatedAfter").optional(),
|
|
4871
5172
|
updatedBefore: objectListDateSchema("updatedBefore").optional(),
|
|
4872
5173
|
createdAfter: objectListDateSchema("createdAfter").optional(),
|
|
4873
5174
|
createdBefore: objectListDateSchema("createdBefore").optional(),
|
|
4874
5175
|
limit: ObjectListLimitSchema.optional(),
|
|
4875
5176
|
offset: ObjectListOffsetSchema.optional(),
|
|
4876
|
-
orderBy:
|
|
5177
|
+
orderBy: z17.enum(["createdAt", "updatedAt", "primaryId"], {
|
|
4877
5178
|
errorMap: () => ({
|
|
4878
5179
|
message: "Invalid query parameter 'orderBy': expected one of createdAt, updatedAt, or primaryId."
|
|
4879
5180
|
})
|
|
4880
5181
|
}).optional(),
|
|
4881
|
-
order:
|
|
5182
|
+
order: z17.enum(["asc", "desc"], {
|
|
4882
5183
|
errorMap: () => ({
|
|
4883
5184
|
message: "Invalid query parameter 'order': expected 'asc' or 'desc'."
|
|
4884
5185
|
})
|
|
@@ -4886,163 +5187,178 @@ var ObjectsQuerySchema = z15.object({
|
|
|
4886
5187
|
}).superRefine((query, context) => {
|
|
4887
5188
|
if (query.updatedAfter && query.updatedBefore && query.updatedAfter > query.updatedBefore) {
|
|
4888
5189
|
context.addIssue({
|
|
4889
|
-
code:
|
|
5190
|
+
code: z17.ZodIssueCode.custom,
|
|
4890
5191
|
path: ["updatedAfter"],
|
|
4891
5192
|
message: "Invalid query parameter range: 'updatedAfter' must be before or equal to 'updatedBefore'."
|
|
4892
5193
|
});
|
|
4893
5194
|
}
|
|
4894
5195
|
if (query.createdAfter && query.createdBefore && query.createdAfter > query.createdBefore) {
|
|
4895
5196
|
context.addIssue({
|
|
4896
|
-
code:
|
|
5197
|
+
code: z17.ZodIssueCode.custom,
|
|
4897
5198
|
path: ["createdAfter"],
|
|
4898
5199
|
message: "Invalid query parameter range: 'createdAfter' must be before or equal to 'createdBefore'."
|
|
4899
5200
|
});
|
|
4900
5201
|
}
|
|
4901
5202
|
});
|
|
4902
|
-
var UpsertObjectBodySchema =
|
|
4903
|
-
properties:
|
|
5203
|
+
var UpsertObjectBodySchema = z17.object({
|
|
5204
|
+
properties: z17.record(z17.unknown())
|
|
4904
5205
|
});
|
|
4905
|
-
var ObjectQueryPredicateSchema =
|
|
4906
|
-
|
|
4907
|
-
op:
|
|
4908
|
-
items:
|
|
5206
|
+
var ObjectQueryPredicateSchema = z17.lazy(() => z17.union([
|
|
5207
|
+
z17.object({
|
|
5208
|
+
op: z17.enum(["and", "or"]),
|
|
5209
|
+
items: z17.array(ObjectQueryPredicateSchema)
|
|
4909
5210
|
}).strict(),
|
|
4910
|
-
|
|
4911
|
-
op:
|
|
5211
|
+
z17.object({
|
|
5212
|
+
op: z17.literal("not"),
|
|
4912
5213
|
item: ObjectQueryPredicateSchema
|
|
4913
5214
|
}).strict(),
|
|
4914
|
-
|
|
4915
|
-
op:
|
|
4916
|
-
propertyId:
|
|
5215
|
+
z17.object({
|
|
5216
|
+
op: z17.enum(["eq", "neq", "lt", "lte", "gt", "gte"]),
|
|
5217
|
+
propertyId: z17.string().min(1),
|
|
4917
5218
|
value: JsonValueSchema
|
|
4918
5219
|
}).strict(),
|
|
4919
|
-
|
|
4920
|
-
op:
|
|
4921
|
-
propertyId:
|
|
4922
|
-
values:
|
|
5220
|
+
z17.object({
|
|
5221
|
+
op: z17.literal("in"),
|
|
5222
|
+
propertyId: z17.string().min(1),
|
|
5223
|
+
values: z17.array(JsonValueSchema)
|
|
4923
5224
|
}).strict(),
|
|
4924
|
-
|
|
4925
|
-
op:
|
|
4926
|
-
propertyId:
|
|
4927
|
-
value:
|
|
5225
|
+
z17.object({
|
|
5226
|
+
op: z17.literal("exists"),
|
|
5227
|
+
propertyId: z17.string().min(1),
|
|
5228
|
+
value: z17.boolean()
|
|
4928
5229
|
}).strict(),
|
|
4929
|
-
|
|
4930
|
-
op:
|
|
4931
|
-
propertyId:
|
|
5230
|
+
z17.object({
|
|
5231
|
+
op: z17.literal("contains"),
|
|
5232
|
+
propertyId: z17.string().min(1),
|
|
4932
5233
|
value: JsonValueSchema
|
|
4933
5234
|
}).strict()
|
|
4934
5235
|
]));
|
|
4935
|
-
var ObjectQuerySortFieldSchema =
|
|
4936
|
-
|
|
4937
|
-
kind:
|
|
4938
|
-
propertyId:
|
|
4939
|
-
direction:
|
|
5236
|
+
var ObjectQuerySortFieldSchema = z17.union([
|
|
5237
|
+
z17.object({
|
|
5238
|
+
kind: z17.literal("property"),
|
|
5239
|
+
propertyId: z17.string().min(1),
|
|
5240
|
+
direction: z17.enum(["asc", "desc"]).optional()
|
|
4940
5241
|
}).strict(),
|
|
4941
|
-
|
|
4942
|
-
kind:
|
|
4943
|
-
direction:
|
|
5242
|
+
z17.object({
|
|
5243
|
+
kind: z17.literal("relevance"),
|
|
5244
|
+
direction: z17.enum(["asc", "desc"]).optional()
|
|
4944
5245
|
}).strict()
|
|
4945
5246
|
]);
|
|
4946
|
-
var ObjectExpansionSchema =
|
|
4947
|
-
linkId:
|
|
4948
|
-
direction:
|
|
4949
|
-
sourceObjectTypeId:
|
|
4950
|
-
limit:
|
|
4951
|
-
orderBy:
|
|
4952
|
-
expand:
|
|
5247
|
+
var ObjectExpansionSchema = z17.lazy(() => z17.object({
|
|
5248
|
+
linkId: z17.string().min(1),
|
|
5249
|
+
direction: z17.enum(["outgoing", "incoming"]),
|
|
5250
|
+
sourceObjectTypeId: z17.string().min(1).optional(),
|
|
5251
|
+
limit: z17.number().int().nonnegative().optional(),
|
|
5252
|
+
orderBy: z17.array(ObjectQuerySortFieldSchema).optional(),
|
|
5253
|
+
expand: z17.array(ObjectExpansionSchema).optional()
|
|
4953
5254
|
}).strict());
|
|
4954
|
-
var ObjectQuerySchema =
|
|
4955
|
-
|
|
4956
|
-
kind:
|
|
4957
|
-
objectTypeId:
|
|
4958
|
-
includeSubtypes:
|
|
5255
|
+
var ObjectQuerySchema = z17.lazy(() => z17.discriminatedUnion("kind", [
|
|
5256
|
+
z17.object({
|
|
5257
|
+
kind: z17.literal("start"),
|
|
5258
|
+
objectTypeId: z17.string().min(1),
|
|
5259
|
+
includeSubtypes: z17.boolean().optional()
|
|
4959
5260
|
}).strict(),
|
|
4960
|
-
|
|
4961
|
-
kind:
|
|
5261
|
+
z17.object({
|
|
5262
|
+
kind: z17.literal("refs"),
|
|
5263
|
+
refs: z17.array(z17.object({
|
|
5264
|
+
objectTypeId: z17.string().min(1),
|
|
5265
|
+
primaryId: z17.string().min(1)
|
|
5266
|
+
}).strict())
|
|
5267
|
+
}).strict(),
|
|
5268
|
+
z17.object({
|
|
5269
|
+
kind: z17.literal("filter"),
|
|
4962
5270
|
input: ObjectQuerySchema,
|
|
4963
5271
|
predicate: ObjectQueryPredicateSchema
|
|
4964
5272
|
}).strict(),
|
|
4965
|
-
|
|
4966
|
-
kind:
|
|
5273
|
+
z17.object({
|
|
5274
|
+
kind: z17.literal("text"),
|
|
4967
5275
|
input: ObjectQuerySchema,
|
|
4968
|
-
query:
|
|
4969
|
-
fields:
|
|
5276
|
+
query: z17.string(),
|
|
5277
|
+
fields: z17.array(z17.string().min(1)).optional()
|
|
4970
5278
|
}).strict(),
|
|
4971
|
-
|
|
4972
|
-
kind:
|
|
5279
|
+
z17.object({
|
|
5280
|
+
kind: z17.literal("vector"),
|
|
4973
5281
|
input: ObjectQuerySchema,
|
|
4974
|
-
vector:
|
|
4975
|
-
propertyId:
|
|
4976
|
-
k:
|
|
5282
|
+
vector: z17.array(z17.number().finite()),
|
|
5283
|
+
propertyId: z17.string().min(1),
|
|
5284
|
+
k: z17.number().int().positive()
|
|
4977
5285
|
}).strict(),
|
|
4978
|
-
|
|
4979
|
-
kind:
|
|
5286
|
+
z17.object({
|
|
5287
|
+
kind: z17.literal("traverse"),
|
|
4980
5288
|
input: ObjectQuerySchema,
|
|
4981
|
-
linkId:
|
|
4982
|
-
direction:
|
|
4983
|
-
sourceObjectTypeId:
|
|
5289
|
+
linkId: z17.string().min(1),
|
|
5290
|
+
direction: z17.enum(["outgoing", "incoming"]),
|
|
5291
|
+
sourceObjectTypeId: z17.string().min(1).optional()
|
|
4984
5292
|
}).strict(),
|
|
4985
|
-
|
|
4986
|
-
kind:
|
|
4987
|
-
op:
|
|
4988
|
-
inputs:
|
|
5293
|
+
z17.object({
|
|
5294
|
+
kind: z17.literal("set"),
|
|
5295
|
+
op: z17.enum(["union", "intersect", "subtract"]),
|
|
5296
|
+
inputs: z17.array(ObjectQuerySchema)
|
|
4989
5297
|
}).strict(),
|
|
4990
|
-
|
|
4991
|
-
kind:
|
|
5298
|
+
z17.object({
|
|
5299
|
+
kind: z17.literal("sort"),
|
|
4992
5300
|
input: ObjectQuerySchema,
|
|
4993
|
-
fields:
|
|
5301
|
+
fields: z17.array(ObjectQuerySortFieldSchema)
|
|
4994
5302
|
}).strict(),
|
|
4995
|
-
|
|
4996
|
-
kind:
|
|
5303
|
+
z17.object({
|
|
5304
|
+
kind: z17.literal("limit"),
|
|
4997
5305
|
input: ObjectQuerySchema,
|
|
4998
|
-
limit:
|
|
5306
|
+
limit: z17.number().int().nonnegative()
|
|
4999
5307
|
}).strict(),
|
|
5000
|
-
|
|
5001
|
-
kind:
|
|
5308
|
+
z17.object({
|
|
5309
|
+
kind: z17.literal("page"),
|
|
5002
5310
|
input: ObjectQuerySchema,
|
|
5003
|
-
pageSize:
|
|
5004
|
-
pageToken:
|
|
5311
|
+
pageSize: z17.number().int().positive(),
|
|
5312
|
+
pageToken: z17.string().optional()
|
|
5005
5313
|
}).strict(),
|
|
5006
|
-
|
|
5007
|
-
kind:
|
|
5314
|
+
z17.object({
|
|
5315
|
+
kind: z17.literal("project"),
|
|
5008
5316
|
input: ObjectQuerySchema,
|
|
5009
|
-
properties:
|
|
5317
|
+
properties: z17.array(z17.string().min(1)).optional()
|
|
5010
5318
|
}).strict(),
|
|
5011
|
-
|
|
5012
|
-
kind:
|
|
5319
|
+
z17.object({
|
|
5320
|
+
kind: z17.literal("expand"),
|
|
5013
5321
|
input: ObjectQuerySchema,
|
|
5014
|
-
expansions:
|
|
5322
|
+
expansions: z17.array(ObjectExpansionSchema)
|
|
5015
5323
|
}).strict()
|
|
5016
5324
|
]));
|
|
5017
|
-
var ObjectQueryRequestSchema =
|
|
5325
|
+
var ObjectQueryRequestSchema = z17.object({
|
|
5018
5326
|
query: ObjectQuerySchema,
|
|
5019
|
-
includeTotal:
|
|
5327
|
+
includeTotal: z17.boolean().optional()
|
|
5020
5328
|
}).strict();
|
|
5021
|
-
var ObjectQueryCountRequestSchema =
|
|
5329
|
+
var ObjectQueryCountRequestSchema = z17.object({
|
|
5022
5330
|
query: ObjectQuerySchema
|
|
5023
5331
|
}).strict();
|
|
5024
|
-
var ObjectQueryExistsRequestSchema =
|
|
5332
|
+
var ObjectQueryExistsRequestSchema = z17.object({
|
|
5025
5333
|
query: ObjectQuerySchema
|
|
5026
5334
|
}).strict();
|
|
5027
|
-
var ObjectQueryFacetRequestSchema =
|
|
5028
|
-
propertyId:
|
|
5029
|
-
limit:
|
|
5335
|
+
var ObjectQueryFacetRequestSchema = z17.object({
|
|
5336
|
+
propertyId: z17.string().min(1),
|
|
5337
|
+
limit: z17.number().int().positive()
|
|
5030
5338
|
}).strict();
|
|
5031
|
-
var ObjectQueryFacetsRequestSchema =
|
|
5339
|
+
var ObjectQueryFacetsRequestSchema = z17.object({
|
|
5032
5340
|
query: ObjectQuerySchema,
|
|
5033
|
-
facets:
|
|
5341
|
+
facets: z17.array(ObjectQueryFacetRequestSchema).min(1)
|
|
5034
5342
|
}).strict();
|
|
5035
|
-
var
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5343
|
+
var ObjectQueryLinksRequestSchema = z17.object({
|
|
5344
|
+
query: ObjectQuerySchema,
|
|
5345
|
+
direction: z17.enum(["outgoing", "incoming", "both"]).default("both"),
|
|
5346
|
+
linkId: z17.string().min(1).optional(),
|
|
5347
|
+
includeObjects: z17.boolean().default(false),
|
|
5348
|
+
pageSize: z17.number().int().positive().max(1000).default(100),
|
|
5349
|
+
pageToken: z17.string().min(1).optional()
|
|
5350
|
+
}).strict();
|
|
5351
|
+
var TwinObjectSchema = z17.object({
|
|
5352
|
+
primaryId: z17.string(),
|
|
5353
|
+
objectTypeId: z17.string(),
|
|
5354
|
+
properties: z17.record(z17.unknown()),
|
|
5355
|
+
createdAt: z17.string(),
|
|
5356
|
+
updatedAt: z17.string()
|
|
5357
|
+
});
|
|
5358
|
+
var ObjectListResponseSchema = z17.object({
|
|
5359
|
+
objects: z17.array(TwinObjectSchema),
|
|
5360
|
+
hasMore: z17.boolean(),
|
|
5361
|
+
total: z17.number()
|
|
5046
5362
|
});
|
|
5047
5363
|
var anyJsonValueSchema = {};
|
|
5048
5364
|
var stringArraySchema = { type: "array", items: { type: "string", minLength: 1 } };
|
|
@@ -5050,6 +5366,7 @@ var objectQueryRef = { $ref: "#/components/schemas/ObjectQuery" };
|
|
|
5050
5366
|
var objectQueryPredicateRef = { $ref: "#/components/schemas/ObjectQueryPredicate" };
|
|
5051
5367
|
var objectQuerySortFieldRef = { $ref: "#/components/schemas/ObjectQuerySortField" };
|
|
5052
5368
|
var objectExpansionRef = { $ref: "#/components/schemas/ObjectExpansion" };
|
|
5369
|
+
var objectRefSchemaRef = { $ref: "#/components/schemas/ObjectRef" };
|
|
5053
5370
|
var ObjectQueryOpenApiSchemas = {
|
|
5054
5371
|
ErrorResponse: {
|
|
5055
5372
|
type: "object",
|
|
@@ -5188,6 +5505,38 @@ var ObjectQueryOpenApiSchemas = {
|
|
|
5188
5505
|
plan: { $ref: "#/components/schemas/ObjectQueryPlanSummary" }
|
|
5189
5506
|
}
|
|
5190
5507
|
},
|
|
5508
|
+
ObjectQueryLink: {
|
|
5509
|
+
type: "object",
|
|
5510
|
+
required: ["source", "linkId", "target", "createdAt", "updatedAt"],
|
|
5511
|
+
additionalProperties: false,
|
|
5512
|
+
properties: {
|
|
5513
|
+
source: objectRefSchemaRef,
|
|
5514
|
+
linkId: { type: "string" },
|
|
5515
|
+
target: objectRefSchemaRef,
|
|
5516
|
+
properties: { type: "object", additionalProperties: true },
|
|
5517
|
+
createdAt: { type: "string" },
|
|
5518
|
+
updatedAt: { type: "string" }
|
|
5519
|
+
}
|
|
5520
|
+
},
|
|
5521
|
+
ObjectQueryLinksResponse: {
|
|
5522
|
+
type: "object",
|
|
5523
|
+
required: ["objects", "links", "hasMore"],
|
|
5524
|
+
additionalProperties: false,
|
|
5525
|
+
properties: {
|
|
5526
|
+
objects: {
|
|
5527
|
+
type: "array",
|
|
5528
|
+
description: "Selected objects followed by visible endpoint objects from this link page, de-duplicated. Empty unless includeObjects is true.",
|
|
5529
|
+
items: { $ref: "#/components/schemas/ObjectQueryObject" }
|
|
5530
|
+
},
|
|
5531
|
+
links: {
|
|
5532
|
+
type: "array",
|
|
5533
|
+
description: "Visible physical links in deterministic identity order.",
|
|
5534
|
+
items: { $ref: "#/components/schemas/ObjectQueryLink" }
|
|
5535
|
+
},
|
|
5536
|
+
hasMore: { type: "boolean" },
|
|
5537
|
+
nextPageToken: { type: "string" }
|
|
5538
|
+
}
|
|
5539
|
+
},
|
|
5191
5540
|
ObjectQueryErrorResponse: {
|
|
5192
5541
|
type: "object",
|
|
5193
5542
|
required: ["error"],
|
|
@@ -5247,6 +5596,36 @@ var ObjectQueryOpenApiSchemas = {
|
|
|
5247
5596
|
}
|
|
5248
5597
|
}
|
|
5249
5598
|
},
|
|
5599
|
+
ObjectQueryLinksRequest: {
|
|
5600
|
+
type: "object",
|
|
5601
|
+
required: ["query"],
|
|
5602
|
+
additionalProperties: false,
|
|
5603
|
+
properties: {
|
|
5604
|
+
query: objectQueryRef,
|
|
5605
|
+
direction: { type: "string", enum: ["outgoing", "incoming", "both"], default: "both" },
|
|
5606
|
+
linkId: { type: "string", minLength: 1 },
|
|
5607
|
+
includeObjects: {
|
|
5608
|
+
type: "boolean",
|
|
5609
|
+
default: false,
|
|
5610
|
+
description: "Include selected objects and visible endpoints from the current link page."
|
|
5611
|
+
},
|
|
5612
|
+
pageSize: { type: "integer", minimum: 1, maximum: 1000, default: 100 },
|
|
5613
|
+
pageToken: {
|
|
5614
|
+
type: "string",
|
|
5615
|
+
minLength: 1,
|
|
5616
|
+
description: "Opaque token from the previous page. The project, normalized query, direction, and linkId must remain unchanged."
|
|
5617
|
+
}
|
|
5618
|
+
}
|
|
5619
|
+
},
|
|
5620
|
+
ObjectRef: {
|
|
5621
|
+
type: "object",
|
|
5622
|
+
required: ["objectTypeId", "primaryId"],
|
|
5623
|
+
additionalProperties: false,
|
|
5624
|
+
properties: {
|
|
5625
|
+
objectTypeId: { type: "string", minLength: 1 },
|
|
5626
|
+
primaryId: { type: "string", minLength: 1 }
|
|
5627
|
+
}
|
|
5628
|
+
},
|
|
5250
5629
|
ObjectQuery: {
|
|
5251
5630
|
oneOf: [
|
|
5252
5631
|
{
|
|
@@ -5259,6 +5638,20 @@ var ObjectQueryOpenApiSchemas = {
|
|
|
5259
5638
|
includeSubtypes: { type: "boolean" }
|
|
5260
5639
|
}
|
|
5261
5640
|
},
|
|
5641
|
+
{
|
|
5642
|
+
type: "object",
|
|
5643
|
+
required: ["kind", "refs"],
|
|
5644
|
+
additionalProperties: false,
|
|
5645
|
+
properties: {
|
|
5646
|
+
kind: { type: "string", enum: ["refs"] },
|
|
5647
|
+
refs: {
|
|
5648
|
+
type: "array",
|
|
5649
|
+
minItems: 1,
|
|
5650
|
+
description: "One to 1,000 unique identities after normalization; duplicate entries are accepted and removed.",
|
|
5651
|
+
items: objectRefSchemaRef
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
},
|
|
5262
5655
|
{
|
|
5263
5656
|
type: "object",
|
|
5264
5657
|
required: ["kind", "input", "predicate"],
|
|
@@ -5472,7 +5865,7 @@ var ObjectQueryOpenApiSchemas = {
|
|
|
5472
5865
|
|
|
5473
5866
|
// src/routes/objects.ts
|
|
5474
5867
|
var ObjectFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
5475
|
-
path:
|
|
5868
|
+
path: z18.string().min(1).regex(/^\/properties(?:\/|$)/, "Object file content paths must start with /properties/")
|
|
5476
5869
|
});
|
|
5477
5870
|
function serializeObject(row) {
|
|
5478
5871
|
return {
|
|
@@ -5483,6 +5876,22 @@ function serializeObject(row) {
|
|
|
5483
5876
|
updatedAt: toIsoString(row.updatedAt)
|
|
5484
5877
|
};
|
|
5485
5878
|
}
|
|
5879
|
+
function serializeObjectLink(link) {
|
|
5880
|
+
return {
|
|
5881
|
+
source: {
|
|
5882
|
+
objectTypeId: link.sourceTypeId,
|
|
5883
|
+
primaryId: link.sourceId
|
|
5884
|
+
},
|
|
5885
|
+
linkId: link.linkId,
|
|
5886
|
+
target: {
|
|
5887
|
+
objectTypeId: link.targetTypeId,
|
|
5888
|
+
primaryId: link.targetId
|
|
5889
|
+
},
|
|
5890
|
+
...link.properties === undefined ? {} : { properties: link.properties },
|
|
5891
|
+
createdAt: toIsoString(link.createdAt),
|
|
5892
|
+
updatedAt: toIsoString(link.updatedAt)
|
|
5893
|
+
};
|
|
5894
|
+
}
|
|
5486
5895
|
function serializeExpandedObject(row) {
|
|
5487
5896
|
const serialized = serializeObject(row);
|
|
5488
5897
|
if (row.links)
|
|
@@ -5702,35 +6111,98 @@ function registerObjectRoutes(app, host) {
|
|
|
5702
6111
|
operationId: "listObjects",
|
|
5703
6112
|
security: bearerSecurityRequirement("listObjects")
|
|
5704
6113
|
}
|
|
5705
|
-
}).post("/api/objects/query", async (context) => {
|
|
6114
|
+
}).post("/api/objects/query", async (context) => {
|
|
6115
|
+
const { body, set } = context;
|
|
6116
|
+
try {
|
|
6117
|
+
const parsed = ObjectQueryRequestSchema.parse(body);
|
|
6118
|
+
const result = await requireRequestSixb(context).objects.executeQuery({
|
|
6119
|
+
query: parsed.query,
|
|
6120
|
+
includeTotal: parsed.includeTotal
|
|
6121
|
+
});
|
|
6122
|
+
return {
|
|
6123
|
+
objects: result.objects.map(serializeExpandedObject),
|
|
6124
|
+
hasMore: result.hasMore,
|
|
6125
|
+
nextPageToken: result.nextPageToken,
|
|
6126
|
+
plan: serializePlan(result.plan),
|
|
6127
|
+
...result.total === undefined ? {} : { total: result.total }
|
|
6128
|
+
};
|
|
6129
|
+
} catch (error) {
|
|
6130
|
+
return handleObjectQueryError(error, set);
|
|
6131
|
+
}
|
|
6132
|
+
}, {
|
|
6133
|
+
detail: {
|
|
6134
|
+
summary: "Query objects",
|
|
6135
|
+
tags: [OPENAPI_TAGS.objects.name],
|
|
6136
|
+
operationId: "queryObjects",
|
|
6137
|
+
security: bearerSecurityRequirement("queryObjects"),
|
|
6138
|
+
requestBody: {
|
|
6139
|
+
required: true,
|
|
6140
|
+
content: {
|
|
6141
|
+
"application/json": {
|
|
6142
|
+
schema: { $ref: "#/components/schemas/ObjectQueryRequest" }
|
|
6143
|
+
}
|
|
6144
|
+
}
|
|
6145
|
+
},
|
|
6146
|
+
responses: {
|
|
6147
|
+
200: {
|
|
6148
|
+
description: "Response for status 200",
|
|
6149
|
+
content: {
|
|
6150
|
+
"application/json": {
|
|
6151
|
+
schema: { $ref: "#/components/schemas/ObjectQueryResponse" }
|
|
6152
|
+
}
|
|
6153
|
+
}
|
|
6154
|
+
},
|
|
6155
|
+
400: {
|
|
6156
|
+
description: "Response for status 400",
|
|
6157
|
+
content: {
|
|
6158
|
+
"application/json": {
|
|
6159
|
+
schema: { $ref: "#/components/schemas/ObjectQueryErrorResponse" }
|
|
6160
|
+
}
|
|
6161
|
+
}
|
|
6162
|
+
},
|
|
6163
|
+
403: {
|
|
6164
|
+
description: "Response for status 403",
|
|
6165
|
+
content: {
|
|
6166
|
+
"application/json": {
|
|
6167
|
+
schema: { $ref: "#/components/schemas/ErrorResponse" }
|
|
6168
|
+
}
|
|
6169
|
+
}
|
|
6170
|
+
},
|
|
6171
|
+
500: {
|
|
6172
|
+
description: "Response for status 500",
|
|
6173
|
+
content: {
|
|
6174
|
+
"application/json": {
|
|
6175
|
+
schema: { $ref: "#/components/schemas/ErrorResponse" }
|
|
6176
|
+
}
|
|
6177
|
+
}
|
|
6178
|
+
}
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
}).post("/api/objects/query/links", async (context) => {
|
|
5706
6182
|
const { body, set } = context;
|
|
5707
6183
|
try {
|
|
5708
|
-
const parsed =
|
|
5709
|
-
const result = await requireRequestSixb(context).objects.
|
|
5710
|
-
query: parsed.query,
|
|
5711
|
-
includeTotal: parsed.includeTotal
|
|
5712
|
-
});
|
|
6184
|
+
const parsed = ObjectQueryLinksRequestSchema.parse(body);
|
|
6185
|
+
const result = await requireRequestSixb(context).objects.queryLinks(parsed);
|
|
5713
6186
|
return {
|
|
5714
|
-
objects: result.objects.map(
|
|
6187
|
+
objects: result.objects.map(serializeObject),
|
|
6188
|
+
links: result.links.map(serializeObjectLink),
|
|
5715
6189
|
hasMore: result.hasMore,
|
|
5716
|
-
nextPageToken: result.nextPageToken
|
|
5717
|
-
plan: serializePlan(result.plan),
|
|
5718
|
-
...result.total === undefined ? {} : { total: result.total }
|
|
6190
|
+
...result.nextPageToken === undefined ? {} : { nextPageToken: result.nextPageToken }
|
|
5719
6191
|
};
|
|
5720
6192
|
} catch (error) {
|
|
5721
6193
|
return handleObjectQueryError(error, set);
|
|
5722
6194
|
}
|
|
5723
6195
|
}, {
|
|
5724
6196
|
detail: {
|
|
5725
|
-
summary: "Query
|
|
5726
|
-
tags: [OPENAPI_TAGS.
|
|
5727
|
-
operationId: "
|
|
5728
|
-
security: bearerSecurityRequirement("
|
|
6197
|
+
summary: "Query object links",
|
|
6198
|
+
tags: [OPENAPI_TAGS.links.name],
|
|
6199
|
+
operationId: "queryObjectLinks",
|
|
6200
|
+
security: bearerSecurityRequirement("queryObjectLinks"),
|
|
5729
6201
|
requestBody: {
|
|
5730
6202
|
required: true,
|
|
5731
6203
|
content: {
|
|
5732
6204
|
"application/json": {
|
|
5733
|
-
schema: { $ref: "#/components/schemas/
|
|
6205
|
+
schema: { $ref: "#/components/schemas/ObjectQueryLinksRequest" }
|
|
5734
6206
|
}
|
|
5735
6207
|
}
|
|
5736
6208
|
},
|
|
@@ -5739,7 +6211,7 @@ function registerObjectRoutes(app, host) {
|
|
|
5739
6211
|
description: "Response for status 200",
|
|
5740
6212
|
content: {
|
|
5741
6213
|
"application/json": {
|
|
5742
|
-
schema: { $ref: "#/components/schemas/
|
|
6214
|
+
schema: { $ref: "#/components/schemas/ObjectQueryLinksResponse" }
|
|
5743
6215
|
}
|
|
5744
6216
|
}
|
|
5745
6217
|
},
|
|
@@ -6129,111 +6601,111 @@ function registerOntologyRoutes(app, _host) {
|
|
|
6129
6601
|
import {
|
|
6130
6602
|
PIPELINE_RUN_FAILURE_CODES
|
|
6131
6603
|
} from "@sixb/core/storage";
|
|
6132
|
-
import { z as
|
|
6604
|
+
import { z as z19 } from "zod";
|
|
6133
6605
|
var PipelineRunFailureSchema = sixbFailureSchema(PIPELINE_RUN_FAILURE_CODES);
|
|
6134
|
-
var PipelineParamsSchema =
|
|
6135
|
-
pipelineId:
|
|
6606
|
+
var PipelineParamsSchema = z19.object({
|
|
6607
|
+
pipelineId: z19.string().min(1)
|
|
6136
6608
|
});
|
|
6137
|
-
var PipelineRunParamsSchema =
|
|
6138
|
-
runId:
|
|
6609
|
+
var PipelineRunParamsSchema = z19.object({
|
|
6610
|
+
runId: z19.string().min(1)
|
|
6139
6611
|
});
|
|
6140
|
-
var PipelineRunStatusSchema =
|
|
6612
|
+
var PipelineRunStatusSchema = z19.enum([
|
|
6141
6613
|
"queued",
|
|
6142
6614
|
"running",
|
|
6143
6615
|
"succeeded",
|
|
6144
6616
|
"failed",
|
|
6145
6617
|
"cancelled"
|
|
6146
6618
|
]);
|
|
6147
|
-
var PipelineStepRunStatusSchema =
|
|
6148
|
-
var PipelineRunsQuerySchema =
|
|
6149
|
-
pipelineId:
|
|
6619
|
+
var PipelineStepRunStatusSchema = z19.enum(["running", "succeeded", "failed", "cancelled"]);
|
|
6620
|
+
var PipelineRunsQuerySchema = z19.object({
|
|
6621
|
+
pipelineId: z19.string().optional(),
|
|
6150
6622
|
status: PipelineRunStatusSchema.optional(),
|
|
6151
|
-
startedAfter:
|
|
6152
|
-
startedBefore:
|
|
6153
|
-
limit:
|
|
6154
|
-
offset:
|
|
6155
|
-
order:
|
|
6623
|
+
startedAfter: z19.string().optional(),
|
|
6624
|
+
startedBefore: z19.string().optional(),
|
|
6625
|
+
limit: z19.string().optional(),
|
|
6626
|
+
offset: z19.string().optional(),
|
|
6627
|
+
order: z19.enum(["asc", "desc"]).optional()
|
|
6156
6628
|
});
|
|
6157
|
-
var DatasetVersionRefSchema2 =
|
|
6158
|
-
datasetId:
|
|
6159
|
-
versionId:
|
|
6629
|
+
var DatasetVersionRefSchema2 = z19.object({
|
|
6630
|
+
datasetId: z19.string(),
|
|
6631
|
+
versionId: z19.string()
|
|
6160
6632
|
});
|
|
6161
|
-
var PipelineTriggerSchema =
|
|
6162
|
-
type:
|
|
6163
|
-
scheduleId:
|
|
6633
|
+
var PipelineTriggerSchema = z19.object({
|
|
6634
|
+
type: z19.literal("schedule"),
|
|
6635
|
+
scheduleId: z19.string()
|
|
6164
6636
|
});
|
|
6165
|
-
var PipelineStepExecutorSchema =
|
|
6166
|
-
|
|
6167
|
-
kind:
|
|
6168
|
-
dialect:
|
|
6637
|
+
var PipelineStepExecutorSchema = z19.union([
|
|
6638
|
+
z19.object({
|
|
6639
|
+
kind: z19.literal("sql"),
|
|
6640
|
+
dialect: z19.literal("duckdb")
|
|
6169
6641
|
}),
|
|
6170
|
-
|
|
6171
|
-
kind:
|
|
6642
|
+
z19.object({
|
|
6643
|
+
kind: z19.literal("run")
|
|
6172
6644
|
})
|
|
6173
6645
|
]);
|
|
6174
|
-
var PipelineRunSchema =
|
|
6175
|
-
id:
|
|
6176
|
-
projectId:
|
|
6177
|
-
pipelineId:
|
|
6646
|
+
var PipelineRunSchema = z19.object({
|
|
6647
|
+
id: z19.string(),
|
|
6648
|
+
projectId: z19.string(),
|
|
6649
|
+
pipelineId: z19.string(),
|
|
6178
6650
|
status: PipelineRunStatusSchema,
|
|
6179
|
-
queuedAt:
|
|
6180
|
-
startedAt:
|
|
6181
|
-
finishedAt:
|
|
6651
|
+
queuedAt: z19.string(),
|
|
6652
|
+
startedAt: z19.string().optional(),
|
|
6653
|
+
finishedAt: z19.string().optional(),
|
|
6182
6654
|
output: DatasetVersionRefSchema2.optional(),
|
|
6183
6655
|
error: PipelineRunFailureSchema.optional()
|
|
6184
6656
|
});
|
|
6185
|
-
var PipelineStepRunSchema =
|
|
6186
|
-
id:
|
|
6187
|
-
projectId:
|
|
6188
|
-
pipelineRunId:
|
|
6189
|
-
pipelineId:
|
|
6190
|
-
stepId:
|
|
6191
|
-
datasetId:
|
|
6192
|
-
mode:
|
|
6657
|
+
var PipelineStepRunSchema = z19.object({
|
|
6658
|
+
id: z19.string(),
|
|
6659
|
+
projectId: z19.string(),
|
|
6660
|
+
pipelineRunId: z19.string(),
|
|
6661
|
+
pipelineId: z19.string(),
|
|
6662
|
+
stepId: z19.string(),
|
|
6663
|
+
datasetId: z19.string(),
|
|
6664
|
+
mode: z19.enum(["snapshot", "append"]),
|
|
6193
6665
|
status: PipelineStepRunStatusSchema,
|
|
6194
|
-
startedAt:
|
|
6195
|
-
finishedAt:
|
|
6196
|
-
inputs:
|
|
6666
|
+
startedAt: z19.string(),
|
|
6667
|
+
finishedAt: z19.string().optional(),
|
|
6668
|
+
inputs: z19.array(DatasetVersionRefSchema2),
|
|
6197
6669
|
output: DatasetVersionRefSchema2.optional(),
|
|
6198
|
-
rowsWritten:
|
|
6670
|
+
rowsWritten: z19.number().optional(),
|
|
6199
6671
|
error: PipelineRunFailureSchema.optional()
|
|
6200
6672
|
});
|
|
6201
|
-
var PipelineStepSchema =
|
|
6202
|
-
id:
|
|
6203
|
-
mode:
|
|
6673
|
+
var PipelineStepSchema = z19.object({
|
|
6674
|
+
id: z19.string(),
|
|
6675
|
+
mode: z19.enum(["snapshot", "append"]),
|
|
6204
6676
|
executor: PipelineStepExecutorSchema,
|
|
6205
|
-
inputs:
|
|
6206
|
-
name:
|
|
6677
|
+
inputs: z19.array(z19.object({
|
|
6678
|
+
name: z19.string(),
|
|
6207
6679
|
dataset: DatasetDefinitionSchema
|
|
6208
6680
|
})),
|
|
6209
6681
|
output: DatasetDefinitionSchema
|
|
6210
6682
|
});
|
|
6211
|
-
var PipelineSchema =
|
|
6212
|
-
id:
|
|
6213
|
-
triggers:
|
|
6214
|
-
graph:
|
|
6215
|
-
kind:
|
|
6216
|
-
nodes:
|
|
6217
|
-
kind:
|
|
6683
|
+
var PipelineSchema = z19.object({
|
|
6684
|
+
id: z19.string(),
|
|
6685
|
+
triggers: z19.array(PipelineTriggerSchema),
|
|
6686
|
+
graph: z19.object({
|
|
6687
|
+
kind: z19.literal("sequence"),
|
|
6688
|
+
nodes: z19.array(z19.object({
|
|
6689
|
+
kind: z19.literal("step"),
|
|
6218
6690
|
step: PipelineStepSchema
|
|
6219
6691
|
}))
|
|
6220
6692
|
}),
|
|
6221
6693
|
latestRun: PipelineRunSchema.nullable()
|
|
6222
6694
|
});
|
|
6223
|
-
var PipelineRunListResponseSchema =
|
|
6224
|
-
runs:
|
|
6225
|
-
hasMore:
|
|
6226
|
-
total:
|
|
6695
|
+
var PipelineRunListResponseSchema = z19.object({
|
|
6696
|
+
runs: z19.array(PipelineRunSchema),
|
|
6697
|
+
hasMore: z19.boolean(),
|
|
6698
|
+
total: z19.number()
|
|
6227
6699
|
});
|
|
6228
|
-
var PipelineRunDetailResponseSchema =
|
|
6700
|
+
var PipelineRunDetailResponseSchema = z19.object({
|
|
6229
6701
|
run: PipelineRunSchema,
|
|
6230
|
-
steps:
|
|
6702
|
+
steps: z19.array(PipelineStepRunSchema)
|
|
6231
6703
|
});
|
|
6232
|
-
var RequestPipelineRunResponseSchema =
|
|
6233
|
-
runId:
|
|
6234
|
-
jobId:
|
|
6235
|
-
pipelineId:
|
|
6236
|
-
queuedAt:
|
|
6704
|
+
var RequestPipelineRunResponseSchema = z19.object({
|
|
6705
|
+
runId: z19.string(),
|
|
6706
|
+
jobId: z19.string(),
|
|
6707
|
+
pipelineId: z19.string(),
|
|
6708
|
+
queuedAt: z19.string()
|
|
6237
6709
|
});
|
|
6238
6710
|
|
|
6239
6711
|
// src/routes/pipelines.ts
|
|
@@ -6455,9 +6927,9 @@ function registerPipelineRoutes(app, host) {
|
|
|
6455
6927
|
}
|
|
6456
6928
|
|
|
6457
6929
|
// src/schemas/project.ts
|
|
6458
|
-
import { z as
|
|
6459
|
-
var ProjectInfoResponseSchema =
|
|
6460
|
-
id:
|
|
6930
|
+
import { z as z20 } from "zod";
|
|
6931
|
+
var ProjectInfoResponseSchema = z20.object({
|
|
6932
|
+
id: z20.string()
|
|
6461
6933
|
});
|
|
6462
6934
|
|
|
6463
6935
|
// src/routes/project.ts
|
|
@@ -6475,141 +6947,147 @@ function registerProjectRoutes(app, host) {
|
|
|
6475
6947
|
|
|
6476
6948
|
// src/schemas/projections.ts
|
|
6477
6949
|
import { PROJECTION_RUN_FAILURE_CODES } from "@sixb/core/storage";
|
|
6478
|
-
import { z as
|
|
6950
|
+
import { z as z21 } from "zod";
|
|
6479
6951
|
var ProjectionRunFailureSchema = sixbFailureSchema(PROJECTION_RUN_FAILURE_CODES);
|
|
6480
|
-
var ProjectionKindSchema =
|
|
6481
|
-
var ProjectionRunStatusSchema =
|
|
6952
|
+
var ProjectionKindSchema = z21.enum(["object", "link", "telemetry"]);
|
|
6953
|
+
var ProjectionRunStatusSchema = z21.enum([
|
|
6482
6954
|
"queued",
|
|
6483
6955
|
"running",
|
|
6484
6956
|
"succeeded",
|
|
6485
6957
|
"failed",
|
|
6486
6958
|
"cancelled"
|
|
6487
6959
|
]);
|
|
6488
|
-
var ProjectionRunIdentityBaseSchema =
|
|
6489
|
-
projectionId:
|
|
6490
|
-
datasetVersion:
|
|
6491
|
-
datasetId:
|
|
6492
|
-
versionId:
|
|
6493
|
-
createdAt:
|
|
6960
|
+
var ProjectionRunIdentityBaseSchema = z21.object({
|
|
6961
|
+
projectionId: z21.string(),
|
|
6962
|
+
datasetVersion: z21.object({
|
|
6963
|
+
datasetId: z21.string(),
|
|
6964
|
+
versionId: z21.string(),
|
|
6965
|
+
createdAt: z21.string()
|
|
6494
6966
|
}),
|
|
6495
|
-
ontologyRevision:
|
|
6496
|
-
projectionRevision:
|
|
6497
|
-
ownershipHash:
|
|
6498
|
-
});
|
|
6499
|
-
var ProjectionRunBaseSchema =
|
|
6500
|
-
id:
|
|
6501
|
-
projectId:
|
|
6502
|
-
executionId:
|
|
6967
|
+
ontologyRevision: z21.string(),
|
|
6968
|
+
projectionRevision: z21.string(),
|
|
6969
|
+
ownershipHash: z21.string()
|
|
6970
|
+
});
|
|
6971
|
+
var ProjectionRunBaseSchema = z21.object({
|
|
6972
|
+
id: z21.string(),
|
|
6973
|
+
projectId: z21.string(),
|
|
6974
|
+
executionId: z21.string(),
|
|
6503
6975
|
status: ProjectionRunStatusSchema,
|
|
6504
|
-
attempt:
|
|
6505
|
-
progress:
|
|
6506
|
-
sourceRowsRead:
|
|
6507
|
-
sourceRowsSkipped:
|
|
6976
|
+
attempt: z21.number(),
|
|
6977
|
+
progress: z21.object({
|
|
6978
|
+
sourceRowsRead: z21.number(),
|
|
6979
|
+
sourceRowsSkipped: z21.number()
|
|
6508
6980
|
}),
|
|
6509
|
-
queuedAt:
|
|
6510
|
-
startedAt:
|
|
6511
|
-
finishedAt:
|
|
6981
|
+
queuedAt: z21.string(),
|
|
6982
|
+
startedAt: z21.string().optional(),
|
|
6983
|
+
finishedAt: z21.string().optional(),
|
|
6512
6984
|
error: ProjectionRunFailureSchema.optional()
|
|
6513
6985
|
});
|
|
6514
6986
|
var ObjectProjectionRunSchema = ProjectionRunBaseSchema.extend({
|
|
6515
6987
|
identity: ProjectionRunIdentityBaseSchema.extend({
|
|
6516
|
-
projectionKind:
|
|
6517
|
-
protocol:
|
|
6988
|
+
projectionKind: z21.literal("object"),
|
|
6989
|
+
protocol: z21.literal("replacement")
|
|
6518
6990
|
}),
|
|
6519
|
-
target:
|
|
6991
|
+
target: z21.object({ objectTypeId: z21.string() })
|
|
6520
6992
|
});
|
|
6521
6993
|
var LinkProjectionRunSchema = ProjectionRunBaseSchema.extend({
|
|
6522
6994
|
identity: ProjectionRunIdentityBaseSchema.extend({
|
|
6523
|
-
projectionKind:
|
|
6524
|
-
protocol:
|
|
6995
|
+
projectionKind: z21.literal("link"),
|
|
6996
|
+
protocol: z21.literal("replacement")
|
|
6525
6997
|
}),
|
|
6526
|
-
target:
|
|
6527
|
-
sourceObjectTypeId:
|
|
6528
|
-
targetObjectTypeId:
|
|
6998
|
+
target: z21.object({
|
|
6999
|
+
sourceObjectTypeId: z21.string(),
|
|
7000
|
+
targetObjectTypeId: z21.string()
|
|
6529
7001
|
})
|
|
6530
7002
|
});
|
|
6531
7003
|
var TelemetryProjectionRunSchema = ProjectionRunBaseSchema.extend({
|
|
6532
7004
|
identity: ProjectionRunIdentityBaseSchema.extend({
|
|
6533
|
-
projectionKind:
|
|
6534
|
-
protocol:
|
|
7005
|
+
projectionKind: z21.literal("telemetry"),
|
|
7006
|
+
protocol: z21.literal("telemetry")
|
|
6535
7007
|
}),
|
|
6536
|
-
target:
|
|
7008
|
+
target: z21.object({ objectTypeId: z21.string() })
|
|
6537
7009
|
});
|
|
6538
|
-
var ProjectionRunSchema =
|
|
7010
|
+
var ProjectionRunSchema = z21.union([
|
|
6539
7011
|
ObjectProjectionRunSchema,
|
|
6540
7012
|
LinkProjectionRunSchema,
|
|
6541
7013
|
TelemetryProjectionRunSchema
|
|
6542
7014
|
]);
|
|
6543
|
-
var ForeignKeyDescriptorSchema =
|
|
6544
|
-
linkId:
|
|
6545
|
-
sourcePropertyId:
|
|
6546
|
-
sourceField:
|
|
6547
|
-
targetObjectTypeId:
|
|
6548
|
-
});
|
|
6549
|
-
var
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
7015
|
+
var ForeignKeyDescriptorSchema = z21.object({
|
|
7016
|
+
linkId: z21.string(),
|
|
7017
|
+
sourcePropertyId: z21.string().optional(),
|
|
7018
|
+
sourceField: z21.string().optional(),
|
|
7019
|
+
targetObjectTypeId: z21.string()
|
|
7020
|
+
});
|
|
7021
|
+
var SourceEditConflictResolutionSchema = z21.union([
|
|
7022
|
+
z21.object({ strategy: z21.literal("editsWin") }),
|
|
7023
|
+
z21.object({ strategy: z21.literal("mostRecent"), sourceTimestamp: z21.string() })
|
|
7024
|
+
]);
|
|
7025
|
+
var ObjectProjectionSchema = z21.object({
|
|
7026
|
+
_tag: z21.literal("ObjectProjectionDefinition"),
|
|
7027
|
+
id: z21.string(),
|
|
7028
|
+
objectTypeId: z21.string(),
|
|
7029
|
+
datasetId: z21.string(),
|
|
7030
|
+
properties: z21.record(z21.string()),
|
|
7031
|
+
links: z21.record(ForeignKeyDescriptorSchema),
|
|
7032
|
+
conflictResolution: SourceEditConflictResolutionSchema,
|
|
6556
7033
|
latestRun: ProjectionRunSchema.nullable()
|
|
6557
7034
|
});
|
|
6558
|
-
var LinkProjectionSchema =
|
|
6559
|
-
_tag:
|
|
6560
|
-
id:
|
|
6561
|
-
linkId:
|
|
6562
|
-
sourceObjectTypeId:
|
|
6563
|
-
targetObjectTypeId:
|
|
6564
|
-
datasetId:
|
|
6565
|
-
sourceField:
|
|
6566
|
-
targetField:
|
|
7035
|
+
var LinkProjectionSchema = z21.object({
|
|
7036
|
+
_tag: z21.literal("LinkProjectionDefinition"),
|
|
7037
|
+
id: z21.string(),
|
|
7038
|
+
linkId: z21.string(),
|
|
7039
|
+
sourceObjectTypeId: z21.string(),
|
|
7040
|
+
targetObjectTypeId: z21.string(),
|
|
7041
|
+
datasetId: z21.string(),
|
|
7042
|
+
sourceField: z21.string(),
|
|
7043
|
+
targetField: z21.string(),
|
|
6567
7044
|
latestRun: ProjectionRunSchema.nullable()
|
|
6568
7045
|
});
|
|
6569
|
-
var TelemetryProjectionSchema =
|
|
6570
|
-
_tag:
|
|
6571
|
-
id:
|
|
6572
|
-
objectTypeId:
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
7046
|
+
var TelemetryProjectionSchema = z21.object({
|
|
7047
|
+
_tag: z21.literal("TelemetryProjectionDefinition"),
|
|
7048
|
+
id: z21.string(),
|
|
7049
|
+
objectTypeId: z21.string(),
|
|
7050
|
+
datasetId: z21.string(),
|
|
7051
|
+
objectIdField: z21.string(),
|
|
7052
|
+
atField: z21.string(),
|
|
7053
|
+
properties: z21.record(z21.object({
|
|
7054
|
+
valueField: z21.string(),
|
|
7055
|
+
unitField: z21.string().optional()
|
|
7056
|
+
})),
|
|
6579
7057
|
latestRun: ProjectionRunSchema.nullable()
|
|
6580
7058
|
});
|
|
6581
|
-
var ProjectionListResponseSchema =
|
|
6582
|
-
objectProjections:
|
|
6583
|
-
linkProjections:
|
|
6584
|
-
telemetryProjections:
|
|
7059
|
+
var ProjectionListResponseSchema = z21.object({
|
|
7060
|
+
objectProjections: z21.array(ObjectProjectionSchema),
|
|
7061
|
+
linkProjections: z21.array(LinkProjectionSchema),
|
|
7062
|
+
telemetryProjections: z21.array(TelemetryProjectionSchema)
|
|
6585
7063
|
});
|
|
6586
|
-
var ProjectionParamsSchema =
|
|
6587
|
-
projectionId:
|
|
7064
|
+
var ProjectionParamsSchema = z21.object({
|
|
7065
|
+
projectionId: z21.string().min(1)
|
|
6588
7066
|
});
|
|
6589
|
-
var ProjectionResponseSchema =
|
|
7067
|
+
var ProjectionResponseSchema = z21.union([
|
|
6590
7068
|
ObjectProjectionSchema,
|
|
6591
7069
|
LinkProjectionSchema,
|
|
6592
7070
|
TelemetryProjectionSchema
|
|
6593
7071
|
]);
|
|
6594
|
-
var ProjectionRunParamsSchema =
|
|
6595
|
-
runId:
|
|
7072
|
+
var ProjectionRunParamsSchema = z21.object({
|
|
7073
|
+
runId: z21.string().min(1)
|
|
6596
7074
|
});
|
|
6597
|
-
var ProjectionRunsQuerySchema =
|
|
6598
|
-
projectionId:
|
|
7075
|
+
var ProjectionRunsQuerySchema = z21.object({
|
|
7076
|
+
projectionId: z21.string().optional(),
|
|
6599
7077
|
projectionKind: ProjectionKindSchema.optional(),
|
|
6600
|
-
datasetId:
|
|
6601
|
-
datasetVersionId:
|
|
7078
|
+
datasetId: z21.string().optional(),
|
|
7079
|
+
datasetVersionId: z21.string().optional(),
|
|
6602
7080
|
status: ProjectionRunStatusSchema.optional(),
|
|
6603
|
-
startedAfter:
|
|
6604
|
-
startedBefore:
|
|
6605
|
-
limit:
|
|
6606
|
-
offset:
|
|
6607
|
-
order:
|
|
7081
|
+
startedAfter: z21.string().optional(),
|
|
7082
|
+
startedBefore: z21.string().optional(),
|
|
7083
|
+
limit: z21.string().optional(),
|
|
7084
|
+
offset: z21.string().optional(),
|
|
7085
|
+
order: z21.enum(["asc", "desc"]).optional()
|
|
6608
7086
|
});
|
|
6609
|
-
var ProjectionRunListResponseSchema =
|
|
6610
|
-
runs:
|
|
6611
|
-
hasMore:
|
|
6612
|
-
total:
|
|
7087
|
+
var ProjectionRunListResponseSchema = z21.object({
|
|
7088
|
+
runs: z21.array(ProjectionRunSchema),
|
|
7089
|
+
hasMore: z21.boolean(),
|
|
7090
|
+
total: z21.number()
|
|
6613
7091
|
});
|
|
6614
7092
|
|
|
6615
7093
|
// src/routes/projections.ts
|
|
@@ -6651,10 +7129,15 @@ function projectionCatalogIds(catalog) {
|
|
|
6651
7129
|
].map((projection) => projection.id);
|
|
6652
7130
|
}
|
|
6653
7131
|
function serializeProjection(projection, latestRuns) {
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
7132
|
+
const latestRun = latestRuns.get(projection.id) ?? null;
|
|
7133
|
+
if (projection._tag === "ObjectProjectionDefinition") {
|
|
7134
|
+
return {
|
|
7135
|
+
...projection,
|
|
7136
|
+
conflictResolution: projection.conflictResolution ?? { strategy: "editsWin" },
|
|
7137
|
+
latestRun
|
|
7138
|
+
};
|
|
7139
|
+
}
|
|
7140
|
+
return { ...projection, latestRun };
|
|
6658
7141
|
}
|
|
6659
7142
|
function serializeProjectionCatalog(catalog, latestRuns) {
|
|
6660
7143
|
return {
|
|
@@ -6772,88 +7255,88 @@ function registerProjectionRoutes(app, host) {
|
|
|
6772
7255
|
import { deriveRuleEventDependencies } from "@sixb/core/internal/rules";
|
|
6773
7256
|
|
|
6774
7257
|
// 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:
|
|
7258
|
+
import { z as z22 } from "zod";
|
|
7259
|
+
var RuleParamsSchema = z22.object({
|
|
7260
|
+
ruleId: z22.string().min(1)
|
|
7261
|
+
});
|
|
7262
|
+
var RuleStatesQuerySchema = z22.object({
|
|
7263
|
+
ruleId: z22.string().optional(),
|
|
7264
|
+
objectTypeId: z22.string().optional(),
|
|
7265
|
+
primaryId: z22.string().optional(),
|
|
7266
|
+
limit: z22.string().optional(),
|
|
7267
|
+
offset: z22.string().optional(),
|
|
7268
|
+
order: z22.enum(["asc", "desc"]).optional()
|
|
7269
|
+
});
|
|
7270
|
+
var RuleValueSchema = z22.union([z22.string(), z22.number(), z22.boolean()]).nullable();
|
|
7271
|
+
var RuleSubjectSchema = z22.object({
|
|
7272
|
+
kind: z22.literal("object"),
|
|
7273
|
+
objectTypeId: z22.string()
|
|
7274
|
+
});
|
|
7275
|
+
var RuleEventSubjectSchema = z22.object({
|
|
7276
|
+
kind: z22.literal("object"),
|
|
7277
|
+
objectTypeId: z22.string(),
|
|
7278
|
+
primaryId: z22.string()
|
|
7279
|
+
});
|
|
7280
|
+
var RulePropertyPredicateSchema = z22.object({
|
|
7281
|
+
kind: z22.literal("property"),
|
|
7282
|
+
propertyId: z22.string(),
|
|
7283
|
+
op: z22.enum(["eq", "notEq", "gt", "gte", "lt", "lte", "isPresent", "isMissing"]),
|
|
6801
7284
|
value: RuleValueSchema.optional()
|
|
6802
7285
|
});
|
|
6803
|
-
var RuleLinkPredicateSchema =
|
|
6804
|
-
kind:
|
|
6805
|
-
linkId:
|
|
6806
|
-
op:
|
|
7286
|
+
var RuleLinkPredicateSchema = z22.object({
|
|
7287
|
+
kind: z22.literal("link"),
|
|
7288
|
+
linkId: z22.string(),
|
|
7289
|
+
op: z22.enum(["exists", "isMissing"])
|
|
6807
7290
|
});
|
|
6808
7291
|
function createRulePredicateSchema(childPredicateSchema) {
|
|
6809
|
-
return
|
|
6810
|
-
|
|
6811
|
-
kind:
|
|
6812
|
-
predicates:
|
|
7292
|
+
return z22.union([
|
|
7293
|
+
z22.object({
|
|
7294
|
+
kind: z22.literal("all"),
|
|
7295
|
+
predicates: z22.array(childPredicateSchema)
|
|
6813
7296
|
}),
|
|
6814
|
-
|
|
6815
|
-
kind:
|
|
6816
|
-
predicates:
|
|
7297
|
+
z22.object({
|
|
7298
|
+
kind: z22.literal("any"),
|
|
7299
|
+
predicates: z22.array(childPredicateSchema)
|
|
6817
7300
|
}),
|
|
6818
|
-
|
|
6819
|
-
kind:
|
|
7301
|
+
z22.object({
|
|
7302
|
+
kind: z22.literal("not"),
|
|
6820
7303
|
predicate: childPredicateSchema
|
|
6821
7304
|
}),
|
|
6822
7305
|
RulePropertyPredicateSchema,
|
|
6823
7306
|
RuleLinkPredicateSchema
|
|
6824
7307
|
]);
|
|
6825
7308
|
}
|
|
6826
|
-
var DeepRulePredicateSchema = createRulePredicateSchema(
|
|
7309
|
+
var DeepRulePredicateSchema = createRulePredicateSchema(z22.unknown());
|
|
6827
7310
|
var NestedRulePredicateSchema = createRulePredicateSchema(DeepRulePredicateSchema);
|
|
6828
7311
|
var RulePredicateSchema = NestedRulePredicateSchema;
|
|
6829
|
-
var RuleEventDependencySchema =
|
|
6830
|
-
|
|
6831
|
-
type:
|
|
6832
|
-
objectTypeId:
|
|
7312
|
+
var RuleEventDependencySchema = z22.union([
|
|
7313
|
+
z22.object({
|
|
7314
|
+
type: z22.enum(["object.created", "object.updated", "object.deleted"]),
|
|
7315
|
+
objectTypeId: z22.string()
|
|
6833
7316
|
}),
|
|
6834
|
-
|
|
6835
|
-
type:
|
|
6836
|
-
sourceTypeId:
|
|
6837
|
-
linkId:
|
|
7317
|
+
z22.object({
|
|
7318
|
+
type: z22.enum(["link.created", "link.updated", "link.deleted"]),
|
|
7319
|
+
sourceTypeId: z22.string(),
|
|
7320
|
+
linkId: z22.string()
|
|
6838
7321
|
})
|
|
6839
7322
|
]);
|
|
6840
|
-
var RuleSchema =
|
|
6841
|
-
kind:
|
|
6842
|
-
id:
|
|
7323
|
+
var RuleSchema = z22.object({
|
|
7324
|
+
kind: z22.literal("rule"),
|
|
7325
|
+
id: z22.string(),
|
|
6843
7326
|
subject: RuleSubjectSchema,
|
|
6844
7327
|
predicate: RulePredicateSchema,
|
|
6845
|
-
dependencies:
|
|
7328
|
+
dependencies: z22.array(RuleEventDependencySchema)
|
|
6846
7329
|
});
|
|
6847
|
-
var RuleStateSchema =
|
|
6848
|
-
projectId:
|
|
6849
|
-
ruleId:
|
|
7330
|
+
var RuleStateSchema = z22.object({
|
|
7331
|
+
projectId: z22.string(),
|
|
7332
|
+
ruleId: z22.string(),
|
|
6850
7333
|
subject: RuleEventSubjectSchema,
|
|
6851
|
-
triggeredAt:
|
|
7334
|
+
triggeredAt: z22.string()
|
|
6852
7335
|
});
|
|
6853
|
-
var RuleStateListResponseSchema =
|
|
6854
|
-
states:
|
|
6855
|
-
hasMore:
|
|
6856
|
-
total:
|
|
7336
|
+
var RuleStateListResponseSchema = z22.object({
|
|
7337
|
+
states: z22.array(RuleStateSchema),
|
|
7338
|
+
hasMore: z22.boolean(),
|
|
7339
|
+
total: z22.number()
|
|
6857
7340
|
});
|
|
6858
7341
|
|
|
6859
7342
|
// src/routes/rules.ts
|
|
@@ -6933,44 +7416,44 @@ function registerRuleRoutes(app, host) {
|
|
|
6933
7416
|
}
|
|
6934
7417
|
|
|
6935
7418
|
// src/schemas/status.ts
|
|
6936
|
-
import { z as
|
|
6937
|
-
var HealthResponseSchema =
|
|
6938
|
-
var StorageReadinessSchema =
|
|
6939
|
-
reachable:
|
|
6940
|
-
schemaValid:
|
|
7419
|
+
import { z as z23 } from "zod";
|
|
7420
|
+
var HealthResponseSchema = z23.object({ status: z23.literal("ok") });
|
|
7421
|
+
var StorageReadinessSchema = z23.object({
|
|
7422
|
+
reachable: z23.boolean(),
|
|
7423
|
+
schemaValid: z23.boolean()
|
|
6941
7424
|
});
|
|
6942
|
-
var ReadinessResponseSchema =
|
|
6943
|
-
status:
|
|
7425
|
+
var ReadinessResponseSchema = z23.object({
|
|
7426
|
+
status: z23.enum(["ready", "unready"]),
|
|
6944
7427
|
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:
|
|
7428
|
+
reason: z23.string().optional()
|
|
7429
|
+
});
|
|
7430
|
+
var MaintenanceSummarySchema = z23.object({
|
|
7431
|
+
running: z23.boolean(),
|
|
7432
|
+
intervalMs: z23.number().int().positive(),
|
|
7433
|
+
lastStartedAt: z23.string().nullable(),
|
|
7434
|
+
lastCompletedAt: z23.string().nullable(),
|
|
7435
|
+
lastDurationMs: z23.number().nonnegative().nullable(),
|
|
7436
|
+
consecutiveFailures: z23.number().int().nonnegative(),
|
|
7437
|
+
lastError: z23.string().nullable(),
|
|
7438
|
+
outbox: z23.object({
|
|
7439
|
+
pendingCount: z23.number().int().nonnegative(),
|
|
7440
|
+
oldestPendingAt: z23.string().nullable(),
|
|
7441
|
+
retryingCount: z23.number().int().nonnegative(),
|
|
7442
|
+
maxAttempts: z23.number().int().nonnegative()
|
|
6960
7443
|
}).nullable(),
|
|
6961
|
-
terminalSources:
|
|
6962
|
-
count:
|
|
6963
|
-
oldestTerminalAt:
|
|
7444
|
+
terminalSources: z23.object({
|
|
7445
|
+
count: z23.number().int().nonnegative(),
|
|
7446
|
+
oldestTerminalAt: z23.string().nullable()
|
|
6964
7447
|
}).nullable(),
|
|
6965
|
-
cleanup:
|
|
6966
|
-
publishedOutboxRowsDeleted:
|
|
6967
|
-
terminalSourceRowsDeleted:
|
|
6968
|
-
terminalSourceMaterializationsDeleted:
|
|
7448
|
+
cleanup: z23.object({
|
|
7449
|
+
publishedOutboxRowsDeleted: z23.number().int().nonnegative(),
|
|
7450
|
+
terminalSourceRowsDeleted: z23.number().int().nonnegative(),
|
|
7451
|
+
terminalSourceMaterializationsDeleted: z23.number().int().nonnegative()
|
|
6969
7452
|
}).nullable()
|
|
6970
7453
|
});
|
|
6971
|
-
var StatusResponseSchema =
|
|
6972
|
-
status:
|
|
6973
|
-
objectTypes:
|
|
7454
|
+
var StatusResponseSchema = z23.object({
|
|
7455
|
+
status: z23.enum(["ok", "degraded"]),
|
|
7456
|
+
objectTypes: z23.number().int().nonnegative(),
|
|
6974
7457
|
maintenance: MaintenanceSummarySchema
|
|
6975
7458
|
});
|
|
6976
7459
|
|
|
@@ -7016,74 +7499,74 @@ function registerStatusRoutes(app, host) {
|
|
|
7016
7499
|
import {
|
|
7017
7500
|
SYNC_RUN_FAILURE_CODES
|
|
7018
7501
|
} from "@sixb/core/storage";
|
|
7019
|
-
import { z as
|
|
7502
|
+
import { z as z24 } from "zod";
|
|
7020
7503
|
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:
|
|
7504
|
+
var SyncParamsSchema = z24.object({
|
|
7505
|
+
syncId: z24.string().min(1)
|
|
7506
|
+
});
|
|
7507
|
+
var SyncRunStatusSchema = z24.enum(["queued", "running", "succeeded", "failed", "cancelled"]);
|
|
7508
|
+
var SyncModeSchema = z24.enum(["snapshot", "append", "merge"]);
|
|
7509
|
+
var SyncRunsQuerySchema = z24.object({
|
|
7510
|
+
syncId: z24.string().optional(),
|
|
7511
|
+
datasetId: z24.string().optional(),
|
|
7029
7512
|
status: SyncRunStatusSchema.optional(),
|
|
7030
|
-
startedAfter:
|
|
7031
|
-
startedBefore:
|
|
7032
|
-
limit:
|
|
7033
|
-
offset:
|
|
7034
|
-
order:
|
|
7513
|
+
startedAfter: z24.string().optional(),
|
|
7514
|
+
startedBefore: z24.string().optional(),
|
|
7515
|
+
limit: z24.string().optional(),
|
|
7516
|
+
offset: z24.string().optional(),
|
|
7517
|
+
order: z24.enum(["asc", "desc"]).optional()
|
|
7035
7518
|
});
|
|
7036
|
-
var RequestSyncRunBodySchema =
|
|
7037
|
-
expectedLatestVersionId:
|
|
7038
|
-
commitMessage:
|
|
7519
|
+
var RequestSyncRunBodySchema = z24.object({
|
|
7520
|
+
expectedLatestVersionId: z24.string().optional(),
|
|
7521
|
+
commitMessage: z24.string().optional()
|
|
7039
7522
|
});
|
|
7040
|
-
var SyncTriggerSchema =
|
|
7041
|
-
type:
|
|
7042
|
-
scheduleId:
|
|
7523
|
+
var SyncTriggerSchema = z24.object({
|
|
7524
|
+
type: z24.literal("schedule"),
|
|
7525
|
+
scheduleId: z24.string()
|
|
7043
7526
|
});
|
|
7044
|
-
var SyncRunSchema =
|
|
7045
|
-
id:
|
|
7046
|
-
projectId:
|
|
7047
|
-
syncId:
|
|
7048
|
-
datasetId:
|
|
7527
|
+
var SyncRunSchema = z24.object({
|
|
7528
|
+
id: z24.string(),
|
|
7529
|
+
projectId: z24.string(),
|
|
7530
|
+
syncId: z24.string(),
|
|
7531
|
+
datasetId: z24.string(),
|
|
7049
7532
|
mode: SyncModeSchema,
|
|
7050
7533
|
status: SyncRunStatusSchema,
|
|
7051
|
-
queuedAt:
|
|
7052
|
-
startedAt:
|
|
7053
|
-
finishedAt:
|
|
7054
|
-
rowsRead:
|
|
7055
|
-
output:
|
|
7056
|
-
datasetId:
|
|
7057
|
-
versionId:
|
|
7534
|
+
queuedAt: z24.string(),
|
|
7535
|
+
startedAt: z24.string().optional(),
|
|
7536
|
+
finishedAt: z24.string().optional(),
|
|
7537
|
+
rowsRead: z24.number().optional(),
|
|
7538
|
+
output: z24.object({
|
|
7539
|
+
datasetId: z24.string(),
|
|
7540
|
+
versionId: z24.string()
|
|
7058
7541
|
}).optional(),
|
|
7059
|
-
expectedLatestVersionId:
|
|
7060
|
-
commitMessage:
|
|
7542
|
+
expectedLatestVersionId: z24.string().optional(),
|
|
7543
|
+
commitMessage: z24.string().optional(),
|
|
7061
7544
|
error: SyncRunFailureSchema.optional()
|
|
7062
7545
|
});
|
|
7063
|
-
var SyncSchema =
|
|
7064
|
-
id:
|
|
7546
|
+
var SyncSchema = z24.object({
|
|
7547
|
+
id: z24.string(),
|
|
7065
7548
|
mode: SyncModeSchema,
|
|
7066
|
-
connector:
|
|
7067
|
-
id:
|
|
7068
|
-
type:
|
|
7549
|
+
connector: z24.object({
|
|
7550
|
+
id: z24.string(),
|
|
7551
|
+
type: z24.string()
|
|
7069
7552
|
}),
|
|
7070
|
-
target:
|
|
7071
|
-
kind:
|
|
7553
|
+
target: z24.object({
|
|
7554
|
+
kind: z24.literal("dataset"),
|
|
7072
7555
|
dataset: DatasetDefinitionSchema
|
|
7073
7556
|
}),
|
|
7074
|
-
triggers:
|
|
7557
|
+
triggers: z24.array(SyncTriggerSchema),
|
|
7075
7558
|
latestRun: SyncRunSchema.nullable()
|
|
7076
7559
|
});
|
|
7077
|
-
var SyncRunListResponseSchema =
|
|
7078
|
-
runs:
|
|
7079
|
-
hasMore:
|
|
7080
|
-
total:
|
|
7560
|
+
var SyncRunListResponseSchema = z24.object({
|
|
7561
|
+
runs: z24.array(SyncRunSchema),
|
|
7562
|
+
hasMore: z24.boolean(),
|
|
7563
|
+
total: z24.number()
|
|
7081
7564
|
});
|
|
7082
|
-
var RequestSyncRunResponseSchema =
|
|
7083
|
-
runId:
|
|
7084
|
-
jobId:
|
|
7085
|
-
syncId:
|
|
7086
|
-
queuedAt:
|
|
7565
|
+
var RequestSyncRunResponseSchema = z24.object({
|
|
7566
|
+
runId: z24.string(),
|
|
7567
|
+
jobId: z24.string(),
|
|
7568
|
+
syncId: z24.string(),
|
|
7569
|
+
queuedAt: z24.string()
|
|
7087
7570
|
});
|
|
7088
7571
|
|
|
7089
7572
|
// src/routes/syncs.ts
|
|
@@ -7237,52 +7720,52 @@ function registerSyncRoutes(app, host) {
|
|
|
7237
7720
|
}
|
|
7238
7721
|
|
|
7239
7722
|
// 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:
|
|
7251
|
-
});
|
|
7252
|
-
var BulkTelemetryHistorySeriesInputSchema =
|
|
7253
|
-
objectTypeId:
|
|
7254
|
-
objectId:
|
|
7255
|
-
propertyId:
|
|
7723
|
+
import { z as z25 } from "zod";
|
|
7724
|
+
var TelemetryParamsSchema = z25.object({
|
|
7725
|
+
objectTypeId: z25.string().min(1),
|
|
7726
|
+
objectId: z25.string().min(1),
|
|
7727
|
+
propertyId: z25.string().min(1)
|
|
7728
|
+
});
|
|
7729
|
+
var TelemetryHistoryQuerySchema = z25.object({
|
|
7730
|
+
from: z25.string().optional(),
|
|
7731
|
+
to: z25.string().optional(),
|
|
7732
|
+
limit: z25.string().optional(),
|
|
7733
|
+
order: z25.enum(["asc", "desc"]).optional()
|
|
7734
|
+
});
|
|
7735
|
+
var BulkTelemetryHistorySeriesInputSchema = z25.object({
|
|
7736
|
+
objectTypeId: z25.string().min(1),
|
|
7737
|
+
objectId: z25.string().min(1),
|
|
7738
|
+
propertyId: z25.string().min(1)
|
|
7256
7739
|
}).strict();
|
|
7257
|
-
var BulkTelemetryHistoryBodySchema =
|
|
7258
|
-
series:
|
|
7259
|
-
from:
|
|
7260
|
-
to:
|
|
7261
|
-
limitPerSeries:
|
|
7262
|
-
order:
|
|
7740
|
+
var BulkTelemetryHistoryBodySchema = z25.object({
|
|
7741
|
+
series: z25.array(BulkTelemetryHistorySeriesInputSchema).min(1),
|
|
7742
|
+
from: z25.string().optional(),
|
|
7743
|
+
to: z25.string().optional(),
|
|
7744
|
+
limitPerSeries: z25.number().int().nonnegative().optional(),
|
|
7745
|
+
order: z25.enum(["asc", "desc"]).optional()
|
|
7263
7746
|
}).strict();
|
|
7264
|
-
var AppendTelemetryBodySchema =
|
|
7265
|
-
value:
|
|
7266
|
-
unit:
|
|
7267
|
-
at:
|
|
7268
|
-
});
|
|
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:
|
|
7747
|
+
var AppendTelemetryBodySchema = z25.object({
|
|
7748
|
+
value: z25.unknown(),
|
|
7749
|
+
unit: z25.string().optional(),
|
|
7750
|
+
at: z25.string().optional()
|
|
7751
|
+
});
|
|
7752
|
+
var TelemetryPointSchema = z25.object({
|
|
7753
|
+
projectId: z25.string(),
|
|
7754
|
+
objectTypeId: z25.string(),
|
|
7755
|
+
objectId: z25.string(),
|
|
7756
|
+
propertyId: z25.string(),
|
|
7757
|
+
value: z25.unknown(),
|
|
7758
|
+
unit: z25.string().optional(),
|
|
7759
|
+
at: z25.string()
|
|
7760
|
+
});
|
|
7761
|
+
var BulkTelemetryHistorySeriesSchema = z25.object({
|
|
7762
|
+
objectTypeId: z25.string(),
|
|
7763
|
+
objectId: z25.string(),
|
|
7764
|
+
propertyId: z25.string(),
|
|
7765
|
+
points: z25.array(TelemetryPointSchema)
|
|
7766
|
+
});
|
|
7767
|
+
var BulkTelemetryHistoryResponseSchema = z25.object({
|
|
7768
|
+
series: z25.array(BulkTelemetryHistorySeriesSchema)
|
|
7286
7769
|
});
|
|
7287
7770
|
|
|
7288
7771
|
// src/routes/telemetry.ts
|
|
@@ -7440,40 +7923,40 @@ function registerTelemetryRoutes(app, _host) {
|
|
|
7440
7923
|
|
|
7441
7924
|
// src/schemas/webhook-runs.ts
|
|
7442
7925
|
import { WEBHOOK_RUN_FAILURE_CODES } from "@sixb/core/storage";
|
|
7443
|
-
import { z as
|
|
7926
|
+
import { z as z26 } from "zod";
|
|
7444
7927
|
var WebhookRunFailureSchema = sixbFailureSchema(WEBHOOK_RUN_FAILURE_CODES);
|
|
7445
|
-
var WebhookRunStatusSchema =
|
|
7446
|
-
var WebhookRunsQuerySchema =
|
|
7447
|
-
connectorId:
|
|
7448
|
-
webhookId:
|
|
7928
|
+
var WebhookRunStatusSchema = z26.enum(["running", "succeeded", "failed"]);
|
|
7929
|
+
var WebhookRunsQuerySchema = z26.object({
|
|
7930
|
+
connectorId: z26.string().optional(),
|
|
7931
|
+
webhookId: z26.string().optional(),
|
|
7449
7932
|
status: WebhookRunStatusSchema.optional(),
|
|
7450
|
-
idempotencyKey:
|
|
7451
|
-
startedAfter:
|
|
7452
|
-
startedBefore:
|
|
7453
|
-
limit:
|
|
7454
|
-
offset:
|
|
7455
|
-
order:
|
|
7456
|
-
});
|
|
7457
|
-
var WebhookRunSchema =
|
|
7458
|
-
id:
|
|
7459
|
-
projectId:
|
|
7460
|
-
executionId:
|
|
7461
|
-
connectorId:
|
|
7462
|
-
webhookId:
|
|
7933
|
+
idempotencyKey: z26.string().optional(),
|
|
7934
|
+
startedAfter: z26.string().optional(),
|
|
7935
|
+
startedBefore: z26.string().optional(),
|
|
7936
|
+
limit: z26.string().optional(),
|
|
7937
|
+
offset: z26.string().optional(),
|
|
7938
|
+
order: z26.enum(["asc", "desc"]).optional()
|
|
7939
|
+
});
|
|
7940
|
+
var WebhookRunSchema = z26.object({
|
|
7941
|
+
id: z26.string(),
|
|
7942
|
+
projectId: z26.string(),
|
|
7943
|
+
executionId: z26.string(),
|
|
7944
|
+
connectorId: z26.string(),
|
|
7945
|
+
webhookId: z26.string(),
|
|
7463
7946
|
status: WebhookRunStatusSchema,
|
|
7464
|
-
method:
|
|
7465
|
-
route:
|
|
7466
|
-
startedAt:
|
|
7467
|
-
finishedAt:
|
|
7468
|
-
requestBodyBytes:
|
|
7469
|
-
responseStatus:
|
|
7470
|
-
idempotencyKey:
|
|
7947
|
+
method: z26.string(),
|
|
7948
|
+
route: z26.string(),
|
|
7949
|
+
startedAt: z26.string(),
|
|
7950
|
+
finishedAt: z26.string().optional(),
|
|
7951
|
+
requestBodyBytes: z26.number(),
|
|
7952
|
+
responseStatus: z26.number().optional(),
|
|
7953
|
+
idempotencyKey: z26.string().optional(),
|
|
7471
7954
|
error: WebhookRunFailureSchema.optional()
|
|
7472
7955
|
});
|
|
7473
|
-
var WebhookRunListResponseSchema =
|
|
7474
|
-
runs:
|
|
7475
|
-
hasMore:
|
|
7476
|
-
total:
|
|
7956
|
+
var WebhookRunListResponseSchema = z26.object({
|
|
7957
|
+
runs: z26.array(WebhookRunSchema),
|
|
7958
|
+
hasMore: z26.boolean(),
|
|
7959
|
+
total: z26.number()
|
|
7477
7960
|
});
|
|
7478
7961
|
|
|
7479
7962
|
// src/routes/webhook-runs.ts
|
|
@@ -7548,25 +8031,25 @@ import {
|
|
|
7548
8031
|
snapshotWorkflowInterventionResponse
|
|
7549
8032
|
} from "@sixb/core/internal/workflows";
|
|
7550
8033
|
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
|
|
8034
|
+
import { z as z28 } from "zod";
|
|
7552
8035
|
|
|
7553
8036
|
// src/schemas/workflows.ts
|
|
7554
8037
|
import {
|
|
7555
8038
|
WORKFLOW_RUN_FAILURE_CODES
|
|
7556
8039
|
} from "@sixb/core/storage";
|
|
7557
|
-
import { z as
|
|
7558
|
-
var WorkflowIOSnapshotSchema =
|
|
8040
|
+
import { z as z27 } from "zod";
|
|
8041
|
+
var WorkflowIOSnapshotSchema = z27.record(JsonValueSchema);
|
|
7559
8042
|
var WorkflowRunFailureSchema = sixbFailureSchema(WORKFLOW_RUN_FAILURE_CODES);
|
|
7560
|
-
var WorkflowParamsSchema =
|
|
7561
|
-
workflowId:
|
|
8043
|
+
var WorkflowParamsSchema = z27.object({
|
|
8044
|
+
workflowId: z27.string().min(1)
|
|
7562
8045
|
});
|
|
7563
|
-
var WorkflowRunParamsSchema =
|
|
7564
|
-
runId:
|
|
8046
|
+
var WorkflowRunParamsSchema = z27.object({
|
|
8047
|
+
runId: z27.string().min(1)
|
|
7565
8048
|
});
|
|
7566
|
-
var WorkflowInterventionParamsSchema =
|
|
7567
|
-
interventionId:
|
|
8049
|
+
var WorkflowInterventionParamsSchema = z27.object({
|
|
8050
|
+
interventionId: z27.string().min(1)
|
|
7568
8051
|
});
|
|
7569
|
-
var WorkflowRunStatusSchema =
|
|
8052
|
+
var WorkflowRunStatusSchema = z27.enum([
|
|
7570
8053
|
"queued",
|
|
7571
8054
|
"running",
|
|
7572
8055
|
"waiting",
|
|
@@ -7574,91 +8057,91 @@ var WorkflowRunStatusSchema = z25.enum([
|
|
|
7574
8057
|
"failed",
|
|
7575
8058
|
"cancelled"
|
|
7576
8059
|
]);
|
|
7577
|
-
var WorkflowInterventionStatusSchema =
|
|
8060
|
+
var WorkflowInterventionStatusSchema = z27.enum([
|
|
7578
8061
|
"pending",
|
|
7579
8062
|
"submitted",
|
|
7580
8063
|
"cancelled",
|
|
7581
8064
|
"expired"
|
|
7582
8065
|
]);
|
|
7583
|
-
var WorkflowRunsQuerySchema =
|
|
7584
|
-
workflowId:
|
|
8066
|
+
var WorkflowRunsQuerySchema = z27.object({
|
|
8067
|
+
workflowId: z27.string().optional(),
|
|
7585
8068
|
status: WorkflowRunStatusSchema.optional(),
|
|
7586
|
-
startedAfter:
|
|
7587
|
-
startedBefore:
|
|
7588
|
-
limit:
|
|
7589
|
-
offset:
|
|
7590
|
-
order:
|
|
8069
|
+
startedAfter: z27.string().optional(),
|
|
8070
|
+
startedBefore: z27.string().optional(),
|
|
8071
|
+
limit: z27.string().optional(),
|
|
8072
|
+
offset: z27.string().optional(),
|
|
8073
|
+
order: z27.enum(["asc", "desc"]).optional()
|
|
7591
8074
|
});
|
|
7592
|
-
var WorkflowInterventionsQuerySchema =
|
|
7593
|
-
workflowId:
|
|
7594
|
-
workflowRunId:
|
|
7595
|
-
nodeRunId:
|
|
7596
|
-
nodeId:
|
|
7597
|
-
nodeKey:
|
|
7598
|
-
interventionId:
|
|
8075
|
+
var WorkflowInterventionsQuerySchema = z27.object({
|
|
8076
|
+
workflowId: z27.string().optional(),
|
|
8077
|
+
workflowRunId: z27.string().optional(),
|
|
8078
|
+
nodeRunId: z27.string().optional(),
|
|
8079
|
+
nodeId: z27.string().optional(),
|
|
8080
|
+
nodeKey: z27.string().optional(),
|
|
8081
|
+
interventionId: z27.string().optional(),
|
|
7599
8082
|
status: WorkflowInterventionStatusSchema.optional(),
|
|
7600
|
-
requestedAfter:
|
|
7601
|
-
requestedBefore:
|
|
7602
|
-
limit:
|
|
7603
|
-
offset:
|
|
7604
|
-
order:
|
|
8083
|
+
requestedAfter: z27.string().optional(),
|
|
8084
|
+
requestedBefore: z27.string().optional(),
|
|
8085
|
+
limit: z27.string().optional(),
|
|
8086
|
+
offset: z27.string().optional(),
|
|
8087
|
+
order: z27.enum(["asc", "desc"]).optional()
|
|
7605
8088
|
});
|
|
7606
|
-
var RequestWorkflowRunBodySchema =
|
|
8089
|
+
var RequestWorkflowRunBodySchema = z27.object({
|
|
7607
8090
|
input: WorkflowIOSnapshotSchema.optional()
|
|
7608
8091
|
}).default({});
|
|
7609
|
-
var WorkflowInterventionActorSchema =
|
|
7610
|
-
principalType:
|
|
7611
|
-
principalId:
|
|
8092
|
+
var WorkflowInterventionActorSchema = z27.object({
|
|
8093
|
+
principalType: z27.enum(["user", "serviceAccount", "system"]),
|
|
8094
|
+
principalId: z27.string().min(1)
|
|
7612
8095
|
});
|
|
7613
|
-
var CancelWorkflowRunBodySchema =
|
|
7614
|
-
var SubmitWorkflowInterventionBodySchema =
|
|
8096
|
+
var CancelWorkflowRunBodySchema = z27.object({}).default({});
|
|
8097
|
+
var SubmitWorkflowInterventionBodySchema = z27.object({
|
|
7615
8098
|
response: WorkflowIOSnapshotSchema
|
|
7616
8099
|
});
|
|
7617
|
-
var CancelWorkflowInterventionBodySchema =
|
|
7618
|
-
var WorkflowTriggerSchema =
|
|
7619
|
-
type:
|
|
7620
|
-
scheduleId:
|
|
8100
|
+
var CancelWorkflowInterventionBodySchema = z27.object({}).default({});
|
|
8101
|
+
var WorkflowTriggerSchema = z27.object({
|
|
8102
|
+
type: z27.literal("schedule"),
|
|
8103
|
+
scheduleId: z27.string()
|
|
7621
8104
|
});
|
|
7622
|
-
var WorkflowNodeSchema =
|
|
7623
|
-
|
|
7624
|
-
type:
|
|
7625
|
-
id:
|
|
7626
|
-
key:
|
|
8105
|
+
var WorkflowNodeSchema = z27.union([
|
|
8106
|
+
z27.object({
|
|
8107
|
+
type: z27.literal("step"),
|
|
8108
|
+
id: z27.string(),
|
|
8109
|
+
key: z27.string(),
|
|
7627
8110
|
input: WorkflowIOSnapshotSchema,
|
|
7628
8111
|
output: WorkflowIOSnapshotSchema
|
|
7629
8112
|
}),
|
|
7630
|
-
|
|
7631
|
-
type:
|
|
7632
|
-
id:
|
|
7633
|
-
key:
|
|
7634
|
-
objectTypeId:
|
|
8113
|
+
z27.object({
|
|
8114
|
+
type: z27.literal("action"),
|
|
8115
|
+
id: z27.string(),
|
|
8116
|
+
key: z27.string(),
|
|
8117
|
+
objectTypeId: z27.string().optional(),
|
|
7635
8118
|
params: WorkflowIOSnapshotSchema
|
|
7636
8119
|
}),
|
|
7637
|
-
|
|
7638
|
-
type:
|
|
7639
|
-
id:
|
|
7640
|
-
key:
|
|
8120
|
+
z27.object({
|
|
8121
|
+
type: z27.literal("intervention"),
|
|
8122
|
+
id: z27.string(),
|
|
8123
|
+
key: z27.string(),
|
|
7641
8124
|
input: WorkflowIOSnapshotSchema,
|
|
7642
8125
|
response: WorkflowIOSnapshotSchema,
|
|
7643
|
-
description:
|
|
8126
|
+
description: z27.string().optional()
|
|
7644
8127
|
}),
|
|
7645
|
-
|
|
7646
|
-
type:
|
|
7647
|
-
id:
|
|
7648
|
-
key:
|
|
7649
|
-
agentId:
|
|
8128
|
+
z27.object({
|
|
8129
|
+
type: z27.literal("agent"),
|
|
8130
|
+
id: z27.string(),
|
|
8131
|
+
key: z27.string(),
|
|
8132
|
+
agentId: z27.string(),
|
|
7650
8133
|
input: WorkflowIOSnapshotSchema,
|
|
7651
8134
|
output: WorkflowIOSnapshotSchema
|
|
7652
8135
|
})
|
|
7653
8136
|
]);
|
|
7654
|
-
var WorkflowRunSummarySchema =
|
|
7655
|
-
id:
|
|
7656
|
-
projectId:
|
|
7657
|
-
workflowId:
|
|
8137
|
+
var WorkflowRunSummarySchema = z27.object({
|
|
8138
|
+
id: z27.string(),
|
|
8139
|
+
projectId: z27.string(),
|
|
8140
|
+
workflowId: z27.string(),
|
|
7658
8141
|
status: WorkflowRunStatusSchema,
|
|
7659
|
-
queuedAt:
|
|
7660
|
-
startedAt:
|
|
7661
|
-
finishedAt:
|
|
8142
|
+
queuedAt: z27.string().optional(),
|
|
8143
|
+
startedAt: z27.string(),
|
|
8144
|
+
finishedAt: z27.string().optional(),
|
|
7662
8145
|
error: WorkflowRunFailureSchema.optional(),
|
|
7663
8146
|
requestedBy: WorkflowInterventionActorSchema
|
|
7664
8147
|
});
|
|
@@ -7666,108 +8149,111 @@ var WorkflowRunDetailSchema = WorkflowRunSummarySchema.extend({
|
|
|
7666
8149
|
input: WorkflowIOSnapshotSchema,
|
|
7667
8150
|
output: WorkflowIOSnapshotSchema.optional()
|
|
7668
8151
|
});
|
|
7669
|
-
var WorkflowAgentNodeExecutionSummarySchema =
|
|
7670
|
-
agentId:
|
|
7671
|
-
status:
|
|
7672
|
-
attempt:
|
|
7673
|
-
modelId:
|
|
7674
|
-
finishReason:
|
|
8152
|
+
var WorkflowAgentNodeExecutionSummarySchema = z27.object({
|
|
8153
|
+
agentId: z27.string(),
|
|
8154
|
+
status: z27.enum(["queued", "running", "succeeded", "failed", "cancelled"]),
|
|
8155
|
+
attempt: z27.number().int().nonnegative(),
|
|
8156
|
+
modelId: z27.string().optional(),
|
|
8157
|
+
finishReason: z27.string().optional(),
|
|
7675
8158
|
usage: AiUsageSummarySchema.optional(),
|
|
7676
|
-
|
|
7677
|
-
|
|
8159
|
+
cost: AiCostSummarySchema.optional(),
|
|
8160
|
+
startedAt: z27.string().optional(),
|
|
8161
|
+
completedAt: z27.string().optional()
|
|
7678
8162
|
});
|
|
8163
|
+
var WorkflowAgentFailurePhaseSchema = z27.enum(["agent-loop", "structured-finalizer"]);
|
|
7679
8164
|
var WorkflowAgentNodeExecutionSchema = WorkflowAgentNodeExecutionSummarySchema.extend({
|
|
7680
|
-
nodeRunId:
|
|
7681
|
-
prompt:
|
|
7682
|
-
trace:
|
|
7683
|
-
diagnostics:
|
|
8165
|
+
nodeRunId: z27.string(),
|
|
8166
|
+
prompt: z27.string(),
|
|
8167
|
+
trace: z27.array(AgentMessagePartSchema).optional(),
|
|
8168
|
+
diagnostics: z27.array(JsonValueSchema).optional(),
|
|
8169
|
+
failurePhase: WorkflowAgentFailurePhaseSchema.optional(),
|
|
7684
8170
|
error: AgentRunFailureSchema.optional(),
|
|
7685
|
-
createdAt:
|
|
8171
|
+
createdAt: z27.string()
|
|
7686
8172
|
});
|
|
7687
|
-
var WorkflowNodeRunSchema =
|
|
7688
|
-
id:
|
|
7689
|
-
projectId:
|
|
7690
|
-
workflowRunId:
|
|
7691
|
-
workflowId:
|
|
7692
|
-
nodeIndex:
|
|
7693
|
-
nodeType:
|
|
7694
|
-
nodeId:
|
|
7695
|
-
nodeKey:
|
|
7696
|
-
status:
|
|
8173
|
+
var WorkflowNodeRunSchema = z27.object({
|
|
8174
|
+
id: z27.string(),
|
|
8175
|
+
projectId: z27.string(),
|
|
8176
|
+
workflowRunId: z27.string(),
|
|
8177
|
+
workflowId: z27.string(),
|
|
8178
|
+
nodeIndex: z27.number(),
|
|
8179
|
+
nodeType: z27.enum(["step", "action", "intervention", "agent"]),
|
|
8180
|
+
nodeId: z27.string(),
|
|
8181
|
+
nodeKey: z27.string(),
|
|
8182
|
+
status: z27.enum(["running", "waiting", "succeeded", "failed", "cancelled"]),
|
|
7697
8183
|
input: WorkflowIOSnapshotSchema,
|
|
7698
|
-
startedAt:
|
|
7699
|
-
finishedAt:
|
|
8184
|
+
startedAt: z27.string(),
|
|
8185
|
+
finishedAt: z27.string().optional(),
|
|
7700
8186
|
output: WorkflowIOSnapshotSchema.optional(),
|
|
7701
8187
|
error: WorkflowRunFailureSchema.optional(),
|
|
7702
8188
|
agentExecution: WorkflowAgentNodeExecutionSummarySchema.optional()
|
|
7703
8189
|
});
|
|
7704
|
-
var WorkflowInterventionSchema =
|
|
7705
|
-
id:
|
|
7706
|
-
projectId:
|
|
7707
|
-
workflowId:
|
|
7708
|
-
workflowRunId:
|
|
7709
|
-
nodeRunId:
|
|
7710
|
-
nodeIndex:
|
|
7711
|
-
nodeId:
|
|
7712
|
-
nodeKey:
|
|
7713
|
-
interventionId:
|
|
8190
|
+
var WorkflowInterventionSchema = z27.object({
|
|
8191
|
+
id: z27.string(),
|
|
8192
|
+
projectId: z27.string(),
|
|
8193
|
+
workflowId: z27.string(),
|
|
8194
|
+
workflowRunId: z27.string(),
|
|
8195
|
+
nodeRunId: z27.string(),
|
|
8196
|
+
nodeIndex: z27.number(),
|
|
8197
|
+
nodeId: z27.string(),
|
|
8198
|
+
nodeKey: z27.string(),
|
|
8199
|
+
interventionId: z27.string(),
|
|
7714
8200
|
input: WorkflowIOSnapshotSchema,
|
|
7715
8201
|
defaultResponse: WorkflowIOSnapshotSchema,
|
|
7716
8202
|
status: WorkflowInterventionStatusSchema,
|
|
7717
|
-
requestedAt:
|
|
7718
|
-
expiresAt:
|
|
7719
|
-
submittedAt:
|
|
8203
|
+
requestedAt: z27.string(),
|
|
8204
|
+
expiresAt: z27.string().optional(),
|
|
8205
|
+
submittedAt: z27.string().optional(),
|
|
7720
8206
|
submittedBy: WorkflowInterventionActorSchema.optional(),
|
|
7721
8207
|
response: WorkflowIOSnapshotSchema.optional(),
|
|
7722
|
-
cancelledAt:
|
|
8208
|
+
cancelledAt: z27.string().optional(),
|
|
7723
8209
|
cancelledBy: WorkflowInterventionActorSchema.optional(),
|
|
7724
|
-
expiredAt:
|
|
8210
|
+
expiredAt: z27.string().optional()
|
|
7725
8211
|
});
|
|
7726
|
-
var WorkflowSchema =
|
|
7727
|
-
id:
|
|
8212
|
+
var WorkflowSchema = z27.object({
|
|
8213
|
+
id: z27.string(),
|
|
7728
8214
|
input: WorkflowIOSnapshotSchema,
|
|
7729
|
-
triggers:
|
|
7730
|
-
nodes:
|
|
8215
|
+
triggers: z27.array(WorkflowTriggerSchema),
|
|
8216
|
+
nodes: z27.array(WorkflowNodeSchema),
|
|
7731
8217
|
latestRun: WorkflowRunSummarySchema.nullable()
|
|
7732
8218
|
});
|
|
7733
|
-
var WorkflowRunListResponseSchema =
|
|
7734
|
-
runs:
|
|
7735
|
-
hasMore:
|
|
7736
|
-
total:
|
|
8219
|
+
var WorkflowRunListResponseSchema = z27.object({
|
|
8220
|
+
runs: z27.array(WorkflowRunSummarySchema),
|
|
8221
|
+
hasMore: z27.boolean(),
|
|
8222
|
+
total: z27.number()
|
|
7737
8223
|
});
|
|
7738
|
-
var WorkflowRunDetailResponseSchema =
|
|
8224
|
+
var WorkflowRunDetailResponseSchema = z27.object({
|
|
7739
8225
|
run: WorkflowRunDetailSchema,
|
|
7740
|
-
nodes:
|
|
8226
|
+
nodes: z27.array(WorkflowNodeRunSchema)
|
|
7741
8227
|
});
|
|
7742
8228
|
var CancelWorkflowRunResponseSchema = WorkflowRunDetailResponseSchema;
|
|
7743
|
-
var WorkflowInterventionListResponseSchema =
|
|
7744
|
-
interventions:
|
|
7745
|
-
hasMore:
|
|
7746
|
-
total:
|
|
8229
|
+
var WorkflowInterventionListResponseSchema = z27.object({
|
|
8230
|
+
interventions: z27.array(WorkflowInterventionSchema),
|
|
8231
|
+
hasMore: z27.boolean(),
|
|
8232
|
+
total: z27.number()
|
|
7747
8233
|
});
|
|
7748
|
-
var SubmitWorkflowInterventionResponseSchema =
|
|
8234
|
+
var SubmitWorkflowInterventionResponseSchema = z27.object({
|
|
7749
8235
|
intervention: WorkflowInterventionSchema,
|
|
7750
|
-
jobId:
|
|
8236
|
+
jobId: z27.string()
|
|
7751
8237
|
});
|
|
7752
|
-
var CancelWorkflowInterventionResponseSchema =
|
|
8238
|
+
var CancelWorkflowInterventionResponseSchema = z27.object({
|
|
7753
8239
|
intervention: WorkflowInterventionSchema
|
|
7754
8240
|
});
|
|
7755
|
-
var RequestWorkflowRunResponseSchema =
|
|
7756
|
-
runId:
|
|
7757
|
-
jobId:
|
|
7758
|
-
workflowId:
|
|
7759
|
-
queuedAt:
|
|
8241
|
+
var RequestWorkflowRunResponseSchema = z27.object({
|
|
8242
|
+
runId: z27.string(),
|
|
8243
|
+
jobId: z27.string(),
|
|
8244
|
+
workflowId: z27.string(),
|
|
8245
|
+
queuedAt: z27.string()
|
|
7760
8246
|
});
|
|
7761
8247
|
|
|
7762
8248
|
// src/routes/workflows.ts
|
|
7763
8249
|
var WorkflowRunFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
7764
|
-
path:
|
|
8250
|
+
path: z28.string().min(1).regex(/^\/(?:input|output)(?:\/|$)/, "Workflow run file content paths must start with /input/ or /output/")
|
|
7765
8251
|
});
|
|
7766
8252
|
var WorkflowNodeFileContentQuerySchema = FileContentQuerySchema.extend({
|
|
7767
|
-
path:
|
|
8253
|
+
path: z28.string().min(1).regex(/^\/(?:input|output)(?:\/|$)/, "Workflow node file content paths must start with /input/ or /output/")
|
|
7768
8254
|
});
|
|
7769
8255
|
var WorkflowNodeFileContentParamsSchema = WorkflowRunParamsSchema.extend({
|
|
7770
|
-
nodeKey:
|
|
8256
|
+
nodeKey: z28.string().min(1)
|
|
7771
8257
|
});
|
|
7772
8258
|
function serializeWorkflowRunSummary(run) {
|
|
7773
8259
|
return {
|
|
@@ -7819,6 +8305,7 @@ function serializeWorkflowAgentExecutionSummary(execution) {
|
|
|
7819
8305
|
modelId: execution.modelId,
|
|
7820
8306
|
finishReason: execution.finishReason,
|
|
7821
8307
|
usage: execution.usage,
|
|
8308
|
+
cost: execution.cost,
|
|
7822
8309
|
startedAt: execution.startedAt ? toIsoString(execution.startedAt) : undefined,
|
|
7823
8310
|
completedAt: execution.completedAt ? toIsoString(execution.completedAt) : undefined
|
|
7824
8311
|
};
|
|
@@ -7830,10 +8317,21 @@ function serializeWorkflowAgentExecution(execution) {
|
|
|
7830
8317
|
prompt: execution.prompt,
|
|
7831
8318
|
trace: execution.trace,
|
|
7832
8319
|
diagnostics: execution.diagnostics,
|
|
8320
|
+
failurePhase: workflowAgentFailurePhase(execution),
|
|
7833
8321
|
error: execution.error,
|
|
7834
8322
|
createdAt: toIsoString(execution.createdAt)
|
|
7835
8323
|
};
|
|
7836
8324
|
}
|
|
8325
|
+
function workflowAgentFailurePhase(execution) {
|
|
8326
|
+
const details = execution.error?.details;
|
|
8327
|
+
if (!isRecord(details))
|
|
8328
|
+
return;
|
|
8329
|
+
const phase = details.failurePhase;
|
|
8330
|
+
return phase === "agent-loop" || phase === "structured-finalizer" ? phase : undefined;
|
|
8331
|
+
}
|
|
8332
|
+
function isRecord(value) {
|
|
8333
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8334
|
+
}
|
|
7837
8335
|
function principalForExecution(sixb) {
|
|
7838
8336
|
return sixb.execution.requestedBy ?? SYSTEM_PRINCIPAL2;
|
|
7839
8337
|
}
|
|
@@ -8780,6 +9278,7 @@ function registerWorkflowRoutes(app, host) {
|
|
|
8780
9278
|
// src/registerRoutes.ts
|
|
8781
9279
|
function registerHttpRoutes(app, host, options) {
|
|
8782
9280
|
registerAgentApiGatewayRoutes(app, host);
|
|
9281
|
+
registerAiAccountingRoutes(app, host);
|
|
8783
9282
|
registerProjectRoutes(app, host);
|
|
8784
9283
|
registerStatusRoutes(app, host);
|
|
8785
9284
|
registerConnectorRoutes(app, host);
|
|
@@ -8796,6 +9295,7 @@ function registerHttpRoutes(app, host, options) {
|
|
|
8796
9295
|
registerFileRoutes(app, host);
|
|
8797
9296
|
registerActionRunRoutes(app, host);
|
|
8798
9297
|
registerAgentRoutes(app, host);
|
|
9298
|
+
registerModelRoutes(app, host);
|
|
8799
9299
|
registerLinkRoutes(app, host);
|
|
8800
9300
|
registerTelemetryRoutes(app, host);
|
|
8801
9301
|
registerEventRoutes(app, host);
|
|
@@ -8826,275 +9326,405 @@ import {
|
|
|
8826
9326
|
} from "@sixb/core/storage";
|
|
8827
9327
|
import { t } from "elysia";
|
|
8828
9328
|
|
|
9329
|
+
// src/auth/experience.ts
|
|
9330
|
+
import { resolve } from "path";
|
|
9331
|
+
var AUTH_BOOTSTRAP_PLACEHOLDER = "__SIXB_AUTH_BOOTSTRAP__";
|
|
9332
|
+
var AUTH_ASSET_PREFIX = "/auth/assets/";
|
|
9333
|
+
async function customAuthExperienceResponse(options, input) {
|
|
9334
|
+
if (!options || input.audience !== (options.audience ?? "app")) {
|
|
9335
|
+
return null;
|
|
9336
|
+
}
|
|
9337
|
+
const template = Bun.file(resolve(options.outdir, "index.html"));
|
|
9338
|
+
if (!await template.exists()) {
|
|
9339
|
+
return null;
|
|
9340
|
+
}
|
|
9341
|
+
const html = await template.text();
|
|
9342
|
+
if (!html.includes(AUTH_BOOTSTRAP_PLACEHOLDER)) {
|
|
9343
|
+
console.warn(`[SixbServer] Custom auth experience in ${options.outdir} is missing its bootstrap placeholder. Using the generic page.`);
|
|
9344
|
+
return null;
|
|
9345
|
+
}
|
|
9346
|
+
const bootstrap = Buffer.from(JSON.stringify({
|
|
9347
|
+
state: input.state,
|
|
9348
|
+
signInUrl: input.signInUrl,
|
|
9349
|
+
...input.submission ? { submission: input.submission } : {}
|
|
9350
|
+
})).toString("base64url");
|
|
9351
|
+
const formAction = ["'self'", ...(input.formActionOrigins ?? []).map(normalizeCspOrigin)].join(" ");
|
|
9352
|
+
return new Response(html.replace(AUTH_BOOTSTRAP_PLACEHOLDER, bootstrap), {
|
|
9353
|
+
status: input.status ?? 200,
|
|
9354
|
+
headers: {
|
|
9355
|
+
"content-type": "text/html; charset=utf-8",
|
|
9356
|
+
"cache-control": "no-store",
|
|
9357
|
+
"content-security-policy": [
|
|
9358
|
+
"default-src 'none'",
|
|
9359
|
+
"script-src 'self'",
|
|
9360
|
+
"style-src 'self' 'unsafe-inline'",
|
|
9361
|
+
"img-src 'self' data:",
|
|
9362
|
+
"font-src 'self'",
|
|
9363
|
+
"base-uri 'none'",
|
|
9364
|
+
`form-action ${formAction}`,
|
|
9365
|
+
"frame-ancestors 'none'"
|
|
9366
|
+
].join("; "),
|
|
9367
|
+
"referrer-policy": input.referrerPolicy ?? "no-referrer",
|
|
9368
|
+
"x-content-type-options": "nosniff"
|
|
9369
|
+
}
|
|
9370
|
+
});
|
|
9371
|
+
}
|
|
9372
|
+
function normalizeCspOrigin(value) {
|
|
9373
|
+
let url;
|
|
9374
|
+
try {
|
|
9375
|
+
url = new URL(value);
|
|
9376
|
+
} catch {
|
|
9377
|
+
throw new Error(`[SixbServer] Invalid custom auth form-action origin: '${value}'.`);
|
|
9378
|
+
}
|
|
9379
|
+
if (url.protocol !== "http:" && url.protocol !== "https:" || url.origin !== value) {
|
|
9380
|
+
throw new Error(`[SixbServer] Invalid custom auth form-action origin: '${value}'.`);
|
|
9381
|
+
}
|
|
9382
|
+
return url.origin;
|
|
9383
|
+
}
|
|
9384
|
+
async function customAuthExperienceAssetResponse(options, request) {
|
|
9385
|
+
const method = request.method.toUpperCase();
|
|
9386
|
+
if (!options || method !== "GET" && method !== "HEAD") {
|
|
9387
|
+
return notFoundResponse();
|
|
9388
|
+
}
|
|
9389
|
+
const url = new URL(request.url);
|
|
9390
|
+
if (!url.pathname.startsWith(AUTH_ASSET_PREFIX)) {
|
|
9391
|
+
return notFoundResponse();
|
|
9392
|
+
}
|
|
9393
|
+
let fileName;
|
|
9394
|
+
try {
|
|
9395
|
+
fileName = decodeURIComponent(url.pathname.slice(AUTH_ASSET_PREFIX.length));
|
|
9396
|
+
} catch {
|
|
9397
|
+
return notFoundResponse();
|
|
9398
|
+
}
|
|
9399
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(fileName)) {
|
|
9400
|
+
return notFoundResponse();
|
|
9401
|
+
}
|
|
9402
|
+
const path = resolve(options.outdir, "assets", fileName);
|
|
9403
|
+
const source = Bun.file(path);
|
|
9404
|
+
if (!await source.exists()) {
|
|
9405
|
+
return notFoundResponse();
|
|
9406
|
+
}
|
|
9407
|
+
const encoding = await resolvePrecompressedAsset(request, path);
|
|
9408
|
+
const body = encoding ? Bun.file(`${path}.${encoding === "br" ? "br" : "gz"}`) : source;
|
|
9409
|
+
const headers = new Headers({
|
|
9410
|
+
"content-type": source.type || "application/octet-stream",
|
|
9411
|
+
"cache-control": "public, max-age=31536000, immutable",
|
|
9412
|
+
"x-content-type-options": "nosniff"
|
|
9413
|
+
});
|
|
9414
|
+
if (encoding) {
|
|
9415
|
+
headers.set("content-encoding", encoding);
|
|
9416
|
+
headers.set("vary", "Accept-Encoding");
|
|
9417
|
+
}
|
|
9418
|
+
return new Response(method === "HEAD" ? null : body, { headers });
|
|
9419
|
+
}
|
|
9420
|
+
async function resolvePrecompressedAsset(request, sourcePath) {
|
|
9421
|
+
for (const encoding of acceptedPrecompressedEncodings(request)) {
|
|
9422
|
+
const suffix = encoding === "br" ? "br" : "gz";
|
|
9423
|
+
if (await Bun.file(`${sourcePath}.${suffix}`).exists()) {
|
|
9424
|
+
return encoding;
|
|
9425
|
+
}
|
|
9426
|
+
}
|
|
9427
|
+
return null;
|
|
9428
|
+
}
|
|
9429
|
+
function acceptedPrecompressedEncodings(request) {
|
|
9430
|
+
const header = request.headers.get("accept-encoding");
|
|
9431
|
+
if (!header)
|
|
9432
|
+
return [];
|
|
9433
|
+
const qualities = new Map;
|
|
9434
|
+
for (const item of header.split(",")) {
|
|
9435
|
+
const [rawName, ...parameters] = item.trim().split(";");
|
|
9436
|
+
const name = rawName.toLowerCase();
|
|
9437
|
+
let quality = 1;
|
|
9438
|
+
for (const parameter of parameters) {
|
|
9439
|
+
const match = parameter.trim().match(/^q=(0(?:\.\d+)?|1(?:\.0+)?)$/);
|
|
9440
|
+
if (match)
|
|
9441
|
+
quality = Number(match[1]);
|
|
9442
|
+
}
|
|
9443
|
+
qualities.set(name, quality);
|
|
9444
|
+
}
|
|
9445
|
+
const wildcard = qualities.get("*") ?? 0;
|
|
9446
|
+
return ["br", "gzip"].map((encoding, preference) => ({
|
|
9447
|
+
encoding,
|
|
9448
|
+
preference,
|
|
9449
|
+
quality: qualities.get(encoding) ?? wildcard
|
|
9450
|
+
})).filter((candidate) => candidate.quality > 0).sort((left, right) => right.quality - left.quality || left.preference - right.preference).map((candidate) => candidate.encoding);
|
|
9451
|
+
}
|
|
9452
|
+
function notFoundResponse() {
|
|
9453
|
+
return new Response("Not Found", {
|
|
9454
|
+
status: 404,
|
|
9455
|
+
headers: { "content-type": "text/plain; charset=utf-8" }
|
|
9456
|
+
});
|
|
9457
|
+
}
|
|
9458
|
+
|
|
8829
9459
|
// 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:
|
|
9460
|
+
import { z as z29 } from "zod";
|
|
9461
|
+
var AuthInvitationStatusSchema = z29.enum(["pending", "accepted", "revoked"]);
|
|
9462
|
+
var AuthGroupOptionSchema = z29.object({
|
|
9463
|
+
id: z29.string(),
|
|
9464
|
+
label: z29.string().optional(),
|
|
9465
|
+
description: z29.string().optional()
|
|
9466
|
+
});
|
|
9467
|
+
var AuthInvitationSchema = z29.object({
|
|
9468
|
+
id: z29.string(),
|
|
9469
|
+
email: z29.string(),
|
|
9470
|
+
groupIds: z29.array(z29.string()),
|
|
8841
9471
|
status: AuthInvitationStatusSchema,
|
|
8842
|
-
createdAt:
|
|
8843
|
-
updatedAt:
|
|
8844
|
-
expiresAt:
|
|
8845
|
-
acceptedAt:
|
|
8846
|
-
revokedAt:
|
|
9472
|
+
createdAt: z29.string(),
|
|
9473
|
+
updatedAt: z29.string(),
|
|
9474
|
+
expiresAt: z29.string(),
|
|
9475
|
+
acceptedAt: z29.string().optional(),
|
|
9476
|
+
revokedAt: z29.string().optional()
|
|
8847
9477
|
});
|
|
8848
|
-
var AuthInvitationDeliverySchema =
|
|
8849
|
-
status:
|
|
9478
|
+
var AuthInvitationDeliverySchema = z29.object({
|
|
9479
|
+
status: z29.enum(["sent", "skipped", "rate_limited", "not_supported"])
|
|
8850
9480
|
});
|
|
8851
9481
|
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:
|
|
9482
|
+
var AuthAccessTokenKindSchema = z29.enum(["personal", "serviceAccount"]);
|
|
9483
|
+
var AuthAccessTokenSubjectTypeSchema = z29.enum(["user", "serviceAccount"]);
|
|
9484
|
+
var AuthAccessTokenStatusSchema = z29.enum(["active", "expired", "revoked"]);
|
|
9485
|
+
var AuthServiceAccountStatusSchema = z29.enum(["active", "suspended"]);
|
|
9486
|
+
var AuthUserStatusSchema = z29.enum(["active", "suspended"]);
|
|
9487
|
+
var AuthAccessTokenSchema = z29.object({
|
|
9488
|
+
id: z29.string(),
|
|
9489
|
+
name: z29.string(),
|
|
8860
9490
|
kind: AuthAccessTokenKindSchema,
|
|
8861
9491
|
status: AuthAccessTokenStatusSchema,
|
|
8862
9492
|
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:
|
|
9493
|
+
subjectId: z29.string(),
|
|
9494
|
+
subjectLabel: z29.string().optional(),
|
|
9495
|
+
groupIds: z29.array(z29.string()).optional(),
|
|
9496
|
+
createdAt: z29.string(),
|
|
9497
|
+
expiresAt: z29.string(),
|
|
9498
|
+
revokedAt: z29.string().optional(),
|
|
9499
|
+
lastUsedAt: z29.string().optional(),
|
|
9500
|
+
lastUsedUserAgent: z29.string().optional(),
|
|
9501
|
+
lastUsedIpAddress: z29.string().optional()
|
|
9502
|
+
});
|
|
9503
|
+
var AuthServiceAccountSchema = z29.object({
|
|
9504
|
+
id: z29.string(),
|
|
9505
|
+
name: z29.string(),
|
|
9506
|
+
description: z29.string().optional(),
|
|
8877
9507
|
status: AuthServiceAccountStatusSchema,
|
|
8878
|
-
groupIds:
|
|
8879
|
-
createdAt:
|
|
8880
|
-
updatedAt:
|
|
8881
|
-
});
|
|
8882
|
-
var AuthMemberUserSchema =
|
|
8883
|
-
id:
|
|
8884
|
-
email:
|
|
8885
|
-
displayName:
|
|
8886
|
-
avatarUrl:
|
|
9508
|
+
groupIds: z29.array(z29.string()),
|
|
9509
|
+
createdAt: z29.string(),
|
|
9510
|
+
updatedAt: z29.string()
|
|
9511
|
+
});
|
|
9512
|
+
var AuthMemberUserSchema = z29.object({
|
|
9513
|
+
id: z29.string(),
|
|
9514
|
+
email: z29.string(),
|
|
9515
|
+
displayName: z29.string().optional(),
|
|
9516
|
+
avatarUrl: z29.string().optional(),
|
|
8887
9517
|
status: AuthUserStatusSchema,
|
|
8888
|
-
createdAt:
|
|
8889
|
-
updatedAt:
|
|
9518
|
+
createdAt: z29.string(),
|
|
9519
|
+
updatedAt: z29.string()
|
|
8890
9520
|
});
|
|
8891
|
-
var AuthManagedMemberSchema =
|
|
9521
|
+
var AuthManagedMemberSchema = z29.object({
|
|
8892
9522
|
user: AuthMemberUserSchema,
|
|
8893
|
-
groupIds:
|
|
9523
|
+
groupIds: z29.array(z29.string())
|
|
8894
9524
|
});
|
|
8895
|
-
var AuthMemberCapabilitiesSchema =
|
|
8896
|
-
assignGroups:
|
|
8897
|
-
suspend:
|
|
8898
|
-
reactivate:
|
|
9525
|
+
var AuthMemberCapabilitiesSchema = z29.object({
|
|
9526
|
+
assignGroups: z29.boolean(),
|
|
9527
|
+
suspend: z29.boolean(),
|
|
9528
|
+
reactivate: z29.boolean()
|
|
8899
9529
|
});
|
|
8900
9530
|
var AuthMemberSchema = AuthManagedMemberSchema.extend({
|
|
8901
9531
|
capabilities: AuthMemberCapabilitiesSchema
|
|
8902
9532
|
});
|
|
8903
|
-
var GetAuthAccessManagementOptionsResponseSchema =
|
|
8904
|
-
groups:
|
|
9533
|
+
var GetAuthAccessManagementOptionsResponseSchema = z29.object({
|
|
9534
|
+
groups: z29.array(AuthGroupOptionSchema)
|
|
8905
9535
|
});
|
|
8906
|
-
var ListAuthAccessTokensResponseSchema =
|
|
8907
|
-
accessTokens:
|
|
9536
|
+
var ListAuthAccessTokensResponseSchema = z29.object({
|
|
9537
|
+
accessTokens: z29.array(AuthAccessTokenSchema)
|
|
8908
9538
|
});
|
|
8909
|
-
var CreateAuthPersonalAccessTokenBodySchema =
|
|
8910
|
-
name:
|
|
8911
|
-
expiresAt:
|
|
8912
|
-
groupIds:
|
|
9539
|
+
var CreateAuthPersonalAccessTokenBodySchema = z29.object({
|
|
9540
|
+
name: z29.string().trim().min(1),
|
|
9541
|
+
expiresAt: z29.string().min(1),
|
|
9542
|
+
groupIds: z29.array(z29.string().min(1)).optional()
|
|
8913
9543
|
});
|
|
8914
|
-
var CreateAuthPersonalAccessTokenResponseSchema =
|
|
9544
|
+
var CreateAuthPersonalAccessTokenResponseSchema = z29.object({
|
|
8915
9545
|
accessToken: AuthAccessTokenSchema,
|
|
8916
|
-
tokenValue:
|
|
9546
|
+
tokenValue: z29.string()
|
|
8917
9547
|
});
|
|
8918
|
-
var RevokeAuthAccessTokenParamsSchema =
|
|
8919
|
-
tokenId:
|
|
9548
|
+
var RevokeAuthAccessTokenParamsSchema = z29.object({
|
|
9549
|
+
tokenId: z29.string().min(1)
|
|
8920
9550
|
});
|
|
8921
|
-
var RevokeAuthAccessTokenResponseSchema =
|
|
9551
|
+
var RevokeAuthAccessTokenResponseSchema = z29.object({
|
|
8922
9552
|
accessToken: AuthAccessTokenSchema
|
|
8923
9553
|
});
|
|
8924
|
-
var ListAuthServiceAccountsResponseSchema =
|
|
8925
|
-
serviceAccounts:
|
|
9554
|
+
var ListAuthServiceAccountsResponseSchema = z29.object({
|
|
9555
|
+
serviceAccounts: z29.array(AuthServiceAccountSchema)
|
|
8926
9556
|
});
|
|
8927
|
-
var CreateAuthServiceAccountBodySchema =
|
|
8928
|
-
id:
|
|
8929
|
-
name:
|
|
8930
|
-
description:
|
|
8931
|
-
groupIds:
|
|
9557
|
+
var CreateAuthServiceAccountBodySchema = z29.object({
|
|
9558
|
+
id: z29.string().trim().min(1).optional(),
|
|
9559
|
+
name: z29.string().trim().min(1),
|
|
9560
|
+
description: z29.string().trim().optional(),
|
|
9561
|
+
groupIds: z29.array(z29.string().min(1)).optional()
|
|
8932
9562
|
});
|
|
8933
|
-
var CreateAuthServiceAccountResponseSchema =
|
|
9563
|
+
var CreateAuthServiceAccountResponseSchema = z29.object({
|
|
8934
9564
|
serviceAccount: AuthServiceAccountSchema
|
|
8935
9565
|
});
|
|
8936
|
-
var AuthServiceAccountParamsSchema =
|
|
8937
|
-
serviceAccountId:
|
|
9566
|
+
var AuthServiceAccountParamsSchema = z29.object({
|
|
9567
|
+
serviceAccountId: z29.string().min(1)
|
|
8938
9568
|
});
|
|
8939
|
-
var DisableAuthServiceAccountResponseSchema =
|
|
9569
|
+
var DisableAuthServiceAccountResponseSchema = z29.object({
|
|
8940
9570
|
serviceAccount: AuthServiceAccountSchema
|
|
8941
9571
|
});
|
|
8942
|
-
var ListAuthServiceAccountAccessTokensResponseSchema =
|
|
8943
|
-
accessTokens:
|
|
9572
|
+
var ListAuthServiceAccountAccessTokensResponseSchema = z29.object({
|
|
9573
|
+
accessTokens: z29.array(AuthAccessTokenSchema)
|
|
8944
9574
|
});
|
|
8945
|
-
var CreateAuthServiceAccountAccessTokenBodySchema =
|
|
8946
|
-
name:
|
|
8947
|
-
expiresAt:
|
|
8948
|
-
groupIds:
|
|
9575
|
+
var CreateAuthServiceAccountAccessTokenBodySchema = z29.object({
|
|
9576
|
+
name: z29.string().trim().min(1),
|
|
9577
|
+
expiresAt: z29.string().min(1),
|
|
9578
|
+
groupIds: z29.array(z29.string().min(1)).optional()
|
|
8949
9579
|
});
|
|
8950
|
-
var CreateAuthServiceAccountAccessTokenResponseSchema =
|
|
9580
|
+
var CreateAuthServiceAccountAccessTokenResponseSchema = z29.object({
|
|
8951
9581
|
accessToken: AuthAccessTokenSchema,
|
|
8952
|
-
tokenValue:
|
|
9582
|
+
tokenValue: z29.string()
|
|
8953
9583
|
});
|
|
8954
9584
|
var RevokeAuthServiceAccountAccessTokenParamsSchema = AuthServiceAccountParamsSchema.extend({
|
|
8955
|
-
tokenId:
|
|
9585
|
+
tokenId: z29.string().min(1)
|
|
8956
9586
|
});
|
|
8957
|
-
var RevokeAuthServiceAccountAccessTokenResponseSchema =
|
|
9587
|
+
var RevokeAuthServiceAccountAccessTokenResponseSchema = z29.object({
|
|
8958
9588
|
accessToken: AuthAccessTokenSchema
|
|
8959
9589
|
});
|
|
8960
|
-
var AuthCreateInvitationCapabilitySchema =
|
|
8961
|
-
|
|
8962
|
-
state:
|
|
9590
|
+
var AuthCreateInvitationCapabilitySchema = z29.union([
|
|
9591
|
+
z29.object({
|
|
9592
|
+
state: z29.literal("enabled")
|
|
8963
9593
|
}),
|
|
8964
|
-
|
|
8965
|
-
state:
|
|
8966
|
-
reason:
|
|
9594
|
+
z29.object({
|
|
9595
|
+
state: z29.literal("disabled"),
|
|
9596
|
+
reason: z29.enum(["missing_membership_policy", "invitation_delivery_not_supported"])
|
|
8967
9597
|
})
|
|
8968
9598
|
]);
|
|
8969
|
-
var AuthInvitationDestinationSchema =
|
|
8970
|
-
id:
|
|
8971
|
-
label:
|
|
8972
|
-
});
|
|
8973
|
-
var GetAuthInvitationOptionsResponseSchema =
|
|
8974
|
-
groups:
|
|
8975
|
-
destinations:
|
|
8976
|
-
defaultDestinationId:
|
|
8977
|
-
canInviteWithoutGroups:
|
|
8978
|
-
capabilities:
|
|
9599
|
+
var AuthInvitationDestinationSchema = z29.object({
|
|
9600
|
+
id: z29.enum(["atlas", "app"]),
|
|
9601
|
+
label: z29.string()
|
|
9602
|
+
});
|
|
9603
|
+
var GetAuthInvitationOptionsResponseSchema = z29.object({
|
|
9604
|
+
groups: z29.array(AuthInvitationGroupOptionSchema),
|
|
9605
|
+
destinations: z29.array(AuthInvitationDestinationSchema),
|
|
9606
|
+
defaultDestinationId: z29.enum(["atlas", "app"]).optional(),
|
|
9607
|
+
canInviteWithoutGroups: z29.boolean(),
|
|
9608
|
+
capabilities: z29.object({
|
|
8979
9609
|
createInvitation: AuthCreateInvitationCapabilitySchema
|
|
8980
9610
|
})
|
|
8981
9611
|
});
|
|
8982
|
-
var GetAuthMembershipOptionsResponseSchema =
|
|
8983
|
-
groups:
|
|
8984
|
-
capabilities:
|
|
8985
|
-
invite:
|
|
8986
|
-
assignGroups:
|
|
8987
|
-
suspend:
|
|
9612
|
+
var GetAuthMembershipOptionsResponseSchema = z29.object({
|
|
9613
|
+
groups: z29.array(AuthGroupOptionSchema),
|
|
9614
|
+
capabilities: z29.object({
|
|
9615
|
+
invite: z29.boolean(),
|
|
9616
|
+
assignGroups: z29.boolean(),
|
|
9617
|
+
suspend: z29.boolean()
|
|
8988
9618
|
})
|
|
8989
9619
|
});
|
|
8990
|
-
var ListAuthMembersQuerySchema =
|
|
8991
|
-
limit:
|
|
8992
|
-
offset:
|
|
8993
|
-
order:
|
|
9620
|
+
var ListAuthMembersQuerySchema = z29.object({
|
|
9621
|
+
limit: z29.string().optional(),
|
|
9622
|
+
offset: z29.string().optional(),
|
|
9623
|
+
order: z29.enum(["asc", "desc"]).optional()
|
|
8994
9624
|
});
|
|
8995
|
-
var ListAuthMembersResponseSchema =
|
|
8996
|
-
members:
|
|
8997
|
-
hasMore:
|
|
8998
|
-
total:
|
|
9625
|
+
var ListAuthMembersResponseSchema = z29.object({
|
|
9626
|
+
members: z29.array(AuthMemberSchema),
|
|
9627
|
+
hasMore: z29.boolean(),
|
|
9628
|
+
total: z29.number()
|
|
8999
9629
|
});
|
|
9000
|
-
var AuthMemberParamsSchema =
|
|
9001
|
-
userId:
|
|
9630
|
+
var AuthMemberParamsSchema = z29.object({
|
|
9631
|
+
userId: z29.string().min(1)
|
|
9002
9632
|
});
|
|
9003
|
-
var UpdateAuthMemberGroupsBodySchema =
|
|
9004
|
-
groupIds:
|
|
9633
|
+
var UpdateAuthMemberGroupsBodySchema = z29.object({
|
|
9634
|
+
groupIds: z29.array(z29.string().min(1))
|
|
9005
9635
|
});
|
|
9006
|
-
var UpdateAuthMemberGroupsResponseSchema =
|
|
9636
|
+
var UpdateAuthMemberGroupsResponseSchema = z29.object({
|
|
9007
9637
|
member: AuthManagedMemberSchema
|
|
9008
9638
|
});
|
|
9009
|
-
var SuspendAuthMemberResponseSchema =
|
|
9639
|
+
var SuspendAuthMemberResponseSchema = z29.object({
|
|
9010
9640
|
member: AuthManagedMemberSchema
|
|
9011
9641
|
});
|
|
9012
|
-
var ReactivateAuthMemberResponseSchema =
|
|
9642
|
+
var ReactivateAuthMemberResponseSchema = z29.object({
|
|
9013
9643
|
member: AuthManagedMemberSchema
|
|
9014
9644
|
});
|
|
9015
|
-
var CreateAuthInvitationBodySchema =
|
|
9016
|
-
email:
|
|
9017
|
-
groupIds:
|
|
9018
|
-
destinationId:
|
|
9019
|
-
expiresAt:
|
|
9020
|
-
returnTo:
|
|
9645
|
+
var CreateAuthInvitationBodySchema = z29.object({
|
|
9646
|
+
email: z29.string().min(1),
|
|
9647
|
+
groupIds: z29.array(z29.string().min(1)).optional(),
|
|
9648
|
+
destinationId: z29.enum(["atlas", "app"]).optional(),
|
|
9649
|
+
expiresAt: z29.string().optional(),
|
|
9650
|
+
returnTo: z29.string().optional()
|
|
9021
9651
|
});
|
|
9022
|
-
var CreateAuthInvitationResponseSchema =
|
|
9652
|
+
var CreateAuthInvitationResponseSchema = z29.object({
|
|
9023
9653
|
invitation: AuthInvitationSchema,
|
|
9024
9654
|
delivery: AuthInvitationDeliverySchema
|
|
9025
9655
|
});
|
|
9026
|
-
var ListAuthInvitationsQuerySchema =
|
|
9027
|
-
email:
|
|
9656
|
+
var ListAuthInvitationsQuerySchema = z29.object({
|
|
9657
|
+
email: z29.string().optional(),
|
|
9028
9658
|
status: AuthInvitationStatusSchema.optional(),
|
|
9029
|
-
limit:
|
|
9030
|
-
offset:
|
|
9031
|
-
order:
|
|
9659
|
+
limit: z29.string().optional(),
|
|
9660
|
+
offset: z29.string().optional(),
|
|
9661
|
+
order: z29.enum(["asc", "desc"]).optional()
|
|
9032
9662
|
});
|
|
9033
|
-
var ListAuthInvitationsResponseSchema =
|
|
9034
|
-
invitations:
|
|
9035
|
-
hasMore:
|
|
9036
|
-
total:
|
|
9663
|
+
var ListAuthInvitationsResponseSchema = z29.object({
|
|
9664
|
+
invitations: z29.array(AuthInvitationSchema),
|
|
9665
|
+
hasMore: z29.boolean(),
|
|
9666
|
+
total: z29.number()
|
|
9037
9667
|
});
|
|
9038
|
-
var RevokeAuthInvitationParamsSchema =
|
|
9039
|
-
invitationId:
|
|
9668
|
+
var RevokeAuthInvitationParamsSchema = z29.object({
|
|
9669
|
+
invitationId: z29.string().min(1)
|
|
9040
9670
|
});
|
|
9041
|
-
var RevokeAuthInvitationResponseSchema =
|
|
9671
|
+
var RevokeAuthInvitationResponseSchema = z29.object({
|
|
9042
9672
|
invitation: AuthInvitationSchema
|
|
9043
9673
|
});
|
|
9044
|
-
var AuthSessionResponseSchema =
|
|
9045
|
-
|
|
9046
|
-
authenticated:
|
|
9674
|
+
var AuthSessionResponseSchema = z29.union([
|
|
9675
|
+
z29.object({
|
|
9676
|
+
authenticated: z29.literal(false)
|
|
9047
9677
|
}),
|
|
9048
|
-
|
|
9049
|
-
authenticated:
|
|
9050
|
-
csrfToken:
|
|
9051
|
-
applicationAccess:
|
|
9052
|
-
allowed:
|
|
9053
|
-
audience:
|
|
9678
|
+
z29.object({
|
|
9679
|
+
authenticated: z29.literal(true),
|
|
9680
|
+
csrfToken: z29.string(),
|
|
9681
|
+
applicationAccess: z29.object({
|
|
9682
|
+
allowed: z29.boolean(),
|
|
9683
|
+
audience: z29.enum(["atlas", "app"])
|
|
9054
9684
|
}),
|
|
9055
|
-
user:
|
|
9056
|
-
id:
|
|
9057
|
-
email:
|
|
9058
|
-
displayName:
|
|
9059
|
-
avatarUrl:
|
|
9060
|
-
groupIds:
|
|
9685
|
+
user: z29.object({
|
|
9686
|
+
id: z29.string(),
|
|
9687
|
+
email: z29.string(),
|
|
9688
|
+
displayName: z29.string().optional(),
|
|
9689
|
+
avatarUrl: z29.string().optional(),
|
|
9690
|
+
groupIds: z29.array(z29.string())
|
|
9061
9691
|
}),
|
|
9062
|
-
session:
|
|
9063
|
-
id:
|
|
9064
|
-
expiresAt:
|
|
9692
|
+
session: z29.object({
|
|
9693
|
+
id: z29.string(),
|
|
9694
|
+
expiresAt: z29.string()
|
|
9065
9695
|
})
|
|
9066
9696
|
})
|
|
9067
9697
|
]);
|
|
9068
|
-
var AuthSignOutResponseSchema =
|
|
9069
|
-
success:
|
|
9698
|
+
var AuthSignOutResponseSchema = z29.object({
|
|
9699
|
+
success: z29.boolean()
|
|
9070
9700
|
});
|
|
9071
|
-
var AuthSessionSummarySchema =
|
|
9072
|
-
id:
|
|
9073
|
-
audience:
|
|
9074
|
-
current:
|
|
9075
|
-
createdAt:
|
|
9076
|
-
expiresAt:
|
|
9077
|
-
lastSeenAt:
|
|
9078
|
-
userAgent:
|
|
9079
|
-
ipAddress:
|
|
9701
|
+
var AuthSessionSummarySchema = z29.object({
|
|
9702
|
+
id: z29.string(),
|
|
9703
|
+
audience: z29.enum(["atlas", "app"]),
|
|
9704
|
+
current: z29.boolean(),
|
|
9705
|
+
createdAt: z29.string(),
|
|
9706
|
+
expiresAt: z29.string(),
|
|
9707
|
+
lastSeenAt: z29.string().optional(),
|
|
9708
|
+
userAgent: z29.string().optional(),
|
|
9709
|
+
ipAddress: z29.string().optional()
|
|
9080
9710
|
});
|
|
9081
|
-
var ListAuthSessionsResponseSchema =
|
|
9082
|
-
sessions:
|
|
9711
|
+
var ListAuthSessionsResponseSchema = z29.object({
|
|
9712
|
+
sessions: z29.array(AuthSessionSummarySchema)
|
|
9083
9713
|
});
|
|
9084
|
-
var RevokeAuthSessionParamsSchema =
|
|
9085
|
-
sessionId:
|
|
9714
|
+
var RevokeAuthSessionParamsSchema = z29.object({
|
|
9715
|
+
sessionId: z29.string().min(1)
|
|
9086
9716
|
});
|
|
9087
|
-
var RevokeAuthSessionResponseSchema =
|
|
9088
|
-
success:
|
|
9717
|
+
var RevokeAuthSessionResponseSchema = z29.object({
|
|
9718
|
+
success: z29.boolean()
|
|
9089
9719
|
});
|
|
9090
|
-
var SignOutAllResponseSchema =
|
|
9091
|
-
success:
|
|
9092
|
-
revokedCount:
|
|
9720
|
+
var SignOutAllResponseSchema = z29.object({
|
|
9721
|
+
success: z29.boolean(),
|
|
9722
|
+
revokedCount: z29.number()
|
|
9093
9723
|
});
|
|
9094
9724
|
|
|
9095
9725
|
// src/routes/auth.ts
|
|
9096
9726
|
function registerAuthRoutes(app, host, options) {
|
|
9097
|
-
return app.get("/api/auth/session", async ({ request }) => {
|
|
9727
|
+
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
9728
|
const authOptions = resolveAuthOptions(options, request);
|
|
9099
9729
|
let session = await host.auth.getSession(request, authOptions);
|
|
9100
9730
|
if (!session.authenticated) {
|
|
@@ -9888,7 +10518,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
9888
10518
|
requestOrigin: authRedirect.requestOrigin,
|
|
9889
10519
|
requesterHash: pending.hash
|
|
9890
10520
|
});
|
|
9891
|
-
const response =
|
|
10521
|
+
const response = await magicLinkRequestedResponse(options, authRedirect);
|
|
9892
10522
|
const existingPending = getCookie3(request, MAGIC_LINK_PENDING_COOKIE_NAME)?.trim();
|
|
9893
10523
|
response.headers.append("set-cookie", magicLinkPendingCookieHeader({
|
|
9894
10524
|
request,
|
|
@@ -9928,7 +10558,7 @@ function registerAuthRoutes(app, host, options) {
|
|
|
9928
10558
|
return authRedirect;
|
|
9929
10559
|
}
|
|
9930
10560
|
if (isMagicLinkAuthStrategy(strategy)) {
|
|
9931
|
-
return signInFormResponse(authRedirect);
|
|
10561
|
+
return await signInFormResponse(options, authRedirect);
|
|
9932
10562
|
}
|
|
9933
10563
|
if (isOidcAuthStrategy(strategy)) {
|
|
9934
10564
|
const result = await strategy.startOidcSignIn({
|
|
@@ -9947,8 +10577,9 @@ function registerAuthRoutes(app, host, options) {
|
|
|
9947
10577
|
const url = new URL(request.url);
|
|
9948
10578
|
const magicLinkId = url.searchParams.get("magicLinkId")?.trim();
|
|
9949
10579
|
const token = url.searchParams.get("token")?.trim();
|
|
10580
|
+
const authRedirectHint = resolveAuthExperienceRedirectHint(options, request, url.searchParams.get("audience"));
|
|
9950
10581
|
if (!magicLinkId || !token) {
|
|
9951
|
-
return
|
|
10582
|
+
return await invalidMagicLinkResponse(options, authRedirectHint);
|
|
9952
10583
|
}
|
|
9953
10584
|
let email;
|
|
9954
10585
|
if (strategy.peekMagicLink) {
|
|
@@ -9960,11 +10591,12 @@ function registerAuthRoutes(app, host, options) {
|
|
|
9960
10591
|
token
|
|
9961
10592
|
});
|
|
9962
10593
|
if (!peeked) {
|
|
9963
|
-
return
|
|
10594
|
+
return await invalidMagicLinkResponse(options, authRedirectHint);
|
|
9964
10595
|
}
|
|
9965
10596
|
email = peeked.email;
|
|
9966
|
-
} catch {
|
|
9967
|
-
|
|
10597
|
+
} catch (error) {
|
|
10598
|
+
logAuthCallbackError("Magic-link", error);
|
|
10599
|
+
return await authExperienceErrorResponse(options, authRedirectHint);
|
|
9968
10600
|
}
|
|
9969
10601
|
}
|
|
9970
10602
|
const requesterHash = url.searchParams.get("requester")?.trim();
|
|
@@ -9977,10 +10609,16 @@ function registerAuthRoutes(app, host, options) {
|
|
|
9977
10609
|
request,
|
|
9978
10610
|
magicLinkId,
|
|
9979
10611
|
token,
|
|
9980
|
-
clearPendingCookie: true
|
|
10612
|
+
clearPendingCookie: true,
|
|
10613
|
+
authRedirectHint
|
|
9981
10614
|
});
|
|
9982
10615
|
}
|
|
9983
|
-
return magicLinkConfirmResponse(
|
|
10616
|
+
return await magicLinkConfirmResponse(options, {
|
|
10617
|
+
magicLinkId,
|
|
10618
|
+
token,
|
|
10619
|
+
email,
|
|
10620
|
+
authRedirect: authRedirectHint
|
|
10621
|
+
});
|
|
9984
10622
|
}
|
|
9985
10623
|
if (isOidcAuthStrategy(strategy)) {
|
|
9986
10624
|
const now = new Date;
|
|
@@ -10024,14 +10662,24 @@ function registerAuthRoutes(app, host, options) {
|
|
|
10024
10662
|
}
|
|
10025
10663
|
const magicLinkId = body.magicLinkId?.trim();
|
|
10026
10664
|
const token = body.token?.trim();
|
|
10665
|
+
const authRedirectHint = resolveAuthExperienceRedirectHint(options, request, body.audience);
|
|
10027
10666
|
if (!magicLinkId || !token) {
|
|
10028
|
-
return
|
|
10667
|
+
return await invalidMagicLinkResponse(options, authRedirectHint);
|
|
10029
10668
|
}
|
|
10030
|
-
return completeMagicLinkCallback({
|
|
10669
|
+
return completeMagicLinkCallback({
|
|
10670
|
+
host,
|
|
10671
|
+
strategy,
|
|
10672
|
+
options,
|
|
10673
|
+
request,
|
|
10674
|
+
magicLinkId,
|
|
10675
|
+
token,
|
|
10676
|
+
authRedirectHint
|
|
10677
|
+
});
|
|
10031
10678
|
}, {
|
|
10032
10679
|
body: t.Object({
|
|
10033
10680
|
magicLinkId: t.Optional(t.String()),
|
|
10034
|
-
token: t.Optional(t.String())
|
|
10681
|
+
token: t.Optional(t.String()),
|
|
10682
|
+
audience: t.Optional(t.String())
|
|
10035
10683
|
}),
|
|
10036
10684
|
parse: "urlencoded",
|
|
10037
10685
|
detail: { hide: true }
|
|
@@ -10106,7 +10754,7 @@ async function completeMagicLinkCallback(input) {
|
|
|
10106
10754
|
}
|
|
10107
10755
|
return response;
|
|
10108
10756
|
} catch {
|
|
10109
|
-
return
|
|
10757
|
+
return await invalidMagicLinkResponse(input.options, input.authRedirectHint);
|
|
10110
10758
|
}
|
|
10111
10759
|
}
|
|
10112
10760
|
function resolveSessionDevice(request) {
|
|
@@ -10377,8 +11025,18 @@ function authPageResponse(body, status = 200) {
|
|
|
10377
11025
|
}
|
|
10378
11026
|
});
|
|
10379
11027
|
}
|
|
10380
|
-
function signInFormResponse(context) {
|
|
10381
|
-
return
|
|
11028
|
+
async function signInFormResponse(options, context) {
|
|
11029
|
+
return await customAuthExperienceResponse(options.authExperience, {
|
|
11030
|
+
audience: context.audience,
|
|
11031
|
+
state: { kind: "signIn" },
|
|
11032
|
+
signInUrl: authExperienceSignInUrl(context),
|
|
11033
|
+
submission: {
|
|
11034
|
+
kind: "requestMagicLink",
|
|
11035
|
+
action: "/auth/sign-in",
|
|
11036
|
+
fields: { audience: context.audience, returnTo: context.returnTo }
|
|
11037
|
+
},
|
|
11038
|
+
referrerPolicy: "same-origin"
|
|
11039
|
+
}) ?? authPageResponse([
|
|
10382
11040
|
"<h1>Sign in</h1>",
|
|
10383
11041
|
"<p>We'll email you a sign-in link.</p>",
|
|
10384
11042
|
'<form method="post" action="/auth/sign-in">',
|
|
@@ -10389,13 +11047,80 @@ function signInFormResponse(context) {
|
|
|
10389
11047
|
"</form>"
|
|
10390
11048
|
].join(""));
|
|
10391
11049
|
}
|
|
10392
|
-
function
|
|
11050
|
+
async function magicLinkRequestedResponse(options, context) {
|
|
11051
|
+
return await customAuthExperienceResponse(options.authExperience, {
|
|
11052
|
+
audience: context.audience,
|
|
11053
|
+
state: { kind: "checkEmail" },
|
|
11054
|
+
signInUrl: authExperienceSignInUrl(context)
|
|
11055
|
+
}) ?? htmlMessageResponse("If this email can sign in, we sent a link. Check your inbox to continue.", 200, "Check your email");
|
|
11056
|
+
}
|
|
11057
|
+
async function invalidMagicLinkResponse(options, context) {
|
|
11058
|
+
if (context) {
|
|
11059
|
+
const custom = await customAuthExperienceResponse(options.authExperience, {
|
|
11060
|
+
audience: context.audience,
|
|
11061
|
+
state: { kind: "invalidLink" },
|
|
11062
|
+
signInUrl: authExperienceSignInUrl(context),
|
|
11063
|
+
status: 400
|
|
11064
|
+
});
|
|
11065
|
+
if (custom)
|
|
11066
|
+
return custom;
|
|
11067
|
+
}
|
|
11068
|
+
return htmlMessageResponse("This sign-in link is invalid or expired.", 400);
|
|
11069
|
+
}
|
|
11070
|
+
async function authExperienceErrorResponse(options, context) {
|
|
11071
|
+
if (context) {
|
|
11072
|
+
const custom = await customAuthExperienceResponse(options.authExperience, {
|
|
11073
|
+
audience: context.audience,
|
|
11074
|
+
state: { kind: "error" },
|
|
11075
|
+
signInUrl: authExperienceSignInUrl(context),
|
|
11076
|
+
status: 500
|
|
11077
|
+
});
|
|
11078
|
+
if (custom)
|
|
11079
|
+
return custom;
|
|
11080
|
+
}
|
|
11081
|
+
return await invalidMagicLinkResponse(options, undefined);
|
|
11082
|
+
}
|
|
11083
|
+
function authExperienceSignInUrl(context) {
|
|
11084
|
+
const params = new URLSearchParams({ audience: context.audience, returnTo: context.returnTo });
|
|
11085
|
+
return `/auth/sign-in?${params.toString()}`;
|
|
11086
|
+
}
|
|
11087
|
+
function resolveAuthExperienceRedirectHint(options, request, audience) {
|
|
11088
|
+
if (audience !== "app" && audience !== "atlas") {
|
|
11089
|
+
return;
|
|
11090
|
+
}
|
|
11091
|
+
const context = resolveInvitationDeliveryContext(options, request, { destinationId: audience });
|
|
11092
|
+
return context instanceof Response ? undefined : context;
|
|
11093
|
+
}
|
|
11094
|
+
async function magicLinkConfirmResponse(options, input) {
|
|
11095
|
+
if (input.authRedirect) {
|
|
11096
|
+
const custom = await customAuthExperienceResponse(options.authExperience, {
|
|
11097
|
+
audience: input.authRedirect.audience,
|
|
11098
|
+
state: { kind: "confirm", ...input.email ? { email: input.email } : {} },
|
|
11099
|
+
signInUrl: authExperienceSignInUrl(input.authRedirect),
|
|
11100
|
+
submission: {
|
|
11101
|
+
kind: "confirmSignIn",
|
|
11102
|
+
action: "/auth/callback",
|
|
11103
|
+
fields: {
|
|
11104
|
+
magicLinkId: input.magicLinkId,
|
|
11105
|
+
token: input.token,
|
|
11106
|
+
audience: input.authRedirect.audience
|
|
11107
|
+
}
|
|
11108
|
+
},
|
|
11109
|
+
referrerPolicy: "same-origin",
|
|
11110
|
+
formActionOrigins: [new URL(input.authRedirect.returnTo).origin]
|
|
11111
|
+
});
|
|
11112
|
+
if (custom)
|
|
11113
|
+
return custom;
|
|
11114
|
+
}
|
|
10393
11115
|
const response = authPageResponse([
|
|
10394
11116
|
"<h1>Sign in</h1>",
|
|
10395
11117
|
input.email ? `<p>You're signing in as <strong>${escapeHtml(input.email)}</strong>.</p>` : "<p>Click continue to finish signing in.</p>",
|
|
10396
11118
|
'<form method="post" action="/auth/callback" id="confirm">',
|
|
10397
11119
|
`<input type="hidden" name="magicLinkId" value="${escapeHtml(input.magicLinkId)}">`,
|
|
10398
11120
|
`<input type="hidden" name="token" value="${escapeHtml(input.token)}">`,
|
|
11121
|
+
...input.authRedirect ? [
|
|
11122
|
+
`<input type="hidden" name="audience" value="${escapeHtml(input.authRedirect.audience)}">`
|
|
11123
|
+
] : [],
|
|
10399
11124
|
'<button type="submit" id="confirm-button">Continue</button>',
|
|
10400
11125
|
"</form>",
|
|
10401
11126
|
"<script>",
|
|
@@ -10876,7 +11601,7 @@ import {
|
|
|
10876
11601
|
isAgentRunActivityEvent
|
|
10877
11602
|
} from "@sixb/core/agents/streams";
|
|
10878
11603
|
import { BrokerCursorExpiredError } from "@sixb/core/broker";
|
|
10879
|
-
import { z as
|
|
11604
|
+
import { z as z30 } from "zod";
|
|
10880
11605
|
|
|
10881
11606
|
// src/utils/ws.ts
|
|
10882
11607
|
function safeSend(target, payload) {
|
|
@@ -10924,25 +11649,25 @@ async function decodeWsMessage(message) {
|
|
|
10924
11649
|
}
|
|
10925
11650
|
|
|
10926
11651
|
// src/routes/ws/agents.ts
|
|
10927
|
-
var SubscribeSchema =
|
|
10928
|
-
type:
|
|
10929
|
-
runId:
|
|
10930
|
-
afterCursor:
|
|
11652
|
+
var SubscribeSchema = z30.object({
|
|
11653
|
+
type: z30.literal("subscribe"),
|
|
11654
|
+
runId: z30.string().min(1),
|
|
11655
|
+
afterCursor: z30.string().min(1).optional()
|
|
10931
11656
|
});
|
|
10932
|
-
var SubscribeActivitySchema =
|
|
10933
|
-
type:
|
|
11657
|
+
var SubscribeActivitySchema = z30.object({
|
|
11658
|
+
type: z30.literal("subscribe.activity")
|
|
10934
11659
|
});
|
|
10935
|
-
var ReplaySchema =
|
|
10936
|
-
type:
|
|
10937
|
-
runId:
|
|
10938
|
-
afterCursor:
|
|
10939
|
-
limit:
|
|
11660
|
+
var ReplaySchema = z30.object({
|
|
11661
|
+
type: z30.literal("replay"),
|
|
11662
|
+
runId: z30.string().min(1),
|
|
11663
|
+
afterCursor: z30.string().min(1).optional(),
|
|
11664
|
+
limit: z30.number().int().positive().max(500).optional()
|
|
10940
11665
|
});
|
|
10941
|
-
var UnsubscribeSchema =
|
|
10942
|
-
type:
|
|
10943
|
-
runId:
|
|
11666
|
+
var UnsubscribeSchema = z30.object({
|
|
11667
|
+
type: z30.literal("unsubscribe"),
|
|
11668
|
+
runId: z30.string().min(1).optional()
|
|
10944
11669
|
});
|
|
10945
|
-
var AgentStreamMessageSchema =
|
|
11670
|
+
var AgentStreamMessageSchema = z30.union([
|
|
10946
11671
|
SubscribeSchema,
|
|
10947
11672
|
SubscribeActivitySchema,
|
|
10948
11673
|
ReplaySchema,
|
|
@@ -11228,22 +11953,22 @@ function errorMessage(error) {
|
|
|
11228
11953
|
|
|
11229
11954
|
// src/routes/ws/events.ts
|
|
11230
11955
|
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 =
|
|
11956
|
+
import { z as z31 } from "zod";
|
|
11957
|
+
var SubscribeSchema2 = z31.object({
|
|
11958
|
+
type: z31.literal("subscribe"),
|
|
11959
|
+
topic: z31.enum(EVENT_TOPICS).optional(),
|
|
11960
|
+
types: z31.array(z31.enum(EVENT_TYPES)).optional(),
|
|
11961
|
+
objectTypeId: z31.string().optional(),
|
|
11962
|
+
primaryId: z31.string().optional(),
|
|
11963
|
+
actionId: z31.string().optional(),
|
|
11964
|
+
runId: z31.string().optional(),
|
|
11965
|
+
afterCursor: z31.string().optional(),
|
|
11966
|
+
limit: z31.number().int().positive().max(500).optional()
|
|
11967
|
+
});
|
|
11968
|
+
var UnsubscribeSchema2 = z31.object({
|
|
11969
|
+
type: z31.literal("unsubscribe")
|
|
11970
|
+
});
|
|
11971
|
+
var SubscriptionMessageSchema = z31.union([SubscribeSchema2, UnsubscribeSchema2]);
|
|
11247
11972
|
function parseSubscriptionMessage(payload) {
|
|
11248
11973
|
if (!payload || typeof payload !== "object") {
|
|
11249
11974
|
return { ok: false, error: "Message must be a JSON object." };
|
|
@@ -11433,7 +12158,7 @@ function eventMatchesScope(event, filter) {
|
|
|
11433
12158
|
}
|
|
11434
12159
|
|
|
11435
12160
|
// src/routes/ws/logs.ts
|
|
11436
|
-
import { z as
|
|
12161
|
+
import { z as z32 } from "zod";
|
|
11437
12162
|
|
|
11438
12163
|
// src/routes/ws/log-subscription-hub.ts
|
|
11439
12164
|
import { BrokerCursorExpiredError as BrokerCursorExpiredError2 } from "@sixb/core/broker";
|
|
@@ -11683,13 +12408,13 @@ class LogSubscriptionHub {
|
|
|
11683
12408
|
this.scheduleFlush(state);
|
|
11684
12409
|
}
|
|
11685
12410
|
waitForQueueProgress(state) {
|
|
11686
|
-
return new Promise((
|
|
12411
|
+
return new Promise((resolve2) => state.queueProgressWaiters.add(resolve2));
|
|
11687
12412
|
}
|
|
11688
12413
|
notifyQueueProgress(state) {
|
|
11689
12414
|
const waiters = [...state.queueProgressWaiters];
|
|
11690
12415
|
state.queueProgressWaiters.clear();
|
|
11691
|
-
for (const
|
|
11692
|
-
|
|
12416
|
+
for (const resolve2 of waiters)
|
|
12417
|
+
resolve2();
|
|
11693
12418
|
}
|
|
11694
12419
|
send(state, payload) {
|
|
11695
12420
|
if (state.closed)
|
|
@@ -11746,26 +12471,26 @@ function socketBufferedAmount(ws) {
|
|
|
11746
12471
|
}
|
|
11747
12472
|
|
|
11748
12473
|
// src/routes/ws/logs.ts
|
|
11749
|
-
var SubscribeSchema3 =
|
|
11750
|
-
type:
|
|
11751
|
-
kinds:
|
|
11752
|
-
levels:
|
|
11753
|
-
run:
|
|
11754
|
-
kind:
|
|
12474
|
+
var SubscribeSchema3 = z32.object({
|
|
12475
|
+
type: z32.literal("subscribe"),
|
|
12476
|
+
kinds: z32.array(z32.enum(SIXB_RUN_KINDS)).min(1).optional(),
|
|
12477
|
+
levels: z32.array(z32.enum(LOG_LEVELS)).min(1).optional(),
|
|
12478
|
+
run: z32.object({
|
|
12479
|
+
kind: z32.enum(SIXB_RUN_KINDS),
|
|
11755
12480
|
id: LogRunIdSchema
|
|
11756
12481
|
}).optional(),
|
|
11757
|
-
afterCursor:
|
|
12482
|
+
afterCursor: z32.string().optional()
|
|
11758
12483
|
}).superRefine((value, context) => {
|
|
11759
12484
|
if (value.run && value.kinds && !value.kinds.includes(value.run.kind)) {
|
|
11760
12485
|
context.addIssue({
|
|
11761
|
-
code:
|
|
12486
|
+
code: z32.ZodIssueCode.custom,
|
|
11762
12487
|
path: ["run"],
|
|
11763
12488
|
message: "run.kind must be included in kinds"
|
|
11764
12489
|
});
|
|
11765
12490
|
}
|
|
11766
12491
|
});
|
|
11767
|
-
var UnsubscribeSchema3 =
|
|
11768
|
-
var SubscriptionMessageSchema2 =
|
|
12492
|
+
var UnsubscribeSchema3 = z32.object({ type: z32.literal("unsubscribe") });
|
|
12493
|
+
var SubscriptionMessageSchema2 = z32.union([SubscribeSchema3, UnsubscribeSchema3]);
|
|
11769
12494
|
function parseLogSubscriptionMessage(payload) {
|
|
11770
12495
|
if (!payload || typeof payload !== "object") {
|
|
11771
12496
|
return { ok: false, error: "Message must be a JSON object." };
|
|
@@ -11866,6 +12591,7 @@ class SixbServer {
|
|
|
11866
12591
|
apiBrowserPolicy;
|
|
11867
12592
|
authContextResolver;
|
|
11868
12593
|
authRedirectContextResolver;
|
|
12594
|
+
authExperience;
|
|
11869
12595
|
app = null;
|
|
11870
12596
|
bunServer = null;
|
|
11871
12597
|
maintenance = null;
|
|
@@ -11877,6 +12603,7 @@ class SixbServer {
|
|
|
11877
12603
|
this.apiBrowserPolicy = resolveApiBrowserPolicy(options.browser);
|
|
11878
12604
|
this.authContextResolver = createApiBrowserAuthContextResolver(this.apiBrowserPolicy);
|
|
11879
12605
|
this.authRedirectContextResolver = createApiBrowserAuthRedirectContextResolver(this.apiBrowserPolicy);
|
|
12606
|
+
this.authExperience = options.authExperience;
|
|
11880
12607
|
}
|
|
11881
12608
|
getHost() {
|
|
11882
12609
|
return this.hostRuntime;
|
|
@@ -11902,6 +12629,9 @@ class SixbServer {
|
|
|
11902
12629
|
getApiBrowserPolicy() {
|
|
11903
12630
|
return this.apiBrowserPolicy;
|
|
11904
12631
|
}
|
|
12632
|
+
getAuthExperience() {
|
|
12633
|
+
return this.authExperience;
|
|
12634
|
+
}
|
|
11905
12635
|
async start() {
|
|
11906
12636
|
if (this.app !== null || this.bunServer !== null || this.maintenance !== null) {
|
|
11907
12637
|
throw new Error("[SixbServer] Server is already running.");
|
|
@@ -12051,6 +12781,7 @@ function createSixbApi(server) {
|
|
|
12051
12781
|
resolveAuthRedirectContext: (request, input) => server.resolveAuthRedirectContext(request, input),
|
|
12052
12782
|
getInvitationDestinationOptions: (request) => server.getInvitationDestinationOptions(request),
|
|
12053
12783
|
resolveAuthRequestOrigin: (request) => server.resolveAuthRequestOrigin(request),
|
|
12784
|
+
authExperience: server.getAuthExperience(),
|
|
12054
12785
|
resolveInvitationRedirectContext: (request, input) => server.resolveInvitationRedirectContext(request, input)
|
|
12055
12786
|
});
|
|
12056
12787
|
registerHttpRoutes(app, host, {
|
|
@@ -12142,4 +12873,4 @@ export {
|
|
|
12142
12873
|
SixbServer
|
|
12143
12874
|
};
|
|
12144
12875
|
|
|
12145
|
-
//# debugId=
|
|
12876
|
+
//# debugId=7EBA739DF50836F764756E2164756E21
|