ngx-dynamic-entity 2.5.0 → 3.0.0-rc.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-dynamic-entity",
3
- "version": "2.5.0",
3
+ "version": "3.0.0-rc.1",
4
4
  "description": "Angular standalone UI library for rendering dynamic entity forms.",
5
5
  "//typings": "Local workspace resolution only: ng-packagr 21 writes types/ngx-dynamic-entity.d.ts into dist/package.json. Do NOT add a 'main' field here — ng-packagr does not generate one, so it would be copied verbatim and resolve wrongly in the published package.",
6
6
  "typings": "types/ngx-dynamic-entity.d.ts",
@@ -8,7 +8,7 @@
8
8
  "@angular/common": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0 || ^22.0.0",
9
9
  "@angular/core": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0 || ^22.0.0",
10
10
  "@angular/forms": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0 || ^22.0.0",
11
- "@dynamic-entity/core": "^2.5.0",
11
+ "@dynamic-entity/core": "^3.0.0-rc.1",
12
12
  "rxjs": "^7.0.0"
13
13
  },
14
14
  "keywords": [
@@ -1,10 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Type, EnvironmentProviders, WritableSignal, OnInit, OnChanges, OnDestroy, EventEmitter, SimpleChanges, Provider } from '@angular/core';
3
- import { ReferenceOption, LocalizedText, EntityFormConfig, FormRule, ImportLookups, DateOrder, MappingPlan, CsvDelimiter, ImportResult, TemplateSpec, SheetGrid, CommonModuleEntry, EntityReferenceLoader, LookupListSource, RecordMigration, FileUploadHandler, FieldValidators, NestedFieldConfig, ReferenceLoaderContext, DropdownOption, LookupListValue, NestedTabConfig, RuleEvaluationResult, FieldScopeEntry, EvaluateFormRulesOptions, ImportColumn, MappingEntry, UnsupportedColumn, ImportRowError, SliderBounds } from '@dynamic-entity/core';
3
+ import { ReferenceOption, LocalizedText, EntityFormConfig, FormRule, ImportLookups, DateOrder, AnyMappingPlan, CsvDelimiter, ImportResult, TemplateSpec, SheetGrid, CommonModuleEntry, EntityReferenceLoader, LookupListSource, RecordMigration, FileUploadHandler, FieldValidators, NestedFieldConfig, ReferenceLoaderContext, DropdownOption, LookupListValue, NestedTabConfig, RuleEvaluationResult, FieldScopeEntry, EvaluateFormRulesOptions, MappingPlan, ImportColumn, MappingEntry, UnsupportedColumn, ImportRowError, SliderBounds } from '@dynamic-entity/core';
4
4
  export { AutoPatchConfig, CommonModuleEntry, ComponentClass, DropdownOption, EntityFormConfig, EntityPermissions, EntityReferenceConfig, EntityReferenceLoader, FieldTableConfig, FieldValidators, FileRef, FormRule, LocalizedText, NestedFieldConfig, NestedTabConfig, PatchOnTrueMapping, RbacContext, ReferenceLoaderContext, ReferenceOption, RichFieldType, RuleAction, RuleCondition, RuleEvaluationResult, VersionedRecord, formatDisplayValue, normalizeConfig, normalizeOption, resolveLabel, resolveOptionLabel, resolveOptionValue, valuesMatch } from '@dynamic-entity/core';
5
5
  import { ValidatorFn, AsyncValidatorFn, AbstractControl, ValidationErrors, FormGroup, FormArray } from '@angular/forms';
6
6
  import * as rxjs from 'rxjs';
7
7
  import * as ngx_dynamic_entity from 'ngx-dynamic-entity';
8
+ import * as sheet_to_schema from 'sheet-to-schema';
8
9
 
9
10
  /**
10
11
  * Backing store for cached reference options.
@@ -290,7 +291,7 @@ interface ImportPreview {
290
291
  /** The first few rows, for the mapping screen to show under each column. */
291
292
  sample: string[][];
292
293
  /** Where the suggester got to. Every inferred match is tagged `guess`. */
293
- suggestion: MappingPlan;
294
+ suggestion: AnyMappingPlan;
294
295
  /** Total data rows in the file, which may be far more than `sample` holds. */
