@common-stack/rollup-vite-utils 8.0.1-alpha.0 → 8.0.1-alpha.2
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/tools/codegen/generateCodegenConfig.cjs +17 -2
- package/lib/tools/codegen/generateCodegenConfig.cjs.map +1 -1
- package/lib/tools/codegen/generateCodegenConfig.d.ts +10 -0
- package/lib/tools/codegen/generateCodegenConfig.js +17 -2
- package/lib/tools/codegen/generateCodegenConfig.js.map +1 -1
- package/lib/tools/codegen/modulePathParser.d.ts +56 -0
- package/lib/tools/codegen/performCopyOperations.cjs +217 -46
- package/lib/tools/codegen/performCopyOperations.cjs.map +1 -1
- package/lib/tools/codegen/performCopyOperations.d.ts +24 -5
- package/lib/tools/codegen/performCopyOperations.js +217 -46
- package/lib/tools/codegen/performCopyOperations.js.map +1 -1
- package/lib/tools/codegen/performCopyOperations.test.d.ts +1 -0
- package/lib/tools/codegen/readModules.cjs +219 -110
- package/lib/tools/codegen/readModules.cjs.map +1 -1
- package/lib/tools/codegen/readModules.d.ts +29 -7
- package/lib/tools/codegen/readModules.js +219 -110
- package/lib/tools/codegen/readModules.js.map +1 -1
- package/lib/tools/codegen/readModules.test.d.ts +1 -0
- package/lib/tools/codegen/templates/common/rollup.config.mjs.template +6 -4
- package/lib/tools/codegen/templates/common/src/apollo-context.ts.template +10 -4
- package/lib/tools/codegen/templates/common/src/index.ts.template +1 -1
- package/lib/tools/codegen/templates/common/tsconfig.json.template +1 -3
- package/package.json +7 -5
- /package/lib/tools/codegen/{readModule.test.d.ts → generateCodegenConfig.test.d.ts} +0 -0
|
@@ -1,140 +1,249 @@
|
|
|
1
|
-
import fs__default from'fs';import path__default from'path';import {createRequire}from'module';import {pathsConfig}from'./commonPaths.js';//
|
|
2
|
-
// import { pathsConfig, checkFileExists } from './commonPaths.mjs';
|
|
3
|
-
// ESM-compatible require
|
|
1
|
+
import fs__default from'fs';import path__default from'path';import {createRequire}from'module';import {pathsConfig}from'./commonPaths.js';// ESM-compatible require
|
|
4
2
|
const esmRequire = createRequire(import.meta.url);
|
|
5
3
|
/**
|
|
6
|
-
*
|
|
4
|
+
* For local modules, if the relative path ends with "lib",
|
|
5
|
+
* remove that segment so that the package root is used.
|
|
6
|
+
*/
|
|
7
|
+
function normalizeLocalBase(modulePath) {
|
|
8
|
+
const parts = modulePath.split(path__default.sep);
|
|
9
|
+
if (parts[parts.length - 1] === 'lib') {
|
|
10
|
+
parts.pop();
|
|
11
|
+
}
|
|
12
|
+
return parts.join(path__default.sep);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* For variant local modules, strip off a trailing role folder (if present)
|
|
16
|
+
* so that the group name equals the package base.
|
|
17
|
+
* E.g. "packages-modules/mail-campaign/browser" becomes "packages-modules/mail-campaign".
|
|
18
|
+
*/
|
|
19
|
+
function getInternalGroupName(modName) {
|
|
20
|
+
const segments = modName.split(path__default.sep);
|
|
21
|
+
const variants = ['server', 'client', 'browser', 'core'];
|
|
22
|
+
if (segments.length && variants.includes(segments[segments.length - 1])) {
|
|
23
|
+
segments.pop();
|
|
24
|
+
}
|
|
25
|
+
return segments.join(path__default.sep);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Determines if a module is external by checking if its computed name starts with "node_modules".
|
|
29
|
+
* (This approach does not rely on any hard-coded vendor-specific package name prefixes.)
|
|
30
|
+
*/
|
|
31
|
+
function isExternalModule(mod) {
|
|
32
|
+
return mod.name.split(path__default.sep)[0] === 'node_modules';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Transforms the collected module definitions into the desired final output format.
|
|
7
36
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
37
|
+
* - External modules:
|
|
38
|
+
* • If the module name contains "-browser", output an object with keys "browser", "client" and "core".
|
|
39
|
+
* The client and core are computed by replacing the "-browser" suffix with "-client" and "-core" respectively.
|
|
40
|
+
* • Else if the name ends with "-server", output an object with key "server".
|
|
41
|
+
* • Otherwise, output an object with key "independent".
|
|
11
42
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
43
|
+
* - Internal (local) modules:
|
|
44
|
+
* • If the module is flagged as independent (flat, no variant indicated), output an object with key "independent"
|
|
45
|
+
* that points to `<baseModule>/src`.
|
|
46
|
+
* • Otherwise (when flagged as variant) group them by their normalized base and output a single object containing
|
|
47
|
+
* four keys: client, core, browser, and server (e.g. `<groupName>/client/src`, etc.).
|
|
14
48
|
*/
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
acc[0].push(mod);
|
|
49
|
+
function transformModules(modules) {
|
|
50
|
+
const finalOutput = [];
|
|
51
|
+
const variantGroups = new Map();
|
|
52
|
+
modules.forEach((mod) => {
|
|
53
|
+
if (isExternalModule(mod)) {
|
|
54
|
+
// External modules: check if the computed name indicates a browser variant.
|
|
55
|
+
if (mod.name.includes('-browser')) {
|
|
56
|
+
// Remove only the trailing "-browser" occurrence to compute client/core names.
|
|
57
|
+
const base = mod.name.replace(/-browser$/, '');
|
|
58
|
+
finalOutput.push({
|
|
59
|
+
client: `${base}-client/lib`,
|
|
60
|
+
core: `${base}-core/lib`,
|
|
61
|
+
browser: `${base}-browser/lib`,
|
|
62
|
+
});
|
|
30
63
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
configData.externalModules?.forEach((mod) => {
|
|
34
|
-
if (mod.endsWith('-server')) {
|
|
35
|
-
acc[1].push(mod);
|
|
64
|
+
else if (mod.name.endsWith('-server')) {
|
|
65
|
+
finalOutput.push({ server: `${mod.name}/lib` });
|
|
36
66
|
}
|
|
37
67
|
else {
|
|
38
|
-
|
|
68
|
+
finalOutput.push({ independent: `${mod.name}/lib` });
|
|
39
69
|
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (mod.
|
|
44
|
-
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Internal (local) modules.
|
|
73
|
+
if (mod.isIndependentLocal) {
|
|
74
|
+
finalOutput.push({ independent: `${mod.name}/src` });
|
|
45
75
|
}
|
|
46
76
|
else {
|
|
47
|
-
|
|
77
|
+
const groupName = getInternalGroupName(mod.name);
|
|
78
|
+
if (!variantGroups.has(groupName)) {
|
|
79
|
+
variantGroups.set(groupName, {
|
|
80
|
+
client: `${groupName}/client/src`,
|
|
81
|
+
core: `${groupName}/core/src`,
|
|
82
|
+
browser: `${groupName}/browser/src`,
|
|
83
|
+
server: `${groupName}/server/src`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
48
86
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return [...finalOutput, ...Array.from(variantGroups.values())];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Reads modules from one or more JSON config files (e.g., cdecode-config.json) and returns an array,
|
|
93
|
+
* transformed into the final desired output format of module objects.
|
|
94
|
+
*
|
|
95
|
+
* The processing steps are:
|
|
96
|
+
* 1. Load module names (from keys such as modules, externalModules, devModules) from each config.
|
|
97
|
+
* 2. Deduplicate the raw module names.
|
|
98
|
+
* 3. For each raw module string, attempt to resolve it using esmRequire.resolve (with fallback).
|
|
99
|
+
* 4. Compute the module's base folder relative to the repository root.
|
|
100
|
+
* 5. Determine if the module is local (i.e. does not live in node_modules).
|
|
101
|
+
* 6. For local modules, decide whether it is "variant" (if the raw config string indicates "-browser" or "-server")
|
|
102
|
+
* or independent (if not).
|
|
103
|
+
* 7. Optionally, if a package.json exists, adjust the server path using its "main" field.
|
|
104
|
+
* 8. Finally, transform the processed definitions into the desired output format.
|
|
105
|
+
*
|
|
106
|
+
* @param {string[]} configPaths - Array of configuration file paths.
|
|
107
|
+
* @returns {any[]} Final processed module objects.
|
|
108
|
+
*/
|
|
109
|
+
function readModules(configPaths = []) {
|
|
110
|
+
const rawModuleSet = new Set();
|
|
111
|
+
// Collect raw module names from all config files.
|
|
112
|
+
configPaths.forEach((configFile) => {
|
|
113
|
+
if (!fs__default.existsSync(configFile)) {
|
|
114
|
+
console.error(`Config file not found: ${configFile}`);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
const configData = JSON.parse(fs__default.readFileSync(configFile, 'utf-8'));
|
|
118
|
+
(configData.modules || []).forEach((mod) => rawModuleSet.add(mod));
|
|
119
|
+
(configData.externalModules || []).forEach((mod) => rawModuleSet.add(mod));
|
|
120
|
+
(configData.devModules || []).forEach((mod) => rawModuleSet.add(mod));
|
|
121
|
+
});
|
|
122
|
+
const collectedModules = [];
|
|
123
|
+
// Process each unique raw module.
|
|
124
|
+
rawModuleSet.forEach((rawStr) => {
|
|
56
125
|
try {
|
|
126
|
+
// Determine if the raw config string suggests a variant module.
|
|
127
|
+
const isVariant = rawStr.includes('-browser') || rawStr.endsWith('-server');
|
|
57
128
|
let resolvedFile;
|
|
58
129
|
try {
|
|
59
|
-
//
|
|
60
|
-
resolvedFile = esmRequire.resolve(
|
|
130
|
+
// Primary resolution: try to resolve directly to package.json.
|
|
131
|
+
resolvedFile = esmRequire.resolve(path__default.join(rawStr, 'package.json'));
|
|
61
132
|
}
|
|
62
133
|
catch (err) {
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
134
|
+
// If resolution fails, try to use error file details.
|
|
135
|
+
if (err && typeof err === 'object' && 'path' in err && typeof err.path === 'string') {
|
|
136
|
+
let filePath = err.path;
|
|
137
|
+
// Check if the file path includes a "/lib/" segment.
|
|
138
|
+
const libSegment = `${path__default.sep}lib${path__default.sep}`;
|
|
139
|
+
const libIndex = filePath.indexOf(libSegment);
|
|
140
|
+
if (libIndex !== -1) {
|
|
141
|
+
// Remove the lib folder and what follows, then append package.json.
|
|
142
|
+
filePath = filePath.slice(0, libIndex);
|
|
143
|
+
filePath = path__default.join(filePath, 'package.json');
|
|
144
|
+
}
|
|
145
|
+
if (fs__default.existsSync(filePath)) {
|
|
146
|
+
resolvedFile = filePath;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// Fallback: if the error-derived path fails, remove "/lib" from the raw string.
|
|
150
|
+
const fallbackModule = rawStr.includes('/lib') ? rawStr.replace(/\/lib.*$/, '') : rawStr;
|
|
151
|
+
try {
|
|
152
|
+
resolvedFile = esmRequire.resolve(path__default.join(fallbackModule, 'package.json'));
|
|
153
|
+
}
|
|
154
|
+
catch (err2) {
|
|
155
|
+
console.warn(`Could not resolve module ${rawStr} even with fallback ${fallbackModule}. Skipping.`);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
67
159
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
160
|
+
else {
|
|
161
|
+
// Fallback resolution if error object doesn't contain a path.
|
|
162
|
+
const fallbackModule = rawStr.includes('/lib') ? rawStr.replace(/\/lib.*$/, '') : rawStr;
|
|
163
|
+
try {
|
|
164
|
+
resolvedFile = esmRequire.resolve(path__default.join(fallbackModule, 'package.json'));
|
|
165
|
+
}
|
|
166
|
+
catch (err2) {
|
|
167
|
+
console.warn(`Could not resolve module ${rawStr} even with fallback ${fallbackModule}. Skipping.`);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
71
170
|
}
|
|
72
171
|
}
|
|
73
172
|
const dirName = path__default.dirname(resolvedFile);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
81
|
-
}
|
|
82
|
-
processedModules.add(baseModule);
|
|
83
|
-
// For local modules, use "src" directory; for node_modules, use "lib"
|
|
173
|
+
// Compute the folder path relative to the repository root.
|
|
174
|
+
const modulePathRaw = path__default.relative(pathsConfig.repoRoot, dirName);
|
|
175
|
+
const isLocal = !modulePathRaw.split(path__default.sep).includes('node_modules');
|
|
176
|
+
const baseModule = isLocal ? normalizeLocalBase(modulePathRaw) : modulePathRaw.replace(/\/lib.*/, '');
|
|
177
|
+
// Avoid duplicates based on the computed base.
|
|
178
|
+
if (collectedModules.find((m) => m.name === baseModule))
|
|
179
|
+
return;
|
|
84
180
|
const srcOrLib = isLocal ? 'src' : 'lib';
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (isLocal) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
181
|
+
// Start a module definition.
|
|
182
|
+
const moduleDef = { raw: rawStr, name: baseModule };
|
|
183
|
+
if (!isLocal) {
|
|
184
|
+
// External modules.
|
|
185
|
+
if (rawStr.includes('-browser')) {
|
|
186
|
+
// For external variants, look for client and core as well.
|
|
187
|
+
moduleDef.browser = `${baseModule}/${srcOrLib}`;
|
|
188
|
+
// Replace only the trailing "-browser" for client/core.
|
|
189
|
+
moduleDef.client = `${baseModule.replace(/-browser$/, '-client')}/${srcOrLib}`;
|
|
190
|
+
moduleDef.core = `${baseModule.replace(/-browser$/, '-core')}/${srcOrLib}`;
|
|
191
|
+
}
|
|
192
|
+
else if (rawStr.endsWith('-server')) {
|
|
193
|
+
moduleDef.server = `${baseModule}/${srcOrLib}`;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
moduleDef.server = `${baseModule}/${srcOrLib}`;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
// Local (internal) modules.
|
|
201
|
+
if (isVariant) {
|
|
202
|
+
if (rawStr.includes('-browser')) {
|
|
203
|
+
// For variant local modules with -browser, expect subfolders for browser, client, core and server.
|
|
204
|
+
moduleDef.browser = `${baseModule}/browser/${srcOrLib}`;
|
|
205
|
+
moduleDef.client = `${baseModule}/client/${srcOrLib}`;
|
|
206
|
+
moduleDef.core = `${baseModule}/core/${srcOrLib}`;
|
|
207
|
+
moduleDef.server = `${baseModule}/server/${srcOrLib}`;
|
|
208
|
+
}
|
|
209
|
+
else if (rawStr.endsWith('-server')) {
|
|
210
|
+
moduleDef.server = `${baseModule}/server/${srcOrLib}`;
|
|
211
|
+
}
|
|
212
|
+
moduleDef.isVariant = true;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
// Independent local package with a flat structure.
|
|
216
|
+
moduleDef.server = `${baseModule}/src`;
|
|
217
|
+
moduleDef.isIndependentLocal = true;
|
|
218
|
+
}
|
|
97
219
|
}
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
...acc,
|
|
103
|
-
{
|
|
104
|
-
browser: `${baseModule}/${srcOrLib}`,
|
|
105
|
-
client: `${baseModule.replace(/-browser$/, '-client')}/${srcOrLib}`,
|
|
106
|
-
core: `${baseModule.replace(/-browser$/, '-core')}/${srcOrLib}`,
|
|
107
|
-
},
|
|
108
|
-
];
|
|
220
|
+
// Optionally, if package.json exists, adjust the server path using its "main" field.
|
|
221
|
+
let packageJsonPath;
|
|
222
|
+
if (isLocal) {
|
|
223
|
+
packageJsonPath = path__default.join(pathsConfig.repoRoot, baseModule, 'package.json');
|
|
109
224
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
...acc,
|
|
113
|
-
{
|
|
114
|
-
server: `${baseModule}/${srcOrLib}`,
|
|
115
|
-
},
|
|
116
|
-
];
|
|
225
|
+
else {
|
|
226
|
+
packageJsonPath = path__default.join('node_modules', baseModule, 'package.json');
|
|
117
227
|
}
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
228
|
+
if (fs__default.existsSync(packageJsonPath)) {
|
|
229
|
+
try {
|
|
230
|
+
const pkgContent = fs__default.readFileSync(packageJsonPath, 'utf-8');
|
|
231
|
+
const pkg = JSON.parse(pkgContent);
|
|
232
|
+
if (pkg.main) {
|
|
233
|
+
moduleDef.server = pkg.main.replace(/\.js$/, `/${srcOrLib}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
console.error(`Error reading package.json for ${baseModule}:`, error);
|
|
238
|
+
}
|
|
125
239
|
}
|
|
126
|
-
|
|
127
|
-
return [
|
|
128
|
-
...acc,
|
|
129
|
-
{
|
|
130
|
-
independent: `${baseModule}/${srcOrLib}`,
|
|
131
|
-
},
|
|
132
|
-
];
|
|
240
|
+
collectedModules.push(moduleDef);
|
|
133
241
|
}
|
|
134
242
|
catch (e) {
|
|
135
|
-
console.error(e);
|
|
136
|
-
console.log('Error while processing module:', moduleName);
|
|
137
|
-
return acc;
|
|
243
|
+
console.error('Error while processing module:', rawStr, e);
|
|
138
244
|
}
|
|
139
|
-
}
|
|
245
|
+
});
|
|
246
|
+
// Transform the intermediate definitions into the final output format.
|
|
247
|
+
const finalOutput = transformModules(collectedModules);
|
|
248
|
+
return finalOutput;
|
|
140
249
|
}export{readModules};//# sourceMappingURL=readModules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readModules.js","sources":["../../../src/tools/codegen/readModules.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"readModules.js","sources":["../../../src/tools/codegen/readModules.ts"],"sourcesContent":[null],"names":["path","fs"],"mappings":"0IAMA;AACA,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAkBlD;;;AAGG;AACH,SAAS,kBAAkB,CAAC,UAAkB,EAAA;IAC1C,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAACA,aAAI,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,KAAK,EAAE;QACnC,KAAK,C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AE,CAAC,CAAC,CAAC;SAC9D;AACL,KAAC,CAAC,CAAC;;AAGH,IAAA,MAAM,WAAW,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;AACvD,IAAA,OAAO,WAAW,CAAC;AACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { createRollupConfig } from '../../rollup.config.base.mjs';
|
|
2
|
-
import multiInput from 'rollup-plugin-multi-input';
|
|
3
2
|
|
|
4
|
-
const additionalPlugins = [
|
|
3
|
+
const additionalPlugins = [];
|
|
5
4
|
// Use the createRollupConfig function to merge the base and specific configurations
|
|
6
5
|
export default (commandLineArgs) => {
|
|
7
6
|
const isWatchMode = commandLineArgs.watch;
|
|
8
7
|
return [
|
|
9
8
|
createRollupConfig(
|
|
10
9
|
{
|
|
11
|
-
input: ['src
|
|
10
|
+
input: ['src/index.ts', 'src/generated/generated.tsx', 'src/generated/introspection-result.ts'],
|
|
12
11
|
plugins: [
|
|
13
12
|
// Spread in additional plugins specific to this config
|
|
14
13
|
...additionalPlugins,
|
|
@@ -26,7 +25,10 @@ export default (commandLineArgs) => {
|
|
|
26
25
|
},
|
|
27
26
|
],
|
|
28
27
|
},
|
|
29
|
-
|
|
28
|
+
{
|
|
29
|
+
isWatchMode,
|
|
30
|
+
generateRoutesJSON: false,
|
|
31
|
+
},
|
|
30
32
|
),
|
|
31
33
|
];
|
|
32
34
|
};
|
|
@@ -4,7 +4,7 @@ import { ApolloClient } from '@apollo/client/index.js';
|
|
|
4
4
|
import { CdmLogger } from '@cdm-logger/core';
|
|
5
5
|
import express from 'express';
|
|
6
6
|
import { IPreferncesTransformed } from '@common-stack/server-core';
|
|
7
|
-
import { IUserContext, IUserProfile, IIAuth0Token,
|
|
7
|
+
import { IUserContext, IUserProfile, IIAuth0Token, AuthStrategy } from './generated/generated-models';
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* Context
|
|
@@ -32,7 +32,7 @@ export interface IDataSources {}
|
|
|
32
32
|
|
|
33
33
|
export interface IHttpMiddlewareContext {
|
|
34
34
|
req?: express.Request & {
|
|
35
|
-
authStrategy:
|
|
35
|
+
authStrategy: AuthStrategy;
|
|
36
36
|
permissions?: any;
|
|
37
37
|
cdecodeuri?: any;
|
|
38
38
|
logger?: CdmLogger.ILogger;
|
|
@@ -42,7 +42,14 @@ export interface IHttpMiddlewareContext {
|
|
|
42
42
|
};
|
|
43
43
|
res: express.Response;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
|
|
46
|
+
export type IGraphQLContext = {
|
|
47
|
+
/**
|
|
48
|
+
* current ip of the user fetched from the request
|
|
49
|
+
*/
|
|
50
|
+
userIp: string;
|
|
51
|
+
};
|
|
52
|
+
export interface ServerContext extends IHttpMiddlewareContext, IGraphQLContext {
|
|
46
53
|
accessRoleService: any;
|
|
47
54
|
user?: IIAuth0Token;
|
|
48
55
|
userContext?: IUserContext;
|
|
@@ -53,6 +60,5 @@ export interface ServerContext extends IHttpMiddlewareContext {
|
|
|
53
60
|
orgRole?: string;
|
|
54
61
|
teamName?: string;
|
|
55
62
|
preferences: IPreferncesTransformed[];
|
|
56
|
-
accountService?: any;
|
|
57
63
|
}
|
|
58
64
|
export interface MyContext extends ClientContext, ServerContext {}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"target": "es2017",
|
|
5
|
-
"lib": ["es2017"],
|
|
6
4
|
"resolveJsonModule": true,
|
|
7
5
|
"allowSyntheticDefaultImports": true,
|
|
8
6
|
"experimentalDecorators": true,
|
|
@@ -14,5 +12,5 @@
|
|
|
14
12
|
"skipLibCheck": true
|
|
15
13
|
},
|
|
16
14
|
"include": ["src"],
|
|
17
|
-
"exclude": ["../../../node_modules", "node_modules", "lib", "
|
|
15
|
+
"exclude": ["../../../node_modules", "node_modules", "lib", "rollup.config.mjs"]
|
|
18
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/rollup-vite-utils",
|
|
3
|
-
"version": "8.0.1-alpha.
|
|
3
|
+
"version": "8.0.1-alpha.2",
|
|
4
4
|
"description": "Client Module for react app",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -22,15 +22,16 @@
|
|
|
22
22
|
"build:clean": "rimraf lib",
|
|
23
23
|
"build:lib": "rollup -c rollup.config.mjs",
|
|
24
24
|
"build:lib:watch": "npm run build:lib -- --watch",
|
|
25
|
-
"jest": "./node_modules/.bin/jest",
|
|
25
|
+
"jest": "node --experimental-vm-modules ./node_modules/.bin/jest",
|
|
26
26
|
"prepublish": "npm run build",
|
|
27
27
|
"test": "jest",
|
|
28
28
|
"test:debug": "npm test -- --runInBand",
|
|
29
29
|
"test:watch": "npm test -- --watch",
|
|
30
|
+
"vitest": "cross-env ENV_FILE=../../config/test/test.env vitest",
|
|
30
31
|
"watch": "npm run build:lib:watch"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@common-stack/client-react": "8.0.1-alpha.
|
|
34
|
+
"@common-stack/client-react": "8.0.1-alpha.2",
|
|
34
35
|
"@common-stack/core": "8.0.1-alpha.0",
|
|
35
36
|
"ajv": "^8.17.1",
|
|
36
37
|
"dot-prop": "^9.0.0",
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
"glob-all": "^3.3.1",
|
|
39
40
|
"js-sha256": "^0.11.0",
|
|
40
41
|
"minimatch": "^10.0.1",
|
|
42
|
+
"replace-in-file": "^8.3.0",
|
|
41
43
|
"ts-deepmerge": "^7.0.0"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
},
|
|
48
50
|
"peerDependencies": {
|
|
49
51
|
"@apollo/client": ">=3.0.0",
|
|
50
|
-
"@remix-run/react": "
|
|
52
|
+
"@remix-run/react": "~2.15.3",
|
|
51
53
|
"react": ">=16.8.6",
|
|
52
54
|
"react-dom": ">=16.8.6",
|
|
53
55
|
"react-router": ">=6.0.0",
|
|
@@ -59,5 +61,5 @@
|
|
|
59
61
|
"typescript": {
|
|
60
62
|
"definition": "lib/index.d.ts"
|
|
61
63
|
},
|
|
62
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "740324071e77326fc0d9dd3ce4a1bc4a64a472f8"
|
|
63
65
|
}
|
|
File without changes
|