@outfitter/contracts 0.2.0 → 0.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.
- package/README.md +41 -2
- package/dist/actions.d.ts +4 -3
- package/dist/assert/index.d.ts +2 -2
- package/dist/assert/index.js +2 -2
- package/dist/context.d.ts +4 -3
- package/dist/envelope.d.ts +2 -2
- package/dist/envelope.js +4 -4
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +4 -2
- package/dist/handler.d.ts +3 -2
- package/dist/index.d.ts +15 -13
- package/dist/index.js +43 -33
- package/dist/logging.d.ts +2 -0
- package/dist/logging.js +7 -0
- package/dist/recovery.d.ts +2 -2
- package/dist/resilience.d.ts +2 -2
- package/dist/resilience.js +2 -2
- package/dist/schema.d.ts +2 -0
- package/dist/schema.js +7 -0
- package/dist/serialization.d.ts +2 -2
- package/dist/serialization.js +2 -2
- package/dist/shared/@outfitter/{contracts-k2jdpbb6.js → contracts-0snpmkdt.js} +1 -1
- package/dist/shared/@outfitter/{contracts-jbhbyhtt.d.ts → contracts-18vcxecr.d.ts} +1 -1
- package/dist/shared/@outfitter/{contracts-t68dwjbk.d.ts → contracts-25bkj17f.d.ts} +2 -1
- package/dist/shared/@outfitter/contracts-2g8r01zf.d.ts +73 -0
- package/dist/shared/@outfitter/{contracts-agvdgx9j.js → contracts-5k6q4n48.js} +41 -9
- package/dist/shared/@outfitter/{contracts-n9hb6hqt.d.ts → contracts-6j6z9dsd.d.ts} +1 -1
- package/dist/shared/@outfitter/{contracts-r64j5rsm.d.ts → contracts-bdwg55c5.d.ts} +1 -1
- package/dist/shared/@outfitter/{contracts-rtsa2s0f.js → contracts-btg89x4h.js} +2 -2
- package/dist/shared/@outfitter/{contracts-2f3khqcc.js → contracts-cp5c6dws.js} +1 -1
- package/dist/shared/@outfitter/{contracts-md2mvvyt.d.ts → contracts-evxky148.d.ts} +1 -1
- package/dist/shared/@outfitter/contracts-hbbxbwkt.d.ts +60 -0
- package/dist/shared/@outfitter/{contracts-6atxbfag.d.ts → contracts-j08e95jw.d.ts} +1 -1
- package/dist/shared/@outfitter/{contracts-k0rhaye3.d.ts → contracts-jggbn5tn.d.ts} +1 -1
- package/dist/shared/@outfitter/{contracts-0cj49e1a.js → contracts-phjhz5q3.js} +26 -1
- package/dist/shared/@outfitter/{contracts-pdk7s4t8.js → contracts-r21yet6j.js} +1 -1
- package/dist/shared/@outfitter/{contracts-5hr9pdcq.d.ts → contracts-r35bn9p6.d.ts} +62 -3
- package/dist/shared/@outfitter/{contracts-zyanj0gf.d.ts → contracts-sf1z80yc.d.ts} +2 -2
- package/dist/shared/@outfitter/contracts-sm6vak1a.js +14 -0
- package/dist/shared/@outfitter/{contracts-amd2ykn8.d.ts → contracts-ss9vjjft.d.ts} +3 -43
- package/dist/shared/@outfitter/contracts-wfht4q2b.js +341 -0
- package/dist/validation.d.ts +2 -2
- package/dist/validation.js +2 -2
- package/package.json +56 -44
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Result/Error patterns, error taxonomy, handler contracts, and shared interfaces
|
|
|
4
4
|
|
|
5
5
|
## Status
|
|
6
6
|
|
|
7
|
-
**
|
|
7
|
+
**Active** - Stable core contracts with active feature development.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
// Define a handler
|
|
37
37
|
const getNote: Handler<{ id: string }, Note, NotFoundError> = async (input, ctx) => {
|
|
38
38
|
const note = await db.notes.find(input.id);
|
|
39
|
-
if (!note) return Result.err(
|
|
39
|
+
if (!note) return Result.err(NotFoundError.create("note", input.id));
|
|
40
40
|
return Result.ok(note);
|
|
41
41
|
};
|
|
42
42
|
|
|
@@ -45,6 +45,45 @@ const ctx = createContext({ logger, config });
|
|
|
45
45
|
const result = await getNote({ id: "abc123" }, ctx);
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
## Error Factory Reference
|
|
49
|
+
|
|
50
|
+
All error classes provide a static `create()` factory method that generates a consistent message from structured parameters. Use `create()` for structured errors and the constructor for custom messages.
|
|
51
|
+
|
|
52
|
+
| Error Class | `create()` Signature | Generated Message |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| `ValidationError` | `create(field, reason, context?)` | `"email: format invalid"` |
|
|
55
|
+
| `ValidationError` | `fromMessage(message, context?)` | *(your message as-is)* |
|
|
56
|
+
| `AmbiguousError` | `create(what, candidates, context?)` | `"Ambiguous heading: 2 matches found"` |
|
|
57
|
+
| `NotFoundError` | `create(resourceType, resourceId, context?)` | `"note not found: abc123"` |
|
|
58
|
+
| `AlreadyExistsError` | `create(resourceType, resourceId, context?)` | `"file already exists: notes/meeting.md"` |
|
|
59
|
+
| `ConflictError` | `create(message, context?)` | *(your message as-is)* |
|
|
60
|
+
| `PermissionError` | `create(message, context?)` | *(your message as-is)* |
|
|
61
|
+
| `TimeoutError` | `create(operation, timeoutMs)` | `"database query timed out after 5000ms"` |
|
|
62
|
+
| `RateLimitError` | `create(message, retryAfterSeconds?)` | *(your message as-is)* |
|
|
63
|
+
| `NetworkError` | `create(message, context?)` | *(your message as-is)* |
|
|
64
|
+
| `InternalError` | `create(message, context?)` | *(your message as-is)* |
|
|
65
|
+
| `AuthError` | `create(message, reason?)` | *(your message as-is)* |
|
|
66
|
+
| `CancelledError` | `create(message)` | *(your message as-is)* |
|
|
67
|
+
|
|
68
|
+
### Message Casing
|
|
69
|
+
|
|
70
|
+
`create()` factories that auto-generate messages use **lowercase** `resourceType`:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
NotFoundError.create("piece", "abc123");
|
|
74
|
+
// → "piece not found: abc123" (not "Piece not found: abc123")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
If you need a capitalized message, use the constructor directly:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
new NotFoundError({
|
|
81
|
+
message: "Piece not found: abc123",
|
|
82
|
+
resourceType: "piece",
|
|
83
|
+
resourceId: "abc123",
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
48
87
|
## License
|
|
49
88
|
|
|
50
89
|
MIT
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ACTION_SURFACES, ActionApiSpec, ActionCliInputContext, ActionCliOption, ActionCliSpec, ActionMcpSpec, ActionRegistry, ActionSpec, ActionSurface, ActionTrpcSpec, AnyActionSpec, DEFAULT_REGISTRY_SURFACES, HttpMethod, createActionRegistry, defineAction } from "./shared/@outfitter/contracts-
|
|
2
|
-
import "./shared/@outfitter/contracts-
|
|
3
|
-
import "./shared/@outfitter/contracts-
|
|
1
|
+
import { ACTION_SURFACES, ActionApiSpec, ActionCliInputContext, ActionCliOption, ActionCliSpec, ActionMcpSpec, ActionRegistry, ActionSpec, ActionSurface, ActionTrpcSpec, AnyActionSpec, DEFAULT_REGISTRY_SURFACES, HttpMethod, createActionRegistry, defineAction } from "./shared/@outfitter/contracts-sf1z80yc";
|
|
2
|
+
import "./shared/@outfitter/contracts-ss9vjjft";
|
|
3
|
+
import "./shared/@outfitter/contracts-r35bn9p6";
|
|
4
|
+
import "./shared/@outfitter/contracts-2g8r01zf";
|
|
4
5
|
export { defineAction, createActionRegistry, HttpMethod, DEFAULT_REGISTRY_SURFACES, AnyActionSpec, ActionTrpcSpec, ActionSurface, ActionSpec, ActionRegistry, ActionMcpSpec, ActionCliSpec, ActionCliOption, ActionCliInputContext, ActionApiSpec, ACTION_SURFACES };
|
package/dist/assert/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NonEmptyArray, assertDefined, assertMatches, assertNonEmpty, isNonEmptyArray } from "../shared/@outfitter/contracts-
|
|
2
|
-
import "../shared/@outfitter/contracts-
|
|
1
|
+
import { NonEmptyArray, assertDefined, assertMatches, assertNonEmpty, isNonEmptyArray } from "../shared/@outfitter/contracts-18vcxecr";
|
|
2
|
+
import "../shared/@outfitter/contracts-r35bn9p6";
|
|
3
3
|
export { isNonEmptyArray, assertNonEmpty, assertMatches, assertDefined, NonEmptyArray };
|
package/dist/assert/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
assertMatches,
|
|
5
5
|
assertNonEmpty,
|
|
6
6
|
isNonEmptyArray
|
|
7
|
-
} from "../shared/@outfitter/contracts-
|
|
8
|
-
import"../shared/@outfitter/contracts-
|
|
7
|
+
} from "../shared/@outfitter/contracts-cp5c6dws.js";
|
|
8
|
+
import"../shared/@outfitter/contracts-phjhz5q3.js";
|
|
9
9
|
export {
|
|
10
10
|
isNonEmptyArray,
|
|
11
11
|
assertNonEmpty,
|
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CreateContextOptions, createContext, generateRequestId } from "./shared/@outfitter/contracts-
|
|
2
|
-
import "./shared/@outfitter/contracts-
|
|
3
|
-
import "./shared/@outfitter/contracts-
|
|
1
|
+
import { CreateContextOptions, createContext, generateRequestId } from "./shared/@outfitter/contracts-25bkj17f";
|
|
2
|
+
import "./shared/@outfitter/contracts-ss9vjjft";
|
|
3
|
+
import "./shared/@outfitter/contracts-r35bn9p6";
|
|
4
|
+
import "./shared/@outfitter/contracts-2g8r01zf";
|
|
4
5
|
export { generateRequestId, createContext, CreateContextOptions };
|
package/dist/envelope.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Envelope, EnvelopeMeta, ErrorEnvelope, HttpResponse, PaginationMeta, SuccessEnvelope, toEnvelope, toHttpResponse } from "./shared/@outfitter/contracts-
|
|
2
|
-
import "./shared/@outfitter/contracts-
|
|
1
|
+
import { Envelope, EnvelopeMeta, ErrorEnvelope, HttpResponse, PaginationMeta, SuccessEnvelope, toEnvelope, toHttpResponse } from "./shared/@outfitter/contracts-jggbn5tn";
|
|
2
|
+
import "./shared/@outfitter/contracts-r35bn9p6";
|
|
3
3
|
export { toHttpResponse, toEnvelope, SuccessEnvelope, PaginationMeta, HttpResponse, ErrorEnvelope, EnvelopeMeta, Envelope };
|
package/dist/envelope.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import {
|
|
3
3
|
toEnvelope,
|
|
4
4
|
toHttpResponse
|
|
5
|
-
} from "./shared/@outfitter/contracts-
|
|
6
|
-
import"./shared/@outfitter/contracts-
|
|
7
|
-
import"./shared/@outfitter/contracts-s15x2rs4.js";
|
|
5
|
+
} from "./shared/@outfitter/contracts-btg89x4h.js";
|
|
6
|
+
import"./shared/@outfitter/contracts-5k6q4n48.js";
|
|
8
7
|
import"./shared/@outfitter/contracts-agmt8915.js";
|
|
9
|
-
import"./shared/@outfitter/contracts-
|
|
8
|
+
import"./shared/@outfitter/contracts-phjhz5q3.js";
|
|
9
|
+
import"./shared/@outfitter/contracts-s15x2rs4.js";
|
|
10
10
|
export {
|
|
11
11
|
toHttpResponse,
|
|
12
12
|
toEnvelope
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AmbiguousError, AnyKitError, AssertionError, AuthError, CancelledError, ConflictError, ERROR_CODES, ErrorCategory, ErrorCode, InternalError, KitErrorProps, NetworkError, NotFoundError, OutfitterError, PermissionError, RateLimitError, SerializedError, TimeoutError, ValidationError, exitCodeMap, getExitCode, getStatusCode, statusCodeMap } from "./shared/@outfitter/contracts-
|
|
2
|
-
export { statusCodeMap, getStatusCode, getExitCode, exitCodeMap, ValidationError, TimeoutError, SerializedError, RateLimitError, PermissionError, OutfitterError, NotFoundError, NetworkError, KitErrorProps, InternalError, ErrorCode, ErrorCategory, ERROR_CODES, ConflictError, CancelledError, AuthError, AssertionError, AnyKitError, AmbiguousError };
|
|
1
|
+
import { AlreadyExistsError, AmbiguousError, AnyKitError, AssertionError, AuthError, CancelledError, ConflictError, ERROR_CODES, ErrorCategory, ErrorCode, InternalError, KitErrorProps, NetworkError, NotFoundError, OutfitterError, PermissionError, RateLimitError, SerializedError, TimeoutError, ValidationError, exitCodeMap, getExitCode, getStatusCode, statusCodeMap } from "./shared/@outfitter/contracts-r35bn9p6";
|
|
2
|
+
export { statusCodeMap, getStatusCode, getExitCode, exitCodeMap, ValidationError, TimeoutError, SerializedError, RateLimitError, PermissionError, OutfitterError, NotFoundError, NetworkError, KitErrorProps, InternalError, ErrorCode, ErrorCategory, ERROR_CODES, ConflictError, CancelledError, AuthError, AssertionError, AnyKitError, AmbiguousError, AlreadyExistsError };
|
package/dist/errors.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
+
AlreadyExistsError,
|
|
3
4
|
AmbiguousError,
|
|
4
5
|
AssertionError,
|
|
5
6
|
AuthError,
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
getExitCode,
|
|
18
19
|
getStatusCode,
|
|
19
20
|
statusCodeMap
|
|
20
|
-
} from "./shared/@outfitter/contracts-
|
|
21
|
+
} from "./shared/@outfitter/contracts-phjhz5q3.js";
|
|
21
22
|
export {
|
|
22
23
|
statusCodeMap,
|
|
23
24
|
getStatusCode,
|
|
@@ -35,5 +36,6 @@ export {
|
|
|
35
36
|
CancelledError,
|
|
36
37
|
AuthError,
|
|
37
38
|
AssertionError,
|
|
38
|
-
AmbiguousError
|
|
39
|
+
AmbiguousError,
|
|
40
|
+
AlreadyExistsError
|
|
39
41
|
};
|
package/dist/handler.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { Handler, HandlerContext,
|
|
2
|
-
import "./shared/@outfitter/contracts-
|
|
1
|
+
import { Handler, HandlerContext, ResolvedConfig, SyncHandler } from "./shared/@outfitter/contracts-ss9vjjft";
|
|
2
|
+
import "./shared/@outfitter/contracts-r35bn9p6";
|
|
3
|
+
import { Logger } from "./shared/@outfitter/contracts-2g8r01zf";
|
|
3
4
|
export { SyncHandler, ResolvedConfig, Logger, HandlerContext, Handler };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { ACTION_CAPABILITIES, ActionCapability, CAPABILITY_SURFACES, CapabilitySurface, DEFAULT_ACTION_SURFACES, capability, capabilityAll, getActionsForSurface } from "./shared/@outfitter/contracts-bb4hjt8g";
|
|
2
|
-
import { DEFAULT_PATTERNS, DEFAULT_SENSITIVE_KEYS, RedactionCallback, RedactionEvent, Redactor, RedactorConfig, createRedactor } from "./shared/@outfitter/contracts-e70qdasg";
|
|
3
|
-
import { BackoffOptions, getBackoffDelay, isRecoverable, isRetryable, shouldRetry } from "./shared/@outfitter/contracts-md2mvvyt";
|
|
4
|
-
import { ACTION_SURFACES, ActionApiSpec, ActionCliInputContext, ActionCliOption, ActionCliSpec, ActionMcpSpec, ActionRegistry, ActionSpec, ActionSurface, ActionTrpcSpec, AnyActionSpec, DEFAULT_REGISTRY_SURFACES, HttpMethod, createActionRegistry, defineAction } from "./shared/@outfitter/contracts-zyanj0gf";
|
|
5
|
-
import { RetryOptions, TimeoutOptions, retry, withTimeout } from "./shared/@outfitter/contracts-r64j5rsm";
|
|
6
1
|
import "./shared/@outfitter/contracts-qaccq0gf";
|
|
7
2
|
import { combine2, combine3, expect, orElse, unwrapOrElse } from "./shared/@outfitter/contracts-ar0etwtx";
|
|
8
|
-
import {
|
|
3
|
+
import { ACTION_SURFACES, ActionApiSpec, ActionCliInputContext, ActionCliOption, ActionCliSpec, ActionMcpSpec, ActionRegistry, ActionSpec, ActionSurface, ActionTrpcSpec, AnyActionSpec, DEFAULT_REGISTRY_SURFACES, HttpMethod, createActionRegistry, defineAction } from "./shared/@outfitter/contracts-sf1z80yc";
|
|
4
|
+
import { ACTION_CAPABILITIES, ActionCapability, CAPABILITY_SURFACES, CapabilitySurface, DEFAULT_ACTION_SURFACES, capability, capabilityAll, getActionsForSurface } from "./shared/@outfitter/contracts-bb4hjt8g";
|
|
5
|
+
import { SerializeErrorOptions, deserializeError, safeParse, safeStringify, serializeError } from "./shared/@outfitter/contracts-j08e95jw";
|
|
6
|
+
import { JsonSchema, zodToJsonSchema } from "./shared/@outfitter/contracts-hbbxbwkt";
|
|
7
|
+
import { CreateContextOptions, createContext, generateRequestId } from "./shared/@outfitter/contracts-25bkj17f";
|
|
8
|
+
import { NonEmptyArray, assertDefined, assertMatches, assertNonEmpty, isNonEmptyArray } from "./shared/@outfitter/contracts-18vcxecr";
|
|
9
|
+
import { Envelope, EnvelopeMeta, ErrorEnvelope, HttpResponse, PaginationMeta, SuccessEnvelope, toEnvelope, toHttpResponse } from "./shared/@outfitter/contracts-jggbn5tn";
|
|
9
10
|
import { AdapterAuthError, AuthAdapter, CacheAdapter, CacheError, IndexAdapter, IndexError, IndexStats, SearchOptions, SearchResult, StorageAdapter, StorageError } from "./shared/@outfitter/contracts-93dx53mt";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { Handler, HandlerContext,
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
11
|
+
import { BackoffOptions, getBackoffDelay, isRecoverable, isRetryable, shouldRetry } from "./shared/@outfitter/contracts-evxky148";
|
|
12
|
+
import { RetryOptions, TimeoutOptions, retry, withTimeout } from "./shared/@outfitter/contracts-bdwg55c5";
|
|
13
|
+
import { createValidator, validateInput } from "./shared/@outfitter/contracts-6j6z9dsd";
|
|
14
|
+
import { Handler, HandlerContext, ResolvedConfig, SyncHandler } from "./shared/@outfitter/contracts-ss9vjjft";
|
|
15
|
+
import { AlreadyExistsError, AmbiguousError, AnyKitError, AssertionError, AuthError, CancelledError, ConflictError, ERROR_CODES, ErrorCategory, ErrorCode, InternalError, KitErrorProps, NetworkError, NotFoundError, OutfitterError, PermissionError, RateLimitError, SerializedError, TimeoutError, ValidationError, exitCodeMap, getExitCode, getStatusCode, statusCodeMap } from "./shared/@outfitter/contracts-r35bn9p6";
|
|
16
|
+
import { LogLevel, LogMetadata, LogMethod, Logger, LoggerAdapter, LoggerFactory, LoggerFactoryConfig, createLoggerFactory } from "./shared/@outfitter/contracts-2g8r01zf";
|
|
17
|
+
import { DEFAULT_PATTERNS, DEFAULT_SENSITIVE_KEYS, RedactionCallback, RedactionEvent, Redactor, RedactorConfig, createRedactor } from "./shared/@outfitter/contracts-e70qdasg";
|
|
16
18
|
import { TaggedErrorClass } from "better-result";
|
|
17
19
|
import { Result, TaggedError } from "better-result";
|
|
18
|
-
export { withTimeout, validateInput, unwrapOrElse, toHttpResponse, toEnvelope, statusCodeMap, shouldRetry, serializeError, safeStringify, safeParse, retry, orElse, isRetryable, isRecoverable, isNonEmptyArray, getStatusCode, getExitCode, getBackoffDelay, getActionsForSurface, generateRequestId, expect, exitCodeMap, deserializeError, defineAction, createValidator, createRedactor, createContext, createActionRegistry, combine3, combine2, capabilityAll, capability, assertNonEmpty, assertMatches, assertDefined, ValidationError, TimeoutOptions, TimeoutError, TaggedErrorClass, TaggedError, SyncHandler, SuccessEnvelope, StorageError, StorageAdapter, SerializedError, SerializeErrorOptions, SearchResult, SearchOptions, RetryOptions, Result, ResolvedConfig, RedactorConfig, Redactor, RedactionEvent, RedactionCallback, RateLimitError, PermissionError, PaginationMeta, OutfitterError, NotFoundError, NonEmptyArray, NetworkError, Logger, KitErrorProps, InternalError, IndexStats, IndexError, IndexAdapter, HttpResponse, HttpMethod, HandlerContext, Handler, ErrorEnvelope, ErrorCode, ErrorCategory, EnvelopeMeta, Envelope, ERROR_CODES, DEFAULT_SENSITIVE_KEYS, DEFAULT_REGISTRY_SURFACES, DEFAULT_PATTERNS, DEFAULT_ACTION_SURFACES, CreateContextOptions, ConflictError, CapabilitySurface, CancelledError, CacheError, CacheAdapter, CAPABILITY_SURFACES, BackoffOptions, AuthError, AuthAdapter, AssertionError, AnyKitError, AnyActionSpec, AmbiguousError, AdapterAuthError, ActionTrpcSpec, ActionSurface, ActionSpec, ActionRegistry, ActionMcpSpec, ActionCliSpec, ActionCliOption, ActionCliInputContext, ActionCapability, ActionApiSpec, ACTION_SURFACES, ACTION_CAPABILITIES };
|
|
20
|
+
export { zodToJsonSchema, withTimeout, validateInput, unwrapOrElse, toHttpResponse, toEnvelope, statusCodeMap, shouldRetry, serializeError, safeStringify, safeParse, retry, orElse, isRetryable, isRecoverable, isNonEmptyArray, getStatusCode, getExitCode, getBackoffDelay, getActionsForSurface, generateRequestId, expect, exitCodeMap, deserializeError, defineAction, createValidator, createRedactor, createLoggerFactory, createContext, createActionRegistry, combine3, combine2, capabilityAll, capability, assertNonEmpty, assertMatches, assertDefined, ValidationError, TimeoutOptions, TimeoutError, TaggedErrorClass, TaggedError, SyncHandler, SuccessEnvelope, StorageError, StorageAdapter, SerializedError, SerializeErrorOptions, SearchResult, SearchOptions, RetryOptions, Result, ResolvedConfig, RedactorConfig, Redactor, RedactionEvent, RedactionCallback, RateLimitError, PermissionError, PaginationMeta, OutfitterError, NotFoundError, NonEmptyArray, NetworkError, LoggerFactoryConfig, LoggerFactory, LoggerAdapter, Logger, LogMethod, LogMetadata, LogLevel, KitErrorProps, JsonSchema, InternalError, IndexStats, IndexError, IndexAdapter, HttpResponse, HttpMethod, HandlerContext, Handler, ErrorEnvelope, ErrorCode, ErrorCategory, EnvelopeMeta, Envelope, ERROR_CODES, DEFAULT_SENSITIVE_KEYS, DEFAULT_REGISTRY_SURFACES, DEFAULT_PATTERNS, DEFAULT_ACTION_SURFACES, CreateContextOptions, ConflictError, CapabilitySurface, CancelledError, CacheError, CacheAdapter, CAPABILITY_SURFACES, BackoffOptions, AuthError, AuthAdapter, AssertionError, AnyKitError, AnyActionSpec, AmbiguousError, AlreadyExistsError, AdapterAuthError, ActionTrpcSpec, ActionSurface, ActionSpec, ActionRegistry, ActionMcpSpec, ActionCliSpec, ActionCliOption, ActionCliInputContext, ActionCapability, ActionApiSpec, ACTION_SURFACES, ACTION_CAPABILITIES };
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
import"./shared/@outfitter/contracts-37gpc56f.js";
|
|
2
3
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "./shared/@outfitter/contracts-d0tq2adf.js";
|
|
10
|
-
import {
|
|
11
|
-
getBackoffDelay,
|
|
12
|
-
isRecoverable,
|
|
13
|
-
isRetryable,
|
|
14
|
-
shouldRetry
|
|
15
|
-
} from "./shared/@outfitter/contracts-4zaj7ejb.js";
|
|
4
|
+
combine2,
|
|
5
|
+
combine3,
|
|
6
|
+
expect,
|
|
7
|
+
orElse,
|
|
8
|
+
unwrapOrElse
|
|
9
|
+
} from "./shared/@outfitter/contracts-zx72gyh1.js";
|
|
16
10
|
import {
|
|
17
11
|
ACTION_SURFACES,
|
|
18
12
|
DEFAULT_REGISTRY_SURFACES,
|
|
@@ -20,47 +14,52 @@ import {
|
|
|
20
14
|
defineAction
|
|
21
15
|
} from "./shared/@outfitter/contracts-q0v44kef.js";
|
|
22
16
|
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
ACTION_CAPABILITIES,
|
|
18
|
+
CAPABILITY_SURFACES,
|
|
19
|
+
DEFAULT_ACTION_SURFACES,
|
|
20
|
+
capability,
|
|
21
|
+
capabilityAll,
|
|
22
|
+
getActionsForSurface
|
|
23
|
+
} from "./shared/@outfitter/contracts-d0tq2adf.js";
|
|
27
24
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
expect,
|
|
31
|
-
orElse,
|
|
32
|
-
unwrapOrElse
|
|
33
|
-
} from "./shared/@outfitter/contracts-zx72gyh1.js";
|
|
25
|
+
zodToJsonSchema
|
|
26
|
+
} from "./shared/@outfitter/contracts-wfht4q2b.js";
|
|
34
27
|
import {
|
|
35
28
|
assertDefined,
|
|
36
29
|
assertMatches,
|
|
37
30
|
assertNonEmpty,
|
|
38
31
|
isNonEmptyArray
|
|
39
|
-
} from "./shared/@outfitter/contracts-
|
|
32
|
+
} from "./shared/@outfitter/contracts-cp5c6dws.js";
|
|
40
33
|
import {
|
|
41
34
|
toEnvelope,
|
|
42
35
|
toHttpResponse
|
|
43
|
-
} from "./shared/@outfitter/contracts-
|
|
36
|
+
} from "./shared/@outfitter/contracts-btg89x4h.js";
|
|
44
37
|
import {
|
|
45
38
|
deserializeError,
|
|
46
39
|
safeParse,
|
|
47
40
|
safeStringify,
|
|
48
41
|
serializeError
|
|
49
|
-
} from "./shared/@outfitter/contracts-
|
|
50
|
-
import {
|
|
51
|
-
DEFAULT_PATTERNS,
|
|
52
|
-
DEFAULT_SENSITIVE_KEYS,
|
|
53
|
-
createRedactor
|
|
54
|
-
} from "./shared/@outfitter/contracts-s15x2rs4.js";
|
|
42
|
+
} from "./shared/@outfitter/contracts-5k6q4n48.js";
|
|
55
43
|
import {
|
|
56
44
|
createContext,
|
|
57
45
|
generateRequestId
|
|
58
46
|
} from "./shared/@outfitter/contracts-agmt8915.js";
|
|
47
|
+
import {
|
|
48
|
+
getBackoffDelay,
|
|
49
|
+
isRecoverable,
|
|
50
|
+
isRetryable,
|
|
51
|
+
shouldRetry
|
|
52
|
+
} from "./shared/@outfitter/contracts-4zaj7ejb.js";
|
|
53
|
+
import {
|
|
54
|
+
retry,
|
|
55
|
+
withTimeout
|
|
56
|
+
} from "./shared/@outfitter/contracts-r21yet6j.js";
|
|
59
57
|
import {
|
|
60
58
|
createValidator,
|
|
61
59
|
validateInput
|
|
62
|
-
} from "./shared/@outfitter/contracts-
|
|
60
|
+
} from "./shared/@outfitter/contracts-0snpmkdt.js";
|
|
63
61
|
import {
|
|
62
|
+
AlreadyExistsError,
|
|
64
63
|
AmbiguousError,
|
|
65
64
|
AssertionError,
|
|
66
65
|
AuthError,
|
|
@@ -78,11 +77,20 @@ import {
|
|
|
78
77
|
getExitCode,
|
|
79
78
|
getStatusCode,
|
|
80
79
|
statusCodeMap
|
|
81
|
-
} from "./shared/@outfitter/contracts-
|
|
80
|
+
} from "./shared/@outfitter/contracts-phjhz5q3.js";
|
|
81
|
+
import {
|
|
82
|
+
createLoggerFactory
|
|
83
|
+
} from "./shared/@outfitter/contracts-sm6vak1a.js";
|
|
84
|
+
import {
|
|
85
|
+
DEFAULT_PATTERNS,
|
|
86
|
+
DEFAULT_SENSITIVE_KEYS,
|
|
87
|
+
createRedactor
|
|
88
|
+
} from "./shared/@outfitter/contracts-s15x2rs4.js";
|
|
82
89
|
|
|
83
90
|
// packages/contracts/src/index.ts
|
|
84
91
|
import { Result, TaggedError } from "better-result";
|
|
85
92
|
export {
|
|
93
|
+
zodToJsonSchema,
|
|
86
94
|
withTimeout,
|
|
87
95
|
validateInput,
|
|
88
96
|
unwrapOrElse,
|
|
@@ -109,6 +117,7 @@ export {
|
|
|
109
117
|
defineAction,
|
|
110
118
|
createValidator,
|
|
111
119
|
createRedactor,
|
|
120
|
+
createLoggerFactory,
|
|
112
121
|
createContext,
|
|
113
122
|
createActionRegistry,
|
|
114
123
|
combine3,
|
|
@@ -138,6 +147,7 @@ export {
|
|
|
138
147
|
AuthError,
|
|
139
148
|
AssertionError,
|
|
140
149
|
AmbiguousError,
|
|
150
|
+
AlreadyExistsError,
|
|
141
151
|
ACTION_SURFACES,
|
|
142
152
|
ACTION_CAPABILITIES
|
|
143
153
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { LogLevel, LogMetadata, LogMethod, Logger, LoggerAdapter, LoggerFactory, LoggerFactoryConfig, createLoggerFactory } from "./shared/@outfitter/contracts-2g8r01zf";
|
|
2
|
+
export { createLoggerFactory, LoggerFactoryConfig, LoggerFactory, LoggerAdapter, Logger, LogMethod, LogMetadata, LogLevel };
|
package/dist/logging.js
ADDED
package/dist/recovery.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { BackoffOptions, getBackoffDelay, isRecoverable, isRetryable, shouldRetry } from "./shared/@outfitter/contracts-
|
|
2
|
-
import "./shared/@outfitter/contracts-
|
|
1
|
+
import { BackoffOptions, getBackoffDelay, isRecoverable, isRetryable, shouldRetry } from "./shared/@outfitter/contracts-evxky148";
|
|
2
|
+
import "./shared/@outfitter/contracts-r35bn9p6";
|
|
3
3
|
export { shouldRetry, isRetryable, isRecoverable, getBackoffDelay, BackoffOptions };
|
package/dist/resilience.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RetryOptions, TimeoutOptions, retry, withTimeout } from "./shared/@outfitter/contracts-
|
|
2
|
-
import "./shared/@outfitter/contracts-
|
|
1
|
+
import { RetryOptions, TimeoutOptions, retry, withTimeout } from "./shared/@outfitter/contracts-bdwg55c5";
|
|
2
|
+
import "./shared/@outfitter/contracts-r35bn9p6";
|
|
3
3
|
export { withTimeout, retry, TimeoutOptions, RetryOptions };
|
package/dist/resilience.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import {
|
|
3
3
|
retry,
|
|
4
4
|
withTimeout
|
|
5
|
-
} from "./shared/@outfitter/contracts-
|
|
6
|
-
import"./shared/@outfitter/contracts-
|
|
5
|
+
} from "./shared/@outfitter/contracts-r21yet6j.js";
|
|
6
|
+
import"./shared/@outfitter/contracts-phjhz5q3.js";
|
|
7
7
|
export {
|
|
8
8
|
withTimeout,
|
|
9
9
|
retry
|
package/dist/schema.d.ts
ADDED
package/dist/schema.js
ADDED
package/dist/serialization.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SerializeErrorOptions, deserializeError, safeParse, safeStringify, serializeError } from "./shared/@outfitter/contracts-
|
|
2
|
-
import "./shared/@outfitter/contracts-
|
|
1
|
+
import { SerializeErrorOptions, deserializeError, safeParse, safeStringify, serializeError } from "./shared/@outfitter/contracts-j08e95jw";
|
|
2
|
+
import "./shared/@outfitter/contracts-r35bn9p6";
|
|
3
3
|
export { serializeError, safeStringify, safeParse, deserializeError, SerializeErrorOptions };
|
package/dist/serialization.js
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
safeParse,
|
|
5
5
|
safeStringify,
|
|
6
6
|
serializeError
|
|
7
|
-
} from "./shared/@outfitter/contracts-
|
|
7
|
+
} from "./shared/@outfitter/contracts-5k6q4n48.js";
|
|
8
|
+
import"./shared/@outfitter/contracts-phjhz5q3.js";
|
|
8
9
|
import"./shared/@outfitter/contracts-s15x2rs4.js";
|
|
9
|
-
import"./shared/@outfitter/contracts-0cj49e1a.js";
|
|
10
10
|
export {
|
|
11
11
|
serializeError,
|
|
12
12
|
safeStringify,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared logging contracts for backend-agnostic logger integration.
|
|
3
|
+
*
|
|
4
|
+
* The `Logger` interface is the minimal surface required by handler contexts.
|
|
5
|
+
* `LoggerAdapter` and `createLoggerFactory` allow runtime packages to plug in
|
|
6
|
+
* backend-specific implementations while keeping transports backend-agnostic.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Log levels ordered from least to most severe.
|
|
10
|
+
*
|
|
11
|
+
* The special `silent` level disables logging output.
|
|
12
|
+
*/
|
|
13
|
+
type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal" | "silent";
|
|
14
|
+
/** Structured metadata attached to log messages. */
|
|
15
|
+
type LogMetadata = Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Message-first logger method with metadata-first overload for strict misuse
|
|
18
|
+
* detection in TypeScript. Calling with metadata first intentionally resolves to
|
|
19
|
+
* `never` for compile-time feedback.
|
|
20
|
+
*/
|
|
21
|
+
interface LogMethod {
|
|
22
|
+
(message: string, metadata?: LogMetadata): void;
|
|
23
|
+
(metadata: LogMetadata, message: string): never;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Logger interface for handler contexts and cross-package contracts.
|
|
27
|
+
*/
|
|
28
|
+
interface Logger {
|
|
29
|
+
trace: LogMethod;
|
|
30
|
+
debug: LogMethod;
|
|
31
|
+
info: LogMethod;
|
|
32
|
+
warn: LogMethod;
|
|
33
|
+
error: LogMethod;
|
|
34
|
+
fatal: LogMethod;
|
|
35
|
+
child(context: LogMetadata): Logger;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Configuration passed through the logger factory to backend adapters.
|
|
39
|
+
*
|
|
40
|
+
* `backend` carries adapter-specific configuration in a strongly typed way.
|
|
41
|
+
*/
|
|
42
|
+
interface LoggerFactoryConfig<TBackendOptions = unknown> {
|
|
43
|
+
/** Logger category/name identifying the source (e.g., "cli", "mcp") */
|
|
44
|
+
name: string;
|
|
45
|
+
/** Minimum level to emit */
|
|
46
|
+
level?: LogLevel;
|
|
47
|
+
/** Static context attached to every emitted record */
|
|
48
|
+
context?: LogMetadata;
|
|
49
|
+
/** Adapter-specific backend options */
|
|
50
|
+
backend?: TBackendOptions;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Backend adapter contract used by the logger factory.
|
|
54
|
+
*
|
|
55
|
+
* Runtime packages provide concrete adapters (for example logtape or custom
|
|
56
|
+
* implementations) behind this contract.
|
|
57
|
+
*/
|
|
58
|
+
interface LoggerAdapter<TBackendOptions = unknown> {
|
|
59
|
+
createLogger(config: LoggerFactoryConfig<TBackendOptions>): Logger;
|
|
60
|
+
flush?(): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Backend-agnostic logger factory surface consumed by CLI/MCP runtime code.
|
|
64
|
+
*/
|
|
65
|
+
interface LoggerFactory<TBackendOptions = unknown> {
|
|
66
|
+
createLogger(config: LoggerFactoryConfig<TBackendOptions>): Logger;
|
|
67
|
+
flush(): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create a logger factory from a backend adapter implementation.
|
|
71
|
+
*/
|
|
72
|
+
declare function createLoggerFactory<TBackendOptions = unknown>(adapter: LoggerAdapter<TBackendOptions>): LoggerFactory<TBackendOptions>;
|
|
73
|
+
export { LogLevel, LogMetadata, LogMethod, Logger, LoggerFactoryConfig, LoggerAdapter, LoggerFactory, createLoggerFactory };
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
DEFAULT_SENSITIVE_KEYS,
|
|
5
|
-
createRedactor
|
|
6
|
-
} from "./contracts-s15x2rs4.js";
|
|
7
|
-
import {
|
|
3
|
+
AlreadyExistsError,
|
|
8
4
|
AmbiguousError,
|
|
9
5
|
AssertionError,
|
|
10
6
|
AuthError,
|
|
@@ -17,7 +13,12 @@ import {
|
|
|
17
13
|
RateLimitError,
|
|
18
14
|
TimeoutError,
|
|
19
15
|
ValidationError
|
|
20
|
-
} from "./contracts-
|
|
16
|
+
} from "./contracts-phjhz5q3.js";
|
|
17
|
+
import {
|
|
18
|
+
DEFAULT_PATTERNS,
|
|
19
|
+
DEFAULT_SENSITIVE_KEYS,
|
|
20
|
+
createRedactor
|
|
21
|
+
} from "./contracts-s15x2rs4.js";
|
|
21
22
|
|
|
22
23
|
// packages/contracts/src/serialization.ts
|
|
23
24
|
import { Result } from "better-result";
|
|
@@ -26,6 +27,7 @@ var errorRegistry = {
|
|
|
26
27
|
AmbiguousError,
|
|
27
28
|
AssertionError,
|
|
28
29
|
NotFoundError,
|
|
30
|
+
AlreadyExistsError,
|
|
29
31
|
ConflictError,
|
|
30
32
|
PermissionError,
|
|
31
33
|
TimeoutError,
|
|
@@ -50,10 +52,22 @@ function extractContext(error) {
|
|
|
50
52
|
}
|
|
51
53
|
case "NotFoundError": {
|
|
52
54
|
const nfe = error;
|
|
55
|
+
if (nfe.context !== undefined) {
|
|
56
|
+
Object.assign(context, nfe.context);
|
|
57
|
+
}
|
|
53
58
|
context["resourceType"] = nfe.resourceType;
|
|
54
59
|
context["resourceId"] = nfe.resourceId;
|
|
55
60
|
break;
|
|
56
61
|
}
|
|
62
|
+
case "AlreadyExistsError": {
|
|
63
|
+
const aee = error;
|
|
64
|
+
if (aee.context !== undefined) {
|
|
65
|
+
Object.assign(context, aee.context);
|
|
66
|
+
}
|
|
67
|
+
context["resourceType"] = aee.resourceType;
|
|
68
|
+
context["resourceId"] = aee.resourceId;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
57
71
|
case "TimeoutError": {
|
|
58
72
|
const te = error;
|
|
59
73
|
context["operation"] = te.operation;
|
|
@@ -139,12 +153,30 @@ function deserializeError(data) {
|
|
|
139
153
|
}
|
|
140
154
|
return new ValidationError(props);
|
|
141
155
|
}
|
|
142
|
-
case "NotFoundError":
|
|
143
|
-
|
|
156
|
+
case "NotFoundError": {
|
|
157
|
+
const props = {
|
|
144
158
|
message: data.message,
|
|
145
159
|
resourceType: context["resourceType"] ?? "unknown",
|
|
146
160
|
resourceId: context["resourceId"] ?? "unknown"
|
|
147
|
-
}
|
|
161
|
+
};
|
|
162
|
+
const contextWithoutIdentity = Object.fromEntries(Object.entries(context).filter(([key]) => key !== "resourceType" && key !== "resourceId"));
|
|
163
|
+
if (Object.keys(contextWithoutIdentity).length > 0) {
|
|
164
|
+
props.context = contextWithoutIdentity;
|
|
165
|
+
}
|
|
166
|
+
return new NotFoundError(props);
|
|
167
|
+
}
|
|
168
|
+
case "AlreadyExistsError": {
|
|
169
|
+
const props = {
|
|
170
|
+
message: data.message,
|
|
171
|
+
resourceType: context["resourceType"] ?? "unknown",
|
|
172
|
+
resourceId: context["resourceId"] ?? "unknown"
|
|
173
|
+
};
|
|
174
|
+
const contextWithoutIdentity = Object.fromEntries(Object.entries(context).filter(([key]) => key !== "resourceType" && key !== "resourceId"));
|
|
175
|
+
if (Object.keys(contextWithoutIdentity).length > 0) {
|
|
176
|
+
props.context = contextWithoutIdentity;
|
|
177
|
+
}
|
|
178
|
+
return new AlreadyExistsError(props);
|
|
179
|
+
}
|
|
148
180
|
case "ConflictError": {
|
|
149
181
|
const props = {
|
|
150
182
|
message: data.message
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
serializeError
|
|
4
|
-
} from "./contracts-
|
|
4
|
+
} from "./contracts-5k6q4n48.js";
|
|
5
5
|
import {
|
|
6
6
|
generateRequestId
|
|
7
7
|
} from "./contracts-agmt8915.js";
|
|
8
8
|
import {
|
|
9
9
|
statusCodeMap
|
|
10
|
-
} from "./contracts-
|
|
10
|
+
} from "./contracts-phjhz5q3.js";
|
|
11
11
|
|
|
12
12
|
// packages/contracts/src/envelope.ts
|
|
13
13
|
function buildMeta(overrides) {
|