@heynixie/contract 0.75.0 → 0.76.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.
@@ -425,7 +425,9 @@ export declare function buildQueryUtils(client: ContractClient): {
425
425
  started: number;
426
426
  };
427
427
  brief: string;
428
+ closedBy?: "disposable" | "nixie" | "owner" | undefined;
428
429
  controls: ("close" | "interrupt" | "pause" | "restart" | "resume" | "stop")[];
430
+ disposable: boolean | null;
429
431
  isPauseRequested: boolean;
430
432
  isPausedByNixie: boolean;
431
433
  isTakingMessages: boolean;
@@ -451,7 +453,9 @@ export declare function buildQueryUtils(client: ContractClient): {
451
453
  started: number;
452
454
  };
453
455
  brief: string;
456
+ closedBy?: "disposable" | "nixie" | "owner" | undefined;
454
457
  controls: ("close" | "interrupt" | "pause" | "restart" | "resume" | "stop")[];
458
+ disposable: boolean | null;
455
459
  isPauseRequested: boolean;
456
460
  isPausedByNixie: boolean;
457
461
  isTakingMessages: boolean;
@@ -791,6 +795,54 @@ export declare function buildQueryUtils(client: ContractClient): {
791
795
  clientActionID: string;
792
796
  taskID: string;
793
797
  }>;
798
+ setDisposable: import("@orpc/tanstack-query").ProcedureUtils<Record<never, never>, {
799
+ clientActionID: string;
800
+ disposable: boolean;
801
+ taskID: string;
802
+ }, {
803
+ changedAt: Date;
804
+ disposable: boolean;
805
+ taskID: string;
806
+ }, import("@orpc/contract").ErrorFromErrorMap<import("@orpc/contract").MergedErrorMap<import("@orpc/contract").MergedErrorMap<import("@orpc/contract").MergedErrorMap<Record<never, never>, {
807
+ UNAUTHORIZED: {
808
+ message: string;
809
+ status: number;
810
+ };
811
+ }>, {
812
+ CLIENT_ACTION_ID_REUSED: {
813
+ message: string;
814
+ status: number;
815
+ };
816
+ }>, {
817
+ TASK_NOT_FOUND: {
818
+ message: string;
819
+ status: number;
820
+ };
821
+ TASK_HAS_NO_MARK: {
822
+ message: string;
823
+ status: number;
824
+ };
825
+ TASK_STATE_REFUSED: {
826
+ message: string;
827
+ status: number;
828
+ data: import("zod").ZodObject<{
829
+ state: import("zod").ZodEnum<{
830
+ closed: "closed";
831
+ done: "done";
832
+ failed: "failed";
833
+ paused: "paused";
834
+ ready: "ready";
835
+ running: "running";
836
+ stopped: "stopped";
837
+ waiting: "waiting";
838
+ }>;
839
+ }, import("zod/v4/core").$strip>;
840
+ };
841
+ }>>> & import("@orpc/tanstack-query").GeneralUtils<{
842
+ clientActionID: string;
843
+ disposable: boolean;
844
+ taskID: string;
845
+ }>;
794
846
  } & import("@orpc/tanstack-query").GeneralUtils<unknown>;
