@nymbalhq/contract-tests 1.2.0 → 1.4.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.
@@ -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-ABEL44IM.js.map
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 'ai',\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;AAAA,EACA;AACF;","names":[]}
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, AiAdapter, SecurityAdapter, NymbalEvent } from '@nymbalhq/types';
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 not
55
- * reject it; `replay` reaches `derived` subscriptions only; each subscription takes its events in order. With `second`,
56
- * a named subscription is handled once across instances and an unnamed one on every instance. Then the delivery
57
- * contract's cases, and health (and, given `unreachable`, downtime).
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,22 @@ 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
- declare function runAiContract(name: string, build: Build<AiAdapter>, options?: ContractOptions<AiAdapter>): void;
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;
125
141
 
126
142
  declare function runSecurityContract(name: string, build: Build<SecurityAdapter>, options?: ContractOptions<SecurityAdapter>): void;
127
143
 
@@ -145,5 +161,5 @@ type ContractSuite = (name: string, build: Build<unknown>, options?: Record<stri
145
161
  /** Each kind's suite, one for every kind in CONTRACT_KINDS. Each is typed here, at the CLI's boundary. */
146
162
  declare const contractSuites: Partial<Record<ContractKind, ContractSuite>>;
147
163
 
148
- export { BOUND_MS, adapterContext, contractSuites, matchesQuery, runAiContract, runAnalyticsContract, runDocumentStoreContract, runEmailContract, runEventBusContract, runMediaStorageContract, runPaymentsContract, runProjectionContract, runReviewsContract, runSearchContract, runSecurityContract, runShippingContract, runTaxContract, searchTerms, toSearchDocument };
149
- export type { Build, ContractKind, ContractOptions, ContractProduct, ContractSuite, DocumentStoreContractOptions, EventBusContractOptions, MediaStorageContractOptions, PaymentsContractOptions, ProjectionContractOptions, SearchContractOptions };
164
+ export { BOUND_MS, adapterContext, contractSuites, matchesQuery, runAnalyticsContract, runDocumentStoreContract, runEmailContract, runEventBusContract, runMediaStorageContract, runPaymentsContract, runProjectionContract, runReviewsContract, runSearchContract, runSecurityContract, runShippingContract, runTaxContract, runWebhookContract, searchTerms, toSearchDocument };
165
+ export type { Build, ContractKind, ContractOptions, ContractProduct, ContractSuite, DocumentStoreContractOptions, EventBusContractOptions, MediaStorageContractOptions, PaymentsContractOptions, ProjectionContractOptions, SearchContractOptions, WebhookContractOptions, WebhookRequest };