@wazobiatech/wazui 0.0.12 → 0.0.13
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/.env.sample +18 -18
- package/.env.test +5 -0
- package/CONVERSION_COMPLETE.md +87 -0
- package/ENVIRONMENT.md +230 -0
- package/NEXTJS_GUIDE.md +186 -0
- package/QUICK_START_ENV.md +0 -0
- package/USAGE_EXAMPLES.tsx +76 -0
- package/package.json +3 -10
- package/src/config/env.ts +8 -8
- package/src/config/next.ts +79 -0
- package/src/decorators/ApolloDecorator.tsx +1 -1
- package/src/decorators/DolosApolloDecorator.tsx +1 -1
- package/src/env.ts +48 -93
- package/src/hooks/useMercuryProjectToken.ts +3 -3
- package/src/hooks/useProjectToken.ts +2 -2
- package/src/index.ts +17 -1
- package/src/mocks/env.ts +9 -9
- package/src/providers/EnvironmentProvider/WazUIEnvironmentProvider.tsx +50 -0
- package/src/providers/EnvironmentProvider/context.ts +5 -0
- package/src/providers/EnvironmentProvider/index.ts +5 -0
- package/src/providers/EnvironmentProvider/useWazUIEnvironment.ts +20 -0
- package/src/providers/EnvironmentProvider/utils.ts +122 -0
- package/src/utils/apolloClient.ts +6 -6
- package/src/utils/images.ts +14 -7
- package/storybook-static/assets/ApolloDecorator-DdFdPk9I.js +1 -0
- package/storybook-static/assets/BlogCategoryContent-j1uDZXn7.js +97 -0
- package/storybook-static/assets/BlogCategoryContent.stories-qYKLjb6F.js +9 -0
- package/storybook-static/assets/BlogPostContentComponent-C2AFWOqJ.js +956 -0
- package/storybook-static/assets/BlogPostContentComponent.stories-ZsTapbYf.js +18 -0
- package/storybook-static/assets/BlogPostsComponent.stories-CcjjSusf.js +11 -0
- package/storybook-static/assets/BlogTagContent-BnwuQUSW.js +92 -0
- package/storybook-static/assets/BlogTagContent.stories-BdzlB1N5.js +9 -0
- package/storybook-static/assets/CategoriesComponent.stories-C4qc6J3o.js +7 -0
- package/storybook-static/assets/ClearCacheHistory.stories-BFGJ9Cpr.js +6 -0
- package/storybook-static/assets/Color-YHDXOIA2-uT_23_Qt.js +1 -0
- package/storybook-static/assets/DocsRenderer-CFRXHY34-PYIpRFNk.js +575 -0
- package/storybook-static/assets/DolosApolloDecorator-DEvkQjrM.js +1 -0
- package/storybook-static/assets/FeatureJungle-Light-CFEx0Apr.woff +0 -0
- package/storybook-static/assets/PictureBlot-Ce0f3E3l.js +2 -0
- package/storybook-static/assets/PurgeCache-6QorPr5P.js +5 -0
- package/storybook-static/assets/PurgeCache.stories-9MRRLCNG.js +13 -0
- package/storybook-static/assets/ReactQueryDecorator-CrsXrNQd.js +1 -0
- package/storybook-static/assets/RecipeCategories.stories--J_t5Kqe.js +7 -0
- package/storybook-static/assets/RecipeCategoryContent-PlykHail.js +139 -0
- package/storybook-static/assets/RecipeCategoryContent.stories-kGW7yk1Q.js +9 -0
- package/storybook-static/assets/RecipeContentComponent.stories-BQ8Uxx67.js +18 -0
- package/storybook-static/assets/RecipeTags.stories-C1FTvpsL.js +7 -0
- package/storybook-static/assets/RecipeTagsContent-DS00_2mK.js +18 -0
- package/storybook-static/assets/RecipeTagsContent.stories-BiMSQhz1.js +5 -0
- package/storybook-static/assets/RecipesComponent.stories-CHZ8K6cH.js +9 -0
- package/storybook-static/assets/RedirectContent-CmGN0ktq.js +96 -0
- package/storybook-static/assets/RedirectContent.stories-9_qkEHzb.js +5 -0
- package/storybook-static/assets/RedirectsComponent.stories-CTycXldt.js +8 -0
- package/storybook-static/assets/TagsComponent.stories-DSohzxP0.js +7 -0
- package/storybook-static/assets/TimeAgo-BMs3lst-.js +5 -0
- package/storybook-static/assets/UniversalJungle-420-mm6ugnAQ.woff +0 -0
- package/storybook-static/assets/WazUIBlogComponent.stories-CCXKbbai.js +86 -0
- package/storybook-static/assets/WazUIBlogDashboard-CtU7uRTr.js +162 -0
- package/storybook-static/assets/WazUIBlogDashboard.stories-CqTZ4exx.js +38 -0
- package/storybook-static/assets/WazUIButton.stories-CDWIbKyS.js +59 -0
- package/storybook-static/assets/WazUIDataTable-DnneDnRd.js +22 -0
- package/storybook-static/assets/WazUIPostActions-BZQom1Yt.js +16 -0
- package/storybook-static/assets/WazUiBreadCrumb-BPc3tEqC.js +1 -0
- package/storybook-static/assets/WazUiBreadCrumb.stories-_gNokkDn.js +7 -0
- package/storybook-static/assets/WazUiButton-e06gz3US.js +27 -0
- package/storybook-static/assets/WazUiCreateBlogContent-DxC86Nwl.js +327 -0
- package/storybook-static/assets/WazUiCreateBlogContent.stories-Bzq3YtfW.js +94 -0
- package/storybook-static/assets/WazUiCreateContentPopup.stories-D_9OExPO.js +41 -0
- package/storybook-static/assets/WazUiDataTable.stories-D1Aj3wPk.js +23 -0
- package/storybook-static/assets/WazUiGqlMediaLibrary.stories-Cug9TM1_.js +105 -0
- package/storybook-static/assets/WazUiGqlMediaLibraryPopup.stories-CuwWYcJs.js +53 -0
- package/storybook-static/assets/WazUiInputBox-C2jVcTq2.js +734 -0
- package/storybook-static/assets/WazUiInputBox.stories-Bs1Vb_Rd.js +270 -0
- package/storybook-static/assets/WazUiNavigationBlocker-BrhA3ONc.js +1 -0
- package/storybook-static/assets/WazUiNavigationBlocker.stories-CgqwQbJ9.js +6 -0
- package/storybook-static/assets/WazUiPostCard-bQlmiDOB.js +99 -0
- package/storybook-static/assets/WazUiPostCard.stories-Dir2IwY1.js +9 -0
- package/storybook-static/assets/WazUiWysiwygInput.stories-BDO7EAIa.js +170 -0
- package/storybook-static/assets/WazuiActionModal-Cgw_QqFv.js +11 -0
- package/storybook-static/assets/WazuiActionModal.stories-CFCFlfLU.js +5 -0
- package/storybook-static/assets/WazuiCreateContentPopup-CXVvIFOU.js +130 -0
- package/storybook-static/assets/WazuiImage-BwRWaPkA.js +58 -0
- package/storybook-static/assets/WazuiImage.stories-CxpLgpmg.js +48 -0
- package/storybook-static/assets/button-BxNLA_J_.js +1 -0
- package/storybook-static/assets/calendar-CorT5FcI.js +6 -0
- package/storybook-static/assets/chunk-XP5HYGXS-BpfKkqn7.js +1 -0
- package/storybook-static/assets/emerald-GdtolcHR.svg +9 -0
- package/storybook-static/assets/entry-preview-Chux9cpU.js +2 -0
- package/storybook-static/assets/entry-preview-docs-DviPOtIv.js +46 -0
- package/storybook-static/assets/env-B_s3Ell7.js +1 -0
- package/storybook-static/assets/gold-CtN6pOVZ.svg +9 -0
- package/storybook-static/assets/groups-GzRK9wBi.js +6 -0
- package/storybook-static/assets/hooks-D-wca2rG.js +1 -0
- package/storybook-static/assets/iconBase-B7i_G6Rg.js +1 -0
- package/storybook-static/assets/iframe-DarAeeHv.js +211 -0
- package/storybook-static/assets/index-BAoN7Cmi.js +240 -0
- package/storybook-static/assets/index-BJvHeDRT.js +1 -0
- package/storybook-static/assets/index-BR89vyis.js +6 -0
- package/storybook-static/assets/index-BWnBDfn-.js +9 -0
- package/storybook-static/assets/index-Bqat3xNk.js +1 -0
- package/storybook-static/assets/index-CBYaBgW8.js +9 -0
- package/storybook-static/assets/index-CZ4jztst.js +30 -0
- package/storybook-static/assets/index-CeH2RAp8.js +22 -0
- package/storybook-static/assets/index-DarTc5kA.js +1 -0
- package/storybook-static/assets/index-DgH-xKnr.js +11 -0
- package/storybook-static/assets/index-DrFu-skq.js +6 -0
- package/storybook-static/assets/instagram-DKTomRJ8.svg +9 -0
- package/storybook-static/assets/jsx-runtime-D_zvdyIk.js +9 -0
- package/storybook-static/assets/no-data-image-Bhn_PKhS.svg +41 -0
- package/storybook-static/assets/no-image-icon-CjrDvlv3.svg +84 -0
- package/storybook-static/assets/pexels-DrnxyPAE.svg +9 -0
- package/storybook-static/assets/popover-BB1qMQFg.js +76 -0
- package/storybook-static/assets/preview-B8lJiyuQ.js +34 -0
- package/storybook-static/assets/preview-BBWR9nbA.js +1 -0
- package/storybook-static/assets/preview-BWzBA1C2.js +396 -0
- package/storybook-static/assets/preview-BaoH-L4j.js +1 -0
- package/storybook-static/assets/preview-C-LZrIW4.js +2 -0
- package/storybook-static/assets/preview-CVgpLj3b.js +1 -0
- package/storybook-static/assets/preview-CvbIS5ZJ.js +1 -0
- package/storybook-static/assets/preview-DGUiP6tS.js +7 -0
- package/storybook-static/assets/preview-DMG083aW.js +240 -0
- package/storybook-static/assets/preview-DoyfkCKF.css +1 -0
- package/storybook-static/assets/preview-TWlugwTp.js +3 -0
- package/storybook-static/assets/provider-Bst_TvlW.js +1 -0
- package/storybook-static/assets/queries-9Km_qMSB.js +125 -0
- package/storybook-static/assets/queries-Bdq7cXa5.js +231 -0
- package/storybook-static/assets/queries-ClywsDTl.js +103 -0
- package/storybook-static/assets/quill-Dex9Y0nc.js +49 -0
- package/storybook-static/assets/react-18-DbMmlWnz.js +25 -0
- package/storybook-static/assets/sapphire-BO-7mqXy.svg +9 -0
- package/storybook-static/assets/test-utils-DxU8HTJE.js +9 -0
- package/storybook-static/assets/upload-image-BZPKKzIo.svg +43 -0
- package/storybook-static/assets/useMercuryProjectToken-BgbQUYG9.js +49 -0
- package/storybook-static/assets/users-ClnJTo4A.js +1 -0
- package/storybook-static/assets/utils-3HBFSLrk.js +2 -0
- package/storybook-static/assets/v4-CtRu48qb.js +1 -0
- package/storybook-static/favicon.svg +1 -0
- package/storybook-static/iframe.html +669 -0
- package/storybook-static/index.html +185 -0
- package/storybook-static/index.json +1 -0
- package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/project.json +1 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js +331 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js.LEGAL.txt +51 -0
- package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +12 -0
- package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js +405 -0
- package/storybook-static/sb-addons/essentials-docs-3/manager-bundle.js +245 -0
- package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/onboarding-9/manager-bundle.js +127 -0
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +3 -0
- package/storybook-static/sb-addons/storybook-experimental-addon-test-11/manager-bundle.js +223 -0
- package/storybook-static/sb-addons/themes-12/manager-bundle.js +3 -0
- package/storybook-static/sb-common-assets/favicon.svg +1 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/globals-module-info.js +1051 -0
- package/storybook-static/sb-manager/globals-runtime.js +41591 -0
- package/storybook-static/sb-manager/globals.js +48 -0
- package/storybook-static/sb-manager/runtime.js +12048 -0
- package/vite.config.ts +1 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Define the environment schema for Next.js apps
|
|
4
|
+
export const nextEnvSchema = z.object({
|
|
5
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT: z.string().default('https://localhost:3000/graphql'),
|
|
6
|
+
NEXT_PUBLIC_DOLOS_URL: z.string().default('https://localhost:3001'),
|
|
7
|
+
NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT: z.string().default('https://localhost:3001/transform'),
|
|
8
|
+
NEXT_PUBLIC_MUSE_TOKEN: z.string().default('dev-token'),
|
|
9
|
+
NEXT_PUBLIC_MUSE_ENDPOINT: z.string().default('https://localhost:3003'),
|
|
10
|
+
NEXT_PUBLIC_RECIPES_ENDPOINT: z.string().default('https://localhost:3002'),
|
|
11
|
+
NEXT_PUBLIC_PHOENIX_ENDPOINT: z.string().default('https://localhost:3004'),
|
|
12
|
+
NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT: z.string().default('https://localhost:3005/token'),
|
|
13
|
+
NEXT_PUBLIC_ATHENS_APP_ID: z.string().default('dev-athens-id'),
|
|
14
|
+
NEXT_PUBLIC_ATHENS_APP_SECRET: z.string().default('dev-athens-secret'),
|
|
15
|
+
NEXT_PUBLIC_PROJECT_TOKEN: z.string().default('dev-project-token'),
|
|
16
|
+
NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN: z.string().default('dev-revalidation-token'),
|
|
17
|
+
NEXT_PUBLIC_REVALIDATION_VT_TOKEN: z.string().default('dev-vt-token'),
|
|
18
|
+
NEXT_PUBLIC_GRAPH_QL_URL: z.string().optional(),
|
|
19
|
+
NEXT_PUBLIC_MUSE_GRAPHQL_URL: z.string().optional(),
|
|
20
|
+
NEXT_PUBLIC_RECIPE_GRAPHQL_URL: z.string().optional(),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type NextEnv = z.infer<typeof nextEnvSchema>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Next.js-specific environment configuration
|
|
27
|
+
* This function automatically reads from Next.js environment variables
|
|
28
|
+
*/
|
|
29
|
+
export function createNextConfig(): NextEnv {
|
|
30
|
+
const env = {
|
|
31
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT: process.env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT,
|
|
32
|
+
NEXT_PUBLIC_DOLOS_URL: process.env.NEXT_PUBLIC_DOLOS_URL,
|
|
33
|
+
NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT: process.env.NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT,
|
|
34
|
+
NEXT_PUBLIC_MUSE_TOKEN: process.env.NEXT_PUBLIC_MUSE_TOKEN,
|
|
35
|
+
NEXT_PUBLIC_MUSE_ENDPOINT: process.env.NEXT_PUBLIC_MUSE_ENDPOINT,
|
|
36
|
+
NEXT_PUBLIC_RECIPES_ENDPOINT: process.env.NEXT_PUBLIC_RECIPES_ENDPOINT,
|
|
37
|
+
NEXT_PUBLIC_PHOENIX_ENDPOINT: process.env.NEXT_PUBLIC_PHOENIX_ENDPOINT,
|
|
38
|
+
NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT: process.env.NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT,
|
|
39
|
+
NEXT_PUBLIC_ATHENS_APP_ID: process.env.NEXT_PUBLIC_ATHENS_APP_ID,
|
|
40
|
+
NEXT_PUBLIC_ATHENS_APP_SECRET: process.env.NEXT_PUBLIC_ATHENS_APP_SECRET,
|
|
41
|
+
NEXT_PUBLIC_PROJECT_TOKEN: process.env.NEXT_PUBLIC_PROJECT_TOKEN,
|
|
42
|
+
NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN: process.env.NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN,
|
|
43
|
+
NEXT_PUBLIC_REVALIDATION_VT_TOKEN: process.env.NEXT_PUBLIC_REVALIDATION_VT_TOKEN,
|
|
44
|
+
NEXT_PUBLIC_GRAPH_QL_URL: process.env.NEXT_PUBLIC_GRAPH_QL_URL,
|
|
45
|
+
NEXT_PUBLIC_MUSE_GRAPHQL_URL: process.env.NEXT_PUBLIC_MUSE_GRAPHQL_URL,
|
|
46
|
+
NEXT_PUBLIC_RECIPE_GRAPHQL_URL: process.env.NEXT_PUBLIC_RECIPE_GRAPHQL_URL,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return nextEnvSchema.parse(env);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Debug helper to check Next.js environment variables
|
|
54
|
+
*/
|
|
55
|
+
export function debugNextConfig() {
|
|
56
|
+
if (process.env.NODE_ENV !== 'development') return;
|
|
57
|
+
|
|
58
|
+
console.group('🔧 Next.js WazUI Configuration Debug');
|
|
59
|
+
|
|
60
|
+
const requiredVars = [
|
|
61
|
+
'NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT',
|
|
62
|
+
'NEXT_PUBLIC_DOLOS_URL',
|
|
63
|
+
'NEXT_PUBLIC_MUSE_TOKEN',
|
|
64
|
+
'NEXT_PUBLIC_MUSE_ENDPOINT',
|
|
65
|
+
'NEXT_PUBLIC_RECIPES_ENDPOINT',
|
|
66
|
+
'NEXT_PUBLIC_PHOENIX_ENDPOINT',
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
requiredVars.forEach(varName => {
|
|
70
|
+
const value = process.env[varName];
|
|
71
|
+
if (value) {
|
|
72
|
+
console.log(`✅ ${varName}:`, value.substring(0, 50) + (value.length > 50 ? '...' : ''));
|
|
73
|
+
} else {
|
|
74
|
+
console.warn(`❌ ${varName}: undefined (will use default)`);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
console.groupEnd();
|
|
79
|
+
}
|
|
@@ -9,7 +9,7 @@ export const withApollo: Decorator = (Story, context) => {
|
|
|
9
9
|
return (
|
|
10
10
|
// use muse endpoint as default
|
|
11
11
|
|
|
12
|
-
<ApolloProvider client={createApolloClient(apolloConfig?.uri || env.
|
|
12
|
+
<ApolloProvider client={createApolloClient(apolloConfig?.uri || env.NEXT_PUBLIC_MUSE_ENDPOINT)}>
|
|
13
13
|
<Story />
|
|
14
14
|
<script src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js'></script>
|
|
15
15
|
<script src='https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.js'></script>
|
|
@@ -9,7 +9,7 @@ import { env } from '../env';
|
|
|
9
9
|
|
|
10
10
|
export const dolosApolloClient = new ApolloClient({
|
|
11
11
|
cache: new InMemoryCache(),
|
|
12
|
-
link: new UploadHttpLink({ uri: env.
|
|
12
|
+
link: new UploadHttpLink({ uri: env.NEXT_PUBLIC_DOLOS_URL }),
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
export const withDolosApollo: Decorator = Story => {
|
package/src/env.ts
CHANGED
|
@@ -1,99 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const isViteEnvironment = typeof import.meta !== 'undefined' && (import.meta as unknown as { env: Record<string, string | undefined> }).env;
|
|
25
|
-
const isNextEnvironment = typeof process !== 'undefined' && process.env;
|
|
26
|
-
|
|
27
|
-
if (process.env.NODE_ENV === 'test') {
|
|
1
|
+
import { createNextConfig, debugNextConfig, NextEnv } from './config/next';
|
|
2
|
+
|
|
3
|
+
// Re-export types for convenience
|
|
4
|
+
export type { NextEnv } from './config/next';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get environment variables for WazUI components in Next.js
|
|
8
|
+
* This function automatically reads from your Next.js environment variables
|
|
9
|
+
*/
|
|
10
|
+
export const getEnv = (): NextEnv => {
|
|
11
|
+
try {
|
|
12
|
+
const config = createNextConfig();
|
|
13
|
+
|
|
14
|
+
// Debug in development
|
|
15
|
+
if (process.env.NODE_ENV === 'development') {
|
|
16
|
+
debugNextConfig();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return config;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error('WazUI: Failed to load environment configuration:', error);
|
|
22
|
+
|
|
23
|
+
// Return defaults if parsing fails
|
|
28
24
|
return {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
VITE_REVALIDATION_VT_TOKEN: process.env.VITE_REVALIDATION_VT_TOKEN ?? 'fallback-token',
|
|
43
|
-
VITE_GRAPH_QL_URL: process.env.VITE_GRAPH_QL_URL ?? '',
|
|
44
|
-
VITE_MUSE_GRAPHQL_URL: process.env.VITE_MUSE_GRAPHQL_URL ?? '',
|
|
45
|
-
VITE_RECIPE_GRAPHQL_URL: process.env.VITE_RECIPE_GRAPHQL_URL ?? '',
|
|
25
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT: 'https://localhost:3000/graphql',
|
|
26
|
+
NEXT_PUBLIC_DOLOS_URL: 'https://localhost:3001',
|
|
27
|
+
NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT: 'https://localhost:3001/transform',
|
|
28
|
+
NEXT_PUBLIC_MUSE_TOKEN: 'dev-token',
|
|
29
|
+
NEXT_PUBLIC_MUSE_ENDPOINT: 'https://localhost:3003',
|
|
30
|
+
NEXT_PUBLIC_RECIPES_ENDPOINT: 'https://localhost:3002',
|
|
31
|
+
NEXT_PUBLIC_PHOENIX_ENDPOINT: 'https://localhost:3004',
|
|
32
|
+
NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT: 'https://localhost:3005/token',
|
|
33
|
+
NEXT_PUBLIC_ATHENS_APP_ID: 'dev-athens-id',
|
|
34
|
+
NEXT_PUBLIC_ATHENS_APP_SECRET: 'dev-athens-secret',
|
|
35
|
+
NEXT_PUBLIC_PROJECT_TOKEN: 'dev-project-token',
|
|
36
|
+
NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN: 'dev-revalidation-token',
|
|
37
|
+
NEXT_PUBLIC_REVALIDATION_VT_TOKEN: 'dev-vt-token',
|
|
46
38
|
};
|
|
47
39
|
}
|
|
48
|
-
|
|
49
|
-
let envSource: Record<string, string | undefined> = {};
|
|
50
|
-
|
|
51
|
-
if (isViteEnvironment) {
|
|
52
|
-
// Use Vite's import.meta.env
|
|
53
|
-
envSource = (import.meta as unknown as { env: Record<string, string | undefined> }).env;
|
|
54
|
-
} else if (isNextEnvironment) {
|
|
55
|
-
envSource = {
|
|
56
|
-
VITE_PORTAL_GRAPHQL_ENDPOINT: process.env.NEXT_PUBLIC_GRAPHQL_URL,
|
|
57
|
-
VITE_DOLOS_URL: process.env.NEXT_PUBLIC_DOLOS_URL,
|
|
58
|
-
VITE_DOLOS_TRANSFORMATION_ENDPOINT: process.env.NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT,
|
|
59
|
-
VITE_MUSE_TOKEN: process.env.NEXT_PUBLIC_MUSE_TOKEN,
|
|
60
|
-
VITE_MUSE_ENDPOINT: process.env.NEXT_PUBLIC_MUSE_GRAPHQL_URL,
|
|
61
|
-
VITE_RECIPES_ENDPOINT: process.env.NEXT_PUBLIC_RECIPE_GRAPHQL_URL,
|
|
62
|
-
VITE_PHOENIX_ENDPOINT: process.env.NEXT_PUBLIC_PHOENIX_ENDPOINT,
|
|
63
|
-
VITE_MERCURY_TOKEN_ENDPOINT: process.env.NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT,
|
|
64
|
-
VITE_ATHENS_APP_ID: process.env.NEXT_PUBLIC_ATHENS_APP_ID,
|
|
65
|
-
VITE_ATHENS_APP_SECRET: process.env.NEXT_PUBLIC_ATHENS_APP_SECRET,
|
|
66
|
-
VITE_PROJECT_TOKEN: process.env.NEXT_PUBLIC_PROJECT_TOKEN,
|
|
67
|
-
VITE_REVALIDATION_TWISTEDFOOD_TOKEN: process.env.NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN,
|
|
68
|
-
VITE_REVALIDATION_VT_TOKEN: process.env.NEXT_PUBLIC_REVALIDATION_VT_TOKEN,
|
|
69
|
-
VITE_GRAPH_QL_URL: process.env.NEXT_PUBLIC_GRAPH_QL_URL,
|
|
70
|
-
VITE_MUSE_GRAPHQL_URL: process.env.NEXT_PUBLIC_MUSE_GRAPHQL_URL,
|
|
71
|
-
VITE_RECIPE_GRAPHQL_URL: process.env.NEXT_PUBLIC_RECIPE_GRAPHQL_URL,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
VITE_PORTAL_GRAPHQL_ENDPOINT: envSource.VITE_PORTAL_GRAPHQL_ENDPOINT,
|
|
77
|
-
VITE_DOLOS_URL: envSource.VITE_DOLOS_URL,
|
|
78
|
-
VITE_DOLOS_TRANSFORMATION_ENDPOINT: envSource.VITE_DOLOS_TRANSFORMATION_ENDPOINT,
|
|
79
|
-
VITE_MUSE_TOKEN: envSource.VITE_MUSE_TOKEN,
|
|
80
|
-
VITE_MUSE_ENDPOINT: envSource.VITE_MUSE_ENDPOINT,
|
|
81
|
-
VITE_RECIPES_ENDPOINT: envSource.VITE_RECIPES_ENDPOINT,
|
|
82
|
-
VITE_PHOENIX_ENDPOINT: envSource.VITE_PHOENIX_ENDPOINT,
|
|
83
|
-
VITE_MERCURY_TOKEN_ENDPOINT: envSource.VITE_MERCURY_TOKEN_ENDPOINT,
|
|
84
|
-
VITE_ATHENS_APP_ID: envSource.VITE_ATHENS_APP_ID,
|
|
85
|
-
VITE_ATHENS_APP_SECRET: envSource.VITE_ATHENS_APP_SECRET,
|
|
86
|
-
VITE_PROJECT_TOKEN: envSource.VITE_PROJECT_TOKEN,
|
|
87
|
-
VITE_REVALIDATION_TWISTEDFOOD_TOKEN: envSource.VITE_REVALIDATION_TWISTEDFOOD_TOKEN,
|
|
88
|
-
VITE_REVALIDATION_VT_TOKEN: envSource.VITE_REVALIDATION_VT_TOKEN,
|
|
89
|
-
VITE_GRAPH_QL_URL: envSource.VITE_GRAPH_QL_URL,
|
|
90
|
-
VITE_MUSE_GRAPHQL_URL: envSource.VITE_MUSE_GRAPHQL_URL,
|
|
91
|
-
VITE_RECIPE_GRAPHQL_URL: envSource.VITE_RECIPE_GRAPHQL_URL,
|
|
92
|
-
};
|
|
93
40
|
};
|
|
94
41
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
42
|
+
// For ease of use, also export a static env object
|
|
43
|
+
let _env: NextEnv | null = null;
|
|
44
|
+
|
|
45
|
+
export const env = new Proxy({} as NextEnv, {
|
|
46
|
+
get(target, prop) {
|
|
47
|
+
if (!_env) {
|
|
48
|
+
_env = getEnv();
|
|
49
|
+
}
|
|
50
|
+
return _env[prop as keyof typeof _env];
|
|
51
|
+
},
|
|
52
|
+
});
|
|
98
53
|
|
|
99
|
-
export type Env =
|
|
54
|
+
export type Env = NextEnv;
|
|
@@ -82,9 +82,9 @@ let tokenManagerInstance: TokenManager | null = null;
|
|
|
82
82
|
function getTokenManager(): TokenManager {
|
|
83
83
|
if (!tokenManagerInstance) {
|
|
84
84
|
tokenManagerInstance = new TokenManager(
|
|
85
|
-
env.
|
|
86
|
-
env.
|
|
87
|
-
env.
|
|
85
|
+
env.NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT,
|
|
86
|
+
env.NEXT_PUBLIC_ATHENS_APP_ID,
|
|
87
|
+
env.NEXT_PUBLIC_ATHENS_APP_SECRET
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
90
|
return tokenManagerInstance;
|
|
@@ -11,11 +11,11 @@ export function useProjectToken() {
|
|
|
11
11
|
gcTime: 50 * 60000, // Data stays fresh for 50 minutes
|
|
12
12
|
queryFn: async () => {
|
|
13
13
|
// This would be replaced with actual project token fetching logic
|
|
14
|
-
const projectToken = import.meta.env.
|
|
14
|
+
const projectToken = import.meta.env.NEXT_PUBLIC_PROJECT_TOKEN;
|
|
15
15
|
if (!projectToken) {
|
|
16
16
|
throw new Error('Project token not configured');
|
|
17
17
|
}
|
|
18
18
|
return projectToken;
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
|
-
}
|
|
21
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// Import styles
|
|
2
4
|
import './index.css';
|
|
3
5
|
|
|
@@ -100,5 +102,19 @@ export type {
|
|
|
100
102
|
} from './components/wazui/WazUIBlogDashboard/types';
|
|
101
103
|
export { useAuthors } from './hooks/useAuthors';
|
|
102
104
|
export * from '@tanstack/react-table';
|
|
103
|
-
|
|
105
|
+
// Note: Zod is not re-exported to avoid 'enum' keyword conflicts in strict mode
|
|
106
|
+
// Import Zod directly in your application if needed: import { z } from 'zod'
|
|
104
107
|
export { fetchMercuryToken } from './hooks/useMercuryProjectToken';
|
|
108
|
+
|
|
109
|
+
// Next.js environment configuration
|
|
110
|
+
export { env, getEnv } from './env';
|
|
111
|
+
export { createNextConfig, debugNextConfig } from './config/next';
|
|
112
|
+
export type { NextEnv, Env } from './env';
|
|
113
|
+
|
|
114
|
+
// Environment provider system for advanced use cases
|
|
115
|
+
export {
|
|
116
|
+
WazUIEnvironmentProvider,
|
|
117
|
+
useWazUIEnvironment,
|
|
118
|
+
getAutoDetectedEnvironment,
|
|
119
|
+
} from './providers/EnvironmentProvider';
|
|
120
|
+
export type { WazUIEnvironmentProviderProps, WazUIEnv } from './providers/EnvironmentProvider';
|
package/src/mocks/env.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Mock for env.ts to avoid import.meta issues in Jest
|
|
2
2
|
export const env = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT: 'https://test.example.com',
|
|
4
|
+
NEXT_PUBLIC_DOLOS_URL: 'https://test.example.com',
|
|
5
|
+
NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT: 'https://test.example.com',
|
|
6
|
+
NEXT_PUBLIC_MUSE_TOKEN: 'test-token',
|
|
7
|
+
NEXT_PUBLIC_MUSE_ENDPOINT: 'https://test.example.com',
|
|
8
|
+
NEXT_PUBLIC_REVALIDATION_WAZOBIA_TOKEN: 'test-token',
|
|
9
|
+
NEXT_PUBLIC_REVALIDATION_DRIPLONDON_TOKEN: 'test-token',
|
|
10
|
+
NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN: 'test-token',
|
|
11
|
+
NEXT_PUBLIC_REVALIDATION_VT_TOKEN: 'test-token',
|
|
12
12
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { WazUIEnv, envSchema, getAutoDetectedEnvironment } from './utils';
|
|
3
|
+
import { WazUIEnvironmentContext } from './context';
|
|
4
|
+
|
|
5
|
+
export interface WazUIEnvironmentProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
env?: Partial<WazUIEnv>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* WazUIEnvironmentProvider allows Next.js apps to inject environment variables
|
|
12
|
+
* directly into WazUI components. This ensures that environment variables from
|
|
13
|
+
* your Next.js app are properly propagated to the component library.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* // In your Next.js app root (pages/_app.tsx or app/layout.tsx)
|
|
18
|
+
* import { WazUIEnvironmentProvider } from '@wazobiatech/wazui';
|
|
19
|
+
*
|
|
20
|
+
* const env = {
|
|
21
|
+
* NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT: process.env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT,
|
|
22
|
+
* NEXT_PUBLIC_DOLOS_URL: process.env.NEXT_PUBLIC_DOLOS_URL,
|
|
23
|
+
* // ... other environment variables
|
|
24
|
+
* };
|
|
25
|
+
*
|
|
26
|
+
* function MyApp({ Component, pageProps }) {
|
|
27
|
+
* return (
|
|
28
|
+
* <WazUIEnvironmentProvider env={env}>
|
|
29
|
+
* <Component {...pageProps} />
|
|
30
|
+
* </WazUIEnvironmentProvider>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export function WazUIEnvironmentProvider({
|
|
36
|
+
children,
|
|
37
|
+
env: providedEnv,
|
|
38
|
+
}: WazUIEnvironmentProviderProps) {
|
|
39
|
+
// Auto-detect environment variables if not provided
|
|
40
|
+
const detectedEnv = providedEnv || getAutoDetectedEnvironment();
|
|
41
|
+
|
|
42
|
+
// Parse and validate environment variables
|
|
43
|
+
const validatedEnv = envSchema.parse(detectedEnv);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<WazUIEnvironmentContext.Provider value={validatedEnv}>
|
|
47
|
+
{children}
|
|
48
|
+
</WazUIEnvironmentContext.Provider>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { WazUIEnvironmentProvider } from './WazUIEnvironmentProvider';
|
|
2
|
+
export type { WazUIEnvironmentProviderProps } from './WazUIEnvironmentProvider';
|
|
3
|
+
export { useWazUIEnvironment } from './useWazUIEnvironment';
|
|
4
|
+
export type { WazUIEnv } from './utils';
|
|
5
|
+
export { getAutoDetectedEnvironment } from './utils';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { WazUIEnvironmentContext } from './context';
|
|
3
|
+
import { WazUIEnv, envSchema, getAutoDetectedEnvironment } from './utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hook to access WazUI environment variables from within components.
|
|
7
|
+
* This hook will first try to get environment variables from the context
|
|
8
|
+
* (if WazUIEnvironmentProvider is used), then fall back to auto-detection.
|
|
9
|
+
*/
|
|
10
|
+
export function useWazUIEnvironment(): WazUIEnv {
|
|
11
|
+
const contextEnv = useContext(WazUIEnvironmentContext);
|
|
12
|
+
|
|
13
|
+
if (contextEnv) {
|
|
14
|
+
return contextEnv;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Fallback to auto-detection if no provider is used
|
|
18
|
+
const autoDetectedEnv = getAutoDetectedEnvironment();
|
|
19
|
+
return envSchema.parse(autoDetectedEnv);
|
|
20
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const envSchema = z.object({
|
|
4
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT: z.string().default('https://localhost:3000/graphql'),
|
|
5
|
+
NEXT_PUBLIC_DOLOS_URL: z.string().default('https://localhost:3001'),
|
|
6
|
+
NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT: z.string().default('https://localhost:3001/transform'),
|
|
7
|
+
NEXT_PUBLIC_MUSE_TOKEN: z.string().default('dev-token'),
|
|
8
|
+
NEXT_PUBLIC_MUSE_ENDPOINT: z.string().default('https://localhost:3003'),
|
|
9
|
+
NEXT_PUBLIC_RECIPES_ENDPOINT: z.string().default('https://localhost:3002'),
|
|
10
|
+
NEXT_PUBLIC_PHOENIX_ENDPOINT: z.string().default('https://localhost:3004'),
|
|
11
|
+
NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT: z.string().default('https://localhost:3005/token'),
|
|
12
|
+
NEXT_PUBLIC_ATHENS_APP_ID: z.string().default('dev-athens-id'),
|
|
13
|
+
NEXT_PUBLIC_ATHENS_APP_SECRET: z.string().default('dev-athens-secret'),
|
|
14
|
+
NEXT_PUBLIC_PROJECT_TOKEN: z.string().default('dev-project-token'),
|
|
15
|
+
NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN: z.string().default('dev-revalidation-token'),
|
|
16
|
+
NEXT_PUBLIC_REVALIDATION_VT_TOKEN: z.string().default('dev-vt-token'),
|
|
17
|
+
NEXT_PUBLIC_GRAPH_QL_URL: z.string().optional(),
|
|
18
|
+
NEXT_PUBLIC_MUSE_GRAPHQL_URL: z.string().optional(),
|
|
19
|
+
NEXT_PUBLIC_RECIPE_GRAPHQL_URL: z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type WazUIEnv = z.infer<typeof envSchema>;
|
|
23
|
+
|
|
24
|
+
// Type definitions for browser globals
|
|
25
|
+
interface WindowWithNextData extends Window {
|
|
26
|
+
__NEXT_DATA__?: {
|
|
27
|
+
env?: Record<string, string | undefined>;
|
|
28
|
+
runtimeConfig?: Record<string, string | undefined>;
|
|
29
|
+
};
|
|
30
|
+
process?: {
|
|
31
|
+
env?: Record<string, string | undefined>;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Auto-detect environment variables from various sources
|
|
37
|
+
*/
|
|
38
|
+
export function getAutoDetectedEnvironment(): Partial<WazUIEnv> {
|
|
39
|
+
// Check for browser environment (client-side Next.js)
|
|
40
|
+
const isBrowser = typeof window !== 'undefined';
|
|
41
|
+
|
|
42
|
+
// In test environment, use fallback values
|
|
43
|
+
if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'test') {
|
|
44
|
+
return {
|
|
45
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT:
|
|
46
|
+
process.env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT || 'https://fallback.test',
|
|
47
|
+
NEXT_PUBLIC_DOLOS_URL: process.env.NEXT_PUBLIC_DOLOS_URL || 'https://fallback.test',
|
|
48
|
+
NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT:
|
|
49
|
+
process.env.NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT || 'https://fallback.test',
|
|
50
|
+
NEXT_PUBLIC_MUSE_TOKEN: process.env.NEXT_PUBLIC_MUSE_TOKEN || 'fallback-token',
|
|
51
|
+
NEXT_PUBLIC_MUSE_ENDPOINT: process.env.NEXT_PUBLIC_MUSE_ENDPOINT || 'https://fallback.test',
|
|
52
|
+
NEXT_PUBLIC_RECIPES_ENDPOINT:
|
|
53
|
+
process.env.NEXT_PUBLIC_RECIPES_ENDPOINT || 'https://fallback.test',
|
|
54
|
+
NEXT_PUBLIC_PHOENIX_ENDPOINT:
|
|
55
|
+
process.env.NEXT_PUBLIC_PHOENIX_ENDPOINT || 'https://fallback.test',
|
|
56
|
+
NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT:
|
|
57
|
+
process.env.NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT || 'https://fallback.test',
|
|
58
|
+
NEXT_PUBLIC_ATHENS_APP_ID: process.env.NEXT_PUBLIC_ATHENS_APP_ID || 'fallback-id',
|
|
59
|
+
NEXT_PUBLIC_ATHENS_APP_SECRET: process.env.NEXT_PUBLIC_ATHENS_APP_SECRET || 'fallback-secret',
|
|
60
|
+
NEXT_PUBLIC_PROJECT_TOKEN: process.env.NEXT_PUBLIC_PROJECT_TOKEN || 'fallback-token',
|
|
61
|
+
NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN:
|
|
62
|
+
process.env.NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN || 'fallback-token',
|
|
63
|
+
NEXT_PUBLIC_REVALIDATION_VT_TOKEN:
|
|
64
|
+
process.env.NEXT_PUBLIC_REVALIDATION_VT_TOKEN || 'fallback-token',
|
|
65
|
+
NEXT_PUBLIC_GRAPH_QL_URL: process.env.NEXT_PUBLIC_GRAPH_QL_URL || '',
|
|
66
|
+
NEXT_PUBLIC_MUSE_GRAPHQL_URL: process.env.NEXT_PUBLIC_MUSE_GRAPHQL_URL || '',
|
|
67
|
+
NEXT_PUBLIC_RECIPE_GRAPHQL_URL: process.env.NEXT_PUBLIC_RECIPE_GRAPHQL_URL || '',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Try to get environment variables from different sources
|
|
72
|
+
let envSource: Record<string, string | undefined> = {};
|
|
73
|
+
|
|
74
|
+
// Check if we're in a Vite environment (for Storybook or standalone usage)
|
|
75
|
+
if (
|
|
76
|
+
typeof import.meta !== 'undefined' &&
|
|
77
|
+
(import.meta as unknown as { env?: Record<string, string | undefined> }).env
|
|
78
|
+
) {
|
|
79
|
+
envSource = (import.meta as unknown as { env: Record<string, string | undefined> }).env;
|
|
80
|
+
}
|
|
81
|
+
// Check if we're in a Node.js/Next.js environment
|
|
82
|
+
else if (typeof process !== 'undefined' && process.env) {
|
|
83
|
+
// In browser with Next.js, environment variables are available via process.env
|
|
84
|
+
// In server-side Next.js, they're also available via process.env
|
|
85
|
+
envSource = process.env;
|
|
86
|
+
}
|
|
87
|
+
// Fallback for browser environment where process might not be available
|
|
88
|
+
else if (isBrowser && typeof window !== 'undefined') {
|
|
89
|
+
const windowWithNext = window as WindowWithNextData;
|
|
90
|
+
|
|
91
|
+
// Try to access Next.js injected environment variables via __NEXT_DATA__
|
|
92
|
+
if (windowWithNext.__NEXT_DATA__?.env) {
|
|
93
|
+
envSource = windowWithNext.__NEXT_DATA__.env;
|
|
94
|
+
} else if (windowWithNext.__NEXT_DATA__?.runtimeConfig) {
|
|
95
|
+
// Try to access Next.js runtime config
|
|
96
|
+
envSource = windowWithNext.__NEXT_DATA__.runtimeConfig;
|
|
97
|
+
} else if (windowWithNext.process?.env) {
|
|
98
|
+
// Final fallback - try to access global process.env (if injected by Next.js)
|
|
99
|
+
envSource = windowWithNext.process.env;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT: envSource.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT,
|
|
105
|
+
NEXT_PUBLIC_DOLOS_URL: envSource.NEXT_PUBLIC_DOLOS_URL,
|
|
106
|
+
NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT: envSource.NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT,
|
|
107
|
+
NEXT_PUBLIC_MUSE_TOKEN: envSource.NEXT_PUBLIC_MUSE_TOKEN,
|
|
108
|
+
NEXT_PUBLIC_MUSE_ENDPOINT: envSource.NEXT_PUBLIC_MUSE_ENDPOINT,
|
|
109
|
+
NEXT_PUBLIC_RECIPES_ENDPOINT: envSource.NEXT_PUBLIC_RECIPES_ENDPOINT,
|
|
110
|
+
NEXT_PUBLIC_PHOENIX_ENDPOINT: envSource.NEXT_PUBLIC_PHOENIX_ENDPOINT,
|
|
111
|
+
NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT: envSource.NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT,
|
|
112
|
+
NEXT_PUBLIC_ATHENS_APP_ID: envSource.NEXT_PUBLIC_ATHENS_APP_ID,
|
|
113
|
+
NEXT_PUBLIC_ATHENS_APP_SECRET: envSource.NEXT_PUBLIC_ATHENS_APP_SECRET,
|
|
114
|
+
NEXT_PUBLIC_PROJECT_TOKEN: envSource.NEXT_PUBLIC_PROJECT_TOKEN,
|
|
115
|
+
NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN:
|
|
116
|
+
envSource.NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN,
|
|
117
|
+
NEXT_PUBLIC_REVALIDATION_VT_TOKEN: envSource.NEXT_PUBLIC_REVALIDATION_VT_TOKEN,
|
|
118
|
+
NEXT_PUBLIC_GRAPH_QL_URL: envSource.NEXT_PUBLIC_GRAPH_QL_URL,
|
|
119
|
+
NEXT_PUBLIC_MUSE_GRAPHQL_URL: envSource.NEXT_PUBLIC_MUSE_GRAPHQL_URL,
|
|
120
|
+
NEXT_PUBLIC_RECIPE_GRAPHQL_URL: envSource.NEXT_PUBLIC_RECIPE_GRAPHQL_URL,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -49,7 +49,7 @@ export const createApolloClient = (
|
|
|
49
49
|
const isMuseClient = options?.isMuseClient;
|
|
50
50
|
|
|
51
51
|
const defaultHeaders = {
|
|
52
|
-
// 'X-Internal-Auth': env.
|
|
52
|
+
// 'X-Internal-Auth': env.NEXT_PUBLIC_MUSE_TOKEN as string,
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
const headers = options?.headers ? { ...defaultHeaders, ...options.headers } : defaultHeaders;
|
|
@@ -105,7 +105,7 @@ export const createApolloUploadClient = (
|
|
|
105
105
|
}
|
|
106
106
|
) => {
|
|
107
107
|
const defaultHeaders = {
|
|
108
|
-
'X-Internal-Auth': env.
|
|
108
|
+
'X-Internal-Auth': env.NEXT_PUBLIC_MUSE_TOKEN as string,
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
const headers = options?.headers ? { ...defaultHeaders, ...options.headers } : defaultHeaders;
|
|
@@ -145,16 +145,16 @@ export const createApolloUploadClient = (
|
|
|
145
145
|
return client;
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
export const blogClient = createApolloClient(env.
|
|
148
|
+
export const blogClient = createApolloClient(env.NEXT_PUBLIC_GRAPH_QL_URL as string, {
|
|
149
149
|
isMuseClient: true,
|
|
150
150
|
});
|
|
151
151
|
|
|
152
|
-
export const blogClientNew = createApolloClient(env.
|
|
152
|
+
export const blogClientNew = createApolloClient(env.NEXT_PUBLIC_MUSE_GRAPHQL_URL as string, {
|
|
153
153
|
isMuseClient: true,
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
export const museClient = createApolloClient(env.
|
|
156
|
+
export const museClient = createApolloClient(env.NEXT_PUBLIC_MUSE_GRAPHQL_URL as string, {
|
|
157
157
|
isMuseClient: true,
|
|
158
158
|
});
|
|
159
159
|
|
|
160
|
-
export const recipeClient = createApolloClient(env.
|
|
160
|
+
export const recipeClient = createApolloClient(env.NEXT_PUBLIC_RECIPE_GRAPHQL_URL as string);
|
package/src/utils/images.ts
CHANGED
|
@@ -163,22 +163,29 @@ export const getImageTransformationsUrl = ({
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
const trimmedUrl = url.trim();
|
|
166
|
-
if (
|
|
167
|
-
|
|
166
|
+
if (
|
|
167
|
+
!trimmedUrl.startsWith('http://') &&
|
|
168
|
+
!trimmedUrl.startsWith('https://') &&
|
|
169
|
+
!trimmedUrl.startsWith('/')
|
|
170
|
+
) {
|
|
171
|
+
console.warn(
|
|
172
|
+
'getImageTransformationsUrl: URL must be absolute (http/https) or relative path:',
|
|
173
|
+
url
|
|
174
|
+
);
|
|
168
175
|
return { url: '', srcset: '', desktop: '', tablet: '', mobile: '' };
|
|
169
176
|
}
|
|
170
177
|
|
|
171
178
|
try {
|
|
172
|
-
const parsedUrl = trimmedUrl.startsWith('/')
|
|
173
|
-
? new URL(trimmedUrl, 'https://placeholder.com')
|
|
179
|
+
const parsedUrl = trimmedUrl.startsWith('/')
|
|
180
|
+
? new URL(trimmedUrl, 'https://placeholder.com')
|
|
174
181
|
: new URL(trimmedUrl);
|
|
175
182
|
const config = parsedUrl.searchParams.get('config') || '';
|
|
176
183
|
|
|
177
184
|
// Build base transformation URL
|
|
178
185
|
const imageTransformUrl =
|
|
179
|
-
transformationsUrl || (env.
|
|
180
|
-
|
|
181
|
-
const baseImageUrl = shouldSkipHostname
|
|
186
|
+
transformationsUrl || (env.NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT as string) || 'images';
|
|
187
|
+
const shouldSkipHostname = parsedUrl.hostname === 'img.wazobia.tech';
|
|
188
|
+
const baseImageUrl = shouldSkipHostname
|
|
182
189
|
? `${imageTransformUrl}${parsedUrl.pathname}`
|
|
183
190
|
: `${imageTransformUrl}${imageTransformUrl.endsWith('/') ? '' : '/'}${parsedUrl.hostname}${parsedUrl.pathname}`;
|
|
184
191
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./jsx-runtime-D_zvdyIk.js";import{A as e,c as o}from"./provider-Bst_TvlW.js";import{e as l}from"./env-B_s3Ell7.js";const p=(i,r)=>{const t=r.parameters.apollo;return s.jsxs(e,{client:o((t==null?void 0:t.uri)||l.VITE_MUSE_ENDPOINT),children:[s.jsx(i,{}),s.jsx("script",{src:"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"}),s.jsx("script",{src:"https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.js"}),s.jsx("script",{src:"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js"})]})};p.__docgenInfo={description:"",methods:[],displayName:"withApollo"};export{p as w};
|