@quantcdn/quant-client 1.0.0 → 2.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.
@@ -0,0 +1,60 @@
1
+ /// <reference types="node" />
2
+ import { type Buffer } from 'buffer';
3
+ export interface Config {
4
+ organization: string;
5
+ token?: string;
6
+ project?: string;
7
+ bearer?: 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
+ location: string;
24
+ skipPurge?: boolean;
25
+ }
26
+ export interface PublishPayload {
27
+ location: string;
28
+ revision: number;
29
+ }
30
+ export declare enum RedirectStatus {
31
+ Permanent = 301,
32
+ Termporary = 302
33
+ }
34
+ export interface RedirectPayload {
35
+ url: string;
36
+ redirect_url: string;
37
+ redirect_http_code: RedirectStatus;
38
+ published: boolean;
39
+ }
40
+ export interface URLPayload {
41
+ url: string;
42
+ }
43
+ export interface WafLogsPayload {
44
+ project: string;
45
+ }
46
+ export interface SearchIndexPayload {
47
+ data: Buffer;
48
+ }
49
+ export interface WafLog {
50
+ timestamp: string;
51
+ ip_address: string;
52
+ location: string;
53
+ type: string;
54
+ mode: string;
55
+ rule_id: string;
56
+ domain: string;
57
+ url: string;
58
+ method: string;
59
+ user_agent: string;
60
+ }
package/dist/types.js ADDED
@@ -0,0 +1,8 @@
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 = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantcdn/quant-client",
3
- "version": "1.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Client library for API connectivity",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,11 +8,13 @@
8
8
  "/dist"
9
9
  ],
10
10
  "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "build": "tsc",
12
+ "test": "jest",
13
+ "lint:src": "eslint --ext .ts ./src"
12
14
  },
13
15
  "repository": {
14
16
  "type": "git",
15
- "url": "git+https://github.com/quantcdn/quant-client.git"
17
+ "url": "git+https://github.com/quantcdn/quant-ts-client.git"
16
18
  },
17
19
  "author": "Stuart Rowlands <stuart.rowlands@quantcdn.io>",
18
20
  "license": "ISC",
@@ -21,10 +23,22 @@
21
23
  },
22
24
  "homepage": "https://github.com/quantcdn/quant-client#readme",
23
25
  "dependencies": {
24
- "mime-types": "^2.1.27",
25
- "request": "^2.88.2"
26
+ "@cypress/request": "3.0.1",
27
+ "mime-types": "^2.1.27"
26
28
  },
27
29
  "devDependencies": {
28
- "@types/node": "^18.16.3"
30
+ "@types/jest": "^29.5.2",
31
+ "@types/node": "^18.16.3",
32
+ "@typescript-eslint/eslint-plugin": "^6.4.1",
33
+ "@typescript-eslint/parser": "^6.4.1",
34
+ "@typescript-eslint/typescript-estree": "^6.4.1",
35
+ "eslint": "^8.48.0",
36
+ "eslint-config-standard-with-typescript": "^38.0.0",
37
+ "eslint-plugin-import": "^2.28.1",
38
+ "eslint-plugin-n": "^16.0.2",
39
+ "eslint-plugin-promise": "^6.1.1",
40
+ "jest": "^29.5.0",
41
+ "ts-jest": "^29.1.0",
42
+ "typescript": "^5.2.2"
29
43
  }
30
44
  }
