@astermd-hq/sdk 0.0.2 → 0.0.5
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/LICENSE +1 -1
- package/README.md +22 -8
- package/dist/index.cjs +103 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +181 -16
- package/dist/index.d.ts +181 -16
- package/dist/index.js +103 -7
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://www.astermd.com/"><img src="https://raw.githubusercontent.com/astermd/node-sdk/main/.github/assets/astermd-logo.svg" alt="AsterMD" height="48"></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# AsterMD Node.js SDK
|
|
2
6
|
|
|
3
|
-
Slim, framework-agnostic TypeScript SDK for the AsterMD
|
|
7
|
+
Slim, framework-agnostic TypeScript SDK for the [AsterMD](https://www.astermd.com/) telehealth API: sessions, intake forms and orders. AsterMD is a white-label, API-first telehealth platform.
|
|
4
8
|
|
|
5
9
|
- Node `>=22`
|
|
6
10
|
- **Zero runtime dependencies** - the platform `fetch`, `node:crypto`, and `node:fs` only
|
|
@@ -78,7 +82,7 @@ per request throws that cache away.
|
|
|
78
82
|
## Resources
|
|
79
83
|
|
|
80
84
|
`sessions`, `intakeSubmissions`, `carts`, `checkoutEvents`, `teleforms`,
|
|
81
|
-
`patients`, `opportunities`, `treatments`, `doctorsNetworks`, `channels`,
|
|
85
|
+
`patients`, `opportunities`, `treatments`, `coupons`, `doctorsNetworks`, `channels`,
|
|
82
86
|
`products`, `categories`, `labTests`, `medications`, `shippings`,
|
|
83
87
|
`verification`, `geo`.
|
|
84
88
|
|
|
@@ -227,10 +231,10 @@ you prefer.
|
|
|
227
231
|
|
|
228
232
|
## Compliance
|
|
229
233
|
|
|
230
|
-
This SDK is a client for an API that carries personal and
|
|
231
|
-
information
|
|
232
|
-
that depends on your own infrastructure, policies, and agreements. Contact
|
|
233
|
-
|
|
234
|
+
AsterMD follows HIPAA guidelines. This SDK is a client for an API that carries personal and
|
|
235
|
+
protected health information, and using it does not by itself make your application HIPAA
|
|
236
|
+
compliant - that depends on your own infrastructure, policies, and agreements. Contact
|
|
237
|
+
hello@astermd.com regarding a Business Associate Agreement.
|
|
234
238
|
|
|
235
239
|
See [`SECURITY.md`](SECURITY.md) for vulnerability reporting and
|
|
236
240
|
credential-handling guidance.
|
|
@@ -246,8 +250,18 @@ credential-handling guidance.
|
|
|
246
250
|
|
|
247
251
|
## Support
|
|
248
252
|
|
|
249
|
-
Questions, access requests, and licensing enquiries: **
|
|
253
|
+
Questions, access requests, and licensing enquiries: **hello@astermd.com**
|
|
250
254
|
|
|
251
255
|
## License
|
|
252
256
|
|
|
253
|
-
[MIT](LICENSE) © 2026 AsterMD
|
|
257
|
+
[MIT](LICENSE) © 2026 CodeClouds™ DBA AsterMD
|
|
258
|
+
|
|
259
|
+
## Trademarks
|
|
260
|
+
|
|
261
|
+
The AsterMD name and logo are proprietary to AsterMD. The MIT license covers the source code in
|
|
262
|
+
this repository only and does not grant rights to use the AsterMD brand.
|
|
263
|
+
|
|
264
|
+
## About AsterMD
|
|
265
|
+
|
|
266
|
+
AsterMD is a telehealth platform that helps healthcare brands launch and grow virtual care services. It includes intake builders, patient portals and your choice of providers and pharmacy, with no vendor lock-in.
|
|
267
|
+
[astermd.com](https://www.astermd.com/) · hello@astermd.com
|
package/dist/index.cjs
CHANGED
|
@@ -1341,7 +1341,13 @@ var CheckoutEvents = class extends AbstractResource {
|
|
|
1341
1341
|
* Send one call per state the visitor reaches: an upsell offered, then accepted
|
|
1342
1342
|
* or declined, then the order placed or declined. The payload carries whatever
|
|
1343
1343
|
* context that state needs, but it can never override `event` - the state
|
|
1344
|
-
* recorded is always the one you passed explicitly.
|
|
1344
|
+
* recorded is always the one you passed explicitly. For an `OrderPlaced` event,
|
|
1345
|
+
* `data` may include an optional `payment` object describing the settled
|
|
1346
|
+
* payment method: `type` (`paypal` | `apple_pay` | `gpay` | `credit_card` |
|
|
1347
|
+
* `pre_paid`), `pre_auth` (boolean), `pre_auth_qa` and `pre_auth_amount`
|
|
1348
|
+
* (optional), and an optional `card` object (`type` - `amex` | `visa` |
|
|
1349
|
+
* `mastercard` | `discover` | `diners_club` | `jcb`, optional `bin`, required
|
|
1350
|
+
* `exp`).
|
|
1345
1351
|
*
|
|
1346
1352
|
* @param options The session, the new state, and any context for it.
|
|
1347
1353
|
* @returns The updated checkout-event record.
|
|
@@ -1361,6 +1367,60 @@ var CheckoutEvents = class extends AbstractResource {
|
|
|
1361
1367
|
}
|
|
1362
1368
|
};
|
|
1363
1369
|
|
|
1370
|
+
// src/resource/coupons.ts
|
|
1371
|
+
var Coupons = class extends AbstractResource {
|
|
1372
|
+
/**
|
|
1373
|
+
* @param transport The shared transport.
|
|
1374
|
+
*/
|
|
1375
|
+
constructor(transport) {
|
|
1376
|
+
super(transport);
|
|
1377
|
+
}
|
|
1378
|
+
/**
|
|
1379
|
+
* Checks a coupon code against a cart without redeeming it.
|
|
1380
|
+
*
|
|
1381
|
+
* Call this when the shopper applies a code at checkout, before the payment is
|
|
1382
|
+
* created. The server validates the coupon's status, validity window, patient,
|
|
1383
|
+
* products, budget, scope and redemption limits, and prices the cart. The check
|
|
1384
|
+
* has no side effects. Inspect `data()` on the response for the coupon terms,
|
|
1385
|
+
* the price before and after the discount, and the discounted lines. A shopper
|
|
1386
|
+
* who is not a patient yet only fits a coupon open to anyone.
|
|
1387
|
+
*
|
|
1388
|
+
* @param options The code, the cart, and optionally who the shopper is
|
|
1389
|
+
* (`patientId`, `email` or `opportunityId`). Each optional identifier is sent
|
|
1390
|
+
* only when provided.
|
|
1391
|
+
* @returns The coupon check; `data()` holds `coupon_id`, `name`,
|
|
1392
|
+
* `discount_type`, `value`, `tiers`, `default_scope`, `gross_amount_cents`,
|
|
1393
|
+
* `discount_cents`, `amount_cents`, `currency` and the discounted `items`.
|
|
1394
|
+
* @throws {NotFoundError} If no coupon exists with this code.
|
|
1395
|
+
* @throws {ValidationError} If the coupon cannot be used on this cart, or the
|
|
1396
|
+
* cart cannot be priced.
|
|
1397
|
+
* @throws {AuthenticationError} If the credentials are refused.
|
|
1398
|
+
* @throws {ApiError} On any other non-2xx status.
|
|
1399
|
+
* @throws {TransportError} If the request never completed.
|
|
1400
|
+
*/
|
|
1401
|
+
async validate(options) {
|
|
1402
|
+
const body = {
|
|
1403
|
+
code: options.code,
|
|
1404
|
+
items: options.items
|
|
1405
|
+
};
|
|
1406
|
+
if (options.patientId !== void 0) {
|
|
1407
|
+
body.patient_id = options.patientId;
|
|
1408
|
+
}
|
|
1409
|
+
if (options.email !== void 0) {
|
|
1410
|
+
body.email = options.email;
|
|
1411
|
+
}
|
|
1412
|
+
if (options.opportunityId !== void 0) {
|
|
1413
|
+
body.opportunity_id = options.opportunityId;
|
|
1414
|
+
}
|
|
1415
|
+
return await this.transport.send({
|
|
1416
|
+
service: "sales",
|
|
1417
|
+
method: "POST",
|
|
1418
|
+
path: "/coupons/validate",
|
|
1419
|
+
body
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1364
1424
|
// src/resource/doctors-networks.ts
|
|
1365
1425
|
var DoctorsNetworks = class extends AbstractResource {
|
|
1366
1426
|
/**
|
|
@@ -2415,7 +2475,8 @@ var Sessions = class extends AbstractResource {
|
|
|
2415
2475
|
*
|
|
2416
2476
|
* @param session The session identifier to update.
|
|
2417
2477
|
* @param data Fields to record. Forwarded unmodified; see the API reference in
|
|
2418
|
-
* your AsterMD dashboard for the recognised keys.
|
|
2478
|
+
* your AsterMD dashboard for the recognised keys. Accepts the same optional
|
|
2479
|
+
* `verification` object documented on {@link Sessions.create}.
|
|
2419
2480
|
* @returns The updated session.
|
|
2420
2481
|
* @throws {NotFoundError} If the session does not exist.
|
|
2421
2482
|
* @throws {ValidationError} If the payload is rejected.
|
|
@@ -2630,16 +2691,24 @@ var Treatments = class extends AbstractResource {
|
|
|
2630
2691
|
* The alternative to {@link Treatments.create} for flows where checkout happens
|
|
2631
2692
|
* outside your storefront: hand over the session and your order identifiers and
|
|
2632
2693
|
* the server creates the treatments and attributes them to that session's
|
|
2633
|
-
* journey. Several orders can be reconciled in one call.
|
|
2694
|
+
* journey. Several orders can be reconciled in one call. `payment`, when
|
|
2695
|
+
* supplied, carries the settled payment method for the order; `verification`,
|
|
2696
|
+
* when supplied, records identity/contact verification already performed by
|
|
2697
|
+
* the caller.
|
|
2634
2698
|
*
|
|
2635
|
-
* @param options The session, your order identifiers,
|
|
2699
|
+
* @param options The session, your order identifiers, the required user agent,
|
|
2700
|
+
* and optional attribution, payment, and verification details.
|
|
2636
2701
|
* @returns The created treatments.
|
|
2702
|
+
* @throws {TypeError} If `userAgent` is missing or empty.
|
|
2637
2703
|
* @throws {ValidationError} If the session or an order identifier is rejected.
|
|
2638
2704
|
* @throws {NotFoundError} If the session does not exist.
|
|
2639
2705
|
* @throws {ApiError} On any other non-2xx status.
|
|
2640
2706
|
* @throws {TransportError} If the request never completed.
|
|
2641
2707
|
*/
|
|
2642
2708
|
async sync(options) {
|
|
2709
|
+
if (options.userAgent === void 0 || options.userAgent === "") {
|
|
2710
|
+
throw new TypeError("Treatments.sync requires a non-empty userAgent.");
|
|
2711
|
+
}
|
|
2643
2712
|
const body = {
|
|
2644
2713
|
session_id: options.session,
|
|
2645
2714
|
order_ids: options.orderIds
|
|
@@ -2647,13 +2716,35 @@ var Treatments = class extends AbstractResource {
|
|
|
2647
2716
|
if (options.utmSource !== void 0) {
|
|
2648
2717
|
body.utm_source = options.utmSource;
|
|
2649
2718
|
}
|
|
2650
|
-
|
|
2719
|
+
if (options.payment !== void 0) {
|
|
2720
|
+
const payment = {
|
|
2721
|
+
type: options.payment.type,
|
|
2722
|
+
pre_auth: options.payment.preAuth
|
|
2723
|
+
};
|
|
2724
|
+
if (options.payment.preAuthQa !== void 0) {
|
|
2725
|
+
payment.pre_auth_qa = options.payment.preAuthQa;
|
|
2726
|
+
}
|
|
2727
|
+
if (options.payment.preAuthAmount !== void 0) {
|
|
2728
|
+
payment.pre_auth_amount = options.payment.preAuthAmount;
|
|
2729
|
+
}
|
|
2730
|
+
if (options.payment.card !== void 0) {
|
|
2731
|
+
payment.card = options.payment.card;
|
|
2732
|
+
}
|
|
2733
|
+
body.payment = payment;
|
|
2734
|
+
}
|
|
2735
|
+
if (options.verification !== void 0) {
|
|
2736
|
+
body.verification = {
|
|
2737
|
+
email: options.verification.email,
|
|
2738
|
+
address: options.verification.address,
|
|
2739
|
+
...options.verification.id !== void 0 ? { id: options.verification.id } : {}
|
|
2740
|
+
};
|
|
2741
|
+
}
|
|
2651
2742
|
return await this.transport.send({
|
|
2652
2743
|
service: "sales",
|
|
2653
2744
|
method: "POST",
|
|
2654
2745
|
path: "/treatments/sync",
|
|
2655
2746
|
body,
|
|
2656
|
-
headers
|
|
2747
|
+
headers: { "User-Agent": options.userAgent }
|
|
2657
2748
|
});
|
|
2658
2749
|
}
|
|
2659
2750
|
};
|
|
@@ -2773,6 +2864,7 @@ var AsterMDClient = class {
|
|
|
2773
2864
|
#patients;
|
|
2774
2865
|
#opportunities;
|
|
2775
2866
|
#treatments;
|
|
2867
|
+
#coupons;
|
|
2776
2868
|
#doctorsNetworks;
|
|
2777
2869
|
#channels;
|
|
2778
2870
|
#products;
|
|
@@ -2886,6 +2978,10 @@ var AsterMDClient = class {
|
|
|
2886
2978
|
treatments() {
|
|
2887
2979
|
return this.#treatments ??= new Treatments(this.#transport);
|
|
2888
2980
|
}
|
|
2981
|
+
/** Coupons - checking a code the shopper typed against their cart. */
|
|
2982
|
+
coupons() {
|
|
2983
|
+
return this.#coupons ??= new Coupons(this.#transport);
|
|
2984
|
+
}
|
|
2889
2985
|
/** Doctors' networks - handing a case to the clinicians who review it. */
|
|
2890
2986
|
doctorsNetworks() {
|
|
2891
2987
|
return this.#doctorsNetworks ??= new DoctorsNetworks(this.#transport);
|
|
@@ -3307,6 +3403,7 @@ exports.Channels = Channels;
|
|
|
3307
3403
|
exports.CheckoutEvent = CheckoutEvent;
|
|
3308
3404
|
exports.CheckoutEvents = CheckoutEvents;
|
|
3309
3405
|
exports.Config = Config;
|
|
3406
|
+
exports.Coupons = Coupons;
|
|
3310
3407
|
exports.DailyFileLogSink = DailyFileLogSink;
|
|
3311
3408
|
exports.DoctorsNetworks = DoctorsNetworks;
|
|
3312
3409
|
exports.Event = Event;
|