@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,217 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createStep,
|
|
3
|
+
createWorkflow,
|
|
4
|
+
StepResponse,
|
|
5
|
+
WorkflowResponse,
|
|
6
|
+
} from "@medusajs/framework/workflows-sdk"
|
|
7
|
+
import {
|
|
8
|
+
resolveStoriesService,
|
|
9
|
+
type StoryEngagementEventType,
|
|
10
|
+
type StoryMediaType,
|
|
11
|
+
type StoryPlacementZone,
|
|
12
|
+
type StoryRingTheme,
|
|
13
|
+
type StoryStickerType,
|
|
14
|
+
} from "../modules/story"
|
|
15
|
+
|
|
16
|
+
const createStoryGroupStep = createStep(
|
|
17
|
+
"create-story-group",
|
|
18
|
+
async (
|
|
19
|
+
input: {
|
|
20
|
+
title: string
|
|
21
|
+
handle?: string
|
|
22
|
+
subtitle?: string | null
|
|
23
|
+
avatar_url?: string | null
|
|
24
|
+
ring_theme?: StoryRingTheme
|
|
25
|
+
custom_ring_color?: string | null
|
|
26
|
+
placement?: StoryPlacementZone
|
|
27
|
+
target_entity_id?: string | null
|
|
28
|
+
is_pinned?: boolean
|
|
29
|
+
is_ephemeral?: boolean
|
|
30
|
+
is_active?: boolean
|
|
31
|
+
display_order?: number
|
|
32
|
+
},
|
|
33
|
+
{ container }
|
|
34
|
+
) => {
|
|
35
|
+
const storiesService = resolveStoriesService(container)
|
|
36
|
+
const group = await storiesService.createGroup(input)
|
|
37
|
+
return new StepResponse(group, { groupId: group.id })
|
|
38
|
+
},
|
|
39
|
+
async (compInput, { container }) => {
|
|
40
|
+
if (!compInput?.groupId) return
|
|
41
|
+
const storiesService = resolveStoriesService(container)
|
|
42
|
+
await storiesService.deleteGroup(compInput.groupId)
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
export const createStoryGroupWorkflow = createWorkflow(
|
|
47
|
+
"create-story-group",
|
|
48
|
+
(input: {
|
|
49
|
+
title: string
|
|
50
|
+
handle?: string
|
|
51
|
+
subtitle?: string | null
|
|
52
|
+
avatar_url?: string | null
|
|
53
|
+
ring_theme?: StoryRingTheme
|
|
54
|
+
custom_ring_color?: string | null
|
|
55
|
+
placement?: StoryPlacementZone
|
|
56
|
+
target_entity_id?: string | null
|
|
57
|
+
is_pinned?: boolean
|
|
58
|
+
is_ephemeral?: boolean
|
|
59
|
+
is_active?: boolean
|
|
60
|
+
display_order?: number
|
|
61
|
+
}) => {
|
|
62
|
+
const group = createStoryGroupStep(input)
|
|
63
|
+
return new WorkflowResponse(group)
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
const createStorySlideStep = createStep(
|
|
68
|
+
"create-story-slide",
|
|
69
|
+
async (
|
|
70
|
+
input: {
|
|
71
|
+
group_id?: string | null
|
|
72
|
+
title: string
|
|
73
|
+
caption?: string | null
|
|
74
|
+
media_type?: StoryMediaType
|
|
75
|
+
media_url: string
|
|
76
|
+
thumbnail_url?: string | null
|
|
77
|
+
duration_ms?: number
|
|
78
|
+
link_url?: string | null
|
|
79
|
+
link_text?: string | null
|
|
80
|
+
is_active?: boolean
|
|
81
|
+
display_order?: number
|
|
82
|
+
starts_at?: string | Date | null
|
|
83
|
+
expires_at?: string | Date | null
|
|
84
|
+
hotspots?: Array<{
|
|
85
|
+
product_id: string
|
|
86
|
+
variant_id?: string | null
|
|
87
|
+
product_title: string
|
|
88
|
+
product_handle?: string | null
|
|
89
|
+
product_thumbnail?: string | null
|
|
90
|
+
price_formatted?: string | null
|
|
91
|
+
price_amount?: number | null
|
|
92
|
+
currency_code?: string | null
|
|
93
|
+
x_percent: number
|
|
94
|
+
y_percent: number
|
|
95
|
+
label?: string | null
|
|
96
|
+
badge_style?: "pill" | "card" | "dot"
|
|
97
|
+
}>
|
|
98
|
+
stickers?: Array<{
|
|
99
|
+
type: StoryStickerType
|
|
100
|
+
prompt: string
|
|
101
|
+
x_percent?: number
|
|
102
|
+
y_percent?: number
|
|
103
|
+
options?: Array<{ id?: string; label: string; votes?: number }> | null
|
|
104
|
+
coupon_code?: string | null
|
|
105
|
+
countdown_until?: string | null
|
|
106
|
+
}>
|
|
107
|
+
},
|
|
108
|
+
{ container }
|
|
109
|
+
) => {
|
|
110
|
+
const storiesService = resolveStoriesService(container)
|
|
111
|
+
const slide = await storiesService.createSlide(input)
|
|
112
|
+
return new StepResponse(slide, { slideId: slide.id })
|
|
113
|
+
},
|
|
114
|
+
async (compInput, { container }) => {
|
|
115
|
+
if (!compInput?.slideId) return
|
|
116
|
+
const storiesService = resolveStoriesService(container)
|
|
117
|
+
await storiesService.deleteSlide(compInput.slideId)
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
export const createStorySlideWorkflow = createWorkflow(
|
|
122
|
+
"create-story-slide",
|
|
123
|
+
(input: {
|
|
124
|
+
group_id?: string | null
|
|
125
|
+
title: string
|
|
126
|
+
caption?: string | null
|
|
127
|
+
media_type?: StoryMediaType
|
|
128
|
+
media_url: string
|
|
129
|
+
thumbnail_url?: string | null
|
|
130
|
+
duration_ms?: number
|
|
131
|
+
link_url?: string | null
|
|
132
|
+
link_text?: string | null
|
|
133
|
+
is_active?: boolean
|
|
134
|
+
display_order?: number
|
|
135
|
+
starts_at?: string | Date | null
|
|
136
|
+
expires_at?: string | Date | null
|
|
137
|
+
hotspots?: Array<{
|
|
138
|
+
product_id: string
|
|
139
|
+
variant_id?: string | null
|
|
140
|
+
product_title: string
|
|
141
|
+
product_handle?: string | null
|
|
142
|
+
product_thumbnail?: string | null
|
|
143
|
+
price_formatted?: string | null
|
|
144
|
+
price_amount?: number | null
|
|
145
|
+
currency_code?: string | null
|
|
146
|
+
x_percent: number
|
|
147
|
+
y_percent: number
|
|
148
|
+
label?: string | null
|
|
149
|
+
badge_style?: "pill" | "card" | "dot"
|
|
150
|
+
}>
|
|
151
|
+
stickers?: Array<{
|
|
152
|
+
type: StoryStickerType
|
|
153
|
+
prompt: string
|
|
154
|
+
x_percent?: number
|
|
155
|
+
y_percent?: number
|
|
156
|
+
options?: Array<{ id?: string; label: string; votes?: number }> | null
|
|
157
|
+
coupon_code?: string | null
|
|
158
|
+
countdown_until?: string | null
|
|
159
|
+
}>
|
|
160
|
+
}) => {
|
|
161
|
+
const slide = createStorySlideStep(input)
|
|
162
|
+
return new WorkflowResponse(slide)
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
const recordStoryEngagementStep = createStep(
|
|
167
|
+
"record-story-engagement",
|
|
168
|
+
async (
|
|
169
|
+
input: {
|
|
170
|
+
story_id: string
|
|
171
|
+
event_type: StoryEngagementEventType
|
|
172
|
+
hotspot_id?: string | null
|
|
173
|
+
sticker_id?: string | null
|
|
174
|
+
product_id?: string | null
|
|
175
|
+
session_id?: string | null
|
|
176
|
+
},
|
|
177
|
+
{ container }
|
|
178
|
+
) => {
|
|
179
|
+
const storiesService = resolveStoriesService(container)
|
|
180
|
+
const res = await storiesService.recordEngagementEvent(input)
|
|
181
|
+
return new StepResponse(res)
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
export const recordStoryEngagementWorkflow = createWorkflow(
|
|
186
|
+
"record-story-engagement",
|
|
187
|
+
(input: {
|
|
188
|
+
story_id: string
|
|
189
|
+
event_type: StoryEngagementEventType
|
|
190
|
+
hotspot_id?: string | null
|
|
191
|
+
sticker_id?: string | null
|
|
192
|
+
product_id?: string | null
|
|
193
|
+
session_id?: string | null
|
|
194
|
+
}) => {
|
|
195
|
+
const res = recordStoryEngagementStep(input)
|
|
196
|
+
return new WorkflowResponse(res)
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
const expireEphemeralStoriesStep = createStep(
|
|
201
|
+
"expire-ephemeral-stories",
|
|
202
|
+
async (_input: Record<string, never>, { container }) => {
|
|
203
|
+
const storiesService = resolveStoriesService(container)
|
|
204
|
+
const res = await storiesService.expireOutdatedStories()
|
|
205
|
+
return new StepResponse(res)
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
export const expireEphemeralStoriesWorkflow = createWorkflow(
|
|
210
|
+
"expire-ephemeral-stories",
|
|
211
|
+
(input: Record<string, never> = {}) => {
|
|
212
|
+
const res = expireEphemeralStoriesStep(input)
|
|
213
|
+
return new WorkflowResponse(res)
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
export const expireStoriesWorkflow = expireEphemeralStoriesWorkflow
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2023",
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
"emitDecoratorMetadata": true,
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"skipDefaultLibCheck": true,
|
|
11
|
+
"declaration": false,
|
|
12
|
+
"sourceMap": false,
|
|
13
|
+
"inlineSourceMap": true,
|
|
14
|
+
"outDir": "./.medusa/server",
|
|
15
|
+
"rootDir": "./",
|
|
16
|
+
"jsx": "react-jsx",
|
|
17
|
+
"forceConsistentCasingInFileNames": true,
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"checkJs": false,
|
|
20
|
+
"strictNullChecks": true,
|
|
21
|
+
"baseUrl": ".",
|
|
22
|
+
"ignoreDeprecations": "5.0",
|
|
23
|
+
"paths": {
|
|
24
|
+
"@stories/*": ["./src/*"]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"ts-node": {
|
|
28
|
+
"swc": true
|
|
29
|
+
},
|
|
30
|
+
"include": ["**/*", ".medusa/types/*"],
|
|
31
|
+
"exclude": [
|
|
32
|
+
"node_modules",
|
|
33
|
+
".medusa/server",
|
|
34
|
+
".medusa/admin",
|
|
35
|
+
"src/admin",
|
|
36
|
+
".cache",
|
|
37
|
+
"eslint.config.*"
|
|
38
|
+
]
|
|
39
|
+
}
|