package/dist/config.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export interface QuantConfig {
2
- dir: string;
3
- endpoint: "https://api.quantcdn.io/v1";
4
- clientid: string;
5
- project: string;
6
- token: string;
7
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * Prepare URLs for quant.
3
- */
4
- export declare class QuantURL {
5
- /**
6
- * Prepare a URI to work with Quant.
7
- *
8
- * @param {string} uri
9
- * The URI to prepare.
10
- *
11
- * @return {string}
12
- * The prepared URI
13
- */
14
- static prepare(uri: any): any;
15
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- /**
3
- * Prepare URLs for quant.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.QuantURL = void 0;
7
- class QuantURL {
8
- /**
9
- * Prepare a URI to work with Quant.
10
- *
11
- * @param {string} uri
12
- * The URI to prepare.
13
- *
14
- * @return {string}
15
- * The prepared URI
16
- */
17
- static prepare(uri) {
18
- uri = uri.startsWith('/') ? uri : `/${uri}`;
19
- uri = uri.toLowerCase();
20
- uri = uri.replace(/^\/\//, '/');
21
- uri = uri.replace(/(\/)index\.html/, '$1');
22
- if (uri.length > 1) {
23
- return uri.endsWith('/') ? uri.slice(0, -1) : uri;
24
- }
25
- return uri;
26
- }
27
- }
28
- exports.QuantURL = QuantURL;
29
- ;
@@ -1,230 +0,0 @@
1
- /**
2
- * Quant API client.
3
- */
4
- export declare function QuantClient(): {
5
- /**
6
- * Initialize the client
7
- */
8
- init: () => void;
9
- /**
10
- * Ping the quant API.
11
- *
12
- * @return {object}
13
- * The response object.
14
- *
15
- * @throws Error.
16
- */
17
- ping: () => Promise<any>;
18
- /**
19
- * Access the global meta for the project.
20
- *
21
- * @param {bool} unfold
22
- * Unfold the record set.
23
- * @param {bool} exclude
24
- * Exclude delete objects from the meta result.
25
- * @param {object} extend
26
- * Additional query parameters to send.
27
- *
28
- * @return {object}
29
- * The global meta response object.
30
- *
31
- * @throws Error.
32
- *
33
- * @TODO
34
- * - Async iterator for memory 21k items ~ 40mb.
35
- */
36
- meta: (unfold?: boolean, exclude?: boolean, extend?: {}) => Promise<{
37
- total_pages: any;
38
- total_records: any;
39
- records: any[];
40
- }>;
41
- /**
42
- * Send a file to the server.
43
- *
44
- * @param {string} file
45
- * The path to the file.
46
- * @param {string} location
47
- * The path the location.
48
- * @param {bool} published
49
- * The status.
50
- * @param {bool} attachments
51
- * Should quant find attachments.
52
- * @param {bool} skipPurge
53
- * Skip CDN cache purge.
54
- * @param {bool} includeIndex
55
- * Include index.html suffix on HTML assets.
56
- * @param {object} extraHeaders
57
- * Additional HTTP headers.
58
- * @param {string} encoding
59
- * The encoding type.
60
- *
61
- * @return {object}
62
- * The API response.
63
- */
64
- send: (file: any, location: any, published?: boolean, attachments?: boolean, skipPurge?: boolean, includeIndex?: boolean, extraHeaders?: {}, encoding?: string) => Promise<any>;
65
- /**
66
- * Upload markup.
67
- *
68
- * @param {string} file
69
- * Filepath on disk.
70
- * @param {string} location
71
- * The web accessible destination.
72
- * @param {bool} published
73
- * The status.
74
- * @param {bool} attachments
75
- * Quant looking for attachments.
76
- * @param {object} extraHeaders
77
- * Additional HTTP headers.
78
- * @param {string} encoding
79
- * The encoding type.
80
- * @param {bool} skipPurge
81
- * Skip CDN cache purge.
82
- *
83
- * @return {object}
84
- * The API response.
85
- */
86
- markup: (file: any, location: any, published?: boolean, attachments?: boolean, extraHeaders?: {}, encoding?: string, skipPurge?: boolean) => Promise<any>;
87
- /**
88
- * Send a file to the Quant API.
89
- *
90
- * @param {string} local
91
- * File path on disk.
92
- * @param {string} location
93
- * Accessible location.
94
- * @param {bool} absolute
95
- * If the location is an absolute path.
96
- * @param {object} extraHeaders
97
- * Additional HTTP headers.
98
- * @param {bool} skipPurge
99
- * Skip CDN cache purge.
100
- *
101
- * @return {object}
102
- * The successful payload.
103
- *
104
- * @throws Error
105
- */
106
- file: (local: any, location: any, absolute?: boolean, extraHeaders?: {}, skipPurge?: boolean) => Promise<any>;
107
- /**
108
- * Change the status of an asset.
109
- *
110
- * @param {string} location
111
- * The URL location of the content.
112
- * @param {string} revision
113
- * The revision to publish.
114
- *
115
- * @return {object}
116
- * API payload.
117
- *
118
- * @throws Error.
119
- */
120
- publish: (location: any, revision: any) => Promise<any>;
121
- /**
122
- * Unpublish a URL.
123
- *
124
- * @param {string} url
125
- * The URL to unpublish.
126
- *
127
- * @return {object}
128
- *
129
- * @throws Error.
130
- */
131
- unpublish: (url: any) => Promise<any>;
132
- /**
133
- *
134
- * @param {string} from
135
- * The URL to redirect form.
136
- * @param {string} to
137
- * The URL to redirect to.
138
- * @param {string} author
139
- * (Optional) Author.
140
- * @param {int} status
141
- * HTTP status code.
142
- *
143
- * @return {object}
144
- * API payload.
145
- *
146
- * @throws Error.
147
- */
148
- redirect: (from: any, to: any, author: any, status?: number) => Promise<any>;
149
- /**
150
- * Create a proxy with the Quant API.
151
- *
152
- * @param {string} url
153
- * The relative URL to proxy.
154
- * @param {string} destination
155
- * The absolute FQDN/path to proxy to.
156
- * @param {bool} published
157
- * If the proxy is published
158
- * @param {string} username
159
- * Basic auth user.
160
- * @param {string} password
161
- * Basic auth password.
162
- *
163
- * @return {object}
164
- * The response.
165
- *
166
- * @throws Error.
167
- */
168
- proxy: (url: any, destination: any, published: boolean, username: any, password: any) => Promise<any>;
169
- /**
170
- * Delete a path from Quant.
171
- *
172
- * @param {string} path
173
- *
174
- * @return {object}
175
- * The response object.
176
- *
177
- * @throw Error.
178
- */
179
- delete: (path: any) => Promise<any>;
180
- /**
181
- * Get the revision history from Quant.
182
- *
183
- * @param {string} url
184
- * The URL path to get revisions for.
185
- * @param {string|bool} revision
186
- * Retrieve a specific revision.
187
- *
188
- * @return {object}
189
- * The response.
190
- *
191
- * @throws Error.
192
- */
193
- revisions: (url: any, revision?: boolean) => Promise<any>;
194
- /**
195
- * Purge URL patterns from Quants Varnish.
196
- *
197
- * @param {string} urlPattern
198
- *
199
- * @throws Error
200
- */
201
- purge: (urlPattern: any) => Promise<any>;
202
- /**
203
- * Add/update items in search index.
204
- *
205
- * @param {string} filePath
206
- *
207
- * @throws Error
208
- */
209
- searchIndex: (filePath: any) => Promise<any>;
210
- /**
211
- * Remove item from search index.
212
- *
213
- * @param {string} url
214
- *
215
- * @throws Error
216
- */
217
- searchRemove: (url: any) => Promise<any>;
218
- /**
219
- * Clear search index.
220
- *
221
- * @throws Error
222
- */
223
- searchClearIndex: () => Promise<any>;
224
- /**
225
- * Retrieve search index status.
226
- *
227
- * @throws Error
228
- */
229
- searchStatus: () => Promise<any>;
230
- };