@dxos/keys 0.8.4-main.ae835ea → 0.8.4-main.bbf232bc24

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,9 +1,13 @@
1
1
  {
2
2
  "name": "@dxos/keys",
3
- "version": "0.8.4-main.ae835ea",
3
+ "version": "0.8.4-main.bbf232bc24",
4
4
  "description": "Key utils and definitions.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
13
  "sideEffects": false,
@@ -17,23 +21,23 @@
17
21
  }
18
22
  },
19
23
  "types": "dist/types/src/index.d.ts",
20
- "typesVersions": {
21
- "*": {}
22
- },
23
24
  "files": [
24
25
  "dist",
25
26
  "src"
26
27
  ],
27
28
  "dependencies": {
28
- "effect": "3.18.3",
29
29
  "ulidx": "^2.3.0",
30
- "@dxos/debug": "0.8.4-main.ae835ea",
31
- "@dxos/invariant": "0.8.4-main.ae835ea",
32
- "@dxos/node-std": "0.8.4-main.ae835ea"
30
+ "@dxos/debug": "0.8.4-main.bbf232bc24",
31
+ "@dxos/invariant": "0.8.4-main.bbf232bc24",
32
+ "@dxos/node-std": "0.8.4-main.bbf232bc24"
33
33
  },
34
34
  "devDependencies": {
35
35
  "base32-decode": "^1.0.0",
36
- "base32-encode": "^2.0.0"
36
+ "base32-encode": "^2.0.0",
37
+ "effect": "3.20.0"
38
+ },
39
+ "peerDependencies": {
40
+ "effect": "3.20.0"
37
41
  },
38
42
  "publishConfig": {
39
43
  "access": "public"
package/src/dxn.ts CHANGED
@@ -2,9 +2,8 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import type { InspectOptionsStylized, inspect } from 'node:util';
6
-
7
5
  import * as Schema from 'effect/Schema';
6
+ import type { InspectOptionsStylized, inspect } from 'node:util';
8
7
 
9
8
  import { type DevtoolsFormatter, devtoolsFormatter, inspectCustom } from '@dxos/debug';
10
9
  import { assertArgument, invariant } from '@dxos/invariant';
@@ -33,7 +32,7 @@ export type QueueSubspaceTag = (typeof QueueSubspaceTags)[keyof typeof QueueSubs
33
32
  // Consider: https://github.com/multiformats/multiaddr
34
33
  // dxn:echo:[<space-id>:[<queue-id>:]]<object-id>
35
34
  // dxn:echo:[S/<space-id>:[Q/<queue-id>:]]<object-id>
36
- // dxn:type:dxos.org/markdown/Contact
35
+ // dxn:type:org.dxos.markdown.contact
37
36
 
38
37
  /**
39
38
  * DXN unambiguously names a resource like an ECHO object, schema definition, plugin, etc.
@@ -47,8 +46,8 @@ export type QueueSubspaceTag = (typeof QueueSubspaceTags)[keyof typeof QueueSubs
47
46
  * dxn:echo:<space key>:<echo id>
48
47
  * dxn:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
49
48
  * dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6
50
- * dxn:type:dxos.org/type/Calendar
51
- * dxn:plugin:dxos.org/agent/plugin/functions
49
+ * dxn:type:org.dxos.type.calendar
50
+ * dxn:plugin:org.dxos.agent.plugin.functions
52
51
  * ```
53
52
  */
54
53
  export class DXN {
@@ -57,11 +56,11 @@ export class DXN {
57
56
  static Schema = Schema.NonEmptyString.pipe(
58
57
  Schema.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),
59
58
  // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.
60
- // FormatAnnotation.set(FormatEnum.DXN),
59
+ // FormatAnnotation.set(TypeFormat.DXN),
61
60
  Schema.annotations({
62
61
  title: 'DXN',
63
62
  description: 'DXN URI',
64
- examples: ['dxn:type:example.com/type/MyType', 'dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6'],
63
+ examples: ['dxn:type:com.example.type.my-type', 'dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6'],
65
64
  }),
66
65
  );
67
66
 
@@ -140,14 +139,14 @@ export class DXN {
140
139
  }
141
140
 
142
141
  /**
143
- * @example `dxn:type:example.com/type/Contact`
142
+ * @example `dxn:type:com.example.type.person`
144
143
  */
145
144
  static fromTypename(typename: string): DXN {
146
145
  return new DXN(DXN.kind.TYPE, [typename]);
147
146
  }
148
147
 
149
148
  /**
150
- * @example `dxn:type:example.com/type/Contact:0.1.0`
149
+ * @example `dxn:type:com.example.type.person:0.1.0`
151
150
  */
152
151
  // TODO(dmaretskyi): Consider using @ as the version separator.
153
152
  static fromTypenameAndVersion(typename: string, version: string): DXN {
@@ -300,7 +299,7 @@ export class DXN {
300
299
  }
301
300
 
302
301
  return {
303
- subspaceTag,
302
+ subspaceTag: subspaceTag as QueueSubspaceTag,
304
303
  spaceId: spaceId as SpaceId,
305
304
  queueId,
306
305
  objectId: objectId as string | undefined,
@@ -338,7 +337,7 @@ export declare namespace DXN {
338
337
  };
339
338
 
340
339
  export type QueueDXN = {
341
- subspaceTag: string;
340
+ subspaceTag: QueueSubspaceTag;
342
341
  spaceId: SpaceId;
343
342
  queueId: string; // TODO(dmaretskyi): ObjectId.
344
343
  objectId?: string; // TODO(dmaretskyi): ObjectId.
package/src/public-key.ts CHANGED
@@ -2,10 +2,9 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { type InspectOptionsStylized, type inspect } from 'node:util';
6
-
7
5
  import base32Decode from 'base32-decode';
8
6
  import base32Encode from 'base32-encode';
7
+ import { type InspectOptionsStylized, type inspect } from 'node:util';
9
8
 
10
9
  import {
11
10
  type DevtoolsFormatter,
@@ -217,7 +216,7 @@ export class PublicKey implements Equatable {
217
216
  return 'B' + base32Encode(this._value, 'RFC4648');
218
217
  }
219
218
 
220
- truncate(length = undefined): string {
219
+ truncate(length?: number): string {
221
220
  return truncateKey(this, length);
222
221
  }
223
222
 
package/src/space-id.ts CHANGED
@@ -17,7 +17,7 @@ const MULTIBASE_PREFIX = 'B';
17
17
 
18
18
  const ENCODED_LENGTH = 33;
19
19
 
20
- const isValid = (value: string): value is SpaceId => {
20
+ const isValid = (value: unknown): value is SpaceId => {
21
21
  return typeof value === 'string' && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;
22
22
  };
23
23
 
@@ -33,7 +33,7 @@ export const SpaceId: Schema.Schema<SpaceId, string> & {
33
33
  byteLength: number;
34
34
  encode: (value: Uint8Array) => SpaceId;
35
35
  decode: (value: SpaceId) => Uint8Array;
36
- isValid: (value: string) => value is SpaceId;
36
+ isValid: (value: unknown) => value is SpaceId;
37
37
  make: (value: string) => SpaceId;
38
38
  random: () => SpaceId;
39
39
  } = class extends Schema.String.pipe(Schema.filter(isValid)) {