@conduit-client/service-store 3.20.0 → 3.20.4

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.
@@ -1,6 +1,2 @@
1
- /*!
2
- * Copyright (c) 2022, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
1
+
6
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/v1/index.js CHANGED
@@ -1,8 +1,3 @@
1
- /*!
2
- * Copyright (c) 2022, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
1
  class KeySetImpl {
7
2
  constructor(initialKeys) {
8
3
  this.data = {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/v1/key-set.ts","../../src/v1/recordable.ts","../../src/v1/in-memory.ts"],"sourcesContent":["import type { Key } from './key';\n\nexport type KeySet = {\n add(key: Key): void;\n contains(key: Key): boolean;\n difference(other: KeySet): KeySet;\n equals(other: KeySet): boolean;\n elements(): Key[];\n isSubsetOf(other: KeySet): boolean;\n length: number;\n overlaps(other: KeySet): boolean;\n};\n\n/**\n * A collection of keys, in no particular order.\n */\nexport class KeySetImpl implements KeySet {\n // TODO - probably better to use Set<Key>\n private data: Record<Key, true> = {};\n private lengthInternal: number = 0;\n\n constructor(initialKeys?: Key[]) {\n if (initialKeys) {\n initialKeys.forEach((key) => {\n this.add(key);\n });\n }\n }\n\n add(key: Key): void {\n this.data[key] = true;\n // TODO - need to account for adding a key that was already in the set\n this.lengthInternal++;\n }\n\n contains(key: Key): boolean {\n return this.data[key] === true;\n }\n\n elements(): Key[] {\n return Object.keys(this.data);\n }\n\n get length(): number {\n return this.lengthInternal;\n }\n\n overlaps(other: KeySet): boolean {\n const otherKeys = other.elements();\n\n for (let j = 0; j < otherKeys.length; ++j) {\n if (this.contains(otherKeys[j])) {\n return true;\n }\n }\n\n return false;\n }\n\n difference(other: KeySet): KeySet {\n const value = new KeySetImpl();\n\n this.elements().forEach((key) => {\n if (!other.contains(key)) {\n value.add(key);\n }\n });\n\n return value;\n }\n\n isSubsetOf(other: KeySet): boolean {\n return this.difference(other).length === 0;\n }\n\n equals(other: KeySet): boolean {\n return this.length === other.length && this.elements().every((key) => other.contains(key));\n }\n\n toString(): string {\n return `<<${JSON.stringify(this.elements())}>>`;\n }\n}\n","import { type Key } from './key';\nimport { type KeySet, KeySetImpl } from './key-set';\nimport { type StoreService } from './store';\n\n/**\n * A RecordableStore wraps another Store and is used to record which keys in the\n * other Store are read/written.\n */\nexport class DefaultRecordableStore implements StoreService {\n keysRead = new KeySetImpl();\n missingKeysRead = new KeySetImpl();\n keysUpdated = new KeySetImpl();\n\n constructor(private baseStore: StoreService) {}\n\n delete(key: Key, options?: {}) {\n this.keysUpdated.add(key);\n this.baseStore.delete(key, options);\n }\n\n get<T>(key: Key, options?: {}) {\n this.keysRead.add(key);\n const value = this.baseStore.get<T>(key, options);\n if (value === undefined) {\n this.missingKeysRead.add(key);\n }\n\n return value;\n }\n\n set(key: Key, value: any, options?: {}) {\n this.keysUpdated.add(key);\n this.baseStore.set(key, value, options);\n }\n\n length() {\n return this.baseStore.length();\n }\n\n keys() {\n return this.baseStore.keys();\n }\n\n toKeySet(keys: Key[]): KeySet {\n return this.baseStore.toKeySet(keys);\n }\n\n record() {\n return this.baseStore.record();\n }\n}\n","import { type Key } from './key';\nimport { type KeySet, KeySetImpl } from './key-set';\nimport { DefaultRecordableStore } from './recordable';\nimport { type StoreService } from './store';\nimport type { RecordableStore, StoreServiceDescriptor } from './store';\n\n/**\n * A simple in-memory implementation of the Store interface.\n *\n * Exported for testing purposes only.\n */\nexport class InMemoryStore implements StoreService {\n protected data: Record<Key, any> = {};\n\n // TODO - only intended for use in tests. We should refactor this into a subclass &\n // add to a test util library.\n clear(): void {\n this.data = {};\n }\n\n delete(key: Key, _options?: {}): void {\n delete this.data[key];\n }\n\n get<T>(key: Key, _options?: {}): T | undefined {\n return this.data[key];\n }\n\n set(key: Key, value: any, _options?: {}): void {\n this.data[key] = value;\n }\n\n length(): number {\n return this.keys().length;\n }\n\n keys(): KeySet {\n return new KeySetImpl(Object.keys(this.data));\n }\n\n toKeySet(keys: Key[]): KeySet {\n return new KeySetImpl(keys);\n }\n\n record(): RecordableStore {\n return new DefaultRecordableStore(this);\n }\n}\n\n/**\n * Constructs an in-memory implementation of StoreService.\n *\n * @returns in-memory implementation of StoreService\n */\nexport function buildServiceDescriptor(): StoreServiceDescriptor {\n return {\n type: 'store',\n version: '1.0',\n service: new InMemoryStore(),\n };\n}\n"],"names":[],"mappings":";;;;;AAgBO,MAAM,WAA6B;AAAA,EAKtC,YAAY,aAAqB;AAHjC,SAAQ,OAA0B,CAAA;AAClC,SAAQ,iBAAyB;AAG7B,QAAI,aAAa;AACb,kBAAY,QAAQ,CAAC,QAAQ;AACzB,aAAK,IAAI,GAAG;AAAA,MAChB,CAAC;AAAA,IACL;AAAA,EACJ;AAAA,EAEA,IAAI,KAAgB;AAChB,SAAK,KAAK,GAAG,IAAI;AAEjB,SAAK;AAAA,EACT;AAAA,EAEA,SAAS,KAAmB;AACxB,WAAO,KAAK,KAAK,GAAG,MAAM;AAAA,EAC9B;AAAA,EAEA,WAAkB;AACd,WAAO,OAAO,KAAK,KAAK,IAAI;AAAA,EAChC;AAAA,EAEA,IAAI,SAAiB;AACjB,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,SAAS,OAAwB;AAC7B,UAAM,YAAY,MAAM,SAAA;AAExB,aAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,EAAE,GAAG;AACvC,UAAI,KAAK,SAAS,UAAU,CAAC,CAAC,GAAG;AAC7B,eAAO;AAAA,MACX;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AAAA,EAEA,WAAW,OAAuB;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AA,EAEA,SAAS,MAAqB;AAC1B,WAAO,KAAK,UAAU,SAAS,IAAI;AAAA,EACvC;AAAA,EAEA,SAAS;AACL,WAAO,KAAK,UAAU,OAAA;AAAA,EAC1B;AACJ;ACvCO,MAAM,cAAsC;AAAA,EAA5C,cAAA;AACH,SAAU,OAAyB,CAAA;AAAA,EAAC;AAAA;AAAA;AAAA,EAIpC,QAAc;AACV,SAAK,OAAO,CAAA;AAAA,EAChB;AAAA,EAEA,OAAO,KAAU,UAAqB;AAClC,WAAO,KAAK,KAAK,GAAG;AAAA,EACxB;AAAA,EAEA,IAAO,KAAU,UAA8B;AAC3C,WAAO,KAAK,KAAK,GAAG;AAAA,EACxB;AAAA,EAEA,IAAI,KAAU,OAAY,UAAqB;AAC3C,SAAK,KAAK,GAAG,IAAI;AAAA,EACrB;AAAA,EAEA,SAAiB;AACb,WAAO,KAAK,OAAO;AAAA,EACvB;AAAA,EAEA,OAAe;AACX,WAAO,IAAI,WAAW,OAAO,KAAK,KAAK,IAAI,CAAC;AAAA,EAChD;AAAA,EAEA,SAAS,MAAqB;AAC1B,WAAO,IAAI,WAAW,IAAI;AAAA,EAC9B;AAAA,EAEA,SAA0B;AACtB,WAAO,IAAI,uBAAuB,IAAI;AAAA,EAC1C;AACJ;AAOO,SAAS,yBAAiD;AAC7D,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS,IAAI,cAAA;AAAA,EAAc;AAEnC;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/v1/key-set.ts","../../src/v1/recordable.ts","../../src/v1/in-memory.ts"],"sourcesContent":["import type { Key } from './key';\n\nexport type KeySet = {\n add(key: Key): void;\n contains(key: Key): boolean;\n difference(other: KeySet): KeySet;\n equals(other: KeySet): boolean;\n elements(): Key[];\n isSubsetOf(other: KeySet): boolean;\n length: number;\n overlaps(other: KeySet): boolean;\n};\n\n/**\n * A collection of keys, in no particular order.\n */\nexport class KeySetImpl implements KeySet {\n // TODO - probably better to use Set<Key>\n private data: Record<Key, true> = {};\n private lengthInternal: number = 0;\n\n constructor(initialKeys?: Key[]) {\n if (initialKeys) {\n initialKeys.forEach((key) => {\n this.add(key);\n });\n }\n }\n\n add(key: Key): void {\n this.data[key] = true;\n // TODO - need to account for adding a key that was already in the set\n this.lengthInternal++;\n }\n\n contains(key: Key): boolean {\n return this.data[key] === true;\n }\n\n elements(): Key[] {\n return Object.keys(this.data);\n }\n\n get length(): number {\n return this.lengthInternal;\n }\n\n overlaps(other: KeySet): boolean {\n const otherKeys = other.elements();\n\n for (let j = 0; j < otherKeys.length; ++j) {\n if (this.contains(otherKeys[j])) {\n return true;\n }\n }\n\n return false;\n }\n\n difference(other: KeySet): KeySet {\n const value = new KeySetImpl();\n\n this.elements().forEach((key) => {\n if (!other.contains(key)) {\n value.add(key);\n }\n });\n\n return value;\n }\n\n isSubsetOf(other: KeySet): boolean {\n return this.difference(other).length === 0;\n }\n\n equals(other: KeySet): boolean {\n return this.length === other.length && this.elements().every((key) => other.contains(key));\n }\n\n toString(): string {\n return `<<${JSON.stringify(this.elements())}>>`;\n }\n}\n","import { type Key } from './key';\nimport { type KeySet, KeySetImpl } from './key-set';\nimport { type StoreService } from './store';\n\n/**\n * A RecordableStore wraps another Store and is used to record which keys in the\n * other Store are read/written.\n */\nexport class DefaultRecordableStore implements StoreService {\n keysRead = new KeySetImpl();\n missingKeysRead = new KeySetImpl();\n keysUpdated = new KeySetImpl();\n\n constructor(private baseStore: StoreService) {}\n\n delete(key: Key, options?: {}) {\n this.keysUpdated.add(key);\n this.baseStore.delete(key, options);\n }\n\n get<T>(key: Key, options?: {}) {\n this.keysRead.add(key);\n const value = this.baseStore.get<T>(key, options);\n if (value === undefined) {\n this.missingKeysRead.add(key);\n }\n\n return value;\n }\n\n set(key: Key, value: any, options?: {}) {\n this.keysUpdated.add(key);\n this.baseStore.set(key, value, options);\n }\n\n length() {\n return this.baseStore.length();\n }\n\n keys() {\n return this.baseStore.keys();\n }\n\n toKeySet(keys: Key[]): KeySet {\n return this.baseStore.toKeySet(keys);\n }\n\n record() {\n return this.baseStore.record();\n }\n}\n","import { type Key } from './key';\nimport { type KeySet, KeySetImpl } from './key-set';\nimport { DefaultRecordableStore } from './recordable';\nimport { type StoreService } from './store';\nimport type { RecordableStore, StoreServiceDescriptor } from './store';\n\n/**\n * A simple in-memory implementation of the Store interface.\n *\n * Exported for testing purposes only.\n */\nexport class InMemoryStore implements StoreService {\n protected data: Record<Key, any> = {};\n\n // TODO - only intended for use in tests. We should refactor this into a subclass &\n // add to a test util library.\n clear(): void {\n this.data = {};\n }\n\n delete(key: Key, _options?: {}): void {\n delete this.data[key];\n }\n\n get<T>(key: Key, _options?: {}): T | undefined {\n return this.data[key];\n }\n\n set(key: Key, value: any, _options?: {}): void {\n this.data[key] = value;\n }\n\n length(): number {\n return this.keys().length;\n }\n\n keys(): KeySet {\n return new KeySetImpl(Object.keys(this.data));\n }\n\n toKeySet(keys: Key[]): KeySet {\n return new KeySetImpl(keys);\n }\n\n record(): RecordableStore {\n return new DefaultRecordableStore(this);\n }\n}\n\n/**\n * Constructs an in-memory implementation of StoreService.\n *\n * @returns in-memory implementation of StoreService\n */\nexport function buildServiceDescriptor(): StoreServiceDescriptor {\n return {\n type: 'store',\n version: '1.0',\n service: new InMemoryStore(),\n };\n}\n"],"names":[],"mappings":"AAgBO,MAAM,WAA6B;AAAA,EAKtC,YAAY,aAAqB;AAHjC,SAAQ,OAA0B,CAAA;AAClC,SAAQ,iBAAyB;AAG7B,QAAI,aAAa;AACb,kBAAY,QAAQ,CAAC,QAAQ;AACzB,aAAK,IAAI,GAAG;AAAA,MAChB,CAAC;AAAA,IACL;AAAA,EACJ;AAAA,EAEA,IAAI,KAAgB;AAChB,SAAK,KAAK,GAAG,IAAI;AAEjB,SAAK;AAAA,EACT;AAAA,EAEA,SAAS,KAAmB;AACxB,WAAO,KAAK,KAAK,GAAG,MAAM;AAAA,EAC9B;AAAA,EAEA,WAAkB;AACd,WAAO,OAAO,K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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduit-client/service-store",
3
- "version": "3.20.0",
3
+ "version": "3.20.4",
4
4
  "private": false,
5
5
  "description": "Luvio request deduplication service",
6
6
  "type": "module",
@@ -30,8 +30,8 @@
30
30
  "watch": "npm run build --watch"
31
31
  },
32
32
  "dependencies": {
33
- "@conduit-client/generator-ts": "3.20.0",
34
- "@conduit-client/utils": "3.20.0"
33
+ "@conduit-client/generator-ts": "3.20.4",
34
+ "@conduit-client/utils": "3.20.4"
35
35
  },
36
36
  "volta": {
37
37
  "extends": "../../../../package.json"