@openmrp/sdk 0.19.4 → 0.19.6
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/CHANGELOG.md +2 -2
- package/README.md +26 -26
- package/client.d.mts +4 -4
- package/client.d.ts +4 -4
- package/client.js +37 -37
- package/client.mjs +35 -35
- package/core/api-promise.d.mts +2 -2
- package/core/api-promise.d.ts +2 -2
- package/core/error.d.mts +2 -2
- package/core/error.d.ts +2 -2
- package/core/error.js +4 -4
- package/core/error.mjs +2 -2
- package/core/resource.d.mts +3 -3
- package/core/resource.d.ts +3 -3
- package/index.d.mts +3 -3
- package/index.d.ts +3 -3
- package/index.js +4 -4
- package/index.mjs +3 -3
- package/internal/parse.d.mts +2 -2
- package/internal/parse.d.ts +2 -2
- package/internal/shims.js +1 -1
- package/internal/shims.mjs +1 -1
- package/internal/uploads.d.mts +4 -4
- package/internal/uploads.d.ts +4 -4
- package/internal/utils/base64.js +2 -2
- package/internal/utils/base64.mjs +3 -3
- package/internal/utils/log.d.mts +3 -3
- package/internal/utils/log.d.ts +3 -3
- package/internal/utils/path.js +1 -1
- package/internal/utils/path.mjs +2 -2
- package/internal/utils/values.js +5 -5
- package/internal/utils/values.mjs +6 -6
- package/package.json +2 -2
- package/resources/ai/agents.d.mts +2 -6
- package/resources/ai/agents.d.mts.map +1 -1
- package/resources/ai/agents.d.ts +2 -6
- package/resources/ai/agents.d.ts.map +1 -1
- package/resources/ai/ai.d.mts +2 -2
- package/resources/ai/ai.d.mts.map +1 -1
- package/resources/ai/ai.d.ts +2 -2
- package/resources/ai/ai.d.ts.map +1 -1
- package/resources/ai/runs/runs.d.mts +1 -4
- package/resources/ai/runs/runs.d.mts.map +1 -1
- package/resources/ai/runs/runs.d.ts +1 -4
- package/resources/ai/runs/runs.d.ts.map +1 -1
- package/resources/ai/runs/runs.js.map +1 -1
- package/resources/ai/runs/runs.mjs.map +1 -1
- package/resources/catalog/items/actions.d.mts +2 -2
- package/resources/catalog/items/actions.d.mts.map +1 -1
- package/resources/catalog/items/actions.d.ts +2 -2
- package/resources/catalog/items/actions.d.ts.map +1 -1
- package/resources/core/request-logs.d.mts +2 -2
- package/resources/core/request-logs.d.mts.map +1 -1
- package/resources/core/request-logs.d.ts +2 -2
- package/resources/core/request-logs.d.ts.map +1 -1
- package/resources/messaging/conversations/actions.d.mts +2 -2
- package/resources/messaging/conversations/actions.d.mts.map +1 -1
- package/resources/messaging/conversations/actions.d.ts +2 -2
- package/resources/messaging/conversations/actions.d.ts.map +1 -1
- package/resources/messaging/conversations/conversations.d.mts +2 -2
- package/resources/messaging/conversations/conversations.d.mts.map +1 -1
- package/resources/messaging/conversations/conversations.d.ts +2 -2
- package/resources/messaging/conversations/conversations.d.ts.map +1 -1
- package/resources/messaging/conversations/conversations.js.map +1 -1
- package/resources/messaging/conversations/conversations.mjs.map +1 -1
- package/resources/messaging/email-domains/email-domains.d.mts +1 -1
- package/resources/messaging/email-domains/email-domains.d.mts.map +1 -1
- package/resources/messaging/email-domains/email-domains.d.ts +1 -1
- package/resources/messaging/email-domains/email-domains.d.ts.map +1 -1
- package/resources/messaging/email-inboxes.d.mts +8 -8
- package/resources/messaging/email-inboxes.d.mts.map +1 -1
- package/resources/messaging/email-inboxes.d.ts +8 -8
- package/resources/messaging/email-inboxes.d.ts.map +1 -1
- package/resources/messaging/preferences.d.mts +1 -1
- package/resources/messaging/preferences.d.mts.map +1 -1
- package/resources/messaging/preferences.d.ts +1 -1
- package/resources/messaging/preferences.d.ts.map +1 -1
- package/resources/operations/shipments/actions.d.mts +1 -1
- package/resources/operations/shipments/actions.d.mts.map +1 -1
- package/resources/operations/shipments/actions.d.ts +1 -1
- package/resources/operations/shipments/actions.d.ts.map +1 -1
- package/resources/sales/sales-orders/sales-orders.d.mts +4 -4
- package/resources/sales/sales-orders/sales-orders.d.mts.map +1 -1
- package/resources/sales/sales-orders/sales-orders.d.ts +4 -4
- package/resources/sales/sales-orders/sales-orders.d.ts.map +1 -1
- package/resources/sales/volume-discounts.d.mts +4 -4
- package/resources/sales/volume-discounts.d.mts.map +1 -1
- package/resources/sales/volume-discounts.d.ts +4 -4
- package/resources/sales/volume-discounts.d.ts.map +1 -1
- package/src/client.ts +17 -17
- package/src/core/api-promise.ts +4 -4
- package/src/core/error.ts +2 -2
- package/src/core/resource.ts +3 -3
- package/src/index.ts +3 -3
- package/src/internal/parse.ts +2 -2
- package/src/internal/shims.ts +1 -1
- package/src/internal/uploads.ts +5 -5
- package/src/internal/utils/base64.ts +3 -3
- package/src/internal/utils/log.ts +3 -3
- package/src/internal/utils/path.ts +2 -2
- package/src/internal/utils/values.ts +6 -6
- package/src/resources/ai/agents.ts +2 -6
- package/src/resources/ai/ai.ts +2 -2
- package/src/resources/ai/runs/runs.ts +8 -4
- package/src/resources/catalog/items/actions.ts +2 -2
- package/src/resources/core/request-logs.ts +36 -2
- package/src/resources/messaging/conversations/actions.ts +2 -2
- package/src/resources/messaging/conversations/conversations.ts +36 -2
- package/src/resources/messaging/email-domains/email-domains.ts +1 -1
- package/src/resources/messaging/email-inboxes.ts +8 -8
- package/src/resources/messaging/preferences.ts +10 -1
- package/src/resources/operations/shipments/actions.ts +1 -1
- package/src/resources/sales/sales-orders/sales-orders.ts +4 -4
- package/src/resources/sales/volume-discounts.ts +32 -4
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.19.
|
|
3
|
+
## [0.19.6](https://github.com/open-mrp/typescript-sdk/compare/v0.19.5...v0.19.6) (2026-08-23)
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
### Bug Fixes
|
|
7
7
|
|
|
8
|
-
* **sdk:** sync with deployed API v1.
|
|
8
|
+
* **sdk:** sync with deployed API v1.1.6 ([c99ae1a](https://github.com/open-mrp/typescript-sdk/commit/c99ae1a7e2af9ef83ec8f5b0fc35913d77a6fa54))
|
package/README.md
CHANGED
|
@@ -27,9 +27,9 @@ The full API of this library can be found in [api.md](api.md).
|
|
|
27
27
|
|
|
28
28
|
<!-- prettier-ignore -->
|
|
29
29
|
```js
|
|
30
|
-
import
|
|
30
|
+
import OpenMRP from '@openmrp/sdk';
|
|
31
31
|
|
|
32
|
-
const client = new
|
|
32
|
+
const client = new OpenMRP({
|
|
33
33
|
bearerToken: process.env['OPENMRP_API_KEY'], // This is the default and can be omitted
|
|
34
34
|
environment: 'local', // defaults to 'production'
|
|
35
35
|
});
|
|
@@ -45,14 +45,14 @@ This library includes TypeScript definitions for all request params and response
|
|
|
45
45
|
|
|
46
46
|
<!-- prettier-ignore -->
|
|
47
47
|
```ts
|
|
48
|
-
import
|
|
48
|
+
import OpenMRP from '@openmrp/sdk';
|
|
49
49
|
|
|
50
|
-
const client = new
|
|
50
|
+
const client = new OpenMRP({
|
|
51
51
|
bearerToken: process.env['OPENMRP_API_KEY'], // This is the default and can be omitted
|
|
52
52
|
environment: 'local', // defaults to 'production'
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
const listItem:
|
|
55
|
+
const listItem: OpenMRP.Catalog.ListItem = await client.catalog.items.list();
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
|
|
@@ -66,7 +66,7 @@ a subclass of `APIError` will be thrown:
|
|
|
66
66
|
<!-- prettier-ignore -->
|
|
67
67
|
```ts
|
|
68
68
|
const listItem = await client.catalog.items.list().catch(async (err) => {
|
|
69
|
-
if (err instanceof
|
|
69
|
+
if (err instanceof OpenMRP.APIError) {
|
|
70
70
|
console.log(err.status); // 400
|
|
71
71
|
console.log(err.name); // BadRequestError
|
|
72
72
|
console.log(err.headers); // {server: 'nginx', ...}
|
|
@@ -100,7 +100,7 @@ You can use the `maxRetries` option to configure or disable this:
|
|
|
100
100
|
<!-- prettier-ignore -->
|
|
101
101
|
```js
|
|
102
102
|
// Configure the default for all requests:
|
|
103
|
-
const client = new
|
|
103
|
+
const client = new OpenMRP({
|
|
104
104
|
maxRetries: 0, // default is 2
|
|
105
105
|
});
|
|
106
106
|
|
|
@@ -117,7 +117,7 @@ Requests time out after 1 minute by default. You can configure this with a `time
|
|
|
117
117
|
<!-- prettier-ignore -->
|
|
118
118
|
```ts
|
|
119
119
|
// Configure the default for all requests:
|
|
120
|
-
const client = new
|
|
120
|
+
const client = new OpenMRP({
|
|
121
121
|
timeout: 20 * 1000, // 20 seconds (default is 1 minute)
|
|
122
122
|
});
|
|
123
123
|
|
|
@@ -140,9 +140,9 @@ If you need to, you can override it by setting default headers on a per-request
|
|
|
140
140
|
Be aware that doing so may result in incorrect types and other unexpected or undefined behavior in the SDK.
|
|
141
141
|
|
|
142
142
|
```ts
|
|
143
|
-
import
|
|
143
|
+
import OpenMRP from '@openmrp/sdk';
|
|
144
144
|
|
|
145
|
-
const client = new
|
|
145
|
+
const client = new OpenMRP();
|
|
146
146
|
|
|
147
147
|
const listItem = await client.catalog.items.list({
|
|
148
148
|
headers: { 'OpenMRP-Version': 'My-Custom-Value' },
|
|
@@ -161,7 +161,7 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
|
|
|
161
161
|
|
|
162
162
|
<!-- prettier-ignore -->
|
|
163
163
|
```ts
|
|
164
|
-
const client = new
|
|
164
|
+
const client = new OpenMRP();
|
|
165
165
|
|
|
166
166
|
const response = await client.catalog.items.list().asResponse();
|
|
167
167
|
console.log(response.headers.get('X-My-Header'));
|
|
@@ -186,9 +186,9 @@ The log level can be configured in two ways:
|
|
|
186
186
|
2. Using the `logLevel` client option (overrides the environment variable if set)
|
|
187
187
|
|
|
188
188
|
```ts
|
|
189
|
-
import
|
|
189
|
+
import OpenMRP from '@openmrp/sdk';
|
|
190
190
|
|
|
191
|
-
const client = new
|
|
191
|
+
const client = new OpenMRP({
|
|
192
192
|
logLevel: 'debug', // Show all log messages
|
|
193
193
|
});
|
|
194
194
|
```
|
|
@@ -214,13 +214,13 @@ When providing a custom logger, the `logLevel` option still controls which messa
|
|
|
214
214
|
below the configured level will not be sent to your logger.
|
|
215
215
|
|
|
216
216
|
```ts
|
|
217
|
-
import
|
|
217
|
+
import OpenMRP from '@openmrp/sdk';
|
|
218
218
|
import pino from 'pino';
|
|
219
219
|
|
|
220
220
|
const logger = pino();
|
|
221
221
|
|
|
222
|
-
const client = new
|
|
223
|
-
logger: logger.child({ name: '
|
|
222
|
+
const client = new OpenMRP({
|
|
223
|
+
logger: logger.child({ name: 'OpenMRP' }),
|
|
224
224
|
logLevel: 'debug', // Send all messages to pino, allowing it to filter
|
|
225
225
|
});
|
|
226
226
|
```
|
|
@@ -283,10 +283,10 @@ globalThis.fetch = fetch;
|
|
|
283
283
|
Or pass it to the client:
|
|
284
284
|
|
|
285
285
|
```ts
|
|
286
|
-
import
|
|
286
|
+
import OpenMRP from '@openmrp/sdk';
|
|
287
287
|
import fetch from 'my-fetch';
|
|
288
288
|
|
|
289
|
-
const client = new
|
|
289
|
+
const client = new OpenMRP({ fetch });
|
|
290
290
|
```
|
|
291
291
|
|
|
292
292
|
### Fetch options
|
|
@@ -294,9 +294,9 @@ const client = new Openmrp({ fetch });
|
|
|
294
294
|
If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
|
|
295
295
|
|
|
296
296
|
```ts
|
|
297
|
-
import
|
|
297
|
+
import OpenMRP from '@openmrp/sdk';
|
|
298
298
|
|
|
299
|
-
const client = new
|
|
299
|
+
const client = new OpenMRP({
|
|
300
300
|
fetchOptions: {
|
|
301
301
|
// `RequestInit` options
|
|
302
302
|
},
|
|
@@ -311,11 +311,11 @@ options to requests:
|
|
|
311
311
|
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg" align="top" width="18" height="21"> **Node** <sup>[[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]</sup>
|
|
312
312
|
|
|
313
313
|
```ts
|
|
314
|
-
import
|
|
314
|
+
import OpenMRP from '@openmrp/sdk';
|
|
315
315
|
import * as undici from 'undici';
|
|
316
316
|
|
|
317
317
|
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
|
|
318
|
-
const client = new
|
|
318
|
+
const client = new OpenMRP({
|
|
319
319
|
fetchOptions: {
|
|
320
320
|
dispatcher: proxyAgent,
|
|
321
321
|
},
|
|
@@ -325,9 +325,9 @@ const client = new Openmrp({
|
|
|
325
325
|
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg" align="top" width="18" height="21"> **Bun** <sup>[[docs](https://bun.sh/guides/http/proxy)]</sup>
|
|
326
326
|
|
|
327
327
|
```ts
|
|
328
|
-
import
|
|
328
|
+
import OpenMRP from '@openmrp/sdk';
|
|
329
329
|
|
|
330
|
-
const client = new
|
|
330
|
+
const client = new OpenMRP({
|
|
331
331
|
fetchOptions: {
|
|
332
332
|
proxy: 'http://localhost:8888',
|
|
333
333
|
},
|
|
@@ -337,10 +337,10 @@ const client = new Openmrp({
|
|
|
337
337
|
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg" align="top" width="18" height="21"> **Deno** <sup>[[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]</sup>
|
|
338
338
|
|
|
339
339
|
```ts
|
|
340
|
-
import
|
|
340
|
+
import OpenMRP from 'npm:@openmrp/sdk';
|
|
341
341
|
|
|
342
342
|
const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
|
|
343
|
-
const client = new
|
|
343
|
+
const client = new OpenMRP({
|
|
344
344
|
fetchOptions: {
|
|
345
345
|
client: httpClient,
|
|
346
346
|
},
|
package/client.d.mts
CHANGED
|
@@ -106,7 +106,7 @@ export interface ClientOptions {
|
|
|
106
106
|
/**
|
|
107
107
|
* API Client for interfacing with the Openmrp API.
|
|
108
108
|
*/
|
|
109
|
-
export declare class
|
|
109
|
+
export declare class OpenMRP {
|
|
110
110
|
#private;
|
|
111
111
|
bearerToken: string | null;
|
|
112
112
|
openmrpAccountID: string | null;
|
|
@@ -182,9 +182,9 @@ export declare class Openmrp {
|
|
|
182
182
|
private buildHeaders;
|
|
183
183
|
private _makeAbort;
|
|
184
184
|
private buildBody;
|
|
185
|
-
static
|
|
185
|
+
static OpenMRP: typeof OpenMRP;
|
|
186
186
|
static DEFAULT_TIMEOUT: number;
|
|
187
|
-
static
|
|
187
|
+
static OpenMRPError: typeof Errors.OpenMRPError;
|
|
188
188
|
static APIError: typeof Errors.APIError;
|
|
189
189
|
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
190
190
|
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
@@ -224,7 +224,7 @@ export declare class Openmrp {
|
|
|
224
224
|
identity: API.Identity;
|
|
225
225
|
settings: API.Settings;
|
|
226
226
|
}
|
|
227
|
-
export declare namespace
|
|
227
|
+
export declare namespace OpenMRP {
|
|
228
228
|
export type RequestOptions = Opts.RequestOptions;
|
|
229
229
|
export { Auth as Auth };
|
|
230
230
|
export { Core as Core, type Entity as Entity, type ListEntity as ListEntity, type CoreRetrieveSearchParams as CoreRetrieveSearchParams, };
|
package/client.d.ts
CHANGED
|
@@ -106,7 +106,7 @@ export interface ClientOptions {
|
|
|
106
106
|
/**
|
|
107
107
|
* API Client for interfacing with the Openmrp API.
|
|
108
108
|
*/
|
|
109
|
-
export declare class
|
|
109
|
+
export declare class OpenMRP {
|
|
110
110
|
#private;
|
|
111
111
|
bearerToken: string | null;
|
|
112
112
|
openmrpAccountID: string | null;
|
|
@@ -182,9 +182,9 @@ export declare class Openmrp {
|
|
|
182
182
|
private buildHeaders;
|
|
183
183
|
private _makeAbort;
|
|
184
184
|
private buildBody;
|
|
185
|
-
static
|
|
185
|
+
static OpenMRP: typeof OpenMRP;
|
|
186
186
|
static DEFAULT_TIMEOUT: number;
|
|
187
|
-
static
|
|
187
|
+
static OpenMRPError: typeof Errors.OpenMRPError;
|
|
188
188
|
static APIError: typeof Errors.APIError;
|
|
189
189
|
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
190
190
|
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
@@ -224,7 +224,7 @@ export declare class Openmrp {
|
|
|
224
224
|
identity: API.Identity;
|
|
225
225
|
settings: API.Settings;
|
|
226
226
|
}
|
|
227
|
-
export declare namespace
|
|
227
|
+
export declare namespace OpenMRP {
|
|
228
228
|
export type RequestOptions = Opts.RequestOptions;
|
|
229
229
|
export { Auth as Auth };
|
|
230
230
|
export { Core as Core, type Entity as Entity, type ListEntity as ListEntity, type CoreRetrieveSearchParams as CoreRetrieveSearchParams, };
|
package/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
-
var
|
|
3
|
+
var _OpenMRP_instances, _a, _OpenMRP_encoder, _OpenMRP_baseURLOverridden;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.
|
|
5
|
+
exports.OpenMRP = void 0;
|
|
6
6
|
const tslib_1 = require("./internal/tslib.js");
|
|
7
7
|
const uuid_1 = require("./internal/utils/uuid.js");
|
|
8
8
|
const values_1 = require("./internal/utils/values.js");
|
|
@@ -37,7 +37,7 @@ const environments = {
|
|
|
37
37
|
/**
|
|
38
38
|
* API Client for interfacing with the Openmrp API.
|
|
39
39
|
*/
|
|
40
|
-
class
|
|
40
|
+
class OpenMRP {
|
|
41
41
|
/**
|
|
42
42
|
* API Client for interfacing with the Openmrp API.
|
|
43
43
|
*
|
|
@@ -53,8 +53,8 @@ class Openmrp {
|
|
|
53
53
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
54
54
|
*/
|
|
55
55
|
constructor({ baseURL = (0, env_1.readEnv)('OPENMRP_BASE_URL'), bearerToken = (0, env_1.readEnv)('OPENMRP_API_KEY') ?? null, openmrpAccountID = null, ...opts } = {}) {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
_OpenMRP_instances.add(this);
|
|
57
|
+
_OpenMRP_encoder.set(this, void 0);
|
|
58
58
|
this.auth = new API.Auth(this);
|
|
59
59
|
/**
|
|
60
60
|
* Unified free-text search across resource types, returning lightweight entity references.
|
|
@@ -88,7 +88,7 @@ class Openmrp {
|
|
|
88
88
|
environment: opts.environment ?? 'production',
|
|
89
89
|
};
|
|
90
90
|
if (baseURL && opts.environment) {
|
|
91
|
-
throw new Errors.
|
|
91
|
+
throw new Errors.OpenMRPError('Ambiguous URL; The `baseURL` option (or OPENMRP_BASE_URL env var) and the `environment` option are given. If you want to use the environment you must pass baseURL: null');
|
|
92
92
|
}
|
|
93
93
|
this.baseURL = options.baseURL || environments[options.environment || 'production'];
|
|
94
94
|
this.timeout = options.timeout ?? _a.DEFAULT_TIMEOUT /* 1 minute */;
|
|
@@ -103,7 +103,7 @@ class Openmrp {
|
|
|
103
103
|
this.fetchOptions = options.fetchOptions;
|
|
104
104
|
this.maxRetries = options.maxRetries ?? 2;
|
|
105
105
|
this.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
106
|
-
tslib_1.__classPrivateFieldSet(this,
|
|
106
|
+
tslib_1.__classPrivateFieldSet(this, _OpenMRP_encoder, Opts.FallbackEncoder, "f");
|
|
107
107
|
const customHeadersEnv = (0, env_1.readEnv)('OPENMRP_CUSTOM_HEADERS');
|
|
108
108
|
if (customHeadersEnv) {
|
|
109
109
|
const parsed = {};
|
|
@@ -164,7 +164,7 @@ class Openmrp {
|
|
|
164
164
|
return Errors.APIError.generate(status, error, message, headers);
|
|
165
165
|
}
|
|
166
166
|
buildURL(path, query, defaultBaseURL) {
|
|
167
|
-
const baseURL = (!tslib_1.__classPrivateFieldGet(this,
|
|
167
|
+
const baseURL = (!tslib_1.__classPrivateFieldGet(this, _OpenMRP_instances, "m", _OpenMRP_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
|
|
168
168
|
const url = (0, values_1.isAbsoluteURL)(path) ?
|
|
169
169
|
new URL(path)
|
|
170
170
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
@@ -490,38 +490,38 @@ class Openmrp {
|
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
492
|
else {
|
|
493
|
-
return tslib_1.__classPrivateFieldGet(this,
|
|
493
|
+
return tslib_1.__classPrivateFieldGet(this, _OpenMRP_encoder, "f").call(this, { body, headers });
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
|
-
exports.
|
|
498
|
-
_a =
|
|
497
|
+
exports.OpenMRP = OpenMRP;
|
|
498
|
+
_a = OpenMRP, _OpenMRP_encoder = new WeakMap(), _OpenMRP_instances = new WeakSet(), _OpenMRP_baseURLOverridden = function _OpenMRP_baseURLOverridden() {
|
|
499
499
|
return this.baseURL !== environments[this._options.environment || 'production'];
|
|
500
500
|
};
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
501
|
+
OpenMRP.OpenMRP = _a;
|
|
502
|
+
OpenMRP.DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
503
|
+
OpenMRP.OpenMRPError = Errors.OpenMRPError;
|
|
504
|
+
OpenMRP.APIError = Errors.APIError;
|
|
505
|
+
OpenMRP.APIConnectionError = Errors.APIConnectionError;
|
|
506
|
+
OpenMRP.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
507
|
+
OpenMRP.APIUserAbortError = Errors.APIUserAbortError;
|
|
508
|
+
OpenMRP.NotFoundError = Errors.NotFoundError;
|
|
509
|
+
OpenMRP.ConflictError = Errors.ConflictError;
|
|
510
|
+
OpenMRP.RateLimitError = Errors.RateLimitError;
|
|
511
|
+
OpenMRP.BadRequestError = Errors.BadRequestError;
|
|
512
|
+
OpenMRP.AuthenticationError = Errors.AuthenticationError;
|
|
513
|
+
OpenMRP.InternalServerError = Errors.InternalServerError;
|
|
514
|
+
OpenMRP.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
515
|
+
OpenMRP.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
516
|
+
OpenMRP.toFile = Uploads.toFile;
|
|
517
|
+
OpenMRP.Auth = auth_1.Auth;
|
|
518
|
+
OpenMRP.Core = core_1.Core;
|
|
519
|
+
OpenMRP.Catalog = catalog_1.Catalog;
|
|
520
|
+
OpenMRP.AI = ai_1.AI;
|
|
521
|
+
OpenMRP.Messaging = messaging_1.Messaging;
|
|
522
|
+
OpenMRP.Sales = sales_1.Sales;
|
|
523
|
+
OpenMRP.Finance = finance_1.Finance;
|
|
524
|
+
OpenMRP.Operations = operations_1.Operations;
|
|
525
|
+
OpenMRP.Identity = identity_1.Identity;
|
|
526
|
+
OpenMRP.Settings = settings_1.Settings;
|
|
527
527
|
//# sourceMappingURL=client.js.map
|
package/client.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
var
|
|
2
|
+
var _OpenMRP_instances, _a, _OpenMRP_encoder, _OpenMRP_baseURLOverridden;
|
|
3
3
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "./internal/tslib.mjs";
|
|
4
4
|
import { uuid4 } from "./internal/utils/uuid.mjs";
|
|
5
5
|
import { validatePositiveInteger, isAbsoluteURL, safeJSON } from "./internal/utils/values.mjs";
|
|
@@ -34,7 +34,7 @@ const environments = {
|
|
|
34
34
|
/**
|
|
35
35
|
* API Client for interfacing with the Openmrp API.
|
|
36
36
|
*/
|
|
37
|
-
export class
|
|
37
|
+
export class OpenMRP {
|
|
38
38
|
/**
|
|
39
39
|
* API Client for interfacing with the Openmrp API.
|
|
40
40
|
*
|
|
@@ -50,8 +50,8 @@ export class Openmrp {
|
|
|
50
50
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
51
51
|
*/
|
|
52
52
|
constructor({ baseURL = readEnv('OPENMRP_BASE_URL'), bearerToken = readEnv('OPENMRP_API_KEY') ?? null, openmrpAccountID = null, ...opts } = {}) {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
_OpenMRP_instances.add(this);
|
|
54
|
+
_OpenMRP_encoder.set(this, void 0);
|
|
55
55
|
this.auth = new API.Auth(this);
|
|
56
56
|
/**
|
|
57
57
|
* Unified free-text search across resource types, returning lightweight entity references.
|
|
@@ -85,7 +85,7 @@ export class Openmrp {
|
|
|
85
85
|
environment: opts.environment ?? 'production',
|
|
86
86
|
};
|
|
87
87
|
if (baseURL && opts.environment) {
|
|
88
|
-
throw new Errors.
|
|
88
|
+
throw new Errors.OpenMRPError('Ambiguous URL; The `baseURL` option (or OPENMRP_BASE_URL env var) and the `environment` option are given. If you want to use the environment you must pass baseURL: null');
|
|
89
89
|
}
|
|
90
90
|
this.baseURL = options.baseURL || environments[options.environment || 'production'];
|
|
91
91
|
this.timeout = options.timeout ?? _a.DEFAULT_TIMEOUT /* 1 minute */;
|
|
@@ -100,7 +100,7 @@ export class Openmrp {
|
|
|
100
100
|
this.fetchOptions = options.fetchOptions;
|
|
101
101
|
this.maxRetries = options.maxRetries ?? 2;
|
|
102
102
|
this.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
103
|
-
__classPrivateFieldSet(this,
|
|
103
|
+
__classPrivateFieldSet(this, _OpenMRP_encoder, Opts.FallbackEncoder, "f");
|
|
104
104
|
const customHeadersEnv = readEnv('OPENMRP_CUSTOM_HEADERS');
|
|
105
105
|
if (customHeadersEnv) {
|
|
106
106
|
const parsed = {};
|
|
@@ -161,7 +161,7 @@ export class Openmrp {
|
|
|
161
161
|
return Errors.APIError.generate(status, error, message, headers);
|
|
162
162
|
}
|
|
163
163
|
buildURL(path, query, defaultBaseURL) {
|
|
164
|
-
const baseURL = (!__classPrivateFieldGet(this,
|
|
164
|
+
const baseURL = (!__classPrivateFieldGet(this, _OpenMRP_instances, "m", _OpenMRP_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
|
|
165
165
|
const url = isAbsoluteURL(path) ?
|
|
166
166
|
new URL(path)
|
|
167
167
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
@@ -487,37 +487,37 @@ export class Openmrp {
|
|
|
487
487
|
};
|
|
488
488
|
}
|
|
489
489
|
else {
|
|
490
|
-
return __classPrivateFieldGet(this,
|
|
490
|
+
return __classPrivateFieldGet(this, _OpenMRP_encoder, "f").call(this, { body, headers });
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
_a =
|
|
494
|
+
_a = OpenMRP, _OpenMRP_encoder = new WeakMap(), _OpenMRP_instances = new WeakSet(), _OpenMRP_baseURLOverridden = function _OpenMRP_baseURLOverridden() {
|
|
495
495
|
return this.baseURL !== environments[this._options.environment || 'production'];
|
|
496
496
|
};
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
497
|
+
OpenMRP.OpenMRP = _a;
|
|
498
|
+
OpenMRP.DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
499
|
+
OpenMRP.OpenMRPError = Errors.OpenMRPError;
|
|
500
|
+
OpenMRP.APIError = Errors.APIError;
|
|
501
|
+
OpenMRP.APIConnectionError = Errors.APIConnectionError;
|
|
502
|
+
OpenMRP.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
503
|
+
OpenMRP.APIUserAbortError = Errors.APIUserAbortError;
|
|
504
|
+
OpenMRP.NotFoundError = Errors.NotFoundError;
|
|
505
|
+
OpenMRP.ConflictError = Errors.ConflictError;
|
|
506
|
+
OpenMRP.RateLimitError = Errors.RateLimitError;
|
|
507
|
+
OpenMRP.BadRequestError = Errors.BadRequestError;
|
|
508
|
+
OpenMRP.AuthenticationError = Errors.AuthenticationError;
|
|
509
|
+
OpenMRP.InternalServerError = Errors.InternalServerError;
|
|
510
|
+
OpenMRP.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
511
|
+
OpenMRP.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
512
|
+
OpenMRP.toFile = Uploads.toFile;
|
|
513
|
+
OpenMRP.Auth = Auth;
|
|
514
|
+
OpenMRP.Core = Core;
|
|
515
|
+
OpenMRP.Catalog = Catalog;
|
|
516
|
+
OpenMRP.AI = AI;
|
|
517
|
+
OpenMRP.Messaging = Messaging;
|
|
518
|
+
OpenMRP.Sales = Sales;
|
|
519
|
+
OpenMRP.Finance = Finance;
|
|
520
|
+
OpenMRP.Operations = Operations;
|
|
521
|
+
OpenMRP.Identity = Identity;
|
|
522
|
+
OpenMRP.Settings = Settings;
|
|
523
523
|
//# sourceMappingURL=client.mjs.map
|
package/core/api-promise.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type OpenMRP } from "../client.mjs";
|
|
2
2
|
import { type PromiseOrValue } from "../internal/types.mjs";
|
|
3
3
|
import { APIResponseProps } from "../internal/parse.mjs";
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ export declare class APIPromise<T> extends Promise<T> {
|
|
|
10
10
|
private responsePromise;
|
|
11
11
|
private parseResponse;
|
|
12
12
|
private parsedPromise;
|
|
13
|
-
constructor(client:
|
|
13
|
+
constructor(client: OpenMRP, responsePromise: Promise<APIResponseProps>, parseResponse?: (client: OpenMRP, props: APIResponseProps) => PromiseOrValue<T>);
|
|
14
14
|
_thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
|
|
15
15
|
/**
|
|
16
16
|
* Gets the raw `Response` instance instead of parsing the response
|
package/core/api-promise.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type OpenMRP } from "../client.js";
|
|
2
2
|
import { type PromiseOrValue } from "../internal/types.js";
|
|
3
3
|
import { APIResponseProps } from "../internal/parse.js";
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ export declare class APIPromise<T> extends Promise<T> {
|
|
|
10
10
|
private responsePromise;
|
|
11
11
|
private parseResponse;
|
|
12
12
|
private parsedPromise;
|
|
13
|
-
constructor(client:
|
|
13
|
+
constructor(client: OpenMRP, responsePromise: Promise<APIResponseProps>, parseResponse?: (client: OpenMRP, props: APIResponseProps) => PromiseOrValue<T>);
|
|
14
14
|
_thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
|
|
15
15
|
/**
|
|
16
16
|
* Gets the raw `Response` instance instead of parsing the response
|
package/core/error.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class OpenMRPError extends Error {
|
|
2
2
|
}
|
|
3
|
-
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends
|
|
3
|
+
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends OpenMRPError {
|
|
4
4
|
/** HTTP status for the response that caused the error */
|
|
5
5
|
readonly status: TStatus;
|
|
6
6
|
/** HTTP headers for the response that caused the error */
|
package/core/error.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class OpenMRPError extends Error {
|
|
2
2
|
}
|
|
3
|
-
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends
|
|
3
|
+
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends OpenMRPError {
|
|
4
4
|
/** HTTP status for the response that caused the error */
|
|
5
5
|
readonly status: TStatus;
|
|
6
6
|
/** HTTP headers for the response that caused the error */
|
package/core/error.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.InternalServerError = exports.RateLimitError = exports.UnprocessableEntityError = exports.ConflictError = exports.NotFoundError = exports.PermissionDeniedError = exports.AuthenticationError = exports.BadRequestError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIUserAbortError = exports.APIError = exports.
|
|
4
|
+
exports.InternalServerError = exports.RateLimitError = exports.UnprocessableEntityError = exports.ConflictError = exports.NotFoundError = exports.PermissionDeniedError = exports.AuthenticationError = exports.BadRequestError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIUserAbortError = exports.APIError = exports.OpenMRPError = void 0;
|
|
5
5
|
const errors_1 = require("../internal/errors.js");
|
|
6
|
-
class
|
|
6
|
+
class OpenMRPError extends Error {
|
|
7
7
|
}
|
|
8
|
-
exports.
|
|
9
|
-
class APIError extends
|
|
8
|
+
exports.OpenMRPError = OpenMRPError;
|
|
9
|
+
class APIError extends OpenMRPError {
|
|
10
10
|
constructor(status, error, message, headers) {
|
|
11
11
|
super(`${APIError.makeMessage(status, error, message)}`);
|
|
12
12
|
this.status = status;
|
package/core/error.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { castToError } from "../internal/errors.mjs";
|
|
3
|
-
export class
|
|
3
|
+
export class OpenMRPError extends Error {
|
|
4
4
|
}
|
|
5
|
-
export class APIError extends
|
|
5
|
+
export class APIError extends OpenMRPError {
|
|
6
6
|
constructor(status, error, message, headers) {
|
|
7
7
|
super(`${APIError.makeMessage(status, error, message)}`);
|
|
8
8
|
this.status = status;
|
package/core/resource.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OpenMRP } from "../client.mjs";
|
|
2
2
|
export declare abstract class APIResource {
|
|
3
|
-
protected _client:
|
|
4
|
-
constructor(client:
|
|
3
|
+
protected _client: OpenMRP;
|
|
4
|
+
constructor(client: OpenMRP);
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=resource.d.mts.map
|
package/core/resource.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OpenMRP } from "../client.js";
|
|
2
2
|
export declare abstract class APIResource {
|
|
3
|
-
protected _client:
|
|
4
|
-
constructor(client:
|
|
3
|
+
protected _client: OpenMRP;
|
|
4
|
+
constructor(client: OpenMRP);
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=resource.d.ts.map
|
package/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { OpenMRP as default } from "./client.mjs";
|
|
2
2
|
export { type Uploadable, toFile } from "./core/uploads.mjs";
|
|
3
3
|
export { APIPromise } from "./core/api-promise.mjs";
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
4
|
+
export { OpenMRP, type ClientOptions } from "./client.mjs";
|
|
5
|
+
export { OpenMRPError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.mjs";
|
|
6
6
|
//# sourceMappingURL=index.d.mts.map
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { OpenMRP as default } from "./client.js";
|
|
2
2
|
export { type Uploadable, toFile } from "./core/uploads.js";
|
|
3
3
|
export { APIPromise } from "./core/api-promise.js";
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
4
|
+
export { OpenMRP, type ClientOptions } from "./client.js";
|
|
5
|
+
export { OpenMRPError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -4,17 +4,17 @@ exports = module.exports = function (...args) {
|
|
|
4
4
|
return new exports.default(...args)
|
|
5
5
|
}
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.
|
|
7
|
+
exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.OpenMRPError = exports.OpenMRP = exports.APIPromise = exports.toFile = exports.default = void 0;
|
|
8
8
|
var client_1 = require("./client.js");
|
|
9
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_1.
|
|
9
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_1.OpenMRP; } });
|
|
10
10
|
var uploads_1 = require("./core/uploads.js");
|
|
11
11
|
Object.defineProperty(exports, "toFile", { enumerable: true, get: function () { return uploads_1.toFile; } });
|
|
12
12
|
var api_promise_1 = require("./core/api-promise.js");
|
|
13
13
|
Object.defineProperty(exports, "APIPromise", { enumerable: true, get: function () { return api_promise_1.APIPromise; } });
|
|
14
14
|
var client_2 = require("./client.js");
|
|
15
|
-
Object.defineProperty(exports, "
|
|
15
|
+
Object.defineProperty(exports, "OpenMRP", { enumerable: true, get: function () { return client_2.OpenMRP; } });
|
|
16
16
|
var error_1 = require("./core/error.js");
|
|
17
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "OpenMRPError", { enumerable: true, get: function () { return error_1.OpenMRPError; } });
|
|
18
18
|
Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return error_1.APIError; } });
|
|
19
19
|
Object.defineProperty(exports, "APIConnectionError", { enumerable: true, get: function () { return error_1.APIConnectionError; } });
|
|
20
20
|
Object.defineProperty(exports, "APIConnectionTimeoutError", { enumerable: true, get: function () { return error_1.APIConnectionTimeoutError; } });
|