@antlur/backstage 1.0.7 → 1.0.8

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/client.js CHANGED
@@ -1,15 +1,9 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.client = exports.BackstageClient = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- const config_1 = require("./config");
9
- class BackstageClient {
1
+ import axios from "axios";
2
+ import { getGlobalConfig } from "./config";
3
+ export class BackstageClient {
10
4
  constructor(config) {
11
5
  // If no config is passed, try to get from the global config
12
- const globalConfig = (0, config_1.getGlobalConfig)();
6
+ const globalConfig = getGlobalConfig();
13
7
  const finalConfig = config || globalConfig;
14
8
  if (!finalConfig) {
15
9
  throw new Error("No Backstage config found. Please call defineConfig() or pass config to BackstageClient.");
@@ -22,7 +16,7 @@ class BackstageClient {
22
16
  throw new Error("No accountId found in the Backstage config. Please provide an accountId.");
23
17
  }
24
18
  const { baseURL, token, onError } = finalConfig;
25
- this.instance = axios_1.default.create({
19
+ this.instance = axios.create({
26
20
  baseURL,
27
21
  headers: {
28
22
  Authorization: `Bearer ${token}`,
@@ -79,8 +73,6 @@ class BackstageClient {
79
73
  return this.instance;
80
74
  }
81
75
  }
82
- exports.BackstageClient = BackstageClient;
83
- const client = function (config) {
76
+ export const client = function (config) {
84
77
  return new BackstageClient(config);
85
78
  };
86
- exports.client = client;
package/dist/config.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGlobalConfig = exports.defineConfig = void 0;
4
1
  const ROOT = process.cwd();
5
2
  const CONFIG_PATH = process.env.BACKSTAGE_CONFIG_PATH || "./backstage.config";
6
3
  const DEFAULT_BASE_URL = "https://bckstg.app/api";
@@ -9,16 +6,14 @@ let globalConfig = {
9
6
  token: process.env.BACKSTAGE_API_KEY ?? undefined,
10
7
  accountId: process.env.BACKSTAGE_ACCOUNT_ID ?? undefined,
11
8
  };
12
- function defineConfig(config) {
9
+ export function defineConfig(config) {
13
10
  globalConfig = {
14
11
  ...globalConfig,
15
12
  ...config,
16
13
  };
17
14
  return globalConfig;
18
15
  }
19
- exports.defineConfig = defineConfig;
20
- function getGlobalConfig() {
16
+ export function getGlobalConfig() {
21
17
  // read the config from the project root
22
18
  return globalConfig;
23
19
  }
24
- exports.getGlobalConfig = getGlobalConfig;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GALocations = exports.GAEvents = void 0;
4
- exports.GAEvents = {
1
+ export const GAEvents = {
5
2
  CLICK_TO_MAP: "click_to_map",
6
3
  CLICK_TO_CALL: "click_to_call",
7
4
  CLICK_TO_SOCIAL: "click_to_social",
@@ -9,7 +6,7 @@ exports.GAEvents = {
9
6
  FIND_LOCATION: "find_location",
10
7
  CLICK_TO_ORDER: "click_to_order",
11
8
  };
12
- exports.GALocations = {
9
+ export const GALocations = {
13
10
  LOCATION_CARD: "location_card",
14
11
  TOPBAR: "topbar",
15
12
  };
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAlerts = void 0;
4
- const client_1 = require("../client");
5
- async function getAlerts() {
6
- const { data } = await (0, client_1.client)().get("/alerts");
1
+ import { client } from "../client";
2
+ export async function getAlerts() {
3
+ const { data } = await client().get("/alerts");
7
4
  return data;
8
5
  }
9
- exports.getAlerts = getAlerts;
@@ -1,22 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEventBySlug = exports.getEvent = exports.getEvents = void 0;
4
- const client_1 = require("../client");
5
- async function getEvents() {
6
- const res = await (0, client_1.client)().get("/events");
1
+ import { client } from "../client";
2
+ export async function getEvents() {
3
+ const res = await client().get("/events");
7
4
  const pages = res.data;
8
5
  return pages;
9
6
  }
10
- exports.getEvents = getEvents;
11
- async function getEvent(id) {
12
- const res = await (0, client_1.client)().get("/events" + "?filter[id]=" + id);
7
+ export async function getEvent(id) {
8
+ const res = await client().get("/events" + "?filter[id]=" + id);
13
9
  const pages = res.data?.[0];
14
10
  return pages;
15
11
  }
16
- exports.getEvent = getEvent;
17
- async function getEventBySlug(slug) {
18
- const res = await (0, client_1.client)().get("/events" + "?filter[slug]=" + slug);
12
+ export async function getEventBySlug(slug) {
13
+ const res = await client().get("/events" + "?filter[slug]=" + slug);
19
14
  const pages = res.data?.[0];
20
15
  return pages;
21
16
  }
22
- exports.getEventBySlug = getEventBySlug;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLocationBySlug = exports.getLocations = void 0;
4
- const client_1 = require("../client");
5
- async function getLocations() {
6
- const res = await (0, client_1.client)().get("/locations");
1
+ import { client } from "../client";
2
+ export async function getLocations() {
3
+ const res = await client().get("/locations");
7
4
  let locations = res.data;
8
5
  locations = locations.sort((a, b) => {
9
6
  if (a.name < b.name) {
@@ -13,13 +10,11 @@ async function getLocations() {
13
10
  });
14
11
  return locations;
15
12
  }
16
- exports.getLocations = getLocations;
17
- async function getLocationBySlug(slug) {
18
- const res = await (0, client_1.client)().get(`/locations?filter[slug]=${slug}`);
13
+ export async function getLocationBySlug(slug) {
14
+ const res = await client().get(`/locations?filter[slug]=${slug}`);
19
15
  const data = res.data;
20
16
  if (Array.isArray(data) && data.length > 0) {
21
17
  return data[0];
22
18
  }
23
19
  return data;
24
20
  }
25
- exports.getLocationBySlug = getLocationBySlug;
@@ -1,28 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMenuBySlug = exports.getMenu = exports.getMenus = void 0;
4
- const client_1 = require("../client");
5
- async function getMenus() {
6
- const res = await (0, client_1.client)().get("/menus");
1
+ import { client } from "../client";
2
+ export async function getMenus() {
3
+ const res = await client().get("/menus");
7
4
  const menus = res.data;
8
5
  return menus;
9
6
  }
10
- exports.getMenus = getMenus;
11
- async function getMenu(id) {
12
- const res = await (0, client_1.client)().get(`/menus?filter[id]=${id}&include=categories.items`);
7
+ export async function getMenu(id) {
8
+ const res = await client().get(`/menus?filter[id]=${id}&include=categories.items`);
13
9
  const data = res.data;
14
10
  if (Array.isArray(data) && data.length > 0) {
15
11
  return data[0];
16
12
  }
17
13
  return data;
18
14
  }
19
- exports.getMenu = getMenu;
20
- async function getMenuBySlug(slug) {
21
- const res = await (0, client_1.client)().get(`/menus?filter[slug]=${slug}&include=categories.items`);
15
+ export async function getMenuBySlug(slug) {
16
+ const res = await client().get(`/menus?filter[slug]=${slug}&include=categories.items`);
22
17
  const data = res.data;
23
18
  if (Array.isArray(data) && data.length > 0) {
24
19
  return data[0];
25
20
  }
26
21
  return data;
27
22
  }
28
- exports.getMenuBySlug = getMenuBySlug;
@@ -1,23 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNavigation = exports.getNavigations = exports.getDefaultNavigation = void 0;
4
- const client_1 = require("../client");
5
- async function getDefaultNavigation() {
1
+ import { client } from "../client";
2
+ export async function getDefaultNavigation() {
6
3
  const navigations = await getNavigations();
7
4
  return navigations[0];
8
5
  }
9
- exports.getDefaultNavigation = getDefaultNavigation;
10
- async function getNavigations() {
11
- const res = await (0, client_1.client)().get("/navigations");
6
+ export async function getNavigations() {
7
+ const res = await client().get("/navigations");
12
8
  const navigations = res.data;
13
9
  return Promise.all(navigations.map(async (navigation) => {
14
- const res = await (0, client_1.client)().get("/navigations/" + navigation.id);
10
+ const res = await client().get("/navigations/" + navigation.id);
15
11
  return res.data[0];
16
12
  }));
17
13
  }
18
- exports.getNavigations = getNavigations;
19
- async function getNavigation(id) {
20
- const res = await (0, client_1.client)().get(`/navigations/${id}`);
14
+ export async function getNavigation(id) {
15
+ const res = await client().get(`/navigations/${id}`);
21
16
  const navigation = res.data;
22
17
  const topLevelItems = navigation.items.filter((item) => item.parent_id === null);
23
18
  topLevelItems.forEach((item) => {
@@ -26,4 +21,3 @@ async function getNavigation(id) {
26
21
  navigation.items = topLevelItems;
27
22
  return navigation;
28
23
  }
29
- exports.getNavigation = getNavigation;
@@ -1,24 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPageBySlug = exports.getHomePage = exports.getPages = exports.getPage = void 0;
4
- const client_1 = require("../client");
5
- async function getPage(slug) {
6
- const res = await (0, client_1.client)().get(`/pages/?filter[slug]=${slug}`);
1
+ import { client } from "../client";
2
+ export async function getPage(slug) {
3
+ const res = await client().get(`/pages/?filter[slug]=${slug}`);
7
4
  return res.data[0];
8
5
  }
9
- exports.getPage = getPage;
10
- async function getPages() {
11
- const { data } = await (0, client_1.client)().get("/pages");
6
+ export async function getPages() {
7
+ const { data } = await client().get("/pages");
12
8
  return data;
13
9
  }
14
- exports.getPages = getPages;
15
- async function getHomePage() {
16
- const res = await (0, client_1.client)().get("/pages?filter[slug]=/");
10
+ export async function getHomePage() {
11
+ const res = await client().get("/pages?filter[slug]=/");
17
12
  return res.data[0];
18
13
  }
19
- exports.getHomePage = getHomePage;
20
- async function getPageBySlug(slug) {
21
- const res = await (0, client_1.client)().get("/pages?filter[slug]=" + slug);
14
+ export async function getPageBySlug(slug) {
15
+ const res = await client().get("/pages?filter[slug]=" + slug);
22
16
  return res.data[0];
23
17
  }
24
- exports.getPageBySlug = getPageBySlug;
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPress = void 0;
4
- const client_1 = require("../client");
5
- async function getPress() {
6
- const { data } = await (0, client_1.client)().get("/press");
1
+ import { client } from "../client";
2
+ export async function getPress() {
3
+ const { data } = await client().get("/press");
7
4
  return data;
8
5
  }
9
- exports.getPress = getPress;
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWebsite = void 0;
4
- const client_1 = require("../client");
5
- async function getWebsite() {
6
- const res = await (0, client_1.client)().get("/websites");
1
+ import { client } from "../client";
2
+ export async function getWebsite() {
3
+ const res = await client().get("/websites");
7
4
  return res.data[0];
8
5
  }
9
- exports.getWebsite = getWebsite;
package/dist/index.js CHANGED
@@ -1,35 +1,15 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.BackstageClient = exports.getGlobalConfig = exports.defineConfig = void 0;
18
1
  // Re-export config
19
- var config_1 = require("./config");
20
- Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
21
- Object.defineProperty(exports, "getGlobalConfig", { enumerable: true, get: function () { return config_1.getGlobalConfig; } });
2
+ export { defineConfig, getGlobalConfig } from "./config";
22
3
  // Re-export the client class
23
- var client_1 = require("./client");
24
- Object.defineProperty(exports, "BackstageClient", { enumerable: true, get: function () { return client_1.BackstageClient; } });
4
+ export { BackstageClient } from "./client";
25
5
  // Re-export endpoints
26
- __exportStar(require("./endpoints/alerts"), exports);
27
- __exportStar(require("./endpoints/events"), exports);
28
- __exportStar(require("./endpoints/locations"), exports);
29
- __exportStar(require("./endpoints/menus"), exports);
30
- __exportStar(require("./endpoints/navigation"), exports);
31
- __exportStar(require("./endpoints/pages"), exports);
32
- __exportStar(require("./endpoints/press"), exports);
33
- __exportStar(require("./endpoints/website"), exports);
6
+ export * from "./endpoints/alerts";
7
+ export * from "./endpoints/events";
8
+ export * from "./endpoints/locations";
9
+ export * from "./endpoints/menus";
10
+ export * from "./endpoints/navigation";
11
+ export * from "./endpoints/pages";
12
+ export * from "./endpoints/press";
13
+ export * from "./endpoints/website";
34
14
  // Re-export domain types
35
- __exportStar(require("./types"), exports);
15
+ export * from "./types";
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/types/api.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,29 +1,13 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./alert"), exports);
18
- __exportStar(require("./api"), exports);
19
- __exportStar(require("./event"), exports);
20
- __exportStar(require("./location"), exports);
21
- __exportStar(require("./media-item"), exports);
22
- __exportStar(require("./menu-category-item"), exports);
23
- __exportStar(require("./menu-category"), exports);
24
- __exportStar(require("./menu-item"), exports);
25
- __exportStar(require("./menu"), exports);
26
- __exportStar(require("./navigation"), exports);
27
- __exportStar(require("./page"), exports);
28
- __exportStar(require("./press"), exports);
29
- __exportStar(require("./website"), exports);
1
+ export * from "./alert";
2
+ export * from "./api";
3
+ export * from "./event";
4
+ export * from "./location";
5
+ export * from "./media-item";
6
+ export * from "./menu-category-item";
7
+ export * from "./menu-category";
8
+ export * from "./menu-item";
9
+ export * from "./menu";
10
+ export * from "./navigation";
11
+ export * from "./page";
12
+ export * from "./press";
13
+ export * from "./website";
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antlur/backstage",
3
3
  "author": "Anthony Holmes",
4
- "version": "1.0.7",
4
+ "version": "1.0.8",
5
5
  "description": "A simple client for Backstage CMS",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",