@digitalmedika/satusehat 0.1.0

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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +135 -0
  3. package/dist/builders/cbc-panel-builder.d.ts +18 -0
  4. package/dist/builders/laboratory-panel-builder.d.ts +72 -0
  5. package/dist/builders/organization-builder.d.ts +23 -0
  6. package/dist/builders/service-request-specimen-observation-builder.d.ts +62 -0
  7. package/dist/client/auth.d.ts +11 -0
  8. package/dist/client/create-client.d.ts +5 -0
  9. package/dist/client/token-store.d.ts +7 -0
  10. package/dist/client/transport.d.ts +28 -0
  11. package/dist/core/errors.d.ts +25 -0
  12. package/dist/core/types.d.ts +293 -0
  13. package/dist/endpoints/condition.d.ts +945 -0
  14. package/dist/endpoints/diagnostic-report.d.ts +560 -0
  15. package/dist/endpoints/encounter.d.ts +1150 -0
  16. package/dist/endpoints/location.d.ts +500 -0
  17. package/dist/endpoints/medication-request.d.ts +1585 -0
  18. package/dist/endpoints/medication.d.ts +395 -0
  19. package/dist/endpoints/observation.d.ts +1415 -0
  20. package/dist/endpoints/organization.d.ts +454 -0
  21. package/dist/endpoints/patient.d.ts +72 -0
  22. package/dist/endpoints/practitioner-role.d.ts +425 -0
  23. package/dist/endpoints/practitioner.d.ts +210 -0
  24. package/dist/endpoints/procedure.d.ts +990 -0
  25. package/dist/endpoints/service-request.d.ts +1040 -0
  26. package/dist/endpoints/specimen.d.ts +1005 -0
  27. package/dist/index.d.ts +26 -0
  28. package/dist/index.js +21 -0
  29. package/dist/schemas/common.d.ts +328 -0
  30. package/dist/schemas/condition.d.ts +5314 -0
  31. package/dist/schemas/diagnostic-report.d.ts +2631 -0
  32. package/dist/schemas/encounter.d.ts +7087 -0
  33. package/dist/schemas/location.d.ts +2432 -0
  34. package/dist/schemas/medication-request.d.ts +12183 -0
  35. package/dist/schemas/medication.d.ts +2111 -0
  36. package/dist/schemas/observation.d.ts +9253 -0
  37. package/dist/schemas/organization.d.ts +3357 -0
  38. package/dist/schemas/patient.d.ts +418 -0
  39. package/dist/schemas/practitioner-role.d.ts +1930 -0
  40. package/dist/schemas/practitioner.d.ts +1626 -0
  41. package/dist/schemas/procedure.d.ts +5283 -0
  42. package/dist/schemas/service-request.d.ts +5268 -0
  43. package/dist/schemas/specimen.d.ts +6520 -0
  44. package/package.json +61 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Digital Medika
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # @digitalmedika/satusehat
2
+
3
+ Type-safe TypeScript SDK untuk SATUSEHAT API.
4
+
5
+ SDK ini dirancang untuk:
6
+
7
+ - validasi request dan response dengan runtime schema
8
+ - type inference end-to-end di TypeScript
9
+ - OAuth2 client credentials
10
+ - token cache in-memory atau file-based
11
+ - ergonomi SDK yang cocok untuk backend service dan internal tooling
12
+
13
+ ## Helpers
14
+
15
+ Helper builder yang saat ini tersedia:
16
+
17
+ - `createCompleteBloodCountPanelBuilder`
18
+ - `createLaboratoryPanelBuilder`
19
+ - `createOrganizationBuilder`
20
+ - `createServiceRequestSpecimenObservationBuilder`
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ bun add @digitalmedika/satusehat
26
+ ```
27
+
28
+ Untuk development library ini sendiri:
29
+
30
+ ```bash
31
+ bun install
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ```ts
37
+ import { createSatuSehatClientFromEnv } from "@digitalmedika/satusehat";
38
+
39
+ const client = createSatuSehatClientFromEnv();
40
+
41
+ const patient = await client.patient.search({
42
+ identifier: "https://fhir.kemkes.go.id/id/nik|9271060312000001",
43
+ });
44
+ ```
45
+
46
+ ## Environment Variables
47
+
48
+ Salin template dari [.env.example](./.env.example).
49
+
50
+ Variable utama:
51
+
52
+ - `SATUSEHAT_ENV`
53
+ - `SATUSEHAT_BASE_URL`
54
+ - `SATUSEHAT_AUTH_BASE_URL`
55
+ - `SATUSEHAT_CLIENT_ID`
56
+ - `SATUSEHAT_CLIENT_SECRET`
57
+ - `SATUSEHAT_TOKEN_CACHE_FILE`
58
+
59
+ ## Available Resources
60
+
61
+ Saat ini resource yang sudah tersedia:
62
+
63
+ - `condition`
64
+ - `diagnosticReport`
65
+ - `encounter`
66
+ - `observation`
67
+ - `procedure`
68
+ - `medication`
69
+ - `medicationRequest`
70
+ - `serviceRequest`
71
+ - `specimen`
72
+ - `patient`
73
+ - `organization`
74
+ - `location`
75
+ - `practitioner`
76
+ - `practitionerRole`
77
+
78
+ ## Token Handling
79
+
80
+ Secara default SDK mendukung:
81
+
82
+ - token provider berbasis OAuth2 client credentials
83
+ - cache token in-memory
84
+ - file-based token store opsional untuk local testing/internal tools
85
+ - refresh otomatis saat token expired atau mendekati expired
86
+ - retry sekali saat menerima `401` jika token bisa di-invalidasi
87
+
88
+ ## Development
89
+
90
+ ```bash
91
+ bun run typecheck
92
+ bun test
93
+ bun run build
94
+ ```
95
+
96
+ Smoke test ke SATUSEHAT live:
97
+
98
+ ```bash
99
+ bun run smoke:live
100
+ ```
101
+
102
+ Untuk environment `sandbox`, smoke test akan memakai dummy patient resmi SATUSEHAT bila parameter test belum diisi.
103
+
104
+ ## Documentation
105
+
106
+ - [Getting Started](./docs/getting-started.md)
107
+ - [Authentication](./docs/authentication.md)
108
+ - [Errors](./docs/errors.md)
109
+ - [Condition](./docs/resources/condition.md)
110
+ - [DiagnosticReport](./docs/resources/diagnostic-report.md)
111
+ - [Patient](./docs/resources/patient.md)
112
+ - [Encounter](./docs/resources/encounter.md)
113
+ - [Procedure](./docs/resources/procedure.md)
114
+ - [Observation](./docs/resources/observation.md)
115
+ - [Medication](./docs/resources/medication.md)
116
+ - [MedicationRequest](./docs/resources/medication-request.md)
117
+ - [ServiceRequest](./docs/resources/service-request.md)
118
+ - [Specimen](./docs/resources/specimen.md)
119
+ - [ServiceRequest -> Specimen -> Observation Builder](./docs/helpers/service-request-specimen-observation-builder.md)
120
+ - [Laboratory Panel Builder](./docs/helpers/laboratory-panel-builder.md)
121
+ - [CBC Panel Builder](./docs/helpers/cbc-panel-builder.md)
122
+ - [Organization](./docs/resources/organization.md)
123
+ - [Location](./docs/resources/location.md)
124
+ - [Practitioner](./docs/resources/practitioner.md)
125
+ - [PractitionerRole](./docs/resources/practitioner-role.md)
126
+ - [Planning](./docs/planning.md)
127
+
128
+ ## Premium Support
129
+
130
+ Untuk premium support dan implementasi, hubungi:
131
+
132
+ - Email: [info@digitalmedika.co.id](mailto:info@digitalmedika.co.id)
133
+ - WhatsApp: [Digital Medika](https://wa.me/qr/F37IBV5GECN7K1)
134
+
135
+ ![QR WhatsApp Digital Medika](docs/assets/premium-support-whatsapp-qr.jpeg)
@@ -0,0 +1,18 @@
1
+ import { type LaboratoryPanelBuilder } from "./laboratory-panel-builder";
2
+ import type { ObservationCreateInput, ObservationQuantity } from "../schemas/observation";
3
+ import type { Reference } from "../schemas/common";
4
+ import type { DiagnosticReportCreateInput } from "../schemas/diagnostic-report";
5
+ import type { ServiceRequestCreateInput } from "../schemas/service-request";
6
+ import type { SpecimenCreateInput } from "../schemas/specimen";
7
+ export type CompleteBloodCountObservationKey = "wbc" | "rbc" | "hemoglobin" | "hematocrit" | "mcv" | "mch" | "mchc" | "platelets" | "rdw" | "pdw" | "mpv";
8
+ export interface CompleteBloodCountPanelBuilderInput {
9
+ subject: Reference;
10
+ encounter: Reference;
11
+ serviceRequest?: Partial<Omit<ServiceRequestCreateInput, "resourceType" | "subject" | "encounter" | "status" | "intent" | "code">>;
12
+ specimen?: Partial<Omit<SpecimenCreateInput, "resourceType" | "subject" | "status" | "type">>;
13
+ diagnosticReport?: Partial<Omit<DiagnosticReportCreateInput, "resourceType" | "subject" | "encounter" | "status" | "code">>;
14
+ observationDefaults?: Partial<Omit<ObservationCreateInput, "resourceType" | "subject" | "encounter" | "status" | "code">>;
15
+ results?: Partial<Record<CompleteBloodCountObservationKey, number | ObservationQuantity>>;
16
+ includeOptionalObservations?: boolean;
17
+ }
18
+ export declare function createCompleteBloodCountPanelBuilder(input: CompleteBloodCountPanelBuilderInput): LaboratoryPanelBuilder;
@@ -0,0 +1,72 @@
1
+ import type { DiagnosticReportCreateInput } from "../schemas/diagnostic-report";
2
+ import type { ObservationCreateInput, ObservationNote, ObservationQuantity } from "../schemas/observation";
3
+ import type { Reference } from "../schemas/common";
4
+ import type { ServiceRequestCreateInput, ServiceRequestNote } from "../schemas/service-request";
5
+ import type { SpecimenCollection, SpecimenContainer, SpecimenCreateInput, SpecimenNote } from "../schemas/specimen";
6
+ export interface LaboratoryPanelBuilderInput {
7
+ subject: Reference;
8
+ encounter: Reference;
9
+ serviceRequest: Pick<ServiceRequestCreateInput, "status" | "intent" | "code"> & Partial<Omit<ServiceRequestCreateInput, "resourceType" | "subject" | "encounter">>;
10
+ specimen: Pick<SpecimenCreateInput, "status" | "type"> & Partial<Omit<SpecimenCreateInput, "resourceType" | "subject">>;
11
+ diagnosticReport: Pick<DiagnosticReportCreateInput, "status" | "code"> & Partial<Omit<DiagnosticReportCreateInput, "resourceType" | "subject" | "encounter">>;
12
+ observationDefaults?: Partial<Omit<ObservationCreateInput, "resourceType" | "subject" | "encounter" | "status" | "code">>;
13
+ }
14
+ export type LaboratoryPanelObservationInput = Pick<ObservationCreateInput, "status" | "code"> & Partial<Omit<ObservationCreateInput, "resourceType" | "subject" | "encounter" | "status" | "code">>;
15
+ export interface LaboratoryPanelObservationEntry {
16
+ key: string;
17
+ body: ObservationCreateInput;
18
+ }
19
+ export interface LaboratoryPanelServiceRequestLinks {
20
+ serviceRequestId?: string;
21
+ serviceRequestReference?: Reference;
22
+ }
23
+ export interface LaboratoryPanelObservationLinks extends LaboratoryPanelServiceRequestLinks {
24
+ specimenId?: string;
25
+ specimenReference?: Reference;
26
+ }
27
+ export interface LaboratoryPanelDiagnosticReportLinks extends LaboratoryPanelServiceRequestLinks {
28
+ specimenId?: string;
29
+ specimenIds?: string[];
30
+ specimenReference?: Reference;
31
+ specimenReferences?: Reference[];
32
+ resultIds?: string[];
33
+ resultReferences?: Reference[];
34
+ }
35
+ type ServiceRequestMutableInput = Partial<Omit<ServiceRequestCreateInput, "resourceType" | "subject" | "encounter">>;
36
+ type SpecimenMutableInput = Partial<Omit<SpecimenCreateInput, "resourceType" | "subject">>;
37
+ type DiagnosticReportMutableInput = Partial<Omit<DiagnosticReportCreateInput, "resourceType" | "subject" | "encounter">>;
38
+ type ObservationDefaultsInput = Partial<Omit<ObservationCreateInput, "resourceType" | "subject" | "encounter" | "status" | "code">>;
39
+ type ObservationMutableInput = Partial<Omit<ObservationCreateInput, "resourceType" | "subject" | "encounter">>;
40
+ export declare class LaboratoryPanelBuilder {
41
+ private serviceRequestDraft;
42
+ private specimenDraft;
43
+ private diagnosticReportDraft;
44
+ private observationDefaults;
45
+ private observationDrafts;
46
+ constructor(input: LaboratoryPanelBuilderInput);
47
+ setSubject(subject: Reference): this;
48
+ setEncounter(encounter: Reference): this;
49
+ mergeServiceRequest(input: ServiceRequestMutableInput): this;
50
+ mergeSpecimen(input: SpecimenMutableInput): this;
51
+ mergeDiagnosticReport(input: DiagnosticReportMutableInput): this;
52
+ setObservationDefaults(input: ObservationDefaultsInput): this;
53
+ addObservation(key: string, input: LaboratoryPanelObservationInput): this;
54
+ mergeObservation(key: string, input: ObservationMutableInput): this;
55
+ setObservationValueQuantity(key: string, valueQuantity: ObservationQuantity): this;
56
+ addObservationNote(key: string, note: ObservationNote): this;
57
+ addServiceRequestNote(note: ServiceRequestNote): this;
58
+ addSpecimenNote(note: SpecimenNote): this;
59
+ setSpecimenCollection(collection: SpecimenCollection): this;
60
+ addSpecimenContainer(container: SpecimenContainer): this;
61
+ listObservationKeys(): string[];
62
+ buildServiceRequest(): ServiceRequestCreateInput;
63
+ buildSpecimen(links?: LaboratoryPanelServiceRequestLinks): SpecimenCreateInput;
64
+ buildObservation(key: string, links?: LaboratoryPanelObservationLinks): ObservationCreateInput;
65
+ buildObservationEntries(links?: LaboratoryPanelObservationLinks): LaboratoryPanelObservationEntry[];
66
+ buildObservations(links?: LaboratoryPanelObservationLinks): ObservationCreateInput[];
67
+ buildDiagnosticReport(links?: LaboratoryPanelDiagnosticReportLinks): DiagnosticReportCreateInput;
68
+ private createObservationDraft;
69
+ private requireObservationDraft;
70
+ }
71
+ export declare function createLaboratoryPanelBuilder(input: LaboratoryPanelBuilderInput): LaboratoryPanelBuilder;
72
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { OrganizationAddress, OrganizationContact, OrganizationCreateInput, OrganizationIdentifier, OrganizationReference, OrganizationTelecom, OrganizationType } from "../schemas/organization";
2
+ export interface OrganizationBuilderRequiredInput {
3
+ active: boolean;
4
+ identifier: OrganizationIdentifier;
5
+ name: string;
6
+ type: OrganizationType;
7
+ }
8
+ export declare class OrganizationBuilder {
9
+ private draft;
10
+ constructor(input: OrganizationBuilderRequiredInput);
11
+ addAddress(address: OrganizationAddress): this;
12
+ addAlias(alias: string): this;
13
+ addContact(contact: OrganizationContact): this;
14
+ addEndpoint(endpoint: OrganizationReference): this;
15
+ addIdentifier(identifier: OrganizationIdentifier): this;
16
+ addTelecom(telecom: OrganizationTelecom): this;
17
+ addType(type: OrganizationType): this;
18
+ setPartOf(partOf: OrganizationReference): this;
19
+ setActive(active: boolean): this;
20
+ setName(name: string): this;
21
+ build(): OrganizationCreateInput;
22
+ }
23
+ export declare function createOrganizationBuilder(input: OrganizationBuilderRequiredInput): OrganizationBuilder;
@@ -0,0 +1,62 @@
1
+ import type { DiagnosticReportCreateInput } from "../schemas/diagnostic-report";
2
+ import type { ObservationCreateInput, ObservationNote, ObservationQuantity } from "../schemas/observation";
3
+ import type { Reference } from "../schemas/common";
4
+ import type { ServiceRequestCreateInput, ServiceRequestNote } from "../schemas/service-request";
5
+ import type { SpecimenCollection, SpecimenContainer, SpecimenCreateInput, SpecimenNote } from "../schemas/specimen";
6
+ export interface ServiceRequestSpecimenObservationBuilderInput {
7
+ subject: Reference;
8
+ encounter: Reference;
9
+ serviceRequest: Pick<ServiceRequestCreateInput, "status" | "intent" | "code"> & Partial<Omit<ServiceRequestCreateInput, "resourceType" | "subject" | "encounter">>;
10
+ specimen: Pick<SpecimenCreateInput, "status" | "type"> & Partial<Omit<SpecimenCreateInput, "resourceType" | "subject">>;
11
+ observation: Pick<ObservationCreateInput, "status" | "code"> & Partial<Omit<ObservationCreateInput, "resourceType" | "subject" | "encounter">>;
12
+ diagnosticReport?: Pick<DiagnosticReportCreateInput, "status" | "code"> & Partial<Omit<DiagnosticReportCreateInput, "resourceType" | "subject" | "encounter">>;
13
+ }
14
+ export interface ServiceRequestBuildLinks {
15
+ serviceRequestId?: string;
16
+ serviceRequestReference?: Reference;
17
+ }
18
+ export interface ObservationBuildLinks extends ServiceRequestBuildLinks {
19
+ specimenId?: string;
20
+ specimenReference?: Reference;
21
+ }
22
+ export interface DiagnosticReportBuildLinks extends ServiceRequestBuildLinks {
23
+ specimenId?: string;
24
+ specimenIds?: string[];
25
+ specimenReference?: Reference;
26
+ specimenReferences?: Reference[];
27
+ resultId?: string;
28
+ resultIds?: string[];
29
+ resultReference?: Reference;
30
+ resultReferences?: Reference[];
31
+ }
32
+ type ServiceRequestMutableInput = Partial<Omit<ServiceRequestCreateInput, "resourceType" | "subject" | "encounter">>;
33
+ type SpecimenMutableInput = Partial<Omit<SpecimenCreateInput, "resourceType" | "subject">>;
34
+ type ObservationMutableInput = Partial<Omit<ObservationCreateInput, "resourceType" | "subject" | "encounter">>;
35
+ type DiagnosticReportMutableInput = Partial<Omit<DiagnosticReportCreateInput, "resourceType" | "subject" | "encounter">>;
36
+ export declare class ServiceRequestSpecimenObservationBuilder {
37
+ private serviceRequestDraft;
38
+ private specimenDraft;
39
+ private observationDraft;
40
+ private diagnosticReportDraft?;
41
+ constructor(input: ServiceRequestSpecimenObservationBuilderInput);
42
+ setSubject(subject: Reference): this;
43
+ setEncounter(encounter: Reference): this;
44
+ mergeServiceRequest(input: ServiceRequestMutableInput): this;
45
+ mergeSpecimen(input: SpecimenMutableInput): this;
46
+ mergeObservation(input: ObservationMutableInput): this;
47
+ setDiagnosticReport(input: Pick<DiagnosticReportCreateInput, "status" | "code"> & Partial<Omit<DiagnosticReportCreateInput, "resourceType" | "subject" | "encounter">>): this;
48
+ mergeDiagnosticReport(input: DiagnosticReportMutableInput): this;
49
+ addServiceRequestNote(note: ServiceRequestNote): this;
50
+ addSpecimenNote(note: SpecimenNote): this;
51
+ addObservationNote(note: ObservationNote): this;
52
+ setSpecimenCollection(collection: SpecimenCollection): this;
53
+ addSpecimenContainer(container: SpecimenContainer): this;
54
+ setObservationValueQuantity(valueQuantity: ObservationQuantity): this;
55
+ buildServiceRequest(): ServiceRequestCreateInput;
56
+ buildSpecimen(links?: ServiceRequestBuildLinks): SpecimenCreateInput;
57
+ buildObservation(links?: ObservationBuildLinks): ObservationCreateInput;
58
+ buildDiagnosticReport(links?: DiagnosticReportBuildLinks): DiagnosticReportCreateInput;
59
+ private requireDiagnosticReportDraft;
60
+ }
61
+ export declare function createServiceRequestSpecimenObservationBuilder(input: ServiceRequestSpecimenObservationBuilderInput): ServiceRequestSpecimenObservationBuilder;
62
+ export {};
@@ -0,0 +1,11 @@
1
+ import { type FetchLike, type MaybePromise, type OAuthClientCredentials, type TokenStore } from "../core/types";
2
+ export interface ClientCredentialsTokenProviderOptions extends OAuthClientCredentials {
3
+ authBaseUrl: string;
4
+ fetch?: FetchLike;
5
+ headers?: HeadersInit;
6
+ tokenStore?: TokenStore;
7
+ tokenExpiryWindowMs?: number;
8
+ now?: () => number;
9
+ }
10
+ export declare function createClientCredentialsTokenProvider(options: ClientCredentialsTokenProviderOptions): () => Promise<string>;
11
+ export declare function resolveAccessToken(accessToken?: string | (() => MaybePromise<string>)): Promise<string | undefined>;
@@ -0,0 +1,5 @@
1
+ import { type SatuSehatClient, type SatuSehatClientConfig, type SatuSehatEnvironment, type SatuSehatEnvSource } from "../core/types";
2
+ export declare function createSatuSehatClient(config?: SatuSehatClientConfig): SatuSehatClient;
3
+ export declare function createSatuSehatClientFromEnv(env?: SatuSehatEnvSource, overrides?: Omit<SatuSehatClientConfig, "environment" | "baseUrl" | "authBaseUrl" | "credentials">): SatuSehatClient;
4
+ export declare function resolveSatuSehatBaseUrl(environment: SatuSehatEnvironment): string;
5
+ export declare function resolveSatuSehatAuthBaseUrl(environment: SatuSehatEnvironment): string;
@@ -0,0 +1,7 @@
1
+ import type { StoredAccessToken, TokenExpiryCheckOptions, TokenStore } from "../core/types";
2
+ export interface FileTokenStoreOptions {
3
+ filePath: string;
4
+ }
5
+ export declare function createMemoryTokenStore(initialToken?: StoredAccessToken): TokenStore;
6
+ export declare function createFileTokenStore(options: FileTokenStoreOptions): TokenStore;
7
+ export declare function isAccessTokenExpired(token: Pick<StoredAccessToken, "expiresAt">, options?: TokenExpiryCheckOptions): boolean;
@@ -0,0 +1,28 @@
1
+ import { type ZodTypeAny } from "zod";
2
+ import { type AccessTokenProvider, type FetchLike } from "../core/types";
3
+ export interface TransportOptions {
4
+ baseUrl: string;
5
+ accessToken?: AccessTokenProvider;
6
+ invalidateAccessToken?: () => Promise<void>;
7
+ retryOnUnauthorized?: boolean;
8
+ defaultHeaders?: HeadersInit;
9
+ fetch?: FetchLike;
10
+ validateResponse?: boolean;
11
+ }
12
+ export interface RequestOptions<TQuerySchema extends ZodTypeAny | undefined, TBodySchema extends ZodTypeAny | undefined, TResponseSchema extends ZodTypeAny> {
13
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
14
+ path: string;
15
+ query?: unknown;
16
+ querySchema?: TQuerySchema;
17
+ body?: unknown;
18
+ bodySchema?: TBodySchema;
19
+ headers?: HeadersInit;
20
+ signal?: AbortSignal;
21
+ responseSchema: TResponseSchema;
22
+ }
23
+ export interface Transport {
24
+ request<TQuerySchema extends ZodTypeAny | undefined, TBodySchema extends ZodTypeAny | undefined, TResponseSchema extends ZodTypeAny>(options: RequestOptions<TQuerySchema, TBodySchema, TResponseSchema>): Promise<InferSchema<TResponseSchema>>;
25
+ }
26
+ type InferSchema<TSchema extends ZodTypeAny> = TSchema["_output"];
27
+ export declare function createTransport(options: TransportOptions): Transport;
28
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { ZodIssue } from "zod";
2
+ export declare class SatuSehatError extends Error {
3
+ readonly cause?: unknown;
4
+ constructor(message: string, options?: {
5
+ cause?: unknown;
6
+ });
7
+ }
8
+ export declare class SatuSehatConfigError extends SatuSehatError {
9
+ constructor(message: string, options?: {
10
+ cause?: unknown;
11
+ });
12
+ }
13
+ export declare class SatuSehatValidationError extends SatuSehatError {
14
+ readonly issues: ZodIssue[];
15
+ constructor(message: string, issues: ZodIssue[], options?: {
16
+ cause?: unknown;
17
+ });
18
+ }
19
+ export declare class SatuSehatApiError extends SatuSehatError {
20
+ readonly status: number;
21
+ readonly response: unknown;
22
+ constructor(message: string, status: number, response: unknown, options?: {
23
+ cause?: unknown;
24
+ });
25
+ }