Skip to content

Commit

Permalink
deprecate PresentationRpcInterface (backport #7319) [release/4.11.x] (#…
Browse files Browse the repository at this point in the history
…7334)

Co-authored-by: Paulius Valiūnas <[email protected]>
  • Loading branch information
mergify[bot] and paulius-valiunas authored Nov 12, 2024
1 parent 5fb0553 commit ba8f252
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 25 deletions.
34 changes: 17 additions & 17 deletions common/api/presentation-common.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2195,45 +2195,45 @@ export type PresentationQueryBinding = IdBinding | IdSetBinding | ECValueBinding
export class PresentationRpcInterface extends RpcInterface {
// @deprecated (undocumented)
computeSelection(_token: IModelRpcProps, _options: SelectionScopeRpcRequestOptions, _ids: Id64String[], _scopeId: string): PresentationRpcResponse<KeySetJSON>;
// (undocumented)
// @deprecated (undocumented)
computeSelection(_token: IModelRpcProps, _options: ComputeSelectionRpcRequestOptions): PresentationRpcResponse<KeySetJSON>;
// (undocumented)
// @deprecated (undocumented)
getContentDescriptor(_token: IModelRpcProps, _options: ContentDescriptorRpcRequestOptions): PresentationRpcResponse<DescriptorJSON | undefined>;
// (undocumented)
// @deprecated (undocumented)
getContentInstanceKeys(_token: IModelRpcProps, _options: ContentInstanceKeysRpcRequestOptions): PresentationRpcResponse<{
total: number;
items: KeySetJSON;
}>;
// (undocumented)
// @deprecated (undocumented)
getContentSetSize(_token: IModelRpcProps, _options: ContentRpcRequestOptions): PresentationRpcResponse<number>;
// (undocumented)
// @deprecated (undocumented)
getContentSources(_token: IModelRpcProps, _options: ContentSourcesRpcRequestOptions): PresentationRpcResponse<ContentSourcesRpcResult>;
// (undocumented)
// @deprecated (undocumented)
getDisplayLabelDefinition(_token: IModelRpcProps, _options: DisplayLabelRpcRequestOptions): PresentationRpcResponse<LabelDefinition>;
// (undocumented)
// @deprecated (undocumented)
getElementProperties(_token: IModelRpcProps, _options: SingleElementPropertiesRpcRequestOptions): PresentationRpcResponse<ElementProperties | undefined>;
// (undocumented)
// @deprecated (undocumented)
getFilteredNodePaths(_token: IModelRpcProps, _options: FilterByTextHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElementJSON[]>;
// (undocumented)
// @deprecated (undocumented)
getNodePaths(_token: IModelRpcProps, _options: FilterByInstancePathsHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElementJSON[]>;
// (undocumented)
// @deprecated (undocumented)
getNodesCount(_token: IModelRpcProps, _options: HierarchyRpcRequestOptions): PresentationRpcResponse<number>;
// (undocumented)
// @deprecated (undocumented)
getNodesDescriptor(_token: IModelRpcProps, _options: HierarchyLevelDescriptorRpcRequestOptions): PresentationRpcResponse<string | DescriptorJSON | undefined>;
// (undocumented)
// @deprecated (undocumented)
getPagedContent(_token: IModelRpcProps, _options: Paged<ContentRpcRequestOptions>): PresentationRpcResponse<{
descriptor: DescriptorJSON;
contentSet: PagedResponse<ItemJSON>;
} | undefined>;
// (undocumented)
// @deprecated (undocumented)
getPagedContentSet(_token: IModelRpcProps, _options: Paged<ContentRpcRequestOptions>): PresentationRpcResponse<PagedResponse<ItemJSON>>;
// (undocumented)
// @deprecated (undocumented)
getPagedDisplayLabelDefinitions(_token: IModelRpcProps, _options: DisplayLabelsRpcRequestOptions): PresentationRpcResponse<PagedResponse<LabelDefinition>>;
// (undocumented)
// @deprecated (undocumented)
getPagedDistinctValues(_token: IModelRpcProps, _options: DistinctValuesRpcRequestOptions): PresentationRpcResponse<PagedResponse<DisplayValueGroupJSON>>;
// (undocumented)
// @deprecated (undocumented)
getPagedNodes(_token: IModelRpcProps, _options: Paged<HierarchyRpcRequestOptions>): PresentationRpcResponse<PagedResponse<NodeJSON>>;
// (undocumented)
// @deprecated (undocumented)
getSelectionScopes(_token: IModelRpcProps, _options: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]>;
static readonly interfaceName = "PresentationRpcInterface";
static interfaceVersion: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/presentation-backend",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/presentation-backend"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/presentation-common",
"comment": "All public methods of `PresentationRpcInterface` have been deprecated. Going forward, RPC interfaces should not be called directly. Public wrappers such as `PresentationManager` should be used instead.",
"type": "minor"
}
],
"packageName": "@itwin/presentation-common"
}
2 changes: 1 addition & 1 deletion docs/changehistory/NextVersion.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
publish: false
---
# NextVersion

