@quantcdn/quant-client 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js CHANGED
@@ -107,8 +107,15 @@ class QuantClient {
107
107
  * @returns Promise<any>
108
108
  * The repsonse object.
109
109
  */
110
- meta: () => __awaiter(this, void 0, void 0, function* () {
111
- return yield this._project.get('global-meta');
110
+ meta: (filters) => __awaiter(this, void 0, void 0, function* () {
111
+ const qs = {};
112
+ if ((filters === null || filters === void 0 ? void 0 : filters.sort_direction) != null) {
113
+ qs.sort_direction = filters.sort_direction;
114
+ }
115
+ if ((filters === null || filters === void 0 ? void 0 : filters.sort_field) != null) {
116
+ qs.sort_field = filters.sort_field;
117
+ }
118
+ return yield this._project.get('global-meta', qs);
112
119
  }),
113
120
  /**
114
121
  * Send markup directly to the Quant API.
@@ -125,13 +132,13 @@ class QuantClient {
125
132
  url: payload.url,
126
133
  content: payload.data.toString('utf-8'),
127
134
  published: payload.published,
128
- find_attachments: 'false'
135
+ find_attachments: false
129
136
  };
130
137
  if (typeof payload.skipPurge !== 'undefined') {
131
- headers['Quant-Skip-Purge'] = 'true';
138
+ headers['Quant-Skip-Purge'] = true;
132
139
  }
133
140
  if (typeof payload.findAttachments !== 'undefined') {
134
- body.find_attachments = 'true';
141
+ body.find_attachments = true;
135
142
  }
136
143
  return yield this._project.post('markup', body, headers);
137
144
  }),
@@ -141,19 +148,26 @@ class QuantClient {
141
148
  * @param payload FilePayload
142
149
  * The file payload data.
143
150
  *
144
- * @returns Promose<any>
151
+ * @returns Promise<any>
145
152
  * The repsonse object.
146
153
  */
147
154
  file: (payload) => __awaiter(this, void 0, void 0, function* () {
148
155
  const headers = {
149
- 'Content-Type': 'multipart/form-data',
150
- 'Quant-File-Url': payload.location
156
+ 'Quant-File-Url': payload.url
151
157
  };
152
- const formData = { data: payload.data };
153
158
  if (typeof payload.skipPurge !== 'undefined') {
154
159
  headers['Quant-Skip-Purge'] = 'true';
155
160
  }
156
- return yield this._project.post('file', {}, headers, formData);
161
+ const formData = {
162
+ file: {
163
+ value: payload.data,
164
+ options: {
165
+ filename: 'file',
166
+ contentType: 'application/octet-stream'
167
+ }
168
+ }
169
+ };
170
+ return yield this._project.post('file', undefined, headers, formData);
157
171
  }),
158
172
  /**
159
173
  * Publish a revision.
@@ -272,8 +286,8 @@ class QuantClient {
272
286
  * @param payload types.SearchIndexPayload
273
287
  * The search index paylod.
274
288
  *
275
- * @returns Promose<any>
276
- * The respose.
289
+ * @returns Promise<any>
290
+ * The response.
277
291
  */
278
292
  index: (payload) => __awaiter(this, void 0, void 0, function* () {
279
293
  return yield this._search.post('search', JSON.parse(payload.data.toString()));
@@ -12,7 +12,7 @@ export interface Client {
12
12
  }
13
13
  export interface ProjectApi {
14
14
  ping: () => Promise<any>;
15
- meta: () => Promise<any>;
15
+ meta: (filter?: types.MetaFilters) => Promise<any>;
16
16
  markup: (payload: types.MarkupPayload) => Promise<any>;
17
17
  file: (payload: types.FilePayload) => Promise<any>;
18
18
  publish: (payload: types.PublishPayload) => Promise<any>;
package/dist/response.js CHANGED
@@ -12,8 +12,9 @@ var __await = (this && this.__await) || function (v) { return this instanceof __
12
12
  var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
13
13
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
14
14
  var g = generator.apply(thisArg, _arguments || []), i, q = [];
15
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
16
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
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]); } }
17
18
  function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
18
19
  function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
19
20
  function fulfill(value) { resume("next", value); }
package/dist/types.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { type Buffer } from 'buffer';
3
2
  export interface Config {
4
3
  organization: string;
@@ -20,7 +19,7 @@ export interface MarkupPayload {
20
19
  }
21
20
  export interface FilePayload {
22
21
  data: Buffer;
23
- location: string;
22
+ url: string;
24
23
  skipPurge?: boolean;
25
24
  }
26
25
  export interface PublishPayload {
@@ -58,3 +57,7 @@ export interface WafLog {
58
57
  method: string;
59
58
  user_agent: string;
60
59
  }
60
+ export interface MetaFilters {
61
+ sort_field: string;
62
+ sort_direction: string;
63
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantcdn/quant-client",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Client library for API connectivity",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",