@wix/astro 1.0.22 → 1.0.24

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 (53) hide show
  1. package/build/index.d.ts +4 -2
  2. package/build/index.js +926 -1796
  3. package/build/index.js.map +1 -1
  4. package/build-browser-runtime/setup.js +4 -4
  5. package/build-runtime/{chunk-C3QOE2TZ.js → chunk-NVTQFGTR.js} +1 -1
  6. package/build-runtime/chunk-W73LN534.js +24 -0
  7. package/build-runtime/context/{non-elevated.js → nonElevated.js} +2 -2
  8. package/build-runtime/context/setupServicePlugin.d.ts +5 -0
  9. package/build-runtime/context/setupServicePlugin.js +16 -0
  10. package/build-runtime/context/setupWebhook.d.ts +5 -0
  11. package/build-runtime/context/setupWebhook.js +16 -0
  12. package/build-runtime/middleware/auth.js +4 -4
  13. package/build-runtime/middleware/html-embeds.js +1 -1
  14. package/build-runtime/routes/auth/callback.js +3 -3
  15. package/build-runtime/routes/auth/login.js +8 -5
  16. package/build-runtime/routes/auth/logout-callback.js +3 -3
  17. package/build-runtime/routes/auth/logout.js +5 -0
  18. package/build-runtime/routes/{service-plugins.js → servicePluginsDevRoute.js} +2 -2
  19. package/build-runtime/routes/{webhooks.js → webhooksDevRoute.js} +2 -2
  20. package/package.json +10 -9
  21. package/runtime/entry.astro +1 -1
  22. package/src/client-context/utils.ts +40 -0
  23. package/src/components.ts +80 -59
  24. package/src/context/setupServicePlugin.ts +13 -0
  25. package/src/context/setupWebhook.ts +13 -0
  26. package/src/context/utils.ts +22 -30
  27. package/src/index.ts +79 -164
  28. package/src/middleware/auth.ts +1 -1
  29. package/src/middleware/html-embeds.ts +1 -1
  30. package/src/plugins/setupSsrContext.ts +1 -1
  31. package/src/routes/auth/login.ts +10 -5
  32. package/src/routes/auth/logout.ts +7 -0
  33. package/src/routes/{service-plugins.ts → servicePluginsDevRoute.ts} +1 -1
  34. package/src/routes/{webhooks.ts → webhooksDevRoute.ts} +1 -1
  35. package/src/utils/buildBackofficeComponent.ts +66 -0
  36. package/src/utils/buildComponents.ts +194 -0
  37. package/src/utils/buildServicePluginComponent.ts +54 -0
  38. package/src/utils/buildWebhookComponent.ts +41 -0
  39. package/src/utils/createProjectModel.ts +42 -30
  40. package/src/utils/fs-utils.ts +7 -1
  41. package/src/utils/removeUnusedCodegenFiles.ts +34 -0
  42. package/tsup.config.mjs +6 -4
  43. package/src/utils/isValidBackofficeComponent.ts +0 -18
  44. package/src/utils/isValidServicePluginComponent.ts +0 -26
  45. package/src/utils/isValidWebhookComponent.ts +0 -10
  46. package/src/utils/writeVirtualBackofficeExtensionFiles.ts +0 -93
  47. package/src/utils/writeVirtualServicePluginExtensionFiles.ts +0 -73
  48. package/src/utils/writeVirtualWebhookExtensionFiles.ts +0 -72
  49. /package/build-runtime/context/{non-elevated.d.ts → nonElevated.d.ts} +0 -0
  50. /package/build-runtime/routes/{service-plugins.d.ts → servicePluginsDevRoute.d.ts} +0 -0
  51. /package/build-runtime/routes/{webhooks.d.ts → webhooksDevRoute.d.ts} +0 -0
  52. /package/src/{context → client-context}/setup.ts +0 -0
  53. /package/src/context/{non-elevated.ts → nonElevated.ts} +0 -0
