@abgov/nx-adsp 13.19.1 → 13.20.1
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/package.json +1 -5
- package/src/generators/angular-app/angular-app.js +1 -19
- package/src/generators/angular-app/angular-app.js.map +1 -1
- package/src/generators/dotnet-service/dotnet-service.js +34 -18
- package/src/generators/dotnet-service/dotnet-service.js.map +1 -1
- package/src/generators/dotnet-service/dotnet-service.spec.ts +40 -29
- package/src/generators/dotnet-service/files/Examples/HelloWorldConfiguration.cs__tmpl__ +2 -2
- package/src/generators/dotnet-service/files/Examples/HelloWorldEvent.cs__tmpl__ +9 -9
- package/src/generators/dotnet-service/files/Examples/ServiceRoles.cs__tmpl__ +1 -1
- package/src/generators/dotnet-service/files/Program.cs__tmpl__ +18 -18
- package/src/generators/dotnet-service/files/__projectName__.csproj__tmpl__ +16 -0
- package/src/generators/dotnet-service/nuget-files/NuGet.Config__tmpl__ +13 -0
- package/src/generators/dotnet-service/schema.d.ts +1 -0
- package/src/generators/dotnet-service/schema.json +5 -0
- package/src/generators/express-service/express-service.js +11 -1
- package/src/generators/express-service/express-service.js.map +1 -1
- package/src/generators/express-service/express-service.spec.ts +195 -1
- package/src/generators/express-service/files/AGENTS.md__tmpl__ +18 -3
- package/src/generators/express-service/schema.d.ts +1 -0
- package/src/generators/express-service/schema.json +4 -0
- package/src/generators/react-app/react-app.js +1 -19
- package/src/generators/react-app/react-app.js.map +1 -1
- package/src/generators/vue-app/vue-app.js +1 -16
- package/src/generators/vue-app/vue-app.js.map +1 -1
- package/src/utils/frontend-app-port.d.ts +1 -0
- package/src/utils/frontend-app-port.js +11 -0
- package/src/utils/frontend-app-port.js.map +1 -0
- package/src/utils/paired-project.d.ts +13 -0
- package/src/utils/paired-project.js +123 -0
- package/src/utils/paired-project.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/nx-adsp",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.20.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"description": "Government of Alberta - Nx plugin for ADSP apps.",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@abgov/nx-oc": "^13.0.0-0",
|
|
14
|
-
"@nx-dotnet/core": "^3.0.0",
|
|
15
14
|
"@nx/angular": "^23.0.0",
|
|
16
15
|
"@nx/devkit": "^23.0.0",
|
|
17
16
|
"@nx/eslint": "^23.0.0",
|
|
@@ -22,9 +21,6 @@
|
|
|
22
21
|
"tslib": "^2.0.0"
|
|
23
22
|
},
|
|
24
23
|
"peerDependenciesMeta": {
|
|
25
|
-
"@nx-dotnet/core": {
|
|
26
|
-
"optional": true
|
|
27
|
-
},
|
|
28
24
|
"@nx/angular": {
|
|
29
25
|
"optional": true
|
|
30
26
|
},
|
|
@@ -44,25 +44,7 @@ function addFiles(host, options) {
|
|
|
44
44
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
|
|
45
45
|
const addProxyConf = options.nginxProxies.length > 0;
|
|
46
46
|
if (addProxyConf) {
|
|
47
|
-
|
|
48
|
-
// TODO: Is this cleaner to add via template?
|
|
49
|
-
const devProxyConf = options.nginxProxies.reduce((proxyConf, nginxProxy) => {
|
|
50
|
-
const upstreamUrl = new URL(nginxProxy.proxyPass);
|
|
51
|
-
const proxy = {
|
|
52
|
-
target: `${upstreamUrl.protocol}//localhost${upstreamUrl.port ? ':' + upstreamUrl.port : ''}`,
|
|
53
|
-
secure: upstreamUrl.protocol === 'https:',
|
|
54
|
-
changeOrigin: false,
|
|
55
|
-
pathRewrite: {},
|
|
56
|
-
};
|
|
57
|
-
// If there is a path on the upstream url, then add a rewrite.
|
|
58
|
-
if (upstreamUrl.pathname.length > 1) {
|
|
59
|
-
proxy.pathRewrite = {
|
|
60
|
-
[`^${nginxProxy.location}`]: upstreamUrl.pathname,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return Object.assign(Object.assign({}, proxyConf), { [nginxProxy.location]: proxy });
|
|
64
|
-
}, {});
|
|
65
|
-
(0, devkit_1.writeJson)(host, `${options.projectRoot}/proxy.conf.json`, devProxyConf);
|
|
47
|
+
(0, devkit_1.writeJson)(host, `${options.projectRoot}/proxy.conf.json`, (0, paired_project_1.buildDevProxyConf)(options.nginxProxies));
|
|
66
48
|
}
|
|
67
49
|
return addProxyConf;
|
|
68
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/angular-app/angular-app.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"angular-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/angular-app/angular-app.ts"],"names":[],"mappings":";;AA0GA,4BAuOC;;AAjVD,wCAIsB;AACtB,6CAA6E;AAC7E,+DAIoC;AACpC,+DAA4D;AAC5D,iDAK6B;AAC7B,uCAAyC;AACzC,uCAaoB;AACpB,6BAA6B;AAC7B,+DAGoC;AAGpC,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAkC;;QAElC,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;QACjD,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC;QACzE,MAAM,kBAAkB,GAAG,cAAc,WAAW,EAAE,CAAC;QAEvD,MAAM,IAAI,GAAG,MAAM,IAAA,4BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEvD,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;YAClD,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CA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,WAAW,EAAE,aAAa;gBAC1B,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAAC,MAAM;gBACrC,aAAa,EAAE,+BAAc;gBAC7B,aAAa,EAAE;oBACb,0BAA0B,EAAE,cAAc;oBAC1C,4BAA4B,EAAE,gBAAgB;oBAC9C,uBAAuB,EAAE,WAAW;oBACpC,uBAAuB,EAAE,WAAW;oBACpC,iCAAiC,EAAE,aAAa;iBACjD;aACF,EACD,IAAI,EACJ,iBAAiB,CAAC,WAAW,CAC9B,CACF,CAAC;QACJ,CAAC;QAED,MAAM,IAAA,2BAAmB,EAAC,IAAI,kCACzB,iBAAiB,KACpB,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,iBAAiB,CAAC,WAAW,IACtC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const nx_oc_1 = require("@abgov/nx-oc");
|
|
6
|
-
const generator_1 = require("@nx-dotnet/core/src/generators/app/generator");
|
|
7
|
-
const generator_2 = require("@nx-dotnet/core/src/generators/nuget-reference/generator");
|
|
8
6
|
const devkit_1 = require("@nx/devkit");
|
|
9
7
|
const path = require("path");
|
|
10
8
|
function normalizeOptions(host, options) {
|
|
@@ -18,30 +16,48 @@ function normalizeOptions(host, options) {
|
|
|
18
16
|
});
|
|
19
17
|
}
|
|
20
18
|
function addFiles(host, options) {
|
|
21
|
-
const templateOptions = Object.assign(Object.assign(Object.assign({}, options), options.adsp), { tmpl: '' });
|
|
19
|
+
const templateOptions = Object.assign(Object.assign(Object.assign(Object.assign({}, options), options.adsp), (0, devkit_1.names)(options.projectName)), { tmpl: '' });
|
|
22
20
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
|
|
23
21
|
}
|
|
22
|
+
function ensureNuGetConfig(host) {
|
|
23
|
+
if (!host.exists('NuGet.Config')) {
|
|
24
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'nuget-files'), '.', { tmpl: '' });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
24
27
|
function default_1(host, options) {
|
|
25
28
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
if (!(0, nx_oc_1.hasDependency)(host, '@nx
|
|
27
|
-
throw new Error('nx
|
|
29
|
+
if (!(0, nx_oc_1.hasDependency)(host, '@nx/dotnet')) {
|
|
30
|
+
throw new Error('@nx/dotnet is required to generate dotnet service');
|
|
28
31
|
}
|
|
29
32
|
const normalizedOptions = yield normalizeOptions(host, options);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
(0, devkit_1.addProjectConfiguration)(host, normalizedOptions.projectName, {
|
|
34
|
+
root: normalizedOptions.projectRoot,
|
|
35
|
+
projectType: 'application',
|
|
36
|
+
sourceRoot: normalizedOptions.projectRoot,
|
|
37
|
+
targets: {
|
|
38
|
+
serve: {
|
|
39
|
+
executor: 'nx:run-commands',
|
|
40
|
+
options: {
|
|
41
|
+
command: 'dotnet run',
|
|
42
|
+
cwd: normalizedOptions.projectRoot,
|
|
43
|
+
},
|
|
44
|
+
configurations: {
|
|
45
|
+
production: {
|
|
46
|
+
command: 'dotnet run --configuration Release',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
tags: ['adsp:type:dotnet'],
|
|
38
52
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
(0, devkit_1.updateJson)(host, 'nx.json', (json) => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
if (!((_a = json.plugins) === null || _a === void 0 ? void 0 : _a.includes('@nx/dotnet'))) {
|
|
56
|
+
json.plugins = [...((_b = json.plugins) !== null && _b !== void 0 ? _b : []), '@nx/dotnet'];
|
|
57
|
+
}
|
|
58
|
+
return json;
|
|
44
59
|
});
|
|
60
|
+
ensureNuGetConfig(host);
|
|
45
61
|
addFiles(host, normalizedOptions);
|
|
46
62
|
yield (0, nx_oc_1.deploymentGenerator)(host, Object.assign(Object.assign({}, normalizedOptions), { appType: 'dotnet', project: normalizedOptions.projectName }));
|
|
47
63
|
return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotnet-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/dotnet-service/dotnet-service.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"dotnet-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/dotnet-service/dotnet-service.ts"],"names":[],"mappings":";;AAuDA,4BA+CC;;AAtGD,wCAIsB;AACtB,uCAQoB;AACpB,6BAA6B;AAG7B,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAe;;QAEf,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;QACjD,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC;QAEzE,MAAM,IAAI,GAAG,MAAM,IAAA,4BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEvD,uCACK,OAAO,KACV,WAAW;YACX,WAAW;YACX,IAAI,IACJ;IACJ,CAAC;CAAA;AAED,SAAS,QAAQ,CAAC,IAAU,EAAE,OAAyB;IACrD,MAAM,eAAe,+DAChB,OAAO,GACP,OAAO,CAAC,IAAI,GACZ,IAAA,cAAK,EAAC,OAAO,CAAC,WAAW,CAAC,KAC7B,IAAI,EAAE,EAAE,GACT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AAA,IAAI,CAAC,OAAO,0CAAE,QAAQ,CAAC,YAAY,CAAC,CAAA,EAAE,CAAC;gBAC1C,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,MAAA,IAAI,CAAC,OAAO,mCAAI,EAAE,CAAC,EAAE,YAAY,CAAC,CAAA;YACxD,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,iBAAiB,CAAC,IAAI,CAAC,CAAA;QACvB,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAA;QAEjC,MAAM,IAAA,2BAAmB,EAAC,IAAI,kCACzB,iBAAiB,KACpB,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,iBAAiB,CAAC,WAAW,IACtC,CAAA;QAEF,OAAO,GAAS,EAAE;YAChB,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAA;QAC3B,CAAC,CAAA,CAAA;IACH,CAAC;CAAA"}
|
|
@@ -1,52 +1,63 @@
|
|
|
1
|
-
import { addDependenciesToPackageJson } from '@nx/devkit'
|
|
2
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'
|
|
3
|
-
import appGenerator from '@nx-dotnet/core/src/generators/app/generator';
|
|
4
|
-
import refGenerator from '@nx-dotnet/core/src/generators/nuget-reference/generator';
|
|
1
|
+
import { addDependenciesToPackageJson, readJson } from '@nx/devkit'
|
|
2
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'
|
|
5
3
|
|
|
6
|
-
import * as utils from '@abgov/nx-oc'
|
|
7
|
-
import { environments } from '@abgov/nx-oc'
|
|
8
|
-
import { Schema } from './schema'
|
|
9
|
-
import generator from './dotnet-service'
|
|
10
|
-
|
|
11
|
-
jest.mock('@nx-dotnet/core/src/generators/app/generator');
|
|
12
|
-
jest.mock('@nx-dotnet/core/src/generators/nuget-reference/generator');
|
|
13
|
-
|
|
14
|
-
const appGeneratorMock = appGenerator as jest.Mocked<typeof appGenerator>;
|
|
15
|
-
const refGeneratorMock = refGenerator as jest.Mocked<typeof refGenerator>;
|
|
4
|
+
import * as utils from '@abgov/nx-oc'
|
|
5
|
+
import { environments } from '@abgov/nx-oc'
|
|
6
|
+
import { Schema } from './schema'
|
|
7
|
+
import generator from './dotnet-service'
|
|
16
8
|
|
|
17
9
|
jest.mock('@abgov/nx-oc', () => ({
|
|
18
10
|
...jest.requireActual('@abgov/nx-oc'),
|
|
19
11
|
getAdspConfiguration: jest.fn(),
|
|
20
12
|
deploymentGenerator: jest.fn(),
|
|
21
|
-
}))
|
|
22
|
-
const utilsMock = utils as jest.Mocked<typeof utils
|
|
13
|
+
}))
|
|
14
|
+
const utilsMock = utils as jest.Mocked<typeof utils>
|
|
23
15
|
utilsMock.getAdspConfiguration.mockResolvedValue({
|
|
24
16
|
tenant: 'test',
|
|
25
17
|
tenantRealm: 'test',
|
|
26
18
|
accessServiceUrl: environments.test.accessServiceUrl,
|
|
27
19
|
directoryServiceUrl: environments.test.directoryServiceUrl,
|
|
28
|
-
})
|
|
29
|
-
utilsMock.deploymentGenerator.mockResolvedValue()
|
|
20
|
+
})
|
|
21
|
+
utilsMock.deploymentGenerator.mockResolvedValue()
|
|
30
22
|
|
|
31
23
|
describe('Dotnet Service Generator', () => {
|
|
32
24
|
const options: Schema = {
|
|
33
25
|
name: 'test',
|
|
34
26
|
env: 'dev',
|
|
35
|
-
}
|
|
27
|
+
}
|
|
36
28
|
|
|
37
29
|
it('can run', async () => {
|
|
38
|
-
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' })
|
|
30
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' })
|
|
39
31
|
addDependenciesToPackageJson(
|
|
40
32
|
host,
|
|
41
33
|
{},
|
|
42
34
|
{
|
|
43
|
-
'@nx
|
|
35
|
+
'@nx/dotnet': '^23.0.0',
|
|
44
36
|
},
|
|
45
|
-
)
|
|
46
|
-
await generator(host, options)
|
|
47
|
-
expect(
|
|
48
|
-
expect(
|
|
49
|
-
expect(
|
|
50
|
-
host.exists('
|
|
51
|
-
})
|
|
52
|
-
|
|
37
|
+
)
|
|
38
|
+
await generator(host, options)
|
|
39
|
+
expect(utils.deploymentGenerator).toHaveBeenCalled()
|
|
40
|
+
expect(host.exists('apps/test/test.csproj')).toBeTruthy()
|
|
41
|
+
expect(host.exists('apps/test/Program.cs')).toBeTruthy()
|
|
42
|
+
expect(host.exists('NuGet.Config')).toBeTruthy()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('adds @nx/dotnet to nx.json plugins', async () => {
|
|
46
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' })
|
|
47
|
+
addDependenciesToPackageJson(
|
|
48
|
+
host,
|
|
49
|
+
{},
|
|
50
|
+
{
|
|
51
|
+
'@nx/dotnet': '^23.0.0',
|
|
52
|
+
},
|
|
53
|
+
)
|
|
54
|
+
await generator(host, options)
|
|
55
|
+
const nxJson = readJson(host, 'nx.json')
|
|
56
|
+
expect(nxJson.plugins).toContain('@nx/dotnet')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('throws when @nx/dotnet is not installed', async () => {
|
|
60
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' })
|
|
61
|
+
await expect(generator(host, options)).rejects.toThrow('@nx/dotnet')
|
|
62
|
+
})
|
|
63
|
+
})
|
|
@@ -4,17 +4,17 @@ namespace Adsp.Sdk.Examples;
|
|
|
4
4
|
|
|
5
5
|
public class HelloWorldEvent
|
|
6
6
|
{
|
|
7
|
-
|
|
7
|
+
public const string EventName = "hello-world-event";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
[JsonPropertyName("fromUserId")]
|
|
10
|
+
public string? FromUserId { get; set; }
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
[JsonPropertyName("fromUser")]
|
|
13
|
+
public string? FromUser { get; set; }
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
[JsonPropertyName("message")]
|
|
16
|
+
public string? Message { get; set; }
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
[JsonPropertyName("response")]
|
|
19
|
+
public string? Response { get; set; }
|
|
20
20
|
}
|
|
@@ -20,31 +20,31 @@ builder.Services.Configure<AdspOptions>(adspConfiguration);
|
|
|
20
20
|
// 2. Add ADSP components to the service collection.
|
|
21
21
|
builder.Services.AddAdspForService(options =>
|
|
22
22
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
// 3. Provide configuration of the service.
|
|
24
|
+
// 3a. Configure basic service information.
|
|
25
|
+
var serviceId = AdspId.Parse(adspConfiguration.GetValue<string>("ClientId"));
|
|
26
|
+
options.ServiceId = serviceId;
|
|
27
|
+
options.DisplayName = "<%= projectName %>";
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
// 3b. Register configuration definition.
|
|
30
|
+
options.Configuration = new ConfigurationDefinition<HelloWorldConfiguration>(
|
|
31
|
+
"Configuration of the hello world sample service.",
|
|
32
|
+
(tenant, core) => tenant
|
|
33
|
+
);
|
|
34
|
+
// Enable / disable socket.io based configuration invalidation.
|
|
35
|
+
// Include `urn:ads:platform:push-service` audience in access token; e.g use an audience mapper on the associated client.
|
|
36
|
+
options.EnableConfigurationInvalidation = false;
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
// 3c. Register service roles.
|
|
39
|
+
options.Roles = new[] {
|
|
40
40
|
new ServiceRole {
|
|
41
41
|
Role = ServiceRoles.HelloWorlder,
|
|
42
42
|
Description = "Hello worlder role that allows user to post a message to the API."
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
// 3d. Register domain events.
|
|
47
|
+
options.Events = new[] {
|
|
48
48
|
new DomainEventDefinition<HelloWorldEvent>(
|
|
49
49
|
HelloWorldEvent.EventName,
|
|
50
50
|
"Signalled when a hello world message is posted to the API."
|
|
@@ -62,7 +62,7 @@ app.UseAdsp();
|
|
|
62
62
|
app.UseAuthorization();
|
|
63
63
|
app.UseAdspMetadata(new AdspMetadataOptions
|
|
64
64
|
{
|
|
65
|
-
|
|
65
|
+
ApiPath = "WeatherForecast"
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
app.MapControllers();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
2
|
+
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<TargetFramework>net10.0</TargetFramework>
|
|
5
|
+
<Nullable>enable</Nullable>
|
|
6
|
+
<ImplicitUsings>enable</ImplicitUsings>
|
|
7
|
+
<RootNamespace><%- className %></RootNamespace>
|
|
8
|
+
<AssemblyName><%- className %></AssemblyName>
|
|
9
|
+
</PropertyGroup>
|
|
10
|
+
|
|
11
|
+
<ItemGroup>
|
|
12
|
+
<PackageReference Include="Adsp.Sdk" Version="2.*" />
|
|
13
|
+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
|
|
14
|
+
</ItemGroup>
|
|
15
|
+
|
|
16
|
+
</Project>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<configuration>
|
|
3
|
+
<packageSources>
|
|
4
|
+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
|
5
|
+
<add key="github" value="https://nuget.pkg.github.com/GovAlta/index.json" />
|
|
6
|
+
</packageSources>
|
|
7
|
+
<packageSourceCredentials>
|
|
8
|
+
<github>
|
|
9
|
+
<add key="Username" value="%GITHUB_USER%" />
|
|
10
|
+
<add key="ClearTextPassword" value="%GITHUB_TOKEN%" />
|
|
11
|
+
</github>
|
|
12
|
+
</packageSourceCredentials>
|
|
13
|
+
</configuration>
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"type": "string",
|
|
29
29
|
"description": "Access token for retrieving configuration from ADSP APIs.",
|
|
30
30
|
"alias": "at"
|
|
31
|
+
},
|
|
32
|
+
"tenant": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "ADSP tenant name. When provided, the realm is looked up anonymously and a single browser login is used instead of the full interactive flow.",
|
|
35
|
+
"alias": "t"
|
|
31
36
|
}
|
|
32
37
|
},
|
|
33
38
|
"required": ["name", "env"],
|
|
@@ -12,15 +12,17 @@ const plugin_version_1 = require("../../utils/plugin-version");
|
|
|
12
12
|
const quality_1 = require("../../utils/quality");
|
|
13
13
|
const init_1 = require("../init/init");
|
|
14
14
|
const express_service_port_1 = require("../../utils/express-service-port");
|
|
15
|
+
const paired_project_1 = require("../../utils/paired-project");
|
|
15
16
|
function normalizeOptions(host, options) {
|
|
16
17
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
18
|
var _a;
|
|
18
19
|
const projectName = (0, devkit_1.names)(options.name).fileName;
|
|
19
20
|
const projectRoot = `${(0, devkit_1.getWorkspaceLayout)(host).appsDir}/${projectName}`;
|
|
20
21
|
const adsp = yield (0, nx_oc_1.getAdspConfiguration)(host, options);
|
|
22
|
+
const pairedFrontend = (0, paired_project_1.resolvePairedFrontendApp)(host, options.pairedProject);
|
|
21
23
|
return Object.assign(Object.assign({}, options), { projectName,
|
|
22
24
|
projectRoot,
|
|
23
|
-
adsp, database: (_a = options.database) !== null && _a !== void 0 ? _a : 'none' });
|
|
25
|
+
adsp, database: (_a = options.database) !== null && _a !== void 0 ? _a : 'none', pairedProjectTag: pairedFrontend === null || pairedFrontend === void 0 ? void 0 : pairedFrontend.tag });
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
function addFiles(host, options) {
|
|
@@ -56,6 +58,13 @@ function default_1(host, options) {
|
|
|
56
58
|
? { 'drizzle-kit': '^0.31.0', '@types/pg': '^8.11.0' }
|
|
57
59
|
: {})), { 'eslint-plugin-security': '^3.0.0', 'eslint-plugin-no-secrets': '^2.0.0', 'eslint-plugin-jest': '^28.0.0' }));
|
|
58
60
|
addFiles(host, normalizedOptions);
|
|
61
|
+
// When the frontend already exists (standalone use: backend generated after frontend),
|
|
62
|
+
// retroactively apply the nginx/dev-proxy wiring that the frontend generator would have
|
|
63
|
+
// set up if it had been given --pairedProject. Safe to call when the frontend doesn't
|
|
64
|
+
// exist yet (composite generator ordering) — applyProxyToExistingFrontend returns early.
|
|
65
|
+
if (normalizedOptions.pairedProject) {
|
|
66
|
+
(0, paired_project_1.applyProxyToExistingFrontend)(host, normalizedOptions.pairedProject, normalizedOptions.projectName);
|
|
67
|
+
}
|
|
59
68
|
(0, quality_1.addEslintQualityRules)(host, normalizedOptions.projectRoot, [
|
|
60
69
|
'**/*.spec.ts',
|
|
61
70
|
'**/*.test.ts',
|
|
@@ -115,6 +124,7 @@ function default_1(host, options) {
|
|
|
115
124
|
const dbTag = `adsp:database:${normalizedOptions.database}`;
|
|
116
125
|
const newTags = [
|
|
117
126
|
...(normalizedOptions.database !== 'none' ? [dbTag] : []),
|
|
127
|
+
...(normalizedOptions.pairedProjectTag ? [normalizedOptions.pairedProjectTag] : []),
|
|
118
128
|
...(0, nx_oc_1.adspProjectTags)(normalizedOptions.env, normalizedOptions.adsp.tenant),
|
|
119
129
|
].filter((tag) => { var _a; return !((_a = projectConfig.tags) !== null && _a !== void 0 ? _a : []).includes(tag); });
|
|
120
130
|
const tags = [...((_d = projectConfig.tags) !== null && _d !== void 0 ? _d : []), ...newTags];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/express-service/express-service.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"express-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/express-service/express-service.ts"],"names":[],"mappings":";;AA+EA,4BA6RC;;AA5WD,wCAIsB;AACtB,uCAUoB;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rC,aAAa,EAAE,+BAAc;gBAC7B,aAAa,kBACX,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,aAAa,EACnC,eAAe,EAAE,QAAQ,IACtB,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACzD;aACF,EACD,IAAI,EACJ,iBAAiB,CAAC,WAAW,CAC9B,CAAC;YAEF,0EAA0E;YAC1E,sEAAsE;YACtE,qEAAqE;YACrE,IAAI,WAAW,IAAI,WAAW,CAAC,YAAY,KAAK,CAAC,EAAE,CAAC;gBAClD,MAAM,EAAE,MAAM,EAAE,GAAG,2CAAa,UAAU,EAAC,CAAC;gBAC5C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAuB;oBACrD,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,SAAS;oBACf,OAAO,EACL,mFAAmF;oBACrF,OAAO,EAAE,CAAC,WAAW,CAAC,WAAW;iBAClC,CAAC,CAAC;gBACH,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,IAAA,2BAAmB,EAAC,IAAI,kCACzB,iBAAiB,KACpB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,iBAAiB,CAAC,WAAW,EACtC,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,IACpC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readJson, readProjectConfiguration, writeJson } from '@nx/devkit';
|
|
1
|
+
import { addProjectConfiguration, readJson, readProjectConfiguration, writeJson } from '@nx/devkit';
|
|
2
2
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
3
|
|
|
4
4
|
import * as utils from '@abgov/nx-oc';
|
|
@@ -338,4 +338,198 @@ describe('Express Service Generator', () => {
|
|
|
338
338
|
expect(host.exists('apps/test/.env.local')).toBeFalsy();
|
|
339
339
|
expect(host.exists('apps/test/.env')).toBeFalsy();
|
|
340
340
|
}, 60000);
|
|
341
|
+
|
|
342
|
+
it('derives the sandbox tag from --pairedProject and adds it to the project', async () => {
|
|
343
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
344
|
+
addProjectConfiguration(host, 'test-app', { root: 'apps/test-app' });
|
|
345
|
+
await generator(host, { ...options, pairedProject: 'test-app' });
|
|
346
|
+
|
|
347
|
+
const config = readProjectConfiguration(host, 'test');
|
|
348
|
+
expect(config.tags).toContain('adsp:paired-frontend:test-app:4200');
|
|
349
|
+
}, 60000);
|
|
350
|
+
|
|
351
|
+
it('surfaces the paired project name in AGENTS.md', async () => {
|
|
352
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
353
|
+
addProjectConfiguration(host, 'test-app', { root: 'apps/test-app' });
|
|
354
|
+
await generator(host, { ...options, pairedProject: 'test-app' });
|
|
355
|
+
|
|
356
|
+
const agents = host.read('apps/test/AGENTS.md').toString();
|
|
357
|
+
expect(agents).toContain('test-app');
|
|
358
|
+
}, 60000);
|
|
359
|
+
|
|
360
|
+
describe('--pairedProject proxy wiring', () => {
|
|
361
|
+
// Simplified nginx.conf matching the template structure (no proxy entries yet).
|
|
362
|
+
const NGINX_CONF_NO_PROXY = `events {
|
|
363
|
+
worker_connections 1024;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
http {
|
|
367
|
+
server {
|
|
368
|
+
listen 8080;
|
|
369
|
+
|
|
370
|
+
location / {
|
|
371
|
+
try_files $uri /index.html;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
`;
|
|
377
|
+
|
|
378
|
+
it('writes vite.proxy.json and patches serve target and nginx.conf for a Vue frontend', async () => {
|
|
379
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
380
|
+
addProjectConfiguration(host, 'my-vue-app', {
|
|
381
|
+
root: 'apps/my-vue-app',
|
|
382
|
+
projectType: 'application',
|
|
383
|
+
targets: {
|
|
384
|
+
serve: { executor: '@nx/vite:dev-server', options: { port: 4200 } },
|
|
385
|
+
build: {
|
|
386
|
+
executor: '@nx/vite:build',
|
|
387
|
+
options: { outputPath: 'dist/apps/my-vue-app' },
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
tags: ['adsp:scaffold-env:dev'],
|
|
391
|
+
});
|
|
392
|
+
host.write('apps/my-vue-app/public/nginx.conf', NGINX_CONF_NO_PROXY);
|
|
393
|
+
|
|
394
|
+
await generator(host, { ...options, pairedProject: 'my-vue-app' });
|
|
395
|
+
|
|
396
|
+
// Dev proxy file written at the Vue location.
|
|
397
|
+
expect(host.exists('apps/my-vue-app/vite.proxy.json')).toBeTruthy();
|
|
398
|
+
const proxyConf = readJson(host, 'apps/my-vue-app/vite.proxy.json');
|
|
399
|
+
expect(proxyConf['/api/']).toBeDefined();
|
|
400
|
+
expect(proxyConf['/api/'].target).toBe('http://localhost:3333');
|
|
401
|
+
expect(proxyConf['/api/'].pathRewrite['^/api/']).toBe('/test/');
|
|
402
|
+
|
|
403
|
+
// serve target updated with proxyConfig.
|
|
404
|
+
const frontendConfig = readProjectConfiguration(host, 'my-vue-app');
|
|
405
|
+
expect(frontendConfig.targets.serve.options.proxyConfig).toBe(
|
|
406
|
+
'apps/my-vue-app/vite.proxy.json',
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
// nginx.conf updated with the proxy block.
|
|
410
|
+
const nginx = host
|
|
411
|
+
.read('apps/my-vue-app/public/nginx.conf')
|
|
412
|
+
.toString();
|
|
413
|
+
expect(nginx).toContain('location /api/');
|
|
414
|
+
expect(nginx).toContain('proxy_pass http://test:3333/test/');
|
|
415
|
+
|
|
416
|
+
// Frontend tagged for the sandbox executor.
|
|
417
|
+
expect(frontendConfig.tags).toContain('adsp:proxy-service:test:3333');
|
|
418
|
+
}, 120000);
|
|
419
|
+
|
|
420
|
+
it('writes proxy.conf.json, patches serve target, adds nginx asset, and updates nginx.conf for a React frontend', async () => {
|
|
421
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
422
|
+
addProjectConfiguration(host, 'my-react-app', {
|
|
423
|
+
root: 'apps/my-react-app',
|
|
424
|
+
projectType: 'application',
|
|
425
|
+
targets: {
|
|
426
|
+
serve: {
|
|
427
|
+
executor: '@nx/webpack:dev-server',
|
|
428
|
+
options: { port: 4200 },
|
|
429
|
+
},
|
|
430
|
+
build: {
|
|
431
|
+
executor: '@nx/webpack:webpack',
|
|
432
|
+
options: { outputPath: 'dist/apps/my-react-app', assets: [] },
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
tags: ['adsp:scaffold-env:dev'],
|
|
436
|
+
});
|
|
437
|
+
host.write('apps/my-react-app/nginx.conf', NGINX_CONF_NO_PROXY);
|
|
438
|
+
|
|
439
|
+
await generator(host, { ...options, pairedProject: 'my-react-app' });
|
|
440
|
+
|
|
441
|
+
// Dev proxy file written at the React location.
|
|
442
|
+
expect(host.exists('apps/my-react-app/proxy.conf.json')).toBeTruthy();
|
|
443
|
+
const proxyConf = readJson(host, 'apps/my-react-app/proxy.conf.json');
|
|
444
|
+
expect(proxyConf['/api/'].target).toBe('http://localhost:3333');
|
|
445
|
+
|
|
446
|
+
// serve target updated.
|
|
447
|
+
const frontendConfig = readProjectConfiguration(host, 'my-react-app');
|
|
448
|
+
expect(frontendConfig.targets.serve.options.proxyConfig).toBe(
|
|
449
|
+
'apps/my-react-app/proxy.conf.json',
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
// nginx.conf at project root updated.
|
|
453
|
+
const nginx = host.read('apps/my-react-app/nginx.conf').toString();
|
|
454
|
+
expect(nginx).toContain('location /api/');
|
|
455
|
+
|
|
456
|
+
// nginx.conf added as a webpack build asset.
|
|
457
|
+
const assets = frontendConfig.targets.build.options.assets ?? [];
|
|
458
|
+
expect(
|
|
459
|
+
assets.some(
|
|
460
|
+
(a: unknown) =>
|
|
461
|
+
typeof a === 'object' &&
|
|
462
|
+
(a as { glob?: string }).glob === 'nginx.conf' &&
|
|
463
|
+
(a as { input?: string }).input === 'apps/my-react-app',
|
|
464
|
+
),
|
|
465
|
+
).toBe(true);
|
|
466
|
+
|
|
467
|
+
// Frontend tagged.
|
|
468
|
+
expect(frontendConfig.tags).toContain('adsp:proxy-service:test:3333');
|
|
469
|
+
}, 120000);
|
|
470
|
+
|
|
471
|
+
it('writes proxy.conf.json, patches serve target, adds nginx asset, and updates nginx.conf for an Angular frontend', async () => {
|
|
472
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
473
|
+
addProjectConfiguration(host, 'my-angular-app', {
|
|
474
|
+
root: 'apps/my-angular-app',
|
|
475
|
+
projectType: 'application',
|
|
476
|
+
targets: {
|
|
477
|
+
serve: {
|
|
478
|
+
executor: '@angular-devkit/build-angular:dev-server',
|
|
479
|
+
options: { port: 4200 },
|
|
480
|
+
},
|
|
481
|
+
build: {
|
|
482
|
+
executor: '@angular-devkit/build-angular:browser',
|
|
483
|
+
options: {
|
|
484
|
+
outputPath: 'dist/apps/my-angular-app',
|
|
485
|
+
assets: [
|
|
486
|
+
`apps/my-angular-app/src/silent-check-sso.html`,
|
|
487
|
+
],
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
},
|
|
491
|
+
tags: ['adsp:scaffold-env:dev'],
|
|
492
|
+
});
|
|
493
|
+
host.write('apps/my-angular-app/nginx.conf', NGINX_CONF_NO_PROXY);
|
|
494
|
+
|
|
495
|
+
await generator(host, { ...options, pairedProject: 'my-angular-app' });
|
|
496
|
+
|
|
497
|
+
// Dev proxy file written at the root (same path Angular generators use).
|
|
498
|
+
expect(host.exists('apps/my-angular-app/proxy.conf.json')).toBeTruthy();
|
|
499
|
+
const proxyConf = readJson(host, 'apps/my-angular-app/proxy.conf.json');
|
|
500
|
+
expect(proxyConf['/api/'].target).toBe('http://localhost:3333');
|
|
501
|
+
|
|
502
|
+
// serve target updated.
|
|
503
|
+
const frontendConfig = readProjectConfiguration(host, 'my-angular-app');
|
|
504
|
+
expect(frontendConfig.targets.serve.options.proxyConfig).toBe(
|
|
505
|
+
'apps/my-angular-app/proxy.conf.json',
|
|
506
|
+
);
|
|
507
|
+
|
|
508
|
+
// nginx.conf at project root updated.
|
|
509
|
+
const nginx = host.read('apps/my-angular-app/nginx.conf').toString();
|
|
510
|
+
expect(nginx).toContain('location /api/');
|
|
511
|
+
|
|
512
|
+
// nginx.conf added as a build asset.
|
|
513
|
+
const assets = frontendConfig.targets.build.options.assets ?? [];
|
|
514
|
+
expect(
|
|
515
|
+
assets.some(
|
|
516
|
+
(a: unknown) =>
|
|
517
|
+
typeof a === 'object' &&
|
|
518
|
+
(a as { glob?: string }).glob === 'nginx.conf',
|
|
519
|
+
),
|
|
520
|
+
).toBe(true);
|
|
521
|
+
|
|
522
|
+
// Frontend tagged.
|
|
523
|
+
expect(frontendConfig.tags).toContain('adsp:proxy-service:test:3333');
|
|
524
|
+
}, 120000);
|
|
525
|
+
|
|
526
|
+
it('does not crash when the frontend does not exist yet (composite generator ordering)', async () => {
|
|
527
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
528
|
+
// No frontend project in the tree — composite generators scaffold
|
|
529
|
+
// express-service before the frontend.
|
|
530
|
+
await expect(
|
|
531
|
+
generator(host, { ...options, pairedProject: 'not-yet-scaffolded' }),
|
|
532
|
+
).resolves.toBeDefined();
|
|
533
|
+
}, 120000);
|
|
534
|
+
});
|
|
341
535
|
});
|
|
@@ -562,9 +562,24 @@ describe('GET /<%= projectName %>/v1/items', () => {
|
|
|
562
562
|
|
|
563
563
|
## Frontend proxy integration
|
|
564
564
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
nginx
|
|
565
|
+
This service has no paired frontend configured yet. All API routes live under
|
|
566
|
+
`/<%= projectName %>/v1/`. To wire up a Vue, React, or Angular frontend's
|
|
567
|
+
nginx proxy (production) and dev-server proxy (development) to this service,
|
|
568
|
+
run either:
|
|
569
|
+
|
|
570
|
+
```bash
|
|
571
|
+
# Re-run this generator against the existing frontend — preferred when the
|
|
572
|
+
# frontend already exists (both proxy files and the adsp:proxy-service: tag
|
|
573
|
+
# are updated automatically):
|
|
574
|
+
npx nx g @abgov/nx-adsp:express-service <%= projectName %> --pairedProject <frontend-name> --no-interactive
|
|
575
|
+
|
|
576
|
+
# Or run the frontend generator against its own existing project instead:
|
|
577
|
+
npx nx g @abgov/nx-adsp:vue-app <frontend-name> --pairedProject <%= projectName %> --no-interactive
|
|
578
|
+
# (substitute react-app or angular-app as appropriate)
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
Both paths produce the same result: the frontend routes `/api/` to
|
|
582
|
+
`/<%= projectName %>/` on port 3333 in dev and via nginx in production.
|
|
568
583
|
<% } %>
|
|
569
584
|
|
|
570
585
|
## OpenShift targets
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
"type": "boolean",
|
|
68
68
|
"description": "Skip the consultAgent interaction and generate base scaffolding only.",
|
|
69
69
|
"default": false
|
|
70
|
+
},
|
|
71
|
+
"pairedProject": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"description": "Name of a frontend app project (vue-app, react-app, or angular-app) to pair with this service. When that frontend already exists in the workspace, the generator automatically wires its nginx proxy config, dev-server proxy file (vite.proxy.json or proxy.conf.json), serve target proxyConfig, and adsp:proxy-service: tag. Set automatically by composite generators (pevn, pern, pean, mern, mean) — also valid standalone when the frontend was scaffolded first."
|
|
70
74
|
}
|
|
71
75
|
},
|
|
72
76
|
"required": ["name", "env"],
|
|
@@ -45,25 +45,7 @@ function addFiles(host, options) {
|
|
|
45
45
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
|
|
46
46
|
const addProxyConf = options.nginxProxies.length > 0;
|
|
47
47
|
if (addProxyConf) {
|
|
48
|
-
|
|
49
|
-
// TODO: Is this cleaner to add via template?
|
|
50
|
-
const devProxyConf = options.nginxProxies.reduce((proxyConf, nginxProxy) => {
|
|
51
|
-
const upstreamUrl = new URL(nginxProxy.proxyPass);
|
|
52
|
-
const proxy = {
|
|
53
|
-
target: `${upstreamUrl.protocol}//localhost${upstreamUrl.port ? ':' + upstreamUrl.port : ''}`,
|
|
54
|
-
secure: upstreamUrl.protocol === 'https:',
|
|
55
|
-
changeOrigin: false,
|
|
56
|
-
pathRewrite: {},
|
|
57
|
-
};
|
|
58
|
-
// If there is a path on the upstream url, then add a rewrite.
|
|
59
|
-
if (upstreamUrl.pathname.length > 1) {
|
|
60
|
-
proxy.pathRewrite = {
|
|
61
|
-
[`^${nginxProxy.location}`]: upstreamUrl.pathname,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
return Object.assign(Object.assign({}, proxyConf), { [nginxProxy.location]: proxy });
|
|
65
|
-
}, {});
|
|
66
|
-
(0, devkit_1.writeJson)(host, `${options.projectRoot}/proxy.conf.json`, devProxyConf);
|
|
48
|
+
(0, devkit_1.writeJson)(host, `${options.projectRoot}/proxy.conf.json`, (0, paired_project_1.buildDevProxyConf)(options.nginxProxies));
|
|
67
49
|
}
|
|
68
50
|
return addProxyConf;
|
|
69
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/react-app/react-app.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"react-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/react-app/react-app.ts"],"names":[],"mappings":";;AA+GA,4BA8MC;;AA7TD,wCAIsB;AACtB,6CAA6E;AAC7E,+DAIoC;AACpC,+DAA4D;AAC5D,iDAM6B;AAC7B,uCAAyC;AACzC,uCAWoB;AACpB,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C,WAAW;gBAC1C,WAAW,EAAE,WAAW;gBACxB,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAAC,MAAM;gBACrC,aAAa,EAAE,+BAAc;gBAC7B,aAAa,EAAE;oBACb,iBAAiB,EAAE,KAAK;oBACxB,cAAc,EAAE,OAAO;oBACvB,iCAAiC,EAAE,aAAa;oBAChD,yBAAyB,EAAE,aAAa;oBACxC,yBAAyB,EAAE,aAAa;iBACzC;aACF,EACD,IAAI,EACJ,iBAAiB,CAAC,WAAW,CAC9B,CACF,CAAC;QACJ,CAAC;QAED,MAAM,IAAA,2BAAmB,EAAC,IAAI,kCACzB,iBAAiB,KACpB,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,iBAAiB,CAAC,WAAW,IACtC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -48,22 +48,7 @@ function addFiles(host, options) {
|
|
|
48
48
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
|
|
49
49
|
const addProxyConf = options.nginxProxies.length > 0;
|
|
50
50
|
if (addProxyConf) {
|
|
51
|
-
|
|
52
|
-
const upstreamUrl = new URL(nginxProxy.proxyPass);
|
|
53
|
-
const proxy = {
|
|
54
|
-
target: `${upstreamUrl.protocol}//localhost${upstreamUrl.port ? ':' + upstreamUrl.port : ''}`,
|
|
55
|
-
secure: upstreamUrl.protocol === 'https:',
|
|
56
|
-
changeOrigin: false,
|
|
57
|
-
pathRewrite: {},
|
|
58
|
-
};
|
|
59
|
-
if (upstreamUrl.pathname.length > 1) {
|
|
60
|
-
proxy.pathRewrite = {
|
|
61
|
-
[`^${nginxProxy.location}`]: upstreamUrl.pathname,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
return Object.assign(Object.assign({}, proxyConf), { [nginxProxy.location]: proxy });
|
|
65
|
-
}, {});
|
|
66
|
-
(0, devkit_1.writeJson)(host, `${options.projectRoot}/vite.proxy.json`, devProxyConf);
|
|
51
|
+
(0, devkit_1.writeJson)(host, `${options.projectRoot}/vite.proxy.json`, (0, paired_project_1.buildDevProxyConf)(options.nginxProxies));
|
|
67
52
|
}
|
|
68
53
|
return addProxyConf;
|
|
69
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/vue-app/vue-app.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"vue-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/vue-app/vue-app.ts"],"names":[],"mappings":";;AA4GA,4BA+MC;;AA3TD,wCAIsB;AACtB,6CAA6E;AAC7E,+DAIoC;AACpC,+DAA4D;AAC5D,iDAK6B;AAC7B,uCAAyC;AACzC,uCAYoB;AACpB,6BAA6B;AAC7B,+DAGoC;AACpC,qEAE0C;AAG1C,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAe;;;QAEf,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;QACjD,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC;QACzE,MAAM,kBAAkB,GAAG,cAAc,WAAW,EAAE,CAAC;QACvD,MAAM,IAAI,GAAG,MAAM,IAAA,4BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;YAClD,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC;YACpB,CAAC,CAAC,OAAO,CAAC,KAAK;gBACb,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;gBACjB,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,MAAM,GAA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BAAiB,CAAC,WAAW,sBAAsB,CAAC,0CAC3D,QAAQ,EAAE,mCAAI,EAAE,CAAC;YACvB,MAAM,aAAa,GACjB,MAAA,MAAA,IAAI;iBACD,IAAI,CACH,GAAG,iBAAiB,CAAC,WAAW,kCAAkC,CACnE,0CACC,QAAQ,EAAE,mCAAI,EAAE,CAAC;YACvB,MAAM,IAAA,kCAA0B,EAC9B,MAAM,IAAA,oBAAY,EAChB,iBAAiB,CAAC,IAAI,CAAC,mBAAmB,EAC1C,WAAW,EACX;gBACE,WAAW,EAAE,iBAAiB,CAAC,WAAW;gBAC1C,WAAW,EAAE,SAAS;gBACtB,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAAC,MAAM;gBACrC,aAAa,EAAE,+BAAc;gBAC7B,aAAa,EAAE;oBACb,aAAa,EAAE,MAAM;oBACrB,aAAa,EAAE,MAAM;oBACrB,qBAAqB,EAAE,QAAQ;oBAC/B,iCAAiC,EAAE,aAAa;iBACjD;aACF,EACD,IAAI,EACJ,iBAAiB,CAAC,WAAW,CAC9B,CACF,CAAC;QACJ,CAAC;QAED,MAAM,IAAA,2BAAmB,EAAC,IAAI,kCACzB,iBAAiB,KACpB,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,iBAAiB,CAAC,WAAW,IACtC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_FRONTEND_APP_PORT = 4200;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_FRONTEND_APP_PORT = void 0;
|
|
4
|
+
// Frontend app generators (vue-app, react-app, angular-app) have no --port option to source
|
|
5
|
+
// a real value from yet, so every consumer that needs to tag a paired frontend by convention
|
|
6
|
+
// (the `adsp:paired-frontend:` tag tooling reads to discover the pairing) has to agree on the
|
|
7
|
+
// same default. One exported constant, not a literal repeated at each call site — update this
|
|
8
|
+
// alongside the vue-app/react-app dev server default if frontends ever gain a real --port option
|
|
9
|
+
// to read instead.
|
|
10
|
+
exports.DEFAULT_FRONTEND_APP_PORT = 4200;
|
|
11
|
+
//# sourceMappingURL=frontend-app-port.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend-app-port.js","sourceRoot":"","sources":["../../../../../packages/nx-adsp/src/utils/frontend-app-port.ts"],"names":[],"mappings":";;;AAAA,4FAA4F;AAC5F,6FAA6F;AAC7F,8FAA8F;AAC9F,8FAA8F;AAC9F,iGAAiG;AACjG,mBAAmB;AACN,QAAA,yBAAyB,GAAG,IAAI,CAAA"}
|
|
@@ -4,4 +4,17 @@ export interface PairedProjectProxy {
|
|
|
4
4
|
proxy: NginxProxyConfiguration;
|
|
5
5
|
tag: string;
|
|
6
6
|
}
|
|
7
|
+
type DevProxyEntry = {
|
|
8
|
+
target: string;
|
|
9
|
+
secure: boolean;
|
|
10
|
+
changeOrigin: boolean;
|
|
11
|
+
pathRewrite: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
export declare function buildDevProxyConf(nginxProxies: NginxProxyConfiguration[]): Record<string, DevProxyEntry>;
|
|
7
14
|
export declare function resolvePairedProjectProxy(host: Tree, pairedProject: string | undefined): PairedProjectProxy | undefined;
|
|
15
|
+
export interface PairedFrontendApp {
|
|
16
|
+
tag: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function resolvePairedFrontendApp(host: Tree, pairedProject: string | undefined): PairedFrontendApp | undefined;
|
|
19
|
+
export declare function applyProxyToExistingFrontend(host: Tree, pairedFrontend: string, backendProjectName: string): void;
|
|
20
|
+
export {};
|
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildDevProxyConf = buildDevProxyConf;
|
|
3
4
|
exports.resolvePairedProjectProxy = resolvePairedProjectProxy;
|
|
5
|
+
exports.resolvePairedFrontendApp = resolvePairedFrontendApp;
|
|
6
|
+
exports.applyProxyToExistingFrontend = applyProxyToExistingFrontend;
|
|
4
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
+
const path = require("path");
|
|
5
9
|
const express_service_port_1 = require("./express-service-port");
|
|
10
|
+
const frontend_app_port_1 = require("./frontend-app-port");
|
|
11
|
+
// Builds the dev-server proxy JSON (vite.proxy.json / proxy.conf.json) from a set of nginx
|
|
12
|
+
// proxy entries. Shared by vue-app, react-app, angular-app, and the retroactive express-service
|
|
13
|
+
// proxy wiring so the format stays consistent.
|
|
14
|
+
function buildDevProxyConf(nginxProxies) {
|
|
15
|
+
return nginxProxies.reduce((proxyConf, nginxProxy) => {
|
|
16
|
+
const upstreamUrl = new URL(nginxProxy.proxyPass);
|
|
17
|
+
const entry = {
|
|
18
|
+
target: `${upstreamUrl.protocol}//localhost${upstreamUrl.port ? ':' + upstreamUrl.port : ''}`,
|
|
19
|
+
secure: upstreamUrl.protocol === 'https:',
|
|
20
|
+
changeOrigin: false,
|
|
21
|
+
pathRewrite: upstreamUrl.pathname.length > 1
|
|
22
|
+
? { [`^${nginxProxy.location}`]: upstreamUrl.pathname }
|
|
23
|
+
: {},
|
|
24
|
+
};
|
|
25
|
+
return Object.assign(Object.assign({}, proxyConf), { [nginxProxy.location]: entry });
|
|
26
|
+
}, {});
|
|
27
|
+
}
|
|
6
28
|
const PAIRED_PROJECT_LOCATION = '/api/';
|
|
7
29
|
// Resolves a frontend's --pairedProject into the nginx/dev-server proxy entry that routes API
|
|
8
30
|
// calls to it, plus the `adsp:proxy-service:<name>:<port>` tag the sandbox executor reads to
|
|
@@ -26,4 +48,105 @@ function resolvePairedProjectProxy(host, pairedProject) {
|
|
|
26
48
|
tag: `adsp:proxy-service:${pairedService}:${port}`,
|
|
27
49
|
};
|
|
28
50
|
}
|
|
51
|
+
// Resolves an express-service's --pairedProject into the `adsp:paired-frontend:<name>:<port>`
|
|
52
|
+
// tag tooling reads to discover which frontend app this service is paired with. Unlike
|
|
53
|
+
// resolvePairedProjectProxy, this does NOT validate that the paired project exists: composite
|
|
54
|
+
// generators (pevn, pern, pean) scaffold express-service first and the frontend second, so the
|
|
55
|
+
// frontend's project configuration is not yet in the tree when this runs. The tag is fully
|
|
56
|
+
// derived from the name alone — no reads from the paired project are required.
|
|
57
|
+
function resolvePairedFrontendApp(host, pairedProject) {
|
|
58
|
+
if (!pairedProject) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const pairedApp = (0, devkit_1.names)(pairedProject).fileName;
|
|
62
|
+
return {
|
|
63
|
+
tag: `adsp:paired-frontend:${pairedApp}:${frontend_app_port_1.DEFAULT_FRONTEND_APP_PORT}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// Retroactively applies proxy wiring to an existing frontend when an express-service is generated
|
|
67
|
+
// after it with --pairedProject. This is the mirror of what resolvePairedProjectProxy + the
|
|
68
|
+
// frontend generator does when the frontend runs first. Safe to call when the frontend doesn't
|
|
69
|
+
// exist yet (composite generator ordering — backend is scaffolded before frontend); returns early.
|
|
70
|
+
function applyProxyToExistingFrontend(host, pairedFrontend, backendProjectName) {
|
|
71
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
72
|
+
const frontendName = (0, devkit_1.names)(pairedFrontend).fileName;
|
|
73
|
+
let frontendConfig;
|
|
74
|
+
try {
|
|
75
|
+
frontendConfig = (0, devkit_1.readProjectConfiguration)(host, frontendName);
|
|
76
|
+
}
|
|
77
|
+
catch (_k) {
|
|
78
|
+
// Frontend not scaffolded yet (composite generator ordering).
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const projectRoot = frontendConfig.root;
|
|
82
|
+
const port = express_service_port_1.DEFAULT_EXPRESS_SERVICE_PORT;
|
|
83
|
+
const backendService = (0, devkit_1.names)(backendProjectName).fileName;
|
|
84
|
+
const nginxProxy = {
|
|
85
|
+
location: PAIRED_PROJECT_LOCATION,
|
|
86
|
+
proxyPass: `http://${backendService}:${port}/${backendService}/`,
|
|
87
|
+
};
|
|
88
|
+
// Detect Vue vs React/Angular by nginx.conf location: Vue emits into public/ (Vite publicDir
|
|
89
|
+
// so it lands in the build output root automatically); React and Angular both emit at the
|
|
90
|
+
// project root and add an explicit webpack build asset glob.
|
|
91
|
+
const isVue = host.exists(path.join(projectRoot, 'public', 'nginx.conf'));
|
|
92
|
+
const isRootNginx = !isVue && host.exists(path.join(projectRoot, 'nginx.conf'));
|
|
93
|
+
if (!isVue && !isRootNginx) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// 1. Patch nginx.conf — insert the proxy block before the server block's closing brace.
|
|
97
|
+
const nginxConfPath = isVue
|
|
98
|
+
? path.join(projectRoot, 'public', 'nginx.conf')
|
|
99
|
+
: path.join(projectRoot, 'nginx.conf');
|
|
100
|
+
const existingNginx = (_b = (_a = host.read(nginxConfPath)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '';
|
|
101
|
+
if (!existingNginx.includes(`location ${nginxProxy.location}`)) {
|
|
102
|
+
const proxyBlock = [
|
|
103
|
+
` location ${nginxProxy.location} {`,
|
|
104
|
+
` proxy_pass ${nginxProxy.proxyPass};`,
|
|
105
|
+
` proxy_set_header Host $host;`,
|
|
106
|
+
` proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;`,
|
|
107
|
+
` proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;`,
|
|
108
|
+
` }`,
|
|
109
|
+
``,
|
|
110
|
+
].join('\n');
|
|
111
|
+
// Find the server block's closing brace (2-space indent — distinct from location
|
|
112
|
+
// blocks at 4-space indent) and insert the proxy block before it.
|
|
113
|
+
const serverCloseIdx = existingNginx.lastIndexOf('\n }');
|
|
114
|
+
if (serverCloseIdx !== -1) {
|
|
115
|
+
host.write(nginxConfPath, existingNginx.slice(0, serverCloseIdx) +
|
|
116
|
+
'\n' +
|
|
117
|
+
proxyBlock +
|
|
118
|
+
existingNginx.slice(serverCloseIdx));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// 2. Write (or merge into) the dev proxy config file.
|
|
122
|
+
const devProxyFilename = isVue ? 'vite.proxy.json' : 'proxy.conf.json';
|
|
123
|
+
const devProxyPath = path.join(projectRoot, devProxyFilename);
|
|
124
|
+
const existingProxy = host.exists(devProxyPath)
|
|
125
|
+
? (0, devkit_1.readJson)(host, devProxyPath)
|
|
126
|
+
: {};
|
|
127
|
+
if (!existingProxy[nginxProxy.location]) {
|
|
128
|
+
(0, devkit_1.writeJson)(host, devProxyPath, Object.assign(Object.assign({}, existingProxy), buildDevProxyConf([nginxProxy])));
|
|
129
|
+
}
|
|
130
|
+
// 3. Patch the frontend's project configuration.
|
|
131
|
+
const proxyTag = `adsp:proxy-service:${backendService}:${port}`;
|
|
132
|
+
if (!((_c = frontendConfig.tags) !== null && _c !== void 0 ? _c : []).includes(proxyTag)) {
|
|
133
|
+
frontendConfig.tags = [...((_d = frontendConfig.tags) !== null && _d !== void 0 ? _d : []), proxyTag];
|
|
134
|
+
}
|
|
135
|
+
if (((_f = (_e = frontendConfig.targets) === null || _e === void 0 ? void 0 : _e.serve) === null || _f === void 0 ? void 0 : _f.options) &&
|
|
136
|
+
!frontendConfig.targets.serve.options.proxyConfig) {
|
|
137
|
+
frontendConfig.targets.serve.options = Object.assign(Object.assign({}, frontendConfig.targets.serve.options), { proxyConfig: devProxyPath });
|
|
138
|
+
}
|
|
139
|
+
// React/Angular only: add nginx.conf as a webpack build asset so it lands in the output root.
|
|
140
|
+
// Vue's @nx/vite:build copies public/ automatically — no asset glob needed.
|
|
141
|
+
if (isRootNginx && ((_h = (_g = frontendConfig.targets) === null || _g === void 0 ? void 0 : _g.build) === null || _h === void 0 ? void 0 : _h.options)) {
|
|
142
|
+
const assets = (_j = frontendConfig.targets.build.options.assets) !== null && _j !== void 0 ? _j : [];
|
|
143
|
+
const hasNginxAsset = assets.some((a) => typeof a === 'object' &&
|
|
144
|
+
a.glob === 'nginx.conf' &&
|
|
145
|
+
a.input === projectRoot);
|
|
146
|
+
if (!hasNginxAsset) {
|
|
147
|
+
frontendConfig.targets.build.options = Object.assign(Object.assign({}, frontendConfig.targets.build.options), { assets: [...assets, { glob: 'nginx.conf', input: projectRoot, output: './' }] });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
(0, devkit_1.updateProjectConfiguration)(host, frontendName, frontendConfig);
|
|
151
|
+
}
|
|
29
152
|
//# sourceMappingURL=paired-project.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paired-project.js","sourceRoot":"","sources":["../../../../../packages/nx-adsp/src/utils/paired-project.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"paired-project.js","sourceRoot":"","sources":["../../../../../packages/nx-adsp/src/utils/paired-project.ts"],"names":[],"mappings":";;AA4BA,8CAmBC;AAWD,8DAiBC;AAYD,4DAWC;AAMD,oEA4GC;AApND,uCAOoB;AACpB,6BAA6B;AAC7B,iEAAsE;AACtE,2DAAgE;AAehE,2FAA2F;AAC3F,gGAAgG;AAChG,+CAA+C;AAC/C,SAAgB,iBAAiB,CAC/B,YAAuC;IAEvC,OAAO,YAAY,CAAC,MAAM,CACxB,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE;QACxB,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAClD,MAAM,KAAK,GAAkB;YAC3B,MAAM,EAAE,GAAG,WAAW,CAAC,QAAQ,cAAc,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YAC7F,MAAM,EAAE,WAAW,CAAC,QAAQ,KAAK,QAAQ;YACzC,YAAY,EAAE,KAAK;YACnB,WAAW,EACT,WAAW,CAAC,QAAQ,CAA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