@common-stack/frontend-stack-react 4.0.1-alpha.36 → 4.0.1-alpha.40

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.
@@ -11,19 +11,28 @@ const errorLink = onError(({ graphQLErrors, networkError }) => {
11
11
  }
12
12
  });
13
13
  const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject, clientState, httpGraphqlURL, httpLocalGraphqlURL, initialState, logger, }) => {
14
+ logger.debug('Initializing Apollo Client with parameters', {
15
+ scope,
16
+ isDev,
17
+ isDebug,
18
+ isSSR,
19
+ httpGraphqlURL,
20
+ httpLocalGraphqlURL,
21
+ });
14
22
  const isBrowser = scope === 'browser';
15
23
  const isServer = scope === 'server';
16
24
  const cache = createCache({ getDataIdFromObject, clientState, logger });
17
25
  logger.debug('Created new Apollo memory cache');
18
26
  const retryLink = new RetryLink({
19
27
  attempts: async (count, operation, error) => {
28
+ logger.debug('Retrying link attempt', { count, operation, error });
20
29
  const promises = (clientState.retryLinkAttemptFuncs || []).map((func) => func(count, operation, error));
21
30
  try {
22
31
  const result = await Promise.all(promises);
23
32
  return !!result.find((item) => item && isBoolean(item));
24
33
  }
25
34
  catch (e) {
26
- logger.trace('Error occurred in retryLink Attempt condition', e);
35
+ logger.error('Error occurred in retryLink attempt condition', e);
27
36
  throw e;
28
37
  }
29
38
  },
@@ -31,6 +40,7 @@ const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject,
31
40
  let link;
32
41
  if (isBrowser) {
33
42
  const connectionParams = async () => {
43
+ logger.debug('Getting WebSocket connection parameters');
34
44
  const param = {};
35
45
  for (const connectionParam of clientState.connectionParams) {
36
46
  const result = await connectionParam();
@@ -42,26 +52,24 @@ const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject,
42
52
  url: httpGraphqlURL.replace(/^http/, 'ws'),
43
53
  retryAttempts: 10,
44
54
  lazy: true,
45
- // reconnect: true,
46
- // timeout: 30000,
47
55
  shouldRetry: () => true,
48
56
  keepAlive: 10000,
49
57
  connectionParams,
50
58
  on: {
51
59
  connected: (socket) => logger.debug('WebSocket connected'),
52
60
  error: async (error) => {
53
- logger.error(error, '[WS connectionCallback error] %j');
61
+ logger.error('WebSocket connection error', error);
54
62
  const promises = (clientState.connectionCallbackFuncs || []).map((func) => func(wsLink, error, {}));
55
63
  try {
56
64
  await Promise.all(promises);
57
65
  }
58
66
  catch (err) {
59
- logger.trace('Error occurred in connectionCallback condition', err);
67
+ logger.trace('Error occurred in WebSocket connection callback', err);
60
68
  throw err;
61
69
  }
62
70
  },
63
- ping: () => logger.trace('Pinged Server'),
64
- pong: () => logger.trace('Pong received'),
71
+ ping: () => logger.trace('WebSocket ping sent'),
72
+ pong: () => logger.trace('WebSocket pong received'),
65
73
  },
66
74
  }));
67
75
  link = ApolloLink.split(({ query, operationName }) => {
@@ -73,6 +81,7 @@ const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject,
73
81
  }, wsLink, new HttpLink({ uri: httpGraphqlURL, credentials: 'include', fetch }));
74
82
  }
75
83
  else if (isServer) {
84
+ logger.debug('Creating BatchHttpLink for server');
76
85
  link = new BatchHttpLink({
77
86
  uri: httpLocalGraphqlURL,
78
87
  fetch,
@@ -82,9 +91,10 @@ const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject,
82
91
  });
83
92
  }
84
93
  else {
94
+ logger.debug('Creating HttpLink for native');
85
95
  link = new HttpLink({ uri: httpLocalGraphqlURL, fetch, credentials: 'include' });
86
96
  }
87
- const links = [errorLink, retryLink, ...(clientState.preLinks || []), link];
97
+ const links = [errorLink, retryLink, ...(clientState.preLinks || []), link].filter(Boolean);
88
98
  const params = {
89
99
  queryDeduplication: true,
90
100
  typeDefs: schema.concat(clientState.typeDefs || ''),
@@ -94,6 +104,7 @@ const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject,
94
104
  credentials: 'include',
95
105
  connectToDevTools: isBrowser && (isDev || isDebug),
96
106
  };
107
+ logger.trace('Apollo client options', params);
97
108
  if (isSSR) {
98
109
  if (isBrowser) {
99
110
  params.ssrForceFetchDelay = 100;
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ supportedLngs: string[];
3
+ fallbackLng: string;
4
+ defaultNS: string;
5
+ };
6
+ export default _default;
@@ -0,0 +1,9 @@
1
+ var i18n = {
2
+ // This is the list of languages your application supports
3
+ supportedLngs: ["en", "es"],
4
+ // This is the language you want to use in case
5
+ // if the user language is not in the supportedLngs
6
+ fallbackLng: "en",
7
+ // The default namespace of i18next is "translation", but you can customize it here
8
+ defaultNS: "common",
9
+ };export{i18n as default};
@@ -0,0 +1,2 @@
1
+ declare let i18next: any;
2
+ export default i18next;
@@ -0,0 +1,18 @@
1
+ import Backend from'i18next-fs-backend';import {resolve}from'node:path';import {RemixI18Next}from'remix-i18next/server';import i18n from'./i18n.js';new RemixI18Next({
2
+ detection: {
3
+ supportedLanguages: i18n.supportedLngs,
4
+ fallbackLanguage: i18n.fallbackLng,
5
+ },
6
+ // This is the configuration for i18next used
7
+ // when translating messages server-side only
8
+ i18next: {
9
+ ...i18n,
10
+ backend: {
11
+ loadPath: resolve('./public/cdm-locales/{{lng}}/{{ns}}.json'),
12
+ },
13
+ },
14
+ // The i18next plugins you want RemixI18next to use for `i18n.getFixedT` inside loaders and actions.
15
+ // E.g. The Backend plugin for loading translations from the file system
16
+ // Tip: You could pass `resources` to the `i18next` configuration and avoid a backend here
17
+ plugins: [Backend],
18
+ });
@@ -0,0 +1,2 @@
1
+ export * from './i18next.server';
2
+ export * from './i18n';
package/lib/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * from './backend/middlewares/cors';
5
5
  export * from './backend/middlewares/container';
6
6
  export * from './backend/middlewares/error';
7
7
  export * from './load-context.server';
8
+ export * from './i18n-localization';
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- export{UtilityClass,logger}from'./utils/index.js';export{createClientContainer}from'./config/client.service.js';export{createReduxStore,epicMiddlewareFunc,persistConfig}from'./config/redux-config.js';export{clientLoaderWithMiddleware}from'./tools/clientLoaderWithMiddleware.js';export{loaderWithMiddleware}from'./tools/loaderWithMiddleware.js';export{corsMiddleware}from'./backend/middlewares/cors.js';export{TYPES,containerMiddleware}from'./backend/middlewares/container.js';export{errorMiddleware}from'./backend/middlewares/error.js';export{loadContext}from'./load-context.server.js';
1
+ export{UtilityClass,logger}from'./utils/index.js';export{createClientContainer}from'./config/client.service.js';export{createReduxStore,epicMiddlewareFunc,persistConfig}from'./config/redux-config.js';export{clientLoaderWithMiddleware}from'./tools/clientLoaderWithMiddleware.js';export{loaderWithMiddleware}from'./tools/loaderWithMiddleware.js';export{corsMiddleware}from'./backend/middlewares/cors.js';export{TYPES,containerMiddleware}from'./backend/middlewares/container.js';export{errorMiddleware}from'./backend/middlewares/error.js';export{loadContext}from'./load-context.server.js';import'./i18n-localization/i18next.server.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common-stack/frontend-stack-react",
3
- "version": "4.0.1-alpha.36",
3
+ "version": "4.0.1-alpha.40",
4
4
  "description": "Client Module for react app",
5
5
  "homepage": "https://github.com/cdmbase/fullstack-pro#readme",
6
6
  "bugs": {
@@ -30,7 +30,11 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@common-stack/client-react": "4.0.1-alpha.36",
33
- "@common-stack/core": "4.0.1-alpha.31"
33
+ "@common-stack/core": "4.0.1-alpha.31",
34
+ "i18next-fs-backend": "^2.3.1",
35
+ "i18next-http-backend": "^2.5.2",
36
+ "react-i18next": "^14.1.0",
37
+ "remix-i18next": "^6.1.0"
34
38
  },
35
39
  "devDependencies": {
36
40
  "jest-fetch-mock": "^3.0.3",
@@ -39,10 +43,8 @@
39
43
  "peerDependencies": {
40
44
  "@apollo/client": ">=3.0.0",
41
45
  "@remix-run/react": "^2.9.2",
42
- "react": ">=16.8.6",
43
- "react-dom": ">=16.8.6",
44
- "react-router": ">=6.0.0",
45
- "redux": ">=4.0.1"
46
+ "react": ">=18",
47
+ "react-dom": ">=18"
46
48
  },
47
49
  "publishConfig": {
48
50
  "access": "public"
@@ -50,5 +52,5 @@
50
52
  "typescript": {
51
53
  "definition": "lib/index.d.ts"
52
54
  },
53
- "gitHead": "8bbf23ccf6303d3a3d7720b4469b168b22d23483"
55
+ "gitHead": "d0bece51592356e7ee1c7fcb3033b36416b2d41b"
54
56
  }