@antlur/backstage 1.2.1 → 1.3.0

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.
Files changed (69) hide show
  1. package/dist/cjs/client.js +2 -0
  2. package/dist/cjs/components/page-meta.js +8 -0
  3. package/dist/cjs/endpoints/layouts.js +16 -0
  4. package/dist/cjs/endpoints/website.js +4 -0
  5. package/dist/cjs/studio/define-layout.js +19 -0
  6. package/dist/cjs/studio/define-schema.js +6 -2
  7. package/dist/cjs/studio/index.js +1 -0
  8. package/dist/cjs/studio/types/index.js +1 -0
  9. package/dist/cjs/studio/types/layout.js +2 -0
  10. package/dist/esm/client.d.ts +2 -0
  11. package/dist/esm/client.d.ts.map +1 -1
  12. package/dist/esm/client.js +2 -0
  13. package/dist/esm/components/page-meta.d.ts +5 -0
  14. package/dist/esm/components/page-meta.d.ts.map +1 -0
  15. package/dist/esm/components/page-meta.js +5 -0
  16. package/dist/esm/config.d.ts +1 -0
  17. package/dist/esm/config.d.ts.map +1 -1
  18. package/dist/esm/endpoints/layouts.d.ts +13 -0
  19. package/dist/esm/endpoints/layouts.d.ts.map +1 -0
  20. package/dist/esm/endpoints/layouts.js +12 -0
  21. package/dist/esm/endpoints/website.d.ts +1 -0
  22. package/dist/esm/endpoints/website.d.ts.map +1 -1
  23. package/dist/esm/endpoints/website.js +4 -0
  24. package/dist/esm/studio/define-layout.d.ts +8 -0
  25. package/dist/esm/studio/define-layout.d.ts.map +1 -0
  26. package/dist/esm/studio/define-layout.js +16 -0
  27. package/dist/esm/studio/define-schema.d.ts +3 -2
  28. package/dist/esm/studio/define-schema.d.ts.map +1 -1
  29. package/dist/esm/studio/define-schema.js +4 -1
  30. package/dist/esm/studio/index.d.ts +1 -0
  31. package/dist/esm/studio/index.d.ts.map +1 -1
  32. package/dist/esm/studio/index.js +1 -0
  33. package/dist/esm/studio/types/index.d.ts +1 -0
  34. package/dist/esm/studio/types/index.d.ts.map +1 -1
  35. package/dist/esm/studio/types/index.js +1 -0
  36. package/dist/esm/studio/types/layout.d.ts +22 -0
  37. package/dist/esm/studio/types/layout.d.ts.map +1 -0
  38. package/dist/esm/studio/types/layout.js +1 -0
  39. package/dist/types/client.d.ts +2 -0
  40. package/dist/types/client.d.ts.map +1 -1
  41. package/dist/types/components/page-meta.d.ts +5 -0
  42. package/dist/types/components/page-meta.d.ts.map +1 -0
  43. package/dist/types/config.d.ts +1 -0
  44. package/dist/types/config.d.ts.map +1 -1
  45. package/dist/types/endpoints/layouts.d.ts +13 -0
  46. package/dist/types/endpoints/layouts.d.ts.map +1 -0
  47. package/dist/types/endpoints/website.d.ts +1 -0
  48. package/dist/types/endpoints/website.d.ts.map +1 -1
  49. package/dist/types/studio/define-layout.d.ts +8 -0
  50. package/dist/types/studio/define-layout.d.ts.map +1 -0
  51. package/dist/types/studio/define-schema.d.ts +3 -2
  52. package/dist/types/studio/define-schema.d.ts.map +1 -1
  53. package/dist/types/studio/index.d.ts +1 -0
  54. package/dist/types/studio/index.d.ts.map +1 -1
  55. package/dist/types/studio/types/index.d.ts +1 -0
  56. package/dist/types/studio/types/index.d.ts.map +1 -1
  57. package/dist/types/studio/types/layout.d.ts +22 -0
  58. package/dist/types/studio/types/layout.d.ts.map +1 -0
  59. package/package.json +1 -1
  60. package/src/client.ts +3 -0
  61. package/src/components/page-meta.tsx +12 -0
  62. package/src/config.ts +1 -0
  63. package/src/endpoints/layouts.ts +22 -0
  64. package/src/endpoints/website.ts +6 -0
  65. package/src/studio/define-layout.ts +27 -0
  66. package/src/studio/define-schema.ts +6 -2
  67. package/src/studio/index.ts +1 -0
  68. package/src/studio/types/index.ts +1 -0
  69. package/src/studio/types/layout.ts +22 -0
@@ -9,6 +9,7 @@ const config_1 = require("./config");
9
9
  const alerts_1 = require("./endpoints/alerts");
10
10
  const blocks_1 = require("./endpoints/blocks");
11
11
  const events_1 = require("./endpoints/events");
12
+ const layouts_1 = require("./endpoints/layouts");
12
13
  const locations_1 = require("./endpoints/locations");
13
14
  const menus_1 = require("./endpoints/menus");
14
15
  const navigation_1 = require("./endpoints/navigation");
@@ -67,6 +68,7 @@ class BackstageClient {
67
68
  this.alerts = new alerts_1.AlertService(this);
68
69
  this.blocks = new blocks_1.BlocksService(this);
69
70
  this.events = new events_1.EventService(this);
71
+ this.layouts = new layouts_1.LayoutService(this);
70
72
  this.locations = new locations_1.LocationService(this);
71
73
  this.menus = new menus_1.MenuService(this);
72
74
  this.navigation = new navigation_1.NavigationService(this);
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PageMeta = PageMeta;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ function PageMeta(props) {
6
+ const { meta } = props.page;
7
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("title", { children: meta.title }), (0, jsx_runtime_1.jsx)("meta", { name: "description", content: meta.description })] }));
8
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LayoutService = void 0;
4
+ const base_1 = require("./base");
5
+ class LayoutService extends base_1.BaseService {
6
+ async all() { }
7
+ async create({ name, slug, schema }) {
8
+ const res = await this.client.post("/layouts", { name, slug, schema });
9
+ return res.data;
10
+ }
11
+ async update(id, { name, slug, schema }) {
12
+ const res = await this.client.put(`/layouts/${id}`, { name, slug, schema });
13
+ return res.data;
14
+ }
15
+ }
16
+ exports.LayoutService = LayoutService;
@@ -7,5 +7,9 @@ class WebsiteService extends base_1.BaseService {
7
7
  const res = await this.client.get("/websites");
8
8
  return res.data[0];
9
9
  }
10
+ async routes() {
11
+ const website = await this.getWebsite();
12
+ return this.client.get(`/websites/${website.id}/routes`);
13
+ }
10
14
  }
11
15
  exports.WebsiteService = WebsiteService;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineLayout = defineLayout;
4
+ function defineLayout(options) {
5
+ // Runtime validation
6
+ if (!options.name || typeof options.name !== "string") {
7
+ throw new Error("Layout name is required and must be a string");
8
+ }
9
+ if (!options.slug || typeof options.slug !== "string") {
10
+ throw new Error("Layout slug is required and must be a string");
11
+ }
12
+ if (!options.schema || typeof options.schema !== "object") {
13
+ throw new Error("Layout schema is required and must be an object");
14
+ }
15
+ if (!options.component) {
16
+ throw new Error("Layout component is required");
17
+ }
18
+ return options;
19
+ }
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineSchema = defineSchema;
4
- function defineSchema(schema) {
3
+ exports.defineBlockSchema = defineBlockSchema;
4
+ exports.defineLayoutSchema = defineLayoutSchema;
5
+ function defineBlockSchema(schema) {
6
+ return schema;
7
+ }
8
+ function defineLayoutSchema(schema) {
5
9
  return schema;
6
10
  }
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./types"), exports);
18
18
  __exportStar(require("./define-block"), exports);
19
19
  __exportStar(require("./define-field"), exports);
20
+ __exportStar(require("./define-layout"), exports);
20
21
  __exportStar(require("./define-schema"), exports);
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./block"), exports);
18
18
  __exportStar(require("./field"), exports);
19
+ __exportStar(require("./layout"), exports);
19
20
  __exportStar(require("./field-values"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,6 +3,7 @@ import { BackstageUserConfig } from "./config";
3
3
  import { AlertService } from "./endpoints/alerts";
4
4
  import { BlocksService } from "./endpoints/blocks";
5
5
  import { EventService } from "./endpoints/events";
6
+ import { LayoutService } from "./endpoints/layouts";
6
7
  import { LocationService } from "./endpoints/locations";
7
8
  import { MenuService } from "./endpoints/menus";
8
9
  import { NavigationService } from "./endpoints/navigation";
@@ -14,6 +15,7 @@ export declare class BackstageClient {
14
15
  readonly alerts: AlertService;
15
16
  readonly blocks: BlocksService;
16
17
  readonly events: EventService;
18
+ readonly layouts: LayoutService;
17
19
  readonly locations: LocationService;
18
20
  readonly menus: MenuService;
19
21
  readonly navigation: NavigationService;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAA6B,MAAM,OAAO,CAAC;AAC5F,OAAO,EAAmB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAgB;IAGhC,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,MAAM,EAAE,aAAa,CAAC;IACtC,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,SAAS,EAAE,eAAe,CAAC;IAC3C,SAAgB,KAAK,EAAE,WAAW,CAAC;IACnC,SAAgB,UAAU,EAAE,iBAAiB,CAAC;IAC9C,SAAgB,KAAK,EAAE,WAAW,CAAC;IACnC,SAAgB,KAAK,EAAE,YAAY,CAAC;IACpC,SAAgB,OAAO,EAAE,cAAc,C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,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKxF,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAK/E,gBAAgB,IAAI,aAAa;CAGzC"}
@@ -3,6 +3,7 @@ import { getGlobalConfig } from "./config";
3
3
  import { AlertService } from "./endpoints/alerts";
4
4
  import { BlocksService } from "./endpoints/blocks";
5
5
  import { EventService } from "./endpoints/events";
6
+ import { LayoutService } from "./endpoints/layouts";
6
7
  import { LocationService } from "./endpoints/locations";
7
8
  import { MenuService } from "./endpoints/menus";
8
9
  import { NavigationService } from "./endpoints/navigation";
@@ -61,6 +62,7 @@ export class BackstageClient {
61
62
  this.alerts = new AlertService(this);
62
63
  this.blocks = new BlocksService(this);
63
64
  this.events = new EventService(this);
65
+ this.layouts = new LayoutService(this);
64
66
  this.locations = new LocationService(this);
65
67
  this.menus = new MenuService(this);
66
68
  this.navigation = new NavigationService(this);
@@ -0,0 +1,5 @@
1
+ import type { Page } from "@/types";
2
+ export declare function PageMeta(props: {
3
+ page: Page;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=page-meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-meta.d.ts","sourceRoot":"","sources":["../../../src/components/page-meta.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,2CAS7C"}
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export function PageMeta(props) {
3
+ const { meta } = props.page;
4
+ return (_jsxs(_Fragment, { children: [_jsx("title", { children: meta.title }), _jsx("meta", { name: "description", content: meta.description })] }));
5
+ }
@@ -5,6 +5,7 @@ export interface BackstageUserConfig {
5
5
  token?: string | undefined;
6
6
  baseURL?: string;
7
7
  blocks?: BlockDefinition<any>[] | undefined;
8
+ layouts?: any[] | undefined;
8
9
  onError?: (error: AxiosError) => void;
9
10
  }
10
11
  export declare function defineConfig(config: BackstageUserConfig): BackstageUserConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CACvC;AAQD,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAM7E;AAED,wBAAgB,eAAe,IAAI,mBAAmB,CAGrD"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;IAC5C,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CACvC;AAQD,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAM7E;AAED,wBAAgB,eAAe,IAAI,mBAAmB,CAGrD"}
@@ -0,0 +1,13 @@
1
+ import { BaseService } from "./base";
2
+ interface LayoutParams {
3
+ name: string;
4
+ slug: string;
5
+ schema: any;
6
+ }
7
+ export declare class LayoutService extends BaseService {
8
+ all(): Promise<void>;
9
+ create({ name, slug, schema }: LayoutParams): Promise<LayoutParams>;
10
+ update(id: string, { name, slug, schema }: LayoutParams): Promise<LayoutParams>;
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=layouts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../../src/endpoints/layouts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;CACb;AAED,qBAAa,aAAc,SAAQ,WAAW;IACtC,GAAG;IAEH,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,YAAY;IAK3C,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,YAAY;CAI9D"}
@@ -0,0 +1,12 @@
1
+ import { BaseService } from "./base";
2
+ export class LayoutService extends BaseService {
3
+ async all() { }
4
+ async create({ name, slug, schema }) {
5
+ const res = await this.client.post("/layouts", { name, slug, schema });
6
+ return res.data;
7
+ }
8
+ async update(id, { name, slug, schema }) {
9
+ const res = await this.client.put(`/layouts/${id}`, { name, slug, schema });
10
+ return res.data;
11
+ }
12
+ }
@@ -2,5 +2,6 @@ import { Website } from "../types";
2
2
  import { BaseService } from "./base";
3
3
  export declare class WebsiteService extends BaseService {
4
4
  getWebsite(): Promise<Website>;
5
+ routes(): Promise<string[]>;
5
6
  }
6
7
  //# sourceMappingURL=website.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"website.d.ts","sourceRoot":"","sources":["../../../src/endpoints/website.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,cAAe,SAAQ,WAAW;IACvC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;CAIrC"}
1
+ {"version":3,"file":"website.d.ts","sourceRoot":"","sources":["../../../src/endpoints/website.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,cAAe,SAAQ,WAAW;IACvC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAK9B,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAKlC"}
@@ -4,4 +4,8 @@ export class WebsiteService extends BaseService {
4
4
  const res = await this.client.get("/websites");
5
5
  return res.data[0];
6
6
  }
7
+ async routes() {
8
+ const website = await this.getWebsite();
9
+ return this.client.get(`/websites/${website.id}/routes`);
10
+ }
7
11
  }
@@ -0,0 +1,8 @@
1
+ import { LayoutSchema, LayoutDefinition, LayoutComponentProps } from "./types";
2
+ export declare function defineLayout(options: {
3
+ name: string;
4
+ slug: string;
5
+ schema: LayoutSchema<any>;
6
+ component: React.ComponentType<LayoutComponentProps<typeof options.schema>>;
7
+ }): LayoutDefinition<typeof options.schema.fields>;
8
+ //# sourceMappingURL=define-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-layout.d.ts","sourceRoot":"","sources":["../../../src/studio/define-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/E,wBAAgB,YAAY,CAAC,OAAO,EAAE;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;IAC1B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,oBAAoB,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;CAC7E,GAAG,gBAAgB,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAmBjD"}
@@ -0,0 +1,16 @@
1
+ export function defineLayout(options) {
2
+ // Runtime validation
3
+ if (!options.name || typeof options.name !== "string") {
4
+ throw new Error("Layout name is required and must be a string");
5
+ }
6
+ if (!options.slug || typeof options.slug !== "string") {
7
+ throw new Error("Layout slug is required and must be a string");
8
+ }
9
+ if (!options.schema || typeof options.schema !== "object") {
10
+ throw new Error("Layout schema is required and must be an object");
11
+ }
12
+ if (!options.component) {
13
+ throw new Error("Layout component is required");
14
+ }
15
+ return options;
16
+ }
@@ -1,4 +1,5 @@
1
- import { BlockSchema, Field } from "./types";
1
+ import { BlockSchema, LayoutSchema, Field } from "./types";
2
2
  export type SchemaFields = Record<string, Field>;
3
- export declare function defineSchema<T extends SchemaFields>(schema: BlockSchema<T>): BlockSchema<T>;
3
+ export declare function defineBlockSchema<T extends SchemaFields>(schema: BlockSchema<T>): BlockSchema<T>;
4
+ export declare function defineLayoutSchema<T extends SchemaFields>(schema: LayoutSchema<T>): LayoutSchema<T>;
4
5
  //# sourceMappingURL=define-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"define-schema.d.ts","sourceRoot":"","sources":["../../../src/studio/define-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEjD,wBAAgB,YAAY,CAAC,CAAC,SAAS,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,kBAE1E"}
1
+ {"version":3,"file":"define-schema.d.ts","sourceRoot":"","sources":["../../../src/studio/define-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEjD,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,kBAE/E;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,mBAEjF"}
@@ -1,3 +1,6 @@
1
- export function defineSchema(schema) {
1
+ export function defineBlockSchema(schema) {
2
+ return schema;
3
+ }
4
+ export function defineLayoutSchema(schema) {
2
5
  return schema;
3
6
  }
@@ -1,5 +1,6 @@
1
1
  export * from "./types";
2
2
  export * from "./define-block";
3
3
  export * from "./define-field";
4
+ export * from "./define-layout";
4
5
  export * from "./define-schema";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/studio/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/studio/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from "./types";
2
2
  export * from "./define-block";
3
3
  export * from "./define-field";
4
+ export * from "./define-layout";
4
5
  export * from "./define-schema";
@@ -1,4 +1,5 @@
1
1
  export * from "./block";
2
2
  export * from "./field";
3
+ export * from "./layout";
3
4
  export * from "./field-values";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/studio/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/studio/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AAEzB,cAAc,gBAAgB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./block";
2
2
  export * from "./field";
3
+ export * from "./layout";
3
4
  export * from "./field-values";
@@ -0,0 +1,22 @@
1
+ import { Field, FieldType, FieldTypeToValue } from "./field";
2
+ type FieldValues<T extends Record<string, Field>> = {
3
+ [K in keyof T]: T[K] extends {
4
+ type: infer Type;
5
+ } ? (Type extends FieldType ? FieldTypeToValue[Type] : never) : never;
6
+ };
7
+ export interface LayoutSchema<TFields extends Record<string, Field>> {
8
+ fields: TFields;
9
+ }
10
+ export interface LayoutDefinition<TFields extends Record<string, Field>> {
11
+ name: string;
12
+ slug: string;
13
+ schema: LayoutSchema<TFields>;
14
+ component: React.ComponentType<LayoutComponentProps<any>>;
15
+ }
16
+ export interface LayoutComponentProps<TSchema extends LayoutSchema<Record<string, Field>>> {
17
+ fields: FieldValues<TSchema["fields"]>;
18
+ children?: React.ReactNode;
19
+ onFieldChange: (layoutId: string, fieldName: keyof TSchema["fields"], value: any) => void;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=layout.d.ts.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 export {};
@@ -3,6 +3,7 @@ import { BackstageUserConfig } from "./config";
3
3
  import { AlertService } from "./endpoints/alerts";
4
4
  import { BlocksService } from "./endpoints/blocks";
5
5
  import { EventService } from "./endpoints/events";
6
+ import { LayoutService } from "./endpoints/layouts";
6
7
  import { LocationService } from "./endpoints/locations";
7
8
  import { MenuService } from "./endpoints/menus";
8
9
  import { NavigationService } from "./endpoints/navigation";
@@ -14,6 +15,7 @@ export declare class BackstageClient {
14
15
  readonly alerts: AlertService;
15
16
  readonly blocks: BlocksService;
16
17
  readonly events: EventService;
18
+ readonly layouts: LayoutService;
17
19
  readonly locations: LocationService;
18
20
  readonly menus: MenuService;
19
21
  readonly navigation: NavigationService;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAA6B,MAAM,OAAO,CAAC;AAC5F,OAAO,EAAmB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAgB;IAGhC,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,MAAM,EAAE,aAAa,CAAC;IACtC,SAAgB,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AC,CAAC;IAKvF,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtF,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKxF,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAK/E,gBAAgB,IAAI,aAAa;CAGzC"}
@@ -0,0 +1,5 @@
1
+ import type { Page } from "@/types";
2
+ export declare function PageMeta(props: {
3
+ page: Page;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=page-meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-meta.d.ts","sourceRoot":"","sources":["../../../src/components/page-meta.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,2CAS7C"}
@@ -5,6 +5,7 @@ export interface BackstageUserConfig {
5
5
  token?: string | undefined;
6
6
  baseURL?: string;
7
7
  blocks?: BlockDefinition<any>[] | undefined;
8
+ layouts?: any[] | undefined;
8
9
  onError?: (error: AxiosError) => void;
9
10
  }
10
11
  export declare function defineConfig(config: BackstageUserConfig): BackstageUserConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CACvC;AAQD,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAM7E;AAED,wBAAgB,eAAe,IAAI,mBAAmB,CAGrD"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;IAC5C,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CACvC;AAQD,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAM7E;AAED,wBAAgB,eAAe,IAAI,mBAAmB,CAGrD"}
@@ -0,0 +1,13 @@
1
+ import { BaseService } from "./base";
2
+ interface LayoutParams {
3
+ name: string;
4
+ slug: string;
5
+ schema: any;
6
+ }
7
+ export declare class LayoutService extends BaseService {
8
+ all(): Promise<void>;
9
+ create({ name, slug, schema }: LayoutParams): Promise<LayoutParams>;
10
+ update(id: string, { name, slug, schema }: LayoutParams): Promise<LayoutParams>;
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=layouts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../../src/endpoints/layouts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;CACb;AAED,qBAAa,aAAc,SAAQ,WAAW;IACtC,GAAG;IAEH,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,YAAY;IAK3C,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,YAAY;CAI9D"}
@@ -2,5 +2,6 @@ import { Website } from "../types";
2
2
  import { BaseService } from "./base";
3
3
  export declare class WebsiteService extends BaseService {
4
4
  getWebsite(): Promise<Website>;
5
+ routes(): Promise<string[]>;
5
6
  }
6
7
  //# sourceMappingURL=website.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"website.d.ts","sourceRoot":"","sources":["../../../src/endpoints/website.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,cAAe,SAAQ,WAAW;IACvC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;CAIrC"}
1
+ {"version":3,"file":"website.d.ts","sourceRoot":"","sources":["../../../src/endpoints/website.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,cAAe,SAAQ,WAAW;IACvC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAK9B,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAKlC"}
@@ -0,0 +1,8 @@
1
+ import { LayoutSchema, LayoutDefinition, LayoutComponentProps } from "./types";
2
+ export declare function defineLayout(options: {
3
+ name: string;
4
+ slug: string;
5
+ schema: LayoutSchema<any>;
6
+ component: React.ComponentType<LayoutComponentProps<typeof options.schema>>;
7
+ }): LayoutDefinition<typeof options.schema.fields>;
8
+ //# sourceMappingURL=define-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-layout.d.ts","sourceRoot":"","sources":["../../../src/studio/define-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/E,wBAAgB,YAAY,CAAC,OAAO,EAAE;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;IAC1B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,oBAAoB,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;CAC7E,GAAG,gBAAgB,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAmBjD"}
@@ -1,4 +1,5 @@
1
- import { BlockSchema, Field } from "./types";
1
+ import { BlockSchema, LayoutSchema, Field } from "./types";
2
2
  export type SchemaFields = Record<string, Field>;
3
- export declare function defineSchema<T extends SchemaFields>(schema: BlockSchema<T>): BlockSchema<T>;
3
+ export declare function defineBlockSchema<T extends SchemaFields>(schema: BlockSchema<T>): BlockSchema<T>;
4
+ export declare function defineLayoutSchema<T extends SchemaFields>(schema: LayoutSchema<T>): LayoutSchema<T>;
4
5
  //# sourceMappingURL=define-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"define-schema.d.ts","sourceRoot":"","sources":["../../../src/studio/define-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEjD,wBAAgB,YAAY,CAAC,CAAC,SAAS,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,kBAE1E"}
1
+ {"version":3,"file":"define-schema.d.ts","sourceRoot":"","sources":["../../../src/studio/define-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEjD,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,kBAE/E;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,mBAEjF"}
@@ -1,5 +1,6 @@
1
1
  export * from "./types";
2
2
  export * from "./define-block";
3
3
  export * from "./define-field";
4
+ export * from "./define-layout";
4
5
  export * from "./define-schema";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/studio/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/studio/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from "./block";
2
2
  export * from "./field";
3
+ export * from "./layout";
3
4
  export * from "./field-values";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/studio/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/studio/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AAEzB,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { Field, FieldType, FieldTypeToValue } from "./field";
2
+ type FieldValues<T extends Record<string, Field>> = {
3
+ [K in keyof T]: T[K] extends {
4
+ type: infer Type;
5
+ } ? (Type extends FieldType ? FieldTypeToValue[Type] : never) : never;
6
+ };
7
+ export interface LayoutSchema<TFields extends Record<string, Field>> {
8
+ fields: TFields;
9
+ }
10
+ export interface LayoutDefinition<TFields extends Record<string, Field>> {
11
+ name: string;
12
+ slug: string;
13
+ schema: LayoutSchema<TFields>;
14
+ component: React.ComponentType<LayoutComponentProps<any>>;
15
+ }
16
+ export interface LayoutComponentProps<TSchema extends LayoutSchema<Record<string, Field>>> {
17
+ fields: FieldValues<TSchema["fields"]>;
18
+ children?: React.ReactNode;
19
+ onFieldChange: (layoutId: string, fieldName: keyof TSchema["fields"], value: any) => void;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../../src/studio/types/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE7D,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI;KACjD,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QAAE,IAAI,EAAE,MAAM,IAAI,CAAA;KAAE,GAAG,CAAC,IAAI,SAAS,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK;CACtH,CAAC;AAEF,MAAM,WAAW,YAAY,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IACjE,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC;CAC3D;AAED,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACvF,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAC3F"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antlur/backstage",
3
3
  "author": "Anthony Holmes",
4
- "version": "1.2.1",
4
+ "version": "1.3.0",
5
5
  "description": "A simple client for Backstage CMS",
6
6
  "main": "./dist/cjs/index.js",
7
7
  "module": "./dist/esm/index.js",
package/src/client.ts CHANGED
@@ -3,6 +3,7 @@ import { getGlobalConfig, BackstageUserConfig } from "./config";
3
3
  import { AlertService } from "./endpoints/alerts";
4
4
  import { BlocksService } from "./endpoints/blocks";
5
5
  import { EventService } from "./endpoints/events";
6
+ import { LayoutService } from "./endpoints/layouts";
6
7
  import { LocationService } from "./endpoints/locations";
7
8
  import { MenuService } from "./endpoints/menus";
8
9
  import { NavigationService } from "./endpoints/navigation";
@@ -17,6 +18,7 @@ export class BackstageClient {
17
18
  public readonly alerts: AlertService;
18
19
  public readonly blocks: BlocksService;
19
20
  public readonly events: EventService;
21
+ public readonly layouts: LayoutService;
20
22
  public readonly locations: LocationService;
21
23
  public readonly menus: MenuService;
22
24
  public readonly navigation: NavigationService;
@@ -85,6 +87,7 @@ export class BackstageClient {
85
87
  this.alerts = new AlertService(this);
86
88
  this.blocks = new BlocksService(this);
87
89
  this.events = new EventService(this);
90
+ this.layouts = new LayoutService(this);
88
91
  this.locations = new LocationService(this);
89
92
  this.menus = new MenuService(this);
90
93
  this.navigation = new NavigationService(this);
@@ -0,0 +1,12 @@
1
+ import type { Page } from "@/types";
2
+
3
+ export function PageMeta(props: { page: Page }) {
4
+ const { meta } = props.page;
5
+
6
+ return (
7
+ <>
8
+ <title>{meta.title}</title>
9
+ <meta name="description" content={meta.description} />
10
+ </>
11
+ );
12
+ }
package/src/config.ts CHANGED
@@ -10,6 +10,7 @@ export interface BackstageUserConfig {
10
10
  token?: string | undefined;
11
11
  baseURL?: string;
12
12
  blocks?: BlockDefinition<any>[] | undefined;
13
+ layouts?: any[] | undefined;
13
14
  onError?: (error: AxiosError) => void;
14
15
  }
15
16
 
@@ -0,0 +1,22 @@
1
+ import { ApiSingleResponse } from "../types";
2
+ import { BaseService } from "./base";
3
+
4
+ interface LayoutParams {
5
+ name: string;
6
+ slug: string;
7
+ schema: any;
8
+ }
9
+
10
+ export class LayoutService extends BaseService {
11
+ async all() {}
12
+
13
+ async create({ name, slug, schema }: LayoutParams) {
14
+ const res = await this.client.post<ApiSingleResponse<LayoutParams>>("/layouts", { name, slug, schema });
15
+ return res.data;
16
+ }
17
+
18
+ async update(id: string, { name, slug, schema }: LayoutParams) {
19
+ const res = await this.client.put<ApiSingleResponse<LayoutParams>>(`/layouts/${id}`, { name, slug, schema });
20
+ return res.data;
21
+ }
22
+ }
@@ -6,4 +6,10 @@ export class WebsiteService extends BaseService {
6
6
  const res = await this.client.get<ApiCollectionResponse<Website>>("/websites");
7
7
  return res.data[0];
8
8
  }
9
+
10
+ async routes(): Promise<string[]> {
11
+ const website = await this.getWebsite();
12
+
13
+ return this.client.get<string[]>(`/websites/${website.id}/routes`);
14
+ }
9
15
  }
@@ -0,0 +1,27 @@
1
+ import { LayoutSchema, LayoutDefinition, LayoutComponentProps } from "./types";
2
+
3
+ export function defineLayout(options: {
4
+ name: string;
5
+ slug: string;
6
+ schema: LayoutSchema<any>;
7
+ component: React.ComponentType<LayoutComponentProps<typeof options.schema>>;
8
+ }): LayoutDefinition<typeof options.schema.fields> {
9
+ // Runtime validation
10
+ if (!options.name || typeof options.name !== "string") {
11
+ throw new Error("Layout name is required and must be a string");
12
+ }
13
+
14
+ if (!options.slug || typeof options.slug !== "string") {
15
+ throw new Error("Layout slug is required and must be a string");
16
+ }
17
+
18
+ if (!options.schema || typeof options.schema !== "object") {
19
+ throw new Error("Layout schema is required and must be an object");
20
+ }
21
+
22
+ if (!options.component) {
23
+ throw new Error("Layout component is required");
24
+ }
25
+
26
+ return options;
27
+ }
@@ -1,7 +1,11 @@
1
- import { BlockSchema, Field } from "./types";
1
+ import { BlockSchema, LayoutSchema, Field } from "./types";
2
2
 
3
3
  export type SchemaFields = Record<string, Field>;
4
4
 
5
- export function defineSchema<T extends SchemaFields>(schema: BlockSchema<T>) {
5
+ export function defineBlockSchema<T extends SchemaFields>(schema: BlockSchema<T>) {
6
+ return schema;
7
+ }
8
+
9
+ export function defineLayoutSchema<T extends SchemaFields>(schema: LayoutSchema<T>) {
6
10
  return schema;
7
11
  }
@@ -2,4 +2,5 @@ export * from "./types";
2
2
 
3
3
  export * from "./define-block";
4
4
  export * from "./define-field";
5
+ export * from "./define-layout";
5
6
  export * from "./define-schema";
@@ -1,4 +1,5 @@
1
1
  export * from "./block";
2
2
  export * from "./field";
3
+ export * from "./layout";
3
4
 
4
5
  export * from "./field-values";
@@ -0,0 +1,22 @@
1
+ import { Field, FieldType, FieldTypeToValue } from "./field";
2
+
3
+ type FieldValues<T extends Record<string, Field>> = {
4
+ [K in keyof T]: T[K] extends { type: infer Type } ? (Type extends FieldType ? FieldTypeToValue[Type] : never) : never;
5
+ };
6
+
7
+ export interface LayoutSchema<TFields extends Record<string, Field>> {
8
+ fields: TFields;
9
+ }
10
+
11
+ export interface LayoutDefinition<TFields extends Record<string, Field>> {
12
+ name: string;
13
+ slug: string;
14
+ schema: LayoutSchema<TFields>;
15
+ component: React.ComponentType<LayoutComponentProps<any>>;
16
+ }
17
+
18
+ export interface LayoutComponentProps<TSchema extends LayoutSchema<Record<string, Field>>> {
19
+ fields: FieldValues<TSchema["fields"]>;
20
+ children?: React.ReactNode;
21
+ onFieldChange: (layoutId: string, fieldName: keyof TSchema["fields"], value: any) => void;
22
+ }