@admin-layout/client 12.0.16-alpha.45 → 12.0.16-alpha.48

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.
@@ -1,16 +1,13 @@
1
- import { IAppLoadContext } from '@common-stack/client-core';
2
- import { IResourceParams } from '@common-stack/core';
3
- import { ProSettings } from '../../interfaces';
4
1
  export declare const settingsCookie: import("@remix-run/server-runtime").Cookie;
5
- export declare function fetchPageSettingsWithFetch(request: Request, graphqlUrl?: string): Promise<{
2
+ export declare function fetchPageSettingsWithFetch(request: Request, overrideIdentifier?: string): Promise<{
6
3
  data: any;
7
4
  }>;
8
- export declare function settingsLoaderUtil({ request, context, params, }: {
9
- request: Request;
10
- context?: IAppLoadContext;
11
- params?: IResourceParams;
5
+ export declare function settingsLoaderUtil({ request, context, params }: {
6
+ request: any;
7
+ context: any;
8
+ params: any;
12
9
  }): Promise<{
13
- settings: ProSettings;
10
+ settings: any;
14
11
  setCookie: string;
15
12
  }>;
16
13
  //# sourceMappingURL=UpdateSettings.server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UpdateSettings.server.d.ts","sourceRoot":"","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAcrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAK/C,eAAO,MAAM,cAAc,4CAMzB,CAAC;AAGH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM;;GAqErF;AAED,wBAAsB,kBAAkB,CAAC,EACrC,OAAO,EACP,OAAO,EACP,MAAM,GACT,EAAE;IACC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,MAAM,CAAC,EAAE,eAAe,CAAC;CAC5B,GAAG,OAAO,CAAC;IACR,QAAQ,EAAE,WAAW,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC,CAsFD"}
1
+ {"version":3,"file":"UpdateSettings.server.d.ts","sourceRoot":"","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc,4CAMzB,CAAC;AAGH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,kBAAkB,CAAC,EAAE,MAAM;;GAmF7F;AAED,wBAAsB,kBAAkB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE;;;;CAAA;;;GA0IpE"}
@@ -5,28 +5,41 @@ import {createCookie}from'@remix-run/node';import {ConfigCollectionName,ConfigFr
5
5
  path: '/', // Ensure cookie is available for all paths
6
6
  domain: config.isProd ? config.APP_DOMAIN : undefined,
7
7
  });
8
- // Direct fetch-based implementation for fetching page settings
9
- async function fetchPageSettingsWithFetch(request, graphqlUrl) {
8
+ // Alternative: Direct fetch-based implementation (for testing/comparison)
9
+ async function fetchPageSettingsWithFetch(request, overrideIdentifier) {
10
10
  const resource = generateCdecodeUri(DEFAULT_TENANT_ID, {
11
11
  resourceType: ConfigCollectionName.Applications,
12
12
  resourceId: config.APPLICATION_ID,
13
13
  idField: 'appId',
14
14
  }, {}, ConfigFragmentName.UiSettings);
15
- const url = graphqlUrl || process.env.GRAPHQL_URL || 'http://localhost:8080/graphql';
15
+ const url = process.env.GRAPHQL_URL || 'http://localhost:8080/graphql';
16
16
  // Convert GraphQL DocumentNode to string
17
17
  const query = print(GetPageSettingsDocument);
18
+ // Prepare options with optional overrides
19
+ const options = {
20
+ schemaId: ConfigurationSchemaId.UiLayout,
21
+ target: 2 /* ConfigurationTarget.APPLICATION */,
22
+ };
23
+ // Add overrides if provided
24
+ if (overrideIdentifier) {
25
+ options.overrides = {
26
+ overrideIdentifier,
27
+ };
28
+ }
29
+ // Add timestamp to force cache invalidation
18
30
  const variables = {
19
31
  resourceUri: resource,
20
- options: {
21
- schemaId: ConfigurationSchemaId.UiLayout,
22
- target: 2 /* ConfigurationTarget.APPLICATION */,
23
- },
32
+ options,
33
+ _timestamp: Date.now(), // Force cache bust
24
34
  };
25
35
  console.log('🔍 Fetching settings with direct fetch to:', url);
26
36
  console.log('🔍 Query variables:', JSON.stringify(variables, null, 2));
27
37
  // Forward cookies from the incoming request
28
38
  const headers = {
29
39
  'Content-Type': 'application/json',
40
+ 'Cache-Control': 'no-cache, no-store, must-revalidate',
41
+ Pragma: 'no-cache',
42
+ Expires: '0',
30
43
  };
31
44
  const cookieHeader = request.headers.get('Cookie');
32
45
  if (cookieHeader) {
@@ -62,18 +75,60 @@ async function fetchPageSettingsWithFetch(request, graphqlUrl) {
62
75
  throw error;
63
76
  }
64
77
  }
65
- async function settingsLoaderUtil({ request, context, params, }) {
78
+ async function settingsLoaderUtil({ request, context, params }) {
66
79
  const cookieHeader = request.headers.get('Cookie');
67
- // Fetch settings from backend using direct fetch
80
+ // Detect device type from User-Agent (simplified detection)
81
+ const userAgent = request.headers.get('User-Agent') || '';
82
+ const isMobile = /mobile|android|iphone|ipad|ipod/i.test(userAgent);
83
+ const deviceType = isMobile ? 'mobile' : 'desktop';
84
+ // Fetch ALL settings for this device upfront (includes all route overrides)
85
+ // Pass device-level override to get all route-specific overrides for this device
86
+ const overrideIdentifier = `[${deviceType}]`;
87
+ // Fetch settings with device override - this will include ALL route overrides for this device
88
+ // Fetch settings from backend - choose method based on flag
68
89
  console.log('📡 Using direct fetch to get settings');
69
- const result = await fetchPageSettingsWithFetch(request);
90
+ const result = await fetchPageSettingsWithFetch(request, overrideIdentifier);
91
+ console.log('RESULT=========>', JSON.stringify(result));
70
92
  const pageSettings = result?.data?.pageSettings?.settings
71
93
  ? JSON.parse(JSON.stringify(result?.data?.pageSettings?.settings))
72
94
  : null;
73
- // Extract uilayout settings if available
95
+ // pageSettings now contains:
96
+ // {
97
+ // uilayout: { base config },
98
+ // [/dashboard][mobile]: { overrides for /dashboard on mobile },
99
+ // [/profile][mobile]: { overrides for /profile on mobile },
100
+ // ... etc
101
+ // }
102
+ // Extract uilayout settings and preserve all other settings
74
103
  const uilayout = pageSettings?.uilayout;
75
104
  const hasUilayoutData = uilayout && typeof uilayout === 'object' && Object.keys(uilayout).length > 0;
105
+ // Extract bracket pattern overrides (keys that start with [)
106
+ const bracketOverrides = {};
107
+ // Extract other top-level settings (like organization, etc.)
108
+ const otherSettings = {};
109
+ Object.keys(pageSettings || {}).forEach((key) => {
110
+ if (key.startsWith('[') && key.endsWith(']')) {
111
+ bracketOverrides[key] = pageSettings[key];
112
+ }
113
+ else if (key !== 'uilayout') {
114
+ // Preserve other top-level settings like organization
115
+ otherSettings[key] = pageSettings[key];
116
+ }
117
+ });
76
118
  let pageDefaultSettings = hasUilayoutData ? uilayout : pageSettings || {};
119
+ console.log('🔍 DEBUG - bracketOverrides:', JSON.stringify(bracketOverrides, null, 2));
120
+ console.log('🔍 DEBUG - otherSettings:', JSON.stringify(otherSettings, null, 2));
121
+ // Structure the settings properly for the frontend
122
+ // The frontend expects uiSettings.overrides to contain the bracket pattern overrides
123
+ pageDefaultSettings = {
124
+ ...pageDefaultSettings,
125
+ ...otherSettings, // Add other top-level settings like organization
126
+ uiSettings: {
127
+ ...pageDefaultSettings.uiSettings,
128
+ overrides: bracketOverrides, // Put bracket overrides in uiSettings.overrides
129
+ },
130
+ };
131
+ console.log('🔍 DEBUG - final pageDefaultSettings:', JSON.stringify(pageDefaultSettings, null, 2));
77
132
  // Add required keys that might not be in backend
78
133
  pageDefaultSettings = {
79
134
  ...pageDefaultSettings,
@@ -130,5 +185,6 @@ async function settingsLoaderUtil({ request, context, params, }) {
130
185
  });
131
186
  // Refresh the cookie to keep it active
132
187
  const cookie = await settingsCookie.serialize(settings);
188
+ console.log('FULL_SETTINGS', fullSettings);
133
189
  return { settings: fullSettings, setCookie: cookie };
134
190
  }export{fetchPageSettingsWithFetch,settingsCookie,settingsLoaderUtil};//# sourceMappingURL=UpdateSettings.server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UpdateSettings.server.js","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"sourcesContent":[null],"names":[],"mappings":"mkBA0GY,MAAA,cAAE,GAAgB,YAAA,CAAA,UAAA,EAAA;IAC1B,MAAM,EAAC,EAAE,GAAA,EAAA,GAAA,EAAA,GAAA,EAAgB;AAC5B,IAAG,QAAQ,EAAA,KAAA;IACR,QAAQ,EAAE;IACV,IAAA,EAAA,GAAS;AACZ,IAsFA,MAAA,EAAA,MAAA,CAAA,MAAA,GAAA,MAAA,CAAA,UAAA,GAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"UpdateSettings.server.js","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAkPC,IAAA,QAAA,EAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@admin-layout/client",
3
- "version": "12.0.16-alpha.45",
3
+ "version": "12.0.16-alpha.48",
4
4
  "description": "Sample client for higher packages to depend on",
5
5
  "license": "ISC",
6
6
  "author": "CDMBase LLC",
@@ -26,7 +26,7 @@
26
26
  "serialize-error": "^8.0.0"
27
27
  },
28
28
  "devDependencies": {
29
- "common": "12.0.16-alpha.44",
29
+ "common": "12.0.16-alpha.48",
30
30
  "rc-menu": "^9.16.1"
31
31
  },
32
32
  "peerDependencies": {
@@ -44,5 +44,5 @@
44
44
  "typescript": {
45
45
  "definition": "lib/index.d.ts"
46
46
  },
47
- "gitHead": "3a607a791be415119ea17a70367ba32204068214"
47
+ "gitHead": "e1eb77f644f9d2f9d8c9d0e0867f86440c6ad921"
48
48
  }