Skip to content

Commit

Permalink
deprecate PresentationRpcInterface (#7319)
Browse files Browse the repository at this point in the history
Co-authored-by: Grigas <35135765+grigasp@users.noreply.github.com>
(cherry picked from commit 0990a56)

# Conflicts:
#	docs/changehistory/NextVersion.md
  • Loading branch information
paulius-valiunas authored and mergify[bot] committed Nov 7, 2024
1 parent f11ea22 commit bfd03d8
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 24 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"
}
21 changes: 21 additions & 0 deletions docs/changehistory/NextVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,24 @@ publish: false
---
# NextVersion

<<<<<<< HEAD
=======
Table of contents:

- [API deprecations](#api-deprecations)
- [@itwin/presentation-common](#itwinpresentation-common)
- [Breaking Changes](#breaking-changes)
- [Opening connection to local snapshot requires IPC](#opening-connection-to-local-snapshot-requires-ipc)

## API deprecations

### @itwin/presentation-common

- All public methods of [PresentationRpcInterface]($presentation-common) have been deprecated. Going forward, RPC interfaces should not be called directly. Public wrappers such as [PresentationManager]($presentation-frontend) should be used instead.

## Breaking Changes

### Opening connection to local snapshot requires IPC

[SnapshotConnection.openFile]($frontend) now requires applications to have set up a valid IPC communication. If you're using this API in an Electron or Mobile application, no additional action is needed as long as you call `ElectronHost.startup` or `MobileHost.startup` respectively. This API shouldn't be used in Web applications, so it has no replacement there.
>>>>>>> 0990a56c24 (deprecate PresentationRpcInterface (#7319))
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
Loading

0 comments on commit bfd03d8

Please sign in to comment.