295
296
  rowCount: number;
296
297
  /**
@@ -335,7 +336,7 @@ interface ImportTransport {
335
336
  /** Headers, a sample, and a suggested mapping for a freshly chosen file. */
336
337
  preview(file: File, context: ImportContext): Promise<ImportPreview>;
337
338
  /** Apply a plan to the whole file. */
338
- commit(file: File, plan: MappingPlan, context: ImportContext): Promise<ImportResult>;
339
+ commit(file: File, plan: AnyMappingPlan, context: ImportContext): Promise<ImportResult>;
339
340
  /**
340
341
  * Render a template for download.
341
342
  *
@@ -2087,8 +2088,14 @@ declare class LocalImportTransport implements ImportTransport {
2087
2088
  private readonly parsed;
2088
2089
  /** The registered parser, or the built-in CSV one. */
2089
2090
  private read;
2090
- preview(file: File, context: ImportContext): Promise<ImportPreview>;
2091
- commit(file: File, plan: MappingPlan, context: ImportContext): Promise<ImportResult>;
2091
+ /**
2092
+ * The suggestion made here is always plan v2, and the return type says so. The contract's is
2093
+ * a plan in either shape, because a 2.x server sends the older one.
2094
+ */
2095
+ preview(file: File, context: ImportContext): Promise<ImportPreview & {
2096
+ suggestion: MappingPlan;
2097
+ }>;
2098
+ commit(file: File, plan: AnyMappingPlan, context: ImportContext): Promise<ImportResult>;
2092
2099
  template(spec: TemplateSpec, format: TemplateFormat): Promise<Blob>;
2093
2100
  static ɵfac: i0.ɵɵFactoryDeclaration<LocalImportTransport, never>;
2094
2101
  static ɵprov: i0.ɵɵInjectableDeclaration<LocalImportTransport>;
@@ -2117,8 +2124,9 @@ interface HttpImportTransportOptions {
2117
2124
  /**
2118
2125
  * Where a warning goes. Defaults to `console.warn`.
2119
2126
  *
2120
- * There is exactly one warning, and it is the engine-version mismatch below — which is a
2121
- * developer's problem, not a user's, so it does not belong in the wizard's error banner.
2127
+ * What is warned about is the two deploys having moved apart: the engine version, the
2128
+ * adapter, the date order the server did not confirm. Those are a developer's problem, not
2129
+ * a user's, so they do not belong in the wizard's error banner.
2122
2130
  */
2123
2131
  warn?: (message: string) => void;
2124
2132
  }
@@ -2129,6 +2137,12 @@ declare class HttpImportTransport implements ImportTransport {
2129
2137
  * Keyed on the `File`, so it lives exactly as long as the file does.
2130
2138
  */
2131
2139
  private readonly reported;
2140
+ /**
2141
+ * The plan versions each previewed file's server said it reads. A file with no entry was
2142
+ * never previewed here, and one whose server said nothing is from before plan v2: either
2143
+ * way `commit` sends nothing that only a v2 reader would understand.
2144
+ */
2145
+ private readonly planVersions;
2132
2146
  constructor(options: HttpImportTransportOptions);
2133
2147
  private warn;
2134
2148
  /**
@@ -2149,8 +2163,15 @@ declare class HttpImportTransport implements ImportTransport {
2149
2163
  * patch release is not a reason to stop somebody importing.
2150
2164
  */
2151
2165
  private checkEngine;
2166
+ /**
2167
+ * Warn when the server runs another adapter, or this one at another major version.
2168
+ *
2169
+ * Since 3.0 a server says which adapter turned its rows into records. A server from before
2170
+ * that says nothing, and `checkEngine` has already compared the one version it does report.
2171
+ */
2172
+ private checkAdapter;
2152
2173
  preview(file: File, context: ImportContext): Promise<ImportPreview>;
2153
- commit(file: File, plan: MappingPlan, context: ImportContext): Promise<ImportResult>;
2174
+ commit(file: File, plan: AnyMappingPlan, context: ImportContext): Promise<ImportResult>;
2154
2175
  template(spec: TemplateSpec, format: TemplateFormat, context: ImportContext, fields?: readonly string[]): Promise<Blob>;
2155
2176
  }
