Azure / azure-functions-durable-js

JavaScript library for using the Durable Functions bindings
https://www.npmjs.com/package/durable-functions
MIT License
128 stars 46 forks source link

Switch to using an options object for all applicable APIs #482

Closed hossam-nasr closed 1 year ago

hossam-nasr commented 1 year ago

Resolves #441. Switch from using concrete optional arguments to an options object where applicable.

I've broken this PR into small steps in commits to aid with PR review.

APIs changed in this PR (notice this list is slightly different than the one in the issue):

In DurableOrchestrationClient:

Before After
```TS getStatus( instanceId: string, showHistory?: boolean, showHistoryOutput?: boolean, showInput?: boolean ): Promise ``` ```TS getStatus( instanceId: string, options?: GetStatusOptions ): Promise ```
```TS getStatusBy( createdTimeFrom: Date | undefined, createdTimeTo: Date | undefined, runtimeStatus: OrchestrationRuntimeStatus[] ): Promise ``` ```TS getStatusBy( options: SelectionOptions ): Promise ```
```TS purgeInstanceHistoryBy( createdTimeFrom: Date, createdTimeTo?: Date, runtimeStatus?: OrchestrationRuntimeStatus[] ): Promise ``` ```TS purgeInstanceHistoryBy( options: SelectionOptions ): Promise ```
```TS raiseEvent( instanceId: string, eventName: string, eventData: unknown, taskHubName?: string, connectionName?: string ): Promise ``` ```TS raiseEvent(options: RaiseEventOptions): Promise ```
```TS readEntityState( entityId: EntityId, taskHubName?: string, connectionName?: string ): Promise> ``` ```TS readEntityState( entityId: EntityId, options?: TaskHubOptions ): Promise> ```
```TS rewind( instanceId: string, reason: string, taskHubName?: string, connectionName?: string ): Promise` ``` ```TS rewind( instanceId: string, reason: string, options?: TaskHubOptions ): Promise ```
```TS signalEntity( entityId: EntityId, operationName?: string, operationContent?: unknown, taskHubName?: string, connectionName?: string ): Promise ``` ```TS signalEntity( entityId: EntityId, options?: SignalEntityContext ): Promise ```
```TS waitForCompletionOrCreateCheckStatusResponse( request: HttpRequest, instanceId: string, timeoutInMilliseconds?: number, retryIntervalInMilliseconds?: number ): Promise; ``` ```TS waitForCompletionOrCreateCheckStatusResponse( request: HttpRequest, instanceId: string, waitOptions?: WaitForCompletionOptions ): Promise; ```

In DurableOrchestrationContext:

Before After
```TS callSubOrchestrator( name: string, input?: unknown, instanceId?: string ): Task ``` ```TS // This is effectively equivalent // to the startNew() change callSubOrchestrator( name: string, options?: CallSubOrchestratorOptions ): Task ```
```TS callSubOrchestratorWithRetry( name: string, retryOptions: RetryOptions, input?: unknown, instanceId?: string ): Task ``` ```TS callSubOrchestratorWithRetry( name: string, retryOptions: RetryOptions, options?: CallSubOrchestratorOptions ): Task ```