@blackglory/estore-js 0.1.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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +368 -0
  3. package/dist/es2015/index.min.mjs +16 -0
  4. package/dist/es2015/index.min.mjs.map +1 -0
  5. package/dist/es2015/index.mjs +5521 -0
  6. package/dist/es2015/index.mjs.map +1 -0
  7. package/dist/es2015/index.umd.js +5532 -0
  8. package/dist/es2015/index.umd.js.map +1 -0
  9. package/dist/es2015/index.umd.min.js +23 -0
  10. package/dist/es2015/index.umd.min.js.map +1 -0
  11. package/dist/es2018/index.min.mjs +2 -0
  12. package/dist/es2018/index.min.mjs.map +1 -0
  13. package/dist/es2018/index.mjs +5424 -0
  14. package/dist/es2018/index.mjs.map +1 -0
  15. package/dist/es2018/index.umd.js +5435 -0
  16. package/dist/es2018/index.umd.js.map +1 -0
  17. package/dist/es2018/index.umd.min.js +9 -0
  18. package/dist/es2018/index.umd.min.js.map +1 -0
  19. package/lib/es2015/blacklist-client.d.ts +6 -0
  20. package/lib/es2015/blacklist-client.js +41 -0
  21. package/lib/es2015/blacklist-client.js.map +1 -0
  22. package/lib/es2015/estore-client.d.ts +41 -0
  23. package/lib/es2015/estore-client.js +139 -0
  24. package/lib/es2015/estore-client.js.map +1 -0
  25. package/lib/es2015/estore-manager.d.ts +20 -0
  26. package/lib/es2015/estore-manager.js +20 -0
  27. package/lib/es2015/estore-manager.js.map +1 -0
  28. package/lib/es2015/index.d.ts +4 -0
  29. package/lib/es2015/index.js +20 -0
  30. package/lib/es2015/index.js.map +1 -0
  31. package/lib/es2015/json-schema-client.d.ts +8 -0
  32. package/lib/es2015/json-schema-client.js +49 -0
  33. package/lib/es2015/json-schema-client.js.map +1 -0
  34. package/lib/es2015/token-client.d.ts +18 -0
  35. package/lib/es2015/token-client.js +73 -0
  36. package/lib/es2015/token-client.js.map +1 -0
  37. package/lib/es2015/token-policy-client.d.ts +17 -0
  38. package/lib/es2015/token-policy-client.js +73 -0
  39. package/lib/es2015/token-policy-client.js.map +1 -0
  40. package/lib/es2015/utils.d.ts +12 -0
  41. package/lib/es2015/utils.js +25 -0
  42. package/lib/es2015/utils.js.map +1 -0
  43. package/lib/es2015/whitelist-client.d.ts +6 -0
  44. package/lib/es2015/whitelist-client.js +41 -0
  45. package/lib/es2015/whitelist-client.js.map +1 -0
  46. package/lib/es2018/blacklist-client.d.ts +6 -0
  47. package/lib/es2018/blacklist-client.js +26 -0
  48. package/lib/es2018/blacklist-client.js.map +1 -0
  49. package/lib/es2018/estore-client.d.ts +41 -0
  50. package/lib/es2018/estore-client.js +110 -0
  51. package/lib/es2018/estore-client.js.map +1 -0
  52. package/lib/es2018/estore-manager.d.ts +20 -0
  53. package/lib/es2018/estore-manager.js +20 -0
  54. package/lib/es2018/estore-manager.js.map +1 -0
  55. package/lib/es2018/index.d.ts +4 -0
  56. package/lib/es2018/index.js +20 -0
  57. package/lib/es2018/index.js.map +1 -0
  58. package/lib/es2018/json-schema-client.d.ts +8 -0
  59. package/lib/es2018/json-schema-client.js +32 -0
  60. package/lib/es2018/json-schema-client.js.map +1 -0
  61. package/lib/es2018/token-client.d.ts +18 -0
  62. package/lib/es2018/token-client.js +48 -0
  63. package/lib/es2018/token-client.js.map +1 -0
  64. package/lib/es2018/token-policy-client.d.ts +17 -0
  65. package/lib/es2018/token-policy-client.js +48 -0
  66. package/lib/es2018/token-policy-client.js.map +1 -0
  67. package/lib/es2018/utils.d.ts +12 -0
  68. package/lib/es2018/utils.js +25 -0
  69. package/lib/es2018/utils.js.map +1 -0
  70. package/lib/es2018/whitelist-client.d.ts +6 -0
  71. package/lib/es2018/whitelist-client.js +26 -0
  72. package/lib/es2018/whitelist-client.js.map +1 -0
  73. package/package.json +75 -0
