@sera4/essentia 1.1.42 → 1.1.43

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.
@@ -15,7 +15,7 @@ export class TestServerWrapper {
15
15
  this.chai = chai;
16
16
 
17
17
  // Support for older/deprecated apis
18
- const oldAuthHeaders = {field: "Authorization", value: `Token organization_token=${oldAuthToken}`};
18
+ const oldAuthHeaders = {headers: {"Authorization" : `Token organization_token=${oldAuthToken}`}};
19
19
  this.v1 = {
20
20
  get: (url) => this.getWithPrefix("/v1", url, oldAuthHeaders),
21
21
  post: (url) => this.postWithPrefix("/v1", url, oldAuthHeaders),
@@ -58,8 +58,8 @@ export class TestServerWrapper {
58
58
  const request = this.chai.request(this.server).get(`${prefix}${sanitizedUrl}`);
59
59
  this.applyHeaders(request, this.defaultHeaders);
60
60
 
61
- if (options?.field) {
62
- this.applyHeaders(request, {[options.field] : options.value});
61
+ if (options?.headers) {
62
+ this.applyHeaders(request, options.headers);
63
63
  }
64
64
 
65
65
  if (options?.body) {
@@ -77,9 +77,10 @@ export class TestServerWrapper {
77
77
  const request = this.chai.request(this.server).post(`${prefix}${sanitizedUrl}`);
78
78
  this.applyHeaders(request, this.defaultHeaders);
79
79
 
80
- if (options?.field) {
81
- this.applyHeaders(request, {[options.field] : options.value});
80
+ if (options?.headers) {
81
+ this.applyHeaders(request, options.headers);
82
82
  }
83
+
83
84
  return request;
84
85
  }
85
86
 
@@ -92,9 +93,10 @@ export class TestServerWrapper {
92
93
  const request = this.chai.request(this.server).put(`${prefix}${sanitizedUrl}`);
93
94
  this.applyHeaders(request, this.defaultHeaders);
94
95
 
95
- if (options?.field) {
96
- this.applyHeaders(request, {[options.field] : options.value});
96
+ if (options?.headers) {
97
+ this.applyHeaders(request, options.headers);
97
98
  }
99
+
98
100
  return request;
99
101
  }
100
102
 
@@ -107,9 +109,10 @@ export class TestServerWrapper {
107
109
  const request = this.chai.request(this.server).delete(`${prefix}${sanitizedUrl}`);
108
110
  this.applyHeaders(request, this.defaultHeaders);
109
111
 
110
- if (options?.field) {
111
- this.applyHeaders(request, {[options.field] : options.value});
112
+ if (options?.headers) {
113
+ this.applyHeaders(request, options.headers);
112
114
  }
115
+
113
116
  return request;
114
117
  }
115
118
 
@@ -122,8 +125,8 @@ export class TestServerWrapper {
122
125
  const request = this.chai.request(this.server).post(`${prefix}${sanitizedUrl}`);
123
126
  this.applyHeaders(request, this.defaultHeaders);
124
127
 
125
- if (options?.field) {
126
- this.applyHeaders(request, {[options.field] : options.value});
128
+ if (options?.headers) {
129
+ this.applyHeaders(request, options.headers);
127
130
  }
128
131
 
129
132
  request.attach("data", fs.readFileSync(file), {filename: "data"});
@@ -142,13 +145,13 @@ export class TestServerWrapper {
142
145
  return this.routePrinter.getAll();
143
146
  }
144
147
 
145
- withHeader (h) {
148
+ withHeaders (headers) {
146
149
  return {
147
- get: (url, options) => this.get(url, {...h, ...options}),
148
- post: (url, options) => this.post(url, {...h, ...options}),
149
- put: (url, options) => this.put(url, {...h, ...options}),
150
- delete: (url, options) => this.delete(url, {...h, ...options}),
151
- upload: (url, fields, file, options) => this.upload(url, fields, file, {...h, ...options}),
150
+ get: (url, options) => this.get(url, {headers, ...options}),
151
+ post: (url, options) => this.post(url, {headers, ...options}),
152
+ put: (url, options) => this.put(url, {headers, ...options}),
153
+ delete: (url, options) => this.delete(url, {headers, ...options}),
154
+ upload: (url, fields, file, options) => this.upload(url, fields, file, {headers, ...options}),
152
155
  stop: this.stop,
153
156
  allRoutes: this.allRoutes,
154
157
  v1: this.v1
@@ -156,8 +159,8 @@ export class TestServerWrapper {
156
159
  }
157
160
 
158
161
  withMembership (m) {
159
- const h = { field: "tws-membership", value: JSON.stringify(m) }
160
- return this.withHeader(h);
162
+ const h = { "tws-membership" : JSON.stringify(m) }
163
+ return this.withHeaders(h);
161
164
  }
162
165
 
163
166
  withS4 () {
@@ -167,4 +170,4 @@ export class TestServerWrapper {
167
170
  withTap() {
168
171
  return this.withMembership({s4_role: 2, id: uuidv4(), account_id: uuidv4(), tenant_id: uuidv4()});
169
172
  }
170
- }
173
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sera4/essentia",
3
- "version": "1.1.42",
3
+ "version": "1.1.43",
4
4
  "description": "A library of utilities for Teleporte Web Services",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/package.tar.gz CHANGED
Binary file