Skip to content

Commit 48d4a82

Browse files
committed
address PR feedback: typed errors, move request model, add LICENSE, cleanup comments
1 parent 6cc743c commit 48d4a82

8 files changed

Lines changed: 60 additions & 38 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

packages/durabletask-js-export-history/src/activities/export-instance-history-activity.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { gzipSync } from "zlib";
66
import { BlobServiceClient } from "@azure/storage-blob";
77
import { ActivityContext, HistoryEvent, OrchestrationStatus, TaskHubGrpcClient } from "@microsoft/durabletask-js";
88
import { ExportDestination, ExportFormat, ExportFormatKind, ExportHistoryStorageOptions } from "../models";
9+
import { ExportJobClientValidationError } from "../errors";
910

1011
/**
1112
* Export request for one orchestration instance.
@@ -117,16 +118,16 @@ export function createExportInstanceHistoryActivity(
117118
input: ExportRequest,
118119
): Promise<ExportResult> {
119120
if (!input) {
120-
throw new Error("input is required");
121+
throw new ExportJobClientValidationError("input is required", "input");
121122
}
122123
if (!input.instanceId) {
123-
throw new Error("instanceId is required");
124+
throw new ExportJobClientValidationError("instanceId is required", "instanceId");
124125
}
125126
if (!input.destination) {
126-
throw new Error("destination is required");
127+
throw new ExportJobClientValidationError("destination is required", "destination");
127128
}
128129
if (!input.format) {
129-
throw new Error("format is required");
130+
throw new ExportJobClientValidationError("format is required", "format");
130131
}
131132

132133
const instanceId = input.instanceId;

packages/durabletask-js-export-history/src/activities/list-terminal-instances-activity.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { ActivityContext, OrchestrationStatus, TaskHubGrpcClient } from "@microsoft/durabletask-js";
55
import { ExportCheckpoint } from "../models";
6+
import { ExportJobClientValidationError } from "../errors";
67

78
/**
89
* Input for listing terminal instances activity.
@@ -62,7 +63,7 @@ export function createListTerminalInstancesActivity(client: TaskHubGrpcClient) {
6263
input: ListTerminalInstancesRequest,
6364
): Promise<InstancePage> {
6465
if (!input) {
65-
throw new Error("input is required");
66+
throw new ExportJobClientValidationError("input is required", "input");
6667
}
6768

6869
// Dates arrive as ISO strings after JSON round-tripping through orchestration input.

packages/durabletask-js-export-history/src/client/export-history-client.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
ExportJobState,
1818
ExportDestination,
1919
ExportHistoryStorageOptions,
20+
ExportJobOperationRequest,
2021
DEFAULT_EXPORT_JOB_QUERY_PAGE_SIZE,
2122
} from "../models";
2223
import {
@@ -25,7 +26,6 @@ import {
2526
getOrchestratorInstanceId,
2627
} from "../constants";
2728
import { ExportJobNotFoundError } from "../errors";
28-
import { ExportJobOperationRequest } from "../orchestrators/execute-export-job-operation-orchestrator";
2929

3030
/**
3131
* Client for managing export history jobs.
@@ -188,9 +188,6 @@ export class ExportHistoryJobClient {
188188
`Failed to create export job '${this.jobId}': ${state?.failureDetails?.message ?? "Unknown error"}`,
189189
);
190190
}
191-
192-
// The entity's Create operation signals Run, which schedules the export orchestrator.
193-
// No need to schedule the orchestrator from the client.
194191
}
195192

196193
/**

packages/durabletask-js-export-history/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export {
2626
ExportJobStatus,
2727
isValidTransition,
2828
ExportMode,
29+
ExportJobOperationRequest,
2930
} from "./models";
3031

3132
// Entity
@@ -45,10 +46,7 @@ export {
4546

4647
// Orchestrators
4748
export { exportJobOrchestrator } from "./orchestrators/export-job-orchestrator";
48-
export {
49-
executeExportJobOperationOrchestrator,
50-
ExportJobOperationRequest,
51-
} from "./orchestrators/execute-export-job-operation-orchestrator";
49+
export { executeExportJobOperationOrchestrator } from "./orchestrators/execute-export-job-operation-orchestrator";
5250

5351
// Client
5452
export { ExportHistoryClient, ExportHistoryJobClient } from "./client/export-history-client";
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
/**
5+
* Request to execute an operation on an ExportJob entity via orchestration.
6+
*
7+
* Note: `entityId` is serialized as a string (e.g. "@exportjob@my-key") rather than
8+
* an EntityInstanceId object to ensure it survives JSON round-tripping through
9+
* orchestration input serialization.
10+
*/
11+
export interface ExportJobOperationRequest {
12+
/**
13+
* The entity instance ID in string form (e.g. "@exportjob@my-key").
14+
* Use EntityInstanceId.toString() to produce this value.
15+
*/
16+
readonly entityId: string;
17+
18+
/**
19+
* The operation name to invoke on the entity.
20+
*/
21+
readonly operationName: string;
22+
23+
/**
24+
* Optional input for the operation.
25+
*/
26+
readonly input?: unknown;
27+
}

packages/durabletask-js-export-history/src/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ export { ExportJobState, createInitialExportJobState } from "./export-job-state"
2323
export { ExportJobStatus } from "./export-job-status";
2424
export { isValidTransition } from "./export-job-transitions";
2525
export { ExportMode } from "./export-mode";
26+
export { ExportJobOperationRequest } from "./export-job-operation-request";

packages/durabletask-js-export-history/src/orchestrators/execute-export-job-operation-orchestrator.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,7 @@
22
// Licensed under the MIT License.
33

44
import { OrchestrationContext, TOrchestrator, EntityInstanceId } from "@microsoft/durabletask-js";
5-
6-
/**
7-
* Request to execute an operation on an ExportJob entity via orchestration.
8-
*
9-
* Note: `entityId` is serialized as a string (e.g. "@exportjob@my-key") rather than
10-
* an EntityInstanceId object to ensure it survives JSON round-tripping through
11-
* orchestration input serialization.
12-
*/
13-
export interface ExportJobOperationRequest {
14-
/**
15-
* The entity instance ID in string form (e.g. "@exportjob@my-key").
16-
* Use EntityInstanceId.toString() to produce this value.
17-
*/
18-
readonly entityId: string;
19-
20-
/**
21-
* The operation name to invoke on the entity.
22-
*/
23-
readonly operationName: string;
24-
25-
/**
26-
* Optional input for the operation.
27-
*/
28-
readonly input?: unknown;
29-
}
5+
import { ExportJobOperationRequest } from "../models";
306

317
/**
328
* A simple orchestrator that routes an operation to the export job entity.

0 commit comments

Comments
 (0)