# NextVersion
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe("PresentationRpcInterface", () => {
});

it("returns properties for requested element", async () => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const result = await rpcInterface.getElementProperties(imodel.getRpcProps(), {
elementId: "0x1",
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ export class PresentationRpcImpl extends PresentationRpcInterface implements IDi
token: IModelRpcProps,
requestOptions: Paged<ContentRpcRequestOptions>,
): PresentationRpcResponse<PagedResponse<ItemJSON>> {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const response = await this.getPagedContent(token, requestOptions);
if (response.statusCode !== PresentationStatus.Success) {
return this.errorResponse(response.statusCode, response.errorMessage, response.diagnostics);
Expand Down
14 changes: 8 additions & 6 deletions presentation/backend/src/test/PresentationRpcImpl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ import { MAX_ALLOWED_KEYS_PAGE_SIZE, MAX_ALLOWED_PAGE_SIZE, PresentationRpcImpl
import { RulesetManager } from "../presentation-backend/RulesetManager";
import { RulesetVariablesManager } from "../presentation-backend/RulesetVariablesManager";

/* eslint-disable @typescript-eslint/no-deprecated -- PresentationRpcInterface methods are deprecated */

describe("PresentationRpcImpl", () => {
beforeEach(() => {
sinon.stub(RpcTrace, "expectCurrentActivity").get(() => {
Expand Down Expand Up @@ -553,9 +555,9 @@ describe("PresentationRpcImpl", () => {

describe("getPagedNodes", () => {
it("calls manager for root nodes", async () => {
// eslint-disable-next-line @typescript-eslint/no-deprecated

const getRootNodesResult: HierarchyLevelJSON = {
// eslint-disable-next-line @typescript-eslint/no-deprecated

nodes: [createTestNode(), createTestNode(), createTestNode()].map(Node.toJSON),
supportsFiltering: true,
};
Expand Down Expand Up @@ -593,9 +595,9 @@ describe("PresentationRpcImpl", () => {
});

it("calls manager for child nodes", async () => {
// eslint-disable-next-line @typescript-eslint/no-deprecated

const getChildNodesResult: HierarchyLevelJSON = {
// eslint-disable-next-line @typescript-eslint/no-deprecated

nodes: [createTestNode(), createTestNode(), createTestNode()].map(Node.toJSON),
supportsFiltering: true,
};
Expand Down Expand Up @@ -774,7 +776,7 @@ describe("PresentationRpcImpl", () => {
presentationManagerMock.setup((x) => x.getDetail()).returns(() => presentationManagerDetailStub as unknown as PresentationManagerDetail);
const actualResult = await impl.getFilteredNodePaths(testData.imodelToken, rpcOptions);
presentationManagerMock.verifyAll();
// eslint-disable-next-line @typescript-eslint/no-deprecated

expect(actualResult.result).to.deep.equal(result.map(NodePathElement.toJSON));
});
});
Expand Down Expand Up @@ -802,7 +804,7 @@ describe("PresentationRpcImpl", () => {
presentationManagerMock.setup((x) => x.getDetail()).returns(() => presentationManagerDetailStub as unknown as PresentationManagerDetail);
const actualResult = await impl.getNodePaths(testData.imodelToken, rpcOptions);
presentationManagerMock.verifyAll();
// eslint-disable-next-line @typescript-eslint/no-deprecated

expect(actualResult.result).to.deep.equal(result.map(NodePathElement.toJSON));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,38 +197,45 @@ export class PresentationRpcInterface extends RpcInterface {
NOTE: Please consult the README in core/common/src/rpc for the semantic versioning rules.
===========================================================================================*/

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getNodesCount(_token: IModelRpcProps, _options: HierarchyRpcRequestOptions): PresentationRpcResponse<number> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
// eslint-disable-next-line @typescript-eslint/no-deprecated
public async getPagedNodes(_token: IModelRpcProps, _options: Paged<HierarchyRpcRequestOptions>): PresentationRpcResponse<PagedResponse<NodeJSON>> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getNodesDescriptor(
_token: IModelRpcProps,
_options: HierarchyLevelDescriptorRpcRequestOptions,
): PresentationRpcResponse<string | DescriptorJSON | undefined> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
// TODO: add paged version of this (#387280)
// eslint-disable-next-line @typescript-eslint/no-deprecated
public async getNodePaths(_token: IModelRpcProps, _options: FilterByInstancePathsHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElementJSON[]> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
// TODO: add paged version of this (#387280)
// eslint-disable-next-line @typescript-eslint/no-deprecated
public async getFilteredNodePaths(_token: IModelRpcProps, _options: FilterByTextHierarchyRpcRequestOptions): PresentationRpcResponse<NodePathElementJSON[]> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getContentSources(_token: IModelRpcProps, _options: ContentSourcesRpcRequestOptions): PresentationRpcResponse<ContentSourcesRpcResult> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getContentDescriptor(_token: IModelRpcProps, _options: ContentDescriptorRpcRequestOptions): PresentationRpcResponse<DescriptorJSON | undefined> {
arguments[1] = { ...arguments[1], transport: "unparsed-json" };
const response: PresentationRpcResponseData<DescriptorJSON | string | undefined> = await this.forward(arguments);
Expand All @@ -238,28 +245,33 @@ export class PresentationRpcInterface extends RpcInterface {
return response as PresentationRpcResponseData<DescriptorJSON | undefined>;
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getContentSetSize(_token: IModelRpcProps, _options: ContentRpcRequestOptions): PresentationRpcResponse<number> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getPagedContent(
_token: IModelRpcProps,
_options: Paged<ContentRpcRequestOptions>,
): PresentationRpcResponse<{ descriptor: DescriptorJSON; contentSet: PagedResponse<ItemJSON> } | undefined> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getPagedContentSet(_token: IModelRpcProps, _options: Paged<ContentRpcRequestOptions>): PresentationRpcResponse<PagedResponse<ItemJSON>> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getElementProperties(
_token: IModelRpcProps,
_options: SingleElementPropertiesRpcRequestOptions,
): PresentationRpcResponse<ElementProperties | undefined> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getPagedDistinctValues(
_token: IModelRpcProps,
_options: DistinctValuesRpcRequestOptions,
Expand All @@ -268,24 +280,28 @@ export class PresentationRpcInterface extends RpcInterface {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getContentInstanceKeys(
_token: IModelRpcProps,
_options: ContentInstanceKeysRpcRequestOptions,
): PresentationRpcResponse<{ total: number; items: KeySetJSON }> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getDisplayLabelDefinition(_token: IModelRpcProps, _options: DisplayLabelRpcRequestOptions): PresentationRpcResponse<LabelDefinition> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getPagedDisplayLabelDefinitions(
_token: IModelRpcProps,
_options: DisplayLabelsRpcRequestOptions,
): PresentationRpcResponse<PagedResponse<LabelDefinition>> {
return this.forward(arguments);
}

/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async getSelectionScopes(_token: IModelRpcProps, _options: SelectionScopeRpcRequestOptions): PresentationRpcResponse<SelectionScope[]> {
return this.forward(arguments);
}
Expand All @@ -297,7 +313,9 @@ export class PresentationRpcInterface extends RpcInterface {
_ids: Id64String[],
_scopeId: string,
): PresentationRpcResponse<KeySetJSON>;
/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async computeSelection(_token: IModelRpcProps, _options: ComputeSelectionRpcRequestOptions): PresentationRpcResponse<KeySetJSON>;
/** @deprecated in 4.10. Use [PresentationManager]($presentation-frontend) instead of calling the RPC interface directly. */
public async computeSelection(
_token: IModelRpcProps,
_options: ComputeSelectionRpcRequestOptions | SelectionScopeRpcRequestOptions,
Expand Down
11 changes: 11 additions & 0 deletions presentation/common/src/presentation-common/RpcRequestsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export class RpcRequestsHandler {
}

public async getNodesCount(options: HierarchyRequestOptions<IModelRpcProps, NodeKey, RulesetVariableJSON> & ClientDiagnosticsAttribute): Promise<number> {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return this.request<number, typeof options>(this.rpcClient.getNodesCount.bind(this.rpcClient), options);
}

Expand All @@ -157,6 +158,7 @@ export class RpcRequestsHandler {
public async getNodesDescriptor(
options: HierarchyLevelDescriptorRequestOptions<IModelRpcProps, NodeKey, RulesetVariableJSON> & ClientDiagnosticsAttribute,
): Promise<DescriptorJSON | undefined> {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const response = await this.request<string | DescriptorJSON | undefined, typeof options>(this.rpcClient.getNodesDescriptor.bind(this.rpcClient), options);
if (typeof response === "string") {
return JSON.parse(response);
Expand All @@ -181,29 +183,34 @@ export class RpcRequestsHandler {
}

public async getContentSources(options: ContentSourcesRequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute): Promise<ContentSourcesRpcResult> {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return this.request<ContentSourcesRpcResult, typeof options>(this.rpcClient.getContentSources.bind(this.rpcClient), options);
}
public async getContentDescriptor(
options: ContentDescriptorRequestOptions<IModelRpcProps, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute,
): Promise<DescriptorJSON | undefined> {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return this.request<DescriptorJSON | undefined, typeof options>(this.rpcClient.getContentDescriptor.bind(this.rpcClient), options);
}
public async getContentSetSize(
options: ContentRequestOptions<IModelRpcProps, DescriptorOverrides, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute,
): Promise<number> {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return this.request<number, typeof options>(this.rpcClient.getContentSetSize.bind(this.rpcClient), options);
}
public async getPagedContent(
options: Paged<ContentRequestOptions<IModelRpcProps, DescriptorOverrides, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute>,
) {
return this.request<{ descriptor: DescriptorJSON; contentSet: PagedResponse<ItemJSON> } | undefined, typeof options>(
// eslint-disable-next-line @typescript-eslint/no-deprecated
this.rpcClient.getPagedContent.bind(this.rpcClient),
options,
);
}
public async getPagedContentSet(
options: Paged<ContentRequestOptions<IModelRpcProps, DescriptorOverrides, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute>,
) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return this.request<PagedResponse<ItemJSON>, typeof options>(this.rpcClient.getPagedContentSet.bind(this.rpcClient), options);
}

Expand All @@ -218,21 +225,25 @@ export class RpcRequestsHandler {
public async getContentInstanceKeys(
options: ContentInstanceKeysRequestOptions<IModelRpcProps, KeySetJSON, RulesetVariableJSON> & ClientDiagnosticsAttribute,
): Promise<{ total: number; items: KeySetJSON }> {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return this.request<{ total: number; items: KeySetJSON }, typeof options>(this.rpcClient.getContentInstanceKeys.bind(this.rpcClient), options);
}

public async getDisplayLabelDefinition(
options: DisplayLabelRequestOptions<IModelRpcProps, InstanceKey> & ClientDiagnosticsAttribute,
): Promise<LabelDefinition> {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return this.request<LabelDefinition, typeof options>(this.rpcClient.getDisplayLabelDefinition.bind(this.rpcClient), options);
}
public async getPagedDisplayLabelDefinitions(
options: DisplayLabelsRequestOptions<IModelRpcProps, InstanceKey> & ClientDiagnosticsAttribute,
): Promise<PagedResponse<LabelDefinition>> {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return this.request<PagedResponse<LabelDefinition>, typeof options>(this.rpcClient.getPagedDisplayLabelDefinitions.bind(this.rpcClient), options);
}

public async getSelectionScopes(options: SelectionScopeRequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute): Promise<SelectionScope[]> {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return this.request<SelectionScope[], typeof options>(this.rpcClient.getSelectionScopes.bind(this.rpcClient), options);
}
public async computeSelection(options: ComputeSelectionRequestOptions<IModelRpcProps> & ClientDiagnosticsAttribute): Promise<KeySetJSON> {
Expand Down
Loading

0 comments on commit ba8f252

Please sign in to comment.