@epic-web/workshop-utils 6.63.0 → 6.64.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.
@@ -2,29 +2,13 @@ import { z } from 'zod';
2
2
  export declare const StackBlitzConfigSchema: z.ZodObject<{
3
3
  title: z.ZodOptional<z.ZodString>;
4
4
  startScript: z.ZodOptional<z.ZodString>;
5
- view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"editor">, z.ZodLiteral<"preview">, z.ZodLiteral<"both">]>>;
5
+ view: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"editor">, z.ZodLiteral<"preview">, z.ZodLiteral<"both">]>>;
6
6
  file: z.ZodOptional<z.ZodString>;
7
7
  hidedevtools: z.ZodOptional<z.ZodString>;
8
8
  terminalHeight: z.ZodOptional<z.ZodString>;
9
9
  hideNavigation: z.ZodOptional<z.ZodString>;
10
- }, "strip", z.ZodTypeAny, {
11
- title?: string | undefined;
12
- startScript?: string | undefined;
13
- view?: "editor" | "preview" | "both" | undefined;
14
- file?: string | undefined;
15
- hidedevtools?: string | undefined;
16
- terminalHeight?: string | undefined;
17
- hideNavigation?: string | undefined;
18
- }, {
19
- title?: string | undefined;
20
- startScript?: string | undefined;
21
- view?: "editor" | "preview" | "both" | undefined;
22
- file?: string | undefined;
23
- hidedevtools?: string | undefined;
24
- terminalHeight?: string | undefined;
25
- hideNavigation?: string | undefined;
26
- }>;
27
- declare const PartialWorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
10
+ }, z.core.$strip>;
11
+ declare const PartialWorkshopConfigSchema: z.ZodPipe<z.ZodObject<{
28
12
  title: z.ZodOptional<z.ZodString>;
29
13
  subtitle: z.ZodOptional<z.ZodString>;
30
14
  instructor: z.ZodOptional<z.ZodObject<{
@@ -32,64 +16,14 @@ declare const PartialWorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
32
16
  avatar: z.ZodOptional<z.ZodString>;
33
17
  𝕏: z.ZodOptional<z.ZodString>;
34
18
  xHandle: z.ZodOptional<z.ZodString>;
35
- }, "strip", z.ZodTypeAny, {
36
- name?: string | undefined;
37
- avatar?: string | undefined;
38
- 𝕏?: string | undefined;
39
- xHandle?: string | undefined;
40
- }, {
41
- name?: string | undefined;
42
- avatar?: string | undefined;
43
- 𝕏?: string | undefined;
44
- xHandle?: string | undefined;
45
- }>>;
19
+ }, z.core.$strip>>;
46
20
  product: z.ZodOptional<z.ZodObject<{
47
21
  host: z.ZodOptional<z.ZodString>;
48
22
  displayName: z.ZodOptional<z.ZodString>;
49
23
  displayNameShort: z.ZodOptional<z.ZodString>;
50
24
  slug: z.ZodOptional<z.ZodString>;
51
- }, "strip", z.ZodTypeAny, {
52
- host?: string | undefined;
53
- displayName?: string | undefined;
54
- displayNameShort?: string | undefined;
55
- slug?: string | undefined;
56
- }, {
57
- host?: string | undefined;
58
- displayName?: string | undefined;
59
- displayNameShort?: string | undefined;
60
- slug?: string | undefined;
61
- }>>;
62
- }, "strip", z.ZodTypeAny, {
63
- title?: string | undefined;
64
- subtitle?: string | undefined;
65
- instructor?: {
66
- name?: string | undefined;
67
- avatar?: string | undefined;
68
- 𝕏?: string | undefined;
69
- xHandle?: string | undefined;
70
- } | undefined;
71
- product?: {
72
- host?: string | undefined;
73
- displayName?: string | undefined;
74
- displayNameShort?: string | undefined;
75
- slug?: string | undefined;
76
- } | undefined;
77
- }, {
78
- title?: string | undefined;
79
- subtitle?: string | undefined;
80
- instructor?: {
81
- name?: string | undefined;
82
- avatar?: string | undefined;
83
- 𝕏?: string | undefined;
84
- xHandle?: string | undefined;
85
- } | undefined;
86
- product?: {
87
- host?: string | undefined;
88
- displayName?: string | undefined;
89
- displayNameShort?: string | undefined;
90
- slug?: string | undefined;
91
- } | undefined;
92
- }>, {
25
+ }, z.core.$strip>>;
26
+ }, z.core.$strip>, z.ZodTransform<{
93
27
  title?: string | undefined;
94
28
  subtitle?: string | undefined;
95
29
  instructor?: {
@@ -126,9 +60,9 @@ declare const PartialWorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
126
60
  displayNameShort?: string | undefined;
127
61
  slug?: string | undefined;
128
62
  } | undefined;
129
- }>;
63
+ }>>;
130
64
  export type PartialWorkshopConfig = z.infer<typeof PartialWorkshopConfigSchema>;
