ngx-dynamic-entity 1.3.0 → 1.5.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.
Files changed (91) hide show
  1. package/README.md +14 -0
  2. package/fesm2022/ngx-dynamic-entity.mjs +255 -157
  3. package/fesm2022/ngx-dynamic-entity.mjs.map +1 -1
  4. package/package.json +6 -7
  5. package/types/ngx-dynamic-entity.d.ts +1730 -0
  6. package/esm2022/lib/field-types/array-field.component.mjs +0 -168
  7. package/esm2022/lib/field-types/boolean-field.component.mjs +0 -101
  8. package/esm2022/lib/field-types/checkbox-field.component.mjs +0 -82
  9. package/esm2022/lib/field-types/currency-field.component.mjs +0 -102
  10. package/esm2022/lib/field-types/date-field.component.mjs +0 -91
  11. package/esm2022/lib/field-types/date-time-field.component.mjs +0 -138
  12. package/esm2022/lib/field-types/dropdown-field.component.mjs +0 -176
  13. package/esm2022/lib/field-types/email-field.component.mjs +0 -102
  14. package/esm2022/lib/field-types/entity-ref-field.component.mjs +0 -195
  15. package/esm2022/lib/field-types/field-component.contract.mjs +0 -2
  16. package/esm2022/lib/field-types/file-field.component.mjs +0 -157
  17. package/esm2022/lib/field-types/group-field.component.mjs +0 -89
  18. package/esm2022/lib/field-types/image-field.component.mjs +0 -169
  19. package/esm2022/lib/field-types/month-year-field.component.mjs +0 -152
  20. package/esm2022/lib/field-types/multi-select-field.component.mjs +0 -146
  21. package/esm2022/lib/field-types/number-field.component.mjs +0 -112
  22. package/esm2022/lib/field-types/password-field.component.mjs +0 -110
  23. package/esm2022/lib/field-types/radio-field.component.mjs +0 -153
  24. package/esm2022/lib/field-types/text-field.component.mjs +0 -121
  25. package/esm2022/lib/field-types/textarea-field.component.mjs +0 -85
  26. package/esm2022/lib/field-types/time-field.component.mjs +0 -96
  27. package/esm2022/lib/form/dynamic-field/dynamic-field.component.mjs +0 -152
  28. package/esm2022/lib/form/dynamic-form.component.mjs +0 -899
  29. package/esm2022/lib/form/dynamic-record-form.component.mjs +0 -531
  30. package/esm2022/lib/providers/provide-field-types.mjs +0 -75
  31. package/esm2022/lib/providers/provide-ngx-dynamic-entity.mjs +0 -27
  32. package/esm2022/lib/services/cascade-data.service.mjs +0 -129
  33. package/esm2022/lib/services/config-source.service.mjs +0 -67
  34. package/esm2022/lib/services/entity-ref-cache.mjs +0 -20
  35. package/esm2022/lib/services/entity-ref-registry.service.mjs +0 -31
  36. package/esm2022/lib/services/entity-ref-selection.service.mjs +0 -27
  37. package/esm2022/lib/services/entity-reference.service.mjs +0 -168
  38. package/esm2022/lib/services/field-registry.service.mjs +0 -55
  39. package/esm2022/lib/services/file-upload.service.mjs +0 -89
  40. package/esm2022/lib/services/hook-registry.service.mjs +0 -26
  41. package/esm2022/lib/services/lookup-registry.service.mjs +0 -246
  42. package/esm2022/lib/services/rbac.service.mjs +0 -46
  43. package/esm2022/lib/services/rules-evaluation.service.mjs +0 -27
  44. package/esm2022/lib/services/validation-messages.service.mjs +0 -56
  45. package/esm2022/lib/services/validator-registry.service.mjs +0 -99
  46. package/esm2022/lib/tokens/injection-tokens.mjs +0 -126
  47. package/esm2022/ngx-dynamic-entity.mjs +0 -5
  48. package/esm2022/public-api.mjs +0 -58
  49. package/index.d.ts +0 -5
  50. package/lib/field-types/array-field.component.d.ts +0 -28
  51. package/lib/field-types/boolean-field.component.d.ts +0 -18
  52. package/lib/field-types/checkbox-field.component.d.ts +0 -13
  53. package/lib/field-types/currency-field.component.d.ts +0 -17
  54. package/lib/field-types/date-field.component.d.ts +0 -15
  55. package/lib/field-types/date-time-field.component.d.ts +0 -30
  56. package/lib/field-types/dropdown-field.component.d.ts +0 -34
  57. package/lib/field-types/email-field.component.d.ts +0 -15
  58. package/lib/field-types/entity-ref-field.component.d.ts +0 -49
  59. package/lib/field-types/field-component.contract.d.ts +0 -49
  60. package/lib/field-types/file-field.component.d.ts +0 -25
  61. package/lib/field-types/group-field.component.d.ts +0 -17
  62. package/lib/field-types/image-field.component.d.ts +0 -30
  63. package/lib/field-types/month-year-field.component.d.ts +0 -28
  64. package/lib/field-types/multi-select-field.component.d.ts +0 -27
  65. package/lib/field-types/number-field.component.d.ts +0 -16
  66. package/lib/field-types/password-field.component.d.ts +0 -17
  67. package/lib/field-types/radio-field.component.d.ts +0 -33
  68. package/lib/field-types/text-field.component.d.ts +0 -23
  69. package/lib/field-types/textarea-field.component.d.ts +0 -14
  70. package/lib/field-types/time-field.component.d.ts +0 -27
  71. package/lib/form/dynamic-field/dynamic-field.component.d.ts +0 -78
  72. package/lib/form/dynamic-form.component.d.ts +0 -293
  73. package/lib/form/dynamic-record-form.component.d.ts +0 -199
  74. package/lib/providers/provide-field-types.d.ts +0 -24
  75. package/lib/providers/provide-ngx-dynamic-entity.d.ts +0 -56
  76. package/lib/services/cascade-data.service.d.ts +0 -45
  77. package/lib/services/config-source.service.d.ts +0 -14
  78. package/lib/services/entity-ref-cache.d.ts +0 -27
  79. package/lib/services/entity-ref-registry.service.d.ts +0 -21
  80. package/lib/services/entity-ref-selection.service.d.ts +0 -24
  81. package/lib/services/entity-reference.service.d.ts +0 -49
  82. package/lib/services/field-registry.service.d.ts +0 -32
  83. package/lib/services/file-upload.service.d.ts +0 -27
  84. package/lib/services/hook-registry.service.d.ts +0 -12
  85. package/lib/services/lookup-registry.service.d.ts +0 -94
  86. package/lib/services/rbac.service.d.ts +0 -27
  87. package/lib/services/rules-evaluation.service.d.ts +0 -17
  88. package/lib/services/validation-messages.service.d.ts +0 -43
  89. package/lib/services/validator-registry.service.d.ts +0 -32
  90. package/lib/tokens/injection-tokens.d.ts +0 -134
  91. package/public-api.d.ts +0 -42
