@dxos/keys 0.9.1-main.c7dcc2e112 → 0.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/keys",
3
- "version": "0.9.1-main.c7dcc2e112",
3
+ "version": "0.10.0",
4
4
  "description": "Key utils and definitions.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -27,17 +27,17 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "ulidx": "^2.3.0",
30
- "@dxos/invariant": "0.9.1-main.c7dcc2e112",
31
- "@dxos/debug": "0.9.1-main.c7dcc2e112",
32
- "@dxos/node-std": "0.9.1-main.c7dcc2e112"
30
+ "@dxos/debug": "0.10.0",
31
+ "@dxos/node-std": "0.10.0",
32
+ "@dxos/invariant": "0.10.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "base32-decode": "^1.0.0",
36
36
  "base32-encode": "^2.0.0",
37
- "effect": "3.21.3"
37
+ "effect": "3.21.4"
38
38
  },
39
39
  "peerDependencies": {
40
- "effect": "3.21.3"
40
+ "effect": "3.21.4"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"
package/src/DXN.test.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ import * as Schema from 'effect/Schema';
5
6
  import { describe, test } from 'vitest';
6
7
 
7
8
  import * as DXN from './DXN';
@@ -120,3 +121,19 @@ describe('DXN.getVersion', () => {
120
121
  expect(DXN.getVersion(DXN.make('org.dxos.type.calendar'))).toBeUndefined();
121
122
  });
122
123
  });
124
+
125
+ describe('DXN.NameSchema', () => {
126
+ const isName = Schema.is(DXN.NameSchema);
127
+
128
+ test('accepts a well-formed NSID name (no dxn: prefix)', ({ expect }) => {
129
+ expect(isName('com.anthropic.model.claude-sonnet-4-6.default')).toBe(true);
130
+ expect(isName('org.dxos.provider.edge')).toBe(true);
131
+ expect(isName('com.meta.model.llama-3-2-1b.instruct')).toBe(true);
132
+ });
133
+
134
+ test('rejects malformed names', ({ expect }) => {
135
+ expect(isName('single')).toBe(false); // not multi-segment
136
+ expect(isName('com.example.model.has-hyphen')).toBe(false); // final segment has a hyphen
137
+ expect(isName('dxn:com.example.type.thing')).toBe(false); // already a full DXN, not a bare name
138
+ });
139
+ });
package/src/DXN.ts CHANGED
@@ -57,6 +57,17 @@ export type Name<T extends string> = [string] extends [T]
57
57
  : T
58
58
  : never;
59
59
 
60
+ /**
61
+ * Effect Schema validating an NSID name — the `dxn:`-less portion — at runtime, mirroring the rules
62
+ * the {@link Name} type checks at compile time (multi-segment; camelCase final segment). Pairs with
63
+ * the {@link Name} type for schema fields that hold a bare NSID (e.g. a model id passed to a creator
64
+ * helper). Named `NameSchema` because a value cannot share the generic `Name` type's name.
65
+ */
66
+ export const NameSchema: Schema.Schema<string, string> = Schema.String.pipe(
67
+ Schema.filter((value) => DXN_SPEC_REGEXP.test(`dxn:${value}`), { message: () => 'Invalid NSID name' }),
68
+ Schema.annotations({ title: 'DXN.Name', description: 'NSID name (the dxn: prefix omitted)' }),
69
+ );
70
+
60
71
  /**
61
72
  * Cheap prefix check — does not validate the full DXN grammar.
62
73
  * Sufficient for narrowing a URI to a DXN.