@fincuratech/stedi-sdk-js 1.4.2 → 1.6.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.
- package/README.md +36 -0
- package/dist/in-memory.js +228 -0
- package/dist/in-memory.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/client.js +5 -4
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/errors.js +35 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/types/in-memory.d.ts +17 -0
- package/dist/types/in-memory.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/client.d.ts.map +1 -1
- package/dist/types/lib/errors.d.ts +17 -0
- package/dist/types/lib/errors.d.ts.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ TypeScript SDK for [Stedi's EDI Platform and Healthcare APIs](https://www.stedi.
|
|
|
19
19
|
|
|
20
20
|
- [Installation](#installation)
|
|
21
21
|
- [Quick Start](#quick-start)
|
|
22
|
+
- [In-Memory Client (Testing & Local Dev)](#in-memory-client-testing--local-dev)
|
|
22
23
|
- [API Reference](#api-reference)
|
|
23
24
|
- [Eligibility](#eligibility)
|
|
24
25
|
- [Payers](#payers)
|
|
@@ -85,6 +86,41 @@ const eligibilityResult = await stedi.eligibility.check({
|
|
|
85
86
|
console.log(eligibilityResult.benefitsInformation);
|
|
86
87
|
```
|
|
87
88
|
|
|
89
|
+
## In-Memory Client (Testing & Local Dev)
|
|
90
|
+
|
|
91
|
+
`createInMemoryStediClient(options?)` returns a client that satisfies the exact
|
|
92
|
+
same `StediClient` contract as `createStediClient`, but never touches the network:
|
|
93
|
+
writes (`provider.create`, `enrollment.create`, …) land in an in-memory store and
|
|
94
|
+
reads come back from it. Use it to exercise provider/enrollment flows in tests and
|
|
95
|
+
local/dev runs without creating real records in Stedi.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import {
|
|
99
|
+
createInMemoryStediClient,
|
|
100
|
+
createInMemoryStediStore,
|
|
101
|
+
} from '@fincuratech/stedi-sdk-js';
|
|
102
|
+
|
|
103
|
+
// A shared store gives several clients read-after-write consistency
|
|
104
|
+
const store = createInMemoryStediStore();
|
|
105
|
+
const stedi = createInMemoryStediClient({ store });
|
|
106
|
+
|
|
107
|
+
const provider = await stedi.provider.create({
|
|
108
|
+
name: 'Main Street Medical Clinic',
|
|
109
|
+
npi: '1234567890',
|
|
110
|
+
taxId: '123456789',
|
|
111
|
+
taxIdType: 'EIN',
|
|
112
|
+
contacts: [],
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
await stedi.provider.get(provider.id); // resolves from memory
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Everything consumer-specific is injected through `options` (`store`, `seedPayers`,
|
|
119
|
+
`buildEligibilityResponse`, `buildTransactionPage`, `now`); the SDK ships only
|
|
120
|
+
generic, environment-agnostic defaults. **Deciding when to use the real client vs.
|
|
121
|
+
the in-memory one, and providing realistic business fixtures, remains entirely the
|
|
122
|
+
consumer's responsibility** — the SDK has no notion of your environment or payers.
|
|
123
|
+
|
|
88
124
|
## API Reference
|
|
89
125
|
|
|
90
126
|
### Eligibility
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { StediApiError } from './lib/errors.js';
|
|
2
|
+
const PLACEHOLDER_EDI = 'ISA*00* *00* *ZZ*INMEMORY *ZZ*INMEMORY *250101*0000*^*00501*000000001*0*T*:~' +
|
|
3
|
+
'GS*HB*INMEMORY*INMEMORY*20250101*0000*1*X*005010X279A1~' +
|
|
4
|
+
'ST*271*0001~SE*1*0001~GE*1*1~IEA*1*000000001~';
|
|
5
|
+
const DEFAULT_SEED_PAYERS = [
|
|
6
|
+
{
|
|
7
|
+
aliases: ['INMEMORY', 'IMHP'],
|
|
8
|
+
coverageTypes: ['medical'],
|
|
9
|
+
displayName: 'In-Memory Health Plan',
|
|
10
|
+
names: ['In-Memory Health Plan'],
|
|
11
|
+
primaryPayerId: '00001',
|
|
12
|
+
stediId: 'INMEMORY001',
|
|
13
|
+
transactionSupport: {
|
|
14
|
+
claimPayment: 'SUPPORTED',
|
|
15
|
+
claimStatus: 'SUPPORTED',
|
|
16
|
+
claimSubmission: 'SUPPORTED',
|
|
17
|
+
coordinationOfBenefits: 'SUPPORTED',
|
|
18
|
+
eligibilityCheck: 'SUPPORTED',
|
|
19
|
+
institutionalClaimSubmission: 'SUPPORTED',
|
|
20
|
+
professionalClaimSubmission: 'SUPPORTED',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
aliases: ['EXAMPLE', 'EIC'],
|
|
25
|
+
coverageTypes: ['medical'],
|
|
26
|
+
displayName: 'Example Insurance Company',
|
|
27
|
+
names: ['Example Insurance Company'],
|
|
28
|
+
primaryPayerId: '00002',
|
|
29
|
+
stediId: 'INMEMORY002',
|
|
30
|
+
transactionSupport: {
|
|
31
|
+
claimPayment: 'SUPPORTED',
|
|
32
|
+
claimStatus: 'SUPPORTED',
|
|
33
|
+
claimSubmission: 'SUPPORTED',
|
|
34
|
+
coordinationOfBenefits: 'SUPPORTED',
|
|
35
|
+
eligibilityCheck: 'SUPPORTED',
|
|
36
|
+
institutionalClaimSubmission: 'SUPPORTED',
|
|
37
|
+
professionalClaimSubmission: 'SUPPORTED',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
const defaultBuildEligibilityResponse = (input) => ({
|
|
42
|
+
benefitsInformation: [],
|
|
43
|
+
controlNumber: input.controlNumber,
|
|
44
|
+
eligibilitySearchId: `in-memory-eligibility-${input.controlNumber}`,
|
|
45
|
+
errors: [],
|
|
46
|
+
meta: {
|
|
47
|
+
applicationMode: 'inmemory',
|
|
48
|
+
outboundTraceId: `in-memory-${input.controlNumber}`,
|
|
49
|
+
senderId: 'in-memory',
|
|
50
|
+
submitterId: 'in-memory',
|
|
51
|
+
traceId: `in-memory-${input.controlNumber}`,
|
|
52
|
+
},
|
|
53
|
+
payer: {},
|
|
54
|
+
planDateInformation: {},
|
|
55
|
+
planInformation: {},
|
|
56
|
+
provider: {
|
|
57
|
+
entityIdentifier: '',
|
|
58
|
+
entityType: '',
|
|
59
|
+
npi: input.provider.npi,
|
|
60
|
+
providerName: input.provider.organizationName,
|
|
61
|
+
},
|
|
62
|
+
reassociationKey: `in-memory-${input.controlNumber}`,
|
|
63
|
+
subscriber: {},
|
|
64
|
+
tradingPartnerServiceId: input.tradingPartnerServiceId,
|
|
65
|
+
});
|
|
66
|
+
const defaultBuildTransactionPage = () => ({
|
|
67
|
+
items: [],
|
|
68
|
+
});
|
|
69
|
+
export const createInMemoryStediStore = () => ({
|
|
70
|
+
enrollments: new Map(),
|
|
71
|
+
providers: new Map(),
|
|
72
|
+
});
|
|
73
|
+
export const clearInMemoryStediStore = (store) => {
|
|
74
|
+
store.enrollments.clear();
|
|
75
|
+
store.providers.clear();
|
|
76
|
+
};
|
|
77
|
+
export const createInMemoryStediClient = (options) => {
|
|
78
|
+
const store = options?.store ?? createInMemoryStediStore();
|
|
79
|
+
const seedPayers = options?.seedPayers ?? DEFAULT_SEED_PAYERS;
|
|
80
|
+
const buildEligibilityResponse = options?.buildEligibilityResponse ?? defaultBuildEligibilityResponse;
|
|
81
|
+
const buildTransactionPage = options?.buildTransactionPage ?? defaultBuildTransactionPage;
|
|
82
|
+
const now = options?.now ?? (() => new Date().toISOString());
|
|
83
|
+
return {
|
|
84
|
+
downloadFile: async () => PLACEHOLDER_EDI,
|
|
85
|
+
eligibility: {
|
|
86
|
+
check: async (input) => buildEligibilityResponse(input),
|
|
87
|
+
},
|
|
88
|
+
enrollment: {
|
|
89
|
+
create: async (input) => {
|
|
90
|
+
const id = `in-memory-enrollment-${input.provider.id}-${input.payer.idOrAlias}`;
|
|
91
|
+
const linkedProvider = store.providers.get(input.provider.id);
|
|
92
|
+
const existing = store.enrollments.get(id);
|
|
93
|
+
const timestamp = now();
|
|
94
|
+
const created = {
|
|
95
|
+
createdAt: existing?.createdAt ?? timestamp,
|
|
96
|
+
id,
|
|
97
|
+
payer: {
|
|
98
|
+
stediPayerId: input.payer.idOrAlias,
|
|
99
|
+
submittedPayerIdOrAlias: input.payer.idOrAlias,
|
|
100
|
+
},
|
|
101
|
+
primaryContact: input.primaryContact,
|
|
102
|
+
provider: {
|
|
103
|
+
id: input.provider.id,
|
|
104
|
+
name: linkedProvider?.name,
|
|
105
|
+
npi: linkedProvider?.npi,
|
|
106
|
+
taxId: linkedProvider?.taxId,
|
|
107
|
+
taxIdType: linkedProvider?.taxIdType,
|
|
108
|
+
},
|
|
109
|
+
source: input.source,
|
|
110
|
+
status: input.status,
|
|
111
|
+
transactions: input.transactions,
|
|
112
|
+
updatedAt: timestamp,
|
|
113
|
+
userEmail: input.userEmail,
|
|
114
|
+
};
|
|
115
|
+
store.enrollments.set(id, created);
|
|
116
|
+
return created;
|
|
117
|
+
},
|
|
118
|
+
get: async (enrollmentId) => {
|
|
119
|
+
const found = store.enrollments.get(enrollmentId);
|
|
120
|
+
if (!found) {
|
|
121
|
+
throw new StediApiError('Not found', 404, undefined);
|
|
122
|
+
}
|
|
123
|
+
return found;
|
|
124
|
+
},
|
|
125
|
+
list: async (params = {}) => {
|
|
126
|
+
const { payerIds, providerTaxIds, status } = params;
|
|
127
|
+
const items = [...store.enrollments.values()].filter((enrollment) => {
|
|
128
|
+
if (providerTaxIds &&
|
|
129
|
+
(enrollment.provider.taxId === undefined ||
|
|
130
|
+
!providerTaxIds.includes(enrollment.provider.taxId))) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (payerIds && !payerIds.includes(enrollment.payer.stediPayerId)) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (status && !status.includes(enrollment.status)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
});
|
|
141
|
+
return { items, totalCount: items.length };
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
payers: {
|
|
145
|
+
get: async () => [...seedPayers],
|
|
146
|
+
search: async (queryParameters) => {
|
|
147
|
+
const query = typeof queryParameters.query === 'string'
|
|
148
|
+
? queryParameters.query.toLowerCase()
|
|
149
|
+
: undefined;
|
|
150
|
+
const eligibilityCheck = typeof queryParameters.eligibilityCheck === 'string'
|
|
151
|
+
? queryParameters.eligibilityCheck
|
|
152
|
+
: undefined;
|
|
153
|
+
return seedPayers.filter((payer) => {
|
|
154
|
+
if (query !== undefined) {
|
|
155
|
+
const haystack = [
|
|
156
|
+
payer.displayName,
|
|
157
|
+
payer.primaryPayerId,
|
|
158
|
+
payer.stediId,
|
|
159
|
+
...payer.names,
|
|
160
|
+
...payer.aliases,
|
|
161
|
+
]
|
|
162
|
+
.join(' ')
|
|
163
|
+
.toLowerCase();
|
|
164
|
+
if (!haystack.includes(query)) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (eligibilityCheck !== undefined &&
|
|
169
|
+
payer.transactionSupport.eligibilityCheck !== eligibilityCheck) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
return true;
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
provider: {
|
|
177
|
+
create: async (input) => {
|
|
178
|
+
const id = `in-memory-provider-${input.npi}`;
|
|
179
|
+
const existing = store.providers.get(id);
|
|
180
|
+
if (existing) {
|
|
181
|
+
return existing;
|
|
182
|
+
}
|
|
183
|
+
const timestamp = now();
|
|
184
|
+
const created = {
|
|
185
|
+
contacts: input.contacts,
|
|
186
|
+
createdAt: timestamp,
|
|
187
|
+
id,
|
|
188
|
+
name: input.name,
|
|
189
|
+
npi: input.npi,
|
|
190
|
+
taxId: input.taxId,
|
|
191
|
+
taxIdType: input.taxIdType,
|
|
192
|
+
updatedAt: timestamp,
|
|
193
|
+
};
|
|
194
|
+
store.providers.set(id, created);
|
|
195
|
+
return created;
|
|
196
|
+
},
|
|
197
|
+
get: async (providerId) => {
|
|
198
|
+
const found = store.providers.get(providerId);
|
|
199
|
+
if (!found) {
|
|
200
|
+
throw new StediApiError('Not found', 404, undefined);
|
|
201
|
+
}
|
|
202
|
+
return found;
|
|
203
|
+
},
|
|
204
|
+
list: async (params = {}) => {
|
|
205
|
+
const { providerNpis, providerTaxIds } = params;
|
|
206
|
+
const items = [...store.providers.values()]
|
|
207
|
+
.filter((provider) => !providerNpis || providerNpis.includes(provider.npi))
|
|
208
|
+
.filter((provider) => !providerTaxIds || providerTaxIds.includes(provider.taxId))
|
|
209
|
+
.map((provider) => ({
|
|
210
|
+
id: provider.id,
|
|
211
|
+
name: provider.name,
|
|
212
|
+
npi: provider.npi,
|
|
213
|
+
taxId: provider.taxId,
|
|
214
|
+
taxIdType: provider.taxIdType,
|
|
215
|
+
}));
|
|
216
|
+
return { items };
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
transactions: {
|
|
220
|
+
get: async () => {
|
|
221
|
+
throw new StediApiError('Not found', 404, undefined);
|
|
222
|
+
},
|
|
223
|
+
list: async () => buildTransactionPage(),
|
|
224
|
+
search: async () => buildTransactionPage(),
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
//# sourceMappingURL=in-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory.js","sourceRoot":"","sources":["../src/in-memory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA6DhD,MAAM,eAAe,GACnB,8GAA8G;IAC9G,yDAAyD;IACzD,+CAA+C,CAAC;AAKlD,MAAM,mBAAmB,GAAqB;IAC5C;QACE,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC;QAC7B,aAAa,EAAE,CAAC,SAAS,CAAC;QAC1B,WAAW,EAAE,uBAAuB;QACpC,KAAK,EAAE,CAAC,uBAAuB,CAAC;QAChC,cAAc,EA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AAE,EAAE,CAAC,CAAC;oBAClB,EAAE,EAAE,QAAQ,CAAC,EAAE;oBACf,IAAI,EAAE,QAAQ,CAAC,IAAI;oBACnB,GAAG,EAAE,QAAQ,CAAC,GAAG;oBACjB,KAAK,EAAE,QAAQ,CAAC,KAAK;oBACrB,SAAS,EAAE,QAAQ,CAAC,SAAS;iBAC9B,CAAC,CAAC,CAAC;gBAEN,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,CAAC;SACF;QAED,YAAY,EAAE;YACZ,GAAG,EAAE,KAAK,IAA0C,EAAE;gBACpD,MAAM,IAAI,aAAa,CAAC,WAAW,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;YACvD,CAAC;YAED,IAAI,EAAE,KAAK,IAA2C,EAAE,CACtD,oBAAoB,EAAE;YAExB,MAAM,EAAE,KAAK,IAA2C,EAAE,CACxD,oBAAoB,EAAE;SACzB;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { type StediClient } from './index.js';\nimport { StediApiError } from './lib/errors.js';\nimport {\n type StediEligibilityInput,\n type StediEligibilityResponse,\n type StediEnrollmentInput,\n type StediEnrollmentResponse,\n type StediListEnrollmentsParams,\n type StediListEnrollmentsResponse,\n type StediListProvidersParams,\n type StediPayerItem,\n type StediPayerResponse,\n type StediProviderInput,\n type StediProviderListResponse,\n type StediProviderResponse,\n type StediTransactionGetResponse,\n type StediTransactionListResponse,\n} from './lib/types.js';\n\n/**\n * In-memory storage backing a fake Stedi client.\n *\n * The store is the unit of read-after-write consistency: pass the same store to\n * several `createInMemoryStediClient` calls and they all observe the same data;\n * give each a fresh store (the default) and they stay isolated.\n *\n * @property enrollments - Created enrollments, keyed by their deterministic in-memory id.\n * @property providers - Created providers, keyed by their deterministic in-memory id.\n */\nexport type InMemoryStediStore = {\n enrollments: Map<string, StediEnrollmentResponse>;\n providers: Map<string, StediProviderResponse>;\n};\n\n/**\n * Options for {@link createInMemoryStediClient}. Everything specific to a\n * consumer (payers, fixtures, clock) is injected here; the SDK ships only\n * generic, environment-agnostic defaults.\n *\n * @property buildEligibilityResponse - Builds the response returned by `eligibility.check`. Defaults to a deterministic, schema-valid minimal response.\n * @property buildTransactionPage - Builds the page returned by `transactions.list` / `transactions.search`. Defaults to an empty page (`{ items: [] }`).\n * @property now - Clock used for deterministic `createdAt` / `updatedAt` timestamps. Defaults to `() => new Date().toISOString()`.\n * @property seedPayers - Payers returned by `payers.get` and filtered by `payers.search`. Defaults to a couple of generic, plausible payers.\n * @property store - Shared store enabling read-after-write consistency across clients. Defaults to a fresh, isolated store per call.\n */\nexport type InMemoryStediClientOptions = {\n buildEligibilityResponse?: (\n input: StediEligibilityInput,\n ) => StediEligibilityResponse;\n\n buildTransactionPage?: () => StediTransactionListResponse;\n\n now?: () => string;\n\n seedPayers?: StediPayerItem[];\n\n store?: InMemoryStediStore;\n};\n\n/**\n * Placeholder EDI payload returned by the in-memory `downloadFile`.\n */\nconst PLACEHOLDER_EDI =\n 'ISA*00* *00* *ZZ*INMEMORY *ZZ*INMEMORY *250101*0000*^*00501*000000001*0*T*:~' +\n 'GS*HB*INMEMORY*INMEMORY*20250101*0000*1*X*005010X279A1~' +\n 'ST*271*0001~SE*1*0001~GE*1*1~IEA*1*000000001~';\n\n/**\n * Generic, plausible payers used when no `seedPayers` are provided.\n */\nconst DEFAULT_SEED_PAYERS: StediPayerItem[] = [\n {\n aliases: ['INMEMORY', 'IMHP'],\n coverageTypes: ['medical'],\n displayName: 'In-Memory Health Plan',\n names: ['In-Memory Health Plan'],\n primaryPayerId: '00001',\n stediId: 'INMEMORY001',\n transactionSupport: {\n claimPayment: 'SUPPORTED',\n claimStatus: 'SUPPORTED',\n claimSubmission: 'SUPPORTED',\n coordinationOfBenefits: 'SUPPORTED',\n eligibilityCheck: 'SUPPORTED',\n institutionalClaimSubmission: 'SUPPORTED',\n professionalClaimSubmission: 'SUPPORTED',\n },\n },\n {\n aliases: ['EXAMPLE', 'EIC'],\n coverageTypes: ['medical'],\n displayName: 'Example Insurance Company',\n names: ['Example Insurance Company'],\n primaryPayerId: '00002',\n stediId: 'INMEMORY002',\n transactionSupport: {\n claimPayment: 'SUPPORTED',\n claimStatus: 'SUPPORTED',\n claimSubmission: 'SUPPORTED',\n coordinationOfBenefits: 'SUPPORTED',\n eligibilityCheck: 'SUPPORTED',\n institutionalClaimSubmission: 'SUPPORTED',\n professionalClaimSubmission: 'SUPPORTED',\n },\n },\n];\n\n/**\n * Deterministic, schema-valid minimal eligibility response derived from the input.\n *\n * @param input - The eligibility check parameters.\n * @returns A minimal {@link StediEligibilityResponse}.\n */\nconst defaultBuildEligibilityResponse = (\n input: StediEligibilityInput,\n): StediEligibilityResponse => ({\n benefitsInformation: [],\n controlNumber: input.controlNumber,\n eligibilitySearchId: `in-memory-eligibility-${input.controlNumber}`,\n errors: [],\n meta: {\n applicationMode: 'inmemory',\n outboundTraceId: `in-memory-${input.controlNumber}`,\n senderId: 'in-memory',\n submitterId: 'in-memory',\n traceId: `in-memory-${input.controlNumber}`,\n },\n payer: {},\n planDateInformation: {},\n planInformation: {},\n provider: {\n entityIdentifier: '',\n entityType: '',\n npi: input.provider.npi,\n providerName: input.provider.organizationName,\n },\n reassociationKey: `in-memory-${input.controlNumber}`,\n subscriber: {},\n tradingPartnerServiceId: input.tradingPartnerServiceId,\n});\n\n/**\n * Empty transaction page used when no `buildTransactionPage` is provided.\n *\n * @returns An empty {@link StediTransactionListResponse}.\n */\nconst defaultBuildTransactionPage = (): StediTransactionListResponse => ({\n items: [],\n});\n\n/**\n * Create an empty, isolated in-memory store.\n *\n * @returns A fresh {@link InMemoryStediStore}.\n */\nexport const createInMemoryStediStore = (): InMemoryStediStore => ({\n enrollments: new Map(),\n providers: new Map(),\n});\n\n/**\n * Clear every entity from a store in place.\n *\n * Optional convenience for reusing a single shared store across test cases.\n * Creating a fresh store with {@link createInMemoryStediStore} is the primary\n * way to isolate state.\n *\n * @param store - The store to clear.\n */\nexport const clearInMemoryStediStore = (store: InMemoryStediStore): void => {\n store.enrollments.clear();\n store.providers.clear();\n};\n\n/**\n * Create an in-memory double of the Stedi client.\n *\n * The returned client satisfies the exact {@link StediClient} contract but never\n * performs any network or filesystem I/O: writes land in the injected (or\n * default) {@link InMemoryStediStore} and reads come back from it. It carries no\n * notion of environment, production, or any consumer-specific data — the\n * real-vs-fake decision and business fixtures remain the consumer's\n * responsibility.\n *\n * @param [options] - Store, seed payers, response builders and clock overrides.\n * @returns A {@link StediClient} backed entirely by memory.\n */\nexport const createInMemoryStediClient = (\n options?: InMemoryStediClientOptions,\n): StediClient => {\n const store = options?.store ?? createInMemoryStediStore();\n const seedPayers = options?.seedPayers ?? DEFAULT_SEED_PAYERS;\n const buildEligibilityResponse =\n options?.buildEligibilityResponse ?? defaultBuildEligibilityResponse;\n const buildTransactionPage =\n options?.buildTransactionPage ?? defaultBuildTransactionPage;\n const now = options?.now ?? (() => new Date().toISOString());\n\n return {\n downloadFile: async (): Promise<string> => PLACEHOLDER_EDI,\n\n eligibility: {\n check: async (\n input: StediEligibilityInput,\n ): Promise<StediEligibilityResponse> => buildEligibilityResponse(input),\n },\n\n enrollment: {\n create: async (\n input: StediEnrollmentInput,\n ): Promise<StediEnrollmentResponse> => {\n const id = `in-memory-enrollment-${input.provider.id}-${input.payer.idOrAlias}`;\n const linkedProvider = store.providers.get(input.provider.id);\n const existing = store.enrollments.get(id);\n const timestamp = now();\n\n const created: StediEnrollmentResponse = {\n createdAt: existing?.createdAt ?? timestamp,\n id,\n payer: {\n stediPayerId: input.payer.idOrAlias,\n submittedPayerIdOrAlias: input.payer.idOrAlias,\n },\n primaryContact: input.primaryContact,\n provider: {\n id: input.provider.id,\n name: linkedProvider?.name,\n npi: linkedProvider?.npi,\n taxId: linkedProvider?.taxId,\n taxIdType: linkedProvider?.taxIdType,\n },\n source: input.source,\n status: input.status,\n transactions: input.transactions,\n updatedAt: timestamp,\n userEmail: input.userEmail,\n };\n\n store.enrollments.set(id, created);\n\n return created;\n },\n\n get: async (enrollmentId: string): Promise<StediEnrollmentResponse> => {\n const found = store.enrollments.get(enrollmentId);\n\n if (!found) {\n throw new StediApiError('Not found', 404, undefined);\n }\n\n return found;\n },\n\n list: async (\n params: StediListEnrollmentsParams = {},\n ): Promise<StediListEnrollmentsResponse> => {\n const { payerIds, providerTaxIds, status } = params;\n\n const items = [...store.enrollments.values()].filter((enrollment) => {\n if (\n providerTaxIds &&\n (enrollment.provider.taxId === undefined ||\n !providerTaxIds.includes(enrollment.provider.taxId))\n ) {\n return false;\n }\n\n if (payerIds && !payerIds.includes(enrollment.payer.stediPayerId)) {\n return false;\n }\n\n if (status && !status.includes(enrollment.status)) {\n return false;\n }\n\n return true;\n });\n\n return { items, totalCount: items.length };\n },\n },\n\n payers: {\n get: async (): Promise<StediPayerResponse['items']> => [...seedPayers],\n\n search: async (\n queryParameters: Record<string, string[] | number | string>,\n ): Promise<StediPayerResponse['items']> => {\n const query =\n typeof queryParameters.query === 'string'\n ? queryParameters.query.toLowerCase()\n : undefined;\n const eligibilityCheck =\n typeof queryParameters.eligibilityCheck === 'string'\n ? queryParameters.eligibilityCheck\n : undefined;\n\n return seedPayers.filter((payer) => {\n if (query !== undefined) {\n const haystack = [\n payer.displayName,\n payer.primaryPayerId,\n payer.stediId,\n ...payer.names,\n ...payer.aliases,\n ]\n .join(' ')\n .toLowerCase();\n\n if (!haystack.includes(query)) {\n return false;\n }\n }\n\n if (\n eligibilityCheck !== undefined &&\n payer.transactionSupport.eligibilityCheck !== eligibilityCheck\n ) {\n return false;\n }\n\n return true;\n });\n },\n },\n\n provider: {\n create: async (\n input: StediProviderInput,\n ): Promise<StediProviderResponse> => {\n const id = `in-memory-provider-${input.npi}`;\n const existing = store.providers.get(id);\n\n // Idempotent on duplicate NPI: same id, no double entry. Mirrors\n // Stedi's 409-on-duplicate semantics by returning the existing record.\n if (existing) {\n return existing;\n }\n\n const timestamp = now();\n const created: StediProviderResponse = {\n contacts: input.contacts,\n createdAt: timestamp,\n id,\n name: input.name,\n npi: input.npi,\n taxId: input.taxId,\n taxIdType: input.taxIdType,\n updatedAt: timestamp,\n };\n\n store.providers.set(id, created);\n\n return created;\n },\n\n get: async (providerId: string): Promise<StediProviderResponse> => {\n const found = store.providers.get(providerId);\n\n if (!found) {\n throw new StediApiError('Not found', 404, undefined);\n }\n\n return found;\n },\n\n list: async (\n params: StediListProvidersParams = {},\n ): Promise<StediProviderListResponse> => {\n const { providerNpis, providerTaxIds } = params;\n\n const items = [...store.providers.values()]\n .filter(\n (provider) => !providerNpis || providerNpis.includes(provider.npi),\n )\n .filter(\n (provider) =>\n !providerTaxIds || providerTaxIds.includes(provider.taxId),\n )\n .map((provider) => ({\n id: provider.id,\n name: provider.name,\n npi: provider.npi,\n taxId: provider.taxId,\n taxIdType: provider.taxIdType,\n }));\n\n return { items };\n },\n },\n\n transactions: {\n get: async (): Promise<StediTransactionGetResponse> => {\n throw new StediApiError('Not found', 404, undefined);\n },\n\n list: async (): Promise<StediTransactionListResponse> =>\n buildTransactionPage(),\n\n search: async (): Promise<StediTransactionListResponse> =>\n buildTransactionPage(),\n },\n };\n};\n"]}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,8 @@ import { payers } from './endpoints/payers.js';
|
|
|
4
4
|
import { provider } from './endpoints/provider.js';
|
|
5
5
|
import { transactions } from './endpoints/transactions.js';
|
|
6
6
|
import { stediClient } from './lib/client.js';
|
|
7
|
+
export { clearInMemoryStediStore, createInMemoryStediClient, createInMemoryStediStore, } from './in-memory.js';
|
|
8
|
+
export { StediApiError } from './lib/errors.js';
|
|
7
9
|
export { createConsoleLogger, createNoOpLogger, setLogger, } from './lib/logger.js';
|
|
8
10
|
export * from './lib/types.js';
|
|
9
11
|
export const createStediClient = (apiKey) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAEhB,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,EAAE;IAClD,MAAM,WAAW,GAAG,sCAAsC,CAAC;IAC3D,MAAM,iBAAiB,GAAG,4CAA4C,CAAC;IACvE,MAAM,kBAAkB,GAAG,6CAA6C,CAAC;IAEzE,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC;QACnD,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,kBAAkB,CAAC;QAClD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC;QACzC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;QAC9C,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC;KAChD,CAAC;AACJ,CAAC,CAAC;AAIF,eAAe,iBAAiB,CAAC","sourcesContent":["import { eligibility } from './endpoints/eligibility.js';\nimport { enrollment } from './endpoints/enrollment.js';\nimport { payers } from './endpoints/payers.js';\nimport { provider } from './endpoints/provider.js';\nimport { transactions } from './endpoints/transactions.js';\nimport { stediClient } from './lib/client.js';\n\nexport {\n createConsoleLogger,\n createNoOpLogger,\n type Logger,\n setLogger,\n} from './lib/logger.js';\nexport * from './lib/types.js';\n\nexport const createStediClient = (apiKey: string) => {\n const coreBaseUrl = 'https://core.us.stedi.com/2023-08-01';\n const healthcareBaseUrl = 'https://healthcare.us.stedi.com/2024-04-01';\n const enrollmentsBaseUrl = 'https://enrollments.us.stedi.com/2024-09-01';\n\n const client = stediClient(apiKey);\n return {\n downloadFile: client.downloadFile,\n eligibility: eligibility(client, healthcareBaseUrl),\n enrollment: enrollment(client, enrollmentsBaseUrl),\n payers: payers(client, healthcareBaseUrl),\n provider: provider(client, enrollmentsBaseUrl),\n transactions: transactions(client, coreBaseUrl),\n };\n};\n\nexport type StediClient = ReturnType<typeof createStediClient>;\n\nexport default createStediClient;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,GAGzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAuB,MAAM,iBAAiB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAEhB,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,EAAE;IAClD,MAAM,WAAW,GAAG,sCAAsC,CAAC;IAC3D,MAAM,iBAAiB,GAAG,4CAA4C,CAAC;IACvE,MAAM,kBAAkB,GAAG,6CAA6C,CAAC;IAEzE,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC;QACnD,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,kBAAkB,CAAC;QAClD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC;QACzC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;QAC9C,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC;KAChD,CAAC;AACJ,CAAC,CAAC;AAIF,eAAe,iBAAiB,CAAC","sourcesContent":["import { eligibility } from './endpoints/eligibility.js';\nimport { enrollment } from './endpoints/enrollment.js';\nimport { payers } from './endpoints/payers.js';\nimport { provider } from './endpoints/provider.js';\nimport { transactions } from './endpoints/transactions.js';\nimport { stediClient } from './lib/client.js';\n\nexport {\n clearInMemoryStediStore,\n createInMemoryStediClient,\n createInMemoryStediStore,\n type InMemoryStediClientOptions,\n type InMemoryStediStore,\n} from './in-memory.js';\nexport { StediApiError, type StediErrorBody } from './lib/errors.js';\nexport {\n createConsoleLogger,\n createNoOpLogger,\n type Logger,\n setLogger,\n} from './lib/logger.js';\nexport * from './lib/types.js';\n\nexport const createStediClient = (apiKey: string) => {\n const coreBaseUrl = 'https://core.us.stedi.com/2023-08-01';\n const healthcareBaseUrl = 'https://healthcare.us.stedi.com/2024-04-01';\n const enrollmentsBaseUrl = 'https://enrollments.us.stedi.com/2024-09-01';\n\n const client = stediClient(apiKey);\n return {\n downloadFile: client.downloadFile,\n eligibility: eligibility(client, healthcareBaseUrl),\n enrollment: enrollment(client, enrollmentsBaseUrl),\n payers: payers(client, healthcareBaseUrl),\n provider: provider(client, enrollmentsBaseUrl),\n transactions: transactions(client, coreBaseUrl),\n };\n};\n\nexport type StediClient = ReturnType<typeof createStediClient>;\n\nexport default createStediClient;\n"]}
|
package/dist/lib/client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosError } from 'axios';
|
|
2
|
+
import { StediApiError } from './errors.js';
|
|
2
3
|
import { getLogger } from './logger.js';
|
|
3
4
|
export const stediClient = (apiKey) => {
|
|
4
5
|
const defaultHeaders = {
|
|
@@ -27,9 +28,9 @@ export const stediClient = (apiKey) => {
|
|
|
27
28
|
delete error.config;
|
|
28
29
|
delete error.request;
|
|
29
30
|
delete error.response?.request;
|
|
30
|
-
throw new
|
|
31
|
+
throw new StediApiError(`Request to Stedi API failed: ${error.response?.data.message ||
|
|
31
32
|
error.response?.data.detail ||
|
|
32
|
-
error.message}`,
|
|
33
|
+
error.message}`, error.response?.status ?? 0, error.response?.data, error);
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
36
|
throw error;
|
|
@@ -63,9 +64,9 @@ export const stediClient = (apiKey) => {
|
|
|
63
64
|
delete error.config;
|
|
64
65
|
delete error.request;
|
|
65
66
|
delete error.response?.request;
|
|
66
|
-
throw new
|
|
67
|
+
throw new StediApiError(`Request to Stedi API failed: ${error.response?.data.message ||
|
|
67
68
|
error.response?.data.detail ||
|
|
68
|
-
error.message}`,
|
|
69
|
+
error.message}`, error.response?.status ?? 0, error.response?.data, error);
|
|
69
70
|
}
|
|
70
71
|
else {
|
|
71
72
|
throw error;
|
package/dist/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAwC,MAAM,OAAO,CAAC;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAOxC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,EAAE;IAC5C,MAAM,cAAc,GAAG;QACrB,OAAO,EAAE;YACP,aAAa,EAAE,MAAM;YACrB,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC;IAQF,MAAM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ACJ,CAAC,CAAC","sourcesContent":["import axios, { AxiosError, type AxiosRequestConfig, type Method } from 'axios';\n\nimport { StediApiError } from './errors.js';\nimport { getLogger } from './logger.js';\n\n/**\n * Create a client for the Stedi API.\n *\n * @returns The Stedi client.\n */\nexport const stediClient = (apiKey: string) => {\n const defaultHeaders = {\n headers: {\n Authorization: apiKey,\n 'Content-Type': 'application/json',\n },\n };\n\n /**\n * Download a file from the Stedi API.\n *\n * @param url - The URL to download the file from.\n * @returns The file content.\n */\n const downloadFile = async (url: string): Promise<string> => {\n // Validate that the URL is from stedi.com or its subdomains\n const stediUrlRegex = /^https:\\/\\/(?:[\\dA-Za-z-]+\\.)*stedi\\.com\\/.*/u;\n if (!stediUrlRegex.test(url)) {\n throw new Error(\n 'Invalid URL: The URL must be from the Stedi API (stedi.com or its subdomains)',\n );\n }\n\n try {\n const response = await axios.get(url, {\n ...defaultHeaders,\n responseType: 'arraybuffer',\n });\n // Convert buffer to string if it's a buffer\n if (Buffer.isBuffer(response.data)) {\n return response.data.toString('utf8');\n }\n\n return response.data;\n } catch (error) {\n if (error instanceof AxiosError) {\n delete error.config;\n delete error.request;\n delete error.response?.request;\n\n throw new StediApiError(\n `Request to Stedi API failed: ${\n error.response?.data.message ||\n error.response?.data.detail ||\n error.message\n }`,\n error.response?.status ?? 0,\n error.response?.data,\n error,\n );\n } else {\n throw error;\n }\n }\n };\n\n /**\n * Execute a request to the Stedi API.\n *\n * @param baseUrl - The base URL to use.\n * @param method - The HTTP method to use.\n * @param path - The path to request.\n * @param [config] - custom configuration for the request.\n * @returns The result of the request.\n */\n const request = async <T>(\n baseUrl: string,\n method: Method,\n path: string,\n config?: AxiosRequestConfig,\n ): Promise<T> => {\n const log = getLogger();\n\n try {\n log.debug('Stedi API request', { config, method, path });\n\n const response = await axios.request<T>({\n ...config,\n headers: {\n ...defaultHeaders.headers,\n ...config?.headers,\n },\n method,\n // Serialize arrays without brackets\n paramsSerializer: {\n indexes: null,\n },\n url: `${baseUrl}/${path.replace(/^\\//u, '')}`,\n });\n\n log.debug('Stedi API response', {\n data: response.data,\n status: response.status,\n });\n\n return response.data;\n } catch (error) {\n if (error instanceof AxiosError) {\n delete error.config;\n delete error.request;\n delete error.response?.request;\n\n throw new StediApiError(\n `Request to Stedi API failed: ${\n error.response?.data.message ||\n error.response?.data.detail ||\n error.message\n }`,\n error.response?.status ?? 0,\n error.response?.data,\n error,\n );\n } else {\n throw error;\n }\n }\n };\n\n return {\n downloadFile,\n request,\n };\n};\n\nexport type StediClient = ReturnType<typeof stediClient>;\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const extractErrorCode = (body) => {
|
|
2
|
+
if (typeof body !== 'object' || body === null) {
|
|
3
|
+
return undefined;
|
|
4
|
+
}
|
|
5
|
+
const record = body;
|
|
6
|
+
if (typeof record.error === 'string') {
|
|
7
|
+
return record.error;
|
|
8
|
+
}
|
|
9
|
+
if (typeof record.code === 'string') {
|
|
10
|
+
return record.code;
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
const extractResponseMessage = (body) => {
|
|
15
|
+
if (typeof body !== 'object' || body === null) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const candidate = body.message;
|
|
19
|
+
return typeof candidate === 'string' ? candidate : undefined;
|
|
20
|
+
};
|
|
21
|
+
export class StediApiError extends Error {
|
|
22
|
+
errorCode;
|
|
23
|
+
responseBody;
|
|
24
|
+
responseMessage;
|
|
25
|
+
statusCode;
|
|
26
|
+
constructor(message, statusCode, responseBody, cause) {
|
|
27
|
+
super(message, { cause });
|
|
28
|
+
this.name = 'StediApiError';
|
|
29
|
+
this.errorCode = extractErrorCode(responseBody);
|
|
30
|
+
this.responseBody = responseBody;
|
|
31
|
+
this.responseMessage = extractResponseMessage(responseBody);
|
|
32
|
+
this.statusCode = statusCode;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,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Y,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/**\n * Shape of a standard Stedi API error response body.\n *\n * The machine-readable code appears as `error` (per the docs) or `code`\n * (observed on some endpoints like enrollments). `message` is always\n * human-readable. When multiple issues are reported the `errors` array\n * is present, but `error`/`code` and `message` are at the top level.\n */\nexport type StediErrorBody = {\n code?: string;\n error?: string;\n errors?: ReadonlyArray<{ error: string; message: string }>;\n message: string;\n};\n\n/**\n * Extract a machine-readable error code from `error` or `code`,\n * whichever is present (preferring `error`).\n */\nconst extractErrorCode = (body: unknown): string | undefined => {\n if (typeof body !== 'object' || body === null) {\n return undefined;\n }\n\n const record = body as Record<string, unknown>;\n\n if (typeof record.error === 'string') {\n return record.error;\n }\n\n if (typeof record.code === 'string') {\n return record.code;\n }\n\n return undefined;\n};\n\nconst extractResponseMessage = (body: unknown): string | undefined => {\n if (typeof body !== 'object' || body === null) {\n return undefined;\n }\n\n const candidate = (body as Record<string, unknown>).message;\n return typeof candidate === 'string' ? candidate : undefined;\n};\n\nexport class StediApiError extends Error {\n /**\n * Machine-readable error code from the Stedi response, if available.\n * Extracted from the `error` or `code` field of the response body.\n */\n public readonly errorCode: string | undefined;\n\n public readonly responseBody: unknown;\n\n /**\n * The upstream `message` field from the Stedi response body, if present.\n */\n public readonly responseMessage: string | undefined;\n\n public readonly statusCode: number;\n\n constructor(\n message: string,\n statusCode: number,\n responseBody: unknown,\n cause?: unknown,\n ) {\n super(message, { cause });\n this.name = 'StediApiError';\n this.errorCode = extractErrorCode(responseBody);\n this.responseBody = responseBody;\n this.responseMessage = extractResponseMessage(responseBody);\n this.statusCode = statusCode;\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type StediClient } from './index.js';
|
|
2
|
+
import { type StediEligibilityInput, type StediEligibilityResponse, type StediEnrollmentResponse, type StediPayerItem, type StediProviderResponse, type StediTransactionListResponse } from './lib/types.js';
|
|
3
|
+
export type InMemoryStediStore = {
|
|
4
|
+
enrollments: Map<string, StediEnrollmentResponse>;
|
|
5
|
+
providers: Map<string, StediProviderResponse>;
|
|
6
|
+
};
|
|
7
|
+
export type InMemoryStediClientOptions = {
|
|
8
|
+
buildEligibilityResponse?: (input: StediEligibilityInput) => StediEligibilityResponse;
|
|
9
|
+
buildTransactionPage?: () => StediTransactionListResponse;
|
|
10
|
+
now?: () => string;
|
|
11
|
+
seedPayers?: StediPayerItem[];
|
|
12
|
+
store?: InMemoryStediStore;
|
|
13
|
+
};
|
|
14
|
+
export declare const createInMemoryStediStore: () => InMemoryStediStore;
|
|
15
|
+
export declare const clearInMemoryStediStore: (store: InMemoryStediStore) => void;
|
|
16
|
+
export declare const createInMemoryStediClient: (options?: InMemoryStediClientOptions) => StediClient;
|
|
17
|
+
//# sourceMappingURL=in-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../../src/in-memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAE7B,KAAK,uBAAuB,EAI5B,KAAK,cAAc,EAInB,KAAK,qBAAqB,EAE1B,KAAK,4BAA4B,EAClC,MAAM,gBAAgB,CAAC;AAYxB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IAClD,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CAC/C,CAAC;AAaF,MAAM,MAAM,0BAA0B,GAAG;IACvC,wBAAwB,CAAC,EAAE,CACzB,KAAK,EAAE,qBAAqB,KACzB,wBAAwB,CAAC;IAE9B,oBAAoB,CAAC,EAAE,MAAM,4BAA4B,CAAC;IAE1D,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAEnB,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;IAE9B,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B,CAAC;AAkGF,eAAO,MAAM,wBAAwB,QAAO,kBAG1C,CAAC;AAWH,eAAO,MAAM,uBAAuB,GAAI,OAAO,kBAAkB,KAAG,IAGnE,CAAC;AAeF,eAAO,MAAM,yBAAyB,GACpC,UAAU,0BAA0B,KACnC,WAsNF,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { clearInMemoryStediStore, createInMemoryStediClient, createInMemoryStediStore, type InMemoryStediClientOptions, type InMemoryStediStore, } from './in-memory.js';
|
|
2
|
+
export { StediApiError, type StediErrorBody } from './lib/errors.js';
|
|
1
3
|
export { createConsoleLogger, createNoOpLogger, type Logger, setLogger, } from './lib/logger.js';
|
|
2
4
|
export * from './lib/types.js';
|
|
3
5
|
export declare const createStediClient: (apiKey: string) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,MAAM,EACX,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,MAAM,EACX,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;oBAQ5C,CAAF;qBAA2B,CAAC;;;8BAWwM,CAAC;;;CALtO,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE/D,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAc,KAAK,kBAAkB,EAAE,KAAK,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAc,KAAK,kBAAkB,EAAE,KAAK,MAAM,EAAE,MAAM,OAAO,CAAC;AAUhF,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM;wBAcP,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;cAmDlC,CAAC,WACb,MAAM,UACP,MAAM,QACR,MAAM,WACH,kBAAkB,KAC1B,OAAO,CAAC,CAAC,CAAC;CAoDd,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type StediErrorBody = {
|
|
2
|
+
code?: string;
|
|
3
|
+
error?: string;
|
|
4
|
+
errors?: ReadonlyArray<{
|
|
5
|
+
error: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}>;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class StediApiError extends Error {
|
|
11
|
+
readonly errorCode: string | undefined;
|
|
12
|
+
readonly responseBody: unknown;
|
|
13
|
+
readonly responseMessage: string | undefined;
|
|
14
|
+
readonly statusCode: number;
|
|
15
|
+
constructor(message: string, statusCode: number, responseBody: unknown, cause?: unknown);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/lib/errors.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3D,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAiCF,qBAAa,aAAc,SAAQ,KAAK;IAKtC,SAAgB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9C,SAAgB,YAAY,EAAE,OAAO,CAAC;IAKtC,SAAgB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IAEpD,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAGjC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,OAAO,EACrB,KAAK,CAAC,EAAE,OAAO;CASlB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "Fincura Technologies, Inc.",
|
|
3
3
|
"packageManager": "pnpm@10.11.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"axios": "1.13.
|
|
5
|
+
"axios": "1.13.6"
|
|
6
6
|
},
|
|
7
7
|
"description": "Stedi SDK JS",
|
|
8
8
|
"devDependencies": {
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
},
|
|
44
44
|
"type": "module",
|
|
45
45
|
"types": "dist/types/index.d.ts",
|
|
46
|
-
"version": "1.
|
|
46
|
+
"version": "1.6.0"
|
|
47
47
|
}
|