@quantcdn/quant-client 2.0.13 → 3.0.1

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 (122) hide show
  1. package/README.md +49 -72
  2. package/dist/api/apis.d.ts +32 -0
  3. package/dist/api/apis.js +50 -0
  4. package/dist/api/applicationsApi.d.ts +104 -0
  5. package/dist/api/applicationsApi.js +431 -0
  6. package/dist/api/backupManagementApi.d.ts +106 -0
  7. package/dist/api/backupManagementApi.js +440 -0
  8. package/dist/api/commandsApi.d.ts +80 -0
  9. package/dist/api/commandsApi.js +316 -0
  10. package/dist/api/composeApi.d.ts +66 -0
  11. package/dist/api/composeApi.js +236 -0
  12. package/dist/api/containersApi.d.ts +67 -0
  13. package/dist/api/containersApi.js +236 -0
  14. package/dist/api/cronApi.d.ts +151 -0
  15. package/dist/api/cronApi.js +681 -0
  16. package/dist/api/environmentsApi.d.ts +194 -0
  17. package/dist/api/environmentsApi.js +861 -0
  18. package/dist/api/sSHAccessApi.d.ts +50 -0
  19. package/dist/api/sSHAccessApi.js +162 -0
  20. package/dist/api/scalingPolicyApi.d.ts +82 -0
  21. package/dist/api/scalingPolicyApi.js +307 -0
  22. package/dist/api/variablesApi.d.ts +83 -0
  23. package/dist/api/variablesApi.js +313 -0
  24. package/dist/api/volumesApi.d.ts +97 -0
  25. package/dist/api/volumesApi.js +405 -0
  26. package/dist/api.d.ts +2 -0
  27. package/dist/api.js +19 -0
  28. package/dist/model/application.d.ts +38 -0
  29. package/dist/model/application.js +93 -0
  30. package/dist/model/command.d.ts +34 -0
  31. package/dist/model/command.js +73 -0
  32. package/dist/model/compose.d.ts +32 -0
  33. package/dist/model/compose.js +58 -0
  34. package/dist/model/configuration.d.ts +26 -0
  35. package/dist/model/configuration.js +30 -0
  36. package/dist/model/container.d.ts +38 -0
  37. package/dist/model/container.js +78 -0
  38. package/dist/model/containerEnvironmentInner.d.ts +26 -0
  39. package/dist/model/containerEnvironmentInner.js +33 -0
  40. package/dist/model/containerImageReference.d.ts +28 -0
  41. package/dist/model/containerImageReference.js +43 -0
  42. package/dist/model/containerMountPointsInner.d.ts +27 -0
  43. package/dist/model/containerMountPointsInner.js +38 -0
  44. package/dist/model/createApplicationRequest.d.ts +28 -0
  45. package/dist/model/createApplicationRequest.js +43 -0
  46. package/dist/model/createBackup202Response.d.ts +27 -0
  47. package/dist/model/createBackup202Response.js +38 -0
  48. package/dist/model/createBackupRequest.d.ts +32 -0
  49. package/dist/model/createBackupRequest.js +33 -0
  50. package/dist/model/createCommandRequest.d.ts +25 -0
  51. package/dist/model/createCommandRequest.js +28 -0
  52. package/dist/model/createCronJob422Response.d.ts +26 -0
  53. package/dist/model/createCronJob422Response.js +33 -0
  54. package/dist/model/createCronJobRequest.d.ts +30 -0
  55. package/dist/model/createCronJobRequest.js +56 -0
  56. package/dist/model/createEnvironmentRequest.d.ts +34 -0
  57. package/dist/model/createEnvironmentRequest.js +53 -0
  58. package/dist/model/cron.d.ts +27 -0
  59. package/dist/model/cron.js +38 -0
  60. package/dist/model/cronRun.d.ts +48 -0
  61. package/dist/model/cronRun.js +89 -0
  62. package/dist/model/deleteBackup200Response.d.ts +26 -0
  63. package/dist/model/deleteBackup200Response.js +33 -0
  64. package/dist/model/downloadBackup200Response.d.ts +36 -0
  65. package/dist/model/downloadBackup200Response.js +38 -0
  66. package/dist/model/environment.d.ts +45 -0
  67. package/dist/model/environment.js +103 -0
  68. package/dist/model/getEcrLoginCredentials200Response.d.ts +28 -0
  69. package/dist/model/getEcrLoginCredentials200Response.js +43 -0
  70. package/dist/model/getScalingPolicies200Response.d.ts +26 -0
  71. package/dist/model/getScalingPolicies200Response.js +28 -0
  72. package/dist/model/getSshAccessCredentials200Response.d.ts +34 -0
  73. package/dist/model/getSshAccessCredentials200Response.js +68 -0
  74. package/dist/model/getSshAccessCredentials200ResponseCredentials.d.ts +28 -0
  75. package/dist/model/getSshAccessCredentials200ResponseCredentials.js +43 -0
  76. package/dist/model/listBackups200Response.d.ts +26 -0
  77. package/dist/model/listBackups200Response.js +28 -0
  78. package/dist/model/listBackups200ResponseBackupsInner.d.ts +29 -0
  79. package/dist/model/listBackups200ResponseBackupsInner.js +48 -0
  80. package/dist/model/models.d.ts +84 -0
  81. package/dist/model/models.js +370 -0
  82. package/dist/model/scalingPolicy.d.ts +35 -0
  83. package/dist/model/scalingPolicy.js +51 -0
  84. package/dist/model/syncOperation.d.ts +31 -0
  85. package/dist/model/syncOperation.js +58 -0
  86. package/dist/model/syncToEnvironmentRequest.d.ts +25 -0
  87. package/dist/model/syncToEnvironmentRequest.js +28 -0
  88. package/dist/model/updateComposeRequest.d.ts +26 -0
  89. package/dist/model/updateComposeRequest.js +28 -0
  90. package/dist/model/updateCronJobRequest.d.ts +29 -0
  91. package/dist/model/updateCronJobRequest.js +48 -0
  92. package/dist/model/updateEnvironmentComposeRequest.d.ts +26 -0
  93. package/dist/model/updateEnvironmentComposeRequest.js +28 -0
  94. package/dist/model/updateEnvironmentRequest.d.ts +26 -0
  95. package/dist/model/updateEnvironmentRequest.js +28 -0
  96. package/dist/model/updateEnvironmentStateRequest.d.ts +26 -0
  97. package/dist/model/updateEnvironmentStateRequest.js +33 -0
  98. package/dist/model/updateEnvironmentVariableRequest.d.ts +25 -0
  99. package/dist/model/updateEnvironmentVariableRequest.js +28 -0
  100. package/dist/model/validateCompose200Response.d.ts +27 -0
  101. package/dist/model/validateCompose200Response.js +38 -0
  102. package/dist/model/validateComposeRequest.d.ts +25 -0
  103. package/dist/model/validateComposeRequest.js +28 -0
  104. package/dist/model/variable.d.ts +26 -0
  105. package/dist/model/variable.js +33 -0
  106. package/dist/model/volume.d.ts +32 -0
  107. package/dist/model/volume.js +63 -0
  108. package/package.json +21 -40
  109. package/dist/src/client.d.ts +0 -15
  110. package/dist/src/client.js +0 -380
  111. package/dist/src/index.d.ts +0 -2
  112. package/dist/src/index.js +0 -42
  113. package/dist/src/interfaces.d.ts +0 -34
  114. package/dist/src/interfaces.js +0 -2
  115. package/dist/src/response.d.ts +0 -15
  116. package/dist/src/response.js +0 -103
  117. package/dist/src/types.d.ts +0 -68
  118. package/dist/src/types.js +0 -8
  119. package/dist/tests/client.test.d.ts +0 -1
  120. package/dist/tests/client.test.js +0 -191
  121. package/dist/tests/response.test.d.ts +0 -1
  122. package/dist/tests/response.test.js +0 -133
@@ -1,380 +0,0 @@
1
- "use strict";
2
- /**
3
- * Quant API client.
4
- */
5
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.QuantClient = void 0;
16
- const request = require("@cypress/request");
17
- const response_1 = require("./response");
18
- class HttpClient {
19
- constructor(baseUrl, headers) {
20
- this.baseUrl = baseUrl;
21
- this.headers = headers;
22
- }
23
- do(options) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- return yield new Promise((resolve, reject) => {
26
- request(options, (error, response, body) => {
27
- if (error !== null) {
28
- reject(error);
29
- }
30
- else {
31
- resolve(body);
32
- }
33
- });
34
- });
35
- });
36
- }
37
- get(path, qs, headers) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const options = {
40
- url: `${this.baseUrl}/${path}`,
41
- method: 'GET',
42
- headers: Object.assign(Object.assign({}, this.headers), headers),
43
- json: true,
44
- qs
45
- };
46
- const res = new response_1.PaginatedResponse(this, options);
47
- return yield new Promise((resolve) => { resolve(res); });
48
- });
49
- }
50
- post(path, body, headers, formData, qs) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const options = {
53
- url: `${this.baseUrl}/${path}`,
54
- method: 'POST',
55
- headers: Object.assign(Object.assign({}, this.headers), headers),
56
- json: true,
57
- body,
58
- formData,
59
- qs
60
- };
61
- const res = new response_1.PaginatedResponse(this, options);
62
- return yield new Promise((resolve) => { resolve(res); });
63
- });
64
- }
65
- delete(path, body, headers) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const options = {
68
- url: `${this.baseUrl}/${path}`,
69
- method: 'DELETE',
70
- headers: Object.assign(Object.assign({}, this.headers), headers),
71
- json: true,
72
- body
73
- };
74
- const res = new response_1.PaginatedResponse(this, options);
75
- return yield new Promise((resolve) => { resolve(res); });
76
- });
77
- }
78
- patch(path, body, headers) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- const options = {
81
- url: `${this.baseUrl}/${path}`,
82
- method: 'PATCH',
83
- headers: Object.assign(Object.assign({}, this.headers), headers),
84
- json: true,
85
- body
86
- };
87
- const res = new response_1.PaginatedResponse(this, options);
88
- return yield new Promise((resolve) => { resolve(res); });
89
- });
90
- }
91
- }
92
- class QuantClient {
93
- constructor(config, Client) {
94
- var _a, _b;
95
- this.project = {
96
- /**
97
- * Ping and ensure the API credentials are valid.
98
- *
99
- * @returns Promise<any>
100
- * The response object.
101
- */
102
- ping: () => __awaiter(this, void 0, void 0, function* () {
103
- return yield this._project.get('ping');
104
- }),
105
- /**
106
- * Fetch metadata for all objects stored in Quant.
107
- *
108
- * @returns Promise<any>
109
- * The repsonse object.
110
- */
111
- meta: (filters) => __awaiter(this, void 0, void 0, function* () {
112
- const qs = {};
113
- if ((filters === null || filters === void 0 ? void 0 : filters.sort_direction) != null) {
114
- qs.sort_direction = filters.sort_direction;
115
- }
116
- if ((filters === null || filters === void 0 ? void 0 : filters.sort_field) != null) {
117
- qs.sort_field = filters.sort_field;
118
- }
119
- if ((filters === null || filters === void 0 ? void 0 : filters.quant_type) != null) {
120
- qs.quant_type = filters.quant_type;
121
- }
122
- if ((filters === null || filters === void 0 ? void 0 : filters.page_size) != null) {
123
- // Ensure page_size is between 1 and 100
124
- qs.page_size = Math.min(Math.max(1, filters.page_size), 100);
125
- }
126
- return yield this._project.get('global-meta', qs);
127
- }),
128
- /**
129
- * Send markup directly to the Quant API.
130
- *
131
- * @param markup MarkupPayload
132
- * The markup payload data.
133
- *
134
- * @returns Promise<any>
135
- * The repsonse object.
136
- */
137
- markup: (payload) => __awaiter(this, void 0, void 0, function* () {
138
- const headers = {};
139
- const body = {
140
- url: payload.url,
141
- content: payload.data.toString('utf-8'),
142
- published: payload.published,
143
- find_attachments: false
144
- };
145
- if (typeof payload.skipPurge !== 'undefined') {
146
- headers['Quant-Skip-Purge'] = 'true';
147
- }
148
- if (typeof payload.findAttachments !== 'undefined') {
149
- body.find_attachments = payload.findAttachments;
150
- }
151
- return yield this._project.post('markup', body, headers);
152
- }),
153
- /**
154
- * Upload a file asset to Quant.
155
- *
156
- * @param payload FilePayload
157
- * The file payload data.
158
- *
159
- * @returns Promise<any>
160
- * The repsonse object.
161
- */
162
- file: (payload) => __awaiter(this, void 0, void 0, function* () {
163
- const headers = {
164
- 'Quant-File-Url': payload.url
165
- };
166
- if (typeof payload.skipPurge !== 'undefined') {
167
- headers['Quant-Skip-Purge'] = 'true';
168
- }
169
- if (typeof payload.headers !== 'undefined') {
170
- headers['Quant-File-Headers'] = payload.headers;
171
- }
172
- const formData = {
173
- file: {
174
- value: payload.data,
175
- options: {
176
- filename: 'file',
177
- contentType: 'application/octet-stream'
178
- }
179
- }
180
- };
181
- return yield this._project.post('file', undefined, headers, formData);
182
- }),
183
- /**
184
- * Publish a revision.
185
- *
186
- * @param payload PublishPayload
187
- * The payload object
188
- *
189
- * @returns Promise<any>
190
- * The response object.
191
- */
192
- publish: (payload) => __awaiter(this, void 0, void 0, function* () {
193
- const response = yield this._project.patch(`publish/${payload.revision}`, {}, {
194
- 'Quant-Url': payload.location
195
- });
196
- return response.first();
197
- }),
198
- /**
199
- * Unpublish the current published revision.
200
- *
201
- * @param payload PublishPayload
202
- * The payload object.
203
- *
204
- * @returns Promise<any>
205
- * The response object.
206
- */
207
- unpublish: (payload) => __awaiter(this, void 0, void 0, function* () {
208
- const response = yield this._project.patch('unpublish', {}, {
209
- 'Quant-Url': payload.location
210
- });
211
- return response.first();
212
- }),
213
- /**
214
- * Redirect a URL.
215
- *
216
- * @param payload RedirectPayload
217
- * The redirect payload.
218
- *
219
- * @returns Promise<any>
220
- * The repsonse object.
221
- */
222
- redirect: (payload) => __awaiter(this, void 0, void 0, function* () {
223
- const headers = {};
224
- const body = {
225
- url: payload.url,
226
- redirect_url: payload.redirect_url,
227
- redirect_http_code: payload.redirect_http_code,
228
- published: payload.published
229
- };
230
- if (typeof payload.skipPurge !== 'undefined') {
231
- headers['Quant-Skip-Purge'] = 'true';
232
- }
233
- return yield this._project.post('redirect', body, headers);
234
- }),
235
- /**
236
- * Proxy a URL to a different origin.
237
- *
238
- * @param payload ProxyPayload
239
- * The proxy API payload.
240
- *
241
- * @returns Promise<any>
242
- * The repsonse object.
243
- */
244
- proxy: (payload) => __awaiter(this, void 0, void 0, function* () {
245
- return yield this._project.post('proxy', payload);
246
- }),
247
- /**
248
- * Delete a URL from Quant.
249
- *
250
- * @param payload URLPayload
251
- * The API payload.
252
- *
253
- * @returns Promise<any>
254
- * The repsonse object.
255
- */
256
- delete: (payload) => __awaiter(this, void 0, void 0, function* () {
257
- const response = yield this._project.delete('delete/all?force_delete=true', {}, {
258
- 'Quant-Url': payload.url
259
- });
260
- return response.first();
261
- }),
262
- /**
263
- * Get a revision from the API.
264
- *
265
- * @param payload URLPayload
266
- * The URL payload.
267
- *
268
- * @returns Promise<any>
269
- * The repsonse object.
270
- */
271
- revisions: (payload) => __awaiter(this, void 0, void 0, function* () {
272
- return yield this._project.get('revisions/latest', {}, {
273
- 'Quant-Url': payload.url
274
- });
275
- }),
276
- /**
277
- * Purge Varnish for a given URL pattern.
278
- *
279
- * @param payload URLPayload
280
- * The URL payload.
281
- *
282
- * @returns Promise<any>
283
- * The repsonse object.
284
- */
285
- purge: (payload) => __awaiter(this, void 0, void 0, function* () {
286
- return yield this._project.post('purge', {}, {
287
- 'Quant-Url': payload.url
288
- });
289
- })
290
- };
291
- this.organization = {
292
- /**
293
- * Fetch WAF logs from.
294
- *
295
- * @param payload types.WafLogsPayload
296
- * The API request payload.
297
- *
298
- * @returns Promise<any>
299
- * The response object.
300
- */
301
- wafLogs: (payload) => __awaiter(this, void 0, void 0, function* () {
302
- const headers = { 'Quant-Project': payload.project };
303
- return yield this._organization.get('waf/logs', {}, headers);
304
- })
305
- };
306
- this.search = {
307
- /**
308
- * Index search data.
309
- *
310
- * @param payload types.SearchIndexPayload
311
- * The search index paylod.
312
- *
313
- * @returns Promise<any>
314
- * The response.
315
- */
316
- index: (payload) => __awaiter(this, void 0, void 0, function* () {
317
- return yield this._search.post('search', JSON.parse(payload.data.toString()));
318
- }),
319
- /**
320
- * Remove an item from the search index.
321
- *
322
- * @param payload types.URLPayload
323
- * The URL payload.
324
- *
325
- * @returns Promise<any>
326
- * The response obejct.
327
- */
328
- remove: (payload) => __awaiter(this, void 0, void 0, function* () {
329
- return yield this._search.delete('search', {}, {
330
- 'Quant-Url': payload.url
331
- });
332
- }),
333
- /**
334
- * Clear the search index.
335
- *
336
- * @returns Promise<any>
337
- * The response object.
338
- */
339
- clear: () => __awaiter(this, void 0, void 0, function* () {
340
- return yield this._search.delete('search/all');
341
- }),
342
- /**
343
- * Get the search index status.
344
- *
345
- * @returns Promise<any>
346
- * The response object.
347
- */
348
- status: () => __awaiter(this, void 0, void 0, function* () {
349
- return yield this._search.get('search');
350
- })
351
- };
352
- if (typeof Client === 'undefined') {
353
- Client = HttpClient;
354
- }
355
- this._project = new Client((_a = config.endpoint) !== null && _a !== void 0 ? _a : 'https://api.quantcdn.io/v1', {
356
- 'User-Agent': 'Quant (+http://api.quantcdn.io)',
357
- 'Quant-Token': config.token,
358
- 'Quant-Customer': config.organization,
359
- 'Quant-Project': config.project,
360
- 'Content-Type': 'application/json'
361
- });
362
- this._search = new Client((_b = config.endpoint) !== null && _b !== void 0 ? _b : 'https://api.quantcdn.io/v1', {
363
- 'User-Agent': 'Quant (+http://api.quantcdn.io)',
364
- 'Quant-Token': config.token,
365
- 'Quant-Customer': config.organization,
366
- 'Quant-Project': config.project,
367
- 'Content-Type': 'application/json'
368
- });
369
- this._organization = new Client('https://dashboard.quantcdn.io/api/v1', {
370
- 'User-Agent': 'Quant (+http://api.quantcdn.io)',
371
- // @todo: Americanise.
372
- 'Quant-Organisation': config.organization,
373
- Authorization: `Bearer ${config.bearer}`
374
- });
375
- }
376
- getClient(name) {
377
- return this[`_${name}`];
378
- }
379
- }
380
- exports.QuantClient = QuantClient;
@@ -1,2 +0,0 @@
1
- export * from './client';
2
- export * as types from './types';
package/dist/src/index.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
- };
21
- var __importStar = (this && this.__importStar) || (function () {
22
- var ownKeys = function(o) {
23
- ownKeys = Object.getOwnPropertyNames || function (o) {
24
- var ar = [];
25
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
- return ar;
27
- };
28
- return ownKeys(o);
29
- };
30
- return function (mod) {
31
- if (mod && mod.__esModule) return mod;
32
- var result = {};
33
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
- __setModuleDefault(result, mod);
35
- return result;
36
- };
37
- })();
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.types = void 0;
40
- // export { QuantClient } from './quant-client'
41
- __exportStar(require("./client"), exports);
42
- exports.types = __importStar(require("./types"));
@@ -1,34 +0,0 @@
1
- import type * as types from './types';
2
- import type * as request from '@cypress/request';
3
- export type ClientConstructor = new (baseUrl: string, headers: object) => Client;
4
- export interface Client {
5
- baseUrl: string;
6
- headers: object;
7
- do: (options: request.Options) => Promise<any>;
8
- get: (path: string, qs?: object, headers?: object) => Promise<any>;
9
- post: (path: string, body?: any, headers?: object, formData?: object, qs?: object) => Promise<any>;
10
- delete: (path: string, body?: any, headers?: object) => Promise<any>;
11
- patch: (path: string, body?: any, headers?: object) => Promise<any>;
12
- }
13
- export interface ProjectApi {
14
- ping: () => Promise<any>;
15
- meta: (filter?: types.MetaFilters) => Promise<any>;
16
- markup: (payload: types.MarkupPayload) => Promise<any>;
17
- file: (payload: types.FilePayload) => Promise<any>;
18
- publish: (payload: types.PublishPayload) => Promise<any>;
19
- unpublish: (payload: types.PublishPayload) => Promise<any>;
20
- redirect: (payload: types.RedirectPayload) => Promise<any>;
21
- proxy: (payload: types.ProxyPayload) => Promise<any>;
22
- delete: (payload: types.URLPayload) => Promise<any>;
23
- revisions: (payload: types.URLPayload) => Promise<any>;
24
- purge: (payload: types.URLPayload) => Promise<any>;
25
- }
26
- export interface OrganizationApi {
27
- wafLogs: (payload: types.WafLogsPayload) => Promise<any>;
28
- }
29
- export interface SearchApi {
30
- index: (payload: types.SearchIndexPayload) => Promise<any>;
31
- remove: (payload: types.URLPayload) => Promise<any>;
32
- clear: () => Promise<any>;
33
- status: () => Promise<any>;
34
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -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 {};