@raubjo/architect-core 0.1.0 → 0.1.2
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/README.md +216 -0
- package/bun.lock +82 -1
- package/package.json +55 -6
- package/src/cache/cache.ts +2 -2
- package/src/cache/manager.ts +93 -83
- package/src/config/adapters/esm.ts +26 -0
- package/src/config/clone.ts +5 -5
- package/src/config/env.global.d.ts +2 -1
- package/src/config/env.ts +53 -55
- package/src/config/env_test.helpers.ts +58 -0
- package/src/config/repository.ts +180 -142
- package/src/container/adapters/builtin.ts +347 -0
- package/src/container/adapters/inversify.ts +123 -0
- package/src/container/contract.ts +58 -0
- package/src/container/runtime.ts +149 -0
- package/src/filesystem/adapters/local.ts +92 -83
- package/src/filesystem/adapters/local_test.helpers.ts +50 -0
- package/src/filesystem/filesystem.ts +11 -11
- package/src/foundation/application.ts +205 -175
- package/src/foundation/application_test.helpers.ts +31 -0
- package/src/index.ts +15 -6
- package/src/react.ts +2 -0
- package/src/renderers/adapters/react.tsx +35 -0
- package/src/renderers/adapters/solid.tsx +32 -0
- package/src/renderers/adapters/svelte.ts +70 -0
- package/src/renderers/adapters/vue.ts +28 -0
- package/src/renderers/contract.ts +15 -0
- package/src/runtimes/react.tsx +24 -12
- package/src/runtimes/solid.tsx +30 -0
- package/src/runtimes/svelte.ts +23 -0
- package/src/runtimes/vue.ts +20 -0
- package/src/solid.ts +2 -0
- package/src/storage/adapters/contract.ts +10 -0
- package/src/storage/adapters/indexed-db.ts +170 -156
- package/src/storage/adapters/local-storage.ts +34 -34
- package/src/storage/adapters/memory.ts +25 -25
- package/src/storage/manager.ts +65 -61
- package/src/storage/storage.ts +1 -8
- package/src/support/facades/cache.ts +40 -40
- package/src/support/facades/config.ts +78 -48
- package/src/support/facades/facade.ts +43 -28
- package/src/support/facades/storage.ts +41 -41
- package/src/support/service-provider.ts +11 -11
- package/src/support/str.ts +94 -90
- package/src/support/str_test.helpers.ts +26 -0
- package/src/svelte.ts +2 -0
- package/src/vue.ts +2 -0
- package/tsconfig.json +16 -0
- package/coverage/lcov.info +0 -1078
- package/src/config/app.ts +0 -5
- package/src/rendering/adapters/react.tsx +0 -27
- package/src/rendering/renderer.ts +0 -13
- package/src/support/providers/config-service-provider.ts +0 -19
- package/tests/application.test.ts +0 -236
- package/tests/cache-facade.test.ts +0 -45
- package/tests/cache.test.ts +0 -68
- package/tests/config-clone.test.ts +0 -31
- package/tests/config-env.test.ts +0 -88
- package/tests/config-facade.test.ts +0 -96
- package/tests/config-repository.test.ts +0 -124
- package/tests/facade-base.test.ts +0 -80
- package/tests/filesystem.test.ts +0 -81
- package/tests/runtime-react.test.tsx +0 -37
- package/tests/service-provider.test.ts +0 -23
- package/tests/storage-facade.test.ts +0 -46
- package/tests/storage.test.ts +0 -264
- package/tests/str.test.ts +0 -73
package/src/storage/manager.ts
CHANGED
|
@@ -2,77 +2,81 @@ import type ConfigRepository from "../config/repository";
|
|
|
2
2
|
import IndexedDbAdapter from "./adapters/indexed-db";
|
|
3
3
|
import LocalStorageAdapter from "./adapters/local-storage";
|
|
4
4
|
import MemoryStorageAdapter from "./adapters/memory";
|
|
5
|
-
import type {
|
|
5
|
+
import type { Adapter } from "./adapters/contract";
|
|
6
6
|
|
|
7
7
|
type DriverName = "memory" | "local" | "indexed";
|
|
8
8
|
|
|
9
|
-
export default class StorageManager implements
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static defaultAdapters(): Record<DriverName, StorageAdapter> {
|
|
26
|
-
const memory = new MemoryStorageAdapter();
|
|
27
|
-
const hasWindow = typeof window !== "undefined";
|
|
28
|
-
const hasLocal = hasWindow && typeof window.localStorage !== "undefined";
|
|
29
|
-
const hasIndexed = typeof globalThis.indexedDB !== "undefined";
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
memory,
|
|
33
|
-
local: hasLocal ? new LocalStorageAdapter(window.localStorage) : memory,
|
|
34
|
-
indexed: hasIndexed ? new IndexedDbAdapter() : memory,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
drv(name?: string): StorageAdapter {
|
|
39
|
-
if (typeof name === "string") {
|
|
40
|
-
if (!(name in this.adapters)) {
|
|
41
|
-
throw new Error(`Storage driver [${name}] is not defined.`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return this.adapters[name];
|
|
9
|
+
export default class StorageManager implements Adapter {
|
|
10
|
+
protected adapters: Record<string, Adapter>;
|
|
11
|
+
protected active: string;
|
|
12
|
+
|
|
13
|
+
constructor(adapters: Record<string, Adapter>, active: string = "memory") {
|
|
14
|
+
this.adapters = adapters;
|
|
15
|
+
this.active = active in this.adapters ? active : "memory";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static fromConfig(config: ConfigRepository): StorageManager {
|
|
19
|
+
const adapters = StorageManager.defaultAdapters();
|
|
20
|
+
const driver = config.string("storage.driver", "memory");
|
|
21
|
+
|
|
22
|
+
return new StorageManager(adapters, driver);
|
|
45
23
|
}
|
|
46
24
|
|
|
47
|
-
|
|
48
|
-
|
|
25
|
+
static defaultAdapters(): Record<DriverName, Adapter> {
|
|
26
|
+
const memory = new MemoryStorageAdapter();
|
|
27
|
+
const hasWindow = typeof window !== "undefined";
|
|
28
|
+
const hasLocal =
|
|
29
|
+
hasWindow && typeof window.localStorage !== "undefined";
|
|
30
|
+
const hasIndexed = typeof globalThis.indexedDB !== "undefined";
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
memory,
|
|
34
|
+
local:
|
|
35
|
+
hasLocal ?
|
|
36
|
+
new LocalStorageAdapter(window.localStorage)
|
|
37
|
+
: memory,
|
|
38
|
+
indexed: hasIndexed ? new IndexedDbAdapter() : memory,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
drv(name?: string): Adapter {
|
|
43
|
+
if (typeof name === "string") {
|
|
44
|
+
if (!(name in this.adapters)) {
|
|
45
|
+
throw new Error(`Storage driver [${name}] is not defined.`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return this.adapters[name];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return this.adapters[this.active];
|
|
52
|
+
}
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
use(name: string): this {
|
|
55
|
+
this.active = this.drv(name) ? name : this.active;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
get<T = unknown>(key: string): Promise<T | null> {
|
|
60
|
+
return this.drv().get<T>(key);
|
|
61
|
+
}
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
set<T = unknown>(key: string, value: T): Promise<void> {
|
|
64
|
+
return this.drv().set<T>(key, value);
|
|
65
|
+
}
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
has(key: string): Promise<boolean> {
|
|
68
|
+
return this.drv().has(key);
|
|
69
|
+
}
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
delete(key: string): Promise<void> {
|
|
72
|
+
return this.drv().delete(key);
|
|
73
|
+
}
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
clear(): Promise<void> {
|
|
76
|
+
return this.drv().clear();
|
|
77
|
+
}
|
|
74
78
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
keys(): Promise<string[]> {
|
|
80
|
+
return this.drv().keys();
|
|
81
|
+
}
|
|
78
82
|
}
|
package/src/storage/storage.ts
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
get<T = unknown>(key: string): Promise<T | null>;
|
|
3
|
-
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
4
|
-
has(key: string): Promise<boolean>;
|
|
5
|
-
delete(key: string): Promise<void>;
|
|
6
|
-
clear(): Promise<void>;
|
|
7
|
-
keys(): Promise<string[]>;
|
|
8
|
-
}
|
|
1
|
+
export type { Adapter as StorageAdapter, Contract } from "./adapters/contract";
|
|
@@ -3,44 +3,44 @@ import type { CacheStore } from "../../cache/cache";
|
|
|
3
3
|
import Facade from "./facade";
|
|
4
4
|
|
|
5
5
|
export default class Cache extends Facade {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
6
|
+
private constructor() {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
protected static getFacadeAccessor(): string {
|
|
11
|
+
return "cache";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static store(name?: string): CacheStore {
|
|
15
|
+
return this.resolveFacadeInstance<CacheManager>().store(name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static use(name: string): Cache {
|
|
19
|
+
this.resolveFacadeInstance<CacheManager>().use(name);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static get<T = unknown>(key: string): Promise<T | null> {
|
|
24
|
+
return this.resolveFacadeInstance<CacheManager>().get<T>(key);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static set<T = unknown>(key: string, value: T): Promise<void> {
|
|
28
|
+
return this.resolveFacadeInstance<CacheManager>().set<T>(key, value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static has(key: string): Promise<boolean> {
|
|
32
|
+
return this.resolveFacadeInstance<CacheManager>().has(key);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static delete(key: string): Promise<void> {
|
|
36
|
+
return this.resolveFacadeInstance<CacheManager>().delete(key);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static clear(): Promise<void> {
|
|
40
|
+
return this.resolveFacadeInstance<CacheManager>().clear();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static keys(): Promise<string[]> {
|
|
44
|
+
return this.resolveFacadeInstance<CacheManager>().keys();
|
|
45
|
+
}
|
|
46
46
|
}
|
|
@@ -3,65 +3,95 @@ import type { ConfigDefaults, ConfigItems } from "../../config/repository";
|
|
|
3
3
|
import Facade from "./facade";
|
|
4
4
|
|
|
5
5
|
export default class Config extends Facade {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
private constructor() {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
protected static getFacadeAccessor(): string {
|
|
11
|
+
return "config";
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
static has(key: string | string[]): boolean {
|
|
15
|
+
return this.resolveFacadeInstance<ConfigRepository>().has(key);
|
|
16
|
+
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
static get<T = unknown>(
|
|
19
|
+
key: string | string[],
|
|
20
|
+
defaultValue: T | (() => T) | null = null,
|
|
21
|
+
): T | Record<string, unknown> | null {
|
|
22
|
+
return this.resolveFacadeInstance<ConfigRepository>().get<T>(
|
|
23
|
+
key,
|
|
24
|
+
defaultValue,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
static getMany(keys: string[] | ConfigDefaults): Record<string, unknown> {
|
|
29
|
+
return this.resolveFacadeInstance<ConfigRepository>().getMany(keys);
|
|
30
|
+
}
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
static string(
|
|
33
|
+
key: string,
|
|
34
|
+
defaultValue: string | (() => string) | null = null,
|
|
35
|
+
): string {
|
|
36
|
+
return this.resolveFacadeInstance<ConfigRepository>().string(
|
|
37
|
+
key,
|
|
38
|
+
defaultValue,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
static integer(
|
|
43
|
+
key: string,
|
|
44
|
+
defaultValue: number | (() => number) | null = null,
|
|
45
|
+
): number {
|
|
46
|
+
return this.resolveFacadeInstance<ConfigRepository>().integer(
|
|
47
|
+
key,
|
|
48
|
+
defaultValue,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
36
51
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
static float(
|
|
53
|
+
key: string,
|
|
54
|
+
defaultValue: number | (() => number) | null = null,
|
|
55
|
+
): number {
|
|
56
|
+
return this.resolveFacadeInstance<ConfigRepository>().float(
|
|
57
|
+
key,
|
|
58
|
+
defaultValue,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
40
61
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
static boolean(
|
|
63
|
+
key: string,
|
|
64
|
+
defaultValue: boolean | (() => boolean) | null = null,
|
|
65
|
+
): boolean {
|
|
66
|
+
return this.resolveFacadeInstance<ConfigRepository>().boolean(
|
|
67
|
+
key,
|
|
68
|
+
defaultValue,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
47
71
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
72
|
+
static array<T = unknown>(
|
|
73
|
+
key: string,
|
|
74
|
+
defaultValue: T[] | (() => T[]) | null = null,
|
|
75
|
+
): T[] {
|
|
76
|
+
return this.resolveFacadeInstance<ConfigRepository>().array<T>(
|
|
77
|
+
key,
|
|
78
|
+
defaultValue,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
51
81
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
82
|
+
static set(key: string | ConfigItems, value: unknown = null): void {
|
|
83
|
+
this.resolveFacadeInstance<ConfigRepository>().set(key, value);
|
|
84
|
+
}
|
|
55
85
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
86
|
+
static prepend(key: string, value: unknown): void {
|
|
87
|
+
this.resolveFacadeInstance<ConfigRepository>().prepend(key, value);
|
|
88
|
+
}
|
|
59
89
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
90
|
+
static push(key: string, value: unknown): void {
|
|
91
|
+
this.resolveFacadeInstance<ConfigRepository>().push(key, value);
|
|
92
|
+
}
|
|
63
93
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
94
|
+
static all(): ConfigItems {
|
|
95
|
+
return this.resolveFacadeInstance<ConfigRepository>().all();
|
|
96
|
+
}
|
|
67
97
|
}
|
|
@@ -1,42 +1,57 @@
|
|
|
1
1
|
import { Application } from "../../foundation/application";
|
|
2
2
|
|
|
3
3
|
export default abstract class Facade {
|
|
4
|
-
|
|
4
|
+
protected static resolvedInstance = new Map<
|
|
5
|
+
Parameters<typeof Application.make>[0],
|
|
6
|
+
unknown
|
|
7
|
+
>();
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
protected constructor() {}
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.resolvedInstance.delete(name);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static clearResolvedInstances(): void {
|
|
17
|
-
this.resolvedInstance.clear();
|
|
18
|
-
}
|
|
11
|
+
protected static getFacadeAccessor(): Parameters<
|
|
12
|
+
typeof Application.make
|
|
13
|
+
>[0] {
|
|
14
|
+
throw new Error("Facade does not implement getFacadeAccessor().");
|
|
15
|
+
}
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
static clearResolvedInstance(
|
|
18
|
+
name: Parameters<typeof Application.make>[0],
|
|
19
|
+
): void {
|
|
20
|
+
this.resolvedInstance.delete(name);
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
static clearResolvedInstances(): void {
|
|
24
|
+
this.resolvedInstance.clear();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
protected static resolveFacadeInstance<T>(): T {
|
|
28
|
+
const accessor = this.getFacadeAccessor();
|
|
29
|
+
|
|
30
|
+
if (this.resolvedInstance.has(accessor)) {
|
|
31
|
+
return this.resolvedInstance.get(accessor) as T;
|
|
32
|
+
}
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
const instance = Application.make<T>(accessor);
|
|
35
|
+
this.resolvedInstance.set(accessor, instance);
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
const instance = this.resolveFacadeInstance<Record<string, (...a: unknown[]) => unknown>>();
|
|
35
|
-
const callable = instance[method];
|
|
36
|
-
if (typeof callable !== "function") {
|
|
37
|
-
throw new Error(`Method [${method}] does not exist on resolved facade instance.`);
|
|
37
|
+
return instance;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
protected static callFacadeMethod<T = unknown>(
|
|
41
|
+
method: string,
|
|
42
|
+
...args: unknown[]
|
|
43
|
+
): T {
|
|
44
|
+
const instance =
|
|
45
|
+
this.resolveFacadeInstance<
|
|
46
|
+
Record<string, (...a: unknown[]) => unknown>
|
|
47
|
+
>();
|
|
48
|
+
const callable = instance[method];
|
|
49
|
+
if (typeof callable !== "function") {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Method [${method}] does not exist on resolved facade instance.`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return callable.apply(instance, args) as T;
|
|
56
|
+
}
|
|
42
57
|
}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import type StorageManager from "../../storage/manager";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Adapter } from "../../storage/adapters/contract";
|
|
3
3
|
import Facade from "./facade";
|
|
4
4
|
|
|
5
5
|
export default class Storage extends Facade {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
6
|
+
private constructor() {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
protected static getFacadeAccessor(): string {
|
|
11
|
+
return "storage";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static drv(name?: string): Adapter {
|
|
15
|
+
return this.resolveFacadeInstance<StorageManager>().drv(name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static use(name: string): Storage {
|
|
19
|
+
this.resolveFacadeInstance<StorageManager>().use(name);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static get<T = unknown>(key: string): Promise<T | null> {
|
|
24
|
+
return this.resolveFacadeInstance<StorageManager>().get<T>(key);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static set<T = unknown>(key: string, value: T): Promise<void> {
|
|
28
|
+
return this.resolveFacadeInstance<StorageManager>().set<T>(key, value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static has(key: string): Promise<boolean> {
|
|
32
|
+
return this.resolveFacadeInstance<StorageManager>().has(key);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static delete(key: string): Promise<void> {
|
|
36
|
+
return this.resolveFacadeInstance<StorageManager>().delete(key);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static clear(): Promise<void> {
|
|
40
|
+
return this.resolveFacadeInstance<StorageManager>().clear();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static keys(): Promise<string[]> {
|
|
44
|
+
return this.resolveFacadeInstance<StorageManager>().keys();
|
|
45
|
+
}
|
|
46
46
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContainerContract } from "../container/contract";
|
|
2
2
|
|
|
3
3
|
export type Cleanup = () => void;
|
|
4
4
|
|
|
5
5
|
export type ServiceProviderContext = {
|
|
6
|
-
|
|
6
|
+
container: ContainerContract;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export default class ServiceProvider {
|
|
10
|
-
|
|
10
|
+
constructor() {}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
register(_context: ServiceProviderContext): void | Cleanup {}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
boot(_context: ServiceProviderContext): void | Cleanup {}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export class DeferrableServiceProvider extends ServiceProvider {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
provides(): Array<string> {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
25
|
}
|