@azure-tools/typespec-java 0.5.0
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/dist/src/code-model-builder.d.ts +102 -0
- package/dist/src/code-model-builder.d.ts.map +1 -0
- package/dist/src/code-model-builder.js +1675 -0
- package/dist/src/code-model-builder.js.map +1 -0
- package/dist/src/common/client.d.ts +18 -0
- package/dist/src/common/client.d.ts.map +1 -0
- package/dist/src/common/client.js +29 -0
- package/dist/src/common/client.js.map +1 -0
- package/dist/src/common/code-model.d.ts +26 -0
- package/dist/src/common/code-model.d.ts.map +1 -0
- package/dist/src/common/code-model.js +59 -0
- package/dist/src/common/code-model.js.map +1 -0
- package/dist/src/common/operation.d.ts +80 -0
- package/dist/src/common/operation.d.ts.map +1 -0
- package/dist/src/common/operation.js +88 -0
- package/dist/src/common/operation.js.map +1 -0
- package/dist/src/common/schemas/choice.d.ts +28 -0
- package/dist/src/common/schemas/choice.d.ts.map +1 -0
- package/dist/src/common/schemas/choice.js +14 -0
- package/dist/src/common/schemas/choice.js.map +1 -0
- package/dist/src/common/schemas/relationship.d.ts +44 -0
- package/dist/src/common/schemas/relationship.d.ts.map +1 -0
- package/dist/src/common/schemas/relationship.js +15 -0
- package/dist/src/common/schemas/relationship.js.map +1 -0
- package/dist/src/common/schemas/usage.d.ts +22 -0
- package/dist/src/common/schemas/usage.d.ts.map +1 -0
- package/dist/src/common/schemas/usage.js +16 -0
- package/dist/src/common/schemas/usage.js.map +1 -0
- package/dist/src/emitter.d.ts +21 -0
- package/dist/src/emitter.d.ts.map +1 -0
- package/dist/src/emitter.js +84 -0
- package/dist/src/emitter.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/models.d.ts +15 -0
- package/dist/src/models.d.ts.map +1 -0
- package/dist/src/models.js +21 -0
- package/dist/src/models.js.map +1 -0
- package/dist/src/prenamer/naming-utils.d.ts +67 -0
- package/dist/src/prenamer/naming-utils.d.ts.map +1 -0
- package/dist/src/prenamer/naming-utils.js +146 -0
- package/dist/src/prenamer/naming-utils.js.map +1 -0
- package/dist/src/prenamer/prenamer.d.ts +36 -0
- package/dist/src/prenamer/prenamer.d.ts.map +1 -0
- package/dist/src/prenamer/prenamer.js +332 -0
- package/dist/src/prenamer/prenamer.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +65 -0
- package/readme.md +74 -0
- package/target/azure-cadl-extension-jar-with-dependencies.jar +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../../src/common/schemas/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,oBAAY,aAAa;IACvB,kDAAkD;IAClD,KAAK,UAAU;IAEf,qDAAqD;IACrD,MAAM,WAAW;IAEjB,wDAAwD;IACxD,SAAS,cAAc;IAEvB,wEAAwE;IACxE,cAAc,oBAAoB;IAElC,iFAAiF;IACjF,KAAK,UAAU;IAEf,gEAAgE;IAChE,SAAS,cAAc;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IAExB,+DAA+D;IAC/D,oBAAoB,CAAC,EAAE,cAAc,EAAE,CAAC;CACzC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var SchemaContext;
|
|
2
|
+
(function (SchemaContext) {
|
|
3
|
+
/** Schema is used as an input to an operation. */
|
|
4
|
+
SchemaContext["Input"] = "input";
|
|
5
|
+
/** Schema is used as an output from an operation. */
|
|
6
|
+
SchemaContext["Output"] = "output";
|
|
7
|
+
/** Schema is used as an exception from an operation. */
|
|
8
|
+
SchemaContext["Exception"] = "exception";
|
|
9
|
+
/** Schema is used from the operation for generating convenience API. */
|
|
10
|
+
SchemaContext["ConvenienceApi"] = "convenience-api";
|
|
11
|
+
/** Schema is used from the pageable operation. This usage does not propagate. */
|
|
12
|
+
SchemaContext["Paged"] = "paged";
|
|
13
|
+
/** Schema as anonymous model. This usage does not propagate. */
|
|
14
|
+
SchemaContext["Anonymous"] = "anonymous";
|
|
15
|
+
})(SchemaContext || (SchemaContext = {}));
|
|
16
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../../src/common/schemas/usage.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,aAkBX;AAlBD,WAAY,aAAa;IACvB,kDAAkD;IAClD,gCAAe,CAAA;IAEf,qDAAqD;IACrD,kCAAiB,CAAA;IAEjB,wDAAwD;IACxD,wCAAuB,CAAA;IAEvB,wEAAwE;IACxE,mDAAkC,CAAA;IAElC,iFAAiF;IACjF,gCAAe,CAAA;IAEf,gEAAgE;IAChE,wCAAuB,CAAA;AACzB,CAAC,EAlBW,aAAa,KAAb,aAAa,QAkBxB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EmitContext } from "@typespec/compiler";
|
|
2
|
+
export interface EmitterOptions {
|
|
3
|
+
"namespace"?: string;
|
|
4
|
+
"service-name"?: string;
|
|
5
|
+
"partial-update"?: boolean;
|
|
6
|
+
"output-dir"?: string;
|
|
7
|
+
"service-versions"?: Array<string>;
|
|
8
|
+
"namer"?: boolean;
|
|
9
|
+
"generate-samples"?: boolean;
|
|
10
|
+
"generate-tests"?: boolean;
|
|
11
|
+
"dev-options"?: DevOptions;
|
|
12
|
+
}
|
|
13
|
+
export interface DevOptions {
|
|
14
|
+
"generate-code-model"?: boolean;
|
|
15
|
+
"generate-convenience-apis"?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
18
|
+
[code: string]: import("@typespec/compiler").DiagnosticMessages;
|
|
19
|
+
}, EmitterOptions>;
|
|
20
|
+
export declare function $onEmit(context: EmitContext<EmitterOptions>): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EAIZ,MAAM,oBAAoB,CAAC;AAS5B,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAqBD,eAAO,MAAM,IAAI;;kBAMf,CAAC;AAEH,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,cAAc,CAAC,iBA0DjE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { resolvePath, getNormalizedAbsolutePath, NoTarget, createTypeSpecLibrary, } from "@typespec/compiler";
|
|
2
|
+
import { dump } from "js-yaml";
|
|
3
|
+
import { promisify } from "util";
|
|
4
|
+
import { execFile } from "child_process";
|
|
5
|
+
import { promises } from "fs";
|
|
6
|
+
import { CodeModelBuilder } from "./code-model-builder.js";
|
|
7
|
+
import { dirname } from "path";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
const EmitterOptionsSchema = {
|
|
10
|
+
type: "object",
|
|
11
|
+
additionalProperties: true,
|
|
12
|
+
properties: {
|
|
13
|
+
"namespace": { type: "string", nullable: true },
|
|
14
|
+
"service-name": { type: "string", nullable: true },
|
|
15
|
+
"partial-update": { type: "boolean", nullable: true, default: false },
|
|
16
|
+
"output-dir": { type: "string", nullable: true },
|
|
17
|
+
"service-versions": { type: "array", items: { type: "string" }, nullable: true },
|
|
18
|
+
"namer": { type: "boolean", nullable: true, default: false },
|
|
19
|
+
"generate-samples": { type: "boolean", nullable: true, default: true },
|
|
20
|
+
"generate-tests": { type: "boolean", nullable: true, default: true },
|
|
21
|
+
"dev-options": { type: "object", additionalProperties: true, nullable: true },
|
|
22
|
+
},
|
|
23
|
+
required: [],
|
|
24
|
+
};
|
|
25
|
+
export const $lib = createTypeSpecLibrary({
|
|
26
|
+
name: "JavaEmitter",
|
|
27
|
+
diagnostics: {},
|
|
28
|
+
emitter: {
|
|
29
|
+
options: EmitterOptionsSchema,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
export async function $onEmit(context) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const program = context.program;
|
|
35
|
+
const options = context.options;
|
|
36
|
+
const builder = new CodeModelBuilder(program, context);
|
|
37
|
+
const codeModel = builder.build();
|
|
38
|
+
if (!program.compilerOptions.noEmit && !program.hasError()) {
|
|
39
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
40
|
+
const moduleRoot = resolvePath(__dirname, "..", "..");
|
|
41
|
+
const outputPath = (_a = options["output-dir"]) !== null && _a !== void 0 ? _a : context.emitterOutputDir;
|
|
42
|
+
options["output-dir"] = getNormalizedAbsolutePath(outputPath, undefined);
|
|
43
|
+
const codeModelFileName = resolvePath(outputPath, "./code-model.yaml");
|
|
44
|
+
await promises.mkdir(outputPath, { recursive: true }).catch((err) => {
|
|
45
|
+
if (err.code !== "EISDIR" && err.code !== "EEXIST") {
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
await program.host.writeFile(codeModelFileName, dump(codeModel));
|
|
50
|
+
program.trace("typespec-java", `Code model file written to ${codeModelFileName}`);
|
|
51
|
+
const emitterOptions = JSON.stringify(options);
|
|
52
|
+
program.trace("typespec-java", `Emitter options ${emitterOptions}`);
|
|
53
|
+
const jarFileName = resolvePath(moduleRoot, "target", "azure-cadl-extension-jar-with-dependencies.jar");
|
|
54
|
+
program.trace("typespec-java", `Exec JAR ${jarFileName}`);
|
|
55
|
+
try {
|
|
56
|
+
const output = await promisify(execFile)("java", [
|
|
57
|
+
`-DemitterOptions=${emitterOptions}`,
|
|
58
|
+
"-jar",
|
|
59
|
+
jarFileName,
|
|
60
|
+
codeModelFileName,
|
|
61
|
+
]);
|
|
62
|
+
program.trace("typespec-java", output.stdout ? output.stdout : output.stderr);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
if ("code" in err && err.code === "ENOENT") {
|
|
66
|
+
const msg = "'java' is not on PATH. Please install JDK 11 or above.";
|
|
67
|
+
program.trace("typespec-java", msg);
|
|
68
|
+
program.reportDiagnostic({
|
|
69
|
+
code: "typespec-java",
|
|
70
|
+
severity: "error",
|
|
71
|
+
message: msg,
|
|
72
|
+
target: NoTarget,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw err;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!((_b = options["dev-options"]) === null || _b === void 0 ? void 0 : _b["generate-code-model"])) {
|
|
80
|
+
await program.host.rm(codeModelFileName);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=emitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAEzB,QAAQ,EAER,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,S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,MAAM,GAAG,CAAC;aACX;SACF;QAED,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,aAAa,CAAC,0CAAG,qBAAqB,CAAC,CAAA,EAAE;YACpD,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC;SAC1C;KACF;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Parameter, Schema } from "@autorest/codemodel";
|
|
2
|
+
export declare class LongRunningMetadata {
|
|
3
|
+
longRunning: boolean;
|
|
4
|
+
pollResultType?: Schema;
|
|
5
|
+
finalResultType?: Schema;
|
|
6
|
+
constructor(longRunning: boolean, pollResultType?: Schema, finalResultType?: Schema);
|
|
7
|
+
}
|
|
8
|
+
export declare class ClientContext {
|
|
9
|
+
baseUri: string;
|
|
10
|
+
hostParameters: Parameter[];
|
|
11
|
+
globalParameters: Parameter[];
|
|
12
|
+
constructor(baseUri: string, hostParameters: Parameter[], globalParameters: Parameter[]);
|
|
13
|
+
addGlobalParameter(parameter: Parameter): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,mBAAmB;IAC9B,WAAW,EAAE,OAAO,CAAS;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;gBAEb,WAAW,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM;CAKpF;AAED,qBAAa,aAAa;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,SAAS,EAAE,CAAC;IAC5B,gBAAgB,EAAE,SAAS,EAAE,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE,gBAAgB,EAAE,SAAS,EAAE;IAMvF,kBAAkB,CAAC,SAAS,EAAE,SAAS;CAKxC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class LongRunningMetadata {
|
|
2
|
+
constructor(longRunning, pollResultType, finalResultType) {
|
|
3
|
+
this.longRunning = false;
|
|
4
|
+
this.longRunning = longRunning;
|
|
5
|
+
this.pollResultType = pollResultType;
|
|
6
|
+
this.finalResultType = finalResultType;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class ClientContext {
|
|
10
|
+
constructor(baseUri, hostParameters, globalParameters) {
|
|
11
|
+
this.baseUri = baseUri;
|
|
12
|
+
this.hostParameters = hostParameters;
|
|
13
|
+
this.globalParameters = globalParameters;
|
|
14
|
+
}
|
|
15
|
+
addGlobalParameter(parameter) {
|
|
16
|
+
if (!this.globalParameters.includes(parameter)) {
|
|
17
|
+
this.globalParameters.push(parameter);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAmB;IAK9B,YAAY,WAAoB,EAAE,cAAuB,EAAE,eAAwB;QAJnF,gBAAW,GAAY,KAAK,CAAC;QAK3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;CACF;AAED,MAAM,OAAO,aAAa;IAKxB,YAAY,OAAe,EAAE,cAA2B,EAAE,gBAA6B;QACrF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IAED,kBAAkB,CAAC,SAAoB;QACrC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YAC9C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACvC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Languages } from "@autorest/codemodel";
|
|
2
|
+
import { Styler } from "@azure-tools/codegen";
|
|
3
|
+
export declare function getNameOptions(typeName: string, components: Array<string>): string[];
|
|
4
|
+
interface SetNameOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Remove consecutive duplicate words in the name.
|
|
7
|
+
* @example "FooBarBarSomething" -> "FooBarSomething"
|
|
8
|
+
*/
|
|
9
|
+
removeDuplicates?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Error message if a name is empty.
|
|
12
|
+
*/
|
|
13
|
+
nameEmptyErrorMessage?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Nameable {
|
|
16
|
+
language: Languages;
|
|
17
|
+
}
|
|
18
|
+
export declare class NamingService {
|
|
19
|
+
constructor();
|
|
20
|
+
setName(thing: Nameable, styler: Styler, defaultValue: string, overrides: Record<string, string>, options?: SetNameOptions): void;
|
|
21
|
+
setNameAllowEmpty(thing: Nameable, styler: Styler, defaultValue: string, overrides: Record<string, string>, options?: SetNameOptions): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function isUnassigned(value: string): boolean;
|
|
24
|
+
export interface ScopeNamerOptions {
|
|
25
|
+
deduplicateNames?: boolean;
|
|
26
|
+
overrides?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Class that will style and resolve unique names for entities in the same scope.
|
|
30
|
+
*/
|
|
31
|
+
export declare class ScopeNamer {
|
|
32
|
+
private options;
|
|
33
|
+
private names;
|
|
34
|
+
constructor(options: ScopeNamerOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Add a nameable entity to be styled and named.
|
|
37
|
+
* @param entity Nameable entity.
|
|
38
|
+
* @param styler Styler to use to render name.
|
|
39
|
+
* @param defaultName Default name in case entity doesn't have any specified.
|
|
40
|
+
*/
|
|
41
|
+
add(entity: Nameable, styler: Styler, defaultName?: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Returns true if the name is already used in this scope.
|
|
44
|
+
* @param name Name to check
|
|
45
|
+
* @returns Boolean
|
|
46
|
+
*/
|
|
47
|
+
isUsed(name: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Trigger the renaming process.
|
|
50
|
+
* Will go over all the entity and find best possible names.
|
|
51
|
+
*/
|
|
52
|
+
process(): void;
|
|
53
|
+
/**
|
|
54
|
+
* 1st pass of the name resolving where it tries to simplify names with duplicate consecutive words.
|
|
55
|
+
*/
|
|
56
|
+
private processSimplifyNames;
|
|
57
|
+
/**
|
|
58
|
+
* 2nd pass of the name resolving where it will deduplicate names used twice.
|
|
59
|
+
*/
|
|
60
|
+
private deduplicateNames;
|
|
61
|
+
/**
|
|
62
|
+
* Tries to find a new compatible name for the given schema.
|
|
63
|
+
*/
|
|
64
|
+
private deduplicateSchemaName;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=naming-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming-utils.d.ts","sourceRoot":"","sources":["../../../src/prenamer/naming-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAoE,MAAM,EAAE,MAAM,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CAAC,gBAAgB;IAWxB;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAwB9B"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { removeSequentialDuplicates, fixLeadingNumber, deconstruct, Style } from "@azure-tools/codegen";
|
|
2
|
+
import pkg from "lodash";
|
|
3
|
+
const { last } = pkg;
|
|
4
|
+
export function getNameOptions(typeName, components) {
|
|
5
|
+
const result = new Set();
|
|
6
|
+
// add a variant for each incrementally inclusive parent naming scheme.
|
|
7
|
+
for (let i = 0; i < components.length; i++) {
|
|
8
|
+
const subset = Style.pascal([...removeSequentialDuplicates(components.slice(-1 * i, components.length))]);
|
|
9
|
+
result.add(subset);
|
|
10
|
+
}
|
|
11
|
+
// add a second-to-last-ditch option as <typename>.<name>
|
|
12
|
+
result.add(Style.pascal([
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
14
|
+
...removeSequentialDuplicates([...fixLeadingNumber(deconstruct(typeName)), ...deconstruct(last(components))]),
|
|
15
|
+
]));
|
|
16
|
+
return [...result.values()];
|
|
17
|
+
}
|
|
18
|
+
const setNameDefaultOptions = Object.freeze({
|
|
19
|
+
removeDuplicates: true,
|
|
20
|
+
});
|
|
21
|
+
export class NamingService {
|
|
22
|
+
constructor() { }
|
|
23
|
+
setName(thing, styler, defaultValue, overrides, options) {
|
|
24
|
+
this.setNameAllowEmpty(thing, styler, defaultValue, overrides, options);
|
|
25
|
+
// if (!thing.language.default.name) {
|
|
26
|
+
// this.session.error(options?.nameEmptyErrorMessage ?? getNameEmptyError(thing), ["Prenamer", "NameEmpty"], thing);
|
|
27
|
+
// }
|
|
28
|
+
}
|
|
29
|
+
setNameAllowEmpty(thing, styler, defaultValue, overrides, options) {
|
|
30
|
+
options = { ...setNameDefaultOptions, ...options };
|
|
31
|
+
thing.language.default.name = styler(defaultValue && isUnassigned(thing.language.default.name) ? defaultValue : thing.language.default.name, options.removeDuplicates, overrides);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function isUnassigned(value) {
|
|
35
|
+
return !value || value.indexOf("·") > -1;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Class that will style and resolve unique names for entities in the same scope.
|
|
39
|
+
*/
|
|
40
|
+
export class ScopeNamer {
|
|
41
|
+
constructor(options) {
|
|
42
|
+
this.options = options;
|
|
43
|
+
this.names = new Map();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Add a nameable entity to be styled and named.
|
|
47
|
+
* @param entity Nameable entity.
|
|
48
|
+
* @param styler Styler to use to render name.
|
|
49
|
+
* @param defaultName Default name in case entity doesn't have any specified.
|
|
50
|
+
*/
|
|
51
|
+
add(entity, styler, defaultName) {
|
|
52
|
+
const initialName = defaultName && isUnassigned(entity.language.default.name) ? defaultName : entity.language.default.name;
|
|
53
|
+
const name = styler(initialName, false, this.options.overrides);
|
|
54
|
+
const list = this.names.get(name);
|
|
55
|
+
const entry = { entity, styler, initialName };
|
|
56
|
+
if (list) {
|
|
57
|
+
list.push(entry);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.names.set(name, [entry]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns true if the name is already used in this scope.
|
|
65
|
+
* @param name Name to check
|
|
66
|
+
* @returns Boolean
|
|
67
|
+
*/
|
|
68
|
+
isUsed(name) {
|
|
69
|
+
return this.names.has(name);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Trigger the renaming process.
|
|
73
|
+
* Will go over all the entity and find best possible names.
|
|
74
|
+
*/
|
|
75
|
+
process() {
|
|
76
|
+
const state = this.processSimplifyNames();
|
|
77
|
+
if (this.options.deduplicateNames) {
|
|
78
|
+
this.deduplicateNames(state);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 1st pass of the name resolving where it tries to simplify names with duplicate consecutive words.
|
|
83
|
+
*/
|
|
84
|
+
processSimplifyNames() {
|
|
85
|
+
const processedNames = new Map();
|
|
86
|
+
for (const [name, entities] of this.names.entries()) {
|
|
87
|
+
for (const { entity, styler, initialName } of entities) {
|
|
88
|
+
let selectedName = name;
|
|
89
|
+
const noDupName = styler(initialName, true, this.options.overrides);
|
|
90
|
+
if (noDupName !== name) {
|
|
91
|
+
if (!this.names.has(noDupName) && !processedNames.has(noDupName)) {
|
|
92
|
+
selectedName = noDupName;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
entity.language.default.name = selectedName;
|
|
96
|
+
const entries = processedNames.get(selectedName);
|
|
97
|
+
if (entries) {
|
|
98
|
+
entries.push(entity);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
processedNames.set(selectedName, [entity]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return processedNames;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 2nd pass of the name resolving where it will deduplicate names used twice.
|
|
109
|
+
*/
|
|
110
|
+
deduplicateNames(names) {
|
|
111
|
+
const entityNames = new Set(names.keys());
|
|
112
|
+
for (const [_, entries] of names.entries()) {
|
|
113
|
+
if (entries.length > 1) {
|
|
114
|
+
for (const entity of entries.slice(1)) {
|
|
115
|
+
this.deduplicateSchemaName(entity, entityNames);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Tries to find a new compatible name for the given schema.
|
|
122
|
+
*/
|
|
123
|
+
deduplicateSchemaName(schema, entityNames) {
|
|
124
|
+
const schemaName = schema.language.default.name;
|
|
125
|
+
const maxDedupes = 1000;
|
|
126
|
+
if (entityNames.has(schemaName)) {
|
|
127
|
+
for (let i = 1; i <= maxDedupes; i++) {
|
|
128
|
+
const newName = `${schemaName}AutoGenerated${i === 1 ? "" : i}`;
|
|
129
|
+
if (!entityNames.has(newName)) {
|
|
130
|
+
schema.language.default.name = newName;
|
|
131
|
+
entityNames.add(newName);
|
|
132
|
+
// this.session.warning(`Deduplicating schema name: '${schemaName}' -> '${newName}'`, [
|
|
133
|
+
// "PreNamer/DeduplicateName",
|
|
134
|
+
// ]);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// this.session.error(
|
|
139
|
+
// `Attempted to deduplicate schema name '${schema.language.default.name}' more than ${maxDedupes} times and failed.`,
|
|
140
|
+
// ["PreNamer/DeduplicateName"],
|
|
141
|
+
// );
|
|
142
|
+
}
|
|
143
|
+
entityNames.add(schemaName);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=naming-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming-utils.js","sourceRoot":"","sources":["../../../src/prenamer/naming-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,WAAW,EAAE,KAAK,EAAU,MAAM,sBAAsB,CAAC;AAChH,OAAO,GAAG,MAAM,QAAQ,CAAC;AACzB,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC;AAErB,MAAM,UAAU,cAAc,CAAC,QAAgB,EAAE,UAAyB;IACxE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IAEjC,uEAAuE;IACvE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,0BAA0B,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1G,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KACpB;IAED,yDAAyD;IACzD,MAAM,CAAC,GAAG,CACR,KAAK,CAAC,MAAM,CAAC;QACX,oEAAoE;QACpE,GAAG,0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C;IAED;;OAEG;IACK,qBAAqB,CAAC,MAAgB,EAAE,WAAwB;QACtE,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;QAChD,MAAM,UAAU,GAAG,IAAI,CAAC;QACxB,IAAI,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,EAAE,EAAE;gBACpC,MAAM,OAAO,GAAG,GAAG,UAAU,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;oBAC7B,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC;oBACvC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;oBACzB,uFAAuF;oBACvF,gCAAgC;oBAChC,MAAM;oBACN,OAAO;iBACR;aACF;YAED,sBAAsB;YACtB,wHAAwH;YACxH,kCAAkC;YAClC,KAAK;SACN;QAED,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ObjectSchema } from "@autorest/codemodel";
|
|
2
|
+
import { CodeModel } from "../common/code-model.js";
|
|
3
|
+
import { Style } from "@azure-tools/codegen";
|
|
4
|
+
export declare class PreNamer {
|
|
5
|
+
codeModel: CodeModel;
|
|
6
|
+
options: any;
|
|
7
|
+
format: {
|
|
8
|
+
parameter: typeof Style.camel;
|
|
9
|
+
property: typeof Style.camel;
|
|
10
|
+
operation: typeof Style.camel;
|
|
11
|
+
operationGroup: typeof Style.pascal;
|
|
12
|
+
responseHeader: typeof Style.camel;
|
|
13
|
+
choice: typeof Style.pascal;
|
|
14
|
+
choiceValue: typeof Style.upper;
|
|
15
|
+
constant: typeof Style.pascal;
|
|
16
|
+
constantParameter: typeof Style.camel;
|
|
17
|
+
type: typeof Style.pascal;
|
|
18
|
+
client: typeof Style.pascal;
|
|
19
|
+
local: typeof Style.camel;
|
|
20
|
+
global: typeof Style.pascal;
|
|
21
|
+
override: Record<string, string>;
|
|
22
|
+
};
|
|
23
|
+
enum: number;
|
|
24
|
+
constant: number;
|
|
25
|
+
private namingService;
|
|
26
|
+
constructor(codeModel: CodeModel);
|
|
27
|
+
init(): this;
|
|
28
|
+
process(): CodeModel;
|
|
29
|
+
private processChoiceNames;
|
|
30
|
+
private setParameterNames;
|
|
31
|
+
private setResponseHeaderNames;
|
|
32
|
+
fixParameterCollisions(): void;
|
|
33
|
+
fixCollisions(schema: ObjectSchema): void;
|
|
34
|
+
fixPropertyCollisions(): void;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=prenamer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prenamer.d.ts","sourceRoot":"","sources":["../../../src/prenamer/prenamer.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAOb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAc,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAKzD,qBAAa,QAAQ;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,GAAG,CAAM;IAClB,MAAM;;;;;;;;;;;;;;;MAeJ;IAEF,IAAI,SAAK;IACT,QAAQ,SAAK;IAEb,OAAO,CAAC,aAAa,CAAgB;gBAEzB,SAAS,EAAE,SAAS;IAKhC,IAAI;IAyCJ,OAAO;IAoNP,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,iBAAiB;IAuBzB,OAAO,CAAC,sBAAsB;IAa9B,sBAAsB;IAkCtB,aAAa,CAAC,MAAM,EAAE,YAAY;IAgClC,qBAAqB;CAKtB"}
|