@azure-tools/typespec-azure-examples 0.1.0 → 0.2.0-dev.2
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/README.md +47 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/migrate/dedup.d.ts +32 -0
- package/dist/src/migrate/dedup.d.ts.map +1 -0
- package/dist/src/migrate/dedup.js +99 -0
- package/dist/src/migrate/dedup.js.map +1 -0
- package/dist/src/migrate/emit.d.ts +28 -0
- package/dist/src/migrate/emit.d.ts.map +1 -0
- package/dist/src/migrate/emit.js +87 -0
- package/dist/src/migrate/emit.js.map +1 -0
- package/dist/src/migrate/index.d.ts +13 -0
- package/dist/src/migrate/index.d.ts.map +1 -0
- package/dist/src/migrate/index.js +12 -0
- package/dist/src/migrate/index.js.map +1 -0
- package/dist/src/migrate/migrate.d.ts +40 -0
- package/dist/src/migrate/migrate.d.ts.map +1 -0
- package/dist/src/migrate/migrate.js +98 -0
- package/dist/src/migrate/migrate.js.map +1 -0
- package/dist/src/migrate/model.d.ts +22 -0
- package/dist/src/migrate/model.d.ts.map +1 -0
- package/dist/src/migrate/model.js +2 -0
- package/dist/src/migrate/model.js.map +1 -0
- package/dist/src/migrate/normalize.d.ts +15 -0
- package/dist/src/migrate/normalize.d.ts.map +1 -0
- package/dist/src/migrate/normalize.js +63 -0
- package/dist/src/migrate/normalize.js.map +1 -0
- package/dist/src/migrate/operation-key.d.ts +12 -0
- package/dist/src/migrate/operation-key.d.ts.map +1 -0
- package/dist/src/migrate/operation-key.js +28 -0
- package/dist/src/migrate/operation-key.js.map +1 -0
- package/dist/src/migrate/swagger-types.d.ts +48 -0
- package/dist/src/migrate/swagger-types.d.ts.map +1 -0
- package/dist/src/migrate/swagger-types.js +7 -0
- package/dist/src/migrate/swagger-types.js.map +1 -0
- package/dist/src/migrate/swagger.d.ts +49 -0
- package/dist/src/migrate/swagger.d.ts.map +1 -0
- package/dist/src/migrate/swagger.js +144 -0
- package/dist/src/migrate/swagger.js.map +1 -0
- package/dist/src/migrate/transform.d.ts +12 -0
- package/dist/src/migrate/transform.d.ts.map +1 -0
- package/dist/src/migrate/transform.js +45 -0
- package/dist/src/migrate/transform.js.map +1 -0
- package/dist/src/migrate/version-order.d.ts +14 -0
- package/dist/src/migrate/version-order.d.ts.map +1 -0
- package/dist/src/migrate/version-order.js +52 -0
- package/dist/src/migrate/version-order.js.map +1 -0
- package/dist/src/migrate-cli.d.ts +3 -0
- package/dist/src/migrate-cli.d.ts.map +1 -0
- package/dist/src/migrate-cli.js +115 -0
- package/dist/src/migrate-cli.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @azure-tools/typespec-azure-examples
|
|
2
2
|
|
|
3
3
|
Tooling for the Azure **unified examples format** (`examples.yaml`): the published JSON Schema
|
|
4
|
-
and the `tsp-examples` CLI.
|
|
4
|
+
and the `tsp-examples` CLI, plus the transitional `tsp-examples-migrate` tool.
|
|
5
5
|
|
|
6
6
|
The unified examples format replaces the ~282K per-version `x-ms-examples` JSON files with a
|
|
7
7
|
single version-aware `examples.yaml` per service (or `examples/<Interface>.yaml` for large
|
|
@@ -70,6 +70,49 @@ found (use `--warn-as-error` to also fail on warnings).
|
|
|
70
70
|
- `{api-version}` is the only supported placeholder, and `api-version` must not appear as a
|
|
71
71
|
request parameter.
|
|
72
72
|
|
|
73
|
+
## `tsp-examples-migrate`
|
|
74
|
+
|
|
75
|
+
> **Transitional tool.** Used to bulk-convert existing specs during rollout; it will be removed
|
|
76
|
+
> once services author `examples.yaml` directly.
|
|
77
|
+
|
|
78
|
+
Convert a service's existing `x-ms-examples` JSON into the unified format:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
tsp-examples-migrate <spec-dir> --out <service-dir>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
It crawls the versioned Swagger under `<spec-dir>` (the `stable/<version>/` and
|
|
85
|
+
`preview/<version>/` layout), follows each operation's `x-ms-examples` `$ref`, and emits a single
|
|
86
|
+
`examples.yaml` (or `examples/<Interface>.yaml` with `--split-by-interface`). The generated output
|
|
87
|
+
is validated with the same rules as `tsp-examples validate` before it is written.
|
|
88
|
+
|
|
89
|
+
If a `service.yaml` sits in `<spec-dir>` (or is passed with `--service`), its version list is
|
|
90
|
+
treated as authoritative: it defines the version order and any on-disk swagger version _not_ listed
|
|
91
|
+
there is ignored, so every generated `since` references a real service version.
|
|
92
|
+
|
|
93
|
+
What it does:
|
|
94
|
+
|
|
95
|
+
- Derives interface-relative operation keys from the Swagger `operationId` (`CaCertificates_Get` →
|
|
96
|
+
`CaCertificates.get`) under a single `$namespace` (detected from `/providers/<Namespace>/`, or
|
|
97
|
+
set with `--namespace`).
|
|
98
|
+
- Buckets each example parameter into `request.path` / `query` / `headers` / `body` using the
|
|
99
|
+
operation's declared parameter locations, and drops the implicit `api-version`.
|
|
100
|
+
- Normalizes embedded version strings (in `Location`, `Azure-AsyncOperation`, `nextLink`, ...) to
|
|
101
|
+
the `{api-version}` placeholder, then dedupes identical examples across versions into `since`
|
|
102
|
+
lineages — one base entry plus a `since` variant whenever the content changes.
|
|
103
|
+
|
|
104
|
+
Options: `--out <dir>` (default `.`), `--namespace <ns>`, `--service <path>`,
|
|
105
|
+
`--split-by-interface`, `--dry-run`, `--warn-as-error`.
|
|
106
|
+
|
|
107
|
+
### Known limitation: examples removed in a later version
|
|
108
|
+
|
|
109
|
+
The format has a `since` ("applies from") marker but no `until`/removal marker, so an example that
|
|
110
|
+
existed in an earlier version but was **dropped** in a later one is still re-materialized for the
|
|
111
|
+
later versions (its base entry applies from its first appearance onward). Migration flags each such
|
|
112
|
+
lineage with an `example-removed-before-latest` **warning** so the author can confirm it still
|
|
113
|
+
applies to later versions, or delete it. Services that rely on removing examples across versions are
|
|
114
|
+
not yet fully supported.
|
|
115
|
+
|
|
73
116
|
## API
|
|
74
117
|
|
|
75
118
|
```ts
|
|
@@ -77,7 +120,10 @@ import {
|
|
|
77
120
|
validateExamplesDir,
|
|
78
121
|
validateExampleFiles,
|
|
79
122
|
loadExampleFile,
|
|
123
|
+
migrate,
|
|
80
124
|
} from "@azure-tools/typespec-azure-examples";
|
|
81
125
|
|
|
82
126
|
const { diagnostics } = await validateExamplesDir("path/to/service");
|
|
127
|
+
|
|
128
|
+
const { files } = await migrate("path/to/specs", { namespace: "Microsoft.EventGrid" });
|
|
83
129
|
```
|
package/dist/src/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { discoverExampleFiles, validateExamplesDir, type ValidateDirResult } from "./discover.js";
|
|
7
7
|
export { isQuotedScalar, loadExampleFile, locationAt, parseServiceVersions, positionAt, type LoadedExampleFile, type Position, } from "./loader.js";
|
|
8
|
+
export * from "./migrate/index.js";
|
|
8
9
|
export { defaultLegacyExampleFilename, slugify, stripJsonExtension } from "./naming.js";
|
|
9
10
|
export { formatDiagnostics, formatSummary } from "./reporter.js";
|
|
10
11
|
export { checkFilePlacement, checkSemantics, type SemanticContext } from "./rules.js";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClG,OAAO,EACL,cAAc,EACd,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,QAAQ,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClG,OAAO,EACL,cAAc,EACd,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,QAAQ,GACd,MAAM,aAAa,CAAC;AACrB,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { discoverExampleFiles, validateExamplesDir } from "./discover.js";
|
|
7
7
|
export { isQuotedScalar, loadExampleFile, locationAt, parseServiceVersions, positionAt, } from "./loader.js";
|
|
8
|
+
export * from "./migrate/index.js";
|
|
8
9
|
export { defaultLegacyExampleFilename, slugify, stripJsonExtension } from "./naming.js";
|
|
9
10
|
export { formatDiagnostics, formatSummary } from "./reporter.js";
|
|
10
11
|
export { checkFilePlacement, checkSemantics } from "./rules.js";
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAA0B,MAAM,eAAe,CAAC;AAClG,OAAO,EACL,cAAc,EACd,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,UAAU,GAGX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAwB,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AASjD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAA0B,MAAM,eAAe,CAAC;AAClG,OAAO,EACL,cAAc,EACd,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,UAAU,GAGX,MAAM,aAAa,CAAC;AACrB,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAwB,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AASjD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MigratedVariant } from "./model.js";
|
|
2
|
+
/** One example as collected from the crawl, prior to lineage collapsing. */
|
|
3
|
+
export interface CollectedExample {
|
|
4
|
+
/** The API version this example was found under. */
|
|
5
|
+
readonly version: string;
|
|
6
|
+
/** The `x-ms-examples` map key, used as the lineage title. */
|
|
7
|
+
readonly exampleName: string;
|
|
8
|
+
/** The original `x-ms-examples` file name (basename of the `$ref`). */
|
|
9
|
+
readonly fileName: string;
|
|
10
|
+
/** The transformed + api-version-normalized variant content. */
|
|
11
|
+
readonly variant: MigratedVariant;
|
|
12
|
+
}
|
|
13
|
+
export interface BuildLineagesOptions {
|
|
14
|
+
/** The Swagger `operationId` of the operation (used to reconstruct the default file name/key). */
|
|
15
|
+
readonly operationId: string;
|
|
16
|
+
/** Ascending comparator over version strings (lowest/earliest first). */
|
|
17
|
+
readonly compareVersions: (a: string, b: string) => number;
|
|
18
|
+
/**
|
|
19
|
+
* The earliest version across the whole migration. When a lineage's first appearance is later
|
|
20
|
+
* than this, its base entry gets a `since` so migration stays faithful. When omitted, the
|
|
21
|
+
* earliest entry of each lineage is always the base (no `since`).
|
|
22
|
+
*/
|
|
23
|
+
readonly baselineVersion?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Collapse an operation's collected examples into unified variants: group by lineage (example
|
|
27
|
+
* name), order by version, keep one base entry, and emit a `since` variant only when the content
|
|
28
|
+
* changes from the previously-emitted entry. If the operation has a single lineage, the `title` is
|
|
29
|
+
* omitted (single-example case).
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildLineages(examples: readonly CollectedExample[], options: BuildLineagesOptions): MigratedVariant[];
|
|
32
|
+
//# sourceMappingURL=dedup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dedup.d.ts","sourceRoot":"","sources":["../../../src/migrate/dedup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,4EAA4E;AAC5E,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,gEAAgE;IAChE,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,kGAAkG;IAClG,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,eAAe,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3D;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EACrC,OAAO,EAAE,oBAAoB,GAC5B,eAAe,EAAE,CA2CnB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { defaultLegacyExampleFilename, stripJsonExtension } from "../naming.js";
|
|
2
|
+
/**
|
|
3
|
+
* Collapse an operation's collected examples into unified variants: group by lineage (example
|
|
4
|
+
* name), order by version, keep one base entry, and emit a `since` variant only when the content
|
|
5
|
+
* changes from the previously-emitted entry. If the operation has a single lineage, the `title` is
|
|
6
|
+
* omitted (single-example case).
|
|
7
|
+
*/
|
|
8
|
+
export function buildLineages(examples, options) {
|
|
9
|
+
const byName = new Map();
|
|
10
|
+
for (const example of examples) {
|
|
11
|
+
const group = byName.get(example.exampleName);
|
|
12
|
+
if (group)
|
|
13
|
+
group.push(example);
|
|
14
|
+
else
|
|
15
|
+
byName.set(example.exampleName, [example]);
|
|
16
|
+
}
|
|
17
|
+
const singleLineage = byName.size <= 1;
|
|
18
|
+
const result = [];
|
|
19
|
+
for (const [name, group] of byName) {
|
|
20
|
+
const ordered = [...group].sort((a, b) => options.compareVersions(a.version, b.version));
|
|
21
|
+
let lastContent;
|
|
22
|
+
let isFirst = true;
|
|
23
|
+
for (const entry of ordered) {
|
|
24
|
+
const content = canonicalize(entry.variant);
|
|
25
|
+
if (!isFirst && content === lastContent)
|
|
26
|
+
continue;
|
|
27
|
+
const variant = {
|
|
28
|
+
request: entry.variant.request,
|
|
29
|
+
responses: entry.variant.responses,
|
|
30
|
+
};
|
|
31
|
+
assignNaming(variant, {
|
|
32
|
+
operationId: options.operationId,
|
|
33
|
+
key: name,
|
|
34
|
+
fileName: entry.fileName,
|
|
35
|
+
singleLineage,
|
|
36
|
+
});
|
|
37
|
+
const introduceSince = !isFirst ||
|
|
38
|
+
(options.baselineVersion !== undefined && entry.version !== options.baselineVersion);
|
|
39
|
+
if (introduceSince)
|
|
40
|
+
variant.since = entry.version;
|
|
41
|
+
result.push(orderKeys(variant));
|
|
42
|
+
lastContent = content;
|
|
43
|
+
isFirst = false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
/** Stable, key-order-independent serialization used to compare variant content for equality. */
|
|
49
|
+
function canonicalize(variant) {
|
|
50
|
+
return JSON.stringify(sortValue({ request: variant.request, responses: variant.responses }));
|
|
51
|
+
}
|
|
52
|
+
function sortValue(value) {
|
|
53
|
+
if (Array.isArray(value))
|
|
54
|
+
return value.map(sortValue);
|
|
55
|
+
if (value !== null && typeof value === "object") {
|
|
56
|
+
const out = {};
|
|
57
|
+
for (const key of Object.keys(value).sort()) {
|
|
58
|
+
out[key] = sortValue(value[key]);
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
/** Present keys in the canonical emission order: title, since, legacyFilename, request, responses. */
|
|
65
|
+
function orderKeys(variant) {
|
|
66
|
+
return {
|
|
67
|
+
...(variant.title !== undefined ? { title: variant.title } : {}),
|
|
68
|
+
...(variant.since !== undefined ? { since: variant.since } : {}),
|
|
69
|
+
...(variant.legacyFilename !== undefined ? { legacyFilename: variant.legacyFilename } : {}),
|
|
70
|
+
request: variant.request,
|
|
71
|
+
responses: variant.responses,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Assign the minimal `title` / `legacyFilename` needed for the emitter to reconstruct the original
|
|
76
|
+
* x-ms-examples key and file name. Both are omitted whenever they follow the default convention
|
|
77
|
+
* (key = `operationId`, file = `<operationId>.json`), so the common case stays clean.
|
|
78
|
+
*/
|
|
79
|
+
function assignNaming(variant, info) {
|
|
80
|
+
const { operationId, key, fileName, singleLineage } = info;
|
|
81
|
+
if (singleLineage) {
|
|
82
|
+
// Both key and file name are the defaults => nothing to store.
|
|
83
|
+
if (key === operationId && fileName === defaultLegacyExampleFilename(operationId)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// The key is recoverable from the file name (`Foo.json` -> key `Foo`) => store only the file.
|
|
87
|
+
if (key === stripJsonExtension(fileName)) {
|
|
88
|
+
variant.legacyFilename = fileName;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Otherwise the key must be stored as `title` (also required to disambiguate multiple lineages);
|
|
93
|
+
// the file name only needs storing when it deviates from the `operationId`+`title` default.
|
|
94
|
+
variant.title = key;
|
|
95
|
+
if (fileName !== defaultLegacyExampleFilename(operationId, key)) {
|
|
96
|
+
variant.legacyFilename = fileName;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=dedup.js.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AAI,QAAQ,KAAK,4BAA4B,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC;QAChE,OAAO,CAAC,cAAc,GAAG,QAAQ,CAAC;IACpC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MigratedVariant } from "./model.js";
|
|
2
|
+
/** A single emitted file: a repo-relative path and its serialized YAML content. */
|
|
3
|
+
export interface EmittedFile {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly content: string;
|
|
6
|
+
}
|
|
7
|
+
/** One operation's key and its collapsed variants. */
|
|
8
|
+
export interface OperationEntry {
|
|
9
|
+
readonly operationKey: string;
|
|
10
|
+
readonly variants: MigratedVariant[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build the plain object for an `examples.yaml` file: `$namespace` (optional) followed by one
|
|
14
|
+
* key per operation. Operations are emitted in sorted key order for deterministic output.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildExamplesObject(entries: readonly OperationEntry[], namespace: string | undefined): Record<string, unknown>;
|
|
17
|
+
/** Serialize an examples object to YAML, force-quoting `since` values so they stay strings. */
|
|
18
|
+
export declare function serializeExamplesYaml(object: Record<string, unknown>): string;
|
|
19
|
+
/**
|
|
20
|
+
* Plan the output files. When `splitByInterface` is set (or the interface count exceeds
|
|
21
|
+
* `autoSplitThreshold`), each interface goes to `examples/<Interface>.yaml`; otherwise everything
|
|
22
|
+
* goes to a single top-level `examples.yaml`. Every file repeats `$namespace`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function planFiles(entries: readonly OperationEntry[], namespace: string | undefined, options?: {
|
|
25
|
+
splitByInterface?: boolean;
|
|
26
|
+
autoSplitThreshold?: number;
|
|
27
|
+
}): EmittedFile[];
|
|
28
|
+
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/migrate/emit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,mFAAmF;AACnF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOzB;AAED,+FAA+F;AAC/F,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAyB7E;AAgBD;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAO,GACxE,WAAW,EAAE,CA+Bf"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Document, isPair, isScalar, Scalar, visit } from "yaml";
|
|
2
|
+
import { interfaceOf } from "./operation-key.js";
|
|
3
|
+
/**
|
|
4
|
+
* Build the plain object for an `examples.yaml` file: `$namespace` (optional) followed by one
|
|
5
|
+
* key per operation. Operations are emitted in sorted key order for deterministic output.
|
|
6
|
+
*/
|
|
7
|
+
export function buildExamplesObject(entries, namespace) {
|
|
8
|
+
const object = {};
|
|
9
|
+
if (namespace !== undefined)
|
|
10
|
+
object.$namespace = namespace;
|
|
11
|
+
for (const entry of [...entries].sort((a, b) => a.operationKey.localeCompare(b.operationKey))) {
|
|
12
|
+
object[entry.operationKey] = entry.variants;
|
|
13
|
+
}
|
|
14
|
+
return object;
|
|
15
|
+
}
|
|
16
|
+
/** Serialize an examples object to YAML, force-quoting `since` values so they stay strings. */
|
|
17
|
+
export function serializeExamplesYaml(object) {
|
|
18
|
+
const doc = new Document(object);
|
|
19
|
+
visit(doc, {
|
|
20
|
+
Pair(_, pair, path) {
|
|
21
|
+
if (isScalar(pair.key) &&
|
|
22
|
+
pair.key.value === "since" &&
|
|
23
|
+
isScalar(pair.value) &&
|
|
24
|
+
typeof pair.value.value === "string") {
|
|
25
|
+
pair.value.type = Scalar.QUOTE_DOUBLE;
|
|
26
|
+
}
|
|
27
|
+
// Emit response status codes as bare integer keys (`200:`), matching the RFC idiom.
|
|
28
|
+
// Converting the key to a number makes yaml render it unquoted.
|
|
29
|
+
if (isScalar(pair.key) &&
|
|
30
|
+
typeof pair.key.value === "string" &&
|
|
31
|
+
/^\d+$/.test(pair.key.value) &&
|
|
32
|
+
isUnderResponses(path)) {
|
|
33
|
+
pair.key.value = Number(pair.key.value);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return doc.toString();
|
|
38
|
+
}
|
|
39
|
+
/** Whether the visited node sits inside a `responses` mapping. */
|
|
40
|
+
function isUnderResponses(path) {
|
|
41
|
+
// Only the status-code keys are direct children of a `responses` mapping. Walking up to the
|
|
42
|
+
// nearest enclosing Pair (rather than any ancestor) avoids rewriting numeric-looking keys nested
|
|
43
|
+
// inside a response body or headers, e.g. a body map key such as "001".
|
|
44
|
+
for (let i = path.length - 1; i >= 0; i--) {
|
|
45
|
+
const node = path[i];
|
|
46
|
+
if (isPair(node)) {
|
|
47
|
+
return isScalar(node.key) && node.key.value === "responses";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Plan the output files. When `splitByInterface` is set (or the interface count exceeds
|
|
54
|
+
* `autoSplitThreshold`), each interface goes to `examples/<Interface>.yaml`; otherwise everything
|
|
55
|
+
* goes to a single top-level `examples.yaml`. Every file repeats `$namespace`.
|
|
56
|
+
*/
|
|
57
|
+
export function planFiles(entries, namespace, options = {}) {
|
|
58
|
+
const interfaces = new Set(entries.map((e) => interfaceOf(e.operationKey)));
|
|
59
|
+
const shouldSplit = options.splitByInterface === true ||
|
|
60
|
+
(options.splitByInterface !== false &&
|
|
61
|
+
options.autoSplitThreshold !== undefined &&
|
|
62
|
+
interfaces.size > options.autoSplitThreshold);
|
|
63
|
+
if (!shouldSplit) {
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
path: "examples.yaml",
|
|
67
|
+
content: serializeExamplesYaml(buildExamplesObject(entries, namespace)),
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
const byInterface = new Map();
|
|
72
|
+
for (const entry of entries) {
|
|
73
|
+
const iface = interfaceOf(entry.operationKey);
|
|
74
|
+
const group = byInterface.get(iface);
|
|
75
|
+
if (group)
|
|
76
|
+
group.push(entry);
|
|
77
|
+
else
|
|
78
|
+
byInterface.set(iface, [entry]);
|
|
79
|
+
}
|
|
80
|
+
return [...byInterface.entries()]
|
|
81
|
+
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
82
|
+
.map(([iface, group]) => ({
|
|
83
|
+
path: `examples/${iface}.yaml`,
|
|
84
|
+
content: serializeExamplesYaml(buildExamplesObject(group, namespace)),
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=emit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.js","sourceRoot":"","sources":["../../../src/migrate/emit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAcjD;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C,CAAC;aACxE;SACF,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IACxD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;;YACxB,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,GAAG,WAAW,CAAC,OAAO,EAAE,CAAC;SAC9B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACxC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QACxB,IAAI,EAAE,YAAY,KAAK,OAAO;QAC9B,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;KACtE,CAAC,CAAC,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tsp-examples-migrate`: convert classic `x-ms-examples` JSON into the unified `examples.yaml` format.
|
|
3
|
+
*/
|
|
4
|
+
export { buildLineages, type BuildLineagesOptions, type CollectedExample } from "./dedup.js";
|
|
5
|
+
export { buildExamplesObject, planFiles, serializeExamplesYaml, type EmittedFile, type OperationEntry, } from "./emit.js";
|
|
6
|
+
export { migrate, type MigrateOptions, type MigrateResult } from "./migrate.js";
|
|
7
|
+
export type { MigratedRequest, MigratedResponse, MigratedVariant } from "./model.js";
|
|
8
|
+
export { normalizeApiVersion, normalizeApiVersions } from "./normalize.js";
|
|
9
|
+
export { deriveOperationKey, interfaceOf } from "./operation-key.js";
|
|
10
|
+
export { collectParamLocations, crawlExamples, discoverSwaggerFiles, extractOperations, namespaceFromPaths, resolveLocalParam, resolveRefPath, versionFromPath, type CrawlResult, type CrawledExample, type ExtractedOperation, } from "./swagger.js";
|
|
11
|
+
export { transformExample } from "./transform.js";
|
|
12
|
+
export { comparatorFromOrder, defaultCompareVersions, earliestVersion, latestVersion, } from "./version-order.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrate/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,qBAAqB,EACrB,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAChF,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,aAAa,GACd,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tsp-examples-migrate`: convert classic `x-ms-examples` JSON into the unified `examples.yaml` format.
|
|
3
|
+
*/
|
|
4
|
+
export { buildLineages } from "./dedup.js";
|
|
5
|
+
export { buildExamplesObject, planFiles, serializeExamplesYaml, } from "./emit.js";
|
|
6
|
+
export { migrate } from "./migrate.js";
|
|
7
|
+
export { normalizeApiVersion, normalizeApiVersions } from "./normalize.js";
|
|
8
|
+
export { deriveOperationKey, interfaceOf } from "./operation-key.js";
|
|
9
|
+
export { collectParamLocations, crawlExamples, discoverSwaggerFiles, extractOperations, namespaceFromPaths, resolveLocalParam, resolveRefPath, versionFromPath, } from "./swagger.js";
|
|
10
|
+
export { transformExample } from "./transform.js";
|
|
11
|
+
export { comparatorFromOrder, defaultCompareVersions, earliestVersion, latestVersion, } from "./version-order.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migrate/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAoD,MAAM,YAAY,CAAC;AAC7F,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,qBAAqB,GAGtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,OAAO,EAA2C,MAAM,cAAc,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,eAAe,GAIhB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,aAAa,GACd,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ExampleDiagnostic } from "../types.js";
|
|
2
|
+
import { type EmittedFile } from "./emit.js";
|
|
3
|
+
/** Options controlling a migration run. */
|
|
4
|
+
export interface MigrateOptions {
|
|
5
|
+
/** Override the detected `$namespace`. */
|
|
6
|
+
readonly namespace?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Authoritative version order (e.g. from `service.yaml`). When omitted, a date-based heuristic
|
|
9
|
+
* is used over the versions discovered while crawling.
|
|
10
|
+
*/
|
|
11
|
+
readonly versionOrder?: readonly string[];
|
|
12
|
+
/** Force (or disable) splitting output into `examples/<Interface>.yaml`. */
|
|
13
|
+
readonly splitByInterface?: boolean;
|
|
14
|
+
/** When `splitByInterface` is undefined, auto-split above this interface count. */
|
|
15
|
+
readonly autoSplitThreshold?: number;
|
|
16
|
+
}
|
|
17
|
+
/** The outcome of a migration run. */
|
|
18
|
+
export interface MigrateResult {
|
|
19
|
+
/** The files to write (relative paths + serialized YAML). */
|
|
20
|
+
readonly files: EmittedFile[];
|
|
21
|
+
/** The namespace used (detected or overridden). */
|
|
22
|
+
readonly namespace?: string;
|
|
23
|
+
/** The versions discovered while crawling. */
|
|
24
|
+
readonly versions: string[];
|
|
25
|
+
/** The number of operations migrated. */
|
|
26
|
+
readonly operationCount: number;
|
|
27
|
+
/**
|
|
28
|
+
* Warnings surfaced during migration — currently, example lineages that stop appearing before the
|
|
29
|
+
* service's latest version. The unified format has no removal marker, so such an example is
|
|
30
|
+
* re-materialized for every version from its last appearance onward; the migrator flags it so the
|
|
31
|
+
* author can confirm it still applies (or remove it).
|
|
32
|
+
*/
|
|
33
|
+
readonly diagnostics: ExampleDiagnostic[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Migrate a tree of versioned Swagger specs with `x-ms-examples` into the unified `examples.yaml`
|
|
37
|
+
* format. Pure aside from reading the input tree (it does not write files).
|
|
38
|
+
*/
|
|
39
|
+
export declare function migrate(root: string, options?: MigrateOptions): Promise<MigrateResult>;
|
|
40
|
+
//# sourceMappingURL=migrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/migrate/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAa,KAAK,WAAW,EAAuB,MAAM,WAAW,CAAC;AAY7E,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,4EAA4E;IAC5E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,mFAAmF;IACnF,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC;IAC9B,mDAAmD;IACnD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,EAAE,iBAAiB,EAAE,CAAC;CAC3C;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAyDhG"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { buildLineages } from "./dedup.js";
|
|
2
|
+
import { planFiles } from "./emit.js";
|
|
3
|
+
import { normalizeApiVersion } from "./normalize.js";
|
|
4
|
+
import { deriveOperationKey } from "./operation-key.js";
|
|
5
|
+
import { crawlExamples } from "./swagger.js";
|
|
6
|
+
import { transformExample } from "./transform.js";
|
|
7
|
+
import { comparatorFromOrder, defaultCompareVersions, earliestVersion, latestVersion, } from "./version-order.js";
|
|
8
|
+
/**
|
|
9
|
+
* Migrate a tree of versioned Swagger specs with `x-ms-examples` into the unified `examples.yaml`
|
|
10
|
+
* format. Pure aside from reading the input tree (it does not write files).
|
|
11
|
+
*/
|
|
12
|
+
export async function migrate(root, options = {}) {
|
|
13
|
+
const crawl = await crawlExamples(root);
|
|
14
|
+
const namespace = options.namespace ?? crawl.namespace;
|
|
15
|
+
const compareVersions = options.versionOrder
|
|
16
|
+
? comparatorFromOrder(options.versionOrder)
|
|
17
|
+
: defaultCompareVersions;
|
|
18
|
+
const baselineVersion = options.versionOrder
|
|
19
|
+
? options.versionOrder[0]
|
|
20
|
+
: earliestVersion(crawl.versions, compareVersions);
|
|
21
|
+
// When an authoritative version order is supplied (e.g. from `service.yaml`), it is the source of
|
|
22
|
+
// truth: examples found under on-disk versions that are not listed there are ignored, so the
|
|
23
|
+
// generated `since` values always reference a real service version.
|
|
24
|
+
const allowedVersions = options.versionOrder ? new Set(options.versionOrder) : undefined;
|
|
25
|
+
const byOperation = new Map();
|
|
26
|
+
const operationIds = new Map();
|
|
27
|
+
for (const crawled of crawl.examples) {
|
|
28
|
+
if (allowedVersions !== undefined && !allowedVersions.has(crawled.version))
|
|
29
|
+
continue;
|
|
30
|
+
const operationKey = deriveOperationKey(crawled.operationId);
|
|
31
|
+
operationIds.set(operationKey, crawled.operationId);
|
|
32
|
+
const variant = normalizeApiVersion(transformExample(crawled.doc, crawled.paramLocations), crawled.version);
|
|
33
|
+
const collected = {
|
|
34
|
+
version: crawled.version,
|
|
35
|
+
exampleName: crawled.exampleName,
|
|
36
|
+
fileName: crawled.fileName,
|
|
37
|
+
variant,
|
|
38
|
+
};
|
|
39
|
+
const group = byOperation.get(operationKey);
|
|
40
|
+
if (group)
|
|
41
|
+
group.push(collected);
|
|
42
|
+
else
|
|
43
|
+
byOperation.set(operationKey, [collected]);
|
|
44
|
+
}
|
|
45
|
+
const entries = [];
|
|
46
|
+
for (const [operationKey, collected] of byOperation) {
|
|
47
|
+
entries.push({
|
|
48
|
+
operationKey,
|
|
49
|
+
variants: buildLineages(collected, {
|
|
50
|
+
operationId: operationIds.get(operationKey),
|
|
51
|
+
compareVersions,
|
|
52
|
+
baselineVersion,
|
|
53
|
+
}),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const files = planFiles(entries, namespace, {
|
|
57
|
+
splitByInterface: options.splitByInterface,
|
|
58
|
+
autoSplitThreshold: options.autoSplitThreshold,
|
|
59
|
+
});
|
|
60
|
+
const versions = options.versionOrder ? [...options.versionOrder] : crawl.versions;
|
|
61
|
+
const diagnostics = collectRemovalDiagnostics(byOperation, versions, compareVersions);
|
|
62
|
+
return { files, namespace, versions, operationCount: entries.length, diagnostics };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Flag example lineages that stop appearing before the latest version. Because the unified format
|
|
66
|
+
* has no removal marker, such an example would be re-materialized for versions it never shipped in,
|
|
67
|
+
* so the author should confirm it still applies (or drop it).
|
|
68
|
+
*/
|
|
69
|
+
function collectRemovalDiagnostics(byOperation, versions, compareVersions) {
|
|
70
|
+
const latest = latestVersion(versions, compareVersions);
|
|
71
|
+
if (latest === undefined)
|
|
72
|
+
return [];
|
|
73
|
+
const diagnostics = [];
|
|
74
|
+
for (const [operationKey, collected] of byOperation) {
|
|
75
|
+
const lastByLineage = new Map();
|
|
76
|
+
for (const example of collected) {
|
|
77
|
+
const current = lastByLineage.get(example.exampleName);
|
|
78
|
+
if (current === undefined || compareVersions(example.version, current) > 0) {
|
|
79
|
+
lastByLineage.set(example.exampleName, example.version);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for (const [lineage, lastSeen] of lastByLineage) {
|
|
83
|
+
if (compareVersions(lastSeen, latest) < 0) {
|
|
84
|
+
diagnostics.push({
|
|
85
|
+
code: "example-removed-before-latest",
|
|
86
|
+
message: `Example "${lineage}" for operation "${operationKey}" last appears in "${lastSeen}", ` +
|
|
87
|
+
`before the latest version "${latest}". The unified format has no removal marker, so it ` +
|
|
88
|
+
`will be re-materialized for every version from "${lastSeen}" onward — confirm it still ` +
|
|
89
|
+
`applies to later versions, or remove it.`,
|
|
90
|
+
severity: "warning",
|
|
91
|
+
file: "examples.yaml",
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return diagnostics;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../src/migrate/migrate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAyB,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,SAAS,EAAyC,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,aAAa,GACd,MAAM,oBAAoB,CAAC;AAoC5B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,UAA0B,EAAE;IACtE,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,SAAS,GAAG,OAAO,CAAC,SA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C,MAAM,WAAW,GAAwB,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,IAAI,WAAW,EAAE,CAAC;QACpD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;QAChD,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACvD,IAAI,OAAO,KAAK,SAAS,IAAI,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3E,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QACD,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,aAAa,EAAE,CAAC;YAChD,IAAI,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1C,WAAW,CAAC,IAAI,CAAC;oBACf,IAAI,EAAE,+BAA+B;oBACrC,OAAO,EACL,YAAY,OAAO,oBAAoB,YAAY,sBAAsB,QAAQ,KAAK;wBACtF,8BAA8B,MAAM,qDAAqD;wBACzF,mDAAmD,QAAQ,8BAA8B;wBACzF,0CAA0C;oBAC5C,QAAQ,EAAE,SAAS;oBACnB,IAAI,EAAE,eAAe;iBACtB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal representation of a migrated example variant, prior to lineage assignment.
|
|
3
|
+
* Mirrors the `Example` shape in the schema but is mutable while being assembled.
|
|
4
|
+
*/
|
|
5
|
+
export interface MigratedRequest {
|
|
6
|
+
path?: Record<string, unknown>;
|
|
7
|
+
query?: Record<string, unknown>;
|
|
8
|
+
headers?: Record<string, unknown>;
|
|
9
|
+
body?: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface MigratedResponse {
|
|
12
|
+
headers?: Record<string, unknown>;
|
|
13
|
+
body?: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface MigratedVariant {
|
|
16
|
+
title?: string;
|
|
17
|
+
since?: string;
|
|
18
|
+
legacyFilename?: string;
|
|
19
|
+
request: MigratedRequest;
|
|
20
|
+
responses: Record<string, MigratedResponse>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/migrate/model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,eAAe,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/migrate/model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize embedded concrete API-version strings to the `{api-version}` placeholder.
|
|
3
|
+
*
|
|
4
|
+
* `x-ms-examples` frequently bake the api-version into header and body string values
|
|
5
|
+
* (`Location`, `Azure-AsyncOperation`, `nextLink`, ...). Replacing those with `{api-version}`
|
|
6
|
+
* lets otherwise-identical variants across versions collapse into a single lineage entry.
|
|
7
|
+
*/
|
|
8
|
+
/** Recursively replace occurrences of `version` in string values with `{api-version}`. */
|
|
9
|
+
export declare function normalizeApiVersion<T>(value: T, version: string): T;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize using any of the provided versions (longest first, so more specific version strings
|
|
12
|
+
* win over prefixes).
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeApiVersions<T>(value: T, versions: readonly string[]): T;
|
|
15
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../src/migrate/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAEnE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,CAIhF"}
|