@aws-amplify/amplify-util-uibuilder 1.2.16-pin-codegen-dependency.0 → 1.2.16
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/CHANGELOG.md +1 -1
- package/lib/commands/generateComponents.d.ts +1 -1
- package/lib/commands/generateComponents.d.ts.map +1 -1
- package/lib/commands/generateComponents.js +8 -9
- package/lib/commands/generateComponents.js.map +1 -1
- package/lib/commands/utils/createUiBuilderComponent.d.ts +4 -3
- package/lib/commands/utils/createUiBuilderComponent.d.ts.map +1 -1
- package/lib/commands/utils/createUiBuilderComponent.js +20 -12
- package/lib/commands/utils/createUiBuilderComponent.js.map +1 -1
- package/lib/commands/utils/createUiBuilderComponentNew.d.ts +5 -0
- package/lib/commands/utils/createUiBuilderComponentNew.d.ts.map +1 -0
- package/lib/commands/utils/createUiBuilderComponentNew.js +44 -0
- package/lib/commands/utils/createUiBuilderComponentNew.js.map +1 -0
- package/lib/commands/utils/notifyMissingPackages.d.ts +2 -1
- package/lib/commands/utils/notifyMissingPackages.d.ts.map +1 -1
- package/lib/commands/utils/notifyMissingPackages.js +13 -4
- package/lib/commands/utils/notifyMissingPackages.js.map +1 -1
- package/lib/commands/utils/syncAmplifyUiBuilderComponents.d.ts +2 -2
- package/package.json +12 -10
- package/src/__tests__/createUiBuilderComponent.test.ts +2 -2
- package/src/__tests__/generateComponents.test.ts +0 -2
- package/src/__tests__/notifyMissingPackages.test.ts +4 -4
- package/src/commands/generateComponents.ts +11 -16
- package/src/commands/utils/createUiBuilderComponent.ts +21 -44
- package/src/commands/utils/createUiBuilderComponentNew.ts +53 -0
- package/src/commands/utils/notifyMissingPackages.ts +16 -12
- package/tsconfig.json +7 -7
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [1.2.16
|
|
6
|
+
## [1.2.16](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/amplify-util-uibuilder@1.2.15...@aws-amplify/amplify-util-uibuilder@1.2.16) (2022-03-14)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @aws-amplify/amplify-util-uibuilder
|
|
9
9
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateComponents.d.ts","sourceRoot":"","sources":["../../src/commands/generateComponents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateComponents.d.ts","sourceRoot":"","sources":["../../src/commands/generateComponents.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,wBAAsB,GAAG,CAAC,OAAO,EAAE,UAAU,iBAyC5C"}
|
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.run = void 0;
|
|
7
|
-
const amplify_prompts_1 = require("amplify-prompts");
|
|
8
|
-
const ora_1 = __importDefault(require("ora"));
|
|
9
7
|
const notifyMissingPackages_1 = require("./utils/notifyMissingPackages");
|
|
10
8
|
const shouldRenderComponents_1 = require("./utils/shouldRenderComponents");
|
|
11
9
|
const syncAmplifyUiBuilderComponents_1 = require("./utils/syncAmplifyUiBuilderComponents");
|
|
12
10
|
const createUiBuilderComponent_1 = require("./utils/createUiBuilderComponent");
|
|
13
|
-
const
|
|
11
|
+
const amplify_prompts_1 = require("amplify-prompts");
|
|
12
|
+
const ora_1 = __importDefault(require("ora"));
|
|
13
|
+
async function run(context) {
|
|
14
14
|
amplify_prompts_1.printer.debug('Running generate components command in amplify-util-uibuilder');
|
|
15
15
|
if (!(await (0, shouldRenderComponents_1.shouldRenderComponents)(context))) {
|
|
16
16
|
return;
|
|
@@ -39,16 +39,15 @@ const run = async (context) => {
|
|
|
39
39
|
else {
|
|
40
40
|
spinner.succeed('Synced UI components.');
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(0, notifyMissingPackages_1.notifyMissingPackages)(context);
|
|
42
|
+
(0, notifyMissingPackages_1.notifyMissingPackages)(context, [
|
|
43
|
+
...generatedComponentResults.filter(({ resultType }) => resultType === 'SUCCESS').map(({ component }) => component),
|
|
44
|
+
...generatedThemeResults.filter(({ resultType }) => resultType === 'SUCCESS').map(({ theme }) => theme),
|
|
45
|
+
]);
|
|
47
46
|
}
|
|
48
47
|
catch (e) {
|
|
49
48
|
amplify_prompts_1.printer.debug(e);
|
|
50
49
|
spinner.fail('Failed to sync UI components');
|
|
51
50
|
}
|
|
52
|
-
}
|
|
51
|
+
}
|
|
53
52
|
exports.run = run;
|
|
54
53
|
//# sourceMappingURL=generateComponents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateComponents.js","sourceRoot":"","sources":["../../src/commands/generateComponents.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"generateComponents.js","sourceRoot":"","sources":["../../src/commands/generateComponents.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAsE;AACtE,2EAAwE;AACxE,2FAKgD;AAEhD,+EAAqF;AACrF,qDAA0C;AAC1C,8CAAsB;AAGf,KAAK,UAAU,GAAG,CAAC,OAAmB;IAC3C,yBAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;IAC/E,IAAI,CAAC,CAAC,MAAM,IAAA,+CAAsB,EAAC,OAAO,CAAC,CAAC,EAAE;QAC5C,OAAO;KACR;IACD,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,EAAE,CAAC,CAAC;IACxB,IAAI;QACF,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAA,wDAAuB,EAAC,OAAO,CAAC,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,EAAE,EAAE,CAAC,UAAU,CAAC;SAClH,CAAC;QAEF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,4CAA4C,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACtF;aAAM;YACL,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;SAC1C;QAED,IAAA,6CAAqB,EAAC,OAAO,EAAE;YAC7B,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC;YACnH,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC;SAChF,CAAC,CAAC;KAC5B;IAAC,OAAO,CAAC,EAAE;QACV,yBAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;KAC9C;AACH,CAAC;AAzCD,kBAyCC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { StudioComponent,
|
|
1
|
+
import { StudioComponent, RenderTextComponentResponse } from '@aws-amplify/codegen-ui-old';
|
|
2
|
+
import { StudioComponent as StudioComponentNew, StudioTheme } from '@aws-amplify/codegen-ui-new';
|
|
2
3
|
import { $TSContext } from 'amplify-cli-core';
|
|
3
|
-
export declare const createUiBuilderComponent: (context: $TSContext, schema: StudioComponent) => StudioComponent;
|
|
4
|
+
export declare const createUiBuilderComponent: (context: $TSContext, schema: StudioComponent) => StudioComponentNew | StudioComponent;
|
|
4
5
|
export declare const createUiBuilderTheme: (context: $TSContext, schema: StudioTheme) => StudioTheme;
|
|
5
|
-
export declare const generateAmplifyUiBuilderIndexFile: (context: $TSContext, schemas:
|
|
6
|
+
export declare const generateAmplifyUiBuilderIndexFile: (context: $TSContext, schemas: StudioComponentNew[]) => RenderTextComponentResponse;
|
|
6
7
|
//# sourceMappingURL=createUiBuilderComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUiBuilderComponent.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/createUiBuilderComponent.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"createUiBuilderComponent.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/createUiBuilderComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,eAAe,EAAiF,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AASzM,OAAO,EAAC,eAAe,IAAI,kBAAkB,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAG/F,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAc9C,eAAO,MAAM,wBAAwB,YAAa,UAAU,UAAU,eAAe,yCAuBpF,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAa,UAAU,UAAU,WAAW,gBAmB5E,CAAC;AAEF,eAAO,MAAM,iCAAiC,YAAa,UAAU,WAAW,kBAAkB,EAAE,gCAgBhG,CAAC"}
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateAmplifyUiBuilderIndexFile = exports.createUiBuilderTheme = exports.createUiBuilderComponent = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const amplify_prompts_1 = require("amplify-prompts");
|
|
4
|
+
const codegen_ui_old_1 = require("@aws-amplify/codegen-ui-old");
|
|
5
|
+
const codegen_ui_react_old_1 = require("@aws-amplify/codegen-ui-react-old");
|
|
7
6
|
const getUiBuilderComponentsPath_1 = require("./getUiBuilderComponentsPath");
|
|
7
|
+
const amplify_prompts_1 = require("amplify-prompts");
|
|
8
|
+
const createUiBuilderComponentNew_1 = require("./createUiBuilderComponentNew");
|
|
9
|
+
const codegen_ui_react_new_1 = require("@aws-amplify/codegen-ui-react-new");
|
|
8
10
|
const config = {
|
|
9
|
-
module:
|
|
10
|
-
target:
|
|
11
|
-
script:
|
|
11
|
+
module: codegen_ui_react_old_1.ModuleKind.ES2020,
|
|
12
|
+
target: codegen_ui_react_old_1.ScriptTarget.ES2020,
|
|
13
|
+
script: codegen_ui_react_old_1.ScriptKind.JSX,
|
|
12
14
|
renderTypeDeclarations: true,
|
|
13
15
|
};
|
|
16
|
+
const isUpdatedSchema = (schema) => {
|
|
17
|
+
return schema.schemaVersion && schema.schemaVersion === '1.0';
|
|
18
|
+
};
|
|
14
19
|
const createUiBuilderComponent = (context, schema) => {
|
|
20
|
+
if (isUpdatedSchema(schema)) {
|
|
21
|
+
return (0, createUiBuilderComponentNew_1.createUiBuilderComponent)(context, schema);
|
|
22
|
+
}
|
|
15
23
|
const uiBuilderComponentsPath = (0, getUiBuilderComponentsPath_1.getUiBuilderComponentsPath)(context);
|
|
16
|
-
const rendererFactory = new
|
|
24
|
+
const rendererFactory = new codegen_ui_old_1.StudioTemplateRendererFactory((component) => new codegen_ui_react_old_1.AmplifyRenderer(component, config));
|
|
17
25
|
const outputPathDir = uiBuilderComponentsPath;
|
|
18
|
-
const rendererManager = new
|
|
26
|
+
const rendererManager = new codegen_ui_old_1.StudioTemplateRendererManager(rendererFactory, {
|
|
19
27
|
outputPathDir,
|
|
20
28
|
});
|
|
21
29
|
rendererManager.renderSchemaToTemplate(schema);
|
|
@@ -24,9 +32,9 @@ const createUiBuilderComponent = (context, schema) => {
|
|
|
24
32
|
exports.createUiBuilderComponent = createUiBuilderComponent;
|
|
25
33
|
const createUiBuilderTheme = (context, schema) => {
|
|
26
34
|
const uiBuilderComponentsPath = (0, getUiBuilderComponentsPath_1.getUiBuilderComponentsPath)(context);
|
|
27
|
-
const rendererFactory = new
|
|
35
|
+
const rendererFactory = new codegen_ui_old_1.StudioTemplateRendererFactory((component) => new codegen_ui_react_old_1.ReactThemeStudioTemplateRenderer(component, config));
|
|
28
36
|
const outputPathDir = uiBuilderComponentsPath;
|
|
29
|
-
const rendererManager = new
|
|
37
|
+
const rendererManager = new codegen_ui_old_1.StudioTemplateRendererManager(rendererFactory, {
|
|
30
38
|
outputPathDir,
|
|
31
39
|
});
|
|
32
40
|
try {
|
|
@@ -43,9 +51,9 @@ const createUiBuilderTheme = (context, schema) => {
|
|
|
43
51
|
exports.createUiBuilderTheme = createUiBuilderTheme;
|
|
44
52
|
const generateAmplifyUiBuilderIndexFile = (context, schemas) => {
|
|
45
53
|
const uiBuilderComponentsPath = (0, getUiBuilderComponentsPath_1.getUiBuilderComponentsPath)(context);
|
|
46
|
-
const rendererFactory = new
|
|
54
|
+
const rendererFactory = new codegen_ui_old_1.StudioTemplateRendererFactory((component) => new codegen_ui_react_new_1.ReactIndexStudioTemplateRenderer(component, config));
|
|
47
55
|
const outputPathDir = uiBuilderComponentsPath;
|
|
48
|
-
const rendererManager = new
|
|
56
|
+
const rendererManager = new codegen_ui_old_1.StudioTemplateRendererManager(rendererFactory, {
|
|
49
57
|
outputPathDir,
|
|
50
58
|
});
|
|
51
59
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUiBuilderComponent.js","sourceRoot":"","sources":["../../../src/commands/utils/createUiBuilderComponent.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"createUiBuilderComponent.js","sourceRoot":"","sources":["../../../src/commands/utils/createUiBuilderComponent.ts"],"names":[],"mappings":";;;AAAA,gEAAyM;AACzM,4EAM2C;AAG3C,6EAA0E;AAC1E,qDAA0C;AAE1C,+EAAwG;AACxG,4EAAqF;AACrF,MAAM,MAAM,GAAG;IACb,MAAM,EAAE,iCAAU,CAAC,MAAM;IACzB,MAAM,EAAE,mCAAY,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a;KACd,CAAC,CAAC;IAEH,IAAI;QACF,eAAe,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAC/C,OAAO,MAAM,CAAC;KACf;IAAC,OAAO,CAAC,EAAE;QACV,yBAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,yBAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACpD,yBAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,CAAC,CAAC;KACT;AACH,CAAC,CAAC;AAnBW,QAAA,oBAAoB,wBAmB/B;AAEK,MAAM,iCAAiC,GAAG,CAAC,OAAmB,EAAE,OAA6B,EAAE,EAAE;IACtG,MAAM,uBAAuB,GAAG,IAAA,uDAA0B,EAAC,OAAO,CAAC,CAAC;IACpE,MAAM,eAAe,GAAG,IAAI,8CAA6B,CAAC,CAAC,SAA+B,EAAE,EAAE,CAAC,IAAI,uDAAgC,CAAC,SAAS,EAAE,MAAM,CAAmI,CAAC,CAAC;IAE1R,MAAM,aAAa,GAAG,uBAAuB,CAAC;IAE9C,MAAM,eAAe,GAAG,IAAI,8CAA6B,CAAC,eAAe,EAAE;QACzE,aAAa;KACd,CAAC,CAAC;IAEH,IAAI;QACF,OAAO,eAAe,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;KACxD;IAAC,OAAO,CAAC,EAAE;QACV,yBAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,yBAAO,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACzD,MAAM,CAAC,CAAC;KACT;AAAA,CAAC,CAAC;AAhBQ,QAAA,iCAAiC,qCAgBzC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { StudioComponent, StudioTheme } from '@aws-amplify/codegen-ui-new';
|
|
2
|
+
import { $TSContext } from 'amplify-cli-core';
|
|
3
|
+
export declare const createUiBuilderComponent: (context: $TSContext, schema: StudioComponent) => StudioComponent;
|
|
4
|
+
export declare const createUiBuilderTheme: (context: $TSContext, schema: StudioTheme) => StudioTheme;
|
|
5
|
+
//# sourceMappingURL=createUiBuilderComponentNew.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUiBuilderComponentNew.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/createUiBuilderComponentNew.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgE,eAAe,EAAE,WAAW,EAA+E,MAAM,6BAA6B,CAAC;AAWtN,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAQ9C,eAAO,MAAM,wBAAwB,YAAa,UAAU,UAAU,eAAe,oBAYpF,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAa,UAAU,UAAU,WAAW,gBAmB5E,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createUiBuilderTheme = exports.createUiBuilderComponent = void 0;
|
|
4
|
+
const codegen_ui_new_1 = require("@aws-amplify/codegen-ui-new");
|
|
5
|
+
const codegen_ui_react_new_1 = require("@aws-amplify/codegen-ui-react-new");
|
|
6
|
+
const getUiBuilderComponentsPath_1 = require("./getUiBuilderComponentsPath");
|
|
7
|
+
const amplify_prompts_1 = require("amplify-prompts");
|
|
8
|
+
const config = {
|
|
9
|
+
module: codegen_ui_react_new_1.ModuleKind.ES2020,
|
|
10
|
+
target: codegen_ui_react_new_1.ScriptTarget.ES2020,
|
|
11
|
+
script: codegen_ui_react_new_1.ScriptKind.JSX,
|
|
12
|
+
renderTypeDeclarations: true,
|
|
13
|
+
};
|
|
14
|
+
const createUiBuilderComponent = (context, schema) => {
|
|
15
|
+
const uiBuilderComponentsPath = (0, getUiBuilderComponentsPath_1.getUiBuilderComponentsPath)(context);
|
|
16
|
+
const rendererFactory = new codegen_ui_new_1.StudioTemplateRendererFactory((component) => new codegen_ui_react_new_1.AmplifyRenderer(component, config));
|
|
17
|
+
const outputPathDir = uiBuilderComponentsPath;
|
|
18
|
+
const rendererManager = new codegen_ui_new_1.StudioTemplateRendererManager(rendererFactory, {
|
|
19
|
+
outputPathDir,
|
|
20
|
+
});
|
|
21
|
+
rendererManager.renderSchemaToTemplate(schema);
|
|
22
|
+
return schema;
|
|
23
|
+
};
|
|
24
|
+
exports.createUiBuilderComponent = createUiBuilderComponent;
|
|
25
|
+
const createUiBuilderTheme = (context, schema) => {
|
|
26
|
+
const uiBuilderComponentsPath = (0, getUiBuilderComponentsPath_1.getUiBuilderComponentsPath)(context);
|
|
27
|
+
const rendererFactory = new codegen_ui_new_1.StudioTemplateRendererFactory((component) => new codegen_ui_react_new_1.ReactThemeStudioTemplateRenderer(component, config));
|
|
28
|
+
const outputPathDir = uiBuilderComponentsPath;
|
|
29
|
+
const rendererManager = new codegen_ui_new_1.StudioTemplateRendererManager(rendererFactory, {
|
|
30
|
+
outputPathDir,
|
|
31
|
+
});
|
|
32
|
+
try {
|
|
33
|
+
rendererManager.renderSchemaToTemplate(schema);
|
|
34
|
+
return schema;
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
amplify_prompts_1.printer.debug(e);
|
|
38
|
+
amplify_prompts_1.printer.debug('Skipping invalid theme with schema');
|
|
39
|
+
amplify_prompts_1.printer.debug(JSON.stringify(schema, null, 2));
|
|
40
|
+
throw e;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.createUiBuilderTheme = createUiBuilderTheme;
|
|
44
|
+
//# sourceMappingURL=createUiBuilderComponentNew.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUiBuilderComponentNew.js","sourceRoot":"","sources":["../../../src/commands/utils/createUiBuilderComponentNew.ts"],"names":[],"mappings":";;;AAAA,gEAAsN;AACtN,4EAO2C;AAC3C,6EAA0E;AAC1E,qDAA0C;AAE1C,MAAM,MAAM,G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AO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACpD,yBAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,CAAC,CAAC;KACT;AACH,CAAC,CAAC;AAnBW,QAAA,oBAAoB,wBAmB/B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { $TSContext } from 'amplify-cli-core';
|
|
2
|
-
|
|
2
|
+
import { StudioComponent } from '@aws-amplify/codegen-ui-new';
|
|
3
|
+
export declare const notifyMissingPackages: (context: $TSContext, schemas: StudioComponent[]) => void;
|
|
3
4
|
//# sourceMappingURL=notifyMissingPackages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifyMissingPackages.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/notifyMissingPackages.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"notifyMissingPackages.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/notifyMissingPackages.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,UAAU,EAAU,MAAM,kBAAkB,CAAC;AAQlF,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAa9D,eAAO,MAAM,qBAAqB,YAAa,UAAU,WAAW,eAAe,EAAE,SA8BpF,CAAC"}
|
|
@@ -9,10 +9,19 @@ const amplify_prompts_1 = require("amplify-prompts");
|
|
|
9
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const subset_1 = __importDefault(require("semver/ranges/subset"));
|
|
12
|
-
const codegen_ui_react_1 = require("@aws-amplify/codegen-ui-react");
|
|
13
12
|
const extractArgs_1 = require("./extractArgs");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
13
|
+
const codegen_ui_react_old_1 = require("@aws-amplify/codegen-ui-react-old");
|
|
14
|
+
const codegen_ui_react_new_1 = require("@aws-amplify/codegen-ui-react-new");
|
|
15
|
+
const isUpdatedSchema = (schemas) => {
|
|
16
|
+
return schemas.some(schema => schema.schemaVersion && schema.schemaVersion === '1.0');
|
|
17
|
+
};
|
|
18
|
+
const getRequiredDependencies = (schemas) => {
|
|
19
|
+
if (isUpdatedSchema(schemas)) {
|
|
20
|
+
return new codegen_ui_react_new_1.ReactRequiredDependencyProvider().getRequiredDependencies();
|
|
21
|
+
}
|
|
22
|
+
return new codegen_ui_react_old_1.ReactRequiredDependencyProvider().getRequiredDependencies();
|
|
23
|
+
};
|
|
24
|
+
const notifyMissingPackages = (context, schemas) => {
|
|
16
25
|
var _a;
|
|
17
26
|
const args = (0, extractArgs_1.extractArgs)(context);
|
|
18
27
|
const localEnvFilePath = (_a = args.localEnvFilePath) !== null && _a !== void 0 ? _a : amplify_cli_core_1.pathManager.getLocalEnvFilePath();
|
|
@@ -27,7 +36,7 @@ const notifyMissingPackages = (context) => {
|
|
|
27
36
|
return;
|
|
28
37
|
}
|
|
29
38
|
const packageJson = amplify_cli_core_1.JSONUtilities.readJson(packageJsonPath);
|
|
30
|
-
getRequiredDependencies().forEach((dependency) => {
|
|
39
|
+
getRequiredDependencies(schemas).forEach((dependency) => {
|
|
31
40
|
const packageIsInstalled = Object.keys(packageJson.dependencies).includes(dependency.dependencyName);
|
|
32
41
|
if (!packageIsInstalled) {
|
|
33
42
|
amplify_prompts_1.printer.warn(`UIBuilder components required "${dependency.dependencyName}" that is not in your package.json. Run \`npm install "${dependency.dependencyName}@${dependency.supportedSemVerPattern}"\`. ${dependency.reason}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifyMissingPackages.js","sourceRoot":"","sources":["../../../src/commands/utils/notifyMissingPackages.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"notifyMissingPackages.js","sourceRoot":"","sources":["../../../src/commands/utils/notifyMissingPackages.ts"],"names":[],"mappings":";;;;;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CAAC,QAAQ,CAAC,eAAe,CAAgD,CAAC;IAC3G,uBAAuB,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,UAAkB,EAAE,EAAE;QAC9D,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QACrG,IAAI,CAAC,kBAAkB,EAAE;YACvB,yBAAO,CAAC,IAAI,CACV,kCAAkC,UAAU,CAAC,cAAc,0DAA0D,UAAU,CAAC,cAAc,IAAI,UAAU,CAAC,sBAAsB,QAAQ,UAAU,CAAC,MAAM,EAAE,CAC/M,CAAC;SACH;aAAM,IAAI,CAAC,IAAA,gBAAW,EAAC,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,sBAAsB,CAAC,EAAE;YAC/G,yBAAO,CAAC,IAAI,CACV,0CAA0C,UAAU,CAAC,sBAAsB,SACzE,UAAU,CAAC,cACb,oCAAoC,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,cAAc,CAAC,yBACrF,UAAU,CAAC,cACb,IAAI,UAAU,CAAC,sBAAsB,QAAQ,UAAU,CAAC,MAAM,EAAE,CACjE,CAAC;SACH;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA9BW,QAAA,qBAAqB,yBA8BhC"}
|
|
@@ -7,7 +7,7 @@ export declare function listUiBuilderComponents(context: $TSContext, envName?: s
|
|
|
7
7
|
export declare function listUiBuilderThemes(context: $TSContext, envName?: string): Promise<import("aws-sdk/lib/request").PromiseResult<aws.AmplifyUIBuilder.ExportThemesResponse, aws.AWSError>>;
|
|
8
8
|
export declare function generateUiBuilderComponents(context: $TSContext, componentSchemas: any[]): ({
|
|
9
9
|
resultType: string;
|
|
10
|
-
component: import("@aws-amplify/codegen-ui").StudioComponent;
|
|
10
|
+
component: import("@aws-amplify/codegen-ui-new").StudioComponent | import("@aws-amplify/codegen-ui-old").StudioComponent;
|
|
11
11
|
schemaName?: undefined;
|
|
12
12
|
error?: undefined;
|
|
13
13
|
} | {
|
|
@@ -18,7 +18,7 @@ export declare function generateUiBuilderComponents(context: $TSContext, compone
|
|
|
18
18
|
})[];
|
|
19
19
|
export declare function generateUiBuilderThemes(context: $TSContext, themeSchemas: any[]): ({
|
|
20
20
|
resultType: string;
|
|
21
|
-
theme: import("@aws-amplify/codegen-ui").StudioTheme;
|
|
21
|
+
theme: import("@aws-amplify/codegen-ui-new").StudioTheme;
|
|
22
22
|
schemaName?: undefined;
|
|
23
23
|
error?: undefined;
|
|
24
24
|
} | {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/amplify-util-uibuilder",
|
|
3
|
-
"version": "1.2.16
|
|
3
|
+
"version": "1.2.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,15 +13,17 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@aws-amplify/codegen-ui": "2.1.
|
|
17
|
-
"@aws-amplify/codegen-ui-
|
|
18
|
-
"@
|
|
19
|
-
"@
|
|
20
|
-
"amplify-cli-core": "2.4.18
|
|
16
|
+
"@aws-amplify/codegen-ui-new": "npm:@aws-amplify/codegen-ui@2.1.0",
|
|
17
|
+
"@aws-amplify/codegen-ui-old": "npm:@aws-amplify/codegen-ui@1.2.0",
|
|
18
|
+
"@aws-amplify/codegen-ui-react-new": "npm:@aws-amplify/codegen-ui-react@2.1.0",
|
|
19
|
+
"@aws-amplify/codegen-ui-react-old": "npm:@aws-amplify/codegen-ui-react@1.2.0",
|
|
20
|
+
"amplify-cli-core": "2.4.18",
|
|
21
21
|
"amplify-prompts": "1.6.3",
|
|
22
|
-
"amplify-provider-awscloudformation": "5.9.10
|
|
23
|
-
"aws-sdk": "2.1084.0"
|
|
24
|
-
|
|
22
|
+
"amplify-provider-awscloudformation": "5.9.10",
|
|
23
|
+
"aws-sdk": "2.1084.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@aws-amplify/codegen-ui": "2.1.0"
|
|
25
27
|
},
|
|
26
28
|
"jest": {
|
|
27
29
|
"testRunner": "jest-circus/runner",
|
|
@@ -58,5 +60,5 @@
|
|
|
58
60
|
"usePathForSuiteName": "true",
|
|
59
61
|
"addFileAttribute": "true"
|
|
60
62
|
},
|
|
61
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "f4fca61223f56eb79e6363d32fc16083fd043759"
|
|
62
64
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as codegen from '@aws-amplify/codegen-ui';
|
|
1
|
+
import * as codegen from '@aws-amplify/codegen-ui-old';
|
|
2
2
|
import {
|
|
3
3
|
generateAmplifyUiBuilderIndexFile,
|
|
4
4
|
createUiBuilderTheme,
|
|
5
5
|
createUiBuilderComponent,
|
|
6
6
|
} from '../commands/utils/createUiBuilderComponent';
|
|
7
|
-
jest.mock('@aws-amplify/codegen-ui');
|
|
7
|
+
jest.mock('@aws-amplify/codegen-ui-old');
|
|
8
8
|
const codegen_mock = codegen as any;
|
|
9
9
|
const renderSchemaToTemplateMock = jest.fn();
|
|
10
10
|
|
|
@@ -23,7 +23,7 @@ describe('should notify when packages are missing', () => {
|
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
|
-
notifyMissingPackages(context as JSONUtilitiesDependency.$TSContext);
|
|
26
|
+
notifyMissingPackages(context as JSONUtilitiesDependency.$TSContext, []);
|
|
27
27
|
expect(printerDependency.printer.debug).toBeCalledTimes(1);
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -39,7 +39,7 @@ describe('should notify when packages are missing', () => {
|
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
|
-
notifyMissingPackages(context as JSONUtilitiesDependency.$TSContext);
|
|
42
|
+
notifyMissingPackages(context as JSONUtilitiesDependency.$TSContext, []);
|
|
43
43
|
expect(printerDependency.printer.debug).toBeCalledTimes(1);
|
|
44
44
|
});
|
|
45
45
|
|
|
@@ -51,7 +51,7 @@ describe('should notify when packages are missing', () => {
|
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
|
-
notifyMissingPackages(context as JSONUtilitiesDependency.$TSContext);
|
|
54
|
+
notifyMissingPackages(context as JSONUtilitiesDependency.$TSContext, []);
|
|
55
55
|
expect(printerDependency.printer.warn).toBeCalledTimes(1);
|
|
56
56
|
});
|
|
57
57
|
|
|
@@ -67,7 +67,7 @@ describe('should notify when packages are missing', () => {
|
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
69
|
};
|
|
70
|
-
notifyMissingPackages(context as JSONUtilitiesDependency.$TSContext);
|
|
70
|
+
notifyMissingPackages(context as JSONUtilitiesDependency.$TSContext, []);
|
|
71
71
|
expect(printerDependency.printer.warn).toBeCalledTimes(1);
|
|
72
72
|
});
|
|
73
73
|
});
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { StudioComponent } from '@aws-amplify/codegen-ui';
|
|
2
|
-
import { printer } from 'amplify-prompts';
|
|
3
|
-
import ora from 'ora';
|
|
4
|
-
import { $TSContext } from 'amplify-cli-core';
|
|
5
1
|
import { notifyMissingPackages } from './utils/notifyMissingPackages';
|
|
6
2
|
import { shouldRenderComponents } from './utils/shouldRenderComponents';
|
|
7
3
|
import {
|
|
@@ -10,12 +6,13 @@ import {
|
|
|
10
6
|
generateUiBuilderComponents,
|
|
11
7
|
generateUiBuilderThemes,
|
|
12
8
|
} from './utils/syncAmplifyUiBuilderComponents';
|
|
9
|
+
import { StudioComponent as StudioComponentNew } from '@aws-amplify/codegen-ui-new';
|
|
13
10
|
import { generateAmplifyUiBuilderIndexFile } from './utils/createUiBuilderComponent';
|
|
11
|
+
import { printer } from 'amplify-prompts';
|
|
12
|
+
import ora from 'ora';
|
|
13
|
+
import { $TSContext } from 'amplify-cli-core';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
* Pulls ui components from Studio backend and generates the code in the user's file system
|
|
17
|
-
*/
|
|
18
|
-
export const run = async (context: $TSContext): Promise<void> => {
|
|
15
|
+
export async function run(context: $TSContext) {
|
|
19
16
|
printer.debug('Running generate components command in amplify-util-uibuilder');
|
|
20
17
|
if (!(await shouldRenderComponents(context))) {
|
|
21
18
|
return;
|
|
@@ -35,7 +32,7 @@ export const run = async (context: $TSContext): Promise<void> => {
|
|
|
35
32
|
generateAmplifyUiBuilderIndexFile(context, [
|
|
36
33
|
...generatedComponentResults.filter(({ resultType }) => resultType === 'SUCCESS').map(({ component }) => component),
|
|
37
34
|
...generatedThemeResults.filter(({ resultType }) => resultType === 'SUCCESS').map(({ theme }) => theme),
|
|
38
|
-
] as
|
|
35
|
+
] as StudioComponentNew[]);
|
|
39
36
|
|
|
40
37
|
const failedSchemas = [
|
|
41
38
|
...generatedComponentResults.filter(({ resultType }) => resultType === 'FAILURE').map(({ schemaName }) => schemaName),
|
|
@@ -48,14 +45,12 @@ export const run = async (context: $TSContext): Promise<void> => {
|
|
|
48
45
|
spinner.succeed('Synced UI components.');
|
|
49
46
|
}
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
notifyMissingPackages(context);
|
|
48
|
+
notifyMissingPackages(context, [
|
|
49
|
+
...generatedComponentResults.filter(({ resultType }) => resultType === 'SUCCESS').map(({ component }) => component),
|
|
50
|
+
...generatedThemeResults.filter(({ resultType }) => resultType === 'SUCCESS').map(({ theme }) => theme),
|
|
51
|
+
] as StudioComponentNew[]);
|
|
57
52
|
} catch (e) {
|
|
58
53
|
printer.debug(e);
|
|
59
54
|
spinner.fail('Failed to sync UI components');
|
|
60
55
|
}
|
|
61
|
-
}
|
|
56
|
+
}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
StudioTemplateRendererManager,
|
|
3
|
-
StudioComponent,
|
|
4
|
-
StudioTheme,
|
|
5
|
-
StudioTemplateRendererFactory,
|
|
6
|
-
StudioTemplateRenderer,
|
|
7
|
-
FrameworkOutputManager,
|
|
8
|
-
RenderTextComponentResponse,
|
|
9
|
-
} from '@aws-amplify/codegen-ui';
|
|
1
|
+
import { StudioTemplateRendererManager, StudioComponent, StudioTemplateRendererFactory, StudioTemplateRenderer, FrameworkOutputManager, RenderTextComponentResponse } from '@aws-amplify/codegen-ui-old';
|
|
10
2
|
import {
|
|
11
3
|
AmplifyRenderer,
|
|
12
4
|
ReactThemeStudioTemplateRenderer,
|
|
13
|
-
ReactIndexStudioTemplateRenderer,
|
|
14
5
|
ModuleKind,
|
|
15
6
|
ScriptTarget,
|
|
16
7
|
ScriptKind,
|
|
17
|
-
} from '@aws-amplify/codegen-ui-react';
|
|
8
|
+
} from '@aws-amplify/codegen-ui-react-old';
|
|
18
9
|
|
|
10
|
+
import {StudioComponent as StudioComponentNew, StudioTheme} from '@aws-amplify/codegen-ui-new';
|
|
11
|
+
import { getUiBuilderComponentsPath } from './getUiBuilderComponentsPath';
|
|
19
12
|
import { printer } from 'amplify-prompts';
|
|
20
13
|
import { $TSContext } from 'amplify-cli-core';
|
|
21
|
-
import {
|
|
22
|
-
|
|
14
|
+
import { createUiBuilderComponent as createUiBuilderComponentNew } from './createUiBuilderComponentNew';
|
|
15
|
+
import { ReactIndexStudioTemplateRenderer } from '@aws-amplify/codegen-ui-react-new';
|
|
23
16
|
const config = {
|
|
24
17
|
module: ModuleKind.ES2020,
|
|
25
18
|
target: ScriptTarget.ES2020,
|
|
@@ -27,13 +20,18 @@ const config = {
|
|
|
27
20
|
renderTypeDeclarations: true,
|
|
28
21
|
};
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
const isUpdatedSchema = (schema: StudioComponent) => {
|
|
24
|
+
return (schema as unknown as StudioComponentNew).schemaVersion && (schema as unknown as StudioComponentNew).schemaVersion === '1.0';
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const createUiBuilderComponent = (context: $TSContext, schema: StudioComponent) => {
|
|
28
|
+
if (isUpdatedSchema(schema)) {
|
|
29
|
+
return createUiBuilderComponentNew(context, schema as unknown as StudioComponentNew);
|
|
30
|
+
}
|
|
34
31
|
const uiBuilderComponentsPath = getUiBuilderComponentsPath(context);
|
|
35
32
|
const rendererFactory = new StudioTemplateRendererFactory(
|
|
36
|
-
(component: StudioComponent) =>
|
|
33
|
+
(component: StudioComponent) =>
|
|
34
|
+
new AmplifyRenderer(component as StudioComponent, config) as unknown as StudioTemplateRenderer<
|
|
37
35
|
unknown,
|
|
38
36
|
StudioComponent,
|
|
39
37
|
FrameworkOutputManager<unknown>,
|
|
@@ -51,19 +49,9 @@ export const createUiBuilderComponent = (context: $TSContext, schema: StudioComp
|
|
|
51
49
|
return schema;
|
|
52
50
|
};
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
* Writes theme file to the work space
|
|
56
|
-
*/
|
|
57
|
-
export const createUiBuilderTheme = (context: $TSContext, schema: StudioTheme): StudioTheme => {
|
|
52
|
+
export const createUiBuilderTheme = (context: $TSContext, schema: StudioTheme) => {
|
|
58
53
|
const uiBuilderComponentsPath = getUiBuilderComponentsPath(context);
|
|
59
|
-
const rendererFactory = new StudioTemplateRendererFactory(
|
|
60
|
-
(component: StudioTheme) => new ReactThemeStudioTemplateRenderer(component, config) as unknown as StudioTemplateRenderer<
|
|
61
|
-
unknown,
|
|
62
|
-
StudioTheme,
|
|
63
|
-
FrameworkOutputManager<unknown>,
|
|
64
|
-
RenderTextComponentResponse
|
|
65
|
-
>,
|
|
66
|
-
);
|
|
54
|
+
const rendererFactory = new StudioTemplateRendererFactory((component: StudioTheme) => new ReactThemeStudioTemplateRenderer(component, config) as unknown as StudioTemplateRenderer<unknown, StudioTheme, FrameworkOutputManager<unknown>, RenderTextComponentResponse>);
|
|
67
55
|
|
|
68
56
|
const outputPathDir = uiBuilderComponentsPath;
|
|
69
57
|
|
|
@@ -82,19 +70,9 @@ export const createUiBuilderTheme = (context: $TSContext, schema: StudioTheme):
|
|
|
82
70
|
}
|
|
83
71
|
};
|
|
84
72
|
|
|
85
|
-
|
|
86
|
-
* Writes index file to the work space
|
|
87
|
-
*/
|
|
88
|
-
export const generateAmplifyUiBuilderIndexFile = (context: $TSContext, schemas: StudioComponent[]): RenderTextComponentResponse => {
|
|
73
|
+
export const generateAmplifyUiBuilderIndexFile = (context: $TSContext, schemas: StudioComponentNew[]) => {
|
|
89
74
|
const uiBuilderComponentsPath = getUiBuilderComponentsPath(context);
|
|
90
|
-
const rendererFactory = new StudioTemplateRendererFactory(
|
|
91
|
-
(component: StudioComponent[]) => new ReactIndexStudioTemplateRenderer(component, config) as unknown as StudioTemplateRenderer<
|
|
92
|
-
unknown,
|
|
93
|
-
StudioComponent[],
|
|
94
|
-
FrameworkOutputManager<unknown>,
|
|
95
|
-
RenderTextComponentResponse
|
|
96
|
-
>,
|
|
97
|
-
);
|
|
75
|
+
const rendererFactory = new StudioTemplateRendererFactory((component: StudioComponentNew[]) => new ReactIndexStudioTemplateRenderer(component, config) as unknown as StudioTemplateRenderer<unknown, StudioComponentNew[], FrameworkOutputManager<unknown>, RenderTextComponentResponse>);
|
|
98
76
|
|
|
99
77
|
const outputPathDir = uiBuilderComponentsPath;
|
|
100
78
|
|
|
@@ -108,5 +86,4 @@ export const generateAmplifyUiBuilderIndexFile = (context: $TSContext, schemas:
|
|
|
108
86
|
printer.debug(e);
|
|
109
87
|
printer.debug('Failed to generate component index file');
|
|
110
88
|
throw e;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
89
|
+
}};
|