UNPKG

@gnosticdev/highlevel-sdk

Version:
159 lines (158 loc) 4.55 kB
/** * A collection of all available fully qualified scopes (as provided by the API Documentation) grouped by access type. * This is auto-generated from the scopes schema. * @example * ScopesCollection['Sub-Account'] // ['blogs/author.readonly', 'blogs/category.readonly', 'blogs/post.write', ...] * ScopesCollection['Agency'] // ['emails/schedule.readonly', 'locations.readonly', 'locations.write', ...] */ const ScopesCollection = { "Sub-Account": [ "blogs/author.readonly", "blogs/category.readonly", "blogs/check-slug.readonly", "blogs/list.readonly", "blogs/posts.readonly", "businesses.readonly", "calendars.readonly", "calendars/events.readonly", "calendars/groups.readonly", "calendars/resources.readonly", "campaigns.readonly", "contacts.readonly", "conversations.readonly", "conversations/message.readonly", "emails/builder.readonly", "emails/schedule.readonly", "forms.readonly", "funnels/funnel.readonly", "funnels/page.readonly", "funnels/pagecount.readonly", "funnels/redirect.readonly", "invoices.readonly", "invoices/schedule.readonly", "invoices/template.readonly", "links.readonly", "locations.readonly", "locations/customFields.readonly", "locations/customValues.readonly", "locations/tags.readonly", "locations/tasks.readonly", "locations/templates.readonly", "medias.readonly", "objects/record.readonly", "objects/schema.readonly", "opportunities.readonly", "payments/integration.readonly", "payments/orders.readonly", "payments/subscriptions.readonly", "payments/transactions.readonly", "products.readonly", "products/prices.readonly", "socialplanner/account.readonly", "socialplanner/category.readonly", "socialplanner/csv.readonly", "socialplanner/oauth.readonly", "socialplanner/post.readonly", "socialplanner/tag.readonly", "surveys.readonly", "users.readonly", "workflows.readonly", "blogs/post.write", "blogs/post-update.write", "businesses.write", "calendars.write", "calendars/events.write", "calendars/groups.write", "calendars/resources.write", "contacts.write", "conversations.write", "conversations/livechat.write", "conversations/message.write", "courses.write", "emails/builder.write", "funnels/redirect.write", "invoices.write", "invoices/schedule.write", "invoices/template.write", "links.write", "locations/customFields.write", "locations/customValues.write", "locations/tags.write", "medias.write", "objects/record.write", "opportunities.write", "payments/integration.write", "payments/orders.write", "products.write", "products/prices.write", "saas/company.write", "saas/location.write", "socialplanner/account.write", "socialplanner/csv.write", "socialplanner/oauth.write", "socialplanner/post.write", "users.write" ], Agency: [ "emails/schedule.readonly", "locations.readonly", "oauth.readonly", "snapshots.readonly", "users.readonly", "locations.write", "oauth.write", "saas/company.write", "saas/location.write", "users.write" ] }; //#endregion //#region src/v2/scopes/scopes-builder.ts /** * Helper for building app scopes based on the access type. */ var ScopesBuilder = class { /** a Set containing the scopes that have been added so far */ collection = /* @__PURE__ */ new Set(); /** All valid scopes for this access type */ validScopes; /** * @constructor * @param accessType - the type of app access needed. 'Sub-Account' is same as 'Location' and 'Agency' is same as Agency */ constructor(accessType) { this.validScopes = ScopesCollection[accessType]; } /** add a scope or an array of scopes from the available scopes for this access type */ add(scopes) { this.collection = new Set([...this.collection, ...scopes]); return this; } /** * Get **ALL** available scopes for the given access type * * @returns an array of all scopes available to the given accessType */ getAllValid() { return this.validScopes; } /** * 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(['calendars.write', 'workflows.readonly']) * client.scopes.get() // "businesses.read calendars.write workflows.readonly" * ``` */ asString() { return Array.from(this.collection).join(" "); } }; function createScopes(accessType, scopes) { return new ScopesBuilder(accessType).add(scopes).asString(); } //#endregion export { ScopesBuilder, createScopes };