From 0b357262442ca62316adfe99d9765ca4c802c580 Mon Sep 17 00:00:00 2001 From: tdeekens Date: Mon, 11 Jan 2021 11:05:23 +0100 Subject: [PATCH 1/9] refactor: to use combine adapters with one --- @types-extensions/graphql-mc.d.ts | 8 ++ packages-backend/express/package.json | 16 ++- packages-backend/loggers/package.json | 7 +- packages/actions-global/package.json | 14 ++- packages/application-components/package.json | 12 +- packages/application-config/package.json | 16 ++- .../application-shell-connectors/package.json | 20 ++- .../src/types/generated/mc.ts | 15 +++ packages/application-shell/package.json | 17 ++- .../fetch-all-features.mc.graphql | 1 + .../setup-flop-flip-provider.tsx | 118 ++++++++++++++---- .../src/types/generated/mc.ts | 15 +++ packages/assets/package.json | 7 +- packages/babel-preset-mc-app/package.json | 7 +- packages/browser-history/package.json | 14 ++- packages/constants/package.json | 14 ++- packages/create-mc-app/package.json | 7 +- packages/cypress/package.json | 6 +- packages/jest-preset-mc-app/package.json | 7 +- packages/jest-stylelint-runner/package.json | 15 ++- packages/l10n/package.json | 15 ++- packages/mc-dev-authentication/package.json | 7 +- packages/mc-html-template/package.json | 7 +- packages/mc-scripts/package.json | 27 +++- packages/notifications/package.json | 14 ++- packages/permissions/package.json | 14 ++- packages/react-notifications/package.json | 14 ++- packages/sdk/package.json | 20 ++- packages/sentry/package.json | 14 ++- packages/url-utils/package.json | 14 ++- schemas/mc.json | 112 ++++++++++++++++- yarn.lock | 54 ++++++++ 32 files changed, 579 insertions(+), 69 deletions(-) create mode 100644 packages/application-shell/src/components/setup-flop-flip-provider/fetch-all-features.mc.graphql diff --git a/@types-extensions/graphql-mc.d.ts b/@types-extensions/graphql-mc.d.ts index aace0fd00d..8045747ec6 100644 --- a/@types-extensions/graphql-mc.d.ts +++ b/@types-extensions/graphql-mc.d.ts @@ -33,6 +33,14 @@ declare module '*/project-switcher.mc.graphql' { export default defaultDocument; } +declare module '*/fetch-all-features.mc.graphql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const AllFeatures: DocumentNode; + + export default defaultDocument; +} + declare module '*/select-user-id.mc.graphql' { import { DocumentNode } from 'graphql'; const defaultDocument: DocumentNode; diff --git a/packages-backend/express/package.json b/packages-backend/express/package.json index af0fe6a58c..2dd4daa960 100644 --- a/packages-backend/express/package.json +++ b/packages-backend/express/package.json @@ -9,7 +9,14 @@ "directory": "packages-backend/express" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "nodejs", "express", "http", "server", "toolkit"], + "keywords": [ + "javascript", + "nodejs", + "express", + "http", + "server", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,7 +24,12 @@ }, "main": "dist/commercetools-backend-express.cjs.js", "module": "dist/commercetools-backend-express.esm.js", - "files": ["dist", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "package.json", + "LICENSE", + "README.md" + ], "dependencies": { "@babel/runtime": "7.12.5", "@babel/runtime-corejs3": "7.12.5", diff --git a/packages-backend/loggers/package.json b/packages-backend/loggers/package.json index ed9704e008..59e0b774da 100644 --- a/packages-backend/loggers/package.json +++ b/packages-backend/loggers/package.json @@ -24,7 +24,12 @@ }, "main": "dist/commercetools-backend-loggers.cjs.js", "module": "dist/commercetools-backend-loggers.esm.js", - "files": ["dist", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "package.json", + "LICENSE", + "README.md" + ], "dependencies": { "@babel/runtime": "7.12.5", "@babel/runtime-corejs3": "7.12.5", diff --git a/packages/actions-global/package.json b/packages/actions-global/package.json index 761a930402..3445abb79a 100644 --- a/packages/actions-global/package.json +++ b/packages/actions-global/package.json @@ -9,7 +9,12 @@ "directory": "packages/actions-global" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,7 +22,12 @@ }, "main": "dist/commercetools-frontend-actions-global.cjs.js", "module": "dist/commercetools-frontend-actions-global.esm.js", - "files": ["dist", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace" }, diff --git a/packages/application-components/package.json b/packages/application-components/package.json index 05f63ff310..70e4e60c2d 100644 --- a/packages/application-components/package.json +++ b/packages/application-components/package.json @@ -9,7 +9,12 @@ "directory": "packages/application-components" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -18,7 +23,10 @@ "main": "dist/commercetools-frontend-application-components.cjs.js", "module": "dist/commercetools-frontend-application-components.esm.js", "preconstruct": { - "entrypoints": ["./index.ts", "./experimental/index.ts"] + "entrypoints": [ + "./index.ts", + "./experimental/index.ts" + ] }, "files": [ "dist", diff --git a/packages/application-config/package.json b/packages/application-config/package.json index fc02806523..e800421ffe 100644 --- a/packages/application-config/package.json +++ b/packages/application-config/package.json @@ -9,7 +9,13 @@ "directory": "packages/application-config" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit", "config"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit", + "config" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,7 +23,13 @@ }, "main": "dist/commercetools-frontend-application-config.cjs.js", "module": "dist/commercetools-frontend-application-config.esm.js", - "files": ["dist", "schema.json", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "schema.json", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace", "prebuild": "yarn build:schema", diff --git a/packages/application-shell-connectors/package.json b/packages/application-shell-connectors/package.json index 399ead50e2..f17400d1e5 100644 --- a/packages/application-shell-connectors/package.json +++ b/packages/application-shell-connectors/package.json @@ -9,7 +9,12 @@ "directory": "packages/application-shell-connectors" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,9 +22,18 @@ }, "main": "dist/commercetools-frontend-application-shell-connectors.cjs.js", "module": "dist/commercetools-frontend-application-shell-connectors.esm.js", - "files": ["dist", "test-utils", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "test-utils", + "package.json", + "LICENSE", + "README.md" + ], "preconstruct": { - "entrypoints": ["./index.ts", "./test-utils/index.ts"] + "entrypoints": [ + "./index.ts", + "./test-utils/index.ts" + ] }, "scripts": { "prepare": "./../../scripts/version.js replace" diff --git a/packages/application-shell-connectors/src/types/generated/mc.ts b/packages/application-shell-connectors/src/types/generated/mc.ts index 00f48122c8..d98fe1deb1 100644 --- a/packages/application-shell-connectors/src/types/generated/mc.ts +++ b/packages/application-shell-connectors/src/types/generated/mc.ts @@ -11,6 +11,10 @@ export type Scalars = { Float: number; }; + + + + export type TAdditionalUserInfo = { firstName: Scalars['String']; lastName: Scalars['String']; @@ -810,6 +814,17 @@ export type TFetchUserProjectsQuery = ( )> } ); +export type TAllFeaturesQueryVariables = Exact<{ [key: string]: never; }>; + + +export type TAllFeaturesQuery = ( + { __typename?: 'Query' } + & { allFeatures: Array<( + { __typename?: 'Feature' } + & Pick + )> } +); + export type TFetchUserIdQueryVariables = Exact<{ [key: string]: never; }>; diff --git a/packages/application-shell/package.json b/packages/application-shell/package.json index 9a4937f815..8e5b9fb4bd 100644 --- a/packages/application-shell/package.json +++ b/packages/application-shell/package.json @@ -9,7 +9,12 @@ "directory": "packages/application-shell" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -19,7 +24,13 @@ "module": "./dist/application-shell-index.es.js", "typings": "./dist/typings/index.d.ts", "types": "./dist/typings/index.d.ts", - "files": ["dist", "test-utils", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "test-utils", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace", "prebuild": "rimraf dist/** test-utils/**", @@ -60,6 +71,8 @@ "@commercetools/http-user-agent": "2.1.2", "@emotion/react": "11.1.4", "@emotion/styled": "11.0.0", + "@flopflip/combine-adapters": "0.0.11", + "@flopflip/http-adapter": "0.0.2", "@flopflip/launchdarkly-adapter": "5.0.8", "@flopflip/memory-adapter": "3.0.12", "@flopflip/react-broadcast": "12.1.10", diff --git a/packages/application-shell/src/components/setup-flop-flip-provider/fetch-all-features.mc.graphql b/packages/application-shell/src/components/setup-flop-flip-provider/fetch-all-features.mc.graphql new file mode 100644 index 0000000000..9e319b2f8c --- /dev/null +++ b/packages/application-shell/src/components/setup-flop-flip-provider/fetch-all-features.mc.graphql @@ -0,0 +1 @@ +query AllFeatures { allFeatures { name value } } diff --git a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx index 4f786247bb..fd3e939cff 100644 --- a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx +++ b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx @@ -1,12 +1,19 @@ import type { TFlags } from '@flopflip/types'; -import type { TFetchLoggedInUserQuery } from '../../types/generated/mc'; +import type { + TAllFeaturesQuery, + TFetchLoggedInUserQuery, +} from '../../types/generated/mc'; import React from 'react'; import ldAdapter from '@flopflip/launchdarkly-adapter'; -import omitEmpty from 'omit-empty-es'; +import httpAdapter from '@flopflip/http-adapter'; +import combineAdapters from '@flopflip/combine-adapters'; import { ConfigureFlopFlip } from '@flopflip/react-broadcast'; +import { useApolloClient } from '@apollo/client/react'; +import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants'; import useAllMenuFeatureToggles from '../../hooks/use-all-menu-feature-toggles'; import { FLAGS } from '../../feature-toggles'; +import AllFeaturesQuery from './fetch-all-features.mc.graphql'; type Props = { projectKey?: string; @@ -18,7 +25,7 @@ type Props = { shouldDeferAdapterConfiguration?: boolean; }; -type CustomLDUser = { +type TLaunchDarklyUserCustomFields = { project: string; id: string; team: string[]; @@ -27,12 +34,56 @@ type CustomLDUser = { tenant: string; }; +type TFetchedHttpAdapterFlag = { + name: string; + value: boolean; + reason?: string; +}; +type TParsedHttpAdapterFlag = Record< + string, + { + value: boolean; + reason?: string; + } +>; + // This value is hard-coded here because we want to make sure that the // app uses our account of LD. The value is meant to be public, so there // is no need to be concerned about security. const ldClientSideIdProduction = '5979d95f6040390cd07b5e01'; +combineAdapters.combine([ldAdapter, httpAdapter]); + +function getUserCustomFieldsForLaunchDarklyAdapter( + user?: Props['user'], + projectKey?: string +): TLaunchDarklyUserCustomFields { + return { + project: projectKey ?? '', + id: user?.launchdarklyTrackingId ?? '', + team: user?.launchdarklyTrackingTeam ?? [], + group: user?.launchdarklyTrackingGroup ?? '', + subgroup: user?.launchdarklyTrackingSubgroup ?? '', + tenant: user?.launchdarklyTrackingTenant ?? '', + }; +} + +type TFetchedFlags = { + allFeatures: TFetchedHttpAdapterFlag[]; +}; +const parseFlags = (fetchedFlags: TFetchedFlags): TParsedHttpAdapterFlag => + Object.fromEntries( + fetchedFlags.allFeatures.map((fetchedFlag) => [ + fetchedFlag.name, + { + value: fetchedFlag.value, + reason: fetchedFlag.reason, + }, + ]) + ); + export const SetupFlopFlipProvider = (props: Props) => { + const apolloClient = useApolloClient(); const allMenuFeatureToggles = useAllMenuFeatureToggles(); const flags = React.useMemo( () => ({ @@ -54,26 +105,49 @@ export const SetupFlopFlipProvider = (props: Props) => { const adapterArgs = React.useMemo( () => ({ - sdk: { - // Allow to overwrite the client ID, passed via the `additionalEnv` properties - // of the application config. - // This is mostly useful for internal usage on our staging environments. - clientSideId: props.ldClientSideId ?? ldClientSideIdProduction, - }, - flags, user: { key: props.user?.id, - custom: omitEmpty>({ - id: props.user?.launchdarklyTrackingId, - project: props.projectKey, - team: props.user?.launchdarklyTrackingTeam, - group: props.user?.launchdarklyTrackingGroup, - subgroup: props.user?.launchdarklyTrackingSubgroup, - tenant: props.user?.launchdarklyTrackingTenant, - }), + }, + memory: { + user: { + key: props.user?.id, + }, + }, + launchdarkly: { + sdk: { + // Allow to overwrite the client ID, passed via the `additionalEnv` properties + // of the application config. + // This is mostly useful for internal usage on our staging environments. + clientSideId: props.ldClientSideId ?? ldClientSideIdProduction, + }, + flags, + user: { + key: props.user?.id, + custom: getUserCustomFieldsForLaunchDarklyAdapter( + props.user, + props.projectKey + ), + }, + }, + http: { + user: { + key: props.user?.id, + }, + execute: async function () { + const response = await apolloClient.query({ + query: AllFeaturesQuery, + errorPolicy: 'ignore', + context: { + target: GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM, + }, + }); + + return parseFlags(response.data); + }, + cacheIdentifier: 'local', }, }), - [flags, props.ldClientSideId, props.projectKey, props.user] + [apolloClient, flags, props.ldClientSideId, props.projectKey, props.user] ); if (process.env.NODE_ENV === 'test') { @@ -81,7 +155,7 @@ export const SetupFlopFlipProvider = (props: Props) => { return ( adapter={memoryAdapter} - adapterArgs={adapterArgs} + adapterArgs={adapterArgs.memory} defaultFlags={defaultFlags} shouldDeferAdapterConfiguration={ typeof props.shouldDeferAdapterConfiguration === 'boolean' @@ -95,8 +169,8 @@ export const SetupFlopFlipProvider = (props: Props) => { } return ( - - adapter={ldAdapter} + + adapter={combineAdapters} adapterArgs={adapterArgs} defaultFlags={defaultFlags} shouldDeferAdapterConfiguration={ diff --git a/packages/application-shell/src/types/generated/mc.ts b/packages/application-shell/src/types/generated/mc.ts index 00f48122c8..d98fe1deb1 100644 --- a/packages/application-shell/src/types/generated/mc.ts +++ b/packages/application-shell/src/types/generated/mc.ts @@ -11,6 +11,10 @@ export type Scalars = { Float: number; }; + + + + export type TAdditionalUserInfo = { firstName: Scalars['String']; lastName: Scalars['String']; @@ -810,6 +814,17 @@ export type TFetchUserProjectsQuery = ( )> } ); +export type TAllFeaturesQueryVariables = Exact<{ [key: string]: never; }>; + + +export type TAllFeaturesQuery = ( + { __typename?: 'Query' } + & { allFeatures: Array<( + { __typename?: 'Feature' } + & Pick + )> } +); + export type TFetchUserIdQueryVariables = Exact<{ [key: string]: never; }>; diff --git a/packages/assets/package.json b/packages/assets/package.json index aea7f60fe4..9447008503 100644 --- a/packages/assets/package.json +++ b/packages/assets/package.json @@ -9,7 +9,12 @@ "directory": "packages/assets" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { diff --git a/packages/babel-preset-mc-app/package.json b/packages/babel-preset-mc-app/package.json index 3c8c261109..6d4183138f 100644 --- a/packages/babel-preset-mc-app/package.json +++ b/packages/babel-preset-mc-app/package.json @@ -9,7 +9,12 @@ "directory": "packages/babel-preset-mc-app" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { diff --git a/packages/browser-history/package.json b/packages/browser-history/package.json index f06084ad19..41b5a12b9a 100644 --- a/packages/browser-history/package.json +++ b/packages/browser-history/package.json @@ -9,7 +9,12 @@ "directory": "packages/browser-history" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,7 +22,12 @@ }, "main": "dist/commercetools-frontend-browser-history.cjs.js", "module": "dist/commercetools-frontend-browser-history.esm.js", - "files": ["dist", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace" }, diff --git a/packages/constants/package.json b/packages/constants/package.json index 17c3f90837..24d7a065e1 100644 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -9,7 +9,12 @@ "directory": "packages/constants" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,7 +22,12 @@ }, "main": "dist/commercetools-frontend-constants.cjs.js", "module": "dist/commercetools-frontend-constants.esm.js", - "files": ["dist", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace" }, diff --git a/packages/create-mc-app/package.json b/packages/create-mc-app/package.json index b815cc3264..011f8d8d13 100644 --- a/packages/create-mc-app/package.json +++ b/packages/create-mc-app/package.json @@ -9,7 +9,12 @@ "directory": "packages/create-mc-app" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { diff --git a/packages/cypress/package.json b/packages/cypress/package.json index 17e43f7d5f..8f752a3187 100644 --- a/packages/cypress/package.json +++ b/packages/cypress/package.json @@ -25,7 +25,11 @@ "main": "dist/commercetools-frontend-cypress.cjs.js", "module": "dist/commercetools-frontend-cypress.esm.js", "preconstruct": { - "entrypoints": ["./index.ts", "./add-commands/index.ts", "./task/index.ts"] + "entrypoints": [ + "./index.ts", + "./add-commands/index.ts", + "./task/index.ts" + ] }, "files": [ "dist", diff --git a/packages/jest-preset-mc-app/package.json b/packages/jest-preset-mc-app/package.json index 406d6a874c..3e4dd93d3c 100644 --- a/packages/jest-preset-mc-app/package.json +++ b/packages/jest-preset-mc-app/package.json @@ -9,7 +9,12 @@ "directory": "packages/jest-preset-mc-app" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { diff --git a/packages/jest-stylelint-runner/package.json b/packages/jest-stylelint-runner/package.json index f9aaa4e64e..d06311a49d 100644 --- a/packages/jest-stylelint-runner/package.json +++ b/packages/jest-stylelint-runner/package.json @@ -9,13 +9,24 @@ "directory": "packages/jest-stylelint-runner" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { "access": "public" }, - "files": ["package.json", "run.js", "index.js", "LICENSE", "README.md"], + "files": [ + "package.json", + "run.js", + "index.js", + "LICENSE", + "README.md" + ], "main": "index.js", "module": "index.js", "peerDependencies": { diff --git a/packages/l10n/package.json b/packages/l10n/package.json index 0826a95c9d..825c0ed3c1 100644 --- a/packages/l10n/package.json +++ b/packages/l10n/package.json @@ -9,7 +9,12 @@ "directory": "packages/l10n" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,7 +22,13 @@ }, "main": "dist/commercetools-frontend-l10n.cjs.js", "module": "dist/commercetools-frontend-l10n.esm.js", - "files": ["data", "dist", "package.json", "LICENSE", "README.md"], + "files": [ + "data", + "dist", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace", "generate-data": "node ./scripts/generate-l10n-data.js" diff --git a/packages/mc-dev-authentication/package.json b/packages/mc-dev-authentication/package.json index d21ec6460b..1355f5eef7 100644 --- a/packages/mc-dev-authentication/package.json +++ b/packages/mc-dev-authentication/package.json @@ -9,7 +9,12 @@ "directory": "packages/mc-dev-authentication" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { diff --git a/packages/mc-html-template/package.json b/packages/mc-html-template/package.json index cb80a01437..800c2d0b72 100644 --- a/packages/mc-html-template/package.json +++ b/packages/mc-html-template/package.json @@ -9,7 +9,12 @@ "directory": "packages/mc-html-template" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { diff --git a/packages/mc-scripts/package.json b/packages/mc-scripts/package.json index a0c2335be4..d3e8e28b70 100644 --- a/packages/mc-scripts/package.json +++ b/packages/mc-scripts/package.json @@ -9,20 +9,39 @@ "directory": "packages/mc-scripts" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { "access": "public" }, "main": "./build/index.js", - "files": ["bin", "build", "config", "package.json", "LICENSE", "README.md"], + "files": [ + "bin", + "build", + "config", + "package.json", + "LICENSE", + "README.md" + ], "bin": { "mc-scripts": "./bin/mc-scripts.js" }, "browserslist": { - "production": [">1%", "not op_mini all", "not dead"], - "development": ["last 2 firefox versions", "last 2 chrome versions"] + "production": [ + ">1%", + "not op_mini all", + "not dead" + ], + "development": [ + "last 2 firefox versions", + "last 2 chrome versions" + ] }, "scripts": { "prebuild": "rimraf build/**", diff --git a/packages/notifications/package.json b/packages/notifications/package.json index f5e2ae2dc1..65160d1252 100644 --- a/packages/notifications/package.json +++ b/packages/notifications/package.json @@ -9,7 +9,12 @@ "directory": "packages/notifications" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,7 +22,12 @@ }, "main": "dist/commercetools-frontend-notifications.cjs.js", "module": "dist/commercetools-frontend-notifications.esm.js", - "files": ["dist", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace" }, diff --git a/packages/permissions/package.json b/packages/permissions/package.json index bf624d0589..e493ea21ce 100644 --- a/packages/permissions/package.json +++ b/packages/permissions/package.json @@ -9,7 +9,12 @@ "directory": "packages/permissions" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,7 +22,12 @@ }, "main": "dist/commercetools-frontend-permissions.cjs.js", "module": "dist/commercetools-frontend-permissions.esm.js", - "files": ["dist", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace" }, diff --git a/packages/react-notifications/package.json b/packages/react-notifications/package.json index a4ea9b716f..d799a95643 100644 --- a/packages/react-notifications/package.json +++ b/packages/react-notifications/package.json @@ -9,7 +9,12 @@ "directory": "packages/react-notifications" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,7 +22,12 @@ }, "main": "dist/commercetools-frontend-react-notifications.cjs.js", "module": "dist/commercetools-frontend-react-notifications.esm.js", - "files": ["dist", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace" }, diff --git a/packages/sdk/package.json b/packages/sdk/package.json index ec156100de..c5e29e0863 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -9,18 +9,32 @@ "directory": "packages/sdk" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { "access": "public" }, "preconstruct": { - "entrypoints": ["./index.ts", "./test-utils/index.ts"] + "entrypoints": [ + "./index.ts", + "./test-utils/index.ts" + ] }, "main": "dist/commercetools-frontend-sdk.cjs.js", "module": "dist/commercetools-frontend-sdk.esm.js", - "files": ["dist", "test-utils", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "test-utils", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace" }, diff --git a/packages/sentry/package.json b/packages/sentry/package.json index 24fbfd40b2..a3d8c94408 100644 --- a/packages/sentry/package.json +++ b/packages/sentry/package.json @@ -9,7 +9,12 @@ "directory": "packages/sentry" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,7 +22,12 @@ }, "main": "dist/commercetools-frontend-sentry.cjs.js", "module": "dist/commercetools-frontend-sentry.esm.js", - "files": ["dist", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace" }, diff --git a/packages/url-utils/package.json b/packages/url-utils/package.json index 62e336c881..db24a72c82 100644 --- a/packages/url-utils/package.json +++ b/packages/url-utils/package.json @@ -9,7 +9,12 @@ "directory": "packages/url-utils" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": ["javascript", "frontend", "react", "toolkit"], + "keywords": [ + "javascript", + "frontend", + "react", + "toolkit" + ], "license": "MIT", "private": false, "publishConfig": { @@ -17,7 +22,12 @@ }, "main": "dist/commercetools-frontend-url-utils.cjs.js", "module": "dist/commercetools-frontend-url-utils.esm.js", - "files": ["dist", "package.json", "LICENSE", "README.md"], + "files": [ + "dist", + "package.json", + "LICENSE", + "README.md" + ], "scripts": { "prepare": "./../../scripts/version.js replace" }, diff --git a/schemas/mc.json b/schemas/mc.json index a8706e7425..b858574791 100644 --- a/schemas/mc.json +++ b/schemas/mc.json @@ -4994,7 +4994,7 @@ { "kind": "OBJECT", "name": "OrganizationTeamsCreated", - "description": "Note:\n This is not a `Organization` type as in the future MC schema will not support\ne.g. expanding on team members on its internal schema.", + "description": "Note:\n This is not a `Organization` type as in the future MC schema will not support e.g. expanding on team members on its internal schema.", "fields": [ { "name": "id", @@ -6353,6 +6353,116 @@ } ], "directives": [ + { + "name": "isAuthenticated", + "description": null, + "locations": ["FIELD_DEFINITION"], + "args": [] + }, + { + "name": "rateLimit", + "description": null, + "locations": ["FIELD_DEFINITION"], + "args": [ + { + "name": "max", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "defaultValue": null + }, + { + "name": "window", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null + }, + { + "name": "message", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null + }, + { + "name": "identityArgs", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null + }, + { + "name": "arrayLengthField", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null + } + ] + }, + { + "name": "collectMetrics", + "description": null, + "locations": ["FIELD_DEFINITION"], + "args": [] + }, + { + "name": "deprecate", + "description": null, + "locations": ["FIELD_DEFINITION"], + "args": [ + { + "name": "reason", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null + }, + { + "name": "withCounter", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": "true" + }, + { + "name": "withLog", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": "true" + } + ] + }, { "name": "skip", "description": "Directs the executor to skip this field or fragment when the `if` argument is true.", diff --git a/yarn.lock b/yarn.lock index ac53a5a4ed..318c849e38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3679,6 +3679,41 @@ globalthis "1.0.1" lodash "4.17.20" +"@flopflip/adapter-utilities@1.0.9": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@flopflip/adapter-utilities/-/adapter-utilities-1.0.9.tgz#b1133ff6c7224c070f8a3eba8df5b596dc3829b8" + integrity sha512-w7cDbxVCo+UEG5xuJ77Vo4UArlwLCctStmiQd+Io36OaZkxKbI1uPKkfGQw/4H6VEcckvGyeJdCMrT+EW3EtEA== + dependencies: + "@babel/runtime" "7.12.5" + "@flopflip/types" "4.1.7" + globalthis "1.0.1" + lodash "4.17.20" + +"@flopflip/combine-adapters@0.0.11": + version "0.0.11" + resolved "https://registry.yarnpkg.com/@flopflip/combine-adapters/-/combine-adapters-0.0.11.tgz#6afeb6350593d75b9f81f5df75d52cf9fa685cad" + integrity sha512-Xi92O5nyNC3bzCVMziQSkRgA4OURAir2cJkgjkrHR9tLY/oO1LK4aLUtMB5Nk2Og5lMqtJoehyoNH8OPgR0BbQ== + dependencies: + "@babel/runtime" "7.12.5" + "@flopflip/adapter-utilities" "1.0.9" + "@flopflip/types" "4.1.7" + mitt "2.1.0" + tiny-warning "1.0.3" + +"@flopflip/http-adapter@0.0.2": + version "0.0.2" + resolved "https://registry.yarnpkg.com/@flopflip/http-adapter/-/http-adapter-0.0.2.tgz#3ab3eda7feed5bb5860c0ef54186523af12a8d8b" + integrity sha512-GNHt3TFRR6h02pcZHLCkODLvrBPInBdz5lDTl4YEgSQy9XZRfIfBJF4mXYmJOyTzQxKcDiMGVAHpeF2mPTbrDg== + dependencies: + "@babel/runtime" "7.12.5" + "@flopflip/adapter-utilities" "1.0.9" + "@flopflip/localstorage-cache" "1.0.10" + "@flopflip/sessionstorage-cache" "1.0.10" + "@flopflip/types" "4.1.7" + lodash "4.17.20" + mitt "2.1.0" + tiny-warning "1.0.3" + "@flopflip/launchdarkly-adapter@5.0.8": version "5.0.8" resolved "https://registry.yarnpkg.com/@flopflip/launchdarkly-adapter/-/launchdarkly-adapter-5.0.8.tgz#2185a9e3014f1e35c6006ba078c9164ed3154a89" @@ -3694,6 +3729,13 @@ mitt "2.1.0" tiny-warning "1.0.3" +"@flopflip/localstorage-cache@1.0.10": + version "1.0.10" + resolved "https://registry.yarnpkg.com/@flopflip/localstorage-cache/-/localstorage-cache-1.0.10.tgz#2d9bfd0668098b72e5842415851747852f1999d4" + integrity sha512-vy84VtOhZV2lz7dadjMO5jdISRA49w1/9mlOMNtUuve5P26cN1UR7MQQjtB1z72xH/tk2OYhDola/YMuFR1s8g== + dependencies: + "@flopflip/types" "4.1.7" + "@flopflip/memory-adapter@3.0.12": version "3.0.12" resolved "https://registry.yarnpkg.com/@flopflip/memory-adapter/-/memory-adapter-3.0.12.tgz#358f77982bb5e7276ef4795613e36009d15430c1" @@ -3727,11 +3769,23 @@ react-is "17.0.1" tiny-warning "1.0.3" +"@flopflip/sessionstorage-cache@1.0.10": + version "1.0.10" + resolved "https://registry.yarnpkg.com/@flopflip/sessionstorage-cache/-/sessionstorage-cache-1.0.10.tgz#d8530afec87d36dc32773fdd39407e9e550c48a5" + integrity sha512-Xprd01oUfNPj2+I68aHmyUJPNhuf2siBDvRJscvFrYZWw3EZsCvqF86Hu8gO+JnUb2xOzBHy09i8ikQfU4GFDQ== + dependencies: + "@flopflip/types" "4.1.7" + "@flopflip/types@4.1.10": version "4.1.10" resolved "https://registry.yarnpkg.com/@flopflip/types/-/types-4.1.10.tgz#43264be1aeda291647b87c8022a31ae69c2d0ae0" integrity sha512-X24CAep+LltfJRypWNSIqpeL2jEH2qTcnUOUlV6q394tnxqey6ZNV0B165OsDVLIcHi1JIBePGRj4V1DqpXwoA== +"@flopflip/types@4.1.7": + version "4.1.7" + resolved "https://registry.yarnpkg.com/@flopflip/types/-/types-4.1.7.tgz#7f127d582abe5bd2615d153f848e7d02ee738d5d" + integrity sha512-E8VLO24BSk4EMb3TPv+a8g8Oe40enjGWVclk7pLkCweQUiUXZsGrOW8QCW32YY9m85+NEnwToAn4yrWW66xWvw== + "@fontsource/open-sans@4.1.0": version "4.1.0" resolved "https://registry.yarnpkg.com/@fontsource/open-sans/-/open-sans-4.1.0.tgz#d44b4495bd23d78018675e4e79973894e393c0ed" From 5d0860d006f59f86175d31ad23502531489d43c9 Mon Sep 17 00:00:00 2001 From: tdeekens Date: Thu, 14 Jan 2021 15:54:21 +0100 Subject: [PATCH 2/9] chore: update versions --- packages/application-shell/package.json | 4 +- .../fetch-all-features.mc.graphql | 8 +- .../setup-flop-flip-provider.tsx | 11 +- yarn.lock | 150 ++++++++++++------ 4 files changed, 115 insertions(+), 58 deletions(-) diff --git a/packages/application-shell/package.json b/packages/application-shell/package.json index 8e5b9fb4bd..79f97b83e4 100644 --- a/packages/application-shell/package.json +++ b/packages/application-shell/package.json @@ -71,8 +71,8 @@ "@commercetools/http-user-agent": "2.1.2", "@emotion/react": "11.1.4", "@emotion/styled": "11.0.0", - "@flopflip/combine-adapters": "0.0.11", - "@flopflip/http-adapter": "0.0.2", + "@flopflip/combine-adapters": "0.0.13", + "@flopflip/http-adapter": "0.0.4", "@flopflip/launchdarkly-adapter": "5.0.8", "@flopflip/memory-adapter": "3.0.12", "@flopflip/react-broadcast": "12.1.10", diff --git a/packages/application-shell/src/components/setup-flop-flip-provider/fetch-all-features.mc.graphql b/packages/application-shell/src/components/setup-flop-flip-provider/fetch-all-features.mc.graphql index 9e319b2f8c..2560be1f4d 100644 --- a/packages/application-shell/src/components/setup-flop-flip-provider/fetch-all-features.mc.graphql +++ b/packages/application-shell/src/components/setup-flop-flip-provider/fetch-all-features.mc.graphql @@ -1 +1,7 @@ -query AllFeatures { allFeatures { name value } } +query AllFeatures { + allFeatures { + name + value + reason + } +} diff --git a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx index fd3e939cff..429e5e806e 100644 --- a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx +++ b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx @@ -39,7 +39,7 @@ type TFetchedHttpAdapterFlag = { value: boolean; reason?: string; }; -type TParsedHttpAdapterFlag = Record< +type TParsedHttpAdapterFlags = Record< string, { value: boolean; @@ -71,7 +71,7 @@ function getUserCustomFieldsForLaunchDarklyAdapter( type TFetchedFlags = { allFeatures: TFetchedHttpAdapterFlag[]; }; -const parseFlags = (fetchedFlags: TFetchedFlags): TParsedHttpAdapterFlag => +const parseFlags = (fetchedFlags: TFetchedFlags): TParsedHttpAdapterFlags => Object.fromEntries( fetchedFlags.allFeatures.map((fetchedFlag) => [ fetchedFlag.name, @@ -133,18 +133,17 @@ export const SetupFlopFlipProvider = (props: Props) => { user: { key: props.user?.id, }, - execute: async function () { + execute: async function () { const response = await apolloClient.query({ query: AllFeaturesQuery, errorPolicy: 'ignore', context: { - target: GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM, + target: GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND, }, }); return parseFlags(response.data); - }, - cacheIdentifier: 'local', + } }, }), [apolloClient, flags, props.ldClientSideId, props.projectKey, props.user] diff --git a/yarn.lock b/yarn.lock index 318c849e38..244f696487 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3669,47 +3669,47 @@ resolved "https://registry.yarnpkg.com/@exodus/schemasafe/-/schemasafe-1.0.0-rc.3.tgz#dda2fbf3dafa5ad8c63dadff7e01d3fdf4736025" integrity sha512-GoXw0U2Qaa33m3eUcxuHnHpNvHjNlLo0gtV091XBpaRINaB4X6FGCG5XKxSFNFiPpugUDqNruHzaqpTdDm4AOg== -"@flopflip/adapter-utilities@1.0.12": - version "1.0.12" - resolved "https://registry.yarnpkg.com/@flopflip/adapter-utilities/-/adapter-utilities-1.0.12.tgz#dd5f034756a76be28c90dbb3522164ddc58ef00a" - integrity sha512-l+jHM+eEvqM45d8B7vxqu2LsHopVoYR5kfRL3+MfhFxuGxCN6SmYTkNjEUqJyTCDOEiYudn9XRHjwP8EGB5UXw== +"@flopflip/adapter-utilities@1.0.11": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@flopflip/adapter-utilities/-/adapter-utilities-1.0.11.tgz#d31dcfa519cf3deed390afa8536563685f738e0a" + integrity sha512-yI7nwyGVWXUQWkROpO2Km8Q0cyTtUVmNaatLE6gCdDn9tOAZGUc/lANOKy6pdZaKlHXhT+WF9whYMTtznHjAiQ== dependencies: "@babel/runtime" "7.12.5" - "@flopflip/types" "4.1.10" + "@flopflip/types" "4.1.9" globalthis "1.0.1" lodash "4.17.20" -"@flopflip/adapter-utilities@1.0.9": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@flopflip/adapter-utilities/-/adapter-utilities-1.0.9.tgz#b1133ff6c7224c070f8a3eba8df5b596dc3829b8" - integrity sha512-w7cDbxVCo+UEG5xuJ77Vo4UArlwLCctStmiQd+Io36OaZkxKbI1uPKkfGQw/4H6VEcckvGyeJdCMrT+EW3EtEA== +"@flopflip/adapter-utilities@1.0.12": + version "1.0.12" + resolved "https://registry.yarnpkg.com/@flopflip/adapter-utilities/-/adapter-utilities-1.0.12.tgz#dd5f034756a76be28c90dbb3522164ddc58ef00a" + integrity sha512-l+jHM+eEvqM45d8B7vxqu2LsHopVoYR5kfRL3+MfhFxuGxCN6SmYTkNjEUqJyTCDOEiYudn9XRHjwP8EGB5UXw== dependencies: "@babel/runtime" "7.12.5" - "@flopflip/types" "4.1.7" + "@flopflip/types" "4.1.10" globalthis "1.0.1" lodash "4.17.20" -"@flopflip/combine-adapters@0.0.11": - version "0.0.11" - resolved "https://registry.yarnpkg.com/@flopflip/combine-adapters/-/combine-adapters-0.0.11.tgz#6afeb6350593d75b9f81f5df75d52cf9fa685cad" - integrity sha512-Xi92O5nyNC3bzCVMziQSkRgA4OURAir2cJkgjkrHR9tLY/oO1LK4aLUtMB5Nk2Og5lMqtJoehyoNH8OPgR0BbQ== +"@flopflip/combine-adapters@0.0.13": + version "0.0.13" + resolved "https://registry.yarnpkg.com/@flopflip/combine-adapters/-/combine-adapters-0.0.13.tgz#ef3b788456612c21297f2b3a294c5f0961547c5b" + integrity sha512-Pw/hrm6O4XWgkqRvyDIyH3hiL/sarnf2AfyBzbQa8IJrEAqSIOvZtDvb+fdVy52v4HJD7YufzV/eMWycJ2mong== dependencies: "@babel/runtime" "7.12.5" - "@flopflip/adapter-utilities" "1.0.9" - "@flopflip/types" "4.1.7" + "@flopflip/adapter-utilities" "1.0.11" + "@flopflip/types" "4.1.9" mitt "2.1.0" tiny-warning "1.0.3" -"@flopflip/http-adapter@0.0.2": - version "0.0.2" - resolved "https://registry.yarnpkg.com/@flopflip/http-adapter/-/http-adapter-0.0.2.tgz#3ab3eda7feed5bb5860c0ef54186523af12a8d8b" - integrity sha512-GNHt3TFRR6h02pcZHLCkODLvrBPInBdz5lDTl4YEgSQy9XZRfIfBJF4mXYmJOyTzQxKcDiMGVAHpeF2mPTbrDg== +"@flopflip/http-adapter@0.0.4": + version "0.0.4" + resolved "https://registry.yarnpkg.com/@flopflip/http-adapter/-/http-adapter-0.0.4.tgz#89be10baaf043432c22efa70bca7bf2f26e20544" + integrity sha512-POpXx1TVfZKWW67DcHx/yVEHg97dsoofcOkt3ga64xbTie7ns9dvEDiBSF6a4gVVcceRMXEGu8eogQvkDzzwnw== dependencies: "@babel/runtime" "7.12.5" - "@flopflip/adapter-utilities" "1.0.9" - "@flopflip/localstorage-cache" "1.0.10" - "@flopflip/sessionstorage-cache" "1.0.10" - "@flopflip/types" "4.1.7" + "@flopflip/adapter-utilities" "1.0.11" + "@flopflip/localstorage-cache" "1.0.12" + "@flopflip/sessionstorage-cache" "1.0.12" + "@flopflip/types" "4.1.9" lodash "4.17.20" mitt "2.1.0" tiny-warning "1.0.3" @@ -3729,12 +3729,12 @@ mitt "2.1.0" tiny-warning "1.0.3" -"@flopflip/localstorage-cache@1.0.10": - version "1.0.10" - resolved "https://registry.yarnpkg.com/@flopflip/localstorage-cache/-/localstorage-cache-1.0.10.tgz#2d9bfd0668098b72e5842415851747852f1999d4" - integrity sha512-vy84VtOhZV2lz7dadjMO5jdISRA49w1/9mlOMNtUuve5P26cN1UR7MQQjtB1z72xH/tk2OYhDola/YMuFR1s8g== +"@flopflip/localstorage-cache@1.0.12": + version "1.0.12" + resolved "https://registry.yarnpkg.com/@flopflip/localstorage-cache/-/localstorage-cache-1.0.12.tgz#d2108509667b3dfda88dfb2033f58c6f0366d76f" + integrity sha512-hd2OtQ4CZZZ8NYf5MjwAWizlYrVQE1aZ/VMB8Tld82bF/5WMGeBARctcKCYUeUSihFg7b5Aad2NwG2mioIstog== dependencies: - "@flopflip/types" "4.1.7" + "@flopflip/types" "4.1.9" "@flopflip/memory-adapter@3.0.12": version "3.0.12" @@ -3769,22 +3769,22 @@ react-is "17.0.1" tiny-warning "1.0.3" -"@flopflip/sessionstorage-cache@1.0.10": - version "1.0.10" - resolved "https://registry.yarnpkg.com/@flopflip/sessionstorage-cache/-/sessionstorage-cache-1.0.10.tgz#d8530afec87d36dc32773fdd39407e9e550c48a5" - integrity sha512-Xprd01oUfNPj2+I68aHmyUJPNhuf2siBDvRJscvFrYZWw3EZsCvqF86Hu8gO+JnUb2xOzBHy09i8ikQfU4GFDQ== +"@flopflip/sessionstorage-cache@1.0.12": + version "1.0.12" + resolved "https://registry.yarnpkg.com/@flopflip/sessionstorage-cache/-/sessionstorage-cache-1.0.12.tgz#418fed54c6bf3ba9a980cbb654bc0c84c6da709b" + integrity sha512-d47gbqrmiyWmpW9JwCvVAh4y5R0j3mxc6ra7CPDdM4TqtprKPam4hJDx2wSGeVFLCblRPTvgtcu8FNDrmxBj+g== dependencies: - "@flopflip/types" "4.1.7" + "@flopflip/types" "4.1.9" "@flopflip/types@4.1.10": version "4.1.10" resolved "https://registry.yarnpkg.com/@flopflip/types/-/types-4.1.10.tgz#43264be1aeda291647b87c8022a31ae69c2d0ae0" integrity sha512-X24CAep+LltfJRypWNSIqpeL2jEH2qTcnUOUlV6q394tnxqey6ZNV0B165OsDVLIcHi1JIBePGRj4V1DqpXwoA== -"@flopflip/types@4.1.7": - version "4.1.7" - resolved "https://registry.yarnpkg.com/@flopflip/types/-/types-4.1.7.tgz#7f127d582abe5bd2615d153f848e7d02ee738d5d" - integrity sha512-E8VLO24BSk4EMb3TPv+a8g8Oe40enjGWVclk7pLkCweQUiUXZsGrOW8QCW32YY9m85+NEnwToAn4yrWW66xWvw== +"@flopflip/types@4.1.9": + version "4.1.9" + resolved "https://registry.yarnpkg.com/@flopflip/types/-/types-4.1.9.tgz#58d6e84d8fc885e7ef2b518ec22d169768ab0356" + integrity sha512-k91KggraKBfhsx5FlYKf7nnejy2OV76AqQzf611YPD2OXhdDM6fZyQ6YuO213XiNVw8FYZ1SWLXNvsbsBe2FYg== "@fontsource/open-sans@4.1.0": version "4.1.0" @@ -7126,15 +7126,20 @@ "@types/node" "*" form-data "^3.0.0" -"@types/node@*", "@types/node@14", "@types/node@14.14.22", "@types/node@>= 8": +"@types/node@*", "@types/node@14", "@types/node@>= 8": + version "14.14.21" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.21.tgz#d934aacc22424fe9622ebf6857370c052eae464e" + integrity sha512-cHYfKsnwllYhjOzuC5q1VpguABBeecUp24yFluHpn/BQaVxB1CuQ1FSRZCzrPxrkIfWISXV2LbeoBthLWg0+0A== + +"@types/node@14.14.22": version "14.14.22" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18" integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw== "@types/node@^12.7.1": - version "12.19.15" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.19.15.tgz#0de7e978fb43db62da369db18ea088a63673c182" - integrity sha512-lowukE3GUI+VSYSu6VcBXl14d61Rp5hA1D+61r16qnwC0lYNSqdxcvRh0pswejorHfS+HgwBasM8jLXz0/aOsw== + version "12.19.14" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.19.14.tgz#59e5029a3c2aea34f68b717955381692fd47cafb" + integrity sha512-2U9uLN46+7dv9PiS8VQJcHhuoOjiDPZOLAt0WuA1EanEknIMae+2QbMhayF7cgGqjvRVIfNpt+6jLPczJZFiRw== "@types/node@^8.5.7": version "8.10.66" @@ -7504,7 +7509,7 @@ semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@4.14.0", "@typescript-eslint/experimental-utils@^4.0.1": +"@typescript-eslint/experimental-utils@4.14.0": version "4.14.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.14.0.tgz#5aa7b006736634f588a69ee343ca959cd09988df" integrity sha512-6i6eAoiPlXMKRbXzvoQD5Yn9L7k9ezzGRvzC/x1V3650rUk3c3AOjQyGYyF9BDxQQDK2ElmKOZRD0CbtdkMzQQ== @@ -7527,6 +7532,18 @@ eslint-scope "^5.0.0" eslint-utils "^2.0.0" +"@typescript-eslint/experimental-utils@^4.0.1": + version "4.13.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.13.0.tgz#9dc9ab375d65603b43d938a0786190a0c72be44e" + integrity sha512-/ZsuWmqagOzNkx30VWYV3MNB/Re/CGv/7EzlqZo5RegBN8tMuPaBgNK6vPBCQA8tcYrbsrTdbx3ixMRRKEEGVw== + dependencies: + "@types/json-schema" "^7.0.3" + "@typescript-eslint/scope-manager" "4.13.0" + "@typescript-eslint/types" "4.13.0" + "@typescript-eslint/typescript-estree" "4.13.0" + eslint-scope "^5.0.0" + eslint-utils "^2.0.0" + "@typescript-eslint/parser@4.14.0", "@typescript-eslint/parser@^2.24.0", "@typescript-eslint/parser@^4.14.0": version "4.14.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.14.0.tgz#62d4cd2079d5c06683e9bfb200c758f292c4dee7" @@ -7537,6 +7554,14 @@ "@typescript-eslint/typescript-estree" "4.14.0" debug "^4.1.1" +"@typescript-eslint/scope-manager@4.13.0": + version "4.13.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.13.0.tgz#5b45912a9aa26b29603d8fa28f5e09088b947141" + integrity sha512-UpK7YLG2JlTp/9G4CHe7GxOwd93RBf3aHO5L+pfjIrhtBvZjHKbMhBXTIQNkbz7HZ9XOe++yKrXutYm5KmjWgQ== + dependencies: + "@typescript-eslint/types" "4.13.0" + "@typescript-eslint/visitor-keys" "4.13.0" + "@typescript-eslint/scope-manager@4.14.0": version "4.14.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.14.0.tgz#55a4743095d684e1f7b7180c4bac2a0a3727f517" @@ -7550,6 +7575,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.10.1.tgz#1d7463fa7c32d8a23ab508a803ca2fe26e758727" integrity sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ== +"@typescript-eslint/types@4.13.0": + version "4.13.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.13.0.tgz#6a7c6015a59a08fbd70daa8c83dfff86250502f8" + integrity sha512-/+aPaq163oX+ObOG00M0t9tKkOgdv9lq0IQv/y4SqGkAXmhFmCfgsELV7kOCTb2vVU5VOmVwXBXJTDr353C1rQ== + "@typescript-eslint/types@4.14.0": version "4.14.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.14.0.tgz#d8a8202d9b58831d6fd9cee2ba12f8a5a5dd44b6" @@ -7569,6 +7599,20 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@4.13.0": + version "4.13.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.13.0.tgz#cf6e2207c7d760f5dfd8d18051428fadfc37b45e" + integrity sha512-9A0/DFZZLlGXn5XA349dWQFwPZxcyYyCFX5X88nWs2uachRDwGeyPz46oTsm9ZJE66EALvEns1lvBwa4d9QxMg== + dependencies: + "@typescript-eslint/types" "4.13.0" + "@typescript-eslint/visitor-keys" "4.13.0" + debug "^4.1.1" + globby "^11.0.1" + is-glob "^4.0.1" + lodash "^4.17.15" + semver "^7.3.2" + tsutils "^3.17.1" + "@typescript-eslint/typescript-estree@4.14.0": version "4.14.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.0.tgz#4bcd67486e9acafc3d0c982b23a9ab8ac8911ed7" @@ -7590,6 +7634,14 @@ dependencies: eslint-visitor-keys "^1.1.0" +"@typescript-eslint/visitor-keys@4.13.0": + version "4.13.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.13.0.tgz#9acb1772d3b3183182b6540d3734143dce9476fe" + integrity sha512-6RoxWK05PAibukE7jElqAtNMq+RWZyqJ6Q/GdIxaiUj2Ept8jh8+FUVlbq9WxMYxkmEOPvCE5cRSyupMpwW31g== + dependencies: + "@typescript-eslint/types" "4.13.0" + eslint-visitor-keys "^2.0.0" + "@typescript-eslint/visitor-keys@4.14.0": version "4.14.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.0.tgz#b1090d9d2955b044b2ea2904a22496849acbdf54" @@ -9753,9 +9805,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001173: - version "1.0.30001179" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001179.tgz#b0803883b4471a6c62066fb1752756f8afc699c8" - integrity sha512-blMmO0QQujuUWZKyVrD1msR4WNDAqb/UPO1Sw2WWsQ7deoM5bJiicKnWJ1Y0NS/aGINSnKPIWBMw5luX+NDUCA== + version "1.0.30001177" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001177.tgz#2c3b384933aafda03e29ccca7bb3d8c3389e1ece" + integrity sha512-6Ld7t3ifCL02jTj3MxPMM5wAYjbo4h/TAQGFTgv1inihP1tWnWp8mxxT4ut4JBEHLbpFXEXJJQ119JCJTBkYDw== capture-exit@^2.0.0: version "2.0.0" @@ -12458,9 +12510,9 @@ ee-first@1.1.1: integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= electron-to-chromium@^1.3.564, electron-to-chromium@^1.3.634: - version "1.3.644" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.644.tgz#c89721733ec26b8d117275fb6b2acbeb3d45a6b6" - integrity sha512-N7FLvjDPADxad+OXXBuYfcvDvCBG0aW8ZZGr7G91sZMviYbnQJFxdSvUus4SJ0K7Q8dzMxE+Wx1d/CrJIIJ0sw== + version "1.3.639" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.639.tgz#0a27e3018ae3acf438a14a1dd4e41db4b8ab764e" + integrity sha512-bwl6/U6xb3d3CNufQU9QeO1L32ueouFwW4bWANSwdXR7LVqyLzWjNbynoKNfuC38QFB5Qn7O0l2KLqBkcXnC3Q== elegant-spinner@^1.0.1: version "1.0.1" From cc5dd28ea2f77e3614bd47b1cc8ae2ce1f49ca59 Mon Sep 17 00:00:00 2001 From: tdeekens Date: Wed, 20 Jan 2021 15:03:30 +0100 Subject: [PATCH 3/9] chore: update deps --- packages/application-shell/package.json | 19 ++------ yarn.lock | 63 ++++++++++--------------- 2 files changed, 28 insertions(+), 54 deletions(-) diff --git a/packages/application-shell/package.json b/packages/application-shell/package.json index 79f97b83e4..ad7b25efe0 100644 --- a/packages/application-shell/package.json +++ b/packages/application-shell/package.json @@ -9,12 +9,7 @@ "directory": "packages/application-shell" }, "homepage": "https://docs.commercetools.com/custom-applications", - "keywords": [ - "javascript", - "frontend", - "react", - "toolkit" - ], + "keywords": ["javascript", "frontend", "react", "toolkit"], "license": "MIT", "private": false, "publishConfig": { @@ -24,13 +19,7 @@ "module": "./dist/application-shell-index.es.js", "typings": "./dist/typings/index.d.ts", "types": "./dist/typings/index.d.ts", - "files": [ - "dist", - "test-utils", - "package.json", - "LICENSE", - "README.md" - ], + "files": ["dist", "test-utils", "package.json", "LICENSE", "README.md"], "scripts": { "prepare": "./../../scripts/version.js replace", "prebuild": "rimraf dist/** test-utils/**", @@ -71,8 +60,8 @@ "@commercetools/http-user-agent": "2.1.2", "@emotion/react": "11.1.4", "@emotion/styled": "11.0.0", - "@flopflip/combine-adapters": "0.0.13", - "@flopflip/http-adapter": "0.0.4", + "@flopflip/combine-adapters": "0.0.14", + "@flopflip/http-adapter": "0.0.5", "@flopflip/launchdarkly-adapter": "5.0.8", "@flopflip/memory-adapter": "3.0.12", "@flopflip/react-broadcast": "12.1.10", diff --git a/yarn.lock b/yarn.lock index 244f696487..b0f757b193 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3669,16 +3669,6 @@ resolved "https://registry.yarnpkg.com/@exodus/schemasafe/-/schemasafe-1.0.0-rc.3.tgz#dda2fbf3dafa5ad8c63dadff7e01d3fdf4736025" integrity sha512-GoXw0U2Qaa33m3eUcxuHnHpNvHjNlLo0gtV091XBpaRINaB4X6FGCG5XKxSFNFiPpugUDqNruHzaqpTdDm4AOg== -"@flopflip/adapter-utilities@1.0.11": - version "1.0.11" - resolved "https://registry.yarnpkg.com/@flopflip/adapter-utilities/-/adapter-utilities-1.0.11.tgz#d31dcfa519cf3deed390afa8536563685f738e0a" - integrity sha512-yI7nwyGVWXUQWkROpO2Km8Q0cyTtUVmNaatLE6gCdDn9tOAZGUc/lANOKy6pdZaKlHXhT+WF9whYMTtznHjAiQ== - dependencies: - "@babel/runtime" "7.12.5" - "@flopflip/types" "4.1.9" - globalthis "1.0.1" - lodash "4.17.20" - "@flopflip/adapter-utilities@1.0.12": version "1.0.12" resolved "https://registry.yarnpkg.com/@flopflip/adapter-utilities/-/adapter-utilities-1.0.12.tgz#dd5f034756a76be28c90dbb3522164ddc58ef00a" @@ -3689,27 +3679,27 @@ globalthis "1.0.1" lodash "4.17.20" -"@flopflip/combine-adapters@0.0.13": - version "0.0.13" - resolved "https://registry.yarnpkg.com/@flopflip/combine-adapters/-/combine-adapters-0.0.13.tgz#ef3b788456612c21297f2b3a294c5f0961547c5b" - integrity sha512-Pw/hrm6O4XWgkqRvyDIyH3hiL/sarnf2AfyBzbQa8IJrEAqSIOvZtDvb+fdVy52v4HJD7YufzV/eMWycJ2mong== +"@flopflip/combine-adapters@0.0.14": + version "0.0.14" + resolved "https://registry.yarnpkg.com/@flopflip/combine-adapters/-/combine-adapters-0.0.14.tgz#d9014f51645243f0f05e0dbda7645ad29db26da0" + integrity sha512-NI/XdI8ZQCjWI8IWcG/eILGivPRWgxCE7kEUh3CorSPfRlT+gQLii4VvO/kV39gpTYcMBXHVHVaJKXW3U4KqlA== dependencies: "@babel/runtime" "7.12.5" - "@flopflip/adapter-utilities" "1.0.11" - "@flopflip/types" "4.1.9" + "@flopflip/adapter-utilities" "1.0.12" + "@flopflip/types" "4.1.10" mitt "2.1.0" tiny-warning "1.0.3" -"@flopflip/http-adapter@0.0.4": - version "0.0.4" - resolved "https://registry.yarnpkg.com/@flopflip/http-adapter/-/http-adapter-0.0.4.tgz#89be10baaf043432c22efa70bca7bf2f26e20544" - integrity sha512-POpXx1TVfZKWW67DcHx/yVEHg97dsoofcOkt3ga64xbTie7ns9dvEDiBSF6a4gVVcceRMXEGu8eogQvkDzzwnw== +"@flopflip/http-adapter@0.0.5": + version "0.0.5" + resolved "https://registry.yarnpkg.com/@flopflip/http-adapter/-/http-adapter-0.0.5.tgz#d076cafe0ba7ca6046360285e117d0e1dfcbc787" + integrity sha512-ImR4/BSbFKGgV2GGOsBpG+YkOdt/lEsQU3Tzg1kDztC6u+ddiJR9enPmkyPuiKqEpPTLWG1imJNk+V7lRRSOcw== dependencies: "@babel/runtime" "7.12.5" - "@flopflip/adapter-utilities" "1.0.11" - "@flopflip/localstorage-cache" "1.0.12" - "@flopflip/sessionstorage-cache" "1.0.12" - "@flopflip/types" "4.1.9" + "@flopflip/adapter-utilities" "1.0.12" + "@flopflip/localstorage-cache" "1.0.13" + "@flopflip/sessionstorage-cache" "1.0.13" + "@flopflip/types" "4.1.10" lodash "4.17.20" mitt "2.1.0" tiny-warning "1.0.3" @@ -3729,12 +3719,12 @@ mitt "2.1.0" tiny-warning "1.0.3" -"@flopflip/localstorage-cache@1.0.12": - version "1.0.12" - resolved "https://registry.yarnpkg.com/@flopflip/localstorage-cache/-/localstorage-cache-1.0.12.tgz#d2108509667b3dfda88dfb2033f58c6f0366d76f" - integrity sha512-hd2OtQ4CZZZ8NYf5MjwAWizlYrVQE1aZ/VMB8Tld82bF/5WMGeBARctcKCYUeUSihFg7b5Aad2NwG2mioIstog== +"@flopflip/localstorage-cache@1.0.13": + version "1.0.13" + resolved "https://registry.yarnpkg.com/@flopflip/localstorage-cache/-/localstorage-cache-1.0.13.tgz#d83114c293fadc858d63a097c832c0fd497f94ba" + integrity sha512-gquLqXE+ID6518dya1SC+xa2TnfILWGLmV2eQHIKzS2KPBvotBdWIPNt2TjQGAj/BnTVj8uCdhQQ/u4l/18+vQ== dependencies: - "@flopflip/types" "4.1.9" + "@flopflip/types" "4.1.10" "@flopflip/memory-adapter@3.0.12": version "3.0.12" @@ -3769,23 +3759,18 @@ react-is "17.0.1" tiny-warning "1.0.3" -"@flopflip/sessionstorage-cache@1.0.12": - version "1.0.12" - resolved "https://registry.yarnpkg.com/@flopflip/sessionstorage-cache/-/sessionstorage-cache-1.0.12.tgz#418fed54c6bf3ba9a980cbb654bc0c84c6da709b" - integrity sha512-d47gbqrmiyWmpW9JwCvVAh4y5R0j3mxc6ra7CPDdM4TqtprKPam4hJDx2wSGeVFLCblRPTvgtcu8FNDrmxBj+g== +"@flopflip/sessionstorage-cache@1.0.13": + version "1.0.13" + resolved "https://registry.yarnpkg.com/@flopflip/sessionstorage-cache/-/sessionstorage-cache-1.0.13.tgz#8dd80da20b7d63f9ec0d4d32b22ebedad0fb1826" + integrity sha512-WQ+l7dbovQT2IA5XCk+SzW5lFfzT5rQUrY1beJOzMt0QGq21+vH60ij/dNZ4v51jyG2UJ0hi/JE9pB6J1EamQw== dependencies: - "@flopflip/types" "4.1.9" + "@flopflip/types" "4.1.10" "@flopflip/types@4.1.10": version "4.1.10" resolved "https://registry.yarnpkg.com/@flopflip/types/-/types-4.1.10.tgz#43264be1aeda291647b87c8022a31ae69c2d0ae0" integrity sha512-X24CAep+LltfJRypWNSIqpeL2jEH2qTcnUOUlV6q394tnxqey6ZNV0B165OsDVLIcHi1JIBePGRj4V1DqpXwoA== -"@flopflip/types@4.1.9": - version "4.1.9" - resolved "https://registry.yarnpkg.com/@flopflip/types/-/types-4.1.9.tgz#58d6e84d8fc885e7ef2b518ec22d169768ab0356" - integrity sha512-k91KggraKBfhsx5FlYKf7nnejy2OV76AqQzf611YPD2OXhdDM6fZyQ6YuO213XiNVw8FYZ1SWLXNvsbsBe2FYg== - "@fontsource/open-sans@4.1.0": version "4.1.0" resolved "https://registry.yarnpkg.com/@fontsource/open-sans/-/open-sans-4.1.0.tgz#d44b4495bd23d78018675e4e79973894e393c0ed" From 478fe87545857ae4ad4ce61010dff92e7fe0451f Mon Sep 17 00:00:00 2001 From: tdeekens Date: Wed, 20 Jan 2021 15:36:46 +0100 Subject: [PATCH 4/9] fix: a comma can make a huge difference --- .../setup-flop-flip-provider/setup-flop-flip-provider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx index 429e5e806e..ca90899082 100644 --- a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx +++ b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx @@ -143,7 +143,7 @@ export const SetupFlopFlipProvider = (props: Props) => { }); return parseFlags(response.data); - } + }, }, }), [apolloClient, flags, props.ldClientSideId, props.projectKey, props.user] From 1e36b8f776df91d14543640e7e58f53ee33ca4d3 Mon Sep 17 00:00:00 2001 From: tdeekens Date: Fri, 22 Jan 2021 13:19:22 +0100 Subject: [PATCH 5/9] feat: add environment based flag for fetching --- .../setup-flop-flip-provider.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx index ca90899082..b80eb5615f 100644 --- a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx +++ b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx @@ -5,6 +5,7 @@ import type { } from '../../types/generated/mc'; import React from 'react'; +import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors'; import ldAdapter from '@flopflip/launchdarkly-adapter'; import httpAdapter from '@flopflip/http-adapter'; import combineAdapters from '@flopflip/combine-adapters'; @@ -52,8 +53,6 @@ type TParsedHttpAdapterFlags = Record< // is no need to be concerned about security. const ldClientSideIdProduction = '5979d95f6040390cd07b5e01'; -combineAdapters.combine([ldAdapter, httpAdapter]); - function getUserCustomFieldsForLaunchDarklyAdapter( user?: Props['user'], projectKey?: string @@ -82,8 +81,16 @@ const parseFlags = (fetchedFlags: TFetchedFlags): TParsedHttpAdapterFlags => ]) ); +type TAdditionalEnvironmentProperties = { + env: { + enableFeatureConfigurationFetching?: boolean; + } +}; export const SetupFlopFlipProvider = (props: Props) => { const apolloClient = useApolloClient(); + const enableFeatureConfigurationFetching = useApplicationContext( + (context) => context.environment.env.enableFeatureConfigurationFetching + ); const allMenuFeatureToggles = useAllMenuFeatureToggles(); const flags = React.useMemo( () => ({ @@ -93,6 +100,13 @@ export const SetupFlopFlipProvider = (props: Props) => { }), [allMenuFeatureToggles.allFeatureToggles, props.flags] ); + React.useMemo(() => { + combineAdapters.combine( + [ldAdapter, enableFeatureConfigurationFetching && httpAdapter].filter( + Boolean + ) + ); + }, [enableFeatureConfigurationFetching]); const defaultFlags = React.useMemo( () => ({ From 3ba1fe3fff691eecff0004fa752ad9665a878742 Mon Sep 17 00:00:00 2001 From: tdeekens Date: Fri, 22 Jan 2021 15:50:22 +0100 Subject: [PATCH 6/9] refactor: simplify code --- .../setup-flop-flip-provider.tsx | 19 +++++++------------ packages/constants/src/constants.ts | 1 + 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx index b80eb5615f..c8106961d6 100644 --- a/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx +++ b/packages/application-shell/src/components/setup-flop-flip-provider/setup-flop-flip-provider.tsx @@ -81,15 +81,10 @@ const parseFlags = (fetchedFlags: TFetchedFlags): TParsedHttpAdapterFlags => ]) ); -type TAdditionalEnvironmentProperties = { - env: { - enableFeatureConfigurationFetching?: boolean; - } -}; export const SetupFlopFlipProvider = (props: Props) => { const apolloClient = useApolloClient(); - const enableFeatureConfigurationFetching = useApplicationContext( - (context) => context.environment.env.enableFeatureConfigurationFetching + const enableFeatureConfigurationFetching = useApplicationContext( + (context) => context.environment.enableFeatureConfigurationFetching ); const allMenuFeatureToggles = useAllMenuFeatureToggles(); const flags = React.useMemo( @@ -101,11 +96,11 @@ export const SetupFlopFlipProvider = (props: Props) => { [allMenuFeatureToggles.allFeatureToggles, props.flags] ); React.useMemo(() => { - combineAdapters.combine( - [ldAdapter, enableFeatureConfigurationFetching && httpAdapter].filter( - Boolean - ) - ); + if (enableFeatureConfigurationFetching) { + combineAdapters.combine([ldAdapter, httpAdapter]); + } else { + combineAdapters.combine([ldAdapter]); + } }, [enableFeatureConfigurationFetching]); const defaultFlags = React.useMemo( diff --git a/packages/constants/src/constants.ts b/packages/constants/src/constants.ts index b445ec4633..17039cc909 100644 --- a/packages/constants/src/constants.ts +++ b/packages/constants/src/constants.ts @@ -169,5 +169,6 @@ export interface ApplicationWindow extends Window { useFullRedirectsForLinks?: boolean; // Properties for OIDC-like workflow for development __DEVELOPMENT__?: ApplicationOidcForDevelopmentConfig; + enableFeatureConfigurationFetching?: boolean; }; } From 60b0d12453d7ecda34731f11b43758996b33636d Mon Sep 17 00:00:00 2001 From: tdeekens Date: Fri, 22 Jan 2021 16:18:45 +0100 Subject: [PATCH 7/9] chore: sort things differently --- packages/constants/src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/constants/src/constants.ts b/packages/constants/src/constants.ts index 17039cc909..79647e7f4b 100644 --- a/packages/constants/src/constants.ts +++ b/packages/constants/src/constants.ts @@ -166,9 +166,9 @@ export interface ApplicationWindow extends Window { trackingSentry?: string; trackingGtm?: string; enableSignUp?: boolean; + enableFeatureConfigurationFetching?: boolean; useFullRedirectsForLinks?: boolean; // Properties for OIDC-like workflow for development __DEVELOPMENT__?: ApplicationOidcForDevelopmentConfig; - enableFeatureConfigurationFetching?: boolean; }; } From 5a753f00c6aaa3838469ba5b5a1cb9c211b4dc4e Mon Sep 17 00:00:00 2001 From: Tobias Deekens Date: Tue, 26 Jan 2021 14:15:20 +0100 Subject: [PATCH 8/9] Create dull-bees-obey.md --- .changeset/dull-bees-obey.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .changeset/dull-bees-obey.md diff --git a/.changeset/dull-bees-obey.md b/.changeset/dull-bees-obey.md new file mode 100644 index 0000000000..8d680163cf --- /dev/null +++ b/.changeset/dull-bees-obey.md @@ -0,0 +1,28 @@ +--- +"@commercetools-backend/express": patch +"@commercetools-backend/loggers": patch +"@commercetools-frontend/actions-global": patch +"@commercetools-frontend/application-components": patch +"@commercetools-frontend/application-config": patch +"@commercetools-frontend/application-shell-connectors": patch +"@commercetools-frontend/application-shell": patch +"@commercetools-frontend/assets": patch +"@commercetools-frontend/babel-preset-mc-app": patch +"@commercetools-frontend/browser-history": patch +"@commercetools-frontend/constants": patch +"@commercetools-frontend/create-mc-app": patch +"@commercetools-frontend/cypress": patch +"@commercetools-frontend/jest-preset-mc-app": patch +"@commercetools-frontend/jest-stylelint-runner": patch +"@commercetools-frontend/l10n": patch +"@commercetools-frontend/mc-dev-authentication": patch +"@commercetools-frontend/mc-html-template": patch +"@commercetools-frontend/mc-scripts": patch +"@commercetools-frontend/notifications": patch +"@commercetools-frontend/permissions": patch +"@commercetools-frontend/react-notifications": patch +"@commercetools-frontend/sdk": patch +"@commercetools-frontend/sentry": patch +--- + +refactor: use `combine-adapter` to be able to use `http-adapter` and `launchdarkly-adapter` From 9b37abb3e28f685067b397f98fcfd3be3e891c87 Mon Sep 17 00:00:00 2001 From: Tobias Deekens Date: Tue, 26 Jan 2021 16:22:18 +0100 Subject: [PATCH 9/9] Update .changeset/dull-bees-obey.md Co-authored-by: Nicola Molinari --- .changeset/dull-bees-obey.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/dull-bees-obey.md b/.changeset/dull-bees-obey.md index 8d680163cf..54a6c73972 100644 --- a/.changeset/dull-bees-obey.md +++ b/.changeset/dull-bees-obey.md @@ -25,4 +25,4 @@ "@commercetools-frontend/sentry": patch --- -refactor: use `combine-adapter` to be able to use `http-adapter` and `launchdarkly-adapter` +Add internal opt-in support for combining feature flag adapters.