@adhd/apigen-base-logical 0.1.1 → 0.1.3

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.
@@ -28,6 +28,25 @@ export interface LogicalTypeCodec<Host = unknown> {
28
28
  readonly schema: SchemaNode;
29
29
  /** Structural, cheap test: does this codec own `node`? (format match, or x-apigen-codec===id). */
30
30
  matches(node: SchemaNode): boolean;
31
+ /**
32
+ * Value-side claim test, used ONLY on the schemaless path (a `{}` / `any`
33
+ * schema node, where `matches(node)` cannot decide anything).
34
+ *
35
+ * Implement this on — and only on — codecs whose HOST type is not
36
+ * JSON-native (`Date`, `bigint`, `Uint8Array`, non-finite `number`). Those
37
+ * are the values that genuinely need the `{$apigen,v}` envelope to survive
38
+ * a JSON round-trip. A codec whose host type IS JSON-native (`uuid` and
39
+ * `decimal` are both branded strings) must NOT implement it: a plain string
40
+ * already round-trips, and claiming it would rewrite a consumer's payload
41
+ * for no gain.
42
+ *
43
+ * A codec that omits `ownsValue` is never eligible for schemaless claiming.
44
+ * That is the safe default — passthrough loses nothing, whereas a wrong
45
+ * claim silently destroys data.
46
+ *
47
+ * MUST be pure and side-effect free.
48
+ */
49
+ ownsValue?(value: unknown): boolean;
31
50
  /** Host -> wire. MUST NOT mutate `value`; MUST be deterministic. */
32
51
  encode(value: Host, node: SchemaNode, ctx: TranscodeCtx): Wire;
33
52
  /** Wire -> host. MUST validate-then-construct; MUST be the inverse of `encode` across the vectors. */
package/package.json CHANGED
@@ -1,7 +1,25 @@
1
1
  {
2
2
  "name": "@adhd/apigen-base-logical",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "main": "./index.js",
5
5
  "module": "./index.mjs",
6
- "typings": "./index.d.ts"
6
+ "typings": "./index.d.ts",
7
+ "description": "Logical-type transcoding contracts for apigen",
8
+ "keywords": [
9
+ "api",
10
+ "codegen",
11
+ "logical-types",
12
+ "schema",
13
+ "typescript"
14
+ ],
15
+ "license": "MIT",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/PseudoSky/adhd.git",
19
+ "directory": "packages/apigen/apigen-base-logical"
20
+ },
21
+ "homepage": "https://github.com/PseudoSky/adhd/tree/main/packages/apigen/apigen-base-logical#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/PseudoSky/adhd/issues"
24
+ }
7
25
  }