@seenn/types 0.1.0 → 0.2.1
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/index.d.mts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +12 -3
package/dist/index.d.mts
CHANGED
|
@@ -308,16 +308,24 @@ interface EtaStats {
|
|
|
308
308
|
/** Last updated timestamp */
|
|
309
309
|
lastUpdated: string;
|
|
310
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Connection mode for real-time updates
|
|
313
|
+
*/
|
|
314
|
+
type ConnectionMode = 'sse' | 'polling';
|
|
311
315
|
/**
|
|
312
316
|
* Base SDK configuration
|
|
313
317
|
*/
|
|
314
318
|
interface SeennConfig {
|
|
315
319
|
/** API base URL */
|
|
316
320
|
baseUrl: string;
|
|
317
|
-
/**
|
|
318
|
-
|
|
321
|
+
/** API key (pk_* for client SDKs, sk_* for server SDKs) */
|
|
322
|
+
apiKey?: string;
|
|
319
323
|
/** SSE endpoint URL (default: baseUrl + /v1/sse) */
|
|
320
324
|
sseUrl?: string;
|
|
325
|
+
/** Connection mode: 'sse' (default) or 'polling' (for self-hosted) */
|
|
326
|
+
mode?: ConnectionMode;
|
|
327
|
+
/** Polling interval in ms (default: 5000, only used when mode is 'polling') */
|
|
328
|
+
pollInterval?: number;
|
|
321
329
|
/** Enable auto-reconnect (default: true) */
|
|
322
330
|
reconnect?: boolean;
|
|
323
331
|
/** Reconnect interval in ms (default: 1000) */
|
|
@@ -403,7 +411,7 @@ interface LiveActivityPushTokenEvent {
|
|
|
403
411
|
/**
|
|
404
412
|
* SDK version info
|
|
405
413
|
*/
|
|
406
|
-
declare const SDK_VERSION = "0.
|
|
414
|
+
declare const SDK_VERSION = "0.2.0";
|
|
407
415
|
/**
|
|
408
416
|
* Minimum API version required
|
|
409
417
|
*/
|
|
@@ -413,4 +421,4 @@ declare const MIN_API_VERSION = "1.0.0";
|
|
|
413
421
|
*/
|
|
414
422
|
declare const SSE_PROTOCOL_VERSION = "1.0";
|
|
415
423
|
|
|
416
|
-
export { type ChildJobSummary, type ChildProgressMode, type ChildrenStats, type CompleteJobParams, type ConnectionState, type CreateJobParams, type EtaStats, type FailJobParams, type InAppMessage, type InAppMessageType, type JobError, type JobResult, type JobStatus, type LiveActivityEndParams, type LiveActivityPushTokenEvent, type LiveActivityResult, type LiveActivityStartParams, type LiveActivityUpdateParams, MIN_API_VERSION, type ParentInfo, type ParentWithChildren, type QueueInfo, SDK_VERSION, type SSEEvent, type SSEEventType, SSE_PROTOCOL_VERSION, type SeennConfig, type SeennJob, type StageInfo, type UpdateJobParams, type WebhookEventType, type WebhookPayload };
|
|
424
|
+
export { type ChildJobSummary, type ChildProgressMode, type ChildrenStats, type CompleteJobParams, type ConnectionMode, type ConnectionState, type CreateJobParams, type EtaStats, type FailJobParams, type InAppMessage, type InAppMessageType, type JobError, type JobResult, type JobStatus, type LiveActivityEndParams, type LiveActivityPushTokenEvent, type LiveActivityResult, type LiveActivityStartParams, type LiveActivityUpdateParams, MIN_API_VERSION, type ParentInfo, type ParentWithChildren, type QueueInfo, SDK_VERSION, type SSEEvent, type SSEEventType, SSE_PROTOCOL_VERSION, type SeennConfig, type SeennJob, type StageInfo, type UpdateJobParams, type WebhookEventType, type WebhookPayload };
|
package/dist/index.d.ts
CHANGED
|
@@ -308,16 +308,24 @@ interface EtaStats {
|
|
|
308
308
|
/** Last updated timestamp */
|
|
309
309
|
lastUpdated: string;
|
|
310
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Connection mode for real-time updates
|
|
313
|
+
*/
|
|
314
|
+
type ConnectionMode = 'sse' | 'polling';
|
|
311
315
|
/**
|
|
312
316
|
* Base SDK configuration
|
|
313
317
|
*/
|
|
314
318
|
interface SeennConfig {
|
|
315
319
|
/** API base URL */
|
|
316
320
|
baseUrl: string;
|
|
317
|
-
/**
|
|
318
|
-
|
|
321
|
+
/** API key (pk_* for client SDKs, sk_* for server SDKs) */
|
|
322
|
+
apiKey?: string;
|
|
319
323
|
/** SSE endpoint URL (default: baseUrl + /v1/sse) */
|
|
320
324
|
sseUrl?: string;
|
|
325
|
+
/** Connection mode: 'sse' (default) or 'polling' (for self-hosted) */
|
|
326
|
+
mode?: ConnectionMode;
|
|
327
|
+
/** Polling interval in ms (default: 5000, only used when mode is 'polling') */
|
|
328
|
+
pollInterval?: number;
|
|
321
329
|
/** Enable auto-reconnect (default: true) */
|
|
322
330
|
reconnect?: boolean;
|
|
323
331
|
/** Reconnect interval in ms (default: 1000) */
|
|
@@ -403,7 +411,7 @@ interface LiveActivityPushTokenEvent {
|
|
|
403
411
|
/**
|
|
404
412
|
* SDK version info
|
|
405
413
|
*/
|
|
406
|
-
declare const SDK_VERSION = "0.
|
|
414
|
+
declare const SDK_VERSION = "0.2.0";
|
|
407
415
|
/**
|
|
408
416
|
* Minimum API version required
|
|
409
417
|
*/
|
|
@@ -413,4 +421,4 @@ declare const MIN_API_VERSION = "1.0.0";
|
|
|
413
421
|
*/
|
|
414
422
|
declare const SSE_PROTOCOL_VERSION = "1.0";
|
|
415
423
|
|
|
416
|
-
export { type ChildJobSummary, type ChildProgressMode, type ChildrenStats, type CompleteJobParams, type ConnectionState, type CreateJobParams, type EtaStats, type FailJobParams, type InAppMessage, type InAppMessageType, type JobError, type JobResult, type JobStatus, type LiveActivityEndParams, type LiveActivityPushTokenEvent, type LiveActivityResult, type LiveActivityStartParams, type LiveActivityUpdateParams, MIN_API_VERSION, type ParentInfo, type ParentWithChildren, type QueueInfo, SDK_VERSION, type SSEEvent, type SSEEventType, SSE_PROTOCOL_VERSION, type SeennConfig, type SeennJob, type StageInfo, type UpdateJobParams, type WebhookEventType, type WebhookPayload };
|
|
424
|
+
export { type ChildJobSummary, type ChildProgressMode, type ChildrenStats, type CompleteJobParams, type ConnectionMode, type ConnectionState, type CreateJobParams, type EtaStats, type FailJobParams, type InAppMessage, type InAppMessageType, type JobError, type JobResult, type JobStatus, type LiveActivityEndParams, type LiveActivityPushTokenEvent, type LiveActivityResult, type LiveActivityStartParams, type LiveActivityUpdateParams, MIN_API_VERSION, type ParentInfo, type ParentWithChildren, type QueueInfo, SDK_VERSION, type SSEEvent, type SSEEventType, SSE_PROTOCOL_VERSION, type SeennConfig, type SeennJob, type StageInfo, type UpdateJobParams, type WebhookEventType, type WebhookPayload };
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
SSE_PROTOCOL_VERSION: () => SSE_PROTOCOL_VERSION
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
var SDK_VERSION = "0.
|
|
28
|
+
var SDK_VERSION = "0.2.0";
|
|
29
29
|
var MIN_API_VERSION = "1.0.0";
|
|
30
30
|
var SSE_PROTOCOL_VERSION = "1.0";
|
|
31
31
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @seenn/types - Shared TypeScript types for Seenn SDKs\n *\n * This package is the single source of truth for all Seenn type definitions.\n * All SDK packages (react-native, node, flutter) should depend on this package.\n *\n * @version 0.1.0\n * @license MIT\n */\n\n// ============================================\n// Core Job Types\n// ============================================\n\n/**\n * Job status values\n */\nexport type JobStatus =\n | 'pending'\n | 'queued'\n | 'running'\n | 'completed'\n | 'failed'\n | 'cancelled';\n\n/**\n * How parent job progress is calculated from children\n */\nexport type ChildProgressMode = 'average' | 'weighted' | 'sequential';\n\n/**\n * Main job object returned by API and SSE\n */\nexport interface SeennJob {\n /** Unique job identifier (ULID format) */\n jobId: string;\n /** User who owns this job */\n userId: string;\n /** Application ID */\n appId: string;\n /** Current job status */\n status: JobStatus;\n /** Human-readable job title */\n title: string;\n /** Job type for categorization */\n jobType: string;\n /** Workflow ID for ETA tracking (default: jobType) */\n workflowId?: string;\n /** Progress percentage (0-100) */\n progress: number;\n /** Current status message */\n message?: string;\n /** Stage information for multi-step jobs */\n stage?: StageInfo;\n /** Estimated completion timestamp (ISO 8601) */\n estimatedCompletionAt?: string;\n /** ETA confidence score (0.0 - 1.0) */\n etaConfidence?: number;\n /** Number of historical jobs used to calculate ETA */\n etaBasedOn?: number;\n /** Queue position info */\n queue?: QueueInfo;\n /** Job result on completion */\n result?: JobResult;\n /** Error details on failure */\n error?: JobError;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n /** Parent info (if this is a child job) */\n parent?: ParentInfo;\n /** Children stats (if this is a parent job) */\n children?: ChildrenStats;\n /** Progress calculation mode for parent jobs */\n childProgressMode?: ChildProgressMode;\n /** Job creation timestamp (ISO 8601) */\n createdAt: string;\n /** Last update timestamp (ISO 8601) */\n updatedAt: string;\n /** When the job started running (ISO 8601) */\n startedAt?: string;\n /** Job completion timestamp (ISO 8601) */\n completedAt?: string;\n}\n\n// ============================================\n// Stage & Queue Types\n// ============================================\n\n/**\n * Stage information for multi-step jobs\n */\nexport interface StageInfo {\n /** Current stage name */\n name: string;\n /** Current stage index (1-based) */\n current: number;\n /** Total number of stages */\n total: number;\n /** Optional stage description */\n description?: string;\n}\n\n/**\n * Queue position information\n */\nexport interface QueueInfo {\n /** Position in queue (1-based) */\n position: number;\n /** Total items in queue */\n total?: number;\n /** Queue name/identifier */\n queueName?: string;\n}\n\n// ============================================\n// Result & Error Types\n// ============================================\n\n/**\n * Job result on successful completion\n */\nexport interface JobResult {\n /** Result type (e.g., 'video', 'image', 'file') */\n type?: string;\n /** Result URL if applicable */\n url?: string;\n /** Additional result data */\n data?: Record<string, unknown>;\n}\n\n/**\n * Error details on job failure\n */\nexport interface JobError {\n /** Error code for programmatic handling */\n code: string;\n /** Human-readable error message */\n message: string;\n /** Additional error details */\n details?: Record<string, unknown>;\n}\n\n// ============================================\n// Parent-Child Types\n// ============================================\n\n/**\n * Parent info for child jobs\n */\nexport interface ParentInfo {\n /** Parent job ID */\n parentJobId: string;\n /** Child index within parent (0-based) */\n childIndex: number;\n}\n\n/**\n * Children stats for parent jobs\n */\nexport interface ChildrenStats {\n /** Total number of children */\n total: number;\n /** Number of completed children */\n completed: number;\n /** Number of failed children */\n failed: number;\n /** Number of running children */\n running: number;\n /** Number of pending children */\n pending: number;\n}\n\n/**\n * Summary of a child job (used in parent.children array)\n */\nexport interface ChildJobSummary {\n /** Child job ID */\n id: string;\n /** Child index within parent (0-based) */\n childIndex: number;\n /** Child job title */\n title: string;\n /** Child job status */\n status: JobStatus;\n /** Child progress (0-100) */\n progress: number;\n /** Child status message */\n message?: string;\n /** Child result */\n result?: JobResult;\n /** Child error */\n error?: JobError;\n /** Child creation timestamp */\n createdAt: string;\n /** Child last update timestamp */\n updatedAt: string;\n /** Child completion timestamp */\n completedAt?: string;\n}\n\n/**\n * Parent job with all its children\n */\nexport interface ParentWithChildren {\n /** Parent job */\n parent: SeennJob;\n /** List of child jobs */\n children: ChildJobSummary[];\n}\n\n// ============================================\n// SSE Types\n// ============================================\n\n/**\n * Connection state for SSE\n */\nexport type ConnectionState =\n | 'disconnected'\n | 'connecting'\n | 'connected'\n | 'reconnecting';\n\n/**\n * SSE event types\n */\nexport type SSEEventType =\n | 'connected'\n | 'job.sync'\n | 'job.started'\n | 'job.progress'\n | 'job.completed'\n | 'job.failed'\n | 'job.cancelled'\n | 'child.progress'\n | 'parent.updated'\n | 'in_app_message'\n | 'connection.idle'\n | 'heartbeat'\n | 'error';\n\n/**\n * SSE event wrapper\n */\nexport interface SSEEvent {\n /** Event type */\n event: SSEEventType;\n /** Event data */\n data: unknown;\n /** Event ID for replay */\n id?: string;\n}\n\n// ============================================\n// In-App Message Types\n// ============================================\n\n/**\n * In-app message types\n */\nexport type InAppMessageType =\n | 'job_complete_banner'\n | 'job_failed_modal'\n | 'job_toast';\n\n/**\n * In-app message for UI notifications\n */\nexport interface InAppMessage {\n /** Message ID */\n messageId: string;\n /** Message type */\n type: InAppMessageType;\n /** Associated job ID */\n jobId: string;\n /** Message title */\n title: string;\n /** Message body */\n body?: string;\n /** Call-to-action text */\n cta?: string;\n /** Call-to-action URL */\n ctaUrl?: string;\n}\n\n// ============================================\n// API Types\n// ============================================\n\n/**\n * Create job request parameters\n */\nexport interface CreateJobParams {\n /** User ID */\n userId: string;\n /** Job type */\n jobType: string;\n /** Job title */\n title: string;\n /** Workflow ID for ETA tracking (default: jobType) */\n workflowId?: string;\n /** Initial message */\n message?: string;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n /** Estimated duration in ms (for ETA default) */\n estimatedDuration?: number;\n /** Parent job ID (for child jobs) */\n parentJobId?: string;\n /** Child index (for child jobs) */\n childIndex?: number;\n /** Total children (for parent jobs) */\n totalChildren?: number;\n /** Child progress mode (for parent jobs) */\n childProgressMode?: ChildProgressMode;\n}\n\n/**\n * Update job request parameters\n */\nexport interface UpdateJobParams {\n /** New progress (0-100) */\n progress?: number;\n /** New message */\n message?: string;\n /** New stage info */\n stage?: StageInfo;\n /** Custom metadata to merge */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Complete job request parameters\n */\nexport interface CompleteJobParams {\n /** Job result */\n result?: JobResult;\n /** Final message */\n message?: string;\n}\n\n/**\n * Fail job request parameters\n */\nexport interface FailJobParams {\n /** Error details */\n error: JobError;\n}\n\n// ============================================\n// Webhook Types\n// ============================================\n\n/**\n * Webhook event types\n */\nexport type WebhookEventType =\n | 'job.started'\n | 'job.progress'\n | 'job.completed'\n | 'job.failed'\n | 'job.cancelled';\n\n/**\n * Webhook payload\n */\nexport interface WebhookPayload {\n /** Event type */\n event: WebhookEventType;\n /** Job data */\n job: SeennJob;\n /** Event timestamp (ISO 8601) */\n timestamp: string;\n /** Webhook delivery ID */\n deliveryId: string;\n}\n\n// ============================================\n// ETA Types\n// ============================================\n\n/**\n * ETA statistics for a workflow/jobType\n */\nexport interface EtaStats {\n /** ETA key (workflowId or jobType) */\n etaKey: string;\n /** Number of completed jobs */\n count: number;\n /** Average duration in ms */\n avgDuration: number;\n /** Minimum duration in ms */\n minDuration: number;\n /** Maximum duration in ms */\n maxDuration: number;\n /** Default duration if no history */\n defaultDuration?: number;\n /** Last updated timestamp */\n lastUpdated: string;\n}\n\n// ============================================\n// SDK Configuration Types\n// ============================================\n\n/**\n * Base SDK configuration\n */\nexport interface SeennConfig {\n /** API base URL */\n baseUrl: string;\n /** Authentication token (pk_* for client, sk_* for server) */\n authToken?: string;\n /** SSE endpoint URL (default: baseUrl + /v1/sse) */\n sseUrl?: string;\n /** Enable auto-reconnect (default: true) */\n reconnect?: boolean;\n /** Reconnect interval in ms (default: 1000) */\n reconnectInterval?: number;\n /** Max reconnect attempts (default: 10) */\n maxReconnectAttempts?: number;\n /** Enable debug logging (default: false) */\n debug?: boolean;\n}\n\n// ============================================\n// Live Activity Types (iOS/Android)\n// ============================================\n\n/**\n * Live Activity start parameters\n */\nexport interface LiveActivityStartParams {\n /** Job ID */\n jobId: string;\n /** Activity title */\n title: string;\n /** Job type for icon selection */\n jobType?: string;\n /** Initial progress (0-100) */\n initialProgress?: number;\n /** Initial message */\n initialMessage?: string;\n}\n\n/**\n * Live Activity update parameters\n */\nexport interface LiveActivityUpdateParams {\n /** Job ID */\n jobId: string;\n /** New progress (0-100) */\n progress?: number;\n /** New status */\n status?: JobStatus;\n /** New message */\n message?: string;\n /** Stage info */\n stage?: StageInfo;\n /** ETA timestamp (Unix ms) */\n estimatedEndTime?: number;\n}\n\n/**\n * Live Activity end parameters\n */\nexport interface LiveActivityEndParams {\n /** Job ID */\n jobId: string;\n /** Final status */\n finalStatus?: JobStatus;\n /** Final progress */\n finalProgress?: number;\n /** Final message */\n message?: string;\n /** Result URL */\n resultUrl?: string;\n /** Error message */\n errorMessage?: string;\n /** Dismiss after seconds (default: 300) */\n dismissAfter?: number;\n}\n\n/**\n * Live Activity result\n */\nexport interface LiveActivityResult {\n /** Success flag */\n success: boolean;\n /** Activity ID (platform-specific) */\n activityId?: string;\n /** Associated job ID */\n jobId?: string;\n /** Error message if failed */\n error?: string;\n}\n\n/**\n * Push token event for Live Activity updates\n */\nexport interface LiveActivityPushTokenEvent {\n /** Job ID */\n jobId: string;\n /** APNs push token */\n token: string;\n}\n\n// ============================================\n// Version & Compatibility\n// ============================================\n\n/**\n * SDK version info\n */\nexport const SDK_VERSION = '0.1.0';\n\n/**\n * Minimum API version required\n */\nexport const MIN_API_VERSION = '1.0.0';\n\n/**\n * SSE protocol version\n */\nexport const SSE_PROTOCOL_VERSION = '1.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkgBO,IAAM,cAAc;AAKpB,IAAM,kBAAkB;AAKxB,IAAM,uBAAuB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @seenn/types - Shared TypeScript types for Seenn SDKs\n *\n * This package is the single source of truth for all Seenn type definitions.\n * All SDK packages (react-native, node, flutter) should depend on this package.\n *\n * @version 0.1.0\n * @license MIT\n */\n\n// ============================================\n// Core Job Types\n// ============================================\n\n/**\n * Job status values\n */\nexport type JobStatus =\n | 'pending'\n | 'queued'\n | 'running'\n | 'completed'\n | 'failed'\n | 'cancelled';\n\n/**\n * How parent job progress is calculated from children\n */\nexport type ChildProgressMode = 'average' | 'weighted' | 'sequential';\n\n/**\n * Main job object returned by API and SSE\n */\nexport interface SeennJob {\n /** Unique job identifier (ULID format) */\n jobId: string;\n /** User who owns this job */\n userId: string;\n /** Application ID */\n appId: string;\n /** Current job status */\n status: JobStatus;\n /** Human-readable job title */\n title: string;\n /** Job type for categorization */\n jobType: string;\n /** Workflow ID for ETA tracking (default: jobType) */\n workflowId?: string;\n /** Progress percentage (0-100) */\n progress: number;\n /** Current status message */\n message?: string;\n /** Stage information for multi-step jobs */\n stage?: StageInfo;\n /** Estimated completion timestamp (ISO 8601) */\n estimatedCompletionAt?: string;\n /** ETA confidence score (0.0 - 1.0) */\n etaConfidence?: number;\n /** Number of historical jobs used to calculate ETA */\n etaBasedOn?: number;\n /** Queue position info */\n queue?: QueueInfo;\n /** Job result on completion */\n result?: JobResult;\n /** Error details on failure */\n error?: JobError;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n /** Parent info (if this is a child job) */\n parent?: ParentInfo;\n /** Children stats (if this is a parent job) */\n children?: ChildrenStats;\n /** Progress calculation mode for parent jobs */\n childProgressMode?: ChildProgressMode;\n /** Job creation timestamp (ISO 8601) */\n createdAt: string;\n /** Last update timestamp (ISO 8601) */\n updatedAt: string;\n /** When the job started running (ISO 8601) */\n startedAt?: string;\n /** Job completion timestamp (ISO 8601) */\n completedAt?: string;\n}\n\n// ============================================\n// Stage & Queue Types\n// ============================================\n\n/**\n * Stage information for multi-step jobs\n */\nexport interface StageInfo {\n /** Current stage name */\n name: string;\n /** Current stage index (1-based) */\n current: number;\n /** Total number of stages */\n total: number;\n /** Optional stage description */\n description?: string;\n}\n\n/**\n * Queue position information\n */\nexport interface QueueInfo {\n /** Position in queue (1-based) */\n position: number;\n /** Total items in queue */\n total?: number;\n /** Queue name/identifier */\n queueName?: string;\n}\n\n// ============================================\n// Result & Error Types\n// ============================================\n\n/**\n * Job result on successful completion\n */\nexport interface JobResult {\n /** Result type (e.g., 'video', 'image', 'file') */\n type?: string;\n /** Result URL if applicable */\n url?: string;\n /** Additional result data */\n data?: Record<string, unknown>;\n}\n\n/**\n * Error details on job failure\n */\nexport interface JobError {\n /** Error code for programmatic handling */\n code: string;\n /** Human-readable error message */\n message: string;\n /** Additional error details */\n details?: Record<string, unknown>;\n}\n\n// ============================================\n// Parent-Child Types\n// ============================================\n\n/**\n * Parent info for child jobs\n */\nexport interface ParentInfo {\n /** Parent job ID */\n parentJobId: string;\n /** Child index within parent (0-based) */\n childIndex: number;\n}\n\n/**\n * Children stats for parent jobs\n */\nexport interface ChildrenStats {\n /** Total number of children */\n total: number;\n /** Number of completed children */\n completed: number;\n /** Number of failed children */\n failed: number;\n /** Number of running children */\n running: number;\n /** Number of pending children */\n pending: number;\n}\n\n/**\n * Summary of a child job (used in parent.children array)\n */\nexport interface ChildJobSummary {\n /** Child job ID */\n id: string;\n /** Child index within parent (0-based) */\n childIndex: number;\n /** Child job title */\n title: string;\n /** Child job status */\n status: JobStatus;\n /** Child progress (0-100) */\n progress: number;\n /** Child status message */\n message?: string;\n /** Child result */\n result?: JobResult;\n /** Child error */\n error?: JobError;\n /** Child creation timestamp */\n createdAt: string;\n /** Child last update timestamp */\n updatedAt: string;\n /** Child completion timestamp */\n completedAt?: string;\n}\n\n/**\n * Parent job with all its children\n */\nexport interface ParentWithChildren {\n /** Parent job */\n parent: SeennJob;\n /** List of child jobs */\n children: ChildJobSummary[];\n}\n\n// ============================================\n// SSE Types\n// ============================================\n\n/**\n * Connection state for SSE\n */\nexport type ConnectionState =\n | 'disconnected'\n | 'connecting'\n | 'connected'\n | 'reconnecting';\n\n/**\n * SSE event types\n */\nexport type SSEEventType =\n | 'connected'\n | 'job.sync'\n | 'job.started'\n | 'job.progress'\n | 'job.completed'\n | 'job.failed'\n | 'job.cancelled'\n | 'child.progress'\n | 'parent.updated'\n | 'in_app_message'\n | 'connection.idle'\n | 'heartbeat'\n | 'error';\n\n/**\n * SSE event wrapper\n */\nexport interface SSEEvent {\n /** Event type */\n event: SSEEventType;\n /** Event data */\n data: unknown;\n /** Event ID for replay */\n id?: string;\n}\n\n// ============================================\n// In-App Message Types\n// ============================================\n\n/**\n * In-app message types\n */\nexport type InAppMessageType =\n | 'job_complete_banner'\n | 'job_failed_modal'\n | 'job_toast';\n\n/**\n * In-app message for UI notifications\n */\nexport interface InAppMessage {\n /** Message ID */\n messageId: string;\n /** Message type */\n type: InAppMessageType;\n /** Associated job ID */\n jobId: string;\n /** Message title */\n title: string;\n /** Message body */\n body?: string;\n /** Call-to-action text */\n cta?: string;\n /** Call-to-action URL */\n ctaUrl?: string;\n}\n\n// ============================================\n// API Types\n// ============================================\n\n/**\n * Create job request parameters\n */\nexport interface CreateJobParams {\n /** User ID */\n userId: string;\n /** Job type */\n jobType: string;\n /** Job title */\n title: string;\n /** Workflow ID for ETA tracking (default: jobType) */\n workflowId?: string;\n /** Initial message */\n message?: string;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n /** Estimated duration in ms (for ETA default) */\n estimatedDuration?: number;\n /** Parent job ID (for child jobs) */\n parentJobId?: string;\n /** Child index (for child jobs) */\n childIndex?: number;\n /** Total children (for parent jobs) */\n totalChildren?: number;\n /** Child progress mode (for parent jobs) */\n childProgressMode?: ChildProgressMode;\n}\n\n/**\n * Update job request parameters\n */\nexport interface UpdateJobParams {\n /** New progress (0-100) */\n progress?: number;\n /** New message */\n message?: string;\n /** New stage info */\n stage?: StageInfo;\n /** Custom metadata to merge */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Complete job request parameters\n */\nexport interface CompleteJobParams {\n /** Job result */\n result?: JobResult;\n /** Final message */\n message?: string;\n}\n\n/**\n * Fail job request parameters\n */\nexport interface FailJobParams {\n /** Error details */\n error: JobError;\n}\n\n// ============================================\n// Webhook Types\n// ============================================\n\n/**\n * Webhook event types\n */\nexport type WebhookEventType =\n | 'job.started'\n | 'job.progress'\n | 'job.completed'\n | 'job.failed'\n | 'job.cancelled';\n\n/**\n * Webhook payload\n */\nexport interface WebhookPayload {\n /** Event type */\n event: WebhookEventType;\n /** Job data */\n job: SeennJob;\n /** Event timestamp (ISO 8601) */\n timestamp: string;\n /** Webhook delivery ID */\n deliveryId: string;\n}\n\n// ============================================\n// ETA Types\n// ============================================\n\n/**\n * ETA statistics for a workflow/jobType\n */\nexport interface EtaStats {\n /** ETA key (workflowId or jobType) */\n etaKey: string;\n /** Number of completed jobs */\n count: number;\n /** Average duration in ms */\n avgDuration: number;\n /** Minimum duration in ms */\n minDuration: number;\n /** Maximum duration in ms */\n maxDuration: number;\n /** Default duration if no history */\n defaultDuration?: number;\n /** Last updated timestamp */\n lastUpdated: string;\n}\n\n// ============================================\n// SDK Configuration Types\n// ============================================\n\n/**\n * Connection mode for real-time updates\n */\nexport type ConnectionMode = 'sse' | 'polling';\n\n/**\n * Base SDK configuration\n */\nexport interface SeennConfig {\n /** API base URL */\n baseUrl: string;\n /** API key (pk_* for client SDKs, sk_* for server SDKs) */\n apiKey?: string;\n /** SSE endpoint URL (default: baseUrl + /v1/sse) */\n sseUrl?: string;\n /** Connection mode: 'sse' (default) or 'polling' (for self-hosted) */\n mode?: ConnectionMode;\n /** Polling interval in ms (default: 5000, only used when mode is 'polling') */\n pollInterval?: number;\n /** Enable auto-reconnect (default: true) */\n reconnect?: boolean;\n /** Reconnect interval in ms (default: 1000) */\n reconnectInterval?: number;\n /** Max reconnect attempts (default: 10) */\n maxReconnectAttempts?: number;\n /** Enable debug logging (default: false) */\n debug?: boolean;\n}\n\n// ============================================\n// Live Activity Types (iOS/Android)\n// ============================================\n\n/**\n * Live Activity start parameters\n */\nexport interface LiveActivityStartParams {\n /** Job ID */\n jobId: string;\n /** Activity title */\n title: string;\n /** Job type for icon selection */\n jobType?: string;\n /** Initial progress (0-100) */\n initialProgress?: number;\n /** Initial message */\n initialMessage?: string;\n}\n\n/**\n * Live Activity update parameters\n */\nexport interface LiveActivityUpdateParams {\n /** Job ID */\n jobId: string;\n /** New progress (0-100) */\n progress?: number;\n /** New status */\n status?: JobStatus;\n /** New message */\n message?: string;\n /** Stage info */\n stage?: StageInfo;\n /** ETA timestamp (Unix ms) */\n estimatedEndTime?: number;\n}\n\n/**\n * Live Activity end parameters\n */\nexport interface LiveActivityEndParams {\n /** Job ID */\n jobId: string;\n /** Final status */\n finalStatus?: JobStatus;\n /** Final progress */\n finalProgress?: number;\n /** Final message */\n message?: string;\n /** Result URL */\n resultUrl?: string;\n /** Error message */\n errorMessage?: string;\n /** Dismiss after seconds (default: 300) */\n dismissAfter?: number;\n}\n\n/**\n * Live Activity result\n */\nexport interface LiveActivityResult {\n /** Success flag */\n success: boolean;\n /** Activity ID (platform-specific) */\n activityId?: string;\n /** Associated job ID */\n jobId?: string;\n /** Error message if failed */\n error?: string;\n}\n\n/**\n * Push token event for Live Activity updates\n */\nexport interface LiveActivityPushTokenEvent {\n /** Job ID */\n jobId: string;\n /** APNs push token */\n token: string;\n}\n\n// ============================================\n// Version & Compatibility\n// ============================================\n\n/**\n * SDK version info\n */\nexport const SDK_VERSION = '0.2.0';\n\n/**\n * Minimum API version required\n */\nexport const MIN_API_VERSION = '1.0.0';\n\n/**\n * SSE protocol version\n */\nexport const SSE_PROTOCOL_VERSION = '1.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2gBO,IAAM,cAAc;AAKpB,IAAM,kBAAkB;AAKxB,IAAM,uBAAuB;","names":[]}
|
package/dist/index.mjs
CHANGED
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @seenn/types - Shared TypeScript types for Seenn SDKs\n *\n * This package is the single source of truth for all Seenn type definitions.\n * All SDK packages (react-native, node, flutter) should depend on this package.\n *\n * @version 0.1.0\n * @license MIT\n */\n\n// ============================================\n// Core Job Types\n// ============================================\n\n/**\n * Job status values\n */\nexport type JobStatus =\n | 'pending'\n | 'queued'\n | 'running'\n | 'completed'\n | 'failed'\n | 'cancelled';\n\n/**\n * How parent job progress is calculated from children\n */\nexport type ChildProgressMode = 'average' | 'weighted' | 'sequential';\n\n/**\n * Main job object returned by API and SSE\n */\nexport interface SeennJob {\n /** Unique job identifier (ULID format) */\n jobId: string;\n /** User who owns this job */\n userId: string;\n /** Application ID */\n appId: string;\n /** Current job status */\n status: JobStatus;\n /** Human-readable job title */\n title: string;\n /** Job type for categorization */\n jobType: string;\n /** Workflow ID for ETA tracking (default: jobType) */\n workflowId?: string;\n /** Progress percentage (0-100) */\n progress: number;\n /** Current status message */\n message?: string;\n /** Stage information for multi-step jobs */\n stage?: StageInfo;\n /** Estimated completion timestamp (ISO 8601) */\n estimatedCompletionAt?: string;\n /** ETA confidence score (0.0 - 1.0) */\n etaConfidence?: number;\n /** Number of historical jobs used to calculate ETA */\n etaBasedOn?: number;\n /** Queue position info */\n queue?: QueueInfo;\n /** Job result on completion */\n result?: JobResult;\n /** Error details on failure */\n error?: JobError;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n /** Parent info (if this is a child job) */\n parent?: ParentInfo;\n /** Children stats (if this is a parent job) */\n children?: ChildrenStats;\n /** Progress calculation mode for parent jobs */\n childProgressMode?: ChildProgressMode;\n /** Job creation timestamp (ISO 8601) */\n createdAt: string;\n /** Last update timestamp (ISO 8601) */\n updatedAt: string;\n /** When the job started running (ISO 8601) */\n startedAt?: string;\n /** Job completion timestamp (ISO 8601) */\n completedAt?: string;\n}\n\n// ============================================\n// Stage & Queue Types\n// ============================================\n\n/**\n * Stage information for multi-step jobs\n */\nexport interface StageInfo {\n /** Current stage name */\n name: string;\n /** Current stage index (1-based) */\n current: number;\n /** Total number of stages */\n total: number;\n /** Optional stage description */\n description?: string;\n}\n\n/**\n * Queue position information\n */\nexport interface QueueInfo {\n /** Position in queue (1-based) */\n position: number;\n /** Total items in queue */\n total?: number;\n /** Queue name/identifier */\n queueName?: string;\n}\n\n// ============================================\n// Result & Error Types\n// ============================================\n\n/**\n * Job result on successful completion\n */\nexport interface JobResult {\n /** Result type (e.g., 'video', 'image', 'file') */\n type?: string;\n /** Result URL if applicable */\n url?: string;\n /** Additional result data */\n data?: Record<string, unknown>;\n}\n\n/**\n * Error details on job failure\n */\nexport interface JobError {\n /** Error code for programmatic handling */\n code: string;\n /** Human-readable error message */\n message: string;\n /** Additional error details */\n details?: Record<string, unknown>;\n}\n\n// ============================================\n// Parent-Child Types\n// ============================================\n\n/**\n * Parent info for child jobs\n */\nexport interface ParentInfo {\n /** Parent job ID */\n parentJobId: string;\n /** Child index within parent (0-based) */\n childIndex: number;\n}\n\n/**\n * Children stats for parent jobs\n */\nexport interface ChildrenStats {\n /** Total number of children */\n total: number;\n /** Number of completed children */\n completed: number;\n /** Number of failed children */\n failed: number;\n /** Number of running children */\n running: number;\n /** Number of pending children */\n pending: number;\n}\n\n/**\n * Summary of a child job (used in parent.children array)\n */\nexport interface ChildJobSummary {\n /** Child job ID */\n id: string;\n /** Child index within parent (0-based) */\n childIndex: number;\n /** Child job title */\n title: string;\n /** Child job status */\n status: JobStatus;\n /** Child progress (0-100) */\n progress: number;\n /** Child status message */\n message?: string;\n /** Child result */\n result?: JobResult;\n /** Child error */\n error?: JobError;\n /** Child creation timestamp */\n createdAt: string;\n /** Child last update timestamp */\n updatedAt: string;\n /** Child completion timestamp */\n completedAt?: string;\n}\n\n/**\n * Parent job with all its children\n */\nexport interface ParentWithChildren {\n /** Parent job */\n parent: SeennJob;\n /** List of child jobs */\n children: ChildJobSummary[];\n}\n\n// ============================================\n// SSE Types\n// ============================================\n\n/**\n * Connection state for SSE\n */\nexport type ConnectionState =\n | 'disconnected'\n | 'connecting'\n | 'connected'\n | 'reconnecting';\n\n/**\n * SSE event types\n */\nexport type SSEEventType =\n | 'connected'\n | 'job.sync'\n | 'job.started'\n | 'job.progress'\n | 'job.completed'\n | 'job.failed'\n | 'job.cancelled'\n | 'child.progress'\n | 'parent.updated'\n | 'in_app_message'\n | 'connection.idle'\n | 'heartbeat'\n | 'error';\n\n/**\n * SSE event wrapper\n */\nexport interface SSEEvent {\n /** Event type */\n event: SSEEventType;\n /** Event data */\n data: unknown;\n /** Event ID for replay */\n id?: string;\n}\n\n// ============================================\n// In-App Message Types\n// ============================================\n\n/**\n * In-app message types\n */\nexport type InAppMessageType =\n | 'job_complete_banner'\n | 'job_failed_modal'\n | 'job_toast';\n\n/**\n * In-app message for UI notifications\n */\nexport interface InAppMessage {\n /** Message ID */\n messageId: string;\n /** Message type */\n type: InAppMessageType;\n /** Associated job ID */\n jobId: string;\n /** Message title */\n title: string;\n /** Message body */\n body?: string;\n /** Call-to-action text */\n cta?: string;\n /** Call-to-action URL */\n ctaUrl?: string;\n}\n\n// ============================================\n// API Types\n// ============================================\n\n/**\n * Create job request parameters\n */\nexport interface CreateJobParams {\n /** User ID */\n userId: string;\n /** Job type */\n jobType: string;\n /** Job title */\n title: string;\n /** Workflow ID for ETA tracking (default: jobType) */\n workflowId?: string;\n /** Initial message */\n message?: string;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n /** Estimated duration in ms (for ETA default) */\n estimatedDuration?: number;\n /** Parent job ID (for child jobs) */\n parentJobId?: string;\n /** Child index (for child jobs) */\n childIndex?: number;\n /** Total children (for parent jobs) */\n totalChildren?: number;\n /** Child progress mode (for parent jobs) */\n childProgressMode?: ChildProgressMode;\n}\n\n/**\n * Update job request parameters\n */\nexport interface UpdateJobParams {\n /** New progress (0-100) */\n progress?: number;\n /** New message */\n message?: string;\n /** New stage info */\n stage?: StageInfo;\n /** Custom metadata to merge */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Complete job request parameters\n */\nexport interface CompleteJobParams {\n /** Job result */\n result?: JobResult;\n /** Final message */\n message?: string;\n}\n\n/**\n * Fail job request parameters\n */\nexport interface FailJobParams {\n /** Error details */\n error: JobError;\n}\n\n// ============================================\n// Webhook Types\n// ============================================\n\n/**\n * Webhook event types\n */\nexport type WebhookEventType =\n | 'job.started'\n | 'job.progress'\n | 'job.completed'\n | 'job.failed'\n | 'job.cancelled';\n\n/**\n * Webhook payload\n */\nexport interface WebhookPayload {\n /** Event type */\n event: WebhookEventType;\n /** Job data */\n job: SeennJob;\n /** Event timestamp (ISO 8601) */\n timestamp: string;\n /** Webhook delivery ID */\n deliveryId: string;\n}\n\n// ============================================\n// ETA Types\n// ============================================\n\n/**\n * ETA statistics for a workflow/jobType\n */\nexport interface EtaStats {\n /** ETA key (workflowId or jobType) */\n etaKey: string;\n /** Number of completed jobs */\n count: number;\n /** Average duration in ms */\n avgDuration: number;\n /** Minimum duration in ms */\n minDuration: number;\n /** Maximum duration in ms */\n maxDuration: number;\n /** Default duration if no history */\n defaultDuration?: number;\n /** Last updated timestamp */\n lastUpdated: string;\n}\n\n// ============================================\n// SDK Configuration Types\n// ============================================\n\n/**\n * Base SDK configuration\n */\nexport interface SeennConfig {\n /** API base URL */\n baseUrl: string;\n /** Authentication token (pk_* for client, sk_* for server) */\n authToken?: string;\n /** SSE endpoint URL (default: baseUrl + /v1/sse) */\n sseUrl?: string;\n /** Enable auto-reconnect (default: true) */\n reconnect?: boolean;\n /** Reconnect interval in ms (default: 1000) */\n reconnectInterval?: number;\n /** Max reconnect attempts (default: 10) */\n maxReconnectAttempts?: number;\n /** Enable debug logging (default: false) */\n debug?: boolean;\n}\n\n// ============================================\n// Live Activity Types (iOS/Android)\n// ============================================\n\n/**\n * Live Activity start parameters\n */\nexport interface LiveActivityStartParams {\n /** Job ID */\n jobId: string;\n /** Activity title */\n title: string;\n /** Job type for icon selection */\n jobType?: string;\n /** Initial progress (0-100) */\n initialProgress?: number;\n /** Initial message */\n initialMessage?: string;\n}\n\n/**\n * Live Activity update parameters\n */\nexport interface LiveActivityUpdateParams {\n /** Job ID */\n jobId: string;\n /** New progress (0-100) */\n progress?: number;\n /** New status */\n status?: JobStatus;\n /** New message */\n message?: string;\n /** Stage info */\n stage?: StageInfo;\n /** ETA timestamp (Unix ms) */\n estimatedEndTime?: number;\n}\n\n/**\n * Live Activity end parameters\n */\nexport interface LiveActivityEndParams {\n /** Job ID */\n jobId: string;\n /** Final status */\n finalStatus?: JobStatus;\n /** Final progress */\n finalProgress?: number;\n /** Final message */\n message?: string;\n /** Result URL */\n resultUrl?: string;\n /** Error message */\n errorMessage?: string;\n /** Dismiss after seconds (default: 300) */\n dismissAfter?: number;\n}\n\n/**\n * Live Activity result\n */\nexport interface LiveActivityResult {\n /** Success flag */\n success: boolean;\n /** Activity ID (platform-specific) */\n activityId?: string;\n /** Associated job ID */\n jobId?: string;\n /** Error message if failed */\n error?: string;\n}\n\n/**\n * Push token event for Live Activity updates\n */\nexport interface LiveActivityPushTokenEvent {\n /** Job ID */\n jobId: string;\n /** APNs push token */\n token: string;\n}\n\n// ============================================\n// Version & Compatibility\n// ============================================\n\n/**\n * SDK version info\n */\nexport const SDK_VERSION = '0.1.0';\n\n/**\n * Minimum API version required\n */\nexport const MIN_API_VERSION = '1.0.0';\n\n/**\n * SSE protocol version\n */\nexport const SSE_PROTOCOL_VERSION = '1.0';\n"],"mappings":";AAkgBO,IAAM,cAAc;AAKpB,IAAM,kBAAkB;AAKxB,IAAM,uBAAuB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @seenn/types - Shared TypeScript types for Seenn SDKs\n *\n * This package is the single source of truth for all Seenn type definitions.\n * All SDK packages (react-native, node, flutter) should depend on this package.\n *\n * @version 0.1.0\n * @license MIT\n */\n\n// ============================================\n// Core Job Types\n// ============================================\n\n/**\n * Job status values\n */\nexport type JobStatus =\n | 'pending'\n | 'queued'\n | 'running'\n | 'completed'\n | 'failed'\n | 'cancelled';\n\n/**\n * How parent job progress is calculated from children\n */\nexport type ChildProgressMode = 'average' | 'weighted' | 'sequential';\n\n/**\n * Main job object returned by API and SSE\n */\nexport interface SeennJob {\n /** Unique job identifier (ULID format) */\n jobId: string;\n /** User who owns this job */\n userId: string;\n /** Application ID */\n appId: string;\n /** Current job status */\n status: JobStatus;\n /** Human-readable job title */\n title: string;\n /** Job type for categorization */\n jobType: string;\n /** Workflow ID for ETA tracking (default: jobType) */\n workflowId?: string;\n /** Progress percentage (0-100) */\n progress: number;\n /** Current status message */\n message?: string;\n /** Stage information for multi-step jobs */\n stage?: StageInfo;\n /** Estimated completion timestamp (ISO 8601) */\n estimatedCompletionAt?: string;\n /** ETA confidence score (0.0 - 1.0) */\n etaConfidence?: number;\n /** Number of historical jobs used to calculate ETA */\n etaBasedOn?: number;\n /** Queue position info */\n queue?: QueueInfo;\n /** Job result on completion */\n result?: JobResult;\n /** Error details on failure */\n error?: JobError;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n /** Parent info (if this is a child job) */\n parent?: ParentInfo;\n /** Children stats (if this is a parent job) */\n children?: ChildrenStats;\n /** Progress calculation mode for parent jobs */\n childProgressMode?: ChildProgressMode;\n /** Job creation timestamp (ISO 8601) */\n createdAt: string;\n /** Last update timestamp (ISO 8601) */\n updatedAt: string;\n /** When the job started running (ISO 8601) */\n startedAt?: string;\n /** Job completion timestamp (ISO 8601) */\n completedAt?: string;\n}\n\n// ============================================\n// Stage & Queue Types\n// ============================================\n\n/**\n * Stage information for multi-step jobs\n */\nexport interface StageInfo {\n /** Current stage name */\n name: string;\n /** Current stage index (1-based) */\n current: number;\n /** Total number of stages */\n total: number;\n /** Optional stage description */\n description?: string;\n}\n\n/**\n * Queue position information\n */\nexport interface QueueInfo {\n /** Position in queue (1-based) */\n position: number;\n /** Total items in queue */\n total?: number;\n /** Queue name/identifier */\n queueName?: string;\n}\n\n// ============================================\n// Result & Error Types\n// ============================================\n\n/**\n * Job result on successful completion\n */\nexport interface JobResult {\n /** Result type (e.g., 'video', 'image', 'file') */\n type?: string;\n /** Result URL if applicable */\n url?: string;\n /** Additional result data */\n data?: Record<string, unknown>;\n}\n\n/**\n * Error details on job failure\n */\nexport interface JobError {\n /** Error code for programmatic handling */\n code: string;\n /** Human-readable error message */\n message: string;\n /** Additional error details */\n details?: Record<string, unknown>;\n}\n\n// ============================================\n// Parent-Child Types\n// ============================================\n\n/**\n * Parent info for child jobs\n */\nexport interface ParentInfo {\n /** Parent job ID */\n parentJobId: string;\n /** Child index within parent (0-based) */\n childIndex: number;\n}\n\n/**\n * Children stats for parent jobs\n */\nexport interface ChildrenStats {\n /** Total number of children */\n total: number;\n /** Number of completed children */\n completed: number;\n /** Number of failed children */\n failed: number;\n /** Number of running children */\n running: number;\n /** Number of pending children */\n pending: number;\n}\n\n/**\n * Summary of a child job (used in parent.children array)\n */\nexport interface ChildJobSummary {\n /** Child job ID */\n id: string;\n /** Child index within parent (0-based) */\n childIndex: number;\n /** Child job title */\n title: string;\n /** Child job status */\n status: JobStatus;\n /** Child progress (0-100) */\n progress: number;\n /** Child status message */\n message?: string;\n /** Child result */\n result?: JobResult;\n /** Child error */\n error?: JobError;\n /** Child creation timestamp */\n createdAt: string;\n /** Child last update timestamp */\n updatedAt: string;\n /** Child completion timestamp */\n completedAt?: string;\n}\n\n/**\n * Parent job with all its children\n */\nexport interface ParentWithChildren {\n /** Parent job */\n parent: SeennJob;\n /** List of child jobs */\n children: ChildJobSummary[];\n}\n\n// ============================================\n// SSE Types\n// ============================================\n\n/**\n * Connection state for SSE\n */\nexport type ConnectionState =\n | 'disconnected'\n | 'connecting'\n | 'connected'\n | 'reconnecting';\n\n/**\n * SSE event types\n */\nexport type SSEEventType =\n | 'connected'\n | 'job.sync'\n | 'job.started'\n | 'job.progress'\n | 'job.completed'\n | 'job.failed'\n | 'job.cancelled'\n | 'child.progress'\n | 'parent.updated'\n | 'in_app_message'\n | 'connection.idle'\n | 'heartbeat'\n | 'error';\n\n/**\n * SSE event wrapper\n */\nexport interface SSEEvent {\n /** Event type */\n event: SSEEventType;\n /** Event data */\n data: unknown;\n /** Event ID for replay */\n id?: string;\n}\n\n// ============================================\n// In-App Message Types\n// ============================================\n\n/**\n * In-app message types\n */\nexport type InAppMessageType =\n | 'job_complete_banner'\n | 'job_failed_modal'\n | 'job_toast';\n\n/**\n * In-app message for UI notifications\n */\nexport interface InAppMessage {\n /** Message ID */\n messageId: string;\n /** Message type */\n type: InAppMessageType;\n /** Associated job ID */\n jobId: string;\n /** Message title */\n title: string;\n /** Message body */\n body?: string;\n /** Call-to-action text */\n cta?: string;\n /** Call-to-action URL */\n ctaUrl?: string;\n}\n\n// ============================================\n// API Types\n// ============================================\n\n/**\n * Create job request parameters\n */\nexport interface CreateJobParams {\n /** User ID */\n userId: string;\n /** Job type */\n jobType: string;\n /** Job title */\n title: string;\n /** Workflow ID for ETA tracking (default: jobType) */\n workflowId?: string;\n /** Initial message */\n message?: string;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n /** Estimated duration in ms (for ETA default) */\n estimatedDuration?: number;\n /** Parent job ID (for child jobs) */\n parentJobId?: string;\n /** Child index (for child jobs) */\n childIndex?: number;\n /** Total children (for parent jobs) */\n totalChildren?: number;\n /** Child progress mode (for parent jobs) */\n childProgressMode?: ChildProgressMode;\n}\n\n/**\n * Update job request parameters\n */\nexport interface UpdateJobParams {\n /** New progress (0-100) */\n progress?: number;\n /** New message */\n message?: string;\n /** New stage info */\n stage?: StageInfo;\n /** Custom metadata to merge */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Complete job request parameters\n */\nexport interface CompleteJobParams {\n /** Job result */\n result?: JobResult;\n /** Final message */\n message?: string;\n}\n\n/**\n * Fail job request parameters\n */\nexport interface FailJobParams {\n /** Error details */\n error: JobError;\n}\n\n// ============================================\n// Webhook Types\n// ============================================\n\n/**\n * Webhook event types\n */\nexport type WebhookEventType =\n | 'job.started'\n | 'job.progress'\n | 'job.completed'\n | 'job.failed'\n | 'job.cancelled';\n\n/**\n * Webhook payload\n */\nexport interface WebhookPayload {\n /** Event type */\n event: WebhookEventType;\n /** Job data */\n job: SeennJob;\n /** Event timestamp (ISO 8601) */\n timestamp: string;\n /** Webhook delivery ID */\n deliveryId: string;\n}\n\n// ============================================\n// ETA Types\n// ============================================\n\n/**\n * ETA statistics for a workflow/jobType\n */\nexport interface EtaStats {\n /** ETA key (workflowId or jobType) */\n etaKey: string;\n /** Number of completed jobs */\n count: number;\n /** Average duration in ms */\n avgDuration: number;\n /** Minimum duration in ms */\n minDuration: number;\n /** Maximum duration in ms */\n maxDuration: number;\n /** Default duration if no history */\n defaultDuration?: number;\n /** Last updated timestamp */\n lastUpdated: string;\n}\n\n// ============================================\n// SDK Configuration Types\n// ============================================\n\n/**\n * Connection mode for real-time updates\n */\nexport type ConnectionMode = 'sse' | 'polling';\n\n/**\n * Base SDK configuration\n */\nexport interface SeennConfig {\n /** API base URL */\n baseUrl: string;\n /** API key (pk_* for client SDKs, sk_* for server SDKs) */\n apiKey?: string;\n /** SSE endpoint URL (default: baseUrl + /v1/sse) */\n sseUrl?: string;\n /** Connection mode: 'sse' (default) or 'polling' (for self-hosted) */\n mode?: ConnectionMode;\n /** Polling interval in ms (default: 5000, only used when mode is 'polling') */\n pollInterval?: number;\n /** Enable auto-reconnect (default: true) */\n reconnect?: boolean;\n /** Reconnect interval in ms (default: 1000) */\n reconnectInterval?: number;\n /** Max reconnect attempts (default: 10) */\n maxReconnectAttempts?: number;\n /** Enable debug logging (default: false) */\n debug?: boolean;\n}\n\n// ============================================\n// Live Activity Types (iOS/Android)\n// ============================================\n\n/**\n * Live Activity start parameters\n */\nexport interface LiveActivityStartParams {\n /** Job ID */\n jobId: string;\n /** Activity title */\n title: string;\n /** Job type for icon selection */\n jobType?: string;\n /** Initial progress (0-100) */\n initialProgress?: number;\n /** Initial message */\n initialMessage?: string;\n}\n\n/**\n * Live Activity update parameters\n */\nexport interface LiveActivityUpdateParams {\n /** Job ID */\n jobId: string;\n /** New progress (0-100) */\n progress?: number;\n /** New status */\n status?: JobStatus;\n /** New message */\n message?: string;\n /** Stage info */\n stage?: StageInfo;\n /** ETA timestamp (Unix ms) */\n estimatedEndTime?: number;\n}\n\n/**\n * Live Activity end parameters\n */\nexport interface LiveActivityEndParams {\n /** Job ID */\n jobId: string;\n /** Final status */\n finalStatus?: JobStatus;\n /** Final progress */\n finalProgress?: number;\n /** Final message */\n message?: string;\n /** Result URL */\n resultUrl?: string;\n /** Error message */\n errorMessage?: string;\n /** Dismiss after seconds (default: 300) */\n dismissAfter?: number;\n}\n\n/**\n * Live Activity result\n */\nexport interface LiveActivityResult {\n /** Success flag */\n success: boolean;\n /** Activity ID (platform-specific) */\n activityId?: string;\n /** Associated job ID */\n jobId?: string;\n /** Error message if failed */\n error?: string;\n}\n\n/**\n * Push token event for Live Activity updates\n */\nexport interface LiveActivityPushTokenEvent {\n /** Job ID */\n jobId: string;\n /** APNs push token */\n token: string;\n}\n\n// ============================================\n// Version & Compatibility\n// ============================================\n\n/**\n * SDK version info\n */\nexport const SDK_VERSION = '0.2.0';\n\n/**\n * Minimum API version required\n */\nexport const MIN_API_VERSION = '1.0.0';\n\n/**\n * SSE protocol version\n */\nexport const SSE_PROTOCOL_VERSION = '1.0';\n"],"mappings":";AA2gBO,IAAM,cAAc;AAKpB,IAAM,kBAAkB;AAKxB,IAAM,uBAAuB;","names":[]}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -403,16 +403,25 @@ export interface EtaStats {
|
|
|
403
403
|
// SDK Configuration Types
|
|
404
404
|
// ============================================
|
|
405
405
|
|
|
406
|
+
/**
|
|
407
|
+
* Connection mode for real-time updates
|
|
408
|
+
*/
|
|
409
|
+
export type ConnectionMode = 'sse' | 'polling';
|
|
410
|
+
|
|
406
411
|
/**
|
|
407
412
|
* Base SDK configuration
|
|
408
413
|
*/
|
|
409
414
|
export interface SeennConfig {
|
|
410
415
|
/** API base URL */
|
|
411
416
|
baseUrl: string;
|
|
412
|
-
/**
|
|
413
|
-
|
|
417
|
+
/** API key (pk_* for client SDKs, sk_* for server SDKs) */
|
|
418
|
+
apiKey?: string;
|
|
414
419
|
/** SSE endpoint URL (default: baseUrl + /v1/sse) */
|
|
415
420
|
sseUrl?: string;
|
|
421
|
+
/** Connection mode: 'sse' (default) or 'polling' (for self-hosted) */
|
|
422
|
+
mode?: ConnectionMode;
|
|
423
|
+
/** Polling interval in ms (default: 5000, only used when mode is 'polling') */
|
|
424
|
+
pollInterval?: number;
|
|
416
425
|
/** Enable auto-reconnect (default: true) */
|
|
417
426
|
reconnect?: boolean;
|
|
418
427
|
/** Reconnect interval in ms (default: 1000) */
|
|
@@ -512,7 +521,7 @@ export interface LiveActivityPushTokenEvent {
|
|
|
512
521
|
/**
|
|
513
522
|
* SDK version info
|
|
514
523
|
*/
|
|
515
|
-
export const SDK_VERSION = '0.
|
|
524
|
+
export const SDK_VERSION = '0.2.0';
|
|
516
525
|
|
|
517
526
|
/**
|
|
518
527
|
* Minimum API version required
|