131
- declare const WorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
65
+ declare const WorkshopConfigSchema: z.ZodPipe<z.ZodObject<{
132
66
  title: z.ZodString;
133
67
  subdomain: z.ZodOptional<z.ZodString>;
134
68
  product: z.ZodDefault<z.ZodObject<{
@@ -138,130 +72,67 @@ declare const WorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
138
72
  logo: z.ZodDefault<z.ZodString>;
139
73
  slug: z.ZodOptional<z.ZodString>;
140
74
  discordChannelId: z.ZodOptional<z.ZodString>;
141
- discordTags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
142
- }, "strip", z.ZodTypeAny, {
143
- host: string;
144
- displayName: string;
145
- displayNameShort: string;
146
- logo: string;
147
- slug?: string | undefined;
148
- discordChannelId?: string | undefined;
149
- discordTags?: string[] | undefined;
150
- }, {
151
- host?: string | undefined;
152
- displayName?: string | undefined;
153
- displayNameShort?: string | undefined;
154
- slug?: string | undefined;
155
- logo?: string | undefined;
156
- discordChannelId?: string | undefined;
157
- discordTags?: string[] | undefined;
158
- }>>;
159
- githubRepo: z.ZodEffects<z.ZodString, string, string>;
160
- githubRoot: z.ZodEffects<z.ZodString, string, string>;
75
+ discordTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
76
+ }, z.core.$strip>>;
77
+ githubRepo: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
78
+ githubRoot: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
161
79
  stackBlitzConfig: z.ZodOptional<z.ZodObject<{
162
80
  title: z.ZodOptional<z.ZodString>;
163
81
  startScript: z.ZodOptional<z.ZodString>;
164
- view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"editor">, z.ZodLiteral<"preview">, z.ZodLiteral<"both">]>>;
82
+ view: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"editor">, z.ZodLiteral<"preview">, z.ZodLiteral<"both">]>>;
165
83
  file: z.ZodOptional<z.ZodString>;
166
84
  hidedevtools: z.ZodOptional<z.ZodString>;
167
85
  terminalHeight: z.ZodOptional<z.ZodString>;
168
86
  hideNavigation: z.ZodOptional<z.ZodString>;
