@en-solutions/tgm-client-sdk 1.7.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.
@@ -76,6 +76,8 @@ export interface ErpEntityMappingRequest {
76
76
  conflictResolution?: string;
77
77
  syncFilter?: Record<string, any>;
78
78
  fieldMappings?: FieldMappingRequest[];
79
+ /** When tgmEntityType=CUSTOM, the CMS collection name to sync to */
80
+ customCollectionName?: string;
79
81
  }
80
82
  export interface FieldMappingRequest {
81
83
  tgmFieldName: string;
@@ -0,0 +1,170 @@
1
+ export interface ContentTypeSchema {
2
+ kind?: string;
3
+ collectionName: string;
4
+ info: {
5
+ singularName: string;
6
+ pluralName: string;
7
+ displayName: string;
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;
13
+ };
14
+ options?: {
15
+ draftAndPublish?: boolean;
16
+ };
17
+ attributes: Record<string, FieldDefinition>;
18
+ }
19
+ export interface FieldDefinition {
20
+ name: string;
21
+ type: 'string' | 'text' | 'richtext' | 'integer' | 'biginteger' | 'float' | 'decimal' | 'boolean' | 'date' | 'time' | 'datetime' | 'json' | 'enumeration' | 'email' | 'media' | 'relation';
22
+ required?: boolean;
23
+ unique?: boolean;
24
+ private?: boolean;
25
+ default?: any;
26
+ minLength?: number;
27
+ maxLength?: number;
28
+ min?: number;
29
+ max?: number;
30
+ regex?: string;
31
+ enum?: string[];
32
+ relation?: 'oneToOne' | 'oneToMany' | 'manyToOne' | 'manyToMany';
33
+ target?: string;
34
+ allowedTypes?: string[];
35
+ multiple?: boolean;
36
+ }
37
+ export interface CmsSavedView {
38
+ id?: number;
39
+ collectionName?: string;
40
+ userId?: number;
41
+ viewName: string;
42
+ isDefault?: boolean;
43
+ filterConfig?: Record<string, any>;
44
+ columnConfig?: string[];
45
+ sortConfig?: {
46
+ field: string;
47
+ order: 'ASC' | 'DESC';
48
+ };
49
+ createdAt?: string;
50
+ updatedAt?: string;
51
+ }
52
+ export interface CmsValidationRule {
53
+ id?: number;
54
+ collectionName?: string;
55
+ ruleName: string;
56
+ ruleType: 'REQUIRED_IF' | 'COMPARISON' | 'REGEX' | 'CUSTOM_EXPRESSION';
57
+ ruleConfig: Record<string, any>;
58
+ errorMessage: string;
59
+ isActive?: boolean;
60
+ displayOrder?: number;
61
+ createdAt?: string;
62
+ updatedAt?: string;
63
+ }
64
+ export interface CmsRecordType {
65
+ id?: number;
66
+ collectionName?: string;
67
+ typeName: string;
68
+ displayName: string;
69
+ description?: string;
70
+ icon?: string;
71
+ color?: string;
72
+ isDefault?: boolean;
73
+ isActive?: boolean;
74
+ fieldOverrides?: Record<string, any>;
75
+ createdAt?: string;
76
+ updatedAt?: string;
77
+ }
78
+ export interface CmsPageLayout {
79
+ id?: number;
80
+ collectionName?: string;
81
+ layoutName: string;
82
+ isDefault?: boolean;
83
+ recordTypeId?: number;
84
+ sections: CmsLayoutSection[];
85
+ createdAt?: string;
86
+ updatedAt?: string;
87
+ }
88
+ export interface CmsLayoutSection {
89
+ title: string;
90
+ columns: number;
91
+ fields: string[];
92
+ }
93
+ export interface CmsFormulaField {
94
+ id?: number;
95
+ collectionName?: string;
96
+ fieldName: string;
97
+ label: string;
98
+ formula: string;
99
+ resultType: 'NUMBER' | 'STRING' | 'DATE' | 'BOOLEAN';
100
+ displayOrder?: number;
101
+ isActive?: boolean;
102
+ createdAt?: string;
103
+ }
104
+ export interface CmsWorkflowRule {
105
+ id?: number;
106
+ collectionName?: string;
107
+ ruleName: string;
108
+ triggerEvent: 'ON_CREATE' | 'ON_UPDATE' | 'ON_CREATE_OR_UPDATE';
109
+ isActive?: boolean;
110
+ evaluationOrder?: number;
111
+ conditionConfig?: Record<string, any>;
112
+ actions: CmsWorkflowAction[];
113
+ createdAt?: string;
114
+ }
115
+ export interface CmsWorkflowAction {
116
+ type: 'FIELD_UPDATE' | 'NOTIFICATION' | 'LOG';
117
+ field?: string;
118
+ value?: any;
119
+ message?: string;
120
+ }
121
+ export interface CmsApprovalProcess {
122
+ id?: number;
123
+ collectionName?: string;
124
+ processName: string;
125
+ isActive?: boolean;
126
+ triggerField: string;
127
+ triggerValue: string;
128
+ finalApproveValue?: string;
129
+ finalRejectValue?: string;
130
+ steps: CmsApprovalStep[];
131
+ notifyOnSubmit?: boolean;
132
+ notifyOnApprove?: boolean;
133
+ notifyOnReject?: boolean;
134
+ createdAt?: string;
135
+ }
136
+ export interface CmsApprovalStep {
137
+ order: number;
138
+ name: string;
139
+ approverField?: string;
140
+ approverRole?: string;
141
+ }
142
+ export interface CmsApprovalInstance {
143
+ id?: number;
144
+ processId: number;
145
+ collectionName?: string;
146
+ recordId: number;
147
+ currentStep?: number;
148
+ status?: 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELLED';
149
+ submittedBy?: number;
150
+ submittedAt?: string;
151
+ completedAt?: string;
152
+ comments?: string;
153
+ stepHistory?: any[];
154
+ }
155
+ export interface CmsRollupResult {
156
+ result: any;
157
+ function: string;
158
+ targetCollection: string;
159
+ }
160
+ export interface CmsDataResponse<T = any> {
161
+ data: T;
162
+ meta?: {
163
+ pagination?: {
164
+ page: number;
165
+ pageSize: number;
166
+ pageCount: number;
167
+ total: number;
168
+ };
169
+ };
170
+ }
@@ -40,10 +40,23 @@ export declare const TgmEntityType: {
40
40
  readonly LOCATION: "LOCATION";
41
41
  readonly UNIT: "UNIT";
42
42
  readonly COMPONENT: "COMPONENT";
43
+ readonly SENSOR: "SENSOR";
44
+ readonly SENSOR_READING: "SENSOR_READING";
43
45
  readonly USER: "USER";
44
46
  readonly INSPECTION: "INSPECTION";
47
+ readonly MAINTENANCE_RECORD: "MAINTENANCE_RECORD";
48
+ readonly MAINTENANCE_PLAN: "MAINTENANCE_PLAN";
45
49
  readonly FAILURE: "FAILURE";
50
+ readonly MATERIAL_ITEM: "MATERIAL_ITEM";
51
+ readonly MATERIAL_CONSUMABLE: "MATERIAL_CONSUMABLE";
52
+ readonly SUPPLIER: "SUPPLIER";
46
53
  readonly INVENTORY: "INVENTORY";
47
54
  readonly INVOICE: "INVOICE";
55
+ readonly PURCHASE_ORDER: "PURCHASE_ORDER";
56
+ readonly GOODS_RECEIPT: "GOODS_RECEIPT";
57
+ readonly STOCK_MOVEMENT: "STOCK_MOVEMENT";
58
+ readonly WAREHOUSE: "WAREHOUSE";
59
+ readonly STOCK_COUNT: "STOCK_COUNT";
60
+ readonly CUSTOM: "CUSTOM";
48
61
  };
49
62
  export type TgmEntityType = (typeof TgmEntityType)[keyof typeof TgmEntityType];
@@ -0,0 +1,85 @@
1
+ import { Observable } from 'rxjs';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Transforms CMS content types into sidebar menu items.
5
+ *
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
12
+ *
13
+ * Usage in AppComponent.initializeMenu():
14
+ *
15
+ * ```typescript
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
+ * });
24
+ * ```
25
+ */
26
+ export declare class CmsMenuHelper {
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;
33
+ /**
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".
37
+ *
38
+ * @param baseUrl - Route base path for CMS pages
39
+ * @param defaultIcon - Default icon when menuIcon not set
40
+ */
41
+ getMenuItemsBySection(baseUrl?: string, defaultIcon?: string): Observable<Record<string, CmsMenuItem[]>>;
42
+ /**
43
+ * Fetch all content types as a flat list of menu items.
44
+ * Use getMenuItemsBySection() instead if you need placement control.
45
+ */
46
+ getMenuItems(baseUrl?: string, defaultIcon?: string): Observable<CmsMenuItem[]>;
47
+ /**
48
+ * Build a "Custom Objects" section for items that target "administration".
49
+ * Items targeting other sections are excluded — use getMenuItemsBySection() for those.
50
+ */
51
+ getMenuSection(baseUrl?: string, roles?: string[]): Observable<CmsMenuSection>;
52
+ private toMenuItem;
53
+ static ɵfac: i0.ɵɵFactoryDeclaration<CmsMenuHelper, never>;
54
+ static ɵprov: i0.ɵɵInjectableDeclaration<CmsMenuHelper>;
55
+ }
56
+ /**
57
+ * Menu item compatible with tgm-manager-ui CoreMenuItem.
58
+ */
59
+ export interface CmsMenuItem {
60
+ id: string;
61
+ title: string;
62
+ type: 'item' | 'section' | 'collapsible';
63
+ icon?: string;
64
+ url?: string;
65
+ role?: string[];
66
+ translate?: string;
67
+ hidden?: boolean;
68
+ disabled?: boolean;
69
+ availableOnMobileNative?: boolean;
70
+ mobileOnly?: boolean;
71
+ badge?: {
72
+ title?: string;
73
+ translate?: string;
74
+ classes?: string;
75
+ };
76
+ children?: CmsMenuItem[];
77
+ /** Internal: target menu section id */
78
+ _menuSection?: string;
79
+ }
80
+ /**
81
+ * Complete menu section ready for sidebar injection.
82
+ */
83
+ export interface CmsMenuSection extends CmsMenuItem {
84
+ children: CmsMenuItem[];
85
+ }
@@ -0,0 +1,83 @@
1
+ import { Observable } from 'rxjs';
2
+ import { TgmHttpClient } from '../../core/http-client.service';
3
+ import { ContentTypeSchema, CmsSavedView, CmsValidationRule, CmsRecordType, CmsPageLayout, CmsDataResponse } from '../../models/api/cms.models';
4
+ import * as i0 from "@angular/core";
5
+ export declare class CmsContentTypeService {
6
+ private http;
7
+ private basePath;
8
+ constructor(http: TgmHttpClient);
9
+ getAll(): Observable<ContentTypeSchema[]>;
10
+ get(collectionName: string): Observable<ContentTypeSchema>;
11
+ getCount(): Observable<{
12
+ count: number;
13
+ }>;
14
+ create(schema: Partial<ContentTypeSchema> & {
15
+ collectionName: string;
16
+ attributes: Record<string, any>;
17
+ }): Observable<any>;
18
+ delete(collectionName: string): Observable<any>;
19
+ syncMigrations(): Observable<any>;
20
+ static ɵfac: i0.ɵɵFactoryDeclaration<CmsContentTypeService, never>;
21
+ static ɵprov: i0.ɵɵInjectableDeclaration<CmsContentTypeService>;
22
+ }
23
+ export declare class CmsDataService {
24
+ private http;
25
+ private basePath;
26
+ constructor(http: TgmHttpClient);
27
+ list(collectionName: string, params?: {
28
+ page?: number;
29
+ pageSize?: number;
30
+ sort?: string;
31
+ order?: string;
32
+ }): Observable<CmsDataResponse<any[]>>;
33
+ get(collectionName: string, id: number): Observable<CmsDataResponse>;
34
+ create(collectionName: string, data: Record<string, any>): Observable<CmsDataResponse>;
35
+ update(collectionName: string, id: number, data: Record<string, any>): Observable<CmsDataResponse>;
36
+ delete(collectionName: string, id: number): Observable<any>;
37
+ bulkDelete(collectionName: string, ids: number[]): Observable<any>;
38
+ count(collectionName: string): Observable<{
39
+ count: number;
40
+ }>;
41
+ search(collectionName: string, filters: Record<string, any>, params?: {
42
+ page?: number;
43
+ pageSize?: number;
44
+ sort?: string;
45
+ order?: string;
46
+ }): Observable<CmsDataResponse<any[]>>;
47
+ publish(collectionName: string, id: number): Observable<CmsDataResponse>;
48
+ unpublish(collectionName: string, id: number): Observable<CmsDataResponse>;
49
+ exportCsv(collectionName: string, columns?: string[]): Observable<string>;
50
+ listViews(collectionName: string): Observable<CmsDataResponse<CmsSavedView[]>>;
51
+ createView(collectionName: string, view: Partial<CmsSavedView>): Observable<CmsDataResponse<CmsSavedView>>;
52
+ updateView(collectionName: string, viewId: number, update: Partial<CmsSavedView>): Observable<CmsDataResponse<CmsSavedView>>;
53
+ deleteView(collectionName: string, viewId: number): Observable<any>;
54
+ listValidationRules(collectionName: string, activeOnly?: boolean): Observable<CmsDataResponse<CmsValidationRule[]>>;
55
+ createValidationRule(collectionName: string, rule: Partial<CmsValidationRule>): Observable<CmsDataResponse<CmsValidationRule>>;
56
+ updateValidationRule(collectionName: string, ruleId: number, update: Partial<CmsValidationRule>): Observable<CmsDataResponse<CmsValidationRule>>;
57
+ deleteValidationRule(collectionName: string, ruleId: number): Observable<any>;
58
+ listRecordTypes(collectionName: string, activeOnly?: boolean): Observable<CmsDataResponse<CmsRecordType[]>>;
59
+ createRecordType(collectionName: string, recordType: Partial<CmsRecordType>): Observable<CmsDataResponse<CmsRecordType>>;
60
+ updateRecordType(collectionName: string, typeId: number, update: Partial<CmsRecordType>): Observable<CmsDataResponse<CmsRecordType>>;
61
+ deleteRecordType(collectionName: string, typeId: number): Observable<any>;
62
+ listLayouts(collectionName: string): Observable<CmsDataResponse<CmsPageLayout[]>>;
63
+ createLayout(collectionName: string, layout: Partial<CmsPageLayout>): Observable<CmsDataResponse<CmsPageLayout>>;
64
+ updateLayout(collectionName: string, layoutId: number, update: Partial<CmsPageLayout>): Observable<CmsDataResponse<CmsPageLayout>>;
65
+ deleteLayout(collectionName: string, layoutId: number): Observable<any>;
66
+ listFormulas(collectionName: string, activeOnly?: boolean): Observable<CmsDataResponse<any[]>>;
67
+ createFormula(collectionName: string, formula: any): Observable<CmsDataResponse<any>>;
68
+ updateFormula(collectionName: string, formulaId: number, update: any): Observable<CmsDataResponse<any>>;
69
+ deleteFormula(collectionName: string, formulaId: number): Observable<any>;
70
+ listWorkflows(collectionName: string, activeOnly?: boolean): Observable<CmsDataResponse<any[]>>;
71
+ createWorkflow(collectionName: string, workflow: any): Observable<CmsDataResponse<any>>;
72
+ updateWorkflow(collectionName: string, workflowId: number, update: any): Observable<CmsDataResponse<any>>;
73
+ deleteWorkflow(collectionName: string, workflowId: number): Observable<any>;
74
+ listApprovalProcesses(collectionName: string): Observable<CmsDataResponse<any[]>>;
75
+ createApprovalProcess(collectionName: string, process: any): Observable<CmsDataResponse<any>>;
76
+ deleteApprovalProcess(collectionName: string, processId: number): Observable<any>;
77
+ getApprovalStatus(collectionName: string, recordId: number): Observable<CmsDataResponse<any[]>>;
78
+ submitForApproval(collectionName: string, recordId: number, processId: number): Observable<CmsDataResponse<any>>;
79
+ approvalAction(collectionName: string, instanceId: number, action: 'APPROVE' | 'REJECT', comment?: string): Observable<CmsDataResponse<any>>;
80
+ rollup(collectionName: string, targetCollection: string, fkField: string, parentId: number, fn?: string, aggregateField?: string): Observable<any>;
81
+ static ɵfac: i0.ɵɵFactoryDeclaration<CmsDataService, never>;
82
+ static ɵprov: i0.ɵɵInjectableDeclaration<CmsDataService>;
83
+ }
@@ -99,3 +99,5 @@ export { ScheduledReportService } from './scheduled-report.service';
99
99
  export { EntityCommentService } from './entity-comment.service';
100
100
  export { AuditEntryService } from './audit-entry.service';
101
101
  export { ThresholdAlertRuleService } from './threshold-alert-rule.service';
102
+ export { CmsContentTypeService, CmsDataService } from './cms.service';
103
+ export { CmsMenuHelper, CmsMenuItem, CmsMenuSection } from './cms-menu.helper';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@en-solutions/tgm-client-sdk",
3
- "version": "1.7.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": {
@@ -8,8 +8,7 @@
8
8
  "url": "https://github.com/EN-Solutions/tgm-client-sdk.git"
9
9
  },
10
10
  "publishConfig": {
11
- "registry": "https://registry.npmjs.org",
12
- "access": "public"
11
+ "registry": "https://npm.pkg.github.com"
13
12
  },
14
13
  "peerDependencies": {
15
14
  "@angular/common": "^18.0.0",