@genesislcap/foundation-comms 14.225.2-alpha-adaf8d7.0 → 14.225.3-alpha-05eb387.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -17,7 +17,8 @@ import { KeyValue, KeyValueTransfer, KVValue, KVEventFailureResponse } from './k
|
|
17
17
|
*/
|
18
18
|
export interface KVStorage {
|
19
19
|
delete(keys: string[]): Promise<true | KVEventFailureResponse>;
|
20
|
-
get<T = KVValue>(
|
20
|
+
get<T = KVValue>(): Promise<KeyValueTransfer<T>[]>;
|
21
|
+
get<T = KVValue>(key: string): Promise<KeyValueTransfer<T>>;
|
21
22
|
list(): Promise<string[]>;
|
22
23
|
put(kvs: KeyValue<KVValue>[]): Promise<true | KVEventFailureResponse>;
|
23
24
|
}
|
@@ -67,7 +68,8 @@ export declare class DefaultKVStorage implements KVStorage {
|
|
67
68
|
* ...
|
68
69
|
* ```
|
69
70
|
*/
|
70
|
-
get<T = KVValue>(
|
71
|
+
get<T = KVValue>(): Promise<KeyValueTransfer<T>[]>;
|
72
|
+
get<T = KVValue>(key: string): Promise<KeyValueTransfer<T>>;
|
71
73
|
/**
|
72
74
|
* Lists all keys for the user.
|
73
75
|
* @alpha
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"kv.service.d.ts","sourceRoot":"","sources":["../../../../src/storage/kv/kv.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;
|
1
|
+
{"version":3,"file":"kv.service.d.ts","sourceRoot":"","sources":["../../../../src/storage/kv/kv.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAMpD,OAAO,EAAgB,OAAO,EAA0B,MAAM,eAAe,CAAC;AAE9E,OAAO,EAA0B,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,sBAAsB,EAGvB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;GA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AO,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,GAAG,sBAAsB,CAAC;CAsB5E;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,iEAAsE,CAAC;AAE7F;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAExC"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { __awaiter, __decorate, __param } from "tslib";
|
2
2
|
import { User } from '@genesislcap/foundation-user';
|
3
|
+
import { decodeFromBase64WithPrefix, encodeToBase64WithPrefix, } from '@genesislcap/foundation-utils';
|
3
4
|
import { DI, optional } from '@microsoft/fast-foundation';
|
4
5
|
import { Connect } from '../../connect';
|
5
6
|
import { logger } from '../../utils';
|
@@ -59,24 +60,6 @@ let DefaultKVStorage = class DefaultKVStorage {
|
|
59
60
|
}
|
60
61
|
});
|
61
62
|
}
|
62
|
-
/**
|
63
|
-
* Gets the specified key-value pairs from the KV storage.
|
64
|
-
* @remarks If no key is specified, all key-value pairs for the current user are returned.
|
65
|
-
* @alpha
|
66
|
-
* @param kv - The single key-value pair to get.
|
67
|
-
* @returns A promise that resolves to an array of key-value pairs.
|
68
|
-
*
|
69
|
-
* @example
|
70
|
-
* ```ts
|
71
|
-
* ...
|
72
|
-
* const result = await this.kvStorage.get({ key: 'myKey' });
|
73
|
-
* logger.debug(result); // [{ key: 'myKey', value: 'myValue' }]
|
74
|
-
*
|
75
|
-
* const result2 = await this.kvStorage.get();
|
76
|
-
* logger.debug(result); // [{ key: 'myKey', value: 'myValue' }, { key: 'myOtherKey', value: 'myOtherValue' }]
|
77
|
-
* ...
|
78
|
-
* ```
|
79
|
-
*/
|
80
63
|
get(key) {
|
81
64
|
var _a;
|
82
65
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -88,11 +71,39 @@ let DefaultKVStorage = class DefaultKVStorage {
|
|
88
71
|
};
|
89
72
|
const result = yield this.connect.request(KVMessageType.REQ_KEY_VALUE_READ, params);
|
90
73
|
if (result && result.REPLY && result.REPLY.length > 0) {
|
91
|
-
const kvs = result.REPLY.map((kv) =>
|
92
|
-
|
74
|
+
const kvs = result.REPLY.map((kv) => {
|
75
|
+
// For backwards compatibility, we need a prefix
|
76
|
+
if (!kv.VALUE.startsWith('str:') && !kv.VALUE.startsWith('bin:')) {
|
77
|
+
kv.VALUE = `str:${kv.VALUE}`;
|
78
|
+
}
|
79
|
+
let decoded = decodeFromBase64WithPrefix(kv.VALUE);
|
80
|
+
// TODO: \/ \/ The bit below only applies if `put` was called with `base64: true`
|
81
|
+
if (typeof decoded === 'string' && decoded.startsWith('str:')) {
|
82
|
+
decoded = decodeFromBase64WithPrefix(decoded);
|
83
|
+
}
|
84
|
+
if (typeof decoded === 'string' && decoded.startsWith('bin:')) {
|
85
|
+
decoded = decodeFromBase64WithPrefix(decoded);
|
86
|
+
}
|
87
|
+
// TODO: /\ /\ The bit above only applies if `put` was called with `base64: true`
|
88
|
+
// `decoded` now is really unknown, due double possibility encoding from the server
|
89
|
+
let value = decoded;
|
90
|
+
if (typeof decoded === 'string') {
|
91
|
+
try {
|
92
|
+
value = JSON.parse(decoded);
|
93
|
+
}
|
94
|
+
catch (_a) {
|
95
|
+
// Silent fail for now, when storing simple strings (not stringfied JSON) this will fail.
|
96
|
+
// logger.error(`Failed to parse value for key ${kv.KEY}`);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
return {
|
100
|
+
kv: { key: kv.KEY, value: value },
|
101
|
+
};
|
102
|
+
});
|
103
|
+
return key ? kvs[0] : kvs;
|
93
104
|
}
|
94
105
|
else {
|
95
|
-
return [];
|
106
|
+
return key ? undefined : [];
|
96
107
|
}
|
97
108
|
});
|
98
109
|
}
|
@@ -143,12 +154,15 @@ let DefaultKVStorage = class DefaultKVStorage {
|
|
143
154
|
return __awaiter(this, void 0, void 0, function* () {
|
144
155
|
const params = {
|
145
156
|
DETAILS: {
|
146
|
-
RECORDS: kvs.map((kv) =>
|
147
|
-
|
148
|
-
|
149
|
-
|
157
|
+
RECORDS: kvs.map((kv) => {
|
158
|
+
return {
|
159
|
+
KEY: kv.key,
|
160
|
+
VALUE: kv.base64 ? encodeToBase64WithPrefix(kv.value) : kv.value,
|
161
|
+
};
|
162
|
+
}),
|
150
163
|
},
|
151
164
|
};
|
165
|
+
debugger;
|
152
166
|
const result = yield this.connect.commitEvent(KVEventMessageType.EVENT_KEY_VALUE_PUT, params);
|
153
167
|
if (result && result.MESSAGE_TYPE === 'EVENT_ACK') {
|
154
168
|
return true;
|
@@ -2028,7 +2028,8 @@ export declare class DefaultKVStorage implements KVStorage {
|
|
2028
2028
|
* ...
|
2029
2029
|
* ```
|
2030
2030
|
*/
|
2031
|
-
get<T = KVValue>(
|
2031
|
+
get<T = KVValue>(): Promise<KeyValueTransfer<T>[]>;
|
2032
|
+
get<T = KVValue>(key: string): Promise<KeyValueTransfer<T>>;
|
2032
2033
|
/**
|
2033
2034
|
* Lists all keys for the user.
|
2034
2035
|
* @alpha
|
@@ -3129,7 +3130,8 @@ export declare enum KVMessageType {
|
|
3129
3130
|
*/
|
3130
3131
|
export declare interface KVStorage {
|
3131
3132
|
delete(keys: string[]): Promise<true | KVEventFailureResponse>;
|
3132
|
-
get<T = KVValue>(
|
3133
|
+
get<T = KVValue>(): Promise<KeyValueTransfer<T>[]>;
|
3134
|
+
get<T = KVValue>(key: string): Promise<KeyValueTransfer<T>>;
|
3133
3135
|
list(): Promise<string[]>;
|
3134
3136
|
put(kvs: KeyValue<KVValue>[]): Promise<true | KVEventFailureResponse>;
|
3135
3137
|
}
|
package/docs/api-report.md
CHANGED
@@ -1323,7 +1323,9 @@ export class DefaultHttpConnect implements Connect {
|
|
1323
1323
|
export class DefaultKVStorage implements KVStorage {
|
1324
1324
|
constructor(connect: Connect, user: User_2, kvStorageConfig?: KVStorageConfig);
|
1325
1325
|
delete(keys: string[]): Promise<true | KVEventFailureResponse>;
|
1326
|
-
get<T = KVValue>(
|
1326
|
+
get<T = KVValue>(): Promise<KeyValueTransfer<T>[]>;
|
1327
|
+
// (undocumented)
|
1328
|
+
get<T = KVValue>(key: string): Promise<KeyValueTransfer<T>>;
|
1327
1329
|
list(): Promise<string[]>;
|
1328
1330
|
put(kvs: KeyValue<KVValue>[]): Promise<true | KVEventFailureResponse>;
|
1329
1331
|
// (undocumented)
|
@@ -1918,7 +1920,9 @@ export interface KVStorage {
|
|
1918
1920
|
// (undocumented)
|
1919
1921
|
delete(keys: string[]): Promise<true | KVEventFailureResponse>;
|
1920
1922
|
// (undocumented)
|
1921
|
-
get<T = KVValue>(
|
1923
|
+
get<T = KVValue>(): Promise<KeyValueTransfer<T>[]>;
|
1924
|
+
// (undocumented)
|
1925
|
+
get<T = KVValue>(key: string): Promise<KeyValueTransfer<T>>;
|
1922
1926
|
// (undocumented)
|
1923
1927
|
list(): Promise<string[]>;
|
1924
1928
|
// (undocumented)
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@genesislcap/foundation-comms",
|
3
3
|
"description": "Genesis Foundation UI Comms",
|
4
|
-
"version": "14.225.
|
4
|
+
"version": "14.225.3-alpha-05eb387.0",
|
5
5
|
"sideEffects": false,
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
7
7
|
"main": "dist/esm/index.js",
|
@@ -75,23 +75,23 @@
|
|
75
75
|
}
|
76
76
|
},
|
77
77
|
"devDependencies": {
|
78
|
-
"@genesislcap/foundation-testing": "14.225.
|
79
|
-
"@genesislcap/genx": "14.225.
|
80
|
-
"@genesislcap/rollup-builder": "14.225.
|
81
|
-
"@genesislcap/ts-builder": "14.225.
|
82
|
-
"@genesislcap/uvu-playwright-builder": "14.225.
|
83
|
-
"@genesislcap/vite-builder": "14.225.
|
84
|
-
"@genesislcap/webpack-builder": "14.225.
|
78
|
+
"@genesislcap/foundation-testing": "14.225.3-alpha-05eb387.0",
|
79
|
+
"@genesislcap/genx": "14.225.3-alpha-05eb387.0",
|
80
|
+
"@genesislcap/rollup-builder": "14.225.3-alpha-05eb387.0",
|
81
|
+
"@genesislcap/ts-builder": "14.225.3-alpha-05eb387.0",
|
82
|
+
"@genesislcap/uvu-playwright-builder": "14.225.3-alpha-05eb387.0",
|
83
|
+
"@genesislcap/vite-builder": "14.225.3-alpha-05eb387.0",
|
84
|
+
"@genesislcap/webpack-builder": "14.225.3-alpha-05eb387.0",
|
85
85
|
"@types/js-cookie": "^3.0.2",
|
86
86
|
"@types/json-schema": "^7.0.11",
|
87
87
|
"@types/webappsec-credential-management": "^0.6.2",
|
88
88
|
"rimraf": "^5.0.0"
|
89
89
|
},
|
90
90
|
"dependencies": {
|
91
|
-
"@genesislcap/foundation-broadcast-channel": "14.225.
|
92
|
-
"@genesislcap/foundation-logger": "14.225.
|
93
|
-
"@genesislcap/foundation-user": "14.225.
|
94
|
-
"@genesislcap/foundation-utils": "14.225.
|
91
|
+
"@genesislcap/foundation-broadcast-channel": "14.225.3-alpha-05eb387.0",
|
92
|
+
"@genesislcap/foundation-logger": "14.225.3-alpha-05eb387.0",
|
93
|
+
"@genesislcap/foundation-user": "14.225.3-alpha-05eb387.0",
|
94
|
+
"@genesislcap/foundation-utils": "14.225.3-alpha-05eb387.0",
|
95
95
|
"@microsoft/fast-element": "1.14.0",
|
96
96
|
"@microsoft/fast-foundation": "2.49.6",
|
97
97
|
"analytics": "^0.8.0",
|
@@ -111,5 +111,5 @@
|
|
111
111
|
"publishConfig": {
|
112
112
|
"access": "public"
|
113
113
|
},
|
114
|
-
"gitHead": "
|
114
|
+
"gitHead": "a2d452dd10b1e62289adc8a4fbea2dce8e6262c9"
|
115
115
|
}
|