@ordinatio/scheduling-api 0.8.0 → 0.9.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.
@@ -1128,6 +1128,135 @@ var CALENDAR_TOOLS = [
1128
1128
  }
1129
1129
  ];
1130
1130
 
1131
+ // src/agent/gift-certificate-tools.ts
1132
+ var CERTIFICATE_FIELDS = "id, code, status, currency, initialCents, balanceCents, expiresAt, recipientName, recipientEmail, purchaserName, purchaserEmail, message, notes, paymentId, createdByUserId, createdAt";
1133
+ var LINE_FIELDS = "id, seq, type, amountCents, balanceAfterCents, appointmentId, note, createdByUserId, createdAt";
1134
+ var NOT_ENABLED = "A server without gift certificates answers 501.";
1135
+ var ID3 = { name: "id", type: "string", required: true, description: "Gift certificate id" };
1136
+ var CODE_CARE = "The code in the answer spends like cash: give it only to the person it is for, and do not repeat it anywhere else. A read-only API key sees only the last four characters of each code.";
1137
+ var GIFT_CERTIFICATE_TOOLS = [
1138
+ {
1139
+ name: "scheduling_list_gift_certificates",
1140
+ module: "scheduling",
1141
+ method: "GET",
1142
+ route: "/admin/gift-certificates",
1143
+ auth: "session_cookie",
1144
+ description: "List the organization's gift certificates, newest first, with their balances.",
1145
+ params: [
1146
+ { name: "status", type: "string", required: false, description: "Only this status", allowedValues: ["ACTIVE", "VOID"] },
1147
+ { name: "limit", type: "number", required: false, description: "How many to return (default 100, at most 500)" }
1148
+ ],
1149
+ example: { status: "ACTIVE" },
1150
+ responseShape: `{ certificates: [{ ${CERTIFICATE_FIELDS} }] }`,
1151
+ whenToUse: "To find a certificate id, see how much value is outstanding, or look up who a certificate was sold to.",
1152
+ pitfalls: [CODE_CARE, "status is ACTIVE or VOID only: a certificate that has expired or been used up is still ACTIVE here; read its expiresAt and balanceCents.", "There is no total and no paging: the newest 100 come back unless limit says more.", NOT_ENABLED, "Needs the scheduling switch to be on for the organization."],
1153
+ dataSensitivity: "critical",
1154
+ risk: "observe"
1155
+ },
1156
+ {
1157
+ name: "scheduling_get_gift_certificate",
1158
+ module: "scheduling",
1159
+ method: "GET",
1160
+ route: "/admin/gift-certificates/[id]",
1161
+ auth: "session_cookie",
1162
+ description: "Read one gift certificate with its history: the issue, every spend, every give-back and any void, in order.",
1163
+ params: [ID3],
1164
+ example: { id: "gc_1" },
1165
+ responseShape: `{ certificate: { ${CERTIFICATE_FIELDS} }, transactions: [{ ${LINE_FIELDS} }], truncated }`,
1166
+ whenToUse: 'To answer "what is left on this certificate" or "what was it spent on". Amounts are whole cents: 1250 is 12.50.',
1167
+ pitfalls: [CODE_CARE, "Spends have a negative amountCents and give-backs a positive one. truncated is true when the history has more than 1000 lines and only the first are shown.", NOT_ENABLED, "Needs the scheduling switch to be on for the organization."],
1168
+ dataSensitivity: "critical",
1169
+ risk: "observe"
1170
+ },
1171
+ {
1172
+ name: "scheduling_issue_gift_certificate",
1173
+ module: "scheduling",
1174
+ method: "POST",
1175
+ route: "/admin/gift-certificates",
1176
+ auth: "session_cookie",
1177
+ description: "Issue a gift certificate worth an amount, with a random code the holder types at booking.",
1178
+ params: [
1179
+ { name: "amountCents", type: "number", required: true, description: "Value in whole cents, from 100 to 1000000: 5000 is 50.00" },
1180
+ { name: "currency", type: "string", required: false, description: "Three-letter currency code, default usd. A certificate only pays a bill in its own currency." },
1181
+ { name: "expiresAt", type: "string", required: false, description: "When it stops working, an ISO date or time in the future. Leave out for no expiry." },
1182
+ { name: "recipientName", type: "string", required: false, description: "Who it is for" },
1183
+ { name: "recipientEmail", type: "string", required: false, description: "Where to send it" },
1184
+ { name: "purchaserName", type: "string", required: false, description: "Who bought it" },
1185
+ { name: "purchaserEmail", type: "string", required: false, description: "The buyer's email" },
1186
+ { name: "message", type: "string", required: false, description: "A note for the recipient, up to 500 characters" },
1187
+ { name: "paymentId", type: "string", required: false, description: "The payment that bought it. A payment makes one certificate: asking again with the same id returns the first one." },
1188
+ { name: "notes", type: "string", required: false, description: "A note for staff, up to 1000 characters" }
1189
+ ],
1190
+ example: { amountCents: 5e3, recipientName: "Jane Smith", recipientEmail: "jane@example.com", message: "Happy birthday" },
1191
+ responseShape: `{ certificate: { ${CERTIFICATE_FIELDS} } }`,
1192
+ whenToUse: "When a certificate is sold at the counter, given as a gift or issued to make up for a problem. It works at once.",
1193
+ pitfalls: [
1194
+ CODE_CARE,
1195
+ "This creates value the business owes the holder: nothing is charged here. Take payment separately and pass its id as paymentId so a repeat cannot issue a second certificate.",
1196
+ "A paymentId already used for a different amount or currency is refused with 409. An amount outside 100 to 1000000 cents, a past expiry or an email that is not an address is refused with 400, with every problem listed.",
1197
+ NOT_ENABLED,
1198
+ "Needs the scheduling switch to be on for the organization."
1199
+ ],
1200
+ dataSensitivity: "critical",
1201
+ risk: "govern",
1202
+ requiresApproval: {
1203
+ action: "Issue a gift certificate",
1204
+ reason: "It creates spendable value that the business owes the holder, and the code in the answer can be spent by anyone who has it.",
1205
+ prompt: "Issue a gift certificate worth {amountCents} cents?"
1206
+ }
1207
+ },
1208
+ {
1209
+ name: "scheduling_void_gift_certificate",
1210
+ module: "scheduling",
1211
+ method: "POST",
1212
+ route: "/admin/gift-certificates/[id]/void",
1213
+ auth: "session_cookie",
1214
+ description: "Stop a gift certificate from being spent. Its balance and history stay on record.",
1215
+ params: [ID3],
1216
+ example: { id: "gc_1" },
1217
+ responseShape: "{ voided: true }",
1218
+ whenToUse: "When a certificate was issued by mistake, was lost or stolen, or the sale was refunded.",
1219
+ pitfalls: ["A void certificate cannot be spent or topped up, and cannot be made active again: issue a new one if the holder is owed value.", "Answers 404 for a certificate that does not exist, belongs to another business, or is already void.", NOT_ENABLED, "Needs the scheduling switch to be on for the organization."],
1220
+ dataSensitivity: "sensitive",
1221
+ risk: "govern",
1222
+ requiresApproval: {
1223
+ action: "Void a gift certificate",
1224
+ reason: "The holder can no longer spend it, and a voided certificate cannot be brought back.",
1225
+ prompt: "Void gift certificate {id}?"
1226
+ }
1227
+ },
1228
+ {
1229
+ name: "scheduling_restore_gift_certificate",
1230
+ module: "scheduling",
1231
+ method: "POST",
1232
+ route: "/admin/gift-certificates/[id]/restore",
1233
+ auth: "session_cookie",
1234
+ description: "Give value back to a gift certificate, for a cancelled or refunded booking or to correct a mistake.",
1235
+ params: [
1236
+ ID3,
1237
+ { name: "amountCents", type: "number", required: true, description: "Value to give back in whole cents: 1250 is 12.50" },
1238
+ { name: "appointmentId", type: "string", required: false, description: "The appointment the value was spent on. With it, no more than was spent on that appointment and not yet returned can come back." },
1239
+ { name: "note", type: "string", required: false, description: "Why, up to 1000 characters" }
1240
+ ],
1241
+ example: { id: "gc_1", amountCents: 2500, appointmentId: "appt_1", note: "Booking cancelled" },
1242
+ responseShape: "{ restored: { certificateId, transactionId, restoredCents, balanceCents } }",
1243
+ whenToUse: "After a booking paid with a certificate is cancelled or refunded, or to put right a wrong spend. Give the appointment whenever there is one.",
1244
+ pitfalls: [
1245
+ "Without appointmentId the only limit is the amount the certificate was issued for, so a correction cannot go above it.",
1246
+ "A repeated give-back for the same appointment returns nothing more and is refused with 409. A void certificate is refused with 409. An expired certificate takes the value back but its expiry is not extended.",
1247
+ NOT_ENABLED,
1248
+ "Needs the scheduling switch to be on for the organization."
1249
+ ],
1250
+ dataSensitivity: "sensitive",
1251
+ risk: "govern",
1252
+ requiresApproval: {
1253
+ action: "Give value back to a gift certificate",
1254
+ reason: "It adds spendable value to the certificate.",
1255
+ prompt: "Give {amountCents} cents back to gift certificate {id}?"
1256
+ }
1257
+ }
1258
+ ];
1259
+
1131
1260
  // src/agent/policy-tools.ts
