-
Notifications
You must be signed in to change notification settings - Fork 138
User metadata #1657
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
User metadata #1657
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7b3aa1c
init impl of user metadata
THardy98 2dab40d
add test, removed proxyActivities overloads instead added withSummari…
THardy98 6af2e2c
schedule metadata test, fix schedule action decode
THardy98 e0489cd
Merge branch 'main' into user-metadata
THardy98 031e295
test fix
THardy98 d496966
use supplied data converter
THardy98 1efb3f0
inline options, lazily decode summary/details on workflow description
THardy98 ebe745f
update proxyActivities comment to show runWithOptions usage
THardy98 2c8f922
Merge branch 'main' into user-metadata
THardy98 67d8e06
add runWithOptions for local activities
THardy98 c491683
allow for undefined userMetadata when scheduling activity
THardy98 60a1e08
move user metadata encoding/decoding to user-metadata.ts, add deepMer…
THardy98 3cfffa7
break circular dependency
THardy98 e56a117
add codec testing
THardy98 421e080
remove redundant 'fixed'
THardy98 f2bd7d3
lint.prune fix
THardy98 af1e8bb
Merge branch 'main' into user-metadata
THardy98 9243c3c
Merge branch 'main' into user-metadata
mjameswh a625f4a
address nits
THardy98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| export * from './enums-helpers'; | ||
| export * from './objects-helpers'; | ||
| export { | ||
| filterNullAndUndefined, | ||
| mergeObjects, | ||
| // ts-prune-ignore-next | ||
| deepMerge, | ||
| } from './objects-helpers'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { temporal } from '@temporalio/proto'; | ||
| import { convertOptionalToPayload, PayloadConverter } from './converter/payload-converter'; | ||
| import { LoadedDataConverter } from './converter/data-converter'; | ||
| import { decodeOptionalSinglePayload, encodeOptionalSingle } from './internal-non-workflow'; | ||
|
|
||
| /** | ||
| * User metadata that can be attached to workflow commands. | ||
| */ | ||
| export interface UserMetadata { | ||
| /** @experimental A fixed, single line summary of the command's purpose */ | ||
| staticSummary?: string; | ||
| /** @experimental Fixed additional details about the command for longer-text description, can span multiple lines */ | ||
| staticDetails?: string; | ||
| } | ||
|
|
||
| export function userMetadataToPayload( | ||
| payloadConverter: PayloadConverter, | ||
| staticSummary: string | undefined, | ||
| staticDetails: string | undefined | ||
| ): temporal.api.sdk.v1.IUserMetadata | undefined { | ||
| if (staticSummary == null && staticDetails == null) return undefined; | ||
|
|
||
| const summary = convertOptionalToPayload(payloadConverter, staticSummary); | ||
| const details = convertOptionalToPayload(payloadConverter, staticDetails); | ||
|
|
||
| if (summary == null && details == null) return undefined; | ||
|
|
||
| return { summary, details }; | ||
| } | ||
|
|
||
| export async function encodeUserMetadata( | ||
| dataConverter: LoadedDataConverter, | ||
| staticSummary: string | undefined, | ||
| staticDetails: string | undefined | ||
| ): Promise<temporal.api.sdk.v1.IUserMetadata | undefined> { | ||
| if (staticSummary == null && staticDetails == null) return undefined; | ||
|
|
||
| const { payloadConverter, payloadCodecs } = dataConverter; | ||
| const summary = await encodeOptionalSingle(payloadCodecs, convertOptionalToPayload(payloadConverter, staticSummary)); | ||
| const details = await encodeOptionalSingle(payloadCodecs, convertOptionalToPayload(payloadConverter, staticDetails)); | ||
|
|
||
| if (summary == null && details == null) return undefined; | ||
|
|
||
| return { summary, details }; | ||
| } | ||
|
|
||
| export async function decodeUserMetadata( | ||
| dataConverter: LoadedDataConverter, | ||
| metadata: temporal.api.sdk.v1.IUserMetadata | undefined | null | ||
| ): Promise<UserMetadata> { | ||
| const res = { staticSummary: undefined, staticDetails: undefined }; | ||
| if (metadata == null) return res; | ||
|
|
||
| const staticSummary = (await decodeOptionalSinglePayload<string>(dataConverter, metadata.summary)) ?? undefined; | ||
| const staticDetails = (await decodeOptionalSinglePayload<string>(dataConverter, metadata.details)) ?? undefined; | ||
|
|
||
| return { staticSummary, staticDetails }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.