@robbeverhelst/do 1.308.1 → 1.309.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.
Files changed (2) hide show
  1. package/dist/do.js +124 -50
  2. package/package.json +1 -1
package/dist/do.js CHANGED
@@ -4630,8 +4630,16 @@ var animals = pgTable("animals", {
4630
4630
  }, (t) => [index("animals_tenant_idx").on(t.tenantId), index("animals_species_idx").on(t.speciesId)]);
4631
4631
  var animalLostCards = pgTable("animal_lost_cards", {
4632
4632
  animalId: text("animal_id").primaryKey().references(() => animals.id, { onDelete: "cascade" }),
4633
+ id: text("id").notNull().unique(),
4633
4634
  tenantId: text("tenant_id").notNull().references(() => tenants.id),
4634
- token: text("token").notNull().unique(),
4635
+ token: text("token").unique(),
4636
+ tokenHash: text("token_hash").notNull().unique(),
4637
+ tokenSealed: text("token_sealed"),
4638
+ expiresAt: timestamp("expires_at", { withTimezone: true }),
4639
+ revokedAt: timestamp("revoked_at", { withTimezone: true }),
4640
+ opens: integer("opens").notNull().default(0),
4641
+ lastOpenedAt: timestamp("last_opened_at", { withTimezone: true }),
4642
+ createdByUserId: text("created_by_user_id").references(() => users.id),
4635
4643
  photoFileId: text("photo_file_id"),
4636
4644
  phone: text("phone"),
4637
4645
  showChipped: boolean("show_chipped").notNull().default(false),
@@ -4639,6 +4647,18 @@ var animalLostCards = pgTable("animal_lost_cards", {
4639
4647
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
4640
4648
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
4641
4649
  }, (t) => [index("animal_lost_cards_tenant_idx").on(t.tenantId)]);
4650
+ var animalHandoverLinks = pgTable("animal_handover_links", {
4651
+ id: text("id").primaryKey(),
4652
+ tenantId: text("tenant_id").notNull().references(() => tenants.id),
4653
+ periodId: text("period_id").notNull().references(() => periods.id, { onDelete: "cascade" }),
4654
+ tokenHash: text("token_hash").notNull().unique(),
4655
+ expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
4656
+ revokedAt: timestamp("revoked_at", { withTimezone: true }),
4657
+ opens: integer("opens").notNull().default(0),
4658
+ lastOpenedAt: timestamp("last_opened_at", { withTimezone: true }),
4659
+ createdByUserId: text("created_by_user_id").references(() => users.id),
4660
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
4661
+ }, (t) => [index("animal_handover_links_period_idx").on(t.tenantId, t.periodId)]);
4642
4662
 
4643
4663
  // ../../packages/schema/src/db/integrations.ts
4644
4664
  var connectionStatus = pgEnum("connection_status", [
@@ -5721,6 +5741,8 @@ var invites = pgTable("invites", {
5721
5741
  type: inviteType("type").notNull(),
5722
5742
  email: text("email"),
5723
5743
  token: text("token").unique(),
5744
+ tokenHash: text("token_hash").unique(),
5745
+ tokenSealed: text("token_sealed"),
5724
5746
  role: baseRole("role").notNull().default("member"),
5725
5747
  customRoleId: text("custom_role_id").references(() => roles.id),
5726
5748
  invitedByUserId: text("invited_by_user_id").references(() => users.id),
@@ -5749,7 +5771,7 @@ var shareLinks = pgTable("share_links", {
5749
5771
  id: text("id").primaryKey(),
5750
5772
  tenantId: text("tenant_id").notNull().references(() => tenants.id),
5751
5773
  nodeId: text("node_id").notNull().references(() => nodes.id),
5752
- token: text("token").notNull().unique(),
5774
+ tokenHash: text("token_hash").notNull().unique(),
5753
5775
  capability: capability("capability").notNull().default("view"),
5754
5776
  createdByUserId: text("created_by_user_id").references(() => users.id),
5755
5777
  expiresAt: timestamp("expires_at", { withTimezone: true }),
@@ -29358,7 +29380,7 @@ var inviteSchema = createSelectSchema(invites, {
29358
29380
  acceptedAt: exports_coerce.date().nullable(),
29359
29381
  createdAt: exports_coerce.date(),
29360
29382
  updatedAt: exports_coerce.date()
29361
- });
29383
+ }).omit({ tokenHash: true, tokenSealed: true });
29362
29384
  var createInviteInputSchema = object({
29363
29385
  id: ulidSchema,
29364
29386
  type: _enum2(["email", "link", "guest"]),
@@ -29423,7 +29445,7 @@ var shareLinkSchema = createSelectSchema(shareLinks, {
29423
29445
  createdAt: exports_coerce.date(),
29424
29446
  updatedAt: exports_coerce.date()
29425
29447
  });
29426
- var shareLinkPublicSchema = shareLinkSchema.omit({ token: true });
29448
+ var shareLinkPublicSchema = shareLinkSchema.omit({ tokenHash: true });
29427
29449
  var createShareLinkInputSchema = createInsertSchema(shareLinks, {
29428
29450
  id: ulidSchema,
29429
29451
  nodeId: ulidSchema,
@@ -29431,7 +29453,7 @@ var createShareLinkInputSchema = createInsertSchema(shareLinks, {
29431
29453
  expiresAt: exports_coerce.date().nullish()
29432
29454
  }).omit({
29433
29455
  tenantId: true,
29434
- token: true,
29456
+ tokenHash: true,
29435
29457
  createdByUserId: true,
29436
29458
  revokedAt: true,
29437
29459
  createdAt: true,
@@ -32296,6 +32318,24 @@ var householdOperations = defineOperations({
32296
32318
  })
32297
32319
  });
32298
32320
 
32321
+ // ../../packages/schema/src/operations/incidents.ts
32322
+ var incidentOperations = defineOperations({
32323
+ ...crudOperations({
32324
+ segment: "incidents",
32325
+ tag: "Incidents",
32326
+ noun: "incident",
32327
+ read: "documents:read",
32328
+ write: "documents:write",
32329
+ create: createIncidentInputSchema,
32330
+ update: updateIncidentInputSchema,
32331
+ listQuery: [
32332
+ { name: "status", description: "Only this status (`open`, `claimed`, `closed`)." },
32333
+ { name: "policyId", description: "Only the incidents under this policy (a document id)." }
32334
+ ],
32335
+ listQuerySchema: incidentsQuerySchema
32336
+ })
32337
+ });
32338
+
32299
32339
  // ../../packages/schema/src/operations/inventory-items.ts
32300
32340
  var inventoryItemOperations = defineOperations({
32301
32341
  ...crudOperations({
@@ -32701,6 +32741,38 @@ var journalOperations = defineOperations({
32701
32741
  }
32702
32742
  });
32703
32743
 
32744
+ // ../../packages/schema/src/operations/key-dates.ts
32745
+ var keyDateOperations = defineOperations({
32746
+ ...crudOperations({
32747
+ segment: "key-dates",
32748
+ tag: "Key dates",
32749
+ noun: "key date",
32750
+ read: "key-dates:read",
32751
+ write: "key-dates:write",
32752
+ create: createKeyDateInputSchema,
32753
+ update: updateKeyDateInputSchema,
32754
+ listQuery: [
32755
+ {
32756
+ name: "nodeId",
32757
+ description: "Only the key dates on this node (a contact, a document, \u2026)."
32758
+ },
32759
+ {
32760
+ name: "kind",
32761
+ description: "Only this kind (`birthday`, `renews`, `cancel_by`, `expires`, `follow_up`, `due_back`, \u2026)."
32762
+ },
32763
+ {
32764
+ name: "from",
32765
+ description: "Only dates whose next occurrence is on or after this day (`YYYY-MM-DD`)."
32766
+ },
32767
+ {
32768
+ name: "to",
32769
+ description: "Only dates whose next occurrence is on or before this day (`YYYY-MM-DD`)."
32770
+ }
32771
+ ],
32772
+ listQuerySchema: keyDatesQuerySchema
32773
+ })
32774
+ });
32775
+
32704
32776
  // ../../packages/schema/src/operations/keys.ts
32705
32777
  var keyOperations = defineOperations({
32706
32778
  list: {
@@ -33125,6 +33197,32 @@ var periodOperations = defineOperations({
33125
33197
  })
33126
33198
  });
33127
33199
 
33200
+ // ../../packages/schema/src/operations/places.ts
33201
+ var placeOperations = defineOperations({
33202
+ ...crudOperations({
33203
+ segment: "places",
33204
+ tag: "Places",
33205
+ noun: "place",
33206
+ read: "places:read",
33207
+ write: "places:write",
33208
+ create: createPlaceInputSchema,
33209
+ update: updatePlaceInputSchema
33210
+ }),
33211
+ importHouse: {
33212
+ method: "post",
33213
+ path: "/places/import",
33214
+ scopes: ["places:write"],
33215
+ tag: "Places",
33216
+ summary: "Import Places from house.json",
33217
+ description: "Import the rooms of one house from Gaard's `house.json` (`{ file, houseIndex? }`; the first house by default). Each room not imported before becomes a Place with its floor and outline; rooms already imported, even ones deleted since, are skipped, so do keeps what it owns. No sync with Gaard. Returns `{ created, skipped, places }`; fires `place.imported`.",
33218
+ body: importPlacesInputSchema,
33219
+ status: 200,
33220
+ response: { description: "`{ created, skipped, places }`." },
33221
+ errors: { 400: true },
33222
+ webhook: "place.imported"
33223
+ }
33224
+ });
33225
+
33128
33226
  // ../../packages/schema/src/operations/planning-rules.ts
33129
33227
  var planningRuleOperations = defineOperations({
33130
33228
  ...crudOperations({
@@ -35256,7 +35354,7 @@ function parseCapture2(input, now) {
35256
35354
 
35257
35355
  // src/meta.ts
35258
35356
  var CLI_NAME = "do";
35259
- var VERSION = "1.308.1";
35357
+ var VERSION = "1.309.0";
35260
35358
  var API_PREFIX = "/api/v1";
35261
35359
  var DEFAULT_API_URL = "http://localhost:3001";
35262
35360
 
@@ -35765,22 +35863,13 @@ var ENTITIES = [
35765
35863
  createInput: "CreateAreaInput",
35766
35864
  updateInput: "UpdateAreaInput"
35767
35865
  }),
35768
- {
35866
+ entityFromOperations(placeOperations, {
35769
35867
  name: "places",
35770
- path: "/places",
35771
- readScopes: ["places:read"],
35772
35868
  returns: "PlaceView",
35773
- canGet: true,
35774
35869
  listFlags: [],
35775
- write: {
35776
- scopes: ["places:write"],
35777
- createSchema: createPlaceInputSchema,
35778
- createInput: "CreatePlaceInput",
35779
- updateSchema: updatePlaceInputSchema,
35780
- updateInput: "UpdatePlaceInput",
35781
- canDelete: true
35782
- }
35783
- },
35870
+ createInput: "CreatePlaceInput",
35871
+ updateInput: "UpdatePlaceInput"
35872
+ }),
35784
35873
  entityFromOperations(routineOperations, {
35785
35874
  name: "routines",
35786
35875
  returns: "RoutineView",
@@ -35959,12 +36048,9 @@ var ENTITIES = [
35959
36048
  createInput: "CreateGuestInput",
35960
36049
  updateInput: "UpdateGuestInput"
35961
36050
  }),
35962
- {
36051
+ entityFromOperations(keyDateOperations, {
35963
36052
  name: "key-dates",
35964
- path: "/key-dates",
35965
- readScopes: ["key-dates:read"],
35966
36053
  returns: "KeyDateView",
35967
- canGet: true,
35968
36054
  listFlags: [
35969
36055
  { name: "node", description: "only the key dates on this node id", query: "nodeId" },
35970
36056
  {
@@ -35983,15 +36069,9 @@ var ENTITIES = [
35983
36069
  query: "to"
35984
36070
  }
35985
36071
  ],
35986
- write: {
35987
- scopes: ["key-dates:write"],
35988
- createSchema: createKeyDateInputSchema,
35989
- createInput: "CreateKeyDateInput",
35990
- updateSchema: updateKeyDateInputSchema,
35991
- updateInput: "UpdateKeyDateInput",
35992
- canDelete: true
35993
- }
35994
- },
36072
+ createInput: "CreateKeyDateInput",
36073
+ updateInput: "UpdateKeyDateInput"
36074
+ }),
35995
36075
  {
35996
36076
  name: "documents",
35997
36077
  path: "/documents",
@@ -36024,12 +36104,9 @@ var ENTITIES = [
36024
36104
  canDelete: true
36025
36105
  }
36026
36106
  },
36027
- {
36107
+ entityFromOperations(incidentOperations, {
36028
36108
  name: "incidents",
36029
- path: "/incidents",
36030
- readScopes: ["documents:read"],
36031
36109
  returns: "IncidentView",
36032
- canGet: true,
36033
36110
  listFlags: [
36034
36111
  { name: "status", description: "only this status (open, claimed, closed)", query: "status" },
36035
36112
  {
@@ -36038,15 +36115,9 @@ var ENTITIES = [
36038
36115
  query: "policyId"
36039
36116
  }
36040
36117
  ],
36041
- write: {
36042
- scopes: ["documents:write"],
36043
- createSchema: createIncidentInputSchema,
36044
- createInput: "CreateIncidentInput",
36045
- updateSchema: updateIncidentInputSchema,
36046
- updateInput: "UpdateIncidentInput",
36047
- canDelete: true
36048
- }
36049
- },
36118
+ createInput: "CreateIncidentInput",
36119
+ updateInput: "UpdateIncidentInput"
36120
+ }),
36050
36121
  entityFromOperations(periodOperations, {
36051
36122
  name: "periods",
36052
36123
  returns: "PeriodView",
@@ -38255,9 +38326,9 @@ var COMMAND_SPECS = [
38255
38326
  description: "The rest of the create body (JSON), e.g. claimNo; overrides the flags."
38256
38327
  }
38257
38328
  ],
38258
- scopes: ["documents:write"],
38329
+ scopes: [...incidentOperations.create.scopes],
38259
38330
  returns: "IncidentView",
38260
- notes: `POST /api/v1/incidents. A policy or Place that isn't a live one in the Space is a 400. Tick steps off with \`do incidents update <id> --data '{"steps":[{"id":"photos","done":true}]}'\`.`
38331
+ notes: `${routeOf(incidentOperations.create)}. A policy or Place that isn't a live one in the Space is a 400. Tick steps off with \`do incidents update <id> --data '{"steps":[{"id":"photos","done":true}]}'\`.`
38261
38332
  },
38262
38333
  {
38263
38334
  path: ["notes", "backlinks"],
@@ -40848,7 +40919,7 @@ var COMMAND_SPECS = [
40848
40919
  description: "Which house in the file (0 = the first, the default)."
40849
40920
  }
40850
40921
  ],
40851
- scopes: ["places:write"],
40922
+ scopes: [...placeOperations.importHouse.scopes],
40852
40923
  returns: "ImportPlacesResult",
40853
40924
  notes: "Each room becomes a Place; rooms already imported (even ones deleted since) are skipped, so do keeps what it owns. No sync with Gaard. Returns { created, skipped, places }."
40854
40925
  },
@@ -44572,7 +44643,10 @@ var HANDLERS = {
44572
44643
  ...fromFlags,
44573
44644
  ...readDataFlag(flags)
44574
44645
  });
44575
- return { data: await requireClient().post("/incidents", body), render: renderRecord };
44646
+ return {
44647
+ data: await requireClient().post(pathOf(incidentOperations.create), body),
44648
+ render: renderRecord
44649
+ };
44576
44650
  },
44577
44651
  "food log": async ({ flags, requireClient }) => {
44578
44652
  if (flagString(flags, "data") === undefined)
@@ -46761,7 +46835,7 @@ var HANDLERS = {
46761
46835
  file,
46762
46836
  ...house !== undefined ? { houseIndex: Number(house) } : {}
46763
46837
  });
46764
- const result = importPlacesResultSchema.parse(await requireClient().post("/places/import", body));
46838
+ const result = importPlacesResultSchema.parse(await requireClient().post(pathOf(placeOperations.importHouse), body));
46765
46839
  return { data: result, render: renderRecord };
46766
46840
  },
46767
46841
  "people note": async ({ flags, requireClient }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robbeverhelst/do",
3
- "version": "1.308.1",
3
+ "version": "1.309.0",
4
4
  "private": false,
5
5
  "description": "do — the agent-drivable CLI over the public /api/v1 surface",
6
6
  "homepage": "https://github.com/robbeverhelst/do/tree/main/apps/cli",