@anybio/govern 0.2.1 → 0.3.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/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- export { A as AUDIENCES, a as AckOptions, b as Audience, C as CHANNELS, c as Channel, D as DEFAULT_BASE_URL, d as DEFAULT_HOLD_MESSAGE, e as DEFAULT_MAX_RETRIES, f as DEFAULT_TIMEOUT_MS, g as Decision, h as DecisionStatus, i as DecisionVerdict, j as DecisionWebhookEvent, k as Disclosure, l as DisclosureAttachment, m as Draft, E as EvaluateInput, G as Govern, n as GovernEvent, o as GovernHandoffs, p as GovernOptions, q as GuardContext, r as GuardResult, H as Handoff, s as HandoffActionInput, t as HandoffContactInput, u as HandoffDetail, v as HandoffList, w as HandoffListQuery, x as HandoffRef, y as HandoffResolveInput, z as HandoffResumeInput, B as HandoffWebhookEvent, F as HeadersLike, I as IN_SESSION_CHANNELS, J as InboundFlag, K as InboundMessage, M as MAX_CONVERSATION_ID_CHARS, L as MAX_TURN_ID_CHARS, N as Mode, O as Outcome, P as PatientConsentInput, Q as PatientOptOutInput, R as PolicyRef, S as REASONS, T as RESERVED_TURN_ID_PREFIX, U as RecordDisclosureInput, V as ReleaseResult, W as ReportOutcomeInput, X as ReviewState, Y as Schemas, Z as StopClass, _ as SubmitTranscriptsInput, $ as TRANSIENT_HTTP_STATUSES, a0 as TranscriptJob, a1 as TranscriptTurnInput, a2 as UnknownWebhookEvent, a3 as VerifiedWebhook, a4 as WEBHOOK_EVENTS, a5 as WEBHOOK_HEADERS, a6 as WaitForReleaseOptions, a7 as WebhookDeliveryQuery, a8 as WebhookEvent, a9 as WebhookOptions, aa as WireCareHandoff, ab as WireConsentRequest, ac as WireDecision, ad as WireDisclosure, ae as WireDisclosureRequest, af as WireEvaluateRequest, ag as WireHandoffDetail, ah as WireHandoffList, ai as WireHandoffRef, aj as WireInboundFlag, ak as WireOptOutRequest, al as WireOutcome, am as WireOutcomeRequest, an as WirePatientState, ao as WirePolicyRef, ap as WireTranscriptBatch, aq as WireTranscriptJob, ar as WireTranscriptTurn, as as WireTranscriptTurnView, at as WireWebhookDelivery, au as createGovern, av as handleWebhook, aw as isAutomationPaused, ax as isClientMisconfiguration, ay as isInSessionChannel, az as parseEvent, aA as signWebhookPayload, aB as verifyWebhookSignature } from './client-CU46a__g.cjs';
1
+ import { R as ReportedOutcomeKind } from './client-BeyMec7E.cjs';
2
+ export { A as AUDIENCES, a as Audience, C as CHANNELS, b as Channel, D as DEFAULT_BASE_URL, c as DEFAULT_HOLD_MESSAGE, d as DEFAULT_MAX_RETRIES, e as DEFAULT_TIMEOUT_MS, f as Decision, g as DecisionStatus, h as DecisionVerdict, i as DecisionWebhookEvent, j as Disclosure, k as DisclosureAttachment, l as Draft, E as EvaluateInput, G as Govern, m as GovernEvent, n as GovernHandoffs, o as GovernOptions, p as GuardContext, q as GuardResult, H as Handoff, r as HandoffActionInput, s as HandoffContactInput, t as HandoffDetail, u as HandoffList, v as HandoffListQuery, w as HandoffRef, x as HandoffResolveInput, y as HandoffResumeInput, z as HandoffWebhookEvent, B as HeadersLike, I as IN_SESSION_CHANNELS, F as InboundFlag, J as InboundMessage, M as MAX_CONVERSATION_ID_CHARS, K as MAX_SUPERSEDES, L as MAX_TURN_ID_CHARS, N as MAX_TURN_REF_CHARS, O as Mode, P as OUTCOME_REASONS, Q as Outcome, S as OutcomeEvent, T as OutcomeKind, U as OutcomeSource, V as PatientConsentInput, W as PatientOptOutInput, X as PolicyRef, Y as REASONS, Z as RESERVED_TURN_ID_PREFIX, _ as RecordDisclosureInput, $ as ReleaseResult, a0 as ReportOutcomeInput, a1 as ReviewState, a2 as Schemas, a3 as StopClass, a4 as SubmitTranscriptsInput, a5 as TRANSIENT_HTTP_STATUSES, a6 as TranscriptJob, a7 as TranscriptTurnInput, a8 as UnknownWebhookEvent, a9 as VerifiedWebhook, aa as WEBHOOK_EVENTS, ab as WEBHOOK_HEADERS, ac as WaitForReleaseOptions, ad as WebhookDeliveryQuery, ae as WebhookEvent, af as WebhookOptions, ag as WireCareHandoff, ah as WireConsentRequest, ai as WireDecision, aj as WireDisclosure, ak as WireDisclosureRequest, al as WireEvaluateRequest, am as WireHandoffDetail, an as WireHandoffList, ao as WireHandoffRef, ap as WireInboundFlag, aq as WireOptOutRequest, ar as WireOutcome, as as WireOutcomeEvent, at as WireOutcomeRequest, au as WirePatientState, av as WirePolicyRef, aw as WireTranscriptBatch, ax as WireTranscriptJob, ay as WireTranscriptTurn, az as WireTranscriptTurnView, aA as WireWebhookDelivery, aB as createGovern, aC as handleWebhook, aD as isAutomationPaused, aE as isClientMisconfiguration, aF as isInSessionChannel, aG as parseEvent, aH as signWebhookPayload, aI as verifyWebhookSignature } from './client-BeyMec7E.cjs';
2
3
 
