@fiction/sdk 1.0.19 → 1.0.20

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.
@@ -1,106 +1,30 @@
1
- import { z } from 'zod'
2
-
3
- // Core media enums - defined here as single source of truth
4
- export const MediaFormatSchema = z.enum(['image', 'video', 'audio'])
5
- export type MediaFormat = z.infer<typeof MediaFormatSchema>
6
-
7
- export const MediaContextSchema = z.enum(['avatar', 'cover', 'voice', 'general'])
8
- export type MediaContext = z.infer<typeof MediaContextSchema>
9
-
10
- export const MediaStatusSchema = z.enum(['processing', 'active', 'failed', 'deleted'])
11
- export type MediaStatus = z.infer<typeof MediaStatusSchema>
12
-
13
- // Format-specific enums for file extensions
14
- export const ImageFormatSchema = z.enum(['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg'])
15
- export type ImageFormat = z.infer<typeof ImageFormatSchema>
16
-
17
- export const VideoFormatSchema = z.enum(['mp4', 'webm', 'ogg', 'mov', 'avi'])
18
- export type VideoFormat = z.infer<typeof VideoFormatSchema>
19
-
20
- export const AudioFormatSchema = z.enum(['mp3', 'wav', 'ogg', 'aac', 'flac'])
21
- export type AudioFormat = z.infer<typeof AudioFormatSchema>
22
-
23
- // Base media schema - independent definition
24
- const baseMediaSchema = z.object({
25
- mediaId: z.string(),
26
- userId: z.string(),
27
- orgId: z.string(),
28
- selfId: z.string().nullable().optional(),
29
- filename: z.string(),
30
- mimeType: z.string(),
31
- size: z.number(),
32
- src: z.string(),
33
- alt: z.string().optional(),
34
- context: MediaContextSchema.default('general'),
35
- status: MediaStatusSchema.default('processing'),
36
- createdAt: z.string().optional(), // ISO string for JSON compatibility
37
- updatedAt: z.string().optional(), // ISO string for JSON compatibility
38
- })
39
-
40
- // Extended MediaObject for UI use - with UI-friendly field names
41
- export const MediaSchema = baseMediaSchema.extend({
42
- // Additional UI fields not in database
43
- format: MediaFormatSchema.optional(), // Derived from mimeType
44
- className: z.string().optional(), // CSS classes for rendering
45
-
46
- // Image/video dimensions
47
- width: z.number().optional(),
48
- height: z.number().optional(),
49
-
50
- // Audio/video duration
51
- duration: z.number().optional(),
52
-
53
- // Image blur hash for loading placeholders
54
- blurhash: z.string().optional(),
55
- }).partial() // Make all fields optional for UI flexibility
56
-
57
- // Video-specific properties
58
- export const VideoPropertiesSchema = z.object({
59
- duration: z.number().optional(), // in seconds
60
- thumbnail: z.string().optional(),
61
- autoplay: z.boolean().optional(),
62
- loop: z.boolean().optional(),
63
- muted: z.boolean().optional(),
64
- controls: z.boolean().optional(),
65
- })
66
-
67
- // Audio-specific properties
68
- export const AudioPropertiesSchema = z.object({
69
- duration: z.number().optional(), // in seconds
70
- autoplay: z.boolean().optional(),
71
- loop: z.boolean().optional(),
72
- muted: z.boolean().optional(),
73
- controls: z.boolean().optional(),
74
- })
75
-
76
- // Extended media schemas with format-specific properties
77
- export const ImageMediaSchema = MediaSchema.extend({
78
- format: z.literal('image'),
79
- imageFormat: ImageFormatSchema,
80
- })
81
-
82
- export const VideoMediaSchema = MediaSchema.extend({
83
- format: z.literal('video'),
84
- videoFormat: VideoFormatSchema,
85
- video: VideoPropertiesSchema.optional(),
86
- })
87
-
88
- export const AudioMediaSchema = MediaSchema.extend({
89
- format: z.literal('audio'),
90
- audioFormat: AudioFormatSchema,
91
- audio: AudioPropertiesSchema.optional(),
92
- })
93
-
94
- // Union type for all media
95
- export const MediaUnionSchema = z.discriminatedUnion('format', [
1
+ // Re-export media types from @fiction/types (single source of truth)
2
+ export {
3
+ AudioFormatSchema,
4
+ AudioMediaSchema,
5
+ AudioPropertiesSchema,
6
+ ImageFormatSchema,
96
7
  ImageMediaSchema,
8
+ MediaContextSchema,
9
+ MediaFormatSchema,
10
+ MediaSchema,
11
+ MediaStatusSchema,
12
+ MediaUnionSchema,
13
+ VideoFormatSchema,
97
14
  VideoMediaSchema,
98
- AudioMediaSchema,
99
- ])
100
-
101
- // Type exports
102
- export type MediaObject = z.infer<typeof MediaSchema>
103
- export type ImageMedia = z.infer<typeof ImageMediaSchema>
104
- export type VideoMedia = z.infer<typeof VideoMediaSchema>
105
- export type AudioMedia = z.infer<typeof AudioMediaSchema>
106
- export type MediaUnion = z.infer<typeof MediaUnionSchema>
15
+ VideoPropertiesSchema,
16
+ } from '@fiction/types'
17
+
18
+ export type {
19
+ AudioFormat,
20
+ AudioMedia,
21
+ ImageFormat,
22
+ ImageMedia,
23
+ MediaContext,
24
+ MediaFormat,
25
+ MediaObject,
26
+ MediaStatus,
27
+ MediaUnion,
28
+ VideoFormat,
29
+ VideoMedia,
30
+ } from '@fiction/types'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiction/sdk",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "SDK for Fiction app authentication and user management",
5
5
  "type": "module",
6
6
  "main": "./dist/sdk.js",
@@ -33,7 +33,7 @@
33
33
  "repository": {
34
34
  "type": "git",
35
35
  "url": "https://github.com/fictionco/fiction-app.git",
36
- "directory": "src/sdk"
36
+ "directory": "packages/sdk"
37
37
  },
38
38
  "homepage": "https://fiction.com",
39
39
  "bugs": {
@@ -44,6 +44,7 @@
44
44
  "registry": "https://registry.npmjs.org/"
45
45
  },
46
46
  "peerDependencies": {
47
+ "@fiction/types": "^1.0.0",
47
48
  "vue": "^3.5.0"
48
49
  },
49
50
  "dependencies": {
@@ -54,7 +55,7 @@
54
55
  "nanoid": "^5.1.6",
55
56
  "nanostores": "^1.0.1",
56
57
  "zod": "^4.1.11",
57
- "@fiction/sdk": "1.0.19"
58
+ "@fiction/types": "1.0.1"
58
59
  },
59
60
  "devDependencies": {
60
61
  "@antfu/eslint-config": "^5.4.1",
@@ -1,6 +0,0 @@
1
- import { Hono } from 'hono';
2
- /**
3
- * Minimal type stub for Hono RPC client
4
- * Satisfies hc<T> requirements without actual route parsing
5
- */
6
- export type SDKAppType = Hono<any, any, any>;