@seenn/types 0.3.0 → 0.5.0
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 +96 -37
- package/dist/index.d.ts +96 -37
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
- package/src/index.ts +116 -61
package/dist/index.d.mts
CHANGED
|
@@ -184,25 +184,6 @@ interface ParentWithChildren {
|
|
|
184
184
|
/** List of child jobs */
|
|
185
185
|
children: ChildJobSummary[];
|
|
186
186
|
}
|
|
187
|
-
/**
|
|
188
|
-
* Connection state for SSE
|
|
189
|
-
*/
|
|
190
|
-
type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
191
|
-
/**
|
|
192
|
-
* SSE event types
|
|
193
|
-
*/
|
|
194
|
-
type SSEEventType = 'connected' | 'job.sync' | 'job.started' | 'job.progress' | 'job.completed' | 'job.failed' | 'job.cancelled' | 'child.progress' | 'parent.updated' | 'in_app_message' | 'connection.idle' | 'heartbeat' | 'error';
|
|
195
|
-
/**
|
|
196
|
-
* SSE event wrapper
|
|
197
|
-
*/
|
|
198
|
-
interface SSEEvent {
|
|
199
|
-
/** Event type */
|
|
200
|
-
event: SSEEventType;
|
|
201
|
-
/** Event data */
|
|
202
|
-
data: unknown;
|
|
203
|
-
/** Event ID for replay */
|
|
204
|
-
id?: string;
|
|
205
|
-
}
|
|
206
187
|
/**
|
|
207
188
|
* In-app message types
|
|
208
189
|
*/
|
|
@@ -274,6 +255,10 @@ interface CompleteJobParams {
|
|
|
274
255
|
result?: JobResult;
|
|
275
256
|
/** Final message */
|
|
276
257
|
message?: string;
|
|
258
|
+
/** Push notification options */
|
|
259
|
+
push?: PushOptions;
|
|
260
|
+
/** Live Activity options */
|
|
261
|
+
liveActivity?: LiveActivityOptions;
|
|
277
262
|
}
|
|
278
263
|
/**
|
|
279
264
|
* Fail job request parameters
|
|
@@ -281,6 +266,21 @@ interface CompleteJobParams {
|
|
|
281
266
|
interface FailJobParams {
|
|
282
267
|
/** Error details */
|
|
283
268
|
error: JobError;
|
|
269
|
+
/** Push notification options */
|
|
270
|
+
push?: PushOptions;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Progress job request parameters
|
|
274
|
+
*/
|
|
275
|
+
interface ProgressJobParams {
|
|
276
|
+
/** New progress (0-100) */
|
|
277
|
+
progress: number;
|
|
278
|
+
/** New message */
|
|
279
|
+
message?: string;
|
|
280
|
+
/** New stage info */
|
|
281
|
+
stage?: StageInfo;
|
|
282
|
+
/** Push notification options */
|
|
283
|
+
push?: PushOptions;
|
|
284
284
|
}
|
|
285
285
|
/**
|
|
286
286
|
* Webhook event types
|
|
@@ -320,8 +320,15 @@ interface EtaStats {
|
|
|
320
320
|
}
|
|
321
321
|
/**
|
|
322
322
|
* Connection mode for real-time updates
|
|
323
|
+
* Note: SSE was removed in v0.4.0. Polling is now the only supported mode.
|
|
324
|
+
*/
|
|
325
|
+
type ConnectionMode = 'polling';
|
|
326
|
+
/**
|
|
327
|
+
* iOS push authorization mode
|
|
328
|
+
* - 'standard': Shows permission prompt, full push access
|
|
329
|
+
* - 'provisional': No prompt, quiet notifications only (iOS 12+)
|
|
323
330
|
*/
|
|
324
|
-
type
|
|
331
|
+
type PushAuthorizationMode = 'standard' | 'provisional';
|
|
325
332
|
/**
|
|
326
333
|
* Base SDK configuration
|
|
327
334
|
*/
|
|
@@ -332,20 +339,32 @@ interface SeennConfig {
|
|
|
332
339
|
apiKey?: string;
|
|
333
340
|
/** API base path prefix (default: '/v1'). Self-hosted backends can use custom paths. */
|
|
334
341
|
basePath?: string;
|
|
335
|
-
/**
|
|
336
|
-
sseUrl?: string;
|
|
337
|
-
/** Connection mode: 'sse' (default) or 'polling' (for self-hosted) */
|
|
338
|
-
mode?: ConnectionMode;
|
|
339
|
-
/** Polling interval in ms (default: 5000, only used when mode is 'polling') */
|
|
342
|
+
/** Polling interval in ms (default: 5000) */
|
|
340
343
|
pollInterval?: number;
|
|
341
|
-
/** Enable auto-reconnect (default: true) */
|
|
342
|
-
reconnect?: boolean;
|
|
343
|
-
/** Reconnect interval in ms (default: 1000) */
|
|
344
|
-
reconnectInterval?: number;
|
|
345
|
-
/** Max reconnect attempts (default: 10) */
|
|
346
|
-
maxReconnectAttempts?: number;
|
|
347
344
|
/** Enable debug logging (default: false) */
|
|
348
345
|
debug?: boolean;
|
|
346
|
+
/** iOS push authorization mode (default: 'standard') */
|
|
347
|
+
pushAuthorizationMode?: PushAuthorizationMode;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* iOS push authorization status
|
|
351
|
+
* - 'notDetermined': Permission never requested
|
|
352
|
+
* - 'denied': User denied permission
|
|
353
|
+
* - 'authorized': Full push access granted
|
|
354
|
+
* - 'provisional': Quiet notifications only (iOS 12+)
|
|
355
|
+
* - 'ephemeral': App Clips only (iOS 14+)
|
|
356
|
+
*/
|
|
357
|
+
type PushAuthorizationStatus = 'notDetermined' | 'denied' | 'authorized' | 'provisional' | 'ephemeral';
|
|
358
|
+
/**
|
|
359
|
+
* Push authorization information
|
|
360
|
+
*/
|
|
361
|
+
interface PushAuthorizationInfo {
|
|
362
|
+
/** Current authorization status */
|
|
363
|
+
status: PushAuthorizationStatus;
|
|
364
|
+
/** Whether current authorization is provisional */
|
|
365
|
+
isProvisional: boolean;
|
|
366
|
+
/** Whether user can be prompted to upgrade to full authorization */
|
|
367
|
+
canRequestFullAuthorization: boolean;
|
|
349
368
|
}
|
|
350
369
|
/**
|
|
351
370
|
* Live Activity start parameters
|
|
@@ -606,17 +625,57 @@ interface SeennWidgetConfig {
|
|
|
606
625
|
/** CTA button configuration */
|
|
607
626
|
ctaButton?: LiveActivityCTAConfig;
|
|
608
627
|
}
|
|
628
|
+
/**
|
|
629
|
+
* Alert push notification options
|
|
630
|
+
*/
|
|
631
|
+
interface AlertPushOptions {
|
|
632
|
+
/** Notification title */
|
|
633
|
+
title: string;
|
|
634
|
+
/** Notification body */
|
|
635
|
+
body: string;
|
|
636
|
+
/** Sound name (default: 'default') */
|
|
637
|
+
sound?: string;
|
|
638
|
+
/** Badge number */
|
|
639
|
+
badge?: number;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Rich push notification options (TikTok-style)
|
|
643
|
+
*/
|
|
644
|
+
interface RichPushOptions {
|
|
645
|
+
/** Sender name for messaging-style notification */
|
|
646
|
+
senderName: string;
|
|
647
|
+
/** Sender avatar URL for notification image */
|
|
648
|
+
senderAvatar?: string;
|
|
649
|
+
/** Mark as Time Sensitive (iOS 15+) */
|
|
650
|
+
timeSensitive?: boolean;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Push configuration options for job updates
|
|
654
|
+
*/
|
|
655
|
+
interface PushOptions {
|
|
656
|
+
/** Send Live Activity update (default: true) */
|
|
657
|
+
liveActivity?: boolean;
|
|
658
|
+
/** Send silent push for background sync (default: true) */
|
|
659
|
+
silent?: boolean;
|
|
660
|
+
/** Alert push notification */
|
|
661
|
+
alert?: AlertPushOptions;
|
|
662
|
+
/** Rich push notification (TikTok-style) */
|
|
663
|
+
richPush?: RichPushOptions;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Live Activity options for backend SDK
|
|
667
|
+
*/
|
|
668
|
+
interface LiveActivityOptions {
|
|
669
|
+
/** CTA button to show on completion/failure */
|
|
670
|
+
ctaButton?: LiveActivityCTAButton;
|
|
671
|
+
}
|
|
609
672
|
/**
|
|
610
673
|
* SDK version info
|
|
611
674
|
*/
|
|
612
|
-
declare const SDK_VERSION = "0.
|
|
675
|
+
declare const SDK_VERSION = "0.5.0";
|
|
613
676
|
/**
|
|
614
677
|
* Minimum API version required
|
|
615
678
|
*/
|
|
616
679
|
declare const MIN_API_VERSION = "1.0.0";
|
|
617
|
-
/**
|
|
618
|
-
* SSE protocol version
|
|
619
|
-
*/
|
|
620
|
-
declare const SSE_PROTOCOL_VERSION = "1.0";
|
|
621
680
|
|
|
622
|
-
export { type ChildJobSummary, type ChildProgressMode, type ChildrenStats, type CompleteJobParams, type ConnectionMode, type
|
|
681
|
+
export { type AlertPushOptions, type ChildJobSummary, type ChildProgressMode, type ChildrenStats, type CompleteJobParams, type ConnectionMode, type CreateJobParams, type EtaStats, type FailJobParams, type FontConfig, type FontWeight, type GradientPoint, type InAppMessage, type InAppMessageType, type JobError, type JobResult, type JobStatus, type JobTypeConfig, type LiveActivityCTAButton, type LiveActivityCTAButtonStyle, type LiveActivityCTAConfig, type LiveActivityCTAStyle, type LiveActivityColors, type LiveActivityEndParams, type LiveActivityFonts, type LiveActivityGradient, type LiveActivityLayout, type LiveActivityOptions, type LiveActivityPushTokenEvent, type LiveActivityResult, type LiveActivityStartParams, type LiveActivityThemeConfig, type LiveActivityThemePreset, type LiveActivityUpdateParams, MIN_API_VERSION, type ParentInfo, type ParentWithChildren, type ProgressJobParams, type PushAuthorizationInfo, type PushAuthorizationMode, type PushAuthorizationStatus, type PushOptions, type QueueInfo, type RichPushOptions, SDK_VERSION, type SeennConfig, type SeennJob, type SeennWidgetConfig, type StageInfo, type UpdateJobParams, type WebhookEventType, type WebhookPayload, type WidgetExtensionConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -184,25 +184,6 @@ interface ParentWithChildren {
|
|
|
184
184
|
/** List of child jobs */
|
|
185
185
|
children: ChildJobSummary[];
|
|
186
186
|
}
|
|
187
|
-
/**
|
|
188
|
-
* Connection state for SSE
|
|
189
|
-
*/
|
|
190
|
-
type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
191
|
-
/**
|
|
192
|
-
* SSE event types
|
|
193
|
-
*/
|
|
194
|
-
type SSEEventType = 'connected' | 'job.sync' | 'job.started' | 'job.progress' | 'job.completed' | 'job.failed' | 'job.cancelled' | 'child.progress' | 'parent.updated' | 'in_app_message' | 'connection.idle' | 'heartbeat' | 'error';
|
|
195
|
-
/**
|
|
196
|
-
* SSE event wrapper
|
|
197
|
-
*/
|
|
198
|
-
interface SSEEvent {
|
|
199
|
-
/** Event type */
|
|
200
|
-
event: SSEEventType;
|
|
201
|
-
/** Event data */
|
|
202
|
-
data: unknown;
|
|
203
|
-
/** Event ID for replay */
|
|
204
|
-
id?: string;
|
|
205
|
-
}
|
|
206
187
|
/**
|
|
207
188
|
* In-app message types
|
|
208
189
|
*/
|
|
@@ -274,6 +255,10 @@ interface CompleteJobParams {
|
|
|
274
255
|
result?: JobResult;
|
|
275
256
|
/** Final message */
|
|
276
257
|
message?: string;
|
|
258
|
+
/** Push notification options */
|
|
259
|
+
push?: PushOptions;
|
|
260
|
+
/** Live Activity options */
|
|
261
|
+
liveActivity?: LiveActivityOptions;
|
|
277
262
|
}
|
|
278
263
|
/**
|
|
279
264
|
* Fail job request parameters
|
|
@@ -281,6 +266,21 @@ interface CompleteJobParams {
|
|
|
281
266
|
interface FailJobParams {
|
|
282
267
|
/** Error details */
|
|
283
268
|
error: JobError;
|
|
269
|
+
/** Push notification options */
|
|
270
|
+
push?: PushOptions;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Progress job request parameters
|
|
274
|
+
*/
|
|
275
|
+
interface ProgressJobParams {
|
|
276
|
+
/** New progress (0-100) */
|
|
277
|
+
progress: number;
|
|
278
|
+
/** New message */
|
|
279
|
+
message?: string;
|
|
280
|
+
/** New stage info */
|
|
281
|
+
stage?: StageInfo;
|
|
282
|
+
/** Push notification options */
|
|
283
|
+
push?: PushOptions;
|
|
284
284
|
}
|
|
285
285
|
/**
|
|
286
286
|
* Webhook event types
|
|
@@ -320,8 +320,15 @@ interface EtaStats {
|
|
|
320
320
|
}
|
|
321
321
|
/**
|
|
322
322
|
* Connection mode for real-time updates
|
|
323
|
+
* Note: SSE was removed in v0.4.0. Polling is now the only supported mode.
|
|
324
|
+
*/
|
|
325
|
+
type ConnectionMode = 'polling';
|
|
326
|
+
/**
|
|
327
|
+
* iOS push authorization mode
|
|
328
|
+
* - 'standard': Shows permission prompt, full push access
|
|
329
|
+
* - 'provisional': No prompt, quiet notifications only (iOS 12+)
|
|
323
330
|
*/
|
|
324
|
-
type
|
|
331
|
+
type PushAuthorizationMode = 'standard' | 'provisional';
|
|
325
332
|
/**
|
|
326
333
|
* Base SDK configuration
|
|
327
334
|
*/
|
|
@@ -332,20 +339,32 @@ interface SeennConfig {
|
|
|
332
339
|
apiKey?: string;
|
|
333
340
|
/** API base path prefix (default: '/v1'). Self-hosted backends can use custom paths. */
|
|
334
341
|
basePath?: string;
|
|
335
|
-
/**
|
|
336
|
-
sseUrl?: string;
|
|
337
|
-
/** Connection mode: 'sse' (default) or 'polling' (for self-hosted) */
|
|
338
|
-
mode?: ConnectionMode;
|
|
339
|
-
/** Polling interval in ms (default: 5000, only used when mode is 'polling') */
|
|
342
|
+
/** Polling interval in ms (default: 5000) */
|
|
340
343
|
pollInterval?: number;
|
|
341
|
-
/** Enable auto-reconnect (default: true) */
|
|
342
|
-
reconnect?: boolean;
|
|
343
|
-
/** Reconnect interval in ms (default: 1000) */
|
|
344
|
-
reconnectInterval?: number;
|
|
345
|
-
/** Max reconnect attempts (default: 10) */
|
|
346
|
-
maxReconnectAttempts?: number;
|
|
347
344
|
/** Enable debug logging (default: false) */
|
|
348
345
|
debug?: boolean;
|
|
346
|
+
/** iOS push authorization mode (default: 'standard') */
|
|
347
|
+
pushAuthorizationMode?: PushAuthorizationMode;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* iOS push authorization status
|
|
351
|
+
* - 'notDetermined': Permission never requested
|
|
352
|
+
* - 'denied': User denied permission
|
|
353
|
+
* - 'authorized': Full push access granted
|
|
354
|
+
* - 'provisional': Quiet notifications only (iOS 12+)
|
|
355
|
+
* - 'ephemeral': App Clips only (iOS 14+)
|
|
356
|
+
*/
|
|
357
|
+
type PushAuthorizationStatus = 'notDetermined' | 'denied' | 'authorized' | 'provisional' | 'ephemeral';
|
|
358
|
+
/**
|
|
359
|
+
* Push authorization information
|
|
360
|
+
*/
|
|
361
|
+
interface PushAuthorizationInfo {
|
|
362
|
+
/** Current authorization status */
|
|
363
|
+
status: PushAuthorizationStatus;
|
|
364
|
+
/** Whether current authorization is provisional */
|
|
365
|
+
isProvisional: boolean;
|
|
366
|
+
/** Whether user can be prompted to upgrade to full authorization */
|
|
367
|
+
canRequestFullAuthorization: boolean;
|
|
349
368
|
}
|
|
350
369
|
/**
|
|
351
370
|
* Live Activity start parameters
|
|
@@ -606,17 +625,57 @@ interface SeennWidgetConfig {
|
|
|
606
625
|
/** CTA button configuration */
|
|
607
626
|
ctaButton?: LiveActivityCTAConfig;
|
|
608
627
|
}
|
|
628
|
+
/**
|
|
629
|
+
* Alert push notification options
|
|
630
|
+
*/
|
|
631
|
+
interface AlertPushOptions {
|
|
632
|
+
/** Notification title */
|
|
633
|
+
title: string;
|
|
634
|
+
/** Notification body */
|
|
635
|
+
body: string;
|
|
636
|
+
/** Sound name (default: 'default') */
|
|
637
|
+
sound?: string;
|
|
638
|
+
/** Badge number */
|
|
639
|
+
badge?: number;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Rich push notification options (TikTok-style)
|
|
643
|
+
*/
|
|
644
|
+
interface RichPushOptions {
|
|
645
|
+
/** Sender name for messaging-style notification */
|
|
646
|
+
senderName: string;
|
|
647
|
+
/** Sender avatar URL for notification image */
|
|
648
|
+
senderAvatar?: string;
|
|
649
|
+
/** Mark as Time Sensitive (iOS 15+) */
|
|
650
|
+
timeSensitive?: boolean;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Push configuration options for job updates
|
|
654
|
+
*/
|
|
655
|
+
interface PushOptions {
|
|
656
|
+
/** Send Live Activity update (default: true) */
|
|
657
|
+
liveActivity?: boolean;
|
|
658
|
+
/** Send silent push for background sync (default: true) */
|
|
659
|
+
silent?: boolean;
|
|
660
|
+
/** Alert push notification */
|
|
661
|
+
alert?: AlertPushOptions;
|
|
662
|
+
/** Rich push notification (TikTok-style) */
|
|
663
|
+
richPush?: RichPushOptions;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Live Activity options for backend SDK
|
|
667
|
+
*/
|
|
668
|
+
interface LiveActivityOptions {
|
|
669
|
+
/** CTA button to show on completion/failure */
|
|
670
|
+
ctaButton?: LiveActivityCTAButton;
|
|
671
|
+
}
|
|
609
672
|
/**
|
|
610
673
|
* SDK version info
|
|
611
674
|
*/
|
|
612
|
-
declare const SDK_VERSION = "0.
|
|
675
|
+
declare const SDK_VERSION = "0.5.0";
|
|
613
676
|
/**
|
|
614
677
|
* Minimum API version required
|
|
615
678
|
*/
|
|
616
679
|
declare const MIN_API_VERSION = "1.0.0";
|
|
617
|
-
/**
|
|
618
|
-
* SSE protocol version
|
|
619
|
-
*/
|
|
620
|
-
declare const SSE_PROTOCOL_VERSION = "1.0";
|
|
621
680
|
|
|
622
|
-
export { type ChildJobSummary, type ChildProgressMode, type ChildrenStats, type CompleteJobParams, type ConnectionMode, type
|
|
681
|
+
export { type AlertPushOptions, type ChildJobSummary, type ChildProgressMode, type ChildrenStats, type CompleteJobParams, type ConnectionMode, type CreateJobParams, type EtaStats, type FailJobParams, type FontConfig, type FontWeight, type GradientPoint, type InAppMessage, type InAppMessageType, type JobError, type JobResult, type JobStatus, type JobTypeConfig, type LiveActivityCTAButton, type LiveActivityCTAButtonStyle, type LiveActivityCTAConfig, type LiveActivityCTAStyle, type LiveActivityColors, type LiveActivityEndParams, type LiveActivityFonts, type LiveActivityGradient, type LiveActivityLayout, type LiveActivityOptions, type LiveActivityPushTokenEvent, type LiveActivityResult, type LiveActivityStartParams, type LiveActivityThemeConfig, type LiveActivityThemePreset, type LiveActivityUpdateParams, MIN_API_VERSION, type ParentInfo, type ParentWithChildren, type ProgressJobParams, type PushAuthorizationInfo, type PushAuthorizationMode, type PushAuthorizationStatus, type PushOptions, type QueueInfo, type RichPushOptions, SDK_VERSION, type SeennConfig, type SeennJob, type SeennWidgetConfig, type StageInfo, type UpdateJobParams, type WebhookEventType, type WebhookPayload, type WidgetExtensionConfig };
|
package/dist/index.js
CHANGED
|
@@ -21,18 +21,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
MIN_API_VERSION: () => MIN_API_VERSION,
|
|
24
|
-
SDK_VERSION: () => SDK_VERSION
|
|
25
|
-
SSE_PROTOCOL_VERSION: () => SSE_PROTOCOL_VERSION
|
|
24
|
+
SDK_VERSION: () => SDK_VERSION
|
|
26
25
|
});
|
|
27
26
|
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
var SDK_VERSION = "0.
|
|
27
|
+
var SDK_VERSION = "0.5.0";
|
|
29
28
|
var MIN_API_VERSION = "1.0.0";
|
|
30
|
-
var SSE_PROTOCOL_VERSION = "1.0";
|
|
31
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
30
|
0 && (module.exports = {
|
|
33
31
|
MIN_API_VERSION,
|
|
34
|
-
SDK_VERSION
|
|
35
|
-
SSE_PROTOCOL_VERSION
|
|
32
|
+
SDK_VERSION
|
|
36
33
|
});
|
|
37
34
|
/**
|
|
38
35
|
* @seenn/types - Shared TypeScript types for Seenn SDKs
|
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 * CTA button text (optional backend override for Live Activity)\n * If provided, overrides mobile SDK default CTA\n */\n ctaButtonText?: string;\n /**\n * CTA deep link (optional backend override for Live Activity)\n * If provided, overrides mobile SDK default CTA\n */\n ctaDeepLink?: 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 /** API base path prefix (default: '/v1'). Self-hosted backends can use custom paths. */\n basePath?: string;\n /** SSE endpoint URL (default: baseUrl + basePath + /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 /** CTA button to show on completion/failure */\n ctaButton?: LiveActivityCTAButton;\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// Live Activity CTA Button Types\n// ============================================\n\n/**\n * CTA (Call-to-Action) button style\n */\nexport type LiveActivityCTAButtonStyle = 'primary' | 'secondary' | 'outline';\n\n/**\n * CTA button configuration for Live Activity completion\n */\nexport interface LiveActivityCTAButton {\n /** Button text */\n text: string;\n /** Deep link URL to open when tapped */\n deepLink: string;\n /** Button style preset */\n style?: LiveActivityCTAButtonStyle;\n /** Custom background color (hex) */\n backgroundColor?: string;\n /** Custom text color (hex) */\n textColor?: string;\n /** Corner radius (default: 20) */\n cornerRadius?: number;\n}\n\n// ============================================\n// Live Activity Theme Configuration Types\n// ============================================\n\n/**\n * Gradient point positions\n */\nexport type GradientPoint =\n | 'top'\n | 'topLeading'\n | 'topTrailing'\n | 'leading'\n | 'trailing'\n | 'bottom'\n | 'bottomLeading'\n | 'bottomTrailing'\n | 'center';\n\n/**\n * Built-in theme presets\n */\nexport type LiveActivityThemePreset =\n | 'default'\n | 'gradient-sunset'\n | 'gradient-ocean'\n | 'gradient-purple'\n | 'minimal-dark'\n | 'minimal-light';\n\n/**\n * Color configuration for Live Activity\n */\nexport interface LiveActivityColors {\n /** Background color (hex) */\n background?: string;\n /** Primary text color (hex) */\n primary?: string;\n /** Secondary text color (hex) */\n secondary?: string;\n /** Progress bar fill color (hex) */\n progressBar?: string;\n /** Progress bar track color (hex) */\n progressTrack?: string;\n /** Status color for running state (hex) */\n statusRunning?: string;\n /** Status color for completed state (hex) */\n statusCompleted?: string;\n /** Status color for failed state (hex) */\n statusFailed?: string;\n}\n\n/**\n * Gradient configuration for Live Activity background\n */\nexport interface LiveActivityGradient {\n /** Gradient color stops (hex values) */\n colors: string[];\n /** Start point of gradient */\n startPoint?: GradientPoint;\n /** End point of gradient */\n endPoint?: GradientPoint;\n}\n\n/**\n * Layout configuration for Live Activity\n */\nexport interface LiveActivityLayout {\n /** Progress bar height in points */\n progressBarHeight?: number;\n /** Corner radius for progress bar */\n progressBarCornerRadius?: number;\n /** Overall corner radius */\n cornerRadius?: number;\n /** Show job type icon */\n showIcon?: boolean;\n /** Show ETA countdown */\n showEta?: boolean;\n /** Show current stage */\n showStage?: boolean;\n /** Show progress percentage text */\n showProgressText?: boolean;\n /** Compact mode for Dynamic Island */\n compactMode?: boolean;\n}\n\n/**\n * Font weight options\n */\nexport type FontWeight = 'regular' | 'medium' | 'semibold' | 'bold';\n\n/**\n * Font configuration\n */\nexport interface FontConfig {\n /** Font size in points */\n size?: number;\n /** Font weight */\n weight?: FontWeight;\n}\n\n/**\n * Font configuration for Live Activity text elements\n */\nexport interface LiveActivityFonts {\n /** Title text font */\n title?: FontConfig;\n /** Progress/percentage text font */\n progress?: FontConfig;\n /** Message text font */\n message?: FontConfig;\n /** Stage text font */\n stage?: FontConfig;\n /** ETA text font */\n eta?: FontConfig;\n}\n\n/**\n * Job type specific icon and color configuration\n */\nexport interface JobTypeConfig {\n /** SF Symbol name (iOS) */\n icon?: string;\n /** Icon tint color (hex) */\n color?: string;\n /** Custom display name */\n displayName?: string;\n}\n\n/**\n * CTA button default styling\n */\nexport interface LiveActivityCTAStyle {\n /** Background color (hex) */\n backgroundColor?: string;\n /** Text color (hex) */\n textColor?: string;\n /** Corner radius */\n cornerRadius?: number;\n /** Font configuration */\n font?: FontConfig;\n}\n\n/**\n * CTA button configuration in theme\n */\nexport interface LiveActivityCTAConfig {\n /** Default CTA button style */\n style?: LiveActivityCTAStyle;\n /** Show CTA on these statuses */\n showOn?: ('completed' | 'failed')[];\n}\n\n/**\n * Complete theme configuration for Live Activity\n */\nexport interface LiveActivityThemeConfig {\n /** Use a built-in preset as base */\n preset?: LiveActivityThemePreset;\n /** Custom colors (override preset) */\n colors?: LiveActivityColors;\n /** Gradient background (overrides solid color) */\n gradient?: LiveActivityGradient;\n /** Layout options */\n layout?: LiveActivityLayout;\n /** Font configuration */\n fonts?: LiveActivityFonts;\n /** CTA button configuration */\n cta?: LiveActivityCTAConfig;\n}\n\n/**\n * Widget extension configuration\n */\nexport interface WidgetExtensionConfig {\n /** Widget extension name (default: 'SeennWidgetExtension') */\n name?: string;\n /** iOS deployment target (default: '16.1') */\n deploymentTarget?: string;\n /** App Groups identifier (auto-generated if not provided) */\n appGroupId?: string;\n}\n\n/**\n * Complete Seenn widget configuration file format\n */\nexport interface SeennWidgetConfig {\n /** Widget extension settings */\n widget?: WidgetExtensionConfig;\n /** Theme configuration */\n theme?: LiveActivityThemeConfig;\n /** Job type specific configurations */\n jobTypes?: Record<string, JobTypeConfig>;\n /** CTA button configuration */\n ctaButton?: LiveActivityCTAConfig;\n}\n\n// ============================================\n// Version & Compatibility\n// ============================================\n\n/**\n * SDK version info\n */\nexport const SDK_VERSION = '0.3.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;AAwvBO,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 * CTA button text (optional backend override for Live Activity)\n * If provided, overrides mobile SDK default CTA\n */\n ctaButtonText?: string;\n /**\n * CTA deep link (optional backend override for Live Activity)\n * If provided, overrides mobile SDK default CTA\n */\n ctaDeepLink?: 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// 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 /** Push notification options */\n push?: PushOptions;\n /** Live Activity options */\n liveActivity?: LiveActivityOptions;\n}\n\n/**\n * Fail job request parameters\n */\nexport interface FailJobParams {\n /** Error details */\n error: JobError;\n /** Push notification options */\n push?: PushOptions;\n}\n\n/**\n * Progress job request parameters\n */\nexport interface ProgressJobParams {\n /** New progress (0-100) */\n progress: number;\n /** New message */\n message?: string;\n /** New stage info */\n stage?: StageInfo;\n /** Push notification options */\n push?: PushOptions;\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 * Note: SSE was removed in v0.4.0. Polling is now the only supported mode.\n */\nexport type ConnectionMode = 'polling';\n\n/**\n * iOS push authorization mode\n * - 'standard': Shows permission prompt, full push access\n * - 'provisional': No prompt, quiet notifications only (iOS 12+)\n */\nexport type PushAuthorizationMode = 'standard' | 'provisional';\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 /** API base path prefix (default: '/v1'). Self-hosted backends can use custom paths. */\n basePath?: string;\n /** Polling interval in ms (default: 5000) */\n pollInterval?: number;\n /** Enable debug logging (default: false) */\n debug?: boolean;\n /** iOS push authorization mode (default: 'standard') */\n pushAuthorizationMode?: PushAuthorizationMode;\n}\n\n// ============================================\n// Push Authorization Types (iOS)\n// ============================================\n\n/**\n * iOS push authorization status\n * - 'notDetermined': Permission never requested\n * - 'denied': User denied permission\n * - 'authorized': Full push access granted\n * - 'provisional': Quiet notifications only (iOS 12+)\n * - 'ephemeral': App Clips only (iOS 14+)\n */\nexport type PushAuthorizationStatus =\n | 'notDetermined'\n | 'denied'\n | 'authorized'\n | 'provisional'\n | 'ephemeral';\n\n/**\n * Push authorization information\n */\nexport interface PushAuthorizationInfo {\n /** Current authorization status */\n status: PushAuthorizationStatus;\n /** Whether current authorization is provisional */\n isProvisional: boolean;\n /** Whether user can be prompted to upgrade to full authorization */\n canRequestFullAuthorization: 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 /** CTA button to show on completion/failure */\n ctaButton?: LiveActivityCTAButton;\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// Live Activity CTA Button Types\n// ============================================\n\n/**\n * CTA (Call-to-Action) button style\n */\nexport type LiveActivityCTAButtonStyle = 'primary' | 'secondary' | 'outline';\n\n/**\n * CTA button configuration for Live Activity completion\n */\nexport interface LiveActivityCTAButton {\n /** Button text */\n text: string;\n /** Deep link URL to open when tapped */\n deepLink: string;\n /** Button style preset */\n style?: LiveActivityCTAButtonStyle;\n /** Custom background color (hex) */\n backgroundColor?: string;\n /** Custom text color (hex) */\n textColor?: string;\n /** Corner radius (default: 20) */\n cornerRadius?: number;\n}\n\n// ============================================\n// Live Activity Theme Configuration Types\n// ============================================\n\n/**\n * Gradient point positions\n */\nexport type GradientPoint =\n | 'top'\n | 'topLeading'\n | 'topTrailing'\n | 'leading'\n | 'trailing'\n | 'bottom'\n | 'bottomLeading'\n | 'bottomTrailing'\n | 'center';\n\n/**\n * Built-in theme presets\n */\nexport type LiveActivityThemePreset =\n | 'default'\n | 'gradient-sunset'\n | 'gradient-ocean'\n | 'gradient-purple'\n | 'minimal-dark'\n | 'minimal-light';\n\n/**\n * Color configuration for Live Activity\n */\nexport interface LiveActivityColors {\n /** Background color (hex) */\n background?: string;\n /** Primary text color (hex) */\n primary?: string;\n /** Secondary text color (hex) */\n secondary?: string;\n /** Progress bar fill color (hex) */\n progressBar?: string;\n /** Progress bar track color (hex) */\n progressTrack?: string;\n /** Status color for running state (hex) */\n statusRunning?: string;\n /** Status color for completed state (hex) */\n statusCompleted?: string;\n /** Status color for failed state (hex) */\n statusFailed?: string;\n}\n\n/**\n * Gradient configuration for Live Activity background\n */\nexport interface LiveActivityGradient {\n /** Gradient color stops (hex values) */\n colors: string[];\n /** Start point of gradient */\n startPoint?: GradientPoint;\n /** End point of gradient */\n endPoint?: GradientPoint;\n}\n\n/**\n * Layout configuration for Live Activity\n */\nexport interface LiveActivityLayout {\n /** Progress bar height in points */\n progressBarHeight?: number;\n /** Corner radius for progress bar */\n progressBarCornerRadius?: number;\n /** Overall corner radius */\n cornerRadius?: number;\n /** Show job type icon */\n showIcon?: boolean;\n /** Show ETA countdown */\n showEta?: boolean;\n /** Show current stage */\n showStage?: boolean;\n /** Show progress percentage text */\n showProgressText?: boolean;\n /** Compact mode for Dynamic Island */\n compactMode?: boolean;\n}\n\n/**\n * Font weight options\n */\nexport type FontWeight = 'regular' | 'medium' | 'semibold' | 'bold';\n\n/**\n * Font configuration\n */\nexport interface FontConfig {\n /** Font size in points */\n size?: number;\n /** Font weight */\n weight?: FontWeight;\n}\n\n/**\n * Font configuration for Live Activity text elements\n */\nexport interface LiveActivityFonts {\n /** Title text font */\n title?: FontConfig;\n /** Progress/percentage text font */\n progress?: FontConfig;\n /** Message text font */\n message?: FontConfig;\n /** Stage text font */\n stage?: FontConfig;\n /** ETA text font */\n eta?: FontConfig;\n}\n\n/**\n * Job type specific icon and color configuration\n */\nexport interface JobTypeConfig {\n /** SF Symbol name (iOS) */\n icon?: string;\n /** Icon tint color (hex) */\n color?: string;\n /** Custom display name */\n displayName?: string;\n}\n\n/**\n * CTA button default styling\n */\nexport interface LiveActivityCTAStyle {\n /** Background color (hex) */\n backgroundColor?: string;\n /** Text color (hex) */\n textColor?: string;\n /** Corner radius */\n cornerRadius?: number;\n /** Font configuration */\n font?: FontConfig;\n}\n\n/**\n * CTA button configuration in theme\n */\nexport interface LiveActivityCTAConfig {\n /** Default CTA button style */\n style?: LiveActivityCTAStyle;\n /** Show CTA on these statuses */\n showOn?: ('completed' | 'failed')[];\n}\n\n/**\n * Complete theme configuration for Live Activity\n */\nexport interface LiveActivityThemeConfig {\n /** Use a built-in preset as base */\n preset?: LiveActivityThemePreset;\n /** Custom colors (override preset) */\n colors?: LiveActivityColors;\n /** Gradient background (overrides solid color) */\n gradient?: LiveActivityGradient;\n /** Layout options */\n layout?: LiveActivityLayout;\n /** Font configuration */\n fonts?: LiveActivityFonts;\n /** CTA button configuration */\n cta?: LiveActivityCTAConfig;\n}\n\n/**\n * Widget extension configuration\n */\nexport interface WidgetExtensionConfig {\n /** Widget extension name (default: 'SeennWidgetExtension') */\n name?: string;\n /** iOS deployment target (default: '16.1') */\n deploymentTarget?: string;\n /** App Groups identifier (auto-generated if not provided) */\n appGroupId?: string;\n}\n\n/**\n * Complete Seenn widget configuration file format\n */\nexport interface SeennWidgetConfig {\n /** Widget extension settings */\n widget?: WidgetExtensionConfig;\n /** Theme configuration */\n theme?: LiveActivityThemeConfig;\n /** Job type specific configurations */\n jobTypes?: Record<string, JobTypeConfig>;\n /** CTA button configuration */\n ctaButton?: LiveActivityCTAConfig;\n}\n\n// ============================================\n// Push Notification Types\n// ============================================\n\n/**\n * Alert push notification options\n */\nexport interface AlertPushOptions {\n /** Notification title */\n title: string;\n /** Notification body */\n body: string;\n /** Sound name (default: 'default') */\n sound?: string;\n /** Badge number */\n badge?: number;\n}\n\n/**\n * Rich push notification options (TikTok-style)\n */\nexport interface RichPushOptions {\n /** Sender name for messaging-style notification */\n senderName: string;\n /** Sender avatar URL for notification image */\n senderAvatar?: string;\n /** Mark as Time Sensitive (iOS 15+) */\n timeSensitive?: boolean;\n}\n\n/**\n * Push configuration options for job updates\n */\nexport interface PushOptions {\n /** Send Live Activity update (default: true) */\n liveActivity?: boolean;\n /** Send silent push for background sync (default: true) */\n silent?: boolean;\n /** Alert push notification */\n alert?: AlertPushOptions;\n /** Rich push notification (TikTok-style) */\n richPush?: RichPushOptions;\n}\n\n/**\n * Live Activity options for backend SDK\n */\nexport interface LiveActivityOptions {\n /** CTA button to show on completion/failure */\n ctaButton?: LiveActivityCTAButton;\n}\n\n// ============================================\n// Version & Compatibility\n// ============================================\n\n/**\n * SDK version info\n */\nexport const SDK_VERSION = '0.5.0';\n\n/**\n * Minimum API version required\n */\nexport const MIN_API_VERSION = '1.0.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAozBO,IAAM,cAAc;AAKpB,IAAM,kBAAkB;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
var SDK_VERSION = "0.
|
|
2
|
+
var SDK_VERSION = "0.5.0";
|
|
3
3
|
var MIN_API_VERSION = "1.0.0";
|
|
4
|
-
var SSE_PROTOCOL_VERSION = "1.0";
|
|
5
4
|
export {
|
|
6
5
|
MIN_API_VERSION,
|
|
7
|
-
SDK_VERSION
|
|
8
|
-
SSE_PROTOCOL_VERSION
|
|
6
|
+
SDK_VERSION
|
|
9
7
|
};
|
|
10
8
|
/**
|
|
11
9
|
* @seenn/types - Shared TypeScript types for Seenn SDKs
|
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 * CTA button text (optional backend override for Live Activity)\n * If provided, overrides mobile SDK default CTA\n */\n ctaButtonText?: string;\n /**\n * CTA deep link (optional backend override for Live Activity)\n * If provided, overrides mobile SDK default CTA\n */\n ctaDeepLink?: 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 /** API base path prefix (default: '/v1'). Self-hosted backends can use custom paths. */\n basePath?: string;\n /** SSE endpoint URL (default: baseUrl + basePath + /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 /** CTA button to show on completion/failure */\n ctaButton?: LiveActivityCTAButton;\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// Live Activity CTA Button Types\n// ============================================\n\n/**\n * CTA (Call-to-Action) button style\n */\nexport type LiveActivityCTAButtonStyle = 'primary' | 'secondary' | 'outline';\n\n/**\n * CTA button configuration for Live Activity completion\n */\nexport interface LiveActivityCTAButton {\n /** Button text */\n text: string;\n /** Deep link URL to open when tapped */\n deepLink: string;\n /** Button style preset */\n style?: LiveActivityCTAButtonStyle;\n /** Custom background color (hex) */\n backgroundColor?: string;\n /** Custom text color (hex) */\n textColor?: string;\n /** Corner radius (default: 20) */\n cornerRadius?: number;\n}\n\n// ============================================\n// Live Activity Theme Configuration Types\n// ============================================\n\n/**\n * Gradient point positions\n */\nexport type GradientPoint =\n | 'top'\n | 'topLeading'\n | 'topTrailing'\n | 'leading'\n | 'trailing'\n | 'bottom'\n | 'bottomLeading'\n | 'bottomTrailing'\n | 'center';\n\n/**\n * Built-in theme presets\n */\nexport type LiveActivityThemePreset =\n | 'default'\n | 'gradient-sunset'\n | 'gradient-ocean'\n | 'gradient-purple'\n | 'minimal-dark'\n | 'minimal-light';\n\n/**\n * Color configuration for Live Activity\n */\nexport interface LiveActivityColors {\n /** Background color (hex) */\n background?: string;\n /** Primary text color (hex) */\n primary?: string;\n /** Secondary text color (hex) */\n secondary?: string;\n /** Progress bar fill color (hex) */\n progressBar?: string;\n /** Progress bar track color (hex) */\n progressTrack?: string;\n /** Status color for running state (hex) */\n statusRunning?: string;\n /** Status color for completed state (hex) */\n statusCompleted?: string;\n /** Status color for failed state (hex) */\n statusFailed?: string;\n}\n\n/**\n * Gradient configuration for Live Activity background\n */\nexport interface LiveActivityGradient {\n /** Gradient color stops (hex values) */\n colors: string[];\n /** Start point of gradient */\n startPoint?: GradientPoint;\n /** End point of gradient */\n endPoint?: GradientPoint;\n}\n\n/**\n * Layout configuration for Live Activity\n */\nexport interface LiveActivityLayout {\n /** Progress bar height in points */\n progressBarHeight?: number;\n /** Corner radius for progress bar */\n progressBarCornerRadius?: number;\n /** Overall corner radius */\n cornerRadius?: number;\n /** Show job type icon */\n showIcon?: boolean;\n /** Show ETA countdown */\n showEta?: boolean;\n /** Show current stage */\n showStage?: boolean;\n /** Show progress percentage text */\n showProgressText?: boolean;\n /** Compact mode for Dynamic Island */\n compactMode?: boolean;\n}\n\n/**\n * Font weight options\n */\nexport type FontWeight = 'regular' | 'medium' | 'semibold' | 'bold';\n\n/**\n * Font configuration\n */\nexport interface FontConfig {\n /** Font size in points */\n size?: number;\n /** Font weight */\n weight?: FontWeight;\n}\n\n/**\n * Font configuration for Live Activity text elements\n */\nexport interface LiveActivityFonts {\n /** Title text font */\n title?: FontConfig;\n /** Progress/percentage text font */\n progress?: FontConfig;\n /** Message text font */\n message?: FontConfig;\n /** Stage text font */\n stage?: FontConfig;\n /** ETA text font */\n eta?: FontConfig;\n}\n\n/**\n * Job type specific icon and color configuration\n */\nexport interface JobTypeConfig {\n /** SF Symbol name (iOS) */\n icon?: string;\n /** Icon tint color (hex) */\n color?: string;\n /** Custom display name */\n displayName?: string;\n}\n\n/**\n * CTA button default styling\n */\nexport interface LiveActivityCTAStyle {\n /** Background color (hex) */\n backgroundColor?: string;\n /** Text color (hex) */\n textColor?: string;\n /** Corner radius */\n cornerRadius?: number;\n /** Font configuration */\n font?: FontConfig;\n}\n\n/**\n * CTA button configuration in theme\n */\nexport interface LiveActivityCTAConfig {\n /** Default CTA button style */\n style?: LiveActivityCTAStyle;\n /** Show CTA on these statuses */\n showOn?: ('completed' | 'failed')[];\n}\n\n/**\n * Complete theme configuration for Live Activity\n */\nexport interface LiveActivityThemeConfig {\n /** Use a built-in preset as base */\n preset?: LiveActivityThemePreset;\n /** Custom colors (override preset) */\n colors?: LiveActivityColors;\n /** Gradient background (overrides solid color) */\n gradient?: LiveActivityGradient;\n /** Layout options */\n layout?: LiveActivityLayout;\n /** Font configuration */\n fonts?: LiveActivityFonts;\n /** CTA button configuration */\n cta?: LiveActivityCTAConfig;\n}\n\n/**\n * Widget extension configuration\n */\nexport interface WidgetExtensionConfig {\n /** Widget extension name (default: 'SeennWidgetExtension') */\n name?: string;\n /** iOS deployment target (default: '16.1') */\n deploymentTarget?: string;\n /** App Groups identifier (auto-generated if not provided) */\n appGroupId?: string;\n}\n\n/**\n * Complete Seenn widget configuration file format\n */\nexport interface SeennWidgetConfig {\n /** Widget extension settings */\n widget?: WidgetExtensionConfig;\n /** Theme configuration */\n theme?: LiveActivityThemeConfig;\n /** Job type specific configurations */\n jobTypes?: Record<string, JobTypeConfig>;\n /** CTA button configuration */\n ctaButton?: LiveActivityCTAConfig;\n}\n\n// ============================================\n// Version & Compatibility\n// ============================================\n\n/**\n * SDK version info\n */\nexport const SDK_VERSION = '0.3.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":";AAwvBO,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 * CTA button text (optional backend override for Live Activity)\n * If provided, overrides mobile SDK default CTA\n */\n ctaButtonText?: string;\n /**\n * CTA deep link (optional backend override for Live Activity)\n * If provided, overrides mobile SDK default CTA\n */\n ctaDeepLink?: 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// 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 /** Push notification options */\n push?: PushOptions;\n /** Live Activity options */\n liveActivity?: LiveActivityOptions;\n}\n\n/**\n * Fail job request parameters\n */\nexport interface FailJobParams {\n /** Error details */\n error: JobError;\n /** Push notification options */\n push?: PushOptions;\n}\n\n/**\n * Progress job request parameters\n */\nexport interface ProgressJobParams {\n /** New progress (0-100) */\n progress: number;\n /** New message */\n message?: string;\n /** New stage info */\n stage?: StageInfo;\n /** Push notification options */\n push?: PushOptions;\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 * Note: SSE was removed in v0.4.0. Polling is now the only supported mode.\n */\nexport type ConnectionMode = 'polling';\n\n/**\n * iOS push authorization mode\n * - 'standard': Shows permission prompt, full push access\n * - 'provisional': No prompt, quiet notifications only (iOS 12+)\n */\nexport type PushAuthorizationMode = 'standard' | 'provisional';\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 /** API base path prefix (default: '/v1'). Self-hosted backends can use custom paths. */\n basePath?: string;\n /** Polling interval in ms (default: 5000) */\n pollInterval?: number;\n /** Enable debug logging (default: false) */\n debug?: boolean;\n /** iOS push authorization mode (default: 'standard') */\n pushAuthorizationMode?: PushAuthorizationMode;\n}\n\n// ============================================\n// Push Authorization Types (iOS)\n// ============================================\n\n/**\n * iOS push authorization status\n * - 'notDetermined': Permission never requested\n * - 'denied': User denied permission\n * - 'authorized': Full push access granted\n * - 'provisional': Quiet notifications only (iOS 12+)\n * - 'ephemeral': App Clips only (iOS 14+)\n */\nexport type PushAuthorizationStatus =\n | 'notDetermined'\n | 'denied'\n | 'authorized'\n | 'provisional'\n | 'ephemeral';\n\n/**\n * Push authorization information\n */\nexport interface PushAuthorizationInfo {\n /** Current authorization status */\n status: PushAuthorizationStatus;\n /** Whether current authorization is provisional */\n isProvisional: boolean;\n /** Whether user can be prompted to upgrade to full authorization */\n canRequestFullAuthorization: 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 /** CTA button to show on completion/failure */\n ctaButton?: LiveActivityCTAButton;\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// Live Activity CTA Button Types\n// ============================================\n\n/**\n * CTA (Call-to-Action) button style\n */\nexport type LiveActivityCTAButtonStyle = 'primary' | 'secondary' | 'outline';\n\n/**\n * CTA button configuration for Live Activity completion\n */\nexport interface LiveActivityCTAButton {\n /** Button text */\n text: string;\n /** Deep link URL to open when tapped */\n deepLink: string;\n /** Button style preset */\n style?: LiveActivityCTAButtonStyle;\n /** Custom background color (hex) */\n backgroundColor?: string;\n /** Custom text color (hex) */\n textColor?: string;\n /** Corner radius (default: 20) */\n cornerRadius?: number;\n}\n\n// ============================================\n// Live Activity Theme Configuration Types\n// ============================================\n\n/**\n * Gradient point positions\n */\nexport type GradientPoint =\n | 'top'\n | 'topLeading'\n | 'topTrailing'\n | 'leading'\n | 'trailing'\n | 'bottom'\n | 'bottomLeading'\n | 'bottomTrailing'\n | 'center';\n\n/**\n * Built-in theme presets\n */\nexport type LiveActivityThemePreset =\n | 'default'\n | 'gradient-sunset'\n | 'gradient-ocean'\n | 'gradient-purple'\n | 'minimal-dark'\n | 'minimal-light';\n\n/**\n * Color configuration for Live Activity\n */\nexport interface LiveActivityColors {\n /** Background color (hex) */\n background?: string;\n /** Primary text color (hex) */\n primary?: string;\n /** Secondary text color (hex) */\n secondary?: string;\n /** Progress bar fill color (hex) */\n progressBar?: string;\n /** Progress bar track color (hex) */\n progressTrack?: string;\n /** Status color for running state (hex) */\n statusRunning?: string;\n /** Status color for completed state (hex) */\n statusCompleted?: string;\n /** Status color for failed state (hex) */\n statusFailed?: string;\n}\n\n/**\n * Gradient configuration for Live Activity background\n */\nexport interface LiveActivityGradient {\n /** Gradient color stops (hex values) */\n colors: string[];\n /** Start point of gradient */\n startPoint?: GradientPoint;\n /** End point of gradient */\n endPoint?: GradientPoint;\n}\n\n/**\n * Layout configuration for Live Activity\n */\nexport interface LiveActivityLayout {\n /** Progress bar height in points */\n progressBarHeight?: number;\n /** Corner radius for progress bar */\n progressBarCornerRadius?: number;\n /** Overall corner radius */\n cornerRadius?: number;\n /** Show job type icon */\n showIcon?: boolean;\n /** Show ETA countdown */\n showEta?: boolean;\n /** Show current stage */\n showStage?: boolean;\n /** Show progress percentage text */\n showProgressText?: boolean;\n /** Compact mode for Dynamic Island */\n compactMode?: boolean;\n}\n\n/**\n * Font weight options\n */\nexport type FontWeight = 'regular' | 'medium' | 'semibold' | 'bold';\n\n/**\n * Font configuration\n */\nexport interface FontConfig {\n /** Font size in points */\n size?: number;\n /** Font weight */\n weight?: FontWeight;\n}\n\n/**\n * Font configuration for Live Activity text elements\n */\nexport interface LiveActivityFonts {\n /** Title text font */\n title?: FontConfig;\n /** Progress/percentage text font */\n progress?: FontConfig;\n /** Message text font */\n message?: FontConfig;\n /** Stage text font */\n stage?: FontConfig;\n /** ETA text font */\n eta?: FontConfig;\n}\n\n/**\n * Job type specific icon and color configuration\n */\nexport interface JobTypeConfig {\n /** SF Symbol name (iOS) */\n icon?: string;\n /** Icon tint color (hex) */\n color?: string;\n /** Custom display name */\n displayName?: string;\n}\n\n/**\n * CTA button default styling\n */\nexport interface LiveActivityCTAStyle {\n /** Background color (hex) */\n backgroundColor?: string;\n /** Text color (hex) */\n textColor?: string;\n /** Corner radius */\n cornerRadius?: number;\n /** Font configuration */\n font?: FontConfig;\n}\n\n/**\n * CTA button configuration in theme\n */\nexport interface LiveActivityCTAConfig {\n /** Default CTA button style */\n style?: LiveActivityCTAStyle;\n /** Show CTA on these statuses */\n showOn?: ('completed' | 'failed')[];\n}\n\n/**\n * Complete theme configuration for Live Activity\n */\nexport interface LiveActivityThemeConfig {\n /** Use a built-in preset as base */\n preset?: LiveActivityThemePreset;\n /** Custom colors (override preset) */\n colors?: LiveActivityColors;\n /** Gradient background (overrides solid color) */\n gradient?: LiveActivityGradient;\n /** Layout options */\n layout?: LiveActivityLayout;\n /** Font configuration */\n fonts?: LiveActivityFonts;\n /** CTA button configuration */\n cta?: LiveActivityCTAConfig;\n}\n\n/**\n * Widget extension configuration\n */\nexport interface WidgetExtensionConfig {\n /** Widget extension name (default: 'SeennWidgetExtension') */\n name?: string;\n /** iOS deployment target (default: '16.1') */\n deploymentTarget?: string;\n /** App Groups identifier (auto-generated if not provided) */\n appGroupId?: string;\n}\n\n/**\n * Complete Seenn widget configuration file format\n */\nexport interface SeennWidgetConfig {\n /** Widget extension settings */\n widget?: WidgetExtensionConfig;\n /** Theme configuration */\n theme?: LiveActivityThemeConfig;\n /** Job type specific configurations */\n jobTypes?: Record<string, JobTypeConfig>;\n /** CTA button configuration */\n ctaButton?: LiveActivityCTAConfig;\n}\n\n// ============================================\n// Push Notification Types\n// ============================================\n\n/**\n * Alert push notification options\n */\nexport interface AlertPushOptions {\n /** Notification title */\n title: string;\n /** Notification body */\n body: string;\n /** Sound name (default: 'default') */\n sound?: string;\n /** Badge number */\n badge?: number;\n}\n\n/**\n * Rich push notification options (TikTok-style)\n */\nexport interface RichPushOptions {\n /** Sender name for messaging-style notification */\n senderName: string;\n /** Sender avatar URL for notification image */\n senderAvatar?: string;\n /** Mark as Time Sensitive (iOS 15+) */\n timeSensitive?: boolean;\n}\n\n/**\n * Push configuration options for job updates\n */\nexport interface PushOptions {\n /** Send Live Activity update (default: true) */\n liveActivity?: boolean;\n /** Send silent push for background sync (default: true) */\n silent?: boolean;\n /** Alert push notification */\n alert?: AlertPushOptions;\n /** Rich push notification (TikTok-style) */\n richPush?: RichPushOptions;\n}\n\n/**\n * Live Activity options for backend SDK\n */\nexport interface LiveActivityOptions {\n /** CTA button to show on completion/failure */\n ctaButton?: LiveActivityCTAButton;\n}\n\n// ============================================\n// Version & Compatibility\n// ============================================\n\n/**\n * SDK version info\n */\nexport const SDK_VERSION = '0.5.0';\n\n/**\n * Minimum API version required\n */\nexport const MIN_API_VERSION = '1.0.0';\n"],"mappings":";AAozBO,IAAM,cAAc;AAKpB,IAAM,kBAAkB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seenn/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Shared TypeScript types for Seenn SDKs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
"typescript",
|
|
19
19
|
"job-tracking"
|
|
20
20
|
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup",
|
|
23
|
+
"dev": "tsup --watch",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"prepublishOnly": "pnpm build"
|
|
26
|
+
},
|
|
21
27
|
"devDependencies": {
|
|
22
28
|
"tsup": "^8.0.1",
|
|
23
29
|
"typescript": "^5.3.3"
|
|
@@ -29,10 +35,5 @@
|
|
|
29
35
|
"publishConfig": {
|
|
30
36
|
"access": "public"
|
|
31
37
|
},
|
|
32
|
-
"sideEffects": false
|
|
33
|
-
|
|
34
|
-
"build": "tsup",
|
|
35
|
-
"dev": "tsup --watch",
|
|
36
|
-
"typecheck": "tsc --noEmit"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
38
|
+
"sideEffects": false
|
|
39
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -218,49 +218,6 @@ export interface ParentWithChildren {
|
|
|
218
218
|
children: ChildJobSummary[];
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
// ============================================
|
|
222
|
-
// SSE Types
|
|
223
|
-
// ============================================
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Connection state for SSE
|
|
227
|
-
*/
|
|
228
|
-
export type ConnectionState =
|
|
229
|
-
| 'disconnected'
|
|
230
|
-
| 'connecting'
|
|
231
|
-
| 'connected'
|
|
232
|
-
| 'reconnecting';
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* SSE event types
|
|
236
|
-
*/
|
|
237
|
-
export type SSEEventType =
|
|
238
|
-
| 'connected'
|
|
239
|
-
| 'job.sync'
|
|
240
|
-
| 'job.started'
|
|
241
|
-
| 'job.progress'
|
|
242
|
-
| 'job.completed'
|
|
243
|
-
| 'job.failed'
|
|
244
|
-
| 'job.cancelled'
|
|
245
|
-
| 'child.progress'
|
|
246
|
-
| 'parent.updated'
|
|
247
|
-
| 'in_app_message'
|
|
248
|
-
| 'connection.idle'
|
|
249
|
-
| 'heartbeat'
|
|
250
|
-
| 'error';
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* SSE event wrapper
|
|
254
|
-
*/
|
|
255
|
-
export interface SSEEvent {
|
|
256
|
-
/** Event type */
|
|
257
|
-
event: SSEEventType;
|
|
258
|
-
/** Event data */
|
|
259
|
-
data: unknown;
|
|
260
|
-
/** Event ID for replay */
|
|
261
|
-
id?: string;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
221
|
// ============================================
|
|
265
222
|
// In-App Message Types
|
|
266
223
|
// ============================================
|
|
@@ -347,6 +304,10 @@ export interface CompleteJobParams {
|
|
|
347
304
|
result?: JobResult;
|
|
348
305
|
/** Final message */
|
|
349
306
|
message?: string;
|
|
307
|
+
/** Push notification options */
|
|
308
|
+
push?: PushOptions;
|
|
309
|
+
/** Live Activity options */
|
|
310
|
+
liveActivity?: LiveActivityOptions;
|
|
350
311
|
}
|
|
351
312
|
|
|
352
313
|
/**
|
|
@@ -355,6 +316,22 @@ export interface CompleteJobParams {
|
|
|
355
316
|
export interface FailJobParams {
|
|
356
317
|
/** Error details */
|
|
357
318
|
error: JobError;
|
|
319
|
+
/** Push notification options */
|
|
320
|
+
push?: PushOptions;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Progress job request parameters
|
|
325
|
+
*/
|
|
326
|
+
export interface ProgressJobParams {
|
|
327
|
+
/** New progress (0-100) */
|
|
328
|
+
progress: number;
|
|
329
|
+
/** New message */
|
|
330
|
+
message?: string;
|
|
331
|
+
/** New stage info */
|
|
332
|
+
stage?: StageInfo;
|
|
333
|
+
/** Push notification options */
|
|
334
|
+
push?: PushOptions;
|
|
358
335
|
}
|
|
359
336
|
|
|
360
337
|
// ============================================
|
|
@@ -415,8 +392,16 @@ export interface EtaStats {
|
|
|
415
392
|
|
|
416
393
|
/**
|
|
417
394
|
* Connection mode for real-time updates
|
|
395
|
+
* Note: SSE was removed in v0.4.0. Polling is now the only supported mode.
|
|
396
|
+
*/
|
|
397
|
+
export type ConnectionMode = 'polling';
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* iOS push authorization mode
|
|
401
|
+
* - 'standard': Shows permission prompt, full push access
|
|
402
|
+
* - 'provisional': No prompt, quiet notifications only (iOS 12+)
|
|
418
403
|
*/
|
|
419
|
-
export type
|
|
404
|
+
export type PushAuthorizationMode = 'standard' | 'provisional';
|
|
420
405
|
|
|
421
406
|
/**
|
|
422
407
|
* Base SDK configuration
|
|
@@ -428,20 +413,43 @@ export interface SeennConfig {
|
|
|
428
413
|
apiKey?: string;
|
|
429
414
|
/** API base path prefix (default: '/v1'). Self-hosted backends can use custom paths. */
|
|
430
415
|
basePath?: string;
|
|
431
|
-
/**
|
|
432
|
-
sseUrl?: string;
|
|
433
|
-
/** Connection mode: 'sse' (default) or 'polling' (for self-hosted) */
|
|
434
|
-
mode?: ConnectionMode;
|
|
435
|
-
/** Polling interval in ms (default: 5000, only used when mode is 'polling') */
|
|
416
|
+
/** Polling interval in ms (default: 5000) */
|
|
436
417
|
pollInterval?: number;
|
|
437
|
-
/** Enable auto-reconnect (default: true) */
|
|
438
|
-
reconnect?: boolean;
|
|
439
|
-
/** Reconnect interval in ms (default: 1000) */
|
|
440
|
-
reconnectInterval?: number;
|
|
441
|
-
/** Max reconnect attempts (default: 10) */
|
|
442
|
-
maxReconnectAttempts?: number;
|
|
443
418
|
/** Enable debug logging (default: false) */
|
|
444
419
|
debug?: boolean;
|
|
420
|
+
/** iOS push authorization mode (default: 'standard') */
|
|
421
|
+
pushAuthorizationMode?: PushAuthorizationMode;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// ============================================
|
|
425
|
+
// Push Authorization Types (iOS)
|
|
426
|
+
// ============================================
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* iOS push authorization status
|
|
430
|
+
* - 'notDetermined': Permission never requested
|
|
431
|
+
* - 'denied': User denied permission
|
|
432
|
+
* - 'authorized': Full push access granted
|
|
433
|
+
* - 'provisional': Quiet notifications only (iOS 12+)
|
|
434
|
+
* - 'ephemeral': App Clips only (iOS 14+)
|
|
435
|
+
*/
|
|
436
|
+
export type PushAuthorizationStatus =
|
|
437
|
+
| 'notDetermined'
|
|
438
|
+
| 'denied'
|
|
439
|
+
| 'authorized'
|
|
440
|
+
| 'provisional'
|
|
441
|
+
| 'ephemeral';
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Push authorization information
|
|
445
|
+
*/
|
|
446
|
+
export interface PushAuthorizationInfo {
|
|
447
|
+
/** Current authorization status */
|
|
448
|
+
status: PushAuthorizationStatus;
|
|
449
|
+
/** Whether current authorization is provisional */
|
|
450
|
+
isProvisional: boolean;
|
|
451
|
+
/** Whether user can be prompted to upgrade to full authorization */
|
|
452
|
+
canRequestFullAuthorization: boolean;
|
|
445
453
|
}
|
|
446
454
|
|
|
447
455
|
// ============================================
|
|
@@ -751,6 +759,58 @@ export interface SeennWidgetConfig {
|
|
|
751
759
|
ctaButton?: LiveActivityCTAConfig;
|
|
752
760
|
}
|
|
753
761
|
|
|
762
|
+
// ============================================
|
|
763
|
+
// Push Notification Types
|
|
764
|
+
// ============================================
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Alert push notification options
|
|
768
|
+
*/
|
|
769
|
+
export interface AlertPushOptions {
|
|
770
|
+
/** Notification title */
|
|
771
|
+
title: string;
|
|
772
|
+
/** Notification body */
|
|
773
|
+
body: string;
|
|
774
|
+
/** Sound name (default: 'default') */
|
|
775
|
+
sound?: string;
|
|
776
|
+
/** Badge number */
|
|
777
|
+
badge?: number;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Rich push notification options (TikTok-style)
|
|
782
|
+
*/
|
|
783
|
+
export interface RichPushOptions {
|
|
784
|
+
/** Sender name for messaging-style notification */
|
|
785
|
+
senderName: string;
|
|
786
|
+
/** Sender avatar URL for notification image */
|
|
787
|
+
senderAvatar?: string;
|
|
788
|
+
/** Mark as Time Sensitive (iOS 15+) */
|
|
789
|
+
timeSensitive?: boolean;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Push configuration options for job updates
|
|
794
|
+
*/
|
|
795
|
+
export interface PushOptions {
|
|
796
|
+
/** Send Live Activity update (default: true) */
|
|
797
|
+
liveActivity?: boolean;
|
|
798
|
+
/** Send silent push for background sync (default: true) */
|
|
799
|
+
silent?: boolean;
|
|
800
|
+
/** Alert push notification */
|
|
801
|
+
alert?: AlertPushOptions;
|
|
802
|
+
/** Rich push notification (TikTok-style) */
|
|
803
|
+
richPush?: RichPushOptions;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Live Activity options for backend SDK
|
|
808
|
+
*/
|
|
809
|
+
export interface LiveActivityOptions {
|
|
810
|
+
/** CTA button to show on completion/failure */
|
|
811
|
+
ctaButton?: LiveActivityCTAButton;
|
|
812
|
+
}
|
|
813
|
+
|
|
754
814
|
// ============================================
|
|
755
815
|
// Version & Compatibility
|
|
756
816
|
// ============================================
|
|
@@ -758,14 +818,9 @@ export interface SeennWidgetConfig {
|
|
|
758
818
|
/**
|
|
759
819
|
* SDK version info
|
|
760
820
|
*/
|
|
761
|
-
export const SDK_VERSION = '0.
|
|
821
|
+
export const SDK_VERSION = '0.5.0';
|
|
762
822
|
|
|
763
823
|
/**
|
|
764
824
|
* Minimum API version required
|
|
765
825
|
*/
|
|
766
826
|
export const MIN_API_VERSION = '1.0.0';
|
|
767
|
-
|
|
768
|
-
/**
|
|
769
|
-
* SSE protocol version
|
|
770
|
-
*/
|
|
771
|
-
export const SSE_PROTOCOL_VERSION = '1.0';
|