@expeed/ngx-data-mapper 1.0.0 → 1.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expeed/ngx-data-mapper",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Visual data mapping components for Angular - drag-and-drop field mapping with transformations, schema editor with JSON Schema export",
5
5
  "keywords": [
6
6
  "angular",
@@ -1,5 +1,6 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { AfterViewInit, OnDestroy, EventEmitter, ElementRef, QueryList, OnInit, OnChanges, SimpleChanges } from '@angular/core';
3
+ import { CdkDragDrop } from '@angular/cdk/drag-drop';
3
4
 
4
5
  interface SchemaField {
5
6
  id: string;
@@ -12,11 +13,15 @@ interface SchemaField {
12
13
  isArrayItem?: boolean;
13
14
  parentArrayPath?: string;
14
15
  }
15
- interface JsonSchema {
16
+ interface SchemaDefinition {
16
17
  name: string;
17
18
  fields: SchemaField[];
18
19
  }
19
- type TransformationType = 'direct' | 'concat' | 'substring' | 'replace' | 'uppercase' | 'lowercase' | 'dateFormat' | 'extractYear' | 'extractMonth' | 'extractDay' | 'extractHour' | 'extractMinute' | 'extractSecond' | 'numberFormat' | 'template' | 'custom';
20
+ type TransformationType = 'direct' | 'concat' | 'substring' | 'replace' | 'uppercase' | 'lowercase' | 'trim' | 'mask' | 'dateFormat' | 'extractYear' | 'extractMonth' | 'extractDay' | 'extractHour' | 'extractMinute' | 'extractSecond' | 'numberFormat' | 'template';
21
+ interface TransformationCondition {
22
+ enabled: boolean;
23
+ root: FilterGroup;
24
+ }
20
25
  interface TransformationConfig {
21
26
  type: TransformationType;
22
27
  separator?: string;
@@ -30,13 +35,14 @@ interface TransformationConfig {
30
35
  decimalPlaces?: number;
31
36
  prefix?: string;
32
37
  suffix?: string;
33
- expression?: string;
38
+ pattern?: string;
39
+ condition?: TransformationCondition;
34
40
  }
35
41
  interface FieldMapping {
36
42
  id: string;
37
43
  sourceFields: SchemaField[];
38
44
  targetField: SchemaField;
39
- transformation: TransformationConfig;
45
+ transformations: TransformationConfig[];
40
46
  isArrayMapping?: boolean;
41
47
  arrayMappingId?: string;
42
48
  isArrayToObjectMapping?: boolean;
@@ -93,7 +99,7 @@ interface Connection {
93
99
  mappingId: string;
94
100
  sourcePoints: ConnectionPoint[];
95
101
  targetPoint: ConnectionPoint;
96
- transformation: TransformationConfig;
102
+ transformations: TransformationConfig[];
97
103
  }
98
104
  interface DragState {
99
105
  isDragging: boolean;
@@ -114,6 +120,78 @@ interface DefaultValue {
114
120
  valueType: 'string' | 'number' | 'boolean' | 'date';
115
121
  }
116
122
 
123
+ /**
124
+ * Standard JSON Schema (draft-07) TypeScript interfaces
125
+ */
126
+ interface JsonSchema {
127
+ $schema?: string;
128
+ $id?: string;
129
+ title?: string;
130
+ description?: string;
131
+ type?: JsonSchemaType | JsonSchemaType[];
132
+ properties?: Record<string, JsonSchema>;
133
+ items?: JsonSchema;
134
+ required?: string[];
135
+ enum?: (string | number | boolean | null)[];
136
+ const?: unknown;
137
+ default?: unknown;
138
+ minLength?: number;
139
+ maxLength?: number;
140
+ pattern?: string;
141
+ format?: string;
142
+ minimum?: number;
143
+ maximum?: number;
144
+ exclusiveMinimum?: number;
145
+ exclusiveMaximum?: number;
146
+ multipleOf?: number;
147
+ minItems?: number;
148
+ maxItems?: number;
149
+ uniqueItems?: boolean;
150
+ minProperties?: number;
151
+ maxProperties?: number;
152
+ additionalProperties?: boolean | JsonSchema;
153
+ allOf?: JsonSchema[];
154
+ anyOf?: JsonSchema[];
155
+ oneOf?: JsonSchema[];
156
+ not?: JsonSchema;
157
+ $ref?: string;
158
+ definitions?: Record<string, JsonSchema>;
159
+ }
160
+ type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
161
+ /**
162
+ * Helper type for working with JSON schemas in the UI
163
+ */
164
+ interface JsonSchemaField {
165
+ name: string;
166
+ path: string;
167
+ schema: JsonSchema;
168
+ children?: JsonSchemaField[];
169
+ expanded?: boolean;
170
+ }
171
+ /**
172
+ * Convert JSON Schema to flat field list for UI rendering
173
+ */
174
+ declare function schemaToFields(schema: JsonSchema, parentPath?: string): JsonSchemaField[];
175
+ /**
176
+ * Get the simple type for display purposes
177
+ */
178
+ declare function getSchemaType(schema: JsonSchema): string;
179
+ /**
180
+ * Create an empty JSON Schema for a new schema definition
181
+ */
182
+ declare function createEmptySchema(title?: string): JsonSchema;
183
+ /**
184
+ * Add a property to a schema
185
+ */
186
+ declare function addProperty(schema: JsonSchema, name: string, type: JsonSchemaType, options?: {
187
+ description?: string;
188
+ required?: boolean;
189
+ }): JsonSchema;
190
+ /**
191
+ * Remove a property from a schema
192
+ */
193
+ declare function removeProperty(schema: JsonSchema, name: string): JsonSchema;
194
+
117
195
  declare class MappingService {
118
196
  private mappings;
119
197
  private arrayMappings;
@@ -150,7 +228,7 @@ declare class MappingService {
150
228
  updateArrayToObjectSelector(mappingId: string, selector: ArraySelectorConfig): void;
151
229
  removeArrayToObjectMapping(mappingId: string): void;
152
230
  updateMapping(mappingId: string, updates: Partial<FieldMapping>): void;
153
- updateTransformation(mappingId: string, transformation: TransformationConfig): void;
231
+ updateTransformations(mappingId: string, transformations: TransformationConfig[]): void;
154
232
  removeMapping(mappingId: string): void;
155
233
  removeSourceFromMapping(mappingId: string, sourceFieldId: string): void;
156
234
  selectMapping(mappingId: string | null): void;
@@ -162,7 +240,11 @@ declare class MappingService {
162
240
  removeDefaultValue(targetFieldId: string): void;
163
241
  hasDefaultValue(targetFieldId: string): boolean;
164
242
  private getValueType;
165
- exportMappings(): string;
243
+ exportMappings(name?: string, description?: string): string;
244
+ /**
245
+ * Export mappings as a MappingDocument object (not stringified)
246
+ */
247
+ exportMappingsAsObject(name?: string, description?: string): object;
166
248
  importMappings(json: string): void;
167
249
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<MappingService, never>;
168
250
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<MappingService>;
@@ -170,18 +252,34 @@ declare class MappingService {
170
252
 
171
253
  declare class TransformationService {
172
254
  applyTransformation(sourceValues: Record<string, unknown>, sourceFields: SchemaField[], config: TransformationConfig): string;
255
+ /**
256
+ * Apply a transformation to a single value (for chained transformations)
257
+ */
258
+ applyTransformationToValue(value: unknown, config: TransformationConfig): string;
259
+ /**
260
+ * Apply multiple transformations in sequence, respecting conditions
261
+ */
262
+ applyTransformations(sourceValues: Record<string, unknown>, sourceFields: SchemaField[], transformations: TransformationConfig[]): string;
173
263
  private getValueByPath;
174
264
  private applyTemplate;
175
265
  private formatDate;
176
266
  private extractDatePart;
177
267
  private formatNumber;
178
- private applyCustomExpression;
268
+ private applyMask;
179
269
  getTransformationLabel(type: TransformationType): string;
180
270
  getAvailableTransformations(): {
181
271
  type: TransformationType;
182
272
  label: string;
183
273
  category?: string;
184
274
  }[];
275
+ evaluateCondition(value: unknown, condition: FilterGroup): boolean;
276
+ private evaluateGroup;
277
+ private evaluateItem;
278
+ private evaluateConditionItem;
279
+ /**
280
+ * Check if a transformation's condition is met
281
+ */
282
+ isConditionMet(value: unknown, config: TransformationConfig): boolean;
185
283
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<TransformationService, never>;
186
284
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<TransformationService>;
187
285
  }
@@ -215,37 +313,21 @@ declare class SvgConnectorService {
215
313
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<SvgConnectorService>;
216
314
  }
217
315
 
218
- interface JsonSchemaDefinition {
219
- type?: string;
220
- format?: string;
221
- properties?: Record<string, JsonSchemaDefinition>;
222
- items?: JsonSchemaDefinition;
316
+ interface SchemaDocument extends JsonSchema {
223
317
  $ref?: string;
224
- description?: string;
225
- enum?: string[];
226
- required?: string[];
227
- additionalProperties?: boolean | JsonSchemaDefinition;
228
- }
229
- interface SchemaDocument {
230
- $ref?: string;
231
- $defs?: Record<string, JsonSchemaDefinition>;
232
- definitions?: Record<string, JsonSchemaDefinition>;
318
+ $defs?: Record<string, JsonSchema>;
233
319
  exclude?: string[];
234
320
  include?: string[];
235
- properties?: Record<string, JsonSchemaDefinition>;
236
- type?: string;
237
- title?: string;
238
- description?: string;
239
321
  }
240
322
  interface ModelRegistry {
241
- [modelName: string]: JsonSchemaDefinition;
323
+ [modelName: string]: JsonSchema;
242
324
  }
243
325
  declare class SchemaParserService {
244
326
  private modelRegistry;
245
327
  private idCounter;
246
328
  registerModels(models: ModelRegistry): void;
247
329
  clearRegistry(): void;
248
- parseSchema(schemaJson: string | SchemaDocument, schemaName?: string): JsonSchema;
330
+ parseSchema(schemaJson: string | SchemaDocument, schemaName?: string): SchemaDefinition;
249
331
  private resolveRef;
250
332
  private buildFields;
251
333
  private buildField;
@@ -317,8 +399,8 @@ interface VisualConnection {
317
399
  hasFilter: boolean;
318
400
  }
319
401
  declare class DataMapperComponent implements AfterViewInit, OnDestroy {
320
- sourceSchema: JsonSchema;
321
- targetSchema: JsonSchema;
402
+ set sourceSchema(value: JsonSchema | SchemaDocument);
403
+ set targetSchema(value: JsonSchema | SchemaDocument);
322
404
  sampleData: Record<string, unknown>;
323
405
  mappingsChange: EventEmitter<FieldMapping[]>;
324
406
  svgContainer: ElementRef<HTMLDivElement>;
@@ -326,6 +408,11 @@ declare class DataMapperComponent implements AfterViewInit, OnDestroy {
326
408
  private mappingService;
327
409
  private svgConnectorService;
328
410
  private transformationService;
411
+ private schemaParserService;
412
+ private _sourceSchemaInput;
413
+ private _targetSchemaInput;
414
+ readonly sourceSchemaForTree: _angular_core.Signal<SchemaDefinition>;
415
+ readonly targetSchemaForTree: _angular_core.Signal<SchemaDefinition>;
329
416
  private sourcePositions;
330
417
  private targetPositions;
331
418
  connections: _angular_core.WritableSignal<VisualConnection[]>;
@@ -374,7 +461,7 @@ declare class DataMapperComponent implements AfterViewInit, OnDestroy {
374
461
  onDefaultValueDelete(): void;
375
462
  closeDefaultValuePopover(): void;
376
463
  getExistingDefaultValue(fieldId: string): DefaultValue | undefined;
377
- onPopoverSave(config: TransformationConfig): void;
464
+ onPopoverSave(transformations: TransformationConfig[]): void;
378
465
  onPopoverDelete(): void;
379
466
  closePopover(): void;
380
467
  private updateConnections;
@@ -399,14 +486,10 @@ interface EditorField {
399
486
  isEditing?: boolean;
400
487
  isEditingValues?: boolean;
401
488
  }
402
- interface SchemaDefinition {
403
- name: string;
404
- fields: EditorField[];
405
- }
406
489
  declare class SchemaEditorComponent {
407
- set schema(value: SchemaDefinition | null);
408
- schemaChange: EventEmitter<SchemaDefinition>;
409
- save: EventEmitter<SchemaDefinition>;
490
+ set schema(value: JsonSchema | null);
491
+ schemaChange: EventEmitter<JsonSchema>;
492
+ save: EventEmitter<JsonSchema>;
410
493
  schemaName: _angular_core.WritableSignal<string>;
411
494
  fields: _angular_core.WritableSignal<EditorField[]>;
412
495
  fieldTypes: Array<{
@@ -443,6 +526,9 @@ declare class SchemaEditorComponent {
443
526
  onSchemaNameChange(name: string, input?: HTMLInputElement): void;
444
527
  private emitChange;
445
528
  onSave(): void;
529
+ private jsonSchemaToEditorFields;
530
+ private jsonSchemaPropertyToEditorField;
531
+ private jsonSchemaTypeToEditorType;
446
532
  toJson(): string;
447
533
  toJsonSchema(): object;
448
534
  private fieldToJsonSchema;
@@ -459,13 +545,15 @@ declare class TransformationPopoverComponent implements OnInit, OnChanges {
459
545
  y: number;
460
546
  };
461
547
  sampleData: Record<string, unknown>;
462
- save: EventEmitter<TransformationConfig>;
548
+ save: EventEmitter<TransformationConfig[]>;
463
549
  delete: EventEmitter<void>;
464
550
  close: EventEmitter<void>;
465
551
  private transformationService;
466
- transformationType: TransformationType;
467
- config: TransformationConfig;
468
- preview: string;
552
+ steps: TransformationConfig[];
553
+ stepPreviews: string[];
554
+ stepInputs: string[];
555
+ finalPreview: string;
556
+ expandedStepIndex: number;
469
557
  availableTransformations: {
470
558
  type: TransformationType;
471
559
  label: string;
@@ -474,15 +562,30 @@ declare class TransformationPopoverComponent implements OnInit, OnChanges {
474
562
  ngOnInit(): void;
475
563
  ngOnChanges(changes: SimpleChanges): void;
476
564
  private initFromMapping;
477
- onTypeChange(): void;
565
+ get isMultiStep(): boolean;
566
+ onStepTypeChange(index: number): void;
478
567
  private getDefaultTemplate;
568
+ addStep(): void;
569
+ removeStep(index: number): void;
570
+ onStepDrop(event: CdkDragDrop<TransformationConfig[]>): void;
571
+ toggleStep(index: number): void;
572
+ isStepExpanded(index: number): boolean;
479
573
  updatePreview(): void;
574
+ private getValueByPath;
480
575
  onConfigChange(): void;
481
576
  onSave(): void;
482
577
  onDelete(): void;
483
578
  onClose(): void;
484
579
  getSourceFieldNames(): string;
485
580
  getPopoverStyle(): Record<string, string>;
581
+ getStepTypeLabel(type: TransformationType): string;
582
+ hasCondition(step: TransformationConfig): boolean;
583
+ toggleCondition(step: TransformationConfig, enabled: boolean): void;
584
+ onConditionChange(step: TransformationConfig, group: FilterGroup): void;
585
+ private createEmptyConditionGroup;
586
+ getConditionSummary(step: TransformationConfig): string;
587
+ private summarizeConditionGroup;
588
+ private getOperatorLabel;
486
589
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<TransformationPopoverComponent, never>;
487
590
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<TransformationPopoverComponent, "transformation-popover", never, { "mapping": { "alias": "mapping"; "required": false; }; "position": { "alias": "position"; "required": false; }; "sampleData": { "alias": "sampleData"; "required": false; }; }, { "save": "save"; "delete": "delete"; "close": "close"; }, never, never, true, never>;
488
591
  }
@@ -600,5 +703,5 @@ declare class DefaultValuePopoverComponent implements OnInit {
600
703
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<DefaultValuePopoverComponent, "default-value-popover", never, { "field": { "alias": "field"; "required": false; }; "existingValue": { "alias": "existingValue"; "required": false; }; "position": { "alias": "position"; "required": false; }; }, { "save": "save"; "delete": "delete"; "close": "close"; }, never, never, true, never>;
601
704
  }
602
705
 
603
- export { ArrayFilterModalComponent, ArraySelectorModalComponent, DataMapperComponent, DefaultValuePopoverComponent, MappingService, SchemaEditorComponent, SchemaParserService, SchemaTreeComponent, SvgConnectorService, TransformationPopoverComponent, TransformationService };
604
- export type { ArrayFilterConfig, ArrayMapping, ArraySelectionMode, ArraySelectorConfig, ArrayToObjectMapping, Connection, ConnectionPath, ConnectionPoint, DefaultValue, DragState, EditorField, FieldMapping, FieldPositionEvent, FilterCondition, FilterGroup, FilterItem, FilterOperator, JsonSchema, JsonSchemaDefinition, ModelRegistry, Point, SchemaDefinition, SchemaDocument, SchemaField, TransformationConfig, TransformationType };
706
+ export { ArrayFilterModalComponent, ArraySelectorModalComponent, DataMapperComponent, DefaultValuePopoverComponent, MappingService, SchemaEditorComponent, SchemaParserService, SchemaTreeComponent, SvgConnectorService, TransformationPopoverComponent, TransformationService, addProperty, createEmptySchema, getSchemaType, removeProperty, schemaToFields };
707
+ export type { ArrayFilterConfig, ArrayMapping, ArraySelectionMode, ArraySelectorConfig, ArrayToObjectMapping, Connection, ConnectionPath, ConnectionPoint, DefaultValue, DragState, FieldMapping, FieldPositionEvent, FilterCondition, FilterGroup, FilterItem, FilterOperator, JsonSchema, JsonSchemaField, JsonSchemaType, ModelRegistry, Point, SchemaDefinition, SchemaDocument, SchemaField, TransformationCondition, TransformationConfig, TransformationType };