From 90958f26835bbe69f8f56822666e8a1b174a531c Mon Sep 17 00:00:00 2001 From: Alitzel Mendez Bustillo Date: Mon, 18 Nov 2024 18:19:45 -0800 Subject: [PATCH 1/9] Remove azure-core nextlink as it is an ambiguous name between TypeSpec.nextLink and Azure.Core.nextLink --- packages/typespec-azure-core/generated-defs/Azure.Core.ts | 6 ------ packages/typespec-azure-core/lib/decorators.tsp | 5 ----- packages/typespec-azure-core/src/decorators.ts | 5 ----- packages/typespec-azure-core/src/tsp-index.ts | 2 -- 4 files changed, 18 deletions(-) diff --git a/packages/typespec-azure-core/generated-defs/Azure.Core.ts b/packages/typespec-azure-core/generated-defs/Azure.Core.ts index 391c141f11..c77cab8841 100644 --- a/packages/typespec-azure-core/generated-defs/Azure.Core.ts +++ b/packages/typespec-azure-core/generated-defs/Azure.Core.ts @@ -50,11 +50,6 @@ export type PollingLocationDecorator = ( */ export type ItemsDecorator = (context: DecoratorContext, entity: ModelProperty) => void; -/** - * Identifies a ModelProperty that contains the next link value. Can only be used on a Model marked with `@pagedResult`. - */ -export type NextLinkDecorator = (context: DecoratorContext, entity: ModelProperty) => void; - /** * Marks a Model as a paged collection. */ @@ -194,7 +189,6 @@ export type AzureCoreDecorators = { finalLocation: FinalLocationDecorator; pollingLocation: PollingLocationDecorator; items: ItemsDecorator; - nextLink: NextLinkDecorator; pagedResult: PagedResultDecorator; fixed: FixedDecorator; lroSucceeded: LroSucceededDecorator; diff --git a/packages/typespec-azure-core/lib/decorators.tsp b/packages/typespec-azure-core/lib/decorators.tsp index 3239278433..17f07161ea 100644 --- a/packages/typespec-azure-core/lib/decorators.tsp +++ b/packages/typespec-azure-core/lib/decorators.tsp @@ -17,11 +17,6 @@ namespace Azure.Core { */ extern dec items(entity: ModelProperty); - /** - * Identifies a ModelProperty that contains the next link value. Can only be used on a Model marked with `@pagedResult`. - */ - extern dec nextLink(entity: ModelProperty); - /** * Used for custom StatusMonitor implementation. * Identifies an Enum or ModelProperty as containing long-running operation diff --git a/packages/typespec-azure-core/src/decorators.ts b/packages/typespec-azure-core/src/decorators.ts index 18da1f7769..d48ef41be0 100644 --- a/packages/typespec-azure-core/src/decorators.ts +++ b/packages/typespec-azure-core/src/decorators.ts @@ -58,7 +58,6 @@ import { LroFailedDecorator, LroStatusDecorator, LroSucceededDecorator, - NextLinkDecorator, NextPageOperationDecorator, OperationLinkDecorator, PagedResultDecorator, @@ -268,10 +267,6 @@ export function getItems(program: Program, entity: Type): boolean | undefined { return program.stateMap(AzureCoreStateKeys.items).get(entity); } -export const $nextLink: NextLinkDecorator = (context: DecoratorContext, entity: ModelProperty) => { - context.program.stateMap(AzureCoreStateKeys.nextLink).set(entity, true); -}; - /** * Returns `true` if the property is marked with `@nextLink`. */ diff --git a/packages/typespec-azure-core/src/tsp-index.ts b/packages/typespec-azure-core/src/tsp-index.ts index 7bc300cc91..a1d9f8ec68 100644 --- a/packages/typespec-azure-core/src/tsp-index.ts +++ b/packages/typespec-azure-core/src/tsp-index.ts @@ -20,7 +20,6 @@ import { $lroStatus, $lroSucceeded, $needsRoute, - $nextLink, $nextPageOperation, $omitKeyProperties, $operationLink, @@ -58,7 +57,6 @@ export const $decorators = { pollingLocation: $pollingLocation, pagedResult: $pagedResult, items: $items, - nextLink: $nextLink, fixed: $fixed, lroSucceeded: $lroSucceeded, lroCanceled: $lroCanceled, From a3ddbec9486ffa809105266773a84d39d965e4e3 Mon Sep 17 00:00:00 2001 From: Alitzel Mendez Bustillo Date: Mon, 18 Nov 2024 20:54:10 -0800 Subject: [PATCH 2/9] Documentation and summary --- ...e-azure-core-nextlink-2024-10-18-20-51-27.md | 7 +++++++ packages/typespec-azure-core/README.md | 17 ----------------- .../azure-core/reference/decorators.md | 16 ---------------- .../libraries/azure-core/reference/index.mdx | 1 - 4 files changed, 7 insertions(+), 34 deletions(-) create mode 100644 .chronus/changes/remove-azure-core-nextlink-2024-10-18-20-51-27.md diff --git a/.chronus/changes/remove-azure-core-nextlink-2024-10-18-20-51-27.md b/.chronus/changes/remove-azure-core-nextlink-2024-10-18-20-51-27.md new file mode 100644 index 0000000000..a44217d20a --- /dev/null +++ b/.chronus/changes/remove-azure-core-nextlink-2024-10-18-20-51-27.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-azure-core" +--- + +Remove `Azure.Core.nextLink` as there is a nextLink instance in `TypeSpec.nextLink`, which is causing an ambiguous problem between the two. diff --git a/packages/typespec-azure-core/README.md b/packages/typespec-azure-core/README.md index e9ddd4e7f0..3dfb5380f5 100644 --- a/packages/typespec-azure-core/README.md +++ b/packages/typespec-azure-core/README.md @@ -82,7 +82,6 @@ Available ruleSets: - [`@lroResult`](#@lroresult) - [`@lroStatus`](#@lrostatus) - [`@lroSucceeded`](#@lrosucceeded) -- [`@nextLink`](#@nextlink) - [`@nextPageOperation`](#@nextpageoperation) - [`@operationLink`](#@operationlink) - [`@pagedResult`](#@pagedresult) @@ -266,22 +265,6 @@ Identifies an EnumMember as a long-running "Succeeded" terminal state. None -#### `@nextLink` - -Identifies a ModelProperty that contains the next link value. Can only be used on a Model marked with `@pagedResult`. - -```typespec -@Azure.Core.nextLink -``` - -##### Target - -`ModelProperty` - -##### Parameters - -None - #### `@nextPageOperation` Identifies that an operation is used to retrieve the next page for paged operations. diff --git a/website/src/content/docs/docs/libraries/azure-core/reference/decorators.md b/website/src/content/docs/docs/libraries/azure-core/reference/decorators.md index 2e375cbe20..eb738c32e8 100644 --- a/website/src/content/docs/docs/libraries/azure-core/reference/decorators.md +++ b/website/src/content/docs/docs/libraries/azure-core/reference/decorators.md @@ -181,22 +181,6 @@ Identifies an EnumMember as a long-running "Succeeded" terminal state. None -### `@nextLink` {#@Azure.Core.nextLink} - -Identifies a ModelProperty that contains the next link value. Can only be used on a Model marked with `@pagedResult`. - -```typespec -@Azure.Core.nextLink -``` - -#### Target - -`ModelProperty` - -#### Parameters - -None - ### `@nextPageOperation` {#@Azure.Core.nextPageOperation} Identifies that an operation is used to retrieve the next page for paged operations. diff --git a/website/src/content/docs/docs/libraries/azure-core/reference/index.mdx b/website/src/content/docs/docs/libraries/azure-core/reference/index.mdx index ee43cf3b58..650f604614 100644 --- a/website/src/content/docs/docs/libraries/azure-core/reference/index.mdx +++ b/website/src/content/docs/docs/libraries/azure-core/reference/index.mdx @@ -44,7 +44,6 @@ npm install --save-peer @azure-tools/typespec-azure-core - [`@lroResult`](./decorators.md#@Azure.Core.lroResult) - [`@lroStatus`](./decorators.md#@Azure.Core.lroStatus) - [`@lroSucceeded`](./decorators.md#@Azure.Core.lroSucceeded) -- [`@nextLink`](./decorators.md#@Azure.Core.nextLink) - [`@nextPageOperation`](./decorators.md#@Azure.Core.nextPageOperation) - [`@operationLink`](./decorators.md#@Azure.Core.operationLink) - [`@pagedResult`](./decorators.md#@Azure.Core.pagedResult) From 2e71ade18b1cac9c57fad7b6354f2b700027997c Mon Sep 17 00:00:00 2001 From: Alitzel Mendez Bustillo Date: Tue, 19 Nov 2024 10:03:29 -0800 Subject: [PATCH 3/9] Adress build issues --- packages/typespec-azure-resource-manager/lib/models.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typespec-azure-resource-manager/lib/models.tsp b/packages/typespec-azure-resource-manager/lib/models.tsp index 7b5cc1999b..f59be03064 100644 --- a/packages/typespec-azure-resource-manager/lib/models.tsp +++ b/packages/typespec-azure-resource-manager/lib/models.tsp @@ -308,7 +308,7 @@ model ResourceListCustomResult { value: Result[]; /** The link to the next page of items */ - @Azure.Core.nextLink + @nextLink nextLink?: string; } From bacb85621def5fadba425002f0f76dca2009f84e Mon Sep 17 00:00:00 2001 From: Alitzel Mendez Bustillo Date: Mon, 2 Dec 2024 17:01:52 -0800 Subject: [PATCH 4/9] Remove Azure.Core.nextLink, update changes and tests --- .../remove-azure-core-nextlink-2024-11-2-16-55-46.md | 7 +++++++ .../azure-http-specs/specs/azure/core/page/main.tsp | 2 +- packages/typespec-autorest/test/paging.test.ts | 4 ++-- packages/typespec-azure-core/src/decorators.ts | 7 ++++--- packages/typespec-azure-core/src/lib.ts | 1 - packages/typespec-azure-core/test/decorators.test.ts | 10 +++++----- .../test/rules/use-standard-names.test.ts | 4 ++-- .../test/packages/paged-operation.test.ts | 2 +- .../test/public-utils/is-paged-result-model.test.ts | 2 +- 9 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 .chronus/changes/remove-azure-core-nextlink-2024-11-2-16-55-46.md diff --git a/.chronus/changes/remove-azure-core-nextlink-2024-11-2-16-55-46.md b/.chronus/changes/remove-azure-core-nextlink-2024-11-2-16-55-46.md new file mode 100644 index 0000000000..bc970a7a3b --- /dev/null +++ b/.chronus/changes/remove-azure-core-nextlink-2024-11-2-16-55-46.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-azure-resource-manager" +--- + +Replace usage of `Azure.Core.nextLink` to `TypeSpec.nextLink`. diff --git a/packages/azure-http-specs/specs/azure/core/page/main.tsp b/packages/azure-http-specs/specs/azure/core/page/main.tsp index 5bdfcf2d82..e592ed29d1 100644 --- a/packages/azure-http-specs/specs/azure/core/page/main.tsp +++ b/packages/azure-http-specs/specs/azure/core/page/main.tsp @@ -146,7 +146,7 @@ model CustomPageModel { @doc("List of items.") items: T[]; - @global.Azure.Core.nextLink + @nextLink @doc("Link to fetch more items.") nextLink?: string; } diff --git a/packages/typespec-autorest/test/paging.test.ts b/packages/typespec-autorest/test/paging.test.ts index 4fbdec9be2..0195027682 100644 --- a/packages/typespec-autorest/test/paging.test.ts +++ b/packages/typespec-autorest/test/paging.test.ts @@ -46,7 +46,7 @@ describe("Legacy define paging operation using Azure.Core decorators", () => { model CustomPageModel { items: T[]; - @Azure.Core.nextLink + @nextLink \`@odata.nextLink\`?: string; } op list(): CustomPageModel<{}>; @@ -66,7 +66,7 @@ describe("Legacy define paging operation using Azure.Core decorators", () => { @Azure.Core.items itemList?: string[]; - @Azure.Core.nextLink + @nextLink nextLink?: string; } diff --git a/packages/typespec-azure-core/src/decorators.ts b/packages/typespec-azure-core/src/decorators.ts index d48ef41be0..92552b6f1f 100644 --- a/packages/typespec-azure-core/src/decorators.ts +++ b/packages/typespec-azure-core/src/decorators.ts @@ -3,6 +3,7 @@ import { getAllProperties } from "./utils.js"; import { createDiagnosticCollector, + createStateSymbol, DecoratorContext, Diagnostic, DiagnosticCollector, @@ -151,7 +152,7 @@ function _getItems(program: Program, entity: Model): PropertyPath | undefined { } function _getNextLink(program: Program, entity: Model): PropertyPath | undefined { - return findPathToProperty(program, entity, (prop) => getNextLink(program, prop) !== undefined); + return findPathToProperty(program, entity, (prop) => getNextLink(program, prop)); } /** @@ -270,8 +271,8 @@ export function getItems(program: Program, entity: Type): boolean | undefined { /** * Returns `true` if the property is marked with `@nextLink`. */ -export function getNextLink(program: Program, entity: Type): boolean | undefined { - return program.stateMap(AzureCoreStateKeys.nextLink).get(entity); +export function getNextLink(program: Program, entity: ModelProperty): boolean { + return program.stateSet(createStateSymbol("nextLink")).has(entity); } /** diff --git a/packages/typespec-azure-core/src/lib.ts b/packages/typespec-azure-core/src/lib.ts index e5da72ad78..ec81c9963d 100644 --- a/packages/typespec-azure-core/src/lib.ts +++ b/packages/typespec-azure-core/src/lib.ts @@ -231,7 +231,6 @@ export const $lib = createTypeSpecLibrary({ fixed: { description: "Data for `@fixed` decorator" }, pagedResult: { description: "Data for `@pagedResult` decorator" }, items: { description: "Data for `@items` decorator" }, - nextLink: { description: "Data for `@nextLink` decorator" }, lroStatus: { description: "Data for `@lroStatus` decorator" }, lroSucceeded: { description: "Data for `@lroSucceeded` decorator" }, lroCanceled: { description: "Data for `@lroCanceled` decorator" }, diff --git a/packages/typespec-azure-core/test/decorators.test.ts b/packages/typespec-azure-core/test/decorators.test.ts index b012ecd26a..52025eab09 100644 --- a/packages/typespec-azure-core/test/decorators.test.ts +++ b/packages/typespec-azure-core/test/decorators.test.ts @@ -46,7 +46,7 @@ describe("typespec-azure-core: decorators", () => { @items foos: string[]; - @Azure.Core.nextLink + @nextLink nextThing?: string; } `); @@ -68,7 +68,7 @@ describe("typespec-azure-core: decorators", () => { things: string[]; doo: { - @Azure.Core.nextLink + @nextLink next?: string; } } @@ -90,7 +90,7 @@ describe("typespec-azure-core: decorators", () => { @items \`base.things\`: string[]; - @Azure.Core.nextLink + @nextLink \`base.next\`?: string; } `); @@ -170,7 +170,7 @@ describe("typespec-azure-core: decorators", () => { @doc(".") nested: { - @Azure.Core.nextLink + @nextLink @doc(".") nextLink: string; } @@ -209,7 +209,7 @@ describe("typespec-azure-core: decorators", () => { @doc(".") values?: string[]; - @Azure.Core.nextLink + @nextLink @doc(".") nextLink: string; } diff --git a/packages/typespec-azure-core/test/rules/use-standard-names.test.ts b/packages/typespec-azure-core/test/rules/use-standard-names.test.ts index 998a86e279..41d762191a 100644 --- a/packages/typespec-azure-core/test/rules/use-standard-names.test.ts +++ b/packages/typespec-azure-core/test/rules/use-standard-names.test.ts @@ -24,7 +24,7 @@ describe("typespec-azure-core: use-standard-names rule", () => { @pagedResult model FooPage { - @Azure.Core.nextLink + @nextLink next: string, @items value: Foo[]; @@ -98,7 +98,7 @@ describe("typespec-azure-core: use-standard-names rule", () => { @pagedResult model FooPage { - @Azure.Core.nextLink + @nextLink next: string, @items value: Foo[]; diff --git a/packages/typespec-client-generator-core/test/packages/paged-operation.test.ts b/packages/typespec-client-generator-core/test/packages/paged-operation.test.ts index 018ddf8c24..ce93b223af 100644 --- a/packages/typespec-client-generator-core/test/packages/paged-operation.test.ts +++ b/packages/typespec-client-generator-core/test/packages/paged-operation.test.ts @@ -25,7 +25,7 @@ describe("typespec-client-generator-core: paged operation", () => { @items @clientName("values") tests: Test[]; - @Azure.Core.nextLink + @nextLink @clientName("nextLink") next: string; } diff --git a/packages/typespec-client-generator-core/test/public-utils/is-paged-result-model.test.ts b/packages/typespec-client-generator-core/test/public-utils/is-paged-result-model.test.ts index 05e0e1e507..4563cb0505 100644 --- a/packages/typespec-client-generator-core/test/public-utils/is-paged-result-model.test.ts +++ b/packages/typespec-client-generator-core/test/public-utils/is-paged-result-model.test.ts @@ -23,7 +23,7 @@ describe("typespec-client-generator-core: public-utils", () => { @items value: Test[]; - @Azure.Core.nextLink + @nextLink nextLink?: url; } From c505e665d38bd498cd358614acb9181856641c2e Mon Sep 17 00:00:00 2001 From: Alitzel Mendez Bustillo Date: Mon, 2 Dec 2024 17:24:58 -0800 Subject: [PATCH 5/9] summary changes --- .../remove-azure-core-nextlink-2024-11-2-17-14-6.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/remove-azure-core-nextlink-2024-11-2-17-14-6.md diff --git a/.chronus/changes/remove-azure-core-nextlink-2024-11-2-17-14-6.md b/.chronus/changes/remove-azure-core-nextlink-2024-11-2-17-14-6.md new file mode 100644 index 0000000000..060daa350e --- /dev/null +++ b/.chronus/changes/remove-azure-core-nextlink-2024-11-2-17-14-6.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/azure-http-specs" +--- + +Replace usage of `Azure.Core.nextLink` to `TypeSpec.nextLink`. \ No newline at end of file From 1e828aa4d027bcc4409fa7eda60f4924b5187d28 Mon Sep 17 00:00:00 2001 From: Alitzel Mendez Bustillo Date: Tue, 3 Dec 2024 12:08:27 -0800 Subject: [PATCH 6/9] Fix error caused on azure-rest-api-specs --- packages/typespec-azure-core/src/decorators.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/typespec-azure-core/src/decorators.ts b/packages/typespec-azure-core/src/decorators.ts index 92552b6f1f..2774c9fe6c 100644 --- a/packages/typespec-azure-core/src/decorators.ts +++ b/packages/typespec-azure-core/src/decorators.ts @@ -3,7 +3,6 @@ import { getAllProperties } from "./utils.js"; import { createDiagnosticCollector, - createStateSymbol, DecoratorContext, Diagnostic, DiagnosticCollector, @@ -272,7 +271,7 @@ export function getItems(program: Program, entity: Type): boolean | undefined { * Returns `true` if the property is marked with `@nextLink`. */ export function getNextLink(program: Program, entity: ModelProperty): boolean { - return program.stateSet(createStateSymbol("nextLink")).has(entity); + return program.stateSet(Symbol.for(`TypeSpec.nextLink`)).has(entity); } /** From a64f0f8aad2f7475f18e086f72f926fba07fdef6 Mon Sep 17 00:00:00 2001 From: Alitzel Mendez Bustillo Date: Tue, 3 Dec 2024 13:23:46 -0800 Subject: [PATCH 7/9] undoio change of signature --- packages/typespec-azure-core/src/decorators.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typespec-azure-core/src/decorators.ts b/packages/typespec-azure-core/src/decorators.ts index 2774c9fe6c..5583e7523a 100644 --- a/packages/typespec-azure-core/src/decorators.ts +++ b/packages/typespec-azure-core/src/decorators.ts @@ -270,7 +270,7 @@ export function getItems(program: Program, entity: Type): boolean | undefined { /** * Returns `true` if the property is marked with `@nextLink`. */ -export function getNextLink(program: Program, entity: ModelProperty): boolean { +export function getNextLink(program: Program, entity: ModelProperty): boolean | undefined { return program.stateSet(Symbol.for(`TypeSpec.nextLink`)).has(entity); } From bc015ed89664d49e85c5de2880a93105996678c2 Mon Sep 17 00:00:00 2001 From: Alitzel Mendez Bustillo Date: Tue, 3 Dec 2024 13:40:46 -0800 Subject: [PATCH 8/9] undoio change of signature --- packages/typespec-azure-core/src/decorators.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typespec-azure-core/src/decorators.ts b/packages/typespec-azure-core/src/decorators.ts index 5583e7523a..79677eadcb 100644 --- a/packages/typespec-azure-core/src/decorators.ts +++ b/packages/typespec-azure-core/src/decorators.ts @@ -151,7 +151,7 @@ function _getItems(program: Program, entity: Model): PropertyPath | undefined { } function _getNextLink(program: Program, entity: Model): PropertyPath | undefined { - return findPathToProperty(program, entity, (prop) => getNextLink(program, prop)); + return findPathToProperty(program, entity, (prop) => getNextLink(program, prop) === true); } /** From 13ff13c4199aef554e681de848cf1061c1789e64 Mon Sep 17 00:00:00 2001 From: Alitzel Mendez Bustillo Date: Fri, 6 Dec 2024 16:35:39 -0800 Subject: [PATCH 9/9] Bump typespec-e2e-cadl-ranch-specs version --- packages/e2e-tests/cadl-ranch-specs/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e-tests/cadl-ranch-specs/package.json b/packages/e2e-tests/cadl-ranch-specs/package.json index b814844704..2ab4d289de 100644 --- a/packages/e2e-tests/cadl-ranch-specs/package.json +++ b/packages/e2e-tests/cadl-ranch-specs/package.json @@ -1,7 +1,7 @@ { "name": "@azure-tools/typespec-e2e-cadl-ranch-specs", "dependencies": { - "@azure-tools/cadl-ranch-specs": "0.39.4" + "@azure-tools/cadl-ranch-specs": "0.39.5" }, "type": "module", "private": true