@temporalio/client
Advanced tools
Comparing version 1.5.2 to 1.6.0
@@ -0,1 +1,2 @@ | ||
import { Workflow } from '@temporalio/common'; | ||
import { Headers } from '@temporalio/common/lib/interceptors'; | ||
@@ -5,3 +6,3 @@ import { temporal } from '@temporalio/proto'; | ||
import { WorkflowService } from './types'; | ||
import { Backfill, CompiledScheduleUpdateOptions, ScheduleSummary, ScheduleDescription, ScheduleOptions, ScheduleOverlapPolicy, ScheduleUpdateOptions } from './schedule-types'; | ||
import { Backfill, CompiledScheduleUpdateOptions, ScheduleSummary, ScheduleDescription, ScheduleOptions, ScheduleOverlapPolicy, ScheduleUpdateOptions, ScheduleOptionsStartWorkflowAction } from './schedule-types'; | ||
import { BaseClient, BaseClientOptions, LoadedWithDefaults } from './base-client'; | ||
@@ -29,3 +30,3 @@ /** | ||
*/ | ||
update(updateFn: (previous: ScheduleDescription) => ScheduleUpdateOptions): Promise<void>; | ||
update<W extends Workflow = Workflow>(updateFn: (previous: ScheduleDescription) => ScheduleUpdateOptions<ScheduleOptionsStartWorkflowAction<W>>): Promise<void>; | ||
/** | ||
@@ -104,3 +105,3 @@ * Delete the Schedule | ||
*/ | ||
create(options: ScheduleOptions): Promise<ScheduleHandle>; | ||
create<W extends Workflow = Workflow>(options: ScheduleOptions<ScheduleOptionsStartWorkflowAction<W>>): Promise<ScheduleHandle>; | ||
/** | ||
@@ -107,0 +108,0 @@ * Create a new Schedule. |
@@ -25,5 +25,2 @@ "use strict"; | ||
} | ||
if (!(opts.spec.calendars?.length || opts.spec.intervals?.length || opts.spec.cronExpressions?.length)) { | ||
throw new TypeError(`At least one ${structureName}.spec.calendars, .intervals or .cronExpressions is required`); | ||
} | ||
switch (opts.action.type) { | ||
@@ -64,8 +61,2 @@ case 'startWorkflow': | ||
} | ||
/** | ||
* Create a new Schedule. | ||
* | ||
* @throws {@link ScheduleAlreadyRunning} if there's a running (not deleted) Schedule with the given `id` | ||
* @returns a ScheduleHandle to the created Schedule | ||
*/ | ||
async create(options) { | ||
@@ -227,10 +218,8 @@ await this._createSchedule(options); | ||
for (const raw of response.schedules ?? []) { | ||
if (!raw.info?.spec) | ||
continue; | ||
yield { | ||
scheduleId: raw.scheduleId, | ||
spec: (0, schedule_helpers_1.decodeScheduleSpec)(raw.info.spec), | ||
action: { | ||
spec: (0, schedule_helpers_1.decodeScheduleSpec)(raw.info?.spec ?? {}), | ||
action: raw.info?.workflowType?.name && { | ||
type: 'startWorkflow', | ||
workflowType: raw.info.workflowType?.name, | ||
workflowType: raw.info.workflowType.name, | ||
}, | ||
@@ -240,7 +229,7 @@ memo: await (0, internal_non_workflow_1.decodeMapFromPayloads)(this.dataConverter, raw.memo?.fields), | ||
state: { | ||
paused: raw.info.paused === true, | ||
note: raw.info.notes ?? undefined, | ||
paused: raw.info?.paused === true, | ||
note: raw.info?.notes ?? undefined, | ||
}, | ||
info: { | ||
recentActions: (0, schedule_helpers_1.decodeScheduleRecentActions)(raw.info.recentActions), | ||
recentActions: (0, schedule_helpers_1.decodeScheduleRecentActions)(raw.info?.recentActions), | ||
nextActionTimes: raw.info?.futureActionTimes?.map(time_1.tsToDate) ?? [], | ||
@@ -247,0 +236,0 @@ }, |
import { LoadedDataConverter, SearchAttributes } from '@temporalio/common'; | ||
import { Headers } from '@temporalio/common/lib/interceptors'; | ||
import { temporal } from '@temporalio/proto'; | ||
import { RequireAtLeastOne } from '@temporalio/common/src/type-helpers'; | ||
import { CalendarSpec, CalendarSpecDescription, CompiledScheduleOptions, CompiledScheduleUpdateOptions, ScheduleOptions, ScheduleOverlapPolicy, ScheduleUpdateOptions, ScheduleSpec, CompiledScheduleAction, ScheduleSpecDescription, ScheduleDescriptionAction, ScheduleExecutionResult, ScheduleExecutionStartWorkflowActionResult } from './schedule-types'; | ||
@@ -16,3 +15,3 @@ export declare function encodeOptionalStructuredCalendarSpecs(input: CalendarSpec[] | null | undefined): temporal.api.schedule.v1.IStructuredCalendarSpec[] | undefined; | ||
export declare function encodeScheduleState(state?: ScheduleOptions['state']): temporal.api.schedule.v1.IScheduleState; | ||
export declare function decodeScheduleSpec(pb: temporal.api.schedule.v1.IScheduleSpec): RequireAtLeastOne<ScheduleSpecDescription, 'calendars' | 'intervals'>; | ||
export declare function decodeScheduleSpec(pb: temporal.api.schedule.v1.IScheduleSpec): ScheduleSpecDescription; | ||
export declare function decodeScheduleAction(dataConverter: LoadedDataConverter, pb: temporal.api.schedule.v1.IScheduleAction): Promise<ScheduleDescriptionAction>; | ||
@@ -19,0 +18,0 @@ export declare function decodeSearchAttributes(pb: temporal.api.common.v1.ISearchAttributes | undefined | null): SearchAttributes; |
@@ -1,2 +0,2 @@ | ||
import { Replace, RequireAtLeastOne } from '@temporalio/common/lib/type-helpers'; | ||
import { Replace } from '@temporalio/common/lib/type-helpers'; | ||
import { SearchAttributes, Workflow } from '@temporalio/common'; | ||
@@ -10,3 +10,3 @@ import type { temporal } from '@temporalio/proto'; | ||
*/ | ||
export interface ScheduleOptions { | ||
export interface ScheduleOptions<A extends ScheduleOptionsAction = ScheduleOptionsAction> { | ||
/** | ||
@@ -21,7 +21,7 @@ * Schedule Id | ||
*/ | ||
spec: RequireAtLeastOne<ScheduleSpec, 'calendars' | 'intervals' | 'cronExpressions'>; | ||
spec: ScheduleSpec; | ||
/** | ||
* Which Action to take | ||
*/ | ||
action: ScheduleOptionsAction; | ||
action: A; | ||
policies?: { | ||
@@ -119,4 +119,4 @@ /** | ||
*/ | ||
export declare type ScheduleUpdateOptions = Replace<Omit<ScheduleOptions, 'scheduleId' | 'memo' | 'searchAttributes'>, { | ||
action: Replace<ScheduleOptions['action'], { | ||
export declare type ScheduleUpdateOptions<A extends ScheduleOptionsAction = ScheduleOptionsAction> = Replace<Omit<ScheduleOptions, 'scheduleId' | 'memo' | 'searchAttributes'>, { | ||
action: Replace<A, { | ||
workflowId: string; | ||
@@ -133,2 +133,5 @@ }>; | ||
* | ||
* Note that schedule listing is eventual consistent; some returned properties may therefore | ||
* be undefined or incorrect for some time after creating or modifying a schedule. | ||
* | ||
* @experimental | ||
@@ -144,7 +147,7 @@ */ | ||
*/ | ||
spec: RequireAtLeastOne<ScheduleSpecDescription, 'calendars' | 'intervals'>; | ||
spec?: ScheduleSpecDescription; | ||
/** | ||
* The Action that will be taken. | ||
*/ | ||
action: ScheduleSummaryAction; | ||
action?: ScheduleSummaryAction; | ||
/** | ||
@@ -161,3 +164,3 @@ * Additional non-indexed information attached to the Schedule. | ||
*/ | ||
searchAttributes: SearchAttributes; | ||
searchAttributes?: SearchAttributes; | ||
state: { | ||
@@ -213,4 +216,12 @@ /** | ||
*/ | ||
export declare type ScheduleDescription = ScheduleSummary & { | ||
export declare type ScheduleDescription = { | ||
/** | ||
* The Schedule Id. We recommend using a meaningful business identifier. | ||
*/ | ||
scheduleId: string; | ||
/** | ||
* When will Actions be taken. | ||
*/ | ||
spec: ScheduleSpecDescription; | ||
/** | ||
* The Action that will be taken. | ||
@@ -243,4 +254,25 @@ */ | ||
}; | ||
state: ScheduleSummary['state'] & { | ||
/** | ||
* Additional non-indexed information attached to the Schedule. | ||
* The values can be anything that is serializable by the {@link DataConverter}. | ||
*/ | ||
memo?: Record<string, unknown>; | ||
/** | ||
* Additional indexed information attached to the Schedule. | ||
* More info: https://docs.temporal.io/docs/typescript/search-attributes | ||
* | ||
* Values are always converted using {@link JsonPayloadConverter}, even when a custom Data Converter is provided. | ||
*/ | ||
searchAttributes: SearchAttributes; | ||
state: { | ||
/** | ||
* Whether Schedule is currently paused. | ||
*/ | ||
paused: boolean; | ||
/** | ||
* Informative human-readable message with contextual notes, e.g. the reason a Schedule is paused. | ||
* The system may overwrite this message on certain conditions, e.g. when pause-on-failure happens. | ||
*/ | ||
note?: string; | ||
/** | ||
* The Actions remaining in this Schedule. | ||
@@ -253,4 +285,12 @@ * Once this number hits `0`, no further Actions are taken (unless {@link ScheduleHandle.trigger} is called). | ||
}; | ||
info: ScheduleSummary['info'] & { | ||
info: { | ||
/** | ||
* Most recent 10 Actions started (including manual triggers), sorted from older start time to newer. | ||
*/ | ||
recentActions: ScheduleExecutionResult[]; | ||
/** | ||
* Scheduled time of the next 10 executions of this Schedule | ||
*/ | ||
nextActionTimes: Date[]; | ||
/** | ||
* Number of Actions taken so far. | ||
@@ -417,3 +457,3 @@ */ | ||
/** | ||
* Valid values: 0–59 | ||
* Valid values: 0–23 | ||
* | ||
@@ -684,3 +724,2 @@ * @default 0 | ||
} | ||
export declare type ScheduleOverlapPolicy2 = keyof typeof temporal.api.enums.v1.ScheduleOverlapPolicy; | ||
/** @experimental */ | ||
@@ -687,0 +726,0 @@ export interface Backfill { |
@@ -5,2 +5,4 @@ "use strict"; | ||
const type_helpers_1 = require("@temporalio/common/lib/type-helpers"); | ||
// Invariant: ScheduleDescription contains at least the same fields as ScheduleSummary | ||
(0, type_helpers_1.checkExtends)(); | ||
// Invariant: An existing ScheduleDescription can be used as template to create a new Schedule | ||
@@ -7,0 +9,0 @@ (0, type_helpers_1.checkExtends)(); |
@@ -157,3 +157,3 @@ import { status as grpcStatus } from '@grpc/grpc-js'; | ||
*/ | ||
interface AsyncWorkflowListIterable extends AsyncIterable<WorkflowExecutionInfo> { | ||
export interface AsyncWorkflowListIterable extends AsyncIterable<WorkflowExecutionInfo> { | ||
/** | ||
@@ -160,0 +160,0 @@ * Return an iterable of histories corresponding to this iterable's WorkflowExecutions. |
{ | ||
"name": "@temporalio/client", | ||
"version": "1.5.2", | ||
"version": "1.6.0", | ||
"description": "Temporal.io SDK Client sub-package", | ||
@@ -16,5 +16,5 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@grpc/grpc-js": "^1.6.7", | ||
"@temporalio/common": "^1.5.2", | ||
"@temporalio/proto": "^1.5.2", | ||
"@grpc/grpc-js": "~1.7.3", | ||
"@temporalio/common": "1.6.0", | ||
"@temporalio/proto": "1.6.0", | ||
"abort-controller": "^3.0.0", | ||
@@ -25,3 +25,2 @@ "long": "^5.2.0", | ||
"devDependencies": { | ||
"@types/long": "^5.0.0", | ||
"protobufjs": "^7.0.0" | ||
@@ -40,3 +39,3 @@ }, | ||
], | ||
"gitHead": "d32adfd8537661c3740767ca1a3862392ca702e2" | ||
"gitHead": "49c6b1341daef2b94a0a989d515cbf97b8b02fa7" | ||
} |
import { status as grpcStatus } from '@grpc/grpc-js'; | ||
import { v4 as uuid4 } from 'uuid'; | ||
import { mapToPayloads, searchAttributePayloadConverter } from '@temporalio/common'; | ||
import { mapToPayloads, searchAttributePayloadConverter, Workflow } from '@temporalio/common'; | ||
import { composeInterceptors, Headers } from '@temporalio/common/lib/interceptors'; | ||
@@ -23,2 +23,4 @@ import { | ||
ScheduleUpdateOptions, | ||
ScheduleOptionsAction, | ||
ScheduleOptionsStartWorkflowAction, | ||
} from './schedule-types'; | ||
@@ -71,3 +73,5 @@ import { | ||
*/ | ||
update(updateFn: (previous: ScheduleDescription) => ScheduleUpdateOptions): Promise<void>; | ||
update<W extends Workflow = Workflow>( | ||
updateFn: (previous: ScheduleDescription) => ScheduleUpdateOptions<ScheduleOptionsStartWorkflowAction<W>> | ||
): Promise<void>; | ||
@@ -144,5 +148,2 @@ /** | ||
} | ||
if (!(opts.spec.calendars?.length || opts.spec.intervals?.length || opts.spec.cronExpressions?.length)) { | ||
throw new TypeError(`At least one ${structureName}.spec.calendars, .intervals or .cronExpressions is required`); | ||
} | ||
switch (opts.action.type) { | ||
@@ -203,3 +204,6 @@ case 'startWorkflow': | ||
*/ | ||
public async create(options: ScheduleOptions): Promise<ScheduleHandle> { | ||
public async create<W extends Workflow = Workflow>( | ||
options: ScheduleOptions<ScheduleOptionsStartWorkflowAction<W>> | ||
): Promise<ScheduleHandle>; | ||
public async create<A extends ScheduleOptionsAction>(options: ScheduleOptions<A>): Promise<ScheduleHandle> { | ||
await this._createSchedule(options); | ||
@@ -377,11 +381,9 @@ return this.getHandle(options.scheduleId); | ||
for (const raw of response.schedules ?? []) { | ||
if (!raw.info?.spec) continue; | ||
yield <ScheduleSummary>{ | ||
scheduleId: raw.scheduleId, | ||
spec: decodeScheduleSpec(raw.info.spec), | ||
action: { | ||
spec: decodeScheduleSpec(raw.info?.spec ?? {}), | ||
action: raw.info?.workflowType?.name && { | ||
type: 'startWorkflow', | ||
workflowType: raw.info.workflowType?.name, | ||
workflowType: raw.info.workflowType.name, | ||
}, | ||
@@ -391,7 +393,7 @@ memo: await decodeMapFromPayloads(this.dataConverter, raw.memo?.fields), | ||
state: { | ||
paused: raw.info.paused === true, | ||
note: raw.info.notes ?? undefined, | ||
paused: raw.info?.paused === true, | ||
note: raw.info?.notes ?? undefined, | ||
}, | ||
info: { | ||
recentActions: decodeScheduleRecentActions(raw.info.recentActions), | ||
recentActions: decodeScheduleRecentActions(raw.info?.recentActions), | ||
nextActionTimes: raw.info?.futureActionTimes?.map(tsToDate) ?? [], | ||
@@ -398,0 +400,0 @@ }, |
@@ -27,3 +27,2 @@ import Long from 'long'; // eslint-disable-line import/no-named-as-default | ||
} from '@temporalio/common/lib/time'; | ||
import { RequireAtLeastOne } from '@temporalio/common/src/type-helpers'; | ||
import { | ||
@@ -304,5 +303,3 @@ CalendarSpec, | ||
export function decodeScheduleSpec( | ||
pb: temporal.api.schedule.v1.IScheduleSpec | ||
): RequireAtLeastOne<ScheduleSpecDescription, 'calendars' | 'intervals'> { | ||
export function decodeScheduleSpec(pb: temporal.api.schedule.v1.IScheduleSpec): ScheduleSpecDescription { | ||
// Note: the server will have compiled calendar and cron_string fields into | ||
@@ -309,0 +306,0 @@ // structured_calendar (and maybe interval and timezone_name), so at this |
@@ -1,2 +0,2 @@ | ||
import { checkExtends, Replace, RequireAtLeastOne } from '@temporalio/common/lib/type-helpers'; | ||
import { checkExtends, Replace } from '@temporalio/common/lib/type-helpers'; | ||
import { SearchAttributes, Workflow } from '@temporalio/common'; | ||
@@ -11,3 +11,3 @@ import type { temporal } from '@temporalio/proto'; | ||
*/ | ||
export interface ScheduleOptions { | ||
export interface ScheduleOptions<A extends ScheduleOptionsAction = ScheduleOptionsAction> { | ||
/** | ||
@@ -23,3 +23,3 @@ * Schedule Id | ||
*/ | ||
spec: RequireAtLeastOne<ScheduleSpec, 'calendars' | 'intervals' | 'cronExpressions'>; | ||
spec: ScheduleSpec; | ||
@@ -29,3 +29,3 @@ /** | ||
*/ | ||
action: ScheduleOptionsAction; | ||
action: A; | ||
@@ -138,7 +138,7 @@ policies?: { | ||
*/ | ||
export type ScheduleUpdateOptions = Replace< | ||
export type ScheduleUpdateOptions<A extends ScheduleOptionsAction = ScheduleOptionsAction> = Replace< | ||
Omit<ScheduleOptions, 'scheduleId' | 'memo' | 'searchAttributes'>, | ||
{ | ||
action: Replace< | ||
ScheduleOptions['action'], | ||
A, | ||
{ | ||
@@ -164,2 +164,5 @@ // No default value on update | ||
* | ||
* Note that schedule listing is eventual consistent; some returned properties may therefore | ||
* be undefined or incorrect for some time after creating or modifying a schedule. | ||
* | ||
* @experimental | ||
@@ -176,3 +179,3 @@ */ | ||
*/ | ||
spec: RequireAtLeastOne<ScheduleSpecDescription, 'calendars' | 'intervals'>; | ||
spec?: ScheduleSpecDescription; | ||
@@ -182,3 +185,3 @@ /** | ||
*/ | ||
action: ScheduleSummaryAction; | ||
action?: ScheduleSummaryAction; | ||
@@ -197,3 +200,3 @@ /** | ||
*/ | ||
searchAttributes: SearchAttributes; | ||
searchAttributes?: SearchAttributes; | ||
@@ -260,4 +263,14 @@ state: { | ||
*/ | ||
export type ScheduleDescription = ScheduleSummary & { | ||
export type ScheduleDescription = { | ||
/** | ||
* The Schedule Id. We recommend using a meaningful business identifier. | ||
*/ | ||
scheduleId: string; | ||
/** | ||
* When will Actions be taken. | ||
*/ | ||
spec: ScheduleSpecDescription; | ||
/** | ||
* The Action that will be taken. | ||
@@ -294,4 +307,29 @@ */ | ||
state: ScheduleSummary['state'] & { | ||
/** | ||
* Additional non-indexed information attached to the Schedule. | ||
* The values can be anything that is serializable by the {@link DataConverter}. | ||
*/ | ||
memo?: Record<string, unknown>; | ||
/** | ||
* Additional indexed information attached to the Schedule. | ||
* More info: https://docs.temporal.io/docs/typescript/search-attributes | ||
* | ||
* Values are always converted using {@link JsonPayloadConverter}, even when a custom Data Converter is provided. | ||
*/ | ||
searchAttributes: SearchAttributes; | ||
state: { | ||
/** | ||
* Whether Schedule is currently paused. | ||
*/ | ||
paused: boolean; | ||
/** | ||
* Informative human-readable message with contextual notes, e.g. the reason a Schedule is paused. | ||
* The system may overwrite this message on certain conditions, e.g. when pause-on-failure happens. | ||
*/ | ||
note?: string; | ||
/** | ||
* The Actions remaining in this Schedule. | ||
@@ -305,4 +343,14 @@ * Once this number hits `0`, no further Actions are taken (unless {@link ScheduleHandle.trigger} is called). | ||
info: ScheduleSummary['info'] & { | ||
info: { | ||
/** | ||
* Most recent 10 Actions started (including manual triggers), sorted from older start time to newer. | ||
*/ | ||
recentActions: ScheduleExecutionResult[]; | ||
/** | ||
* Scheduled time of the next 10 executions of this Schedule | ||
*/ | ||
nextActionTimes: Date[]; | ||
/** | ||
* Number of Actions taken so far. | ||
@@ -336,2 +384,5 @@ */ | ||
// Invariant: ScheduleDescription contains at least the same fields as ScheduleSummary | ||
checkExtends<ScheduleSummary, ScheduleDescription>(); | ||
// Invariant: An existing ScheduleDescription can be used as template to create a new Schedule | ||
@@ -504,3 +555,3 @@ checkExtends<ScheduleOptions, ScheduleDescription>(); | ||
/** | ||
* Valid values: 0–59 | ||
* Valid values: 0–23 | ||
* | ||
@@ -850,4 +901,2 @@ * @default 0 | ||
export type ScheduleOverlapPolicy2 = keyof typeof temporal.api.enums.v1.ScheduleOverlapPolicy; | ||
checkExtends< | ||
@@ -854,0 +903,0 @@ keyof typeof temporal.api.enums.v1.ScheduleOverlapPolicy, |
@@ -259,3 +259,3 @@ import { status as grpcStatus } from '@grpc/grpc-js'; | ||
*/ | ||
interface AsyncWorkflowListIterable extends AsyncIterable<WorkflowExecutionInfo> { | ||
export interface AsyncWorkflowListIterable extends AsyncIterable<WorkflowExecutionInfo> { | ||
/** | ||
@@ -262,0 +262,0 @@ * Return an iterable of histories corresponding to this iterable's WorkflowExecutions. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
409413
1
8655
+ Added@grpc/grpc-js@1.7.3(transitive)
+ Added@opentelemetry/api@1.9.0(transitive)
+ Added@temporalio/common@1.6.0(transitive)
+ Added@temporalio/proto@1.6.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedproto3-json-serializer@1.1.1(transitive)
- Removed@grpc/grpc-js@1.12.2(transitive)
- Removed@js-sdsl/ordered-map@4.4.2(transitive)
- Removed@temporalio/common@1.11.3(transitive)
- Removed@temporalio/proto@1.11.3(transitive)
- Removedms@3.0.0-canary.1(transitive)
- Removedproto3-json-serializer@2.0.2(transitive)
Updated@grpc/grpc-js@~1.7.3
Updated@temporalio/common@1.6.0
Updated@temporalio/proto@1.6.0