@@ -0,0 +1,6 @@
1
+ import { IEStoreManagerRequestOptions, EStoreManagerBase } from './utils';
2
+ export declare class BlacklistClient extends EStoreManagerBase {
3
+ getNamespaces(options?: IEStoreManagerRequestOptions): Promise<string[]>;
4
+ add(namespace: string, options?: IEStoreManagerRequestOptions): Promise<void>;
5
+ remove(namespace: string, options?: IEStoreManagerRequestOptions): Promise<void>;
6
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BlacklistClient = void 0;
13
+ const extra_fetch_1 = require("extra-fetch");
14
+ const extra_request_1 = require("extra-request");
15
+ const index_js_1 = require("extra-request/transformers/index.js");
16
+ const extra_response_1 = require("extra-response");
17
+ const utils_1 = require("./utils");
18
+ class BlacklistClient extends utils_1.EStoreManagerBase {
19
+ getNamespaces(options = {}) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)('/admin/blacklist'));
22
+ return yield (0, extra_fetch_1.fetch)(req)
23
+ .then(extra_response_1.ok)
24
+ .then(extra_response_1.toJSON);
25
+ });
26
+ }
27
+ add(namespace, options = {}) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const req = (0, extra_request_1.put)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/blacklist/${namespace}`));
30
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
31
+ });
32
+ }
33
+ remove(namespace, options = {}) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const req = (0, extra_request_1.del)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/blacklist/${namespace}`));
36
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
37
+ });
38
+ }
39
+ }
40
+ exports.BlacklistClient = BlacklistClient;
41
+ //# sourceMappingURL=blacklist-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blacklist-client.js","sourceRoot":"","sources":["../../src/blacklist-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmC;AACnC,iDAA6C;AAC7C,kEAA8D;AAC9D,mDAA2C;AAC3C,mCAAyE;AAEzE,MAAa,eAAgB,SAAQ,yBAAiB;IAI9C,aAAa,CAAC,UAAwC,EAAE;;YAC5D,MAAM,GAAG,GAAG,IAAA,mBAAG,EACb,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACtC,IAAA,mBAAQ,EAAC,kBAAkB,CAAC,CAC7B,CAAA;YAED,OAAO,MAAM,IAAA,mBAAK,EAAC,GAAG,CAAC;iBACpB,IAAI,CAAC,mBAAE,CAAC;iBACR,IAAI,CAAC,uBAAM,CAAa,CAAA;QAC7B,CAAC;KAAA;IAKK,GAAG,CAAC,SAAiB,EAAE,UAAwC,EAAE;;YACrE,MAAM,GAAG,GAAG,IAAA,mBAAG,EACb,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACtC,IAAA,mBAAQ,EAAC,oBAAoB,SAAS,EAAE,CAAC,CAC1C,CAAA;YAED,MAAM,IAAA,mBAAK,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAE,CAAC,CAAA;QAC3B,CAAC;KAAA;IAKK,MAAM,CAAC,SAAiB,EAAE,UAAwC,EAAE;;YACxE,MAAM,GAAG,GAAG,IAAA,mBAAG,EACb,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACtC,IAAA,mBAAQ,EAAC,oBAAoB,SAAS,EAAE,CAAC,CAC1C,CAAA;YAED,MAAM,IAAA,mBAAK,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAE,CAAC,CAAA;QAC3B,CAAC;KAAA;CACF;AAtCD,0CAsCC"}
@@ -0,0 +1,41 @@
1
+ export { HTTPClientError } from '@blackglory/http-status';
2
+ interface IInfo {
3
+ namespace: string;
4
+ items: number;
5
+ }
6
+ export interface IEStoreClientOptions {
7
+ server: string;
8
+ token?: string;
9
+ basicAuth?: {
10
+ username: string;
11
+ password: string;
12
+ };
13
+ keepalive?: boolean;
14
+ timeout?: number;
15
+ }
16
+ export interface IEStoreClientRequestOptions {
17
+ signal?: AbortSignal;
18
+ token?: string;
19
+ keepalive?: boolean;
20
+ timeout?: number | false;
21
+ }
22
+ export interface IEStoreClientRequestOptionsWithoutToken {
23
+ signal?: AbortSignal;
24
+ keepalive?: boolean;
25
+ timeout?: number | false;
26
+ }
27
+ export declare class EStoreClient {
28
+ private options;
29
+ constructor(options: IEStoreClientOptions);
30
+ private getCommonTransformers;
31
+ append<T>(namespace: string, itemId: string, payload: T, index?: number, options?: IEStoreClientRequestOptions): Promise<void>;
32
+ getEvent<T>(namespace: string, itemId: string, index: number, options?: IEStoreClientRequestOptions): Promise<T | undefined>;
33
+ getEvents<T>(namespace: string, itemId: string, options?: IEStoreClientRequestOptions): Promise<T[] | undefined>;
34
+ getSize(namespace: string, itemId: string, options?: IEStoreClientRequestOptions): Promise<number>;
35
+ has(namespace: string, itemId: string, options?: IEStoreClientRequestOptions): Promise<boolean>;
36
+ del(namespace: string, itemId: string, options?: IEStoreClientRequestOptions): Promise<void>;
37
+ clear(namespace: string, options?: IEStoreClientRequestOptions): Promise<void>;
38
+ getAllItemIds(namespace: string, options?: IEStoreClientRequestOptions): Promise<string[]>;
39
+ getAllNamespaces(options?: IEStoreClientRequestOptionsWithoutToken): Promise<string[]>;
40
+ stats(namespace: string, options?: IEStoreClientRequestOptionsWithoutToken): Promise<IInfo>;
41
+ }
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EStoreClient = exports.HTTPClientError = void 0;
13
+ const extra_fetch_1 = require("extra-fetch");
14
+ const extra_request_1 = require("extra-request");
15
+ const index_js_1 = require("extra-request/transformers/index.js");
16
+ const http_status_1 = require("@blackglory/http-status");
17
+ const extra_response_1 = require("extra-response");
18
+ const extra_abort_1 = require("extra-abort");
19
+ const types_1 = require("@blackglory/types");
20
+ var http_status_2 = require("@blackglory/http-status");
21
+ Object.defineProperty(exports, "HTTPClientError", { enumerable: true, get: function () { return http_status_2.HTTPClientError; } });
22
+ class EStoreClient {
23
+ constructor(options) {
24
+ this.options = options;
25
+ }
26
+ getCommonTransformers(options) {
27
+ var _a, _b, _c;
28
+ const token = 'token' in options
29
+ ? ((_a = options.token) !== null && _a !== void 0 ? _a : this.options.token)
30
+ : this.options.token;
31
+ const auth = this.options.basicAuth;
32
+ return [
33
+ (0, index_js_1.url)(this.options.server),
34
+ auth && (0, index_js_1.basicAuth)(auth.username, auth.password),
35
+ token && (0, index_js_1.searchParams)({ token }),
36
+ (0, index_js_1.signal)((0, extra_abort_1.raceAbortSignals)([
37
+ options.signal,
38
+ options.timeout !== false && ((_b = (options.timeout && (0, extra_abort_1.timeoutSignal)(options.timeout))) !== null && _b !== void 0 ? _b : (this.options.timeout && (0, extra_abort_1.timeoutSignal)(this.options.timeout)))
39
+ ])),
40
+ (0, index_js_1.keepalive)((_c = options.keepalive) !== null && _c !== void 0 ? _c : this.options.keepalive)
41
+ ];
42
+ }
43
+ append(namespace, itemId, payload, index, options = {}) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const req = (0, extra_request_1.post)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/estore/${namespace}/items/${itemId}/events`), (0, types_1.isntUndefined)(index) && (0, index_js_1.header)('If-Match', `${index}`), (0, index_js_1.json)(payload));
46
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
47
+ });
48
+ }
49
+ getEvent(namespace, itemId, index, options = {}) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/estore/${namespace}/items/${itemId}/events/${index}`));
52
+ try {
53
+ return yield (0, extra_fetch_1.fetch)(req)
54
+ .then(extra_response_1.ok)
55
+ .then(extra_response_1.toJSON);
56
+ }
57
+ catch (e) {
58
+ if (e instanceof http_status_1.NotFound)
59
+ return undefined;
60
+ throw e;
61
+ }
62
+ });
63
+ }
64
+ getEvents(namespace, itemId, options = {}) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/estore/${namespace}/items/${itemId}/events`));
67
+ try {
68
+ return yield (0, extra_fetch_1.fetch)(req)
69
+ .then(extra_response_1.ok)
70
+ .then(extra_response_1.toJSON);
71
+ }
72
+ catch (e) {
73
+ if (e instanceof http_status_1.NotFound)
74
+ return undefined;
75
+ throw e;
76
+ }
77
+ });
78
+ }
79
+ getSize(namespace, itemId, options = {}) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/estore/${namespace}/items/${itemId}/size`));
82
+ return yield (0, extra_fetch_1.fetch)(req)
83
+ .then(extra_response_1.ok)
84
+ .then(extra_response_1.toJSON);
85
+ });
86
+ }
87
+ has(namespace, itemId, options = {}) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ const req = (0, extra_request_1.head)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/estore/${namespace}/items/${itemId}`));
90
+ try {
91
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
92
+ return true;
93
+ }
94
+ catch (e) {
95
+ if (e instanceof http_status_1.NotFound)
96
+ return false;
97
+ throw e;
98
+ }
99
+ });
100
+ }
101
+ del(namespace, itemId, options = {}) {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ const req = (0, extra_request_1.del)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/estore/${namespace}/items/${itemId}`));
104
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
105
+ });
106
+ }
107
+ clear(namespace, options = {}) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ const req = (0, extra_request_1.del)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/estore/${namespace}`));
110
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
111
+ });
112
+ }
113
+ getAllItemIds(namespace, options = {}) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/estore/${namespace}/items`));
116
+ return yield (0, extra_fetch_1.fetch)(req)
117
+ .then(extra_response_1.ok)
118
+ .then(extra_response_1.toJSON);
119
+ });
120
+ }
121
+ getAllNamespaces(options = {}) {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)('/estore'));
124
+ return yield (0, extra_fetch_1.fetch)(req)
125
+ .then(extra_response_1.ok)
126
+ .then(extra_response_1.toJSON);
127
+ });
128
+ }
129
+ stats(namespace, options = {}) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/estore/${namespace}/stats`));
132
+ return yield (0, extra_fetch_1.fetch)(req)
133
+ .then(extra_response_1.ok)
134
+ .then(extra_response_1.toJSON);
135
+ });
136
+ }
137
+ }
138
+ exports.EStoreClient = EStoreClient;
139
+ //# sourceMappingURL=estore-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estore-client.js","sourceRoot":"","sources":["../../src/estore-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmC;AACnC,iDAA6E;AAC7E,kEAA6H;AAC7H,yDAAkD;AAClD,mDAA2C;AAE3C,6CAA6D;AAC7D,6CAAiD;AAEjD,uDAAyD;AAAhD,8GAAA,eAAe,OAAA;AA+BxB,MAAa,YAAY;IACvB,YAAoB,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;IAAG,CAAC;IAE7C,qBAAqB,CAC3B,OAA8E;;QAE9E,MAAM,KAAK,GAAG,OAAO,IAAI,OAAO;YAClB,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,KAAK,mCAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YACvC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAA;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAA;QAEnC,OAAO;YACL,IAAA,cAAG,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YACxB,IAAI,IAAI,IAAA,oBAAS,EAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC;YAC/C,KAAK,IAAI,IAAA,uBAAY,EAAC,EAAE,KAAK,EAAE,CAAC;YAChC,IAAA,iBAAM,EAAC,IAAA,8BAAgB,EAAC;gBACtB,OAAO,CAAC,MAAM;gBACd,OAAO,CAAC,OAAO,KAAK,KAAK,IAAI,CAC3B,MAAA,CAAC,OAAO,CAAC,OAAO,IAAI,IAAA,2BAAa,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC,mCACnD,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,IAAA,2BA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BAAM,CAAa,CAAA;QAC7B,CAAC;KAAA;IAKK,KAAK,CACT,SAAiB,EACjB,UAAmD,EAAE;;YAErD,MAAM,GAAG,GAAG,IAAA,mBAAG,EACb,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACtC,IAAA,mBAAQ,EAAC,WAAW,SAAS,QAAQ,CAAC,CACvC,CAAA;YAED,OAAO,MAAM,IAAA,mBAAK,EAAC,GAAG,CAAC;iBACpB,IAAI,CAAC,mBAAE,CAAC;iBACR,IAAI,CAAC,uBAAM,CAAU,CAAA;QAC1B,CAAC;KAAA;CACF;AArND,oCAqNC"}
@@ -0,0 +1,20 @@
1
+ import { JsonSchemaClient } from './json-schema-client';
2
+ import { BlacklistClient } from './blacklist-client';
3
+ import { WhitelistClient } from './whitelist-client';
4
+ import { TokenPolicyClient } from './token-policy-client';
5
+ import { TokenClient } from './token-client';
6
+ export interface IEStoreManagerOptions {
7
+ server: string;
8
+ adminPassword: string;
9
+ keepalive?: boolean;
10
+ timeout?: number;
11
+ }
12
+ export declare class EStoreManager {
13
+ private options;
14
+ constructor(options: IEStoreManagerOptions);
15
+ JsonSchema: JsonSchemaClient;
16
+ Blacklist: BlacklistClient;
17
+ Whitelist: WhitelistClient;
18
+ TokenPolicy: TokenPolicyClient;
19
+ Token: TokenClient;
20
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EStoreManager = void 0;
4
+ const json_schema_client_1 = require("./json-schema-client");
5
+ const blacklist_client_1 = require("./blacklist-client");
6
+ const whitelist_client_1 = require("./whitelist-client");
7
+ const token_policy_client_1 = require("./token-policy-client");
8
+ const token_client_1 = require("./token-client");
9
+ class EStoreManager {
10
+ constructor(options) {
11
+ this.options = options;
12
+ this.JsonSchema = new json_schema_client_1.JsonSchemaClient(this.options);
13
+ this.Blacklist = new blacklist_client_1.BlacklistClient(this.options);
14
+ this.Whitelist = new whitelist_client_1.WhitelistClient(this.options);
15
+ this.TokenPolicy = new token_policy_client_1.TokenPolicyClient(this.options);
16
+ this.Token = new token_client_1.TokenClient(this.options);
17
+ }
18
+ }
19
+ exports.EStoreManager = EStoreManager;
20
+ //# sourceMappingURL=estore-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estore-manager.js","sourceRoot":"","sources":["../../src/estore-manager.ts"],"names":[],"mappings":";;;AAAA,6DAAuD;AACvD,yDAAoD;AACpD,yDAAoD;AACpD,+DAAyD;AACzD,iDAA4C;AAS5C,MAAa,aAAa;IACxB,YAAoB,OAA8B;QAA9B,YAAO,GAAP,OAAO,CAAuB;QAElD,eAAU,GAAG,IAAI,qCAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC/C,cAAS,GAAG,IAAI,kCAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC7C,cAAS,GAAG,IAAI,kCAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC7C,gBAAW,GAAG,IAAI,uCAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACjD,UAAK,GAAG,IAAI,0BAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IANgB,CAAC;CAOvD;AARD,sCAQC"}
@@ -0,0 +1,4 @@
1
+ export * from './estore-client';
2
+ export * from './estore-manager';
3
+ export { HTTPError } from 'extra-response';
4
+ export { AbortError } from 'extra-fetch';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.AbortError = exports.HTTPError = void 0;
14
+ __exportStar(require("./estore-client"), exports);
15
+ __exportStar(require("./estore-manager"), exports);
16
+ var extra_response_1 = require("extra-response");
17
+ Object.defineProperty(exports, "HTTPError", { enumerable: true, get: function () { return extra_response_1.HTTPError; } });
18
+ var extra_fetch_1 = require("extra-fetch");
19
+ Object.defineProperty(exports, "AbortError", { enumerable: true, get: function () { return extra_fetch_1.AbortError; } });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,iDAA0C;AAAjC,2GAAA,SAAS,OAAA;AAClB,2CAAwC;AAA/B,yGAAA,UAAU,OAAA"}
@@ -0,0 +1,8 @@
1
+ import { Json } from 'justypes';
2
+ import { IEStoreManagerRequestOptions, EStoreManagerBase } from './utils';
3
+ export declare class JsonSchemaClient extends EStoreManagerBase {
4
+ getNamespaces(options?: IEStoreManagerRequestOptions): Promise<string[]>;
5
+ get(namespace: string, options?: IEStoreManagerRequestOptions): Promise<unknown>;
6
+ set(namespace: string, schema: Json, options?: IEStoreManagerRequestOptions): Promise<void>;
7
+ remove(namespace: string, options?: IEStoreManagerRequestOptions): Promise<void>;
8
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.JsonSchemaClient = void 0;
13
+ const extra_fetch_1 = require("extra-fetch");
14
+ const extra_request_1 = require("extra-request");
15
+ const index_js_1 = require("extra-request/transformers/index.js");
16
+ const extra_response_1 = require("extra-response");
17
+ const utils_1 = require("./utils");
18
+ class JsonSchemaClient extends utils_1.EStoreManagerBase {
19
+ getNamespaces(options = {}) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)('/admin/estore-with-json-schema'));
22
+ return yield (0, extra_fetch_1.fetch)(req)
23
+ .then(extra_response_1.ok)
24
+ .then(extra_response_1.toJSON);
25
+ });
26
+ }
27
+ get(namespace, options = {}) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/json-schema`));
30
+ return yield (0, extra_fetch_1.fetch)(req)
31
+ .then(extra_response_1.ok)
32
+ .then(extra_response_1.toJSON);
33
+ });
34
+ }
35
+ set(namespace, schema, options = {}) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const req = (0, extra_request_1.put)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/json-schema`), (0, index_js_1.json)(schema));
38
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
39
+ });
40
+ }
41
+ remove(namespace, options = {}) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const req = (0, extra_request_1.del)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/json-schema`));
44
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
45
+ });
46
+ }
47
+ }
48
+ exports.JsonSchemaClient = JsonSchemaClient;
49
+ //# sourceMappingURL=json-schema-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-schema-client.js","sourceRoot":"","sources":["../../src/json-schema-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AI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACtC,IAAA,mBAAQ,EAAC,iBAAiB,SAAS,cAAc,CAAC,CACnD,CAAA;YAED,MAAM,IAAA,mBAAK,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAE,CAAC,CAAA;QAC3B,CAAC;KAAA;CACF;AA5DD,4CA4DC"}
@@ -0,0 +1,18 @@
1
+ import { IEStoreManagerRequestOptions, EStoreManagerBase } from './utils';
2
+ interface ITokenInfo {
3
+ token: string;
4
+ write: boolean;
5
+ read: boolean;
6
+ delete: boolean;
7
+ }
8
+ export declare class TokenClient extends EStoreManagerBase {
9
+ getNamespaces(options?: IEStoreManagerRequestOptions): Promise<string[]>;
10
+ getTokens(namespace: string, options?: IEStoreManagerRequestOptions): Promise<ITokenInfo[]>;
11
+ addWriteToken(namespace: string, token: string, options?: IEStoreManagerRequestOptions): Promise<void>;
12
+ removeWriteToken(namespace: string, token: string, options?: IEStoreManagerRequestOptions): Promise<void>;
13
+ addReadToken(namespace: string, token: string, options?: IEStoreManagerRequestOptions): Promise<void>;
14
+ removeReadToken(namespace: string, token: string, options?: IEStoreManagerRequestOptions): Promise<void>;
15
+ addDeleteToken(namespace: string, token: string, options?: IEStoreManagerRequestOptions): Promise<void>;
16
+ removeDeleteToken(namespace: string, token: string, options?: IEStoreManagerRequestOptions): Promise<void>;
17
+ }
18
+ export {};
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TokenClient = void 0;
13
+ const extra_fetch_1 = require("extra-fetch");
14
+ const extra_request_1 = require("extra-request");
15
+ const index_js_1 = require("extra-request/transformers/index.js");
16
+ const extra_response_1 = require("extra-response");
17
+ const utils_1 = require("./utils");
18
+ class TokenClient extends utils_1.EStoreManagerBase {
19
+ getNamespaces(options = {}) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)('/admin/estore-with-tokens'));
22
+ return yield (0, extra_fetch_1.fetch)(req)
23
+ .then(extra_response_1.ok)
24
+ .then(extra_response_1.toJSON);
25
+ });
26
+ }
27
+ getTokens(namespace, options = {}) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/tokens`));
30
+ return yield (0, extra_fetch_1.fetch)(req)
31
+ .then(extra_response_1.ok)
32
+ .then(extra_response_1.toJSON);
33
+ });
34
+ }
35
+ addWriteToken(namespace, token, options = {}) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const req = (0, extra_request_1.put)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/tokens/${token}/write`));
38
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
39
+ });
40
+ }
41
+ removeWriteToken(namespace, token, options = {}) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const req = (0, extra_request_1.del)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/tokens/${token}/write`));
44
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
45
+ });
46
+ }
47
+ addReadToken(namespace, token, options = {}) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const req = (0, extra_request_1.put)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/tokens/${token}/read`));
50
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
51
+ });
52
+ }
53
+ removeReadToken(namespace, token, options = {}) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const req = (0, extra_request_1.del)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/tokens/${token}/read`));
56
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
57
+ });
58
+ }
59
+ addDeleteToken(namespace, token, options = {}) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const req = (0, extra_request_1.put)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/tokens/${token}/delete`));
62
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
63
+ });
64
+ }
65
+ removeDeleteToken(namespace, token, options = {}) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ const req = (0, extra_request_1.del)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/tokens/${token}/delete`));
68
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
69
+ });
70
+ }
71
+ }
72
+ exports.TokenClient = TokenClient;
73
+ //# sourceMappingURL=token-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-client.js","sourceRoot":"","sources":["../../src/token-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmC;AACnC,iDAA6C;AAC7C,kEAA8D;AAC9D,mDAA2C;AAC3C,mCAAyE;AASzE,MAAa,WAAY,SAAQ,yBAAiB;IAI1C,aAAa,CAAC,UAAwC,EAAE;;YAC5D,MAAM,GAAG,GAAG,IAAA,mBAAG,EACb,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACtC,IAAA,mBAAQ,EAAC,2BAA2B,CAAC,CACtC,CAAA;YAED,OAAO,MAAM,IAAA,mBAAK,EAAC,GAAG,CAAC;iBACpB,IAAI,CAAC,mBAAE,CAAC;iBAC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equired: boolean | null;
5
+ deleteTokenRequired: boolean | null;
6
+ }
7
+ export declare class TokenPolicyClient extends EStoreManagerBase {
8
+ getNamespaces(options?: IEStoreManagerRequestOptions): Promise<string[]>;
9
+ get(namespace: string, options?: IEStoreManagerRequestOptions): Promise<ITokenPolicy>;
10
+ setWriteTokenRequired(namespace: string, val: boolean, options?: IEStoreManagerRequestOptions): Promise<void>;
11
+ removeWriteTokenRequired(namespace: string, options?: IEStoreManagerRequestOptions): Promise<void>;
12
+ setReadTokenRequired(namespace: string, val: boolean, options?: IEStoreManagerRequestOptions): Promise<void>;
13
+ removeReadTokenRequired(namespace: string, options?: IEStoreManagerRequestOptions): Promise<void>;
14
+ setDeleteTokenRequired(namespace: string, val: boolean, options?: IEStoreManagerRequestOptions): Promise<void>;
15
+ removeDeleteTokenRequired(namespace: string, options?: IEStoreManagerRequestOptions): Promise<void>;
16
+ }
17
+ export {};
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TokenPolicyClient = void 0;
13
+ const extra_fetch_1 = require("extra-fetch");
14
+ const extra_request_1 = require("extra-request");
15
+ const index_js_1 = require("extra-request/transformers/index.js");
16
+ const extra_response_1 = require("extra-response");
17
+ const utils_1 = require("./utils");
18
+ class TokenPolicyClient extends utils_1.EStoreManagerBase {
19
+ getNamespaces(options = {}) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)('/admin/estore-with-token-policies'));
22
+ return yield (0, extra_fetch_1.fetch)(req)
23
+ .then(extra_response_1.ok)
24
+ .then(extra_response_1.toJSON);
25
+ });
26
+ }
27
+ get(namespace, options = {}) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const req = (0, extra_request_1.get)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/token-policies`));
30
+ return yield (0, extra_fetch_1.fetch)(req)
31
+ .then(extra_response_1.ok)
32
+ .then(extra_response_1.toJSON);
33
+ });
34
+ }
35
+ setWriteTokenRequired(namespace, val, options = {}) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const req = (0, extra_request_1.put)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/token-policies/write-token-required`), (0, index_js_1.json)(val));
38
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
39
+ });
40
+ }
41
+ removeWriteTokenRequired(namespace, options = {}) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const req = (0, extra_request_1.del)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/token-policies/write-token-required`));
44
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
45
+ });
46
+ }
47
+ setReadTokenRequired(namespace, val, options = {}) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const req = (0, extra_request_1.put)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/token-policies/read-token-required`), (0, index_js_1.json)(val));
50
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
51
+ });
52
+ }
53
+ removeReadTokenRequired(namespace, options = {}) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const req = (0, extra_request_1.del)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/token-policies/read-token-required`));
56
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
57
+ });
58
+ }
59
+ setDeleteTokenRequired(namespace, val, options = {}) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const req = (0, extra_request_1.put)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/token-policies/delete-token-required`), (0, index_js_1.json)(val));
62
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
63
+ });
64
+ }
65
+ removeDeleteTokenRequired(namespace, options = {}) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ const req = (0, extra_request_1.del)(...this.getCommonTransformers(options), (0, index_js_1.pathname)(`/admin/estore/${namespace}/token-policies/delete-token-required`));
68
+ yield (0, extra_fetch_1.fetch)(req).then(extra_response_1.ok);
69
+ });
70
+ }
71
+ }
72
+ exports.TokenPolicyClient = TokenPolicyClient;
73
+ //# sourceMappingURL=token-policy-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-policy-client.js","sourceRoot":"","sources":["../../src/token-policy-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmC;AACnC,iDAA6C;AAC7C,kEAAoE;AACpE,mDAA2C;AAC3C,mCAAyE;AAQzE,MAAa,iBAAkB,SAAQ,yBAAiB;IAIhD,aAAa,CAAC,UAAwC,EAAE;;YAC5D,MAAM,GAAG,GAAG,IAAA,mBAAG,EACb,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACtC,IAAA,mBAAQ,EAAC,mCAAmC,CAAC,CAC9C,CAAA;YAED,OAAO,MAAM,IAAA,mBAAK,EAAC,GAAG,CAAC;iBACpB,IAAI,CAAC,mBAAE,CAAC;iBACR,IAAI,CAAC,uBAAM,CAAa,CAAA;QAC7B,CAAC;KAAA;IAKK,GAAG,CAAC,SAAiB,EAAE,UAAwC,EAAE;;YACrE,MAAM,GAAG,GAAG,IAAA,mBAAG,EACb,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,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AiB,EACjB,UAAwC,EAAE;;YAE1C,MAAM,GAAG,GAAG,IAAA,mBAAG,EACb,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACtC,IAAA,mBAAQ,EAAC,iBAAiB,SAAS,qCAAqC,CAAC,CAC1E,CAAA;YAED,MAAM,IAAA,mBAAK,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAE,CAAC,CAAA;QAC3B,CAAC;KAAA;IAKK,sBAAsB,CAC1B,SAAiB,EACjB,GAAY,EACZ,UAAwC,EAAE;;YAE1C,MAAM,GAAG,GAAG,IAAA,mBAAG,EACb,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACtC,IAAA,mBAAQ,EAAC,iBAAiB,SAAS,uCAAuC,CAAC,EAC3E,IAAA,eAAI,EAAC,GAAG,CAAC,CACV,CAAA;YAED,MAAM,IAAA,mBAAK,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAE,CAAC,CAAA;QAC3B,CAAC;KAAA;IAKK,yBAAyB,CAC7B,SAAiB,EACjB,UAAwC,EAAE;;YAE1C,MAAM,GAAG,GAAG,IAAA,mBAAG,EACb,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACtC,IAAA,mBAAQ,EAAC,iBAAiB,SAAS,uCAAuC,CAAC,CAC5E,CAAA;YAED,MAAM,IAAA,mBAAK,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAE,CAAC,CAAA;QAC3B,CAAC;KAAA;CACF;AA5HD,8CA4HC"}
@@ -0,0 +1,12 @@
1
+ import { IHTTPOptionsTransformer } from 'extra-request';
2
+ import type { IEStoreManagerOptions } from './estore-manager';
3
+ export interface IEStoreManagerRequestOptions {
4
+ signal?: AbortSignal;
5
+ keepalive?: boolean;
6
+ timeout?: number | false;
7
+ }
8
+ export declare class EStoreManagerBase {
9
+ private options;
10
+ constructor(options: IEStoreManagerOptions);
11
+ protected getCommonTransformers(options: IEStoreManagerRequestOptions): IHTTPOptionsTransformer[];
12
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EStoreManagerBase = void 0;
4
+ const index_js_1 = require("extra-request/transformers/index.js");
5
+ const extra_abort_1 = require("extra-abort");
6
+ class EStoreManagerBase {
7
+ constructor(options) {
8
+ this.options = options;
9
+ }
10
+ getCommonTransformers(options) {
11
+ var _a, _b;
12
+ return [
13
+ (0, index_js_1.url)(this.options.server),
14
+ (0, index_js_1.bearerAuth)(this.options.adminPassword),
15
+ (0, index_js_1.signal)((0, extra_abort_1.raceAbortSignals)([
16
+ options.signal,
17
+ options.timeout !== false && ((_a = (options.timeout && (0, extra_abort_1.timeoutSignal)(options.timeout))) !== null && _a !== void 0 ? _a : (this.options.timeout && (0, extra_abort_1.timeoutSignal)(this.options.timeout)))
18
+ ])),
19
+ (0, index_js_1.keepalive)((_b = options.keepalive) !== null && _b !== void 0 ? _b : this.options.keepalive),
20
+ (0, index_js_1.header)('Accept-Version', '0.1.0')
21
+ ];
22
+ }
23
+ }
24
+ exports.EStoreManagerBase = EStoreManagerBase;
25
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AACA,kEAAgG;AAChG,6CAA6D;AAS7D,MAAa,iBAAiB;IAC5B,YAAoB,OAA8B;QAA9B,YAAO,GAAP,OAAO,CAAuB;IAAG,CAAC;IAE5C,qBAAqB,CAC7B,OAAqC;;QAErC,OAAO;YACL,IAAA,cAAG,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YACxB,IAAA,qBAAU,EAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;YACtC,IAAA,iBAAM,EAAC,IAAA,8BAAgB,EAAC;gBACtB,OAAO,CAAC,MAAM;gBACd,OAAO,CAAC,OAAO,KAAK,KAAK,IAAI,CAC3B,MAAA,CAAC,OAAO,CAAC,OAAO,IAAI,IAAA,2BAAa,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC,mCACnD,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,IAAA,2BAAa,EAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAC9D;aACF,CAAC,CAAC;YACH,IAAA,oBAAS,EAAC,MAAA,OAAO,CAAC,SAAS,mCAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;YACtD,IAAA,iBAAM,EAAC,gBAAgB,EAAE,OAAO,CAAC;SAClC,CAAA;IACH,CAAC;CACF;AApBD,8CAoBC"}