Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions packages/azure-functions-durable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
],
"scripts": {
"clean": "node -e \"require('fs').rmSync('dist', {recursive:true, force:true})\"",
"prebuild": "node -p \"'// Auto-generated by prebuild\\nexport const SDK_VERSION = ' + JSON.stringify(require('./package.json').version) + ';\\nexport const SDK_PACKAGE_NAME = ' + JSON.stringify(require('./package.json').name) + ';'\" > src/version.ts",
"build:core": "npm run build -w @microsoft/durabletask-js",
"build": "npm run clean && npm run build:core && tsc -p tsconfig.build.json",
"pretest": "npm run prebuild",
"pretest:unit": "npm run prebuild",
"test": "jest --runInBand --detectOpenHandles",
"test:unit": "jest test/unit --runInBand --detectOpenHandles",
"prepublishOnly": "npm run build && npm run test"
Expand Down
10 changes: 9 additions & 1 deletion packages/azure-functions-durable/src/durable-grpc.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { SDK_PACKAGE_NAME, SDK_VERSION } from "./version";

export type DurableBindingMetadata = Record<string, unknown>;

export function addDurableGrpcMetadata<TBinding extends DurableBindingMetadata>(
binding: TBinding,
): TBinding & { durableRequiresGrpc: true } {
): TBinding & {
durableRequiresGrpc: true;
durableSdkName: string;
durableSdkVersion: string;
} {
return {
...binding,
durableRequiresGrpc: true,
durableSdkName: SDK_PACKAGE_NAME,
durableSdkVersion: SDK_VERSION,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

import { addDurableGrpcMetadata } from "../../src/durable-grpc";
import packageJson from "../../package.json";

describe("addDurableGrpcMetadata", () => {
it("adds durableRequiresGrpc without mutating the original binding", () => {
Expand All @@ -13,6 +14,8 @@ describe("addDurableGrpcMetadata", () => {
type: "orchestrationTrigger",
name: "context",
durableRequiresGrpc: true,
durableSdkName: packageJson.name,
durableSdkVersion: packageJson.version,
});
expect(binding).toEqual({ type: "orchestrationTrigger", name: "context" });
});
Expand Down
Loading