@robbeverhelst/do 1.21.0 → 1.23.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.
- package/dist/do.js +123 -11
- package/package.json +1 -1
package/dist/do.js
CHANGED
|
@@ -1177,6 +1177,33 @@ function mapColumnsInSQLToAlias(query, alias) {
|
|
|
1177
1177
|
}));
|
|
1178
1178
|
}
|
|
1179
1179
|
|
|
1180
|
+
// ../../node_modules/.bun/drizzle-orm@0.45.2+c7294ea0f0c54ed0/node_modules/drizzle-orm/pg-core/checks.js
|
|
1181
|
+
class CheckBuilder {
|
|
1182
|
+
constructor(name, value) {
|
|
1183
|
+
this.name = name;
|
|
1184
|
+
this.value = value;
|
|
1185
|
+
}
|
|
1186
|
+
static [entityKind] = "PgCheckBuilder";
|
|
1187
|
+
brand;
|
|
1188
|
+
build(table) {
|
|
1189
|
+
return new Check(table, this);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
class Check {
|
|
1194
|
+
constructor(table, builder) {
|
|
1195
|
+
this.table = table;
|
|
1196
|
+
this.name = builder.name;
|
|
1197
|
+
this.value = builder.value;
|
|
1198
|
+
}
|
|
1199
|
+
static [entityKind] = "PgCheck";
|
|
1200
|
+
name;
|
|
1201
|
+
value;
|
|
1202
|
+
}
|
|
1203
|
+
function check(name, value) {
|
|
1204
|
+
return new CheckBuilder(name, value);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1180
1207
|
// ../../node_modules/.bun/drizzle-orm@0.45.2+c7294ea0f0c54ed0/node_modules/drizzle-orm/utils.js
|
|
1181
1208
|
function orderSelectedFields(fields, pathPrefix) {
|
|
1182
1209
|
return Object.entries(fields).reduce((result, [name, field]) => {
|
|
@@ -4224,6 +4251,7 @@ var areas = pgTable("areas", {
|
|
|
4224
4251
|
|
|
4225
4252
|
// ../../packages/schema/src/db/core.ts
|
|
4226
4253
|
var routineKind = pgEnum("routine_kind", ["sequence", "time_blocked"]);
|
|
4254
|
+
var routineStepRef = pgEnum("routine_step_ref", ["free", "habit", "task"]);
|
|
4227
4255
|
var projectStatus = pgEnum("project_status", [
|
|
4228
4256
|
"planning",
|
|
4229
4257
|
"active",
|
|
@@ -4260,11 +4288,22 @@ var routineSteps = pgTable("routine_steps", {
|
|
|
4260
4288
|
tenantId: text("tenant_id").notNull().references(() => tenants.id),
|
|
4261
4289
|
routineId: text("routine_id").notNull().references(() => routines.id),
|
|
4262
4290
|
title: text("title").notNull(),
|
|
4291
|
+
refKind: routineStepRef("ref_kind").notNull().default("free"),
|
|
4292
|
+
habitId: text("habit_id").references(() => habits.id),
|
|
4293
|
+
taskId: text("task_id").references(() => tasks.id),
|
|
4263
4294
|
sortOrder: integer("sort_order").notNull().default(0),
|
|
4264
4295
|
durationMinutes: integer("duration_minutes"),
|
|
4265
4296
|
notes: text("notes"),
|
|
4266
4297
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
4267
|
-
}, (t) => [
|
|
4298
|
+
}, (t) => [
|
|
4299
|
+
index("routine_steps_routine_order_idx").on(t.routineId, t.sortOrder),
|
|
4300
|
+
index("routine_steps_habit_idx").on(t.habitId),
|
|
4301
|
+
check("routine_steps_ref_kind_chk", sql`(
|
|
4302
|
+
(${t.refKind} = 'free' AND ${t.habitId} IS NULL AND ${t.taskId} IS NULL) OR
|
|
4303
|
+
(${t.refKind} = 'habit' AND ${t.habitId} IS NOT NULL AND ${t.taskId} IS NULL) OR
|
|
4304
|
+
(${t.refKind} = 'task' AND ${t.taskId} IS NOT NULL AND ${t.habitId} IS NULL)
|
|
4305
|
+
)`)
|
|
4306
|
+
]);
|
|
4268
4307
|
var routineRuns = pgTable("routine_runs", {
|
|
4269
4308
|
id: text("id").primaryKey(),
|
|
4270
4309
|
tenantId: text("tenant_id").notNull().references(() => tenants.id),
|
|
@@ -4280,13 +4319,19 @@ var routineRunSteps = pgTable("routine_run_steps", {
|
|
|
4280
4319
|
runId: text("run_id").notNull().references(() => routineRuns.id),
|
|
4281
4320
|
stepId: text("step_id").notNull().references(() => routineSteps.id),
|
|
4282
4321
|
title: text("title").notNull(),
|
|
4322
|
+
refKind: routineStepRef("ref_kind").notNull().default("free"),
|
|
4323
|
+
habitId: text("habit_id").references(() => habits.id),
|
|
4324
|
+
habitEntryId: text("habit_entry_id").references(() => habitEntries.id),
|
|
4283
4325
|
sortOrder: integer("sort_order").notNull().default(0),
|
|
4284
4326
|
durationMinutes: integer("duration_minutes"),
|
|
4285
4327
|
status: routineRunStepStatus("status").notNull().default("pending"),
|
|
4286
4328
|
elapsedSeconds: integer("elapsed_seconds").notNull().default(0),
|
|
4287
4329
|
carriedOver: boolean("carried_over").notNull().default(false),
|
|
4288
4330
|
completedAt: timestamp("completed_at", { withTimezone: true })
|
|
4289
|
-
}, (t) => [
|
|
4331
|
+
}, (t) => [
|
|
4332
|
+
index("routine_run_steps_run_order_idx").on(t.runId, t.sortOrder),
|
|
4333
|
+
check("routine_run_steps_ref_kind_chk", sql`(${t.refKind} <> 'habit' OR ${t.habitId} IS NOT NULL)`)
|
|
4334
|
+
]);
|
|
4290
4335
|
var projects = pgTable("projects", {
|
|
4291
4336
|
id: text("id").primaryKey().references(() => nodes.id),
|
|
4292
4337
|
tenantId: text("tenant_id").notNull().references(() => tenants.id),
|
|
@@ -4336,6 +4381,7 @@ var habitMeasurementType = pgEnum("habit_measurement_type", [
|
|
|
4336
4381
|
"negative"
|
|
4337
4382
|
]);
|
|
4338
4383
|
var habitPeriod = pgEnum("habit_period", ["day", "week", "month"]);
|
|
4384
|
+
var habitEntrySource = pgEnum("habit_entry_source", ["manual", "routine"]);
|
|
4339
4385
|
var recurrenceMode = pgEnum("recurrence_mode", ["rigid", "flexible"]);
|
|
4340
4386
|
var recurrenceFreq = pgEnum("recurrence_freq", ["daily", "weekly", "monthly", "yearly"]);
|
|
4341
4387
|
var recurrenceUnit = pgEnum("recurrence_unit", ["day", "week", "month"]);
|
|
@@ -4387,6 +4433,7 @@ var habitEntries = pgTable("habit_entries", {
|
|
|
4387
4433
|
tenantId: text("tenant_id").notNull().references(() => tenants.id),
|
|
4388
4434
|
habitId: text("habit_id").notNull().references(() => habits.id),
|
|
4389
4435
|
value: doublePrecision("value").notNull().default(1),
|
|
4436
|
+
source: habitEntrySource("source").notNull().default("manual"),
|
|
4390
4437
|
occurredAt: timestamp("occurred_at", { withTimezone: true }).notNull(),
|
|
4391
4438
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
4392
4439
|
}, (t) => [index("habit_entries_habit_occurred_idx").on(t.habitId, t.occurredAt)]);
|
|
@@ -5092,7 +5139,7 @@ __export(exports_external, {
|
|
|
5092
5139
|
clone: () => clone,
|
|
5093
5140
|
cidrv6: () => cidrv62,
|
|
5094
5141
|
cidrv4: () => cidrv42,
|
|
5095
|
-
check: () =>
|
|
5142
|
+
check: () => check2,
|
|
5096
5143
|
catch: () => _catch2,
|
|
5097
5144
|
boolean: () => boolean3,
|
|
5098
5145
|
bigint: () => bigint3,
|
|
@@ -17209,7 +17256,7 @@ __export(exports_schemas2, {
|
|
|
17209
17256
|
codec: () => codec,
|
|
17210
17257
|
cidrv6: () => cidrv62,
|
|
17211
17258
|
cidrv4: () => cidrv42,
|
|
17212
|
-
check: () =>
|
|
17259
|
+
check: () => check2,
|
|
17213
17260
|
catch: () => _catch2,
|
|
17214
17261
|
boolean: () => boolean3,
|
|
17215
17262
|
bigint: () => bigint3,
|
|
@@ -17501,8 +17548,8 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
17501
17548
|
reg.add(this, meta2);
|
|
17502
17549
|
return this;
|
|
17503
17550
|
},
|
|
17504
|
-
refine(
|
|
17505
|
-
return this.check(refine(
|
|
17551
|
+
refine(check2, params) {
|
|
17552
|
+
return this.check(refine(check2, params));
|
|
17506
17553
|
},
|
|
17507
17554
|
superRefine(refinement, params) {
|
|
17508
17555
|
return this.check(superRefine(refinement, params));
|
|
@@ -18644,7 +18691,7 @@ var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
|
18644
18691
|
ZodType.init(inst, def);
|
|
18645
18692
|
inst._zod.processJSONSchema = (ctx, json2, params) => customProcessor(inst, ctx, json2, params);
|
|
18646
18693
|
});
|
|
18647
|
-
function
|
|
18694
|
+
function check2(fn) {
|
|
18648
18695
|
const ch = new $ZodCheck({
|
|
18649
18696
|
check: "custom"
|
|
18650
18697
|
});
|
|
@@ -19595,6 +19642,7 @@ var habitMeasurementTypeSchema = exports_external.enum([
|
|
|
19595
19642
|
"negative"
|
|
19596
19643
|
]);
|
|
19597
19644
|
var habitPeriodSchema = exports_external.enum(["day", "week", "month"]);
|
|
19645
|
+
var habitEntrySourceSchema = exports_external.enum(habitEntrySource.enumValues);
|
|
19598
19646
|
var createHabitInputSchema = exports_external.object({
|
|
19599
19647
|
id: ulidSchema,
|
|
19600
19648
|
title: exports_external.string().min(1),
|
|
@@ -19616,6 +19664,7 @@ var updateHabitInputSchema = exports_external.object({
|
|
|
19616
19664
|
var createHabitEntryInputSchema = exports_external.object({
|
|
19617
19665
|
id: ulidSchema,
|
|
19618
19666
|
value: exports_external.number().nonnegative().default(1),
|
|
19667
|
+
source: habitEntrySourceSchema.default("manual"),
|
|
19619
19668
|
occurredAt: exports_external.coerce.date().optional()
|
|
19620
19669
|
});
|
|
19621
19670
|
var habitStreakSchema = exports_external.object({
|
|
@@ -19625,10 +19674,15 @@ var habitStreakSchema = exports_external.object({
|
|
|
19625
19674
|
periodTarget: exports_external.number(),
|
|
19626
19675
|
satisfiedToday: exports_external.boolean()
|
|
19627
19676
|
});
|
|
19677
|
+
var habitRoutineRefSchema = exports_external.object({
|
|
19678
|
+
id: ulidSchema,
|
|
19679
|
+
title: exports_external.string()
|
|
19680
|
+
});
|
|
19628
19681
|
var habitSummarySchema = habitSchema.extend({
|
|
19629
19682
|
title: exports_external.string(),
|
|
19630
19683
|
createdAt: exports_external.coerce.date(),
|
|
19631
|
-
streak: habitStreakSchema
|
|
19684
|
+
streak: habitStreakSchema,
|
|
19685
|
+
inRoutines: exports_external.array(habitRoutineRefSchema).default([])
|
|
19632
19686
|
});
|
|
19633
19687
|
var habitHeatmapCellSchema = exports_external.object({
|
|
19634
19688
|
date: exports_external.string(),
|
|
@@ -19688,6 +19742,7 @@ var updateOccurrenceInputSchema = exports_external.object({
|
|
|
19688
19742
|
}).strict();
|
|
19689
19743
|
// ../../packages/schema/src/contracts/routines.ts
|
|
19690
19744
|
var routineKindSchema = exports_external.enum(routineKind.enumValues);
|
|
19745
|
+
var routineStepRefSchema = exports_external.enum(routineStepRef.enumValues);
|
|
19691
19746
|
var routineSchema = createSelectSchema(routines);
|
|
19692
19747
|
var routineStepSchema = createSelectSchema(routineSteps, {
|
|
19693
19748
|
createdAt: exports_external.coerce.date()
|
|
@@ -19695,9 +19750,61 @@ var routineStepSchema = createSelectSchema(routineSteps, {
|
|
|
19695
19750
|
var routineStepInputSchema = exports_external.object({
|
|
19696
19751
|
id: ulidSchema,
|
|
19697
19752
|
title: exports_external.string().min(1),
|
|
19753
|
+
refKind: routineStepRefSchema.default("free"),
|
|
19754
|
+
habitId: ulidSchema.nullish(),
|
|
19755
|
+
taskId: ulidSchema.nullish(),
|
|
19756
|
+
newHabit: createHabitInputSchema.optional(),
|
|
19698
19757
|
sortOrder: exports_external.number().int().min(0).optional(),
|
|
19699
19758
|
durationMinutes: exports_external.number().int().positive().nullish(),
|
|
19700
19759
|
notes: exports_external.string().nullish()
|
|
19760
|
+
}).superRefine((step, ctx) => {
|
|
19761
|
+
if (step.refKind === "habit") {
|
|
19762
|
+
const linkId = step.newHabit?.id ?? step.habitId;
|
|
19763
|
+
if (!linkId) {
|
|
19764
|
+
ctx.addIssue({
|
|
19765
|
+
code: exports_external.ZodIssueCode.custom,
|
|
19766
|
+
message: "a habit step needs habitId or newHabit",
|
|
19767
|
+
path: ["habitId"]
|
|
19768
|
+
});
|
|
19769
|
+
}
|
|
19770
|
+
if (step.newHabit && step.habitId && step.newHabit.id !== step.habitId) {
|
|
19771
|
+
ctx.addIssue({
|
|
19772
|
+
code: exports_external.ZodIssueCode.custom,
|
|
19773
|
+
message: "habitId must equal newHabit.id",
|
|
19774
|
+
path: ["habitId"]
|
|
19775
|
+
});
|
|
19776
|
+
}
|
|
19777
|
+
if (step.taskId) {
|
|
19778
|
+
ctx.addIssue({
|
|
19779
|
+
code: exports_external.ZodIssueCode.custom,
|
|
19780
|
+
message: "a habit step cannot also set taskId",
|
|
19781
|
+
path: ["taskId"]
|
|
19782
|
+
});
|
|
19783
|
+
}
|
|
19784
|
+
} else if (step.refKind === "task") {
|
|
19785
|
+
if (!step.taskId) {
|
|
19786
|
+
ctx.addIssue({
|
|
19787
|
+
code: exports_external.ZodIssueCode.custom,
|
|
19788
|
+
message: "a task step needs taskId",
|
|
19789
|
+
path: ["taskId"]
|
|
19790
|
+
});
|
|
19791
|
+
}
|
|
19792
|
+
if (step.habitId || step.newHabit) {
|
|
19793
|
+
ctx.addIssue({
|
|
19794
|
+
code: exports_external.ZodIssueCode.custom,
|
|
19795
|
+
message: "a task step cannot set a habit link",
|
|
19796
|
+
path: ["habitId"]
|
|
19797
|
+
});
|
|
19798
|
+
}
|
|
19799
|
+
} else {
|
|
19800
|
+
if (step.habitId || step.taskId || step.newHabit) {
|
|
19801
|
+
ctx.addIssue({
|
|
19802
|
+
code: exports_external.ZodIssueCode.custom,
|
|
19803
|
+
message: "a free step cannot set a habit/task link",
|
|
19804
|
+
path: ["refKind"]
|
|
19805
|
+
});
|
|
19806
|
+
}
|
|
19807
|
+
}
|
|
19701
19808
|
});
|
|
19702
19809
|
var createRoutineInputSchema = exports_external.object({
|
|
19703
19810
|
id: ulidSchema,
|
|
@@ -19735,10 +19842,13 @@ var routineRunSchema = createSelectSchema(routineRuns, {
|
|
|
19735
19842
|
var routineRunStepSchema = createSelectSchema(routineRunSteps, {
|
|
19736
19843
|
completedAt: exports_external.coerce.date().nullable()
|
|
19737
19844
|
});
|
|
19845
|
+
var routineRunStepViewSchema = routineRunStepSchema.extend({
|
|
19846
|
+
habit: habitSummarySchema.nullable().default(null)
|
|
19847
|
+
});
|
|
19738
19848
|
var routineRunViewSchema = routineRunSchema.extend({
|
|
19739
19849
|
routineTitle: exports_external.string(),
|
|
19740
19850
|
kind: routineKindSchema,
|
|
19741
|
-
steps: exports_external.array(
|
|
19851
|
+
steps: exports_external.array(routineRunStepViewSchema)
|
|
19742
19852
|
});
|
|
19743
19853
|
var startRoutineRunInputSchema = exports_external.object({
|
|
19744
19854
|
id: ulidSchema,
|
|
@@ -19746,7 +19856,9 @@ var startRoutineRunInputSchema = exports_external.object({
|
|
|
19746
19856
|
});
|
|
19747
19857
|
var updateRoutineRunStepInputSchema = exports_external.object({
|
|
19748
19858
|
status: routineRunStepStatusSchema.optional(),
|
|
19749
|
-
elapsedSeconds: exports_external.number().int().nonnegative().optional()
|
|
19859
|
+
elapsedSeconds: exports_external.number().int().nonnegative().optional(),
|
|
19860
|
+
habitValue: exports_external.number().nonnegative().optional(),
|
|
19861
|
+
logAgain: exports_external.boolean().optional()
|
|
19750
19862
|
}).strict();
|
|
19751
19863
|
var updateRoutineRunInputSchema = exports_external.object({
|
|
19752
19864
|
status: routineRunStatusSchema.optional()
|
|
@@ -21196,7 +21308,7 @@ function parseCapture2(input) {
|
|
|
21196
21308
|
|
|
21197
21309
|
// src/meta.ts
|
|
21198
21310
|
var CLI_NAME = "do";
|
|
21199
|
-
var VERSION = "1.
|
|
21311
|
+
var VERSION = "1.23.0";
|
|
21200
21312
|
var API_PREFIX = "/api/v1";
|
|
21201
21313
|
var DEFAULT_API_URL = "http://localhost:3001";
|
|
21202
21314
|
|