@en-solutions/tgm-client-sdk 1.8.0 → 1.8.1

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.
@@ -6,6 +6,10 @@ export interface ContentTypeSchema {
6
6
  pluralName: string;
7
7
  displayName: string;
8
8
  description?: string;
9
+ /** Target menu section id (e.g., "tgm-om", "administration", "tgm-inventory-management") */
10
+ menuSection?: string;
11
+ /** Icon name for sidebar tab (feather/lucide, e.g., "shield", "clipboard") */
12
+ menuIcon?: string;
9
13
  };
10
14
  options?: {
11
15
  draftAndPublish?: boolean;
@@ -1,65 +1,60 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import * as i0 from "@angular/core";
3
3
  /**
4
- * Menu item structure matching tgm-manager-ui's CoreMenuItem interface.
5
- * Frontend devs can inject these into the sidebar dynamically.
4
+ * Transforms CMS content types into sidebar menu items.
6
5
  *
7
- * Usage in tgm-manager-ui:
6
+ * Each content type can specify where it appears via info.menuSection:
7
+ * - "tgm-om" → TGM O&M section
8
+ * - "tgm-economics" → TGM Economics section
9
+ * - "tgm-inventory-management" → Inventory section
10
+ * - "administration" (default) → Administration → Custom Objects
11
+ * - Any other menu section id from menu.ts
8
12
  *
9
- * ```typescript
10
- * // In AppComponent or a module initializer:
11
- * cmsMenuHelper.getMenuItems('administration/cms').subscribe(items => {
12
- * // items is a CoreMenuItem[] array ready to inject into the sidebar
13
- * const adminSection = menu.find(m => m.id === 'administration');
14
- * const cmsGroup = {
15
- * id: 'custom-objects',
16
- * type: 'section' as const,
17
- * title: 'Custom Objects',
18
- * icon: 'layers',
19
- * role: [Role['Administration.Read']],
20
- * children: items
21
- * };
22
- * const moreIdx = adminSection.children.findIndex(c => c.id === 'more');
23
- * adminSection.children.splice(moreIdx, 0, cmsGroup);
24
- * });
25
- * ```
13
+ * Usage in AppComponent.initializeMenu():
26
14
  *
27
- * Route setup in administraton.module.ts:
28
15
  * ```typescript
29
- * {
30
- * path: 'cms/:collectionName',
31
- * loadChildren: () => import('./cms/cms.module').then(m => m.CmsModule),
32
- * canActivate: [AuthGuard]
33
- * }
16
+ * this.cmsMenuHelper.getMenuItemsBySection('cms').subscribe(grouped => {
17
+ * for (const [sectionId, items] of Object.entries(grouped)) {
18
+ * const section = menu.find(m => m.id === sectionId);
19
+ * if (section?.children) {
20
+ * section.children.push(...items);
21
+ * }
22
+ * }
23
+ * });
34
24
  * ```
35
25
  */
36
26
  export declare class CmsMenuHelper {
37
27
  private contentTypeService;
28
+ /** Cached content types — shared across subscribers, auto-refreshes on invalidate() */
29
+ private _cache$;
30
+ private getContentTypes;
31
+ /** Invalidate the cache — call after creating/updating/deleting a content type */
32
+ invalidate(): void;
38
33
  /**
39
- * Fetch all active content types and transform them into menu items.
34
+ * Fetch all content types and return menu items grouped by menuSection.
35
+ * Each key is a menu section id (e.g., "tgm-om", "administration").
36
+ * Items without menuSection default to "administration".
40
37
  *
41
- * @param baseUrl - The base route path (e.g., 'administration/cms')
42
- * @param defaultIcon - Default icon for items without a specific one (default: 'database')
43
- * @returns Observable of menu items array
38
+ * @param baseUrl - Route base path for CMS pages
39
+ * @param defaultIcon - Default icon when menuIcon not set
44
40
  */
45
- getMenuItems(baseUrl?: string, defaultIcon?: string): Observable<CmsMenuItem[]>;
41
+ getMenuItemsBySection(baseUrl?: string, defaultIcon?: string): Observable<Record<string, CmsMenuItem[]>>;
46
42
  /**
47
- * Transform a single content type into a menu item.
43
+ * Fetch all content types as a flat list of menu items.
44
+ * Use getMenuItemsBySection() instead if you need placement control.
48
45
  */
49
- private toMenuItem;
46
+ getMenuItems(baseUrl?: string, defaultIcon?: string): Observable<CmsMenuItem[]>;
50
47
  /**
51
- * Build a complete "Custom Objects" collapsible menu section.
52
- * Ready to inject directly into the sidebar menu array.
53
- *
54
- * @param baseUrl - Route base path
55
- * @param roles - Required roles to see this section
48
+ * Build a "Custom Objects" section for items that target "administration".
49
+ * Items targeting other sections are excluded use getMenuItemsBySection() for those.
56
50
  */
57
51
  getMenuSection(baseUrl?: string, roles?: string[]): Observable<CmsMenuSection>;
52
+ private toMenuItem;
58
53
  static ɵfac: i0.ɵɵFactoryDeclaration<CmsMenuHelper, never>;
59
54
  static ɵprov: i0.ɵɵInjectableDeclaration<CmsMenuHelper>;
60
55
  }
61
56
  /**
62
- * Menu item structure compatible with tgm-manager-ui's CoreMenuItem.
57
+ * Menu item compatible with tgm-manager-ui CoreMenuItem.
63
58
  */
64
59
  export interface CmsMenuItem {
65
60
  id: string;
@@ -79,6 +74,8 @@ export interface CmsMenuItem {
79
74
  classes?: string;
80
75
  };
81
76
  children?: CmsMenuItem[];
77
+ /** Internal: target menu section id */
78
+ _menuSection?: string;
82
79
  }
83
80
  /**
84
81
  * Complete menu section ready for sidebar injection.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@en-solutions/tgm-client-sdk",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "TGM Manager Client SDK for Angular 18 - Type-safe services for all TGM API endpoints",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {