@sera4/essentia 1.1.41 → 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,21 +145,24 @@ export class TestServerWrapper {
142
145
  return this.routePrinter.getAll();
143
146
  }
144
147
 
145
- // Support for injecting certain memberships in every request
146
- withMembership (m) {
147
- const headers = { field: "tws-membership", value: JSON.stringify(m) }
148
+ withHeaders (headers) {
148
149
  return {
149
- get: (url, options) => this.get(url, {...headers, ...options}),
150
- post: (url, options) => this.post(url, {...headers, ...options}),
151
- put: (url, options) => this.put(url, {...headers, ...options}),
152
- delete: (url, options) => this.delete(url, {...headers, ...options}),
153
- upload: (url, fields, file, options) => this.upload(url, fields, file, {...headers, ...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}),
154
155
  stop: this.stop,
155
156
  allRoutes: this.allRoutes,
156
157
  v1: this.v1
157
158
  }
158
159
  }
159
160
 
161
+ withMembership (m) {
162
+ const h = { "tws-membership" : JSON.stringify(m) }
163
+ return this.withHeaders(h);
164
+ }
165
+
160
166
  withS4 () {
161
167
  return this.withMembership({s4_role: 1, id: uuidv4(), account_id: uuidv4(), tenant_id: uuidv4()});
162
168
  }
@@ -164,4 +170,4 @@ export class TestServerWrapper {
164
170
  withTap() {
165
171
  return this.withMembership({s4_role: 2, id: uuidv4(), account_id: uuidv4(), tenant_id: uuidv4()});
166
172
  }
167
- }
173
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sera4/essentia",
3
- "version": "1.1.41",
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