@outputai/cli 0.18.1-next.72b80da.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/docker/docker-compose-dev.yml +1 -1
- package/dist/generated/framework_version.json +1 -1
- package/dist/services/workflow_debug.js +11 -6
- package/dist/services/workflow_run_data.d.ts +1 -1
- package/dist/services/workflow_run_data.js +1 -1
- package/dist/utils/history_serializer.contract.spec.d.ts +1 -0
- package/dist/utils/history_serializer.contract.spec.js +135 -0
- package/dist/utils/history_serializer.d.ts +15 -0
- package/dist/utils/history_serializer.js +99 -0
- package/dist/utils/history_serializer.spec.d.ts +1 -0
- package/dist/utils/history_serializer.spec.js +120 -0
- package/oclif.manifest.json +1 -1
- package/package.json +4 -3
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { WorkflowNotFoundError } from '@temporalio/client';
|
|
2
|
-
import { defaultPayloadConverter } from '@temporalio/common';
|
|
3
|
-
import { historyToJSON, JSONToPayload } from '@temporalio/common/lib/proto-utils.js';
|
|
1
|
+
import { WorkflowNotFoundError, defaultPayloadConverter } from '@temporalio/client';
|
|
4
2
|
import { callTemporal } from '#services/temporal_client.js';
|
|
3
|
+
import { serializeHistoryEvent } from '#utils/history_serializer.js';
|
|
5
4
|
import { truncateStack, truncateValue } from '#utils/payload_truncator.js';
|
|
6
5
|
const PAGE_SIZE = 1000;
|
|
7
6
|
const DEFAULT_PAGE_BUDGET = 1000;
|
|
@@ -17,9 +16,14 @@ const isPayload = (value) => {
|
|
|
17
16
|
}
|
|
18
17
|
return isObject(value.metadata) && typeof value.metadata.encoding === 'string';
|
|
19
18
|
};
|
|
19
|
+
/** Rebuilds a Temporal Payload from history JSON without protobufjs protojson (avoids duplicate-instance TypeError) */
|
|
20
|
+
const payloadFromJson = (payload) => ({
|
|
21
|
+
metadata: Object.fromEntries(Object.entries(payload.metadata).map(([key, value]) => [key, Buffer.from(value, 'base64')])),
|
|
22
|
+
...(payload.data === undefined ? {} : { data: Buffer.from(payload.data, 'base64') })
|
|
23
|
+
});
|
|
20
24
|
const decodePayload = (payload) => {
|
|
21
25
|
try {
|
|
22
|
-
const decoded = defaultPayloadConverter.fromPayload(
|
|
26
|
+
const decoded = defaultPayloadConverter.fromPayload(payloadFromJson(payload));
|
|
23
27
|
return decoded instanceof Uint8Array ? `[Binary Payload: ${decoded.byteLength} bytes]` : decoded;
|
|
24
28
|
}
|
|
25
29
|
catch {
|
|
@@ -99,8 +103,9 @@ const fetchPage = async (client, target) => {
|
|
|
99
103
|
nextPageToken: target.nextPageToken
|
|
100
104
|
}));
|
|
101
105
|
const events = response.history?.events ?? [];
|
|
102
|
-
const
|
|
103
|
-
|
|
106
|
+
const tagged = events.map(event => Object.assign(serializeHistoryEvent(event), {
|
|
107
|
+
timeKey: buildTimeKey(event.eventTime)
|
|
108
|
+
}));
|
|
104
109
|
return { events: tagged, nextPageToken: response.nextPageToken?.length ? response.nextPageToken : undefined };
|
|
105
110
|
};
|
|
106
111
|
const buildEntry = (ids, workflowType, parent) => ({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defaultPayloadConverter } from '@temporalio/
|
|
1
|
+
import { defaultPayloadConverter } from '@temporalio/client';
|
|
2
2
|
import { callTemporal } from '#services/temporal_client.js';
|
|
3
3
|
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
4
4
|
const formatStatus = (name) => name.toLowerCase().replaceAll('_', ' ');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { historyToJSON } from '@temporalio/common/lib/proto-utils.js';
|
|
6
|
+
import proto from '@temporalio/proto';
|
|
7
|
+
import { isDurationKey, isTimestampKey, serializeHistoryEvent } from './history_serializer.js';
|
|
8
|
+
const fixturesDir = join(dirname(fileURLToPath(import.meta.url)), 'fixtures/history');
|
|
9
|
+
const readJson = (name) => JSON.parse(readFileSync(join(fixturesDir, name), 'utf8'));
|
|
10
|
+
const listGoldenCases = () => [...new Set(readdirSync(fixturesDir)
|
|
11
|
+
.filter(name => name.endsWith('.input.json'))
|
|
12
|
+
.map(name => name.replace(/\.input\.json$/, '')))].sort();
|
|
13
|
+
/** Builds protobuf history events from plain objects, as Temporal's own decode would produce them */
|
|
14
|
+
const buildHistoryEvents = (rawEvents) => {
|
|
15
|
+
const history = proto.temporal.api.history.v1.History.fromObject({ events: rawEvents });
|
|
16
|
+
return history.events ?? [];
|
|
17
|
+
};
|
|
18
|
+
const serializeWithTemporal = (events) => {
|
|
19
|
+
const parsed = JSON.parse(historyToJSON({ events }));
|
|
20
|
+
return parsed.events ?? [];
|
|
21
|
+
};
|
|
22
|
+
/** Collects every Duration/Timestamp field name reachable from a protobuf message type */
|
|
23
|
+
const collectWktFieldNames = (type, seen = new Set()) => {
|
|
24
|
+
if (!type.fullName || seen.has(type.fullName)) {
|
|
25
|
+
return { duration: [], timestamp: [] };
|
|
26
|
+
}
|
|
27
|
+
seen.add(type.fullName);
|
|
28
|
+
const duration = [];
|
|
29
|
+
const timestamp = [];
|
|
30
|
+
for (const field of type.fieldsArray ?? []) {
|
|
31
|
+
const resolved = field.resolve();
|
|
32
|
+
const nested = resolved.resolvedType;
|
|
33
|
+
if (!nested?.fullName) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (nested.fullName === '.google.protobuf.Duration') {
|
|
37
|
+
duration.push(resolved.name);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (nested.fullName === '.google.protobuf.Timestamp') {
|
|
41
|
+
timestamp.push(resolved.name);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const nestedNames = collectWktFieldNames(nested, seen);
|
|
45
|
+
duration.push(...nestedNames.duration);
|
|
46
|
+
timestamp.push(...nestedNames.timestamp);
|
|
47
|
+
}
|
|
48
|
+
return { duration, timestamp };
|
|
49
|
+
};
|
|
50
|
+
describe('history serializer contract', () => {
|
|
51
|
+
describe('WKT field-name predicates', () => {
|
|
52
|
+
it('recognize every Duration and Timestamp field under HistoryEvent', () => {
|
|
53
|
+
const root = proto.temporal.api.history.v1.HistoryEvent;
|
|
54
|
+
const { duration, timestamp } = collectWktFieldNames(root);
|
|
55
|
+
expect(duration.length).toBeGreaterThan(0);
|
|
56
|
+
expect(timestamp.length).toBeGreaterThan(0);
|
|
57
|
+
expect(duration.filter(name => !isDurationKey(name))).toEqual([]);
|
|
58
|
+
expect(timestamp.filter(name => !isTimestampKey(name))).toEqual([]);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
describe('golden fixtures', () => {
|
|
62
|
+
it.each(listGoldenCases())('%s matches the committed Temporal-tool JSON', name => {
|
|
63
|
+
const input = readJson(`${name}.input.json`);
|
|
64
|
+
const expected = readJson(`${name}.expected.json`);
|
|
65
|
+
expect(serializeHistoryEvent(input)).toEqual(expected);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe('oracle vs historyToJSON', () => {
|
|
69
|
+
it('matches Temporal for timer, activity, failure and child events', () => {
|
|
70
|
+
const rawEvents = [
|
|
71
|
+
{
|
|
72
|
+
eventId: 1,
|
|
73
|
+
eventTime: { seconds: 10, nanos: 500_000_000 },
|
|
74
|
+
eventType: 'EVENT_TYPE_TIMER_FIRED',
|
|
75
|
+
timerFiredEventAttributes: { timerId: 'timer-1', startedEventId: 3 }
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
eventId: 2,
|
|
79
|
+
eventTime: { seconds: 11 },
|
|
80
|
+
eventType: 'EVENT_TYPE_ACTIVITY_TASK_SCHEDULED',
|
|
81
|
+
activityTaskScheduledEventAttributes: {
|
|
82
|
+
activityId: 'step-1',
|
|
83
|
+
activityType: { name: 'do_work' },
|
|
84
|
+
taskQueue: { name: 'default' },
|
|
85
|
+
input: {
|
|
86
|
+
payloads: [{
|
|
87
|
+
metadata: { encoding: Buffer.from('json/plain') },
|
|
88
|
+
data: Buffer.from('{"a":1}')
|
|
89
|
+
}]
|
|
90
|
+
},
|
|
91
|
+
scheduleToCloseTimeout: { seconds: 60 },
|
|
92
|
+
startToCloseTimeout: { seconds: 30, nanos: 500_000_000 },
|
|
93
|
+
heartbeatTimeout: {},
|
|
94
|
+
workflowTaskCompletedEventId: 1
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
eventId: 3,
|
|
99
|
+
eventTime: { seconds: 12 },
|
|
100
|
+
eventType: 'EVENT_TYPE_WORKFLOW_EXECUTION_FAILED',
|
|
101
|
+
workflowExecutionFailedEventAttributes: {
|
|
102
|
+
failure: {
|
|
103
|
+
message: 'boom',
|
|
104
|
+
stackTrace: 'Error: boom\n at step (workflow.js:1:1)',
|
|
105
|
+
applicationFailureInfo: { type: 'Error', nonRetryable: true }
|
|
106
|
+
},
|
|
107
|
+
retryState: 'RETRY_STATE_NON_RETRYABLE_FAILURE',
|
|
108
|
+
workflowTaskCompletedEventId: 2
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
eventId: 4,
|
|
113
|
+
eventTime: { seconds: 13, nanos: 250_000_000 },
|
|
114
|
+
eventType: 'EVENT_TYPE_CHILD_WORKFLOW_EXECUTION_STARTED',
|
|
115
|
+
childWorkflowExecutionStartedEventAttributes: {
|
|
116
|
+
namespace: 'default',
|
|
117
|
+
initiatedEventId: 2,
|
|
118
|
+
workflowExecution: { workflowId: 'wf-child-1', runId: 'run-child-1' },
|
|
119
|
+
workflowType: { name: 'child_workflow' }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
];
|
|
123
|
+
const events = buildHistoryEvents(rawEvents);
|
|
124
|
+
expect(events.map(event => serializeHistoryEvent(event))).toEqual(serializeWithTemporal(events));
|
|
125
|
+
});
|
|
126
|
+
it('matches Temporal for each golden input after History.fromObject', () => {
|
|
127
|
+
for (const name of listGoldenCases()) {
|
|
128
|
+
const input = readJson(`${name}.input.json`);
|
|
129
|
+
const events = buildHistoryEvents([input]);
|
|
130
|
+
expect(events.map(event => serializeHistoryEvent(event)), name)
|
|
131
|
+
.toEqual(serializeWithTemporal(events));
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type JsonObject = Record<string, unknown>;
|
|
2
|
+
/** True when the field name is treated as a google.protobuf.Duration in Temporal history JSON */
|
|
3
|
+
export declare const isDurationKey: (key: string) => boolean;
|
|
4
|
+
/** True when the field name is treated as a google.protobuf.Timestamp in Temporal history JSON */
|
|
5
|
+
export declare const isTimestampKey: (key: string) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Converts a Temporal history event into the JSON shape Temporal tools use: enum names, string ids,
|
|
8
|
+
* ISO-8601 times and `"Ns"` durations. Accepts a protobufjs message (`toJSON`) or an equivalent plain object.
|
|
9
|
+
* Pure: returns a new tree and does not mutate the input.
|
|
10
|
+
*
|
|
11
|
+
* @param event - History event from Temporal or a plain fixture
|
|
12
|
+
* @returns JSON-ready event object
|
|
13
|
+
*/
|
|
14
|
+
export declare const serializeHistoryEvent: (event: unknown) => JsonObject;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
2
|
+
/** True when the value is only the protobuf seconds/nanos pair used by Timestamp and Duration */
|
|
3
|
+
const isSecondsNanos = (value) => Object.keys(value).every(key => key === 'seconds' || key === 'nanos');
|
|
4
|
+
/** True when the field name is treated as a google.protobuf.Duration in Temporal history JSON */
|
|
5
|
+
export const isDurationKey = (key) => /(?:Timeout|Duration|Interval|Backoff|Delay)$/i.test(key);
|
|
6
|
+
/** True when the field name is treated as a google.protobuf.Timestamp in Temporal history JSON */
|
|
7
|
+
export const isTimestampKey = (key) => /(?:Time|Timestamp)$/i.test(key);
|
|
8
|
+
/** int64 ids Temporal tools print as strings; Message.toJSON already does this, plain fixtures may not */
|
|
9
|
+
const isInt64IdKey = (key) => key === 'eventId' || key.endsWith('EventId');
|
|
10
|
+
const toNumber = (value) => {
|
|
11
|
+
if (value === undefined) {
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
return typeof value === 'number' ? value : Number(value) || 0;
|
|
15
|
+
};
|
|
16
|
+
/** Drops trailing groups of three zeros while more than three digits remain (ProtoJSON nanos style) */
|
|
17
|
+
const trimNanosFraction = (digits) => (digits.length > 3 && digits.endsWith('000') ? trimNanosFraction(digits.slice(0, -3)) : digits);
|
|
18
|
+
/**
|
|
19
|
+
* ProtoJSON nanos fraction: nine digits, then trailing groups of three zeros dropped (500000000 -> "500").
|
|
20
|
+
*
|
|
21
|
+
* @param nanos - Absolute nanosecond value
|
|
22
|
+
* @returns Fraction digits without a leading dot
|
|
23
|
+
*/
|
|
24
|
+
const formatNanosFraction = (nanos) => trimNanosFraction(String(Math.abs(nanos)).padStart(9, '0'));
|
|
25
|
+
/**
|
|
26
|
+
* Formats a Timestamp the way Temporal history JSON does: an RFC 3339 UTC string.
|
|
27
|
+
*
|
|
28
|
+
* @param value - `{ seconds, nanos }` from Message.toJSON or a plain fixture
|
|
29
|
+
* @returns e.g. `1970-01-01T00:00:10.500Z`
|
|
30
|
+
*/
|
|
31
|
+
const formatTimestamp = (value) => {
|
|
32
|
+
const seconds = toNumber(value.seconds);
|
|
33
|
+
const nanos = toNumber(value.nanos);
|
|
34
|
+
const iso = new Date(seconds * 1000).toISOString();
|
|
35
|
+
if (!nanos) {
|
|
36
|
+
return iso.replace(/\.\d+Z$/, 'Z');
|
|
37
|
+
}
|
|
38
|
+
return iso.replace(/\.\d+Z$/, `.${formatNanosFraction(nanos)}Z`);
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Formats a Duration the way Temporal history JSON does: a seconds string with an `s` suffix.
|
|
42
|
+
*
|
|
43
|
+
* @param value - `{ seconds, nanos }` from Message.toJSON or a plain fixture
|
|
44
|
+
* @returns e.g. `60s`, `0s`, `1.500s`
|
|
45
|
+
*/
|
|
46
|
+
const formatDuration = (value) => {
|
|
47
|
+
const seconds = toNumber(value.seconds);
|
|
48
|
+
const nanos = toNumber(value.nanos);
|
|
49
|
+
const negative = seconds < 0 || nanos < 0;
|
|
50
|
+
const fraction = nanos ? `.${formatNanosFraction(nanos)}` : '';
|
|
51
|
+
return `${negative ? '-' : ''}${Math.abs(seconds)}${fraction}s`;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Walks a JSON tree from Message.toJSON (or an equivalent plain object) and rewrites Timestamp /
|
|
55
|
+
* Duration objects into Temporal-tool strings. Everything else is copied as-is.
|
|
56
|
+
*
|
|
57
|
+
* @param value - Node to serialize
|
|
58
|
+
* @param key - Parent field name, used to tell Timestamp from Duration
|
|
59
|
+
* @returns A new JSON-compatible value
|
|
60
|
+
*/
|
|
61
|
+
const serializeNode = (value, key) => {
|
|
62
|
+
if (Array.isArray(value)) {
|
|
63
|
+
return value.map(item => serializeNode(item, key));
|
|
64
|
+
}
|
|
65
|
+
if (!isObject(value)) {
|
|
66
|
+
if (key && typeof value === 'number' && Number.isInteger(value) && isInt64IdKey(key)) {
|
|
67
|
+
return String(value);
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
if (key !== undefined && isSecondsNanos(value)) {
|
|
72
|
+
const secondsNanos = value;
|
|
73
|
+
if (isDurationKey(key)) {
|
|
74
|
+
return formatDuration(secondsNanos);
|
|
75
|
+
}
|
|
76
|
+
if (isTimestampKey(key)) {
|
|
77
|
+
return formatTimestamp(secondsNanos);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return Object.fromEntries(Object.entries(value).map(([childKey, child]) => [
|
|
81
|
+
childKey,
|
|
82
|
+
serializeNode(child, childKey)
|
|
83
|
+
]));
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Converts a Temporal history event into the JSON shape Temporal tools use: enum names, string ids,
|
|
87
|
+
* ISO-8601 times and `"Ns"` durations. Accepts a protobufjs message (`toJSON`) or an equivalent plain object.
|
|
88
|
+
* Pure: returns a new tree and does not mutate the input.
|
|
89
|
+
*
|
|
90
|
+
* @param event - History event from Temporal or a plain fixture
|
|
91
|
+
* @returns JSON-ready event object
|
|
92
|
+
*/
|
|
93
|
+
export const serializeHistoryEvent = (event) => {
|
|
94
|
+
const json = event?.toJSON?.() ?? event;
|
|
95
|
+
if (!isObject(json)) {
|
|
96
|
+
throw new TypeError('History event must be an object');
|
|
97
|
+
}
|
|
98
|
+
return serializeNode(json);
|
|
99
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { serializeHistoryEvent } from './history_serializer.js';
|
|
3
|
+
describe('serializeHistoryEvent', () => {
|
|
4
|
+
it('turns Timestamp fields into RFC 3339 UTC strings', () => {
|
|
5
|
+
expect(serializeHistoryEvent({
|
|
6
|
+
eventId: '1',
|
|
7
|
+
eventTime: { seconds: '10', nanos: 500_000_000 },
|
|
8
|
+
eventType: 'EVENT_TYPE_TIMER_FIRED'
|
|
9
|
+
})).toEqual({
|
|
10
|
+
eventId: '1',
|
|
11
|
+
eventTime: '1970-01-01T00:00:10.500Z',
|
|
12
|
+
eventType: 'EVENT_TYPE_TIMER_FIRED'
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
it('drops the fractional second when nanos are zero', () => {
|
|
16
|
+
expect(serializeHistoryEvent({
|
|
17
|
+
eventTime: { seconds: 11 }
|
|
18
|
+
}).eventTime).toBe('1970-01-01T00:00:11Z');
|
|
19
|
+
});
|
|
20
|
+
it('turns Duration fields into seconds strings', () => {
|
|
21
|
+
expect(serializeHistoryEvent({
|
|
22
|
+
activityTaskScheduledEventAttributes: {
|
|
23
|
+
scheduleToCloseTimeout: { seconds: '60' },
|
|
24
|
+
startToCloseTimeout: { seconds: 30, nanos: 500_000_000 },
|
|
25
|
+
heartbeatTimeout: {}
|
|
26
|
+
}
|
|
27
|
+
})).toEqual({
|
|
28
|
+
activityTaskScheduledEventAttributes: {
|
|
29
|
+
scheduleToCloseTimeout: '60s',
|
|
30
|
+
startToCloseTimeout: '30.500s',
|
|
31
|
+
heartbeatTimeout: '0s'
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
it('treats a lowercase duration field as a Duration', () => {
|
|
36
|
+
expect(serializeHistoryEvent({
|
|
37
|
+
fastForwardConfig: { duration: { seconds: '5' } }
|
|
38
|
+
})).toEqual({
|
|
39
|
+
fastForwardConfig: { duration: '5s' }
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
it('keeps negative durations signed', () => {
|
|
43
|
+
expect(serializeHistoryEvent({
|
|
44
|
+
backoffInterval: { seconds: -2, nanos: -500_000_000 }
|
|
45
|
+
}).backoffInterval).toBe('-2.500s');
|
|
46
|
+
});
|
|
47
|
+
it('stringifies int64 event ids left as numbers in plain fixtures', () => {
|
|
48
|
+
expect(serializeHistoryEvent({
|
|
49
|
+
eventId: 7,
|
|
50
|
+
activityTaskCompletedEventAttributes: { scheduledEventId: 3, startedEventId: 4 }
|
|
51
|
+
})).toEqual({
|
|
52
|
+
eventId: '7',
|
|
53
|
+
activityTaskCompletedEventAttributes: { scheduledEventId: '3', startedEventId: '4' }
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
it('leaves payloads and other nested objects unchanged aside from WKT fields', () => {
|
|
57
|
+
const event = {
|
|
58
|
+
eventId: '2',
|
|
59
|
+
eventTime: { seconds: '12' },
|
|
60
|
+
activityTaskScheduledEventAttributes: {
|
|
61
|
+
activityId: '5',
|
|
62
|
+
input: {
|
|
63
|
+
payloads: [{
|
|
64
|
+
metadata: { encoding: 'anNvbi9wbGFpbg==' },
|
|
65
|
+
data: 'eyJhIjoxfQ=='
|
|
66
|
+
}]
|
|
67
|
+
},
|
|
68
|
+
startToCloseTimeout: { seconds: '30' }
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
expect(serializeHistoryEvent(event)).toEqual({
|
|
72
|
+
eventId: '2',
|
|
73
|
+
eventTime: '1970-01-01T00:00:12Z',
|
|
74
|
+
activityTaskScheduledEventAttributes: {
|
|
75
|
+
activityId: '5',
|
|
76
|
+
input: {
|
|
77
|
+
payloads: [{
|
|
78
|
+
metadata: { encoding: 'anNvbi9wbGFpbg==' },
|
|
79
|
+
data: 'eyJhIjoxfQ=='
|
|
80
|
+
}]
|
|
81
|
+
},
|
|
82
|
+
startToCloseTimeout: '30s'
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
it('does not mutate the input', () => {
|
|
87
|
+
const event = {
|
|
88
|
+
eventTime: { seconds: '1', nanos: 0 },
|
|
89
|
+
nested: { startToCloseTimeout: { seconds: '5' } }
|
|
90
|
+
};
|
|
91
|
+
const before = structuredClone(event);
|
|
92
|
+
serializeHistoryEvent(event);
|
|
93
|
+
expect(event).toEqual(before);
|
|
94
|
+
});
|
|
95
|
+
it('uses Message.toJSON when present, then applies WKT conversion', () => {
|
|
96
|
+
const event = {
|
|
97
|
+
toJSON: () => ({
|
|
98
|
+
eventId: '9',
|
|
99
|
+
eventTime: { seconds: '3' },
|
|
100
|
+
startToCloseTimeout: { seconds: '1' }
|
|
101
|
+
})
|
|
102
|
+
};
|
|
103
|
+
expect(serializeHistoryEvent(event)).toEqual({
|
|
104
|
+
eventId: '9',
|
|
105
|
+
eventTime: '1970-01-01T00:00:03Z',
|
|
106
|
+
startToCloseTimeout: '1s'
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
it('walks arrays without treating the parent key as a WKT field on items that are not seconds/nanos', () => {
|
|
110
|
+
expect(serializeHistoryEvent({
|
|
111
|
+
pendingActivities: [{ activityId: '1', lastHeartbeatTime: { seconds: '4' } }]
|
|
112
|
+
})).toEqual({
|
|
113
|
+
pendingActivities: [{ activityId: '1', lastHeartbeatTime: '1970-01-01T00:00:04Z' }]
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
it('rejects non-object events', () => {
|
|
117
|
+
expect(() => serializeHistoryEvent(null)).toThrow(/History event must be an object/);
|
|
118
|
+
expect(() => serializeHistoryEvent('nope')).toThrow(/History event must be an object/);
|
|
119
|
+
});
|
|
120
|
+
});
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outputai/cli",
|
|
3
|
-
"version": "0.18.1
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "CLI for Output.ai workflow generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"@oclif/core": "4.10.6",
|
|
25
25
|
"@oclif/plugin-help": "6.2.45",
|
|
26
26
|
"@temporalio/client": "1.24.0",
|
|
27
|
-
"@temporalio/common": "1.24.0",
|
|
28
27
|
"@temporalio/envconfig": "1.24.0",
|
|
29
28
|
"change-case": "5.4.4",
|
|
30
29
|
"cli-progress": "3.12.0",
|
|
@@ -40,9 +39,11 @@
|
|
|
40
39
|
"react": "19.3.0",
|
|
41
40
|
"semver": "7.8.5",
|
|
42
41
|
"undici": "8.12.3",
|
|
43
|
-
"@outputai/core": "0.18.1
|
|
42
|
+
"@outputai/core": "0.18.1"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
45
|
+
"@temporalio/common": "1.24.0",
|
|
46
|
+
"@temporalio/proto": "1.24.0",
|
|
46
47
|
"@types/cli-progress": "3.11.6",
|
|
47
48
|
"@types/debug": "4.1.13",
|
|
48
49
|
"@types/js-yaml": "4.0.9",
|