2156
2177
  /**
@@ -2222,11 +2243,11 @@ declare class EntityImportComponent {
2222
2243
  protected readonly sample: i0.WritableSignal<string[][]>;
2223
2244
  protected readonly rowCount: i0.WritableSignal<number>;
2224
2245
  /** The separator a delimited file turned out to use, so the user can see how it was read. */
2225
- protected readonly delimiter: i0.WritableSignal<CsvDelimiter>;
2246
+ protected readonly delimiter: i0.WritableSignal<sheet_to_schema.CsvDelimiter>;
2226
2247
  /** The date order the transport said it will read with at commit, from its preview. */
2227
2248
  protected readonly reportedDateOrder: i0.WritableSignal<DateOrder>;
2228
2249
  protected readonly fileName: i0.WritableSignal<string>;
2229
- protected readonly plan: i0.WritableSignal<MappingPlan>;
2250
+ protected readonly plan: i0.WritableSignal<AnyMappingPlan>;
2230
2251
  protected readonly result: i0.WritableSignal<ImportResult>;
2231
2252
  private readonly registered;
2232
2253
  private readonly local;
@@ -2322,11 +2343,11 @@ interface ArraySlots {
2322
2343
  declare class ImportMapperComponent implements OnChanges {
2323
2344
  config: EntityFormConfig;
2324
2345
  headers: readonly string[];
2325
- /** The starting point, normally `suggestMapping`'s output. */
2326
- plan: MappingPlan | null;
2346
+ /** The starting point, normally `suggestMapping`'s output. A stored 2.x plan is taken too. */
2347
+ plan: AnyMappingPlan | null;
2327
2348
  language: string;
2328
- /** Emitted whenever the user changes a selection. */
2329
- readonly planChange: EventEmitter<MappingPlan>;
2349
+ /** Emitted whenever the user changes a selection. Always plan v2, whichever shape came in. */
2350
+ readonly planChange: EventEmitter<sheet_to_schema.MappingPlan>;
2330
2351
  protected readonly ui: UiTextService;
2331
2352
  protected readonly rows: i0.WritableSignal<MappingRow[]>;
2332
2353
  /**
@@ -2338,7 +2359,7 @@ declare class ImportMapperComponent implements OnChanges {
2338
2359
  */
2339
2360
  protected readonly unsupported: i0.WritableSignal<number>;
2340
2361
  /** A plan entry whose field this config no longer has. Kept, and emitted, until removed. */
2341
- protected readonly stale: i0.WritableSignal<MappingEntry[]>;
2362
+ protected readonly stale: i0.WritableSignal<sheet_to_schema.MappingEntry[]>;
2342
2363
  /** Repeating fields the user can add a row to. */
2343
2364
  protected readonly arrays: i0.WritableSignal<ArraySlots[]>;
2344
2365
  protected readonly constant = -1;
@@ -2369,6 +2390,10 @@ declare class ImportMapperComponent implements OnChanges {
2369
2390
  * Every entry of the incoming plan survives in its own position — a fixed value, a ref the
2370
2391
  * config no longer has — unless the user changed or removed it, and an untouched entry is
2371
2392
  * emitted exactly as it arrived. New selections follow, in field order.
2393
+ *
2394
+ * What is emitted is plan v2, whichever shape came in: `target` and `schemaVersion`, where a
2395
+ * 2.x plan said `entity` and `configVersion`. Anything else the incoming plan carried, such
2396
+ * as its lists and its grouping, is kept.
2372
2397
  */
2373
2398
  private toPlan;
2374
2399
  static ɵfac: i0.ɵɵFactoryDeclaration<ImportMapperComponent, never>;
@@ -2411,7 +2436,7 @@ interface PreviewRow {
2411
2436
  */
2412
2437
  declare class ImportPreviewComponent implements OnChanges {
2413
2438
  config: EntityFormConfig;
2414
- plan: MappingPlan;
2439
+ plan: AnyMappingPlan;
2415
2440
  rows: readonly (readonly string[])[];
2416
2441
  lookups?: ImportLookups;
2417
2442
  /** The same rules the commit will apply; without them a rule-driven rejection is invisible. */