@niscorp/tide 0.1.10 → 0.1.12

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/index.d.cts CHANGED
@@ -1,10 +1,11 @@
1
- import { F as FactInput, L as LoadReport, a as Fact, A as AdvanceReport, P as PreviewReport, R as Run, T as TaskState, b as Task, c as Retention, d as TideConfig, e as TideStore, f as ReflexState } from './types-lAPfp7JD.cjs';
2
- export { g as AttemptOutcome, C as COMPARISON_OPS, h as ClaimSpec, i as Comparison, E as EffectHandler, j as EffectRegistry, k as FactInputSchema, l as FactKind, m as FactKindSchema, M as Mutation, N as NewFact, O as Order, n as PRIMARY_KEY, o as PreviewCtx, p as PreviewUnit, Q as QuerySpec, q as RemoveSpec, r as Row, s as RunState, S as SelectCtx, t as SelectFn, u as TableName, v as TideCtx, w as TideEvent, x as TideTables, y as TransformFn, U as UNIQUE_BY, z as UniqueKey, W as Where } from './types-lAPfp7JD.cjs';
3
- import { R as Reflex, a as ReflexInput, b as ReflexDraft, T as Timer } from './reflex.schema-DW1znJfS.cjs';
4
- export { D as DRAFT_TRIGGERS, c as DraftChoice, d as DraftField, e as DraftTrigger, E as EffectRef, f as EffectRefSchema, g as ReflexDraftSchema, h as ReflexSchema, S as Selection, i as SelectionSchema, j as TimerSchema, k as TimerTriggerSchema, l as draftSchemaOf } from './reflex.schema-DW1znJfS.cjs';
1
+ import { F as FactInput, L as LoadReport, a as Fact, A as AdvanceReport, P as PreviewReport, R as Run, T as TaskState, b as Task, c as Retention, d as TideConfig, e as TideStore, f as ReflexState } from './types-Bpep20hD.cjs';
2
+ export { g as AttemptOutcome, C as COMPARISON_OPS, h as ClaimSpec, i as Comparison, E as EffectHandler, j as EffectRegistry, k as FactInputSchema, l as FactKind, m as FactKindSchema, n as LoadRefusal, M as Mutation, N as NewFact, O as Order, o as PRIMARY_KEY, p as PreviewCtx, q as PreviewUnit, Q as QuerySpec, r as RemoveSpec, s as Row, t as RunState, S as SelectCtx, u as SelectFn, v as TableName, w as TideCtx, x as TideError, y as TideErrorCode, z as TideEvent, B as TideTables, D as TransformFn, U as UNIQUE_BY, G as UniqueKey, W as Where, H as isTideError } from './types-Bpep20hD.cjs';
3
+ import { R as Reflex, a as ReflexInput, b as ReflexDraft, T as Timer } from './reflex.schema-wJ0MHKQn.cjs';
4
+ export { D as DRAFT_TRIGGERS, c as DraftChoice, d as DraftField, e as DraftTrigger, E as EffectRef, f as EffectRefSchema, g as REFLEX_TRIGGERS, h as ReflexDraftSchema, i as ReflexSchema, j as ReflexTrigger, S as Selection, k as SelectionSchema, l as TimerSchema, m as TimerTriggerSchema, n as draftSchemaOf, r as reflexSchemaOf } from './reflex.schema-wJ0MHKQn.cjs';
5
5
  import { z } from 'zod';
6
6
 
7
7
  declare const WEEKDAYS: readonly ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