@@ -0,0 +1,54 @@
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
+ EcomAdditionalFees,
7
+ EcomDiscountsTrigger,
8
+ EcomGiftCardsProvider,
9
+ EcomPaymentSettings,
10
+ EcomShippingRates,
11
+ EcomValidations,
12
+ } from '../components.js';
13
+ import { outputDir, toRelativePath } from './fs-utils.js';
14
+
15
+ export async function buildServicePluginComponent({
16
+ codegenDir,
17
+ component,
18
+ injectRoute,
19
+ rootDir,
20
+ }: {
21
+ codegenDir: string;
22
+ component:
23
+ | EcomAdditionalFees
24
+ | EcomDiscountsTrigger
25
+ | EcomGiftCardsProvider
26
+ | EcomPaymentSettings
27
+ | EcomShippingRates
28
+ | EcomValidations;
29
+ injectRoute: (injectRoute: InjectedRoute) => void;
30
+ rootDir: string;
31
+ }): Promise<void> {
32
+ const directory = join(codegenDir, component.manifest.compId);
33
+
34
+ await outputDir(directory);
35
+
36
+ const entrypoint = join(directory, `entry.ts`);
37
+ const entryFilePath = join(rootDir, component.directory, 'plugin.ts');
38
+
39
+ await writeFile(
40
+ entrypoint,
41
+ outdent`
42
+ import { setupServicePlugin } from '@wix/astro/context/setup-service-plugin';
43
+
44
+ export const ALL = await setupServicePlugin(
45
+ () => import('${toRelativePath(entrypoint, entryFilePath)}'),
46
+ );
47
+ `
48
+ );
49
+
50
+ injectRoute({
51
+ entrypoint,
52
+ pattern: `/_wix/extensions/service-plugins/${component.manifest.compId}`,
53
+ });
54
+ }
@@ -0,0 +1,41 @@
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 { Webhook } from '../components.js';
6
+ import { outputDir, toRelativePath } from './fs-utils.js';
7
+
8
+ export async function buildWebhookComponent({
9
+ codegenDir,
10
+ component,
11
+ injectRoute,
12
+ rootDir,
13
+ }: {
14
+ codegenDir: string;
15
+ component: Webhook;
16
+ injectRoute: (injectRoute: InjectedRoute) => void;
17
+ rootDir: string;
18
+ }): Promise<void> {
19
+ const directory = join(codegenDir, component.manifest.compId);
20
+
21
+ await outputDir(directory);
22
+
23
+ const entrypoint = join(directory, `entry.ts`);
24
+ const entryFilePath = join(rootDir, component.directory, 'event.ts');
25
+
26
+ await writeFile(
27
+ entrypoint,
28
+ outdent`
29
+ import { setupWebhook } from '@wix/astro/context/setup-webhook';
30
+
31
+ export const ALL = await setupWebhook(
32
+ () => import('${toRelativePath(entrypoint, entryFilePath)}'),
33
+ );
34
+ `
35
+ );
36
+
37
+ injectRoute({
38
+ entrypoint,
39
+ pattern: `/_wix/extensions/webhooks/${component.manifest.compId}`,
40
+ });
41
+ }
@@ -3,9 +3,9 @@ import { cwd } from 'node:process';
3
3
  import type { AstroIntegrationLogger } from 'astro';
4
4
  import { globby } from 'globby';
5
5
  import { outdent } from 'outdent';
6
+ import type { Component, UnknownComponent } from '../components.js';
6
7
  import type { DevCenterComponent } from '../schemas.js';
7
8
  import type { Model } from '../types.js';
8
- import { Component, UnknownComponent } from '../components.js';
9
9
  import { EXTENSIONS_DIR } from '../directories.js';
