@ethlete/query 4.6.0 → 4.6.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/esm2022/lib/directives/infinity-query-trigger.directive.mjs +3 -3
- package/esm2022/lib/directives/infinity-query.directive.mjs +3 -3
- package/esm2022/lib/directives/query.directive.mjs +3 -3
- package/esm2022/lib/entity/entity-store.mjs +28 -12
- package/esm2022/lib/entity/entity.types.mjs +1 -1
- package/esm2022/lib/entity/entity.utils.mjs +26 -2
- package/esm2022/lib/query-form/query-form.mjs +10 -5
- package/esm2022/lib/request/request.util.mjs +2 -1
- package/fesm2022/ethlete-query.mjs +71 -25
- package/fesm2022/ethlete-query.mjs.map +1 -1
- package/lib/auth/auth-provider.types.d.ts +0 -5
- package/lib/auth/bearer-auth-provider.d.ts +0 -4
- package/lib/entity/entity-store.d.ts +4 -0
- package/lib/entity/entity.types.d.ts +20 -0
- package/lib/entity/entity.utils.d.ts +10 -0
- package/lib/query/query.d.ts +0 -16
- package/lib/query/query.types.d.ts +0 -14
- package/package.json +1 -1
|
@@ -201,6 +201,7 @@ const serializeBody = (body) => {
|
|
|
201
201
|
if (typeof body === 'object' || typeof body === 'boolean' || Array.isArray(body)) {
|
|
202
202
|
return JSON.stringify(body);
|
|
203
203
|
}
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
204
205
|
return body.toString();
|
|
205
206
|
};
|
|
206
207
|
const transformMethod = (config) => {
|
|
@@ -1253,10 +1254,10 @@ class QueryDirective {
|
|
|
1253
1254
|
this._viewContainerRef.createEmbeddedView(this._mainTemplateRef, this._viewContext);
|
|
1254
1255
|
}
|
|
1255
1256
|
}
|
|
1256
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.
|
|
1257
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.
|
|
1257
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: QueryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1258
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.5", type: QueryDirective, isStandalone: true, selector: "[etQuery]", inputs: { query: ["etQuery", "query"], cache: ["etQueryCache", "cache"] }, ngImport: i0 }); }
|
|
1258
1259
|
}
|
|
1259
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.
|
|
1260
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: QueryDirective, decorators: [{
|
|
1260
1261
|
type: Directive,
|
|
1261
1262
|
args: [{
|
|
1262
1263
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
@@ -1584,10 +1585,10 @@ class InfinityQueryDirective {
|
|
|
1584
1585
|
this._viewContext.currentQuery = null;
|
|
1585
1586
|
this._data$.next([]);
|
|
1586
1587
|
}
|
|
1587
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.
|
|
1588
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.
|
|
1588
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: InfinityQueryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1589
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.5", type: InfinityQueryDirective, isStandalone: true, selector: "[etInfinityQuery]", inputs: { infinityQuery: ["etInfinityQuery", "infinityQuery"] }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }], exportAs: ["etInfinityQuery"], hostDirectives: [{ directive: i1.DelayableDirective }], ngImport: i0 }); }
|
|
1589
1590
|
}
|
|
1590
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.
|
|
1591
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: InfinityQueryDirective, decorators: [{
|
|
1591
1592
|
type: Directive,
|
|
1592
1593
|
args: [{
|
|
1593
1594
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
@@ -1638,10 +1639,10 @@ class InfinityQueryTriggerDirective {
|
|
|
1638
1639
|
});
|
|
1639
1640
|
this._observer.observe(this._elementRef.nativeElement);
|
|
1640
1641
|
}
|
|
1641
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.
|
|
1642
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.
|
|
1642
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: InfinityQueryTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1643
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.5", type: InfinityQueryTriggerDirective, isStandalone: true, selector: "[etInfinityQueryTrigger], et-infinity-query-trigger", inputs: { scrollContainerSelector: "scrollContainerSelector" }, ngImport: i0 }); }
|
|
1643
1644
|
}
|
|
1644
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.
|
|
1645
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: InfinityQueryTriggerDirective, decorators: [{
|
|
1645
1646
|
type: Directive,
|
|
1646
1647
|
args: [{
|
|
1647
1648
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
@@ -1659,6 +1660,9 @@ class EntityStoreError extends Error {
|
|
|
1659
1660
|
this.name = 'EntityStoreError';
|
|
1660
1661
|
}
|
|
1661
1662
|
}
|
|
1663
|
+
function flatten(arr) {
|
|
1664
|
+
return arr.reduce((acc, val) => acc.concat(val), []);
|
|
1665
|
+
}
|
|
1662
1666
|
class EntityStore {
|
|
1663
1667
|
constructor(_config) {
|
|
1664
1668
|
this._config = _config;
|
|
@@ -1667,7 +1671,8 @@ class EntityStore {
|
|
|
1667
1671
|
}
|
|
1668
1672
|
select(keyOrKeys) {
|
|
1669
1673
|
if (Array.isArray(keyOrKeys)) {
|
|
1670
|
-
|
|
1674
|
+
const _keys = this._normalizeKeys(keyOrKeys);
|
|
1675
|
+
return this._selectMany(_keys);
|
|
1671
1676
|
}
|
|
1672
1677
|
return this._select(keyOrKeys);
|
|
1673
1678
|
}
|
|
@@ -1678,32 +1683,35 @@ class EntityStore {
|
|
|
1678
1683
|
return this._change$.pipe(startWith(null), debounceTime(0), map(() => Array.from(this._dictionary.values()).filter(predicate)), shareReplay({ bufferSize: 1, refCount: true }));
|
|
1679
1684
|
}
|
|
1680
1685
|
set(keyOrKeys, valueOrValues) {
|
|
1681
|
-
|
|
1686
|
+
const _keys = this._normalizeKeys(keyOrKeys);
|
|
1687
|
+
if (Array.isArray(_keys)) {
|
|
1682
1688
|
if (!Array.isArray(valueOrValues)) {
|
|
1683
1689
|
throw new EntityStoreError('When setting multiple keys, values must be an array', {
|
|
1684
|
-
keyOrValues:
|
|
1690
|
+
keyOrValues: _keys,
|
|
1685
1691
|
valueOrValues,
|
|
1686
1692
|
});
|
|
1687
1693
|
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1694
|
+
const _values = (Array.isArray(valueOrValues[0]) ? flatten(valueOrValues) : valueOrValues);
|
|
1695
|
+
for (let i = 0; i < _keys.length; i++) {
|
|
1696
|
+
this._set(_keys[i], _values[i]);
|
|
1690
1697
|
}
|
|
1691
1698
|
}
|
|
1692
1699
|
else {
|
|
1693
|
-
this._set(
|
|
1700
|
+
this._set(_keys, valueOrValues);
|
|
1694
1701
|
}
|
|
1695
|
-
this._change$.next(
|
|
1702
|
+
this._change$.next(_keys);
|
|
1696
1703
|
}
|
|
1697
1704
|
remove(keyOrKeys) {
|
|
1698
|
-
|
|
1699
|
-
|
|
1705
|
+
const _keys = this._normalizeKeys(keyOrKeys);
|
|
1706
|
+
if (Array.isArray(_keys)) {
|
|
1707
|
+
for (const key of _keys) {
|
|
1700
1708
|
this._remove(key);
|
|
1701
1709
|
}
|
|
1702
1710
|
}
|
|
1703
1711
|
else {
|
|
1704
|
-
this._remove(
|
|
1712
|
+
this._remove(_keys);
|
|
1705
1713
|
}
|
|
1706
|
-
this._change$.next(
|
|
1714
|
+
this._change$.next(_keys);
|
|
1707
1715
|
}
|
|
1708
1716
|
logState() {
|
|
1709
1717
|
console.log('EntityStore:', this._config.name, {
|
|
@@ -1750,11 +1758,44 @@ class EntityStore {
|
|
|
1750
1758
|
}
|
|
1751
1759
|
this._dictionary.delete(key);
|
|
1752
1760
|
}
|
|
1761
|
+
_normalizeKeys(keys) {
|
|
1762
|
+
if (Array.isArray(keys)) {
|
|
1763
|
+
if (Array.isArray(keys[0])) {
|
|
1764
|
+
return flatten(keys);
|
|
1765
|
+
}
|
|
1766
|
+
return keys;
|
|
1767
|
+
}
|
|
1768
|
+
return keys;
|
|
1769
|
+
}
|
|
1753
1770
|
}
|
|
1754
1771
|
|
|
1755
1772
|
function mapToPaginated(response) {
|
|
1756
1773
|
return map((items) => ({ ...response, items }));
|
|
1757
1774
|
}
|
|
1775
|
+
// FIXME: This breaks if SubStoreType is an array
|
|
1776
|
+
/**
|
|
1777
|
+
* Use an other store to represent a property of the current entity.
|
|
1778
|
+
*/
|
|
1779
|
+
const insertFrom = (store, { for: key, id }) => switchMap((value) => {
|
|
1780
|
+
if (!value)
|
|
1781
|
+
return of(null);
|
|
1782
|
+
const ids = id(value);
|
|
1783
|
+
if (Array.isArray(ids)) {
|
|
1784
|
+
return store.select(ids).pipe(map((data) => ({ ...value, [key]: data })));
|
|
1785
|
+
}
|
|
1786
|
+
else {
|
|
1787
|
+
return store.select(ids).pipe(map((data) => ({ ...value, [key]: data })));
|
|
1788
|
+
}
|
|
1789
|
+
});
|
|
1790
|
+
/**
|
|
1791
|
+
* Remove entities from a store based on a where function.
|
|
1792
|
+
*/
|
|
1793
|
+
const removeFrom = (store, { where, id }) => {
|
|
1794
|
+
store
|
|
1795
|
+
.selectWhere(where)
|
|
1796
|
+
.pipe(tap((entities) => store.remove(entities.map(id))), take(1))
|
|
1797
|
+
.subscribe();
|
|
1798
|
+
};
|
|
1758
1799
|
|
|
1759
1800
|
class QueryCreator {
|
|
1760
1801
|
constructor(_queryConfig, _client, _store) {
|
|
@@ -2005,6 +2046,7 @@ const buildGqlCacheKey = (config, args) => {
|
|
|
2005
2046
|
return `${queryFirst50Chars}...${queryMiddle25Chars}...${queryLast50Chars}...${vars}`;
|
|
2006
2047
|
};
|
|
2007
2048
|
|
|
2049
|
+
const ET_ARR_PREFIX = 'ET_ARR__';
|
|
2008
2050
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2009
2051
|
class QueryFormGroup extends FormGroup {
|
|
2010
2052
|
patchValue(
|
|
@@ -2148,7 +2190,7 @@ class QueryForm {
|
|
|
2148
2190
|
if (previousValue &&
|
|
2149
2191
|
currentValue &&
|
|
2150
2192
|
!equal(previousValue[resetConditionKey], currentValue[resetConditionKey])) {
|
|
2151
|
-
const defaultValueForKeyToReset = this.
|
|
2193
|
+
const defaultValueForKeyToReset = this._getDefaultValue(formFieldKey);
|
|
2152
2194
|
const currentValueForKeyToReset = currentValue[formFieldKey];
|
|
2153
2195
|
if (equal(defaultValueForKeyToReset, currentValueForKeyToReset)) {
|
|
2154
2196
|
continue;
|
|
@@ -2183,10 +2225,14 @@ class QueryForm {
|
|
|
2183
2225
|
}
|
|
2184
2226
|
}
|
|
2185
2227
|
_getDefaultValue(key) {
|
|
2186
|
-
|
|
2228
|
+
const val = this._defaultValues[key];
|
|
2229
|
+
if (typeof val === 'string' && val.startsWith(ET_ARR_PREFIX)) {
|
|
2230
|
+
return JSON.parse(val.slice(ET_ARR_PREFIX.length));
|
|
2231
|
+
}
|
|
2232
|
+
return val ?? null;
|
|
2187
2233
|
}
|
|
2188
2234
|
_isDefaultValue(key, value) {
|
|
2189
|
-
const normalizedValue = Array.isArray(value) ? JSON.stringify(value) : value;
|
|
2235
|
+
const normalizedValue = Array.isArray(value) ? `${ET_ARR_PREFIX}${JSON.stringify(value)}` : value;
|
|
2190
2236
|
return this._getDefaultValue(key) === normalizedValue;
|
|
2191
2237
|
}
|
|
2192
2238
|
_setupFormGroup() {
|
|
@@ -2204,7 +2250,7 @@ class QueryForm {
|
|
|
2204
2250
|
continue;
|
|
2205
2251
|
}
|
|
2206
2252
|
if (Array.isArray(value)) {
|
|
2207
|
-
defaultValues[key] = JSON.stringify(value)
|
|
2253
|
+
defaultValues[key] = `${ET_ARR_PREFIX}${JSON.stringify(value)}`;
|
|
2208
2254
|
}
|
|
2209
2255
|
else {
|
|
2210
2256
|
defaultValues[key] = value;
|
|
@@ -2360,5 +2406,5 @@ const def = () => null;
|
|
|
2360
2406
|
* Generated bundle index. Do not edit.
|
|
2361
2407
|
*/
|
|
2362
2408
|
|
|
2363
|
-
export { BasicAuthProvider, BearerAuthProvider, CustomHeaderAuthProvider, EntityStore, INFINITY_QUERY_TOKEN, InfinityQuery, InfinityQueryDirective, InfinityQueryTriggerDirective, Query, QueryClient, QueryCreator, QueryDirective, QueryError, QueryField, QueryForm, QueryFormGroup, QueryStore, buildErrorMessage, buildGqlCacheKey, buildQueryString, buildRoute, buildTimestampFromSeconds, castQueryCreatorTypes, computeQueryAuthHeader, computeQueryBody, computeQueryHeaders, computeQueryMethod, computeQueryQueryParams, createInfinityQueryConfig, createQueryCollection, decryptBearer, deepFreeze, def, detectContentTypeHeader, extractExpiresInSeconds, extractQuery, filterFailure, filterNull, filterQueryStates, filterSuccess, forEachHeader, getDefaultHeaders, getResponseUrl, gql, hasHeader, ignoreAutoRefresh, invalidBaseRouteError, invalidBodyError, invalidRouteError, isAutoRefresh, isBasicAuthProvider, isBearerAuthProvider, isClassValidatorError, isCustomHeaderAuthProvider, isEmptyString, isGqlQueryConfig, isNaN$1 as isNaN, isQuery, isQueryCollection, isQueryStateCancelled, isQueryStateFailure, isQueryStateLoading, isQueryStatePrepared, isQueryStateSuccess, isRequestError, isSymfonyError, isSymfonyFormViolationListError, isSymfonyPagerfantaOutOfRangeError, mapToPaginated, mergeHeaders, paginatedEntityValueUpdater, parseAllXhrResponseHeaders, pathParamsMissingInRouteFunctionError, queryStateAlreadyHasKeyError, queryStateCannotTransformError, queryStateDoesNotContainKeyError, request, resetPageOnError, serializeBody, shouldCacheQuery, shouldRetryRequest, skipPaginationPageParamCalculator, switchQueryCollectionState, switchQueryState, takeUntilResponse, transformGql, transformMethod, transformToBoolean, transformToBooleanArray, transformToDate, transformToDateArray, transformToNumber, transformToNumberArray, transformToSort, transformToSortQueryParam, transformToString, transformToStringArray };
|
|
2409
|
+
export { BasicAuthProvider, BearerAuthProvider, CustomHeaderAuthProvider, EntityStore, INFINITY_QUERY_TOKEN, InfinityQuery, InfinityQueryDirective, InfinityQueryTriggerDirective, Query, QueryClient, QueryCreator, QueryDirective, QueryError, QueryField, QueryForm, QueryFormGroup, QueryStore, buildErrorMessage, buildGqlCacheKey, buildQueryString, buildRoute, buildTimestampFromSeconds, castQueryCreatorTypes, computeQueryAuthHeader, computeQueryBody, computeQueryHeaders, computeQueryMethod, computeQueryQueryParams, createInfinityQueryConfig, createQueryCollection, decryptBearer, deepFreeze, def, detectContentTypeHeader, extractExpiresInSeconds, extractQuery, filterFailure, filterNull, filterQueryStates, filterSuccess, forEachHeader, getDefaultHeaders, getResponseUrl, gql, hasHeader, ignoreAutoRefresh, insertFrom, invalidBaseRouteError, invalidBodyError, invalidRouteError, isAutoRefresh, isBasicAuthProvider, isBearerAuthProvider, isClassValidatorError, isCustomHeaderAuthProvider, isEmptyString, isGqlQueryConfig, isNaN$1 as isNaN, isQuery, isQueryCollection, isQueryStateCancelled, isQueryStateFailure, isQueryStateLoading, isQueryStatePrepared, isQueryStateSuccess, isRequestError, isSymfonyError, isSymfonyFormViolationListError, isSymfonyPagerfantaOutOfRangeError, mapToPaginated, mergeHeaders, paginatedEntityValueUpdater, parseAllXhrResponseHeaders, pathParamsMissingInRouteFunctionError, queryStateAlreadyHasKeyError, queryStateCannotTransformError, queryStateDoesNotContainKeyError, removeFrom, request, resetPageOnError, serializeBody, shouldCacheQuery, shouldRetryRequest, skipPaginationPageParamCalculator, switchQueryCollectionState, switchQueryState, takeUntilResponse, transformGql, transformMethod, transformToBoolean, transformToBooleanArray, transformToDate, transformToDateArray, transformToNumber, transformToNumberArray, transformToSort, transformToSortQueryParam, transformToString, transformToStringArray };
|
|
2364
2410
|
//# sourceMappingURL=ethlete-query.mjs.map
|