@wix/astro 1.0.30 → 2.1.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.
Files changed (92) hide show
  1. package/.turbo/turbo-build.log +16 -0
  2. package/CHANGELOG.md +66 -0
  3. package/build/builders.d.ts +2 -0
  4. package/build/builders.js +34 -0
  5. package/build/builders.js.map +1 -0
  6. package/build/index.d.ts +2 -3
  7. package/build/index.js +20 -17116
  8. package/build/index.js.map +1 -1
  9. package/package.json +14 -33
  10. package/src/builders.ts +14 -0
  11. package/src/index.ts +23 -252
  12. package/tsconfig.json +1 -3
  13. package/tsup.config.mjs +1 -46
  14. package/build-browser-runtime/setup.d.ts +0 -5
  15. package/build-browser-runtime/setup.js +0 -129
  16. package/build-runtime/chunk-B6RICTPP.js +0 -94
  17. package/build-runtime/chunk-FR26HCAT.js +0 -471
  18. package/build-runtime/chunk-HPW4ZAEJ.js +0 -23
  19. package/build-runtime/chunk-MLKGABMK.js +0 -9
  20. package/build-runtime/chunk-NVTQFGTR.js +0 -7
  21. package/build-runtime/chunk-RKE6XT5Z.js +0 -3104
  22. package/build-runtime/chunk-UZPSWWI5.js +0 -13
  23. package/build-runtime/chunk-W73LN534.js +0 -24
  24. package/build-runtime/context/elevated.d.ts +0 -2
  25. package/build-runtime/context/elevated.js +0 -24
  26. package/build-runtime/context/nonElevated.d.ts +0 -2
  27. package/build-runtime/context/nonElevated.js +0 -37
  28. package/build-runtime/context/setupServicePlugin.d.ts +0 -5
  29. package/build-runtime/context/setupServicePlugin.js +0 -16
  30. package/build-runtime/context/setupWebhook.d.ts +0 -5
  31. package/build-runtime/context/setupWebhook.js +0 -16
  32. package/build-runtime/middleware/auth.d.ts +0 -5
  33. package/build-runtime/middleware/auth.js +0 -74
  34. package/build-runtime/middleware/html-embeds.d.ts +0 -5
  35. package/build-runtime/middleware/html-embeds.js +0 -165
  36. package/build-runtime/routes/auth/callback.d.ts +0 -5
  37. package/build-runtime/routes/auth/callback.js +0 -52
  38. package/build-runtime/routes/auth/login.d.ts +0 -5
  39. package/build-runtime/routes/auth/login.js +0 -45
  40. package/build-runtime/routes/auth/logout-callback.d.ts +0 -5
  41. package/build-runtime/routes/auth/logout-callback.js +0 -23
  42. package/build-runtime/routes/auth/logout.d.ts +0 -5
  43. package/build-runtime/routes/auth/logout.js +0 -32
  44. package/build-runtime/routes/paylink/paylink.d.ts +0 -5
  45. package/build-runtime/routes/paylink/paylink.js +0 -1101
  46. package/build-runtime/routes/servicePluginsDevRoute.d.ts +0 -5
  47. package/build-runtime/routes/servicePluginsDevRoute.js +0 -13
  48. package/build-runtime/routes/webhooksDevRoute.d.ts +0 -5
  49. package/build-runtime/routes/webhooksDevRoute.js +0 -13
  50. package/runtime/entry.astro +0 -26
  51. package/src/client-context/setup.ts +0 -14
  52. package/src/client-context/utils.ts +0 -59
  53. package/src/components.ts +0 -98
  54. package/src/constants.ts +0 -2
  55. package/src/context/elevated.ts +0 -20
  56. package/src/context/hostProxy.ts +0 -38
  57. package/src/context/nonElevated.ts +0 -42
  58. package/src/context/setupServicePlugin.ts +0 -13
  59. package/src/context/setupWebhook.ts +0 -13
  60. package/src/context/utils.ts +0 -32
  61. package/src/directories.ts +0 -5
  62. package/src/env.d.ts +0 -11
  63. package/src/middleware/auth.ts +0 -38
  64. package/src/middleware/html-embeds.ts +0 -59
  65. package/src/plugins/patchAstroInlineScripts.ts +0 -27
  66. package/src/plugins/patchGlobal.ts +0 -20
  67. package/src/plugins/setupSsrContext.ts +0 -68
  68. package/src/routes/auth/callback.ts +0 -51
  69. package/src/routes/auth/login.ts +0 -42
  70. package/src/routes/auth/logout-callback.ts +0 -18
  71. package/src/routes/auth/logout.ts +0 -28
  72. package/src/routes/paylink/paylink.ts +0 -33
  73. package/src/routes/servicePluginsDevRoute.ts +0 -10
  74. package/src/routes/webhooksDevRoute.ts +0 -10
  75. package/src/schemas.ts +0 -227
  76. package/src/types.ts +0 -9
  77. package/src/utils/authAsyncLocalStorage.ts +0 -7
  78. package/src/utils/buildBackofficeComponent.ts +0 -64
  79. package/src/utils/buildComponents.ts +0 -182
  80. package/src/utils/buildServicePluginComponent.ts +0 -52
  81. package/src/utils/buildWebhookComponent.ts +0 -39
  82. package/src/utils/contextualAuth.ts +0 -4
  83. package/src/utils/createProjectModel.ts +0 -190
  84. package/src/utils/fs-utils.ts +0 -48
  85. package/src/utils/generateAppManifest.ts +0 -177
  86. package/src/utils/generateVisitorTokens.ts +0 -11
  87. package/src/utils/getSessionTokensFromCookie.ts +0 -38
  88. package/src/utils/loadEnvVars.ts +0 -47
  89. package/src/utils/removeUnusedCodegenFiles.ts +0 -34
  90. package/src/utils/resolveBuildMetadata.ts +0 -37
  91. package/src/utils/saveSessionTokensToCookie.ts +0 -27
  92. package/src/utils/transformStreamUtils.ts +0 -39
@@ -1,51 +0,0 @@
1
- import type { APIRoute } from 'astro';
2
- import * as z from 'zod/v4';
3
- import { oAuthStateCookieName } from '../../constants.js';
4
- import { auth } from '../../utils/contextualAuth.js';
5
- import { saveSessionTokensToCookie } from '../../utils/saveSessionTokensToCookie.js';
6
-
7
- const oauthCookieSchema = z.object({
8
- codeChallenge: z.string(),
9
- codeVerifier: z.string(),
10
- originalUri: z.string(),
11
- redirectUri: z.string(),
12
- state: z.string(),
13
- });
14
-
15
- export const GET: APIRoute = async (context) => {
16
- const oauthStateCookie = context.cookies.get(oAuthStateCookieName);
17
-
18
- if (oauthStateCookie == null) {
19
- throw new Error(`Missing \`${oAuthStateCookieName}\` cookie`);
20
- }
21
-
22
- const oauthData = oauthCookieSchema.parse(JSON.parse(oauthStateCookie.value));
23
-
24
- if (!oauthData.originalUri.startsWith('/')) {
25
- throw new Error(
26
- 'Invalid `originalUri` cookie param, only relative URLs are allowed'
27
- );
28
- }
29
-
30
- const { code, error, errorDescription, state } = auth.parseFromUrl(
31
- context.url.toString(),
32
- 'query'
33
- );
34
-
35
- if (error != null) {
36
- throw new Error(`Error while authenticating: \`${errorDescription}\``);
37
- }
38
-
39
- const memberTokens = await auth.getMemberTokens(code, state, oauthData);
40
-
41
- context.cookies.delete(oAuthStateCookieName, {
42
- httpOnly: true,
43
- path: '/',
44
- sameSite: 'lax',
45
- secure: true,
46
- });
47
-
48
- saveSessionTokensToCookie(context, memberTokens);
49
-
50
- return context.redirect(oauthData.originalUri);
51
- };
@@ -1,42 +0,0 @@
1
- import type { APIRoute } from 'astro';
2
- import * as z from 'zod/v4';
3
- import { oAuthStateCookieName } from '../../constants.js';
4
- import { auth } from '../../utils/contextualAuth.js';
5
-
6
- const loginSearchParams = z.object({
7
- prompt: z.enum(['login', 'none']).optional(),
8
- returnToUrl: z.string().optional(),
9
- });
10
-
11
- export const GET: APIRoute = async ({ request, url }) => {
12
- const { prompt, returnToUrl = '/' } = loginSearchParams.parse(
13
- Object.fromEntries(url.searchParams.entries())
14
- );
15
-
16
- const callbackUrl = new URL('/api/auth/callback', url);
17
- const referer = request.headers.get('referer');
18
-
19
- if (referer != null) {
20
- const originalUrl = new URL(referer);
21
- callbackUrl.protocol = originalUrl.protocol;
22
- }
23
-
24
- const oauthData = auth.generateOAuthData(callbackUrl.toString(), returnToUrl);
25
-
26
- const { authUrl } = await auth.getAuthUrl(oauthData, {
27
- prompt,
28
- responseMode: 'query',
29
- });
30
-
31
- const sameSite = import.meta.env.DEV ? 'None' : 'Lax';
32
-
33
- return new Response(null, {
34
- headers: {
35
- Location: authUrl,
36
- 'Set-Cookie': `${oAuthStateCookieName}=${JSON.stringify(
37
- oauthData
38
- )}; Max-Age=1800; Path=/; HttpOnly; Secure; SameSite=${sameSite}`,
39
- },
40
- status: 302,
41
- });
42
- };
@@ -1,18 +0,0 @@
1
- import type { APIRoute } from 'astro';
2
- import { returnToQueryParamName } from '../../constants.js';
3
- import { auth } from '../../utils/contextualAuth.js';
4
- import { saveSessionTokensToCookie } from '../../utils/saveSessionTokensToCookie.js';
5
-
6
- export const GET: APIRoute = async (context) => {
7
- const returnTo = context.url.searchParams.get(returnToQueryParamName) ?? '/';
8
-
9
- if (!returnTo.startsWith('/')) {
10
- throw new Error(
11
- `Invalid \`${returnToQueryParamName}\` query param, only relative URLs are allowed`
12
- );
13
- }
14
-
15
- saveSessionTokensToCookie(context, await auth.generateVisitorTokens());
16
-
17
- return context.redirect(returnTo);
18
- };
@@ -1,28 +0,0 @@
1
- import type { APIRoute } from 'astro';
2
- import * as z from 'zod/v4';
3
- import { returnToQueryParamName } from '../../constants.js';
4
- import { auth } from '../../utils/contextualAuth.js';
5
-
6
- const logoutSearchParams = z.object({
7
- returnToUrl: z.string().optional(),
8
- });
9
-
10
- export const POST: APIRoute = async ({ redirect, request, url }) => {
11
- const { returnToUrl = '/' } = logoutSearchParams.parse(
12
- Object.fromEntries(url.searchParams.entries())
13
- );
14
- const baseUrl = `${new URL(request.url).origin}/${import.meta.env.BASE_URL}`;
15
- const postFlowUrl = new URL('/api/auth/logout-callback', baseUrl);
16
- const referer = request.headers.get('referer');
17
-
18
- if (referer != null) {
19
- const originalUrl = new URL(referer);
20
- postFlowUrl.protocol = originalUrl.protocol;
21
- }
22
-
23
- postFlowUrl.searchParams.set(returnToQueryParamName, returnToUrl);
24
-
25
- const { logoutUrl } = await auth.logout(postFlowUrl.toString());
26
-
27
- return redirect(logoutUrl);
28
- };
@@ -1,33 +0,0 @@
1
- import type { APIRoute } from 'astro';
2
- import { oAuthApps } from '@wix/auth-management';
3
- import { auth } from '@wix/essentials';
4
- import { WIX_CLIENT_ID } from 'astro:env/client';
5
-
6
- export const GET: APIRoute = async ({ params }) => {
7
- try {
8
- const { redirectUrlWixPages } = await auth.elevate(oAuthApps.getOAuthApp)(
9
- WIX_CLIENT_ID
10
- );
11
-
12
- if (redirectUrlWixPages == null) {
13
- throw new Error(`Invalid Redirect URL: ${redirectUrlWixPages}`);
14
- }
15
-
16
- const paylinkId = params.id;
17
-
18
- const baseUrl = redirectUrlWixPages.endsWith('/')
19
- ? redirectUrlWixPages
20
- : `${redirectUrlWixPages}/`;
21
-
22
- const paylinkUrl = new URL(`_paylink/${paylinkId}`, baseUrl);
23
-
24
- return new Response(null, {
25
- headers: { Location: paylinkUrl.toString() },
26
- status: 302,
27
- });
28
- } catch (error) {
29
- throw new Error(
30
- `Error while constructing Paylink URL: ${JSON.stringify(error)}`
31
- );
32
- }
33
- };
@@ -1,10 +0,0 @@
1
- import type { APIRoute } from 'astro';
2
-
3
- export const ALL: APIRoute = async (context) => {
4
- const { ALL } = (await import(
5
- /* @vite-ignore */
6
- `/.astro/integrations/_wix_astro/extensions/service-plugins/${context.params.compId}/entry.ts`
7
- )) as { ALL: APIRoute };
8
-
9
- return ALL(context);
10
- };
@@ -1,10 +0,0 @@
1
- import type { APIRoute } from 'astro';
2
-
3
- export const ALL: APIRoute = async (context) => {
4
- const { ALL } = (await import(
5
- /* @vite-ignore */
6
- `/.astro/integrations/_wix_astro/extensions/webhooks/${context.params.compId}/entry.ts`
7
- )) as { ALL: APIRoute };
8
-
9
- return ALL(context);
10
- };
package/src/schemas.ts DELETED
@@ -1,227 +0,0 @@
1
- import * as z from 'zod/v4';
2
-
3
- export const baseDevCenterComponentSchema = z
4
- .object({
5
- compData: z.unknown(),
6
- compId: z.string(),
7
- compName: z.string().optional(),
8
- compType: z.string(),
9
- })
10
- .loose();
11
-
12
- export type BaseDevCenterComponent = z.TypeOf<
13
- typeof baseDevCenterComponentSchema
14
- >;
15
-
16
- const devCenterWebhookSchema = z.object({
17
- ...baseDevCenterComponentSchema.shape,
18
- ...z.object({
19
- compData: z.object({
20
- webhook: z
21
- .object({
22
- callbackUrl: z.string().optional(),
23
- })
24
- .loose(),
25
- }),
26
- compType: z.literal('WEBHOOK'),
27
- }).shape,
28
- });
29
-
30
- export type DevCenterWebhook = z.TypeOf<typeof devCenterWebhookSchema>;
31
-
32
- const devCenterBackofficeExtensionWidgetSchema = z.object({
33
- ...baseDevCenterComponentSchema.shape,
34
- ...z.object({
35
- compData: z.object({
36
- backOfficeExtensionWidget: z
37
- .object({
38
- iframeUrl: z.string().optional(),
39
- })
40
- .loose(),
41
- }),
42
- compType: z.literal('BACK_OFFICE_EXTENSION_WIDGET'),
43
- }).shape,
44
- });
45
-
46
- export type DevCenterBackofficeExtensionWidget = z.TypeOf<
47
- typeof devCenterBackofficeExtensionWidgetSchema
48
- >;
49
-
50
- const devCenterBackofficeExtensionMenuPluginSchema = z.object({
51
- ...baseDevCenterComponentSchema.shape,
52
- ...z.object({
53
- compData: z.object({
54
- backOfficeExtensionMenuItem: z.unknown().optional(),
55
- }),
56
- compType: z.literal('BACK_OFFICE_EXTENSION_MENU_ITEM'),
57
- }).shape,
58
- });
59
-
60
- export type DevCenterBackofficeExtensionMenuItem = z.TypeOf<
61
- typeof devCenterBackofficeExtensionMenuPluginSchema
62
- >;
63
-
64
- const devCenterBackofficeModalSchema = z.object({
65
- ...baseDevCenterComponentSchema.shape,
66
- ...z.object({
67
- compData: z.object({
68
- backOfficeModal: z
69
- .object({
70
- iframeUrl: z.string().optional(),
71
- })
72
- .loose(),
73
- }),
74
- compType: z.literal('BACK_OFFICE_MODAL'),
75
- }).shape,
76
- });
77
-
78
- export type DevCenterBackofficeModal = z.TypeOf<
79
- typeof devCenterBackofficeModalSchema
80
- >;
81
-
82
- const devCenterBackofficePageSchema = z.object({
83
- ...baseDevCenterComponentSchema.shape,
84
- ...z.object({
85
- compData: z.object({
86
- backOfficePage: z
87
- .object({
88
- iframeUrl: z.string().optional(),
89
- })
90
- .loose(),
91
- }),
92
- compType: z.literal('BACK_OFFICE_PAGE'),
93
- }).shape,
94
- });
95
-
96
- export type DevCenterBackofficePage = z.TypeOf<
97
- typeof devCenterBackofficePageSchema
98
- >;
99
-
100
- const devCenterEcomAdditionalFeesSchema = z.object({
101
- ...baseDevCenterComponentSchema.shape,
102
- ...z.object({
103
- compData: z.object({
104
- ecomAdditionalFees: z
105
- .object({
106
- deploymentUri: z.string().optional(),
107
- })
108
- .loose(),
109
- }),
110
- compType: z.literal('ECOM_ADDITIONAL_FEES'),
111
- }).shape,
112
- });
113
-
114
- export type DevCenterEcomAdditionalFees = z.TypeOf<
115
- typeof devCenterEcomAdditionalFeesSchema
116
- >;
117
-
118
- const devCenterEcomDiscountsTriggerSchema = z.object({
119
- ...baseDevCenterComponentSchema.shape,
120
- ...z.object({
121
- compData: z.object({
122
- ecomDiscountsTrigger: z
123
- .object({
124
- deploymentUri: z.string().optional(),
125
- })
126
- .loose(),
127
- }),
128
- compType: z.literal('ECOM_DISCOUNTS_TRIGGER'),
129
- }).shape,
130
- });
131
-
132
- export type DevCenterEcomDiscountsTrigger = z.TypeOf<
133
- typeof devCenterEcomDiscountsTriggerSchema
134
- >;
135
-
136
- const devCenterEcomPaymentSettingsSchema = z.object({
137
- ...baseDevCenterComponentSchema.shape,
138
- ...z.object({
139
- compData: z.object({
140
- ecomPaymentSettings: z
141
- .object({
142
- deploymentUri: z.string().optional(),
143
- })
144
- .loose(),
145
- }),
146
- compType: z.literal('ECOM_PAYMENT_SETTINGS'),
147
- }).shape,
148
- });
149
-
150
- export type DevCenterEcomPaymentSettings = z.TypeOf<
151
- typeof devCenterEcomPaymentSettingsSchema
152
- >;
153
-
154
- const devCenterEcomShippingRatesSchema = z.object({
155
- ...baseDevCenterComponentSchema.shape,
156
- ...z.object({
157
- compData: z.object({
158
- ecomShippingRates: z
159
- .object({
160
- deploymentUri: z.string().optional(),
161
- })
162
- .loose(),
163
- }),
164
- compType: z.literal('ECOM_SHIPPING_RATES'),
165
- }).shape,
166
- });
167
-
168
- export type DevCenterEcomShippingRates = z.TypeOf<
169
- typeof devCenterEcomShippingRatesSchema
170
- >;
171
-
172
- const devCenterEcomValidationsSchema = z.object({
173
- ...baseDevCenterComponentSchema.shape,
174
- ...z.object({
175
- compData: z.object({
176
- ecomValidations: z
177
- .object({
178
- deploymentUri: z.string().optional(),
179
- })
180
- .loose(),
181
- }),
182
- compType: z.literal('ECOM_VALIDATIONS'),
183
- }).shape,
184
- });
185
-
186
- export type DevCenterEcomValidations = z.TypeOf<
187
- typeof devCenterEcomValidationsSchema
188
- >;
189
-
190
- const devCenterEcomGiftCardsProviderSchema = z.object({
191
- ...baseDevCenterComponentSchema.shape,
192
- ...z.object({
193
- compData: z.object({
194
- giftCardsProvider: z
195
- .object({
196
- deploymentUri: z.string().optional(),
197
- })
198
- .loose(),
199
- }),
200
- compType: z.literal('GIFT_CARDS_PROVIDER'),
201
- }).shape,
202
- });
203
-
204
- export type DevCenterEcomGiftCardsProvider = z.TypeOf<
205
- typeof devCenterEcomGiftCardsProviderSchema
206
- >;
207
-
208
- export const devCenterComponentSchema = z.discriminatedUnion('compType', [
209
- devCenterBackofficePageSchema,
210
- devCenterBackofficeExtensionWidgetSchema,
211
- devCenterBackofficeExtensionMenuPluginSchema,
212
- devCenterBackofficeModalSchema,
213
- devCenterWebhookSchema,
214
- devCenterEcomAdditionalFeesSchema,
215
- devCenterEcomShippingRatesSchema,
216
- devCenterEcomDiscountsTriggerSchema,
217
- devCenterEcomValidationsSchema,
218
- devCenterEcomPaymentSettingsSchema,
219
- devCenterEcomGiftCardsProviderSchema,
220
- ]);
221
-
222
- export interface DevCenterAppManifest {
223
- appId: string;
224
- components: BaseDevCenterComponent[];
225
- }
226
-
227
- export type DevCenterComponent = z.infer<typeof devCenterComponentSchema>;
package/src/types.ts DELETED
@@ -1,9 +0,0 @@
1
- import type { Component, UnknownComponent } from './components.js';
2
-
3
- export interface Model {
4
- appId: string;
5
- components: Component[];
6
- env: Record<string, string>;
7
- rootDir: string;
8
- unknownComponents: UnknownComponent[];
9
- }
@@ -1,7 +0,0 @@
1
- import { AsyncLocalStorage } from 'node:async_hooks';
2
- import type { Tokens } from '@wix/sdk';
3
-
4
- export const authAsyncLocalStorage = new AsyncLocalStorage<{
5
- request: Request;
6
- sessionTokens: Tokens;
7
- }>();
@@ -1,64 +0,0 @@
1
- import { writeFile } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
- import type { InjectedRoute } from 'astro';
4
- import { outdent } from 'outdent';
5
- import type {
6
- BackofficeExtensionWidget,
7
- BackofficeModal,
8
- BackofficePage,
9
- } from '../components.js';
10
- import { outputDir, toRelativePath } from './fs-utils.js';
11
-
12
- export async function buildBackofficeComponent({
13
- codegenDir,
14
- component,
15
- entryFileName,
16
- injectRoute,
17
- }: {
18
- codegenDir: string;
19
- component: BackofficeExtensionWidget | BackofficeModal | BackofficePage;
20
- entryFileName: string;
21
- injectRoute: (injectRoute: InjectedRoute) => void;
22
- }): Promise<void> {
23
- const directory = join(codegenDir, component.manifest.compId);
24
-
25
- await outputDir(directory);
26
-
27
- const entryFilePath = join(component.directory, entryFileName);
28
-
29
- const entrypoint = join(directory, `entry.astro`);
30
- const HocEntrypoint = join(directory, `wrapper.tsx`);
31
-
32
- await writeFile(
33
- HocEntrypoint,
34
- outdent`
35
- import Component from '${toRelativePath(HocEntrypoint, entryFilePath)}';
36
- import { withContextualWixClient } from '@wix/dashboard/internal';
37
-
38
- export const WrappedComponent = withContextualWixClient(Component);
39
- `
40
- );
41
-
42
- await writeFile(
43
- entrypoint,
44
- outdent`
45
- ---
46
- import { WrappedComponent } from '${toRelativePath(entrypoint, HocEntrypoint)}';
47
- ---
48
-
49
- <html lang="en">
50
- <head></head>
51
- <body>
52
- <div>
53
- <WrappedComponent client:only="react" />
54
- </div>
55
- </body>
56
- </html>
57
- `
58
- );
59
-
60
- injectRoute({
61
- entrypoint,
62
- pattern: `/_wix/extensions/backoffice/${component.manifest.compId}`,
63
- });
64
- }
@@ -1,182 +0,0 @@
1
- import { join } from 'node:path';
2
- import type { InjectedRoute } from 'astro';
3
- import type { Model } from '../types.js';
4
- import { buildBackofficeComponent } from './buildBackofficeComponent.js';
5
- import { buildServicePluginComponent } from './buildServicePluginComponent.js';
6
- import { buildWebhookComponent } from './buildWebhookComponent.js';
7
-
8
- export async function buildComponents({
9
- extensionsDir,
10
- injectRoute: originalInjectRoute,
11
- isDev,
12
- model,
13
- }: {
14
- extensionsDir: string;
15
- injectRoute: (injectRoute: InjectedRoute) => void;
16
- isDev: boolean;
17
- model: Model;
18
- }): Promise<void> {
19
- // during dev, a single dynamic route is injected so adding or removing
20
- // components doesn't require re-running the dev command
21
- const injectRoute = isDev ? () => null : originalInjectRoute;
22
-
23
- const backofficeCodegenDir = join(extensionsDir, 'backoffice');
24
- const webhooksCodegenDir = join(extensionsDir, 'webhooks');
25
- const servicePluginsCodegenDir = join(extensionsDir, 'service-plugins');
26
-
27
- for (const component of model.components) {
28
- switch (component.type) {
29
- case 'BackofficeExtensionMenuPlugin': {
30
- // configuration only
31
-
32
- break;
33
- }
34
- case 'BackofficeExtensionWidget': {
35
- if (
36
- component.manifest.compData.backOfficeExtensionWidget.iframeUrl !=
37
- null
38
- ) {
39
- continue;
40
- }
41
-
42
- await buildBackofficeComponent({
43
- codegenDir: backofficeCodegenDir,
44
- component,
45
- entryFileName: 'widget.tsx',
46
- injectRoute,
47
- });
48
-
49
- break;
50
- }
51
- case 'BackofficeModal': {
52
- if (component.manifest.compData.backOfficeModal.iframeUrl != null) {
53
- continue;
54
- }
55
-
56
- await buildBackofficeComponent({
57
- codegenDir: backofficeCodegenDir,
58
- component,
59
- entryFileName: 'modal.tsx',
60
- injectRoute,
61
- });
62
-
63
- break;
64
- }
65
- case 'BackofficePage': {
66
- if (component.manifest.compData.backOfficePage.iframeUrl != null) {
67
- continue;
68
- }
69
-
70
- await buildBackofficeComponent({
71
- codegenDir: backofficeCodegenDir,
72
- component,
73
- entryFileName: 'page.tsx',
74
- injectRoute,
75
- });
76
-
77
- break;
78
- }
79
- case 'EcomAdditionalFees': {
80
- if (
81
- component.manifest.compData.ecomAdditionalFees.deploymentUri != null
82
- ) {
83
- continue;
84
- }
85
-
86
- await buildServicePluginComponent({
87
- codegenDir: servicePluginsCodegenDir,
88
- component,
89
- injectRoute,
90
- });
91
-
92
- break;
93
- }
94
- case 'EcomDiscountsTrigger': {
95
- if (
96
- component.manifest.compData.ecomDiscountsTrigger.deploymentUri != null
97
- ) {
98
- continue;
99
- }
100
-
101
- await buildServicePluginComponent({
102
- codegenDir: servicePluginsCodegenDir,
103
- component,
104
- injectRoute,
105
- });
106
-
107
- break;
108
- }
109
- case 'EcomGiftCardsProvider': {
110
- if (
111
- component.manifest.compData.giftCardsProvider.deploymentUri != null
112
- ) {
113
- continue;
114
- }
115
-
116
- await buildServicePluginComponent({
117
- codegenDir: servicePluginsCodegenDir,
118
- component,
119
- injectRoute,
120
- });
121
-
122
- break;
123
- }
124
- case 'EcomPaymentSettings': {
125
- if (
126
- component.manifest.compData.ecomPaymentSettings.deploymentUri != null
127
- ) {
128
- continue;
129
- }
130
-
131
- await buildServicePluginComponent({
132
- codegenDir: servicePluginsCodegenDir,
133
- component,
134
- injectRoute,
135
- });
136
-
137
- break;
138
- }
139
- case 'EcomShippingRates': {
140
- if (
141
- component.manifest.compData.ecomShippingRates.deploymentUri != null
142
- ) {
143
- continue;
144
- }
145
-
146
- await buildServicePluginComponent({
147
- codegenDir: servicePluginsCodegenDir,
148
- component,
149
- injectRoute,
150
- });
151
-
152
- break;
153
- }
154
- case 'EcomValidations': {
155
- if (component.manifest.compData.ecomValidations.deploymentUri != null) {
156
- continue;
157
- }
158
-
159
- await buildServicePluginComponent({
160
- codegenDir: servicePluginsCodegenDir,
161
- component,
162
- injectRoute,
163
- });
164
-
165
- break;
166
- }
167
- case 'Webhook': {
168
- if (component.manifest.compData.webhook.callbackUrl != null) {
169
- continue;
170
- }
171
-
172
- await buildWebhookComponent({
173
- codegenDir: webhooksCodegenDir,
174
- component,
175
- injectRoute,
176
- });
177
-
178
- break;
179
- }
180
- }
181
- }
182
- }