@gnosticdev/highlevel-sdk
Version:
SDK for the HighLevel API
1,535 lines (1,530 loc) • 40.9 kB
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// node_modules/kleur/index.mjs
var FORCE_COLOR;
var NODE_DISABLE_COLORS;
var NO_COLOR;
var TERM;
var isTTY = true;
if (typeof process !== "undefined") {
({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
isTTY = process.stdout && process.stdout.isTTY;
}
var $ = {
enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY),
// modifiers
reset: init(0, 0),
bold: init(1, 22),
dim: init(2, 22),
italic: init(3, 23),
underline: init(4, 24),
inverse: init(7, 27),
hidden: init(8, 28),
strikethrough: init(9, 29),
// colors
black: init(30, 39),
red: init(31, 39),
green: init(32, 39),
yellow: init(33, 39),
blue: init(34, 39),
magenta: init(35, 39),
cyan: init(36, 39),
white: init(37, 39),
gray: init(90, 39),
grey: init(90, 39),
// background colors
bgBlack: init(40, 49),
bgRed: init(41, 49),
bgGreen: init(42, 49),
bgYellow: init(43, 49),
bgBlue: init(44, 49),
bgMagenta: init(45, 49),
bgCyan: init(46, 49),
bgWhite: init(47, 49)
};
function run(arr, str) {
let i = 0, tmp, beg = "", end = "";
for (; i < arr.length; i++) {
tmp = arr[i];
beg += tmp.open;
end += tmp.close;
if (!!~str.indexOf(tmp.close)) {
str = str.replace(tmp.rgx, tmp.close + tmp.open);
}
}
return beg + str + end;
}
__name(run, "run");
function chain(has, keys) {
let ctx = { has, keys };
ctx.reset = $.reset.bind(ctx);
ctx.bold = $.bold.bind(ctx);
ctx.dim = $.dim.bind(ctx);
ctx.italic = $.italic.bind(ctx);
ctx.underline = $.underline.bind(ctx);
ctx.inverse = $.inverse.bind(ctx);
ctx.hidden = $.hidden.bind(ctx);
ctx.strikethrough = $.strikethrough.bind(ctx);
ctx.black = $.black.bind(ctx);
ctx.red = $.red.bind(ctx);
ctx.green = $.green.bind(ctx);
ctx.yellow = $.yellow.bind(ctx);
ctx.blue = $.blue.bind(ctx);
ctx.magenta = $.magenta.bind(ctx);
ctx.cyan = $.cyan.bind(ctx);
ctx.white = $.white.bind(ctx);
ctx.gray = $.gray.bind(ctx);
ctx.grey = $.grey.bind(ctx);
ctx.bgBlack = $.bgBlack.bind(ctx);
ctx.bgRed = $.bgRed.bind(ctx);
ctx.bgGreen = $.bgGreen.bind(ctx);
ctx.bgYellow = $.bgYellow.bind(ctx);
ctx.bgBlue = $.bgBlue.bind(ctx);
ctx.bgMagenta = $.bgMagenta.bind(ctx);
ctx.bgCyan = $.bgCyan.bind(ctx);
ctx.bgWhite = $.bgWhite.bind(ctx);
return ctx;
}
__name(chain, "chain");
function init(open, close) {
let blk = {
open: `\x1B[${open}m`,
close: `\x1B[${close}m`,
rgx: new RegExp(`\\x1b\\[${close}m`, "g")
};
return function(txt) {
if (this !== void 0 && this.has !== void 0) {
!!~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
return txt === void 0 ? this : $.enabled ? run(this.keys, txt + "") : txt + "";
}
return txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt + "") : txt + "";
};
}
__name(init, "init");
// src/lib/utils.ts
function objectEntries(obj) {
return Object.entries(obj);
}
__name(objectEntries, "objectEntries");
// src/v2/types/custom/scopes.ts
var ScopesSchema = {
businesses: {
readonly: [
{
methodAndEndpoint: "GET /businesses",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /businesses/:businessId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /businesses",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /businesses/:businessId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /businesses/:businessId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
calendars: {
write: [
{
methodAndEndpoint: "POST /calendars/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /calendars/:calendarId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /calendars/:calendarId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
readonly: [
{
methodAndEndpoint: "GET /calendars/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /calendars/:calendarId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /calendars/:calendarId/free-slots",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"calendars/groups": {
readonly: [
{
methodAndEndpoint: "GET /calendars/groups",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /calendars/groups",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /calendars/groups/validate-slug",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /calendars/groups/:groupId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /calendars/groups/:groupId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /calendars/groups/:groupId/status",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"calendars/resources": {
readonly: [
{
methodAndEndpoint: "GET /calendars/resources/:resourceType",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /calendars/resources/:resourceType/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /calendars/resources",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /calendars/resources/:resourceType/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /calendars/resources/:resourceType/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"calendars/events": {
readonly: [
{
methodAndEndpoint: "GET /calendars/events/appointments/:eventId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /calendars/events",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /calendars/blocked-slots",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "DELETE /calendars/events/:eventId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /calendars/events/block-slots",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /calendars/events/block-slots/:eventId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /calendars/events/appointments",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /calendars/events/appointments /:eventId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
campaigns: {
readonly: [
{
methodAndEndpoint: "GET /campaigns/",
webhookEvents: "CampaignStatusUpdate",
accessType: ["Sub-Account"]
}
]
},
contacts: {
readonly: [
{
methodAndEndpoint: "GET /contacts/:contactId",
webhookEvents: "ContactCreate",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /contacts/:contactId/tasks",
webhookEvents: "ContactDelete",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /contacts/:contactId/tasks/:taskId",
webhookEvents: "ContactDndUpdate",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /contacts/:contactId/notes",
webhookEvents: "ContactTagUpdate",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /contacts/:contactId/notes/:id",
webhookEvents: "NoteCreate",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /contacts/:contactId/appointments",
webhookEvents: "NoteDelete",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /contacts/",
webhookEvents: "TaskCreate",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /contacts/business/:businessId",
webhookEvents: "TaskDelete",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /contacts/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /contacts/:contactId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /contacts/:contactId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /contacts/:contactId/tasks",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /contacts/:contactId/tasks/:taskId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /contacts/:contactId/tasks/:taskId/completed",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /contacts/:contactId/tasks/:taskId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /contacts/:contactId/tags",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /contacts/:contactId/tags",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /contacts/:contactId/notes",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /contacts/:contactId/notes/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /contacts/:contactId/notes/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /contacts/:contactId/campaigns/:campaignId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /contacts/:contactId/campaigns/removeAll",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /contacts/:contactId/campaigns/:campaignId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /contacts/:contactId/workflow/:workflowId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /contacts/:contactId/workflow/:workflowId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
conversations: {
readonly: [
{
methodAndEndpoint: "GET /conversations/:conversationsId",
webhookEvents: "ConversationUnreadWebhook",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /conversations/search",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /conversations/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /conversations/:conversationsId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /conversations/:conversationsId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"conversations/message": {
readonly: [
{
methodAndEndpoint: "GET conversations/messages/:messageId/locations/:locationId/recording",
webhookEvents: "InboundMessage",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "",
webhookEvents: "OutboundMessage",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET conversations/locations/:locationId/messages/:messageId/transcription",
webhookEvents: "InboundMessage",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "",
webhookEvents: "OutboundMessage",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET conversations/locations/:locationId/messages/:messageId/transcription/download",
webhookEvents: "InboundMessage",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "",
webhookEvents: "OutboundMessage",
accessType: [""]
}
],
write: [
{
methodAndEndpoint: "POST /conversations/messages",
webhookEvents: "ConversationProviderOutboundMessage",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /conversations/messages/inbound",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /conversations/messages/upload",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /conversations/messages/:messageId/status",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /conversations/messages/:messageId/schedule",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /conversations/messages/email/:emailMessageId/schedule",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
forms: {
readonly: [
{
methodAndEndpoint: "GET /forms/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /forms/submissions",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
invoices: {
readonly: [
{
methodAndEndpoint: "GET /invoices/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /invoices/:invoiceId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /invoices/generate-invoice-number",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /invoices",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /invoices/:invoiceId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /invoices/:invoiceId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /invoices/:invoiceId/send",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /invoices/:invoiceId/void",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /invoices/:invoiceId/record-payment",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /invoices/text2pay",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"invoices/schedule": {
readonly: [
{
methodAndEndpoint: "GET /invoices/schedule/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /invoices/schedule/:scheduleId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /invoices/schedule",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /invoices/schedule/:scheduleId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /invoices/schedule/:scheduleId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /invoices/schedule/:scheduleId/schedule",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /invoices/schedule/:scheduleId/auto-payment",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /invoices/schedule/:scheduleId/cancel",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"invoices/template": {
readonly: [
{
methodAndEndpoint: "GET /invoices/template/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /invoices/template/:templateId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /invoices/template/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /invoices/template/:templateId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /invoices/template/:templateId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
links: {
readonly: [
{
methodAndEndpoint: "GET /links/",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /links/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /links/:linkId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /links/:linkId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
locations: {
readonly: [
{
methodAndEndpoint: "GET /locations/:locationId",
webhookEvents: "LocationCreate",
accessType: ["Sub-Account", "Agency"]
},
{
methodAndEndpoint: "",
webhookEvents: "LocationUpdate",
accessType: ["Sub-Account", "Agency"]
},
{
methodAndEndpoint: "GET /locations/search",
webhookEvents: "",
accessType: ["Sub-Account", "Agency"]
},
{
methodAndEndpoint: "GET /locations/timeZones",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /locations/",
webhookEvents: "",
accessType: ["Agency"]
},
{
methodAndEndpoint: "PUT /locations/:locationId",
webhookEvents: "",
accessType: ["Agency"]
},
{
methodAndEndpoint: "DELETE /locations/:locationId",
webhookEvents: "",
accessType: ["Agency"]
}
]
},
"locations/customValues": {
readonly: [
{
methodAndEndpoint: "GET /locations/:locationId/customValues",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /locations/:locationId/customValues/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /locations/:locationId/customValues",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /locations/:locationId/customValues/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /locations/:locationId/customValues/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"locations/customFields": {
readonly: [
{
methodAndEndpoint: "GET /locations/:locationId/customFields",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /locations/:locationId/customFields/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /locations/:locationId/customFields",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /locations/:locationId/customFields/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /locations/:locationId/customFields/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"locations/tags": {
readonly: [
{
methodAndEndpoint: "GET /locations/:locationId/tags",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /locations/:locationId/tags/:tagId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /locations/:locationId/tags/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /locations/:locationId/tags/:tagId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /locations/:locationId/tags/:tagId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"locations/templates": {
readonly: [
{
methodAndEndpoint: "GET /locations/:locationId/templates",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"locations/tasks": {
readonly: [
{
methodAndEndpoint: "POST /locations/:locationId/tasks/search",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
medias: {
readonly: [
{
methodAndEndpoint: "GET /medias/files",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /medias/upload-file",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"funnels/redirect": {
readonly: [
{
methodAndEndpoint: "GET /funnels/lookup/redirect/list",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /funnels/lookup/redirect",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"funnels/page": {
readonly: [
{
methodAndEndpoint: "GET /funnels/page",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"funnels/funnel": {
readonly: [
{
methodAndEndpoint: "GET /funnels/funnel/list",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"funnels/pagecount": {
readonly: [
{
methodAndEndpoint: "GET /funnels/page/count",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /funnels/lookup/redirect/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PATCH /funnels/lookup/redirect/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /medias/:fileId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
opportunities: {
readonly: [
{
methodAndEndpoint: "GET /opportunities/search",
webhookEvents: "OpportunityCreate",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /opportunities/:id",
webhookEvents: "OpportunityDelete",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /opportunities/pipelines",
webhookEvents: "OpportunityStageUpdate",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "",
webhookEvents: "OpportunityStatusUpdate",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "",
webhookEvents: "OpportunityMonetaryValueUpdate",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "DELETE /opportunities/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /opportunities/:id/status",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /opportunities",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /opportunities/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"payments/integration": {
readonly: [
{
methodAndEndpoint: "GET /payments/integrations/provider/whitelabel",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /payments/integrations/provider/whitelabel",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"payments/orders": {
readonly: [
{
methodAndEndpoint: "GET /payments/orders/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /payments/orders/:orderId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /payments/orders/:orderId/fulfillments",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /payments/orders/:orderId/fulfillments",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"payments/transactions": {
readonly: [
{
methodAndEndpoint: "GET /payments/transactions/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /payments/transactions/:transactionId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"payments/subscriptions": {
readonly: [
{
methodAndEndpoint: "GET /payments/subscriptions/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /payments/subscriptions/:subscriptionId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
products: {
readonly: [
{
methodAndEndpoint: "GET /products/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /products/:productId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /products/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /products/:productId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /products/:productId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"products/prices": {
readonly: [
{
methodAndEndpoint: "GET /products/:productId/price/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /products/:productId/price/:priceId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /products/:productId/price/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /products/:productId/price/:priceId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /products/:productId/price/:priceId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
oauth: {
readonly: [
{
methodAndEndpoint: "GET /oauth/installedLocations",
webhookEvents: "",
accessType: ["Agency"]
}
],
write: [
{
methodAndEndpoint: "POST /oauth/locationToken",
webhookEvents: "",
accessType: ["Agency"]
}
]
},
"saas/location": {
write: [
{
methodAndEndpoint: "PUT /update-saas-subscription/:locationId",
webhookEvents: "",
accessType: ["Agency"]
},
{
methodAndEndpoint: "POST /enable-saas/:locationId",
webhookEvents: "",
accessType: ["Sub-Account", "Agency"]
}
],
readonly: [
{
methodAndEndpoint: "GET /locations",
webhookEvents: "",
accessType: ["Sub-Account", "Agency"]
}
]
},
"saas/company": {
write: [
{
methodAndEndpoint: "POST /bulk-disable-saas/:companyId",
webhookEvents: "",
accessType: ["Sub-Account", "Agency"]
}
]
},
snapshots: {
readonly: [
{
methodAndEndpoint: "GET /snapshots",
webhookEvents: "",
accessType: ["Agency"]
}
]
},
"socialplanner/account": {
readonly: [
{
methodAndEndpoint: "GET /social-media-posting/:locationId/accounts",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "DELETE /social-media-posting/:locationId/accounts/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"socialplanner/csv": {
readonly: [
{
methodAndEndpoint: "GET /social-media-posting/:locationId/csv",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/:locationId/csv/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /social-media-posting/:locationId/csv",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /social-media-posting/:locationId/set-accounts",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /social-media-posting/:locationId/csv/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PATCH /social-media-posting/:locationId/csv/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /social-media-posting/:locationId/csv/:csvId/post/:postId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"socialplanner/category": {
readonly: [
{
methodAndEndpoint: "GET /social-media-posting/:locationId/categories",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/:locationId/categories/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"socialplanner/oauth": {
readonly: [
{
methodAndEndpoint: "GET /social-media-posting/oauth/facebook/start",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/:locationId/facebook/accounts/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/google/start",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/:locationId/google/locations/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/instagram/start",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/:locationId/instagram/accounts/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/linkedin/start",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/:locationId/linkedin/accounts/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/tiktok/start",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/:locationId/tiktok/accounts/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/tiktok-business/start",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/:locationId/tiktok-business/accounts/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/twitter/start",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /social-media-posting/oauth/:locationId/twitter/accounts/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /social-media-posting/oauth/:locationId/facebook/accounts/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /social-media-posting/oauth/:locationId/google/locations/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /social-media-posting/oauth/:locationId/instagram/accounts/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /social-media-posting/oauth/:locationId/linkedin/accounts/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /social-media-posting/oauth/:locationId/tiktok/accounts/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /social-media-posting/oauth/:locationId/twitter/accounts/:accountId",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"socialplanner/post": {
readonly: [
{
methodAndEndpoint: "GET /social-media-posting/:locationId/posts/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /social-media-posting/:locationId/posts/list",
webhookEvents: "",
accessType: ["Sub-Account"]
}
],
write: [
{
methodAndEndpoint: "POST /social-media-posting/:locationId/posts",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PUT /social-media-posting/:locationId/posts/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "DELETE /social-media-posting/:locationId/posts/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "PATCH /social-media-posting/:locationId/posts/:id",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
"socialplanner/tag": {
readonly: [
{
methodAndEndpoint: "GET /social-media-posting/:locationId/tags",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "POST /social-media-posting/:locationId/tags/details",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
surveys: {
readonly: [
{
methodAndEndpoint: "GET /surveys/",
webhookEvents: "",
accessType: ["Sub-Account"]
},
{
methodAndEndpoint: "GET /surveys/submissions",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
users: {
readonly: [
{
methodAndEndpoint: "GET /users/",
webhookEvents: "",
accessType: ["Sub-Account", "Agency"]
},
{
methodAndEndpoint: "GET /users/:userId",
webhookEvents: "",
accessType: ["Sub-Account", "Agency"]
}
],
write: [
{
methodAndEndpoint: "POST /users/",
webhookEvents: "",
accessType: ["Sub-Account", "Agency"]
},
{
methodAndEndpoint: "DELETE /users/:userId",
webhookEvents: "",
accessType: ["Sub-Account", "Agency"]
},
{
methodAndEndpoint: "PUT /users/:userId",
webhookEvents: "",
accessType: ["Sub-Account", "Agency"]
}
]
},
workflows: {
readonly: [
{
methodAndEndpoint: "GET /workflows/",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
},
courses: {
write: [
{
methodAndEndpoint: "POST courses/courses-exporter/public/import",
webhookEvents: "",
accessType: ["Sub-Account"]
}
]
}
};
// src/lib/scopes.ts
var ScopesBuilder = class {
static {
__name(this, "ScopesBuilder");
}
/** the access level for your app. Sub-Account is same as Location. Agency same as Company. */
#accessType;
/** a Set containing the scopes that have been added so far */
collection = /* @__PURE__ */ new Set();
/**
* @constructor
* @param accessType - the type of app access needed. 'Sub-Account' is same as 'Location' and 'Agency' is same as Agency
*/
constructor(config) {
this.#accessType = config.accessType;
}
/** add a scope or an array of scopes from the available scopes for this access type */
add(scopes) {
if (Array.isArray(scopes)) {
this.collection = /* @__PURE__ */ new Set([...this.collection, ...scopes]);
} else {
this.collection.add(scopes);
}
return this;
}
/**
* Get **ALL** available scopes for the given access type
*
* @returns an array of all scopes available to the given accessType
*/
all() {
const literals = /* @__PURE__ */ new Set();
for (const [scopeName, scopeValue] of objectEntries(ScopesSchema)) {
for (const [access, endpoints] of Object.entries(scopeValue)) {
for (const endpoint of endpoints) {
if (Array.isArray(endpoint.accessType) && endpoint.accessType.includes(this.#accessType)) {
literals.add(
`${scopeName.toString()}.${access}`
);
}
}
}
}
return Array.from(literals);
}
/**
* Returns a string of all scopes added to the builder so far.
*
* For use in the authorization redirect uri
* @returns a string of the scopes joined by a space
* @example
* ```ts
* client.scopes.add('businesses.read')
* client.scopes.add(['calendars.write', 'workflows.readonly'])
* client.scopes.get() // "businesses.read calendars.write workflows.readonly"
* ```
*/
get() {
return Array.from(this.collection).join(" ");
}
/**
* Check if the builder has a scope or an array of scopes
* @param scopes - a single scope or an array of scopes
* @returns true if the builder has the scope or scopes, false otherwise
*/
has(scopes) {
if (Array.isArray(scopes)) {
return scopes.every((scope) => this.collection.has(scope));
}
return this.collection.has(scopes);
}
};
export {
ScopesBuilder
};