169
- }, "strip", z.ZodTypeAny, {
170
- title?: string | undefined;
171
- startScript?: string | undefined;
172
- view?: "editor" | "preview" | "both" | undefined;
173
- file?: string | undefined;
174
- hidedevtools?: string | undefined;
175
- terminalHeight?: string | undefined;
176
- hideNavigation?: string | undefined;
177
- }, {
178
- title?: string | undefined;
179
- startScript?: string | undefined;
180
- view?: "editor" | "preview" | "both" | undefined;
181
- file?: string | undefined;
182
- hidedevtools?: string | undefined;
183
- terminalHeight?: string | undefined;
184
- hideNavigation?: string | undefined;
185
- }>>;
87
+ }, z.core.$strip>>;
186
88
  forms: z.ZodDefault<z.ZodObject<{
187
89
  workshop: z.ZodDefault<z.ZodString>;
188
90
  exercise: z.ZodDefault<z.ZodString>;
189
- }, "strip", z.ZodTypeAny, {
190
- workshop: string;
191
- exercise: string;
192
- }, {
193
- workshop?: string | undefined;
194
- exercise?: string | undefined;
195
- }>>;
91
+ }, z.core.$strip>>;
196
92
  testTab: z.ZodDefault<z.ZodObject<{
197
93
  enabled: z.ZodDefault<z.ZodBoolean>;
198
- }, "strip", z.ZodTypeAny, {
199
- enabled: boolean;
200
- }, {
201
- enabled?: boolean | undefined;
202
- }>>;
94
+ }, z.core.$strip>>;
203
95
  scripts: z.ZodOptional<z.ZodObject<{
204
96
  postupdate: z.ZodOptional<z.ZodString>;
205
- }, "strip", z.ZodTypeAny, {
206
- postupdate?: string | undefined;
207
- }, {
208
- postupdate?: string | undefined;
209
- }>>;
97
+ }, z.core.$strip>>;
210
98
  initialRoute: z.ZodDefault<z.ZodOptional<z.ZodString>>;
211
99
  notifications: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
212
100
  id: z.ZodString;
213
101
  title: z.ZodString;
214
102
  message: z.ZodString;
215
103
  link: z.ZodOptional<z.ZodString>;
216
- type: z.ZodEnum<["info", "warning", "danger"]>;
104
+ type: z.ZodEnum<{
105
+ info: "info";
106
+ warning: "warning";
107
+ danger: "danger";
108
+ }>;
217
109
  expiresAt: z.ZodNullable<z.ZodDate>;
218
- }, "strip", z.ZodTypeAny, {
219
- message: string;
220
- type: "info" | "warning" | "danger";
221
- title: string;
222
- id: string;
223
- expiresAt: Date | null;
224
- link?: string | undefined;
225
- }, {
226
- message: string;
227
- type: "info" | "warning" | "danger";
228
- title: string;
229
- id: string;
230
- expiresAt: Date | null;
231
- link?: string | undefined;
232
- }>, "many">>>;
110
+ }, z.core.$strip>>>>;
233
111
  sidecarProcesses: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
234
- appType: z.ZodOptional<z.ZodEnum<["standard", "export"]>>;
112
+ appType: z.ZodOptional<z.ZodEnum<{
113
+ standard: "standard";
114
+ export: "export";
115
+ }>>;
235
116
  subtitle: z.ZodOptional<z.ZodString>;
