@kosdev-code/kos-codegen-core 0.1.0-next.900 → 0.1.0-next.903
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/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +104 -14
- package/index.js.map +1 -1
- package/index.mjs +104 -14
- package/index.mjs.map +1 -1
- package/lib/generators/add-container-support/generate-add-container-support.d.ts.map +1 -1
- package/lib/generators/augment/find-model-declaration.d.ts +15 -2
- package/lib/generators/augment/find-model-declaration.d.ts.map +1 -1
- package/lib/generators/augment/resolve-model-file.d.ts +9 -0
- package/lib/generators/augment/resolve-model-file.d.ts.map +1 -1
- package/lib/generators/generate-view-model.d.ts.map +1 -1
- package/lib/generators/index.d.ts +1 -1
- package/lib/generators/index.d.ts.map +1 -1
- package/lib/generators/java-workspace.d.ts.map +1 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ export { setCodegenLogger, getCodegenLogger } from './lib/logger';
|
|
|
12
12
|
export { getCurrentDirectoryName, getProject, getKosProjectConfiguration, getKosModelConfiguration, getKosModelConfigProp, addKosModelConfiguration, } from './lib/kos-config';
|
|
13
13
|
export type { KosModelConfiguration, KosProjectConfiguration, } from './lib/kos-config';
|
|
14
14
|
export { getTemplateDir } from './lib/template-resolver';
|
|
15
|
-
export { generateSplashProject, generateModelProject, resolveModelProjectLayout, DEFAULT_MODEL_LIBS_DIR, generateInit, generatePolyglotWorkspace, ensureJavaAggregatorPom, finalizeArchetypeModule, addJavaArtifactToManifests, syncCiManifests, discoverUiArtifacts, discoverJavaArtifacts, buildKabTargets, buildSbomTarget, listServiceCatalog, resolveKabPath, KAB_OUTPUT_DIR, KAB_OUTPUT_PATH, UPDATE_RELEASE_VERSION_SCRIPT, UPDATE_RELEASE_VERSION_SCRIPT_PATH, normalizeOptions, appendBarrelExport, updateModelIndex, generateHook, generateContext, generateContainerModel, generateCompanionModel, generateModel, generateViewModel, addFutureToModel, addContainerSupportToModel, addParentAwareToModel, addModelEffectToModel, addDependencyToModel, addChildToModel, addTopicHandlerToModel, addConfigPropertyToModel, addServiceRequestToModel, addPropertyToModel, addComputedToModel, validateModel, describeModel, upsertChainEntry, countChainEntries, lookupSdkType, resolveModelFilePath, generateComponent, PLUGIN_TYPES, CONTRIBUTION_TYPE_MAP, LOCALIZED_PLUGIN_TYPES, KOS_JSON_PATHS, PluginHandlerFactory, BasePluginHandler, KosConfigBuilder, ValidationError, } from './lib/generators';
|
|
15
|
+
export { generateSplashProject, generateModelProject, resolveModelProjectLayout, DEFAULT_MODEL_LIBS_DIR, generateInit, generatePolyglotWorkspace, ensureJavaAggregatorPom, finalizeArchetypeModule, addJavaArtifactToManifests, syncCiManifests, discoverUiArtifacts, discoverJavaArtifacts, buildKabTargets, buildSbomTarget, listServiceCatalog, resolveKabPath, KAB_OUTPUT_DIR, KAB_OUTPUT_PATH, UPDATE_RELEASE_VERSION_SCRIPT, UPDATE_RELEASE_VERSION_SCRIPT_PATH, normalizeOptions, appendBarrelExport, updateModelIndex, generateHook, generateContext, generateContainerModel, generateCompanionModel, generateModel, generateViewModel, addFutureToModel, addContainerSupportToModel, addParentAwareToModel, addModelEffectToModel, addDependencyToModel, addChildToModel, addTopicHandlerToModel, addConfigPropertyToModel, addServiceRequestToModel, addPropertyToModel, addComputedToModel, validateModel, describeModel, upsertChainEntry, countChainEntries, lookupSdkType, resolveModelFilePath, ModelFileNotFoundError, generateComponent, PLUGIN_TYPES, CONTRIBUTION_TYPE_MAP, LOCALIZED_PLUGIN_TYPES, KOS_JSON_PATHS, PluginHandlerFactory, BasePluginHandler, KosConfigBuilder, ValidationError, } from './lib/generators';
|
|
16
16
|
export type { SplashProjectOptions, ModelProjectOptions, ModelProjectLayout, KosInitOptions, KabTargetsOptions, KabTargetDefinition, PolyglotWorkspaceOptions, PolyglotWorkspaceResult, EnsureJavaAggregatorOptions, FinalizeArchetypeModuleOptions, AddJavaArtifactOptions, CiSyncOptions, CiSyncResult, CiSyncManifestResult, DiscoveredArtifact, KosBaseGeneratorOptions, NormalizedOptions, HookOptions, ContextOptions, ContainerModelOptions, CompanionModelOptions, ModelOptions, GenerateModelParams, ViewModelOptions, ViewModelSource, ViewModelResult, AddFutureToModelOptions, NormalizedAddFutureToModelOptions, AddContainerSupportOptions, AddModelEffectOptions, AddDependencyOptions, AddChildOptions, ChildShape, AddTopicHandlerOptions, AddConfigPropertyOptions, AddServiceRequestOptions, AddServiceRequestResult, ServiceRequestMockMode, UntypedEndpointDetails, UntypedEndpointError, AddPropertyOptions, AddComputedOptions, ValidateModelOptions, ValidationFinding, ValidationResult, UpsertChainEntryResult, DescribeModelOptions, DescribedMember, ModelDescription, ModelFileQuery, LookupSdkTypeOptions, SdkSymbolDeclaration, SdkTypeLookupResult, ComponentOptions, NormalizedComponentOptions, PluginConfiguration, PluginContribution, ExperienceConfig, PluginType, PluginHandler, } from './lib/generators';
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/kos-codegen-core/src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGlE,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,GACX,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,EACL,QAAQ,EACR,SAAS,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,kBAAkB,CAAC;AAC1B,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,iCAAiC,EACjC,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,aAAa,GACd,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/kos-codegen-core/src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGlE,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EACL,gBAAgB,EAChB,iBAA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ClB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,iCAAiC,EACjC,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,aAAa,GACd,MAAM,kBAAkB,CAAC"}
|
package/index.js
CHANGED
|
@@ -1888,36 +1888,44 @@ function generateModel(params) {
|
|
|
1888
1888
|
}
|
|
1889
1889
|
}
|
|
1890
1890
|
const DECLARATION_MARKER = "@kosModel";
|
|
1891
|
-
function
|
|
1892
|
-
const
|
|
1893
|
-
if (wanted.size === 0) return null;
|
|
1894
|
-
const matches = [];
|
|
1891
|
+
function collectModelDeclarations(codegenFs, searchRoot) {
|
|
1892
|
+
const found = [];
|
|
1895
1893
|
for (const filePath of codegenFs.listFiles(searchRoot)) {
|
|
1896
1894
|
if (!filePath.endsWith(".ts") || filePath.endsWith(".d.ts")) continue;
|
|
1897
1895
|
const content = codegenFs.read(filePath);
|
|
1898
1896
|
if (!content || !content.includes(DECLARATION_MARKER)) continue;
|
|
1899
|
-
const declared =
|
|
1900
|
-
if (declared
|
|
1897
|
+
const declared = readModelDeclaration(codegenFs, filePath);
|
|
1898
|
+
if (declared) found.push(declared);
|
|
1901
1899
|
}
|
|
1900
|
+
return found;
|
|
1901
|
+
}
|
|
1902
|
+
function findModelDeclarationFile(codegenFs, searchRoot, identifiers) {
|
|
1903
|
+
const wanted = new Set(identifiers.filter(Boolean));
|
|
1904
|
+
if (wanted.size === 0) return null;
|
|
1905
|
+
const matches = collectModelDeclarations(codegenFs, searchRoot).filter(
|
|
1906
|
+
(d) => d.typeId && wanted.has(d.typeId) || d.className && wanted.has(d.className)
|
|
1907
|
+
).map((d) => d.filePath);
|
|
1902
1908
|
if (matches.length === 0) return null;
|
|
1903
1909
|
if (matches.length > 1) {
|
|
1904
1910
|
throw new Error(
|
|
1905
|
-
`Model
|
|
1911
|
+
`Model '${[...wanted].join(
|
|
1912
|
+
"' / '"
|
|
1913
|
+
)}' is declared in more than one file:
|
|
1906
1914
|
` + matches.sort().map((c) => ` - ${c}`).join("\n") + `
|
|
1907
1915
|
Pass modelPath to pick one.`
|
|
1908
1916
|
);
|
|
1909
1917
|
}
|
|
1910
1918
|
return matches[0];
|
|
1911
1919
|
}
|
|
1912
|
-
function
|
|
1920
|
+
function readModelDeclaration(codegenFs, filePath) {
|
|
1913
1921
|
try {
|
|
1914
1922
|
return readSourceFile(codegenFs, filePath, (sf) => {
|
|
1915
1923
|
const cls = sf.getClasses().find((c) => c.getDecorator("kosModel"));
|
|
1916
1924
|
if (!cls) return void 0;
|
|
1917
1925
|
const config = decoratorConfigText(sf, cls, "kosModel");
|
|
1918
1926
|
const inner = config?.startsWith("{") ? modelTypeIdProperty(config) : config;
|
|
1919
|
-
|
|
1920
|
-
return
|
|
1927
|
+
const typeId = inner ? resolveToStringLiteral(inner.trim(), sf.getFullText()) : void 0;
|
|
1928
|
+
return { filePath, typeId, className: cls.getName() };
|
|
1921
1929
|
});
|
|
1922
1930
|
} catch {
|
|
1923
1931
|
return void 0;
|
|
@@ -1932,7 +1940,9 @@ function resolveToStringLiteral(expression, fileText) {
|
|
|
1932
1940
|
if (literal) return literal[1];
|
|
1933
1941
|
if (!/^[A-Za-z_$][\w$]*$/.test(expression)) return void 0;
|
|
1934
1942
|
const declared = fileText.match(
|
|
1935
|
-
new RegExp(
|
|
1943
|
+
new RegExp(
|
|
1944
|
+
`\\b(?:const|let|var)\\s+${expression}\\s*(?::[^=]+)?=\\s*["'\`]([^"'\`]+)["'\`]`
|
|
1945
|
+
)
|
|
1936
1946
|
);
|
|
1937
1947
|
return declared ? declared[1] : void 0;
|
|
1938
1948
|
}
|
|
@@ -1987,7 +1997,82 @@ function resolveModelFilePath(codegenFs, query, projects) {
|
|
|
1987
1997
|
if (byDeclaration) {
|
|
1988
1998
|
return { modelFilePath: byDeclaration, internal, sourceRoot };
|
|
1989
1999
|
}
|
|
1990
|
-
|
|
2000
|
+
throw new ModelFileNotFoundError(
|
|
2001
|
+
query.modelName,
|
|
2002
|
+
query.modelProject,
|
|
2003
|
+
modelFilePath,
|
|
2004
|
+
collectModelDeclarations(codegenFs, searchRoot)
|
|
2005
|
+
);
|
|
2006
|
+
}
|
|
2007
|
+
class ModelFileNotFoundError extends Error {
|
|
2008
|
+
constructor(modelName, modelProject, conventionalPath, candidates) {
|
|
2009
|
+
super(
|
|
2010
|
+
buildNotFoundMessage(
|
|
2011
|
+
modelName,
|
|
2012
|
+
modelProject,
|
|
2013
|
+
conventionalPath,
|
|
2014
|
+
candidates
|
|
2015
|
+
)
|
|
2016
|
+
);
|
|
2017
|
+
this.modelName = modelName;
|
|
2018
|
+
this.modelProject = modelProject;
|
|
2019
|
+
this.conventionalPath = conventionalPath;
|
|
2020
|
+
this.candidates = candidates;
|
|
2021
|
+
this.name = "ModelFileNotFoundError";
|
|
2022
|
+
}
|
|
2023
|
+
modelName;
|
|
2024
|
+
modelProject;
|
|
2025
|
+
conventionalPath;
|
|
2026
|
+
candidates;
|
|
2027
|
+
}
|
|
2028
|
+
function buildNotFoundMessage(modelName, modelProject, conventionalPath, candidates) {
|
|
2029
|
+
const lines = [
|
|
2030
|
+
`Model '${modelName}' not found in project '${modelProject}'.`,
|
|
2031
|
+
`Looked for ${conventionalPath}, any '*-model.ts' under the model folder, and any '@kosModel' class named or typed '${modelName}'.`
|
|
2032
|
+
];
|
|
2033
|
+
if (candidates.length === 0) {
|
|
2034
|
+
lines.push(
|
|
2035
|
+
`This project declares no '@kosModel' classes under its model folder.`
|
|
2036
|
+
);
|
|
2037
|
+
return lines.join("\n");
|
|
2038
|
+
}
|
|
2039
|
+
const ranked = [...candidates].sort(
|
|
2040
|
+
(a, b) => closeness(modelName, b) - closeness(modelName, a)
|
|
2041
|
+
);
|
|
2042
|
+
const shown = ranked.slice(0, NOT_FOUND_SUGGESTIONS);
|
|
2043
|
+
lines.push(
|
|
2044
|
+
``,
|
|
2045
|
+
`Closest of the ${candidates.length} models this project declares:`
|
|
2046
|
+
);
|
|
2047
|
+
for (const c of shown) {
|
|
2048
|
+
const names = [c.typeId, c.className].filter(Boolean).join(" | ");
|
|
2049
|
+
lines.push(` ${names || "(name unresolved)"}
|
|
2050
|
+
${c.filePath}`);
|
|
2051
|
+
}
|
|
2052
|
+
if (ranked.length > shown.length) {
|
|
2053
|
+
lines.push(` …and ${ranked.length - shown.length} more.`);
|
|
2054
|
+
}
|
|
2055
|
+
lines.push(``, `Or pass modelPath to name the file directly.`);
|
|
2056
|
+
return lines.join("\n");
|
|
2057
|
+
}
|
|
2058
|
+
const NOT_FOUND_SUGGESTIONS = 8;
|
|
2059
|
+
function closeness(wanted, candidate) {
|
|
2060
|
+
const norm = (v) => v.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
2061
|
+
const target = norm(wanted);
|
|
2062
|
+
let best = 0;
|
|
2063
|
+
for (const name of [candidate.typeId, candidate.className]) {
|
|
2064
|
+
if (!name) continue;
|
|
2065
|
+
const n = norm(name);
|
|
2066
|
+
if (n === target) return 1e3;
|
|
2067
|
+
if (n.includes(target) || target.includes(n)) {
|
|
2068
|
+
best = Math.max(best, 500 + Math.min(n.length, target.length));
|
|
2069
|
+
continue;
|
|
2070
|
+
}
|
|
2071
|
+
let i = 0;
|
|
2072
|
+
while (i < n.length && i < target.length && n[i] === target[i]) i++;
|
|
2073
|
+
best = Math.max(best, i);
|
|
2074
|
+
}
|
|
2075
|
+
return best;
|
|
1991
2076
|
}
|
|
1992
2077
|
function findModelFileByName(codegenFs, searchRoot, modelNameDashCase) {
|
|
1993
2078
|
const fileName = `${modelNameDashCase}-model.ts`;
|
|
@@ -2084,7 +2169,9 @@ function generateViewModel(codegenFs, templateDir, options, cwd, projects) {
|
|
|
2084
2169
|
logger.info(
|
|
2085
2170
|
`Generating ViewModel ${normalized.nameDashCase} in ${projectRoot}`
|
|
2086
2171
|
);
|
|
2087
|
-
const constructorParams = resolved.map(({ name, type }) =>
|
|
2172
|
+
const constructorParams = resolved.map(({ name, type }) => {
|
|
2173
|
+
return { name, type };
|
|
2174
|
+
});
|
|
2088
2175
|
generateFilesFromTemplates(codegenFs, templateDir, viewModelFolder, {
|
|
2089
2176
|
...normalized,
|
|
2090
2177
|
internal,
|
|
@@ -2144,7 +2231,9 @@ function groupImports(resolved) {
|
|
|
2144
2231
|
types.push(type);
|
|
2145
2232
|
}
|
|
2146
2233
|
}
|
|
2147
|
-
return [...byModule].map(([module2, types]) =>
|
|
2234
|
+
return [...byModule].map(([module2, types]) => {
|
|
2235
|
+
return { module: module2, types };
|
|
2236
|
+
});
|
|
2148
2237
|
}
|
|
2149
2238
|
function modelBaseName(modelFilePath, modelName) {
|
|
2150
2239
|
const base = path__namespace.basename(modelFilePath);
|
|
@@ -4551,6 +4640,7 @@ exports.KAB_OUTPUT_PATH = KAB_OUTPUT_PATH;
|
|
|
4551
4640
|
exports.KOS_JSON_PATHS = KOS_JSON_PATHS;
|
|
4552
4641
|
exports.KosConfigBuilder = KosConfigBuilder;
|
|
4553
4642
|
exports.LOCALIZED_PLUGIN_TYPES = LOCALIZED_PLUGIN_TYPES;
|
|
4643
|
+
exports.ModelFileNotFoundError = ModelFileNotFoundError;
|
|
4554
4644
|
exports.PLUGIN_TYPES = PLUGIN_TYPES;
|
|
4555
4645
|
exports.PluginHandlerFactory = PluginHandlerFactory;
|
|
4556
4646
|
exports.TrackingFileSystem = TrackingFileSystem;
|