@forge/cli-shared 0.0.0-experimental-e1cefc4 → 0.0.0-experimental-416047f

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/CHANGELOG.md CHANGED
@@ -1,6 +1,78 @@
1
1
  # @forge/cli-shared
2
2
 
3
- ## 0.0.0-experimental-e1cefc4
3
+ ## 0.0.0-experimental-416047f
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [1a8d47c]
8
+ - Updated dependencies [e314dd0]
9
+ - Updated dependencies [0137135]
10
+ - Updated dependencies [2bd062d]
11
+ - Updated dependencies [9047581]
12
+ - Updated dependencies [5c9419f]
13
+ - Updated dependencies [e8a6926]
14
+ - Updated dependencies [cb28bc0]
15
+ - Updated dependencies [0920759]
16
+ - @forge/manifest@0.0.0-experimental-416047f
17
+
18
+ ## 2.4.1-next.7
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [0920759f]
23
+ - @forge/manifest@3.6.0-next.7
24
+
25
+ ## 2.4.1-next.6
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [2bd062d0]
30
+ - @forge/manifest@3.6.0-next.6
31
+
32
+ ## 2.4.1-next.5
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [cb28bc0]
37
+ - @forge/manifest@3.6.0-next.5
38
+
39
+ ## 2.4.1-next.4
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies [e314dd0]
44
+ - @forge/manifest@3.6.0-next.4
45
+
46
+ ## 2.4.1-next.3
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [90475812]
51
+ - @forge/manifest@3.6.0-next.3
52
+
53
+ ## 2.4.1-next.2
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [5c9419f4]
58
+ - Updated dependencies [e8a69267]
59
+ - @forge/manifest@3.6.0-next.2
60
+
61
+ ## 2.4.1-next.1
62
+
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies [1a8d47c0]
66
+ - @forge/manifest@3.6.0-next.1
67
+
68
+ ## 2.4.1-next.0
69
+
70
+ ### Patch Changes
71
+
72
+ - Updated dependencies [01371351]
73
+ - @forge/manifest@3.5.1-next.0
74
+
75
+ ## 2.4.0
4
76
 
5
77
  ### Minor Changes
6
78
 
@@ -9,8 +81,9 @@
9
81
 
10
82
  ### Patch Changes
11
83
 
84
+ - Updated dependencies [3d82376]
12
85
  - Updated dependencies [d094c69]
13
- - Updated dependencies [ba67459]
86
+ - Updated dependencies [ba674590]
14
87
  - Updated dependencies [f3ac287]
15
88
  - Updated dependencies [d196b41]
16
89
  - Updated dependencies [e411a29]
@@ -18,7 +91,14 @@
18
91
  - Updated dependencies [a3bfe81]
19
92
  - Updated dependencies [02839be]
20
93
  - Updated dependencies [ffb508a]
21
- - @forge/manifest@0.0.0-experimental-e1cefc4
94
+ - @forge/manifest@3.5.0
95
+
96
+ ## 2.4.0-next.8
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies [3d82376]
101
+ - @forge/manifest@3.5.0-next.7
22
102
 
23
103
  ## 2.4.0-next.7
24
104
 
@@ -1,9 +1,23 @@
1
+ interface CachedValue<E> {
2
+ value: E;
3
+ expiry: number | undefined;
4
+ }
5
+ interface ConfStore {
6
+ get(key: string): CachedValue<any> | undefined;
7
+ set(key: string, value: CachedValue<any>): void;
8
+ delete(key: string): void;
9
+ }
1
10
  export declare class CachedConf {
2
11
  private readonly conf;
3
12
  constructor(projectName: string);
13
+ constructor(store: ConfStore);
4
14
  get<T = string | object>(key: string): T | undefined;
5
15
  set<T = string | object>(key: string, value: T, age?: number): void;
6
16
  delete(key: string): void;
17
+ cached<T = string | object>(key: string, getter: () => T, age?: number): T;
18
+ cached<T = string | object>(key: string, getter: () => Promise<T>, age?: number): Promise<T>;
7
19
  static getCache(projectName: string): CachedConf;
20
+ static memoryCache(): CachedConf;
8
21
  }
22
+ export {};
9
23
  //# sourceMappingURL=cached-conf.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cached-conf.d.ts","sourceRoot":"","sources":["../../src/cache/cached-conf.ts"],"names":[],"mappings":"AAOA,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;gBAEhB,WAAW,EAAE,MAAM;IAOxB,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAapD,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAOnE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIhC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU;CAGjD"}
1
+ {"version":3,"file":"cached-conf.d.ts","sourceRoot":"","sources":["../../src/cache/cached-conf.ts"],"names":[],"mappings":"AAEA,UAAU,WAAW,CAAC,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC;IACT,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,UAAU,SAAS;IACjB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC/C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAChD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAID,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;gBAErB,WAAW,EAAE,MAAM;gBACnB,KAAK,EAAE,SAAS;IAYrB,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAapD,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAOnE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAWzB,MAAM,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC;IAC1E,MAAM,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAkBnG,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU;IAQhD,MAAM,CAAC,WAAW,IAAI,UAAU;CAGjC"}
@@ -3,11 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CachedConf = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const conf_1 = tslib_1.__importDefault(require("conf"));
6
+ const isThenable = (input) => input && typeof input.then === 'function';
6
7
  class CachedConf {
7
- constructor(projectName) {
8
- this.conf = new conf_1.default({
9
- projectName
10
- });
8
+ constructor(arg) {
9
+ if (typeof arg === 'string') {
10
+ this.conf = new conf_1.default({
11
+ projectName: arg
12
+ });
13
+ }
14
+ else {
15
+ this.conf = arg;
16
+ }
11
17
  }
12
18
  get(key) {
13
19
  const result = this.conf.get(key);
@@ -28,8 +34,28 @@ class CachedConf {
28
34
  delete(key) {
29
35
  this.conf.delete(key);
30
36
  }
37
+ cached(key, getter, age) {
38
+ const cached = this.get(key);
39
+ if (cached) {
40
+ return cached;
41
+ }
42
+ const valuePromise = getter();
43
+ if (isThenable(valuePromise)) {
44
+ return valuePromise.then((value) => {
45
+ this.set(key, value, age);
46
+ return value;
47
+ });
48
+ }
49
+ else {
50
+ this.set(key, valuePromise, age);
51
+ return valuePromise;
52
+ }
53
+ }
31
54
  static getCache(projectName) {
32
55
  return new CachedConf(projectName);
33
56
  }
57
+ static memoryCache() {
58
+ return new CachedConf(new Map());
59
+ }
34
60
  }
35
61
  exports.CachedConf = CachedConf;