@gomomento/sdk-core 1.86.0 → 1.88.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/dist/src/auth/credential-provider.d.ts +26 -0
- package/dist/src/auth/credential-provider.js +45 -7
- package/dist/src/errors/errors.js +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +2 -1
- package/dist/src/internal/utils/auth.d.ts +7 -3
- package/dist/src/internal/utils/auth.js +19 -7
- package/dist/src/messages/responses/cache-batch-get.d.ts +18 -51
- package/dist/src/messages/responses/cache-batch-get.js +23 -56
- package/dist/src/messages/responses/cache-batch-set.d.ts +14 -51
- package/dist/src/messages/responses/cache-batch-set.js +12 -42
- package/dist/src/messages/responses/cache-delete.d.ts +11 -44
- package/dist/src/messages/responses/cache-delete.js +14 -35
- package/dist/src/messages/responses/cache-dictionary-fetch.d.ts +18 -54
- package/dist/src/messages/responses/cache-dictionary-fetch.js +23 -46
- package/dist/src/messages/responses/cache-dictionary-get-field.d.ts +19 -58
- package/dist/src/messages/responses/cache-dictionary-get-field.js +19 -52
- package/dist/src/messages/responses/cache-dictionary-get-fields.d.ts +19 -56
- package/dist/src/messages/responses/cache-dictionary-get-fields.js +27 -50
- package/dist/src/messages/responses/cache-dictionary-increment.d.ts +14 -46
- package/dist/src/messages/responses/cache-dictionary-increment.js +14 -41
- package/dist/src/messages/responses/cache-dictionary-length.d.ts +19 -53
- package/dist/src/messages/responses/cache-dictionary-length.js +26 -40
- package/dist/src/messages/responses/cache-dictionary-remove-field.d.ts +10 -43
- package/dist/src/messages/responses/cache-dictionary-remove-field.js +13 -34
- package/dist/src/messages/responses/cache-dictionary-remove-fields.d.ts +10 -43
- package/dist/src/messages/responses/cache-dictionary-remove-fields.js +13 -34
- package/dist/src/messages/responses/cache-dictionary-set-field.d.ts +10 -43
- package/dist/src/messages/responses/cache-dictionary-set-field.js +13 -34
- package/dist/src/messages/responses/cache-dictionary-set-fields.d.ts +10 -43
- package/dist/src/messages/responses/cache-dictionary-set-fields.js +13 -34
- package/dist/src/messages/responses/cache-flush.d.ts +12 -45
- package/dist/src/messages/responses/cache-flush.js +15 -36
- package/dist/src/messages/responses/cache-get.d.ts +19 -54
- package/dist/src/messages/responses/cache-get.js +22 -45
- package/dist/src/messages/responses/cache-increment.d.ts +24 -51
- package/dist/src/messages/responses/cache-increment.js +27 -49
- package/dist/src/messages/responses/cache-item-get-ttl.d.ts +22 -55
- package/dist/src/messages/responses/cache-item-get-ttl.js +27 -41
- package/dist/src/messages/responses/cache-item-get-type.d.ts +22 -55
- package/dist/src/messages/responses/cache-item-get-type.js +27 -41
- package/dist/src/messages/responses/cache-key-exists.d.ts +16 -47
- package/dist/src/messages/responses/cache-key-exists.js +17 -38
- package/dist/src/messages/responses/cache-keys-exist.d.ts +16 -47
- package/dist/src/messages/responses/cache-keys-exist.js +16 -37
- package/dist/src/messages/responses/cache-list-concatenate-back.d.ts +13 -46
- package/dist/src/messages/responses/cache-list-concatenate-back.js +13 -37
- package/dist/src/messages/responses/cache-list-concatenate-front.d.ts +13 -46
- package/dist/src/messages/responses/cache-list-concatenate-front.js +13 -37
- package/dist/src/messages/responses/cache-list-fetch.d.ts +23 -58
- package/dist/src/messages/responses/cache-list-fetch.js +26 -49
- package/dist/src/messages/responses/cache-list-length.d.ts +27 -59
- package/dist/src/messages/responses/cache-list-length.js +32 -42
- package/dist/src/messages/responses/cache-list-pop-back.d.ts +22 -57
- package/dist/src/messages/responses/cache-list-pop-back.js +25 -48
- package/dist/src/messages/responses/cache-list-pop-front.d.ts +22 -57
- package/dist/src/messages/responses/cache-list-pop-front.js +25 -48
- package/dist/src/messages/responses/cache-list-push-back.d.ts +13 -46
- package/dist/src/messages/responses/cache-list-push-back.js +13 -37
- package/dist/src/messages/responses/cache-list-push-front.d.ts +13 -46
- package/dist/src/messages/responses/cache-list-push-front.js +13 -37
- package/dist/src/messages/responses/cache-list-remove-value.d.ts +11 -44
- package/dist/src/messages/responses/cache-list-remove-value.js +14 -35
- package/dist/src/messages/responses/cache-list-retain.d.ts +11 -44
- package/dist/src/messages/responses/cache-list-retain.js +14 -35
- package/dist/src/messages/responses/cache-set-add-element.d.ts +10 -53
- package/dist/src/messages/responses/cache-set-add-element.js +13 -34
- package/dist/src/messages/responses/cache-set-add-elements.d.ts +12 -45
- package/dist/src/messages/responses/cache-set-add-elements.js +17 -38
- package/dist/src/messages/responses/cache-set-fetch.d.ts +18 -54
- package/dist/src/messages/responses/cache-set-fetch.js +23 -46
- package/dist/src/messages/responses/cache-set-if-absent-or-equal.d.ts +15 -55
- package/dist/src/messages/responses/cache-set-if-absent-or-equal.js +21 -41
- package/dist/src/messages/responses/cache-set-if-absent.d.ts +14 -63
- package/dist/src/messages/responses/cache-set-if-absent.js +20 -40
- package/dist/src/messages/responses/cache-set-if-equal.d.ts +15 -55
- package/dist/src/messages/responses/cache-set-if-equal.js +21 -41
- package/dist/src/messages/responses/cache-set-if-not-equal.d.ts +15 -55
- package/dist/src/messages/responses/cache-set-if-not-equal.js +21 -41
- package/dist/src/messages/responses/cache-set-if-not-exists.d.ts +14 -54
- package/dist/src/messages/responses/cache-set-if-not-exists.js +20 -40
- package/dist/src/messages/responses/cache-set-if-present-and-not-equal.d.ts +15 -55
- package/dist/src/messages/responses/cache-set-if-present-and-not-equal.js +21 -41
- package/dist/src/messages/responses/cache-set-if-present.d.ts +15 -55
- package/dist/src/messages/responses/cache-set-if-present.js +21 -41
- package/dist/src/messages/responses/cache-set-remove-element.d.ts +10 -43
- package/dist/src/messages/responses/cache-set-remove-element.js +13 -34
- package/dist/src/messages/responses/cache-set-remove-elements.d.ts +13 -46
- package/dist/src/messages/responses/cache-set-remove-elements.js +13 -34
- package/dist/src/messages/responses/cache-set-sample.d.ts +18 -54
- package/dist/src/messages/responses/cache-set-sample.js +23 -46
- package/dist/src/messages/responses/cache-set.d.ts +10 -43
- package/dist/src/messages/responses/cache-set.js +13 -34
- package/dist/src/messages/responses/cache-sorted-set-fetch.js +1 -1
- package/dist/src/messages/responses/cache-sorted-set-get-score.d.ts +6 -1
- package/dist/src/messages/responses/cache-sorted-set-get-score.js +1 -1
- package/dist/src/messages/responses/cache-sorted-set-get-scores.js +1 -1
- package/dist/src/messages/responses/cache-sorted-set-increment-score.js +1 -1
- package/dist/src/messages/responses/cache-ttl-decrease.d.ts +19 -53
- package/dist/src/messages/responses/cache-ttl-decrease.js +29 -39
- package/dist/src/messages/responses/cache-ttl-increase.d.ts +19 -53
- package/dist/src/messages/responses/cache-ttl-increase.js +29 -39
- package/dist/src/messages/responses/cache-ttl-update.d.ts +15 -55
- package/dist/src/messages/responses/cache-ttl-update.js +21 -41
- package/dist/src/messages/responses/create-cache.d.ts +15 -58
- package/dist/src/messages/responses/create-cache.js +21 -39
- package/dist/src/messages/responses/delete-cache.d.ts +11 -44
- package/dist/src/messages/responses/delete-cache.js +14 -35
- package/dist/src/messages/responses/enums/auth/generate-api-key.d.ts +4 -0
- package/dist/src/messages/responses/enums/auth/generate-api-key.js +9 -0
- package/dist/src/messages/responses/enums/auth/generate-disposable-token.d.ts +4 -0
- package/dist/src/messages/responses/enums/auth/generate-disposable-token.js +9 -0
- package/dist/src/messages/responses/enums/auth/index.d.ts +3 -0
- package/dist/src/messages/responses/enums/auth/index.js +10 -0
- package/dist/src/messages/responses/enums/auth/refresh-api-key.d.ts +4 -0
- package/dist/src/messages/responses/enums/auth/refresh-api-key.js +9 -0
- package/dist/src/messages/responses/enums/cache/control/index.d.ts +17 -0
- package/dist/src/messages/responses/enums/cache/control/index.js +25 -0
- package/dist/src/messages/responses/enums/cache/dictionary/index.d.ts +40 -0
- package/dist/src/messages/responses/enums/cache/dictionary/index.js +53 -0
- package/dist/src/messages/responses/enums/cache/index.d.ts +5 -0
- package/dist/src/messages/responses/enums/cache/index.js +22 -0
- package/dist/src/messages/responses/enums/cache/list/index.d.ts +44 -0
- package/dist/src/messages/responses/enums/cache/list/index.js +58 -0
- package/dist/src/messages/responses/enums/cache/scalar/index.d.ts +95 -0
- package/dist/src/messages/responses/enums/cache/scalar/index.js +122 -0
- package/dist/src/messages/responses/enums/cache/set/index.d.ts +26 -0
- package/dist/src/messages/responses/enums/cache/set/index.js +36 -0
- package/dist/src/messages/responses/enums/index.d.ts +4 -0
- package/dist/src/messages/responses/enums/index.js +21 -0
- package/dist/src/messages/responses/enums/leaderboard/index.d.ts +20 -0
- package/dist/src/messages/responses/enums/leaderboard/index.js +29 -0
- package/dist/src/messages/responses/enums/topics/index.d.ts +8 -0
- package/dist/src/messages/responses/enums/topics/index.js +14 -0
- package/dist/src/messages/responses/generate-api-key.d.ts +10 -27
- package/dist/src/messages/responses/generate-api-key.js +10 -18
- package/dist/src/messages/responses/generate-disposable-token.d.ts +10 -27
- package/dist/src/messages/responses/generate-disposable-token.js +10 -18
- package/dist/src/messages/responses/leaderboard/leaderboard-delete.d.ts +10 -43
- package/dist/src/messages/responses/leaderboard/leaderboard-delete.js +13 -34
- package/dist/src/messages/responses/leaderboard/leaderboard-fetch.d.ts +12 -45
- package/dist/src/messages/responses/leaderboard/leaderboard-fetch.js +11 -35
- package/dist/src/messages/responses/leaderboard/leaderboard-length.d.ts +12 -45
- package/dist/src/messages/responses/leaderboard/leaderboard-length.js +11 -35
- package/dist/src/messages/responses/leaderboard/leaderboard-remove-elements.d.ts +10 -43
- package/dist/src/messages/responses/leaderboard/leaderboard-remove-elements.js +13 -34
- package/dist/src/messages/responses/leaderboard/leaderboard-upsert.d.ts +11 -44
- package/dist/src/messages/responses/leaderboard/leaderboard-upsert.js +14 -35
- package/dist/src/messages/responses/list-caches.d.ts +13 -46
- package/dist/src/messages/responses/list-caches.js +11 -35
- package/dist/src/messages/responses/refresh-api-key.d.ts +10 -27
- package/dist/src/messages/responses/refresh-api-key.js +10 -18
- package/dist/src/messages/responses/response-base.d.ts +20 -0
- package/dist/src/messages/responses/response-base.js +42 -2
- package/dist/src/messages/responses/topic-publish.d.ts +10 -43
- package/dist/src/messages/responses/topic-publish.js +13 -34
- package/dist/src/messages/responses/topic-subscribe.d.ts +10 -37
- package/dist/src/messages/responses/topic-subscribe.js +10 -33
- package/dist/src/messages/responses/webhook/put-webhook.d.ts +1 -10
- package/package.json +1 -1
@@ -1,29 +1,16 @@
|
|
1
1
|
import { SdkError } from '../../errors';
|
2
|
-
import { ResponseBase } from './response-base';
|
3
|
-
|
4
|
-
|
5
|
-
* response object is resolved to a type-safe object of one of
|
6
|
-
* the following subtypes:
|
7
|
-
*
|
8
|
-
* - {Hit}
|
9
|
-
* - {Miss}
|
10
|
-
* - {Error}
|
11
|
-
*
|
12
|
-
* `instanceof` type guards can be used to operate on the appropriate subtype.
|
13
|
-
* @example
|
14
|
-
* For example:
|
15
|
-
* ```
|
16
|
-
* if (response instanceof CacheGet.Error) {
|
17
|
-
* // Handle error as appropriate. The compiler will smart-cast `response` to type
|
18
|
-
* // `CacheGet.Error` in this block, so you will have access to the properties
|
19
|
-
* // of the Error class; e.g. `response.errorCode()`.
|
20
|
-
* }
|
21
|
-
* ```
|
22
|
-
*/
|
23
|
-
export declare abstract class Response extends ResponseBase {
|
2
|
+
import { BaseResponseError, BaseResponseMiss, ResponseBase } from './response-base';
|
3
|
+
import { CacheGetResponse } from './enums';
|
4
|
+
interface IResponse {
|
24
5
|
value(): string | undefined;
|
6
|
+
readonly type: CacheGetResponse;
|
25
7
|
}
|
26
|
-
|
8
|
+
/**
|
9
|
+
* Indicates that the requested data was successfully retrieved from the cache. Provides
|
10
|
+
* `value*` accessors to retrieve the data in the appropriate format.
|
11
|
+
*/
|
12
|
+
export declare class Hit extends ResponseBase implements IResponse {
|
13
|
+
readonly type: CacheGetResponse.Hit;
|
27
14
|
private readonly body;
|
28
15
|
constructor(body: Uint8Array);
|
29
16
|
/**
|
@@ -43,40 +30,14 @@ declare class _Hit extends Response {
|
|
43
30
|
valueUint8Array(): Uint8Array;
|
44
31
|
toString(): string;
|
45
32
|
}
|
46
|
-
declare const Hit_base: {
|
47
|
-
new (...args: any[]): {};
|
48
|
-
} & typeof _Hit;
|
49
|
-
/**
|
50
|
-
* Indicates that the requested data was successfully retrieved from the cache. Provides
|
51
|
-
* `value*` accessors to retrieve the data in the appropriate format.
|
52
|
-
*/
|
53
|
-
export declare class Hit extends Hit_base {
|
54
|
-
}
|
55
|
-
declare class _Miss extends Response {
|
56
|
-
}
|
57
|
-
declare const Miss_base: {
|
58
|
-
new (...args: any[]): {
|
59
|
-
readonly is_miss: boolean;
|
60
|
-
};
|
61
|
-
} & typeof _Miss;
|
62
33
|
/**
|
63
34
|
* Indicates that the requested data was not available in the cache.
|
64
35
|
*/
|
65
|
-
export declare class Miss extends
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
constructor(_innerException: SdkError);
|
36
|
+
export declare class Miss extends BaseResponseMiss implements IResponse {
|
37
|
+
readonly type: CacheGetResponse.Miss;
|
38
|
+
constructor();
|
39
|
+
value(): undefined;
|
70
40
|
}
|
71
|
-
declare const Error_base: {
|
72
|
-
new (...args: any[]): {
|
73
|
-
_innerException: SdkError;
|
74
|
-
message(): string;
|
75
|
-
innerException(): SdkError;
|
76
|
-
errorCode(): import("../../errors").MomentoErrorCode;
|
77
|
-
toString(): string;
|
78
|
-
};
|
79
|
-
} & typeof _Error;
|
80
41
|
/**
|
81
42
|
* Indicates that an error occurred during the cache get request.
|
82
43
|
*
|
@@ -87,6 +48,10 @@ declare const Error_base: {
|
|
87
48
|
* - `message()` - a human-readable description of the error
|
88
49
|
* - `innerException()` - the original error that caused the failure; can be re-thrown.
|
89
50
|
*/
|
90
|
-
export declare class Error extends
|
51
|
+
export declare class Error extends BaseResponseError implements IResponse {
|
52
|
+
readonly type: CacheGetResponse.Error;
|
53
|
+
constructor(_innerException: SdkError);
|
54
|
+
value(): undefined;
|
91
55
|
}
|
56
|
+
export type Response = Hit | Miss | Error;
|
92
57
|
export {};
|
@@ -1,41 +1,18 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Error = exports.Miss = exports.Hit =
|
3
|
+
exports.Error = exports.Miss = exports.Hit = void 0;
|
4
4
|
const response_base_1 = require("./response-base");
|
5
5
|
const utils_1 = require("../../internal/utils");
|
6
|
+
const enums_1 = require("./enums");
|
6
7
|
const TEXT_DECODER = new TextDecoder();
|
7
8
|
/**
|
8
|
-
*
|
9
|
-
*
|
10
|
-
* the following subtypes:
|
11
|
-
*
|
12
|
-
* - {Hit}
|
13
|
-
* - {Miss}
|
14
|
-
* - {Error}
|
15
|
-
*
|
16
|
-
* `instanceof` type guards can be used to operate on the appropriate subtype.
|
17
|
-
* @example
|
18
|
-
* For example:
|
19
|
-
* ```
|
20
|
-
* if (response instanceof CacheGet.Error) {
|
21
|
-
* // Handle error as appropriate. The compiler will smart-cast `response` to type
|
22
|
-
* // `CacheGet.Error` in this block, so you will have access to the properties
|
23
|
-
* // of the Error class; e.g. `response.errorCode()`.
|
24
|
-
* }
|
25
|
-
* ```
|
9
|
+
* Indicates that the requested data was successfully retrieved from the cache. Provides
|
10
|
+
* `value*` accessors to retrieve the data in the appropriate format.
|
26
11
|
*/
|
27
|
-
class
|
28
|
-
value() {
|
29
|
-
if (this instanceof Hit) {
|
30
|
-
return this.value();
|
31
|
-
}
|
32
|
-
return undefined;
|
33
|
-
}
|
34
|
-
}
|
35
|
-
exports.Response = Response;
|
36
|
-
class _Hit extends Response {
|
12
|
+
class Hit extends response_base_1.ResponseBase {
|
37
13
|
constructor(body) {
|
38
14
|
super();
|
15
|
+
this.type = enums_1.CacheGetResponse.Hit;
|
39
16
|
this.body = body;
|
40
17
|
}
|
41
18
|
/**
|
@@ -64,27 +41,20 @@ class _Hit extends Response {
|
|
64
41
|
return `${super.toString()}: ${display}`;
|
65
42
|
}
|
66
43
|
}
|
67
|
-
/**
|
68
|
-
* Indicates that the requested data was successfully retrieved from the cache. Provides
|
69
|
-
* `value*` accessors to retrieve the data in the appropriate format.
|
70
|
-
*/
|
71
|
-
class Hit extends (0, response_base_1.ResponseHit)(_Hit) {
|
72
|
-
}
|
73
44
|
exports.Hit = Hit;
|
74
|
-
class _Miss extends Response {
|
75
|
-
}
|
76
45
|
/**
|
77
46
|
* Indicates that the requested data was not available in the cache.
|
78
47
|
*/
|
79
|
-
class Miss extends
|
80
|
-
|
81
|
-
exports.Miss = Miss;
|
82
|
-
class _Error extends Response {
|
83
|
-
constructor(_innerException) {
|
48
|
+
class Miss extends response_base_1.BaseResponseMiss {
|
49
|
+
constructor() {
|
84
50
|
super();
|
85
|
-
this.
|
51
|
+
this.type = enums_1.CacheGetResponse.Miss;
|
52
|
+
}
|
53
|
+
value() {
|
54
|
+
return undefined;
|
86
55
|
}
|
87
56
|
}
|
57
|
+
exports.Miss = Miss;
|
88
58
|
/**
|
89
59
|
* Indicates that an error occurred during the cache get request.
|
90
60
|
*
|
@@ -95,7 +65,14 @@ class _Error extends Response {
|
|
95
65
|
* - `message()` - a human-readable description of the error
|
96
66
|
* - `innerException()` - the original error that caused the failure; can be re-thrown.
|
97
67
|
*/
|
98
|
-
class Error extends
|
68
|
+
class Error extends response_base_1.BaseResponseError {
|
69
|
+
constructor(_innerException) {
|
70
|
+
super(_innerException);
|
71
|
+
this.type = enums_1.CacheGetResponse.Error;
|
72
|
+
}
|
73
|
+
value() {
|
74
|
+
return undefined;
|
75
|
+
}
|
99
76
|
}
|
100
77
|
exports.Error = Error;
|
101
|
-
//# sourceMappingURL=data:application/json;base64,
|
78
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FjaGUtZ2V0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL21lc3NhZ2VzL3Jlc3BvbnNlcy9jYWNoZS1nZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQ0EsbURBSXlCO0FBQ3pCLGdEQUFvRDtBQUNwRCxtQ0FBeUM7QUFFekMsTUFBTSxZQUFZLEdBQUcsSUFBSSxXQUFX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XJlOyBjYW4gYmUgcmUtdGhyb3duLlxuICovXG5leHBvcnQgY2xhc3MgRXJyb3IgZXh0ZW5kcyBCYXNlUmVzcG9uc2VFcnJvciBpbXBsZW1lbnRzIElSZXNwb25zZSB7XG4gIHJlYWRvbmx5IHR5cGU6IENhY2hlR2V0UmVzcG9uc2UuRXJyb3IgPSBDYWNoZUdldFJlc3BvbnNlLkVycm9yO1xuICBjb25zdHJ1Y3RvcihfaW5uZXJFeGNlcHRpb246IFNka0Vycm9yKSB7XG4gICAgc3VwZXIoX2lubmVyRXhjZXB0aW9uKTtcbiAgfVxuXG4gIHZhbHVlKCk6IHVuZGVmaW5lZCB7XG4gICAgcmV0dXJuIHVuZGVmaW5lZDtcbiAgfVxufVxuXG5leHBvcnQgdHlwZSBSZXNwb25zZSA9IEhpdCB8IE1pc3MgfCBFcnJvcjtcbiJdfQ==
|
@@ -1,61 +1,30 @@
|
|
1
1
|
import { SdkError } from '../../errors';
|
2
|
-
import {
|
3
|
-
|
4
|
-
|
5
|
-
* response object is resolved to a type-safe object of one of
|
6
|
-
* the following subtypes:
|
7
|
-
*
|
8
|
-
* - {Success}
|
9
|
-
* - {Error}
|
10
|
-
*
|
11
|
-
* `instanceof` type guards can be used to operate on the appropriate subtype.
|
12
|
-
* @example
|
13
|
-
* For example:
|
14
|
-
* ```
|
15
|
-
* if (response instanceof CacheIncrement.Error) {
|
16
|
-
* // Handle error as appropriate. The compiler will smart-cast `response` to type
|
17
|
-
* // `CacheIncrement.Error` in this block, so you will have access to the properties
|
18
|
-
* // of the Error class; e.g. `response.errorCode()`.
|
19
|
-
* }
|
20
|
-
* ```
|
21
|
-
*/
|
22
|
-
export declare abstract class Response extends ResponseBase {
|
2
|
+
import { BaseResponseError, BaseResponseSuccess } from './response-base';
|
3
|
+
import { CacheIncrementResponse } from './enums';
|
4
|
+
interface IResponse {
|
23
5
|
value(): number | undefined;
|
6
|
+
readonly type: CacheIncrementResponse;
|
24
7
|
}
|
25
|
-
|
26
|
-
|
27
|
-
|
8
|
+
/**
|
9
|
+
* Indicates a successful cache increment request.
|
10
|
+
* Provides `value*` accessors to retrieve the updated value in the appropriate format.
|
11
|
+
*/
|
12
|
+
export declare class Success extends BaseResponseSuccess implements IResponse {
|
13
|
+
readonly type: CacheIncrementResponse.Success;
|
14
|
+
private readonly body;
|
15
|
+
constructor(body: number);
|
28
16
|
/**
|
29
|
-
*
|
30
|
-
* @returns
|
17
|
+
* Returns the updated value as a number.
|
18
|
+
* @returns number
|
31
19
|
*/
|
32
20
|
value(): number;
|
21
|
+
/**
|
22
|
+
* Returns the updated value as a number.
|
23
|
+
* @returns number
|
24
|
+
*/
|
33
25
|
valueNumber(): number;
|
34
26
|
toString(): string;
|
35
27
|
}
|
36
|
-
declare const Success_base: {
|
37
|
-
new (...args: any[]): {
|
38
|
-
readonly is_success: boolean;
|
39
|
-
};
|
40
|
-
} & typeof _Success;
|
41
|
-
/**
|
42
|
-
* Indicates a Successful increment request.
|
43
|
-
*/
|
44
|
-
export declare class Success extends Success_base {
|
45
|
-
}
|
46
|
-
declare class _Error extends Response {
|
47
|
-
protected _innerException: SdkError;
|
48
|
-
constructor(_innerException: SdkError);
|
49
|
-
}
|
50
|
-
declare const Error_base: {
|
51
|
-
new (...args: any[]): {
|
52
|
-
_innerException: SdkError;
|
53
|
-
message(): string;
|
54
|
-
innerException(): SdkError;
|
55
|
-
errorCode(): import("../../errors").MomentoErrorCode;
|
56
|
-
toString(): string;
|
57
|
-
};
|
58
|
-
} & typeof _Error;
|
59
28
|
/**
|
60
29
|
* Indicates that an error occurred during the increment request.
|
61
30
|
*
|
@@ -63,9 +32,13 @@ declare const Error_base: {
|
|
63
32
|
* how you would like to handle the error:
|
64
33
|
*
|
65
34
|
* - `errorCode()` - a unique Momento error code indicating the type of error that occurred.
|
66
|
-
* - `message()` - a human-readable description of the error
|
35
|
+
* - `message()` - a human-readable description of the error.
|
67
36
|
* - `innerException()` - the original error that caused the failure; can be re-thrown.
|
68
37
|
*/
|
69
|
-
export declare class Error extends
|
38
|
+
export declare class Error extends BaseResponseError implements IResponse {
|
39
|
+
constructor(_innerException: SdkError);
|
40
|
+
readonly type: CacheIncrementResponse.Error;
|
41
|
+
value(): undefined;
|
70
42
|
}
|
43
|
+
export type Response = Success | Error;
|
71
44
|
export {};
|
@@ -1,66 +1,37 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Error = exports.Success =
|
3
|
+
exports.Error = exports.Success = void 0;
|
4
4
|
const response_base_1 = require("./response-base");
|
5
|
+
const enums_1 = require("./enums");
|
5
6
|
/**
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* the following subtypes:
|
9
|
-
*
|
10
|
-
* - {Success}
|
11
|
-
* - {Error}
|
12
|
-
*
|
13
|
-
* `instanceof` type guards can be used to operate on the appropriate subtype.
|
14
|
-
* @example
|
15
|
-
* For example:
|
16
|
-
* ```
|
17
|
-
* if (response instanceof CacheIncrement.Error) {
|
18
|
-
* // Handle error as appropriate. The compiler will smart-cast `response` to type
|
19
|
-
* // `CacheIncrement.Error` in this block, so you will have access to the properties
|
20
|
-
* // of the Error class; e.g. `response.errorCode()`.
|
21
|
-
* }
|
22
|
-
* ```
|
7
|
+
* Indicates a successful cache increment request.
|
8
|
+
* Provides `value*` accessors to retrieve the updated value in the appropriate format.
|
23
9
|
*/
|
24
|
-
class
|
25
|
-
|
26
|
-
if (this instanceof Success) {
|
27
|
-
return this.value();
|
28
|
-
}
|
29
|
-
return undefined;
|
30
|
-
}
|
31
|
-
}
|
32
|
-
exports.Response = Response;
|
33
|
-
class _Success extends Response {
|
34
|
-
constructor(value) {
|
10
|
+
class Success extends response_base_1.BaseResponseSuccess {
|
11
|
+
constructor(body) {
|
35
12
|
super();
|
36
|
-
this.
|
13
|
+
this.type = enums_1.CacheIncrementResponse.Success;
|
14
|
+
this.body = body;
|
37
15
|
}
|
38
16
|
/**
|
39
|
-
*
|
40
|
-
* @returns
|
17
|
+
* Returns the updated value as a number.
|
18
|
+
* @returns number
|
41
19
|
*/
|
42
20
|
value() {
|
43
|
-
return this.
|
21
|
+
return this.body;
|
44
22
|
}
|
23
|
+
/**
|
24
|
+
* Returns the updated value as a number.
|
25
|
+
* @returns number
|
26
|
+
*/
|
45
27
|
valueNumber() {
|
46
|
-
return this.
|
28
|
+
return this.body;
|
47
29
|
}
|
48
30
|
toString() {
|
49
|
-
return `${super.toString()}: value: ${this.
|
31
|
+
return `${super.toString()}: value: ${this.value()}`;
|
50
32
|
}
|
51
33
|
}
|
52
|
-
/**
|
53
|
-
* Indicates a Successful increment request.
|
54
|
-
*/
|
55
|
-
class Success extends (0, response_base_1.ResponseSuccess)(_Success) {
|
56
|
-
}
|
57
34
|
exports.Success = Success;
|
58
|
-
class _Error extends Response {
|
59
|
-
constructor(_innerException) {
|
60
|
-
super();
|
61
|
-
this._innerException = _innerException;
|
62
|
-
}
|
63
|
-
}
|
64
35
|
/**
|
65
36
|
* Indicates that an error occurred during the increment request.
|
66
37
|
*
|
@@ -68,10 +39,17 @@ class _Error extends Response {
|
|
68
39
|
* how you would like to handle the error:
|
69
40
|
*
|
70
41
|
* - `errorCode()` - a unique Momento error code indicating the type of error that occurred.
|
71
|
-
* - `message()` - a human-readable description of the error
|
42
|
+
* - `message()` - a human-readable description of the error.
|
72
43
|
* - `innerException()` - the original error that caused the failure; can be re-thrown.
|
73
44
|
*/
|
74
|
-
class Error extends
|
45
|
+
class Error extends response_base_1.BaseResponseError {
|
46
|
+
constructor(_innerException) {
|
47
|
+
super(_innerException);
|
48
|
+
this.type = enums_1.CacheIncrementResponse.Error;
|
49
|
+
}
|
50
|
+
value() {
|
51
|
+
return undefined;
|
52
|
+
}
|
75
53
|
}
|
76
54
|
exports.Error = Error;
|
77
|
-
//# sourceMappingURL=data:application/json;base64,
|
55
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FjaGUtaW5jcmVtZW50LmpzIiwic291c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jogU2RrRXJyb3IpIHtcbiAgICBzdXBlcihfaW5uZXJFeGNlcHRpb24pO1xuICB9XG5cbiAgcmVhZG9ubHkgdHlwZTogQ2FjaGVJbmNyZW1lbnRSZXNwb25zZS5FcnJvciA9IENhY2hlSW5jcmVtZW50UmVzcG9uc2UuRXJyb3I7XG5cbiAgdmFsdWUoKTogdW5kZWZpbmVkIHtcbiAgICByZXR1cm4gdW5kZWZpbmVkO1xuICB9XG59XG5cbmV4cG9ydCB0eXBlIFJlc3BvbnNlID0gU3VjY2VzcyB8IEVycm9yO1xuIl19
|
@@ -1,71 +1,34 @@
|
|
1
1
|
import { SdkError } from '../../errors';
|
2
|
-
import { ResponseBase } from './response-base';
|
2
|
+
import { BaseResponseError, BaseResponseMiss, ResponseBase } from './response-base';
|
3
|
+
import { CacheItemGetTtlResponse } from './enums';
|
4
|
+
interface IResponse {
|
5
|
+
remainingTtlMillis(): number | undefined;
|
6
|
+
readonly type: CacheItemGetTtlResponse;
|
7
|
+
}
|
3
8
|
/**
|
4
|
-
*
|
5
|
-
* response object is resolved to a type-safe object of one of
|
6
|
-
* the following subtypes:
|
7
|
-
*
|
8
|
-
* - {Hit}
|
9
|
-
* - {Miss}
|
10
|
-
* - {Error}
|
11
|
-
*
|
12
|
-
* `instanceof` type guards can be used to operate on the appropriate subtype.
|
13
|
-
* @example
|
14
|
-
* For example:
|
15
|
-
* ```
|
16
|
-
* if (response instanceof ItemGetTtl.Error) {
|
17
|
-
* // Handle error as appropriate. The compiler will smart-cast `response` to type
|
18
|
-
* // `ItemGetTtl.Error` in this block, so you will have access to the properties
|
19
|
-
* // of the Error class; e.g. `response.errorCode()`.
|
20
|
-
* }
|
21
|
-
* ```
|
9
|
+
* Indicates a successful item get ttl request.
|
22
10
|
*/
|
23
|
-
export declare
|
24
|
-
|
25
|
-
declare class _Hit extends Response {
|
11
|
+
export declare class Hit extends ResponseBase implements IResponse {
|
12
|
+
readonly type: CacheItemGetTtlResponse.Hit;
|
26
13
|
private readonly ttlMillis;
|
27
14
|
constructor(itemTTLMillisRemaining: number);
|
28
15
|
/**
|
29
16
|
* Returns the remaining ttl in milliseconds for object stored at passed key.
|
30
|
-
* @returns
|
17
|
+
* @returns number
|
31
18
|
*/
|
32
19
|
remainingTtlMillis(): number;
|
20
|
+
toString(): string;
|
33
21
|
}
|
34
|
-
declare const Hit_base: {
|
35
|
-
new (...args: any[]): {};
|
36
|
-
} & typeof _Hit;
|
37
22
|
/**
|
38
|
-
* Indicates that the
|
23
|
+
* Indicates that the requested item was not available in the cache.
|
39
24
|
*/
|
40
|
-
export declare class
|
41
|
-
|
42
|
-
|
25
|
+
export declare class Miss extends BaseResponseMiss implements IResponse {
|
26
|
+
readonly type: CacheItemGetTtlResponse.Miss;
|
27
|
+
constructor();
|
28
|
+
remainingTtlMillis(): undefined;
|
43
29
|
}
|
44
|
-
declare const Miss_base: {
|
45
|
-
new (...args: any[]): {
|
46
|
-
readonly is_miss: boolean;
|
47
|
-
};
|
48
|
-
} & typeof _Miss;
|
49
30
|
/**
|
50
|
-
* Indicates that
|
51
|
-
*/
|
52
|
-
export declare class Miss extends Miss_base {
|
53
|
-
}
|
54
|
-
declare class _Error extends Response {
|
55
|
-
protected _innerException: SdkError;
|
56
|
-
constructor(_innerException: SdkError);
|
57
|
-
}
|
58
|
-
declare const Error_base: {
|
59
|
-
new (...args: any[]): {
|
60
|
-
_innerException: SdkError;
|
61
|
-
message(): string;
|
62
|
-
innerException(): SdkError;
|
63
|
-
errorCode(): import("../../errors").MomentoErrorCode;
|
64
|
-
toString(): string;
|
65
|
-
};
|
66
|
-
} & typeof _Error;
|
67
|
-
/**
|
68
|
-
* Indicates that an error occurred during the item ttl request.
|
31
|
+
* Indicates that an error occurred during the item get ttl request.
|
69
32
|
*
|
70
33
|
* This response object includes the following fields that you can use to determine
|
71
34
|
* how you would like to handle the error:
|
@@ -74,6 +37,10 @@ declare const Error_base: {
|
|
74
37
|
* - `message()` - a human-readable description of the error
|
75
38
|
* - `innerException()` - the original error that caused the failure; can be re-thrown.
|
76
39
|
*/
|
77
|
-
export declare class Error extends
|
40
|
+
export declare class Error extends BaseResponseError implements IResponse {
|
41
|
+
readonly type: CacheItemGetTtlResponse.Error;
|
42
|
+
constructor(_innerException: SdkError);
|
43
|
+
remainingTtlMillis(): undefined;
|
78
44
|
}
|
45
|
+
export type Response = Hit | Miss | Error;
|
79
46
|
export {};
|
@@ -1,65 +1,44 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Error = exports.Miss = exports.Hit =
|
3
|
+
exports.Error = exports.Miss = exports.Hit = void 0;
|
4
4
|
const response_base_1 = require("./response-base");
|
5
|
+
const enums_1 = require("./enums");
|
5
6
|
/**
|
6
|
-
*
|
7
|
-
* response object is resolved to a type-safe object of one of
|
8
|
-
* the following subtypes:
|
9
|
-
*
|
10
|
-
* - {Hit}
|
11
|
-
* - {Miss}
|
12
|
-
* - {Error}
|
13
|
-
*
|
14
|
-
* `instanceof` type guards can be used to operate on the appropriate subtype.
|
15
|
-
* @example
|
16
|
-
* For example:
|
17
|
-
* ```
|
18
|
-
* if (response instanceof ItemGetTtl.Error) {
|
19
|
-
* // Handle error as appropriate. The compiler will smart-cast `response` to type
|
20
|
-
* // `ItemGetTtl.Error` in this block, so you will have access to the properties
|
21
|
-
* // of the Error class; e.g. `response.errorCode()`.
|
22
|
-
* }
|
23
|
-
* ```
|
7
|
+
* Indicates a successful item get ttl request.
|
24
8
|
*/
|
25
|
-
class
|
26
|
-
}
|
27
|
-
exports.Response = Response;
|
28
|
-
class _Hit extends Response {
|
9
|
+
class Hit extends response_base_1.ResponseBase {
|
29
10
|
constructor(itemTTLMillisRemaining) {
|
30
11
|
super();
|
12
|
+
this.type = enums_1.CacheItemGetTtlResponse.Hit;
|
31
13
|
this.ttlMillis = itemTTLMillisRemaining;
|
32
14
|
}
|
33
15
|
/**
|
34
16
|
* Returns the remaining ttl in milliseconds for object stored at passed key.
|
35
|
-
* @returns
|
17
|
+
* @returns number
|
36
18
|
*/
|
37
19
|
remainingTtlMillis() {
|
38
20
|
return this.ttlMillis;
|
39
21
|
}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
*/
|
44
|
-
class Hit extends (0, response_base_1.ResponseHit)(_Hit) {
|
22
|
+
toString() {
|
23
|
+
return `${super.toString()}: remaining ttl: ${this.ttlMillis}`;
|
24
|
+
}
|
45
25
|
}
|
46
26
|
exports.Hit = Hit;
|
47
|
-
class _Miss extends Response {
|
48
|
-
}
|
49
27
|
/**
|
50
|
-
* Indicates that the requested
|
28
|
+
* Indicates that the requested item was not available in the cache.
|
51
29
|
*/
|
52
|
-
class Miss extends
|
53
|
-
|
54
|
-
exports.Miss = Miss;
|
55
|
-
class _Error extends Response {
|
56
|
-
constructor(_innerException) {
|
30
|
+
class Miss extends response_base_1.BaseResponseMiss {
|
31
|
+
constructor() {
|
57
32
|
super();
|
58
|
-
this.
|
33
|
+
this.type = enums_1.CacheItemGetTtlResponse.Miss;
|
34
|
+
}
|
35
|
+
remainingTtlMillis() {
|
36
|
+
return undefined;
|
59
37
|
}
|
60
38
|
}
|
39
|
+
exports.Miss = Miss;
|
61
40
|
/**
|
62
|
-
* Indicates that an error occurred during the item ttl request.
|
41
|
+
* Indicates that an error occurred during the item get ttl request.
|
63
42
|
*
|
64
43
|
* This response object includes the following fields that you can use to determine
|
65
44
|
* how you would like to handle the error:
|
@@ -68,7 +47,14 @@ class _Error extends Response {
|
|
68
47
|
* - `message()` - a human-readable description of the error
|
69
48
|
* - `innerException()` - the original error that caused the failure; can be re-thrown.
|
70
49
|
*/
|
71
|
-
class Error extends
|
50
|
+
class Error extends response_base_1.BaseResponseError {
|
51
|
+
constructor(_innerException) {
|
52
|
+
super(_innerException);
|
53
|
+
this.type = enums_1.CacheItemGetTtlResponse.Error;
|
54
|
+
}
|
55
|
+
remainingTtlMillis() {
|
56
|
+
return undefined;
|
57
|
+
}
|
72
58
|
}
|
73
59
|
exports.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