@01.software/sdk 0.7.0 → 0.8.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/README.md +38 -0
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/const-CCh99Gxu.d.ts +19 -0
- package/dist/const-dv0zuAxG.d.cts +19 -0
- package/dist/index.cjs +9 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -37
- package/dist/index.d.ts +32 -37
- package/dist/index.js +9 -16
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-CFDtFiSz.d.cts → payload-types-FfZ2Zxp1.d.cts} +801 -450
- package/dist/{payload-types-CFDtFiSz.d.ts → payload-types-FfZ2Zxp1.d.ts} +801 -450
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.cjs +1 -1
- package/dist/ui/video.cjs.map +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/ui/video.js +1 -1
- package/dist/ui/video.js.map +1 -1
- package/dist/{webhook-BB8amLBv.d.ts → webhook-B9MDrH22.d.ts} +2 -2
- package/dist/{webhook-CrBjPpUT.d.cts → webhook-t7JGFLKQ.d.cts} +2 -2
- package/dist/webhook.d.cts +3 -3
- package/dist/webhook.d.ts +3 -3
- package/package.json +3 -3
- package/dist/const-6BfmvZug.d.cts +0 -19
- package/dist/const-DQYzabjw.d.ts +0 -19
package/dist/realtime.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as RealtimeEvent } from './realtime-DupPIYx-.cjs';
|
|
2
2
|
export { a as RealtimeConnection, b as RealtimeListener } from './realtime-DupPIYx-.cjs';
|
|
3
|
-
import { P as PublicCollection } from './const-
|
|
4
|
-
import './payload-types-
|
|
3
|
+
import { P as PublicCollection } from './const-dv0zuAxG.cjs';
|
|
4
|
+
import './payload-types-FfZ2Zxp1.cjs';
|
|
5
5
|
|
|
6
6
|
interface UseRealtimeQueryOptions {
|
|
7
7
|
/** Filter events to specific collections. Empty/undefined = all collections. */
|
package/dist/realtime.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { R as RealtimeEvent } from './realtime-DupPIYx-.js';
|
|
2
2
|
export { a as RealtimeConnection, b as RealtimeListener } from './realtime-DupPIYx-.js';
|
|
3
|
-
import { P as PublicCollection } from './const-
|
|
4
|
-
import './payload-types-
|
|
3
|
+
import { P as PublicCollection } from './const-CCh99Gxu.js';
|
|
4
|
+
import './payload-types-FfZ2Zxp1.js';
|
|
5
5
|
|
|
6
6
|
interface UseRealtimeQueryOptions {
|
|
7
7
|
/** Filter events to specific collections. Empty/undefined = all collections. */
|
package/dist/ui/form.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { F as Form } from '../payload-types-
|
|
2
|
+
import { F as Form } from '../payload-types-FfZ2Zxp1.cjs';
|
|
3
3
|
import { RichTextData } from './rich-text.cjs';
|
|
4
4
|
import '@payloadcms/richtext-lexical';
|
|
5
5
|
import '@payloadcms/richtext-lexical/lexical';
|
package/dist/ui/form.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { F as Form } from '../payload-types-
|
|
2
|
+
import { F as Form } from '../payload-types-FfZ2Zxp1.js';
|
|
3
3
|
import { RichTextData } from './rich-text.js';
|
|
4
4
|
import '@payloadcms/richtext-lexical';
|
|
5
5
|
import '@payloadcms/richtext-lexical/lexical';
|
package/dist/ui/video.cjs
CHANGED
|
@@ -106,7 +106,7 @@ function resolveAspectRatio(video) {
|
|
|
106
106
|
}
|
|
107
107
|
function resolveStatus(video) {
|
|
108
108
|
if (typeof video === "string") return "ready";
|
|
109
|
-
return video.
|
|
109
|
+
return video.muxStatus ?? "waiting";
|
|
110
110
|
}
|
|
111
111
|
var VideoPlayer = (0, import_react.forwardRef)(
|
|
112
112
|
function VideoPlayer2(props, ref) {
|
package/dist/ui/video.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ui/Video/index.tsx","../../src/utils/video.ts"],"sourcesContent":["'use client'\n\nimport React, { forwardRef, type CSSProperties } from 'react'\nimport MuxPlayer from '@mux/mux-player-react'\nimport type {\n MuxPlayerRefAttributes,\n MuxPlayerProps,\n} from '@mux/mux-player-react'\nimport type { Video, Image } from '../../payload-types'\nimport { getVideoThumbnail } from '../../utils/video'\n\n// Re-export video utilities for convenience\nexport {\n getVideoThumbnail,\n getVideoGif,\n getVideoStreamUrl,\n getVideoMp4Url,\n getVideoStoryboard,\n type VideoThumbnailOptions,\n type VideoGifOptions,\n} from '../../utils/video'\n\n// ── CSS custom properties ──\n\nexport interface VideoPlayerCSSProperties extends CSSProperties {\n [key: `--${string}`]: string | undefined\n}\n\n// ── Props ──\n\nexport interface VideoPlayerProps {\n /** Video document or playbackId string */\n video: Video | string\n\n // ── Theming ──\n /** Theme accent color */\n accentColor?: string\n /** Theme primary color (controls) */\n primaryColor?: string\n /** Theme secondary color (time display, etc.) */\n secondaryColor?: string\n\n // ── Playback ──\n /** Title overlay (auto-resolved from Video.title if omitted) */\n title?: string\n /** Autoplay behavior */\n autoPlay?: boolean | 'muted' | 'any'\n /** Loop playback */\n loop?: boolean\n /** Muted by default */\n muted?: boolean\n /** Preload strategy (default: 'metadata') */\n preload?: 'auto' | 'metadata' | 'none'\n /** Start time in seconds */\n startTime?: number\n /** Stream type (default: 'on-demand') */\n streamType?: 'on-demand' | 'live' | 'll-live'\n /** Audio-only mode */\n audio?: boolean\n /** Disable keyboard shortcuts */\n noHotKeys?: boolean\n /** Max resolution cap */\n maxResolution?: '720p' | '1080p' | '1440p' | '2160p'\n\n // ── Poster ──\n /** Thumbnail time for auto-generated poster (default: 0) */\n thumbnailTime?: number\n /** Custom poster URL (overrides auto-generated thumbnail) */\n poster?: string\n\n // ── Placeholder (when video not ready) ──\n /** Placeholder text when video is not ready */\n placeholder?: string\n /** CSS class for the placeholder */\n placeholderClassName?: string\n /** Inline styles for the placeholder */\n placeholderStyle?: CSSProperties\n\n // ── Styling ──\n /** CSS class */\n className?: string\n /** Inline styles (supports --mux CSS custom properties) */\n style?: VideoPlayerCSSProperties\n\n // ── Events ──\n onPlay?: () => void\n onPause?: () => void\n onEnded?: () => void\n onTimeUpdate?: () => void\n onLoadedData?: () => void\n onError?: () => void\n\n // ── Escape hatch ──\n /** Extra props forwarded directly to MuxPlayer */\n playerProps?: Omit<\n MuxPlayerProps,\n | 'playbackId'\n | 'streamType'\n | 'accentColor'\n | 'primaryColor'\n | 'secondaryColor'\n | 'title'\n | 'autoPlay'\n | 'loop'\n | 'muted'\n | 'preload'\n | 'startTime'\n | 'poster'\n | 'audio'\n | 'nohotkeys'\n | 'maxResolution'\n | 'className'\n | 'style'\n >\n}\n\n// ── Helpers ──\n\nfunction resolvePlaybackId(video: Video | string): string | null {\n if (typeof video === 'string') return video\n return video.muxPlaybackId ?? null\n}\n\nfunction resolveTitle(props: VideoPlayerProps): string | undefined {\n if (props.title !== undefined) return props.title\n if (typeof props.video !== 'string') return props.video.title ?? undefined\n return undefined\n}\n\nfunction resolvePoster(props: VideoPlayerProps): string | undefined {\n // 1. Explicit poster URL (highest priority)\n if (props.poster) return props.poster\n\n // 2. Video.thumbnail uploaded image\n if (typeof props.video !== 'string' && props.video.thumbnail) {\n const thumb = props.video.thumbnail\n if (typeof thumb === 'object' && thumb !== null && 'url' in thumb) {\n const url = (thumb as Image).url\n if (url) return url\n }\n }\n\n // 3. Auto-generate from Mux image API\n const playbackId = resolvePlaybackId(props.video)\n if (!playbackId) return undefined\n return getVideoThumbnail(playbackId, {\n width: 1280,\n time: props.thumbnailTime ?? 0,\n })\n}\n\nfunction resolveAspectRatio(video: Video | string): string | undefined {\n if (typeof video === 'string') return undefined\n return video.aspectRatio ?? undefined\n}\n\nfunction resolveStatus(video: Video | string): string {\n if (typeof video === 'string') return 'ready'\n return video.status ?? 'waiting'\n}\n\n// ── Component ──\n\n/**\n * Mux video player component.\n * Requires `@mux/mux-player-react` (optional peer dependency).\n *\n * @example Basic usage\n * ```tsx\n * import { VideoPlayer } from '@01.software/sdk/ui/video'\n *\n * <VideoPlayer video={videoDoc} />\n * ```\n *\n * @example With playback ID string\n * ```tsx\n * <VideoPlayer video=\"abc123def\" autoPlay=\"muted\" loop />\n * ```\n *\n * @example Custom theming with CSS custom properties\n * ```tsx\n * <VideoPlayer\n * video={videoDoc}\n * accentColor=\"#f43f5e\"\n * primaryColor=\"#fff\"\n * className=\"rounded-lg overflow-hidden\"\n * style={{ '--controls-backdrop-color': 'rgba(0,0,0,0.6)' }}\n * />\n * ```\n *\n * @example Audio-only mode\n * ```tsx\n * <VideoPlayer video={videoDoc} audio />\n * ```\n */\nexport const VideoPlayer: React.ForwardRefExoticComponent<\n VideoPlayerProps & React.RefAttributes<MuxPlayerRefAttributes>\n> = forwardRef<MuxPlayerRefAttributes, VideoPlayerProps>(\n function VideoPlayer(props, ref) {\n const {\n video,\n accentColor,\n primaryColor,\n secondaryColor,\n autoPlay,\n loop,\n muted,\n preload = 'metadata',\n startTime,\n streamType = 'on-demand',\n audio,\n noHotKeys,\n maxResolution,\n placeholder,\n placeholderClassName,\n placeholderStyle,\n className,\n style,\n onPlay,\n onPause,\n onEnded,\n onTimeUpdate,\n onLoadedData,\n onError,\n playerProps,\n } = props\n\n const playbackId = resolvePlaybackId(video)\n const title = resolveTitle(props)\n const poster = resolvePoster(props)\n const aspectRatio = resolveAspectRatio(video)\n const status = resolveStatus(video)\n\n // Show placeholder when no playbackId or video not ready\n if (!playbackId || (typeof video !== 'string' && status !== 'ready')) {\n return (\n <div\n className={placeholderClassName ?? className}\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n aspectRatio: aspectRatio ?? '16/9',\n backgroundColor: '#000',\n color: '#888',\n fontSize: 14,\n width: '100%',\n ...placeholderStyle,\n }}\n >\n {placeholder ??\n (status === 'preparing'\n ? 'Video is processing...'\n : status === 'errored'\n ? 'Video processing failed'\n : 'Video not available')}\n </div>\n )\n }\n\n return (\n <MuxPlayer\n ref={ref}\n playbackId={playbackId}\n streamType={streamType}\n accentColor={accentColor}\n primaryColor={primaryColor}\n secondaryColor={secondaryColor}\n title={title}\n autoPlay={autoPlay}\n loop={loop}\n muted={muted}\n preload={preload}\n startTime={startTime}\n poster={poster}\n audio={audio}\n nohotkeys={noHotKeys}\n maxResolution={maxResolution}\n className={className}\n style={{\n aspectRatio: aspectRatio ?? '16/9',\n width: '100%',\n ...style,\n }}\n onPlay={onPlay}\n onPause={onPause}\n onEnded={onEnded}\n onTimeUpdate={onTimeUpdate}\n onLoadedData={onLoadedData}\n onError={onError}\n {...playerProps}\n />\n )\n },\n)\n\n// ── Type Exports ──\n\nexport type { MuxPlayerRefAttributes as VideoPlayerRef } from '@mux/mux-player-react'\nexport type { Video as VideoData } from '../../payload-types'\n","const MUX_IMAGE_BASE = 'https://image.mux.com'\nconst MUX_STREAM_BASE = 'https://stream.mux.com'\n\n// ── Thumbnail ──\n\nexport interface VideoThumbnailOptions {\n /** Width in pixels (default: 640) */\n width?: number\n /** Height in pixels (auto if omitted) */\n height?: number\n /** Time offset in seconds (default: 0) */\n time?: number\n /** Fit mode (default: 'smartcrop') */\n fitMode?: 'preserve' | 'stretch' | 'crop' | 'smartcrop' | 'pad'\n /** Flip horizontally */\n flipH?: boolean\n /** Flip vertically */\n flipV?: boolean\n /** Rotation in degrees (90, 180, 270) */\n rotate?: 90 | 180 | 270\n}\n\n/**\n * Returns a Mux thumbnail URL for a video.\n *\n * @example\n * ```ts\n * getVideoThumbnail('abc123')\n * // => 'https://image.mux.com/abc123/thumbnail.jpg?width=640'\n *\n * getVideoThumbnail('abc123', { width: 320, time: 5 })\n * // => 'https://image.mux.com/abc123/thumbnail.jpg?width=320&time=5'\n * ```\n */\nexport function getVideoThumbnail(\n playbackId: string,\n options?: VideoThumbnailOptions,\n): string {\n const params = new URLSearchParams()\n params.set('width', String(options?.width ?? 640))\n if (options?.height) params.set('height', String(options.height))\n if (options?.time != null) params.set('time', String(options.time))\n if (options?.fitMode) params.set('fit_mode', options.fitMode)\n if (options?.flipH) params.set('flip_h', 'true')\n if (options?.flipV) params.set('flip_v', 'true')\n if (options?.rotate) params.set('rotate', String(options.rotate))\n return `${MUX_IMAGE_BASE}/${playbackId}/thumbnail.jpg?${params}`\n}\n\n// ── Animated GIF ──\n\nexport interface VideoGifOptions {\n /** Width in pixels (default: 320) */\n width?: number\n /** Start time in seconds (default: 0) */\n start?: number\n /** End time in seconds (default: start + 5) */\n end?: number\n /** Frames per second (default: 15) */\n fps?: number\n}\n\n/**\n * Returns a Mux animated GIF URL for a video.\n *\n * @example\n * ```ts\n * getVideoGif('abc123')\n * // => 'https://image.mux.com/abc123/animated.gif?width=320'\n *\n * getVideoGif('abc123', { width: 240, start: 2, end: 6 })\n * // => 'https://image.mux.com/abc123/animated.gif?width=240&start=2&end=6'\n * ```\n */\nexport function getVideoGif(\n playbackId: string,\n options?: VideoGifOptions,\n): string {\n const params = new URLSearchParams()\n params.set('width', String(options?.width ?? 320))\n if (options?.start != null) params.set('start', String(options.start))\n if (options?.end != null) params.set('end', String(options.end))\n if (options?.fps) params.set('fps', String(options.fps))\n return `${MUX_IMAGE_BASE}/${playbackId}/animated.gif?${params}`\n}\n\n// ── Storyboard ──\n\n/**\n * Returns a Mux storyboard VTT URL for timeline hover previews.\n *\n * @example\n * ```ts\n * getVideoStoryboard('abc123')\n * // => 'https://image.mux.com/abc123/storyboard.vtt'\n * ```\n */\nexport function getVideoStoryboard(playbackId: string): string {\n return `${MUX_IMAGE_BASE}/${playbackId}/storyboard.vtt`\n}\n\n// ── Stream / Playback URLs ──\n\n/**\n * Returns the HLS stream URL for a video.\n *\n * @example\n * ```ts\n * getVideoStreamUrl('abc123')\n * // => 'https://stream.mux.com/abc123.m3u8'\n * ```\n */\nexport function getVideoStreamUrl(playbackId: string): string {\n return `${MUX_STREAM_BASE}/${playbackId}.m3u8`\n}\n\n/**\n * Returns a Mux MP4 download URL for a video.\n * Only available if the asset was created with `mp4_support` enabled.\n *\n * @example\n * ```ts\n * getVideoMp4Url('abc123', 'high')\n * // => 'https://stream.mux.com/abc123/high.mp4'\n * ```\n */\nexport function getVideoMp4Url(\n playbackId: string,\n resolution: 'high' | 'medium' | 'low' = 'high',\n): string {\n return `${MUX_STREAM_BASE}/${playbackId}/${resolution}.mp4`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAsD;AACtD,8BAAsB;;;ACHtB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAiCjB,SAAS,kBACd,YACA,SACQ;AACR,QAAM,SAAS,IAAI,gBAAgB;AACnC,SAAO,IAAI,SAAS,OAAO,SAAS,SAAS,GAAG,CAAC;AACjD,MAAI,SAAS,OAAQ,QAAO,IAAI,UAAU,OAAO,QAAQ,MAAM,CAAC;AAChE,MAAI,SAAS,QAAQ,KAAM,QAAO,IAAI,QAAQ,OAAO,QAAQ,IAAI,CAAC;AAClE,MAAI,SAAS,QAAS,QAAO,IAAI,YAAY,QAAQ,OAAO;AAC5D,MAAI,SAAS,MAAO,QAAO,IAAI,UAAU,MAAM;AAC/C,MAAI,SAAS,MAAO,QAAO,IAAI,UAAU,MAAM;AAC/C,MAAI,SAAS,OAAQ,QAAO,IAAI,UAAU,OAAO,QAAQ,MAAM,CAAC;AAChE,SAAO,GAAG,cAAc,IAAI,UAAU,kBAAkB,MAAM;AAChE;AA2BO,SAAS,YACd,YACA,SACQ;AACR,QAAM,SAAS,IAAI,gBAAgB;AACnC,SAAO,IAAI,SAAS,OAAO,SAAS,SAAS,GAAG,CAAC;AACjD,MAAI,SAAS,SAAS,KAAM,QAAO,IAAI,SAA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ACA;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA,OAAO;AAAA,UACL,aAAa,eAAe;AAAA,UAC5B,OAAO;AAAA,UACP,GAAG;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;","names":["VideoPlayer","React","MuxPlayer"]}
|
|
1
|
+
{"version":3,"sources":["../../src/ui/Video/index.tsx","../../src/utils/video.ts"],"sourcesContent":["'use client'\n\nimport React, { forwardRef, type CSSProperties } from 'react'\nimport MuxPlayer from '@mux/mux-player-react'\nimport type {\n MuxPlayerRefAttributes,\n MuxPlayerProps,\n} from '@mux/mux-player-react'\nimport type { Video, Image } from '../../payload-types'\nimport { getVideoThumbnail } from '../../utils/video'\n\n// Re-export video utilities for convenience\nexport {\n getVideoThumbnail,\n getVideoGif,\n getVideoStreamUrl,\n getVideoMp4Url,\n getVideoStoryboard,\n type VideoThumbnailOptions,\n type VideoGifOptions,\n} from '../../utils/video'\n\n// ── CSS custom properties ──\n\nexport interface VideoPlayerCSSProperties extends CSSProperties {\n [key: `--${string}`]: string | undefined\n}\n\n// ── Props ──\n\nexport interface VideoPlayerProps {\n /** Video document or playbackId string */\n video: Video | string\n\n // ── Theming ──\n /** Theme accent color */\n accentColor?: string\n /** Theme primary color (controls) */\n primaryColor?: string\n /** Theme secondary color (time display, etc.) */\n secondaryColor?: string\n\n // ── Playback ──\n /** Title overlay (auto-resolved from Video.title if omitted) */\n title?: string\n /** Autoplay behavior */\n autoPlay?: boolean | 'muted' | 'any'\n /** Loop playback */\n loop?: boolean\n /** Muted by default */\n muted?: boolean\n /** Preload strategy (default: 'metadata') */\n preload?: 'auto' | 'metadata' | 'none'\n /** Start time in seconds */\n startTime?: number\n /** Stream type (default: 'on-demand') */\n streamType?: 'on-demand' | 'live' | 'll-live'\n /** Audio-only mode */\n audio?: boolean\n /** Disable keyboard shortcuts */\n noHotKeys?: boolean\n /** Max resolution cap */\n maxResolution?: '720p' | '1080p' | '1440p' | '2160p'\n\n // ── Poster ──\n /** Thumbnail time for auto-generated poster (default: 0) */\n thumbnailTime?: number\n /** Custom poster URL (overrides auto-generated thumbnail) */\n poster?: string\n\n // ── Placeholder (when video not ready) ──\n /** Placeholder text when video is not ready */\n placeholder?: string\n /** CSS class for the placeholder */\n placeholderClassName?: string\n /** Inline styles for the placeholder */\n placeholderStyle?: CSSProperties\n\n // ── Styling ──\n /** CSS class */\n className?: string\n /** Inline styles (supports --mux CSS custom properties) */\n style?: VideoPlayerCSSProperties\n\n // ── Events ──\n onPlay?: () => void\n onPause?: () => void\n onEnded?: () => void\n onTimeUpdate?: () => void\n onLoadedData?: () => void\n onError?: () => void\n\n // ── Escape hatch ──\n /** Extra props forwarded directly to MuxPlayer */\n playerProps?: Omit<\n MuxPlayerProps,\n | 'playbackId'\n | 'streamType'\n | 'accentColor'\n | 'primaryColor'\n | 'secondaryColor'\n | 'title'\n | 'autoPlay'\n | 'loop'\n | 'muted'\n | 'preload'\n | 'startTime'\n | 'poster'\n | 'audio'\n | 'nohotkeys'\n | 'maxResolution'\n | 'className'\n | 'style'\n >\n}\n\n// ── Helpers ──\n\nfunction resolvePlaybackId(video: Video | string): string | null {\n if (typeof video === 'string') return video\n return video.muxPlaybackId ?? null\n}\n\nfunction resolveTitle(props: VideoPlayerProps): string | undefined {\n if (props.title !== undefined) return props.title\n if (typeof props.video !== 'string') return props.video.title ?? undefined\n return undefined\n}\n\nfunction resolvePoster(props: VideoPlayerProps): string | undefined {\n // 1. Explicit poster URL (highest priority)\n if (props.poster) return props.poster\n\n // 2. Video.thumbnail uploaded image\n if (typeof props.video !== 'string' && props.video.thumbnail) {\n const thumb = props.video.thumbnail\n if (typeof thumb === 'object' && thumb !== null && 'url' in thumb) {\n const url = (thumb as Image).url\n if (url) return url\n }\n }\n\n // 3. Auto-generate from Mux image API\n const playbackId = resolvePlaybackId(props.video)\n if (!playbackId) return undefined\n return getVideoThumbnail(playbackId, {\n width: 1280,\n time: props.thumbnailTime ?? 0,\n })\n}\n\nfunction resolveAspectRatio(video: Video | string): string | undefined {\n if (typeof video === 'string') return undefined\n return video.aspectRatio ?? undefined\n}\n\nfunction resolveStatus(video: Video | string): string {\n if (typeof video === 'string') return 'ready'\n return video.muxStatus ?? 'waiting'\n}\n\n// ── Component ──\n\n/**\n * Mux video player component.\n * Requires `@mux/mux-player-react` (optional peer dependency).\n *\n * @example Basic usage\n * ```tsx\n * import { VideoPlayer } from '@01.software/sdk/ui/video'\n *\n * <VideoPlayer video={videoDoc} />\n * ```\n *\n * @example With playback ID string\n * ```tsx\n * <VideoPlayer video=\"abc123def\" autoPlay=\"muted\" loop />\n * ```\n *\n * @example Custom theming with CSS custom properties\n * ```tsx\n * <VideoPlayer\n * video={videoDoc}\n * accentColor=\"#f43f5e\"\n * primaryColor=\"#fff\"\n * className=\"rounded-lg overflow-hidden\"\n * style={{ '--controls-backdrop-color': 'rgba(0,0,0,0.6)' }}\n * />\n * ```\n *\n * @example Audio-only mode\n * ```tsx\n * <VideoPlayer video={videoDoc} audio />\n * ```\n */\nexport const VideoPlayer: React.ForwardRefExoticComponent<\n VideoPlayerProps & React.RefAttributes<MuxPlayerRefAttributes>\n> = forwardRef<MuxPlayerRefAttributes, VideoPlayerProps>(\n function VideoPlayer(props, ref) {\n const {\n video,\n accentColor,\n primaryColor,\n secondaryColor,\n autoPlay,\n loop,\n muted,\n preload = 'metadata',\n startTime,\n streamType = 'on-demand',\n audio,\n noHotKeys,\n maxResolution,\n placeholder,\n placeholderClassName,\n placeholderStyle,\n className,\n style,\n onPlay,\n onPause,\n onEnded,\n onTimeUpdate,\n onLoadedData,\n onError,\n playerProps,\n } = props\n\n const playbackId = resolvePlaybackId(video)\n const title = resolveTitle(props)\n const poster = resolvePoster(props)\n const aspectRatio = resolveAspectRatio(video)\n const status = resolveStatus(video)\n\n // Show placeholder when no playbackId or video not ready\n if (!playbackId || (typeof video !== 'string' && status !== 'ready')) {\n return (\n <div\n className={placeholderClassName ?? className}\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n aspectRatio: aspectRatio ?? '16/9',\n backgroundColor: '#000',\n color: '#888',\n fontSize: 14,\n width: '100%',\n ...placeholderStyle,\n }}\n >\n {placeholder ??\n (status === 'preparing'\n ? 'Video is processing...'\n : status === 'errored'\n ? 'Video processing failed'\n : 'Video not available')}\n </div>\n )\n }\n\n return (\n <MuxPlayer\n ref={ref}\n playbackId={playbackId}\n streamType={streamType}\n accentColor={accentColor}\n primaryColor={primaryColor}\n secondaryColor={secondaryColor}\n title={title}\n autoPlay={autoPlay}\n loop={loop}\n muted={muted}\n preload={preload}\n startTime={startTime}\n poster={poster}\n audio={audio}\n nohotkeys={noHotKeys}\n maxResolution={maxResolution}\n className={className}\n style={{\n aspectRatio: aspectRatio ?? '16/9',\n width: '100%',\n ...style,\n }}\n onPlay={onPlay}\n onPause={onPause}\n onEnded={onEnded}\n onTimeUpdate={onTimeUpdate}\n onLoadedData={onLoadedData}\n onError={onError}\n {...playerProps}\n />\n )\n },\n)\n\n// ── Type Exports ──\n\nexport type { MuxPlayerRefAttributes as VideoPlayerRef } from '@mux/mux-player-react'\nexport type { Video as VideoData } from '../../payload-types'\n","const MUX_IMAGE_BASE = 'https://image.mux.com'\nconst MUX_STREAM_BASE = 'https://stream.mux.com'\n\n// ── Thumbnail ──\n\nexport interface VideoThumbnailOptions {\n /** Width in pixels (default: 640) */\n width?: number\n /** Height in pixels (auto if omitted) */\n height?: number\n /** Time offset in seconds (default: 0) */\n time?: number\n /** Fit mode (default: 'smartcrop') */\n fitMode?: 'preserve' | 'stretch' | 'crop' | 'smartcrop' | 'pad'\n /** Flip horizontally */\n flipH?: boolean\n /** Flip vertically */\n flipV?: boolean\n /** Rotation in degrees (90, 180, 270) */\n rotate?: 90 | 180 | 270\n}\n\n/**\n * Returns a Mux thumbnail URL for a video.\n *\n * @example\n * ```ts\n * getVideoThumbnail('abc123')\n * // => 'https://image.mux.com/abc123/thumbnail.jpg?width=640'\n *\n * getVideoThumbnail('abc123', { width: 320, time: 5 })\n * // => 'https://image.mux.com/abc123/thumbnail.jpg?width=320&time=5'\n * ```\n */\nexport function getVideoThumbnail(\n playbackId: string,\n options?: VideoThumbnailOptions,\n): string {\n const params = new URLSearchParams()\n params.set('width', String(options?.width ?? 640))\n if (options?.height) params.set('height', String(options.height))\n if (options?.time != null) params.set('time', String(options.time))\n if (options?.fitMode) params.set('fit_mode', options.fitMode)\n if (options?.flipH) params.set('flip_h', 'true')\n if (options?.flipV) params.set('flip_v', 'true')\n if (options?.rotate) params.set('rotate', String(options.rotate))\n return `${MUX_IMAGE_BASE}/${playbackId}/thumbnail.jpg?${params}`\n}\n\n// ── Animated GIF ──\n\nexport interface VideoGifOptions {\n /** Width in pixels (default: 320) */\n width?: number\n /** Start time in seconds (default: 0) */\n start?: number\n /** End time in seconds (default: start + 5) */\n end?: number\n /** Frames per second (default: 15) */\n fps?: number\n}\n\n/**\n * Returns a Mux animated GIF URL for a video.\n *\n * @example\n * ```ts\n * getVideoGif('abc123')\n * // => 'https://image.mux.com/abc123/animated.gif?width=320'\n *\n * getVideoGif('abc123', { width: 240, start: 2, end: 6 })\n * // => 'https://image.mux.com/abc123/animated.gif?width=240&start=2&end=6'\n * ```\n */\nexport function getVideoGif(\n playbackId: string,\n options?: VideoGifOptions,\n): string {\n const params = new URLSearchParams()\n params.set('width', String(options?.width ?? 320))\n if (options?.start != null) params.set('start', String(options.start))\n if (options?.end != null) params.set('end', String(options.end))\n if (options?.fps) params.set('fps', String(options.fps))\n return `${MUX_IMAGE_BASE}/${playbackId}/animated.gif?${params}`\n}\n\n// ── Storyboard ──\n\n/**\n * Returns a Mux storyboard VTT URL for timeline hover previews.\n *\n * @example\n * ```ts\n * getVideoStoryboard('abc123')\n * // => 'https://image.mux.com/abc123/storyboard.vtt'\n * ```\n */\nexport function getVideoStoryboard(playbackId: string): string {\n return `${MUX_IMAGE_BASE}/${playbackId}/storyboard.vtt`\n}\n\n// ── Stream / Playback URLs ──\n\n/**\n * Returns the HLS stream URL for a video.\n *\n * @example\n * ```ts\n * getVideoStreamUrl('abc123')\n * // => 'https://stream.mux.com/abc123.m3u8'\n * ```\n */\nexport function getVideoStreamUrl(playbackId: string): string {\n return `${MUX_STREAM_BASE}/${playbackId}.m3u8`\n}\n\n/**\n * Returns a Mux MP4 download URL for a video.\n * Only available if the asset was created with `mp4_support` enabled.\n *\n * @example\n * ```ts\n * getVideoMp4Url('abc123', 'high')\n * // => 'https://stream.mux.com/abc123/high.mp4'\n * ```\n */\nexport function getVideoMp4Url(\n playbackId: string,\n resolution: 'high' | 'medium' | 'low' = 'high',\n): string {\n return `${MUX_STREAM_BASE}/${playbackId}/${resolution}.mp4`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAsD;AACtD,8BAAsB;;;ACHtB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAiCjB,SAAS,kBACd,YACA,SACQ;AACR,QAAM,SAAS,IAAI,gBAAgB;AACnC,SAAO,IAAI,SAAS,OAAO,SAAS,SAAS,GAAG,CAAC;AACjD,MAAI,SAAS,OAAQ,QAAO,IAAI,UAAU,OAAO,QAAQ,MAAM,CAAC;AAChE,MAAI,SAAS,QAAQ,KAAM,QAAO,IAAI,QAAQ,OAAO,QAAQ,IAAI,CAAC;AAClE,MAAI,SAAS,QAAS,QAAO,IAAI,YAAY,QAAQ,OAAO;AAC5D,MAAI,SAAS,MAAO,QAAO,IAAI,UAAU,MAAM;AAC/C,MAAI,SAAS,MAAO,QAAO,IAAI,UAAU,MAAM;AAC/C,MAAI,SAAS,OAAQ,QAAO,IAAI,UAAU,OAAO,QAAQ,MAAM,CAAC;AAChE,SAAO,GAAG,cAAc,IAAI,UAAU,kBAAkB,MAAM;AA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,MAAC,wBAAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA,OAAO;AAAA,UACL,aAAa,eAAe;AAAA,UAC5B,OAAO;AAAA,UACP,GAAG;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;","names":["VideoPlayer","React","MuxPlayer"]}
|
package/dist/ui/video.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { CSSProperties } from 'react';
|
|
2
2
|
import { MuxPlayerProps, MuxPlayerRefAttributes } from '@mux/mux-player-react';
|
|
3
3
|
export { MuxPlayerRefAttributes as VideoPlayerRef } from '@mux/mux-player-react';
|
|
4
|
-
import { V as Video } from '../payload-types-
|
|
4
|
+
import { V as Video } from '../payload-types-FfZ2Zxp1.cjs';
|
|
5
5
|
export { e as VideoGifOptions, V as VideoThumbnailOptions, a as getVideoGif, c as getVideoMp4Url, d as getVideoStoryboard, b as getVideoStreamUrl, g as getVideoThumbnail } from '../video-DbLL8yuc.cjs';
|
|
6
6
|
|
|
7
7
|
interface VideoPlayerCSSProperties extends CSSProperties {
|
package/dist/ui/video.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { CSSProperties } from 'react';
|
|
2
2
|
import { MuxPlayerProps, MuxPlayerRefAttributes } from '@mux/mux-player-react';
|
|
3
3
|
export { MuxPlayerRefAttributes as VideoPlayerRef } from '@mux/mux-player-react';
|
|
4
|
-
import { V as Video } from '../payload-types-
|
|
4
|
+
import { V as Video } from '../payload-types-FfZ2Zxp1.js';
|
|
5
5
|
export { e as VideoGifOptions, V as VideoThumbnailOptions, a as getVideoGif, c as getVideoMp4Url, d as getVideoStoryboard, b as getVideoStreamUrl, g as getVideoThumbnail } from '../video-DbLL8yuc.js';
|
|
6
6
|
|
|
7
7
|
interface VideoPlayerCSSProperties extends CSSProperties {
|
package/dist/ui/video.js
CHANGED
|
@@ -68,7 +68,7 @@ function resolveAspectRatio(video) {
|
|
|
68
68
|
}
|
|
69
69
|
function resolveStatus(video) {
|
|
70
70
|
if (typeof video === "string") return "ready";
|
|
71
|
-
return video.
|
|
71
|
+
return video.muxStatus ?? "waiting";
|
|
72
72
|
}
|
|
73
73
|
var VideoPlayer = forwardRef(
|
|
74
74
|
function VideoPlayer2(props, ref) {
|
package/dist/ui/video.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ui/Video/index.tsx","../../src/utils/video.ts"],"sourcesContent":["'use client'\n\nimport React, { forwardRef, type CSSProperties } from 'react'\nimport MuxPlayer from '@mux/mux-player-react'\nimport type {\n MuxPlayerRefAttributes,\n MuxPlayerProps,\n} from '@mux/mux-player-react'\nimport type { Video, Image } from '../../payload-types'\nimport { getVideoThumbnail } from '../../utils/video'\n\n// Re-export video utilities for convenience\nexport {\n getVideoThumbnail,\n getVideoGif,\n getVideoStreamUrl,\n getVideoMp4Url,\n getVideoStoryboard,\n type VideoThumbnailOptions,\n type VideoGifOptions,\n} from '../../utils/video'\n\n// ── CSS custom properties ──\n\nexport interface VideoPlayerCSSProperties extends CSSProperties {\n [key: `--${string}`]: string | undefined\n}\n\n// ── Props ──\n\nexport interface VideoPlayerProps {\n /** Video document or playbackId string */\n video: Video | string\n\n // ── Theming ──\n /** Theme accent color */\n accentColor?: string\n /** Theme primary color (controls) */\n primaryColor?: string\n /** Theme secondary color (time display, etc.) */\n secondaryColor?: string\n\n // ── Playback ──\n /** Title overlay (auto-resolved from Video.title if omitted) */\n title?: string\n /** Autoplay behavior */\n autoPlay?: boolean | 'muted' | 'any'\n /** Loop playback */\n loop?: boolean\n /** Muted by default */\n muted?: boolean\n /** Preload strategy (default: 'metadata') */\n preload?: 'auto' | 'metadata' | 'none'\n /** Start time in seconds */\n startTime?: number\n /** Stream type (default: 'on-demand') */\n streamType?: 'on-demand' | 'live' | 'll-live'\n /** Audio-only mode */\n audio?: boolean\n /** Disable keyboard shortcuts */\n noHotKeys?: boolean\n /** Max resolution cap */\n maxResolution?: '720p' | '1080p' | '1440p' | '2160p'\n\n // ── Poster ──\n /** Thumbnail time for auto-generated poster (default: 0) */\n thumbnailTime?: number\n /** Custom poster URL (overrides auto-generated thumbnail) */\n poster?: string\n\n // ── Placeholder (when video not ready) ──\n /** Placeholder text when video is not ready */\n placeholder?: string\n /** CSS class for the placeholder */\n placeholderClassName?: string\n /** Inline styles for the placeholder */\n placeholderStyle?: CSSProperties\n\n // ── Styling ──\n /** CSS class */\n className?: string\n /** Inline styles (supports --mux CSS custom properties) */\n style?: VideoPlayerCSSProperties\n\n // ── Events ──\n onPlay?: () => void\n onPause?: () => void\n onEnded?: () => void\n onTimeUpdate?: () => void\n onLoadedData?: () => void\n onError?: () => void\n\n // ── Escape hatch ──\n /** Extra props forwarded directly to MuxPlayer */\n playerProps?: Omit<\n MuxPlayerProps,\n | 'playbackId'\n | 'streamType'\n | 'accentColor'\n | 'primaryColor'\n | 'secondaryColor'\n | 'title'\n | 'autoPlay'\n | 'loop'\n | 'muted'\n | 'preload'\n | 'startTime'\n | 'poster'\n | 'audio'\n | 'nohotkeys'\n | 'maxResolution'\n | 'className'\n | 'style'\n >\n}\n\n// ── Helpers ──\n\nfunction resolvePlaybackId(video: Video | string): string | null {\n if (typeof video === 'string') return video\n return video.muxPlaybackId ?? null\n}\n\nfunction resolveTitle(props: VideoPlayerProps): string | undefined {\n if (props.title !== undefined) return props.title\n if (typeof props.video !== 'string') return props.video.title ?? undefined\n return undefined\n}\n\nfunction resolvePoster(props: VideoPlayerProps): string | undefined {\n // 1. Explicit poster URL (highest priority)\n if (props.poster) return props.poster\n\n // 2. Video.thumbnail uploaded image\n if (typeof props.video !== 'string' && props.video.thumbnail) {\n const thumb = props.video.thumbnail\n if (typeof thumb === 'object' && thumb !== null && 'url' in thumb) {\n const url = (thumb as Image).url\n if (url) return url\n }\n }\n\n // 3. Auto-generate from Mux image API\n const playbackId = resolvePlaybackId(props.video)\n if (!playbackId) return undefined\n return getVideoThumbnail(playbackId, {\n width: 1280,\n time: props.thumbnailTime ?? 0,\n })\n}\n\nfunction resolveAspectRatio(video: Video | string): string | undefined {\n if (typeof video === 'string') return undefined\n return video.aspectRatio ?? undefined\n}\n\nfunction resolveStatus(video: Video | string): string {\n if (typeof video === 'string') return 'ready'\n return video.status ?? 'waiting'\n}\n\n// ── Component ──\n\n/**\n * Mux video player component.\n * Requires `@mux/mux-player-react` (optional peer dependency).\n *\n * @example Basic usage\n * ```tsx\n * import { VideoPlayer } from '@01.software/sdk/ui/video'\n *\n * <VideoPlayer video={videoDoc} />\n * ```\n *\n * @example With playback ID string\n * ```tsx\n * <VideoPlayer video=\"abc123def\" autoPlay=\"muted\" loop />\n * ```\n *\n * @example Custom theming with CSS custom properties\n * ```tsx\n * <VideoPlayer\n * video={videoDoc}\n * accentColor=\"#f43f5e\"\n * primaryColor=\"#fff\"\n * className=\"rounded-lg overflow-hidden\"\n * style={{ '--controls-backdrop-color': 'rgba(0,0,0,0.6)' }}\n * />\n * ```\n *\n * @example Audio-only mode\n * ```tsx\n * <VideoPlayer video={videoDoc} audio />\n * ```\n */\nexport const VideoPlayer: React.ForwardRefExoticComponent<\n VideoPlayerProps & React.RefAttributes<MuxPlayerRefAttributes>\n> = forwardRef<MuxPlayerRefAttributes, VideoPlayerProps>(\n function VideoPlayer(props, ref) {\n const {\n video,\n accentColor,\n primaryColor,\n secondaryColor,\n autoPlay,\n loop,\n muted,\n preload = 'metadata',\n startTime,\n streamType = 'on-demand',\n audio,\n noHotKeys,\n maxResolution,\n placeholder,\n placeholderClassName,\n placeholderStyle,\n className,\n style,\n onPlay,\n onPause,\n onEnded,\n onTimeUpdate,\n onLoadedData,\n onError,\n playerProps,\n } = props\n\n const playbackId = resolvePlaybackId(video)\n const title = resolveTitle(props)\n const poster = resolvePoster(props)\n const aspectRatio = resolveAspectRatio(video)\n const status = resolveStatus(video)\n\n // Show placeholder when no playbackId or video not ready\n if (!playbackId || (typeof video !== 'string' && status !== 'ready')) {\n return (\n <div\n className={placeholderClassName ?? className}\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n aspectRatio: aspectRatio ?? '16/9',\n backgroundColor: '#000',\n color: '#888',\n fontSize: 14,\n width: '100%',\n ...placeholderStyle,\n }}\n >\n {placeholder ??\n (status === 'preparing'\n ? 'Video is processing...'\n : status === 'errored'\n ? 'Video processing failed'\n : 'Video not available')}\n </div>\n )\n }\n\n return (\n <MuxPlayer\n ref={ref}\n playbackId={playbackId}\n streamType={streamType}\n accentColor={accentColor}\n primaryColor={primaryColor}\n secondaryColor={secondaryColor}\n title={title}\n autoPlay={autoPlay}\n loop={loop}\n muted={muted}\n preload={preload}\n startTime={startTime}\n poster={poster}\n audio={audio}\n nohotkeys={noHotKeys}\n maxResolution={maxResolution}\n className={className}\n style={{\n aspectRatio: aspectRatio ?? '16/9',\n width: '100%',\n ...style,\n }}\n onPlay={onPlay}\n onPause={onPause}\n onEnded={onEnded}\n onTimeUpdate={onTimeUpdate}\n onLoadedData={onLoadedData}\n onError={onError}\n {...playerProps}\n />\n )\n },\n)\n\n// ── Type Exports ──\n\nexport type { MuxPlayerRefAttributes as VideoPlayerRef } from '@mux/mux-player-react'\nexport type { Video as VideoData } from '../../payload-types'\n","const MUX_IMAGE_BASE = 'https://image.mux.com'\nconst MUX_STREAM_BASE = 'https://stream.mux.com'\n\n// ── Thumbnail ──\n\nexport interface VideoThumbnailOptions {\n /** Width in pixels (default: 640) */\n width?: number\n /** Height in pixels (auto if omitted) */\n height?: number\n /** Time offset in seconds (default: 0) */\n time?: number\n /** Fit mode (default: 'smartcrop') */\n fitMode?: 'preserve' | 'stretch' | 'crop' | 'smartcrop' | 'pad'\n /** Flip horizontally */\n flipH?: boolean\n /** Flip vertically */\n flipV?: boolean\n /** Rotation in degrees (90, 180, 270) */\n rotate?: 90 | 180 | 270\n}\n\n/**\n * Returns a Mux thumbnail URL for a video.\n *\n * @example\n * ```ts\n * getVideoThumbnail('abc123')\n * // => 'https://image.mux.com/abc123/thumbnail.jpg?width=640'\n *\n * getVideoThumbnail('abc123', { width: 320, time: 5 })\n * // => 'https://image.mux.com/abc123/thumbnail.jpg?width=320&time=5'\n * ```\n */\nexport function getVideoThumbnail(\n playbackId: string,\n options?: VideoThumbnailOptions,\n): string {\n const params = new URLSearchParams()\n params.set('width', String(options?.width ?? 640))\n if (options?.height) params.set('height', String(options.height))\n if (options?.time != null) params.set('time', String(options.time))\n if (options?.fitMode) params.set('fit_mode', options.fitMode)\n if (options?.flipH) params.set('flip_h', 'true')\n if (options?.flipV) params.set('flip_v', 'true')\n if (options?.rotate) params.set('rotate', String(options.rotate))\n return `${MUX_IMAGE_BASE}/${playbackId}/thumbnail.jpg?${params}`\n}\n\n// ── Animated GIF ──\n\nexport interface VideoGifOptions {\n /** Width in pixels (default: 320) */\n width?: number\n /** Start time in seconds (default: 0) */\n start?: number\n /** End time in seconds (default: start + 5) */\n end?: number\n /** Frames per second (default: 15) */\n fps?: number\n}\n\n/**\n * Returns a Mux animated GIF URL for a video.\n *\n * @example\n * ```ts\n * getVideoGif('abc123')\n * // => 'https://image.mux.com/abc123/animated.gif?width=320'\n *\n * getVideoGif('abc123', { width: 240, start: 2, end: 6 })\n * // => 'https://image.mux.com/abc123/animated.gif?width=240&start=2&end=6'\n * ```\n */\nexport function getVideoGif(\n playbackId: string,\n options?: VideoGifOptions,\n): string {\n const params = new URLSearchParams()\n params.set('width', String(options?.width ?? 320))\n if (options?.start != null) params.set('start', String(options.start))\n if (options?.end != null) params.set('end', String(options.end))\n if (options?.fps) params.set('fps', String(options.fps))\n return `${MUX_IMAGE_BASE}/${playbackId}/animated.gif?${params}`\n}\n\n// ── Storyboard ──\n\n/**\n * Returns a Mux storyboard VTT URL for timeline hover previews.\n *\n * @example\n * ```ts\n * getVideoStoryboard('abc123')\n * // => 'https://image.mux.com/abc123/storyboard.vtt'\n * ```\n */\nexport function getVideoStoryboard(playbackId: string): string {\n return `${MUX_IMAGE_BASE}/${playbackId}/storyboard.vtt`\n}\n\n// ── Stream / Playback URLs ──\n\n/**\n * Returns the HLS stream URL for a video.\n *\n * @example\n * ```ts\n * getVideoStreamUrl('abc123')\n * // => 'https://stream.mux.com/abc123.m3u8'\n * ```\n */\nexport function getVideoStreamUrl(playbackId: string): string {\n return `${MUX_STREAM_BASE}/${playbackId}.m3u8`\n}\n\n/**\n * Returns a Mux MP4 download URL for a video.\n * Only available if the asset was created with `mp4_support` enabled.\n *\n * @example\n * ```ts\n * getVideoMp4Url('abc123', 'high')\n * // => 'https://stream.mux.com/abc123/high.mp4'\n * ```\n */\nexport function getVideoMp4Url(\n playbackId: string,\n resolution: 'high' | 'medium' | 'low' = 'high',\n): string {\n return `${MUX_STREAM_BASE}/${playbackId}/${resolution}.mp4`\n}\n"],"mappings":";;;AAEA,OAAO,SAAS,kBAAsC;AACtD,OAAO,eAAe;;;ACHtB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAiCjB,SAAS,kBACd,YACA,SACQ;AACR,QAAM,SAAS,IAAI,gBAAgB;AACnC,SAAO,IAAI,SAAS,OAAO,SAAS,SAAS,GAAG,CAAC;AACjD,MAAI,SAAS,OAAQ,QAAO,IAAI,UAAU,OAAO,QAAQ,MAAM,CAAC;AAChE,MAAI,SAAS,QAAQ,KAAM,QAAO,IAAI,QAAQ,OAAO,QAAQ,IAAI,CAAC;AAClE,MAAI,SAAS,QAAS,QAAO,IAAI,YAAY,QAAQ,OAAO;AAC5D,MAAI,SAAS,MAAO,QAAO,IAAI,UAAU,MAAM;AAC/C,MAAI,SAAS,MAAO,QAAO,IAAI,UAAU,MAAM;AAC/C,MAAI,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BACE,WAAW,cACR,2BACA,WAAW,YACT,4BACA;AAAA,MACV;AAAA,IAEJ;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA,OAAO;AAAA,UACL,aAAa,eAAe;AAAA,UAC5B,OAAO;AAAA,UACP,GAAG;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;","names":["VideoPlayer"]}
|
|
1
|
+
{"version":3,"sources":["../../src/ui/Video/index.tsx","../../src/utils/video.ts"],"sourcesContent":["'use client'\n\nimport React, { forwardRef, type CSSProperties } from 'react'\nimport MuxPlayer from '@mux/mux-player-react'\nimport type {\n MuxPlayerRefAttributes,\n MuxPlayerProps,\n} from '@mux/mux-player-react'\nimport type { Video, Image } from '../../payload-types'\nimport { getVideoThumbnail } from '../../utils/video'\n\n// Re-export video utilities for convenience\nexport {\n getVideoThumbnail,\n getVideoGif,\n getVideoStreamUrl,\n getVideoMp4Url,\n getVideoStoryboard,\n type VideoThumbnailOptions,\n type VideoGifOptions,\n} from '../../utils/video'\n\n// ── CSS custom properties ──\n\nexport interface VideoPlayerCSSProperties extends CSSProperties {\n [key: `--${string}`]: string | undefined\n}\n\n// ── Props ──\n\nexport interface VideoPlayerProps {\n /** Video document or playbackId string */\n video: Video | string\n\n // ── Theming ──\n /** Theme accent color */\n accentColor?: string\n /** Theme primary color (controls) */\n primaryColor?: string\n /** Theme secondary color (time display, etc.) */\n secondaryColor?: string\n\n // ── Playback ──\n /** Title overlay (auto-resolved from Video.title if omitted) */\n title?: string\n /** Autoplay behavior */\n autoPlay?: boolean | 'muted' | 'any'\n /** Loop playback */\n loop?: boolean\n /** Muted by default */\n muted?: boolean\n /** Preload strategy (default: 'metadata') */\n preload?: 'auto' | 'metadata' | 'none'\n /** Start time in seconds */\n startTime?: number\n /** Stream type (default: 'on-demand') */\n streamType?: 'on-demand' | 'live' | 'll-live'\n /** Audio-only mode */\n audio?: boolean\n /** Disable keyboard shortcuts */\n noHotKeys?: boolean\n /** Max resolution cap */\n maxResolution?: '720p' | '1080p' | '1440p' | '2160p'\n\n // ── Poster ──\n /** Thumbnail time for auto-generated poster (default: 0) */\n thumbnailTime?: number\n /** Custom poster URL (overrides auto-generated thumbnail) */\n poster?: string\n\n // ── Placeholder (when video not ready) ──\n /** Placeholder text when video is not ready */\n placeholder?: string\n /** CSS class for the placeholder */\n placeholderClassName?: string\n /** Inline styles for the placeholder */\n placeholderStyle?: CSSProperties\n\n // ── Styling ──\n /** CSS class */\n className?: string\n /** Inline styles (supports --mux CSS custom properties) */\n style?: VideoPlayerCSSProperties\n\n // ── Events ──\n onPlay?: () => void\n onPause?: () => void\n onEnded?: () => void\n onTimeUpdate?: () => void\n onLoadedData?: () => void\n onError?: () => void\n\n // ── Escape hatch ──\n /** Extra props forwarded directly to MuxPlayer */\n playerProps?: Omit<\n MuxPlayerProps,\n | 'playbackId'\n | 'streamType'\n | 'accentColor'\n | 'primaryColor'\n | 'secondaryColor'\n | 'title'\n | 'autoPlay'\n | 'loop'\n | 'muted'\n | 'preload'\n | 'startTime'\n | 'poster'\n | 'audio'\n | 'nohotkeys'\n | 'maxResolution'\n | 'className'\n | 'style'\n >\n}\n\n// ── Helpers ──\n\nfunction resolvePlaybackId(video: Video | string): string | null {\n if (typeof video === 'string') return video\n return video.muxPlaybackId ?? null\n}\n\nfunction resolveTitle(props: VideoPlayerProps): string | undefined {\n if (props.title !== undefined) return props.title\n if (typeof props.video !== 'string') return props.video.title ?? undefined\n return undefined\n}\n\nfunction resolvePoster(props: VideoPlayerProps): string | undefined {\n // 1. Explicit poster URL (highest priority)\n if (props.poster) return props.poster\n\n // 2. Video.thumbnail uploaded image\n if (typeof props.video !== 'string' && props.video.thumbnail) {\n const thumb = props.video.thumbnail\n if (typeof thumb === 'object' && thumb !== null && 'url' in thumb) {\n const url = (thumb as Image).url\n if (url) return url\n }\n }\n\n // 3. Auto-generate from Mux image API\n const playbackId = resolvePlaybackId(props.video)\n if (!playbackId) return undefined\n return getVideoThumbnail(playbackId, {\n width: 1280,\n time: props.thumbnailTime ?? 0,\n })\n}\n\nfunction resolveAspectRatio(video: Video | string): string | undefined {\n if (typeof video === 'string') return undefined\n return video.aspectRatio ?? undefined\n}\n\nfunction resolveStatus(video: Video | string): string {\n if (typeof video === 'string') return 'ready'\n return video.muxStatus ?? 'waiting'\n}\n\n// ── Component ──\n\n/**\n * Mux video player component.\n * Requires `@mux/mux-player-react` (optional peer dependency).\n *\n * @example Basic usage\n * ```tsx\n * import { VideoPlayer } from '@01.software/sdk/ui/video'\n *\n * <VideoPlayer video={videoDoc} />\n * ```\n *\n * @example With playback ID string\n * ```tsx\n * <VideoPlayer video=\"abc123def\" autoPlay=\"muted\" loop />\n * ```\n *\n * @example Custom theming with CSS custom properties\n * ```tsx\n * <VideoPlayer\n * video={videoDoc}\n * accentColor=\"#f43f5e\"\n * primaryColor=\"#fff\"\n * className=\"rounded-lg overflow-hidden\"\n * style={{ '--controls-backdrop-color': 'rgba(0,0,0,0.6)' }}\n * />\n * ```\n *\n * @example Audio-only mode\n * ```tsx\n * <VideoPlayer video={videoDoc} audio />\n * ```\n */\nexport const VideoPlayer: React.ForwardRefExoticComponent<\n VideoPlayerProps & React.RefAttributes<MuxPlayerRefAttributes>\n> = forwardRef<MuxPlayerRefAttributes, VideoPlayerProps>(\n function VideoPlayer(props, ref) {\n const {\n video,\n accentColor,\n primaryColor,\n secondaryColor,\n autoPlay,\n loop,\n muted,\n preload = 'metadata',\n startTime,\n streamType = 'on-demand',\n audio,\n noHotKeys,\n maxResolution,\n placeholder,\n placeholderClassName,\n placeholderStyle,\n className,\n style,\n onPlay,\n onPause,\n onEnded,\n onTimeUpdate,\n onLoadedData,\n onError,\n playerProps,\n } = props\n\n const playbackId = resolvePlaybackId(video)\n const title = resolveTitle(props)\n const poster = resolvePoster(props)\n const aspectRatio = resolveAspectRatio(video)\n const status = resolveStatus(video)\n\n // Show placeholder when no playbackId or video not ready\n if (!playbackId || (typeof video !== 'string' && status !== 'ready')) {\n return (\n <div\n className={placeholderClassName ?? className}\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n aspectRatio: aspectRatio ?? '16/9',\n backgroundColor: '#000',\n color: '#888',\n fontSize: 14,\n width: '100%',\n ...placeholderStyle,\n }}\n >\n {placeholder ??\n (status === 'preparing'\n ? 'Video is processing...'\n : status === 'errored'\n ? 'Video processing failed'\n : 'Video not available')}\n </div>\n )\n }\n\n return (\n <MuxPlayer\n ref={ref}\n playbackId={playbackId}\n streamType={streamType}\n accentColor={accentColor}\n primaryColor={primaryColor}\n secondaryColor={secondaryColor}\n title={title}\n autoPlay={autoPlay}\n loop={loop}\n muted={muted}\n preload={preload}\n startTime={startTime}\n poster={poster}\n audio={audio}\n nohotkeys={noHotKeys}\n maxResolution={maxResolution}\n className={className}\n style={{\n aspectRatio: aspectRatio ?? '16/9',\n width: '100%',\n ...style,\n }}\n onPlay={onPlay}\n onPause={onPause}\n onEnded={onEnded}\n onTimeUpdate={onTimeUpdate}\n onLoadedData={onLoadedData}\n onError={onError}\n {...playerProps}\n />\n )\n },\n)\n\n// ── Type Exports ──\n\nexport type { MuxPlayerRefAttributes as VideoPlayerRef } from '@mux/mux-player-react'\nexport type { Video as VideoData } from '../../payload-types'\n","const MUX_IMAGE_BASE = 'https://image.mux.com'\nconst MUX_STREAM_BASE = 'https://stream.mux.com'\n\n// ── Thumbnail ──\n\nexport interface VideoThumbnailOptions {\n /** Width in pixels (default: 640) */\n width?: number\n /** Height in pixels (auto if omitted) */\n height?: number\n /** Time offset in seconds (default: 0) */\n time?: number\n /** Fit mode (default: 'smartcrop') */\n fitMode?: 'preserve' | 'stretch' | 'crop' | 'smartcrop' | 'pad'\n /** Flip horizontally */\n flipH?: boolean\n /** Flip vertically */\n flipV?: boolean\n /** Rotation in degrees (90, 180, 270) */\n rotate?: 90 | 180 | 270\n}\n\n/**\n * Returns a Mux thumbnail URL for a video.\n *\n * @example\n * ```ts\n * getVideoThumbnail('abc123')\n * // => 'https://image.mux.com/abc123/thumbnail.jpg?width=640'\n *\n * getVideoThumbnail('abc123', { width: 320, time: 5 })\n * // => 'https://image.mux.com/abc123/thumbnail.jpg?width=320&time=5'\n * ```\n */\nexport function getVideoThumbnail(\n playbackId: string,\n options?: VideoThumbnailOptions,\n): string {\n const params = new URLSearchParams()\n params.set('width', String(options?.width ?? 640))\n if (options?.height) params.set('height', String(options.height))\n if (options?.time != null) params.set('time', String(options.time))\n if (options?.fitMode) params.set('fit_mode', options.fitMode)\n if (options?.flipH) params.set('flip_h', 'true')\n if (options?.flipV) params.set('flip_v', 'true')\n if (options?.rotate) params.set('rotate', String(options.rotate))\n return `${MUX_IMAGE_BASE}/${playbackId}/thumbnail.jpg?${params}`\n}\n\n// ── Animated GIF ──\n\nexport interface VideoGifOptions {\n /** Width in pixels (default: 320) */\n width?: number\n /** Start time in seconds (default: 0) */\n start?: number\n /** End time in seconds (default: start + 5) */\n end?: number\n /** Frames per second (default: 15) */\n fps?: number\n}\n\n/**\n * Returns a Mux animated GIF URL for a video.\n *\n * @example\n * ```ts\n * getVideoGif('abc123')\n * // => 'https://image.mux.com/abc123/animated.gif?width=320'\n *\n * getVideoGif('abc123', { width: 240, start: 2, end: 6 })\n * // => 'https://image.mux.com/abc123/animated.gif?width=240&start=2&end=6'\n * ```\n */\nexport function getVideoGif(\n playbackId: string,\n options?: VideoGifOptions,\n): string {\n const params = new URLSearchParams()\n params.set('width', String(options?.width ?? 320))\n if (options?.start != null) params.set('start', String(options.start))\n if (options?.end != null) params.set('end', String(options.end))\n if (options?.fps) params.set('fps', String(options.fps))\n return `${MUX_IMAGE_BASE}/${playbackId}/animated.gif?${params}`\n}\n\n// ── Storyboard ──\n\n/**\n * Returns a Mux storyboard VTT URL for timeline hover previews.\n *\n * @example\n * ```ts\n * getVideoStoryboard('abc123')\n * // => 'https://image.mux.com/abc123/storyboard.vtt'\n * ```\n */\nexport function getVideoStoryboard(playbackId: string): string {\n return `${MUX_IMAGE_BASE}/${playbackId}/storyboard.vtt`\n}\n\n// ── Stream / Playback URLs ──\n\n/**\n * Returns the HLS stream URL for a video.\n *\n * @example\n * ```ts\n * getVideoStreamUrl('abc123')\n * // => 'https://stream.mux.com/abc123.m3u8'\n * ```\n */\nexport function getVideoStreamUrl(playbackId: string): string {\n return `${MUX_STREAM_BASE}/${playbackId}.m3u8`\n}\n\n/**\n * Returns a Mux MP4 download URL for a video.\n * Only available if the asset was created with `mp4_support` enabled.\n *\n * @example\n * ```ts\n * getVideoMp4Url('abc123', 'high')\n * // => 'https://stream.mux.com/abc123/high.mp4'\n * ```\n */\nexport function getVideoMp4Url(\n playbackId: string,\n resolution: 'high' | 'medium' | 'low' = 'high',\n): string {\n return `${MUX_STREAM_BASE}/${playbackId}/${resolution}.mp4`\n}\n"],"mappings":";;;AAEA,OAAO,SAAS,kBAAsC;AACtD,OAAO,eAAe;;;ACHtB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAiCjB,SAAS,kBACd,YACA,SACQ;AACR,QAAM,SAAS,IAAI,gBAAgB;AACnC,SAAO,IAAI,SAAS,OAAO,SAAS,SAAS,GAAG,CAAC;AACjD,MAAI,SAAS,OAAQ,QAAO,IAAI,UAAU,OAAO,QAAQ,MAAM,CAAC;AAChE,MAAI,SAAS,QAAQ,KAAM,QAAO,IAAI,QAAQ,OAAO,QAAQ,IAAI,CAAC;AAClE,MAAI,SAAS,QAAS,QAAO,IAAI,YAAY,QAAQ,OAAO;AAC5D,MAAI,SAAS,MAAO,QAAO,IAAI,UAAU,MAAM;AAC/C,MAAI,SAAS,MAAO,QAAO,IA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AAAA,UACL;AAAA;AAAA,QAEC,gBACE,WAAW,cACR,2BACA,WAAW,YACT,4BACA;AAAA,MACV;AAAA,IAEJ;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA,OAAO;AAAA,UACL,aAAa,eAAe;AAAA,UAC5B,OAAO;AAAA,UACP,GAAG;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;","names":["VideoPlayer"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Collection } from './const-
|
|
2
|
-
import { C as Config } from './payload-types-
|
|
1
|
+
import { C as Collection } from './const-CCh99Gxu.js';
|
|
2
|
+
import { C as Config } from './payload-types-FfZ2Zxp1.js';
|
|
3
3
|
|
|
4
4
|
type CollectionType<T extends string> = T extends keyof Config['collections'] ? Config['collections'][T] : never;
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Collection } from './const-
|
|
2
|
-
import { C as Config } from './payload-types-
|
|
1
|
+
import { C as Collection } from './const-dv0zuAxG.cjs';
|
|
2
|
+
import { C as Config } from './payload-types-FfZ2Zxp1.cjs';
|
|
3
3
|
|
|
4
4
|
type CollectionType<T extends string> = T extends keyof Config['collections'] ? Config['collections'][T] : never;
|
|
5
5
|
|
package/dist/webhook.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, d as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-
|
|
2
|
-
import './const-
|
|
3
|
-
import './payload-types-
|
|
1
|
+
export { a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, d as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-t7JGFLKQ.cjs';
|
|
2
|
+
import './const-dv0zuAxG.cjs';
|
|
3
|
+
import './payload-types-FfZ2Zxp1.cjs';
|
package/dist/webhook.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, d as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-
|
|
2
|
-
import './const-
|
|
3
|
-
import './payload-types-
|
|
1
|
+
export { a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, d as createTypedWebhookHandler, h as handleWebhook, i as isValidWebhookEvent } from './webhook-B9MDrH22.js';
|
|
2
|
+
import './const-CCh99Gxu.js';
|
|
3
|
+
import './payload-types-FfZ2Zxp1.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@01.software/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "01.software SDK",
|
|
5
5
|
"author": "<office@01.works>",
|
|
6
6
|
"keywords": [],
|
|
@@ -148,8 +148,8 @@
|
|
|
148
148
|
"shadcn": "^3.6.3",
|
|
149
149
|
"tsup": "^8.3.7",
|
|
150
150
|
"vitest": "^3.2.3",
|
|
151
|
-
"@repo/
|
|
152
|
-
"@repo/
|
|
151
|
+
"@repo/eslint-config": "0.0.0",
|
|
152
|
+
"@repo/typescript-config": "0.0.0"
|
|
153
153
|
},
|
|
154
154
|
"dependencies": {
|
|
155
155
|
"@payloadcms/richtext-lexical": ">=3.82.0",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { C as Config } from './payload-types-CFDtFiSz.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Collection type derived from Payload Config.
|
|
5
|
-
* This ensures type safety and automatic synchronization with payload-types.ts
|
|
6
|
-
*/
|
|
7
|
-
type Collection = keyof Config['collections'];
|
|
8
|
-
/**
|
|
9
|
-
* Array of all public collection names for runtime use (e.g., Zod enum validation).
|
|
10
|
-
* This is the single source of truth for which collections are publicly accessible via SDK.
|
|
11
|
-
*/
|
|
12
|
-
declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-products", "returns", "return-products", "exchanges", "exchange-products", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "customer-groups", "carts", "cart-items", "discounts", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-authors", "post-categories", "post-tags", "playlists", "playlist-categories", "playlist-tags", "musics", "music-categories", "music-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "threads", "comments", "reactions", "reaction-types", "bookmarks", "thread-categories", "reports", "community-bans"];
|
|
13
|
-
/**
|
|
14
|
-
* Public collections available for SDK access.
|
|
15
|
-
* Derived from the COLLECTIONS array (single source of truth).
|
|
16
|
-
*/
|
|
17
|
-
type PublicCollection = (typeof COLLECTIONS)[number];
|
|
18
|
-
|
|
19
|
-
export { type Collection as C, type PublicCollection as P, COLLECTIONS as a };
|
package/dist/const-DQYzabjw.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { C as Config } from './payload-types-CFDtFiSz.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Collection type derived from Payload Config.
|
|
5
|
-
* This ensures type safety and automatic synchronization with payload-types.ts
|
|
6
|
-
*/
|
|
7
|
-
type Collection = keyof Config['collections'];
|
|
8
|
-
/**
|
|
9
|
-
* Array of all public collection names for runtime use (e.g., Zod enum validation).
|
|
10
|
-
* This is the single source of truth for which collections are publicly accessible via SDK.
|
|
11
|
-
*/
|
|
12
|
-
declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-products", "returns", "return-products", "exchanges", "exchange-products", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "customer-groups", "carts", "cart-items", "discounts", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-authors", "post-categories", "post-tags", "playlists", "playlist-categories", "playlist-tags", "musics", "music-categories", "music-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "threads", "comments", "reactions", "reaction-types", "bookmarks", "thread-categories", "reports", "community-bans"];
|
|
13
|
-
/**
|
|
14
|
-
* Public collections available for SDK access.
|
|
15
|
-
* Derived from the COLLECTIONS array (single source of truth).
|
|
16
|
-
*/
|
|
17
|
-
type PublicCollection = (typeof COLLECTIONS)[number];
|
|
18
|
-
|
|
19
|
-
export { type Collection as C, type PublicCollection as P, COLLECTIONS as a };
|