From e5cd14ce9ad7d0f219d9e3a2504661a6647666f9 Mon Sep 17 00:00:00 2001 From: Tyler Cloutier Date: Wed, 23 Jul 2025 23:48:30 -0400 Subject: [PATCH 1/2] Addresses #2969 --- .../packages/sdk/src/schedule_at.ts | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/sdks/typescript/packages/sdk/src/schedule_at.ts b/sdks/typescript/packages/sdk/src/schedule_at.ts index e31dd692f5e..f8f002bc27d 100644 --- a/sdks/typescript/packages/sdk/src/schedule_at.ts +++ b/sdks/typescript/packages/sdk/src/schedule_at.ts @@ -4,37 +4,30 @@ import type { AlgebraicValue } from './algebraic_value'; export namespace ScheduleAt { export function getAlgebraicType(): AlgebraicType { return AlgebraicType.createSumType([ - new SumTypeVariant('Interval', AlgebraicType.createU64Type()), - new SumTypeVariant('Time', AlgebraicType.createU64Type()), + new SumTypeVariant('Interval', AlgebraicType.createTimeDurationType()), + new SumTypeVariant('Time', AlgebraicType.createTimestampType()), ]); } - export function serialize(value: ScheduleAt): object { - switch (value.tag) { - case 'Interval': - return { Interval: value.value }; - case 'Time': - return { Time: value.value }; - default: - throw 'unreachable'; - } - } - - export type Interval = { tag: 'Interval'; value: BigInt }; + export type Interval = { tag: 'Interval'; value: { __time_duration_micros__: BigInt } }; export const Interval = (value: BigInt): Interval => ({ tag: 'Interval', - value, + value: { __time_duration_micros__: value }, }); - export type Time = { tag: 'Time'; value: BigInt }; - export const Time = (value: BigInt): Time => ({ tag: 'Time', value }); + export type Time = { tag: 'Time'; value: { __timestamp_micros_since_unix_epoch__: BigInt } }; + export const Time = (value: BigInt): Time => ({ tag: 'Time', value: { __timestamp_micros_since_unix_epoch__: value } }); export function fromValue(value: AlgebraicValue): ScheduleAt { let sumValue = value.asSumValue(); switch (sumValue.tag) { case 0: - return { tag: 'Interval', value: sumValue.value.asBigInt() }; + return { tag: 'Interval', value: { + __time_duration_micros__: sumValue.value.asProductValue().elements[0].asBigInt() + }}; case 1: - return { tag: 'Time', value: sumValue.value.asBigInt() }; + return { tag: 'Time', value: { + __timestamp_micros_since_unix_epoch__: sumValue.value.asBigInt() + }}; default: throw 'unreachable'; } From 956436a6090a6ff9731aea7f8c44813c15bdc4de Mon Sep 17 00:00:00 2001 From: Tyler Cloutier Date: Wed, 23 Jul 2025 23:54:28 -0400 Subject: [PATCH 2/2] Formatting --- .../packages/sdk/src/schedule_at.ts | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/sdks/typescript/packages/sdk/src/schedule_at.ts b/sdks/typescript/packages/sdk/src/schedule_at.ts index f8f002bc27d..0cbbac29448 100644 --- a/sdks/typescript/packages/sdk/src/schedule_at.ts +++ b/sdks/typescript/packages/sdk/src/schedule_at.ts @@ -9,25 +9,42 @@ export namespace ScheduleAt { ]); } - export type Interval = { tag: 'Interval'; value: { __time_duration_micros__: BigInt } }; + export type Interval = { + tag: 'Interval'; + value: { __time_duration_micros__: BigInt }; + }; export const Interval = (value: BigInt): Interval => ({ tag: 'Interval', value: { __time_duration_micros__: value }, }); - export type Time = { tag: 'Time'; value: { __timestamp_micros_since_unix_epoch__: BigInt } }; - export const Time = (value: BigInt): Time => ({ tag: 'Time', value: { __timestamp_micros_since_unix_epoch__: value } }); + export type Time = { + tag: 'Time'; + value: { __timestamp_micros_since_unix_epoch__: BigInt }; + }; + export const Time = (value: BigInt): Time => ({ + tag: 'Time', + value: { __timestamp_micros_since_unix_epoch__: value }, + }); export function fromValue(value: AlgebraicValue): ScheduleAt { let sumValue = value.asSumValue(); switch (sumValue.tag) { case 0: - return { tag: 'Interval', value: { - __time_duration_micros__: sumValue.value.asProductValue().elements[0].asBigInt() - }}; + return { + tag: 'Interval', + value: { + __time_duration_micros__: sumValue.value + .asProductValue() + .elements[0].asBigInt(), + }, + }; case 1: - return { tag: 'Time', value: { - __timestamp_micros_since_unix_epoch__: sumValue.value.asBigInt() - }}; + return { + tag: 'Time', + value: { + __timestamp_micros_since_unix_epoch__: sumValue.value.asBigInt(), + }, + }; default: throw 'unreachable'; }