@nymbalhq/contract-tests 1.3.0 → 1.5.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/dist/{chunk-ABEL44IM.js → chunk-KK53D2KL.js} +1 -2
- package/dist/{chunk-ABEL44IM.js.map → chunk-KK53D2KL.js.map} +1 -1
- package/dist/index.d.ts +62 -8
- package/dist/index.js +964 -357
- package/dist/index.js.map +1 -1
- package/dist/kinds.d.ts +1 -1
- package/dist/kinds.js +1 -1
- package/package.json +2 -2
|
@@ -7,7 +7,6 @@ var CONTRACT_KINDS = [
|
|
|
7
7
|
"analytics",
|
|
8
8
|
"shipping",
|
|
9
9
|
"tax",
|
|
10
|
-
"ai",
|
|
11
10
|
"documentStore",
|
|
12
11
|
"eventBus",
|
|
13
12
|
"media"
|
|
@@ -16,4 +15,4 @@ var CONTRACT_KINDS = [
|
|
|
16
15
|
export {
|
|
17
16
|
CONTRACT_KINDS
|
|
18
17
|
};
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
18
|
+
//# sourceMappingURL=chunk-KK53D2KL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/kinds.ts"],"sourcesContent":["import type { Slot } from '@nymbalhq/types'\n\n// Its own entry (`@nymbalhq/contract-tests/kinds`), free of vitest: the CLI reads it in its own process, where\n// importing vitest outside a test run throws.\n\n/** The kinds `contractSuites` has a suite for. */\nexport const CONTRACT_KINDS = [\n 'payments',\n 'email',\n 'reviews',\n 'search',\n 'analytics',\n 'shipping',\n 'tax',\n '
|
|
1
|
+
{"version":3,"sources":["../src/kinds.ts"],"sourcesContent":["import type { Slot } from '@nymbalhq/types'\n\n// Its own entry (`@nymbalhq/contract-tests/kinds`), free of vitest: the CLI reads it in its own process, where\n// importing vitest outside a test run throws.\n\n/** The kinds `contractSuites` has a suite for. */\nexport const CONTRACT_KINDS = [\n 'payments',\n 'email',\n 'reviews',\n 'search',\n 'analytics',\n 'shipping',\n 'tax',\n 'documentStore',\n 'eventBus',\n 'media',\n] as const satisfies readonly Slot[]\n"],"mappings":";AAMO,IAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Slot, AdapterContext, DocumentStoreAdapter, EventBusAdapter, MediaStorage, PaymentsAdapter, EmailAdapter, ReviewsAdapter, SearchAdapter, SearchDocument, AnalyticsAdapter, ShippingAdapter, TaxAdapter,
|
|
1
|
+
import { Slot, AdapterContext, DocumentStoreAdapter, EventBusAdapter, MediaStorage, PaymentsAdapter, EmailAdapter, ReviewsAdapter, SearchAdapter, SearchDocument, AnalyticsAdapter, ShippingAdapter, TaxAdapter, WebhookHeaders, CommerceAdapter, SecurityAdapter, NymbalEvent } from '@nymbalhq/types';
|
|
2
2
|
export { CONTRACT_KINDS } from './kinds.js';
|
|
3
3
|
|
|
4
4
|
/** How long a health check, or a call on an unreachable dependency, may take to settle. */
|
|
@@ -51,10 +51,11 @@ interface EventBusContractOptions extends ContractOptions<EventBusAdapter> {
|
|
|
51
51
|
type Make = Build<EventBusAdapter>;
|
|
52
52
|
/**
|
|
53
53
|
* The event bus contract every implementation runs. `publish` resolves only after every matching subscription's
|
|
54
|
-
* handler has finished (what a read straight after a command relies on); a throwing handler is logged and does
|
|
55
|
-
* reject it
|
|
56
|
-
*
|
|
57
|
-
*
|
|
54
|
+
* handler has finished (what a read straight after a command relies on); a throwing unnamed handler is logged and does
|
|
55
|
+
* not reject it, and a throwing named one rejects it with `handler_failed` once the rest have finished; `replay`
|
|
56
|
+
* reaches `derived` subscriptions only; each subscription takes its events in order. With `second`, a named
|
|
57
|
+
* subscription is handled once across instances and an unnamed one on every instance. Then the delivery contract's
|
|
58
|
+
* cases, the handler-failure cases, and health (and, given `unreachable`, downtime).
|
|
58
59
|
*/
|
|
59
60
|
declare function runEventBusContract(name: string, make: Make, opts?: EventBusContractOptions): void;
|
|
60
61
|
|
|
@@ -121,7 +122,60 @@ declare function runShippingContract(name: string, build: Build<ShippingAdapter>
|
|
|
121
122
|
|
|
122
123
|
declare function runTaxContract(name: string, build: Build<TaxAdapter>, options?: ContractOptions<TaxAdapter>): void;
|
|
123
124
|
|
|
124
|
-
|
|
125
|
+
/** One delivery as the provider sends it: the exact bytes and the headers its signature is in. */
|
|
126
|
+
interface WebhookRequest {
|
|
127
|
+
rawBody: Buffer;
|
|
128
|
+
headers: WebhookHeaders;
|
|
129
|
+
}
|
|
130
|
+
interface WebhookContractOptions {
|
|
131
|
+
/** One signed delivery carrying at least one event, as the provider would send it. */
|
|
132
|
+
delivery: () => WebhookRequest;
|
|
133
|
+
/** The same delivery with one byte of its body changed. Given, the suite checks it is not verified. */
|
|
134
|
+
tampered?: () => WebhookRequest;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Certifies an adapter's `receiveWebhook`: one delivery received twice is one delivery, a tampered one is refused,
|
|
138
|
+
* and every event it hands on is the adapter's own type with a plain JSON object payload.
|
|
139
|
+
*/
|
|
140
|
+
declare function runWebhookContract(name: string, build: Build<CommerceAdapter>, options: WebhookContractOptions): void;
|
|
141
|
+
|
|
142
|
+
/** One signed delivery as the provider sends it, and the address its bounce or complaint is for. */
|
|
143
|
+
interface EmailFeedbackSample {
|
|
144
|
+
request: WebhookRequest;
|
|
145
|
+
recipient: string;
|
|
146
|
+
}
|
|
147
|
+
interface EmailFeedbackContractOptions {
|
|
148
|
+
/** A delivery of a hard bounce (the provider's permanent failure). */
|
|
149
|
+
bounce: () => EmailFeedbackSample;
|
|
150
|
+
/** A delivery of a soft bounce (a transient failure). Given, the suite checks it is classified `soft`. */
|
|
151
|
+
softBounce?: () => EmailFeedbackSample;
|
|
152
|
+
/** A delivery of a spam complaint. Given, the suite checks it is a complaint. */
|
|
153
|
+
complaint?: () => EmailFeedbackSample;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Certifies an email adapter's bounces and complaints from `receiveWebhook`: a bounce received twice is one delivery
|
|
157
|
+
* with the same events, every delivery is one the kernel's route accepts for the email slot, and each bounce and
|
|
158
|
+
* complaint is classified as the provider reported it. Run it beside `runWebhookContract`.
|
|
159
|
+
*/
|
|
160
|
+
declare function runEmailFeedbackContract(name: string, build: Build<CommerceAdapter>, options: EmailFeedbackContractOptions): void;
|
|
161
|
+
|
|
162
|
+
/** One signed delivery as the provider sends it, and the tracking number its update is for. */
|
|
163
|
+
interface ShippingTrackingSample {
|
|
164
|
+
request: WebhookRequest;
|
|
165
|
+
trackingNumber: string;
|
|
166
|
+
}
|
|
167
|
+
interface ShippingTrackingContractOptions {
|
|
168
|
+
/** A delivery of a delivered update. */
|
|
169
|
+
delivered: () => ShippingTrackingSample;
|
|
170
|
+
/** A delivery of an in-transit update. Given, the suite checks it is classified `in_transit`. */
|
|
171
|
+
inTransit?: () => ShippingTrackingSample;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Certifies a shipping adapter's tracking updates from `receiveWebhook`: an update received twice is one delivery with
|
|
175
|
+
* the same events, every delivery is one the kernel's route accepts for the shipping slot, and each update is
|
|
176
|
+
* classified as the carrier reported it. Run it beside `runWebhookContract`.
|
|
177
|
+
*/
|
|
178
|
+
declare function runShippingTrackingContract(name: string, build: Build<CommerceAdapter>, options: ShippingTrackingContractOptions): void;
|
|
125
179
|
|
|
126
180
|
declare function runSecurityContract(name: string, build: Build<SecurityAdapter>, options?: ContractOptions<SecurityAdapter>): void;
|
|
127
181
|
|
|
@@ -145,5 +199,5 @@ type ContractSuite = (name: string, build: Build<unknown>, options?: Record<stri
|
|
|
145
199
|
/** Each kind's suite, one for every kind in CONTRACT_KINDS. Each is typed here, at the CLI's boundary. */
|
|
146
200
|
declare const contractSuites: Partial<Record<ContractKind, ContractSuite>>;
|
|
147
201
|
|
|
148
|
-
export { BOUND_MS, adapterContext, contractSuites, matchesQuery,
|
|
149
|
-
export type { Build, ContractKind, ContractOptions, ContractProduct, ContractSuite, DocumentStoreContractOptions, EventBusContractOptions, MediaStorageContractOptions, PaymentsContractOptions, ProjectionContractOptions, SearchContractOptions };
|
|
202
|
+
export { BOUND_MS, adapterContext, contractSuites, matchesQuery, runAnalyticsContract, runDocumentStoreContract, runEmailContract, runEmailFeedbackContract, runEventBusContract, runMediaStorageContract, runPaymentsContract, runProjectionContract, runReviewsContract, runSearchContract, runSecurityContract, runShippingContract, runShippingTrackingContract, runTaxContract, runWebhookContract, searchTerms, toSearchDocument };
|
|
203
|
+
export type { Build, ContractKind, ContractOptions, ContractProduct, ContractSuite, DocumentStoreContractOptions, EmailFeedbackContractOptions, EmailFeedbackSample, EventBusContractOptions, MediaStorageContractOptions, PaymentsContractOptions, ProjectionContractOptions, SearchContractOptions, ShippingTrackingContractOptions, ShippingTrackingSample, WebhookContractOptions, WebhookRequest };
|