795
847
  memory: {
796
848
  export: import("@orpc/tanstack-query").ProcedureUtils<Record<never, never>, {
@@ -441,6 +441,11 @@ export declare const contract: {
441
441
  started: z.ZodInt;
442
442
  }, z.core.$strip>;
443
443
  brief: z.ZodString;
444
+ closedBy: z.ZodOptional<z.ZodEnum<{
445
+ disposable: "disposable";
446
+ nixie: "nixie";
447
+ owner: "owner";
448
+ }>>;
444
449
  controls: z.ZodArray<z.ZodEnum<{
445
450
  close: "close";
446
451
  interrupt: "interrupt";
@@ -449,6 +454,7 @@ export declare const contract: {
449
454
  resume: "resume";
450
455
  stop: "stop";
451
456
  }>>;
457
+ disposable: z.ZodNullable<z.ZodBoolean>;
452
458
  isPauseRequested: z.ZodBoolean;
453
459
  isPausedByNixie: z.ZodBoolean;
454
460
  isTakingMessages: z.ZodBoolean;
@@ -483,6 +489,11 @@ export declare const contract: {
483
489
  started: z.ZodInt;
484
490
  }, z.core.$strip>;
485
491
  brief: z.ZodString;
492
+ closedBy: z.ZodOptional<z.ZodEnum<{
493
+ disposable: "disposable";
494
+ nixie: "nixie";
495
+ owner: "owner";
496
+ }>>;
486
497
  controls: z.ZodArray<z.ZodEnum<{
487
498
  close: "close";
488
499
  interrupt: "interrupt";
@@ -491,6 +502,7 @@ export declare const contract: {
491
502
  resume: "resume";
492
503
  stop: "stop";
493
504
  }>>;
505
+ disposable: z.ZodNullable<z.ZodBoolean>;
494
506
  isPauseRequested: z.ZodBoolean;
495
507
  isPausedByNixie: z.ZodBoolean;
496
508
  isTakingMessages: z.ZodBoolean;
@@ -871,6 +883,50 @@ export declare const contract: {
871
883
  status: number;
872
884
  };
873
885
  }>, Record<never, never>>;
886
+ setDisposable: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
887
+ clientActionID: z.ZodUUID;
888
+ disposable: z.ZodBoolean;
889
+ taskID: z.ZodString;
890
+ }, z.core.$strip>, z.ZodObject<{
891
+ changedAt: z.ZodDate;
892
+ disposable: z.ZodBoolean;
893
+ taskID: z.ZodString;
894
+ }, z.core.$strip>, import("@orpc/contract").MergedErrorMap<import("@orpc/contract").MergedErrorMap<import("@orpc/contract").MergedErrorMap<Record<never, never>, {
895
+ UNAUTHORIZED: {
896
+ message: string;
897
+ status: number;
898
+ };
899
+ }>, {
900
+ CLIENT_ACTION_ID_REUSED: {
901
+ message: string;
902
+ status: number;
903
+ };
904
+ }>, {
905
+ TASK_NOT_FOUND: {
906
+ message: string;
907
+ status: number;
908
+ };
909
+ TASK_HAS_NO_MARK: {
910
+ message: string;
911
+ status: number;
912
+ };
913
+ TASK_STATE_REFUSED: {
914
+ message: string;
915
+ status: number;
916
+ data: z.ZodObject<{
917
+ state: z.ZodEnum<{
918
+ closed: "closed";
919
+ done: "done";
920
+ failed: "failed";
921
+ paused: "paused";
922
+ ready: "ready";
923
+ running: "running";
924
+ stopped: "stopped";
925
+ waiting: "waiting";
926
+ }>;
927
+ }, z.core.$strip>;
928
+ };
929
+ }>, Record<never, never>>;
874
930
  };
875
931
  memory: {
876
932
  export: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ export declare const scheduleSchema: z.ZodObject<{
3
+ every: z.ZodUnion<readonly [z.ZodEnum<{
4
+ day: "day";
5
+ hour: "hour";
6
+ week: "week";
7
+ }>, z.ZodObject<{
8
+ minutes: z.ZodInt;
9
+ }, z.core.$strict>]>;
10
+ at: z.ZodOptional<z.ZodString>;
11
+ on: z.ZodOptional<z.ZodEnum<{
12
+ fri: "fri";
13
+ mon: "mon";
14
+ sat: "sat";
15
+ sun: "sun";
16
+ thu: "thu";
17
+ tue: "tue";
18
+ wed: "wed";
19
+ }>>;
20
+ window: z.ZodOptional<z.ZodObject<{
21
+ from: z.ZodString;
22
+ until: z.ZodString;
23
+ }, z.core.$strict>>;
24
+ idleMinutes: z.ZodOptional<z.ZodInt>;
25
+ zone: z.ZodDefault<z.ZodString>;
26
+ catchUp: z.ZodDefault<z.ZodEnum<{
27
+ once: "once";
28
+ skip: "skip";
29
+ }>>;
30
+ }, z.core.$strict>;
31
+ export type Schedule = z.output<typeof scheduleSchema>;
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ export declare const triggerAtSchema: z.ZodISODateTime;
3
+ export declare const triggerSchema: z.ZodUnion<readonly [z.ZodObject<{
4
+ schedule: z.ZodObject<{
5
+ every: z.ZodUnion<readonly [z.ZodEnum<{
6
+ day: "day";
7
+ hour: "hour";
8
+ week: "week";
9
+ }>, z.ZodObject<{
10
+ minutes: z.ZodInt;
11
+ }, z.core.$strict>]>;
12
+ at: z.ZodOptional<z.ZodString>;
13
+ on: z.ZodOptional<z.ZodEnum<{
14
+ fri: "fri";
15
+ mon: "mon";
16
+ sat: "sat";
17
+ sun: "sun";
18
+ thu: "thu";
19
+ tue: "tue";
20
+ wed: "wed";
21
+ }>>;
22
+ window: z.ZodOptional<z.ZodObject<{
23
+ from: z.ZodString;
24
+ until: z.ZodString;
25
+ }, z.core.$strict>>;
26
+ idleMinutes: z.ZodOptional<z.ZodInt>;
27
+ zone: z.ZodDefault<z.ZodString>;
28
+ catchUp: z.ZodDefault<z.ZodEnum<{
29
+ once: "once";
30
+ skip: "skip";
31
+ }>>;
32
+ }, z.core.$strict>;
33
+ }, z.core.$strict>, z.ZodObject<{
34
+ at: z.ZodISODateTime;
35
+ }, z.core.$strict>]>;
36
+ export type Trigger = z.output<typeof triggerSchema>;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,10 @@ export { contract } from './contract/contract.js';
8
8
  export { hostContract } from './contract/host-contract.js';
9
9
  export { imageLimits } from './contract/image-limits.js';
10
10
  export { isTimeZone } from './contract/is-time-zone.js';
11
+ export type { Schedule } from './contract/schedule-schema.js';
12
+ export { scheduleSchema } from './contract/schedule-schema.js';
13
+ export type { Trigger } from './contract/trigger-schema.js';
14
+ export { triggerAtSchema, triggerSchema } from './contract/trigger-schema.js';
11
15
  export { pickSpanSource } from './span/pick-span-source.js';
12
16
  export { renderSessionCookie } from './contract/render-session-cookie.js';
13
17
  export { sessionCookieName } from './contract/session-cookie-name.js';
package/dist/index.js CHANGED
@@ -1244,7 +1244,9 @@ var listedTaskSchema = z26.object({
1244
1244
  started: actionCountSchema
1245
1245
  }),
1246
1246
  brief: z26.string(),
1247
+ closedBy: z26.enum(["owner", "nixie", "disposable"]).optional(),
1247
1248
  controls: z26.array(taskControlSchema),
1249
+ disposable: z26.boolean().nullable(),
1248
1250
  isPauseRequested: z26.boolean(),
1249
1251
  isPausedByNixie: z26.boolean(),
1250
1252
  isTakingMessages: z26.boolean(),
@@ -1273,6 +1275,11 @@ var taskControl = checkedAction.errors({
1273
1275
  status: 409
1274
1276
  }
1275
1277
  }).input(z26.object({ clientActionID: clientActionIDSchema2, taskID: threadSchema })).output(controlledTaskSchema);
1278
+ var markedTaskSchema = z26.object({
1279
+ changedAt: z26.date(),
1280
+ disposable: z26.boolean(),
1281
+ taskID: threadSchema
1282
+ });
1276
1283
  var nixieControl = checkedAction.input(z26.object({ clientActionID: clientActionIDSchema2 })).output(z26.object({ paused: pauseStateSchema }));
1277
1284
  var backupNoticeSchema = z26.object({
1278
1285
  cause: z26.enum(["failed", "missing"]),
@@ -1346,7 +1353,20 @@ var contract = {
1346
1353
  close: taskControl.errors({
1347
1354
  CONVERSATION_NEVER_CLOSES: { message: "The conversation is never closed", status: 409 }
1348
1355
  }),
1349
- interrupt: taskControl
1356
+ interrupt: taskControl,
1357
+ setDisposable: checkedAction.errors({
1358
+ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 },
1359
+ TASK_HAS_NO_MARK: { message: "The task has no disposable mark", status: 409 },
1360
+ TASK_STATE_REFUSED: {
1361
+ message: "The task is in a state that does not take this change",
1362
+ status: 409,
1363
+ data: z26.object({ state: taskStateSchema2 })
1364
+ }
1365
+ }).input(z26.object({
1366
+ clientActionID: clientActionIDSchema2,
1367
+ disposable: z26.boolean(),
1368
+ taskID: threadSchema
1369
+ })).output(markedTaskSchema)
1350
1370
  },
1351
1371
  memory: {
1352
1372
  readVersions: signedIn.input(z26.object({ versions: z26.array(versionRefSchema).min(1).max(100) })).output(z26.object({ versions: z26.array(versionTextSchema) })),
@@ -1954,6 +1974,52 @@ function isTimeZone(zone) {
1954
1974
  return false;
1955
1975
  }
1956
1976
  }
1977
+ // src/contract/schedule-schema.ts
1978
+ import { z as z36 } from "zod";
1979
+ var clockTimeSchema = z36.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d$/u, "a time is HH:MM, 24-hour");
1980
+ var minutesSchema = z36.strictObject({
1981
+ minutes: z36.int().min(5).max(1440)
1982
+ });
1983
+ var weekdaySchema = z36.enum(["mon", "tue", "wed", "thu", "fri", "sat", "sun"]);
1984
+ var scheduleSchema = z36.strictObject({
1985
+ every: z36.union([z36.enum(["day", "week", "hour"]), minutesSchema]),
1986
+ at: clockTimeSchema.optional(),
1987
+ on: weekdaySchema.optional(),
1988
+ window: z36.strictObject({ from: clockTimeSchema, until: clockTimeSchema }).optional(),
1989
+ idleMinutes: z36.int().min(1).max(720).optional(),
1990
+ zone: z36.string().refine((zone) => zone === "owner" || isTimeZone(zone), "a zone is owner or an IANA zone").default("owner"),
1991
+ catchUp: z36.enum(["once", "skip"]).default("once")
1992
+ }).superRefine((schedule, context) => {
1993
+ const isCalendar = schedule.every === "day" || schedule.every === "week";
1994
+ if (isCalendar && schedule.at === undefined && schedule.window === undefined) {
1995
+ context.addIssue({ code: "custom", message: "day and week need at or window" });
1996
+ }
1997
+ if (isCalendar && schedule.at !== undefined && schedule.window !== undefined) {
1998
+ context.addIssue({ code: "custom", message: "at and window never come together" });
1999
+ }
2000
+ if (!isCalendar && schedule.at !== undefined) {
2001
+ context.addIssue({ code: "custom", message: "hour and minutes schedules take no at" });
2002
+ }
2003
+ if (!isCalendar && schedule.window !== undefined) {
2004
+ context.addIssue({ code: "custom", message: "hour and minutes schedules take no window" });
2005
+ }
2006
+ if (schedule.every === "week" && schedule.on === undefined) {
2007
+ context.addIssue({ code: "custom", message: "a week schedule needs on" });
2008
+ }
2009
+ if (schedule.every !== "week" && schedule.on !== undefined) {
2010
+ context.addIssue({ code: "custom", message: "only a week schedule takes on" });
2011
+ }
2012
+ if (schedule.idleMinutes !== undefined && schedule.window === undefined) {
2013
+ context.addIssue({ code: "custom", message: "idleMinutes needs window" });
2014
+ }
2015
+ });
2016
+ // src/contract/trigger-schema.ts
2017
+ import { z as z37 } from "zod";
2018
+ var triggerAtSchema = z37.iso.datetime({ offset: true });
2019
+ var triggerSchema = z37.union([
2020
+ z37.strictObject({ schedule: scheduleSchema }),
2021
+ z37.strictObject({ at: triggerAtSchema })
2022
+ ]);
1957
2023
  // src/contract/session-cookie-name.ts
1958
2024
  var sessionCookieName = "nixie_session";
1959
2025
 
@@ -1964,11 +2030,11 @@ function renderSessionCookie(token) {
1964
2030
  return `${sessionCookieName}=${token ?? ""}; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=${maxAgeS}`;
1965
2031
  }
1966
2032
  // src/message/task-message-input-schema.ts
1967
- import { z as z37 } from "zod";
2033
+ import { z as z39 } from "zod";
1968
2034
 
1969
2035
  // src/message/task-message-kind-schema.ts
1970
- import { z as z36 } from "zod";
1971
- var taskMessageKindSchema = z36.enum([
2036
+ import { z as z38 } from "zod";
2037
+ var taskMessageKindSchema = z38.enum([
1972
2038
  "progress",
1973
2039
  "question",
1974
2040
  "request",
@@ -1978,21 +2044,21 @@ var taskMessageKindSchema = z36.enum([
1978
2044
  ]);
1979
2045
 
1980
2046
  // src/message/task-message-input-schema.ts
1981
- var taskMessageInputSchema = z37.object({
1982
- to: z37.string(),
2047
+ var taskMessageInputSchema = z39.object({
2048
+ to: z39.string(),
1983
2049
  kind: taskMessageKindSchema,
1984
- body: z37.string(),
1985
- replyTo: z37.string().optional(),
1986
- onBehalfOf: z37.string().array().optional(),
1987
- wake: z37.boolean().optional()
2050
+ body: z39.string(),
2051
+ replyTo: z39.string().optional(),
2052
+ onBehalfOf: z39.string().array().optional(),
2053
+ wake: z39.boolean().optional()
1988
2054
  });
1989
2055
  // src/message/task-message-result-schema.ts
1990
- import { z as z38 } from "zod";
1991
- var taskMessageResultSchema = z38.object({
1992
- messageID: z38.string(),
1993
- woke: z38.boolean(),
1994
- hop: z38.int().nonnegative(),
1995
- note: z38.string().optional()
2056
+ import { z as z40 } from "zod";
2057
+ var taskMessageResultSchema = z40.object({
2058
+ messageID: z40.string(),
2059
+ woke: z40.boolean(),
2060
+ hop: z40.int().nonnegative(),
2061
+ note: z40.string().optional()
1996
2062
  });
1997
2063
  export {
1998
2064
  buildPendingInput,
@@ -2006,9 +2072,12 @@ export {
2006
2072
  isTimeZone,
2007
2073
  pickSpanSource,
2008
2074
  renderSessionCookie,
2075
+ scheduleSchema,
2009
2076
  sessionCookieName,
2010
2077
  spanSchema,
2011
2078
  taskMessageInputSchema,
2012
2079
  taskMessageKindSchema,
2013
- taskMessageResultSchema
2080
+ taskMessageResultSchema,
2081
+ triggerAtSchema,
2082
+ triggerSchema
2014
2083
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heynixie/contract",
3
- "version": "0.75.0",
3
+ "version": "0.76.0",
4
4
  "description": "The oRPC contract of the nixie API, with the types a client needs",
5
5
  "license": "MIT",
6
6
  "repository": {