1132
1261
  var FEE = "An object with enabled (true or false), amount (0 to 10000, required when enabled is true; for a PERCENTAGE it is at most 100) and feeType (FLAT or PERCENTAGE; FLAT if left out).";
1133
1262
  var PREVENTION = "An object with enabled (true or false; false if left out), threshold (how many no-shows trigger it, a whole number 1 to 20; 2 if left out) and action (REQUIRE_APPROVAL, so the booking waits for a person, or BLOCK_BOOKING, so online booking is refused; REQUIRE_APPROVAL if left out).";
@@ -1196,7 +1325,7 @@ var POLICY_TOOLS = [
1196
1325
 
1197
1326
  // src/agent/privacy-tools.ts
1198
1327
  var COUNTS = "{ appointments, notifications, waitlistEntries, packagePurchases, recurringSeries, webhookDeliveries }";
1199
- var NOT_ENABLED = "A server without data export and erasure answers 501.";
1328
+ var NOT_ENABLED2 = "A server without data export and erasure answers 501.";
1200
1329
  var WHO = "Name the person with email, clientId or both. A client id also stands for every address that client has booked with.";
1201
1330
  var SUBJECT_PARAMS = [
1202
1331
  { name: "email", type: "string", required: false, description: "The person's email address: one valid address, up to 254 characters, in any letter case" },
@@ -1220,7 +1349,7 @@ var PRIVACY_TOOLS = [
1220
1349
  "Self-service links and waitlist links are left out or removed from the messages, so the document cannot be used to change a booking.",
1221
1350
  "Someone with no data gets empty lists and zero counts, not an error. The request is recorded either way, and if it cannot be recorded nothing is returned.",
1222
1351
  "The request is recorded with only a digest of the address, never the address itself.",
1223
- NOT_ENABLED,
1352
+ NOT_ENABLED2,
1224
1353
  "Needs the scheduling switch to be on for the organization."
1225
1354
  ],
1226
1355
  dataSensitivity: "critical",
@@ -1252,7 +1381,7 @@ var PRIVACY_TOOLS = [
1252
1381
  "It is refused with 409 while the person has an upcoming pending or confirmed booking or a waitlist offer they hold (blockers says how many). Cancel those first.",
1253
1382
  "warnings notes sessions left on an active package: after erasure it can no longer be matched to the person.",
1254
1383
  "Copies already sent elsewhere, such as emails, webhook receivers or backups outside this system, are not recalled.",
1255
- NOT_ENABLED,
1384
+ NOT_ENABLED2,
1256
1385
  "Needs the scheduling switch to be on for the organization."
1257
1386
  ],
1258
1387
  dataSensitivity: "critical",
@@ -1279,7 +1408,7 @@ var PRIVACY_TOOLS = [
1279
1408
  whenToUse: "To show that a request was handled, or to see who has been exporting or erasing data.",
1280
1409
  pitfalls: [
1281
1410
  "kind is EXPORT or ERASE. The log holds counts and who asked, never the person's name or address.",
1282
- NOT_ENABLED,
1411
+ NOT_ENABLED2,
1283
1412
  "Needs the scheduling switch to be on for the organization."
1284
1413
  ],
1285
1414
  dataSensitivity: "internal",
@@ -1291,7 +1420,7 @@ var PRIVACY_TOOLS = [
1291
1420
  var SUMMARY_FIELDS = "id, name, slug, description, isActive, updatedAt";
1292
1421
  var FORM_FIELDS = "id, name, slug, description, isActive, questions, rules, fallback, createdAt, updatedAt";
1293
1422
  var FORM_ID = { name: "id", type: "string", required: true, description: "Routing form id" };
1294
- var NOT_ENABLED2 = "A server without routing forms answers 501.";
1423
+ var NOT_ENABLED3 = "A server without routing forms answers 501.";
1295
1424
  var DETAILS = "A form with any problem is refused with 400 and nothing is saved; for a problem in the form itself, details lists every one with its path (such as rules[1].conditions[0].value) and the reason. A body of the wrong shape (a missing fallback, a list that is too long) is refused earlier with 400 and details that name the field instead.";
1296
1425
  var QUESTIONS = "A list of 1 to 20 questions, each an object with id (starts with a letter; letters, digits, - and _; at most 40 characters; different for each question), label (1 to 200 characters), type (select, radio, checkbox, text or number), required (true or false; false if left out) and, for select, radio and checkbox only, options (2 to 50 different choices of 1 to 100 characters).";
1297
1426
  var RULES = `A list of 1 to 50 rules, tried in order; the first whose conditions hold decides where the client goes. Each rule is an object with match ("all" conditions must hold, or "any"; "all" if left out), conditions (1 to 10, each an object with questionId, operator and value) and destination (an object with typeId, calendarId or both), and optionally id (made up if left out) and label (up to 200 characters). Operators by question type: select and radio take equals, not_equals, in, is_answered, is_empty; checkbox takes contains, not_contains, is_answered, is_empty; text takes equals, not_equals, contains, not_contains, is_answered, is_empty; number takes equals, not_equals, gt, gte, lt, lte, is_answered, is_empty. For in the value is a list of the question's options. Otherwise the value is one of the question's options, or a text of 1 to 200 characters for a text question, or a number; is_answered and is_empty take no value.`;
@@ -1308,7 +1437,7 @@ var ROUTING_TOOLS = [
1308
1437
  example: {},
1309
1438
  responseShape: `{ forms: [{ ${SUMMARY_FIELDS} }] }`,
1310
1439
  whenToUse: "To find a form id or slug. Read one form in full with scheduling_get_routing_form.",
1311
- pitfalls: ["The list has no questions or rules; it is a summary.", "The answer is a plain list with no paging, ordered by name.", NOT_ENABLED2, "Needs the scheduling switch to be on for the organization."],
1440
+ pitfalls: ["The list has no questions or rules; it is a summary.", "The answer is a plain list with no paging, ordered by name.", NOT_ENABLED3, "Needs the scheduling switch to be on for the organization."],
1312
1441
  dataSensitivity: "internal",
1313
1442
  risk: "observe"
1314
1443
  },
@@ -1323,7 +1452,7 @@ var ROUTING_TOOLS = [
1323
1452
  example: { id: "form_1" },
1324
1453
  responseShape: `{ form: { ${FORM_FIELDS} } }`,
1325
1454
  whenToUse: "Before changing a form, to see what it is now and send back what should stay.",
1326
- pitfalls: ["A form of another organization is a plain 404.", NOT_ENABLED2, "Needs the scheduling switch to be on for the organization."],
1455
+ pitfalls: ["A form of another organization is a plain 404.", NOT_ENABLED3, "Needs the scheduling switch to be on for the organization."],
1327
1456
  dataSensitivity: "internal",
1328
1457
  risk: "observe"
1329
1458
  },
@@ -1357,7 +1486,7 @@ var ROUTING_TOOLS = [
1357
1486
  "Every type and calendar a rule or the fallback names must exist, be switched on and, when both are named, the type must be offered on that calendar; otherwise it is refused with 400.",
1358
1487
  "A slug that another organization uses is refused with 400 (details names slug); the same slug on two of your own forms, or a 51st form, is refused with 409.",
1359
1488
  "At least one rule is required.",
1360
- NOT_ENABLED2,
1489
+ NOT_ENABLED3,
1361
1490
  "Needs the scheduling switch to be on for the organization."
1362
1491
  ],
1363
1492
  dataSensitivity: "internal",
@@ -1393,7 +1522,7 @@ var ROUTING_TOOLS = [
1393
1522
  DETAILS,
1394
1523
  "Changing a question can break a rule that uses it, so the whole result is checked; the destinations are checked again only when questions, rules or the fallback are sent, so renaming or switching off a form always works.",
1395
1524
  "A slug that another organization uses is refused with 400, and one that another of your own forms uses with 409. A form of another organization is a plain 404.",
1396
- NOT_ENABLED2,
1525
+ NOT_ENABLED3,
1397
1526
  "Needs the scheduling switch to be on for the organization."
1398
1527
  ],
1399
1528
  dataSensitivity: "internal",
@@ -1415,7 +1544,7 @@ var ROUTING_TOOLS = [
1415
1544
  example: { id: "form_1" },
1416
1545
  responseShape: "{ success: true }",
1417
1546
  whenToUse: "Only to remove a form that is no longer wanted. To stop clients using one for now, switch it off with scheduling_update_routing_form.",
1418
- pitfalls: ["A link to the form stops working at once.", "A deleted form cannot be brought back.", "A form of another organization is a plain 404.", NOT_ENABLED2, "Needs the scheduling switch to be on for the organization."],
1547
+ pitfalls: ["A link to the form stops working at once.", "A deleted form cannot be brought back.", "A form of another organization is a plain 404.", NOT_ENABLED3, "Needs the scheduling switch to be on for the organization."],
1419
1548
  dataSensitivity: "internal",
1420
1549
  risk: "act",
1421
1550
  requiresApproval: {
@@ -1444,7 +1573,7 @@ var ROUTING_TOOLS = [
1444
1573
  "A rule whose destination has since been switched off is skipped and the next matching rule is tried; if the fallback destination is also gone, message tells the client to get in touch.",
1445
1574
  "Answers that do not fit the form are refused with 400 and details.",
1446
1575
  "It changes nothing, but it is a POST, so it asks first.",
1447
- NOT_ENABLED2
1576
+ NOT_ENABLED3
1448
1577
  ],
1449
1578
  dataSensitivity: "none",
1450
1579
  risk: "act",
@@ -1970,7 +2099,7 @@ var SETTINGS_TOOLS = [
1970
2099
  ];
1971
2100
 
1972
2101
  // src/agent/type-tools.ts
1973
- var ID3 = { name: "id", type: "string", required: true, description: "Appointment type id" };
2102
+ var ID4 = { name: "id", type: "string", required: true, description: "Appointment type id" };
1974
2103
  var TYPE_FIELDS = "id, name, slug, description, location, locationType, duration, color, price, deposit, currency, isGroup, maxSeats, assignmentStrategy, intakeForm, requiresPayment, requiresApproval, allowReschedule, allowCancel, cancelDeadlineHrs, reminder1MinsBefore, reminder2MinsBefore, followupMinsAfter, organizationId, categoryId, isActive, sortOrder, createdAt, updatedAt";
1975
2104
  var LOCATION_TYPES = ["IN_PERSON", "TRAVEL_TO_CLIENT", "VIRTUAL", "PHONE"];
1976
2105
  var STRATEGIES = ["NONE", "ROUND_ROBIN", "LOAD_BALANCED"];
@@ -2054,7 +2183,7 @@ var TYPE_TOOLS = [
2054
2183
  auth: "session_cookie",
2055
2184
  description: "Change an appointment type. Only the fields you send change; a field left out stays as it is. Setting isActive to false switches it off.",
2056
2185
  params: [
2057
- ID3,
2186
+ ID4,
2058
2187
  ...typeFields(true),
2059
2188
  { name: "isActive", type: "boolean", required: false, description: "false switches the type off so it can no longer be booked, true switches it back on" }
2060
2189
  ],
@@ -2084,7 +2213,7 @@ var TYPE_TOOLS = [
2084
2213
  route: "/admin/types/[id]",
2085
2214
  auth: "session_cookie",
2086
2215
  description: "Delete an appointment type that no appointment has ever used, and release its short booking address.",
2087
- params: [ID3],
2216
+ params: [ID4],
2088
2217
  example: { id: "type_1" },
2089
2218
  responseShape: "{ success: true }",
2090
2219
  whenToUse: "Only to remove a type that was created by mistake and never booked.",
@@ -2107,7 +2236,7 @@ var TYPE_TOOLS = [
2107
2236
  route: "/admin/types/[id]/round-robin-state",
2108
2237
  auth: "session_cookie",
2109
2238
  description: "Restart the turn-taking of a team appointment type, so the next booking goes to whoever the rotation starts with.",
2110
- params: [ID3],
2239
+ params: [ID4],
2111
2240
  example: { id: "type_1" },
2112
2241
  responseShape: "{ success: true }",
2113
2242
  whenToUse: "After a staff member joins or leaves a team type and the rotation should begin again.",
@@ -2127,7 +2256,7 @@ var TYPE_TOOLS = [
2127
2256
 
2128
2257
  // src/agent/waitlist-tools.ts
2129
2258
  var ENTRY_FIELDS = "id, typeId, calendarId, day, slotStart, clientName, clientEmail, clientPhone, status, offerSlotStart, offerExpiresAt, createdAt";
2130
- var NOT_ENABLED3 = "A server without the waitlist answers 501.";
2259
+ var NOT_ENABLED4 = "A server without the waitlist answers 501.";
2131
2260
  var WAITLIST_TOOLS = [
2132
2261
  {
2133
2262
  name: "scheduling_list_waitlist",
@@ -2150,7 +2279,7 @@ var WAITLIST_TOOLS = [
2150
2279
  "The client's private link token is never part of the answer.",
2151
2280
  "The answer carries names, email addresses and phone numbers.",
2152
2281
  "Any other status value is refused with 400.",
2153
- NOT_ENABLED3,
2282
+ NOT_ENABLED4,
2154
2283
  "Needs the scheduling switch to be on for the organization."
2155
2284
  ],
2156
2285
  dataSensitivity: "sensitive",
@@ -2172,7 +2301,7 @@ var WAITLIST_TOOLS = [
2172
2301
  "Removing someone who holds an offer frees that slot, and it is offered to the next person who fits, who is told by the host's own notice.",
2173
2302
  "The person removed is not sent a message by this tool, and a removed entry cannot be brought back; the client has to join again.",
2174
2303
  "An entry of another organization is a plain 404.",
2175
- NOT_ENABLED3,
2304
+ NOT_ENABLED4,
2176
2305
  "Needs the scheduling switch to be on for the organization."
2177
2306
  ],
2178
2307
  dataSensitivity: "sensitive",
@@ -2189,7 +2318,7 @@ var WAITLIST_TOOLS = [
2189
2318
  var ENDPOINT_FIELDS = "id, url, description, eventTypes, isActive, createdAt";
2190
2319
  var DELIVERY_FIELDS = "id, endpointId, eventId, eventType, status, attempts, nextAttemptAt, lastStatusCode, lastError, deliveredAt, createdAt, attemptLog: [{ attemptNumber, statusCode, error, durationMs, createdAt }]";
2191
2320
  var ENDPOINT_ID = { name: "id", type: "string", required: true, description: "Webhook endpoint id" };
2192
- var NOT_ENABLED4 = "A server without webhooks answers 501.";
2321
+ var NOT_ENABLED5 = "A server without webhooks answers 501.";
2193
2322
  var WEBHOOK_TOOLS = [
2194
2323
  {
2195
2324
  name: "scheduling_list_webhooks",
@@ -2202,7 +2331,7 @@ var WEBHOOK_TOOLS = [
2202
2331
  example: {},
2203
2332
  responseShape: `{ endpoints: [{ ${ENDPOINT_FIELDS} }], eventTypes }`,
2204
2333
  whenToUse: "To see what outside systems are told about bookings, to find an endpoint id, or to learn the event names.",
2205
- pitfalls: ["The signing secret is never part of this answer; it was shown once when the endpoint was added.", "The answer is a plain list with no paging, newest first.", NOT_ENABLED4, "Needs the scheduling switch to be on for the organization."],
2334
+ pitfalls: ["The signing secret is never part of this answer; it was shown once when the endpoint was added.", "The answer is a plain list with no paging, newest first.", NOT_ENABLED5, "Needs the scheduling switch to be on for the organization."],
2206
2335
  dataSensitivity: "internal",
2207
2336
  risk: "observe"
2208
2337
  },
@@ -2225,7 +2354,7 @@ var WEBHOOK_TOOLS = [
2225
2354
  "The answer carries the signing secret, and it is shown only this once; it is never returned again. Give it to the person who is setting up the receiver and do not repeat it anywhere else.",
2226
2355
  "An address that is not https, points at a private or local network, has no domain, or contains a user name or password is refused with 400. An organization can have at most 20 endpoints; the 21st is refused with 400. A list that names an unknown event, or mixes * with other events, is refused with 400; an event named twice is counted once.",
2227
2356
  "Events are sent from the server and a receiver that keeps failing is retried, then its deliveries are parked as DEAD_LETTER (see scheduling_list_webhook_deliveries).",
2228
- NOT_ENABLED4,
2357
+ NOT_ENABLED5,
2229
2358
  "Needs the scheduling switch to be on for the organization."
2230
2359
  ],
2231
2360
  dataSensitivity: "critical",
@@ -2247,7 +2376,7 @@ var WEBHOOK_TOOLS = [
2247
2376
  example: { id: "hook_1" },
2248
2377
  responseShape: "{ success: true }",
2249
2378
  whenToUse: "When an outside system should stop being told about bookings. There is no way to switch one off without deleting it.",
2250
- pitfalls: ["Its deliveries and their log are deleted too, including any that were still waiting to be sent.", "It cannot be brought back; add the address again for a new endpoint with a new secret.", "An endpoint of another organization is a plain 404.", NOT_ENABLED4, "Needs the scheduling switch to be on for the organization."],
2379
+ pitfalls: ["Its deliveries and their log are deleted too, including any that were still waiting to be sent.", "It cannot be brought back; add the address again for a new endpoint with a new secret.", "An endpoint of another organization is a plain 404.", NOT_ENABLED5, "Needs the scheduling switch to be on for the organization."],
2251
2380
  dataSensitivity: "internal",
2252
2381
  risk: "act",
2253
2382
  requiresApproval: {
@@ -2271,7 +2400,7 @@ var WEBHOOK_TOOLS = [
2271
2400
  "The answer is 200 whether or not the receiver accepted it: read ok. ok false comes with the receiver's statusCode, or an error when it could not be reached.",
2272
2401
  "It makes a real outgoing request from the server to the address, and the test shows in the delivery log as the event webhook.test. A test that fails (the receiver answers with an error or cannot be reached) is logged as DEAD_LETTER after its single try, so it appears in that list and could be retried like any other.",
2273
2402
  "An endpoint of another organization is a plain 404.",
2274
- NOT_ENABLED4,
2403
+ NOT_ENABLED5,
2275
2404
  "Needs the scheduling switch to be on for the organization."
2276
2405
  ],
2277
2406
  dataSensitivity: "internal",
@@ -2298,7 +2427,7 @@ var WEBHOOK_TOOLS = [
2298
2427
  example: { id: "hook_1", status: "DEAD_LETTER" },
2299
2428
  responseShape: `{ deliveries: [{ ${DELIVERY_FIELDS} }], total, hasMore }`,
2300
2429
  whenToUse: "To find out why an outside system missed events, and to find the id of a DEAD_LETTER delivery to retry.",
2301
- pitfalls: ["Each delivery shows only its last 10 attempts.", "Any other status value is refused with 400.", "An endpoint of another organization is a plain 404.", NOT_ENABLED4, "Needs the scheduling switch to be on for the organization."],
2430
+ pitfalls: ["Each delivery shows only its last 10 attempts.", "Any other status value is refused with 400.", "An endpoint of another organization is a plain 404.", NOT_ENABLED5, "Needs the scheduling switch to be on for the organization."],
2302
2431
  dataSensitivity: "internal",
2303
2432
  risk: "observe"
2304
2433
  },
@@ -2317,7 +2446,7 @@ var WEBHOOK_TOOLS = [
2317
2446
  "Only a DEAD_LETTER delivery can be retried (this includes a failed test send); any other delivery, or one of another organization, is a plain 404.",
2318
2447
  "This only queues it. The server's background delivery sends it, so success true does not mean the receiver has it yet; read the delivery log again later.",
2319
2448
  "The event is sent again as it was first made, so the receiver may see an event it partly processed before.",
2320
- NOT_ENABLED4,
2449
+ NOT_ENABLED5,
2321
2450
  "Needs the scheduling switch to be on for the organization."
2322
2451
  ],
2323
2452
  dataSensitivity: "internal",
@@ -2336,6 +2465,7 @@ var SCHEDULING_AGENT_EXCLUDED = {
2336
2465
  "POST /admin/api-keys": "Makes a credential whose secret would be shown in the agent's own transcript. The owner makes keys in the dashboard.",
2337
2466
  "DELETE /admin/api-keys/[id]": "Credential management is left to the owner in the dashboard, not to an agent.",
2338
2467
  "POST /coupons/validate": "Advisory price check for a visitor's booking page. It changes nothing but is a POST, and only GET tools run without approval; staff read a coupon's terms with the coupon list tool.",
2468
+ "POST /gift-certificates/check": "A visitor checking the balance of a code they hold, from the public booking page. It changes nothing but is a POST, and only GET tools run without approval; staff read a certificate with the get tool.",
2339
2469
  "POST /waitlist": "A client joining the waitlist for themselves; the answer holds their own private link token, which an agent should never be handed.",
2340
2470
  "DELETE /waitlist": "A client leaving the waitlist from their own private link; staff remove an entry with the remove-waitlist-entry tool.",
2341
2471
  "GET /waitlist/offer": "A client reading their own offer from a private link token.",
@@ -2365,7 +2495,7 @@ var SCHEDULING_AGENT_EXCLUDED = {
2365
2495
  var SCHEDULING_AGENT_PENDING = [];
2366
2496
 
2367
2497
  // src/agent/index.ts
2368
- var SCHEDULING_AGENT_TOOLS = [...APPOINTMENT_TOOLS, ...CALENDAR_TOOLS, ...TYPE_TOOLS, ...AVAILABILITY_TOOLS, ...SERIES_TOOLS, ...SETTINGS_TOOLS, ...POLICY_TOOLS, ...BILLING_TOOLS, ...WEBHOOK_TOOLS, ...ROUTING_TOOLS, ...WAITLIST_TOOLS, ...PRIVACY_TOOLS, ...ANALYTICS_TOOLS];
2498
+ var SCHEDULING_AGENT_TOOLS = [...APPOINTMENT_TOOLS, ...CALENDAR_TOOLS, ...TYPE_TOOLS, ...AVAILABILITY_TOOLS, ...SERIES_TOOLS, ...SETTINGS_TOOLS, ...POLICY_TOOLS, ...BILLING_TOOLS, ...GIFT_CERTIFICATE_TOOLS, ...WEBHOOK_TOOLS, ...ROUTING_TOOLS, ...WAITLIST_TOOLS, ...PRIVACY_TOOLS, ...ANALYTICS_TOOLS];
2369
2499
  function createSchedulingAgentTools(options = {}) {
2370
2500
  const base = (options.basePath ?? "/api/scheduling").replace(/\/+$/, "");
2371
2501
  return SCHEDULING_AGENT_TOOLS.filter((tool) => !options.readOnly || tool.method === "GET").map(({ route, ...tool }) => ({
@@ -444,6 +444,31 @@ var ApiKeySchema = z10.object({
444
444
  access: z10.string().max(20)
445
445
  }).strict();
446
446
 
447
+ // src/schemas/gift-certificate.schema.ts
448
+ import { z as z11 } from "zod";
449
+ var text = (max) => z11.string().max(max).nullable().optional();
450
+ var GiftCertificateSchema = z11.object({
451
+ amountCents: z11.number(),
452
+ currency: z11.string().max(10).optional(),
453
+ expiresAt: z11.string().max(40).nullable().optional(),
454
+ recipientName: text(300),
455
+ recipientEmail: text(300),
456
+ purchaserName: text(300),
457
+ purchaserEmail: text(300),
458
+ message: text(1e3),
459
+ paymentId: text(300),
460
+ notes: text(2e3)
461
+ }).strict();
462
+ var GiftCertificateRestoreSchema = z11.object({
463
+ amountCents: z11.number(),
464
+ appointmentId: z11.string().max(200).optional(),
465
+ note: z11.string().max(1e3).optional()
466
+ }).strict();
467
+ var GiftCertificateCheckSchema = z11.object({
468
+ code: z11.string().max(64),
469
+ calendarId: z11.string().min(1).max(200)
470
+ }).strict();
471
+
447
472
  export {
448
473
  IntakeFormFieldSchema,
449
474
  CreateAppointmentTypeSchema,
@@ -484,5 +509,8 @@ export {
484
509
  PrivacyEraseSchema,
485
510
  BrandSchema,
486
511
  TextSettingsSchema,
487
- ApiKeySchema
512
+ ApiKeySchema,
513
+ GiftCertificateSchema,
514
+ GiftCertificateRestoreSchema,
515
+ GiftCertificateCheckSchema
488
516
  };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { S as SchedulingHost, R as Route, H as HttpMethod, a as RateLimitTier, b as SchedulingCache, P as PublicBookingResolver, c as PublicOrganizationResolver, A as AvailabilityCache, B as BalancePaymentControl, d as SendingDomainCheck, e as SendingDomainRecord, f as SendingDomainRecords, D as DnsResolver, g as StaffResolver, h as StaffContext } from './routes-mii9tsbA.mjs';
2
- export { i as ActivityEntry, j as ActivityLog, k as ApiKeySettings, l as AppointmentEventSink, m as BookingClientResolver, n as BookingPolicy, o as BrandSettings, C as CacheOptions, p as CalendarConnectOutcome, q as CalendarConnector, r as CalendarConnectors, s as CalendarVisibility, I as InternalAccess, N as NoShowPolicy, t as PrivacySettings, u as PublicBookingContext, v as PublicBookingKind, w as PublicOrganization, x as RecordCheck, y as RecordStatus, z as ResolvedHost, E as RouteContext, F as RouteHandler, G as RoutingFormSettings, J as StaffDirectory, W as WaitlistSettings, K as WebhookSettings, L as WorkerCommands, M as checkSendingDomain, O as normalizeSendingDomain } from './routes-mii9tsbA.mjs';
1
+ import { S as SchedulingHost, R as Route, H as HttpMethod, a as RateLimitTier, b as SchedulingCache, P as PublicBookingResolver, c as PublicOrganizationResolver, A as AvailabilityCache, B as BalancePaymentControl, d as SendingDomainCheck, e as SendingDomainRecord, f as SendingDomainRecords, D as DnsResolver, g as StaffResolver, h as StaffContext } from './routes-h90wEQuD.mjs';
2
+ export { i as ActivityEntry, j as ActivityLog, k as ApiKeySettings, l as AppointmentEventSink, m as BookingClientResolver, n as BookingPolicy, o as BrandSettings, C as CacheOptions, p as CalendarConnectOutcome, q as CalendarConnector, r as CalendarConnectors, s as CalendarVisibility, I as InternalAccess, N as NoShowPolicy, t as PrivacySettings, u as PublicBookingContext, v as PublicBookingKind, w as PublicOrganization, x as RecordCheck, y as RecordStatus, z as ResolvedHost, E as RouteContext, F as RouteHandler, G as RoutingFormSettings, J as StaffDirectory, W as WaitlistSettings, K as WebhookSettings, L as WorkerCommands, M as checkSendingDomain, O as normalizeSendingDomain } from './routes-h90wEQuD.mjs';
3
3
  import { SchedulingDb, PaymentAdapter, NotificationAdapter, AppointmentStatus, CalendarSyncAdapter, CalendarEventRef, CalendarEvent } from '@ordinatio/scheduling';
4
- export { ApiKeySchema, BookingPageConfig, BookingPageConfigSchema, BookingPageTheme, BookingPageThemeSchema, BrandSchema, CancelRecurringScopeSchema, CancelRecurringSeriesInput, CancelRecurringSeriesSchema, CreateAppointmentCategoryInput, CreateAppointmentCategorySchema, CreateAppointmentTypeInput, CreateAppointmentTypeSchema, CreateAvailabilityRuleInput, CreateAvailabilityRuleSchema, CreateCalendarInput, CreateCalendarSchema, CreateCouponCodeInput, CreateCouponCodeSchema, CreateNotificationTemplateInput, CreateNotificationTemplateSchema, CreatePackagePurchaseInput, CreatePackagePurchaseSchema, CreateRecurringSeriesInput, CreateRecurringSeriesSchema, CreateRoutingFormInput, CreateRoutingFormSchema, CreateServicePackageInput, CreateServicePackageSchema, CreateWebhookEndpointInput, CreateWebhookEndpointSchema, DEFAULT_CANCELLATION_POLICY, IntakeFormFieldSchema, NoShowPrevention, NoShowPreventionAction, NoShowPreventionActionSchema, NotificationChannelSchema, NotificationTriggerSchema, OrgCancellationPolicy, OrgCancellationPolicySchema, PrivacyEraseSchema, PrivacySubjectSchema, RecurringFrequencySchema, RouteClientSchema, SLOT_GRANULARITY_DEFAULT, SLOT_GRANULARITY_OPTIONS, SlotGranularityMinutes, TestRoutingFormSchema, TextSettingsSchema, UpdateAppointmentCategoryInput, UpdateAppointmentCategorySchema, UpdateAppointmentTypeInput, UpdateAppointmentTypeSchema, UpdateBookingPageInput, UpdateBookingPageSchema, UpdateCalendarInput, UpdateCalendarSchema, UpdateCouponCodeInput, UpdateCouponCodeSchema, UpdateNotificationTemplateInput, UpdateNotificationTemplateSchema, UpdatePackagePurchaseInput, UpdatePackagePurchaseSchema, UpdateRoutingFormInput, UpdateRoutingFormSchema, UpdateServicePackageInput, UpdateServicePackageSchema } from './schemas/index.mjs';
4
+ export { ApiKeySchema, BookingPageConfig, BookingPageConfigSchema, BookingPageTheme, BookingPageThemeSchema, BrandSchema, CancelRecurringScopeSchema, CancelRecurringSeriesInput, CancelRecurringSeriesSchema, CreateAppointmentCategoryInput, CreateAppointmentCategorySchema, CreateAppointmentTypeInput, CreateAppointmentTypeSchema, CreateAvailabilityRuleInput, CreateAvailabilityRuleSchema, CreateCalendarInput, CreateCalendarSchema, CreateCouponCodeInput, CreateCouponCodeSchema, CreateNotificationTemplateInput, CreateNotificationTemplateSchema, CreatePackagePurchaseInput, CreatePackagePurchaseSchema, CreateRecurringSeriesInput, CreateRecurringSeriesSchema, CreateRoutingFormInput, CreateRoutingFormSchema, CreateServicePackageInput, CreateServicePackageSchema, CreateWebhookEndpointInput, CreateWebhookEndpointSchema, DEFAULT_CANCELLATION_POLICY, GiftCertificateCheckSchema, GiftCertificateRestoreSchema, GiftCertificateSchema, IntakeFormFieldSchema, NoShowPrevention, NoShowPreventionAction, NoShowPreventionActionSchema, NotificationChannelSchema, NotificationTriggerSchema, OrgCancellationPolicy, OrgCancellationPolicySchema, PrivacyEraseSchema, PrivacySubjectSchema, RecurringFrequencySchema, RouteClientSchema, SLOT_GRANULARITY_DEFAULT, SLOT_GRANULARITY_OPTIONS, SlotGranularityMinutes, TestRoutingFormSchema, TextSettingsSchema, UpdateAppointmentCategoryInput, UpdateAppointmentCategorySchema, UpdateAppointmentTypeInput, UpdateAppointmentTypeSchema, UpdateBookingPageInput, UpdateBookingPageSchema, UpdateCalendarInput, UpdateCalendarSchema, UpdateCouponCodeInput, UpdateCouponCodeSchema, UpdateNotificationTemplateInput, UpdateNotificationTemplateSchema, UpdatePackagePurchaseInput, UpdatePackagePurchaseSchema, UpdateRoutingFormInput, UpdateRoutingFormSchema, UpdateServicePackageInput, UpdateServicePackageSchema } from './schemas/index.mjs';
5
5
  import { IncomingMessage, ServerResponse } from 'node:http';
6
6
  import 'zod';
7
7
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { S as SchedulingHost, R as Route, H as HttpMethod, a as RateLimitTier, b as SchedulingCache, P as PublicBookingResolver, c as PublicOrganizationResolver, A as AvailabilityCache, B as BalancePaymentControl, d as SendingDomainCheck, e as SendingDomainRecord, f as SendingDomainRecords, D as DnsResolver, g as StaffResolver, h as StaffContext } from './routes-mii9tsbA.js';
2
- export { i as ActivityEntry, j as ActivityLog, k as ApiKeySettings, l as AppointmentEventSink, m as BookingClientResolver, n as BookingPolicy, o as BrandSettings, C as CacheOptions, p as CalendarConnectOutcome, q as CalendarConnector, r as CalendarConnectors, s as CalendarVisibility, I as InternalAccess, N as NoShowPolicy, t as PrivacySettings, u as PublicBookingContext, v as PublicBookingKind, w as PublicOrganization, x as RecordCheck, y as RecordStatus, z as ResolvedHost, E as RouteContext, F as RouteHandler, G as RoutingFormSettings, J as StaffDirectory, W as WaitlistSettings, K as WebhookSettings, L as WorkerCommands, M as checkSendingDomain, O as normalizeSendingDomain } from './routes-mii9tsbA.js';
1
+ import { S as SchedulingHost, R as Route, H as HttpMethod, a as RateLimitTier, b as SchedulingCache, P as PublicBookingResolver, c as PublicOrganizationResolver, A as AvailabilityCache, B as BalancePaymentControl, d as SendingDomainCheck, e as SendingDomainRecord, f as SendingDomainRecords, D as DnsResolver, g as StaffResolver, h as StaffContext } from './routes-h90wEQuD.js';
2
+ export { i as ActivityEntry, j as ActivityLog, k as ApiKeySettings, l as AppointmentEventSink, m as BookingClientResolver, n as BookingPolicy, o as BrandSettings, C as CacheOptions, p as CalendarConnectOutcome, q as CalendarConnector, r as CalendarConnectors, s as CalendarVisibility, I as InternalAccess, N as NoShowPolicy, t as PrivacySettings, u as PublicBookingContext, v as PublicBookingKind, w as PublicOrganization, x as RecordCheck, y as RecordStatus, z as ResolvedHost, E as RouteContext, F as RouteHandler, G as RoutingFormSettings, J as StaffDirectory, W as WaitlistSettings, K as WebhookSettings, L as WorkerCommands, M as checkSendingDomain, O as normalizeSendingDomain } from './routes-h90wEQuD.js';
3
3
  import { SchedulingDb, PaymentAdapter, NotificationAdapter, AppointmentStatus, CalendarSyncAdapter, CalendarEventRef, CalendarEvent } from '@ordinatio/scheduling';
4
- export { ApiKeySchema, BookingPageConfig, BookingPageConfigSchema, BookingPageTheme, BookingPageThemeSchema, BrandSchema, CancelRecurringScopeSchema, CancelRecurringSeriesInput, CancelRecurringSeriesSchema, CreateAppointmentCategoryInput, CreateAppointmentCategorySchema, CreateAppointmentTypeInput, CreateAppointmentTypeSchema, CreateAvailabilityRuleInput, CreateAvailabilityRuleSchema, CreateCalendarInput, CreateCalendarSchema, CreateCouponCodeInput, CreateCouponCodeSchema, CreateNotificationTemplateInput, CreateNotificationTemplateSchema, CreatePackagePurchaseInput, CreatePackagePurchaseSchema, CreateRecurringSeriesInput, CreateRecurringSeriesSchema, CreateRoutingFormInput, CreateRoutingFormSchema, CreateServicePackageInput, CreateServicePackageSchema, CreateWebhookEndpointInput, CreateWebhookEndpointSchema, DEFAULT_CANCELLATION_POLICY, IntakeFormFieldSchema, NoShowPrevention, NoShowPreventionAction, NoShowPreventionActionSchema, NotificationChannelSchema, NotificationTriggerSchema, OrgCancellationPolicy, OrgCancellationPolicySchema, PrivacyEraseSchema, PrivacySubjectSchema, RecurringFrequencySchema, RouteClientSchema, SLOT_GRANULARITY_DEFAULT, SLOT_GRANULARITY_OPTIONS, SlotGranularityMinutes, TestRoutingFormSchema, TextSettingsSchema, UpdateAppointmentCategoryInput, UpdateAppointmentCategorySchema, UpdateAppointmentTypeInput, UpdateAppointmentTypeSchema, UpdateBookingPageInput, UpdateBookingPageSchema, UpdateCalendarInput, UpdateCalendarSchema, UpdateCouponCodeInput, UpdateCouponCodeSchema, UpdateNotificationTemplateInput, UpdateNotificationTemplateSchema, UpdatePackagePurchaseInput, UpdatePackagePurchaseSchema, UpdateRoutingFormInput, UpdateRoutingFormSchema, UpdateServicePackageInput, UpdateServicePackageSchema } from './schemas/index.js';
4
+ export { ApiKeySchema, BookingPageConfig, BookingPageConfigSchema, BookingPageTheme, BookingPageThemeSchema, BrandSchema, CancelRecurringScopeSchema, CancelRecurringSeriesInput, CancelRecurringSeriesSchema, CreateAppointmentCategoryInput, CreateAppointmentCategorySchema, CreateAppointmentTypeInput, CreateAppointmentTypeSchema, CreateAvailabilityRuleInput, CreateAvailabilityRuleSchema, CreateCalendarInput, CreateCalendarSchema, CreateCouponCodeInput, CreateCouponCodeSchema, CreateNotificationTemplateInput, CreateNotificationTemplateSchema, CreatePackagePurchaseInput, CreatePackagePurchaseSchema, CreateRecurringSeriesInput, CreateRecurringSeriesSchema, CreateRoutingFormInput, CreateRoutingFormSchema, CreateServicePackageInput, CreateServicePackageSchema, CreateWebhookEndpointInput, CreateWebhookEndpointSchema, DEFAULT_CANCELLATION_POLICY, GiftCertificateCheckSchema, GiftCertificateRestoreSchema, GiftCertificateSchema, IntakeFormFieldSchema, NoShowPrevention, NoShowPreventionAction, NoShowPreventionActionSchema, NotificationChannelSchema, NotificationTriggerSchema, OrgCancellationPolicy, OrgCancellationPolicySchema, PrivacyEraseSchema, PrivacySubjectSchema, RecurringFrequencySchema, RouteClientSchema, SLOT_GRANULARITY_DEFAULT, SLOT_GRANULARITY_OPTIONS, SlotGranularityMinutes, TestRoutingFormSchema, TextSettingsSchema, UpdateAppointmentCategoryInput, UpdateAppointmentCategorySchema, UpdateAppointmentTypeInput, UpdateAppointmentTypeSchema, UpdateBookingPageInput, UpdateBookingPageSchema, UpdateCalendarInput, UpdateCalendarSchema, UpdateCouponCodeInput, UpdateCouponCodeSchema, UpdateNotificationTemplateInput, UpdateNotificationTemplateSchema, UpdatePackagePurchaseInput, UpdatePackagePurchaseSchema, UpdateRoutingFormInput, UpdateRoutingFormSchema, UpdateServicePackageInput, UpdateServicePackageSchema } from './schemas/index.js';
5
5
  import { IncomingMessage, ServerResponse } from 'node:http';
6
6
  import 'zod';
7
7