@edifice.io/rest-client-base 2.5.4-feat-ENABLING-562.20251216121304 → 2.5.4-feat-ENABLING-562.20251216130507
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/browser/index.js +343 -2
- package/dist/browser/src/index.d.ts +2 -0
- package/dist/browser/tsconfig.browser.tsbuildinfo +1 -1
- package/dist/browser/vite.config.browser.d.ts +2 -0
- package/dist/browser/vite.config.node.d.ts +2 -0
- package/dist/browser/vite.config.react-native.d.ts +2 -0
- package/dist/node/index.cjs +1 -0
- package/dist/node/index.js +446 -16
- package/dist/node/src/index.d.ts +2 -0
- package/dist/node/tsconfig.tsbuildinfo +1 -0
- package/dist/node/vite.config.browser.d.ts +2 -0
- package/dist/node/vite.config.node.d.ts +2 -0
- package/dist/node/vite.config.react-native.d.ts +2 -0
- package/dist/react-native/index.js +343 -2
- package/dist/react-native/src/index.d.ts +2 -0
- package/dist/react-native/tsconfig.browser.tsbuildinfo +1 -1
- package/dist/react-native/vite.config.browser.d.ts +2 -0
- package/dist/react-native/vite.config.node.d.ts +2 -0
- package/dist/react-native/vite.config.react-native.d.ts +2 -0
- package/package.json +29 -53
- package/dist/browser/client/adapters/fetch-adapter.js +0 -82
- package/dist/browser/client/adapters/fetch-adapter.js.map +0 -1
- package/dist/browser/client/adapters/http-adapter.js +0 -2
- package/dist/browser/client/adapters/http-adapter.js.map +0 -1
- package/dist/browser/client/adapters/http-service-adapter.js +0 -31
- package/dist/browser/client/adapters/http-service-adapter.js.map +0 -1
- package/dist/browser/client/base-api.client.js +0 -61
- package/dist/browser/client/base-api.client.js.map +0 -1
- package/dist/browser/client/errors/api-error.js +0 -46
- package/dist/browser/client/errors/api-error.js.map +0 -1
- package/dist/browser/client/index.js +0 -6
- package/dist/browser/client/index.js.map +0 -1
- package/dist/browser/decorators/custom-type.decorator.browser.js +0 -10
- package/dist/browser/decorators/custom-type.decorator.browser.js.map +0 -1
- package/dist/browser/decorators/custom-type.decorator.node.js +0 -4
- package/dist/browser/decorators/custom-type.decorator.node.js.map +0 -1
- package/dist/browser/index.d.ts +0 -1
- package/dist/browser/index.js.map +0 -1
- package/dist/node/client/adapters/fetch-adapter.js +0 -86
- package/dist/node/client/adapters/fetch-adapter.js.map +0 -1
- package/dist/node/client/adapters/http-adapter.js +0 -3
- package/dist/node/client/adapters/http-adapter.js.map +0 -1
- package/dist/node/client/adapters/http-service-adapter.js +0 -35
- package/dist/node/client/adapters/http-service-adapter.js.map +0 -1
- package/dist/node/client/base-api.client.js +0 -65
- package/dist/node/client/base-api.client.js.map +0 -1
- package/dist/node/client/errors/api-error.js +0 -50
- package/dist/node/client/errors/api-error.js.map +0 -1
- package/dist/node/client/index.js +0 -22
- package/dist/node/client/index.js.map +0 -1
- package/dist/node/decorators/custom-type.decorator.browser.js +0 -15
- package/dist/node/decorators/custom-type.decorator.browser.js.map +0 -1
- package/dist/node/decorators/custom-type.decorator.node.js +0 -9
- package/dist/node/decorators/custom-type.decorator.node.js.map +0 -1
- package/dist/node/index.d.ts +0 -1
- package/dist/node/index.js.map +0 -1
- package/dist/node/tsconfig.node.tsbuildinfo +0 -1
- package/dist/react-native/client/adapters/fetch-adapter.js +0 -82
- package/dist/react-native/client/adapters/fetch-adapter.js.map +0 -1
- package/dist/react-native/client/adapters/http-adapter.js +0 -2
- package/dist/react-native/client/adapters/http-adapter.js.map +0 -1
- package/dist/react-native/client/adapters/http-service-adapter.js +0 -31
- package/dist/react-native/client/adapters/http-service-adapter.js.map +0 -1
- package/dist/react-native/client/base-api.client.js +0 -61
- package/dist/react-native/client/base-api.client.js.map +0 -1
- package/dist/react-native/client/errors/api-error.js +0 -46
- package/dist/react-native/client/errors/api-error.js.map +0 -1
- package/dist/react-native/client/index.js +0 -6
- package/dist/react-native/client/index.js.map +0 -1
- package/dist/react-native/decorators/custom-type.decorator.browser.js +0 -10
- package/dist/react-native/decorators/custom-type.decorator.browser.js.map +0 -1
- package/dist/react-native/index.d.ts +0 -1
- package/dist/react-native/index.js.map +0 -1
- package/tsconfig.base.json +0 -21
- package/tsconfig.browser.json +0 -13
- package/tsconfig.node.json +0 -11
- /package/dist/browser/{client → src/client}/adapters/fetch-adapter.d.ts +0 -0
- /package/dist/browser/{client → src/client}/adapters/http-adapter.d.ts +0 -0
- /package/dist/browser/{client → src/client}/adapters/http-service-adapter.d.ts +0 -0
- /package/dist/browser/{client → src/client}/base-api.client.d.ts +0 -0
- /package/dist/browser/{client → src/client}/errors/api-error.d.ts +0 -0
- /package/dist/browser/{client → src/client}/index.d.ts +0 -0
- /package/dist/browser/{decorators → src/decorators}/custom-type.decorator.browser.d.ts +0 -0
- /package/dist/browser/{decorators → src/decorators}/custom-type.decorator.node.d.ts +0 -0
- /package/dist/node/{client → src/client}/adapters/fetch-adapter.d.ts +0 -0
- /package/dist/node/{client → src/client}/adapters/http-adapter.d.ts +0 -0
- /package/dist/node/{client → src/client}/adapters/http-service-adapter.d.ts +0 -0
- /package/dist/node/{client → src/client}/base-api.client.d.ts +0 -0
- /package/dist/node/{client → src/client}/errors/api-error.d.ts +0 -0
- /package/dist/node/{client → src/client}/index.d.ts +0 -0
- /package/dist/node/{decorators → src/decorators}/custom-type.decorator.browser.d.ts +0 -0
- /package/dist/node/{decorators → src/decorators}/custom-type.decorator.node.d.ts +0 -0
- /package/dist/react-native/{client → src/client}/adapters/fetch-adapter.d.ts +0 -0
- /package/dist/react-native/{client → src/client}/adapters/http-adapter.d.ts +0 -0
- /package/dist/react-native/{client → src/client}/adapters/http-service-adapter.d.ts +0 -0
- /package/dist/react-native/{client → src/client}/base-api.client.d.ts +0 -0
- /package/dist/react-native/{client → src/client}/errors/api-error.d.ts +0 -0
- /package/dist/react-native/{client → src/client}/index.d.ts +0 -0
- /package/dist/react-native/{decorators → src/decorators}/custom-type.decorator.browser.d.ts +0 -0
- /package/dist/react-native/{decorators → src/decorators}/custom-type.decorator.node.d.ts +0 -0
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,343 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var c = Object.defineProperty;
|
|
2
|
+
var l = (a, t, e) => t in a ? c(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
3
|
+
var h = (a, t, e) => l(a, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
class i extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Create a new API error
|
|
7
|
+
* @param response The original HTTP response
|
|
8
|
+
* @param message Optional custom error message
|
|
9
|
+
*/
|
|
10
|
+
constructor(e, s) {
|
|
11
|
+
super(
|
|
12
|
+
s || `API request failed: ${e.status} ${e.statusText}`
|
|
13
|
+
);
|
|
14
|
+
h(this, "_response");
|
|
15
|
+
h(this, "_jsonData", null);
|
|
16
|
+
h(this, "_textData", null);
|
|
17
|
+
this.name = "ApiError", this._response = e, Object.setPrototypeOf(this, i.prototype);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the original Response object
|
|
21
|
+
* @returns The original Response
|
|
22
|
+
*/
|
|
23
|
+
response() {
|
|
24
|
+
return this._response;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get the HTTP status code
|
|
28
|
+
* @returns The numeric status code (e.g., 404, 500)
|
|
29
|
+
*/
|
|
30
|
+
status() {
|
|
31
|
+
return this._response.status;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the HTTP status text
|
|
35
|
+
* @returns The status text (e.g., "Not Found", "Internal Server Error")
|
|
36
|
+
*/
|
|
37
|
+
statusText() {
|
|
38
|
+
return this._response.statusText;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the response body as JSON
|
|
42
|
+
* @returns Parsed JSON data or null if not available
|
|
43
|
+
* @throws If the response body isn't valid JSON
|
|
44
|
+
*/
|
|
45
|
+
async json() {
|
|
46
|
+
if (this._jsonData === null)
|
|
47
|
+
try {
|
|
48
|
+
const e = this._response.clone();
|
|
49
|
+
this._jsonData = await e.json();
|
|
50
|
+
} catch {
|
|
51
|
+
this._jsonData = null;
|
|
52
|
+
}
|
|
53
|
+
return this._jsonData;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the response body as text
|
|
57
|
+
* @returns Text content or empty string if not available
|
|
58
|
+
*/
|
|
59
|
+
async text() {
|
|
60
|
+
if (this._textData === null)
|
|
61
|
+
try {
|
|
62
|
+
const e = this._response.clone();
|
|
63
|
+
this._textData = await e.text();
|
|
64
|
+
} catch {
|
|
65
|
+
this._textData = "";
|
|
66
|
+
}
|
|
67
|
+
return this._textData;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
class d {
|
|
71
|
+
constructor(t = fetch) {
|
|
72
|
+
this.fetchImpl = t;
|
|
73
|
+
}
|
|
74
|
+
async handleResponse(t) {
|
|
75
|
+
if (!t.ok)
|
|
76
|
+
throw new i(t);
|
|
77
|
+
const e = t.headers.get("content-type");
|
|
78
|
+
return e && e.includes("application/json") ? await t.json() : {};
|
|
79
|
+
}
|
|
80
|
+
async get(t, e) {
|
|
81
|
+
const s = await this.fetchImpl(t, {
|
|
82
|
+
method: "GET",
|
|
83
|
+
headers: e,
|
|
84
|
+
credentials: "include"
|
|
85
|
+
});
|
|
86
|
+
return this.handleResponse(s);
|
|
87
|
+
}
|
|
88
|
+
async post(t, e, s) {
|
|
89
|
+
const r = await this.fetchImpl(t, {
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: {
|
|
92
|
+
"Content-Type": "application/json",
|
|
93
|
+
...s
|
|
94
|
+
},
|
|
95
|
+
body: JSON.stringify(e),
|
|
96
|
+
credentials: "include"
|
|
97
|
+
});
|
|
98
|
+
return this.handleResponse(r);
|
|
99
|
+
}
|
|
100
|
+
async put(t, e, s) {
|
|
101
|
+
const r = await this.fetchImpl(t, {
|
|
102
|
+
method: "PUT",
|
|
103
|
+
headers: {
|
|
104
|
+
"Content-Type": "application/json",
|
|
105
|
+
...s
|
|
106
|
+
},
|
|
107
|
+
body: JSON.stringify(e),
|
|
108
|
+
credentials: "include"
|
|
109
|
+
});
|
|
110
|
+
return this.handleResponse(r);
|
|
111
|
+
}
|
|
112
|
+
async patch(t, e, s) {
|
|
113
|
+
const r = await this.fetchImpl(t, {
|
|
114
|
+
method: "PATCH",
|
|
115
|
+
headers: {
|
|
116
|
+
"Content-Type": "application/json",
|
|
117
|
+
...s
|
|
118
|
+
},
|
|
119
|
+
body: JSON.stringify(e),
|
|
120
|
+
credentials: "include"
|
|
121
|
+
});
|
|
122
|
+
return this.handleResponse(r);
|
|
123
|
+
}
|
|
124
|
+
async delete(t, e) {
|
|
125
|
+
const s = await this.fetchImpl(t, {
|
|
126
|
+
method: "DELETE",
|
|
127
|
+
headers: e,
|
|
128
|
+
credentials: "include"
|
|
129
|
+
});
|
|
130
|
+
return this.handleResponse(s);
|
|
131
|
+
}
|
|
132
|
+
async deleteWithBody(t, e, s) {
|
|
133
|
+
const r = await this.fetchImpl(t, {
|
|
134
|
+
method: "DELETE",
|
|
135
|
+
headers: {
|
|
136
|
+
"Content-Type": "application/json",
|
|
137
|
+
...s
|
|
138
|
+
},
|
|
139
|
+
body: JSON.stringify(e),
|
|
140
|
+
credentials: "include"
|
|
141
|
+
});
|
|
142
|
+
return this.handleResponse(r);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
class u {
|
|
146
|
+
constructor(t) {
|
|
147
|
+
this.httpService = t;
|
|
148
|
+
}
|
|
149
|
+
async get(t, e) {
|
|
150
|
+
const s = e ? { headers: e } : void 0;
|
|
151
|
+
return this.httpService.get(t, s);
|
|
152
|
+
}
|
|
153
|
+
async post(t, e, s) {
|
|
154
|
+
const r = s ? { headers: s } : void 0;
|
|
155
|
+
return this.httpService.postJson(t, e, r);
|
|
156
|
+
}
|
|
157
|
+
async put(t, e, s) {
|
|
158
|
+
const r = s ? { headers: s } : void 0;
|
|
159
|
+
return this.httpService.putJson(t, e, r);
|
|
160
|
+
}
|
|
161
|
+
async patch(t, e, s) {
|
|
162
|
+
const r = s ? { headers: s } : void 0;
|
|
163
|
+
return this.httpService.patchJson(t, e, r);
|
|
164
|
+
}
|
|
165
|
+
async delete(t, e) {
|
|
166
|
+
const s = e ? { headers: e } : void 0;
|
|
167
|
+
return this.httpService.delete(t, s);
|
|
168
|
+
}
|
|
169
|
+
async deleteWithBody(t, e, s) {
|
|
170
|
+
return this.httpService.deleteJson(t, e);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
class o {
|
|
174
|
+
/**
|
|
175
|
+
* Creates a new API client instance
|
|
176
|
+
*
|
|
177
|
+
* @param options Configuration options
|
|
178
|
+
* @param options.baseUrl Base URL for API requests
|
|
179
|
+
* @param options.defaultHeaders Default headers for all requests
|
|
180
|
+
* @param options.fetchImpl Custom fetch implementation (deprecated, use httpAdapter)
|
|
181
|
+
* @param options.httpService Edifice HttpService instance (from odeServices.http())
|
|
182
|
+
* @param options.httpAdapter Custom HTTP adapter implementation
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* // With Edifice HttpService
|
|
186
|
+
* import { odeServices } from '@edifice.io/client';
|
|
187
|
+
*
|
|
188
|
+
* const client = new CommunityClient({
|
|
189
|
+
* httpService: odeServices.http(),
|
|
190
|
+
* defaultHeaders: {
|
|
191
|
+
* 'X-Custom-Header': 'value'
|
|
192
|
+
* }
|
|
193
|
+
* });
|
|
194
|
+
*/
|
|
195
|
+
constructor(t = {}) {
|
|
196
|
+
/**
|
|
197
|
+
* Base URL for all API requests
|
|
198
|
+
* @protected
|
|
199
|
+
*/
|
|
200
|
+
h(this, "baseUrl");
|
|
201
|
+
/**
|
|
202
|
+
* Default headers included with all requests
|
|
203
|
+
* @protected
|
|
204
|
+
*/
|
|
205
|
+
h(this, "defaultHeaders");
|
|
206
|
+
/**
|
|
207
|
+
* HTTP adapter for making requests
|
|
208
|
+
* @protected
|
|
209
|
+
*/
|
|
210
|
+
h(this, "httpAdapter");
|
|
211
|
+
this.baseUrl = t.baseUrl || "", this.defaultHeaders = t.defaultHeaders || {}, t.httpAdapter ? this.httpAdapter = t.httpAdapter : t.httpService ? this.httpAdapter = new u(t.httpService) : this.httpAdapter = new d(t.fetchImpl || fetch);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Performs a GET request
|
|
215
|
+
* @param endpoint API endpoint path
|
|
216
|
+
* @param queryParams URL query parameters
|
|
217
|
+
* @param options Request options
|
|
218
|
+
* @returns Promise resolving to the response data
|
|
219
|
+
*/
|
|
220
|
+
async get(t, e, s) {
|
|
221
|
+
const r = this.buildUrl(t, e);
|
|
222
|
+
return this.httpAdapter.get(r, this.buildHeaders(s == null ? void 0 : s.headers));
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Performs a POST request
|
|
226
|
+
* @param endpoint API endpoint path
|
|
227
|
+
* @param body Request body
|
|
228
|
+
* @param queryParams Optional URL query parameters
|
|
229
|
+
* @param options Request options
|
|
230
|
+
* @returns Promise resolving to the response data
|
|
231
|
+
*/
|
|
232
|
+
async post(t, e, s, r) {
|
|
233
|
+
const n = this.buildUrl(t, s);
|
|
234
|
+
return this.httpAdapter.post(
|
|
235
|
+
n,
|
|
236
|
+
e,
|
|
237
|
+
this.buildHeaders(r == null ? void 0 : r.headers)
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Performs a PUT request
|
|
242
|
+
* @param endpoint API endpoint path
|
|
243
|
+
* @param body Request body
|
|
244
|
+
* @param queryParams Optional URL query parameters
|
|
245
|
+
* @param options Request options
|
|
246
|
+
* @returns Promise resolving to the response data
|
|
247
|
+
*/
|
|
248
|
+
async put(t, e, s, r) {
|
|
249
|
+
const n = this.buildUrl(t, s);
|
|
250
|
+
return this.httpAdapter.put(
|
|
251
|
+
n,
|
|
252
|
+
e,
|
|
253
|
+
this.buildHeaders(r == null ? void 0 : r.headers)
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Performs a PATCH request
|
|
258
|
+
* @param endpoint API endpoint path
|
|
259
|
+
* @param body Request body
|
|
260
|
+
* @param queryParams Optional URL query parameters
|
|
261
|
+
* @param options Request options
|
|
262
|
+
* @returns Promise resolving to the response data
|
|
263
|
+
*/
|
|
264
|
+
async patch(t, e, s, r) {
|
|
265
|
+
const n = this.buildUrl(t, s);
|
|
266
|
+
return this.httpAdapter.patch(
|
|
267
|
+
n,
|
|
268
|
+
e,
|
|
269
|
+
this.buildHeaders(r == null ? void 0 : r.headers)
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Performs a DELETE request
|
|
274
|
+
* @param endpoint API endpoint path
|
|
275
|
+
* @param queryParams Optional URL query parameters
|
|
276
|
+
* @param options Request options
|
|
277
|
+
* @returns Promise resolving when the request is complete
|
|
278
|
+
*/
|
|
279
|
+
async delete(t, e, s) {
|
|
280
|
+
const r = this.buildUrl(t, e);
|
|
281
|
+
return this.httpAdapter.delete(r, this.buildHeaders(s == null ? void 0 : s.headers));
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Performs a DELETE request with body
|
|
285
|
+
* @param endpoint API endpoint path
|
|
286
|
+
* @param body Request body
|
|
287
|
+
* @param queryParams Optional URL query parameters
|
|
288
|
+
* @param options Request options
|
|
289
|
+
* @returns Promise resolving to the response data
|
|
290
|
+
*/
|
|
291
|
+
async deleteWithBody(t, e, s, r) {
|
|
292
|
+
const n = this.buildUrl(t, s);
|
|
293
|
+
return this.httpAdapter.deleteWithBody(
|
|
294
|
+
n,
|
|
295
|
+
e,
|
|
296
|
+
this.buildHeaders(r == null ? void 0 : r.headers)
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Builds complete URL from endpoint and query parameters
|
|
301
|
+
* @param endpoint API endpoint path
|
|
302
|
+
* @param queryParams Optional query parameters
|
|
303
|
+
* @returns Complete URL
|
|
304
|
+
* @protected
|
|
305
|
+
*/
|
|
306
|
+
buildUrl(t, e) {
|
|
307
|
+
let s = `${this.baseUrl}${t}`;
|
|
308
|
+
return s.startsWith("//") && (s = s.replace(/^\/\//, "/")), e && e.toString() && (s += `?${e.toString()}`), s;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Builds headers for a request by combining default and request-specific headers
|
|
312
|
+
* @param additionalHeaders Optional additional headers
|
|
313
|
+
* @returns Combined headers
|
|
314
|
+
* @protected
|
|
315
|
+
*/
|
|
316
|
+
buildHeaders(t) {
|
|
317
|
+
return {
|
|
318
|
+
...this.defaultHeaders,
|
|
319
|
+
...t
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function y(...a) {
|
|
324
|
+
return () => {
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function f(...a) {
|
|
328
|
+
return () => {
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function b(...a) {
|
|
332
|
+
return () => {
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
export {
|
|
336
|
+
i as ApiError,
|
|
337
|
+
f as ApiProperty,
|
|
338
|
+
b as ApiPropertyOptional,
|
|
339
|
+
o as BaseApiClient,
|
|
340
|
+
d as FetchAdapter,
|
|
341
|
+
u as HttpServiceAdapter,
|
|
342
|
+
y as Type
|
|
343
|
+
};
|