@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
|
@@ -39375,14 +39375,17 @@ var removeLeadingCssBlockComments = (rule) => {
|
|
|
39375
39375
|
}
|
|
39376
39376
|
return { prefix, rest: rule.slice(idx) };
|
|
39377
39377
|
};
|
|
39378
|
+
var CUSTOM_TAG_SELECTOR_PATTERN = /(^|[\s>+~,(])([a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]*)/g;
|
|
39379
|
+
var convertCustomTagSelectorsToClasses = (sel) => sel.replace(CUSTOM_TAG_SELECTOR_PATTERN, (_match, boundary, tag) => `${boundary}.${tag}`);
|
|
39378
39380
|
var scopeSingleSelector = (selector, scopeClass) => {
|
|
39379
|
-
const
|
|
39380
|
-
if (!
|
|
39381
|
-
return
|
|
39381
|
+
const trimmed = selector.trim();
|
|
39382
|
+
if (!trimmed) {
|
|
39383
|
+
return trimmed;
|
|
39382
39384
|
}
|
|
39383
|
-
if (
|
|
39384
|
-
return
|
|
39385
|
+
if (trimmed.startsWith(":")) {
|
|
39386
|
+
return trimmed;
|
|
39385
39387
|
}
|
|
39388
|
+
const sel = convertCustomTagSelectorsToClasses(trimmed);
|
|
39386
39389
|
const wmAppIndex = sel.search(/\.wm-app\b/);
|
|
39387
39390
|
if (wmAppIndex !== -1) {
|
|
39388
39391
|
if (sel.includes(`.${scopeClass}`)) {
|
|
@@ -39771,6 +39774,54 @@ function resolveFormatContext(expression, context) {
|
|
|
39771
39774
|
return expression.replace(/,\s*\{formatContext:''\}/g, "").replace(FORMAT_CONTEXT_REGEX, "");
|
|
39772
39775
|
}
|
|
39773
39776
|
|
|
39777
|
+
// src/services/schema-to-ts.ts
|
|
39778
|
+
function toPascalCase(name) {
|
|
39779
|
+
const words = String(name || "").split(/[^a-zA-Z0-9]+/).filter(Boolean);
|
|
39780
|
+
if (!words.length) return "Model";
|
|
39781
|
+
let result = words.map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
39782
|
+
if (/^[0-9]/.test(result)) result = "_" + result;
|
|
39783
|
+
return result;
|
|
39784
|
+
}
|
|
39785
|
+
function buildServiceClassName(serviceId, tag) {
|
|
39786
|
+
const servicePascal = toPascalCase(serviceId || "");
|
|
39787
|
+
const serviceCore = servicePascal.endsWith("Service") ? servicePascal.slice(0, -"Service".length) : servicePascal;
|
|
39788
|
+
const core = tag === servicePascal || tag === serviceCore ? serviceCore : tag;
|
|
39789
|
+
return `${core}Service`;
|
|
39790
|
+
}
|
|
39791
|
+
|
|
39792
|
+
// src/services/doc-normalizer.ts
|
|
39793
|
+
function toCamelCaseIdentifier(name) {
|
|
39794
|
+
if (typeof name !== "string" || !/[^a-zA-Z0-9]/.test(name)) return name;
|
|
39795
|
+
const words = name.split(/[^a-zA-Z0-9]+/).filter(Boolean);
|
|
39796
|
+
if (!words.length) return name;
|
|
39797
|
+
let result = words.map((w, i) => i === 0 ? w : w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
39798
|
+
if (/^[0-9]/.test(result)) result = "_" + result;
|
|
39799
|
+
return result;
|
|
39800
|
+
}
|
|
39801
|
+
function deriveMethodName(rawOperationId, prefixCandidates) {
|
|
39802
|
+
if (!rawOperationId) return "";
|
|
39803
|
+
for (const prefix of prefixCandidates) {
|
|
39804
|
+
if (!prefix) continue;
|
|
39805
|
+
const doubled = `${prefix}_${prefix}_`;
|
|
39806
|
+
if (rawOperationId.startsWith(doubled)) {
|
|
39807
|
+
return toCamelCaseIdentifier(rawOperationId.slice(prefix.length + 1));
|
|
39808
|
+
}
|
|
39809
|
+
}
|
|
39810
|
+
let operationId = rawOperationId;
|
|
39811
|
+
let strippedSomething = true;
|
|
39812
|
+
while (strippedSomething) {
|
|
39813
|
+
strippedSomething = false;
|
|
39814
|
+
for (const prefix of prefixCandidates) {
|
|
39815
|
+
if (prefix && operationId.startsWith(`${prefix}_`)) {
|
|
39816
|
+
operationId = operationId.slice(prefix.length + 1);
|
|
39817
|
+
strippedSomething = true;
|
|
39818
|
+
break;
|
|
39819
|
+
}
|
|
39820
|
+
}
|
|
39821
|
+
}
|
|
39822
|
+
return toCamelCaseIdentifier(operationId);
|
|
39823
|
+
}
|
|
39824
|
+
|
|
39774
39825
|
// src/variables/variable.transformer.ts
|
|
39775
39826
|
var import_lodash2 = __toESM(require_lodash());
|
|
39776
39827
|
function bindingValueIsStatic(value) {
|
|
@@ -39803,6 +39854,28 @@ function isStaticParamsVariable(variable2) {
|
|
|
39803
39854
|
}
|
|
39804
39855
|
return filterExpressionsAreStatic(variable2.filterExpressions);
|
|
39805
39856
|
}
|
|
39857
|
+
function simpleSingularize(plural) {
|
|
39858
|
+
const lower = plural.toLowerCase();
|
|
39859
|
+
if (lower.endsWith("ies")) return plural.substring(0, plural.length - 3) + "y";
|
|
39860
|
+
if (lower.endsWith("es")) return plural.substring(0, plural.length - 2);
|
|
39861
|
+
if (lower.endsWith("s")) return plural.substring(0, plural.length - 1);
|
|
39862
|
+
return plural;
|
|
39863
|
+
}
|
|
39864
|
+
function simplePluralize(singular) {
|
|
39865
|
+
if (!singular) return singular;
|
|
39866
|
+
const last = singular[singular.length - 1].toLowerCase();
|
|
39867
|
+
const prev = singular.length > 1 ? singular[singular.length - 2].toLowerCase() : null;
|
|
39868
|
+
const vowels = "aeiouy";
|
|
39869
|
+
if (last === "x" || last === "s") {
|
|
39870
|
+
return singular + "es";
|
|
39871
|
+
} else if (last === "y") {
|
|
39872
|
+
return prev !== null && vowels.includes(prev) ? singular + "s" : singular.slice(0, -1) + "ies";
|
|
39873
|
+
} else if (last === "h") {
|
|
39874
|
+
return prev !== null && (prev === "c" || prev === "s") ? singular + "es" : singular + "s";
|
|
39875
|
+
} else {
|
|
39876
|
+
return singular + "s";
|
|
39877
|
+
}
|
|
39878
|
+
}
|
|
39806
39879
|
function parseStaticJsonValue(value) {
|
|
39807
39880
|
const trimmedValue = value.trim();
|
|
39808
39881
|
if (!trimmedValue.startsWith("{") && !trimmedValue.startsWith("[")) {
|
|
@@ -40212,9 +40285,166 @@ function transformModelVariable(variable2, scope) {
|
|
|
40212
40285
|
tv.isList = !!variable2.isList;
|
|
40213
40286
|
return tv;
|
|
40214
40287
|
}
|
|
40215
|
-
|
|
40288
|
+
var capitalizeFirstLetter = (str) => {
|
|
40289
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
40290
|
+
};
|
|
40291
|
+
var getServiceInstanceName = (className) => className.charAt(0).toLowerCase() + className.slice(1);
|
|
40292
|
+
function getServiceLocalName(serviceId, className) {
|
|
40293
|
+
const instanceName = getServiceInstanceName(className);
|
|
40294
|
+
if (!serviceId) {
|
|
40295
|
+
return instanceName;
|
|
40296
|
+
}
|
|
40297
|
+
const prefix = toPascalCase(serviceId);
|
|
40298
|
+
const core = prefix.endsWith("Service") ? prefix.slice(0, -"Service".length) : prefix;
|
|
40299
|
+
if (className.startsWith(core)) {
|
|
40300
|
+
return instanceName;
|
|
40301
|
+
}
|
|
40302
|
+
return getServiceInstanceName(`${core}${className}`);
|
|
40303
|
+
}
|
|
40304
|
+
function getServiceClassName(prefix) {
|
|
40305
|
+
if (!prefix || typeof prefix !== "string") return "Service";
|
|
40306
|
+
const base = prefix.replace(/[\s/\\\-_]+/g, "").trim();
|
|
40307
|
+
if (!base) return "Service";
|
|
40308
|
+
let basePascal = capitalizeFirstLetter(base);
|
|
40309
|
+
if (basePascal.endsWith("Controller")) {
|
|
40310
|
+
basePascal = basePascal.slice(0, -"Controller".length);
|
|
40311
|
+
}
|
|
40312
|
+
if (!basePascal) return "Service";
|
|
40313
|
+
return basePascal.endsWith("Service") ? basePascal : basePascal + "Service";
|
|
40314
|
+
}
|
|
40315
|
+
function toCamelCaseIdentifier2(name) {
|
|
40316
|
+
if (typeof name !== "string" || !/[^a-zA-Z0-9]/.test(name)) return name;
|
|
40317
|
+
const words = name.split(/[^a-zA-Z0-9]+/).filter(Boolean);
|
|
40318
|
+
if (!words.length) return name;
|
|
40319
|
+
let result = words.map((word, i) => i === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
40320
|
+
if (/^[0-9]/.test(result)) result = "_" + result;
|
|
40321
|
+
return result;
|
|
40322
|
+
}
|
|
40323
|
+
function resolveServiceTag(serviceId, controller, serviceType) {
|
|
40324
|
+
const isLumpedOpenApiService = serviceType === "OpenAPIService" && (!controller || controller.toLowerCase() === "default");
|
|
40325
|
+
const base = isLumpedOpenApiService ? serviceId.endsWith("Service") ? serviceId.slice(0, -"Service".length) : serviceId : controller || serviceId;
|
|
40326
|
+
return base ? toPascalCase(base) : base;
|
|
40327
|
+
}
|
|
40328
|
+
function formatServiceDetails(variable2) {
|
|
40329
|
+
if (variable2.operationId) {
|
|
40330
|
+
const serviceName = variable2.service;
|
|
40331
|
+
let prefix;
|
|
40332
|
+
let invokeFnName;
|
|
40333
|
+
if (serviceName) {
|
|
40334
|
+
prefix = serviceName;
|
|
40335
|
+
const controllerRaw = variable2.controller ? `${variable2.controller}Controller` : void 0;
|
|
40336
|
+
const prefixCandidates = [serviceName, variable2.controller, controllerRaw].filter(
|
|
40337
|
+
Boolean
|
|
40338
|
+
);
|
|
40339
|
+
invokeFnName = deriveMethodName(variable2.operationId, prefixCandidates);
|
|
40340
|
+
} else {
|
|
40341
|
+
const sepIdx = variable2.operationId.indexOf("_");
|
|
40342
|
+
prefix = sepIdx >= 0 ? variable2.operationId.substring(0, sepIdx) : variable2.operationId;
|
|
40343
|
+
invokeFnName = sepIdx >= 0 ? variable2.operationId.substring(sepIdx + 1) : variable2.operationId;
|
|
40344
|
+
}
|
|
40345
|
+
invokeFnName = toCamelCaseIdentifier2(invokeFnName);
|
|
40346
|
+
const formattedServiceName = variable2.service ? buildServiceClassName(
|
|
40347
|
+
variable2.service,
|
|
40348
|
+
resolveServiceTag(variable2.service, variable2.controller, variable2.serviceType)
|
|
40349
|
+
) : getServiceClassName(prefix);
|
|
40350
|
+
return {
|
|
40351
|
+
formattedServiceName,
|
|
40352
|
+
invokeFnName
|
|
40353
|
+
};
|
|
40354
|
+
}
|
|
40355
|
+
if (variable2.type && variable2.operation) {
|
|
40356
|
+
const entity = variable2.type;
|
|
40357
|
+
const singular = simpleSingularize(entity);
|
|
40358
|
+
const plural = simplePluralize(singular);
|
|
40359
|
+
const operationMap = {
|
|
40360
|
+
read: `filter${plural}`,
|
|
40361
|
+
insert: `create${singular}`,
|
|
40362
|
+
update: `edit${singular}`,
|
|
40363
|
+
delete: `delete${singular}`
|
|
40364
|
+
};
|
|
40365
|
+
const invokeFnName = operationMap[variable2.operation];
|
|
40366
|
+
if (!invokeFnName) return null;
|
|
40367
|
+
const formattedServiceName = variable2.liveSource ? buildServiceClassName(variable2.liveSource, capitalizeFirstLetter(entity)) : capitalizeFirstLetter(entity + "Service");
|
|
40368
|
+
return {
|
|
40369
|
+
formattedServiceName,
|
|
40370
|
+
invokeFnName
|
|
40371
|
+
};
|
|
40372
|
+
}
|
|
40373
|
+
return null;
|
|
40374
|
+
}
|
|
40375
|
+
function isServiceAvailable(className, validServiceClassNames) {
|
|
40376
|
+
return !validServiceClassNames || !className || validServiceClassNames.has(className);
|
|
40377
|
+
}
|
|
40378
|
+
function callArgExpression(arg, isLiveVariable, isBodyTypeQueryOrProcedure = false) {
|
|
40379
|
+
if (isBodyTypeQueryOrProcedure && arg.source.kind === "body") {
|
|
40380
|
+
return "params";
|
|
40381
|
+
}
|
|
40382
|
+
if (arg.source.kind === "pageable") {
|
|
40383
|
+
const props = arg.source.paramNames.map((wireName) => {
|
|
40384
|
+
const prop = wireName === "sort" ? "sort" : wireName === "size" ? "pageSize" : "pageNumber";
|
|
40385
|
+
return `${prop}: params?.[${JSON.stringify(wireName)}]`;
|
|
40386
|
+
}).join(", ");
|
|
40387
|
+
return `{ ${props} }`;
|
|
40388
|
+
}
|
|
40389
|
+
return `params?.[${JSON.stringify(liveVariableParamKey(arg, isLiveVariable))}]`;
|
|
40390
|
+
}
|
|
40391
|
+
function applyServiceCallShape(tv, lookupKey, methodArgsByOperation, servicePathByOperation, isLiveVariable = false, isBodyTypeQueryOrProcedure = false) {
|
|
40392
|
+
var _a;
|
|
40393
|
+
const importPath = servicePathByOperation == null ? void 0 : servicePathByOperation.get(lookupKey);
|
|
40394
|
+
if (importPath) {
|
|
40395
|
+
tv.serviceImportPath = importPath;
|
|
40396
|
+
const resolvedClassName = importPath.split("/").pop();
|
|
40397
|
+
if (resolvedClassName && resolvedClassName !== tv.serviceFileClass) {
|
|
40398
|
+
tv.serviceFile = resolvedClassName;
|
|
40399
|
+
tv.serviceFileClass = resolvedClassName;
|
|
40400
|
+
tv.serviceExportName = getServiceInstanceName(resolvedClassName);
|
|
40401
|
+
tv.serviceInstanceName = getServiceLocalName((_a = tv.service) != null ? _a : tv.liveSource, resolvedClassName);
|
|
40402
|
+
}
|
|
40403
|
+
}
|
|
40404
|
+
const args = methodArgsByOperation == null ? void 0 : methodArgsByOperation.get(lookupKey);
|
|
40405
|
+
if (!args) {
|
|
40406
|
+
return;
|
|
40407
|
+
}
|
|
40408
|
+
tv.hasResolvedCallArgs = true;
|
|
40409
|
+
tv.callArgs = args.map((arg) => callArgExpression(arg, isLiveVariable, isBodyTypeQueryOrProcedure));
|
|
40410
|
+
}
|
|
40411
|
+
function liveVariableParamKey(arg, isLiveVariable) {
|
|
40412
|
+
const swaggerName = arg.source.paramName;
|
|
40413
|
+
if (!isLiveVariable) {
|
|
40414
|
+
return swaggerName;
|
|
40415
|
+
}
|
|
40416
|
+
switch (arg.source.kind) {
|
|
40417
|
+
case "query":
|
|
40418
|
+
return swaggerName === "q" ? "data" : swaggerName;
|
|
40419
|
+
case "body":
|
|
40420
|
+
case "formData":
|
|
40421
|
+
return "data";
|
|
40422
|
+
case "path":
|
|
40423
|
+
return "id";
|
|
40424
|
+
default:
|
|
40425
|
+
return swaggerName;
|
|
40426
|
+
}
|
|
40427
|
+
}
|
|
40428
|
+
function transformServiceVariable(variable2, scope, validServiceClassNames, methodArgsByOperation, methodNameByOperation, servicePathByOperation) {
|
|
40429
|
+
var _a;
|
|
40430
|
+
const serviceDetails = formatServiceDetails(variable2);
|
|
40431
|
+
let skipInvokeHttp = false;
|
|
40432
|
+
if (!isServiceAvailable(serviceDetails == null ? void 0 : serviceDetails.formattedServiceName, validServiceClassNames)) {
|
|
40433
|
+
console.warn(
|
|
40434
|
+
`ServiceVariable "${variable2.name}" references service "${variable2.service}" (${serviceDetails == null ? void 0 : serviceDetails.formattedServiceName}), which was not generated. Emitting the variable without an invokeHttp \u2014 the runtime falls back to its own transport.`
|
|
40435
|
+
);
|
|
40436
|
+
skipInvokeHttp = true;
|
|
40437
|
+
}
|
|
40438
|
+
const operationKey = `${variable2.service}::${variable2.operationId}`;
|
|
40439
|
+
if (servicePathByOperation && !servicePathByOperation.has(operationKey)) {
|
|
40440
|
+
console.warn(
|
|
40441
|
+
`ServiceVariable "${variable2.name}" references operation "${variable2.operationId}" on service "${variable2.service}", which has no such operation. Emitting the variable without an invokeHttp \u2014 the runtime falls back to its own transport.`
|
|
40442
|
+
);
|
|
40443
|
+
skipInvokeHttp = true;
|
|
40444
|
+
}
|
|
40216
40445
|
const tv = transformVariable(variable2, scope);
|
|
40217
40446
|
tv.classname = "ServiceVariable";
|
|
40447
|
+
tv.hasInvokeHttp = !skipInvokeHttp;
|
|
40218
40448
|
tv.operationId = variable2.operationId;
|
|
40219
40449
|
tv.isList = !!variable2.isList;
|
|
40220
40450
|
tv.inFlightBehavior = variable2.inFlightBehavior;
|
|
@@ -40228,6 +40458,21 @@ function transformServiceVariable(variable2, scope) {
|
|
|
40228
40458
|
tv.autoUpdate = variable2.autoUpdate;
|
|
40229
40459
|
tv.orderBy = variable2.orderBy;
|
|
40230
40460
|
tv.isStaticParams = isStaticParamsVariable(variable2);
|
|
40461
|
+
tv.serviceFile = serviceDetails == null ? void 0 : serviceDetails.formattedServiceName;
|
|
40462
|
+
tv.serviceFileClass = serviceDetails == null ? void 0 : serviceDetails.formattedServiceName;
|
|
40463
|
+
tv.serviceExportName = serviceDetails && getServiceInstanceName(serviceDetails.formattedServiceName);
|
|
40464
|
+
tv.serviceInstanceName = serviceDetails && getServiceLocalName(variable2.service, serviceDetails.formattedServiceName);
|
|
40465
|
+
const lookupKey = `${variable2.service}::${variable2.operationId}`;
|
|
40466
|
+
tv.invokeFnName = (_a = methodNameByOperation == null ? void 0 : methodNameByOperation.get(lookupKey)) != null ? _a : serviceDetails == null ? void 0 : serviceDetails.invokeFnName;
|
|
40467
|
+
const isBodyTypeQueryOrProcedure = ["QueryExecution", "ProcedureExecution"].includes(variable2.controller) && ["put", "post"].includes(variable2.operationType);
|
|
40468
|
+
applyServiceCallShape(
|
|
40469
|
+
tv,
|
|
40470
|
+
lookupKey,
|
|
40471
|
+
methodArgsByOperation,
|
|
40472
|
+
servicePathByOperation,
|
|
40473
|
+
false,
|
|
40474
|
+
isBodyTypeQueryOrProcedure
|
|
40475
|
+
);
|
|
40231
40476
|
return tv;
|
|
40232
40477
|
}
|
|
40233
40478
|
function transformNavigationAction(variable2, scope) {
|
|
@@ -40257,9 +40502,11 @@ function transformNotificationAction(variable2, scope, imports102) {
|
|
|
40257
40502
|
tv.classname = "NotificationAction";
|
|
40258
40503
|
tv.group = "action";
|
|
40259
40504
|
tv.operation = variable2.operation;
|
|
40260
|
-
const
|
|
40261
|
-
|
|
40262
|
-
|
|
40505
|
+
const bindings = Array.isArray(variable2.dataBinding) ? variable2.dataBinding : [];
|
|
40506
|
+
const getBinding = (target) => bindings.find((b) => b.target === target);
|
|
40507
|
+
const contentBinding = getBinding("content");
|
|
40508
|
+
const rendersPartial = contentBinding ? contentBinding.value === "page" : variable2.operation !== "toast";
|
|
40509
|
+
const partialContent = rendersPartial ? getBinding("page") : null;
|
|
40263
40510
|
if (variable2.onOk || variable2.onClick) {
|
|
40264
40511
|
tv.onOk = appendIfNotEmpty(bind_ex_transformer_default(variable2.onOk || variable2.onClick, scope, "event"));
|
|
40265
40512
|
}
|
|
@@ -40315,9 +40562,61 @@ function transformLogoutVariable(variable2, scope) {
|
|
|
40315
40562
|
tv.redirectTo = variable2.redirectTo;
|
|
40316
40563
|
return tv;
|
|
40317
40564
|
}
|
|
40318
|
-
function
|
|
40565
|
+
function findOperationKeyByMethodName(serviceName, methodName, methodNameByOperation) {
|
|
40566
|
+
if (!serviceName || !methodName || !methodNameByOperation) {
|
|
40567
|
+
return void 0;
|
|
40568
|
+
}
|
|
40569
|
+
const prefix = `${serviceName}::`;
|
|
40570
|
+
for (const [key, name] of methodNameByOperation) {
|
|
40571
|
+
if (name === methodName && key.startsWith(prefix)) {
|
|
40572
|
+
return key;
|
|
40573
|
+
}
|
|
40574
|
+
}
|
|
40575
|
+
return void 0;
|
|
40576
|
+
}
|
|
40577
|
+
function findLiveOperationKeyByVerb(liveSource, entity, verbTokens, methodNameByOperation) {
|
|
40578
|
+
if (!liveSource || !entity || !methodNameByOperation) {
|
|
40579
|
+
return void 0;
|
|
40580
|
+
}
|
|
40581
|
+
const tagPrefix = `${liveSource}::${entity}Controller_`;
|
|
40582
|
+
let best;
|
|
40583
|
+
for (const key of methodNameByOperation.keys()) {
|
|
40584
|
+
if (!key.startsWith(tagPrefix)) continue;
|
|
40585
|
+
const verbAndName = key.slice(tagPrefix.length);
|
|
40586
|
+
if (!verbTokens.some((verb) => verbAndName.startsWith(verb))) continue;
|
|
40587
|
+
if (!best || key.length < best.length) {
|
|
40588
|
+
best = key;
|
|
40589
|
+
}
|
|
40590
|
+
}
|
|
40591
|
+
return best;
|
|
40592
|
+
}
|
|
40593
|
+
var LIVE_OPERATION_VERBS = {
|
|
40594
|
+
readTableData: ["find"],
|
|
40595
|
+
searchTableDataWithQuery: ["filter"],
|
|
40596
|
+
searchTableData: ["search"],
|
|
40597
|
+
insertTableData: ["create"],
|
|
40598
|
+
updateTableData: ["edit"],
|
|
40599
|
+
deleteTableData: ["delete"]
|
|
40600
|
+
};
|
|
40601
|
+
var LIVE_DEFAULT_ACTION_BY_OPERATION = {
|
|
40602
|
+
read: "searchTableDataWithQuery",
|
|
40603
|
+
insert: "insertTableData",
|
|
40604
|
+
update: "updateTableData",
|
|
40605
|
+
delete: "deleteTableData"
|
|
40606
|
+
};
|
|
40607
|
+
function transformLiveVariable(variable2, scope, validServiceClassNames, methodArgsByOperation, methodNameByOperation, servicePathByOperation) {
|
|
40608
|
+
var _a, _b;
|
|
40609
|
+
const serviceDetails = formatServiceDetails(variable2);
|
|
40610
|
+
let skipInvokeHttp = false;
|
|
40611
|
+
if (serviceDetails && !isServiceAvailable(serviceDetails.formattedServiceName, validServiceClassNames)) {
|
|
40612
|
+
console.warn(
|
|
40613
|
+
`LiveVariable "${variable2.name}" targets entity "${variable2.type}" (${serviceDetails.formattedServiceName}), which was not generated. Emitting the variable without an invokeHttp \u2014 the runtime falls back to its own transport.`
|
|
40614
|
+
);
|
|
40615
|
+
skipInvokeHttp = true;
|
|
40616
|
+
}
|
|
40319
40617
|
const tv = transformVariable(variable2, scope);
|
|
40320
40618
|
tv.classname = "LiveVariable";
|
|
40619
|
+
tv.hasInvokeHttp = !skipInvokeHttp;
|
|
40321
40620
|
tv.isList = !!variable2.isList;
|
|
40322
40621
|
tv.inFlightBehavior = variable2.inFlightBehavior;
|
|
40323
40622
|
tv.maxResults = variable2.maxResults;
|
|
@@ -40334,9 +40633,117 @@ function transformLiveVariable(variable2, scope) {
|
|
|
40334
40633
|
tv.filterExpressions = variable2.filterExpressions;
|
|
40335
40634
|
tv._id = variable2._id;
|
|
40336
40635
|
tv.isStaticParams = isStaticParamsVariable(variable2);
|
|
40636
|
+
if (serviceDetails) {
|
|
40637
|
+
tv.serviceFile = serviceDetails.formattedServiceName;
|
|
40638
|
+
tv.serviceFileClass = serviceDetails.formattedServiceName;
|
|
40639
|
+
tv.serviceExportName = getServiceInstanceName(serviceDetails.formattedServiceName);
|
|
40640
|
+
tv.serviceInstanceName = getServiceLocalName(
|
|
40641
|
+
variable2.liveSource,
|
|
40642
|
+
serviceDetails.formattedServiceName
|
|
40643
|
+
);
|
|
40644
|
+
tv.invokeFnName = serviceDetails.invokeFnName;
|
|
40645
|
+
let lookupKey = findOperationKeyByMethodName(
|
|
40646
|
+
variable2.liveSource,
|
|
40647
|
+
serviceDetails.invokeFnName,
|
|
40648
|
+
methodNameByOperation
|
|
40649
|
+
);
|
|
40650
|
+
if (!lookupKey) {
|
|
40651
|
+
lookupKey = findLiveOperationKeyByVerb(
|
|
40652
|
+
variable2.liveSource,
|
|
40653
|
+
variable2.type,
|
|
40654
|
+
(_a = LIVE_OPERATION_VERBS[LIVE_DEFAULT_ACTION_BY_OPERATION[variable2.operation]]) != null ? _a : [],
|
|
40655
|
+
methodNameByOperation
|
|
40656
|
+
);
|
|
40657
|
+
}
|
|
40658
|
+
if (lookupKey) {
|
|
40659
|
+
tv.invokeFnName = (_b = methodNameByOperation == null ? void 0 : methodNameByOperation.get(lookupKey)) != null ? _b : tv.invokeFnName;
|
|
40660
|
+
applyServiceCallShape(
|
|
40661
|
+
tv,
|
|
40662
|
+
lookupKey,
|
|
40663
|
+
methodArgsByOperation,
|
|
40664
|
+
servicePathByOperation,
|
|
40665
|
+
true
|
|
40666
|
+
// LiveVariable — its params object is keyed by the runtime's own DB-operation names
|
|
40667
|
+
);
|
|
40668
|
+
}
|
|
40669
|
+
tv.liveTargets = buildLiveTargets(
|
|
40670
|
+
variable2,
|
|
40671
|
+
methodArgsByOperation,
|
|
40672
|
+
methodNameByOperation,
|
|
40673
|
+
servicePathByOperation
|
|
40674
|
+
);
|
|
40675
|
+
}
|
|
40337
40676
|
return tv;
|
|
40338
40677
|
}
|
|
40339
|
-
function
|
|
40678
|
+
function buildLiveTargets(variable2, methodArgsByOperation, methodNameByOperation, servicePathByOperation) {
|
|
40679
|
+
var _a, _b, _c;
|
|
40680
|
+
const entity = variable2.type;
|
|
40681
|
+
if (!entity) {
|
|
40682
|
+
return void 0;
|
|
40683
|
+
}
|
|
40684
|
+
const singular = simpleSingularize(entity);
|
|
40685
|
+
const plural = simplePluralize(singular);
|
|
40686
|
+
const byAction = [
|
|
40687
|
+
// readTableData's template is `GET /<entity>?page=&size=&:sort` — the collection GET, which
|
|
40688
|
+
// the generator names find<Plural>. filter<Plural> is the POST /filter twin and belongs only
|
|
40689
|
+
// to the query-bearing actions.
|
|
40690
|
+
["readTableData", `find${plural}`],
|
|
40691
|
+
["searchTableDataWithQuery", `filter${plural}`],
|
|
40692
|
+
["searchTableData", `search${plural}ByQueryFilters`],
|
|
40693
|
+
["insertTableData", `create${singular}`],
|
|
40694
|
+
["updateTableData", `edit${singular}`],
|
|
40695
|
+
["deleteTableData", `delete${singular}`]
|
|
40696
|
+
];
|
|
40697
|
+
const targets = [];
|
|
40698
|
+
for (const [action, guessedMethodName] of byAction) {
|
|
40699
|
+
let lookupKey = findOperationKeyByMethodName(
|
|
40700
|
+
variable2.liveSource,
|
|
40701
|
+
guessedMethodName,
|
|
40702
|
+
methodNameByOperation
|
|
40703
|
+
);
|
|
40704
|
+
if (!lookupKey) {
|
|
40705
|
+
lookupKey = findLiveOperationKeyByVerb(
|
|
40706
|
+
variable2.liveSource,
|
|
40707
|
+
entity,
|
|
40708
|
+
(_a = LIVE_OPERATION_VERBS[action]) != null ? _a : [],
|
|
40709
|
+
methodNameByOperation
|
|
40710
|
+
);
|
|
40711
|
+
}
|
|
40712
|
+
if (!lookupKey || servicePathByOperation && !servicePathByOperation.has(lookupKey)) {
|
|
40713
|
+
continue;
|
|
40714
|
+
}
|
|
40715
|
+
const methodName = (_b = methodNameByOperation == null ? void 0 : methodNameByOperation.get(lookupKey)) != null ? _b : guessedMethodName;
|
|
40716
|
+
const shape = {};
|
|
40717
|
+
applyServiceCallShape(shape, lookupKey, methodArgsByOperation, servicePathByOperation, true);
|
|
40718
|
+
targets.push({
|
|
40719
|
+
action,
|
|
40720
|
+
invokeFnName: methodName,
|
|
40721
|
+
callArgs: (_c = shape.callArgs) != null ? _c : [],
|
|
40722
|
+
hasResolvedCallArgs: !!shape.hasResolvedCallArgs
|
|
40723
|
+
});
|
|
40724
|
+
}
|
|
40725
|
+
return targets.length ? targets : void 0;
|
|
40726
|
+
}
|
|
40727
|
+
function buildCrudTargets(variable2, crudOperationsById) {
|
|
40728
|
+
const group = crudOperationsById == null ? void 0 : crudOperationsById.get(variable2.crudOperationId);
|
|
40729
|
+
if (!group) {
|
|
40730
|
+
return void 0;
|
|
40731
|
+
}
|
|
40732
|
+
const targets = Object.entries(group).map(([operationType, target]) => {
|
|
40733
|
+
const className = target.importPath.split("/").pop();
|
|
40734
|
+
return {
|
|
40735
|
+
operationType,
|
|
40736
|
+
importPath: target.importPath,
|
|
40737
|
+
serviceExportName: getServiceInstanceName(className),
|
|
40738
|
+
serviceInstanceName: getServiceLocalName(variable2.service, className),
|
|
40739
|
+
invokeFnName: target.methodName,
|
|
40740
|
+
// A CrudVariable is never a LiveVariable, so params are keyed by the swagger names.
|
|
40741
|
+
callArgs: target.args.map((arg) => callArgExpression(arg, false))
|
|
40742
|
+
};
|
|
40743
|
+
});
|
|
40744
|
+
return targets.length ? targets : void 0;
|
|
40745
|
+
}
|
|
40746
|
+
function transformCrudVariable(variable2, scope, crudOperationsById) {
|
|
40340
40747
|
const tv = transformVariable(variable2, scope);
|
|
40341
40748
|
tv._id = variable2._id;
|
|
40342
40749
|
tv.name = variable2.name;
|
|
@@ -40361,15 +40768,23 @@ function transformCrudVariable(variable2, scope) {
|
|
|
40361
40768
|
tv.dataBinding = variable2._transformedDataBinding || variable2.dataBinding;
|
|
40362
40769
|
tv.classname = "CrudVariable";
|
|
40363
40770
|
tv.group = "variable";
|
|
40771
|
+
tv.crudTargets = buildCrudTargets(variable2, crudOperationsById);
|
|
40364
40772
|
tv.isStaticParams = isStaticParamsVariable(variable2);
|
|
40365
40773
|
return tv;
|
|
40366
40774
|
}
|
|
40367
|
-
var variable_transformer_default = (variable2, scope, appUrl, imports102) => {
|
|
40775
|
+
var variable_transformer_default = (variable2, scope, appUrl, imports102, validServiceClassNames, methodArgsByOperation, methodNameByOperation, servicePathByOperation, crudOperationsById) => {
|
|
40368
40776
|
switch (variable2.category) {
|
|
40369
40777
|
case "wm.Variable":
|
|
40370
40778
|
return transformModelVariable(variable2, scope);
|
|
40371
40779
|
case "wm.ServiceVariable":
|
|
40372
|
-
return transformServiceVariable(
|
|
40780
|
+
return transformServiceVariable(
|
|
40781
|
+
variable2,
|
|
40782
|
+
scope,
|
|
40783
|
+
validServiceClassNames,
|
|
40784
|
+
methodArgsByOperation,
|
|
40785
|
+
methodNameByOperation,
|
|
40786
|
+
servicePathByOperation
|
|
40787
|
+
);
|
|
40373
40788
|
case "wm.NavigationAction":
|
|
40374
40789
|
return transformNavigationAction(variable2, scope);
|
|
40375
40790
|
case "wm.TimerAction":
|
|
@@ -40383,9 +40798,16 @@ var variable_transformer_default = (variable2, scope, appUrl, imports102) => {
|
|
|
40383
40798
|
case "wm.LogoutAction":
|
|
40384
40799
|
return transformLogoutVariable(variable2, scope);
|
|
40385
40800
|
case "wm.LiveVariable":
|
|
40386
|
-
return transformLiveVariable(
|
|
40801
|
+
return transformLiveVariable(
|
|
40802
|
+
variable2,
|
|
40803
|
+
scope,
|
|
40804
|
+
validServiceClassNames,
|
|
40805
|
+
methodArgsByOperation,
|
|
40806
|
+
methodNameByOperation,
|
|
40807
|
+
servicePathByOperation
|
|
40808
|
+
);
|
|
40387
40809
|
case "wm.CrudVariable":
|
|
40388
|
-
return transformCrudVariable(variable2, scope);
|
|
40810
|
+
return transformCrudVariable(variable2, scope, crudOperationsById);
|
|
40389
40811
|
}
|
|
40390
40812
|
return null;
|
|
40391
40813
|
};
|
|
@@ -45355,9 +45777,14 @@ var dialog_transformer_default = {
|
|
|
45355
45777
|
pre: (element, context) => {
|
|
45356
45778
|
element.getAttribute("name");
|
|
45357
45779
|
const hasExplicitBody = element.childNodes.some(
|
|
45358
|
-
(e) => isHTMLElement(e) && ["wm-dialogcontent", "wm-dialogbody"].includes(e.tagName.toLowerCase())
|
|
45780
|
+
(e) => isHTMLElement(e) && ["wm-dialogcontent", "wm-dialogbody"].includes(e.tagName.toLowerCase()) && e.childNodes.some(isHTMLElement)
|
|
45359
45781
|
);
|
|
45360
45782
|
if (!hasExplicitBody) {
|
|
45783
|
+
const markerIndex = element.childNodes.findIndex(
|
|
45784
|
+
(e) => isHTMLElement(e) && ["wm-dialogcontent", "wm-dialogbody"].includes(e.tagName.toLowerCase())
|
|
45785
|
+
);
|
|
45786
|
+
const marker = markerIndex >= 0 ? element.childNodes[markerIndex] : null;
|
|
45787
|
+
const remainingChildren = markerIndex >= 0 ? element.childNodes.filter((_, i) => i !== markerIndex) : element.childNodes;
|
|
45361
45788
|
const content = new HTMLElement(
|
|
45362
45789
|
"wm-dialogbody",
|
|
45363
45790
|
{},
|
|
@@ -45366,10 +45793,13 @@ var dialog_transformer_default = {
|
|
|
45366
45793
|
[0, 41]
|
|
45367
45794
|
);
|
|
45368
45795
|
content.nodeType = NodeType.ELEMENT_NODE;
|
|
45369
|
-
|
|
45796
|
+
if (marker) {
|
|
45797
|
+
content.setAttributes(marker.attributes);
|
|
45798
|
+
}
|
|
45799
|
+
const actionsIndex = remainingChildren.findIndex(
|
|
45370
45800
|
(e) => isHTMLElement(e) && e.tagName.toLowerCase() === "wm-dialogactions"
|
|
45371
45801
|
);
|
|
45372
|
-
content.childNodes =
|
|
45802
|
+
content.childNodes = remainingChildren;
|
|
45373
45803
|
element.childNodes = [content];
|
|
45374
45804
|
if (actionsIndex >= 0) {
|
|
45375
45805
|
const actions = content.childNodes.splice(actionsIndex, 1);
|
|
@@ -45486,6 +45916,8 @@ var tabs_transformer_default = {
|
|
|
45486
45916
|
`fragment.Widgets.${widgetName}.currentItem`,
|
|
45487
45917
|
"currentItem"
|
|
45488
45918
|
);
|
|
45919
|
+
transformRepeatChildAttr(repeatTemplate, "fragment.item", "$item");
|
|
45920
|
+
transformRepeatChildAttr(repeatTemplate, "fragment.index", "$index");
|
|
45489
45921
|
transformRepeatChildData(
|
|
45490
45922
|
repeatTemplate,
|
|
45491
45923
|
dataSet.substring(5) + "[0]",
|
|
@@ -45595,6 +46027,8 @@ var prefab_container_transformer_default = {
|
|
|
45595
46027
|
__toESM(require_lodash());
|
|
45596
46028
|
var DefaultProfile = {
|
|
45597
46029
|
generateWeb: false,
|
|
46030
|
+
generateWmxComponents: true,
|
|
46031
|
+
groupPagesByLayout: true,
|
|
45598
46032
|
copyResources: true,
|
|
45599
46033
|
lazyloadPages: true,
|
|
45600
46034
|
lazyloadPartials: true,
|