@gencow/core 0.1.27 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-config.d.ts +92 -5
- package/dist/config.d.ts +107 -0
- package/dist/config.js +12 -0
- package/dist/context.d.ts +139 -0
- package/dist/context.js +3 -0
- package/dist/crud.d.ts +5 -5
- package/dist/crud.js +19 -35
- package/dist/document-types.d.ts +65 -0
- package/dist/document-types.js +15 -0
- package/dist/grounded-answer-types.d.ts +62 -0
- package/dist/grounded-answer-types.js +6 -0
- package/dist/http-action.d.ts +77 -0
- package/dist/http-action.js +41 -0
- package/dist/index.d.ts +30 -5
- package/dist/index.js +15 -2
- package/dist/platform-capacity-profile.d.ts +19 -0
- package/dist/platform-capacity-profile.js +94 -0
- package/dist/procedure.d.ts +58 -0
- package/dist/procedure.js +115 -0
- package/dist/rag-ingest-types.d.ts +39 -0
- package/dist/rag-ingest-types.js +1 -0
- package/dist/rag-operations-types.d.ts +81 -0
- package/dist/rag-operations-types.js +1 -0
- package/dist/rag-schema.d.ts +1466 -0
- package/dist/rag-schema.js +87 -0
- package/dist/reactive-mutation-types.d.ts +11 -0
- package/dist/reactive-mutation-types.js +1 -0
- package/dist/reactive-mutation.d.ts +51 -0
- package/dist/reactive-mutation.js +75 -0
- package/dist/reactive-query-types.d.ts +12 -0
- package/dist/reactive-query-types.js +1 -0
- package/dist/reactive-query.d.ts +14 -0
- package/dist/reactive-query.js +28 -0
- package/dist/reactive-realtime.d.ts +48 -0
- package/dist/reactive-realtime.js +236 -0
- package/dist/reactive.d.ts +29 -5
- package/dist/reactive.js +65 -0
- package/dist/rls-db.d.ts +9 -2
- package/dist/runtime-env-policy.d.ts +5 -0
- package/dist/runtime-env-policy.js +56 -0
- package/dist/search-types.d.ts +83 -0
- package/dist/search-types.js +1 -0
- package/dist/server.d.ts +1 -2
- package/dist/server.js +0 -1
- package/dist/storage-metering.d.ts +13 -0
- package/dist/storage-metering.js +18 -0
- package/dist/storage-shared.d.ts +36 -0
- package/dist/storage-shared.js +39 -0
- package/dist/storage.d.ts +5 -27
- package/dist/storage.js +30 -22
- package/dist/wake-app-result.d.ts +22 -0
- package/dist/wake-app-result.js +11 -0
- package/dist/workflow-types.d.ts +16 -2
- package/dist/workflow.d.ts +1 -1
- package/dist/workflow.js +136 -11
- package/dist/workflows-api.js +71 -3
- package/package.json +11 -7
- package/src/auth-config.ts +104 -3
- package/src/config.ts +119 -0
- package/src/context.ts +152 -0
- package/src/crud.ts +18 -35
- package/src/document-types.ts +102 -0
- package/src/grounded-answer-types.ts +78 -0
- package/src/http-action.ts +101 -0
- package/src/index.ts +142 -19
- package/src/platform-capacity-profile.ts +114 -0
- package/src/procedure.ts +283 -0
- package/src/rag-ingest-types.ts +52 -0
- package/src/rag-operations-types.ts +90 -0
- package/src/rag-schema.ts +94 -0
- package/src/reactive-mutation-types.ts +13 -0
- package/src/reactive-mutation.ts +115 -0
- package/src/reactive-query-types.ts +14 -0
- package/src/reactive-query.ts +48 -0
- package/src/reactive-realtime.ts +267 -0
- package/src/rls-db.ts +9 -4
- package/src/runtime-env-policy.ts +66 -0
- package/src/search-types.ts +91 -0
- package/src/server.ts +6 -2
- package/src/storage-metering.ts +35 -0
- package/src/storage-shared.ts +74 -0
- package/src/storage.ts +44 -53
- package/src/wake-app-result.ts +37 -0
- package/src/workflow-types.ts +16 -2
- package/src/workflow.ts +166 -12
- package/src/workflows-api.ts +82 -3
- package/src/__tests__/auth.test.ts +0 -118
- package/src/__tests__/crons.test.ts +0 -83
- package/src/__tests__/crud-codegen-integration.test.ts +0 -246
- package/src/__tests__/crud-owner-rls.test.ts +0 -387
- package/src/__tests__/crud.test.ts +0 -930
- package/src/__tests__/dist-exports.test.ts +0 -176
- package/src/__tests__/fixtures/basic/auth.ts +0 -32
- package/src/__tests__/fixtures/basic/drizzle.config.ts +0 -12
- package/src/__tests__/fixtures/basic/index.ts +0 -6
- package/src/__tests__/fixtures/basic/migrations/0000_last_warstar.sql +0 -75
- package/src/__tests__/fixtures/basic/migrations/meta/0000_snapshot.json +0 -497
- package/src/__tests__/fixtures/basic/migrations/meta/_journal.json +0 -13
- package/src/__tests__/fixtures/basic/schema.ts +0 -51
- package/src/__tests__/fixtures/basic/tasks.ts +0 -15
- package/src/__tests__/fixtures/common/auth-schema.ts +0 -67
- package/src/__tests__/helpers/basic-rls-fixture.ts +0 -135
- package/src/__tests__/helpers/pglite-migrations.ts +0 -32
- package/src/__tests__/helpers/pglite-rls-session.ts +0 -51
- package/src/__tests__/helpers/seed-like-fill.ts +0 -202
- package/src/__tests__/helpers/test-gencow-ctx-rls.ts +0 -50
- package/src/__tests__/httpaction.test.ts +0 -122
- package/src/__tests__/image-optimization.test.ts +0 -648
- package/src/__tests__/load.test.ts +0 -389
- package/src/__tests__/network-sim.test.ts +0 -319
- package/src/__tests__/reactive.test.ts +0 -479
- package/src/__tests__/retry.test.ts +0 -113
- package/src/__tests__/rls-crud-basic.test.ts +0 -317
- package/src/__tests__/rls-crud-no-owner-rls-pglite.test.ts +0 -117
- package/src/__tests__/rls-custom-mutation-handlers.test.ts +0 -142
- package/src/__tests__/rls-custom-query-handlers.test.ts +0 -128
- package/src/__tests__/rls-db-leased-connection.test.ts +0 -118
- package/src/__tests__/rls-session-and-policies.test.ts +0 -228
- package/src/__tests__/scheduler-durable-v2.test.ts +0 -288
- package/src/__tests__/scheduler-durable.test.ts +0 -173
- package/src/__tests__/scheduler-exec.test.ts +0 -328
- package/src/__tests__/scheduler.test.ts +0 -187
- package/src/__tests__/storage.test.ts +0 -334
- package/src/__tests__/tsconfig.json +0 -8
- package/src/__tests__/validator.test.ts +0 -323
- package/src/__tests__/workflow.test.ts +0 -606
- package/src/__tests__/ws-integration.test.ts +0 -309
- package/src/__tests__/ws-scale.test.ts +0 -241
- package/src/auth.ts +0 -155
- package/src/reactive.ts +0 -580
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { GencowCtx } from "./context.js";
|
|
2
|
+
/** httpAction 핸들러 — Hono 대신 Request/Response 타입으로 full HTTP 제어. */
|
|
3
|
+
export type HttpActionHandler = (ctx: GencowCtx, req: HttpActionRequest) => Promise<HttpActionResponse>;
|
|
4
|
+
export interface HttpActionRequest {
|
|
5
|
+
/** HTTP method (GET, POST, PUT, DELETE, PATCH) */
|
|
6
|
+
method: string;
|
|
7
|
+
/** Full URL */
|
|
8
|
+
url: string;
|
|
9
|
+
/** URL path (e.g. /api/cli/auth-start) */
|
|
10
|
+
path: string;
|
|
11
|
+
/** Route params (e.g. { id: "abc" } for /api/apps/:id) */
|
|
12
|
+
params: Record<string, string>;
|
|
13
|
+
/** Query string params */
|
|
14
|
+
query: Record<string, string>;
|
|
15
|
+
/** Request headers */
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
/** Parse JSON body */
|
|
18
|
+
json: <T = unknown>() => Promise<T>;
|
|
19
|
+
/** Parse form data */
|
|
20
|
+
formData: () => Promise<FormData>;
|
|
21
|
+
/** Raw body as ArrayBuffer */
|
|
22
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
23
|
+
/** Raw body as text */
|
|
24
|
+
text: () => Promise<string>;
|
|
25
|
+
}
|
|
26
|
+
export interface HttpActionResponse {
|
|
27
|
+
status?: number;
|
|
28
|
+
headers?: Record<string, string>;
|
|
29
|
+
body?: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** httpAction 정의. 커스텀 HTTP 엔드포인트를 선언적으로 등록. */
|
|
32
|
+
export interface HttpActionDef {
|
|
33
|
+
/** HTTP method */
|
|
34
|
+
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
35
|
+
/** URL path (Hono 패턴 — /api/cli/:code 형태 지원) */
|
|
36
|
+
path: string;
|
|
37
|
+
/** true = 인증 없이 접근 가능, false(기본) = auth 필수 */
|
|
38
|
+
isPublic: boolean;
|
|
39
|
+
/** 핸들러 */
|
|
40
|
+
handler: HttpActionHandler;
|
|
41
|
+
}
|
|
42
|
+
declare global {
|
|
43
|
+
var __gencow_httpActionRegistry: HttpActionDef[];
|
|
44
|
+
}
|
|
45
|
+
export declare const httpActionRegistry: HttpActionDef[];
|
|
46
|
+
/**
|
|
47
|
+
* 커스텀 HTTP 엔드포인트를 선언적으로 등록합니다.
|
|
48
|
+
* query/mutation은 RPC 패턴이지만, httpAction은 RESTful HTTP 라우트를 직접 정의합니다.
|
|
49
|
+
*
|
|
50
|
+
* 사용 사례:
|
|
51
|
+
* - CLI Device Auth (POST /api/cli/auth-start)
|
|
52
|
+
* - 파일 업로드 (POST /api/apps/:id/deploy)
|
|
53
|
+
* - Webhook 수신
|
|
54
|
+
* - 외부 서비스 콜백
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { httpAction } from "@gencow/core";
|
|
59
|
+
*
|
|
60
|
+
* export const authStart = httpAction({
|
|
61
|
+
* method: "POST",
|
|
62
|
+
* path: "/api/cli/auth-start",
|
|
63
|
+
* public: true,
|
|
64
|
+
* handler: async (ctx, req) => {
|
|
65
|
+
* const code = crypto.randomUUID().slice(0, 8);
|
|
66
|
+
* return { body: { code, url: `https://gencow.com/cli-auth?code=${code}` } };
|
|
67
|
+
* },
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function httpAction(def: {
|
|
72
|
+
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
73
|
+
path: string;
|
|
74
|
+
public?: boolean;
|
|
75
|
+
handler: HttpActionHandler;
|
|
76
|
+
}): HttpActionDef;
|
|
77
|
+
export declare function getRegisteredHttpActions(): HttpActionDef[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
if (!globalThis.__gencow_httpActionRegistry)
|
|
2
|
+
globalThis.__gencow_httpActionRegistry = [];
|
|
3
|
+
export const httpActionRegistry = globalThis.__gencow_httpActionRegistry;
|
|
4
|
+
/**
|
|
5
|
+
* 커스텀 HTTP 엔드포인트를 선언적으로 등록합니다.
|
|
6
|
+
* query/mutation은 RPC 패턴이지만, httpAction은 RESTful HTTP 라우트를 직접 정의합니다.
|
|
7
|
+
*
|
|
8
|
+
* 사용 사례:
|
|
9
|
+
* - CLI Device Auth (POST /api/cli/auth-start)
|
|
10
|
+
* - 파일 업로드 (POST /api/apps/:id/deploy)
|
|
11
|
+
* - Webhook 수신
|
|
12
|
+
* - 외부 서비스 콜백
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { httpAction } from "@gencow/core";
|
|
17
|
+
*
|
|
18
|
+
* export const authStart = httpAction({
|
|
19
|
+
* method: "POST",
|
|
20
|
+
* path: "/api/cli/auth-start",
|
|
21
|
+
* public: true,
|
|
22
|
+
* handler: async (ctx, req) => {
|
|
23
|
+
* const code = crypto.randomUUID().slice(0, 8);
|
|
24
|
+
* return { body: { code, url: `https://gencow.com/cli-auth?code=${code}` } };
|
|
25
|
+
* },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function httpAction(def) {
|
|
30
|
+
const actionDef = {
|
|
31
|
+
method: def.method,
|
|
32
|
+
path: def.path,
|
|
33
|
+
isPublic: def.public === true,
|
|
34
|
+
handler: def.handler,
|
|
35
|
+
};
|
|
36
|
+
httpActionRegistry.push(actionDef);
|
|
37
|
+
return actionDef;
|
|
38
|
+
}
|
|
39
|
+
export function getRegisteredHttpActions() {
|
|
40
|
+
return [...httpActionRegistry];
|
|
41
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,31 @@
|
|
|
4
4
|
* Provides: query, mutation, storage, scheduler, auth
|
|
5
5
|
* All with Convex-compatible DX patterns.
|
|
6
6
|
*/
|
|
7
|
-
export type { GencowCtx, AuthCtx, UserIdentity,
|
|
8
|
-
export {
|
|
9
|
-
export type {
|
|
7
|
+
export type { GencowCtx, AuthCtx, UserIdentity, RealtimeCtx, RealtimeNotifyEvent, AIContext, AIMessage, AIResult, } from "./context.js";
|
|
8
|
+
export { defineApi } from "./context.js";
|
|
9
|
+
export type { QueryDef } from "./reactive-query-types.js";
|
|
10
|
+
export type { MutationDef } from "./reactive-mutation-types.js";
|
|
11
|
+
export type { HttpActionDef, HttpActionRequest, HttpActionResponse, HttpActionHandler, } from "./http-action.js";
|
|
12
|
+
export type { SearchPrimitive, SearchScope, SearchFilter, SearchOptions, VectorSearchOptions, HybridSearchOptions, SearchHit, SearchResponse, SearchTierConfig, } from "./search-types.js";
|
|
13
|
+
export type { DocumentVisibility, DocumentConvertMode, DocumentConvertProvider, DocumentResolvedProvider, DocumentConvertInput, DocumentPage, DocumentSection, DocumentProviderTrace, DocumentConvertResult, DocumentCacheArtifact, DocumentCacheKeyInput, GencowServicesCtx, WorkflowDocumentServicesCtx, } from "./document-types.js";
|
|
14
|
+
export { buildDocumentCacheKey } from "./document-types.js";
|
|
15
|
+
export type { WakeAppBootFailedResult, WakeAppDeferredResult, WakeAppDeferredStatus, WakeAppResult, WakeAppSuccessResult, WakeAppSuccessStatus, } from "./wake-app-result.js";
|
|
16
|
+
export { DEFAULT_WAKE_RETRY_AFTER_SEC, buildWakeAppBootFailedResult, buildWakeAppSuccessResult, isWakeAppDeferredResult, } from "./wake-app-result.js";
|
|
17
|
+
export type { PlatformCapacityPreset, PlatformCapacityProfileName } from "./platform-capacity-profile.js";
|
|
18
|
+
export { PLATFORM_CAPACITY_ENV_KEYS, PLATFORM_CAPACITY_PRESETS, PLATFORM_CAPACITY_PROFILE_ENV, detectPlatformCapacityProfile, resolvePlatformCapacityPreset, } from "./platform-capacity-profile.js";
|
|
19
|
+
export type { RagIngestReindexMode, RagIngestInput, RagIngestWorkflowArgs, RagIngestStartResult, RagIngestJobStatus, RagIngestJobRecord, } from "./rag-ingest-types.js";
|
|
20
|
+
export type { CitationCoverage, ClaimSupportStatus, GroundedAnswerMode, Citation, ClaimEvidenceMap, GroundedAnswer, GroundingBudget, GroundedClaimInput, GroundedCompareInput, GroundedTopicInput, GroundedAnswerInput, GroundingRuntime, } from "./grounded-answer-types.js";
|
|
21
|
+
export { DEFAULT_GROUNDING_BUDGET } from "./grounded-answer-types.js";
|
|
22
|
+
export type { RagOperationKind, RagOperationMetricUnit, RagIndexHealth, RagOperationMetric, RagOperationsSummary, RagEvaluationExpectedClaim, RagEvaluationFixture, RagEvaluationFixtureResult, RagEvaluationRunResult, RagReindexMode, RagReindexPlan, } from "./rag-operations-types.js";
|
|
23
|
+
export { ragCorpora, ragSources, ragSections, ragChunks, ragIngestJobs, ragOperationMetrics, } from "./rag-schema.js";
|
|
24
|
+
export { buildQuerySubscriptionKey, subscriptionKeyMatchesQueryKey } from "./reactive-realtime.js";
|
|
25
|
+
export { query, getQueryHandler, getQueryDef, getRegisteredQueries } from "./reactive-query.js";
|
|
26
|
+
export { mutation, getRegisteredMutations } from "./reactive-mutation.js";
|
|
27
|
+
export { procQuery, procMutation } from "./procedure.js";
|
|
28
|
+
export type { GencowProcedureBuilder, GencowProcedureDef, GencowProcedureMiddleware, GencowProcedureHandler, } from "./procedure.js";
|
|
29
|
+
export { httpAction, getRegisteredHttpActions } from "./http-action.js";
|
|
30
|
+
export { subscribe, unsubscribe, registerClient, deregisterClient, buildRealtimeCtx, handleWsMessage, } from "./reactive-realtime.js";
|
|
31
|
+
export type { Storage, StoredFile } from "./storage.js";
|
|
10
32
|
export { createScheduler, getSchedulerInfo } from "./scheduler.js";
|
|
11
33
|
export type { Scheduler, ScheduleOptions, FailedJob, CreateSchedulerOptions, ScheduledJobRecord, } from "./scheduler.js";
|
|
12
34
|
export { workflow, getWorkflowDef, getRegisteredWorkflows, getWorkflowResumeActionName, getWorkflowRealtimeKey, createWorkflowRealtimeToken, serializeWorkflowValue, deserializeWorkflowValue, parseWorkflowDurationMs, DEFAULT_WORKFLOW_MAX_DURATION_MS, DEFAULT_WORKFLOW_MAX_RETRIES, WORKFLOW_RESUME_ACTION_PREFIX, WORKFLOW_REALTIME_KEY_PREFIX, } from "./workflow.js";
|
|
@@ -17,14 +39,17 @@ export { v, parseArgs, GencowValidationError } from "./v.js";
|
|
|
17
39
|
export type { Validator, Infer, InferArgs } from "./v.js";
|
|
18
40
|
export { withRetry } from "./retry.js";
|
|
19
41
|
export type { RetryOptions } from "./retry.js";
|
|
42
|
+
export { filterTenantRuntimeEnvVars, isReservedTenantRuntimeEnvKey } from "./runtime-env-policy.js";
|
|
20
43
|
export { cronJobs } from "./crons.js";
|
|
21
44
|
export type { CronJobsBuilder, CronJobDef, IntervalOptions, DailyOptions, WeeklyOptions } from "./crons.js";
|
|
22
45
|
export { defineAuth } from "./auth-config.js";
|
|
23
|
-
export type { GencowAuthConfig, AuthEmailVerification } from "./auth-config.js";
|
|
46
|
+
export type { GencowAuthConfig, AuthEmailVerification, AuthPasswordReset, AuthEvents, AuthHookContext, AuthUserLike, AuthOAuthConfig, SocialProviderConfig, SocialProvidersConfig, KakaoConfig, NaverConfig, CustomOAuthProvider, OAuthUserInfo, } from "./auth-config.js";
|
|
47
|
+
export { defineConfig } from "./config.js";
|
|
48
|
+
export type { GencowConfig, GencowDbConfig, GencowDeployConfig } from "./config.js";
|
|
24
49
|
export { ownerRls, getOwnerRlsMeta, registerOwnerRls } from "./rls.js";
|
|
25
50
|
export type { OwnerRlsMeta } from "./rls.js";
|
|
26
51
|
export { createRlsDb } from "./rls-db.js";
|
|
27
52
|
export type { RlsSessionContext } from "./rls-db.js";
|
|
28
|
-
export { crud, parseFilterNode, applyFilterOp, getOwnerRlsTables, getRegisteredCrudCodegenMeta } from "./crud.js";
|
|
53
|
+
export { crud, parseFilterNode, applyFilterOp, getOwnerRlsTables, getRegisteredCrudCodegenMeta, } from "./crud.js";
|
|
29
54
|
export type { CrudCodegenMeta } from "./crud.js";
|
|
30
55
|
export { crud as gencowCrud } from "./crud.js";
|
package/dist/index.js
CHANGED
|
@@ -4,18 +4,31 @@
|
|
|
4
4
|
* Provides: query, mutation, storage, scheduler, auth
|
|
5
5
|
* All with Convex-compatible DX patterns.
|
|
6
6
|
*/
|
|
7
|
-
export {
|
|
7
|
+
export { defineApi } from "./context.js";
|
|
8
|
+
export { buildDocumentCacheKey } from "./document-types.js";
|
|
9
|
+
export { DEFAULT_WAKE_RETRY_AFTER_SEC, buildWakeAppBootFailedResult, buildWakeAppSuccessResult, isWakeAppDeferredResult, } from "./wake-app-result.js";
|
|
10
|
+
export { PLATFORM_CAPACITY_ENV_KEYS, PLATFORM_CAPACITY_PRESETS, PLATFORM_CAPACITY_PROFILE_ENV, detectPlatformCapacityProfile, resolvePlatformCapacityPreset, } from "./platform-capacity-profile.js";
|
|
11
|
+
export { DEFAULT_GROUNDING_BUDGET } from "./grounded-answer-types.js";
|
|
12
|
+
export { ragCorpora, ragSources, ragSections, ragChunks, ragIngestJobs, ragOperationMetrics, } from "./rag-schema.js";
|
|
13
|
+
export { buildQuerySubscriptionKey, subscriptionKeyMatchesQueryKey } from "./reactive-realtime.js";
|
|
14
|
+
export { query, getQueryHandler, getQueryDef, getRegisteredQueries } from "./reactive-query.js";
|
|
15
|
+
export { mutation, getRegisteredMutations } from "./reactive-mutation.js";
|
|
16
|
+
export { procQuery, procMutation } from "./procedure.js";
|
|
17
|
+
export { httpAction, getRegisteredHttpActions } from "./http-action.js";
|
|
18
|
+
export { subscribe, unsubscribe, registerClient, deregisterClient, buildRealtimeCtx, handleWsMessage, } from "./reactive-realtime.js";
|
|
8
19
|
export { createScheduler, getSchedulerInfo } from "./scheduler.js";
|
|
9
20
|
export { workflow, getWorkflowDef, getRegisteredWorkflows, getWorkflowResumeActionName, getWorkflowRealtimeKey, createWorkflowRealtimeToken, serializeWorkflowValue, deserializeWorkflowValue, parseWorkflowDurationMs, DEFAULT_WORKFLOW_MAX_DURATION_MS, DEFAULT_WORKFLOW_MAX_RETRIES, WORKFLOW_RESUME_ACTION_PREFIX, WORKFLOW_REALTIME_KEY_PREFIX, } from "./workflow.js";
|
|
10
21
|
export { deriveWorkflowStatus } from "./workflow-types.js";
|
|
11
22
|
export { loadWorkflowSnapshot } from "./workflows-api.js";
|
|
12
23
|
export { v, parseArgs, GencowValidationError } from "./v.js";
|
|
13
24
|
export { withRetry } from "./retry.js";
|
|
25
|
+
export { filterTenantRuntimeEnvVars, isReservedTenantRuntimeEnvKey } from "./runtime-env-policy.js";
|
|
14
26
|
export { cronJobs } from "./crons.js";
|
|
15
27
|
export { defineAuth } from "./auth-config.js";
|
|
28
|
+
export { defineConfig } from "./config.js";
|
|
16
29
|
// ─── RLS + CRUD Factory ───────────
|
|
17
30
|
export { ownerRls, getOwnerRlsMeta, registerOwnerRls } from "./rls.js";
|
|
18
31
|
export { createRlsDb } from "./rls-db.js";
|
|
19
|
-
export { crud, parseFilterNode, applyFilterOp, getOwnerRlsTables, getRegisteredCrudCodegenMeta } from "./crud.js";
|
|
32
|
+
export { crud, parseFilterNode, applyFilterOp, getOwnerRlsTables, getRegisteredCrudCodegenMeta, } from "./crud.js";
|
|
20
33
|
// Deprecated alias — 하위호환용, 향후 메이저 버전에서 제거 예정
|
|
21
34
|
export { crud as gencowCrud } from "./crud.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type PlatformCapacityProfileName = "prod" | "dev" | "local";
|
|
2
|
+
export interface PlatformCapacityPreset {
|
|
3
|
+
profile: PlatformCapacityProfileName;
|
|
4
|
+
maxConcurrentRunning: number | null;
|
|
5
|
+
maxConcurrentWake: number | null;
|
|
6
|
+
maxWakeQueueMs: number;
|
|
7
|
+
minAvailableRamMB: number | null;
|
|
8
|
+
evictionThresholdMB: number | null;
|
|
9
|
+
sleepTimeoutMinutes: number;
|
|
10
|
+
sleepMaxPerCycle: number;
|
|
11
|
+
warmPoolMinIdle: number;
|
|
12
|
+
warmPoolMax: number;
|
|
13
|
+
deployCandidateReserve: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const PLATFORM_CAPACITY_PROFILE_ENV = "GENCOW_CAPACITY_PROFILE";
|
|
16
|
+
export declare const PLATFORM_CAPACITY_ENV_KEYS: readonly ["GENCOW_CAPACITY_PROFILE", "MAX_CONCURRENT_RUNNING", "MAX_CONCURRENT_WAKE", "MAX_WAKE_QUEUE_MS", "MIN_AVAILABLE_RAM_MB", "WAKE_RETRY_AFTER_SEC", "EVICTION_THRESHOLD_MB", "GENCOW_SLEEP_TIMEOUT_MINUTES", "GENCOW_SLEEP_MAX_PER_CYCLE", "WARM_POOL_MIN_IDLE", "WARM_POOL_MAX", "DEPLOY_CANDIDATE_RESERVE", "GENCOW_APP_PORT_RANGE", "COWBOX_WARM_POOL_PORT_RANGE"];
|
|
17
|
+
export declare const PLATFORM_CAPACITY_PRESETS: Record<PlatformCapacityProfileName, PlatformCapacityPreset>;
|
|
18
|
+
export declare function detectPlatformCapacityProfile(env?: Record<string, string | undefined>): PlatformCapacityProfileName;
|
|
19
|
+
export declare function resolvePlatformCapacityPreset(env?: Record<string, string | undefined>): PlatformCapacityPreset;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export const PLATFORM_CAPACITY_PROFILE_ENV = "GENCOW_CAPACITY_PROFILE";
|
|
2
|
+
export const PLATFORM_CAPACITY_ENV_KEYS = [
|
|
3
|
+
PLATFORM_CAPACITY_PROFILE_ENV,
|
|
4
|
+
"MAX_CONCURRENT_RUNNING",
|
|
5
|
+
"MAX_CONCURRENT_WAKE",
|
|
6
|
+
"MAX_WAKE_QUEUE_MS",
|
|
7
|
+
"MIN_AVAILABLE_RAM_MB",
|
|
8
|
+
"WAKE_RETRY_AFTER_SEC",
|
|
9
|
+
"EVICTION_THRESHOLD_MB",
|
|
10
|
+
"GENCOW_SLEEP_TIMEOUT_MINUTES",
|
|
11
|
+
"GENCOW_SLEEP_MAX_PER_CYCLE",
|
|
12
|
+
"WARM_POOL_MIN_IDLE",
|
|
13
|
+
"WARM_POOL_MAX",
|
|
14
|
+
"DEPLOY_CANDIDATE_RESERVE",
|
|
15
|
+
"GENCOW_APP_PORT_RANGE",
|
|
16
|
+
"COWBOX_WARM_POOL_PORT_RANGE",
|
|
17
|
+
];
|
|
18
|
+
export const PLATFORM_CAPACITY_PRESETS = Object.freeze({
|
|
19
|
+
prod: Object.freeze({
|
|
20
|
+
profile: "prod",
|
|
21
|
+
maxConcurrentRunning: 600,
|
|
22
|
+
maxConcurrentWake: 20,
|
|
23
|
+
maxWakeQueueMs: 5000,
|
|
24
|
+
minAvailableRamMB: 8192,
|
|
25
|
+
evictionThresholdMB: 16384,
|
|
26
|
+
sleepTimeoutMinutes: 15,
|
|
27
|
+
sleepMaxPerCycle: 50,
|
|
28
|
+
warmPoolMinIdle: 10,
|
|
29
|
+
warmPoolMax: 650,
|
|
30
|
+
deployCandidateReserve: 40,
|
|
31
|
+
}),
|
|
32
|
+
dev: Object.freeze({
|
|
33
|
+
profile: "dev",
|
|
34
|
+
maxConcurrentRunning: 60,
|
|
35
|
+
maxConcurrentWake: 5,
|
|
36
|
+
maxWakeQueueMs: 3000,
|
|
37
|
+
minAvailableRamMB: 2048,
|
|
38
|
+
evictionThresholdMB: 4096,
|
|
39
|
+
sleepTimeoutMinutes: 10,
|
|
40
|
+
sleepMaxPerCycle: 20,
|
|
41
|
+
warmPoolMinIdle: 3,
|
|
42
|
+
warmPoolMax: 70,
|
|
43
|
+
deployCandidateReserve: 5,
|
|
44
|
+
}),
|
|
45
|
+
local: Object.freeze({
|
|
46
|
+
profile: "local",
|
|
47
|
+
maxConcurrentRunning: null,
|
|
48
|
+
maxConcurrentWake: null,
|
|
49
|
+
maxWakeQueueMs: 5000,
|
|
50
|
+
minAvailableRamMB: null,
|
|
51
|
+
evictionThresholdMB: null,
|
|
52
|
+
sleepTimeoutMinutes: 30,
|
|
53
|
+
sleepMaxPerCycle: 10,
|
|
54
|
+
warmPoolMinIdle: 3,
|
|
55
|
+
warmPoolMax: 10,
|
|
56
|
+
deployCandidateReserve: 0,
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
function normalizeDomain(value) {
|
|
60
|
+
return (value || "")
|
|
61
|
+
.trim()
|
|
62
|
+
.toLowerCase()
|
|
63
|
+
.replace(/^https?:\/\//, "")
|
|
64
|
+
.replace(/\/.*$/, "");
|
|
65
|
+
}
|
|
66
|
+
export function detectPlatformCapacityProfile(env = process.env) {
|
|
67
|
+
const explicit = env[PLATFORM_CAPACITY_PROFILE_ENV]?.trim().toLowerCase();
|
|
68
|
+
if (explicit) {
|
|
69
|
+
if (["prod", "production", "128gb"].includes(explicit))
|
|
70
|
+
return "prod";
|
|
71
|
+
if (["dev", "development", "16gb"].includes(explicit))
|
|
72
|
+
return "dev";
|
|
73
|
+
if (["local", "test", "disabled"].includes(explicit))
|
|
74
|
+
return "local";
|
|
75
|
+
throw new Error(`Invalid ${PLATFORM_CAPACITY_PROFILE_ENV}: ${explicit}. Expected prod, dev, or local.`);
|
|
76
|
+
}
|
|
77
|
+
const baseDomain = normalizeDomain(env.BASE_DOMAIN);
|
|
78
|
+
if (baseDomain === "gencow.dev")
|
|
79
|
+
return "dev";
|
|
80
|
+
if (baseDomain === "gencow.app")
|
|
81
|
+
return "prod";
|
|
82
|
+
const platformUrl = normalizeDomain(env.GENCOW_PLATFORM_URL);
|
|
83
|
+
if (platformUrl === "gencow.dev")
|
|
84
|
+
return "dev";
|
|
85
|
+
if (platformUrl === "gencow.app")
|
|
86
|
+
return "prod";
|
|
87
|
+
if (env.NODE_ENV === "production" && env.IS_PLATFORM === "true")
|
|
88
|
+
return "prod";
|
|
89
|
+
return "local";
|
|
90
|
+
}
|
|
91
|
+
export function resolvePlatformCapacityPreset(env = process.env) {
|
|
92
|
+
const profile = detectPlatformCapacityProfile(env);
|
|
93
|
+
return { ...PLATFORM_CAPACITY_PRESETS[profile] };
|
|
94
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
import type { GencowCtx } from "./context.js";
|
|
3
|
+
type InferInputSchema<TSchema> = TSchema extends {
|
|
4
|
+
"~standard": {
|
|
5
|
+
types: {
|
|
6
|
+
input: infer TInput;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
} ? TInput : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TSchema> : unknown;
|
|
10
|
+
type InferOutputSchema<TSchema> = TSchema extends {
|
|
11
|
+
"~standard": {
|
|
12
|
+
types: {
|
|
13
|
+
output: infer TOutput;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
} ? TOutput : TSchema extends {
|
|
17
|
+
_output: infer TOutput;
|
|
18
|
+
} ? TOutput : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : unknown;
|
|
19
|
+
type NextFn<TContext, TInput, TOutput> = (overrides?: {
|
|
20
|
+
context?: TContext;
|
|
21
|
+
input?: TInput;
|
|
22
|
+
}) => Promise<TOutput>;
|
|
23
|
+
export type GencowProcedureMiddleware<TContext, TInput, TOutput> = (options: {
|
|
24
|
+
context: TContext;
|
|
25
|
+
input: TInput;
|
|
26
|
+
next: NextFn<TContext, TInput, TOutput>;
|
|
27
|
+
}) => Promise<TOutput> | TOutput;
|
|
28
|
+
export type GencowProcedureHandler<TContext, TInput, TOutput> = (options: {
|
|
29
|
+
context: TContext;
|
|
30
|
+
input: TInput;
|
|
31
|
+
}) => Promise<TOutput> | TOutput;
|
|
32
|
+
export interface GencowProcedureDef<TKind extends "query" | "mutation" = "query" | "mutation", TContext = any, TInput = unknown, TOutput = unknown> {
|
|
33
|
+
kind: TKind;
|
|
34
|
+
name: string;
|
|
35
|
+
/** When false (default), RPC requires an authenticated user. */
|
|
36
|
+
isPublic: boolean;
|
|
37
|
+
middlewares: readonly GencowProcedureMiddleware<TContext, TInput, TOutput>[];
|
|
38
|
+
inputSchema?: StandardSchemaV1;
|
|
39
|
+
outputSchema?: StandardSchemaV1;
|
|
40
|
+
inputValidationIndex: number;
|
|
41
|
+
outputValidationIndex: number;
|
|
42
|
+
handler: (context: TContext, input: TInput) => Promise<TOutput>;
|
|
43
|
+
}
|
|
44
|
+
export interface GencowProcedureBuilder<TKind extends "query" | "mutation" = "query" | "mutation", TContext = any, TInput = unknown, TOutput = unknown> {
|
|
45
|
+
name(name: string): GencowProcedureBuilder<TKind, TContext, TInput, TOutput>;
|
|
46
|
+
/**
|
|
47
|
+
* Allow calling this procedure without authentication (like `query("x", { public: true, ... })`).
|
|
48
|
+
* Default is authenticated-only.
|
|
49
|
+
*/
|
|
50
|
+
allowPublic(): GencowProcedureBuilder<TKind, TContext, TInput, TOutput>;
|
|
51
|
+
use(middleware: GencowProcedureMiddleware<TContext, TInput, TOutput>): GencowProcedureBuilder<TKind, TContext, TInput, TOutput>;
|
|
52
|
+
input<TNextSchema extends StandardSchemaV1>(schema: TNextSchema): GencowProcedureBuilder<TKind, TContext, InferInputSchema<TNextSchema>, TOutput>;
|
|
53
|
+
output<TNextSchema extends StandardSchemaV1>(schema: TNextSchema): GencowProcedureBuilder<TKind, TContext, TInput, InferOutputSchema<TNextSchema>>;
|
|
54
|
+
handler(handler: GencowProcedureHandler<TContext, TInput, TOutput>): GencowProcedureDef<TKind, TContext, TInput, TOutput>;
|
|
55
|
+
}
|
|
56
|
+
export declare const procQuery: GencowProcedureBuilder<"query", GencowCtx>;
|
|
57
|
+
export declare const procMutation: GencowProcedureBuilder<"mutation", GencowCtx>;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
function hasStandardSchema(schema) {
|
|
2
|
+
return (!!schema &&
|
|
3
|
+
typeof schema === "object" &&
|
|
4
|
+
"~standard" in schema &&
|
|
5
|
+
!!schema["~standard"] &&
|
|
6
|
+
typeof schema["~standard"].validate === "function");
|
|
7
|
+
}
|
|
8
|
+
async function validateWithSchema(schema, value) {
|
|
9
|
+
if (!schema)
|
|
10
|
+
return value;
|
|
11
|
+
if (hasStandardSchema(schema)) {
|
|
12
|
+
const result = (await schema["~standard"].validate(value));
|
|
13
|
+
if ("issues" in result && result.issues.length > 0) {
|
|
14
|
+
throw new Error(result.issues[0]?.message ?? "Validation failed");
|
|
15
|
+
}
|
|
16
|
+
if ("value" in result) {
|
|
17
|
+
return result.value;
|
|
18
|
+
}
|
|
19
|
+
throw new Error("Validation failed");
|
|
20
|
+
}
|
|
21
|
+
throw new Error("procQuery/procMutation only supports Standard Schema v1 validators");
|
|
22
|
+
}
|
|
23
|
+
function composeMiddlewares(middlewares, handler, inputSchema, outputSchema, inputValidationIndex, outputValidationIndex) {
|
|
24
|
+
return async (initialContext, initialInput) => {
|
|
25
|
+
let idx = -1;
|
|
26
|
+
const boundedInputValidationIndex = Math.min(Math.max(0, inputValidationIndex), middlewares.length);
|
|
27
|
+
const boundedOutputValidationIndex = Math.min(Math.max(0, outputValidationIndex), middlewares.length);
|
|
28
|
+
const run = async (currentIdx, context, input) => {
|
|
29
|
+
if (currentIdx <= idx) {
|
|
30
|
+
throw new Error("next() called multiple times in the same middleware");
|
|
31
|
+
}
|
|
32
|
+
idx = currentIdx;
|
|
33
|
+
let currentInput = input;
|
|
34
|
+
if (currentIdx === boundedInputValidationIndex) {
|
|
35
|
+
currentInput = (await validateWithSchema(inputSchema, currentInput));
|
|
36
|
+
}
|
|
37
|
+
if (currentIdx === middlewares.length) {
|
|
38
|
+
const output = await handler({ context, input: currentInput });
|
|
39
|
+
if (currentIdx === boundedOutputValidationIndex) {
|
|
40
|
+
return await validateWithSchema(outputSchema, output);
|
|
41
|
+
}
|
|
42
|
+
return output;
|
|
43
|
+
}
|
|
44
|
+
const middleware = middlewares[currentIdx];
|
|
45
|
+
const output = await middleware({
|
|
46
|
+
context,
|
|
47
|
+
input: currentInput,
|
|
48
|
+
next: async (overrides) => {
|
|
49
|
+
return await run(currentIdx + 1, (overrides?.context ?? context), (overrides?.input ?? currentInput));
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
if (currentIdx === boundedOutputValidationIndex) {
|
|
53
|
+
return await validateWithSchema(outputSchema, output);
|
|
54
|
+
}
|
|
55
|
+
return output;
|
|
56
|
+
};
|
|
57
|
+
return await run(0, initialContext, initialInput);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
class GencowProcedureBuilderImpl {
|
|
61
|
+
kind;
|
|
62
|
+
procedureName;
|
|
63
|
+
middlewares;
|
|
64
|
+
inputSchema;
|
|
65
|
+
outputSchema;
|
|
66
|
+
inputValidationIndex;
|
|
67
|
+
outputValidationIndex;
|
|
68
|
+
isPublic;
|
|
69
|
+
constructor(kind, procedureName, middlewares = [], inputSchema, outputSchema, inputValidationIndex = -1, outputValidationIndex = -1, isPublic = false) {
|
|
70
|
+
this.kind = kind;
|
|
71
|
+
this.procedureName = procedureName;
|
|
72
|
+
this.middlewares = middlewares;
|
|
73
|
+
this.inputSchema = inputSchema;
|
|
74
|
+
this.outputSchema = outputSchema;
|
|
75
|
+
this.inputValidationIndex = inputValidationIndex;
|
|
76
|
+
this.outputValidationIndex = outputValidationIndex;
|
|
77
|
+
this.isPublic = isPublic;
|
|
78
|
+
}
|
|
79
|
+
name(name) {
|
|
80
|
+
return new GencowProcedureBuilderImpl(this.kind, name, this.middlewares, this.inputSchema, this.outputSchema, this.inputValidationIndex, this.outputValidationIndex, this.isPublic);
|
|
81
|
+
}
|
|
82
|
+
allowPublic() {
|
|
83
|
+
return new GencowProcedureBuilderImpl(this.kind, this.procedureName, this.middlewares, this.inputSchema, this.outputSchema, this.inputValidationIndex, this.outputValidationIndex, true);
|
|
84
|
+
}
|
|
85
|
+
use(middleware) {
|
|
86
|
+
return new GencowProcedureBuilderImpl(this.kind, this.procedureName, [...this.middlewares, middleware], this.inputSchema, this.outputSchema, this.inputValidationIndex, this.outputValidationIndex, this.isPublic);
|
|
87
|
+
}
|
|
88
|
+
input(schema) {
|
|
89
|
+
const nextInputValidationIndex = this.middlewares.length < 0 ? 0 : this.middlewares.length;
|
|
90
|
+
return new GencowProcedureBuilderImpl(this.kind, this.procedureName, this.middlewares, schema, this.outputSchema, nextInputValidationIndex, this.outputValidationIndex, this.isPublic);
|
|
91
|
+
}
|
|
92
|
+
output(schema) {
|
|
93
|
+
const nextOutputValidationIndex = this.middlewares.length < 0 ? 0 : this.middlewares.length;
|
|
94
|
+
return new GencowProcedureBuilderImpl(this.kind, this.procedureName, this.middlewares, this.inputSchema, schema, this.inputValidationIndex, nextOutputValidationIndex, this.isPublic);
|
|
95
|
+
}
|
|
96
|
+
handler(handler) {
|
|
97
|
+
if (!this.procedureName) {
|
|
98
|
+
throw new Error("Procedure name is required. Call .name(...) before .handler(...)");
|
|
99
|
+
}
|
|
100
|
+
const run = composeMiddlewares(this.middlewares, handler, this.inputSchema, this.outputSchema, this.inputValidationIndex, this.outputValidationIndex);
|
|
101
|
+
return {
|
|
102
|
+
kind: this.kind,
|
|
103
|
+
name: this.procedureName,
|
|
104
|
+
isPublic: this.isPublic,
|
|
105
|
+
middlewares: [...this.middlewares],
|
|
106
|
+
inputSchema: this.inputSchema,
|
|
107
|
+
outputSchema: this.outputSchema,
|
|
108
|
+
inputValidationIndex: this.inputValidationIndex,
|
|
109
|
+
outputValidationIndex: this.outputValidationIndex,
|
|
110
|
+
handler: run,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export const procQuery = new GencowProcedureBuilderImpl("query");
|
|
115
|
+
export const procMutation = new GencowProcedureBuilderImpl("mutation");
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DocumentConvertProvider, DocumentConvertMode, DocumentProviderTrace, DocumentVisibility } from "./document-types.js";
|
|
2
|
+
export type RagIngestReindexMode = "if_changed" | "force";
|
|
3
|
+
export type RagIngestJobStatus = "queued" | "converting" | "chunking" | "embedding" | "upserting" | "completed" | "failed" | "canceled";
|
|
4
|
+
export type RagIngestInput = {
|
|
5
|
+
storageId: string;
|
|
6
|
+
corpus: string;
|
|
7
|
+
visibility: DocumentVisibility;
|
|
8
|
+
ownerUserId?: string;
|
|
9
|
+
sourceKey?: string;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
reindexMode?: RagIngestReindexMode;
|
|
12
|
+
mode?: DocumentConvertMode;
|
|
13
|
+
provider?: DocumentConvertProvider;
|
|
14
|
+
};
|
|
15
|
+
export type RagIngestWorkflowArgs = RagIngestInput & {
|
|
16
|
+
jobId: string;
|
|
17
|
+
sourceId: string;
|
|
18
|
+
};
|
|
19
|
+
export type RagIngestStartResult = {
|
|
20
|
+
workflowId: string;
|
|
21
|
+
jobId: string;
|
|
22
|
+
sourceId: string;
|
|
23
|
+
status: "queued";
|
|
24
|
+
};
|
|
25
|
+
export type RagIngestJobRecord = {
|
|
26
|
+
id: string;
|
|
27
|
+
workflowId: string;
|
|
28
|
+
sourceId: string;
|
|
29
|
+
corpus: string;
|
|
30
|
+
visibility: DocumentVisibility;
|
|
31
|
+
ownerUserId: string | null;
|
|
32
|
+
status: RagIngestJobStatus;
|
|
33
|
+
stage: string;
|
|
34
|
+
providerTrace: Partial<DocumentProviderTrace> | Record<string, never>;
|
|
35
|
+
metrics: Record<string, unknown>;
|
|
36
|
+
error: string | null;
|
|
37
|
+
startedAt: string;
|
|
38
|
+
completedAt: string | null;
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { SearchScope } from "./search-types.js";
|
|
2
|
+
export type RagOperationKind = "ingest" | "retrieve" | "answer" | "reindex" | "evaluate";
|
|
3
|
+
export type RagOperationMetricUnit = "ms" | "count" | "tokens" | "usd";
|
|
4
|
+
export type RagIndexHealth = "ready" | "empty" | "degraded" | "failed";
|
|
5
|
+
export type RagOperationMetric = {
|
|
6
|
+
id: string;
|
|
7
|
+
appId: string;
|
|
8
|
+
corpus: string;
|
|
9
|
+
visibility: SearchScope["visibility"];
|
|
10
|
+
ownerUserId: string | null;
|
|
11
|
+
operation: RagOperationKind;
|
|
12
|
+
jobId: string | null;
|
|
13
|
+
workflowId: string | null;
|
|
14
|
+
sourceId: string | null;
|
|
15
|
+
metricName: string;
|
|
16
|
+
metricValue: number;
|
|
17
|
+
unit: RagOperationMetricUnit | null;
|
|
18
|
+
metadata: Record<string, unknown>;
|
|
19
|
+
recordedAt: string;
|
|
20
|
+
};
|
|
21
|
+
export type RagOperationsSummary = {
|
|
22
|
+
corpus: string;
|
|
23
|
+
visibility: SearchScope["visibility"];
|
|
24
|
+
ownerUserId: string | null;
|
|
25
|
+
sourceCount: number;
|
|
26
|
+
sectionCount: number;
|
|
27
|
+
chunkCount: number;
|
|
28
|
+
jobCounts: Record<string, number>;
|
|
29
|
+
latestJob: {
|
|
30
|
+
id: string;
|
|
31
|
+
status: string;
|
|
32
|
+
stage: string;
|
|
33
|
+
updatedAt: string;
|
|
34
|
+
} | null;
|
|
35
|
+
recentMetricCounts: Record<string, number>;
|
|
36
|
+
averageLatencyMs: number | null;
|
|
37
|
+
indexHealth: RagIndexHealth;
|
|
38
|
+
};
|
|
39
|
+
export type RagEvaluationExpectedClaim = {
|
|
40
|
+
claim: string;
|
|
41
|
+
verdict: "supported" | "partial" | "unsupported";
|
|
42
|
+
};
|
|
43
|
+
export type RagEvaluationFixture = {
|
|
44
|
+
name: string;
|
|
45
|
+
scope: SearchScope;
|
|
46
|
+
query: string;
|
|
47
|
+
expectedSourceIds?: string[];
|
|
48
|
+
expectedCitationCountMin?: number;
|
|
49
|
+
expectedClaims?: RagEvaluationExpectedClaim[];
|
|
50
|
+
};
|
|
51
|
+
export type RagEvaluationFixtureResult = {
|
|
52
|
+
name: string;
|
|
53
|
+
ok: boolean;
|
|
54
|
+
failures: string[];
|
|
55
|
+
matchedSourceIds: string[];
|
|
56
|
+
citationCount: number;
|
|
57
|
+
claimStatuses: Array<{
|
|
58
|
+
claim: string;
|
|
59
|
+
expected: RagEvaluationExpectedClaim["verdict"];
|
|
60
|
+
actual: string | null;
|
|
61
|
+
}>;
|
|
62
|
+
};
|
|
63
|
+
export type RagEvaluationRunResult = {
|
|
64
|
+
ok: boolean;
|
|
65
|
+
total: number;
|
|
66
|
+
passed: number;
|
|
67
|
+
failed: number;
|
|
68
|
+
results: RagEvaluationFixtureResult[];
|
|
69
|
+
};
|
|
70
|
+
export type RagReindexMode = "source-changed" | "section-changed" | "corpus-policy-changed" | "full-rebuild";
|
|
71
|
+
export type RagReindexPlan = {
|
|
72
|
+
corpus: string;
|
|
73
|
+
visibility: SearchScope["visibility"];
|
|
74
|
+
ownerUserId: string | null;
|
|
75
|
+
mode: RagReindexMode;
|
|
76
|
+
reason: string;
|
|
77
|
+
sourceIds: string[];
|
|
78
|
+
sourceCount: number;
|
|
79
|
+
estimatedChunkCount: number;
|
|
80
|
+
requiresConfirmation: boolean;
|
|
81
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|