Skip to content

Rename getProjectionStatistics to getProjectionStatus #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/projection-management.ts
Original file line number Diff line number Diff line change
@@ -264,7 +264,7 @@ describe("[sample] projection-management", () => {
const name = await createTestProjection();

// region GetStatus
const projection = await client.getProjectionStatistics(name);
const projection = await client.getProjectionStatus(name);

console.log(
projection.name,
54 changes: 54 additions & 0 deletions src/__test__/projections/getProjectionStatus.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { createTestNode } from "@test-utils";

import { EventStoreDBClient, UnknownError } from "@eventstore/db-client";

describe("getProjectionStatus", () => {
const node = createTestNode();
let client!: EventStoreDBClient;

const basicProjection = `
fromAll()
.when({
$init: function (state, ev) {
return {};
}
});
`;

const projections = ["projection-1", "projection-2", "projection-3"];

beforeAll(async () => {
await node.up();
client = new EventStoreDBClient(
{ endpoint: node.uri },
{ rootCertificate: node.rootCertificate },
{ username: "admin", password: "changeit" }
);

for (const name of projections) {
await client.createProjection(name, basicProjection);
}
});

afterAll(async () => {
await node.down();
});

describe("gets Projection Status", () => {
test("gets status", async () => {
const REQUESTED_NAME = projections[2];

const details = await client.getProjectionStatus(REQUESTED_NAME);

expect(details).toBeDefined();
expect(details.name).toBe(REQUESTED_NAME);
});

test("non-existant", async () => {
const REQUESTED_NAME = "some-non-existant-projection";
await expect(
client.getProjectionStatus(REQUESTED_NAME)
).rejects.toThrowError(UnknownError); // https://github.com/EventStore/EventStore/issues/2732
});
});
});
Original file line number Diff line number Diff line change
@@ -10,14 +10,30 @@ import {
convertGrpcProjectionDetails,
} from "../utils";

export interface GetProjectionStatisticsOptions extends BaseOptions {}
export interface GetProjectionStatusOptions extends BaseOptions {}

/**
* @deprecated Renamed to `GetProjectionStatusOptions`.
*/
export type GetProjectionStatisticsOptions = GetProjectionStatusOptions;

declare module "../Client" {
interface Client {
/**
* Gets the result of a projection.
* Gets the current status of a projection.
* @param projectionName The name of the projection.
* @param options Get status options.
*/
getProjectionStatus(
projectionName: string,
options?: GetProjectionStatusOptions
): Promise<ProjectionDetails>;

/**
* Gets the current status of a projection.
* @param projectionName The name of the projection.
* @param options Get state options.
* @param options Get statistics options.
* @deprecated Renamed to `getProjectionStatus`.
*/
getProjectionStatistics(
projectionName: string,
@@ -26,10 +42,10 @@ declare module "../Client" {
}
}

Client.prototype.getProjectionStatistics = async function (
Client.prototype.getProjectionStatus = async function (
this: Client,
projectionName: string,
baseOptions: GetProjectionStatisticsOptions = {}
baseOptions: GetProjectionStatusOptions = {}
): Promise<ProjectionDetails> {
const req = new StatisticsReq();
const options = new StatisticsReq.Options();
@@ -67,3 +83,5 @@ Client.prototype.getProjectionStatistics = async function (
}
);
};

Client.prototype.getProjectionStatistics = Client.prototype.getProjectionStatus;
2 changes: 1 addition & 1 deletion src/projections/index.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ export * from "./disableProjection";
export * from "./enableProjection";
export * from "./getProjectionResult";
export * from "./getProjectionState";
export * from "./getProjectionStatistics";
export * from "./getProjectionStatus";
export * from "./listProjections";
export * from "./resetProjection";
export * from "./restartSubsystem";