UNPKG

@gnosticdev/highlevel-sdk

Version:
1,767 lines (1,761 loc) 47 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/lib/scopes.ts var scopes_exports = {}; __export(scopes_exports, { ScopesBuilder: () => ScopesBuilder }); module.exports = __toCommonJS(scopes_exports); // 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 = { "blogs/author": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /blogs/authors", webhookEvents: "" } ] }, "blogs/category": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /blogs/categories", webhookEvents: "" } ] }, "blogs/check-slug": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /blogs/posts/url-slug-exists", webhookEvents: "" } ] }, "blogs/list": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /blogs/site/all", webhookEvents: "" } ] }, "blogs/post": { write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /blogs/posts", webhookEvents: "" } ] }, "blogs/post-update": { write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "PUT /blogs/posts/:postId", webhookEvents: "" } ] }, "blogs/posts": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /blogs/posts/all", webhookEvents: "" } ] }, businesses: { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /businesses", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /businesses/:businessId", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /businesses", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "PUT /businesses/:businessId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /businesses/:businessId", webhookEvents: "" } ] }, calendars: { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /calendars/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /calendars/:calendarId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /calendars/:calendarId/free-slots", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /calendars/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "PUT /calendars/:calendarId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /calendars/:calendarId", webhookEvents: "" } ] }, "calendars/events": { readonly: [ { accessType: ["Sub-Account"], 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"], methodAndEndpoint: "GET /calendars/appointments/:appointmentId/notes", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /calendars/:calendarId/notifications/:notificationId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /calendars/:calendarId/notifications", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], 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"], methodAndEndpoint: "POST /calendars/appointments/:appointmentId/notes", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "PUT /calendars/appointments/:appointmentId/notes/:noteId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /calendars/appointments/:appointmentId/notes/:noteId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "POST /calendars/:calendarId/notifications", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "PUT /calendars/:calendarId/notifications/:notificationId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /calendars/:calendarId/notifications/:notificationId", webhookEvents: "" } ] }, "calendars/groups": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /calendars/groups", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, "calendars/resources": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /calendars/resources/:resourceType", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /calendars/resources/:resourceType/:id", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, campaigns: { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /campaigns/", webhookEvents: "CampaignStatusUpdate" } ] }, contacts: { readonly: [ { accessType: ["Sub-Account"], 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" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, conversations: { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /conversations/:conversationsId", webhookEvents: "ConversationUnreadWebhook" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /conversations/search", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /conversations/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "PUT /conversations/:conversationsId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /conversations/:conversationsId", webhookEvents: "" } ] }, "conversations/livechat": { write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /conversations/providers/live-chat/typing", webhookEvents: "" } ] }, "conversations/message": { readonly: [ { accessType: ["Sub-Account"], 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: [""], methodAndEndpoint: "", webhookEvents: "OutboundMessage" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, courses: { write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST courses/courses-exporter/public/import", webhookEvents: "" } ] }, "emails/builder": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET emails/builder", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST emails/builder", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "POST /emails/builder/data", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /emails/builder/:locationId/:templateId", webhookEvents: "" } ] }, "emails/schedule": { readonly: [ { accessType: ["Sub-Account", "Agency"], methodAndEndpoint: "GET emails/schedule", webhookEvents: "" } ] }, forms: { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /forms/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /forms/submissions", webhookEvents: "" } ] }, "funnels/funnel": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /funnels/funnel/list", webhookEvents: "" } ] }, "funnels/page": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /funnels/page", webhookEvents: "" } ] }, "funnels/pagecount": { readonly: [ { accessType: ["Sub-Account"], 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: "" } ] }, "funnels/redirect": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /funnels/lookup/redirect/list", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /funnels/lookup/redirect", webhookEvents: "" } ] }, invoices: { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /invoices/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /invoices/:invoiceId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /invoices/generate-invoice-number", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, "invoices/schedule": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /invoices/schedule/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /invoices/schedule/:scheduleId", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, "invoices/template": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /invoices/template/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /invoices/template/:templateId", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /invoices/template/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "PUT /invoices/template/:templateId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /invoices/template/:templateId", webhookEvents: "" } ] }, links: { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /links/", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /links/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "PUT /links/:linkId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /links/:linkId", webhookEvents: "" } ] }, locations: { readonly: [ { accessType: ["Sub-Account", "Agency"], 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"], methodAndEndpoint: "GET /locations/timeZones", webhookEvents: "" } ], write: [ { accessType: ["Agency"], methodAndEndpoint: "POST /locations/", webhookEvents: "" }, { accessType: ["Agency"], methodAndEndpoint: "PUT /locations/:locationId", webhookEvents: "" }, { accessType: ["Agency"], methodAndEndpoint: "DELETE /locations/:locationId", webhookEvents: "" } ] }, "locations/customFields": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /locations/:locationId/customFields", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /locations/:locationId/customFields/:id", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /custom-fields/:id", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /custom-field/object-key/:key", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, "locations/customValues": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /locations/:locationId/customValues", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /locations/:locationId/customValues/:id", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, "locations/tags": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /locations/:locationId/tags", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /locations/:locationId/tags/:tagId", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, "locations/tasks": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /locations/:locationId/tasks/search", webhookEvents: "" } ] }, "locations/templates": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /locations/:locationId/templates", webhookEvents: "" } ] }, medias: { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /medias/files", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /medias/upload-file", webhookEvents: "" } ] }, oauth: { readonly: [ { accessType: ["Agency"], methodAndEndpoint: "GET /oauth/installedLocations", webhookEvents: "" } ], write: [ { accessType: ["Agency"], methodAndEndpoint: "POST /oauth/locationToken", webhookEvents: "" } ] }, "objects/record": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /objects/:schemaKey/records/:id", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /objects/:schemaKey/records", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "PUT /objects/:schemaKey/records/:id", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /objects/:schemaKey/records/:id", webhookEvents: "" } ] }, "objects/schema": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /objects/:key", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /objects", webhookEvents: "" } ] }, opportunities: { readonly: [ { accessType: ["Sub-Account"], 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" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, "payments/integration": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /payments/integrations/provider/whitelabel", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /payments/integrations/provider/whitelabel", webhookEvents: "" } ] }, "payments/orders": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /payments/orders/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /payments/orders/:orderId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /payments/orders/:orderId/fulfillments", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /payments/orders/:orderId/fulfillments", webhookEvents: "" } ] }, "payments/subscriptions": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /payments/subscriptions/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /payments/subscriptions/:subscriptionId", webhookEvents: "" } ] }, "payments/transactions": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /payments/transactions/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /payments/transactions/:transactionId", webhookEvents: "" } ] }, products: { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /products/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /products/:productId", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "POST /products/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "PUT /products/:productId", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /products/:productId", webhookEvents: "" } ] }, "products/prices": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /products/:productId/price/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /products/:productId/price/:priceId", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, "saas/company": { write: [ { accessType: ["Sub-Account", "Agency"], methodAndEndpoint: "POST /bulk-disable-saas/:companyId", webhookEvents: "" } ] }, "saas/location": { readonly: [ { accessType: ["Sub-Account", "Agency"], methodAndEndpoint: "GET /locations", webhookEvents: "" } ], write: [ { accessType: ["Agency"], methodAndEndpoint: "PUT /update-saas-subscription/:locationId", webhookEvents: "" }, { accessType: ["Sub-Account", "Agency"], methodAndEndpoint: "POST /enable-saas/:locationId", webhookEvents: "" } ] }, snapshots: { readonly: [ { accessType: ["Agency"], methodAndEndpoint: "GET /snapshots", webhookEvents: "" } ] }, "socialplanner/account": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /social-media-posting/:locationId/accounts", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /social-media-posting/:locationId/accounts/:id", webhookEvents: "" } ] }, "socialplanner/category": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /social-media-posting/:locationId/categories", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /social-media-posting/:locationId/categories/:id", webhookEvents: "" } ] }, "socialplanner/csv": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /social-media-posting/:locationId/csv", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /social-media-posting/:locationId/csv/:id", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], 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: "POST /social-media-posting/:locationId/posts/bulk-delete", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "DELETE /social-media-posting/:locationId/csv/:csvId/post/:postId", webhookEvents: "" } ] }, "socialplanner/oauth": { readonly: [ { accessType: ["Sub-Account"], 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: "" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, "socialplanner/post": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /social-media-posting/:locationId/posts/:id", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "POST /social-media-posting/:locationId/posts/list", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account"], 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: "" } ] }, "socialplanner/tag": { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /social-media-posting/:locationId/tags", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "POST /social-media-posting/:locationId/tags/details", webhookEvents: "" } ] }, surveys: { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /surveys/", webhookEvents: "" }, { accessType: ["Sub-Account"], methodAndEndpoint: "GET /surveys/submissions", webhookEvents: "" } ] }, users: { readonly: [ { accessType: ["Sub-Account", "Agency"], methodAndEndpoint: "GET /users/", webhookEvents: "" }, { accessType: ["Sub-Account", "Agency"], methodAndEndpoint: "GET /users/:userId", webhookEvents: "" } ], write: [ { accessType: ["Sub-Account", "Agency"], methodAndEndpoint: "POST /users/", webhookEvents: "" }, { accessType: ["Sub-Account", "Agency"], methodAndEndpoint: "DELETE /users/:userId", webhookEvents: "" }, { accessType: ["Sub-Account", "Agency"], methodAndEndpoint: "PUT /users/:userId", webhookEvents: "" } ] }, workflows: { readonly: [ { accessType: ["Sub-Account"], methodAndEndpoint: "GET /workflows/", webhookEvents: "" } ] } }; // 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); } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { ScopesBuilder });