@wavemaker-ai/react-codegen 1.0.0-rc.647712 → 12.0.0-rc.335
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/command.js +52 -7
- package/command.js.map +1 -1
- package/dist/transpiler/index.d.mts +42 -1
- package/dist/transpiler/index.mjs +452 -18
- package/dist/transpiler/index.mjs.map +1 -1
- package/dist/transpiler/wm-styles.css +7 -0
- package/index.js +7 -0
- package/index.js.map +1 -1
- package/package-lock.json +100 -100
- package/package.json +1 -1
- package/src/app.generator.js +223 -35
- package/src/app.generator.js.map +1 -1
- package/src/handlebar-helpers.js +32 -0
- package/src/handlebar-helpers.js.map +1 -1
- package/src/increment-builder.js +32 -2
- package/src/increment-builder.js.map +1 -1
- package/src/profiles/profile.js +2 -0
- package/src/profiles/profile.js.map +1 -1
- package/src/profiles/web-preview.profile.js +4 -0
- package/src/profiles/web-preview.profile.js.map +1 -1
- package/src/services/designtime-collector.js +235 -0
- package/src/services/designtime-collector.js.map +1 -0
- package/src/services/doc-normalizer.js +185 -0
- package/src/services/doc-normalizer.js.map +1 -0
- package/src/services/method-emitter.js +367 -0
- package/src/services/method-emitter.js.map +1 -0
- package/src/services/model-emitter.js +281 -0
- package/src/services/model-emitter.js.map +1 -0
- package/src/services/schema-to-ts.js +50 -0
- package/src/services/schema-to-ts.js.map +1 -0
- package/src/services/service.generator.js +223 -0
- package/src/services/service.generator.js.map +1 -0
- package/src/transpile/components/container/tabs.transformer.js +2 -0
- package/src/transpile/components/container/tabs.transformer.js.map +1 -1
- package/src/transpile/components/dialogs/dialog.transformer.js +14 -3
- package/src/transpile/components/dialogs/dialog.transformer.js.map +1 -1
- package/src/transpile/variables-template-source.js +2 -2
- package/src/transpile/variables-template-source.js.map +1 -1
- package/src/utils.browser.js +9 -5
- package/src/utils.browser.js.map +1 -1
- package/src/variables/variable.transformer.js +623 -12
- package/src/variables/variable.transformer.js.map +1 -1
- package/templates/project/app/client.layout.tsx +7 -7
- package/templates/project/app/components.css +7 -0
- package/templates/project/package.json +6 -5
- package/templates/project/services/base.service.ts +361 -0
- package/templates/service/service-class.hbs +19 -0
- package/templates/variables.template +67 -1
package/command.js
CHANGED
|
@@ -10,6 +10,8 @@ const handlebar_helpers_1 = __importDefault(require("./src/handlebar-helpers"));
|
|
|
10
10
|
const app_generator_1 = __importDefault(require("./src/app.generator"));
|
|
11
11
|
const execa_1 = __importDefault(require("execa"));
|
|
12
12
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
13
|
+
const web_preview_profile_1 = __importDefault(require("./src/profiles/web-preview.profile"));
|
|
14
|
+
const profile_1 = require("./src/profiles/profile");
|
|
13
15
|
const increment_builder_1 = require("./src/increment-builder");
|
|
14
16
|
const utils_1 = require("./src/utils");
|
|
15
17
|
const wmx_generator_1 = require("./src/wmx.generator");
|
|
@@ -55,12 +57,20 @@ const updateAppId = (dest, appId) => {
|
|
|
55
57
|
app_config["expo"]["android"]["package"] = appId;
|
|
56
58
|
(0, utils_1.writeFile)(`${dest}/app.json`, JSON.stringify(app_config, null, 4));
|
|
57
59
|
};
|
|
58
|
-
const buildCmd = ({ src, dest, page, profile, autoClean, incrementalBuild, options, }) => {
|
|
60
|
+
const buildCmd = ({ src, dest, page, profile, autoClean, incrementalBuild, filePath, options, }) => {
|
|
59
61
|
const isRemoteProvider = src.startsWith("http");
|
|
60
62
|
const appUrl = isRemoteProvider ? src : "..";
|
|
61
63
|
const buildDataPath = `${dest}/.build`;
|
|
62
64
|
let buildData = {};
|
|
63
65
|
let buildStartTime = Date.now();
|
|
66
|
+
// Activates the profile's flags. Dropped in 1d3126a's refactor, which left the
|
|
67
|
+
// import behind -- so every web-preview build silently ran with the DEFAULT
|
|
68
|
+
// profile, and web-preview.profile.ts was dead code. Anything the profile is
|
|
69
|
+
// meant to switch off (page/layout grouping, WMX component generation) has to
|
|
70
|
+
// go through here or it has no effect.
|
|
71
|
+
if (profile === "web-preview") {
|
|
72
|
+
(0, profile_1.setProfile)(web_preview_profile_1.default);
|
|
73
|
+
}
|
|
64
74
|
(0, transform_register_1.default)();
|
|
65
75
|
(0, handlebar_helpers_1.default)();
|
|
66
76
|
console.log(`Generating the project from "${src}".`);
|
|
@@ -69,16 +79,38 @@ const buildCmd = ({ src, dest, page, profile, autoClean, incrementalBuild, optio
|
|
|
69
79
|
if (options.appId) {
|
|
70
80
|
updateAppId(dest, options.appId);
|
|
71
81
|
}
|
|
72
|
-
|
|
82
|
+
const namedFiles = [].concat(filePath || []).filter(f => !!f);
|
|
83
|
+
// Decided here rather than in the chain below because whether the target is
|
|
84
|
+
// about to be wiped determines whether this run may be narrowed at all.
|
|
85
|
+
// isCleanNecessary creates .wm_lock on its first call, so it is asked once and
|
|
86
|
+
// the answer reused.
|
|
87
|
+
const willClean = autoClean && fs_extra_1.default.existsSync(dest) && isCleanNecessary(dest);
|
|
88
|
+
// A narrowed build is only safe on top of an app that already exists: with an
|
|
89
|
+
// IncrementalBuilder set, generateApp skips copying the project template, so
|
|
90
|
+
// running one against an ungenerated -- or about to be emptied -- target would
|
|
91
|
+
// leave a broken app behind.
|
|
92
|
+
//
|
|
93
|
+
// `.build` living inside the target is what makes it the right test: wipe the
|
|
94
|
+
// target and the marker goes with it, so the next run is a full one.
|
|
95
|
+
const alreadyBuilt = !isRemoteProvider && !willClean && fs_extra_1.default.existsSync(buildDataPath);
|
|
96
|
+
// True when this run was told what changed rather than working it out. Such a
|
|
97
|
+
// run only covers what it was told about, so it must not advance the marker.
|
|
98
|
+
let scopedToNamedFiles = false;
|
|
99
|
+
if (alreadyBuilt) {
|
|
73
100
|
buildData = fs_extra_1.default.readJSONSync(buildDataPath) || {};
|
|
74
|
-
if (
|
|
101
|
+
if (namedFiles.length) {
|
|
102
|
+
// lastBuildTime is unused when the list is supplied.
|
|
103
|
+
incBuilder = new increment_builder_1.IncrementalBuilder(src, 0, namedFiles);
|
|
104
|
+
scopedToNamedFiles = true;
|
|
105
|
+
}
|
|
106
|
+
else if (profile !== "web-preview" && incrementalBuild && buildData.lastBuildTime) {
|
|
75
107
|
incBuilder = new increment_builder_1.IncrementalBuilder(src, buildData.lastBuildTime);
|
|
76
108
|
}
|
|
77
109
|
}
|
|
78
110
|
const generator = new app_generator_1.default(dest, projectService, appUrl, undefined, incBuilder, options);
|
|
79
111
|
return (Promise.resolve()
|
|
80
112
|
.then(() => {
|
|
81
|
-
if (
|
|
113
|
+
if (willClean) {
|
|
82
114
|
fs_extra_1.default.removeSync(dest);
|
|
83
115
|
fs_extra_1.default.mkdirpSync(dest);
|
|
84
116
|
}
|
|
@@ -90,12 +122,25 @@ const buildCmd = ({ src, dest, page, profile, autoClean, incrementalBuild, optio
|
|
|
90
122
|
return generator.generateApp(options);
|
|
91
123
|
})
|
|
92
124
|
.then(() => {
|
|
93
|
-
|
|
94
|
-
|
|
125
|
+
// `lastBuildTime` claims everything older than it has been generated.
|
|
126
|
+
// A run scoped to named files has no basis for that claim: anything that
|
|
127
|
+
// changed but was not named would be buried by the marker moving past
|
|
128
|
+
// it, and no later scan would ever see it again.
|
|
129
|
+
if (!scopedToNamedFiles) {
|
|
130
|
+
buildData.lastBuildTime = buildStartTime;
|
|
131
|
+
fs_extra_1.default.writeJSONSync(buildDataPath, buildData);
|
|
132
|
+
}
|
|
95
133
|
console.timeEnd("App creation");
|
|
96
134
|
})
|
|
97
135
|
.then(() => installLocalDependencies(dest))
|
|
98
|
-
|
|
136
|
+
// Skipped for web previews: the preview builder installs WMX dependencies
|
|
137
|
+
// itself with a single `npm install` at the generated app's root, which
|
|
138
|
+
// the "workspaces": ["wmx-components/*"] entry resolves in one pass.
|
|
139
|
+
// Installing per component here would repeat that work on every page
|
|
140
|
+
// save, and it leaves the root node_modules holding only the hoisted
|
|
141
|
+
// component deps -- enough to look installed while the app's own
|
|
142
|
+
// dependencies (esbuild among them) are still missing.
|
|
143
|
+
.then(() => profile !== "web-preview" && (0, wmx_generator_1.installWmxDependencies)(dest))
|
|
99
144
|
// TODO: Check why it's required
|
|
100
145
|
// .then(() => installNPMDependencies(dest))
|
|
101
146
|
.catch(e => {
|
package/command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../command.ts"],"names":[],"mappings":";;;;;;AAAA,uGAAiF;AACjF,4EAAsD;AACtD,gFAAsD;AACtD,wEAA+C;AAC/C,kDAA0B;AAC1B,wDAA0B;
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../command.ts"],"names":[],"mappings":";;;;;;AAAA,uGAAiF;AACjF,4EAAsD;AACtD,gFAAsD;AACtD,wEAA+C;AAC/C,kDAA0B;AAC1B,wDAA0B;AAC1B,6FAAmE;AACnE,oDAA8D;AAC9D,+DAA6D;AAC7D,uCAAwC;AACxC,uDAA6D;AAI7D,MAAM,mBAAmB,GAAG,CAAC,CAAS,EAAE,EAAE;IACxC,IAAI,CAAC;QACH,OAAO,kBAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC,CAAC;AAEF,iGAAiG;AACjG,mEAAmE;AAEnE,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE;;IAChD,MAAM,WAAW,GAAG,kBAAE,CAAC,YAAY,CAAC,GAAG,IAAI,eAAe,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACnF,IAAI,CAAA,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,YAAY,CAAC,6BAA6B,CAAC,0CAAE,OAAO,CAAC,OAAO,CAAC,IAAG,CAAC,EAAE,CAAC;QACnF,OAAO,IAAA,eAAK,EACV,MAAM,EACN;YACE,KAAK;YACL,yBAAyB;YACzB,6BAA6B;YAC7B,6BAA6B;SAC9B,EACD;YACE,GAAG,EAAE,IAAI;SACV,CACF,CAAC;IACJ,CAAC;AACH,CAAC,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E,CAAC,aAAa,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QAC3C,0EAA0E;QAC1E,wEAAwE;QACxE,qEAAqE;QACrE,qEAAqE;QACrE,qEAAqE;QACrE,iEAAiE;QACjE,uDAAuD;SACtD,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,KAAK,aAAa,IAAI,IAAA,sCAAsB,EAAC,IAAI,CAAC,CAAC;QACtE,gCAAgC;QAChC,4CAA4C;SAC3C,KAAK,CAAC,CAAC,CAAC,EAAE;QACT,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CACL,CAAC;AACJ,CAAC,CAAC;AA5GW,QAAA,QAAQ,YA4GnB"}
|
|
@@ -29,7 +29,48 @@ interface TranspiledOutput {
|
|
|
29
29
|
|
|
30
30
|
declare const transform: (expr: string, scopeName?: string, mode?: "event" | "attr") => string;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Emits one method per operation: every declared parameter becomes a positional argument, in the
|
|
34
|
+
* doc's order, named from `x-WM-ORIGINAL-NAME`. Types come from the service's shared models
|
|
35
|
+
* (model-emitter.ts) — this file emits none of its own.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** One positional argument of the generated method. */
|
|
39
|
+
interface MethodArg {
|
|
40
|
+
/** Identifier used in the generated signature (declared arg name, made TS-safe). */
|
|
41
|
+
name: string;
|
|
42
|
+
/** TS type expression. */
|
|
43
|
+
tsType: string;
|
|
44
|
+
optional: boolean;
|
|
45
|
+
/** How the invokeHttp glue sources this arg from the runtime's flat params object. */
|
|
46
|
+
source: {
|
|
47
|
+
kind: "path";
|
|
48
|
+
paramName: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: "query";
|
|
51
|
+
paramName: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: "body";
|
|
54
|
+
paramName: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "formData";
|
|
57
|
+
paramName: string;
|
|
58
|
+
} | {
|
|
59
|
+
kind: "header";
|
|
60
|
+
paramName: string;
|
|
61
|
+
} | {
|
|
62
|
+
kind: "pageable";
|
|
63
|
+
paramNames: string[];
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface CrudOperationTarget {
|
|
68
|
+
methodName: string;
|
|
69
|
+
importPath: string;
|
|
70
|
+
args: MethodArg[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare const _default: (variable: any, scope: string, appUrl: string, imports: string[], validServiceClassNames?: Set<string>, methodArgsByOperation?: Map<string, MethodArg[]>, methodNameByOperation?: Map<string, string>, servicePathByOperation?: Map<string, string>, crudOperationsById?: Map<string, Record<string, CrudOperationTarget>>) => any;
|
|
33
74
|
|
|
34
75
|
interface TranspiledVariableDefinitions {
|
|
35
76
|
variables: any[];
|