Skip to content

Commit

Permalink
feat: add fallback support for env not being passed to weaverse clien…
Browse files Browse the repository at this point in the history
…t from server entry
  • Loading branch information
paul-phan committed Nov 23, 2023
1 parent 55be2b5 commit 8fa9c1e
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "weaverse-sdks",
"version": "2.6.3",
"version": "2.7.0",
"description": "Weaverse SDKs monorepo.",
"license": "MIT",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@weaverse/core",
"author": "Weaverse Team",
"description": "Weaverse Core",
"version": "2.6.3",
"version": "2.7.0",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/hydrogen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@weaverse/hydrogen",
"author": "Weaverse Team",
"description": "Components, hooks, and utilities for building Shopify Hydrogen websites with Weaverse",
"version": "2.6.3",
"version": "2.7.0",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions packages/hydrogen/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export interface HydrogenComponent<T extends HydrogenComponentProps = any> {

export type WeaverseStudioQueries = {
weaverseProjectId: string
weaverseApiKey: string
weaverseHost: string
weaverseVersion: string
isDesignMode: boolean
Expand All @@ -194,6 +195,7 @@ export type PublicEnv = {
export type WeaverseProjectConfigs = {
projectId: string
weaverseHost: string
weaverseApiKey: string
weaverseVersion?: string
isDesignMode?: boolean
publicEnv?: PublicEnv
Expand Down Expand Up @@ -274,6 +276,7 @@ export type FetchProjectPayload = {

export type HydrogenThemeEnv = {
WEAVERSE_PROJECT_ID: string
WEAVERSE_API_KEY: string
WEAVERSE_HOST: string
PUBLIC_STORE_DOMAIN: string
PUBLIC_STOREFRONT_API_TOKEN: string
Expand Down
8 changes: 5 additions & 3 deletions packages/hydrogen/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ export function getWeaverseConfigs(
let queries = getRequestQueries<WeaverseStudioQueries>(request)
let {
WEAVERSE_PROJECT_ID,
WEAVERSE_API_KEY,
WEAVERSE_HOST,
PUBLIC_STORE_DOMAIN,
PUBLIC_STOREFRONT_API_TOKEN,
} = env || {}
let { weaverseProjectId, weaverseHost, isDesignMode, weaverseVersion } =
let { weaverseProjectId, weaverseHost, isDesignMode, weaverseVersion,weaverseApiKey } =
queries
return {
projectId: weaverseProjectId || WEAVERSE_PROJECT_ID || '',
weaverseHost: weaverseHost || WEAVERSE_HOST || 'https://weaverse.io',
projectId: weaverseProjectId || WEAVERSE_PROJECT_ID || process?.env?.WEAVERSE_PROJECT_ID || '',
weaverseHost: weaverseHost || WEAVERSE_HOST || process?.env?.WEAVERSE_HOST || 'https://weaverse.io',
weaverseApiKey: weaverseApiKey || WEAVERSE_API_KEY || process?.env?.WEAVERSE_API_KEY || '',
weaverseVersion: weaverseVersion || '',
isDesignMode: isDesignMode || false,
publicEnv: {
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen/src/weaverse-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class WeaverseClient {
this.basePageConfigs = {
projectId: this.configs.projectId,
weaverseHost: this.configs.weaverseHost,
weaverseApiKey: this.configs.weaverseApiKey,
weaverseVersion: this.configs.weaverseVersion,
isDesignMode: this.configs.isDesignMode,
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@weaverse/react",
"author": "Weaverse Team",
"description": "React bindings for Weaverse",
"version": "2.6.3",
"version": "2.7.0",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/shopify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@weaverse/shopify",
"author": "Weaverse Team",
"description": "Weaverse Components for Shopify Online Store 2.0 Section builder",
"version": "2.6.3",
"version": "2.7.0",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
34 changes: 30 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8fa9c1e

Please sign in to comment.