@nestwork/chevron 1.0.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.
- package/LICENSE +21 -0
- package/README.md +82 -0
- package/dist/chevron-core.module.d.ts +37 -0
- package/dist/chevron-core.module.d.ts.map +1 -0
- package/dist/chevron-core.module.js +296 -0
- package/dist/chevron-core.module.js.map +1 -0
- package/dist/chevron.constants.d.ts +3 -0
- package/dist/chevron.constants.d.ts.map +1 -0
- package/dist/chevron.constants.js +6 -0
- package/dist/chevron.constants.js.map +1 -0
- package/dist/chevron.module-definition.d.ts +5 -0
- package/dist/chevron.module-definition.d.ts.map +1 -0
- package/dist/chevron.module-definition.js +12 -0
- package/dist/chevron.module-definition.js.map +1 -0
- package/dist/chevron.module.d.ts +8 -0
- package/dist/chevron.module.d.ts.map +1 -0
- package/dist/chevron.module.js +36 -0
- package/dist/chevron.module.js.map +1 -0
- package/dist/chevron.registry.d.ts +32 -0
- package/dist/chevron.registry.d.ts.map +1 -0
- package/dist/chevron.registry.js +171 -0
- package/dist/chevron.registry.js.map +1 -0
- package/dist/chevron.service.d.ts +16 -0
- package/dist/chevron.service.d.ts.map +1 -0
- package/dist/chevron.service.js +53 -0
- package/dist/chevron.service.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/chevron-driver-options.interface.d.ts +15 -0
- package/dist/interfaces/chevron-driver-options.interface.d.ts.map +1 -0
- package/dist/interfaces/chevron-driver-options.interface.js +3 -0
- package/dist/interfaces/chevron-driver-options.interface.js.map +1 -0
- package/dist/interfaces/chevron-options.interface.d.ts +31 -0
- package/dist/interfaces/chevron-options.interface.d.ts.map +1 -0
- package/dist/interfaces/chevron-options.interface.js +3 -0
- package/dist/interfaces/chevron-options.interface.js.map +1 -0
- package/dist/interfaces/chevron-resolver.type.d.ts +4 -0
- package/dist/interfaces/chevron-resolver.type.d.ts.map +1 -0
- package/dist/interfaces/chevron-resolver.type.js +3 -0
- package/dist/interfaces/chevron-resolver.type.js.map +1 -0
- package/dist/interfaces/chevron-storage.interface.d.ts +10 -0
- package/dist/interfaces/chevron-storage.interface.d.ts.map +1 -0
- package/dist/interfaces/chevron-storage.interface.js +3 -0
- package/dist/interfaces/chevron-storage.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +5 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/storage/create-chevron-storage.d.ts +4 -0
- package/dist/storage/create-chevron-storage.d.ts.map +1 -0
- package/dist/storage/create-chevron-storage.js +40 -0
- package/dist/storage/create-chevron-storage.js.map +1 -0
- package/dist/storage/in-memory-chevron.storage.d.ts +11 -0
- package/dist/storage/in-memory-chevron.storage.d.ts.map +1 -0
- package/dist/storage/in-memory-chevron.storage.js +35 -0
- package/dist/storage/in-memory-chevron.storage.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/chevron-process-state.d.ts +8 -0
- package/dist/utils/chevron-process-state.d.ts.map +1 -0
- package/dist/utils/chevron-process-state.js +38 -0
- package/dist/utils/chevron-process-state.js.map +1 -0
- package/dist/utils/chevron.utils.d.ts +17 -0
- package/dist/utils/chevron.utils.d.ts.map +1 -0
- package/dist/utils/chevron.utils.js +76 -0
- package/dist/utils/chevron.utils.js.map +1 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nestwork contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# @nestwork/chevron
|
|
2
|
+
|
|
3
|
+
Feature flags for NestJS applications.
|
|
4
|
+
|
|
5
|
+
## Layout
|
|
6
|
+
|
|
7
|
+
| Path | Purpose |
|
|
8
|
+
| --------------- | ----------------------------------------------------- |
|
|
9
|
+
| `src/` | Library source (compiled to `dist/`) |
|
|
10
|
+
| `sample/` | Private integration apps (`link:../../`) |
|
|
11
|
+
| `tools/eslint/` | Shared ESLint flat config (repo-local, not published) |
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
- Node.js 20+; **22 recommended** — `.nvmrc` / `.node-version`
|
|
16
|
+
- pnpm 11.25.0 — `corepack enable`
|
|
17
|
+
|
|
18
|
+
## Commands
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
pnpm install
|
|
22
|
+
pnpm build # src → dist/
|
|
23
|
+
pnpm build:all # lib + samples
|
|
24
|
+
pnpm test # lib unit tests
|
|
25
|
+
pnpm test:all # lib + sample tests
|
|
26
|
+
pnpm lint
|
|
27
|
+
pnpm check-types
|
|
28
|
+
pnpm dev:sample # lib watch + sample/000-in-memory-app
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick start
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { Injectable, Module } from '@nestjs/common';
|
|
35
|
+
import { ChevronModule, InjectChevron, ChevronService } from '@nestwork/chevron';
|
|
36
|
+
|
|
37
|
+
@Module({
|
|
38
|
+
imports: [
|
|
39
|
+
ChevronModule.forRoot({
|
|
40
|
+
features: {
|
|
41
|
+
'new-checkout': true,
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
45
|
+
})
|
|
46
|
+
export class AppModule {}
|
|
47
|
+
|
|
48
|
+
@Injectable()
|
|
49
|
+
export class CheckoutService {
|
|
50
|
+
constructor(@InjectChevron() private readonly features: ChevronService) {}
|
|
51
|
+
|
|
52
|
+
async run(): Promise<void> {
|
|
53
|
+
if (await this.features.active('new-checkout')) {
|
|
54
|
+
// ...
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
See `sample/000-in-memory-app` for default + async named gates.
|
|
61
|
+
|
|
62
|
+
## Named gates and injection scope
|
|
63
|
+
|
|
64
|
+
- **Default chevron** (no `name`) is global — `@InjectChevron()` works in any module without re-importing `ChevronModule`.
|
|
65
|
+
- **Named chevrons** default to module scope — inject `@InjectChevron('billing')` only in modules that import `ChevronModule.forRoot({ name: 'billing' })`. The feature module must **export** `ChevronModule` for importers.
|
|
66
|
+
- **App-wide named chevron** — set `isGlobal: true` on `forRoot` / `forRootAsync`.
|
|
67
|
+
|
|
68
|
+
## Storage
|
|
69
|
+
|
|
70
|
+
Default storage is in-memory (`{ driver: 'memory' }`). Class-token and `useClass` registrations use Nest `ModuleRef.create()` for constructor DI.
|
|
71
|
+
|
|
72
|
+
## Release
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
pnpm changeset
|
|
76
|
+
pnpm version-packages
|
|
77
|
+
pnpm release
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Code style
|
|
81
|
+
|
|
82
|
+
Prettier, ESLint (type-checked flat config), Husky + lint-staged, Jest.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DynamicModule, OnApplicationBootstrap, OnApplicationShutdown, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { ModuleRef } from '@nestjs/core';
|
|
3
|
+
import { ChevronModuleAsyncOptions, ChevronModuleOptions } from './interfaces';
|
|
4
|
+
export declare class ChevronCoreModule implements OnModuleInit, OnApplicationBootstrap, OnModuleDestroy, OnApplicationShutdown {
|
|
5
|
+
private readonly options;
|
|
6
|
+
private readonly moduleRef;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor(options: ChevronModuleOptions, moduleRef: ModuleRef);
|
|
9
|
+
static forRoot(options?: Partial<ChevronModuleOptions>): DynamicModule;
|
|
10
|
+
static forRootAsync(asyncOptions: ChevronModuleAsyncOptions): DynamicModule;
|
|
11
|
+
onModuleInit(): void;
|
|
12
|
+
onApplicationBootstrap(): void;
|
|
13
|
+
onModuleDestroy(): void;
|
|
14
|
+
onApplicationShutdown(): Promise<void>;
|
|
15
|
+
private lookupStorage;
|
|
16
|
+
private static isUnknownElementError;
|
|
17
|
+
private static createGateProviders;
|
|
18
|
+
private static createSyncStorageProvider;
|
|
19
|
+
private static createAsyncStorageProvider;
|
|
20
|
+
private static createRegistryProvider;
|
|
21
|
+
private static createServiceProvider;
|
|
22
|
+
private static createAsyncOptionsProviders;
|
|
23
|
+
private static createAsyncOptionsProvider;
|
|
24
|
+
private static buildRegistry;
|
|
25
|
+
private static instantiateStorage;
|
|
26
|
+
private static createStorageInstance;
|
|
27
|
+
private static invokeStorageFactory;
|
|
28
|
+
private static resolveInjectedDependencies;
|
|
29
|
+
private static getOptional;
|
|
30
|
+
private static isUseClassShorthand;
|
|
31
|
+
private static isUseFactoryShorthand;
|
|
32
|
+
private static isUseExistingShorthand;
|
|
33
|
+
private static isUseFactoryProvider;
|
|
34
|
+
private static isUseClassProvider;
|
|
35
|
+
private static isUseExistingProvider;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=chevron-core.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chevron-core.module.d.ts","sourceRoot":"","sources":["../src/chevron-core.module.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAKb,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,YAAY,EAGf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAsBzC,OAAO,EACH,yBAAyB,EACzB,oBAAoB,EAIvB,MAAM,cAAc,CAAC;AAGtB,qBACa,iBAAkB,YAAW,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,qBAAqB;IAK9G,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAL9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;gBAIxC,OAAO,EAAE,oBAAoB,EAC7B,SAAS,EAAE,SAAS;IAGzC,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,OAAO,CAAC,oBAAoB,CAAM,GAAG,aAAa;IAY1E,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,yBAAyB,GAAG,aAAa;IAqB3E,YAAY,IAAI,IAAI;IAIpB,sBAAsB,IAAI,IAAI;IAI9B,eAAe,IAAI,IAAI;IAIjB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IA2B5C,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAIpC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAQlC,OAAO,CAAC,MAAM,CAAC,yBAAyB;IASxC,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAoBzC,OAAO,CAAC,MAAM,CAAC,sBAAsB;IASrC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAQpC,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAU1C,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAoBzC,OAAO,CAAC,MAAM,CAAC,aAAa;IAU5B,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAmDjC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAWpC,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAYnC,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAqB1C,OAAO,CAAC,MAAM,CAAC,WAAW;IAY1B,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAWlC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAYpC,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAWrC,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAcnC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAYjC,OAAO,CAAC,MAAM,CAAC,qBAAqB;CAYvC"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var ChevronCoreModule_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ChevronCoreModule = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const core_1 = require("@nestjs/core");
|
|
19
|
+
const chevron_process_state_1 = require("./utils/chevron-process-state");
|
|
20
|
+
const chevron_utils_1 = require("./utils/chevron.utils");
|
|
21
|
+
const chevron_module_definition_1 = require("./chevron.module-definition");
|
|
22
|
+
const chevron_registry_1 = require("./chevron.registry");
|
|
23
|
+
const chevron_service_1 = require("./chevron.service");
|
|
24
|
+
const create_chevron_storage_1 = require("./storage/create-chevron-storage");
|
|
25
|
+
let ChevronCoreModule = ChevronCoreModule_1 = class ChevronCoreModule {
|
|
26
|
+
options;
|
|
27
|
+
moduleRef;
|
|
28
|
+
logger = new common_1.Logger(ChevronCoreModule_1.name);
|
|
29
|
+
constructor(options, moduleRef) {
|
|
30
|
+
this.options = options;
|
|
31
|
+
this.moduleRef = moduleRef;
|
|
32
|
+
}
|
|
33
|
+
static forRoot(options = {}) {
|
|
34
|
+
const resolved = (0, chevron_utils_1.withDefaultChevronOptions)(options);
|
|
35
|
+
const gateName = (0, chevron_utils_1.getChevronName)(resolved);
|
|
36
|
+
return {
|
|
37
|
+
module: ChevronCoreModule_1,
|
|
38
|
+
global: (0, chevron_utils_1.resolveIsGlobal)(resolved),
|
|
39
|
+
providers: [{ provide: chevron_module_definition_1.CHEVRON_MODULE_OPTIONS, useValue: resolved }, ...this.createGateProviders(gateName)],
|
|
40
|
+
exports: [(0, chevron_utils_1.getChevronToken)(gateName)],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
static forRootAsync(asyncOptions) {
|
|
44
|
+
const registrationGateName = (0, chevron_utils_1.resolveAsyncRegistrationChevronName)(asyncOptions);
|
|
45
|
+
return {
|
|
46
|
+
module: ChevronCoreModule_1,
|
|
47
|
+
imports: asyncOptions.imports,
|
|
48
|
+
global: (0, chevron_utils_1.resolveIsGlobal)({
|
|
49
|
+
name: asyncOptions.name,
|
|
50
|
+
isGlobal: asyncOptions.isGlobal,
|
|
51
|
+
}),
|
|
52
|
+
providers: [
|
|
53
|
+
...this.createAsyncOptionsProviders(asyncOptions),
|
|
54
|
+
this.createAsyncStorageProvider(asyncOptions, registrationGateName),
|
|
55
|
+
this.createRegistryProvider(registrationGateName),
|
|
56
|
+
this.createServiceProvider(registrationGateName),
|
|
57
|
+
...(asyncOptions.extraProviders ?? []),
|
|
58
|
+
],
|
|
59
|
+
exports: [(0, chevron_utils_1.getChevronToken)(registrationGateName)],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
onModuleInit() {
|
|
63
|
+
(0, chevron_process_state_1.assertGateNameNotExplicitDefault)(this.options);
|
|
64
|
+
}
|
|
65
|
+
onApplicationBootstrap() {
|
|
66
|
+
(0, chevron_process_state_1.assertGateNameAvailable)((0, chevron_utils_1.getChevronName)(this.options));
|
|
67
|
+
}
|
|
68
|
+
onModuleDestroy() {
|
|
69
|
+
(0, chevron_process_state_1.releaseRegisteredGateName)((0, chevron_utils_1.getChevronName)(this.options));
|
|
70
|
+
}
|
|
71
|
+
async onApplicationShutdown() {
|
|
72
|
+
const gateName = (0, chevron_utils_1.getChevronName)(this.options);
|
|
73
|
+
if ((0, chevron_process_state_1.isGateShutdownComplete)(gateName)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
(0, chevron_process_state_1.markGateShutdownComplete)(gateName);
|
|
77
|
+
try {
|
|
78
|
+
const storage = this.lookupStorage(gateName);
|
|
79
|
+
if (storage === undefined) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (typeof storage.onModuleDestroy !== 'function' && typeof storage.destroy === 'function') {
|
|
83
|
+
await storage.destroy();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
88
|
+
this.logger.error(message);
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
(0, chevron_process_state_1.releaseRegisteredGateName)(gateName);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
lookupStorage(gateName) {
|
|
95
|
+
try {
|
|
96
|
+
return this.moduleRef.get((0, chevron_utils_1.getChevronStorageToken)(gateName), {
|
|
97
|
+
strict: false,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (ChevronCoreModule_1.isUnknownElementError(error)) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
static isUnknownElementError(error) {
|
|
108
|
+
return error instanceof Error && error.constructor.name === 'UnknownElementException';
|
|
109
|
+
}
|
|
110
|
+
static createGateProviders(gateName) {
|
|
111
|
+
return [
|
|
112
|
+
this.createSyncStorageProvider(gateName),
|
|
113
|
+
this.createRegistryProvider(gateName),
|
|
114
|
+
this.createServiceProvider(gateName),
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
static createSyncStorageProvider(gateName) {
|
|
118
|
+
return {
|
|
119
|
+
provide: (0, chevron_utils_1.getChevronStorageToken)(gateName),
|
|
120
|
+
useFactory: (options, moduleRef) => this.instantiateStorage((0, chevron_utils_1.withDefaultChevronOptions)(options).storage, moduleRef),
|
|
121
|
+
inject: [chevron_module_definition_1.CHEVRON_MODULE_OPTIONS, core_1.ModuleRef],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
static createAsyncStorageProvider(asyncOptions, gateName) {
|
|
125
|
+
if (asyncOptions.storageFactory !== undefined) {
|
|
126
|
+
return {
|
|
127
|
+
provide: (0, chevron_utils_1.getChevronStorageToken)(gateName),
|
|
128
|
+
useFactory: async (options) => asyncOptions.storageFactory(options),
|
|
129
|
+
inject: [chevron_module_definition_1.CHEVRON_MODULE_OPTIONS],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
provide: (0, chevron_utils_1.getChevronStorageToken)(gateName),
|
|
134
|
+
useFactory: async (options, moduleRef) => this.instantiateStorage((0, chevron_utils_1.withDefaultChevronOptions)(options).storage, moduleRef),
|
|
135
|
+
inject: [chevron_module_definition_1.CHEVRON_MODULE_OPTIONS, core_1.ModuleRef],
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
static createRegistryProvider(gateName) {
|
|
139
|
+
return {
|
|
140
|
+
provide: (0, chevron_utils_1.getChevronRegistryToken)(gateName),
|
|
141
|
+
useFactory: (storage, options) => this.buildRegistry(storage, options),
|
|
142
|
+
inject: [(0, chevron_utils_1.getChevronStorageToken)(gateName), chevron_module_definition_1.CHEVRON_MODULE_OPTIONS],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
static createServiceProvider(gateName) {
|
|
146
|
+
return {
|
|
147
|
+
provide: (0, chevron_utils_1.getChevronToken)(gateName),
|
|
148
|
+
useFactory: (registry) => new chevron_service_1.ChevronService(registry),
|
|
149
|
+
inject: [(0, chevron_utils_1.getChevronRegistryToken)(gateName)],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
static createAsyncOptionsProviders(options) {
|
|
153
|
+
if (options.useExisting !== undefined || options.useFactory !== undefined) {
|
|
154
|
+
return [this.createAsyncOptionsProvider(options)];
|
|
155
|
+
}
|
|
156
|
+
const useClass = options.useClass;
|
|
157
|
+
return [this.createAsyncOptionsProvider(options), { provide: useClass, useClass }];
|
|
158
|
+
}
|
|
159
|
+
static createAsyncOptionsProvider(options) {
|
|
160
|
+
if (options.useFactory !== undefined) {
|
|
161
|
+
return {
|
|
162
|
+
provide: chevron_module_definition_1.CHEVRON_MODULE_OPTIONS,
|
|
163
|
+
useFactory: async (...args) => (0, chevron_utils_1.finalizeAsyncChevronOptions)(options, await options.useFactory(...args)),
|
|
164
|
+
inject: options.inject ?? [],
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const inject = [(options.useClass ?? options.useExisting)];
|
|
168
|
+
return {
|
|
169
|
+
provide: chevron_module_definition_1.CHEVRON_MODULE_OPTIONS,
|
|
170
|
+
useFactory: async (optionsFactory) => (0, chevron_utils_1.finalizeAsyncChevronOptions)(options, await optionsFactory.createChevronOptions(options.name)),
|
|
171
|
+
inject,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
static buildRegistry(storage, options) {
|
|
175
|
+
const registry = new chevron_registry_1.ChevronRegistry(storage);
|
|
176
|
+
if (options.features !== undefined) {
|
|
177
|
+
registry.bootstrapFeatures(options.features);
|
|
178
|
+
}
|
|
179
|
+
return registry;
|
|
180
|
+
}
|
|
181
|
+
static instantiateStorage(registration, moduleRef) {
|
|
182
|
+
if (typeof registration === 'function') {
|
|
183
|
+
return this.createStorageInstance(registration, moduleRef);
|
|
184
|
+
}
|
|
185
|
+
if (this.isUseClassShorthand(registration)) {
|
|
186
|
+
return this.createStorageInstance(registration.useClass, moduleRef);
|
|
187
|
+
}
|
|
188
|
+
if (this.isUseFactoryShorthand(registration)) {
|
|
189
|
+
return this.invokeStorageFactory(registration.useFactory, registration.inject, moduleRef);
|
|
190
|
+
}
|
|
191
|
+
if (this.isUseExistingShorthand(registration)) {
|
|
192
|
+
if (moduleRef === undefined) {
|
|
193
|
+
throw new TypeError('Storage useExisting requires module registration with ModuleRef.');
|
|
194
|
+
}
|
|
195
|
+
return moduleRef.get(registration.useExisting, { strict: false });
|
|
196
|
+
}
|
|
197
|
+
if (this.isUseFactoryProvider(registration)) {
|
|
198
|
+
return this.invokeStorageFactory(registration.useFactory, 'inject' in registration ? registration.inject : undefined, moduleRef);
|
|
199
|
+
}
|
|
200
|
+
if (this.isUseClassProvider(registration)) {
|
|
201
|
+
return this.createStorageInstance(registration.useClass, moduleRef);
|
|
202
|
+
}
|
|
203
|
+
if (this.isUseExistingProvider(registration)) {
|
|
204
|
+
if (moduleRef === undefined) {
|
|
205
|
+
throw new TypeError('Storage useExisting requires module registration with ModuleRef.');
|
|
206
|
+
}
|
|
207
|
+
return moduleRef.get(registration.useExisting, { strict: false });
|
|
208
|
+
}
|
|
209
|
+
if ((0, create_chevron_storage_1.isChevronStorageDriverOptions)(registration)) {
|
|
210
|
+
return (0, create_chevron_storage_1.createChevronStorageFromDriver)(registration);
|
|
211
|
+
}
|
|
212
|
+
throw new TypeError('Invalid ChevronStorage registration.');
|
|
213
|
+
}
|
|
214
|
+
static createStorageInstance(StorageClass, moduleRef) {
|
|
215
|
+
if (moduleRef === undefined) {
|
|
216
|
+
return new StorageClass();
|
|
217
|
+
}
|
|
218
|
+
return moduleRef.create(StorageClass);
|
|
219
|
+
}
|
|
220
|
+
static invokeStorageFactory(factory, inject, moduleRef) {
|
|
221
|
+
if (moduleRef === undefined) {
|
|
222
|
+
throw new TypeError('Storage useFactory requires module registration with ModuleRef.');
|
|
223
|
+
}
|
|
224
|
+
return factory(...this.resolveInjectedDependencies(inject, moduleRef));
|
|
225
|
+
}
|
|
226
|
+
static resolveInjectedDependencies(dependencies, moduleRef) {
|
|
227
|
+
if (dependencies === undefined) {
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
230
|
+
return dependencies.map((dependency) => {
|
|
231
|
+
if (typeof dependency === 'object' && dependency !== null && 'token' in dependency) {
|
|
232
|
+
if (dependency.optional === true) {
|
|
233
|
+
return this.getOptional(dependency.token, moduleRef);
|
|
234
|
+
}
|
|
235
|
+
return moduleRef.get(dependency.token, { strict: false });
|
|
236
|
+
}
|
|
237
|
+
return moduleRef.get(dependency, { strict: false });
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
static getOptional(token, moduleRef) {
|
|
241
|
+
try {
|
|
242
|
+
return moduleRef.get(token, { strict: false });
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
if (this.isUnknownElementError(error)) {
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
static isUseClassShorthand(registration) {
|
|
252
|
+
return (typeof registration === 'object' &&
|
|
253
|
+
registration !== null &&
|
|
254
|
+
'useClass' in registration &&
|
|
255
|
+
!('provide' in registration));
|
|
256
|
+
}
|
|
257
|
+
static isUseFactoryShorthand(registration) {
|
|
258
|
+
return (typeof registration === 'object' &&
|
|
259
|
+
registration !== null &&
|
|
260
|
+
'useFactory' in registration &&
|
|
261
|
+
!('provide' in registration));
|
|
262
|
+
}
|
|
263
|
+
static isUseExistingShorthand(registration) {
|
|
264
|
+
return (typeof registration === 'object' &&
|
|
265
|
+
registration !== null &&
|
|
266
|
+
'useExisting' in registration &&
|
|
267
|
+
!('provide' in registration));
|
|
268
|
+
}
|
|
269
|
+
static isUseFactoryProvider(registration) {
|
|
270
|
+
return (typeof registration === 'object' &&
|
|
271
|
+
registration !== null &&
|
|
272
|
+
'provide' in registration &&
|
|
273
|
+
'useFactory' in registration &&
|
|
274
|
+
typeof registration.useFactory === 'function');
|
|
275
|
+
}
|
|
276
|
+
static isUseClassProvider(registration) {
|
|
277
|
+
return (typeof registration === 'object' &&
|
|
278
|
+
registration !== null &&
|
|
279
|
+
'provide' in registration &&
|
|
280
|
+
'useClass' in registration &&
|
|
281
|
+
typeof registration.useClass === 'function');
|
|
282
|
+
}
|
|
283
|
+
static isUseExistingProvider(registration) {
|
|
284
|
+
return (typeof registration === 'object' &&
|
|
285
|
+
registration !== null &&
|
|
286
|
+
'provide' in registration &&
|
|
287
|
+
'useExisting' in registration);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
exports.ChevronCoreModule = ChevronCoreModule;
|
|
291
|
+
exports.ChevronCoreModule = ChevronCoreModule = ChevronCoreModule_1 = __decorate([
|
|
292
|
+
(0, common_1.Module)({}),
|
|
293
|
+
__param(0, (0, common_1.Inject)(chevron_module_definition_1.CHEVRON_MODULE_OPTIONS)),
|
|
294
|
+
__metadata("design:paramtypes", [Object, core_1.ModuleRef])
|
|
295
|
+
], ChevronCoreModule);
|
|
296
|
+
//# sourceMappingURL=chevron-core.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chevron-core.module.js","sourceRoot":"","sources":["../src/chevron-core.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAYwB;AACxB,uCAAyC;AAEzC,yEAMuC;AACvC,yDAS+B;AAC/B,2EAAqE;AACrE,yDAAqD;AACrD,uDAAmD;AAQnD,6EAAiH;AAG1G,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAKL;IACA;IALJ,MAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAE7D,YAEqB,OAA6B,EAC7B,SAAoB;QADpB,YAAO,GAAP,OAAO,CAAsB;QAC7B,cAAS,GAAT,SAAS,CAAW;IACtC,CAAC;IAEJ,MAAM,CAAC,OAAO,CAAC,UAAyC,EAAE;QACtD,MAAM,QAAQ,GAAG,IAAA,yCAAyB,EAAC,OAAO,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,IAAA,8BAAc,EAAC,QAAQ,CAAC,CAAC;QAE1C,OAAO;YACH,MAAM,EAAE,mBAAiB;YACzB,MAAM,EAAE,IAAA,+BAAe,EAAC,QAAQ,CAAC;YACjC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,kDAAsB,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;YAC3G,OAAO,EAAE,CAAC,IAAA,+BAAe,EAAC,QAAQ,CAAC,CAAC;SACvC,CAAC;IACN,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,YAAuC;QACvD,MAAM,oBAAoB,GAAG,IAAA,mDAAmC,EAAC,YAAY,CAAC,CAAC;QAE/E,OAAO;YACH,MAAM,EAAE,mBAAiB;YACzB,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,MAAM,EAAE,IAAA,+BA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.d.ts","sourceRoot":"","sources":["../src/chevron.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAE9C,eAAO,MAAM,iBAAiB,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GLOBAL_NULL_SCOPE = exports.DEFAULT_CHEVRON_NAME = void 0;
|
|
4
|
+
exports.DEFAULT_CHEVRON_NAME = 'default';
|
|
5
|
+
exports.GLOBAL_NULL_SCOPE = '__chevron_null__';
|
|
6
|
+
//# sourceMappingURL=chevron.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chevron.constants.js","sourceRoot":"","sources":["../src/chevron.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,SAAS,CAAC;AAEjC,QAAA,iBAAiB,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ChevronModuleOptions } from './interfaces';
|
|
2
|
+
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<ChevronModuleOptions, "forRoot", "createChevronOptions", {}>, CHEVRON_MODULE_OPTIONS: string | symbol, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<ChevronModuleOptions, "createChevronOptions"> & Partial<{}>, OPTIONS_TYPE: ChevronModuleOptions & Partial<{}>;
|
|
3
|
+
export type ChevronModuleOptionsType = typeof OPTIONS_TYPE;
|
|
4
|
+
export type ChevronModuleAsyncOptionsType = typeof ASYNC_OPTIONS_TYPE;
|
|
5
|
+
//# sourceMappingURL=chevron.module-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chevron.module-definition.d.ts","sourceRoot":"","sources":["../src/chevron.module-definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MACH,uBAAuB,+GACD,sBAAsB,mBAC5C,kBAAkB,uHAClB,YAAY,oCAMJ,CAAC;AAEb,MAAM,MAAM,wBAAwB,GAAG,OAAO,YAAY,CAAC;AAC3D,MAAM,MAAM,6BAA6B,GAAG,OAAO,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.OPTIONS_TYPE = exports.ASYNC_OPTIONS_TYPE = exports.CHEVRON_MODULE_OPTIONS = exports.ConfigurableModuleClass = void 0;
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
_a = new common_1.ConfigurableModuleBuilder({
|
|
7
|
+
moduleName: 'Chevron',
|
|
8
|
+
})
|
|
9
|
+
.setClassMethodName('forRoot')
|
|
10
|
+
.setFactoryMethodName('createChevronOptions')
|
|
11
|
+
.build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.CHEVRON_MODULE_OPTIONS = _a.MODULE_OPTIONS_TOKEN, exports.ASYNC_OPTIONS_TYPE = _a.ASYNC_OPTIONS_TYPE, exports.OPTIONS_TYPE = _a.OPTIONS_TYPE;
|
|
12
|
+
//# sourceMappingURL=chevron.module-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chevron.module-definition.js","sourceRoot":"","sources":["../src/chevron.module-definition.ts"],"names":[],"mappings":";;;;AAAA,2CAA2D;AAG9C,KAKT,IAAI,kCAAyB,CAAuB;IACpD,UAAU,EAAE,SAAS;CACxB,CAAC;KACG,kBAAkB,CAAC,SAAS,CAAC;KAC7B,oBAAoB,CAAC,sBAAsB,CAAC;KAC5C,KAAK,EAAE,EATR,+BAAuB,+BACD,8BAAsB,4BAC5C,0BAAkB,0BAClB,oBAAY,mBAMH"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { ConfigurableModuleClass, ChevronModuleAsyncOptionsType, ChevronModuleOptionsType } from './chevron.module-definition';
|
|
3
|
+
import { ChevronModuleAsyncOptions } from './interfaces';
|
|
4
|
+
export declare class ChevronModule extends ConfigurableModuleClass {
|
|
5
|
+
static forRoot(options?: ChevronModuleOptionsType): DynamicModule;
|
|
6
|
+
static forRootAsync(options: ChevronModuleAsyncOptionsType & ChevronModuleAsyncOptions): DynamicModule;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=chevron.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chevron.module.d.ts","sourceRoot":"","sources":["../src/chevron.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EACH,uBAAuB,EACvB,6BAA6B,EAC7B,wBAAwB,EAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,qBACa,aAAc,SAAQ,uBAAuB;IACtD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,aAAa;IAUjE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,6BAA6B,GAAG,yBAAyB,GAAG,aAAa;CASzG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var ChevronModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ChevronModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const chevron_core_module_1 = require("./chevron-core.module");
|
|
13
|
+
const chevron_module_definition_1 = require("./chevron.module-definition");
|
|
14
|
+
let ChevronModule = ChevronModule_1 = class ChevronModule extends chevron_module_definition_1.ConfigurableModuleClass {
|
|
15
|
+
static forRoot(options) {
|
|
16
|
+
const coreModule = chevron_core_module_1.ChevronCoreModule.forRoot(options ?? {});
|
|
17
|
+
return {
|
|
18
|
+
module: ChevronModule_1,
|
|
19
|
+
imports: [coreModule],
|
|
20
|
+
exports: [coreModule],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static forRootAsync(options) {
|
|
24
|
+
const coreModule = chevron_core_module_1.ChevronCoreModule.forRootAsync(options);
|
|
25
|
+
return {
|
|
26
|
+
module: ChevronModule_1,
|
|
27
|
+
imports: [coreModule],
|
|
28
|
+
exports: [coreModule],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.ChevronModule = ChevronModule;
|
|
33
|
+
exports.ChevronModule = ChevronModule = ChevronModule_1 = __decorate([
|
|
34
|
+
(0, common_1.Module)({})
|
|
35
|
+
], ChevronModule);
|
|
36
|
+
//# sourceMappingURL=chevron.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chevron.module.js","sourceRoot":"","sources":["../src/chevron.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,+DAA0D;AAC1D,2EAIqC;AAI9B,IAAM,aAAa,qBAAnB,MAAM,aAAc,SAAQ,mDAAuB;IACtD,MAAM,CAAC,OAAO,CAAC,OAAkC;QAC7C,MAAM,UAAU,GAAG,uCAAiB,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QAE5D,OAAO;YACH,MAAM,EAAE,eAAa;YACrB,OAAO,EAAE,CAAC,UAAU,CAAC;YACrB,OAAO,EAAE,CAAC,UAAU,CAAC;SACxB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,OAAkE;QAClF,MAAM,UAAU,GAAG,uCAAiB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAE3D,OAAO;YACH,MAAM,EAAE,eAAa;YACrB,OAAO,EAAE,CAAC,UAAU,CAAC;YACrB,OAAO,EAAE,CAAC,UAAU,CAAC;SACxB,CAAC;IACN,CAAC;CACJ,CAAA;AApBY,sCAAa;wBAAb,aAAa;IADzB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,aAAa,CAoBzB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FeatureResolver, FeatureValue, ChevronStorage } from './interfaces';
|
|
2
|
+
export declare class ChevronRegistry {
|
|
3
|
+
private readonly storage;
|
|
4
|
+
private readonly definitions;
|
|
5
|
+
private readonly cache;
|
|
6
|
+
private readonly pendingLookups;
|
|
7
|
+
private readonly featureGenerations;
|
|
8
|
+
private globalGeneration;
|
|
9
|
+
constructor(storage: ChevronStorage);
|
|
10
|
+
define(feature: string, resolver: FeatureResolver): void;
|
|
11
|
+
defined(): string[];
|
|
12
|
+
value(feature: string): Promise<FeatureValue | false>;
|
|
13
|
+
active(feature: string): Promise<boolean>;
|
|
14
|
+
inactive(feature: string): Promise<boolean>;
|
|
15
|
+
activate(feature: string, featureValue?: FeatureValue): Promise<void>;
|
|
16
|
+
deactivate(feature: string): Promise<void>;
|
|
17
|
+
forget(feature: string): Promise<void>;
|
|
18
|
+
purge(features?: string[]): Promise<void>;
|
|
19
|
+
bootstrapFeatures(features: Record<string, FeatureResolver>): void;
|
|
20
|
+
private resolveValue;
|
|
21
|
+
private lookupValue;
|
|
22
|
+
private resolveDefinition;
|
|
23
|
+
private isFeatureResolverFn;
|
|
24
|
+
private cacheKey;
|
|
25
|
+
private invalidateFeature;
|
|
26
|
+
private clearCache;
|
|
27
|
+
private healStaleWrite;
|
|
28
|
+
private bumpGeneration;
|
|
29
|
+
private snapshotGeneration;
|
|
30
|
+
private isCurrentGeneration;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=chevron.registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chevron.registry.d.ts","sourceRoot":"","sources":["../src/chevron.registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEhG,qBAAa,eAAe;IAWZ,OAAO,CAAC,QAAQ,CAAC,OAAO;IAVpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsC;IAElE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmC;IAEzD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAoD;IAEnF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA6B;IAEhE,OAAO,CAAC,gBAAgB,CAAK;gBAEA,OAAO,EAAE,cAAc;IAEpD,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI;IAKxD,OAAO,IAAI,MAAM,EAAE;IAIb,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC;IAIrD,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMzC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM3C,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,GAAE,YAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3E,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtC,KAAK,CAAC,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