@vicacha-devs/medusa-plugin-stories 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/__tests__/stories-plugin.spec.js +358 -0
- package/.medusa/server/src/admin/i18n/index.js +35 -0
- package/.medusa/server/src/admin/i18n/json/ar.json +196 -0
- package/.medusa/server/src/admin/i18n/json/de.json +196 -0
- package/.medusa/server/src/admin/i18n/json/en.json +196 -0
- package/.medusa/server/src/admin/i18n/json/es.json +196 -0
- package/.medusa/server/src/admin/i18n/json/fr.json +196 -0
- package/.medusa/server/src/admin/i18n/json/it.json +196 -0
- package/.medusa/server/src/admin/i18n/json/nl.json +196 -0
- package/.medusa/server/src/admin/i18n/json/pl.json +196 -0
- package/.medusa/server/src/admin/i18n/json/pt.json +196 -0
- package/.medusa/server/src/admin/i18n/json/tr.json +196 -0
- package/.medusa/server/src/admin/index.cjs +4699 -0
- package/.medusa/server/src/admin/index.js +4699 -0
- package/.medusa/server/src/api/admin/plugin/route.js +4 -0
- package/.medusa/server/src/api/admin/stories/[id]/hotspots/route.js +14 -0
- package/.medusa/server/src/api/admin/stories/[id]/route.js +27 -0
- package/.medusa/server/src/api/admin/stories/[id]/stickers/route.js +14 -0
- package/.medusa/server/src/api/admin/stories/analytics/route.js +7 -0
- package/.medusa/server/src/api/admin/stories/groups/[id]/route.js +23 -0
- package/.medusa/server/src/api/admin/stories/groups/route.js +15 -0
- package/.medusa/server/src/api/admin/stories/route.js +21 -0
- package/.medusa/server/src/api/middlewares.js +58 -0
- package/.medusa/server/src/api/store/plugin/route.js +4 -0
- package/.medusa/server/src/api/store/stories/[id]/events/route.js +12 -0
- package/.medusa/server/src/api/store/stories/[id]/interact/route.js +14 -0
- package/.medusa/server/src/api/store/stories/route.js +33 -0
- package/.medusa/server/src/api/validators.js +136 -0
- package/.medusa/server/src/hooks/index.js +213 -0
- package/.medusa/server/src/hooks/use-sdk-primitives.js +93 -0
- package/.medusa/server/src/index.js +6 -0
- package/.medusa/server/src/jobs/expire-ephemeral-stories.js +10 -0
- package/.medusa/server/src/modules/index.js +7 -0
- package/.medusa/server/src/modules/stories/index.js +3 -0
- package/.medusa/server/src/modules/story/index.js +23 -0
- package/.medusa/server/src/modules/story/migrations/Migration20260514000000.js +181 -0
- package/.medusa/server/src/modules/story/models/index.js +141 -0
- package/.medusa/server/src/modules/story/service.js +673 -0
- package/.medusa/server/src/modules/story/types.js +3 -0
- package/.medusa/server/src/modules/story/utils/security.js +76 -0
- package/.medusa/server/src/rbac.js +75 -0
- package/.medusa/server/src/sdk/index.js +148 -0
- package/.medusa/server/src/subscribers/product-deleted.js +11 -0
- package/.medusa/server/src/types/index.js +2 -0
- package/.medusa/server/src/ui/index.js +5 -0
- package/.medusa/server/src/ui/story-hotspot-pin.js +43 -0
- package/.medusa/server/src/ui/story-player-modal.js +104 -0
- package/.medusa/server/src/ui/story-product-sheet.js +7 -0
- package/.medusa/server/src/ui/story-rings-bar.js +42 -0
- package/.medusa/server/src/workflows/index.js +50 -0
- package/LICENSE +21 -0
- package/README.md +246 -2
- package/package.json +127 -3
- package/src/__tests__/medusa-shim.mjs +533 -0
- package/src/__tests__/register-ts-resolver.mjs +141 -0
- package/src/__tests__/stories-plugin.spec.ts +526 -0
- package/src/admin/README.md +94 -0
- package/src/admin/components/analytics-tab.tsx +225 -0
- package/src/admin/components/canvas-editor-tab.tsx +77 -0
- package/src/admin/components/hotspot-form-section.tsx +155 -0
- package/src/admin/components/index.ts +15 -0
- package/src/admin/components/overview-cards.tsx +96 -0
- package/src/admin/components/product-stories-card.tsx +123 -0
- package/src/admin/components/rbac-guard.tsx +153 -0
- package/src/admin/components/slide-form-section.tsx +187 -0
- package/src/admin/components/slide-preview-canvas.tsx +166 -0
- package/src/admin/components/slide-timeline-section.tsx +126 -0
- package/src/admin/components/sticker-form-section.tsx +201 -0
- package/src/admin/components/sticker-list-section.tsx +113 -0
- package/src/admin/components/stickers-tab.tsx +34 -0
- package/src/admin/components/story-ring-form.tsx +241 -0
- package/src/admin/components/story-rings-tab.tsx +204 -0
- package/src/admin/components/story-rings-table.tsx +222 -0
- package/src/admin/components/studio-header.tsx +67 -0
- package/src/admin/hooks/use-product-stories.ts +71 -0
- package/src/admin/hooks/use-stories-studio.ts +439 -0
- package/src/admin/i18n/README.md +84 -0
- package/src/admin/i18n/index.ts +36 -0
- package/src/admin/i18n/json/ar.json +196 -0
- package/src/admin/i18n/json/de.json +196 -0
- package/src/admin/i18n/json/en.json +196 -0
- package/src/admin/i18n/json/es.json +196 -0
- package/src/admin/i18n/json/fr.json +196 -0
- package/src/admin/i18n/json/it.json +196 -0
- package/src/admin/i18n/json/nl.json +196 -0
- package/src/admin/i18n/json/pl.json +196 -0
- package/src/admin/i18n/json/pt.json +196 -0
- package/src/admin/i18n/json/tr.json +196 -0
- package/src/admin/routes/stories/analytics/page.tsx +66 -0
- package/src/admin/routes/stories/canvas/page.tsx +101 -0
- package/src/admin/routes/stories/page.tsx +164 -0
- package/src/admin/routes/stories/rings/@create/page.tsx +61 -0
- package/src/admin/routes/stories/rings/page.tsx +88 -0
- package/src/admin/routes/stories/stickers/page.tsx +74 -0
- package/src/admin/tsconfig.json +23 -0
- package/src/admin/utils/theme-presets.ts +94 -0
- package/src/admin/vite-env.d.ts +1 -0
- package/src/admin/widgets/product-stories-widget.tsx +32 -0
- package/src/api/README.md +61 -0
- package/src/api/admin/plugin/route.ts +5 -0
- package/src/api/admin/stories/[id]/hotspots/route.ts +17 -0
- package/src/api/admin/stories/[id]/route.ts +40 -0
- package/src/api/admin/stories/[id]/stickers/route.ts +20 -0
- package/src/api/admin/stories/analytics/route.ts +8 -0
- package/src/api/admin/stories/groups/[id]/route.ts +30 -0
- package/src/api/admin/stories/groups/route.ts +18 -0
- package/src/api/admin/stories/route.ts +31 -0
- package/src/api/middlewares.ts +73 -0
- package/src/api/store/plugin/route.ts +5 -0
- package/src/api/store/stories/[id]/events/route.ts +14 -0
- package/src/api/store/stories/[id]/interact/route.ts +18 -0
- package/src/api/store/stories/route.ts +44 -0
- package/src/api/validators.ts +166 -0
- package/src/hooks/index.ts +419 -0
- package/src/hooks/use-sdk-primitives.ts +114 -0
- package/src/index.ts +14 -0
- package/src/jobs/README.md +16 -0
- package/src/jobs/expire-ephemeral-stories.ts +14 -0
- package/src/links/README.md +18 -0
- package/src/modules/README.md +46 -0
- package/src/modules/index.ts +15 -0
- package/src/modules/stories/index.ts +11 -0
- package/src/modules/story/index.ts +34 -0
- package/src/modules/story/migrations/Migration20260514000000.ts +196 -0
- package/src/modules/story/models/index.ts +146 -0
- package/src/modules/story/service.ts +1052 -0
- package/src/modules/story/types.ts +190 -0
- package/src/modules/story/utils/security.ts +100 -0
- package/src/providers/README.md +14 -0
- package/src/rbac.ts +89 -0
- package/src/sdk/index.ts +233 -0
- package/src/subscribers/README.md +16 -0
- package/src/subscribers/product-deleted.ts +15 -0
- package/src/types/index.ts +1 -0
- package/src/types/medusa-ui.d.ts +451 -0
- package/src/ui/index.ts +4 -0
- package/src/ui/story-hotspot-pin.tsx +122 -0
- package/src/ui/story-player-modal.tsx +361 -0
- package/src/ui/story-product-sheet.tsx +85 -0
- package/src/ui/story-rings-bar.tsx +113 -0
- package/src/workflows/README.md +19 -0
- package/src/workflows/index.ts +217 -0
- package/tsconfig.json +39 -0
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
declare module "@medusajs/ui" {
|
|
2
|
+
import type * as React from "react"
|
|
3
|
+
|
|
4
|
+
export interface ContainerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
children?: React.ReactNode
|
|
6
|
+
}
|
|
7
|
+
export const Container: React.FC<ContainerProps>
|
|
8
|
+
|
|
9
|
+
export interface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {
|
|
10
|
+
level?: "h1" | "h2" | "h3"
|
|
11
|
+
children?: React.ReactNode
|
|
12
|
+
}
|
|
13
|
+
export const Heading: React.FC<HeadingProps>
|
|
14
|
+
|
|
15
|
+
export interface TextProps extends React.HTMLAttributes<HTMLParagraphElement> {
|
|
16
|
+
size?: "xsmall" | "small" | "base" | "large" | "xlarge"
|
|
17
|
+
weight?: "regular" | "plus"
|
|
18
|
+
leading?: "normal" | "compact"
|
|
19
|
+
children?: React.ReactNode
|
|
20
|
+
}
|
|
21
|
+
export const Text: React.FC<TextProps>
|
|
22
|
+
|
|
23
|
+
export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
24
|
+
color?: "green" | "red" | "blue" | "orange" | "grey" | "purple"
|
|
25
|
+
size?: "2xsmall" | "xsmall" | "small" | "base" | "large"
|
|
26
|
+
rounded?: "base" | "full"
|
|
27
|
+
children?: React.ReactNode
|
|
28
|
+
}
|
|
29
|
+
export const Badge: React.FC<BadgeProps>
|
|
30
|
+
|
|
31
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
32
|
+
variant?: "primary" | "secondary" | "transparent" | "danger"
|
|
33
|
+
size?: "small" | "base" | "large" | "xlarge"
|
|
34
|
+
isLoading?: boolean
|
|
35
|
+
children?: React.ReactNode
|
|
36
|
+
}
|
|
37
|
+
export const Button: React.FC<ButtonProps>
|
|
38
|
+
|
|
39
|
+
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
40
|
+
size?: "base" | "small"
|
|
41
|
+
}
|
|
42
|
+
export const Input: React.FC<InputProps>
|
|
43
|
+
|
|
44
|
+
export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
45
|
+
size?: "xsmall" | "small" | "base" | "large"
|
|
46
|
+
weight?: "regular" | "plus"
|
|
47
|
+
children?: React.ReactNode
|
|
48
|
+
}
|
|
49
|
+
export const Label: React.FC<LabelProps>
|
|
50
|
+
|
|
51
|
+
export interface SwitchProps {
|
|
52
|
+
id?: string
|
|
53
|
+
checked?: boolean
|
|
54
|
+
defaultChecked?: boolean
|
|
55
|
+
disabled?: boolean
|
|
56
|
+
onCheckedChange?: (checked: boolean) => void
|
|
57
|
+
className?: string
|
|
58
|
+
}
|
|
59
|
+
export const Switch: React.FC<SwitchProps>
|
|
60
|
+
|
|
61
|
+
export interface TabsRootProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
62
|
+
defaultValue?: string
|
|
63
|
+
value?: string
|
|
64
|
+
onValueChange?: (value: string) => void
|
|
65
|
+
children?: React.ReactNode
|
|
66
|
+
}
|
|
67
|
+
export interface TabsTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
68
|
+
value: string
|
|
69
|
+
children?: React.ReactNode
|
|
70
|
+
}
|
|
71
|
+
export interface TabsContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
72
|
+
value: string
|
|
73
|
+
children?: React.ReactNode
|
|
74
|
+
}
|
|
75
|
+
export const Tabs: React.FC<TabsRootProps> & {
|
|
76
|
+
List: React.FC<React.HTMLAttributes<HTMLDivElement>>
|
|
77
|
+
Trigger: React.FC<TabsTriggerProps>
|
|
78
|
+
Content: React.FC<TabsContentProps>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const Table: React.FC<React.TableHTMLAttributes<HTMLTableElement>> & {
|
|
82
|
+
Header: React.FC<React.HTMLAttributes<HTMLTableSectionElement>>
|
|
83
|
+
Body: React.FC<React.HTMLAttributes<HTMLTableSectionElement>>
|
|
84
|
+
Row: React.FC<React.HTMLAttributes<HTMLTableRowElement>>
|
|
85
|
+
HeaderCell: React.FC<React.ThHTMLAttributes<HTMLTableCellElement>>
|
|
86
|
+
Cell: React.FC<React.TdHTMLAttributes<HTMLTableCellElement>>
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface SelectRootProps {
|
|
90
|
+
size?: "base" | "small"
|
|
91
|
+
value?: string
|
|
92
|
+
defaultValue?: string
|
|
93
|
+
onValueChange?: (value: string) => void
|
|
94
|
+
children?: React.ReactNode
|
|
95
|
+
}
|
|
96
|
+
export interface SelectItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
97
|
+
value: string
|
|
98
|
+
children?: React.ReactNode
|
|
99
|
+
}
|
|
100
|
+
export const Select: React.FC<SelectRootProps> & {
|
|
101
|
+
Trigger: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>
|
|
102
|
+
Value: React.FC<{ placeholder?: string }>
|
|
103
|
+
Content: React.FC<React.HTMLAttributes<HTMLDivElement>>
|
|
104
|
+
Item: React.FC<SelectItemProps>
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare module "@medusajs/icons" {
|
|
109
|
+
import type * as React from "react"
|
|
110
|
+
export type IconProps = React.SVGProps<SVGSVGElement> & {
|
|
111
|
+
color?: string
|
|
112
|
+
}
|
|
113
|
+
export const ArrowPath: React.FC<IconProps>
|
|
114
|
+
export const PlaySolid: React.FC<IconProps>
|
|
115
|
+
export const PlusMini: React.FC<IconProps>
|
|
116
|
+
export const Trash: React.FC<IconProps>
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare module "react-i18next" {
|
|
120
|
+
export interface I18nInstance {
|
|
121
|
+
language: string
|
|
122
|
+
resolvedLanguage?: string
|
|
123
|
+
changeLanguage: (lng: string) => Promise<void>
|
|
124
|
+
dir: (lng?: string) => "ltr" | "rtl"
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type TFunction = (
|
|
128
|
+
key: string,
|
|
129
|
+
options?: Record<string, string | number | boolean | undefined> | string
|
|
130
|
+
) => string
|
|
131
|
+
|
|
132
|
+
export function useTranslation(ns?: string | string[]): {
|
|
133
|
+
t: TFunction
|
|
134
|
+
i18n: I18nInstance
|
|
135
|
+
ready: boolean
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
declare module "@mikro-orm/migrations" {
|
|
140
|
+
export abstract class Migration {
|
|
141
|
+
addSql(sql: string): void
|
|
142
|
+
abstract up(): Promise<void>
|
|
143
|
+
down(): Promise<void>
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare module "@medusajs/framework/mikro-orm/migrations" {
|
|
148
|
+
export { Migration } from "@mikro-orm/migrations"
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
declare module "@medusajs/framework/utils" {
|
|
152
|
+
export class MedusaError extends Error {
|
|
153
|
+
static Types: {
|
|
154
|
+
DB_ERROR: string
|
|
155
|
+
DUPLICATE_ERROR: string
|
|
156
|
+
INVALID_ARGUMENT: string
|
|
157
|
+
INVALID_DATA: string
|
|
158
|
+
UNAUTHORIZED: string
|
|
159
|
+
NOT_FOUND: string
|
|
160
|
+
NOT_ALLOWED: string
|
|
161
|
+
UNEXPECTED_STATE: string
|
|
162
|
+
CONFLICT: string
|
|
163
|
+
}
|
|
164
|
+
type: string
|
|
165
|
+
code?: string
|
|
166
|
+
constructor(type: string, message: string, code?: string)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
interface ChainableProperty {
|
|
170
|
+
primaryKey(): ChainableProperty
|
|
171
|
+
searchable(): ChainableProperty
|
|
172
|
+
nullable(): ChainableProperty
|
|
173
|
+
default(val: unknown): ChainableProperty
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export const model: {
|
|
177
|
+
define(
|
|
178
|
+
name: string,
|
|
179
|
+
schema: Record<string, unknown>
|
|
180
|
+
): {
|
|
181
|
+
indexes(idx: Array<{ on: string[]; unique?: boolean }>): unknown
|
|
182
|
+
}
|
|
183
|
+
id(opts?: { prefix?: string }): ChainableProperty
|
|
184
|
+
text(): ChainableProperty
|
|
185
|
+
number(): ChainableProperty
|
|
186
|
+
boolean(): ChainableProperty
|
|
187
|
+
json(): ChainableProperty
|
|
188
|
+
dateTime(): ChainableProperty
|
|
189
|
+
enum(values: string[]): ChainableProperty
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function MedusaService<TModels extends Record<string, unknown>>(
|
|
193
|
+
models: TModels
|
|
194
|
+
): {
|
|
195
|
+
new (...args: any[]): {
|
|
196
|
+
[K in keyof TModels as `list${string & K}s`]: (
|
|
197
|
+
filter?: Record<string, any>,
|
|
198
|
+
config?: Record<string, any>
|
|
199
|
+
) => Promise<any[]>
|
|
200
|
+
} & {
|
|
201
|
+
[K in keyof TModels as `create${string & K}s`]: (
|
|
202
|
+
data: any
|
|
203
|
+
) => Promise<any>
|
|
204
|
+
} & {
|
|
205
|
+
[K in keyof TModels as `update${string & K}s`]: (
|
|
206
|
+
data: any
|
|
207
|
+
) => Promise<any>
|
|
208
|
+
} & {
|
|
209
|
+
[K in keyof TModels as `delete${string & K}s`]: (
|
|
210
|
+
id: string | string[]
|
|
211
|
+
) => Promise<void>
|
|
212
|
+
} & {
|
|
213
|
+
listStories(
|
|
214
|
+
filter?: Record<string, any>,
|
|
215
|
+
config?: Record<string, any>
|
|
216
|
+
): Promise<any[]>
|
|
217
|
+
createStories(data: any): Promise<any>
|
|
218
|
+
updateStories(data: any): Promise<any>
|
|
219
|
+
deleteStories(id: string | string[]): Promise<void>
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function Module(
|
|
224
|
+
name: string,
|
|
225
|
+
config: { service: unknown; loaders?: unknown[] }
|
|
226
|
+
): unknown
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
declare module "@medusajs/framework/http" {
|
|
230
|
+
export interface MedusaRequest<TBody = unknown> {
|
|
231
|
+
params: Record<string, string>
|
|
232
|
+
query: Record<string, unknown>
|
|
233
|
+
body: TBody
|
|
234
|
+
validatedBody?: TBody
|
|
235
|
+
validatedQuery?: Record<string, unknown>
|
|
236
|
+
scope: {
|
|
237
|
+
resolve<T = any>(key: string): T
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface MedusaResponse {
|
|
242
|
+
status(code: number): MedusaResponse
|
|
243
|
+
sendStatus(code: number): MedusaResponse
|
|
244
|
+
json(payload: unknown): void
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function defineMiddlewares(config: {
|
|
248
|
+
routes: Array<{
|
|
249
|
+
matcher: string
|
|
250
|
+
method?: string | string[]
|
|
251
|
+
middlewares?: unknown[]
|
|
252
|
+
}>
|
|
253
|
+
}): {
|
|
254
|
+
routes: Array<{
|
|
255
|
+
matcher: string
|
|
256
|
+
method?: string | string[]
|
|
257
|
+
middlewares?: unknown[]
|
|
258
|
+
}>
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export function validateAndTransformBody(schema: unknown): unknown
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
declare module "@medusajs/framework/workflows-sdk" {
|
|
265
|
+
export class StepResponse<TOutput = any, TComp = any> {
|
|
266
|
+
constructor(output: TOutput, compensateInput?: TComp)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export class WorkflowResponse<TOutput = any> {
|
|
270
|
+
constructor(output: TOutput)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function createStep<TInput = any, TOutput = any, TComp = any>(
|
|
274
|
+
name: string,
|
|
275
|
+
invokeFn: (
|
|
276
|
+
input: TInput,
|
|
277
|
+
context: { container: { resolve<T = any>(key: string): T } }
|
|
278
|
+
) => Promise<StepResponse<TOutput, TComp>>,
|
|
279
|
+
compensateFn?: (
|
|
280
|
+
compInput: TComp | undefined,
|
|
281
|
+
context: { container: { resolve<T = any>(key: string): T } }
|
|
282
|
+
) => Promise<void>
|
|
283
|
+
): (input: TInput) => TOutput
|
|
284
|
+
|
|
285
|
+
export function createWorkflow<TInput = any, TOutput = any>(
|
|
286
|
+
name: string,
|
|
287
|
+
composer: (input: TInput) => WorkflowResponse<TOutput>
|
|
288
|
+
): (scope?: unknown) => {
|
|
289
|
+
run(opts?: { input?: TInput }): Promise<{ result: TOutput }>
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare module "@medusajs/framework/zod" {
|
|
294
|
+
export interface ZodType<T = any> {
|
|
295
|
+
_output: T
|
|
296
|
+
min(n: number): ZodType<T>
|
|
297
|
+
max(n: number): ZodType<T>
|
|
298
|
+
int(): ZodType<T>
|
|
299
|
+
optional(): ZodType<T | undefined>
|
|
300
|
+
nullable(): ZodType<T | null>
|
|
301
|
+
default(val: T): ZodType<T>
|
|
302
|
+
partial(): ZodType<Partial<T>>
|
|
303
|
+
omit<K extends keyof T>(mask: Record<K, true>): ZodType<Omit<T, K>>
|
|
304
|
+
refine(
|
|
305
|
+
check: (val: T) => boolean,
|
|
306
|
+
params?: string | { message?: string }
|
|
307
|
+
): ZodType<T>
|
|
308
|
+
parse(val: unknown): T
|
|
309
|
+
safeParse(
|
|
310
|
+
val: unknown
|
|
311
|
+
): { success: true; data: T } | { success: false; error: unknown }
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export namespace z {
|
|
315
|
+
export type infer<T extends ZodType<any>> = T["_output"]
|
|
316
|
+
export function string(): ZodType<string>
|
|
317
|
+
export function number(): ZodType<number>
|
|
318
|
+
export function boolean(): ZodType<boolean>
|
|
319
|
+
export function unknown(): ZodType<unknown>
|
|
320
|
+
function _enum<const T extends readonly [string, ...string[]]>(
|
|
321
|
+
values: T
|
|
322
|
+
): ZodType<T[number]>
|
|
323
|
+
export { _enum as enum }
|
|
324
|
+
export function array<T extends ZodType<any>>(
|
|
325
|
+
schema: T
|
|
326
|
+
): ZodType<Array<T["_output"]>>
|
|
327
|
+
export function record<K extends ZodType<string>, V extends ZodType<any>>(
|
|
328
|
+
key: K,
|
|
329
|
+
value: V
|
|
330
|
+
): ZodType<Record<string, V["_output"]>>
|
|
331
|
+
export function object<T extends Record<string, ZodType<any>>>(
|
|
332
|
+
shape: T
|
|
333
|
+
): ZodType<{ [K in keyof T]: T[K]["_output"] }>
|
|
334
|
+
export const coerce: {
|
|
335
|
+
number(): ZodType<number>
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
declare module "@medusajs/framework/types" {
|
|
341
|
+
export interface MedusaContainer {
|
|
342
|
+
resolve<T = any>(key: string): T
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
declare module "@medusajs/framework" {
|
|
347
|
+
import type { MedusaContainer } from "@medusajs/framework/types"
|
|
348
|
+
|
|
349
|
+
export interface SubscriberArgs<T = unknown> {
|
|
350
|
+
event: { data: T; name?: string }
|
|
351
|
+
container: MedusaContainer
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export interface SubscriberConfig {
|
|
355
|
+
event: string | string[]
|
|
356
|
+
context?: Record<string, unknown>
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
declare module "react" {
|
|
361
|
+
export type ReactNode = any
|
|
362
|
+
export type CSSProperties = Record<string, string | number | undefined>
|
|
363
|
+
export type MouseEvent<T = Element> = {
|
|
364
|
+
currentTarget: T
|
|
365
|
+
clientX: number
|
|
366
|
+
clientY: number
|
|
367
|
+
stopPropagation(): void
|
|
368
|
+
preventDefault(): void
|
|
369
|
+
}
|
|
370
|
+
export type KeyboardEvent<T = Element> = {
|
|
371
|
+
key: string
|
|
372
|
+
stopPropagation(): void
|
|
373
|
+
preventDefault(): void
|
|
374
|
+
}
|
|
375
|
+
export type HTMLAttributes<T = Element> = Record<string, any> & {
|
|
376
|
+
children?: ReactNode
|
|
377
|
+
className?: string
|
|
378
|
+
style?: CSSProperties
|
|
379
|
+
}
|
|
380
|
+
export type ButtonHTMLAttributes<T = Element> = HTMLAttributes<T> & {
|
|
381
|
+
type?: "button" | "submit" | "reset"
|
|
382
|
+
disabled?: boolean
|
|
383
|
+
}
|
|
384
|
+
export type InputHTMLAttributes<T = Element> = HTMLAttributes<T> & {
|
|
385
|
+
value?: string | number
|
|
386
|
+
placeholder?: string
|
|
387
|
+
type?: string
|
|
388
|
+
disabled?: boolean
|
|
389
|
+
}
|
|
390
|
+
export type LabelHTMLAttributes<T = Element> = HTMLAttributes<T> & {
|
|
391
|
+
htmlFor?: string
|
|
392
|
+
}
|
|
393
|
+
export type TableHTMLAttributes<T = Element> = HTMLAttributes<T>
|
|
394
|
+
export type ThHTMLAttributes<T = Element> = HTMLAttributes<T>
|
|
395
|
+
export type TdHTMLAttributes<T = Element> = HTMLAttributes<T>
|
|
396
|
+
export type SVGProps<T = SVGSVGElement> = Record<string, any>
|
|
397
|
+
export type FC<P = {}> = (props: P & { key?: any }) => any
|
|
398
|
+
|
|
399
|
+
export function useState<T>(
|
|
400
|
+
initial: T | (() => T)
|
|
401
|
+
): [T, (next: T | ((prev: T) => T)) => void]
|
|
402
|
+
export function useEffect(
|
|
403
|
+
effect: () => void | (() => void),
|
|
404
|
+
deps?: readonly unknown[]
|
|
405
|
+
): void
|
|
406
|
+
export function useCallback<T extends (...args: any[]) => any>(
|
|
407
|
+
fn: T,
|
|
408
|
+
deps: readonly unknown[]
|
|
409
|
+
): T
|
|
410
|
+
export function useMemo<T>(fn: () => T, deps: readonly unknown[]): T
|
|
411
|
+
export function useRef<T>(initial: T): { current: T }
|
|
412
|
+
|
|
413
|
+
export namespace JSX {
|
|
414
|
+
interface IntrinsicAttributes {
|
|
415
|
+
key?: any
|
|
416
|
+
}
|
|
417
|
+
interface IntrinsicElements {
|
|
418
|
+
[elemName: string]: any
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
declare module "react/jsx-runtime" {
|
|
424
|
+
export namespace JSX {
|
|
425
|
+
interface IntrinsicAttributes {
|
|
426
|
+
key?: any
|
|
427
|
+
}
|
|
428
|
+
interface IntrinsicElements {
|
|
429
|
+
[elemName: string]: any
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
export function jsx(type: any, props: any, key?: any): any
|
|
433
|
+
export function jsxs(type: any, props: any, key?: any): any
|
|
434
|
+
export const Fragment: any
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
declare module "node:test" {
|
|
438
|
+
export function describe(name: string, fn: () => void | Promise<void>): void
|
|
439
|
+
export function it(name: string, fn: () => void | Promise<void>): void
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
declare module "node:assert/strict" {
|
|
443
|
+
const assert: {
|
|
444
|
+
ok(value: unknown, message?: string): void
|
|
445
|
+
equal(actual: unknown, expected: unknown, message?: string): void
|
|
446
|
+
deepEqual(actual: unknown, expected: unknown, message?: string): void
|
|
447
|
+
throws(fn: () => unknown, error?: unknown): void
|
|
448
|
+
rejects(fn: () => Promise<unknown>, error?: unknown): Promise<void>
|
|
449
|
+
}
|
|
450
|
+
export default assert
|
|
451
|
+
}
|
package/src/ui/index.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { StoryHotspotDTO } from "../modules/story/types"
|
|
2
|
+
import { sanitizeHttpUrl } from "../modules/story/utils/security"
|
|
3
|
+
|
|
4
|
+
export interface StoryHotspotPinProps {
|
|
5
|
+
hotspot: StoryHotspotDTO
|
|
6
|
+
onSelect: (hotspot: StoryHotspotDTO) => void
|
|
7
|
+
isSelected?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const StoryHotspotPin = ({
|
|
11
|
+
hotspot,
|
|
12
|
+
onSelect,
|
|
13
|
+
isSelected = false,
|
|
14
|
+
}: StoryHotspotPinProps) => {
|
|
15
|
+
const x = Math.min(95, Math.max(5, hotspot.x_percent))
|
|
16
|
+
const y = Math.min(92, Math.max(8, hotspot.y_percent))
|
|
17
|
+
const badgeStyle = hotspot.badge_style ?? "pill"
|
|
18
|
+
const safeThumb = sanitizeHttpUrl(hotspot.product_thumbnail)
|
|
19
|
+
|
|
20
|
+
if (badgeStyle === "dot") {
|
|
21
|
+
return (
|
|
22
|
+
<button
|
|
23
|
+
type="button"
|
|
24
|
+
onClick={(e) => {
|
|
25
|
+
e.stopPropagation()
|
|
26
|
+
onSelect(hotspot)
|
|
27
|
+
}}
|
|
28
|
+
style={{
|
|
29
|
+
left: `${x}%`,
|
|
30
|
+
top: `${y}%`,
|
|
31
|
+
transform: "translate(-50%, -50%)",
|
|
32
|
+
}}
|
|
33
|
+
aria-label={`Shop ${hotspot.product_title}`}
|
|
34
|
+
className={`absolute z-20 flex h-7 w-7 items-center justify-center rounded-full shadow-lg transition-transform duration-150 hover:scale-110 ${
|
|
35
|
+
isSelected
|
|
36
|
+
? "bg-black ring-2 ring-white"
|
|
37
|
+
: "bg-white/95 backdrop-blur-sm"
|
|
38
|
+
}`}
|
|
39
|
+
>
|
|
40
|
+
<span className="relative flex h-3 w-3">
|
|
41
|
+
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-rose-400 opacity-75" />
|
|
42
|
+
<span className="relative inline-flex rounded-full h-3 w-3 bg-rose-500" />
|
|
43
|
+
</span>
|
|
44
|
+
</button>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (badgeStyle === "card") {
|
|
49
|
+
return (
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
onClick={(e) => {
|
|
53
|
+
e.stopPropagation()
|
|
54
|
+
onSelect(hotspot)
|
|
55
|
+
}}
|
|
56
|
+
style={{
|
|
57
|
+
left: `${x}%`,
|
|
58
|
+
top: `${y}%`,
|
|
59
|
+
transform: "translate(-50%, -50%)",
|
|
60
|
+
}}
|
|
61
|
+
aria-label={`Shop ${hotspot.product_title}`}
|
|
62
|
+
className={`absolute z-20 flex items-center gap-2 rounded-xl p-1.5 pr-3 text-left text-xs shadow-xl transition-transform duration-150 hover:scale-105 ${
|
|
63
|
+
isSelected
|
|
64
|
+
? "bg-black text-white ring-2 ring-white"
|
|
65
|
+
: "bg-white/95 text-gray-900 backdrop-blur-sm"
|
|
66
|
+
}`}
|
|
67
|
+
>
|
|
68
|
+
{safeThumb && (
|
|
69
|
+
<img
|
|
70
|
+
src={safeThumb}
|
|
71
|
+
alt={hotspot.product_title}
|
|
72
|
+
className="h-8 w-8 rounded-lg object-cover shrink-0"
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
75
|
+
<div className="min-w-0">
|
|
76
|
+
<p className="max-w-[110px] truncate font-semibold">
|
|
77
|
+
{hotspot.label || hotspot.product_title}
|
|
78
|
+
</p>
|
|
79
|
+
{hotspot.price_formatted && (
|
|
80
|
+
<p className="text-[11px] font-bold text-rose-600">
|
|
81
|
+
{hotspot.price_formatted}
|
|
82
|
+
</p>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
</button>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<button
|
|
91
|
+
type="button"
|
|
92
|
+
onClick={(e) => {
|
|
93
|
+
e.stopPropagation()
|
|
94
|
+
onSelect(hotspot)
|
|
95
|
+
}}
|
|
96
|
+
style={{
|
|
97
|
+
left: `${x}%`,
|
|
98
|
+
top: `${y}%`,
|
|
99
|
+
transform: "translate(-50%, -50%)",
|
|
100
|
+
}}
|
|
101
|
+
aria-label={`Shop ${hotspot.product_title}`}
|
|
102
|
+
className={`absolute z-20 flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium shadow-lg transition-transform duration-150 hover:scale-105 ${
|
|
103
|
+
isSelected
|
|
104
|
+
? "bg-black text-white ring-2 ring-white"
|
|
105
|
+
: "bg-white/95 text-gray-900 backdrop-blur-sm"
|
|
106
|
+
}`}
|
|
107
|
+
>
|
|
108
|
+
<span className="relative flex h-2.5 w-2.5">
|
|
109
|
+
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-rose-400 opacity-75" />
|
|
110
|
+
<span className="relative inline-flex rounded-full h-2.5 w-2.5 bg-rose-500" />
|
|
111
|
+
</span>
|
|
112
|
+
<span className="max-w-[130px] truncate">
|
|
113
|
+
{hotspot.label || hotspot.product_title}
|
|
114
|
+
</span>
|
|
115
|
+
{hotspot.price_formatted && (
|
|
116
|
+
<span className="font-semibold text-rose-600 ml-0.5">
|
|
117
|
+
{hotspot.price_formatted}
|
|
118
|
+
</span>
|
|
119
|
+
)}
|
|
120
|
+
</button>
|
|
121
|
+
)
|
|
122
|
+
}
|