@cmo-so/cli 0.12.18 → 0.12.19
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/cmo.mjs +597 -2
- package/package.json +1 -1
package/dist/cmo.mjs
CHANGED
|
@@ -37988,6 +37988,514 @@ var cssTools = [
|
|
|
37988
37988
|
}
|
|
37989
37989
|
})
|
|
37990
37990
|
];
|
|
37991
|
+
var MB = "/maggie-booking/v1/admin";
|
|
37992
|
+
var NEEDS_BOOKING = "Online booking lives in the Maggie Core theme 0.17 or later (wp_theme_update), switched on with wp_booking_turn_on.";
|
|
37993
|
+
async function mb(ctx, method, path3, body, query) {
|
|
37994
|
+
try {
|
|
37995
|
+
return await call(siteOf(ctx), {
|
|
37996
|
+
method,
|
|
37997
|
+
path: MB + path3,
|
|
37998
|
+
...body !== void 0 ? { body } : {},
|
|
37999
|
+
...query ? {
|
|
38000
|
+
query: Object.fromEntries(
|
|
38001
|
+
Object.entries(query).filter(([, v2]) => v2 !== void 0 && v2 !== null && v2 !== "")
|
|
38002
|
+
)
|
|
38003
|
+
} : {}
|
|
38004
|
+
});
|
|
38005
|
+
} catch (e2) {
|
|
38006
|
+
const m = e2.message ?? "";
|
|
38007
|
+
if (/rest_no_route|404/.test(m) && !/not found|not_found/i.test(m)) throw new Error(NEEDS_BOOKING);
|
|
38008
|
+
throw e2;
|
|
38009
|
+
}
|
|
38010
|
+
}
|
|
38011
|
+
var ITEMS = arr(
|
|
38012
|
+
"Treatments, in order (back to back): service id and option (variant) id from wp_booking_list resource services.",
|
|
38013
|
+
obj("", { service_id: int2("Service id."), variant_id: int2("Option id (default: the first).") })
|
|
38014
|
+
);
|
|
38015
|
+
var itemsParam = (items3) => (Array.isArray(items3) ? items3 : []).map(
|
|
38016
|
+
(i) => `${i.service_id}${i.variant_id ? `:${i.variant_id}` : ""}`
|
|
38017
|
+
).join(",");
|
|
38018
|
+
var MB_RESOURCES = {
|
|
38019
|
+
services: {
|
|
38020
|
+
path: "/services",
|
|
38021
|
+
write: true,
|
|
38022
|
+
what: "treatments with options (name, duration_minutes, price_minor), rules and who does them"
|
|
38023
|
+
},
|
|
38024
|
+
categories: { path: "/categories", write: true, what: "menu categories" },
|
|
38025
|
+
staff: { path: "/staff", write: true, what: "team: services, weekly hours, own prices" },
|
|
38026
|
+
"time-off": { path: "/time-off", write: true, what: "time off and closures (staff_id 0 = whole business)" },
|
|
38027
|
+
resources: { path: "/resources", write: true, what: "rooms / equipment a treatment needs" },
|
|
38028
|
+
locations: { path: "/locations", write: true, what: "locations (timezone, currency, address)" },
|
|
38029
|
+
customers: { path: "/customers", write: true, what: "customers (search=\u2026), id \u2192 history" },
|
|
38030
|
+
vouchers: { path: "/vouchers", write: true, what: "gift cards for sale" },
|
|
38031
|
+
"voucher-codes": { path: "/voucher-codes", write: false, what: "issued gift card codes (search by last 4, buyer)" },
|
|
38032
|
+
"addon-groups": {
|
|
38033
|
+
path: "/addon-groups",
|
|
38034
|
+
write: true,
|
|
38035
|
+
what: "add-on groups (extras with price and minutes) linked to services"
|
|
38036
|
+
},
|
|
38037
|
+
promos: { path: "/promos", write: true, what: "discount codes and last-minute deals" },
|
|
38038
|
+
bundles: { path: "/bundles", write: true, what: "packages: treatments back to back at one price" },
|
|
38039
|
+
"price-rules": { path: "/price-rules", write: true, what: "peak / off-peak price changes by weekday and time" },
|
|
38040
|
+
pricing: { path: "/pricing", write: false, what: "everything about add-ons, deals, packages and rules at once" },
|
|
38041
|
+
forms: { path: "/forms", write: true, what: "intake / consultation forms linked to services" },
|
|
38042
|
+
reviews: { path: "/reviews", write: true, what: "reviews (approve, hide, reply)" },
|
|
38043
|
+
waitlist: { path: "/waitlist", write: true, what: "waitlist entries" },
|
|
38044
|
+
payments: { path: "/payments", write: false, what: "payments and refunds" },
|
|
38045
|
+
settings: {
|
|
38046
|
+
path: "/settings",
|
|
38047
|
+
write: false,
|
|
38048
|
+
what: "booking rules, location, languages (change with wp_booking_settings_set)"
|
|
38049
|
+
},
|
|
38050
|
+
imports: { path: "/import", write: false, what: "import history (undo with wp_booking_import undo_id)" }
|
|
38051
|
+
};
|
|
38052
|
+
var bookingTools = [
|
|
38053
|
+
tool({
|
|
38054
|
+
name: "wp_booking_status",
|
|
38055
|
+
description: "Online booking on the connected WordPress site (Maggie Booking in the Maggie Core theme): whether it is on, today's appointments, upcoming count, this week's takings, the setup checklist (hours, treatments, team, payments, Book page, gift cards) and whether online payment (Stripe) is ready. Read-only. Payment keys are entered by the owner in wp-admin \u2192 Bookings \u2192 Payments (never ask for them).",
|
|
38056
|
+
parameters: { type: "object", properties: {} },
|
|
38057
|
+
group: "site",
|
|
38058
|
+
need: READ,
|
|
38059
|
+
risk: "R0",
|
|
38060
|
+
gates: ["WP"],
|
|
38061
|
+
run: async (ctx) => {
|
|
38062
|
+
const module = await mb(ctx, "GET", "/module");
|
|
38063
|
+
if (!module.installed || !module.enabled) return { ...module, next: "wp_booking_turn_on" };
|
|
38064
|
+
const [overview2, gateways] = await Promise.all([
|
|
38065
|
+
mb(ctx, "GET", "/overview"),
|
|
38066
|
+
mb(ctx, "GET", "/gateways").catch(() => null)
|
|
38067
|
+
]);
|
|
38068
|
+
return {
|
|
38069
|
+
...module,
|
|
38070
|
+
overview: overview2,
|
|
38071
|
+
payments: gateways ? {
|
|
38072
|
+
gateways: gateways.gateways,
|
|
38073
|
+
stripe: {
|
|
38074
|
+
mode: gateways.stripe?.mode,
|
|
38075
|
+
ready: gateways.stripe?.has_secret && gateways.stripe?.has_webhook_secret,
|
|
38076
|
+
webhook_url: gateways.stripe?.webhook_url
|
|
38077
|
+
}
|
|
38078
|
+
} : null
|
|
38079
|
+
};
|
|
38080
|
+
}
|
|
38081
|
+
}),
|
|
38082
|
+
tool({
|
|
38083
|
+
name: "wp_booking_turn_on",
|
|
38084
|
+
description: "Switch online booking on (creates its tables, a Book page, one team member and Mon\u2013Sat 10\u201318 hours to start from) or off (enabled false: the Bookings dashboard stays, nothing is deleted). To only pause visitors' online booking, use wp_booking_settings_set online_open false.",
|
|
38085
|
+
parameters: { type: "object", properties: { enabled: bool("true to switch on (default), false to switch off.") } },
|
|
38086
|
+
group: "site",
|
|
38087
|
+
need: WRITE,
|
|
38088
|
+
risk: "W2",
|
|
38089
|
+
gates: [...GATES],
|
|
38090
|
+
confirm: (a3, lang) => a3.enabled === false ? say(lang, "Switch online booking off on your website.", "\u95DC\u9589\u7DB2\u7AD9\u7684\u7DDA\u4E0A\u9810\u7D04\u3002") : say(
|
|
38091
|
+
lang,
|
|
38092
|
+
"Switch online booking on for your website (adds a Book page and the Bookings dashboard).",
|
|
38093
|
+
"\u70BA\u7DB2\u7AD9\u958B\u555F\u7DDA\u4E0A\u9810\u7D04\uFF08\u65B0\u589E\u9810\u7D04\u9801\u548C\u9810\u7D04\u5F8C\u53F0\uFF09\u3002"
|
|
38094
|
+
),
|
|
38095
|
+
run: (ctx, a3) => mb(ctx, "POST", "/module", { enabled: a3.enabled !== false })
|
|
38096
|
+
}),
|
|
38097
|
+
tool({
|
|
38098
|
+
name: "wp_booking_appointments",
|
|
38099
|
+
description: "Appointments: one booking by id (with customer, items, payments, history), or a list filtered by status (held, pending, confirmed, arrived, completed, cancelled, no_show, expired), date range (from/to, Y-m-d, venue time) and search (name, email, reference). Read-only.",
|
|
38100
|
+
parameters: {
|
|
38101
|
+
type: "object",
|
|
38102
|
+
properties: {
|
|
38103
|
+
id: int2("A booking id."),
|
|
38104
|
+
status: str2("Filter by status."),
|
|
38105
|
+
from: str2("From date (Y-m-d)."),
|
|
38106
|
+
to: str2("To date (Y-m-d)."),
|
|
38107
|
+
search: str2("Name, email, phone or reference."),
|
|
38108
|
+
page: int2("Page (1\u2026).")
|
|
38109
|
+
}
|
|
38110
|
+
},
|
|
38111
|
+
group: "site",
|
|
38112
|
+
need: READ,
|
|
38113
|
+
risk: "R0",
|
|
38114
|
+
gates: ["WP"],
|
|
38115
|
+
run: (ctx, a3) => a3.id ? mb(ctx, "GET", `/bookings/${Number(a3.id)}`) : mb(ctx, "GET", "/bookings", void 0, {
|
|
38116
|
+
status: a3.status,
|
|
38117
|
+
from: a3.from,
|
|
38118
|
+
to: a3.to,
|
|
38119
|
+
search: a3.search,
|
|
38120
|
+
page: a3.page
|
|
38121
|
+
})
|
|
38122
|
+
}),
|
|
38123
|
+
tool({
|
|
38124
|
+
name: "wp_booking_availability",
|
|
38125
|
+
description: "Free start times on a date for one or more treatments (the business's view: no lead-time limit). Use before wp_booking_create or a move. Read-only.",
|
|
38126
|
+
parameters: {
|
|
38127
|
+
type: "object",
|
|
38128
|
+
properties: { items: ITEMS, date: str2("Date (Y-m-d, venue time)."), staff_id: int2("Only this team member.") },
|
|
38129
|
+
required: ["items", "date"]
|
|
38130
|
+
},
|
|
38131
|
+
group: "site",
|
|
38132
|
+
need: READ,
|
|
38133
|
+
risk: "R0",
|
|
38134
|
+
gates: ["WP"],
|
|
38135
|
+
run: (ctx, a3) => mb(ctx, "GET", "/slots", void 0, { items: itemsParam(a3.items), date: a3.date, staff: a3.staff_id })
|
|
38136
|
+
}),
|
|
38137
|
+
tool({
|
|
38138
|
+
name: "wp_booking_create",
|
|
38139
|
+
description: "Book an appointment for a customer (as the business): treatments, date and time (venue time), optional team member, the customer (existing customer_id, or name + email/phone), notes and how they pay (venue, deposit, full). force books even if the time looks taken (double booking).",
|
|
38140
|
+
parameters: {
|
|
38141
|
+
type: "object",
|
|
38142
|
+
properties: {
|
|
38143
|
+
items: ITEMS,
|
|
38144
|
+
date: str2("Date (Y-m-d)."),
|
|
38145
|
+
time: str2("Start time (HH:MM, venue time)."),
|
|
38146
|
+
staff_id: int2("Team member (default: anyone free)."),
|
|
38147
|
+
customer_id: int2("An existing customer."),
|
|
38148
|
+
customer: obj("A new or matching customer.", {
|
|
38149
|
+
name: str2("Name."),
|
|
38150
|
+
email: str2("Email."),
|
|
38151
|
+
phone: str2("Phone.")
|
|
38152
|
+
}),
|
|
38153
|
+
notes: str2("Notes for the team."),
|
|
38154
|
+
payment: str2("venue (default), deposit or full."),
|
|
38155
|
+
force: bool("Book even if the time is taken.")
|
|
38156
|
+
},
|
|
38157
|
+
required: ["items", "date", "time"]
|
|
38158
|
+
},
|
|
38159
|
+
group: "site",
|
|
38160
|
+
need: WRITE,
|
|
38161
|
+
risk: "W2",
|
|
38162
|
+
gates: [...GATES],
|
|
38163
|
+
confirm: (a3, lang) => say(
|
|
38164
|
+
lang,
|
|
38165
|
+
`Book ${Array.isArray(a3.items) ? a3.items.length : 1} treatment(s) on ${a3.date} at ${a3.time} for ${q2(a3.customer?.name, a3.customer_id ? `customer #${a3.customer_id}` : "the customer")}${a3.force ? " even if the time is taken" : ""}; they get the confirmation email.`,
|
|
38166
|
+
`\u70BA${q2(a3.customer?.name, a3.customer_id ? `\u5BA2\u6236 #${a3.customer_id}` : "\u5BA2\u6236")}\u9810\u7D04 ${a3.date} ${a3.time}${a3.force ? "\uFF08\u5373\u4F7F\u6642\u9593\u5DF2\u88AB\u4F54\u7528\uFF09" : ""}\uFF0C\u4E26\u5BC4\u51FA\u78BA\u8A8D\u96FB\u90F5\u3002`
|
|
38167
|
+
),
|
|
38168
|
+
run: (ctx, a3) => mb(ctx, "POST", "/bookings", {
|
|
38169
|
+
items: a3.items,
|
|
38170
|
+
date: a3.date,
|
|
38171
|
+
time: a3.time,
|
|
38172
|
+
staff_id: a3.staff_id,
|
|
38173
|
+
customer_id: a3.customer_id,
|
|
38174
|
+
customer: a3.customer,
|
|
38175
|
+
notes: a3.notes,
|
|
38176
|
+
payment: a3.payment,
|
|
38177
|
+
force: !!a3.force
|
|
38178
|
+
})
|
|
38179
|
+
}),
|
|
38180
|
+
tool({
|
|
38181
|
+
name: "wp_booking_change",
|
|
38182
|
+
description: "Change one booking: action status (arrived, completed, no_show, confirmed), notes, cancel (by the business: everything paid is refunded; the customer is emailed), reschedule (new date + time, optional staff_id, force) or refund (payment_id and amount in minor units, e.g. 2500 = 25.00).",
|
|
38183
|
+
parameters: {
|
|
38184
|
+
type: "object",
|
|
38185
|
+
properties: {
|
|
38186
|
+
id: int2("Booking id."),
|
|
38187
|
+
action: str2("status | notes | cancel | reschedule | refund"),
|
|
38188
|
+
status: str2("For status."),
|
|
38189
|
+
notes: str2("For notes."),
|
|
38190
|
+
reason: str2("For cancel."),
|
|
38191
|
+
date: str2("For reschedule (Y-m-d)."),
|
|
38192
|
+
time: str2("For reschedule (HH:MM)."),
|
|
38193
|
+
staff_id: int2("For reschedule: another team member."),
|
|
38194
|
+
force: bool("For reschedule: even if taken."),
|
|
38195
|
+
payment_id: int2("For refund."),
|
|
38196
|
+
amount: int2("For refund, minor units.")
|
|
38197
|
+
},
|
|
38198
|
+
required: ["id", "action"]
|
|
38199
|
+
},
|
|
38200
|
+
group: "site",
|
|
38201
|
+
need: WRITE,
|
|
38202
|
+
risk: "W3",
|
|
38203
|
+
gates: [...GATES],
|
|
38204
|
+
confirm: (a3, lang) => {
|
|
38205
|
+
const id = `#${a3.id}`;
|
|
38206
|
+
switch (a3.action) {
|
|
38207
|
+
case "cancel":
|
|
38208
|
+
return say(
|
|
38209
|
+
lang,
|
|
38210
|
+
`Cancel booking ${id} (paid money is refunded, the customer is emailed).`,
|
|
38211
|
+
`\u53D6\u6D88\u9810\u7D04 ${id}\uFF08\u9000\u56DE\u5DF2\u4ED8\u6B3E\u9805\u4E26\u901A\u77E5\u5BA2\u6236\uFF09\u3002`
|
|
38212
|
+
);
|
|
38213
|
+
case "reschedule":
|
|
38214
|
+
return say(
|
|
38215
|
+
lang,
|
|
38216
|
+
`Move booking ${id} to ${a3.date} ${a3.time} (the customer is emailed).`,
|
|
38217
|
+
`\u628A\u9810\u7D04 ${id} \u6539\u5230 ${a3.date} ${a3.time}\uFF08\u901A\u77E5\u5BA2\u6236\uFF09\u3002`
|
|
38218
|
+
);
|
|
38219
|
+
case "refund":
|
|
38220
|
+
return say(
|
|
38221
|
+
lang,
|
|
38222
|
+
`Refund ${a3.amount} (minor units) of payment #${a3.payment_id} on booking ${id}.`,
|
|
38223
|
+
`\u70BA\u9810\u7D04 ${id} \u9000\u6B3E ${a3.amount}\uFF08\u6700\u5C0F\u55AE\u4F4D\uFF09\u3002`
|
|
38224
|
+
);
|
|
38225
|
+
default:
|
|
38226
|
+
return say(
|
|
38227
|
+
lang,
|
|
38228
|
+
`Update booking ${id}: ${a3.action} ${a3.status ?? ""}.`,
|
|
38229
|
+
`\u66F4\u65B0\u9810\u7D04 ${id}\uFF1A${a3.action} ${a3.status ?? ""}\u3002`
|
|
38230
|
+
);
|
|
38231
|
+
}
|
|
38232
|
+
},
|
|
38233
|
+
run: (ctx, a3) => {
|
|
38234
|
+
const id = Number(a3.id);
|
|
38235
|
+
switch (a3.action) {
|
|
38236
|
+
case "cancel":
|
|
38237
|
+
return mb(ctx, "POST", `/bookings/${id}/cancel`, { reason: a3.reason ?? "" });
|
|
38238
|
+
case "reschedule":
|
|
38239
|
+
return mb(ctx, "POST", `/bookings/${id}/reschedule`, {
|
|
38240
|
+
date: a3.date,
|
|
38241
|
+
time: a3.time,
|
|
38242
|
+
staff_id: a3.staff_id,
|
|
38243
|
+
force: !!a3.force
|
|
38244
|
+
});
|
|
38245
|
+
case "refund":
|
|
38246
|
+
return mb(ctx, "POST", `/bookings/${id}/refund`, { payment_id: a3.payment_id, amount: a3.amount });
|
|
38247
|
+
case "notes":
|
|
38248
|
+
return mb(ctx, "PATCH", `/bookings/${id}`, { notes: a3.notes ?? "" });
|
|
38249
|
+
case "status":
|
|
38250
|
+
return mb(ctx, "PATCH", `/bookings/${id}`, { status: a3.status });
|
|
38251
|
+
default:
|
|
38252
|
+
throw new Error("action: status, notes, cancel, reschedule or refund.");
|
|
38253
|
+
}
|
|
38254
|
+
}
|
|
38255
|
+
}),
|
|
38256
|
+
tool({
|
|
38257
|
+
name: "wp_booking_list",
|
|
38258
|
+
description: `Read the booking set-up and records. resource: ${Object.entries(MB_RESOURCES).map(([k, v2]) => `${k} (${v2.what})`).join("; ")}. id for one item, search for customers / codes. Money is in minor units (8000 = 80.00). Read-only.`,
|
|
38259
|
+
parameters: {
|
|
38260
|
+
type: "object",
|
|
38261
|
+
properties: {
|
|
38262
|
+
resource: str2("What to read."),
|
|
38263
|
+
id: int2("One item."),
|
|
38264
|
+
search: str2("Search text."),
|
|
38265
|
+
page: int2("Page.")
|
|
38266
|
+
},
|
|
38267
|
+
required: ["resource"]
|
|
38268
|
+
},
|
|
38269
|
+
group: "site",
|
|
38270
|
+
need: READ,
|
|
38271
|
+
risk: "R0",
|
|
38272
|
+
gates: ["WP"],
|
|
38273
|
+
run: (ctx, a3) => {
|
|
38274
|
+
const r = MB_RESOURCES[String(a3.resource)];
|
|
38275
|
+
if (!r) throw new Error(`resource: ${Object.keys(MB_RESOURCES).join(", ")}.`);
|
|
38276
|
+
return a3.id ? mb(ctx, "GET", `${r.path}/${Number(a3.id)}`) : mb(ctx, "GET", r.path, void 0, { search: a3.search, page: a3.page });
|
|
38277
|
+
}
|
|
38278
|
+
}),
|
|
38279
|
+
tool({
|
|
38280
|
+
name: "wp_booking_save",
|
|
38281
|
+
description: `Create, change or delete one booking set-up item. resource: ${Object.entries(MB_RESOURCES).filter(([, v2]) => v2.write).map(([k]) => k).join(
|
|
38282
|
+
", "
|
|
38283
|
+
)}. Without id: create; with id: change (send only the fields to change; a service's variants array replaces its options \u2014 keep their ids); delete true: remove (services, team and options used by past bookings are archived, not deleted). Read the item with wp_booking_list first to see its fields. Money in minor units.`,
|
|
38284
|
+
parameters: {
|
|
38285
|
+
type: "object",
|
|
38286
|
+
properties: {
|
|
38287
|
+
resource: str2("What to save."),
|
|
38288
|
+
id: int2("Item to change or delete."),
|
|
38289
|
+
data: obj("The fields."),
|
|
38290
|
+
delete: bool("Delete it.")
|
|
38291
|
+
},
|
|
38292
|
+
required: ["resource"]
|
|
38293
|
+
},
|
|
38294
|
+
group: "site",
|
|
38295
|
+
need: WRITE,
|
|
38296
|
+
risk: "W2",
|
|
38297
|
+
gates: [...GATES],
|
|
38298
|
+
confirm: (a3, lang) => {
|
|
38299
|
+
const what = `${a3.resource}${a3.id ? ` #${a3.id}` : ""}`;
|
|
38300
|
+
return a3.delete ? say(lang, `Delete ${what} from your booking set-up.`, `\u5F9E\u9810\u7D04\u8A2D\u5B9A\u4E2D\u522A\u9664 ${what}\u3002`) : a3.id ? say(lang, `Change ${what} in your booking set-up.`, `\u4FEE\u6539\u9810\u7D04\u8A2D\u5B9A\u4E2D\u7684 ${what}\u3002`) : say(lang, `Add a new ${a3.resource} to your booking set-up.`, `\u5728\u9810\u7D04\u8A2D\u5B9A\u4E2D\u65B0\u589E ${a3.resource}\u3002`);
|
|
38301
|
+
},
|
|
38302
|
+
run: (ctx, a3) => {
|
|
38303
|
+
const r = MB_RESOURCES[String(a3.resource)];
|
|
38304
|
+
if (!r?.write)
|
|
38305
|
+
throw new Error(
|
|
38306
|
+
`resource: ${Object.entries(MB_RESOURCES).filter(([, v2]) => v2.write).map(([k]) => k).join(", ")}.`
|
|
38307
|
+
);
|
|
38308
|
+
if (a3.delete) {
|
|
38309
|
+
if (!a3.id) throw new Error("delete needs the id.");
|
|
38310
|
+
return mb(ctx, "DELETE", `${r.path}/${Number(a3.id)}`);
|
|
38311
|
+
}
|
|
38312
|
+
return a3.id ? mb(ctx, "PATCH", `${r.path}/${Number(a3.id)}`, a3.data ?? {}) : mb(ctx, "POST", r.path, a3.data ?? {});
|
|
38313
|
+
}
|
|
38314
|
+
}),
|
|
38315
|
+
tool({
|
|
38316
|
+
name: "wp_booking_settings_set",
|
|
38317
|
+
description: 'Change booking settings: settings {online_open, slot_minutes, lead_minutes, horizon_days, hold_minutes, cancel_window_hours, default_payment (venue|deposit|full|card), deposit_percent, deposit_min_minor, no_show_fee_percent, auto_confirm, assignment_mode (balance|priority|turns), gap_rule (off|reduce|eliminate), allow_staff_choice, languages (extra content languages, e.g. ["zh-hans","es"]), notify_email, customer_note, terms, reminder_hours, gift_cards_enabled}, location {name, address, phone, email, timezone, currency} and/or business hours [{weekday 0=Mon\u20266, start HH:MM, end HH:MM, week_slot null|0|1}] (replaces all business hours). Read the current values with wp_booking_list resource settings.',
|
|
38318
|
+
parameters: {
|
|
38319
|
+
type: "object",
|
|
38320
|
+
properties: {
|
|
38321
|
+
settings: obj("Booking rules to change."),
|
|
38322
|
+
location: obj("Location fields to change."),
|
|
38323
|
+
hours: arr(
|
|
38324
|
+
"Business hours (all of them).",
|
|
38325
|
+
obj("", { weekday: int2("0 = Monday."), start: str2("HH:MM"), end: str2("HH:MM") })
|
|
38326
|
+
)
|
|
38327
|
+
}
|
|
38328
|
+
},
|
|
38329
|
+
group: "site",
|
|
38330
|
+
need: WRITE,
|
|
38331
|
+
risk: "W2",
|
|
38332
|
+
gates: [...GATES],
|
|
38333
|
+
confirm: (a3, lang) => say(
|
|
38334
|
+
lang,
|
|
38335
|
+
`Change booking ${[a3.settings && "settings", a3.location && "location", a3.hours && "opening hours"].filter(Boolean).join(", ") || "settings"}.`,
|
|
38336
|
+
`\u4FEE\u6539\u9810\u7D04${[a3.settings && "\u8A2D\u5B9A", a3.location && "\u5730\u9EDE", a3.hours && "\u71DF\u696D\u6642\u9593"].filter(Boolean).join("\u3001") || "\u8A2D\u5B9A"}\u3002`
|
|
38337
|
+
),
|
|
38338
|
+
run: (ctx, a3) => mb(ctx, "POST", "/settings", {
|
|
38339
|
+
...a3.settings ? { settings: a3.settings } : {},
|
|
38340
|
+
...a3.location ? { location: a3.location } : {},
|
|
38341
|
+
...a3.hours ? { hours: a3.hours } : {}
|
|
38342
|
+
})
|
|
38343
|
+
}),
|
|
38344
|
+
tool({
|
|
38345
|
+
name: "wp_booking_import_preview",
|
|
38346
|
+
description: "Preview bringing data from another booking system, nothing saved: source fresha (the venue's public Fresha page URL: treatments, options, prices), json (a catalogue JSON from another provider's export: Treatwell, Booksy, Square, Vagaro\u2026) or csv (kind clients | appointments | gift_cards, the CSV text). Shows what would be added, updated, withdrawn or skipped. Then wp_booking_import.",
|
|
38347
|
+
parameters: {
|
|
38348
|
+
type: "object",
|
|
38349
|
+
properties: {
|
|
38350
|
+
source: str2("fresha | json | csv"),
|
|
38351
|
+
url: str2("Fresha page URL."),
|
|
38352
|
+
json: str2("Catalogue JSON."),
|
|
38353
|
+
csv: str2("CSV text."),
|
|
38354
|
+
kind: str2("For csv: clients | appointments | gift_cards.")
|
|
38355
|
+
},
|
|
38356
|
+
required: ["source"]
|
|
38357
|
+
},
|
|
38358
|
+
group: "site",
|
|
38359
|
+
need: READ,
|
|
38360
|
+
risk: "R0",
|
|
38361
|
+
gates: ["WP"],
|
|
38362
|
+
run: (ctx, a3) => mb(ctx, "POST", `/import/${String(a3.source)}`, {
|
|
38363
|
+
url: a3.url,
|
|
38364
|
+
json: a3.json,
|
|
38365
|
+
csv: a3.csv,
|
|
38366
|
+
kind: a3.kind,
|
|
38367
|
+
dry_run: true
|
|
38368
|
+
})
|
|
38369
|
+
}),
|
|
38370
|
+
tool({
|
|
38371
|
+
name: "wp_booking_import",
|
|
38372
|
+
description: "Import from another booking system after wp_booking_import_preview (same arguments), or undo an earlier import (undo_id from wp_booking_list resource imports). Re-running a Fresha import later syncs changes; the owner's own edits are kept.",
|
|
38373
|
+
parameters: {
|
|
38374
|
+
type: "object",
|
|
38375
|
+
properties: {
|
|
38376
|
+
source: str2("fresha | json | csv"),
|
|
38377
|
+
url: str2("Fresha page URL."),
|
|
38378
|
+
json: str2("Catalogue JSON."),
|
|
38379
|
+
csv: str2("CSV text."),
|
|
38380
|
+
kind: str2("For csv."),
|
|
38381
|
+
undo_id: int2("Undo this import instead.")
|
|
38382
|
+
}
|
|
38383
|
+
},
|
|
38384
|
+
group: "site",
|
|
38385
|
+
need: WRITE,
|
|
38386
|
+
risk: "W2",
|
|
38387
|
+
gates: [...GATES],
|
|
38388
|
+
confirm: (a3, lang) => a3.undo_id ? say(
|
|
38389
|
+
lang,
|
|
38390
|
+
`Undo import #${a3.undo_id} (removes what it added).`,
|
|
38391
|
+
`\u64A4\u92B7\u532F\u5165 #${a3.undo_id}\uFF08\u79FB\u9664\u5B83\u65B0\u589E\u7684\u8CC7\u6599\uFF09\u3002`
|
|
38392
|
+
) : say(
|
|
38393
|
+
lang,
|
|
38394
|
+
`Import ${a3.source === "csv" ? a3.kind : "the menu"} from ${a3.source} into your bookings.`,
|
|
38395
|
+
`\u5F9E ${a3.source} \u532F\u5165${a3.source === "csv" ? a3.kind : "\u670D\u52D9\u9805\u76EE"}\u5230\u9810\u7D04\u7CFB\u7D71\u3002`
|
|
38396
|
+
),
|
|
38397
|
+
run: (ctx, a3) => a3.undo_id ? mb(ctx, "POST", `/import/${Number(a3.undo_id)}/undo`, {}) : mb(ctx, "POST", `/import/${String(a3.source)}`, {
|
|
38398
|
+
url: a3.url,
|
|
38399
|
+
json: a3.json,
|
|
38400
|
+
csv: a3.csv,
|
|
38401
|
+
kind: a3.kind,
|
|
38402
|
+
dry_run: false
|
|
38403
|
+
})
|
|
38404
|
+
}),
|
|
38405
|
+
tool({
|
|
38406
|
+
name: "wp_gift_card",
|
|
38407
|
+
description: "Gift cards: lookup (code \u2192 status, balance), issue (by hand: voucher_id of a gift card for sale or value_minor, recipient and buyer names/emails, message, send_email; the code is shown once), redeem (code id + amount_minor), void (code id). List cards for sale and issued codes with wp_booking_list resource vouchers / voucher-codes.",
|
|
38408
|
+
parameters: {
|
|
38409
|
+
type: "object",
|
|
38410
|
+
properties: {
|
|
38411
|
+
action: str2("lookup | issue | redeem | void"),
|
|
38412
|
+
code: str2("For lookup."),
|
|
38413
|
+
id: int2("Code id, for redeem / void."),
|
|
38414
|
+
amount_minor: int2("For redeem."),
|
|
38415
|
+
voucher_id: int2("For issue."),
|
|
38416
|
+
value_minor: int2("For issue: a custom value."),
|
|
38417
|
+
recipient_name: str2("For issue."),
|
|
38418
|
+
recipient_email: str2("For issue."),
|
|
38419
|
+
buyer_name: str2("For issue."),
|
|
38420
|
+
buyer_email: str2("For issue."),
|
|
38421
|
+
message: str2("For issue."),
|
|
38422
|
+
send_email: bool("For issue: email the code (default true)."),
|
|
38423
|
+
note: str2("Note for the ledger.")
|
|
38424
|
+
},
|
|
38425
|
+
required: ["action"]
|
|
38426
|
+
},
|
|
38427
|
+
group: "site",
|
|
38428
|
+
need: WRITE,
|
|
38429
|
+
risk: "W2",
|
|
38430
|
+
gates: [...GATES],
|
|
38431
|
+
confirm: (a3, lang) => {
|
|
38432
|
+
switch (a3.action) {
|
|
38433
|
+
case "issue":
|
|
38434
|
+
return say(
|
|
38435
|
+
lang,
|
|
38436
|
+
`Issue a gift card for ${q2(a3.recipient_name, "the recipient")}.`,
|
|
38437
|
+
`\u70BA${q2(a3.recipient_name, "\u6536\u4EF6\u4EBA")}\u767C\u51FA\u79AE\u54C1\u5361\u3002`
|
|
38438
|
+
);
|
|
38439
|
+
case "redeem":
|
|
38440
|
+
return say(
|
|
38441
|
+
lang,
|
|
38442
|
+
`Take ${a3.amount_minor} (minor units) off gift card #${a3.id}.`,
|
|
38443
|
+
`\u5F9E\u79AE\u54C1\u5361 #${a3.id} \u6263\u9664 ${a3.amount_minor}\uFF08\u6700\u5C0F\u55AE\u4F4D\uFF09\u3002`
|
|
38444
|
+
);
|
|
38445
|
+
case "void":
|
|
38446
|
+
return say(lang, `Void gift card #${a3.id} (it can no longer be used).`, `\u4F5C\u5EE2\u79AE\u54C1\u5361 #${a3.id}\u3002`);
|
|
38447
|
+
default:
|
|
38448
|
+
return say(lang, "Look up a gift card.", "\u67E5\u8A62\u79AE\u54C1\u5361\u3002");
|
|
38449
|
+
}
|
|
38450
|
+
},
|
|
38451
|
+
run: (ctx, a3) => {
|
|
38452
|
+
switch (a3.action) {
|
|
38453
|
+
case "lookup":
|
|
38454
|
+
return mb(ctx, "POST", "/voucher-codes/lookup", { code: a3.code });
|
|
38455
|
+
case "issue":
|
|
38456
|
+
return mb(ctx, "POST", "/voucher-codes", {
|
|
38457
|
+
voucher_id: a3.voucher_id,
|
|
38458
|
+
value_minor: a3.value_minor,
|
|
38459
|
+
recipient_name: a3.recipient_name,
|
|
38460
|
+
recipient_email: a3.recipient_email,
|
|
38461
|
+
buyer_name: a3.buyer_name,
|
|
38462
|
+
buyer_email: a3.buyer_email,
|
|
38463
|
+
message: a3.message,
|
|
38464
|
+
send_email: a3.send_email !== false
|
|
38465
|
+
});
|
|
38466
|
+
case "redeem":
|
|
38467
|
+
return mb(ctx, "POST", `/voucher-codes/${Number(a3.id)}/redeem`, {
|
|
38468
|
+
amount_minor: a3.amount_minor,
|
|
38469
|
+
note: a3.note ?? ""
|
|
38470
|
+
});
|
|
38471
|
+
case "void":
|
|
38472
|
+
return mb(ctx, "POST", `/voucher-codes/${Number(a3.id)}/void`, { note: a3.note ?? "" });
|
|
38473
|
+
default:
|
|
38474
|
+
throw new Error("action: lookup, issue, redeem or void.");
|
|
38475
|
+
}
|
|
38476
|
+
}
|
|
38477
|
+
}),
|
|
38478
|
+
tool({
|
|
38479
|
+
name: "wp_booking_translate",
|
|
38480
|
+
description: "Read or write the translations of booking content (type service | variant | category | staff | voucher, id, lang such as zh-hans or es; fields name, description). Without fields: read. The site's extra languages are set with wp_booking_settings_set settings.languages.",
|
|
38481
|
+
parameters: {
|
|
38482
|
+
type: "object",
|
|
38483
|
+
properties: {
|
|
38484
|
+
type: str2("service | variant | category | staff | voucher"),
|
|
38485
|
+
id: int2("Item id."),
|
|
38486
|
+
lang: str2("Language code."),
|
|
38487
|
+
fields: obj("{ name, description } to save.")
|
|
38488
|
+
},
|
|
38489
|
+
required: ["type", "id"]
|
|
38490
|
+
},
|
|
38491
|
+
group: "site",
|
|
38492
|
+
need: WRITE,
|
|
38493
|
+
risk: "W2",
|
|
38494
|
+
gates: [...GATES],
|
|
38495
|
+
confirm: (a3, lang) => say(lang, `Save the ${a3.lang} translation of ${a3.type} #${a3.id}.`, `\u5132\u5B58 ${a3.type} #${a3.id} \u7684 ${a3.lang} \u7FFB\u8B6F\u3002`),
|
|
38496
|
+
run: (ctx, a3) => a3.fields ? mb(ctx, "POST", "/translations", { type: a3.type, id: a3.id, lang: a3.lang, fields: a3.fields }) : mb(ctx, "GET", "/translations", void 0, { type: a3.type, id: a3.id })
|
|
38497
|
+
})
|
|
38498
|
+
];
|
|
37991
38499
|
var RESTYLE = /* @__PURE__ */ new Set([
|
|
37992
38500
|
"wp_page_markup_set",
|
|
37993
38501
|
"wp_post_save",
|
|
@@ -38033,7 +38541,8 @@ var wordpressTools = [
|
|
|
38033
38541
|
...themeTools,
|
|
38034
38542
|
...seoTools,
|
|
38035
38543
|
...elementTools,
|
|
38036
|
-
...cssTools
|
|
38544
|
+
...cssTools,
|
|
38545
|
+
...bookingTools
|
|
38037
38546
|
].map(withRestyle);
|
|
38038
38547
|
|
|
38039
38548
|
// ../../packages/tools/src/index.ts
|
|
@@ -41444,7 +41953,7 @@ var program = new Command();
|
|
|
41444
41953
|
// package.json
|
|
41445
41954
|
var package_default = {
|
|
41446
41955
|
name: "@cmo-so/cli",
|
|
41447
|
-
version: "0.12.
|
|
41956
|
+
version: "0.12.19",
|
|
41448
41957
|
description: "CMO.so on the command line: your websites, ideas, blog posts, LinkedIn queue and results, plus a local MCP server for Claude Desktop, Cursor and other MCP clients.",
|
|
41449
41958
|
type: "module",
|
|
41450
41959
|
license: "MIT",
|
|
@@ -60681,6 +61190,92 @@ function registerWp(program3) {
|
|
|
60681
61190
|
wp.command("security").description(
|
|
60682
61191
|
"security check: vulnerable or outdated plugins, themes and WordPress, risky settings, admins, WP-Cron, what visitors can see"
|
|
60683
61192
|
).option("--no-outside", "skip the checks from outside").action((o2, c2) => run(g3(c2), "wp_security_scan", { outside: o2.outside !== false }));
|
|
61193
|
+
const items3 = (spec) => spec.split(",").map((x2) => {
|
|
61194
|
+
const [service, variant] = x2.split(":");
|
|
61195
|
+
return { service_id: Number(service), ...variant ? { variant_id: Number(variant) } : {} };
|
|
61196
|
+
});
|
|
61197
|
+
const booking = wp.command("booking").description("online booking: appointments, set-up, imports, gift cards");
|
|
61198
|
+
booking.command("status").description("on or off, today, setup checklist, payments").action((_o, c2) => run(g3(c2), "wp_booking_status", {}));
|
|
61199
|
+
booking.command("on").description("switch online booking on").action((_o, c2) => run(g3(c2), "wp_booking_turn_on", { enabled: true }));
|
|
61200
|
+
booking.command("off").description("switch online booking off (nothing deleted)").action((_o, c2) => run(g3(c2), "wp_booking_turn_on", { enabled: false }));
|
|
61201
|
+
booking.command("list").description("appointments").option("--from <date>").option("--to <date>").option("--status <s>").option("--search <text>").action((o2, c2) => run(g3(c2), "wp_booking_appointments", o2));
|
|
61202
|
+
booking.command("get <id>").action((id, _o, c2) => run(g3(c2), "wp_booking_appointments", { id: Number(id) }));
|
|
61203
|
+
booking.command("slots <treatments> <date>").description("free times; treatments as service[:option],\u2026 (ids)").option("--staff <id>").action(
|
|
61204
|
+
(t, date3, o2, c2) => run(g3(c2), "wp_booking_availability", { items: items3(t), date: date3, staff_id: o2.staff ? Number(o2.staff) : void 0 })
|
|
61205
|
+
);
|
|
61206
|
+
booking.command("book <treatments> <date> <time>").description("book for a customer (venue time)").option("--customer <id>").option("--name <name>").option("--email <email>").option("--phone <phone>").option("--staff <id>").option("--notes <text>").option("--payment <p>", "venue | deposit | full").option("--force", "even if the time is taken").action(
|
|
61207
|
+
(t, date3, time3, o2, c2) => run(g3(c2), "wp_booking_create", {
|
|
61208
|
+
items: items3(t),
|
|
61209
|
+
date: date3,
|
|
61210
|
+
time: time3,
|
|
61211
|
+
customer_id: o2.customer ? Number(o2.customer) : void 0,
|
|
61212
|
+
customer: o2.customer ? void 0 : { name: o2.name, email: o2.email, phone: o2.phone },
|
|
61213
|
+
staff_id: o2.staff ? Number(o2.staff) : void 0,
|
|
61214
|
+
notes: o2.notes,
|
|
61215
|
+
payment: o2.payment,
|
|
61216
|
+
force: !!o2.force
|
|
61217
|
+
})
|
|
61218
|
+
);
|
|
61219
|
+
booking.command("cancel <id>").option("--reason <text>").action(
|
|
61220
|
+
(id, o2, c2) => run(g3(c2), "wp_booking_change", { id: Number(id), action: "cancel", reason: o2.reason })
|
|
61221
|
+
);
|
|
61222
|
+
booking.command("move <id> <date> <time>").option("--staff <id>").option("--force").action(
|
|
61223
|
+
(id, date3, time3, o2, c2) => run(g3(c2), "wp_booking_change", {
|
|
61224
|
+
id: Number(id),
|
|
61225
|
+
action: "reschedule",
|
|
61226
|
+
date: date3,
|
|
61227
|
+
time: time3,
|
|
61228
|
+
staff_id: o2.staff ? Number(o2.staff) : void 0,
|
|
61229
|
+
force: !!o2.force
|
|
61230
|
+
})
|
|
61231
|
+
);
|
|
61232
|
+
booking.command("mark <id> <status>").description("arrived | completed | no_show | confirmed").action(
|
|
61233
|
+
(id, status, _o, c2) => run(g3(c2), "wp_booking_change", { id: Number(id), action: "status", status })
|
|
61234
|
+
);
|
|
61235
|
+
booking.command("refund <id> <payment> <amount>").description("amount in minor units (2500 = 25.00)").action(
|
|
61236
|
+
(id, payment, amount, _o, c2) => run(g3(c2), "wp_booking_change", {
|
|
61237
|
+
id: Number(id),
|
|
61238
|
+
action: "refund",
|
|
61239
|
+
payment_id: Number(payment),
|
|
61240
|
+
amount: Number(amount)
|
|
61241
|
+
})
|
|
61242
|
+
);
|
|
61243
|
+
booking.command("ls <resource>").description(
|
|
61244
|
+
"services, categories, staff, time-off, customers, vouchers, voucher-codes, promos, bundles, pricing, settings, imports \u2026"
|
|
61245
|
+
).option("--id <id>").option("--search <text>").action(
|
|
61246
|
+
(resource, o2, c2) => run(g3(c2), "wp_booking_list", { resource, id: o2.id ? Number(o2.id) : void 0, search: o2.search })
|
|
61247
|
+
);
|
|
61248
|
+
booking.command("save <resource> <file>").description("create (or with --id change) one item from a JSON file").option("--id <id>").action(
|
|
61249
|
+
async (resource, file, o2, c2) => run(g3(c2), "wp_booking_save", { resource, id: o2.id ? Number(o2.id) : void 0, data: await json(file) })
|
|
61250
|
+
);
|
|
61251
|
+
booking.command("rm <resource> <id>").action(
|
|
61252
|
+
(resource, id, _o, c2) => run(g3(c2), "wp_booking_save", { resource, id: Number(id), delete: true })
|
|
61253
|
+
);
|
|
61254
|
+
booking.command("settings <file>").description("JSON { settings?, location?, hours? }").action(async (file, _o, c2) => run(g3(c2), "wp_booking_settings_set", await json(file)));
|
|
61255
|
+
booking.command("import <source>").description(
|
|
61256
|
+
"a Fresha page URL, a catalogue .json, or a .csv (--kind clients|appointments|gift_cards); preview unless --apply"
|
|
61257
|
+
).option("--kind <kind>").option("--apply", "import (default: preview only)").action(async (src, o2, c2) => {
|
|
61258
|
+
const isUrl = /^https?:\/\//.test(src);
|
|
61259
|
+
const source = isUrl ? "fresha" : src.endsWith(".csv") ? "csv" : "json";
|
|
61260
|
+
const body = isUrl ? { url: src } : source === "csv" ? { csv: await readFile2(src, "utf8"), kind: o2.kind } : { json: await readFile2(src, "utf8") };
|
|
61261
|
+
return run(g3(c2), o2.apply ? "wp_booking_import" : "wp_booking_import_preview", { source, ...body });
|
|
61262
|
+
});
|
|
61263
|
+
booking.command("import-undo <id>").action((id, _o, c2) => run(g3(c2), "wp_booking_import", { undo_id: Number(id) }));
|
|
61264
|
+
booking.command("gift <action>").description("lookup --code | issue --voucher/--value --to-name --to-email | redeem --id --amount | void --id").option("--code <code>").option("--id <id>").option("--amount <minor>").option("--voucher <id>").option("--value <minor>").option("--to-name <name>").option("--to-email <email>").option("--from-name <name>").option("--from-email <email>").option("--message <text>").action(
|
|
61265
|
+
(action, o2, c2) => run(g3(c2), "wp_gift_card", {
|
|
61266
|
+
action,
|
|
61267
|
+
code: o2.code,
|
|
61268
|
+
id: o2.id ? Number(o2.id) : void 0,
|
|
61269
|
+
amount_minor: o2.amount ? Number(o2.amount) : void 0,
|
|
61270
|
+
voucher_id: o2.voucher ? Number(o2.voucher) : void 0,
|
|
61271
|
+
value_minor: o2.value ? Number(o2.value) : void 0,
|
|
61272
|
+
recipient_name: o2.toName,
|
|
61273
|
+
recipient_email: o2.toEmail,
|
|
61274
|
+
buyer_name: o2.fromName,
|
|
61275
|
+
buyer_email: o2.fromEmail,
|
|
61276
|
+
message: o2.message
|
|
61277
|
+
})
|
|
61278
|
+
);
|
|
60684
61279
|
wp.command("cron-rm <hook>").description("remove a scheduled job nothing runs any more (left by a removed plugin)").action((hook, _o, c2) => run(g3(c2), "wp_cron_unschedule", { hook }));
|
|
60685
61280
|
seo.command("get <page>").description("stored fields and what the page outputs").action((p2, _o, c2) => run(g3(c2), "wp_seo_get", { page: p2 }));
|
|
60686
61281
|
seo.command("set <page>").description("set a page's SEO fields").option("--title <t>").option("--description <d>").option("--keywords <k>").option("--robots <r>", '"index, follow" | "noindex, follow" | "noindex, nofollow"').option("--canonical <url>").option("--og-image <url>").option("--from <file>", "several pages: JSON { items: [{ page, title, description, \u2026 }] }").action(async (p2, o2, c2) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmo-so/cli",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.19",
|
|
4
4
|
"description": "CMO.so on the command line: your websites, ideas, blog posts, LinkedIn queue and results, plus a local MCP server for Claude Desktop, Cursor and other MCP clients.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|