236
117
  instructor: z.ZodOptional<z.ZodObject<{
237
118
  name: z.ZodOptional<z.ZodString>;
238
119
  avatar: z.ZodOptional<z.ZodString>;
239
120
  𝕏: z.ZodOptional<z.ZodString>;
240
121
  xHandle: z.ZodOptional<z.ZodString>;
241
- }, "strip", z.ZodTypeAny, {
242
- name?: string | undefined;
243
- avatar?: string | undefined;
244
- 𝕏?: string | undefined;
245
- xHandle?: string | undefined;
246
- }, {
247
- name?: string | undefined;
248
- avatar?: string | undefined;
249
- 𝕏?: string | undefined;
250
- xHandle?: string | undefined;
251
- }>>;
252
- }, "strip", z.ZodTypeAny, {
253
- githubRepo: string;
254
- githubRoot: string;
255
- title: string;
122
+ }, z.core.$strip>>;
123
+ }, z.core.$strip>, z.ZodTransform<{
256
124
  product: {
125
+ displayNameShort: string;
257
126
  host: string;
258
127
  displayName: string;
259
- displayNameShort: string;
260
128
  logo: string;
261
129
  slug?: string | undefined;
262
130
  discordChannelId?: string | undefined;
263
131
  discordTags?: string[] | undefined;
264
132
  };
133
+ title: string;
134
+ githubRepo: string;
135
+ githubRoot: string;
265
136
  forms: {
266
137
  workshop: string;
267
138
  exercise: string;
@@ -271,21 +142,14 @@ declare const WorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
271
142
  };
272
143
  initialRoute: string;
273
144
  notifications: {
145
+ id: string;
146
+ title: string;
274
147
  message: string;
275
148
  type: "info" | "warning" | "danger";
276
- title: string;
277
- id: string;
278
149
  expiresAt: Date | null;
279
150
  link?: string | undefined;
280
151
  }[];
281
152
  sidecarProcesses: Record<string, string>;
282
- subtitle?: string | undefined;
283
- instructor?: {
284
- name?: string | undefined;
285
- avatar?: string | undefined;
286
- 𝕏?: string | undefined;
287
- xHandle?: string | undefined;
288
- } | undefined;
289
153
  subdomain?: string | undefined;
290
154
  stackBlitzConfig?: {
291
155
  title?: string | undefined;
@@ -300,10 +164,6 @@ declare const WorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
300
164
  postupdate?: string | undefined;
301
165
  } | undefined;
302
166
  appType?: "standard" | "export" | undefined;
303
- }, {
304
- githubRepo: string;
305
- githubRoot: string;
306
- title: string;
307
167
  subtitle?: string | undefined;
308
168
  instructor?: {
309
169
  name?: string | undefined;
@@ -311,51 +171,12 @@ declare const WorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
311
171
  𝕏?: string | undefined;
312
172
  xHandle?: string | undefined;
313
173
  } | undefined;
314
- product?: {
315
- host?: string | undefined;
316
- displayName?: string | undefined;
317
- displayNameShort?: string | undefined;
318
- slug?: string | undefined;
319
- logo?: string | undefined;
320
- discordChannelId?: string | undefined;
321
- discordTags?: string[] | undefined;
322
- } | undefined;
323
- subdomain?: string | undefined;
324
- stackBlitzConfig?: {
325
- title?: string | undefined;
326
- startScript?: string | undefined;
327
- view?: "editor" | "preview" | "both" | undefined;
328
- file?: string | undefined;
329
- hidedevtools?: string | undefined;
330
- terminalHeight?: string | undefined;
331
- hideNavigation?: string | undefined;
332
- } | undefined;
333
- forms?: {
334
- workshop?: string | undefined;
335
- exercise?: string | undefined;
336
- } | undefined;
337
- testTab?: {
338
- enabled?: boolean | undefined;
339
- } | undefined;
340
- scripts?: {
341
- postupdate?: string | undefined;
342
- } | undefined;
343
- initialRoute?: string | undefined;
344
- notifications?: {
345
- message: string;
346
- type: "info" | "warning" | "danger";
347
- title: string;
348
- id: string;
349
- expiresAt: Date | null;
350
- link?: string | undefined;
351
- }[] | undefined;
352
- sidecarProcesses?: Record<string, string> | undefined;
353
- appType?: "standard" | "export" | undefined;
354
- }>, {
174
+ }, {
175
+ title: string;
355
176
  product: {
356
- displayNameShort: string;
357
177
  host: string;
358
178
  displayName: string;
179
+ displayNameShort: string;
359
180
  logo: string;
360
181
  slug?: string | undefined;
361
182
  discordChannelId?: string | undefined;
@@ -363,7 +184,6 @@ declare const WorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
363
184
  };
364
185
  githubRepo: string;
365
186
  githubRoot: string;
366
- title: string;
367
187
  forms: {
368
188
  workshop: string;
369
189
  exercise: string;
@@ -373,21 +193,14 @@ declare const WorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
373
193
  };
374
194
  initialRoute: string;
375
195
  notifications: {
196
+ id: string;
197
+ title: string;
376
198
  message: string;
377
199
  type: "info" | "warning" | "danger";
378
- title: string;
379
- id: string;
380
200
  expiresAt: Date | null;
381
201
  link?: string | undefined;
382
202
  }[];
383
203
  sidecarProcesses: Record<string, string>;
384
- subtitle?: string | undefined;
385
- instructor?: {
386
- name?: string | undefined;
387
- avatar?: string | undefined;
388
- 𝕏?: string | undefined;
389
- xHandle?: string | undefined;
390
- } | undefined;
391
204
  subdomain?: string | undefined;
392
205
  stackBlitzConfig?: {
393
206
  title?: string | undefined;
@@ -402,10 +215,6 @@ declare const WorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
402
215
  postupdate?: string | undefined;
403
216
  } | undefined;
404
217
  appType?: "standard" | "export" | undefined;
405
- }, {
406
- githubRepo: string;
407
- githubRoot: string;
408
- title: string;
409
218
  subtitle?: string | undefined;
410
219
  instructor?: {
411
220
  name?: string | undefined;
@@ -413,47 +222,7 @@ declare const WorkshopConfigSchema: z.ZodEffects<z.ZodObject<{
413
222
  𝕏?: string | undefined;
414
223
  xHandle?: string | undefined;
415
224
  } | undefined;
416
- product?: {
417
- host?: string | undefined;
418
- displayName?: string | undefined;
419
- displayNameShort?: string | undefined;
420
- slug?: string | undefined;
421
- logo?: string | undefined;
422
- discordChannelId?: string | undefined;
423
- discordTags?: string[] | undefined;
424
- } | undefined;
425
- subdomain?: string | undefined;
426
- stackBlitzConfig?: {
427
- title?: string | undefined;
428
- startScript?: string | undefined;
429
- view?: "editor" | "preview" | "both" | undefined;
430
- file?: string | undefined;
431
- hidedevtools?: string | undefined;
432
- terminalHeight?: string | undefined;
433
- hideNavigation?: string | undefined;
434
- } | undefined;
435
- forms?: {
436
- workshop?: string | undefined;
437
- exercise?: string | undefined;
438
- } | undefined;
439
- testTab?: {
440
- enabled?: boolean | undefined;
441
- } | undefined;
442
- scripts?: {
443
- postupdate?: string | undefined;
444
- } | undefined;
445
- initialRoute?: string | undefined;
446
- notifications?: {
447
- message: string;
448
- type: "info" | "warning" | "danger";
449
- title: string;
450
- id: string;
451
- expiresAt: Date | null;
452
- link?: string | undefined;
453
- }[] | undefined;
454
- sidecarProcesses?: Record<string, string> | undefined;
455
- appType?: "standard" | "export" | undefined;
456
- }>;
225
+ }>>;
457
226
  export type WorkshopConfig = z.infer<typeof WorkshopConfigSchema>;
