@masterteam/governance 0.0.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.
@@ -0,0 +1,443 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { OnDestroy, TemplateRef, OnInit } from '@angular/core';
3
+ import { TableAction, ColumnDef, CellChangeEvent } from '@masterteam/components/table';
4
+ import { ModalService } from '@masterteam/components/modal';
5
+ import * as _masterteam_governance from '@masterteam/governance';
6
+ import { FormControl } from '@angular/forms';
7
+ import { ModalRef } from '@masterteam/components/dialog';
8
+ import * as _masterteam_components from '@masterteam/components';
9
+ import { CrudStateBase, DynamicFormConfig } from '@masterteam/components';
10
+ import * as rxjs from 'rxjs';
11
+ import { StateContext } from '@ngxs/store';
12
+
13
+ interface LoadingStateShape<L extends string = string> {
14
+ loadingActive: L[];
15
+ errors: Partial<Record<L, string>>;
16
+ }
17
+
18
+ interface Translatable {
19
+ en: string;
20
+ ar: string;
21
+ }
22
+ declare enum GovernanceRuleTypeEnum {
23
+ ModuleExists = 1,
24
+ ModuleDoesNotExist = 2,
25
+ ModuleMaxCount = 3,
26
+ ModuleMinCount = 4,
27
+ FieldRequired = 5,
28
+ FieldValue = 6,
29
+ PhaseGateModuleRequired = 7,
30
+ NoActiveRequest = 8
31
+ }
32
+ /**
33
+ * Option for select/multi-select fields
34
+ */
35
+ interface ConfigurationFieldOption {
36
+ label: string;
37
+ value: string;
38
+ }
39
+ /**
40
+ * Options source indicator for select fields
41
+ * - 'auto-populated': Options already in response (modules, phase gates, statuses)
42
+ * - 'static': Hardcoded options in response
43
+ * - 'requestSchema': Fetch from request schema endpoint
44
+ * - 'properties': Fetch from properties endpoint
45
+ * - null/undefined: No options needed (text/number fields)
46
+ */
47
+ type OptionsSource = 'auto-populated' | 'static' | 'requestSchema' | 'properties' | null;
48
+ /**
49
+ * Configuration field schema - now array-based with key property
50
+ */
51
+ interface ConfigurationFieldSchema {
52
+ key: string;
53
+ type: 'text' | 'textarea' | 'number' | 'select' | 'multi-select' | 'checkbox' | 'date';
54
+ label: Translatable;
55
+ required?: boolean;
56
+ defaultValue?: any;
57
+ min?: number;
58
+ max?: number;
59
+ options?: ConfigurationFieldOption[];
60
+ optionsSource?: OptionsSource;
61
+ colSpan?: number;
62
+ }
63
+ interface GovernanceRuleType {
64
+ type: string;
65
+ key: string;
66
+ name: Translatable;
67
+ description: Translatable;
68
+ supportedScopes: string[];
69
+ supportedOperations: string[];
70
+ configurationSchema: ConfigurationFieldSchema[];
71
+ }
72
+ interface GovernanceRule {
73
+ id: number;
74
+ key: string;
75
+ name: Translatable;
76
+ description?: Translatable;
77
+ errorMessage: Translatable;
78
+ ruleType: GovernanceRuleTypeEnum;
79
+ ruleTypeKey: string;
80
+ targetScope: string;
81
+ targetModuleKey?: string;
82
+ targetOperationKey?: string;
83
+ levelId: number;
84
+ configuration: Record<string, any>;
85
+ priority: number;
86
+ isActive: boolean;
87
+ stopOnFailure: boolean;
88
+ createdAt: string;
89
+ createdBy?: string;
90
+ modifiedAt?: string;
91
+ modifiedBy?: string;
92
+ }
93
+ interface CreateGovernanceRuleDto {
94
+ key: string;
95
+ name: Record<string, string>;
96
+ description?: Record<string, string>;
97
+ errorMessage: Record<string, string>;
98
+ ruleType: string;
99
+ targetScope: string;
100
+ targetModuleKey?: string;
101
+ targetOperationKey?: string;
102
+ configuration?: Record<string, any>;
103
+ priority: number;
104
+ stopOnFailure: boolean;
105
+ }
106
+ interface UpdateGovernanceRuleDto extends CreateGovernanceRuleDto {
107
+ isActive: boolean;
108
+ }
109
+ interface GovernanceViolation {
110
+ ruleKey: string;
111
+ message: string;
112
+ details?: any;
113
+ }
114
+ interface GovernanceViolationError {
115
+ type: 'GovernanceViolation';
116
+ title: string;
117
+ status: 403;
118
+ violations: GovernanceViolation[];
119
+ }
120
+ interface GovernanceModule {
121
+ id: string;
122
+ key: string;
123
+ name: Translatable;
124
+ isActive: boolean;
125
+ }
126
+ declare enum GovernanceActionKey {
127
+ GetRules = "getRules",
128
+ GetRule = "getRule",
129
+ GetRuleTypes = "getRuleTypes",
130
+ AddRule = "addRule",
131
+ UpdateRule = "updateRule",
132
+ DeleteRule = "deleteRule",
133
+ ToggleRuleActive = "toggleRuleActive",
134
+ GetModules = "getModules",
135
+ GetRequestSchemas = "getRequestSchemas",
136
+ GetProperties = "getProperties"
137
+ }
138
+ interface GovernanceRequestSchema {
139
+ id: number;
140
+ name: Translatable;
141
+ isPublished: boolean;
142
+ }
143
+ interface GovernanceProperty {
144
+ id: number;
145
+ key: string;
146
+ name: Translatable;
147
+ }
148
+ interface GovernanceStateModel extends LoadingStateShape<GovernanceActionKey> {
149
+ levelId: number | null;
150
+ rules: GovernanceRule[];
151
+ ruleTypes: GovernanceRuleType[];
152
+ selectedRule: GovernanceRule | null;
153
+ modules: GovernanceModule[];
154
+ requestSchemas: GovernanceRequestSchema[];
155
+ properties: GovernanceProperty[];
156
+ }
157
+
158
+ declare class SetLevelId {
159
+ levelId: number;
160
+ static readonly type = "[Governance] Set Level ID";
161
+ constructor(levelId: number);
162
+ }
163
+ declare class GetGovernanceRules {
164
+ static readonly type = "[Governance] Get Rules";
165
+ }
166
+ declare class GetGovernanceRule {
167
+ id: number;
168
+ static readonly type = "[Governance] Get Rule";
169
+ constructor(id: number);
170
+ }
171
+ declare class GetGovernanceRuleTypes {
172
+ static readonly type = "[Governance] Get Rule Types";
173
+ }
174
+ declare class AddGovernanceRule {
175
+ rule: CreateGovernanceRuleDto;
176
+ static readonly type = "[Governance] Add Rule";
177
+ constructor(rule: CreateGovernanceRuleDto);
178
+ }
179
+ declare class UpdateGovernanceRule {
180
+ id: number;
181
+ rule: UpdateGovernanceRuleDto;
182
+ static readonly type = "[Governance] Update Rule";
183
+ constructor(id: number, rule: UpdateGovernanceRuleDto);
184
+ }
185
+ declare class DeleteGovernanceRule {
186
+ id: number;
187
+ static readonly type = "[Governance] Delete Rule";
188
+ constructor(id: number);
189
+ }
190
+ declare class ToggleGovernanceRuleActive {
191
+ id: number;
192
+ static readonly type = "[Governance] Toggle Rule Active";
193
+ constructor(id: number);
194
+ }
195
+ declare class ClearSelectedRule {
196
+ static readonly type = "[Governance] Clear Selected Rule";
197
+ }
198
+ declare class ResetGovernanceState {
199
+ static readonly type = "[Governance] Reset State";
200
+ }
201
+ declare class GetModules {
202
+ static readonly type = "[Governance] Get Modules";
203
+ }
204
+ /**
205
+ * Get request schemas for a specific scope
206
+ * @param targetScope - 'Level' or 'Module'
207
+ * @param targetModuleKey - Required if scope is 'Module'
208
+ */
209
+ declare class GetRequestSchemas {
210
+ targetScope: string;
211
+ targetModuleKey?: string | undefined;
212
+ static readonly type = "[Governance] Get Request Schemas";
213
+ constructor(targetScope: string, targetModuleKey?: string | undefined);
214
+ }
215
+ /**
216
+ * Get properties for a specific scope
217
+ * @param targetScope - 'Level' or 'Module'
218
+ * @param targetModuleKey - Required if scope is 'Module'
219
+ */
220
+ declare class GetProperties {
221
+ targetScope: string;
222
+ targetModuleKey?: string | undefined;
223
+ static readonly type = "[Governance] Get Properties";
224
+ constructor(targetScope: string, targetModuleKey?: string | undefined);
225
+ }
226
+ /**
227
+ * Clear request schemas (when scope/module changes)
228
+ */
229
+ declare class ClearRequestSchemas {
230
+ static readonly type = "[Governance] Clear Request Schemas";
231
+ }
232
+ /**
233
+ * Clear properties (when scope/module changes)
234
+ */
235
+ declare class ClearProperties {
236
+ static readonly type = "[Governance] Clear Properties";
237
+ }
238
+
239
+ declare class GovernanceFacade {
240
+ private readonly store;
241
+ readonly levelId: _angular_core.Signal<number | null>;
242
+ readonly rules: _angular_core.Signal<_masterteam_governance.GovernanceRule[]>;
243
+ readonly ruleTypes: _angular_core.Signal<_masterteam_governance.GovernanceRuleType[]>;
244
+ readonly selectedRule: _angular_core.Signal<_masterteam_governance.GovernanceRule | null>;
245
+ readonly modules: _angular_core.Signal<_masterteam_governance.GovernanceModule[]>;
246
+ readonly requestSchemas: _angular_core.Signal<_masterteam_governance.GovernanceRequestSchema[]>;
247
+ readonly properties: _angular_core.Signal<_masterteam_governance.GovernanceProperty[]>;
248
+ private readonly loadingActive;
249
+ private readonly errors;
250
+ readonly isLoadingRules: _angular_core.Signal<boolean>;
251
+ readonly isLoadingRule: _angular_core.Signal<boolean>;
252
+ readonly isLoadingRuleTypes: _angular_core.Signal<boolean>;
253
+ readonly isAddingRule: _angular_core.Signal<boolean>;
254
+ readonly isUpdatingRule: _angular_core.Signal<boolean>;
255
+ readonly isDeletingRule: _angular_core.Signal<boolean>;
256
+ readonly isTogglingRule: _angular_core.Signal<boolean>;
257
+ readonly isLoadingModules: _angular_core.Signal<boolean>;
258
+ readonly isLoadingRequestSchemas: _angular_core.Signal<boolean>;
259
+ readonly isLoadingProperties: _angular_core.Signal<boolean>;
260
+ readonly rulesError: _angular_core.Signal<string | null>;
261
+ readonly ruleError: _angular_core.Signal<string | null>;
262
+ readonly ruleTypesError: _angular_core.Signal<string | null>;
263
+ readonly addRuleError: _angular_core.Signal<string | null>;
264
+ readonly updateRuleError: _angular_core.Signal<string | null>;
265
+ readonly deleteRuleError: _angular_core.Signal<string | null>;
266
+ readonly modulesError: _angular_core.Signal<string | null>;
267
+ readonly requestSchemasError: _angular_core.Signal<string | null>;
268
+ readonly propertiesError: _angular_core.Signal<string | null>;
269
+ readonly activeRules: _angular_core.Signal<_masterteam_governance.GovernanceRule[]>;
270
+ readonly inactiveRules: _angular_core.Signal<_masterteam_governance.GovernanceRule[]>;
271
+ readonly rulesCount: _angular_core.Signal<number>;
272
+ setLevelId(levelId: number): rxjs.Observable<void>;
273
+ getRules(): rxjs.Observable<void>;
274
+ getRule(id: number): rxjs.Observable<void>;
275
+ getRuleTypes(): rxjs.Observable<void>;
276
+ getModules(): rxjs.Observable<void>;
277
+ addRule(rule: CreateGovernanceRuleDto): rxjs.Observable<void>;
278
+ updateRule(id: number, rule: UpdateGovernanceRuleDto): rxjs.Observable<void>;
279
+ deleteRule(id: number): rxjs.Observable<void>;
280
+ toggleRuleActive(id: number): rxjs.Observable<void>;
281
+ clearSelectedRule(): rxjs.Observable<void>;
282
+ resetState(): rxjs.Observable<void>;
283
+ getRequestSchemas(targetScope: string, targetModuleKey?: string): rxjs.Observable<void>;
284
+ getProperties(targetScope: string, targetModuleKey?: string): rxjs.Observable<void>;
285
+ clearRequestSchemas(): rxjs.Observable<void>;
286
+ clearProperties(): rxjs.Observable<void>;
287
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<GovernanceFacade, never>;
288
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<GovernanceFacade>;
289
+ }
290
+
291
+ interface Response<T> {
292
+ endpoint: string;
293
+ status: number;
294
+ code: number;
295
+ locale: string;
296
+ message?: string | null;
297
+ errors?: any | null;
298
+ data: T;
299
+ cacheSession?: string;
300
+ }
301
+
302
+ declare class GovernanceState extends CrudStateBase<GovernanceRule, GovernanceStateModel, GovernanceActionKey> {
303
+ private http;
304
+ static getLevelId(state: GovernanceStateModel): number | null;
305
+ static getRules(state: GovernanceStateModel): GovernanceRule[];
306
+ static getRuleTypes(state: GovernanceStateModel): GovernanceRuleType[];
307
+ static getSelectedRule(state: GovernanceStateModel): GovernanceRule | null;
308
+ static getModules(state: GovernanceStateModel): GovernanceModule[];
309
+ static getRequestSchemas(state: GovernanceStateModel): GovernanceRequestSchema[];
310
+ static getProperties(state: GovernanceStateModel): GovernanceProperty[];
311
+ static getLoadingActive(state: GovernanceStateModel): string[];
312
+ static getErrors(state: GovernanceStateModel): Record<string, string | null>;
313
+ setLevelId(ctx: StateContext<GovernanceStateModel>, { levelId }: SetLevelId): void;
314
+ resetState(ctx: StateContext<GovernanceStateModel>): void;
315
+ getRules(ctx: StateContext<GovernanceStateModel>): rxjs.Observable<Response<GovernanceRule[]>> | undefined;
316
+ getRule(ctx: StateContext<GovernanceStateModel>, { id }: GetGovernanceRule): rxjs.Observable<Response<GovernanceRule>> | undefined;
317
+ getRuleTypes(ctx: StateContext<GovernanceStateModel>): rxjs.Observable<Response<GovernanceRuleType[]>>;
318
+ addRule(ctx: StateContext<GovernanceStateModel>, { rule }: AddGovernanceRule): rxjs.Observable<_masterteam_components.Response<GovernanceRule>> | undefined;
319
+ updateRule(ctx: StateContext<GovernanceStateModel>, { id, rule }: UpdateGovernanceRule): rxjs.Observable<_masterteam_components.Response<GovernanceRule>> | undefined;
320
+ deleteRule(ctx: StateContext<GovernanceStateModel>, { id }: DeleteGovernanceRule): rxjs.Observable<_masterteam_components.Response<void>> | undefined;
321
+ toggleRuleActive(ctx: StateContext<GovernanceStateModel>, { id }: ToggleGovernanceRuleActive): rxjs.Observable<Response<GovernanceRule>> | undefined;
322
+ getModules(ctx: StateContext<GovernanceStateModel>): rxjs.Observable<Response<GovernanceModule[]>> | undefined;
323
+ clearSelectedRule(ctx: StateContext<GovernanceStateModel>): void;
324
+ getRequestSchemas(ctx: StateContext<GovernanceStateModel>, { targetScope, targetModuleKey }: GetRequestSchemas): rxjs.Observable<Response<GovernanceRequestSchema[]>> | undefined;
325
+ getProperties(ctx: StateContext<GovernanceStateModel>, { targetScope, targetModuleKey }: GetProperties): rxjs.Observable<Response<GovernanceProperty[]>> | undefined;
326
+ clearRequestSchemas(ctx: StateContext<GovernanceStateModel>): void;
327
+ clearProperties(ctx: StateContext<GovernanceStateModel>): void;
328
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<GovernanceState, never>;
329
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<GovernanceState>;
330
+ }
331
+
332
+ declare class GovernanceRulesList implements OnDestroy {
333
+ levelId: _angular_core.InputSignal<number>;
334
+ typeCol: _angular_core.Signal<TemplateRef<any>>;
335
+ scopeCol: _angular_core.Signal<TemplateRef<any>>;
336
+ priorityCol: _angular_core.Signal<TemplateRef<any>>;
337
+ private readonly facade;
338
+ readonly modal: ModalService;
339
+ private readonly translocoService;
340
+ breadcrumbItems: _angular_core.WritableSignal<({
341
+ label: string;
342
+ icon: string;
343
+ routerLink: string;
344
+ } | {
345
+ label: string;
346
+ routerLink: string;
347
+ icon?: undefined;
348
+ } | {
349
+ label: string;
350
+ icon?: undefined;
351
+ routerLink?: undefined;
352
+ })[]>;
353
+ rules: _angular_core.Signal<GovernanceRule[]>;
354
+ tabs: _angular_core.WritableSignal<{
355
+ label: string;
356
+ value: string;
357
+ }[]>;
358
+ activeTab: _angular_core.WritableSignal<string>;
359
+ tableActions: _angular_core.WritableSignal<TableAction[]>;
360
+ deletingRowIds: _angular_core.WritableSignal<any[]>;
361
+ rowActions: _angular_core.WritableSignal<TableAction[]>;
362
+ tableColumns: _angular_core.WritableSignal<ColumnDef[]>;
363
+ loading: _angular_core.Signal<boolean>;
364
+ private allRules;
365
+ private activeRules;
366
+ private inactiveRules;
367
+ ngOnDestroy(): void;
368
+ openRuleDialog(rule?: GovernanceRule | null): void;
369
+ onCellChange(event: CellChangeEvent): void;
370
+ private getRuleTypeOptions;
371
+ getRuleTypeChipClass(ruleTypeKey: string): string;
372
+ getScopeIcon(scope: string): string;
373
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<GovernanceRulesList, never>;
374
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<GovernanceRulesList, "mt-governance-rules-list", never, { "levelId": { "alias": "levelId"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
375
+ }
376
+
377
+ declare class GovernanceRuleForm implements OnInit {
378
+ modal: ModalService;
379
+ ref: ModalRef;
380
+ private readonly translocoService;
381
+ private readonly facade;
382
+ ruleForEdit: _angular_core.InputSignal<GovernanceRule | null>;
383
+ selectedRule: _angular_core.Signal<GovernanceRule | null>;
384
+ ruleTypes: _angular_core.Signal<GovernanceRuleType[]>;
385
+ isLoadingRule: _angular_core.Signal<boolean>;
386
+ isAddingRule: _angular_core.Signal<boolean>;
387
+ isUpdatingRule: _angular_core.Signal<boolean>;
388
+ modules: _angular_core.Signal<_masterteam_governance.GovernanceModule[]>;
389
+ requestSchemas: _angular_core.Signal<_masterteam_governance.GovernanceRequestSchema[]>;
390
+ properties: _angular_core.Signal<_masterteam_governance.GovernanceProperty[]>;
391
+ isLoadingRequestSchemas: _angular_core.Signal<boolean>;
392
+ isLoadingProperties: _angular_core.Signal<boolean>;
393
+ ruleFormControl: FormControl<any>;
394
+ formValue: _angular_core.Signal<any>;
395
+ selectedRuleType: _angular_core.Signal<GovernanceRuleType | null>;
396
+ targetScope: _angular_core.Signal<any>;
397
+ targetModuleKey: _angular_core.Signal<any>;
398
+ requestSchemaOptions: _angular_core.Signal<ConfigurationFieldOption[]>;
399
+ propertyOptions: _angular_core.Signal<ConfigurationFieldOption[]>;
400
+ moduleOptions: _angular_core.Signal<ConfigurationFieldOption[]>;
401
+ scopeOptions: _angular_core.Signal<{
402
+ label: string;
403
+ value: string;
404
+ }[]>;
405
+ operationOptions: _angular_core.Signal<{
406
+ label: string;
407
+ value: string;
408
+ }[]>;
409
+ ruleTypeOptions: _angular_core.Signal<{
410
+ label: string;
411
+ value: string;
412
+ }[]>;
413
+ formConfig: _angular_core.Signal<DynamicFormConfig>;
414
+ constructor();
415
+ /**
416
+ * Extract default values from rule type's configuration schema
417
+ */
418
+ private getDefaultsFromSchema;
419
+ ngOnInit(): void;
420
+ onSubmit(): void;
421
+ private buildConfigurationSection;
422
+ private buildConfigFieldsForType;
423
+ /**
424
+ * Convert a ConfigurationFieldSchema to DynamicForm BaseFieldConfig
425
+ */
426
+ private schemaFieldToFormField;
427
+ /**
428
+ * Get options for a field based on its optionsSource
429
+ * - 'static' or 'auto-populated': Use options from schema (already in API response)
430
+ * - 'requestSchema': Use fetched request schemas from state
431
+ * - 'properties': Use fetched properties from state
432
+ */
433
+ private getOptionsForField;
434
+ private unpackRuleToForm;
435
+ private packFormToCreateDto;
436
+ private packFormToUpdateDto;
437
+ private extractConfiguration;
438
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<GovernanceRuleForm, never>;
439
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<GovernanceRuleForm, "mt-governance-rule-form", never, { "ruleForEdit": { "alias": "ruleForEdit"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
440
+ }
441
+
442
+ export { AddGovernanceRule, ClearProperties, ClearRequestSchemas, ClearSelectedRule, DeleteGovernanceRule, GetGovernanceRule, GetGovernanceRuleTypes, GetGovernanceRules, GetModules, GetProperties, GetRequestSchemas, GovernanceActionKey, GovernanceFacade, GovernanceRuleForm, GovernanceRuleTypeEnum, GovernanceRulesList, GovernanceState, ResetGovernanceState, SetLevelId, ToggleGovernanceRuleActive, UpdateGovernanceRule };
443
+ export type { ConfigurationFieldOption, ConfigurationFieldSchema, CreateGovernanceRuleDto, GovernanceModule, GovernanceProperty, GovernanceRequestSchema, GovernanceRule, GovernanceRuleType, GovernanceStateModel, GovernanceViolation, GovernanceViolationError, OptionsSource, Translatable, UpdateGovernanceRuleDto };