Skip to content

Commit 101fa8b

Browse files
authored
Merge branch 'main' into main
2 parents 61aea5f + c738ef3 commit 101fa8b

File tree

6 files changed

+55
-15
lines changed

6 files changed

+55
-15
lines changed

.changeset/new-items-glow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
OTEL attributes can include Dates that will be formatted as ISO strings

.github/workflows/e2e.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
matrix:
1818
os: [buildjet-8vcpu-ubuntu-2204, windows-latest]
1919
package-manager: ["npm", "pnpm", "yarn"]
20+
env:
21+
YARN_ENABLE_IMMUTABLE_INSTALLS: false
2022
steps:
2123
- name: ⬇️ Checkout repo
2224
uses: actions/checkout@v3

apps/webapp/app/presenters/v3/ApiRunListPresenter.server.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,27 @@ import { ApiRetrieveRunPresenter } from "./ApiRetrieveRunPresenter.server";
88
import { RunListOptions, RunListPresenter } from "./RunListPresenter.server";
99
import { BasePresenter } from "./basePresenter.server";
1010

11+
const CoercedDate = z.preprocess((arg) => {
12+
if (arg === undefined || arg === null) {
13+
return;
14+
}
15+
16+
if (typeof arg === "number") {
17+
return new Date(arg);
18+
}
19+
20+
if (typeof arg === "string") {
21+
const num = Number(arg);
22+
if (!isNaN(num)) {
23+
return new Date(num);
24+
}
25+
26+
return new Date(arg);
27+
}
28+
29+
return arg;
30+
}, z.date().optional());
31+
1132
const SearchParamsSchema = z.object({
1233
"page[size]": z.coerce.number().int().positive().min(1).max(100).optional(),
1334
"page[after]": z.string().optional(),
@@ -95,8 +116,8 @@ const SearchParamsSchema = z.object({
95116

96117
return z.NEVER;
97118
}),
98-
"filter[createdAt][from]": z.coerce.date().optional(),
99-
"filter[createdAt][to]": z.coerce.date().optional(),
119+
"filter[createdAt][from]": CoercedDate,
120+
"filter[createdAt][to]": CoercedDate,
100121
"filter[createdAt][period]": z.string().optional(),
101122
});
102123

packages/cli-v3/e2e/fixtures/monorepo-react-email/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "monorepo-react-email",
33
"private": true,
4-
"packageManager": "[email protected]+sha256.4b4efa12490e5055d59b9b9fc9438b7d581a6b7af3b5675eb5c5f447cee1a589",
4+
"packageManager": "[email protected]+sha256.1aa43a5304405be7a7cb9cb5de7b97de9c4e8ddd3273e4dad00d6ae3eb39f0ef",
55
"engines": {
66
"pnpm": "8.15.5",
77
"yarn": "4.2.2"

packages/core/src/v3/utils/flattenAttributes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ export function flattenAttributes(
3333
return result;
3434
}
3535

36+
if (obj instanceof Date) {
37+
result[prefix || ""] = obj.toISOString();
38+
return result;
39+
}
40+
3641
for (const [key, value] of Object.entries(obj)) {
3742
const newPrefix = `${prefix ? `${prefix}.` : ""}${Array.isArray(obj) ? `[${key}]` : key}`;
3843
if (Array.isArray(value)) {

references/v3-catalog/src/trigger/tags.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { RunTags } from "@trigger.dev/core/v3";
2-
import { logger, runs, tags, task, tasks } from "@trigger.dev/sdk/v3";
3-
import { simpleChildTask } from "./subtasks";
1+
import { logger, runs, task, tasks } from "@trigger.dev/sdk/v3";
2+
import { simpleChildTask } from "./subtasks.js";
43

54
type Payload = {
6-
tags: RunTags;
5+
tags: string | string[];
76
};
87

98
export const triggerRunsWithTags = task({
@@ -16,6 +15,22 @@ export const triggerRunsWithTags = task({
1615
{ tags: payload.tags }
1716
);
1817

18+
//runs in the past 5 seconds, as a date
19+
const from = new Date();
20+
from.setSeconds(from.getSeconds() - 5);
21+
const result2 = await runs.list({ tag: payload.tags, from });
22+
logger.log("list with Date()", { length: result2.data.length, data: result2.data });
23+
24+
//runs in the past 5 seconds, as a number timestamp
25+
const result3 = await runs.list({ tag: payload.tags, from: from.getTime() - 5000 });
26+
logger.log("list with timestamp", { length: result3.data.length, data: result3.data });
27+
28+
logger.log("run usage", {
29+
costInCents: result2.data[0].costInCents,
30+
baseCostInCents: result2.data[0].baseCostInCents,
31+
durationMs: result2.data[0].durationMs,
32+
});
33+
1934
await simpleChildTask.triggerAndWait(
2035
{ message: "triggerAndWait from triggerRunsWithTags" },
2136
{ tags: payload.tags }
@@ -71,13 +86,5 @@ export const triggerRunsWithTags = task({
7186
baseCostInCents: run.baseCostInCents,
7287
durationMs: run.durationMs,
7388
});
74-
75-
const result2 = await runs.list({ tag: payload.tags });
76-
logger.log("trigger runs ", { length: result2.data.length, data: result2.data });
77-
logger.log("run usage", {
78-
costInCents: result2.data[0].costInCents,
79-
baseCostInCents: result2.data[0].baseCostInCents,
80-
durationMs: result2.data[0].durationMs,
81-
});
8289
},
8390
});

0 commit comments

Comments
 (0)