@oxyhq/contracts 0.5.0 → 0.6.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.
@@ -37,7 +37,10 @@ import { z } from 'zod';
37
37
  * - `first` / `last` default to `''` in Mongo, so they are optional on the wire.
38
38
  * - `full` is a Mongoose virtual — absent unless the query materialised
39
39
  * virtuals or the serializer composed it.
40
- * - `displayName` is the required canonical app-facing display string.
40
+ * - `displayName` is the canonical app-facing display string when present.
41
+ * It is OPTIONAL on the wire: the API still synthesizes a default today, but
42
+ * the contract no longer guarantees it, so consumers fall back to a handle
43
+ * (e.g. `getNormalizedUserHandle`) when it is absent.
41
44
  *
42
45
  * This is declared as an explicit `interface` rather than being inferred from
43
46
  * the runtime schema via `z.infer<typeof userNameSchema>`. Inferring it produced
@@ -47,7 +50,7 @@ import { z } from 'zod';
47
50
  * Under a consumer's `moduleResolution: "node"` (node10), that chain does not
48
51
  * always resolve, so `name.displayName` silently widened to `{}` and broke the
49
52
  * "render `name.displayName` directly" contract at the type level. An explicit
50
- * interface emits `displayName: string` literally and survives BOTH `node` and
53
+ * interface emits `displayName?: string` literally and survives BOTH `node` and
51
54
  * `bundler` resolution. The index signature preserves the passthrough behaviour
52
55
  * (additive name fields are tolerated without a coordinated contract bump).
53
56
  */
@@ -55,16 +58,18 @@ export interface UserNameResponse {
55
58
  first?: string;
56
59
  last?: string;
57
60
  full?: string;
58
- /** Required canonical display string — render this directly. */
59
- displayName: string;
61
+ /** Canonical display string when present — render this directly. */
62
+ displayName?: string;
60
63
  [key: string]: unknown;
61
64
  }
62
65
  export declare const userNameSchema: z.ZodType<UserNameResponse>;
63
66
  /**
64
67
  * The canonical user object emitted by `formatUserResponse`.
65
68
  *
66
- * `id` and `name.displayName` are guaranteed on formatted user DTOs. The rest
67
- * is forwarded from the user document and may be absent depending on the query's
69
+ * `id` is present on formatted user DTOs. `name.displayName` is OPTIONAL on the
70
+ * contract the API still synthesizes a default today, but consumers must not
71
+ * assume it is present and should fall back to a handle when it is absent. The
72
+ * rest is forwarded from the user document and may be absent depending on the query's
68
73
  * `.select(...)`/`.lean()` projection. Both `id` and `_id` are accepted because
69
74
  * some raw-document responses carry `_id` instead of `id`; resolve the
70
75
  * identifier with {@link resolveUserId}.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/contracts",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "OxyHQ API contracts — single source of truth for request/response Zod schemas and inferred types, shared by the backend and the client SDKs",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",