@haverstack/wire-types 0.5.0 → 0.7.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 CHANGED
@@ -16,10 +16,10 @@ npm install @haverstack/wire-types
16
16
 
17
17
  Each wire type mirrors a domain type from `@haverstack/core` with `Date` fields replaced by ISO 8601 strings.
18
18
 
19
- | Wire type | Domain type |
20
- |-----------|-------------|
21
- | `WireRecord` | `StackRecord` |
22
- | `WireType` | `StackType` |
19
+ | Wire type | Domain type |
20
+ | ------------- | --------------- |
21
+ | `WireRecord` | `StackRecord` |
22
+ | `WireType` | `StackType` |
23
23
  | `WireVersion` | `RecordVersion` |
24
24
 
25
25
  ## Serialization
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { StackRecord, StackType, RecordVersion, Association, Permission } from '@haverstack/core';
1
+ import type { StackRecord, StackType, RecordVersion, Association, Permission, ValidationError, SchemaDriftViolation, StackErrorCode } from '@haverstack/core';
2
+ import type { AdapterCapabilities } from '@haverstack/core/adapter';
2
3
  export type WireRecord = {
3
4
  id: string;
4
5
  typeId: string;
@@ -9,10 +10,29 @@ export type WireRecord = {
9
10
  parentId?: string;
10
11
  entityId?: string;
11
12
  appId?: string;
13
+ principalId?: string;
12
14
  deletedAt?: string;
13
15
  permissions?: Permission[];
14
16
  associations?: Association[];
15
17
  };
18
+ /**
19
+ * The response envelope of `GET /records` and `POST /records/query`.
20
+ *
21
+ * `cursor` is the only end-of-results signal: `records` may be empty while
22
+ * `cursor` is non-null, since a server filters a bounded window of stored
23
+ * Records per request against the requester's permissions.
24
+ *
25
+ * `total` is typed `null` rather than `number | null` because every wire
26
+ * response has passed a permission boundary, and an unfiltered count would
27
+ * report how many Records exist beyond what the requester may read. A
28
+ * server MUST NOT populate it; `APIAdapter` discards a number if one
29
+ * arrives anyway. See docs/spec/wire-format.md § Response envelope.
30
+ */
31
+ export type WireQueryResponse = {
32
+ records: WireRecord[];
33
+ cursor: string | null;
34
+ total: null;
35
+ };
16
36
  export type WireType = {
17
37
  id: string;
18
38
  baseId: string;
@@ -25,13 +45,163 @@ export type WireType = {
25
45
  };
26
46
  export type WireVersion = {
27
47
  version: number;
48
+ typeId: string;
28
49
  content: Record<string, unknown>;
29
50
  updatedAt: string;
30
51
  entityId?: string;
52
+ associations?: Association[];
53
+ permissions?: Permission[];
31
54
  };
32
55
  export declare function serializeRecord(r: StackRecord): WireRecord;
33
56
  export declare function serializeType(t: StackType): WireType;
34
57
  export declare function serializeVersion(v: RecordVersion): WireVersion;
35
58
  /** Parse an ISO date string from a wire body, returns undefined if absent or invalid. */
36
59
  export declare function parseDate(val: unknown): Date | undefined;
60
+ /**
61
+ * Alias of core's StackErrorCode: the vocabulary belongs with the classes
62
+ * that carry it, and StackError.code is typed by it, so re-declaring the
63
+ * union here would be a second copy to drift.
64
+ */
65
+ export type WireErrorCode = StackErrorCode;
66
+ export type WireError = {
67
+ error: {
68
+ code: WireErrorCode;
69
+ message: string;
70
+ /** Field-level validation failures. Only present for code: 'validation'. */
71
+ details?: ValidationError[];
72
+ /** ifVersion/If-Match precondition state. Only present for code: 'version_conflict'. */
73
+ versionConflict?: {
74
+ recordId: string;
75
+ expectedVersion: number;
76
+ actualVersion: number;
77
+ };
78
+ /** The rejected defineType() call's target and violations. Only present for code: 'schema_drift'. */
79
+ schemaDrift?: {
80
+ typeId: string;
81
+ violations: SchemaDriftViolation[];
82
+ };
83
+ };
84
+ };
85
+ /** Canonical HTTP status for each wire error code. */
86
+ export declare const WIRE_ERROR_STATUS: Record<WireErrorCode, number>;
87
+ /**
88
+ * Statuses that unambiguously imply a wire error code, for reconstructing
89
+ * an error from status alone when a response has no parseable wire error
90
+ * body. 500 is deliberately excluded — it would misclassify ordinary
91
+ * server bugs as StackMigrationError. See docs/spec/wire-format.md
92
+ * § Wire error body.
93
+ */
94
+ export declare const STATUS_TO_CODE: Partial<Record<number, WireErrorCode>>;
95
+ /** Type guard: does this parsed JSON body look like a WireError? */
96
+ export declare function isWireError(body: unknown): body is WireError;
97
+ /**
98
+ * Convert a thrown core error into its wire response. Used by server
99
+ * implementations. Returns null for anything that isn't a StackError —
100
+ * callers fall back to their own generic error handling, so an ordinary bug
101
+ * stays a bare 500 rather than being dressed as a protocol error.
102
+ */
103
+ export declare function serializeError(err: unknown): {
104
+ status: number;
105
+ body: WireError;
106
+ } | null;
107
+ /** Reconstruct the core error a WireError body describes. */
108
+ export declare function deserializeError(body: WireError): Error;
109
+ /**
110
+ * Reconstruct a core error from an HTTP status alone (no usable wire error
111
+ * body). Returns null for statuses with no unambiguous code — callers
112
+ * should fall back to a generic adapter-level error.
113
+ */
114
+ export declare function errorForStatus(status: number, message: string): Error | null;
115
+ /**
116
+ * The wire protocol this package describes. Bump the major when a change
117
+ * would make an older client read a response wrongly; bump the minor for
118
+ * additions an older client can ignore. See docs/spec/wire-format.md
119
+ * § Version negotiation.
120
+ */
121
+ export declare const WIRE_PROTOCOL_VERSION = "1.0";
122
+ /** GET /.well-known/stack. See docs/spec/wire-format.md § Discovery. */
123
+ export type DiscoveryResponse = {
124
+ version: string;
125
+ entityId: string;
126
+ timezone?: string;
127
+ capabilities: AdapterCapabilities;
128
+ auth?: DiscoveryAuth;
129
+ };
130
+ /**
131
+ * How a token can be earned here. Optional, and absent means only whatever
132
+ * issuance scheme the server arranged out of band — a client holding a DID
133
+ * credential then has nothing to perform and is told so at open(), rather
134
+ * than discovering it as a 404 partway through a handshake.
135
+ *
136
+ * An object rather than a boolean because issuance is the surface most
137
+ * likely to grow one: a consent flow arrives as another entry here.
138
+ */
139
+ export type DiscoveryAuth = {
140
+ methods: AuthMethod[];
141
+ };
142
+ /** The challenge–response handshake of docs/spec/wire-format.md § Authentication. */
143
+ export declare const AUTH_METHOD_DID_CHALLENGE = "did-challenge";
144
+ export type AuthMethod = typeof AUTH_METHOD_DID_CHALLENGE;
145
+ /** Whether a server advertises the DID challenge–response handshake. */
146
+ export declare function supportsDidChallenge(discovery: DiscoveryResponse): boolean;
147
+ /** POST /auth/challenge request. */
148
+ export type AuthChallengeRequest = {
149
+ did: string;
150
+ };
151
+ /** POST /auth/challenge response. */
152
+ export type AuthChallengeResponse = {
153
+ /** Opaque, single-use, base64url-charset. Bound to the requested DID. */
154
+ nonce: string;
155
+ expiresAt: string;
156
+ };
157
+ /** POST /auth/token request. `signature` is base64url. */
158
+ export type AuthTokenRequest = {
159
+ did: string;
160
+ nonce: string;
161
+ signature: string;
162
+ };
163
+ /**
164
+ * POST /auth/token response. Both identities are always present, and this
165
+ * endpoint always reports them equal — a handshake proves key possession,
166
+ * which says nothing about whom that key may act for. The pair is reported
167
+ * anyway so an issuance path that does delegate needs no new shape.
168
+ * See docs/spec/wire-format.md § Authentication.
169
+ */
170
+ export type AuthTokenResponse = {
171
+ token: string;
172
+ expiresAt?: string;
173
+ principalId: string;
174
+ subjectId: string;
175
+ };
176
+ /**
177
+ * Auth failures have their own vocabulary, deliberately outside
178
+ * WireErrorCode: no Stack operation has begun, so none of them is a
179
+ * StackError and none has a class to reconstruct. The split a client acts
180
+ * on is retryable versus fatal — a stale nonce warrants a fresh handshake,
181
+ * a rejected signature never will.
182
+ */
183
+ export type WireAuthErrorCode = 'invalid_did' | 'unknown_nonce' | 'expired_nonce' | 'invalid_signature';
184
+ export type WireAuthError = {
185
+ error: {
186
+ code: WireAuthErrorCode;
187
+ message: string;
188
+ };
189
+ };
190
+ export declare const WIRE_AUTH_ERROR_STATUS: Record<WireAuthErrorCode, number>;
191
+ /** Type guard: does this parsed JSON body look like a WireAuthError? */
192
+ export declare function isWireAuthError(body: unknown): body is WireAuthError;
193
+ /** Whether retrying the handshake from a fresh nonce could succeed. */
194
+ export declare function isRetryableAuthError(code: WireAuthErrorCode): boolean;
195
+ /** Splits a MAJOR.MINOR protocol version. Returns null if it isn't one. */
196
+ export declare function parseProtocolVersion(version: string): {
197
+ major: number;
198
+ minor: number;
199
+ } | null;
200
+ /**
201
+ * Majors must match; minors never have to. A higher server minor is additive
202
+ * fields this client ignores, and a higher client minor is optional fields
203
+ * the server may omit — neither can make a response read wrongly, which is
204
+ * the only thing a major bump signals.
205
+ */
206
+ export declare function isProtocolCompatible(version: string, against?: string): boolean;
37
207
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,UAAU,EACX,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EA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ED,uEAAuE;AACvE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAErE;AAED,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAG7F;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,SAAwB,GAAG,OAAO,CAI9F"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { StackError, StackValidationError, StackPermissionError, StackNotFoundError, StackConflictError, StackVersionConflictError, StackMigrationError, StackQueryError, StackSchemaDriftError, StackPayloadTooLargeError, StackTimeoutError, } from '@haverstack/core';
1
2
  export function serializeRecord(r) {
2
3
  const w = {
3
4
  id: r.id,
@@ -13,6 +14,8 @@ export function serializeRecord(r) {
13
14
  w.entityId = r.entityId;
14
15
  if (r.appId !== undefined)
15
16
  w.appId = r.appId;
17
+ if (r.principalId !== undefined)
18
+ w.principalId = r.principalId;
16
19
  if (r.deletedAt !== undefined)
17
20
  w.deletedAt = r.deletedAt.toISOString();
18
21
  if (r.permissions !== undefined)
@@ -38,11 +41,16 @@ export function serializeType(t) {
38
41
  export function serializeVersion(v) {
39
42
  const w = {
40
43
  version: v.version,
44
+ typeId: v.typeId,
41
45
  content: v.content,
42
46
  updatedAt: v.updatedAt.toISOString(),
43
47
  };
44
48
  if (v.entityId !== undefined)
45
49
  w.entityId = v.entityId;
50
+ if (v.associations !== undefined)
51
+ w.associations = v.associations;
52
+ if (v.permissions !== undefined)
53
+ w.permissions = v.permissions;
46
54
  return w;
47
55
  }
48
56
  /** Parse an ISO date string from a wire body, returns undefined if absent or invalid. */
@@ -52,4 +60,197 @@ export function parseDate(val) {
52
60
  const d = new Date(val);
53
61
  return isNaN(d.getTime()) ? undefined : d;
54
62
  }
63
+ /** Canonical HTTP status for each wire error code. */
64
+ export const WIRE_ERROR_STATUS = {
65
+ bad_request: 400,
66
+ permission: 403,
67
+ not_found: 404,
68
+ conflict: 409,
69
+ // 412 (not 409): RFC 7232's status for a failed If-Match precondition,
70
+ // and distinct from 'conflict' — StackVersionConflictError is not a
71
+ // StackConflictError subtype (see its doc comment), so each code keeps
72
+ // its own unambiguous status, including for the status-only fallback
73
+ // below.
74
+ version_conflict: 412,
75
+ validation: 422,
76
+ /**
77
+ * No core code path currently produces a StackMigrationError over the
78
+ * wire (migration-graph errors are thrown during client-side migration
79
+ * registration, never as a server response) — this entry exists so a
80
+ * future server-side migration-graph check has a defined status to use.
81
+ */
82
+ migration: 500,
83
+ // Shares 409 with 'conflict', so a schema-drift response without a
84
+ // parseable body degrades to a generic StackConflictError in
85
+ // status-only reconstruction. See docs/spec/wire-format.md § Wire error
86
+ // body.
87
+ schema_drift: 409,
88
+ // 413 is unambiguous — no other wire code shares it — so status-only
89
+ // reconstruction (STATUS_TO_CODE below) recovers this class even from a
90
+ // bodyless response (e.g. a reverse proxy's own request-entity-too-large
91
+ // page, not the server's JSON error body).
92
+ payload_too_large: 413,
93
+ /**
94
+ * 503, not 408 or 504: the request arrived fine (408 says it didn't) and
95
+ * the server is not a gateway (504 says it is) — it declined to keep
96
+ * spending its own time on this one. Retryable, which is the part a
97
+ * client acts on, and the reason a query timeout must not reuse
98
+ * `bad_request`: that code means "malformed, retrying won't help."
99
+ */
100
+ timeout: 503,
101
+ };
102
+ /**
103
+ * Statuses that unambiguously imply a wire error code, for reconstructing
104
+ * an error from status alone when a response has no parseable wire error
105
+ * body. 500 is deliberately excluded — it would misclassify ordinary
106
+ * server bugs as StackMigrationError. See docs/spec/wire-format.md
107
+ * § Wire error body.
108
+ */
109
+ export const STATUS_TO_CODE = {
110
+ 400: 'bad_request',
111
+ 403: 'permission',
112
+ 404: 'not_found',
113
+ 409: 'conflict',
114
+ 412: 'version_conflict',
115
+ 422: 'validation',
116
+ 413: 'payload_too_large',
117
+ // 503 is deliberately excluded, for the same reason as 500: a bodyless
118
+ // 503 is a load balancer or a restarting process saying "not right now",
119
+ // and reporting that as StackTimeoutError would tell an app its query
120
+ // was too expensive when the server never saw it. The typed body is
121
+ // what distinguishes the two, so `timeout` only reconstructs from one.
122
+ };
123
+ const KNOWN_CODES = new Set(Object.keys(WIRE_ERROR_STATUS));
124
+ /** Type guard: does this parsed JSON body look like a WireError? */
125
+ export function isWireError(body) {
126
+ if (!body || typeof body !== 'object')
127
+ return false;
128
+ const err = body.error;
129
+ if (!err || typeof err !== 'object')
130
+ return false;
131
+ const code = err.code;
132
+ const message = err.message;
133
+ return typeof code === 'string' && KNOWN_CODES.has(code) && typeof message === 'string';
134
+ }
135
+ /**
136
+ * Convert a thrown core error into its wire response. Used by server
137
+ * implementations. Returns null for anything that isn't a StackError —
138
+ * callers fall back to their own generic error handling, so an ordinary bug
139
+ * stays a bare 500 rather than being dressed as a protocol error.
140
+ */
141
+ export function serializeError(err) {
142
+ if (!(err instanceof StackError))
143
+ return null;
144
+ const error = { code: err.code, message: err.message };
145
+ // The three classes carrying structured payload still need instanceof: a
146
+ // literal `code` doesn't narrow a class type to its subclass in TypeScript.
147
+ // Order-independent, since these are leaves with no subtype relation.
148
+ if (err instanceof StackValidationError) {
149
+ error.details = err.errors;
150
+ }
151
+ else if (err instanceof StackVersionConflictError) {
152
+ error.versionConflict = {
153
+ recordId: err.recordId,
154
+ expectedVersion: err.expectedVersion,
155
+ actualVersion: err.actualVersion,
156
+ };
157
+ }
158
+ else if (err instanceof StackSchemaDriftError) {
159
+ error.schemaDrift = { typeId: err.typeId, violations: err.violations };
160
+ }
161
+ return { status: WIRE_ERROR_STATUS[err.code], body: { error } };
162
+ }
163
+ /** Reconstruct the core error a WireError body describes. */
164
+ export function deserializeError(body) {
165
+ const { code, message, details, versionConflict, schemaDrift } = body.error;
166
+ switch (code) {
167
+ case 'validation':
168
+ return new StackValidationError(details ?? []);
169
+ case 'permission':
170
+ return new StackPermissionError(message);
171
+ case 'not_found':
172
+ return new StackNotFoundError(message);
173
+ case 'conflict':
174
+ return new StackConflictError(message);
175
+ case 'version_conflict':
176
+ return new StackVersionConflictError(message, versionConflict?.recordId ?? '', versionConflict?.expectedVersion ?? -1, versionConflict?.actualVersion ?? -1);
177
+ case 'bad_request':
178
+ return new StackQueryError(message);
179
+ case 'migration':
180
+ return new StackMigrationError(message);
181
+ case 'schema_drift':
182
+ return new StackSchemaDriftError(schemaDrift?.typeId ?? '', schemaDrift?.violations ?? []);
183
+ case 'payload_too_large':
184
+ return new StackPayloadTooLargeError(message);
185
+ case 'timeout':
186
+ return new StackTimeoutError(message);
187
+ }
188
+ }
189
+ /**
190
+ * Reconstruct a core error from an HTTP status alone (no usable wire error
191
+ * body). Returns null for statuses with no unambiguous code — callers
192
+ * should fall back to a generic adapter-level error.
193
+ */
194
+ export function errorForStatus(status, message) {
195
+ const code = STATUS_TO_CODE[status];
196
+ return code ? deserializeError({ error: { code, message } }) : null;
197
+ }
198
+ // -------------------------------------------------------
199
+ // Discovery
200
+ // -------------------------------------------------------
201
+ /**
202
+ * The wire protocol this package describes. Bump the major when a change
203
+ * would make an older client read a response wrongly; bump the minor for
204
+ * additions an older client can ignore. See docs/spec/wire-format.md
205
+ * § Version negotiation.
206
+ */
207
+ export const WIRE_PROTOCOL_VERSION = '1.0';
208
+ /** The challenge–response handshake of docs/spec/wire-format.md § Authentication. */
209
+ export const AUTH_METHOD_DID_CHALLENGE = 'did-challenge';
210
+ /** Whether a server advertises the DID challenge–response handshake. */
211
+ export function supportsDidChallenge(discovery) {
212
+ return discovery.auth?.methods?.includes(AUTH_METHOD_DID_CHALLENGE) ?? false;
213
+ }
214
+ export const WIRE_AUTH_ERROR_STATUS = {
215
+ // Malformed input, not a rejected credential — there is nothing here to
216
+ // authenticate yet.
217
+ invalid_did: 400,
218
+ unknown_nonce: 401,
219
+ expired_nonce: 401,
220
+ invalid_signature: 401,
221
+ };
222
+ /** Codes a fresh handshake can resolve. Anything else is fatal to retry. */
223
+ const RETRYABLE_AUTH_CODES = new Set(['unknown_nonce', 'expired_nonce']);
224
+ const KNOWN_AUTH_CODES = new Set(Object.keys(WIRE_AUTH_ERROR_STATUS));
225
+ /** Type guard: does this parsed JSON body look like a WireAuthError? */
226
+ export function isWireAuthError(body) {
227
+ if (!body || typeof body !== 'object')
228
+ return false;
229
+ const err = body.error;
230
+ if (!err || typeof err !== 'object')
231
+ return false;
232
+ const code = err.code;
233
+ const message = err.message;
234
+ return typeof code === 'string' && KNOWN_AUTH_CODES.has(code) && typeof message === 'string';
235
+ }
236
+ /** Whether retrying the handshake from a fresh nonce could succeed. */
237
+ export function isRetryableAuthError(code) {
238
+ return RETRYABLE_AUTH_CODES.has(code);
239
+ }
240
+ /** Splits a MAJOR.MINOR protocol version. Returns null if it isn't one. */
241
+ export function parseProtocolVersion(version) {
242
+ const match = /^(\d+)\.(\d+)$/.exec(version);
243
+ return match ? { major: Number(match[1]), minor: Number(match[2]) } : null;
244
+ }
245
+ /**
246
+ * Majors must match; minors never have to. A higher server minor is additive
247
+ * fields this client ignores, and a higher client minor is optional fields
248
+ * the server may omit — neither can make a response read wrongly, which is
249
+ * the only thing a major bump signals.
250
+ */
251
+ export function isProtocolCompatible(version, against = WIRE_PROTOCOL_VERSION) {
252
+ const server = parseProtocolVersion(version);
253
+ const client = parseProtocolVersion(against);
254
+ return server !== null && client !== null && server.major === client.major;
255
+ }
55
256
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyCA,MAAM,UAAU,eAAe,CAAC,CAAc;IAC5C,MAAM,CAAC,GAAe;QACpB,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE;QACpC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE;QAC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B,CAAC,OAAe,EAAE,OAAO,GAAG,qBAAqB;IACnF,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC7C,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC;AAC7E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haverstack/wire-types",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "HTTP wire types and serialization for Haverstack",
5
5
  "type": "module",
6
6
  "exports": {
@@ -15,15 +15,17 @@
15
15
  "dist"
16
16
  ],
17
17
  "dependencies": {
18
- "@haverstack/core": "0.5.0"
18
+ "@haverstack/core": "^0.9.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/node": "^22.0.0",
22
- "typescript": "^5.5.0"
22
+ "typescript": "^5.5.0",
23
+ "vitest": "^2.0.0"
23
24
  },
24
25
  "scripts": {
25
26
  "build": "tsc -p tsconfig.build.json",
27
+ "test": "vitest run",
26
28
  "typecheck": "tsc --noEmit",
27
- "lint": "eslint src"
29
+ "lint": "eslint src tests"
28
30
  }
29
31
  }