@quantcdn/quant-client 2.0.12 → 3.0.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 (108) hide show
  1. package/README.md +49 -72
  2. package/dist/api/apis.d.ts +30 -0
  3. package/dist/api/apis.js +48 -0
  4. package/dist/api/applicationsApi.d.ts +104 -0
  5. package/dist/api/applicationsApi.js +431 -0
  6. package/dist/api/commandsApi.d.ts +80 -0
  7. package/dist/api/commandsApi.js +316 -0
  8. package/dist/api/composeApi.d.ts +66 -0
  9. package/dist/api/composeApi.js +236 -0
  10. package/dist/api/containersApi.d.ts +67 -0
  11. package/dist/api/containersApi.js +236 -0
  12. package/dist/api/cronApi.d.ts +151 -0
  13. package/dist/api/cronApi.js +681 -0
  14. package/dist/api/environmentsApi.d.ts +194 -0
  15. package/dist/api/environmentsApi.js +861 -0
  16. package/dist/api/sSHAccessApi.d.ts +50 -0
  17. package/dist/api/sSHAccessApi.js +162 -0
  18. package/dist/api/scalingPolicyApi.d.ts +82 -0
  19. package/dist/api/scalingPolicyApi.js +307 -0
  20. package/dist/api/variablesApi.d.ts +83 -0
  21. package/dist/api/variablesApi.js +313 -0
  22. package/dist/api/volumesApi.d.ts +97 -0
  23. package/dist/api/volumesApi.js +405 -0
  24. package/dist/api.d.ts +2 -0
  25. package/dist/api.js +19 -0
  26. package/dist/model/application.d.ts +38 -0
  27. package/dist/model/application.js +93 -0
  28. package/dist/model/command.d.ts +34 -0
  29. package/dist/model/command.js +73 -0
  30. package/dist/model/compose.d.ts +32 -0
  31. package/dist/model/compose.js +58 -0
  32. package/dist/model/configuration.d.ts +26 -0
  33. package/dist/model/configuration.js +30 -0
  34. package/dist/model/container.d.ts +38 -0
  35. package/dist/model/container.js +78 -0
  36. package/dist/model/containerEnvironmentInner.d.ts +26 -0
  37. package/dist/model/containerEnvironmentInner.js +33 -0
  38. package/dist/model/containerImageReference.d.ts +28 -0
  39. package/dist/model/containerImageReference.js +43 -0
  40. package/dist/model/containerMountPointsInner.d.ts +27 -0
  41. package/dist/model/containerMountPointsInner.js +38 -0
  42. package/dist/model/createApplicationRequest.d.ts +28 -0
  43. package/dist/model/createApplicationRequest.js +43 -0
  44. package/dist/model/createCommandRequest.d.ts +25 -0
  45. package/dist/model/createCommandRequest.js +28 -0
  46. package/dist/model/createCronJob422Response.d.ts +26 -0
  47. package/dist/model/createCronJob422Response.js +33 -0
  48. package/dist/model/createCronJobRequest.d.ts +30 -0
  49. package/dist/model/createCronJobRequest.js +56 -0
  50. package/dist/model/createEnvironmentRequest.d.ts +34 -0
  51. package/dist/model/createEnvironmentRequest.js +53 -0
  52. package/dist/model/cron.d.ts +27 -0
  53. package/dist/model/cron.js +38 -0
  54. package/dist/model/cronRun.d.ts +48 -0
  55. package/dist/model/cronRun.js +89 -0
  56. package/dist/model/environment.d.ts +45 -0
  57. package/dist/model/environment.js +103 -0
  58. package/dist/model/getEcrLoginCredentials200Response.d.ts +28 -0
  59. package/dist/model/getEcrLoginCredentials200Response.js +43 -0
  60. package/dist/model/getScalingPolicies200Response.d.ts +26 -0
  61. package/dist/model/getScalingPolicies200Response.js +28 -0
  62. package/dist/model/getSshAccessCredentials200Response.d.ts +34 -0
  63. package/dist/model/getSshAccessCredentials200Response.js +68 -0
  64. package/dist/model/getSshAccessCredentials200ResponseCredentials.d.ts +28 -0
  65. package/dist/model/getSshAccessCredentials200ResponseCredentials.js +43 -0
  66. package/dist/model/models.d.ts +78 -0
  67. package/dist/model/models.js +352 -0
  68. package/dist/model/scalingPolicy.d.ts +35 -0
  69. package/dist/model/scalingPolicy.js +51 -0
  70. package/dist/model/syncOperation.d.ts +31 -0
  71. package/dist/model/syncOperation.js +58 -0
  72. package/dist/model/syncToEnvironmentRequest.d.ts +25 -0
  73. package/dist/model/syncToEnvironmentRequest.js +28 -0
  74. package/dist/model/updateComposeRequest.d.ts +26 -0
  75. package/dist/model/updateComposeRequest.js +28 -0
  76. package/dist/model/updateCronJobRequest.d.ts +29 -0
  77. package/dist/model/updateCronJobRequest.js +48 -0
  78. package/dist/model/updateEnvironmentComposeRequest.d.ts +26 -0
  79. package/dist/model/updateEnvironmentComposeRequest.js +28 -0
  80. package/dist/model/updateEnvironmentRequest.d.ts +26 -0
  81. package/dist/model/updateEnvironmentRequest.js +28 -0
  82. package/dist/model/updateEnvironmentStateRequest.d.ts +26 -0
  83. package/dist/model/updateEnvironmentStateRequest.js +33 -0
  84. package/dist/model/updateEnvironmentVariableRequest.d.ts +25 -0
  85. package/dist/model/updateEnvironmentVariableRequest.js +28 -0
  86. package/dist/model/validateCompose200Response.d.ts +27 -0
  87. package/dist/model/validateCompose200Response.js +38 -0
  88. package/dist/model/validateComposeRequest.d.ts +25 -0
  89. package/dist/model/validateComposeRequest.js +28 -0
  90. package/dist/model/variable.d.ts +26 -0
  91. package/dist/model/variable.js +33 -0
  92. package/dist/model/volume.d.ts +32 -0
  93. package/dist/model/volume.js +63 -0
  94. package/package.json +21 -40
  95. package/dist/src/client.d.ts +0 -15
  96. package/dist/src/client.js +0 -380
  97. package/dist/src/index.d.ts +0 -2
  98. package/dist/src/index.js +0 -42
  99. package/dist/src/interfaces.d.ts +0 -34
  100. package/dist/src/interfaces.js +0 -2
  101. package/dist/src/response.d.ts +0 -15
  102. package/dist/src/response.js +0 -103
  103. package/dist/src/types.d.ts +0 -68
  104. package/dist/src/types.js +0 -8
  105. package/dist/tests/client.test.d.ts +0 -1
  106. package/dist/tests/client.test.js +0 -191
  107. package/dist/tests/response.test.d.ts +0 -1
  108. package/dist/tests/response.test.js +0 -133