@@ -1,27 +0,0 @@
1
- import type { EntityFormConfig, NestedFieldConfig, NestedTabConfig } from '@dynamic-entity/core';
2
- import * as i0 from "@angular/core";
3
- /**
4
- * RbacService — ALL permission checks and masking logic live here.
5
- */
6
- export declare class RbacService {
7
- private readonly maskedRoles;
8
- /**
9
- * Check if any of the user's roles satisfy the required roles.
10
- * hasPermission(roles, undefined) → true (no restriction).
11
- */
12
- hasPermission(userRoles: string[], requiredRoles?: string[]): boolean;
13
- /** 3-level OR resolution */
14
- resolveEffectiveMask(formMask?: boolean, tabMask?: boolean, fieldMask?: boolean): boolean;
15
- /** Check if the user's roles include any masked role */
16
- isUserMaskedRole(userRoles: string[]): boolean;
17
- /** Determine if a specific field should be masked for this user */
18
- shouldMaskField(field: NestedFieldConfig, tab: NestedTabConfig | undefined, config: EntityFormConfig, userRoles: string[]): boolean;
19
- /** Get view/edit/delete permissions for a config */
20
- getPermissions(config: EntityFormConfig, userRoles: string[]): {
21
- canView: boolean;
22
- canEdit: boolean;
23
- canDelete: boolean;
24
- };
25
- static ɵfac: i0.ɵɵFactoryDeclaration<RbacService, never>;
26
- static ɵprov: i0.ɵɵInjectableDeclaration<RbacService>;
27
- }
@@ -1,17 +0,0 @@
1
- import type { EntityFormConfig, FormRule, RuleEvaluationResult } from '@dynamic-entity/core';
2
- import * as i0 from "@angular/core";
3
- /**
4
- * RulesEvaluationService — evaluates dynamic form rules against active reactive form state.
5
- */
6
- export declare class RulesEvaluationService {
7
- /**
8
- * Evaluate rules against form values and optional original baseline values.
9
- */
10
- evaluate(rules: FormRule[] | undefined | null, values: Record<string, unknown>, originalValues?: Record<string, unknown>): RuleEvaluationResult;
11
- /**
12
- * Filter rules pertinent to a single tab.
13
- */
14
- filterForTab(rules: FormRule[] | undefined | null, tabId: string, config: EntityFormConfig): FormRule[];
15
- static ɵfac: i0.ɵɵFactoryDeclaration<RulesEvaluationService, never>;
16
- static ɵprov: i0.ɵɵInjectableDeclaration<RulesEvaluationService>;
17
- }
@@ -1,43 +0,0 @@
1
- import type { ValidationErrors } from '@angular/forms';
2
- import * as i0 from "@angular/core";
3
- /**
4
- * Resolves an Angular `ValidationErrors` object to the message shown under a field.
5
- *
6
- * These strings used to be hardcoded English literals inside each field component, so a
7
- * German form meant re-implementing every field type — the labels honoured `language` while
8
- * the errors underneath them did not.
9
- *
10
- * A message is a plain string, or a function when it needs the error's own detail
11
- * (`minlength.requiredLength`, `min.min`, and so on). The active `language` is passed
12
- * through, so one registration can serve every locale:
13
- *
14
- * ```typescript
15
- * provideNgxDynamicEntity({
16
- * validationMessages: {
17
- * required: lang => (lang === 'de' ? 'Pflichtfeld.' : 'This field is required.'),
18
- * minlength: (lang, err) => `Mindestens ${err['requiredLength']} Zeichen.`,
19
- * },
20
- * });
21
- * ```
22
- *
23
- * Unregistered keys fall back to the defaults below, so overriding one message does not
24
- * mean supplying them all.
25
- */
26
- export type ValidationMessage = string | ((language: string, error: any) => string);
27
- /** The built-in English messages. Every key here can be overridden individually. */
28
- export declare const DEFAULT_VALIDATION_MESSAGES: Record<string, ValidationMessage>;
29
- export declare class ValidationMessagesService {
30
- private readonly overrides;
31
- /**
32
- * The message for the first error present, in the order the caller lists.
33
- *
34
- * Order is the caller's because it is field-specific: a dropdown wants
35
- * `requiredSelection` where a text input wants `required`, and the first match wins so the
36
- * most specific message is the one shown.
37
- */
38
- resolve(errors: ValidationErrors | null | undefined, language: string, order: readonly (string | readonly [errorKey: string, messageKey: string])[], fallbackKey?: string): string;
39
- /** One message by key, honouring an override before the default. */
40
- messageFor(key: string, language: string, error: unknown): string;
41
- static ɵfac: i0.ɵɵFactoryDeclaration<ValidationMessagesService, never>;
42
- static ɵprov: i0.ɵɵInjectableDeclaration<ValidationMessagesService>;
43
- }
@@ -1,32 +0,0 @@
1
- import { AsyncValidatorFn, ValidatorFn } from '@angular/forms';
2
- import type { FieldValidators } from '@dynamic-entity/core';
3
- import * as i0 from "@angular/core";
4
- /**
5
- * ValidatorRegistryService — resolves validator configs / key strings to Angular ValidatorFns.
6
- */
7
- export declare class ValidatorRegistryService {
8
- private readonly consumerRegistry;
9
- private readonly asyncRegistry;
10
- /**
11
- * Resolve a validator key string to a ValidatorFn.
12
- * Supports parameterized built-ins like 'min:0', 'maxLength:255'.
13
- */
14
- resolve(validatorKey: string): ValidatorFn | null;
15
- /** Resolve multiple validator keys into a ValidatorFn[] */
16
- resolveAll(validatorKeys?: string[]): ValidatorFn[];
17
- /** Resolve a FieldValidators object or string[] into ValidatorFn[] */
18
- resolveFromConfig(config?: FieldValidators | string[]): ValidatorFn[];
19
- /**
20
- * Resolve the async validators a field names, in `validators.customAsync`.
21
- *
22
- * Async validators are deliberately a separate registry and a separate config key: Angular
23
- * attaches them through `setAsyncValidators`, runs them only once the synchronous ones
24
- * pass, and holds the control in `pending` until they settle. Mixing them into the
25
- * synchronous list would silently never run them.
26
- *
27
- * An unknown name is skipped rather than throwing, matching the synchronous behaviour.
28
- */
29
- resolveAsyncFromConfig(config?: FieldValidators | string[]): AsyncValidatorFn[];
30
- static ɵfac: i0.ɵɵFactoryDeclaration<ValidatorRegistryService, never>;
31
- static ɵprov: i0.ɵɵInjectableDeclaration<ValidatorRegistryService>;
32
- }
@@ -1,134 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- import type { Type } from '@angular/core';
3
- import { type EntityRefCacheStore } from '../services/entity-ref-cache';
4
- /** Roles that see XXXXXXXXX for masked fields. Presentational only — enforce authz server-side. */
5
- export declare const MASKED_ROLES: InjectionToken<string[]>;
6
- /**
7
- * Consumer **overrides**: fieldType string → Angular component class.
8
- * Highest priority — beats anything registered through `provideFieldTypes()`.
9
- */
10
- export declare const FIELD_TYPE_REGISTRY: InjectionToken<Map<string, Type<any>>>;
11
- /**
12
- * Multi-provider of field-type sets, contributed by `provideFieldTypes()` /
13
- * `provideBuiltInFieldTypes()`. Multi so several calls compose instead of clobbering;
14
- * later sets win on key collision. This is the seam that keeps unused field components
15
- * out of the bundle — nothing is imported until a set names it.
16
- */
17
- export declare const FIELD_TYPE_SETS: InjectionToken<Record<string, Type<any>>[]>;
18
- /**
19
- * Registry: entity key → option loader.
20
- *
21
- * A loader receives a `ReferenceLoaderContext` (`parentValue`, `filters`, `lang`) and may
22
- * return an array, a Promise, or an Observable of `ReferenceOption[]`. `ctx` is optional,
23
- * so a zero-arg loader (`() => svc.list()`) is still a valid registration.
24
- */
25
- export declare const ENTITY_REF_REGISTRY: InjectionToken<Map<string, EntityReferenceLoader>>;
26
- /**
27
- * Registry: list name → the values of a named master list (`field.listName`).
28
- *
29
- * A source may be the values themselves (array / Promise / Observable) or a **loader function**,
30
- * which is what you want for anything fetched: a bare Promise is created when the provider is
31
- * built, so every list would load whether or not a form uses it.
32
- *
33
- * Values are normalised by `normalizeLookupValues` — bare strings and `LocalizedText` are
34
- * accepted alongside the full `{ code, name, sortOrder }` shape.
35
- *
36
- * @example
37
- * provideNgxDynamicEntity({
38
- * lookups: {
39
- * employeeStatus: () => listService.getByName('employeeStatus'),
40
- * grades: ['Junior', 'Senior'],
41
- * },
42
- * })
43
- */
44
- export declare const LOOKUP_REGISTRY: InjectionToken<Map<string, LookupListSource>>;
45
- /**
46
- * Ordered steps that move a saved record forward when a config's `version` increases.
47
- *
48
- * Without these, `EntityFormConfig.version` and `VersionedRecord._configVersion` are
49
- * declarations nothing acts on: a schema can be edited freely while records keep their old
50
- * shape, and nothing reconciles the two. Registering migrations makes the version numbers
51
- * mean something.
52
- *
53
- * @example
54
- * provideNgxDynamicEntity({
55
- * migrations: [
56
- * { from: 1, to: 2, description: 'split name', migrate: r => ({ ...r, firstName: r['name'] }) },
57
- * ],
58
- * })
59
- */
60
- export declare const RECORD_MIGRATIONS: InjectionToken<RecordMigration[]>;
61
- /**
62
- * Overrides for the messages shown under an invalid field, keyed by Angular error key
63
- * (`required`, `minlength`, `pattern`, …) plus a few field-specific keys.
64
- *
65
- * The built-in messages are English literals. Registering here is what makes a non-English
66
- * form possible without re-implementing every field component; unlisted keys keep their
67
- * default, so overriding one does not mean supplying them all.
68
- */
69
- export declare const VALIDATION_MESSAGES: InjectionToken<Record<string, any>>;
70
- /** Registry: validator key → ValidatorFn */
71
- export declare const VALIDATOR_REGISTRY: InjectionToken<Map<string, any>>;
72
- /**
73
- * Registry: validator key → AsyncValidatorFn.
74
- *
75
- * Kept separate from VALIDATOR_REGISTRY because Angular applies the two differently: an async
76
- * validator runs only once the synchronous ones pass, and puts the control into `pending`
77
- * while it does. Name them from a schema with `validators: { customAsync: ['uniqueEmail'] }`.
78
- */
79
- export declare const ASYNC_VALIDATOR_REGISTRY: InjectionToken<Map<string, any>>;
80
- /**
81
- * A registered hook: receives the payload, returns it (or a replacement), sync or async.
82
- *
83
- * Spelled out rather than typed as `Function`, which accepts class declarations and any
84
- * arity and gives a consumer no signature to write against.
85
- */
86
- export type HookFn = (data: any, context?: unknown) => unknown | Promise<unknown>;
87
- /** Registry: hook key → async (data, context) => data */
88
- export declare const HOOK_REGISTRY: InjectionToken<Map<string, HookFn>>;
89
- /**
90
- * Consumer-registered list of common module tabs (documents, audit, tasks, etc.).
91
- * The library ships no built-in implementations. Consumers provide their own list
92
- * so the builder's module-picker and the renderer's tab switcher know what's available.
93
- *
94
- * @example
95
- * providers: [
96
- * {
97
- * provide: COMMON_MODULES_REGISTRY,
98
- * useValue: [
99
- * { id: 'documents', label: { en: 'Documents' }, component: 'app-documents-view' },
100
- * { id: 'audit', label: { en: 'Audit Log' }, component: 'app-audit' },
101
- * ] satisfies CommonModuleEntry[]
102
- * }
103
- * ]
104
- */
105
- export declare const COMMON_MODULES_REGISTRY: InjectionToken<CommonModuleEntry[]>;
106
- /**
107
- * Consumer-provided file/image upload handler.
108
- * When supplied, image-field and file-field call it to persist the File and receive a stable
109
- * URL back. Without it the field stores `{ file, name, size, mimeType }` for the consumer to
110
- * upload on submit. May return the result directly, as a Promise, or as an Observable.
111
- *
112
- * @example
113
- * { provide: UPLOAD_HANDLER, useFactory: () => (file: File) => myUploadService.upload(file) }
114
- */
115
- export declare const UPLOAD_HANDLER: InjectionToken<FileUploadHandler>;
116
- /**
117
- * Backing store for the entity-reference options cache. Defaults to in-memory.
118
- * Provide your own to make the cache outlive a page refresh.
119
- *
120
- * @example
121
- * { provide: ENTITY_REF_CACHE_STORE, useClass: SessionStorageRefCache }
122
- */
123
- export declare const ENTITY_REF_CACHE_STORE: InjectionToken<EntityRefCacheStore>;
124
- /**
125
- * Consumer-provided predicate function to check whether user roles can edit system default tabs or fields.
126
- * Defaults to allowing edits if not provided.
127
- */
128
- export declare const SYSTEM_DEFAULT_CAN_EDIT: InjectionToken<(roles: string[]) => boolean>;
129
- export type ConfigSourceHandler = (entityKey: string) => any;
130
- /**
131
- * Registry/Resolver for resolving an EntityFormConfig by entity key across entities (Phase 8).
132
- * Enables cross-entity field referencing (`isReferenced`, `referencedEntityKey`, `referencedFieldId`, `hasDrift`).
133
- */
134
- export declare const CONFIG_SOURCE: InjectionToken<ConfigSourceHandler>;
package/public-api.d.ts DELETED
@@ -1,42 +0,0 @@
1
- export * from './lib/tokens/injection-tokens';
2
- export * from './lib/providers/provide-ngx-dynamic-entity';
3
- export * from './lib/providers/provide-field-types';
4
- export * from './lib/services/field-registry.service';
5
- export * from './lib/services/hook-registry.service';
6
- export * from './lib/services/validator-registry.service';
7
- export * from './lib/services/entity-ref-registry.service';
8
- export * from './lib/services/entity-ref-selection.service';
9
- export * from './lib/services/cascade-data.service';
10
- export * from './lib/services/entity-reference.service';
11
- export * from './lib/services/entity-ref-cache';
12
- export * from './lib/services/lookup-registry.service';
13
- export * from './lib/services/rbac.service';
14
- export * from './lib/services/rules-evaluation.service';
15
- export * from './lib/services/config-source.service';
16
- export * from './lib/services/validation-messages.service';
17
- export * from './lib/form/dynamic-form.component';
18
- export * from './lib/form/dynamic-record-form.component';
19
- export * from './lib/form/dynamic-field/dynamic-field.component';
20
- export * from './lib/field-types/field-component.contract';
21
- export * from './lib/field-types/text-field.component';
22
- export * from './lib/field-types/textarea-field.component';
23
- export * from './lib/field-types/number-field.component';
24
- export * from './lib/field-types/currency-field.component';
25
- export * from './lib/field-types/email-field.component';
26
- export * from './lib/field-types/password-field.component';
27
- export * from './lib/field-types/checkbox-field.component';
28
- export * from './lib/field-types/boolean-field.component';
29
- export * from './lib/field-types/date-field.component';
30
- export * from './lib/field-types/date-time-field.component';
31
- export * from './lib/field-types/time-field.component';
32
- export * from './lib/field-types/month-year-field.component';
33
- export * from './lib/field-types/dropdown-field.component';
34
- export * from './lib/field-types/radio-field.component';
35
- export * from './lib/field-types/multi-select-field.component';
36
- export * from './lib/field-types/entity-ref-field.component';
37
- export * from './lib/field-types/group-field.component';
38
- export * from './lib/field-types/array-field.component';
39
- export * from './lib/field-types/image-field.component';
40
- export * from './lib/field-types/file-field.component';
41
- export { resolveLabel, resolveOptionLabel, resolveOptionValue, formatDisplayValue, valuesMatch, normalizeOption, normalizeConfig, } from '@dynamic-entity/core';
42
- export type { EntityFormConfig, NestedTabConfig, NestedFieldConfig, FieldTableConfig, RichFieldType, LocalizedText, DropdownOption, VersionedRecord, EntityPermissions, RbacContext, FieldValidators, EntityReferenceConfig, EntityReferenceLoader, ReferenceOption, ReferenceLoaderContext, AutoPatchConfig, PatchOnTrueMapping, FileRef, FormRule, RuleCondition, RuleAction, RuleEvaluationResult, CommonModuleEntry, } from '@dynamic-entity/core';