10
10
  import {
11
11
  baseDevCenterComponentSchema,
@@ -42,12 +42,10 @@ export async function createProjectModel(
42
42
 
43
43
  const unknownManifest = parseBaseExtensionManifest(extensionManifest);
44
44
 
45
- unknownComponents.push(
46
- UnknownComponent.Unknown({
47
- directory: componentPath,
48
- manifest: unknownManifest,
49
- })
50
- );
45
+ unknownComponents.push({
46
+ directory: componentPath,
47
+ manifest: unknownManifest,
48
+ });
51
49
  }
52
50
 
53
51
  return {
@@ -61,72 +59,86 @@ export async function createProjectModel(
61
59
 
62
60
  // https://github.com/mrmlnc/fast-glob/releases/tag/3.0.0
63
61
  // globby using fast-glob under the hood accepts only forward slashes in patterns.
64
- function createComponent(manifest: DevCenterComponent, directory: string) {
62
+ function createComponent(
63
+ manifest: DevCenterComponent,
64
+ directory: string
65
+ ): Component {
65
66
  switch (manifest.compType) {
66
67
  case 'BACK_OFFICE_EXTENSION_MENU_ITEM':
67
- return Component.BackofficeExtensionMenuPlugin({
68
+ return {
68
69
  directory,
69
70
  manifest,
70
- });
71
+ type: 'BackofficeExtensionMenuPlugin',
72
+ };
71
73
  case 'BACK_OFFICE_EXTENSION_WIDGET': {
72
- return Component.BackofficeExtensionWidget({
74
+ return {
73
75
  directory,
74
76
  manifest,
75
- });
77
+ type: 'BackofficeExtensionWidget',
78
+ };
76
79
  }
77
80
  case 'BACK_OFFICE_MODAL': {
78
- return Component.BackofficeModal({
81
+ return {
79
82
  directory,
80
83
  manifest,
81
- });
84
+ type: 'BackofficeModal',
85
+ };
82
86
  }
83
87
  case 'BACK_OFFICE_PAGE': {
84
- return Component.BackofficePage({
88
+ return {
85
89
  directory,
86
90
  manifest,
87
- });
91
+ type: 'BackofficePage',
92
+ };
88
93
  }
89
94
  case 'ECOM_ADDITIONAL_FEES': {
90
- return Component.EcomAdditionalFees({
95
+ return {
91
96
  directory,
92
97
  manifest,
93
- });
98
+ type: 'EcomAdditionalFees',
99
+ };
94
100
  }
95
101
  case 'ECOM_DISCOUNTS_TRIGGER': {
96
- return Component.EcomDiscountsTrigger({
102
+ return {
97
103
  directory,
98
104
  manifest,
99
- });
105
+ type: 'EcomDiscountsTrigger',
106
+ };
100
107
  }
101
108
  case 'ECOM_PAYMENT_SETTINGS': {
102
- return Component.EcomPaymentSettings({
109
+ return {
103
110
  directory,
104
111
  manifest,
105
- });
112
+ type: 'EcomPaymentSettings',
113
+ };
106
114
  }
107
115
  case 'ECOM_SHIPPING_RATES': {
108
- return Component.EcomShippingRates({
116
+ return {
109
117
  directory,
110
118
  manifest,
111
- });
119
+ type: 'EcomShippingRates',
120
+ };
112
121
  }
113
122
  case 'ECOM_VALIDATIONS': {
114
- return Component.EcomValidations({
123
+ return {
115
124
  directory,
116
125
  manifest,
117
- });
126
+ type: 'EcomValidations',
127
+ };
118
128
  }
119
129
  case 'GIFT_CARDS_PROVIDER': {
120
- return Component.EcomGiftCardsProvider({
130
+ return {
121
131
  directory,
122
132
  manifest,
123
- });
133
+ type: 'EcomGiftCardsProvider',
134
+ };
124
135
  }
125
136
  case 'WEBHOOK': {
126
- return Component.Webhook({
137
+ return {
127
138
  directory,
128
139
  manifest,
129
- });
140
+ type: 'Webhook',
141
+ };
130
142
  }
131
143
  }
132
144
  }
@@ -2,16 +2,22 @@ import {
2
2
  access,
3
3
  readFile as fsReadFile,
4
4
  mkdir,
5
+ rm,
5
6
  writeFile,
6
7
  } from 'node:fs/promises';
7
8
  import { EOL } from 'node:os';
8
9
  import { dirname, relative } from 'node:path';
9
10
 
11
+ export async function clearDir(dir: string): Promise<void> {
12
+ await rm(dir, { recursive: true });
13
+ await mkdir(dir);
14
+ }
15
+
10
16
  export async function outputDir(dir: string): Promise<void> {
11
17
  await mkdir(dir, { recursive: true });
12
18
  }
13
19
 
14
- export function pathExists(path: string): Promise<boolean> {
20
+ export async function pathExists(path: string): Promise<boolean> {
15
21
  return access(path)
16
22
  .then(() => true)
17
23
  .catch(() => false);
@@ -0,0 +1,34 @@
1
+ import { rm } from 'node:fs/promises';
2
+ import { basename } from 'node:path';
3
+ import { globby } from 'globby';
4
+ import type { Model } from '../types.js';
5
+
6
+ export async function removeUnusedCodegenFiles({
7
+ extensionsDir,
8
+ model,
9
+ }: {
10
+ extensionsDir: string;
11
+ model: Model;
12
+ }): Promise<void> {
13
+ const codegenFiles = await globby(`*/*`, {
14
+ absolute: true,
15
+ cwd: extensionsDir,
16
+ onlyDirectories: true,
17
+ });
18
+
19
+ for (const dirname of codegenFiles) {
20
+ // rely on codegen files being in the following format:
21
+ // `backoffice/{componentId}/...`, `webhooks/{componentId}/...`, etc...
22
+ const componentId = basename(dirname);
23
+
24
+ if (
25
+ model.components.some(
26
+ (component) => component.manifest.compId === componentId
27
+ )
28
+ ) {
29
+ continue;
30
+ }
31
+
32
+ await rm(dirname, { recursive: true });
33
+ }
34
+ }
package/tsup.config.mjs CHANGED
@@ -39,13 +39,15 @@ export default defineConfig([
39
39
  },
40
40
  entry: [
41
41
  // extensions
42
- 'src/routes/webhooks.ts',
43
- 'src/routes/service-plugins.ts',
42
+ 'src/routes/webhooksDevRoute.ts',
43
+ 'src/routes/servicePluginsDevRoute.ts',
44
44
 
45
45
  // contextual client
46
46
  'src/middleware/auth.ts',
47
47
  'src/context/elevated.ts',
48
- 'src/context/non-elevated.ts',
48
+ 'src/context/nonElevated.ts',
49
+ 'src/context/setupServicePlugin.ts',
50
+ 'src/context/setupWebhook.ts',
49
51
 
50
52
  // auth routes
51
53
  'src/routes/auth/login.ts',
@@ -66,7 +68,7 @@ export default defineConfig([
66
68
  dts: {
67
69
  resolve: [...astroExternals, ...viteExternals, '@wix/sdk-context'],
68
70
  },
69
- entry: ['src/context/setup.ts'],
71
+ entry: ['src/client-context/setup.ts'],
70
72
  external: [...astroExternals, ...viteExternals, '@wix/sdk-context'],
71
73
  format: ['esm'],
72
74
  outDir: 'build-browser-runtime',
@@ -1,18 +0,0 @@
1
- import type { Component } from '../components.js';
2
-
3
- export function isValidBackofficeComponent(
4
- component: Component
5
- ): component is
6
- | Component<'BackofficeExtensionWidget'>
7
- | Component<'BackofficeModal'>
8
- | Component<'BackofficePage'> {
9
- return (
10
- (component.type === 'BackofficePage' &&
11
- component.manifest.compData.backOfficePage.iframeUrl == null) ||
12
- (component.type === 'BackofficeExtensionWidget' &&
13
- component.manifest.compData.backOfficeExtensionWidget.iframeUrl ==
14
- null) ||
15
- (component.type === 'BackofficeModal' &&
16
- component.manifest.compData.backOfficeModal.iframeUrl == null)
17
- );
18
- }
@@ -1,26 +0,0 @@
1
- import type { Component } from '../components.js';
2
-
3
- export function isValidServicePluginComponent(
4
- component: Component
5
- ): component is
6
- | Component<'EcomAdditionalFees'>
7
- | Component<'EcomDiscountsTrigger'>
8
- | Component<'EcomGiftCardsProvider'>
9
- | Component<'EcomPaymentSettings'>
10
- | Component<'EcomShippingRates'>
11
- | Component<'EcomValidations'> {
12
- return (
13
- (component.type === 'EcomShippingRates' &&
14
- component.manifest.compData.ecomShippingRates.deploymentUri == null) ||
15
- (component.type === 'EcomAdditionalFees' &&
16
- component.manifest.compData.ecomAdditionalFees.deploymentUri == null) ||
17
- (component.type === 'EcomDiscountsTrigger' &&
18
- component.manifest.compData.ecomDiscountsTrigger.deploymentUri == null) ||
19
- (component.type === 'EcomValidations' &&
20
- component.manifest.compData.ecomValidations.deploymentUri == null) ||
21
- (component.type === 'EcomPaymentSettings' &&
22
- component.manifest.compData.ecomPaymentSettings.deploymentUri == null) ||
23
- (component.type === 'EcomGiftCardsProvider' &&
24
- component.manifest.compData.giftCardsProvider.deploymentUri == null)
25
- );
26
- }
@@ -1,10 +0,0 @@
1
- import type { Component } from '../components.js';
2
-
3
- export function isValidWebhookComponent(
4
- component: Component
5
- ): component is Component<'Webhook'> {
6
- return (
7
- component.type === 'Webhook' &&
8
- component.manifest.compData.webhook.callbackUrl == null
9
- );
10
- }
@@ -1,93 +0,0 @@
1
- import { rm, writeFile } from 'node:fs/promises';
2
- import { join, resolve } from 'node:path';
3
- import { globby } from 'globby';
4
- import { outdent } from 'outdent';
5
- import { match } from 'variant';
6
- import type { Component } from '../components.js';
7
- import type { Model } from '../types.js';
8
- import { isValidBackofficeComponent } from '../utils/isValidBackofficeComponent.js';
9
- import { toRelativePath } from './fs-utils.js';
10
-
11
- export async function writeVirtualBackofficeExtensionFiles(
12
- model: Model,
13
- codegenDir: string
14
- ): Promise<void> {
15
- const backofficeComponents = model.components.filter(
16
- isValidBackofficeComponent
17
- );
18
-
19
- const existingFiles = await globby(`*.astro`, {
20
- cwd: codegenDir,
21
- onlyFiles: true,
22
- });
23
-
24
- for (const filename of existingFiles) {
25
- const hasMatchingSourceFile = backofficeComponents.some(
26
- (component) => `${component.manifest.compId}.astro` === filename
27
- );
28
-
29
- if (hasMatchingSourceFile) {
30
- continue;
31
- }
32
-
33
- await rm(join(codegenDir, filename));
34
- }
35
-
36
- for (const component of backofficeComponents) {
37
- const entryFilename = resolveEntry(component);
38
- const originalEntrypoint = resolve(model.rootDir, entryFilename);
39
-
40
- const virtualHocEntrypoint = join(
41
- codegenDir,
42
- `hoc_${component.manifest.compId}.tsx`
43
- );
44
-
45
- await writeFile(
46
- virtualHocEntrypoint,
47
- outdent`
48
- import Component from '${toRelativePath(virtualHocEntrypoint, originalEntrypoint)}';
49
- import { withContextualWixClient } from '@wix/dashboard/internal';
50
-
51
- export const WrappedComponent = withContextualWixClient(Component);
52
- `
53
- );
54
-
55
- const virtualEntrypoint = join(
56
- codegenDir,
57
- `${component.manifest.compId}.astro`
58
- );
59
-
60
- await writeFile(
61
- virtualEntrypoint,
62
- outdent`
63
- ---
64
- import { WrappedComponent } from '${toRelativePath(virtualEntrypoint, virtualHocEntrypoint)}';
65
- ---
66
-
67
- <html lang="en">
68
- <head></head>
69
- <body>
70
- <div>
71
- <WrappedComponent client:only="react" />
72
- </div>
73
- </body>
74
- </html>
75
- `
76
- );
77
- }
78
- }
79
-
80
- function resolveEntry(
81
- component:
82
- | Component<'BackofficeExtensionWidget'>
83
- | Component<'BackofficeModal'>
84
- | Component<'BackofficePage'>
85
- ) {
86
- const entryName = match(component, {
87
- BackofficeExtensionWidget: () => 'widget.tsx',
88
- BackofficeModal: () => 'modal.tsx',
89
- BackofficePage: () => 'page.tsx',
90
- });
91
-
92
- return join(component.directory, entryName);
93
- }
@@ -1,73 +0,0 @@
1
- import { rm, writeFile } from 'node:fs/promises';
2
- import { join, resolve } from 'node:path';
3
- import { globby } from 'globby';
4
- import { outdent } from 'outdent';
5
- import type { Model } from '../types.js';
6
- import { toRelativePath } from './fs-utils.js';
7
- import { isValidServicePluginComponent } from './isValidServicePluginComponent.js';
8
-
9
- export async function writeVirtualServicePluginExtensionFiles(
10
- model: Model,
11
- codegenDir: string
12
- ): Promise<void> {
13
- const servicePluginComponents = model.components.filter(
14
- isValidServicePluginComponent
15
- );
16
-
17
- const existingFiles = await globby(`*.ts`, {
18
- cwd: codegenDir,
19
- onlyFiles: true,
20
- });
21
-
22
- for (const filename of existingFiles) {
23
- const hasMatchingSourceFile = servicePluginComponents.some(
24
- (component) => `${component.manifest.compId}.ts` === filename
25
- );
26
-
27
- if (hasMatchingSourceFile) {
28
- continue;
29
- }
30
-
31
- await rm(join(codegenDir, filename));
32
- }
33
-
34
- for (const component of servicePluginComponents) {
35
- const originalEntrypoint = resolve(component.directory, 'plugin.ts');
36
- const virtualEntrypoint = join(
37
- codegenDir,
38
- `${component.manifest.compId}.ts`
39
- );
40
-
41
- await writeFile(
42
- virtualEntrypoint,
43
- outdent`
44
- import type { APIRoute } from 'astro';
45
- import { AppStrategy, createClient } from '@wix/sdk';
46
- import { WIX_CLIENT_ID } from 'astro:env/client';
47
- import { WIX_CLIENT_PUBLIC_KEY, WIX_CLIENT_SECRET } from 'astro:env/server';
48
-
49
- const client = createClient({
50
- auth: AppStrategy({
51
- appId: WIX_CLIENT_ID,
52
- appSecret: WIX_CLIENT_SECRET,
53
- publicKey: WIX_CLIENT_PUBLIC_KEY,
54
- }),
55
- });
56
-
57
- const olderClient = globalThis.__wix_context__.client;
58
-
59
- client.enableContext('global');
60
-
61
- await import('${toRelativePath(virtualEntrypoint, originalEntrypoint)}');
62
-
63
- if (olderClient) {
64
- olderClient.enableContext('global');
65
- }
66
-
67
- export const ALL: APIRoute = async (context) => {
68
- return await client.servicePlugins.processRequest(context.request);
69
- };
70
- `
71
- );
72
- }
73
- }
@@ -1,72 +0,0 @@
1
- import { rm, writeFile } from 'node:fs/promises';
2
- import { join, resolve } from 'node:path';
3
- import { globby } from 'globby';
4
- import { outdent } from 'outdent';
5
- import type { Model } from '../types.js';
6
- import { toRelativePath } from './fs-utils.js';
7
- import { isValidWebhookComponent } from './isValidWebhookComponent.js';
8
-
9
- export async function writeVirtualWebhookExtensionFiles(
10
- model: Model,
11
- codegenDir: string
12
- ): Promise<void> {
13
- const webhookComponents = model.components.filter(isValidWebhookComponent);
14
-
15
- const existingFiles = await globby(`*.ts`, {
16
- cwd: codegenDir,
17
- onlyFiles: true,
18
- });
19
-
20
- for (const filename of existingFiles) {
21
- const hasMatchingSourceFile = webhookComponents.some(
22
- (component) => `${component.manifest.compId}.ts` === filename
23
- );
24
-
25
- if (hasMatchingSourceFile) {
26
- continue;
27
- }
28
-
29
- await rm(join(codegenDir, filename));
30
- }
31
-
32
- for (const component of webhookComponents) {
33
- const originalEntrypoint = resolve(component.directory, 'event.ts');
34
- const virtualEntrypoint = join(
35
- codegenDir,
36
- `${component.manifest.compId}.ts`
37
- );
38
-
39
- await writeFile(
40
- virtualEntrypoint,
41
- outdent`
42
- import type { APIRoute } from 'astro';
43
- import { AppStrategy, createClient } from '@wix/sdk';
44
- import { WIX_CLIENT_ID } from 'astro:env/client';
45
- import { WIX_CLIENT_PUBLIC_KEY, WIX_CLIENT_SECRET } from 'astro:env/server';
46
-
47
- const client = createClient({
48
- auth: AppStrategy({
49
- appId: WIX_CLIENT_ID,
50
- appSecret: WIX_CLIENT_SECRET,
51
- publicKey: WIX_CLIENT_PUBLIC_KEY,
52
- }),
53
- });
54
-
55
- const olderClient = globalThis.__wix_context__.client;
56
-
57
- client.enableContext('global');
58
-
59
- await import('${toRelativePath(virtualEntrypoint, originalEntrypoint)}');
60
-
61
- if (olderClient) {
62
- olderClient.enableContext('global');
63
- }
64
-
65
- export const ALL: APIRoute = async (context) => {
66
- await client.webhooks.processRequest(context.request);
67
- return new Response('OK');
68
- };
69
- `
70
- );
71
- }
72
- }
File without changes
File without changes