@temporalio/common
Advanced tools
Comparing version 1.7.2 to 1.7.3
@@ -9,3 +9,3 @@ export declare const METADATA_ENCODING_KEY = "encoding"; | ||
}; | ||
export declare type EncodingType = typeof encodingTypes[keyof typeof encodingTypes]; | ||
export type EncodingType = (typeof encodingTypes)[keyof typeof encodingTypes]; | ||
export declare const encodingKeys: { | ||
@@ -12,0 +12,0 @@ readonly METADATA_ENCODING_NULL: Uint8Array; |
import type { temporal } from '@temporalio/proto'; | ||
export declare const FAILURE_SOURCE = "TypeScriptSDK"; | ||
export declare type ProtoFailure = temporal.api.failure.v1.IFailure; | ||
export type ProtoFailure = temporal.api.failure.v1.IFailure; | ||
export declare enum TimeoutType { | ||
@@ -21,3 +21,3 @@ TIMEOUT_TYPE_UNSPECIFIED = 0, | ||
} | ||
export declare type WorkflowExecution = temporal.api.common.v1.IWorkflowExecution; | ||
export type WorkflowExecution = temporal.api.common.v1.IWorkflowExecution; | ||
/** | ||
@@ -24,0 +24,0 @@ * Represents failures that can cross Workflow and Activity boundaries. |
@@ -8,5 +8,5 @@ import { AnyFunc, OmitLastParam } from './type-helpers'; | ||
*/ | ||
export declare type Next<IF, FN extends keyof IF> = Required<IF>[FN] extends AnyFunc ? OmitLastParam<Required<IF>[FN]> : never; | ||
export type Next<IF, FN extends keyof IF> = Required<IF>[FN] extends AnyFunc ? OmitLastParam<Required<IF>[FN]> : never; | ||
/** Headers are just a mapping of header name to Payload */ | ||
export declare type Headers = Record<string, Payload>; | ||
export type Headers = Record<string, Payload>; | ||
/** | ||
@@ -13,0 +13,0 @@ * Composes all interceptor methods into a single function |
import type { temporal } from '@temporalio/proto'; | ||
export declare type Payload = temporal.api.common.v1.IPayload; | ||
export type Payload = temporal.api.common.v1.IPayload; | ||
/** Type that can be returned from a Workflow `execute` function */ | ||
export declare type WorkflowReturnType = Promise<any>; | ||
export declare type WorkflowSignalType = (...args: any[]) => Promise<void> | void; | ||
export declare type WorkflowQueryType = (...args: any[]) => any; | ||
export type WorkflowReturnType = Promise<any>; | ||
export type WorkflowSignalType = (...args: any[]) => Promise<void> | void; | ||
export type WorkflowQueryType = (...args: any[]) => any; | ||
/** | ||
@@ -13,3 +13,3 @@ * Broad Workflow function definition, specific Workflows will typically use a narrower type definition, e.g: | ||
*/ | ||
export declare type Workflow = (...args: any[]) => WorkflowReturnType; | ||
export type Workflow = (...args: any[]) => WorkflowReturnType; | ||
declare const argsBrand: unique symbol; | ||
@@ -53,3 +53,3 @@ /** | ||
/** Get the "unwrapped" return type (without Promise) of the execute handler from Workflow type `W` */ | ||
export declare type WorkflowResultType<W extends Workflow> = ReturnType<W> extends Promise<infer R> ? R : never; | ||
export type WorkflowResultType<W extends Workflow> = ReturnType<W> extends Promise<infer R> ? R : never; | ||
/** | ||
@@ -60,4 +60,4 @@ * If another SDK creates a Search Attribute that's not an array, we wrap it in an array. | ||
*/ | ||
export declare type SearchAttributes = Record<string, SearchAttributeValue | Readonly<SearchAttributeValue> | undefined>; | ||
export declare type SearchAttributeValue = string[] | number[] | boolean[] | Date[]; | ||
export type SearchAttributes = Record<string, SearchAttributeValue | Readonly<SearchAttributeValue> | undefined>; | ||
export type SearchAttributeValue = string[] | number[] | boolean[] | Date[]; | ||
export interface ActivityFunction<P extends any[] = any[], R = any> { | ||
@@ -70,7 +70,7 @@ (...args: P): Promise<R>; | ||
*/ | ||
export declare type ActivityInterface = Record<string, ActivityFunction>; | ||
export type ActivityInterface = Record<string, ActivityFunction>; | ||
/** | ||
* Mapping of Activity name to function | ||
*/ | ||
export declare type UntypedActivities = Record<string, ActivityFunction>; | ||
export type UntypedActivities = Record<string, ActivityFunction>; | ||
/** | ||
@@ -77,0 +77,0 @@ * A workflow's history and ID. Useful for replay. |
@@ -10,9 +10,9 @@ import type { Payload } from '../interfaces'; | ||
/** Replace `Payload`s with `EncodedPayload`s */ | ||
export declare type Encoded<T> = ReplaceNested<T, Payload, EncodedPayload>; | ||
export type Encoded<T> = ReplaceNested<T, Payload, EncodedPayload>; | ||
/** Replace `Payload`s with `DecodedPayload`s */ | ||
export declare type Decoded<T> = ReplaceNested<T, Payload, DecodedPayload>; | ||
export declare type EncodedProtoFailure = Encoded<ProtoFailure>; | ||
export declare type DecodedProtoFailure = Decoded<ProtoFailure>; | ||
export type Decoded<T> = ReplaceNested<T, Payload, DecodedPayload>; | ||
export type EncodedProtoFailure = Encoded<ProtoFailure>; | ||
export type DecodedProtoFailure = Decoded<ProtoFailure>; | ||
/** An object T with any nested values of type ToReplace replaced with ReplaceWith */ | ||
export declare type ReplaceNested<T, ToReplace, ReplaceWith> = T extends (...args: any[]) => any ? T : [keyof T] extends [never] ? T : T extends { | ||
export type ReplaceNested<T, ToReplace, ReplaceWith> = T extends (...args: any[]) => any ? T : [keyof T] extends [never] ? T : T extends { | ||
[k: string]: ToReplace; | ||
@@ -19,0 +19,0 @@ } ? { |
@@ -28,3 +28,3 @@ /// <reference types="node" /> | ||
*/ | ||
export declare type TLSConfigOption = TLSConfig | boolean | null; | ||
export type TLSConfigOption = TLSConfig | boolean | null; | ||
/** | ||
@@ -31,0 +31,0 @@ * Normalize {@link TLSConfigOption} by turning false and null to undefined and true to and empty object |
import * as proto from '@temporalio/proto'; | ||
export declare type History = proto.temporal.api.history.v1.IHistory; | ||
export declare type Payload = proto.temporal.api.common.v1.IPayload; | ||
export type History = proto.temporal.api.history.v1.IHistory; | ||
export type Payload = proto.temporal.api.common.v1.IPayload; | ||
/** | ||
@@ -5,0 +5,0 @@ * Convert a proto JSON representation of History to a valid History object |
@@ -39,5 +39,25 @@ "use strict"; | ||
return (obj[attr] && { | ||
[attr]: `${prefix}_${pascalCaseToConstantCase(obj[attr])}`, | ||
[attr]: obj[attr].startsWith(prefix) ? obj[attr] : `${prefix}_${pascalCaseToConstantCase(obj[attr])}`, | ||
}); | ||
} | ||
// fromProto3JSON doesn't allow null values on 'bytes' fields. This turns out to be a problem for payloads. | ||
// Recursively descend on objects and array, and fix in-place any payload that has a null data field | ||
function fixPayloads(e) { | ||
function isPayload(p) { | ||
return p && typeof p === 'object' && 'metadata' in p && 'data' in p; | ||
} | ||
if (e && typeof e === 'object') { | ||
if (isPayload(e)) { | ||
if (e.data === null) { | ||
const { data: _data, ...rest } = e; | ||
return rest; | ||
} | ||
return e; | ||
} | ||
if (Array.isArray(e)) | ||
return e.map(fixPayloads); | ||
return Object.fromEntries(Object.entries(e).map(([k, v]) => [k, fixPayloads(v)])); | ||
} | ||
return e; | ||
} | ||
function fixHistoryEvent(e) { | ||
@@ -48,2 +68,4 @@ const type = Object.keys(e).find((k) => k.endsWith('EventAttributes')); | ||
} | ||
// Fix payloads with null data | ||
e = fixPayloads(e); | ||
return { | ||
@@ -50,0 +72,0 @@ ...e, |
import type { google } from '@temporalio/proto'; | ||
export declare type Timestamp = google.protobuf.ITimestamp; | ||
export type Timestamp = google.protobuf.ITimestamp; | ||
/** | ||
@@ -4,0 +4,0 @@ * Lossy conversion function from Timestamp to number due to possible overflow. |
/** Shorthand alias */ | ||
export declare type AnyFunc = (...args: any[]) => any; | ||
export type AnyFunc = (...args: any[]) => any; | ||
/** A tuple without its last element */ | ||
export declare type OmitLast<T> = T extends [...infer REST, any] ? REST : never; | ||
export type OmitLast<T> = T extends [...infer REST, any] ? REST : never; | ||
/** F with all arguments but the last */ | ||
export declare type OmitLastParam<F extends AnyFunc> = (...args: OmitLast<Parameters<F>>) => ReturnType<F>; | ||
export type OmitLastParam<F extends AnyFunc> = (...args: OmitLast<Parameters<F>>) => ReturnType<F>; | ||
/** Verify that an type _Copy extends _Orig */ | ||
export declare function checkExtends<_Orig, _Copy extends _Orig>(): void; | ||
export declare type Replace<Base, New> = Omit<Base, keyof New> & New; | ||
export type Replace<Base, New> = Omit<Base, keyof New> & New; | ||
export declare function isRecord(value: unknown): value is Record<string, unknown>; | ||
@@ -11,0 +11,0 @@ export declare function hasOwnProperty<X extends Record<string, unknown>, Y extends PropertyKey>(record: X, prop: Y): record is X & Record<Y, unknown>; |
@@ -76,3 +76,3 @@ import type { google } from '@temporalio/proto'; | ||
} | ||
export declare type WithWorkflowArgs<W extends Workflow, T> = T & (Parameters<W> extends [any, ...any[]] ? { | ||
export type WithWorkflowArgs<W extends Workflow, T> = T & (Parameters<W> extends [any, ...any[]] ? { | ||
/** | ||
@@ -113,4 +113,4 @@ * Arguments to pass to the Workflow | ||
} | ||
export declare type CommonWorkflowOptions = BaseWorkflowOptions & WorkflowDurationOptions; | ||
export declare type WithCompiledWorkflowOptions<T extends CommonWorkflowOptions> = Replace<T, { | ||
export type CommonWorkflowOptions = BaseWorkflowOptions & WorkflowDurationOptions; | ||
export type WithCompiledWorkflowOptions<T extends CommonWorkflowOptions> = Replace<T, { | ||
workflowExecutionTimeout?: google.protobuf.IDuration; | ||
@@ -117,0 +117,0 @@ workflowRunTimeout?: google.protobuf.IDuration; |
{ | ||
"name": "@temporalio/common", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"description": "Common library for code that's used across the Client, Worker, and/or Workflow", | ||
@@ -15,4 +15,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@opentelemetry/api": "^1.3.0", | ||
"@temporalio/proto": "1.7.2", | ||
"@opentelemetry/api": "^1.4.1", | ||
"@temporalio/proto": "1.7.3", | ||
"long": "^5.2.0", | ||
@@ -39,3 +39,3 @@ "ms": "^2.1.3", | ||
], | ||
"gitHead": "779561124eecdec8396e658c0a1305d343dfaff7" | ||
"gitHead": "c78237bad40342b97a0aaec97ef01763b39a04f8" | ||
} |
@@ -11,3 +11,3 @@ import { encode } from '../encoding'; | ||
} as const; | ||
export type EncodingType = typeof encodingTypes[keyof typeof encodingTypes]; | ||
export type EncodingType = (typeof encodingTypes)[keyof typeof encodingTypes]; | ||
@@ -14,0 +14,0 @@ export const encodingKeys = { |
@@ -20,3 +20,3 @@ import { fromProto3JSON, toProto3JSON } from 'proto3-json-serializer'; | ||
obj[attr] && { | ||
[attr]: `${prefix}_${pascalCaseToConstantCase(obj[attr])}`, | ||
[attr]: obj[attr].startsWith(prefix) ? obj[attr] : `${prefix}_${pascalCaseToConstantCase(obj[attr])}`, | ||
} | ||
@@ -26,2 +26,23 @@ ); | ||
// fromProto3JSON doesn't allow null values on 'bytes' fields. This turns out to be a problem for payloads. | ||
// Recursively descend on objects and array, and fix in-place any payload that has a null data field | ||
function fixPayloads<T>(e: T): T { | ||
function isPayload(p: any): p is JSONPayload { | ||
return p && typeof p === 'object' && 'metadata' in p && 'data' in p; | ||
} | ||
if (e && typeof e === 'object') { | ||
if (isPayload(e)) { | ||
if (e.data === null) { | ||
const { data: _data, ...rest } = e; | ||
return rest as T; | ||
} | ||
return e; | ||
} | ||
if (Array.isArray(e)) return e.map(fixPayloads) as T; | ||
return Object.fromEntries(Object.entries(e as object).map(([k, v]) => [k, fixPayloads(v)])) as T; | ||
} | ||
return e; | ||
} | ||
function fixHistoryEvent(e: Record<string, any>) { | ||
@@ -33,2 +54,5 @@ const type = Object.keys(e).find((k) => k.endsWith('EventAttributes')); | ||
// Fix payloads with null data | ||
e = fixPayloads(e); | ||
return { | ||
@@ -35,0 +59,0 @@ ...e, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
351334
6890
+ Added@temporalio/proto@1.7.3(transitive)
- Removed@temporalio/proto@1.7.2(transitive)
Updated@opentelemetry/api@^1.4.1
Updated@temporalio/proto@1.7.3