8
+ declare const TimeZoneSchema: z.ZodString;
8
9
  declare const ClockUnitSchema: z.ZodEnum<{
9
10
  day: "day";
10
11
  week: "week";
@@ -201,6 +202,11 @@ type Edge = {
201
202
  to: string;
202
203
  via: string;
203
204
  };
205
+ type GraphRefusal = {
206
+ code: 'unknown_reflex' | 'unknown_effect' | 'unguarded_cycle';
207
+ message: string;
208
+ reflexIds: readonly string[];
209
+ };
204
210
  type GraphReport = {
205
211
  edges: readonly Edge[];
206
212
  cycles: readonly {
@@ -212,10 +218,7 @@ type GraphReport = {
212
218
  effect: string;
213
219
  }[];
214
220
  errors: readonly string[];
215
- refusals: readonly {
216
- code: 'unknown_reflex' | 'unknown_effect' | 'unguarded_cycle';
217
- message: string;
218
- }[];
221
+ refusals: readonly GraphRefusal[];
219
222
  warnings: readonly string[];
220
223
  };
221
224
 
@@ -234,6 +237,7 @@ type PreviewOptions = {
234
237
  type Tide = {
235
238
  load: (reflexes: readonly ReflexInput[], options?: {
236
239
  at?: number;
240
+ isolate?: boolean;
237
241
  }) => Promise<LoadReport>;
238
242
  reflexes: () => readonly Reflex[];
239
243
  graph: () => GraphReport;
@@ -276,14 +280,6 @@ type Tide = {
276
280
  };
277
281
  declare const createTide: (config: TideConfig) => Tide;
278
282
 
279
- type TideErrorCode = 'invalid_reflex' | 'invalid_fact' | 'duplicate_reflex' | 'unknown_reflex' | 'unknown_effect' | 'unguarded_cycle' | 'duplicate_unit' | 'no_transform' | 'store';
280
- declare class TideError extends Error {
281
- readonly code: TideErrorCode;
282
- readonly details?: unknown;
283
- constructor(code: TideErrorCode, message: string, details?: unknown);
284
- }
285
- declare const isTideError: (value: unknown) => value is TideError;
286
-
287
283
  type MemoryStore = TideStore & {
288
284
  snapshot: () => {
289
285
  facts: readonly Fact[];
@@ -341,4 +337,4 @@ declare const anchorDraft: (draft: ReflexDraft, anchor: {
341
337
  tz: string;
342
338
  }) => Reflex;
343
339
 
344
- export { type AdvanceOptions, AdvanceReport, type Clock, type ClockOnce, ClockOnceSchema, type ClockRecurring, ClockRecurringSchema, ClockTriggerSchema, ClockUnitSchema, type Edge, Fact, FactInput, type GraphReport, LoadReport, type LocalDay, type LocalParts, ManualTriggerSchema, type MemoryStore, type Occurrence, type Op, OpSchema, type Policy, PolicySchema, type PreviewOptions, PreviewReport, Reflex, ReflexDraft, ReflexInput, ReflexState, Retention, type Retry, RetrySchema, Run, RunTriggerSchema, SignalTriggerSchema, Task, TaskState, type Tide, TideConfig, type TideDriver, type TideDriverConfig, TideError, type TideErrorCode, TideStore, Timer, type Trigger, TriggerSchema, WEEKDAYS, type Weekday, WriteTriggerSchema, anchorDraft, createMemoryStore, createTide, createTideDriver, daysInMonth, isTideError, occurrenceKey, occurrencesBetween, timerMs, versionOf, zonedParts, zonedToUtc };
340
+ export { type AdvanceOptions, AdvanceReport, type Clock, type ClockOnce, ClockOnceSchema, type ClockRecurring, ClockRecurringSchema, ClockTriggerSchema, ClockUnitSchema, type Edge, Fact, FactInput, type GraphRefusal, type GraphReport, LoadReport, type LocalDay, type LocalParts, ManualTriggerSchema, type MemoryStore, type Occurrence, type Op, OpSchema, type Policy, PolicySchema, type PreviewOptions, PreviewReport, Reflex, ReflexDraft, ReflexInput, ReflexState, Retention, type Retry, RetrySchema, Run, RunTriggerSchema, SignalTriggerSchema, Task, TaskState, type Tide, TideConfig, type TideDriver, type TideDriverConfig, TideStore, TimeZoneSchema, Timer, type Trigger, TriggerSchema, WEEKDAYS, type Weekday, WriteTriggerSchema, anchorDraft, createMemoryStore, createTide, createTideDriver, daysInMonth, occurrenceKey, occurrencesBetween, timerMs, versionOf, zonedParts, zonedToUtc };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { F as FactInput, L as LoadReport, a as Fact, A as AdvanceReport, P as PreviewReport, R as Run, T as TaskState, b as Task, c as Retention, d as TideConfig, e as TideStore, f as ReflexState } from './types-lAPfp7JD.js';
2
- export { g as AttemptOutcome, C as COMPARISON_OPS, h as ClaimSpec, i as Comparison, E as EffectHandler, j as EffectRegistry, k as FactInputSchema, l as FactKind, m as FactKindSchema, M as Mutation, N as NewFact, O as Order, n as PRIMARY_KEY, o as PreviewCtx, p as PreviewUnit, Q as QuerySpec, q as RemoveSpec, r as Row, s as RunState, S as SelectCtx, t as SelectFn, u as TableName, v as TideCtx, w as TideEvent, x as TideTables, y as TransformFn, U as UNIQUE_BY, z as UniqueKey, W as Where } from './types-lAPfp7JD.js';
3
- import { R as Reflex, a as ReflexInput, b as ReflexDraft, T as Timer } from './reflex.schema-DW1znJfS.js';
4
- export { D as DRAFT_TRIGGERS, c as DraftChoice, d as DraftField, e as DraftTrigger, E as EffectRef, f as EffectRefSchema, g as ReflexDraftSchema, h as ReflexSchema, S as Selection, i as SelectionSchema, j as TimerSchema, k as TimerTriggerSchema, l as draftSchemaOf } from './reflex.schema-DW1znJfS.js';
1
+ import { F as FactInput, L as LoadReport, a as Fact, A as AdvanceReport, P as PreviewReport, R as Run, T as TaskState, b as Task, c as Retention, d as TideConfig, e as TideStore, f as ReflexState } from './types-Bpep20hD.js';
2
+ export { g as AttemptOutcome, C as COMPARISON_OPS, h as ClaimSpec, i as Comparison, E as EffectHandler, j as EffectRegistry, k as FactInputSchema, l as FactKind, m as FactKindSchema, n as LoadRefusal, M as Mutation, N as NewFact, O as Order, o as PRIMARY_KEY, p as PreviewCtx, q as PreviewUnit, Q as QuerySpec, r as RemoveSpec, s as Row, t as RunState, S as SelectCtx, u as SelectFn, v as TableName, w as TideCtx, x as TideError, y as TideErrorCode, z as TideEvent, B as TideTables, D as TransformFn, U as UNIQUE_BY, G as UniqueKey, W as Where, H as isTideError } from './types-Bpep20hD.js';
3
+ import { R as Reflex, a as ReflexInput, b as ReflexDraft, T as Timer } from './reflex.schema-wJ0MHKQn.js';
4
+ export { D as DRAFT_TRIGGERS, c as DraftChoice, d as DraftField, e as DraftTrigger, E as EffectRef, f as EffectRefSchema, g as REFLEX_TRIGGERS, h as ReflexDraftSchema, i as ReflexSchema, j as ReflexTrigger, S as Selection, k as SelectionSchema, l as TimerSchema, m as TimerTriggerSchema, n as draftSchemaOf, r as reflexSchemaOf } from './reflex.schema-wJ0MHKQn.js';
5
5
  import { z } from 'zod';
6
6
 
7
7
  declare const WEEKDAYS: readonly ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
8
+ declare const TimeZoneSchema: z.ZodString;
8
9
  declare const ClockUnitSchema: z.ZodEnum<{
9
10
  day: "day";
10
11
  week: "week";
@@ -201,6 +202,11 @@ type Edge = {
201
202
  to: string;
202
203
  via: string;
203
204
  };
205
+ type GraphRefusal = {
206
+ code: 'unknown_reflex' | 'unknown_effect' | 'unguarded_cycle';
207
+ message: string;
208
+ reflexIds: readonly string[];
209
+ };
204
210
  type GraphReport = {
205
211
  edges: readonly Edge[];
206
212
  cycles: readonly {
@@ -212,10 +218,7 @@ type GraphReport = {
212
218
  effect: string;
213
219
  }[];
214
220
  errors: readonly string[];
215
- refusals: readonly {
216
- code: 'unknown_reflex' | 'unknown_effect' | 'unguarded_cycle';
217
- message: string;
218
- }[];
221
+ refusals: readonly GraphRefusal[];
219
222
  warnings: readonly string[];
220
223
  };
221
224
 
@@ -234,6 +237,7 @@ type PreviewOptions = {
234
237
  type Tide = {
235
238
  load: (reflexes: readonly ReflexInput[], options?: {
236
239
  at?: number;
240
+ isolate?: boolean;
237
241
  }) => Promise<LoadReport>;
238
242
  reflexes: () => readonly Reflex[];
239
243
  graph: () => GraphReport;
@@ -276,14 +280,6 @@ type Tide = {
276
280
  };
277
281
  declare const createTide: (config: TideConfig) => Tide;
278
282
 
279
- type TideErrorCode = 'invalid_reflex' | 'invalid_fact' | 'duplicate_reflex' | 'unknown_reflex' | 'unknown_effect' | 'unguarded_cycle' | 'duplicate_unit' | 'no_transform' | 'store';
280
- declare class TideError extends Error {
281
- readonly code: TideErrorCode;
282
- readonly details?: unknown;
283
- constructor(code: TideErrorCode, message: string, details?: unknown);
284
- }
285
- declare const isTideError: (value: unknown) => value is TideError;
286
-
287
283
  type MemoryStore = TideStore & {
288
284
  snapshot: () => {
289
285
  facts: readonly Fact[];
@@ -341,4 +337,4 @@ declare const anchorDraft: (draft: ReflexDraft, anchor: {
341
337
  tz: string;
342
338
  }) => Reflex;
343
339
 
344
- export { type AdvanceOptions, AdvanceReport, type Clock, type ClockOnce, ClockOnceSchema, type ClockRecurring, ClockRecurringSchema, ClockTriggerSchema, ClockUnitSchema, type Edge, Fact, FactInput, type GraphReport, LoadReport, type LocalDay, type LocalParts, ManualTriggerSchema, type MemoryStore, type Occurrence, type Op, OpSchema, type Policy, PolicySchema, type PreviewOptions, PreviewReport, Reflex, ReflexDraft, ReflexInput, ReflexState, Retention, type Retry, RetrySchema, Run, RunTriggerSchema, SignalTriggerSchema, Task, TaskState, type Tide, TideConfig, type TideDriver, type TideDriverConfig, TideError, type TideErrorCode, TideStore, Timer, type Trigger, TriggerSchema, WEEKDAYS, type Weekday, WriteTriggerSchema, anchorDraft, createMemoryStore, createTide, createTideDriver, daysInMonth, isTideError, occurrenceKey, occurrencesBetween, timerMs, versionOf, zonedParts, zonedToUtc };
340
+ export { type AdvanceOptions, AdvanceReport, type Clock, type ClockOnce, ClockOnceSchema, type ClockRecurring, ClockRecurringSchema, ClockTriggerSchema, ClockUnitSchema, type Edge, Fact, FactInput, type GraphRefusal, type GraphReport, LoadReport, type LocalDay, type LocalParts, ManualTriggerSchema, type MemoryStore, type Occurrence, type Op, OpSchema, type Policy, PolicySchema, type PreviewOptions, PreviewReport, Reflex, ReflexDraft, ReflexInput, ReflexState, Retention, type Retry, RetrySchema, Run, RunTriggerSchema, SignalTriggerSchema, Task, TaskState, type Tide, TideConfig, type TideDriver, type TideDriverConfig, TideStore, TimeZoneSchema, Timer, type Trigger, TriggerSchema, WEEKDAYS, type Weekday, WriteTriggerSchema, anchorDraft, createMemoryStore, createTide, createTideDriver, daysInMonth, occurrenceKey, occurrencesBetween, timerMs, versionOf, zonedParts, zonedToUtc };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { UNIQUE_BY, PRIMARY_KEY, COMPARISON_OPS } from './chunk-7KHOAJNL.js';
2
- export { COMPARISON_OPS, PRIMARY_KEY, UNIQUE_BY } from './chunk-7KHOAJNL.js';
3
- import { isRecurring, ReflexSchema, FactInputSchema, clockOf, factOf, WEEKDAYS, isManual } from './chunk-ZEEJLISU.js';
4
- export { ClockOnceSchema, ClockRecurringSchema, ClockTriggerSchema, ClockUnitSchema, DRAFT_TRIGGERS, EffectRefSchema, FactInputSchema, FactKindSchema, ManualTriggerSchema, OpSchema, PolicySchema, ReflexDraftSchema, ReflexSchema, RetrySchema, RunTriggerSchema, SelectionSchema, SignalTriggerSchema, TimerSchema, TimerTriggerSchema, TriggerSchema, WEEKDAYS, WriteTriggerSchema, draftSchemaOf } from './chunk-ZEEJLISU.js';
1
+ import { UNIQUE_BY, PRIMARY_KEY, COMPARISON_OPS } from './chunk-MGGWP6C7.js';
2
+ export { COMPARISON_OPS, PRIMARY_KEY, UNIQUE_BY } from './chunk-MGGWP6C7.js';
3
+ import { isRecurring, ReflexSchema, FactInputSchema, clockOf, factOf, WEEKDAYS, isManual } from './chunk-SLLCUI65.js';
4
+ export { ClockOnceSchema, ClockRecurringSchema, ClockTriggerSchema, ClockUnitSchema, DRAFT_TRIGGERS, EffectRefSchema, FactInputSchema, FactKindSchema, ManualTriggerSchema, OpSchema, PolicySchema, REFLEX_TRIGGERS, ReflexDraftSchema, ReflexSchema, RetrySchema, RunTriggerSchema, SelectionSchema, SignalTriggerSchema, TimeZoneSchema, TimerSchema, TimerTriggerSchema, TriggerSchema, WEEKDAYS, WriteTriggerSchema, draftSchemaOf, reflexSchemaOf } from './chunk-SLLCUI65.js';
5
5
 
6
6
  // src/errors.ts
7
7
  var TideError = class extends Error {
@@ -73,13 +73,13 @@ var buildGraph = (reflexes, effects) => {
73
73
  const existing = runWatchers.get(fact.run) ?? [];
74
74
  runWatchers.set(fact.run, [...existing, reflex.id]);
75
75
  if (fact.run === reflex.id) warnings.push(`${reflex.id} subscribes to its own run \u2014 a drain loop; make sure it narrows`);
76
- if (!byId.has(fact.run)) refusals.push({ code: "unknown_reflex", message: `${reflex.id} watches the run of unknown reflex "${fact.run}"` });
76
+ if (!byId.has(fact.run)) refusals.push({ code: "unknown_reflex", message: `${reflex.id} watches the run of unknown reflex "${fact.run}"`, reflexIds: [reflex.id] });
77
77
  }
78
78
  }
79
79
  for (const reflex of reflexes) {
80
80
  const handler = effects[reflex.effect.name];
81
81
  if (handler === void 0) {
82
- refusals.push({ code: "unknown_effect", message: `${reflex.id} names effect "${reflex.effect.name}", which is not registered` });
82
+ refusals.push({ code: "unknown_effect", message: `${reflex.id} names effect "${reflex.effect.name}", which is not registered`, reflexIds: [reflex.id] });
83
83
  continue;
84
84
  }
85
85
  if (handler.writes === void 0) {
@@ -102,7 +102,8 @@ var buildGraph = (reflexes, effects) => {
102
102
  if (!cycle.guarded)
103
103
  refusals.push({
104
104
  code: "unguarded_cycle",
105
- message: `unguarded cycle: ${cycle.reflexIds.join(" \u2192 ")} \u2192 ${cycle.reflexIds[0]} \u2014 no selection and no \`when\` anywhere on the loop, so it diverges by construction`
105
+ message: `unguarded cycle: ${cycle.reflexIds.join(" \u2192 ")} \u2192 ${cycle.reflexIds[0]} \u2014 no selection and no \`when\` anywhere on the loop, so it diverges by construction`,
106
+ reflexIds: cycle.reflexIds
106
107
  });
107
108
  return { edges, cycles, blind, errors: refusals.map((refusal) => refusal.message), refusals, warnings };
108
109
  };
@@ -158,6 +159,46 @@ var findCycles = (reflexes, edges) => {
158
159
  });
159
160
  };
160
161
 
162
+ // src/engine/admit.ts
163
+ var idOf = (candidate) => typeof candidate === "object" && candidate !== null && "id" in candidate && typeof candidate.id === "string" ? candidate.id : void 0;
164
+ var admitReflexes = ({
165
+ input,
166
+ effectsOf,
167
+ isolate
168
+ }) => {
169
+ const parsed = [];
170
+ const refused = [];
171
+ const seen = /* @__PURE__ */ new Set();
172
+ for (const candidate of input) {
173
+ const result = ReflexSchema.safeParse(candidate);
174
+ if (!result.success) {
175
+ const message = `reflex did not parse: ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`;
176
+ if (!isolate) throw new TideError("invalid_reflex", message, { issues: result.error.issues });
177
+ refused.push({ reflexId: idOf(candidate), code: "invalid_reflex", message });
178
+ continue;
179
+ }
180
+ if (seen.has(result.data.id)) {
181
+ const message = `duplicate reflex id "${result.data.id}"`;
182
+ if (!isolate) throw new TideError("duplicate_reflex", message);
183
+ refused.push({ reflexId: result.data.id, code: "duplicate_reflex", message });
184
+ continue;
185
+ }
186
+ seen.add(result.data.id);
187
+ parsed.push(result.data);
188
+ }
189
+ let kept = parsed;
190
+ let graph = buildGraph(kept, effectsOf(kept));
191
+ for (let [first] = graph.refusals; first !== void 0; [first] = graph.refusals) {
192
+ if (!isolate) throw new TideError(first.code, `tide refused to load:
193
+ ${graph.errors.join("\n ")}`, { errors: graph.errors, refusals: graph.refusals });
194
+ const out = new Set(graph.refusals.flatMap((refusal) => refusal.reflexIds));
195
+ for (const refusal of graph.refusals) for (const reflexId of refusal.reflexIds) refused.push({ reflexId, code: refusal.code, message: refusal.message });
196
+ kept = kept.filter((reflex) => !out.has(reflex.id));
197
+ graph = buildGraph(kept, effectsOf(kept));
198
+ }
199
+ return { reflexes: kept, graph, refused };
200
+ };
201
+
161
202
  // src/engine/occurrence.ts
162
203
  var HALF_DAY_MS = 432e5;
163
204
  var DAY_MS = 864e5;
@@ -964,23 +1005,7 @@ var createTide = (config) => {
964
1005
  }
965
1006
  };
966
1007
  const load = async (input, options) => {
967
- const parsed = [];
968
- const seen = /* @__PURE__ */ new Set();
969
- for (const candidate of input) {
970
- const result = ReflexSchema.safeParse(candidate);
971
- if (!result.success)
972
- throw new TideError("invalid_reflex", `reflex did not parse: ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`, {
973
- issues: result.error.issues
974
- });
975
- if (seen.has(result.data.id)) throw new TideError("duplicate_reflex", `duplicate reflex id "${result.data.id}"`);
976
- seen.add(result.data.id);
977
- parsed.push(result.data);
978
- }
979
- const graph = buildGraph(parsed, mergedEffects(parsed));
980
- const refused = graph.refusals[0];
981
- if (refused !== void 0)
982
- throw new TideError(refused.code, `tide refused to load:
983
- ${graph.errors.join("\n ")}`, { errors: graph.errors, refusals: graph.refusals });
1008
+ const { reflexes: parsed, graph, refused } = admitReflexes({ input, effectsOf: mergedEffects, isolate: options?.isolate === true });
984
1009
  const previously = new Set(loaded.keys());
985
1010
  const next = /* @__PURE__ */ new Map();
986
1011
  for (const reflex of parsed) {
@@ -993,7 +1018,7 @@ var createTide = (config) => {
993
1018
  }
994
1019
  loaded.clear();
995
1020
  for (const [id, entry] of next) loaded.set(id, entry);
996
- return { loaded: parsed.length, cycles: graph.cycles, blind: graph.blind, warnings: graph.warnings };
1021
+ return { loaded: parsed.length, cycles: graph.cycles, blind: graph.blind, warnings: graph.warnings, refused };
997
1022
  };
998
1023
  const mergedEffects = (parsed) => {
999
1024
  if (typeof config.effects !== "function") return config.effects ?? {};
@@ -1361,7 +1386,11 @@ var localDateTime = (instant, tz) => {
1361
1386
  var anchorDraft = (draft, anchor) => {
1362
1387
  if (!("timer" in draft.on)) return ReflexSchema.parse(draft);
1363
1388
  const fires = Math.ceil((anchor.at + timerMs(draft.on.timer)) / 1e3) * 1e3;
1364
- return ReflexSchema.parse({ ...draft, on: { clock: { at: localDateTime(fires, anchor.tz), tz: anchor.tz } } });
1389
+ return ReflexSchema.parse({ ...draft, on: { clock: clockAt(fires, anchor.tz) } });
1390
+ };
1391
+ var clockAt = (fires, tz) => {
1392
+ const local = { at: localDateTime(fires, tz), tz };
1393
+ return occurrencesBetween(local, fires - 1e3, fires, 1)[0]?.at === fires ? local : { at: localDateTime(fires, "UTC"), tz: "UTC" };
1365
1394
  };
1366
1395
 
1367
1396
  export { TideError, anchorDraft, createMemoryStore, createTide, createTideDriver, daysInMonth, isTideError, occurrenceKey, occurrencesBetween, timerMs, versionOf, zonedParts, zonedToUtc };