Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
Generic date + time inputs for integration steps — implementation plan
Spec / source: .ai/specs/implemented/2026-09-04-integration-datetime-inputs.md
Research: .ai/research/datetime-input-plumbing.md
Worktree: /Users/aashu/work/carbon/carbon-feat-active-pieces-integration
Progress
- Task 1: Declare
precisionon the three catalog input types - Task 2: Derive
precisionfrom the piece'sDATE_TIMEproperty - Task 3: Regenerate the workflow catalog
- Task 4: Render
DateTimePickerfor aprecision: "datetime"input - Task 5: Verify end to end
Dependencies
- Task 2 needs Task 1 (it sets a field Task 1 declares).
- Task 3 needs Tasks 1–2 (it regenerates from them) and MUST run before any typecheck that reads the generated catalog.
- Task 4 needs Task 1 (it reads
CatalogInput.precision); it is otherwise independent of Tasks 2–3 and may be done in parallel with them. - Task 5 needs everything.
Background the executor needs
precision?: "datetime" is a presentation-only flag. The input's ValueType
stays { kind: "primitive", of: "date" } — do NOT add a new PrimitiveKind, and do
not touch compare.ts, values.ts, OPERATORS_BY_TYPE or any switch over
PrimitiveKind. The runtime already accepts a full ISO instant for a date.
Two of the files on this path build their objects with hand-written field lists
rather than spreading, so an unlisted field is silently dropped:
packages/workflows/src/catalog/build.ts (buildDeclaredInputs) and
packages/jobs/src/workflows/integrations/catalog.ts (the declared literal).
Both are covered explicitly below.
Never use JavaScript Date anywhere in this work (.claude/rules/date-handling.md).
Use @internationalized/date, which is already a dependency of both erp and
packages/workflows.
Task 1: Declare precision on the three catalog input types
Depends on: none Files:
- Modify:
packages/workflows/src/catalog/actions.ts— addprecisiontoActionInputLike - Modify:
packages/workflows/src/catalog/build.ts— addprecisiontoBuiltActionInput, copy it inbuildDeclaredInputs, add a validation rule - Modify:
packages/workflows/src/definition/catalog.ts— addprecisiontoCatalogInput - Copy from (precedent): the existing
template?: booleanfield in all three of those files
Steps:
In
packages/workflows/src/catalog/actions.ts, ininterface ActionInputLike, immediately after thetemplate?: boolean;line (~line 13), add:/** The input is a moment, not a calendar day: the builder renders a date AND * time picker and stores a full ISO instant. Set from a vendor's `DATE_TIME` * property. Never set on a Carbon business date (`dueDate`, `orderDate`, * `postingDate`), which is a day on the company's calendar and has no time. */ precision?: "datetime";In
packages/workflows/src/catalog/build.ts, ininterface BuiltActionInput, immediately after itstemplate?: boolean;line (~line 91), add the SAME field with the same doc comment.In the same file, in
buildDeclaredInputs, inside theinputs[input] = { … }object literal, immediately after the line...(spec.template ? { template: true } : {}),add:...(spec.precision ? { precision: spec.precision } : {}),This literal does NOT spread
spec— without this line the flag never reaches the generated catalog.In the same file, in
validateCatalogInputs, immediately after the existingspec.template === true && …block that pushes`${id}.${input} is a template but is not a string.`, add the parallel rule:if ( spec.precision !== undefined && !(spec.type.kind === "primitive" && spec.type.of === "date") ) { problems.push(`${id}.${input} declares precision but is not a date.`); }In
packages/workflows/src/definition/catalog.ts, ininterface CatalogInput, immediately after itstemplate?: boolean;line (~line 65), add the SAME field with the same doc comment. This is the shape the builder UI reads.
Verify:
pnpm exec turbo run typecheck --filter=@carbon/workflows
# Expected: exits 0. (The flag is optional and nothing sets it yet, so nothing breaks.)
Out of scope: PrimitiveKind / primitiveKindSchema in definition/types.ts;
OPERATORS_BY_TYPE; compare.ts; values.ts; any zod schema (none covers catalog
input declarations); pickControl in fields/control.ts.
Task 2: Derive precision from the piece's DATE_TIME property
Depends on: Task 1 Files:
- Modify:
packages/jobs/src/workflows/integrations/properties.ts— addprecisiontoMappedProperty, set it in theDATE_TIMEcase - Modify:
packages/jobs/src/workflows/integrations/catalog.ts— copy it into the emitteddeclaredliteral - Modify:
packages/jobs/src/workflows/integrations/properties.test.ts— assert the new mapping - Copy from (precedent): how
template: trueis set inproperties.ts'sLONG_TEXTcase and merged incatalog.ts
Steps:
In
packages/jobs/src/workflows/integrations/properties.ts, ininterface MappedProperty, after thetemplate?: boolean;field (~line 41), add:/** The vendor declared a moment, not a day. The builder renders a date and time * picker; the stored value is a full ISO instant. */ precision?: "datetime";In the same file, in
toValueType, change theDATE_TIMEcase fromcase "DATE_TIME": return { ...base, type: DATE };to
// The vendor said DATE_TIME, not DATE. Dropping the time here is what left // Google Calendar's "Start date time of the event" with a date-only picker, // and made the value an underspecified instant the piece then read in the // WORKER's timezone. case "DATE_TIME": return { ...base, type: DATE, precision: "datetime" };This one line is what makes the fix generic — every piece declares its date-times as
DATE_TIME, so future pieces need no further edit.In
packages/jobs/src/workflows/integrations/catalog.ts, inside thedeclaredobject literal, immediately after the existing block...(mapped.template === true || override?.template === true ? { template: true } : {}),add:
...(mapped.precision === undefined ? {} : { precision: mapped.precision }),There is deliberately NO allowlist override for
precision— the vendor's own type is the signal, and an override would reintroduce the per-piece edit this change removes. Do not add a field toAllowlistPropOverride.In
packages/jobs/src/workflows/integrations/properties.test.ts, find the existing assertion near line 52 that readsexpect(map({ type: "DATE_TIME" }).type).toEqual({ … })and add a sibling assertion in the same test thatmap({ type: "DATE_TIME" }).precisionequals"datetime", plus one that aSHORT_TEXTproperty'sprecisionisundefined. Match the file's existing test style — read the surrounding cases first and follow them.
Verify:
cd /Users/aashu/work/carbon/carbon-feat-active-pieces-integration && pnpm exec turbo run typecheck --filter=@carbon/jobs && pnpm exec turbo run test --filter=@carbon/jobs
# Expected: typecheck exits 0; tests pass, including the new DATE_TIME precision assertions.
Out of scope: allowlist.ts (no override field); visibility.ts; outputs.ts
(a piece's format: "datetime" OUTPUT is a separate, already-working path — do not
touch it); toPropsValue (the value arrives already correct).
Task 3: Regenerate the workflow catalog
Depends on: Tasks 1 and 2
Files:
- Modify (generated, do NOT hand-edit):
packages/workflows/src/catalog/actions.generated.ts
Steps:
Run the generator:
cd /Users/aashu/work/carbon/carbon-feat-active-pieces-integration && pnpm run generate:workflow-catalogscripts/generate-workflow-catalog.tsemits viaJSON.stringify, so the new field carries automatically; the script then runs biome, which is why generated keys are unquoted.Inspect the diff and confirm it is limited to
precision: "datetime"appearing on integration inputs that came from aDATE_TIMEproperty, and on nothing else:git diff --stat packages/workflows/src/catalog/actions.generated.ts git diff packages/workflows/src/catalog/actions.generated.ts | grep '^[+-]' | grep -v '^[+-][+-]'Expect
+lines only, every one containingprecision: "datetime". Google Calendar'sstart_date_timeandend_date_timemust be among them.If any line changes something OTHER than adding
precision, STOP and report — do not improvise.Confirm no Carbon-native action input gained the flag: every
+line must sit insideWORKFLOW_INTEGRATION_CATALOG, notWORKFLOW_ACTION_CATALOG. (Carbon's owndueDate/orderDate/postingDateare built from the database schema bypropertyType, which never setsprecision.) If an action-catalog input gained it, STOP and report.
Verify:
cd /Users/aashu/work/carbon/carbon-feat-active-pieces-integration && pnpm run check:workflow-catalog
# Expected: exits 0. This uses assert.deepStrictEqual on the whole catalog, so it
# fails loudly if the generated file and the builders disagree.
Out of scope: hand-editing actions.generated.ts; events.generated.ts,
labels.generated.ts, help.generated.ts (this change adds no label or event).
Task 4: Render DateTimePicker for a precision: "datetime" input
Depends on: Task 1 (may run in parallel with Tasks 2–3) Files:
- Modify:
apps/erp/app/modules/workflows/ui/Builder/fields/types.ts— addprecisiontoValueFieldProps - Modify:
apps/erp/app/modules/workflows/ui/Builder/config/forms/StepInput.tsx— forwardinputDef.precision - Modify:
apps/erp/app/modules/workflows/ui/Builder/fields/ValueField.tsx— destructure and forward - Modify:
apps/erp/app/modules/workflows/ui/Builder/fields/LiteralControl.tsx— branch thedatecase - Copy from (precedent):
packages/form/src/components/DateTimePicker.tsx:60-86— the exactparseAbsolute→toCalendarDateTimeread andtoZoned(...).toAbsoluteString()write round-trip. Our version substitutesuseCompanyTimeZone()for that file'sgetLocalTimeZone().
Steps:
In
fields/types.ts, inValueFieldProps, immediately after thechoices?: readonly string[];line, add:/** The input is a moment, not a calendar day: render a date AND time picker * and store a full ISO instant, resolved against the company's timezone. */ precision?: "datetime";In
config/forms/StepInput.tsx, in the finalreturn (<ValueField … />)fallthrough, addprecision={inputDef.precision}immediately after the existingchoices={inputDef.choices}line. This prop list is hand-picked — without this lineValueFieldnever sees the flag.In
fields/ValueField.tsx:- add
precisionto the destructured props at the top of the component (alongsidechoices); - in the
<LiteralControl … />call in theelsebranch, addprecision={precision}immediately afterchoices={choices}.
- add
In
fields/LiteralControl.tsx:a. Extend the imports. From
@carbon/reactaddDateTimePickerto the existing import list. Replace the current@internationalized/dateimport (parseDate) with:import { parseAbsolute, parseDate, toCalendarDateTime, toZoned } from "@internationalized/date";and add:
import { useCompanyTimeZone } from "~/hooks";b. Beside the existing
asCalendarDatehelper, add a read helper. It must handle three cases: a full ISO instant (the new format), a legacyYYYY-MM-DDliteral saved before this change, and anything unparseable./** Stored datetimes are the full ISO instant the picker itself writes. A * value saved before datetime inputs existed is a bare `YYYY-MM-DD`, which * `parseAbsolute` rejects — read it as midnight on the company's calendar, * the moment it already effectively meant. Anything else leaves the picker * empty rather than crashing the node form. */ function asCalendarDateTime(value: unknown, timeZone: string) { if (typeof value !== "string" || !value) return null; try { return toCalendarDateTime(parseAbsolute(value, timeZone)); } catch { const date = asCalendarDate(value); return date ? toCalendarDateTime(date) : null; } }c. Add
precision?: "datetime";toLiteralControlProps(next tochoices) and destructure it in the component signature.d. Call the hook at the top of the component body, beside the existing
const { t } = useLingui();:const companyTimeZone = useCompanyTimeZone();It must be called unconditionally at the top level — never inside the
datebranch, which would violate the rules of hooks.e. Replace the existing
case "date":block with one that branches on the flag, keeping the date-only path byte-for-byte as it is today:case "date": { // A vendor's DATE_TIME. The picked wall clock is resolved against the // COMPANY's timezone, not the browser's — two admins in different offices // must not store different moments for the same typed time — and stored as // a full ISO instant, so the piece's own `dayjs(value).format(...)` // reproduces that moment whatever zone the worker runs in. if (precision === "datetime") { return shell( <DateTimePicker value={asCalendarDateTime(value, companyTimeZone)} onChange={(date) => emit( date ? toZoned(date, companyTimeZone).toAbsoluteString() : undefined ) } aria-label={t`Date and time`} isDisabled={isReadOnly} /> ); } return shell( <DatePicker value={asCalendarDate(value)} onChange={(date) => emit(date?.toString() ?? undefined)} aria-label={t`Date`} isDisabled={isReadOnly} /> ); }Note
DateTimePicker'sonChangemay be typed loosely (the form wrapper casts it). If TypeScript objects to the handler or tovalue, mirror whatever castpackages/form/src/components/DateTimePicker.tsxuses at its ownonChange={handleChange as any}call site rather than inventing a new one.f. The new
aria-labelstring uses Lingui'stmacro, consistent with every other label in this file. Do not introduce an untranslated English string.
Verify:
cd /Users/aashu/work/carbon/carbon-feat-active-pieces-integration && pnpm exec turbo run typecheck --filter=erp
# Expected: exits 0.
Out of scope: fields/control.ts pickControl (already returns "literal" for a
date — the choice between the two pickers is internal to LiteralControl);
ComputeForm.tsx (renders ValueField directly and passes no precision, so its
Carbon-typed date inputs correctly stay date-only); TemplateField,
MultiChoiceField, PairsField, OptionsField; packages/react's
DateTimePicker itself (use it as-is).
If useCompanyTimeZone cannot be imported from ~/hooks inside this file (a
circular import, or the builder rendering outside the /x layout), STOP and report —
do not fall back to getLocalTimeZone(), which would store a different moment
depending on who edited the workflow.
Task 5: Verify end to end
Depends on: Tasks 1–4
Steps:
Full scoped verification:
cd /Users/aashu/work/carbon/carbon-feat-active-pieces-integration pnpm exec turbo run typecheck --filter=@carbon/workflows --filter=@carbon/jobs --filter=erp pnpm run check:workflow-catalog pnpm run test pnpm run lintExpected: all four exit 0. (A whole-repo
pnpm run typecheckOOMs perAGENTS.md, so it stays scoped.)Confirm the round-trip logic directly, without a browser, by checking that a wall clock resolved in a company timezone reads back as the same wall clock:
cd /Users/aashu/work/carbon/carbon-feat-active-pieces-integration && pnpm exec tsx -e ' import { CalendarDateTime, parseAbsolute, toCalendarDateTime, toZoned } from "@internationalized/date"; const tz = "America/Chicago"; const typed = new CalendarDateTime(2026, 9, 10, 15, 0); const stored = toZoned(typed, tz).toAbsoluteString(); const readBack = toCalendarDateTime(parseAbsolute(stored, tz)); console.log("stored:", stored); console.log("reads back as:", readBack.toString()); console.log("same wall clock:", readBack.toString() === typed.toString()); ' # Expected: "same wall clock: true", and `stored` ends in a -05:00/-06:00 offset # (NOT a bare date, and NOT Z unless the company timezone is UTC).If
same wall clockis false, STOP and report — the read and write helpers disagree and every saved node would drift.Browser check in the real builder (ask the user before driving the app, per
AGENTS.md). Open a workflow, add an Integration node, pick Google Calendar → Create Event, and confirm each acceptance criterion in the spec:- "Start date time of the event" shows a calendar AND a time field;
- entering a date and
3:00 PM, saving, and re-opening the node shows3:00 PMagain; - "End date time of the event" also shows a time field;
- a Carbon-native action with a date input still shows the date-only picker.
Tick every box in the spec's Acceptance Criteria that now holds, and update the spec's changelog with an implementation line.
Out of scope: committing (the user commits — never run git commit without
explicit permission); moving the spec to .ai/specs/implemented/; running a
database migration (there is none).