@anchrd/intel-contract 0.7.0 → 0.8.0

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.
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod";
2
2
  export declare const IntelId: z.ZodString;
3
3
  export declare const IsoDateTime: z.ZodISODateTime;
4
+ export declare const UI_LANGUAGES: readonly ["en", "de", "es"];
5
+ export type UiLanguage = (typeof UI_LANGUAGES)[number];
4
6
  export declare const ProblemDetails: z.ZodObject<{
5
7
  type: z.ZodString;
6
8
  status: z.ZodNumber;
@@ -478,6 +480,7 @@ export declare const AgentScheduleTarget: z.ZodObject<{
478
480
  export type AgentScheduleTarget = z.infer<typeof AgentScheduleTarget>;
479
481
  export declare const AgentSchedule: z.ZodObject<{
480
482
  cron: z.ZodString;
483
+ timezone: z.ZodDefault<z.ZodString>;
481
484
  target: z.ZodObject<{
482
485
  kind: z.ZodEnum<{
483
486
  document: "document";
@@ -553,6 +556,7 @@ export declare const AgentDefinition: z.ZodObject<{
553
556
  }, z.core.$strict>>>;
554
557
  schedules: z.ZodDefault<z.ZodArray<z.ZodObject<{
555
558
  cron: z.ZodString;
559
+ timezone: z.ZodDefault<z.ZodString>;
556
560
  target: z.ZodObject<{
557
561
  kind: z.ZodEnum<{
558
562
  document: "document";
@@ -595,6 +599,7 @@ export declare const AgentDefinitionInput: z.ZodObject<{
595
599
  }, z.core.$strict>>>;
596
600
  schedules: z.ZodDefault<z.ZodArray<z.ZodObject<{
597
601
  cron: z.ZodString;
602
+ timezone: z.ZodDefault<z.ZodString>;
598
603
  target: z.ZodObject<{
599
604
  kind: z.ZodEnum<{
600
605
  document: "document";
@@ -629,6 +634,7 @@ export declare const SaveAgentDefinitionInput: z.ZodObject<{
629
634
  }, z.core.$strict>>>;
630
635
  schedules: z.ZodDefault<z.ZodArray<z.ZodObject<{
631
636
  cron: z.ZodString;
637
+ timezone: z.ZodDefault<z.ZodString>;
632
638
  target: z.ZodObject<{
633
639
  kind: z.ZodEnum<{
634
640
  document: "document";
@@ -690,6 +696,7 @@ export declare const CreateAgentInput: z.ZodObject<{
690
696
  }, z.core.$strict>>>;
691
697
  schedules: z.ZodDefault<z.ZodArray<z.ZodObject<{
692
698
  cron: z.ZodString;
699
+ timezone: z.ZodDefault<z.ZodString>;
693
700
  target: z.ZodObject<{
694
701
  kind: z.ZodEnum<{
695
702
  document: "document";
@@ -759,6 +766,7 @@ export declare const NodeAgent: z.ZodObject<{
759
766
  }, z.core.$strict>>>;
760
767
  schedules: z.ZodDefault<z.ZodArray<z.ZodObject<{
761
768
  cron: z.ZodString;
769
+ timezone: z.ZodDefault<z.ZodString>;
762
770
  target: z.ZodObject<{
763
771
  kind: z.ZodEnum<{
764
772
  document: "document";
@@ -842,6 +850,7 @@ export declare const CreatedAgent: z.ZodObject<{
842
850
  }, z.core.$strict>>>;
843
851
  schedules: z.ZodDefault<z.ZodArray<z.ZodObject<{
844
852
  cron: z.ZodString;
853
+ timezone: z.ZodDefault<z.ZodString>;
845
854
  target: z.ZodObject<{
846
855
  kind: z.ZodEnum<{
847
856
  document: "document";
@@ -1,6 +1,14 @@
1
1
  import { z } from "zod";
2
2
  export const IntelId = z.string().min(1).max(128);
3
3
  export const IsoDateTime = z.iso.datetime({ offset: true });
4
+ // The languages whose UI catalog ships inside intel-ui. They live here rather than only in the UI
5
+ // because `intel build` has to know them: a built-in language may be chosen as `ui.defaultLanguage`
6
+ // without the customer listing a copy under `ui.languages` that would rot at every UI update.
7
+ //
8
+ // ⚠️ The list is a claim about the contents of packages/ui/src/i18n and cannot be checked here.
9
+ // `i18n.unit.ts` compares it against the catalogs actually built in; a language listed here without
10
+ // a file gives a red run there instead of a UI that starts on a catalog which does not exist.
11
+ export const UI_LANGUAGES = ["en", "de", "es"];
4
12
  export const ProblemDetails = z.strictObject({
5
13
  type: z.string(),
6
14
  status: z.number().int().min(400).max(599),
@@ -283,8 +291,42 @@ export const AgentScheduleTarget = z.strictObject({
283
291
  kind: z.enum(["document", "flow"]),
284
292
  id: IntelId,
285
293
  });
294
+ /**
295
+ * ⚠️ `timezone` is what the cron expression is READ IN, and it belongs to the schedule rather than
296
+ * to whoever is looking at it (#228). "Every morning at eight" means eight o'clock where the person
297
+ * who wrote it sits — in Berlin that is 06:00 UTC in summer and 07:00 in winter, and a field that
298
+ * does not carry the zone cannot express that difference. A UTC cron is an hour wrong twice a year
299
+ * and nobody sees why.
300
+ *
301
+ * The UI suggests the reader's own zone when a schedule is created, but it is not a per-user
302
+ * setting: an agent's schedule would otherwise move whenever its owner travelled, and it would mean
303
+ * different times to two people reading the same definition. What is stored is the answer.
304
+ *
305
+ * ⚠️ The default is `"UTC"`, and it is load-bearing rather than tidy: every definition written
306
+ * before this field parses to it and therefore keeps firing exactly when it did. A default of
307
+ * "whatever the writer's browser says" would silently move every existing schedule at the next save.
308
+ *
309
+ * The name is validated against this runtime's own tz database rather than a pattern. A regular
310
+ * expression would accept `Mars/Olympus`, and the failure would surface inside a Durable Object
311
+ * alarm — the place where nobody is watching.
312
+ */
313
+ const IanaTimezone = z
314
+ .string()
315
+ .trim()
316
+ .min(1)
317
+ .max(64)
318
+ .refine((zone) => {
319
+ try {
320
+ new Intl.DateTimeFormat("en-US", { timeZone: zone });
321
+ return true;
322
+ }
323
+ catch {
324
+ return false;
325
+ }
326
+ }, { message: "must be an IANA timezone name this runtime knows, for example Europe/Berlin" });
286
327
  export const AgentSchedule = z.strictObject({
287
328
  cron: z.string().trim().min(1).max(120),
329
+ timezone: IanaTimezone.default("UTC"),
288
330
  target: AgentScheduleTarget,
289
331
  });
290
332
  export const AgentModel = z.strictObject({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anchrd/intel-contract",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {