@fireberry/cli 0.0.5-beta.16 → 0.0.5-beta.17

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.
@@ -25,7 +25,11 @@ export interface RecordComponentSettings {
25
25
  export interface GlobalMenuComponentSettings {
26
26
  displayName: string;
27
27
  }
28
- export type ComponentSettings = RecordComponentSettings | GlobalMenuComponentSettings;
28
+ export interface SideMenuComponentSettings {
29
+ icon: string;
30
+ width: "S" | "M" | "L";
31
+ }
32
+ export type ComponentSettings = RecordComponentSettings | GlobalMenuComponentSettings | SideMenuComponentSettings;
29
33
  export interface BaseManifestComponent {
30
34
  title: string;
31
35
  id: string;
@@ -1,5 +1,6 @@
1
1
  export declare const COMPONENT_TYPE: {
2
2
  readonly RECORD: "record";
3
3
  readonly GLOBAL_MENU: "global-menu";
4
+ readonly SIDE_MENU: "side-menu";
4
5
  };
5
6
  export type ComponentType = (typeof COMPONENT_TYPE)[keyof typeof COMPONENT_TYPE];
@@ -1,4 +1,5 @@
1
1
  export const COMPONENT_TYPE = {
2
2
  RECORD: "record",
3
3
  GLOBAL_MENU: "global-menu",
4
+ SIDE_MENU: "side-menu",
4
5
  };
@@ -58,6 +58,23 @@ const validateGlobalMenuComponentSettings = (comp) => {
58
58
  throw new Error(`Component "${comp.title}" (type: ${COMPONENT_TYPE.GLOBAL_MENU}) setting "displayName" must be a string`);
59
59
  }
60
60
  };
61
+ const validateSideMenuComponentSettings = (comp) => {
62
+ const settings = comp.settings;
63
+ if (!settings) {
64
+ throw new Error(`Component "${comp.title}" (type: ${COMPONENT_TYPE.SIDE_MENU}) is missing required settings`);
65
+ }
66
+ if (!settings.icon) {
67
+ throw new Error(`Component "${comp.title}" (type: ${COMPONENT_TYPE.SIDE_MENU}) setting "icon" must be a string`);
68
+ }
69
+ if (!settings.width) {
70
+ throw new Error(`Component "${comp.title}" (type: ${COMPONENT_TYPE.SIDE_MENU}) setting "width" must be a S | M | L`);
71
+ }
72
+ if (settings.width !== "S" &&
73
+ settings.width !== "M" &&
74
+ settings.width !== "L") {
75
+ throw new Error(`Component "${comp.title}" (type: ${COMPONENT_TYPE.SIDE_MENU}) setting "width" must be a S | M | L`);
76
+ }
77
+ };
61
78
  const validateComponentSettings = (comp) => {
62
79
  switch (comp.type) {
63
80
  case COMPONENT_TYPE.RECORD:
@@ -66,6 +83,9 @@ const validateComponentSettings = (comp) => {
66
83
  case COMPONENT_TYPE.GLOBAL_MENU:
67
84
  validateGlobalMenuComponentSettings(comp);
68
85
  break;
86
+ case COMPONENT_TYPE.SIDE_MENU:
87
+ validateSideMenuComponentSettings(comp);
88
+ break;
69
89
  default:
70
90
  throw new Error(`Component "${comp.title}" has unsupported type: ${comp.type}. Supported types: ${COMPONENT_TYPE.RECORD}, ${COMPONENT_TYPE.GLOBAL_MENU}`);
71
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireberry/cli",
3
- "version": "0.0.5-beta.16",
3
+ "version": "0.0.5-beta.17",
4
4
  "description": "Fireberry CLI tool",
5
5
  "type": "module",
6
6
  "author": "",
package/src/api/types.ts CHANGED
@@ -32,9 +32,15 @@ export interface GlobalMenuComponentSettings {
32
32
  displayName: string;
33
33
  }
34
34
 
35
+ export interface SideMenuComponentSettings {
36
+ icon: string;
37
+ width: "S" | "M" | "L";
38
+ }
39
+
35
40
  export type ComponentSettings =
36
41
  | RecordComponentSettings
37
- | GlobalMenuComponentSettings;
42
+ | GlobalMenuComponentSettings
43
+ | SideMenuComponentSettings;
38
44
 
39
45
  export interface BaseManifestComponent {
40
46
  title: string;
@@ -1,6 +1,8 @@
1
1
  export const COMPONENT_TYPE = {
2
2
  RECORD: "record",
3
3
  GLOBAL_MENU: "global-menu",
4
+ SIDE_MENU: "side-menu",
4
5
  } as const;
5
6
 
6
- export type ComponentType = (typeof COMPONENT_TYPE)[keyof typeof COMPONENT_TYPE];
7
+ export type ComponentType =
8
+ (typeof COMPONENT_TYPE)[keyof typeof COMPONENT_TYPE];
@@ -10,6 +10,7 @@ import {
10
10
  UntypedManifestComponent,
11
11
  RecordComponentSettings,
12
12
  GlobalMenuComponentSettings,
13
+ SideMenuComponentSettings,
13
14
  } from "../api/types.js";
14
15
  import { COMPONENT_TYPE } from "../constants/component-types.js";
15
16
 
@@ -112,6 +113,42 @@ const validateGlobalMenuComponentSettings = (
112
113
  }
113
114
  };
114
115
 
116
+ const validateSideMenuComponentSettings = (
117
+ comp: UntypedManifestComponent
118
+ ): void => {
119
+ const settings = comp.settings as
120
+ | Partial<SideMenuComponentSettings>
121
+ | undefined;
122
+
123
+ if (!settings) {
124
+ throw new Error(
125
+ `Component "${comp.title}" (type: ${COMPONENT_TYPE.SIDE_MENU}) is missing required settings`
126
+ );
127
+ }
128
+
129
+ if (!settings.icon) {
130
+ throw new Error(
131
+ `Component "${comp.title}" (type: ${COMPONENT_TYPE.SIDE_MENU}) setting "icon" must be a string`
132
+ );
133
+ }
134
+
135
+ if (!settings.width) {
136
+ throw new Error(
137
+ `Component "${comp.title}" (type: ${COMPONENT_TYPE.SIDE_MENU}) setting "width" must be a S | M | L`
138
+ );
139
+ }
140
+
141
+ if (
142
+ settings.width !== "S" &&
143
+ settings.width !== "M" &&
144
+ settings.width !== "L"
145
+ ) {
146
+ throw new Error(
147
+ `Component "${comp.title}" (type: ${COMPONENT_TYPE.SIDE_MENU}) setting "width" must be a S | M | L`
148
+ );
149
+ }
150
+ };
151
+
115
152
  const validateComponentSettings = (comp: UntypedManifestComponent): void => {
116
153
  switch (comp.type) {
117
154
  case COMPONENT_TYPE.RECORD:
@@ -120,6 +157,9 @@ const validateComponentSettings = (comp: UntypedManifestComponent): void => {
120
157
  case COMPONENT_TYPE.GLOBAL_MENU:
121
158
  validateGlobalMenuComponentSettings(comp);
122
159
  break;
160
+ case COMPONENT_TYPE.SIDE_MENU:
161
+ validateSideMenuComponentSettings(comp);
162
+ break;
123
163
  default:
124
164
  throw new Error(
125
165
  `Component "${comp.title}" has unsupported type: ${comp.type}. Supported types: ${COMPONENT_TYPE.RECORD}, ${COMPONENT_TYPE.GLOBAL_MENU}`