@admin-layout/client 12.0.16-alpha.45 → 12.0.16-alpha.46
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/lib/components/UpdateSettings/UpdateSettings.server.d.ts +6 -9
- package/lib/components/UpdateSettings/UpdateSettings.server.d.ts.map +1 -1
- package/lib/components/UpdateSettings/UpdateSettings.server.js +67 -11
- package/lib/components/UpdateSettings/UpdateSettings.server.js.map +1 -1
- package/package.json +2 -2
|
@@ -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,
|
|
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:
|
|
10
|
-
context
|
|
11
|
-
params
|
|
5
|
+
export declare function settingsLoaderUtil({ request, context, params }: {
|
|
6
|
+
request: any;
|
|
7
|
+
context: any;
|
|
8
|
+
params: any;
|
|
12
9
|
}): Promise<{
|
|
13
|
-
settings:
|
|
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":"
|
|
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
|
|
9
|
-
async function fetchPageSettingsWithFetch(request,
|
|
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 =
|
|
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
|
-
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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":"
|
|
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.
|
|
3
|
+
"version": "12.0.16-alpha.46",
|
|
4
4
|
"description": "Sample client for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"typescript": {
|
|
45
45
|
"definition": "lib/index.d.ts"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "ce30e2742a315175f9ec774fe3422976b5d7110f"
|
|
48
48
|
}
|