@robbeverhelst/do 1.392.0 → 1.393.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 +359 -4
- package/package.json +1 -1
package/dist/do.js
CHANGED
|
@@ -14420,7 +14420,7 @@ var configError = (message) => new CliError("config", message, EXIT.CONFIG);
|
|
|
14420
14420
|
|
|
14421
14421
|
// src/meta.ts
|
|
14422
14422
|
var CLI_NAME = "do";
|
|
14423
|
-
var VERSION = "1.
|
|
14423
|
+
var VERSION = "1.393.0";
|
|
14424
14424
|
var API_PREFIX = "/api/v1";
|
|
14425
14425
|
var DEFAULT_API_URL = "http://localhost:3001";
|
|
14426
14426
|
|
|
@@ -20801,6 +20801,49 @@ var animalHandoverNotes = pgTable("animal_handover_notes", {
|
|
|
20801
20801
|
photoFileId: text("photo_file_id").references(() => files.id, { onDelete: "set null" }),
|
|
20802
20802
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
20803
20803
|
}, (t) => [index("animal_handover_notes_period_idx").on(t.tenantId, t.periodId)]);
|
|
20804
|
+
var animalMedicineEveryUnit = pgEnum("animal_medicine_every_unit", [
|
|
20805
|
+
"day",
|
|
20806
|
+
"week",
|
|
20807
|
+
"month"
|
|
20808
|
+
]);
|
|
20809
|
+
var animalMedicines = pgTable("animal_medicines", {
|
|
20810
|
+
id: text("id").primaryKey(),
|
|
20811
|
+
tenantId: text("tenant_id").notNull().references(() => tenants.id),
|
|
20812
|
+
title: text("title").notNull(),
|
|
20813
|
+
dose: text("dose"),
|
|
20814
|
+
everyCount: integer2("every_count").notNull().default(1),
|
|
20815
|
+
everyUnit: animalMedicineEveryUnit("every_unit").notNull().default("day"),
|
|
20816
|
+
timeOfDay: text("time_of_day"),
|
|
20817
|
+
startsOn: date5("starts_on", { mode: "string" }),
|
|
20818
|
+
endsOn: date5("ends_on", { mode: "string" }),
|
|
20819
|
+
nextOn: date5("next_on", { mode: "string" }),
|
|
20820
|
+
stock: doublePrecision("stock"),
|
|
20821
|
+
unit: text("unit"),
|
|
20822
|
+
perDose: doublePrecision("per_dose").notNull().default(1),
|
|
20823
|
+
lowAt: doublePrecision("low_at"),
|
|
20824
|
+
note: text("note"),
|
|
20825
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
20826
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
20827
|
+
}, (t) => [index("animal_medicines_tenant_idx").on(t.tenantId)]);
|
|
20828
|
+
var animalMedicineAnimals = pgTable("animal_medicine_animals", {
|
|
20829
|
+
tenantId: text("tenant_id").notNull().references(() => tenants.id),
|
|
20830
|
+
medicineId: text("medicine_id").notNull().references(() => animalMedicines.id, { onDelete: "cascade" }),
|
|
20831
|
+
animalId: text("animal_id").notNull().references(() => animals.id, { onDelete: "cascade" })
|
|
20832
|
+
}, (t) => [
|
|
20833
|
+
primaryKey({ columns: [t.medicineId, t.animalId] }),
|
|
20834
|
+
index("animal_medicine_animals_animal_idx").on(t.tenantId, t.animalId)
|
|
20835
|
+
]);
|
|
20836
|
+
var animalMedicineDoses = pgTable("animal_medicine_doses", {
|
|
20837
|
+
id: text("id").primaryKey(),
|
|
20838
|
+
tenantId: text("tenant_id").notNull().references(() => tenants.id),
|
|
20839
|
+
medicineId: text("medicine_id").notNull().references(() => animalMedicines.id, { onDelete: "cascade" }),
|
|
20840
|
+
day: date5("day", { mode: "string" }).notNull(),
|
|
20841
|
+
givenAt: timestamp("given_at", { withTimezone: true }).notNull().defaultNow(),
|
|
20842
|
+
givenByUserId: text("given_by_user_id").references(() => users.id, { onDelete: "set null" }),
|
|
20843
|
+
took: doublePrecision("took").notNull().default(0),
|
|
20844
|
+
nextWas: date5("next_was", { mode: "string" }),
|
|
20845
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
20846
|
+
}, (t) => [unique("animal_medicine_doses_day_uniq").on(t.medicineId, t.day)]);
|
|
20804
20847
|
|
|
20805
20848
|
// ../../packages/schema/src/db/documents.ts
|
|
20806
20849
|
var documentKind = pgEnum("document_kind", [
|
|
@@ -21712,6 +21755,61 @@ var animalArrivedInputSchema = object({
|
|
|
21712
21755
|
on: keyDateDaySchema.optional(),
|
|
21713
21756
|
quarantineMonths: number2().int().min(0).max(12).optional()
|
|
21714
21757
|
}).strict();
|
|
21758
|
+
var animalMedicineEveryUnitSchema = _enum2(animalMedicineEveryUnit.enumValues);
|
|
21759
|
+
var animalMedicineViewSchema = object({
|
|
21760
|
+
id: ulidSchema,
|
|
21761
|
+
title: string2(),
|
|
21762
|
+
dose: string2().nullable(),
|
|
21763
|
+
everyCount: number2().int(),
|
|
21764
|
+
everyUnit: animalMedicineEveryUnitSchema,
|
|
21765
|
+
timeOfDay: string2().nullable(),
|
|
21766
|
+
startsOn: string2().nullable(),
|
|
21767
|
+
endsOn: string2().nullable(),
|
|
21768
|
+
nextOn: string2().nullable(),
|
|
21769
|
+
stock: number2().nullable(),
|
|
21770
|
+
unit: string2().nullable(),
|
|
21771
|
+
perDose: number2(),
|
|
21772
|
+
lowAt: number2().nullable(),
|
|
21773
|
+
note: string2().nullable(),
|
|
21774
|
+
animals: array(nodeRefSchema),
|
|
21775
|
+
daily: boolean2(),
|
|
21776
|
+
low: boolean2(),
|
|
21777
|
+
ended: boolean2(),
|
|
21778
|
+
course: object({ day: number2().int(), of: number2().int() }).nullable(),
|
|
21779
|
+
dueToday: boolean2(),
|
|
21780
|
+
doneToday: boolean2(),
|
|
21781
|
+
lastGivenOn: string2().nullable(),
|
|
21782
|
+
createdAt: exports_coerce.date(),
|
|
21783
|
+
updatedAt: exports_coerce.date()
|
|
21784
|
+
});
|
|
21785
|
+
var medicineText = (max) => string2().trim().min(1).max(max);
|
|
21786
|
+
var animalMedicineFields = object({
|
|
21787
|
+
id: ulidSchema,
|
|
21788
|
+
title: medicineText(120),
|
|
21789
|
+
animalIds: array(ulidSchema).min(1).max(20),
|
|
21790
|
+
dose: medicineText(120).nullish(),
|
|
21791
|
+
everyCount: number2().int().min(1).max(366).optional(),
|
|
21792
|
+
everyUnit: animalMedicineEveryUnitSchema.optional(),
|
|
21793
|
+
timeOfDay: string2().regex(/^(morning|midday|afternoon|evening|night|([01][0-9]|2[0-3]):[0-5][0-9])$/).nullish(),
|
|
21794
|
+
startsOn: keyDateDaySchema.nullish(),
|
|
21795
|
+
endsOn: keyDateDaySchema.nullish(),
|
|
21796
|
+
nextOn: keyDateDaySchema.nullish(),
|
|
21797
|
+
stock: number2().min(0).max(1e5).nullish(),
|
|
21798
|
+
unit: medicineText(30).nullish(),
|
|
21799
|
+
perDose: number2().positive().max(1e4).optional(),
|
|
21800
|
+
lowAt: number2().min(0).max(1e5).nullish(),
|
|
21801
|
+
note: medicineText(300).nullish()
|
|
21802
|
+
}).strict();
|
|
21803
|
+
var endsAfterStart2 = (v) => !v.startsOn || !v.endsOn || v.endsOn >= v.startsOn;
|
|
21804
|
+
var endsMessage = { message: "endsOn is before startsOn", path: ["endsOn"] };
|
|
21805
|
+
var createAnimalMedicineInputSchema = animalMedicineFields.refine(endsAfterStart2, endsMessage);
|
|
21806
|
+
var updateAnimalMedicineInputSchema = animalMedicineFields.omit({ id: true }).partial().strict().refine(endsAfterStart2, endsMessage);
|
|
21807
|
+
var animalMedicinesQuerySchema = object({
|
|
21808
|
+
animalId: ulidSchema.optional(),
|
|
21809
|
+
day: keyDateDaySchema.optional(),
|
|
21810
|
+
includeEnded: _enum2(["true", "false"]).transform((v) => v === "true").optional()
|
|
21811
|
+
});
|
|
21812
|
+
var animalMedicineDoseInputSchema = object({ day: keyDateDaySchema.optional() }).strict();
|
|
21715
21813
|
|
|
21716
21814
|
// ../../packages/schema/src/operations/crud.ts
|
|
21717
21815
|
var DELETE_REASON_QUERY = [
|
|
@@ -21795,6 +21893,7 @@ function crudOperations(r) {
|
|
|
21795
21893
|
var READ = ["animals:read"];
|
|
21796
21894
|
var WRITE = ["animals:write"];
|
|
21797
21895
|
var visit = { visitId: "The vet visit's ULID." };
|
|
21896
|
+
var medicine = { medicineId: "The medicine's ULID." };
|
|
21798
21897
|
var animalOperations = defineOperations({
|
|
21799
21898
|
...crudOperations({
|
|
21800
21899
|
segment: "animals",
|
|
@@ -21883,6 +21982,96 @@ var animalOperations = defineOperations({
|
|
|
21883
21982
|
response: { description: "The species profile." },
|
|
21884
21983
|
errors: { 400: true }
|
|
21885
21984
|
},
|
|
21985
|
+
listMedicines: {
|
|
21986
|
+
method: "get",
|
|
21987
|
+
path: "/animals/medicines",
|
|
21988
|
+
scopes: READ,
|
|
21989
|
+
tag: "Animals",
|
|
21990
|
+
summary: "List the animals' medicines",
|
|
21991
|
+
description: "By title: each medicine with the `animals` it's for, its `dose`, how often (`everyCount` `everyUnit`; `daily` when every 1 day), `timeOfDay`, a course's `startsOn`/`endsOn` and its `course` day N of M, the `nextOn` day of one that isn't daily, the counted `stock` (`unit`, `perDose`, `low` at `lowAt`), the `note`, and on `day` (UTC today by default) whether it's `dueToday` and `doneToday`, with `lastGivenOn`. Ended courses only with `includeEnded`.",
|
|
21992
|
+
query: [
|
|
21993
|
+
{ name: "animalId", description: "Only this animal's (an animal's ULID)." },
|
|
21994
|
+
{ name: "day", description: "The reader's day, `YYYY-MM-DD`; UTC today when left out." },
|
|
21995
|
+
{ name: "includeEnded", description: "`true`: ended courses too." }
|
|
21996
|
+
],
|
|
21997
|
+
querySchema: animalMedicinesQuerySchema,
|
|
21998
|
+
status: 200,
|
|
21999
|
+
response: { description: "The medicines." }
|
|
22000
|
+
},
|
|
22001
|
+
createMedicine: {
|
|
22002
|
+
method: "post",
|
|
22003
|
+
path: "/animals/medicines",
|
|
22004
|
+
scopes: WRITE,
|
|
22005
|
+
tag: "Animals",
|
|
22006
|
+
summary: "Add a medicine for one animal or a few",
|
|
22007
|
+
description: "A daily one (the default, every 1 day), a course (`startsOn` to `endsOn`) or one that comes round (`everyCount` `everyUnit`, with its `nextOn`). Count the `stock` to have each dose take `perDose` (default 1) from it and say low at `lowAt`. Every animal must be one in this Space (400).",
|
|
22008
|
+
body: createAnimalMedicineInputSchema,
|
|
22009
|
+
status: 201,
|
|
22010
|
+
response: { description: "The medicine." },
|
|
22011
|
+
errors: { 400: true }
|
|
22012
|
+
},
|
|
22013
|
+
getMedicine: {
|
|
22014
|
+
method: "get",
|
|
22015
|
+
path: "/animals/medicines/{medicineId}",
|
|
22016
|
+
pathParams: medicine,
|
|
22017
|
+
scopes: READ,
|
|
22018
|
+
tag: "Animals",
|
|
22019
|
+
summary: "A medicine, as it stands today",
|
|
22020
|
+
description: "The same shape as a row of the list, on UTC today.",
|
|
22021
|
+
status: 200,
|
|
22022
|
+
response: { description: "The medicine." },
|
|
22023
|
+
errors: { 404: true }
|
|
22024
|
+
},
|
|
22025
|
+
updateMedicine: {
|
|
22026
|
+
method: "patch",
|
|
22027
|
+
path: "/animals/medicines/{medicineId}",
|
|
22028
|
+
pathParams: medicine,
|
|
22029
|
+
scopes: WRITE,
|
|
22030
|
+
tag: "Animals",
|
|
22031
|
+
summary: "Change a medicine",
|
|
22032
|
+
description: "A field left out stays; `null` clears it; `animalIds` replaces who it's for. Set `stock` when a new box comes in.",
|
|
22033
|
+
body: updateAnimalMedicineInputSchema,
|
|
22034
|
+
status: 200,
|
|
22035
|
+
response: { description: "The medicine." },
|
|
22036
|
+
errors: { 400: true, 404: true }
|
|
22037
|
+
},
|
|
22038
|
+
removeMedicine: {
|
|
22039
|
+
method: "delete",
|
|
22040
|
+
path: "/animals/medicines/{medicineId}",
|
|
22041
|
+
pathParams: medicine,
|
|
22042
|
+
scopes: WRITE,
|
|
22043
|
+
tag: "Animals",
|
|
22044
|
+
summary: "Remove a medicine",
|
|
22045
|
+
description: "With the doses given; to stop a course and keep it, set its `endsOn` instead.",
|
|
22046
|
+
status: 204,
|
|
22047
|
+
response: { description: "Removed." },
|
|
22048
|
+
errors: { 404: true }
|
|
22049
|
+
},
|
|
22050
|
+
giveMedicineDose: {
|
|
22051
|
+
method: "post",
|
|
22052
|
+
path: "/animals/medicines/{medicineId}/doses",
|
|
22053
|
+
pathParams: medicine,
|
|
22054
|
+
scopes: WRITE,
|
|
22055
|
+
tag: "Animals",
|
|
22056
|
+
summary: "Give a medicine's dose",
|
|
22057
|
+
description: "The dose for `day` (UTC today by default): it takes `perDose` from a counted stock (never below 0) and moves the next day of one that isn't daily on from that day. Again that day changes nothing.",
|
|
22058
|
+
body: animalMedicineDoseInputSchema,
|
|
22059
|
+
status: 200,
|
|
22060
|
+
response: { description: "The medicine, on that day." },
|
|
22061
|
+
errors: { 400: true, 404: true }
|
|
22062
|
+
},
|
|
22063
|
+
undoMedicineDose: {
|
|
22064
|
+
method: "delete",
|
|
22065
|
+
path: "/animals/medicines/{medicineId}/doses/{day}",
|
|
22066
|
+
pathParams: { ...medicine, day: "The day it was given for, `YYYY-MM-DD`." },
|
|
22067
|
+
scopes: WRITE,
|
|
22068
|
+
tag: "Animals",
|
|
22069
|
+
summary: "Take a medicine's dose back",
|
|
22070
|
+
description: "The stock and the next day go back to before it; 404 when none was given that day.",
|
|
22071
|
+
status: 200,
|
|
22072
|
+
response: { description: "The medicine, on that day." },
|
|
22073
|
+
errors: { 400: "`day` isn't a `YYYY-MM-DD` day.", 404: true }
|
|
22074
|
+
},
|
|
21886
22075
|
vetVisit: {
|
|
21887
22076
|
method: "get",
|
|
21888
22077
|
path: "/animals/vet-visits/{visitId}",
|
|
@@ -31543,9 +31732,9 @@ var eventFields = {
|
|
|
31543
31732
|
note: eventTextSchema(1000).nullish(),
|
|
31544
31733
|
sort: number2().int().min(0).max(1e4).optional()
|
|
31545
31734
|
};
|
|
31546
|
-
var
|
|
31547
|
-
var createGuestListEventInputSchema = object({ id: ulidSchema, guestListId: ulidSchema, key: guestEventKeySchema, ...eventFields }).strict().refine(
|
|
31548
|
-
var updateGuestListEventInputSchema = object(eventFields).partial().strict().refine(
|
|
31735
|
+
var endsAfterStart3 = (e) => !e.startsAt || !e.endsAt || e.endsAt >= e.startsAt;
|
|
31736
|
+
var createGuestListEventInputSchema = object({ id: ulidSchema, guestListId: ulidSchema, key: guestEventKeySchema, ...eventFields }).strict().refine(endsAfterStart3, { message: "endsAt is before startsAt", path: ["endsAt"] });
|
|
31737
|
+
var updateGuestListEventInputSchema = object(eventFields).partial().strict().refine(endsAfterStart3, { message: "endsAt is before startsAt", path: ["endsAt"] });
|
|
31549
31738
|
var guestListEventsQuerySchema = object({ guestListId: ulidSchema });
|
|
31550
31739
|
var guestTableSchema = createSelectSchema(guestTables, {
|
|
31551
31740
|
createdAt: exports_coerce.date(),
|
|
@@ -46298,6 +46487,172 @@ var commands2 = [
|
|
|
46298
46487
|
return { data: { ok: true, animalId: id }, render: renderRecord };
|
|
46299
46488
|
}
|
|
46300
46489
|
},
|
|
46490
|
+
{
|
|
46491
|
+
spec: {
|
|
46492
|
+
path: ["animals", "medicines"],
|
|
46493
|
+
summary: "List the animals' medicines and where each stands today.",
|
|
46494
|
+
args: [],
|
|
46495
|
+
flags: [
|
|
46496
|
+
{ name: "animal", type: "string", description: "Only this animal's (ULID)." },
|
|
46497
|
+
{
|
|
46498
|
+
name: "day",
|
|
46499
|
+
type: "string",
|
|
46500
|
+
description: "The day to read for, YYYY-MM-DD (default UTC today)."
|
|
46501
|
+
},
|
|
46502
|
+
{ name: "include-ended", type: "boolean", description: "Ended courses too." }
|
|
46503
|
+
],
|
|
46504
|
+
scopes: [...animalOperations.listMedicines.scopes],
|
|
46505
|
+
returns: "AnimalMedicineView[]",
|
|
46506
|
+
notes: `${routeOf(animalOperations.listMedicines)}. Each with its animals, dose, how often, the course's day N of M, the next day, the stock (low or not), and dueToday / doneToday.`
|
|
46507
|
+
},
|
|
46508
|
+
run: async ({ flags, requireClient }) => {
|
|
46509
|
+
const raw = {};
|
|
46510
|
+
const animal = flagString(flags, "animal");
|
|
46511
|
+
const day = flagString(flags, "day");
|
|
46512
|
+
if (animal)
|
|
46513
|
+
raw.animalId = animal;
|
|
46514
|
+
if (day)
|
|
46515
|
+
raw.day = day;
|
|
46516
|
+
if (flagBool(flags, "include-ended"))
|
|
46517
|
+
raw.includeEnded = "true";
|
|
46518
|
+
parseInput(animalMedicinesQuerySchema, raw);
|
|
46519
|
+
return {
|
|
46520
|
+
data: await requireClient().getPage(pathOf(animalOperations.listMedicines), { query: raw }),
|
|
46521
|
+
render: renderList
|
|
46522
|
+
};
|
|
46523
|
+
}
|
|
46524
|
+
},
|
|
46525
|
+
{
|
|
46526
|
+
spec: {
|
|
46527
|
+
path: ["animals", "medicine"],
|
|
46528
|
+
summary: "One medicine, as it stands today.",
|
|
46529
|
+
args: [{ name: "id", required: true, description: "Medicine ULID." }],
|
|
46530
|
+
flags: [],
|
|
46531
|
+
scopes: [...animalOperations.getMedicine.scopes],
|
|
46532
|
+
returns: "AnimalMedicineView",
|
|
46533
|
+
notes: `${routeOf(animalOperations.getMedicine)}.`
|
|
46534
|
+
},
|
|
46535
|
+
run: readOperation(animalOperations.getMedicine, renderRecord, { medicineId: "medicine id" })
|
|
46536
|
+
},
|
|
46537
|
+
{
|
|
46538
|
+
spec: {
|
|
46539
|
+
path: ["animals", "medicine-add"],
|
|
46540
|
+
summary: "Add a medicine for one animal or a few: daily, a course, or one that comes round.",
|
|
46541
|
+
args: [],
|
|
46542
|
+
flags: [
|
|
46543
|
+
{
|
|
46544
|
+
name: "data",
|
|
46545
|
+
type: "string",
|
|
46546
|
+
description: 'JSON: `{ "title": "Joint tablet", "animalIds": ["\u2026"], "dose": "1 tablet with breakfast", "timeOfDay": "morning", "stock": 22, "unit": "tablets", "lowAt": 5 }`; a course adds `startsOn`/`endsOn`, one that comes round `everyCount`/`everyUnit` (`day`, `week`, `month`) and `nextOn`. The id is minted.'
|
|
46547
|
+
}
|
|
46548
|
+
],
|
|
46549
|
+
scopes: [...animalOperations.createMedicine.scopes],
|
|
46550
|
+
returns: "AnimalMedicineView",
|
|
46551
|
+
notes: `${routeOf(animalOperations.createMedicine)}. Daily unless said; each dose takes \`perDose\` (default 1) from a counted stock.`
|
|
46552
|
+
},
|
|
46553
|
+
run: async ({ flags, requireClient }) => {
|
|
46554
|
+
const body = parseInput(createAnimalMedicineInputSchema, {
|
|
46555
|
+
id: ulid3(),
|
|
46556
|
+
...readDataFlag(flags)
|
|
46557
|
+
});
|
|
46558
|
+
return {
|
|
46559
|
+
data: await requireClient().post(pathOf(animalOperations.createMedicine), body),
|
|
46560
|
+
render: renderRecord
|
|
46561
|
+
};
|
|
46562
|
+
}
|
|
46563
|
+
},
|
|
46564
|
+
{
|
|
46565
|
+
spec: {
|
|
46566
|
+
path: ["animals", "medicine-update"],
|
|
46567
|
+
summary: "Change a medicine (a new box: set its stock).",
|
|
46568
|
+
args: [{ name: "id", required: true, description: "Medicine ULID." }],
|
|
46569
|
+
flags: [
|
|
46570
|
+
{
|
|
46571
|
+
name: "data",
|
|
46572
|
+
type: "string",
|
|
46573
|
+
description: "UpdateAnimalMedicineInput JSON; null clears a field."
|
|
46574
|
+
}
|
|
46575
|
+
],
|
|
46576
|
+
scopes: [...animalOperations.updateMedicine.scopes],
|
|
46577
|
+
returns: "AnimalMedicineView",
|
|
46578
|
+
notes: `${routeOf(animalOperations.updateMedicine)}. \`animalIds\` replaces who it's for.`
|
|
46579
|
+
},
|
|
46580
|
+
run: async ({ args, flags, requireClient }) => {
|
|
46581
|
+
const medicineId = requireArg(args, 0, "medicine id");
|
|
46582
|
+
const body = parseInput(updateAnimalMedicineInputSchema, readDataFlag(flags));
|
|
46583
|
+
return {
|
|
46584
|
+
data: await requireClient().patch(pathOf(animalOperations.updateMedicine, { medicineId }), body),
|
|
46585
|
+
render: renderRecord
|
|
46586
|
+
};
|
|
46587
|
+
}
|
|
46588
|
+
},
|
|
46589
|
+
{
|
|
46590
|
+
spec: {
|
|
46591
|
+
path: ["animals", "medicine-remove"],
|
|
46592
|
+
summary: "Remove a medicine, with the doses given.",
|
|
46593
|
+
args: [{ name: "id", required: true, description: "Medicine ULID." }],
|
|
46594
|
+
flags: [],
|
|
46595
|
+
scopes: [...animalOperations.removeMedicine.scopes],
|
|
46596
|
+
returns: "void",
|
|
46597
|
+
notes: `${routeOf(animalOperations.removeMedicine)}. Destructive: the doses go too, so it needs --allow-destructive; to stop a course and keep it, set its endsOn.`
|
|
46598
|
+
},
|
|
46599
|
+
run: async ({ args, flags, requireClient }) => {
|
|
46600
|
+
const medicineId = requireArg(args, 0, "medicine id");
|
|
46601
|
+
assertDestructiveAllowed(flags, `remove medicine ${medicineId} and its doses`);
|
|
46602
|
+
await requireClient().delete(pathOf(animalOperations.removeMedicine, { medicineId }));
|
|
46603
|
+
return { data: { ok: true, medicineId }, render: renderRecord };
|
|
46604
|
+
}
|
|
46605
|
+
},
|
|
46606
|
+
{
|
|
46607
|
+
spec: {
|
|
46608
|
+
path: ["animals", "medicine-dose"],
|
|
46609
|
+
summary: "Give a medicine's dose (today, or --day).",
|
|
46610
|
+
args: [{ name: "id", required: true, description: "Medicine ULID." }],
|
|
46611
|
+
flags: [
|
|
46612
|
+
{
|
|
46613
|
+
name: "day",
|
|
46614
|
+
type: "string",
|
|
46615
|
+
description: "The day it's for, YYYY-MM-DD (default UTC today)."
|
|
46616
|
+
}
|
|
46617
|
+
],
|
|
46618
|
+
scopes: [...animalOperations.giveMedicineDose.scopes],
|
|
46619
|
+
returns: "AnimalMedicineView",
|
|
46620
|
+
notes: `${routeOf(animalOperations.giveMedicineDose)}. Takes \`perDose\` from a counted stock and moves the next day on; again that day changes nothing.`
|
|
46621
|
+
},
|
|
46622
|
+
run: async ({ args, flags, requireClient }) => {
|
|
46623
|
+
const medicineId = requireArg(args, 0, "medicine id");
|
|
46624
|
+
const day = flagString(flags, "day");
|
|
46625
|
+
const body = parseInput(animalMedicineDoseInputSchema, day ? { day } : {});
|
|
46626
|
+
return {
|
|
46627
|
+
data: await requireClient().post(pathOf(animalOperations.giveMedicineDose, { medicineId }), body),
|
|
46628
|
+
render: renderRecord
|
|
46629
|
+
};
|
|
46630
|
+
}
|
|
46631
|
+
},
|
|
46632
|
+
{
|
|
46633
|
+
spec: {
|
|
46634
|
+
path: ["animals", "medicine-undose"],
|
|
46635
|
+
summary: "Take a medicine's dose back.",
|
|
46636
|
+
args: [
|
|
46637
|
+
{ name: "id", required: true, description: "Medicine ULID." },
|
|
46638
|
+
{ name: "day", required: true, description: "The day it was given for, YYYY-MM-DD." }
|
|
46639
|
+
],
|
|
46640
|
+
flags: [],
|
|
46641
|
+
scopes: [...animalOperations.undoMedicineDose.scopes],
|
|
46642
|
+
returns: "AnimalMedicineView",
|
|
46643
|
+
notes: `${routeOf(animalOperations.undoMedicineDose)}. The stock and the next day go back to before it.`
|
|
46644
|
+
},
|
|
46645
|
+
run: async ({ args, requireClient }) => {
|
|
46646
|
+
const medicineId = requireArg(args, 0, "medicine id");
|
|
46647
|
+
const { day } = parseInput(animalMedicineDoseInputSchema, {
|
|
46648
|
+
day: requireArg(args, 1, "day")
|
|
46649
|
+
});
|
|
46650
|
+
return {
|
|
46651
|
+
data: await requireClient().delete(pathOf(animalOperations.undoMedicineDose, { medicineId, day })),
|
|
46652
|
+
render: renderRecord
|
|
46653
|
+
};
|
|
46654
|
+
}
|
|
46655
|
+
},
|
|
46301
46656
|
{
|
|
46302
46657
|
spec: {
|
|
46303
46658
|
path: ["animals", "acquisition"],
|
package/package.json
CHANGED