458
227
  /**
459
228
  * Parse epicshop config from an arbitrary package.json object.
@@ -38,6 +38,7 @@ const BaseWorkshopConfigFields = {
38
38
  instructor: InstructorSchema.optional(),
39
39
  product: BaseProductSchema.optional(),
40
40
  };
41
+ const formatFieldErrors = (errors) => Array.isArray(errors) ? errors.join(', ') : '';
41
42
  function transformProductFields(data) {
42
43
  const product = data.product ?? {};
43
44
  return {
@@ -50,6 +51,19 @@ function transformProductFields(data) {
50
51
  },
51
52
  };
52
53
  }
54
+ const defaultProductConfig = {
55
+ host: 'www.epicweb.dev',
56
+ displayName: 'EpicWeb.dev',
57
+ displayNameShort: 'Epic Web',
58
+ logo: '/logo.svg',
59
+ };
60
+ const defaultFormsConfig = {
61
+ workshop: 'https://docs.google.com/forms/d/e/1FAIpQLSdRmj9p8-5zyoqRzxp3UpqSbC3aFkweXvvJIKes0a5s894gzg/viewform?hl=en&embedded=true&entry.2123647600={workshopTitle}',
62
+ exercise: 'https://docs.google.com/forms/d/e/1FAIpQLSf3o9xyjQepTlOTH5Z7ZwkeSTdXh6YWI_RGc9KiyD3oUN0p6w/viewform?hl=en&embedded=true&entry.1836176234={workshopTitle}&entry.428900931={exerciseTitle}',
63
+ };
64
+ const defaultTestTabConfig = {
65
+ enabled: true,
66
+ };
53
67
  const PartialWorkshopConfigSchema = z
54
68
  .object(BaseWorkshopConfigFields)
55
69
  .transform(transformProductFields);
@@ -69,7 +83,7 @@ const WorkshopConfigSchema = z
69
83
  discordChannelId: z.string().optional(),
70
84
  discordTags: z.array(z.string()).optional(),
71
85
  })
72
- .default({}),
86
+ .default(defaultProductConfig),
73
87
  githubRepo: z
74
88
  .string()
75
89
  .transform((githubRepo) => githubRepo ?? getEnv().EPICSHOP_GITHUB_REPO),
@@ -79,19 +93,15 @@ const WorkshopConfigSchema = z
79
93
  stackBlitzConfig: StackBlitzConfigSchema.optional(),
80
94
  forms: z
81
95
  .object({
82
- workshop: z
83
- .string()
84
- .default('https://docs.google.com/forms/d/e/1FAIpQLSdRmj9p8-5zyoqRzxp3UpqSbC3aFkweXvvJIKes0a5s894gzg/viewform?hl=en&embedded=true&entry.2123647600={workshopTitle}'),
85
- exercise: z
86
- .string()
87
- .default('https://docs.google.com/forms/d/e/1FAIpQLSf3o9xyjQepTlOTH5Z7ZwkeSTdXh6YWI_RGc9KiyD3oUN0p6w/viewform?hl=en&embedded=true&entry.1836176234={workshopTitle}&entry.428900931={exerciseTitle}'),
96
+ workshop: z.string().default(defaultFormsConfig.workshop),
97
+ exercise: z.string().default(defaultFormsConfig.exercise),
88
98
  })
89
- .default({}),
99
+ .default(defaultFormsConfig),
90
100
  testTab: z
91
101
  .object({
92
102
  enabled: z.boolean().default(true),
93
103
  })
94
- .default({}),
104
+ .default(defaultTestTabConfig),
95
105
  scripts: z
96
106
  .object({
97
107
  postupdate: z.string().optional(),
@@ -195,7 +205,7 @@ export function getWorkshopConfig() {
195
205
  if (error instanceof z.ZodError) {
196
206
  const flattenedErrors = error.flatten();
197
207
  const errorMessages = Object.entries(flattenedErrors.fieldErrors)
198
- .map(([field, errors]) => `${field}: ${errors?.join(', ')}`)
208
+ .map(([field, errors]) => `${field}: ${formatFieldErrors(errors)}`)
199
209
  .concat(flattenedErrors.formErrors);
200
210
  throw new Error(`Invalid epicshop configuration in ${getRootPkgJsonPath()}:\n${errorMessages.join('\n')}`);
201
211
  }
@@ -290,7 +300,7 @@ export async function getAppConfig(fullPath) {
290
300
  .optional()
291
301
  .default(workshopConfig.testTab?.enabled ?? true),
292
302
  })
293
- .default({}),
303
+ .default({ enabled: workshopConfig.testTab?.enabled ?? true }),
294
304
  scripts: z
295
305
  .object({
296
306
  test: z.string().optional(),
@@ -331,7 +341,7 @@ export async function getAppConfig(fullPath) {
331
341
  if (error instanceof z.ZodError) {
332
342
  const flattenedErrors = error.flatten();
333
343
  const errorMessages = Object.entries(flattenedErrors.fieldErrors)
334
- .map(([field, errors]) => `${field}: ${errors?.join(', ')}`)
344
+ .map(([field, errors]) => `${field}: ${formatFieldErrors(errors)}`)
335
345
  .concat(flattenedErrors.formErrors);
336
346
  throw new Error(`Invalid app configuration for ${fullPath}:\n${errorMessages.join('\n')}`);
337
347
  }