@@ -1,15 +0,0 @@
1
- import { type Client } from './interfaces';
2
- import type * as request from '@cypress/request';
3
- export declare class PaginatedResponse implements AsyncIterator<any> {
4
- private readonly client;
5
- private readonly request;
6
- private readonly per_page;
7
- private page;
8
- private total;
9
- private hasNext;
10
- constructor(client: Client, options: request.Options);
11
- first(): Promise<any>;
12
- do(): Promise<any>;
13
- next(): Promise<IteratorResult<any>>;
14
- [Symbol.asyncIterator](): AsyncIterator<any>;
15
- }
@@ -1,103 +0,0 @@
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
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
12
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
13
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
14
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
15
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
16
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
17
- function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
18
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
19
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
20
- function fulfill(value) { resume("next", value); }
21
- function reject(value) { resume("throw", value); }
22
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.PaginatedResponse = void 0;
26
- class PaginatedResponse {
27
- constructor(client, options) {
28
- var _a, _b;
29
- this.page = 0;
30
- this.total = 0;
31
- this.hasNext = true;
32
- this.client = client;
33
- this.request = options;
34
- // Use page_size from query parameters or default to 10
35
- this.per_page = (_b = (_a = this.request.qs) === null || _a === void 0 ? void 0 : _a.page_size) !== null && _b !== void 0 ? _b : 10;
36
- this.page = 1;
37
- if (typeof this.request.qs !== 'object') {
38
- this.request.qs = {};
39
- }
40
- }
41
- first() {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- let body = { data: {} };
44
- try {
45
- body = yield this.client.do(this.request);
46
- }
47
- catch (err) {
48
- return yield new Promise((resolve, reject) => { reject(err); });
49
- }
50
- return yield new Promise(resolve => { resolve(body); });
51
- });
52
- }
53
- do() {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- return yield this.first();
56
- });
57
- }
58
- next() {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- let body = { data: {} };
61
- if (this.page > this.total && this.total !== 0) {
62
- this.hasNext = false;
63
- return body;
64
- }
65
- this.request.qs.page = this.page;
66
- this.request.qs.per_page = this.per_page;
67
- try {
68
- body = yield this.client.do(this.request);
69
- }
70
- catch (err) {
71
- this.hasNext = false;
72
- return body;
73
- }
74
- this.page += 1;
75
- if ('global_meta' in body) {
76
- // Handle meta responses.
77
- this.total = body.global_meta.total_pages;
78
- this.hasNext = this.page <= body.global_meta.total_pages;
79
- return body.global_meta.records;
80
- }
81
- else if ('total_records' in body) {
82
- // WAFlog responses.
83
- this.total = Math.ceil(body.total_reccords % this.per_page);
84
- this.hasNext = body.next !== '';
85
- return body.data;
86
- }
87
- else {
88
- this.total = body.pagination.total_pages;
89
- this.hasNext = this.page <= body.pagination.total_pages;
90
- return body.data;
91
- }
92
- });
93
- }
94
- [Symbol.asyncIterator]() {
95
- return __asyncGenerator(this, arguments, function* _a() {
96
- while (this.hasNext) {
97
- const data = yield __await(this.next());
98
- yield yield __await(data);
99
- }
100
- });
101
- }
102
- }
103
- exports.PaginatedResponse = PaginatedResponse;
@@ -1,68 +0,0 @@
1
- import { type Buffer } from 'buffer';
2
- export interface Config {
3
- organization: string;
4
- token?: string;
5
- project?: string;
6
- bearer?: string;
7
- endpoint?: string;
8
- }
9
- export interface ProxyPayload {
10
- url: string;
11
- destination: string;
12
- published: boolean;
13
- }
14
- export interface MarkupPayload {
15
- data: Buffer;
16
- url: string;
17
- published: boolean;
18
- findAttachments?: boolean;
19
- skipPurge?: boolean;
20
- }
21
- export interface FilePayload {
22
- data: Buffer;
23
- url: string;
24
- skipPurge?: boolean;
25
- headers?: string;
26
- }
27
- export interface PublishPayload {
28
- location: string;
29
- revision: number;
30
- }
31
- export declare enum RedirectStatus {
32
- Permanent = 301,
33
- Termporary = 302
34
- }
35
- export interface RedirectPayload {
36
- url: string;
37
- redirect_url: string;
38
- redirect_http_code: RedirectStatus;
39
- published: boolean;
40
- skipPurge?: boolean;
41
- }
42
- export interface URLPayload {
43
- url: string;
44
- }
45
- export interface WafLogsPayload {
46
- project: string;
47
- }
48
- export interface SearchIndexPayload {
49
- data: Buffer;
50
- }
51
- export interface WafLog {
52
- timestamp: string;
53
- ip_address: string;
54
- location: string;
55
- type: string;
56
- mode: string;
57
- rule_id: string;
58
- domain: string;
59
- url: string;
60
- method: string;
61
- user_agent: string;
62
- }
63
- export interface MetaFilters {
64
- sort_field: string;
65
- sort_direction: string;
66
- quant_type?: 'edge_function' | 'redirect' | 'content' | 'file';
67
- page_size?: number;
68
- }
package/dist/src/types.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RedirectStatus = void 0;
4
- var RedirectStatus;
5
- (function (RedirectStatus) {
6
- RedirectStatus[RedirectStatus["Permanent"] = 301] = "Permanent";
7
- RedirectStatus[RedirectStatus["Termporary"] = 302] = "Termporary";
8
- })(RedirectStatus || (exports.RedirectStatus = RedirectStatus = {}));
@@ -1 +0,0 @@
1
- export {};
@@ -1,191 +0,0 @@
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
- const src_1 = require("../src");
13
- const buffer_1 = require("buffer");
14
- const chai_1 = require("chai");
15
- class TestClient {
16
- constructor(baseUrl, headers) {
17
- this.reject = false;
18
- this.baseUrl = baseUrl;
19
- this.headers = headers;
20
- this.reject = false;
21
- }
22
- do(options) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- return yield Promise.resolve('okay!');
25
- });
26
- }
27
- get(path, qs, headers) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- return yield Promise.resolve({});
30
- });
31
- }
32
- post(path, body, headers, formData, qs) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- return yield Promise.resolve({});
35
- });
36
- }
37
- delete(path, body, headers) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- return yield Promise.resolve({});
40
- });
41
- }
42
- patch(path, body, headers) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- return yield Promise.resolve({});
45
- });
46
- }
47
- }
48
- // Create a singleton mock client that all tests will use
49
- const mockClient = new TestClient('https://api.quantcdn.io/v1', {});
50
- // Create a constructor function that returns our singleton
51
- function MockClientConstructor(baseUrl, headers) {
52
- return mockClient;
53
- }
54
- describe('file()', () => {
55
- beforeEach(() => {
56
- // Reset the mock client's post method before each test
57
- mockClient.post = () => __awaiter(void 0, void 0, void 0, function* () { return ({}); });
58
- });
59
- it('should successfully upload a file', () => __awaiter(void 0, void 0, void 0, function* () {
60
- const testData = buffer_1.Buffer.from('test file content');
61
- const payload = {
62
- data: testData,
63
- url: '/test/file.txt'
64
- };
65
- mockClient.post = () => __awaiter(void 0, void 0, void 0, function* () { return ({ status: 'success' }); });
66
- const client = new src_1.QuantClient({
67
- organization: 'test-org',
68
- project: 'test-project',
69
- token: 'test-token'
70
- }, MockClientConstructor);
71
- const response = yield client.project.file(payload);
72
- (0, chai_1.expect)(response.status).to.equal('success');
73
- }));
74
- it('should handle file upload with skipPurge option', () => __awaiter(void 0, void 0, void 0, function* () {
75
- const testData = buffer_1.Buffer.from('test file content');
76
- const payload = {
77
- data: testData,
78
- url: '/test/file.txt',
79
- skipPurge: true
80
- };
81
- mockClient.post = (path_1, body_1, ...args_1) => __awaiter(void 0, [path_1, body_1, ...args_1], void 0, function* (path, body, headers = {}) {
82
- (0, chai_1.expect)(headers['Quant-Skip-Purge']).to.equal('true');
83
- return { status: 'success' };
84
- });
85
- const client = new src_1.QuantClient({
86
- organization: 'test-org',
87
- project: 'test-project',
88
- token: 'test-token'
89
- }, MockClientConstructor);
90
- const response = yield client.project.file(payload);
91
- (0, chai_1.expect)(response.status).to.equal('success');
92
- }));
93
- it('should handle API errors appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
94
- const testData = buffer_1.Buffer.from('test file content');
95
- const payload = {
96
- data: testData,
97
- url: '/test/file.txt'
98
- };
99
- mockClient.post = () => __awaiter(void 0, void 0, void 0, function* () {
100
- throw new Error('Invalid file format');
101
- });
102
- const client = new src_1.QuantClient({
103
- organization: 'test-org',
104
- project: 'test-project',
105
- token: 'test-token'
106
- }, MockClientConstructor);
107
- try {
108
- yield client.project.file(payload);
109
- chai_1.expect.fail('Should have thrown an error');
110
- }
111
- catch (error) {
112
- (0, chai_1.expect)(error.message).to.equal('Invalid file format');
113
- }
114
- }));
115
- it('should handle large files correctly', () => __awaiter(void 0, void 0, void 0, function* () {
116
- const testData = buffer_1.Buffer.alloc(1024 * 1024, 'x');
117
- const payload = {
118
- data: testData,
119
- url: '/test/large-file.txt'
120
- };
121
- mockClient.post = () => __awaiter(void 0, void 0, void 0, function* () { return ({ status: 'success' }); });
122
- const client = new src_1.QuantClient({
123
- organization: 'test-org',
124
- project: 'test-project',
125
- token: 'test-token'
126
- }, MockClientConstructor);
127
- const response = yield client.project.file(payload);
128
- (0, chai_1.expect)(response.status).to.equal('success');
129
- }));
130
- });
131
- describe('markup', () => {
132
- beforeEach(() => {
133
- mockClient.post = () => __awaiter(void 0, void 0, void 0, function* () { return ({}); });
134
- });
135
- it('should respect findAttachments when false', () => __awaiter(void 0, void 0, void 0, function* () {
136
- const testData = buffer_1.Buffer.from('test content');
137
- const payload = {
138
- data: testData,
139
- url: '/test/markup',
140
- published: true,
141
- findAttachments: false
142
- };
143
- mockClient.post = (path, body) => __awaiter(void 0, void 0, void 0, function* () {
144
- (0, chai_1.expect)(body.find_attachments).to.equal(false);
145
- return { status: 'success' };
146
- });
147
- const client = new src_1.QuantClient({
148
- organization: 'test-org',
149
- project: 'test-project',
150
- token: 'test-token'
151
- }, MockClientConstructor);
152
- yield client.project.markup(payload);
153
- }));
154
- it('should respect findAttachments when true', () => __awaiter(void 0, void 0, void 0, function* () {
155
- const testData = buffer_1.Buffer.from('test content');
156
- const payload = {
157
- data: testData,
158
- url: '/test/markup',
159
- published: true,
160
- findAttachments: true
161
- };
162
- mockClient.post = (path, body) => __awaiter(void 0, void 0, void 0, function* () {
163
- (0, chai_1.expect)(body.find_attachments).to.equal(true);
164
- return { status: 'success' };
165
- });
166
- const client = new src_1.QuantClient({
167
- organization: 'test-org',
168
- project: 'test-project',
169
- token: 'test-token'
170
- }, MockClientConstructor);
171
- yield client.project.markup(payload);
172
- }));
173
- it('should default findAttachments to false when not specified', () => __awaiter(void 0, void 0, void 0, function* () {
174
- const testData = buffer_1.Buffer.from('test content');
175
- const payload = {
176
- data: testData,
177
- url: '/test/markup',
178
- published: true
179
- };
180
- mockClient.post = (path, body) => __awaiter(void 0, void 0, void 0, function* () {
181
- (0, chai_1.expect)(body.find_attachments).to.equal(false);
182
- return { status: 'success' };
183
- });
184
- const client = new src_1.QuantClient({
185
- organization: 'test-org',
186
- project: 'test-project',
187
- token: 'test-token'
188
- }, MockClientConstructor);
189
- yield client.project.markup(payload);
190
- }));
191
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,133 +0,0 @@
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
- var __asyncValues = (this && this.__asyncValues) || function (o) {
12
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
- var m = o[Symbol.asyncIterator], i;
14
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- const response_1 = require("../src/response");
20
- const chai_1 = require("chai");
21
- class TestClient {
22
- constructor(baseUrl, headers, testData) {
23
- this.baseUrl = baseUrl;
24
- this.headers = headers;
25
- this.testData = testData || {
26
- data: [1, 2, 3],
27
- pagination: {
28
- current_page: 1,
29
- from: 1,
30
- total_pages: 1,
31
- per_page: 3,
32
- to: 3,
33
- total: 3
34
- }
35
- };
36
- }
37
- do(options) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- return yield Promise.resolve(this.testData);
40
- });
41
- }
42
- get(path, qs, headers) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- return yield Promise.resolve({});
45
- });
46
- }
47
- post(path, body, headers, formData, qs) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- return yield Promise.resolve({});
50
- });
51
- }
52
- delete(path, body, headers) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- return yield Promise.resolve({});
55
- });
56
- }
57
- patch(path, body, headers) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- return yield Promise.resolve({});
60
- });
61
- }
62
- }
63
- describe('PaginatedResponse', () => {
64
- const client = new TestClient('https://api.quantcdn.io/v1', {});
65
- const options = {
66
- url: 'https://api.quantcdn.io/v1/test',
67
- method: 'GET'
68
- };
69
- it('should paginate through results', () => __awaiter(void 0, void 0, void 0, function* () {
70
- var _a, e_1, _b, _c;
71
- const response = new response_1.PaginatedResponse(client, options);
72
- let results = [];
73
- try {
74
- for (var _d = true, response_2 = __asyncValues(response), response_2_1; response_2_1 = yield response_2.next(), _a = response_2_1.done, !_a; _d = true) {
75
- _c = response_2_1.value;
76
- _d = false;
77
- const items = _c;
78
- if (Array.isArray(items)) {
79
- results = results.concat(items);
80
- }
81
- else {
82
- results.push(items);
83
- }
84
- }
85
- }
86
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
87
- finally {
88
- try {
89
- if (!_d && !_a && (_b = response_2.return)) yield _b.call(response_2);
90
- }
91
- finally { if (e_1) throw e_1.error; }
92
- }
93
- (0, chai_1.expect)(results).to.deep.equal([1, 2, 3]);
94
- }));
95
- it('should handle empty responses', () => __awaiter(void 0, void 0, void 0, function* () {
96
- var _a, e_2, _b, _c;
97
- const emptyData = {
98
- data: [],
99
- pagination: {
100
- current_page: 1,
101
- from: null,
102
- total_pages: 1,
103
- per_page: 10,
104
- to: null,
105
- total: 0
106
- }
107
- };
108
- const emptyClient = new TestClient('https://api.quantcdn.io/v1', {}, emptyData);
109
- const response = new response_1.PaginatedResponse(emptyClient, options);
110
- let results = [];
111
- try {
112
- for (var _d = true, response_3 = __asyncValues(response), response_3_1; response_3_1 = yield response_3.next(), _a = response_3_1.done, !_a; _d = true) {
113
- _c = response_3_1.value;
114
- _d = false;
115
- const items = _c;
116
- if (Array.isArray(items)) {
117
- results = results.concat(items);
118
- }
119
- else {
120
- results.push(items);
121
- }
122
- }
123
- }
124
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
125
- finally {
126
- try {
127
- if (!_d && !_a && (_b = response_3.return)) yield _b.call(response_3);
128
- }
129
- finally { if (e_2) throw e_2.error; }
130
- }
131
- (0, chai_1.expect)(results).to.deep.equal([]);
132
- }));
133
- });