@forge/cli-shared 2.4.0-next.6 → 2.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # @forge/cli-shared
2
2
 
3
+ ## 2.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f33aada: Fix vulnerability dependencies
8
+ - 726ef79: Fix dependency vulnerabilities
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [3d82376]
13
+ - Updated dependencies [d094c69]
14
+ - Updated dependencies [ba674590]
15
+ - Updated dependencies [f3ac287]
16
+ - Updated dependencies [d196b41]
17
+ - Updated dependencies [e411a29]
18
+ - Updated dependencies [0accde8]
19
+ - Updated dependencies [a3bfe81]
20
+ - Updated dependencies [02839be]
21
+ - Updated dependencies [ffb508a]
22
+ - @forge/manifest@3.5.0
23
+
24
+ ## 2.4.0-next.8
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [3d82376]
29
+ - @forge/manifest@3.5.0-next.7
30
+
31
+ ## 2.4.0-next.7
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [f3ac287]
36
+ - Updated dependencies [0accde8]
37
+ - Updated dependencies [ffb508a]
38
+ - @forge/manifest@3.5.0-next.6
39
+
3
40
  ## 2.4.0-next.6
4
41
 
5
42
  ### Patch Changes
@@ -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;