@solidev/data 0.6.4 → 0.7.0-beta.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.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, makeStateKey, PLATFORM_ID, Inject, Optional, Injectable, ViewChild, Input, Component, inject, DestroyRef, Pipe, LOCALE_ID, DEFAULT_CURRENCY_CODE, EventEmitter, Output, HostListener, Directive, NgModule } from '@angular/core';
|
|
3
|
-
import 'reflect-metadata';
|
|
4
3
|
import * as i2$2 from '@angular/forms';
|
|
5
4
|
import { FormControl, Validators, FormGroup, ReactiveFormsModule, UntypedFormControl, NG_VALUE_ACCESSOR, UntypedFormGroup } from '@angular/forms';
|
|
6
5
|
import { throwError, ReplaySubject, share, combineLatest, of, Subject, BehaviorSubject, takeUntil, NEVER, debounceTime, distinctUntilChanged, firstValueFrom, isObservable, timer, Observable, merge } from 'rxjs';
|
|
@@ -59,6 +58,24 @@ const BootstrapDataDisplayConfig = {
|
|
|
59
58
|
const DATA_DISPLAY_CONFIG = new InjectionToken("data.display.config");
|
|
60
59
|
|
|
61
60
|
const PROPERTY_METADATA_KEY = Symbol('ngxDataMetadata');
|
|
61
|
+
function getOrCreateFieldsMap(target) {
|
|
62
|
+
if (!Object.prototype.hasOwnProperty.call(target, PROPERTY_METADATA_KEY)) {
|
|
63
|
+
const inherited = target[PROPERTY_METADATA_KEY];
|
|
64
|
+
const map = inherited ? new Map(inherited) : new Map();
|
|
65
|
+
Object.defineProperty(target, PROPERTY_METADATA_KEY, {
|
|
66
|
+
value: map,
|
|
67
|
+
enumerable: false,
|
|
68
|
+
configurable: true,
|
|
69
|
+
writable: false,
|
|
70
|
+
});
|
|
71
|
+
return map;
|
|
72
|
+
}
|
|
73
|
+
return target[PROPERTY_METADATA_KEY];
|
|
74
|
+
}
|
|
75
|
+
function getFieldsMetadata(target) {
|
|
76
|
+
const proto = typeof target === 'function' ? target.prototype : target;
|
|
77
|
+
return proto[PROPERTY_METADATA_KEY];
|
|
78
|
+
}
|
|
62
79
|
/**
|
|
63
80
|
* Base field manager, stores metadata and provides common field utilities
|
|
64
81
|
*
|
|
@@ -159,7 +176,6 @@ class BaseFieldManager {
|
|
|
159
176
|
return this.defaultValue;
|
|
160
177
|
}
|
|
161
178
|
}
|
|
162
|
-
/** Util to get own object keys */
|
|
163
179
|
const ownKeys = (target) => Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
|
|
164
180
|
/**
|
|
165
181
|
* Creates a field decorator that can only be applied within
|
|
@@ -172,9 +188,9 @@ const ownKeys = (target) => Object.getOwnPropertyNames(target).concat(Object.get
|
|
|
172
188
|
*/
|
|
173
189
|
function genericDataField(meta, type, manager) {
|
|
174
190
|
return (target, propertyKey) => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
191
|
+
// Utilisation du store symbolisé au lieu de Reflect
|
|
192
|
+
const allMetadata = getOrCreateFieldsMap(target);
|
|
193
|
+
const cname = `${target.constructor.__name}`;
|
|
178
194
|
if ((cname === `undefined` || cname === '') && type !== 'primaryField') {
|
|
179
195
|
throw Error(`Decorator ${type} allowed only on classes with static __name field : "${cname}" found for - ${target}`);
|
|
180
196
|
}
|
|
@@ -182,7 +198,6 @@ function genericDataField(meta, type, manager) {
|
|
|
182
198
|
let cm = allMetadata.get(pk);
|
|
183
199
|
/* istanbul ignore if */
|
|
184
200
|
if (cm) {
|
|
185
|
-
// This should never occur as metadata is object bound and property names must be unique
|
|
186
201
|
throw Error(`Field ${pk} already defined = ${cm}`);
|
|
187
202
|
}
|
|
188
203
|
cm = {};
|
|
@@ -196,7 +211,7 @@ function genericDataField(meta, type, manager) {
|
|
|
196
211
|
cm.self = pk;
|
|
197
212
|
cm.manager = new manager(cm);
|
|
198
213
|
allMetadata.set(pk, cm);
|
|
199
|
-
Reflect.defineMetadata
|
|
214
|
+
// Plus besoin de Reflect.defineMetadata : la Map est déjà stockée sur le prototype.
|
|
200
215
|
};
|
|
201
216
|
}
|
|
202
217
|
|
|
@@ -224,7 +239,8 @@ class DataModel {
|
|
|
224
239
|
*/
|
|
225
240
|
constructor(_coll) {
|
|
226
241
|
this._coll = _coll;
|
|
227
|
-
|
|
242
|
+
// Remplacement de Reflect.getMetadata par getFieldsMetadata
|
|
243
|
+
const md = getFieldsMetadata(this);
|
|
228
244
|
// istanbul ignore if
|
|
229
245
|
if (!md) {
|
|
230
246
|
// This should never occur as all datamodel have at least id field
|
|
@@ -1961,7 +1977,9 @@ class AuthInterceptor {
|
|
|
1961
1977
|
}
|
|
1962
1978
|
}
|
|
1963
1979
|
_addToken(request, token) {
|
|
1964
|
-
const headers = request.headers
|
|
1980
|
+
const headers = request.headers
|
|
1981
|
+
.delete('Authorization')
|
|
1982
|
+
.append('Authorization', `Bearer ${token}`);
|
|
1965
1983
|
return request.clone({ headers });
|
|
1966
1984
|
}
|
|
1967
1985
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: AuthInterceptor, deps: [{ token: DATA_AUTH_SERVICE }, { token: DATA_API_URL }, { token: DATA_AUTH_URLS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|