3
4
  /**
4
5
  * Error classes. No error message ever carries message content: they are built
@@ -10,9 +11,10 @@ export { A as AUDIENCES, a as AckOptions, b as Audience, C as CHANNELS, c as Cha
10
11
  * schema for the body, so what is in it is the server's business and may
11
12
  * change without this package moving. It is kept off `.message` and out of
12
13
  * every event, and parked on `GovernApiError.serverMessage`, where reading it
13
- * is a decision the caller makes for one error rather than a property of every
14
+ * is a decision the caller makes for one error, not a property of every
14
15
  * string the SDK hands to a log.
15
16
  */
17
+
16
18
  declare class GovernError extends Error {
17
19
  readonly name: string;
18
20
  constructor(message: string, options?: {
@@ -53,13 +55,53 @@ declare class GovernApiError extends GovernError {
53
55
  }
54
56
  /**
55
57
  * 409: the resource changed under you (a stale `expectedVersion` on a
56
- * hand-off action) or a different report is already recorded (an outcome that
57
- * disagrees with the one on file). Refresh and decide again; the SDK does not
58
- * retry it.
58
+ * hand-off action, a `retryOf` or `supersedes` naming a decision that moved
59
+ * on) or a different outcome event of the same kind is already recorded.
60
+ * Refresh and decide again; the SDK does not retry it.
59
61
  */
60
62
  declare class GovernConflictError extends GovernApiError {
61
63
  readonly name = "GovernConflictError";
62
64
  }
65
+ /**
66
+ * An outcome report an adapter made failed: the error the adapters pass to
67
+ * `onError` for a report that did not land. It carries the event exactly as
68
+ * it was sent, so the caller can send the identical event again with
69
+ * `reportOutcome`:
70
+ *
71
+ * govern.reportOutcome(error.decisionId, { kind: error.kind, at: error.at, contentHash: error.contentHash, deliveryRef: error.deliveryRef, reason: error.reason }).catch(log)
72
+ *
73
+ * The same `at` makes it the same event: the API answers a resend of an event
74
+ * that did land with 200 and records nothing, where a resend with a new `at`
75
+ * would be a different event (a 409, or a second row for `failed`). The
76
+ * failure itself is `cause`: a `GovernConflictError` when a different event
77
+ * of that kind is already on record (resending changes nothing), a
78
+ * `GovernApiError`, `GovernNetworkError` or `GovernTimeoutError` when the
79
+ * transport gave up, a `GovernConfigError` when a field was refused before
80
+ * anything was sent. Never message text: the hash, not the content.
81
+ */
82
+ declare class GovernReportError extends GovernError {
83
+ readonly name = "GovernReportError";
84
+ readonly decisionId: string;
85
+ /** The kind the event had: from an adapter, `released` or `discarded`. */
86
+ readonly kind: ReportedOutcomeKind;
87
+ /** The event's `at`, as it was sent. */
88
+ readonly at: string;
89
+ /** The SHA-256 hex the event carried, on `released` and `delivered`; null otherwise, and when nothing was sent. */
90
+ readonly contentHash: string | null;
91
+ /** The reference as sent, or as given when nothing was sent; trimmed as the API trims it either way. Null when there was none. */
92
+ readonly deliveryRef: string | null;
93
+ /** The reason code, as `deliveryRef` is. Null when there was none. */
94
+ readonly reason: string | null;
95
+ constructor(input: {
96
+ decisionId: string;
97
+ kind: ReportedOutcomeKind;
98
+ at: string;
99
+ contentHash: string | null;
100
+ deliveryRef: string | null;
101
+ reason: string | null;
102
+ cause: unknown;
103
+ });
104
+ }
63
105
  /** The request could not be sent or no response arrived. */
64
106
  declare class GovernNetworkError extends GovernError {
65
107
  readonly name = "GovernNetworkError";
@@ -91,7 +133,7 @@ declare function isGovernError(error: unknown): error is GovernError;
91
133
  /** SHA-256 over the UTF-8 bytes of `text`, lowercase hex. The outcome hash the API expects. */
92
134
  declare function sha256Hex(text: string): Promise<string>;
93
135
 
94
- declare const SDK_VERSION = "0.2.1";
136
+ declare const SDK_VERSION = "0.3.0";
95
137
  declare const SDK_NAME = "@anybio/govern";
96
138
 
97
- export { GovernAbortError, GovernApiError, GovernConfigError, GovernConflictError, GovernError, GovernNetworkError, GovernNotAvailableError, GovernTimeoutError, GovernWebhookError, SDK_NAME, SDK_VERSION, isGovernError, sha256Hex };
139
+ export { GovernAbortError, GovernApiError, GovernConfigError, GovernConflictError, GovernError, GovernNetworkError, GovernNotAvailableError, GovernReportError, GovernTimeoutError, GovernWebhookError, ReportedOutcomeKind, SDK_NAME, SDK_VERSION, isGovernError, sha256Hex };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { A as AUDIENCES, a as AckOptions, b as Audience, C as CHANNELS, c as Channel, D as DEFAULT_BASE_URL, d as DEFAULT_HOLD_MESSAGE, e as DEFAULT_MAX_RETRIES, f as DEFAULT_TIMEOUT_MS, g as Decision, h as DecisionStatus, i as DecisionVerdict, j as DecisionWebhookEvent, k as Disclosure, l as DisclosureAttachment, m as Draft, E as EvaluateInput, G as Govern, n as GovernEvent, o as GovernHandoffs, p as GovernOptions, q as GuardContext, r as GuardResult, H as Handoff, s as HandoffActionInput, t as HandoffContactInput, u as HandoffDetail, v as HandoffList, w as HandoffListQuery, x as HandoffRef, y as HandoffResolveInput, z as HandoffResumeInput, B as HandoffWebhookEvent, F as HeadersLike, I as IN_SESSION_CHANNELS, J as InboundFlag, K as InboundMessage, M as MAX_CONVERSATION_ID_CHARS, L as MAX_TURN_ID_CHARS, N as Mode, O as Outcome, P as PatientConsentInput, Q as PatientOptOutInput, R as PolicyRef, S as REASONS, T as RESERVED_TURN_ID_PREFIX, U as RecordDisclosureInput, V as ReleaseResult, W as ReportOutcomeInput, X as ReviewState, Y as Schemas, Z as StopClass, _ as SubmitTranscriptsInput, $ as TRANSIENT_HTTP_STATUSES, a0 as TranscriptJob, a1 as TranscriptTurnInput, a2 as UnknownWebhookEvent, a3 as VerifiedWebhook, a4 as WEBHOOK_EVENTS, a5 as WEBHOOK_HEADERS, a6 as WaitForReleaseOptions, a7 as WebhookDeliveryQuery, a8 as WebhookEvent, a9 as WebhookOptions, aa as WireCareHandoff, ab as WireConsentRequest, ac as WireDecision, ad as WireDisclosure, ae as WireDisclosureRequest, af as WireEvaluateRequest, ag as WireHandoffDetail, ah as WireHandoffList, ai as WireHandoffRef, aj as WireInboundFlag, ak as WireOptOutRequest, al as WireOutcome, am as WireOutcomeRequest, an as WirePatientState, ao as WirePolicyRef, ap as WireTranscriptBatch, aq as WireTranscriptJob, ar as WireTranscriptTurn, as as WireTranscriptTurnView, at as WireWebhookDelivery, au as createGovern, av as handleWebhook, aw as isAutomationPaused, ax as isClientMisconfiguration, ay as isInSessionChannel, az as parseEvent, aA as signWebhookPayload, aB as verifyWebhookSignature } from './client-CU46a__g.js';
1
+ import { R as ReportedOutcomeKind } from './client-BeyMec7E.js';
2
+ export { A as AUDIENCES, a as Audience, C as CHANNELS, b as Channel, D as DEFAULT_BASE_URL, c as DEFAULT_HOLD_MESSAGE, d as DEFAULT_MAX_RETRIES, e as DEFAULT_TIMEOUT_MS, f as Decision, g as DecisionStatus, h as DecisionVerdict, i as DecisionWebhookEvent, j as Disclosure, k as DisclosureAttachment, l as Draft, E as EvaluateInput, G as Govern, m as GovernEvent, n as GovernHandoffs, o as GovernOptions, p as GuardContext, q as GuardResult, H as Handoff, r as HandoffActionInput, s as HandoffContactInput, t as HandoffDetail, u as HandoffList, v as HandoffListQuery, w as HandoffRef, x as HandoffResolveInput, y as HandoffResumeInput, z as HandoffWebhookEvent, B as HeadersLike, I as IN_SESSION_CHANNELS, F as InboundFlag, J as InboundMessage, M as MAX_CONVERSATION_ID_CHARS, K as MAX_SUPERSEDES, L as MAX_TURN_ID_CHARS, N as MAX_TURN_REF_CHARS, O as Mode, P as OUTCOME_REASONS, Q as Outcome, S as OutcomeEvent, T as OutcomeKind, U as OutcomeSource, V as PatientConsentInput, W as PatientOptOutInput, X as PolicyRef, Y as REASONS, Z as RESERVED_TURN_ID_PREFIX, _ as RecordDisclosureInput, $ as ReleaseResult, a0 as ReportOutcomeInput, a1 as ReviewState, a2 as Schemas, a3 as StopClass, a4 as SubmitTranscriptsInput, a5 as TRANSIENT_HTTP_STATUSES, a6 as TranscriptJob, a7 as TranscriptTurnInput, a8 as UnknownWebhookEvent, a9 as VerifiedWebhook, aa as WEBHOOK_EVENTS, ab as WEBHOOK_HEADERS, ac as WaitForReleaseOptions, ad as WebhookDeliveryQuery, ae as WebhookEvent, af as WebhookOptions, ag as WireCareHandoff, ah as WireConsentRequest, ai as WireDecision, aj as WireDisclosure, ak as WireDisclosureRequest, al as WireEvaluateRequest, am as WireHandoffDetail, an as WireHandoffList, ao as WireHandoffRef, ap as WireInboundFlag, aq as WireOptOutRequest, ar as WireOutcome, as as WireOutcomeEvent, at as WireOutcomeRequest, au as WirePatientState, av as WirePolicyRef, aw as WireTranscriptBatch, ax as WireTranscriptJob, ay as WireTranscriptTurn, az as WireTranscriptTurnView, aA as WireWebhookDelivery, aB as createGovern, aC as handleWebhook, aD as isAutomationPaused, aE as isClientMisconfiguration, aF as isInSessionChannel, aG as parseEvent, aH as signWebhookPayload, aI as verifyWebhookSignature } from './client-BeyMec7E.js';
2
3
 
3
4
  /**
4
5
  * Error classes. No error message ever carries message content: they are built
@@ -10,9 +11,10 @@ export { A as AUDIENCES, a as AckOptions, b as Audience, C as CHANNELS, c as Cha
10
11
  * schema for the body, so what is in it is the server's business and may
11
12
  * change without this package moving. It is kept off `.message` and out of
12
13
  * every event, and parked on `GovernApiError.serverMessage`, where reading it
13
- * is a decision the caller makes for one error rather than a property of every
14
+ * is a decision the caller makes for one error, not a property of every
14
15
  * string the SDK hands to a log.
15
16
  */
17
+
16
18
  declare class GovernError extends Error {
17
19
  readonly name: string;
18
20
  constructor(message: string, options?: {
@@ -53,13 +55,53 @@ declare class GovernApiError extends GovernError {
53
55
  }
54
56
  /**
55
57
  * 409: the resource changed under you (a stale `expectedVersion` on a
56
- * hand-off action) or a different report is already recorded (an outcome that
57
- * disagrees with the one on file). Refresh and decide again; the SDK does not
58
- * retry it.
58
+ * hand-off action, a `retryOf` or `supersedes` naming a decision that moved
59
+ * on) or a different outcome event of the same kind is already recorded.
60
+ * Refresh and decide again; the SDK does not retry it.
59
61
  */
60
62
  declare class GovernConflictError extends GovernApiError {
61
63
  readonly name = "GovernConflictError";
62
64
  }
65
+ /**
66
+ * An outcome report an adapter made failed: the error the adapters pass to
67
+ * `onError` for a report that did not land. It carries the event exactly as
68
+ * it was sent, so the caller can send the identical event again with
69
+ * `reportOutcome`:
70
+ *
71
+ * govern.reportOutcome(error.decisionId, { kind: error.kind, at: error.at, contentHash: error.contentHash, deliveryRef: error.deliveryRef, reason: error.reason }).catch(log)
72
+ *
73
+ * The same `at` makes it the same event: the API answers a resend of an event
74
+ * that did land with 200 and records nothing, where a resend with a new `at`
75
+ * would be a different event (a 409, or a second row for `failed`). The
76
+ * failure itself is `cause`: a `GovernConflictError` when a different event
77
+ * of that kind is already on record (resending changes nothing), a
78
+ * `GovernApiError`, `GovernNetworkError` or `GovernTimeoutError` when the
79
+ * transport gave up, a `GovernConfigError` when a field was refused before
80
+ * anything was sent. Never message text: the hash, not the content.
81
+ */
82
+ declare class GovernReportError extends GovernError {
83
+ readonly name = "GovernReportError";
84
+ readonly decisionId: string;
85
+ /** The kind the event had: from an adapter, `released` or `discarded`. */
86
+ readonly kind: ReportedOutcomeKind;
87
+ /** The event's `at`, as it was sent. */
88
+ readonly at: string;
89
+ /** The SHA-256 hex the event carried, on `released` and `delivered`; null otherwise, and when nothing was sent. */
90
+ readonly contentHash: string | null;
91
+ /** The reference as sent, or as given when nothing was sent; trimmed as the API trims it either way. Null when there was none. */
92
+ readonly deliveryRef: string | null;
93
+ /** The reason code, as `deliveryRef` is. Null when there was none. */
94
+ readonly reason: string | null;
95
+ constructor(input: {
96
+ decisionId: string;
97
+ kind: ReportedOutcomeKind;
98
+ at: string;
99
+ contentHash: string | null;
100
+ deliveryRef: string | null;
101
+ reason: string | null;
102
+ cause: unknown;
103
+ });
104
+ }
63
105
  /** The request could not be sent or no response arrived. */
64
106
  declare class GovernNetworkError extends GovernError {
65
107
  readonly name = "GovernNetworkError";
@@ -91,7 +133,7 @@ declare function isGovernError(error: unknown): error is GovernError;
91
133
  /** SHA-256 over the UTF-8 bytes of `text`, lowercase hex. The outcome hash the API expects. */
92
134
  declare function sha256Hex(text: string): Promise<string>;
93
135
 
94
- declare const SDK_VERSION = "0.2.1";
136
+ declare const SDK_VERSION = "0.3.0";
95
137
  declare const SDK_NAME = "@anybio/govern";
96
138
 
97
- export { GovernAbortError, GovernApiError, GovernConfigError, GovernConflictError, GovernError, GovernNetworkError, GovernNotAvailableError, GovernTimeoutError, GovernWebhookError, SDK_NAME, SDK_VERSION, isGovernError, sha256Hex };
139
+ export { GovernAbortError, GovernApiError, GovernConfigError, GovernConflictError, GovernError, GovernNetworkError, GovernNotAvailableError, GovernReportError, GovernTimeoutError, GovernWebhookError, ReportedOutcomeKind, SDK_NAME, SDK_VERSION, isGovernError, sha256Hex };