@quadrel-enterprise-ui/persistence 19.0.13 → 19.0.15
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.
|
@@ -10,12 +10,10 @@ const QD_PERSISTENCE_CONFIG = new InjectionToken('QD_PERSISTENCE_CONFIG');
|
|
|
10
10
|
class QdStringifyer {
|
|
11
11
|
static tryStringify(value) {
|
|
12
12
|
let data = '';
|
|
13
|
-
if (['object', 'boolean', 'number'].includes(typeof value))
|
|
13
|
+
if (['object', 'boolean', 'number'].includes(typeof value))
|
|
14
14
|
data = JSON.stringify(value);
|
|
15
|
-
|
|
16
|
-
if (typeof value === 'string') {
|
|
15
|
+
if (typeof value === 'string')
|
|
17
16
|
data = value;
|
|
18
|
-
}
|
|
19
17
|
return data;
|
|
20
18
|
}
|
|
21
19
|
}
|
|
@@ -104,10 +102,10 @@ class QdCookieStrategyFactory {
|
|
|
104
102
|
return `QD-PRIVATE_${this.config.applicationIdentifier}_${this.config.frontendIdentifier}`;
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
108
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.
|
|
105
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdCookieStrategyFactory, deps: [{ token: QD_PERSISTENCE_CONFIG }, { token: i1.CookieService }, { token: DOCUMENT, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
106
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdCookieStrategyFactory });
|
|
109
107
|
}
|
|
110
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
108
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdCookieStrategyFactory, decorators: [{
|
|
111
109
|
type: Injectable
|
|
112
110
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
113
111
|
type: Inject,
|
|
@@ -134,10 +132,10 @@ class QdStrategyResolverService {
|
|
|
134
132
|
return this.cookieStrategyFactory.getCookieStrategy(scope);
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
138
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.
|
|
135
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdStrategyResolverService, deps: [{ token: QD_PERSISTENCE_CONFIG }, { token: QdCookieStrategyFactory }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
136
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdStrategyResolverService });
|
|
139
137
|
}
|
|
140
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
138
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdStrategyResolverService, decorators: [{
|
|
141
139
|
type: Injectable
|
|
142
140
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
143
141
|
type: Inject,
|
|
@@ -161,10 +159,10 @@ class QdPersistenceService {
|
|
|
161
159
|
const strategy = this.strategyResolverService.resolve(scope);
|
|
162
160
|
strategy.removeItem(key);
|
|
163
161
|
}
|
|
164
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
165
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.
|
|
162
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdPersistenceService, deps: [{ token: QdStrategyResolverService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
163
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdPersistenceService });
|
|
166
164
|
}
|
|
167
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
165
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdPersistenceService, decorators: [{
|
|
168
166
|
type: Injectable
|
|
169
167
|
}], ctorParameters: () => [{ type: QdStrategyResolverService }] });
|
|
170
168
|
|
|
@@ -175,11 +173,11 @@ class QdPersistenceModule {
|
|
|
175
173
|
providers: [{ provide: QD_PERSISTENCE_CONFIG, useValue: config }]
|
|
176
174
|
};
|
|
177
175
|
}
|
|
178
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
179
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.
|
|
180
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.
|
|
176
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdPersistenceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
177
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.18", ngImport: i0, type: QdPersistenceModule });
|
|
178
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdPersistenceModule, providers: [QdPersistenceService, QdStrategyResolverService, QdCookieStrategyFactory] });
|
|
181
179
|
}
|
|
182
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
180
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: QdPersistenceModule, decorators: [{
|
|
183
181
|
type: NgModule,
|
|
184
182
|
args: [{
|
|
185
183
|
providers: [QdPersistenceService, QdStrategyResolverService, QdCookieStrategyFactory]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quadrel-enterprise-ui-persistence.mjs","sources":["../../../../libs/qd-persistence/src/lib/persistence-config.token.ts","../../../../libs/qd-persistence/src/lib/utils/stringifyer.ts","../../../../libs/qd-persistence/src/lib/strategy/cookie-strategy/cookie-strategy.ts","../../../../libs/qd-persistence/src/lib/strategy/cookie-strategy/cookie-strategy.factory.ts","../../../../libs/qd-persistence/src/lib/strategy/strategy-resolver.service.ts","../../../../libs/qd-persistence/src/lib/persistence.service.ts","../../../../libs/qd-persistence/src/lib/persistence.module.ts","../../../../libs/qd-persistence/src/quadrel-enterprise-ui-persistence.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { QdPersistenceConfig } from './model/persistence-config';\n\nexport const QD_PERSISTENCE_CONFIG = new InjectionToken<QdPersistenceConfig>('QD_PERSISTENCE_CONFIG');\n","export class QdStringifyer {\n static tryStringify<T>(value: T): string {\n let data = '';\n\n if (['object', 'boolean', 'number'].includes(typeof value)) {\n data = JSON.stringify(value);\n }\n\n if (typeof value === 'string') {\n data = value;\n }\n\n return data;\n }\n}\n","import { Inject, Optional } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\nimport { CookieService } from 'ngx-cookie-service';\nimport { QdStringifyer } from '../../utils/stringifyer';\nimport { QdPersistStrategy } from '../persist-strategy';\n\ntype QdPersistedData = { [key: string]: unknown };\n\n/**\n * This strategy uses cookies to make the data visible between different subdomains of the host 'bazg.admin.ch'.\n * In contrast, local storage would make the data only visible for a specific subdomain.\n * If this strategy is used locally, the cookies will be saved for the domain 'localhost'.\n * For the future another strategy is planned that saves the data in a backend service and that will also allow data\n * to be shared between websites with different hosts.\n */\nexport class QdCookieStrategy implements QdPersistStrategy {\n private cookieExpiresDays = 365 * 10;\n\n constructor(\n private cookieName: string,\n private cookieService: CookieService,\n @Optional() @Inject(DOCUMENT) private document?: Document\n ) {}\n\n private get cookieDomain(): string {\n if (this.document?.location?.hostname === 'localhost') return 'localhost';\n return '.bazg.admin.ch';\n }\n\n get persistedData(): QdPersistedData {\n try {\n const parsed = JSON.parse(this.cookieService.get(this.cookieName));\n\n if (typeof parsed !== 'object' || Array.isArray(parsed)) return {};\n\n return parsed ?? {};\n } catch {\n return {};\n }\n }\n\n private persistData(data: QdPersistedData) {\n this.cookieService.set(this.cookieName, JSON.stringify(data), this.cookieExpiresDays, '/', this.cookieDomain);\n }\n\n setItem<T>(key: string, value: T): void {\n const data = this.persistedData;\n data[key] = QdStringifyer.tryStringify<T>(value);\n\n this.persistData(data);\n }\n\n getItem<T>(key: string): T | null {\n try {\n return JSON.parse(<string>this.persistedData[key]);\n } catch {\n return (this.persistedData[key] as T) ?? null;\n }\n }\n\n removeItem(key: string): void {\n const data = this.persistedData;\n delete data[key];\n\n this.persistData(data);\n }\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\nimport { CookieService } from 'ngx-cookie-service';\nimport { QdCookieStrategy } from './cookie-strategy';\nimport { QD_PERSISTENCE_CONFIG } from '../../persistence-config.token';\nimport { QdPersistenceConfig } from '../../model/persistence-config';\nimport { QdPersistScope } from '../../model/persistence-types';\nimport { QdPersistStrategy } from '../persist-strategy';\n\n@Injectable()\nexport class QdCookieStrategyFactory {\n constructor(\n @Inject(QD_PERSISTENCE_CONFIG) private config: QdPersistenceConfig,\n private cookieService: CookieService,\n @Optional() @Inject(DOCUMENT) private document?: Document\n ) {}\n\n getCookieStrategy(scope: QdPersistScope): QdPersistStrategy {\n return new QdCookieStrategy(this.getCookieName(scope), this.cookieService, document);\n }\n\n private getCookieName(scope: QdPersistScope): string {\n switch (scope) {\n case 'bazg':\n return 'QD-BAZG';\n case 'application':\n return `QD-APPLICATION_${this.config.applicationIdentifier}`;\n case 'private':\n return `QD-PRIVATE_${this.config.applicationIdentifier}_${this.config.frontendIdentifier}`;\n }\n }\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { QdPersistScope } from '../model/persistence-types';\nimport { QdPersistStrategy } from './persist-strategy';\nimport { QD_PERSISTENCE_CONFIG } from '../persistence-config.token';\nimport { QdPersistenceConfig } from '../model/persistence-config';\nimport { QdCookieStrategyFactory } from './cookie-strategy/cookie-strategy.factory';\n\n@Injectable()\nexport class QdStrategyResolverService {\n constructor(\n @Inject(QD_PERSISTENCE_CONFIG) private config: QdPersistenceConfig,\n private cookieStrategyFactory: QdCookieStrategyFactory\n ) {}\n\n resolve(scope: QdPersistScope): QdPersistStrategy {\n /* istanbul ignore next (remove comment when another strategy is added) */\n switch (this.config.persistStrategy) {\n case 'cookie':\n default:\n return this.cookieStrategyFactory.getCookieStrategy(scope);\n }\n }\n}\n","import { Injectable } from '@angular/core';\nimport { QdStrategyResolverService } from './strategy/strategy-resolver.service';\nimport { QdPersistScope } from './model/persistence-types';\n\n@Injectable()\nexport class QdPersistenceService {\n constructor(private strategyResolverService: QdStrategyResolverService) {}\n\n write<T>(key: string, data: T, scope: QdPersistScope = 'bazg'): void {\n const strategy = this.strategyResolverService.resolve(scope);\n\n strategy.setItem<T>(key, data);\n }\n\n read<T>(key: string, scope: QdPersistScope = 'bazg'): T | null {\n const strategy = this.strategyResolverService.resolve(scope);\n\n return strategy.getItem<T>(key);\n }\n\n delete(key: string, scope: QdPersistScope = 'bazg'): void {\n const strategy = this.strategyResolverService.resolve(scope);\n\n strategy.removeItem(key);\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { QdPersistenceConfig } from './model/persistence-config';\nimport { QD_PERSISTENCE_CONFIG } from './persistence-config.token';\nimport { QdPersistenceService } from './persistence.service';\nimport { QdStrategyResolverService } from './strategy/strategy-resolver.service';\nimport { QdCookieStrategyFactory } from './strategy/cookie-strategy/cookie-strategy.factory';\n\n@NgModule({\n providers: [QdPersistenceService, QdStrategyResolverService, QdCookieStrategyFactory]\n})\nexport class QdPersistenceModule {\n static forRoot(config: QdPersistenceConfig): ModuleWithProviders<QdPersistenceModule> {\n return {\n ngModule: QdPersistenceModule,\n providers: [{ provide: QD_PERSISTENCE_CONFIG, useValue: config }]\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.QdCookieStrategyFactory","i1.QdStrategyResolverService"],"mappings":";;;;;;;AAGO,MAAM,qBAAqB,GAAG,IAAI,cAAc,CAAsB,uBAAuB,CAAC;;MCHxF,aAAa,CAAA;IACxB,OAAO,YAAY,CAAI,KAAQ,EAAA;QAC7B,IAAI,IAAI,GAAG,EAAE;AAEb,QAAA,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,EAAE;AAC1D,YAAA,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;;AAG9B,QAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,IAAI,GAAG,KAAK;;AAGd,QAAA,OAAO,IAAI;;AAEd;;ACND;;;;;;AAMG;AACH,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB,CAAA;AAIjB,IAAA,UAAA;AACA,IAAA,aAAA;AAC8B,IAAA,QAAA;AALhC,IAAA,iBAAiB,GAAG,GAAG,GAAG,EAAE;AAEpC,IAAA,WAAA,CACU,UAAkB,EAClB,aAA4B,EACE,QAAmB,EAAA;QAFjD,IAAU,CAAA,UAAA,GAAV,UAAU;QACV,IAAa,CAAA,aAAA,GAAb,aAAa;QACiB,IAAQ,CAAA,QAAA,GAAR,QAAQ;;AAGhD,IAAA,IAAY,YAAY,GAAA;QACtB,IAAI,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,KAAK,WAAW;AAAE,YAAA,OAAO,WAAW;AACzE,QAAA,OAAO,gBAAgB;;AAGzB,IAAA,IAAI,aAAa,GAAA;AACf,QAAA,I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iBAAA;;;ACTD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"quadrel-enterprise-ui-persistence.mjs","sources":["../../../../libs/qd-persistence/src/lib/persistence-config.token.ts","../../../../libs/qd-persistence/src/lib/utils/stringifyer.ts","../../../../libs/qd-persistence/src/lib/strategy/cookie-strategy/cookie-strategy.ts","../../../../libs/qd-persistence/src/lib/strategy/cookie-strategy/cookie-strategy.factory.ts","../../../../libs/qd-persistence/src/lib/strategy/strategy-resolver.service.ts","../../../../libs/qd-persistence/src/lib/persistence.service.ts","../../../../libs/qd-persistence/src/lib/persistence.module.ts","../../../../libs/qd-persistence/src/quadrel-enterprise-ui-persistence.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { QdPersistenceConfig } from './model/persistence-config';\n\nexport const QD_PERSISTENCE_CONFIG = new InjectionToken<QdPersistenceConfig>('QD_PERSISTENCE_CONFIG');\n","export class QdStringifyer {\n static tryStringify<T>(value: T): string {\n let data = '';\n\n if (['object', 'boolean', 'number'].includes(typeof value)) data = JSON.stringify(value);\n\n if (typeof value === 'string') data = value;\n\n return data;\n }\n}\n","import { Inject, Optional } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\nimport { CookieService } from 'ngx-cookie-service';\nimport { QdStringifyer } from '../../utils/stringifyer';\nimport { QdPersistStrategy } from '../persist-strategy';\n\ntype QdPersistedData = { [key: string]: unknown };\n\n/**\n * This strategy uses cookies to make the data visible between different subdomains of the host 'bazg.admin.ch'.\n * In contrast, local storage would make the data only visible for a specific subdomain.\n * If this strategy is used locally, the cookies will be saved for the domain 'localhost'.\n * For the future another strategy is planned that saves the data in a backend service and that will also allow data\n * to be shared between websites with different hosts.\n */\nexport class QdCookieStrategy implements QdPersistStrategy {\n private cookieExpiresDays = 365 * 10;\n\n constructor(\n private cookieName: string,\n private cookieService: CookieService,\n @Optional() @Inject(DOCUMENT) private document?: Document\n ) {}\n\n private get cookieDomain(): string {\n if (this.document?.location?.hostname === 'localhost') return 'localhost';\n return '.bazg.admin.ch';\n }\n\n get persistedData(): QdPersistedData {\n try {\n const parsed = JSON.parse(this.cookieService.get(this.cookieName));\n\n if (typeof parsed !== 'object' || Array.isArray(parsed)) return {};\n\n return parsed ?? {};\n } catch {\n return {};\n }\n }\n\n private persistData(data: QdPersistedData) {\n this.cookieService.set(this.cookieName, JSON.stringify(data), this.cookieExpiresDays, '/', this.cookieDomain);\n }\n\n setItem<T>(key: string, value: T): void {\n const data = this.persistedData;\n data[key] = QdStringifyer.tryStringify<T>(value);\n\n this.persistData(data);\n }\n\n getItem<T>(key: string): T | null {\n try {\n return JSON.parse(<string>this.persistedData[key]);\n } catch {\n return (this.persistedData[key] as T) ?? null;\n }\n }\n\n removeItem(key: string): void {\n const data = this.persistedData;\n delete data[key];\n\n this.persistData(data);\n }\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\nimport { CookieService } from 'ngx-cookie-service';\nimport { QdCookieStrategy } from './cookie-strategy';\nimport { QD_PERSISTENCE_CONFIG } from '../../persistence-config.token';\nimport { QdPersistenceConfig } from '../../model/persistence-config';\nimport { QdPersistScope } from '../../model/persistence-types';\nimport { QdPersistStrategy } from '../persist-strategy';\n\n@Injectable()\nexport class QdCookieStrategyFactory {\n constructor(\n @Inject(QD_PERSISTENCE_CONFIG) private config: QdPersistenceConfig,\n private cookieService: CookieService,\n @Optional() @Inject(DOCUMENT) private document?: Document\n ) {}\n\n getCookieStrategy(scope: QdPersistScope): QdPersistStrategy {\n return new QdCookieStrategy(this.getCookieName(scope), this.cookieService, document);\n }\n\n private getCookieName(scope: QdPersistScope): string {\n switch (scope) {\n case 'bazg':\n return 'QD-BAZG';\n case 'application':\n return `QD-APPLICATION_${this.config.applicationIdentifier}`;\n case 'private':\n return `QD-PRIVATE_${this.config.applicationIdentifier}_${this.config.frontendIdentifier}`;\n }\n }\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { QdPersistScope } from '../model/persistence-types';\nimport { QdPersistStrategy } from './persist-strategy';\nimport { QD_PERSISTENCE_CONFIG } from '../persistence-config.token';\nimport { QdPersistenceConfig } from '../model/persistence-config';\nimport { QdCookieStrategyFactory } from './cookie-strategy/cookie-strategy.factory';\n\n@Injectable()\nexport class QdStrategyResolverService {\n constructor(\n @Inject(QD_PERSISTENCE_CONFIG) private config: QdPersistenceConfig,\n private cookieStrategyFactory: QdCookieStrategyFactory\n ) {}\n\n resolve(scope: QdPersistScope): QdPersistStrategy {\n /* istanbul ignore next (remove comment when another strategy is added) */\n switch (this.config.persistStrategy) {\n case 'cookie':\n default:\n return this.cookieStrategyFactory.getCookieStrategy(scope);\n }\n }\n}\n","import { Injectable } from '@angular/core';\nimport { QdStrategyResolverService } from './strategy/strategy-resolver.service';\nimport { QdPersistScope } from './model/persistence-types';\n\n@Injectable()\nexport class QdPersistenceService {\n constructor(private strategyResolverService: QdStrategyResolverService) {}\n\n write<T>(key: string, data: T, scope: QdPersistScope = 'bazg'): void {\n const strategy = this.strategyResolverService.resolve(scope);\n\n strategy.setItem<T>(key, data);\n }\n\n read<T>(key: string, scope: QdPersistScope = 'bazg'): T | null {\n const strategy = this.strategyResolverService.resolve(scope);\n\n return strategy.getItem<T>(key);\n }\n\n delete(key: string, scope: QdPersistScope = 'bazg'): void {\n const strategy = this.strategyResolverService.resolve(scope);\n\n strategy.removeItem(key);\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { QdPersistenceConfig } from './model/persistence-config';\nimport { QD_PERSISTENCE_CONFIG } from './persistence-config.token';\nimport { QdPersistenceService } from './persistence.service';\nimport { QdStrategyResolverService } from './strategy/strategy-resolver.service';\nimport { QdCookieStrategyFactory } from './strategy/cookie-strategy/cookie-strategy.factory';\n\n@NgModule({\n providers: [QdPersistenceService, QdStrategyResolverService, QdCookieStrategyFactory]\n})\nexport class QdPersistenceModule {\n static forRoot(config: QdPersistenceConfig): ModuleWithProviders<QdPersistenceModule> {\n return {\n ngModule: QdPersistenceModule,\n providers: [{ provide: QD_PERSISTENCE_CONFIG, useValue: config }]\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.QdCookieStrategyFactory","i1.QdStrategyResolverService"],"mappings":";;;;;;;AAGO,MAAM,qBAAqB,GAAG,IAAI,cAAc,CAAsB,uBAAuB,CAAC;;MCHxF,aAAa,CAAA;IACxB,OAAO,YAAY,CAAI,KAAQ,EAAA;QAC7B,IAAI,IAAI,GAAG,EAAE;AAEb,QAAA,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC;AAAE,YAAA,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;QAExF,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,IAAI,GAAG,KAAK;AAE3C,QAAA,OAAO,IAAI;;AAEd;;ACFD;;;;;;AAMG;AACH,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB,CAAA;AAIjB,IAAA,UAAA;AACA,IAAA,aAAA;AAC8B,IAAA,QAAA;AALhC,IAAA,iBAAiB,GAAG,GAAG,GAAG,EAAE;AAEpC,IAAA,WAAA,CACU,UAAkB,EAClB,aAA4B,EACE,QAAmB,EAAA;QAFjD,IAAU,CAAA,UAAA,GAAV,UAAU;QACV,IAAa,CAAA,aAAA,GAAb,aAAa;QACiB,IAAQ,CAAA,QAAA,GAAR,QAAQ;;AAGhD,IAAA,IAAY,YAAY,GAAA;QACtB,IAAI,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,KAAK,WAAW;AAAE,YAAA,OAAO,WAAW;AACzE,QAAA,OAAO,gBAAgB;;AAGzB,IAAA,IAAI,aAAa,GAAA;AACf,QAAA,IAAI;AACF,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAElE,IAAI,OAAO,MA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0.
|
|
3
|
+
"version": "19.0.15",
|
|
4
4
|
"description": "Library for the persistence of data",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@angular/common": "^19.2.9",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"tslib": "^2.6.3",
|
|
11
|
-
"ngx-cookie-service": "^
|
|
11
|
+
"ngx-cookie-service": "^19.1.2"
|
|
12
12
|
},
|
|
13
13
|
"jestSonar": {
|
|
14
14
|
"reportPath": "../../coverage/libs/qd-persistence/",
|