@dxos/keys 0.7.5-labs.a279d8c → 0.7.5-main.2567c87

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.
@@ -1,6 +1,5 @@
1
1
  import type { inspect, InspectOptionsStylized } from 'node:util';
2
2
  import { inspectCustom } from '@dxos/debug';
3
- import type { SpaceId } from './space-id';
4
3
  /**
5
4
  * DXN unambiguously names a resource like an ECHO object, schema definition, plugin, etc.
6
5
  * Each DXN starts with a dx prefix, followed by a resource kind.
@@ -24,26 +23,12 @@ export declare class DXN {
24
23
  * Kind constants.
25
24
  */
26
25
  static kind: Readonly<{
27
- /**
28
- * dxn:type:<type name>[:<version>]
29
- */
30
26
  TYPE: "type";
31
- /**
32
- * dxn:echo:<space id>:<echo id>
33
- * dxn:echo:@:<echo id>
34
- */
35
27
  ECHO: "echo";
36
- /**
37
- * dxn:queue:<subspace tag>:<space id>:<queue id>[:object id]
38
- * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
39
- * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
40
- */
41
- QUEUE: "queue";
42
28
  }>;
43
29
  static equals(a: DXN, b: DXN): boolean;
44
30
  static isDXNString(dxn: string): boolean;
45
31
  static parse(dxn: string): DXN;
46
- static parse(dxn: string, noThrow: boolean): DXN | undefined;
47
32
  /**
48
33
  * @example `dxn:type:example.com/type/Contact`
49
34
  */
@@ -61,9 +46,10 @@ export declare class DXN {
61
46
  get parts(): string[];
62
47
  toTypename(): string;
63
48
  hasTypenameOf(typename: string): boolean;
64
- asTypeDXN(): DXN.TypeDXN | undefined;
65
- asEchoDXN(): DXN.EchoDXN | undefined;
66
- asQueueDXN(): DXN.QueueDXN | undefined;
49
+ asTypeDXN(): {
50
+ type: string;
51
+ version: string | undefined;
52
+ } | undefined;
67
53
  isLocalObjectId(): boolean;
68
54
  toString(): string;
69
55
  /**
@@ -71,28 +57,8 @@ export declare class DXN {
71
57
  */
72
58
  [inspectCustom](depth: number, options: InspectOptionsStylized, inspectFn: typeof inspect): string;
73
59
  }
74
- export declare namespace DXN {
75
- type TypeDXN = {
76
- type: string;
77
- version?: string;
78
- };
79
- type EchoDXN = {
80
- spaceId?: SpaceId;
81
- echoId: string;
82
- };
83
- type QueueDXN = {
84
- subspaceTag: string;
85
- spaceId: SpaceId;
86
- queueId: string;
87
- objectId?: string;
88
- };
89
- }
90
60
  /**
91
61
  * Tags for ECHO DXNs that should resolve the object ID in the local space.
92
62
  */
93
63
  export declare const LOCAL_SPACE_TAG = "@";
94
- export declare const QueueSubspaceTags: Readonly<{
95
- DATA: "data";
96
- TRACE: "trace";
97
- }>;
98
64
  //# sourceMappingURL=dxn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dxn.d.ts","sourceRoot":"","sources":["../../../src/dxn.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,GAAG;;IACd;;OAEG;IACH,MAAM,CAAC,IAAI;QACT;;WAEG;;QAEH;;;WAGG;;QAEH;;;;WAIG;;OAEF;IAEH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG;IAI5B,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM;IAI9B,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IAC9B,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,GAAG,GAAG,SAAS;IA+B5D;;OAEG;IACH,MAAM,CAAC,Y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,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,GAAG;;IACd;;OAEG;IACH,MAAM,CAAC,IAAI;;;OAGR;IAEH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG;IAI5B,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM;IAI9B,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IAkB9B;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM;IAIhC;;OAEG;IAEH,MAAM,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAI3D;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,EAAE,EAAE,MAAM;gBAOvB,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAsBzC,IAAI,IAAI,WAEP;IAED,IAAI,KAAK,aAER;IAED,UAAU;IAKV,aAAa,CAAC,QAAQ,EAAE,MAAM;IAI9B,SAAS;;iBAOsB,MAAM,GAAG,SAAS;;IAIjD,eAAe;IAIf,QAAQ;IAIR;;OAEG;IACH,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,OAAO,OAAO;CAS1F;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":"5.7.2"}
1
+ {"version":"5.7.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/keys",
3
- "version": "0.7.5-labs.a279d8c",
3
+ "version": "0.7.5-main.2567c87",
4
4
  "description": "Key utils and definitions.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -26,9 +26,9 @@
26
26
  "src"
27
27
  ],
28
28
  "dependencies": {
29
- "@dxos/debug": "0.7.5-labs.a279d8c",
30
- "@dxos/invariant": "0.7.5-labs.a279d8c",
31
- "@dxos/node-std": "0.7.5-labs.a279d8c"
29
+ "@dxos/debug": "0.7.5-main.2567c87",
30
+ "@dxos/invariant": "0.7.5-main.2567c87",
31
+ "@dxos/node-std": "0.7.5-main.2567c87"
32
32
  },
33
33
  "devDependencies": {
34
34
  "base32-decode": "^1.0.0",
package/src/dxn.ts CHANGED
@@ -7,8 +7,6 @@ import type { inspect, InspectOptionsStylized } from 'node:util';
7
7
  import { inspectCustom } from '@dxos/debug';
8
8
  import { invariant } from '@dxos/invariant';
9
9
 
10
- import type { SpaceId } from './space-id';
11
-
12
10
  /**
13
11
  * DXN unambiguously names a resource like an ECHO object, schema definition, plugin, etc.
14
12
  * Each DXN starts with a dx prefix, followed by a resource kind.
@@ -31,21 +29,8 @@ export class DXN {
31
29
  * Kind constants.
32
30
  */
33
31
  static kind = Object.freeze({
34
- /**
35
- * dxn:type:<type name>[:<version>]
36
- */
37
32
  TYPE: 'type',
38
- /**
39
- * dxn:echo:<space id>:<echo id>
40
- * dxn:echo:@:<echo id>
41
- */
42
33
  ECHO: 'echo',
43
- /**
44
- * dxn:queue:<subspace tag>:<space id>:<queue id>[:object id]
45
- * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
46
- * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
47
- */
48
- QUEUE: 'queue',
49
34
  });
50
35
 
51
36
  static equals(a: DXN, b: DXN) {
@@ -56,33 +41,19 @@ export class DXN {
56
41
  return dxn.startsWith('dxn:');
57
42
  }
58
43
 
59
- static parse(dxn: string): DXN;
60
- static parse(dxn: string, noThrow: boolean): DXN | undefined;
61
- static parse(dxn: string, noThrow?: boolean): DXN | undefined {
44
+ static parse(dxn: string): DXN {
62
45
  if (typeof dxn !== 'string') {
63
- if (noThrow) {
64
- return undefined;
65
- }
66
- throw new Error(`Invalid DXN: ${dxn}`);
46
+ throw new Error('Invalid DXN');
67
47
  }
68
48
  const [prefix, kind, ...parts] = dxn.split(':');
69
49
  if (!(prefix === 'dxn')) {
70
- if (noThrow) {
71
- return undefined;
72
- }
73
- throw new Error(`Invalid DXN: ${dxn}`);
50
+ throw new Error('Invalid DXN');
74
51
  }
75
52
  if (!(typeof kind === 'string' && kind.length > 0)) {
76
- if (noThrow) {
77
- return undefined;
78
- }
79
- throw new Error(`Invalid DXN: ${dxn}`);
53
+ throw new Error('Invalid DXN');
80
54
  }
81
55
  if (!(parts.length > 0)) {
82
- if (noThrow) {
83
- return undefined;
84
- }
85
- throw new Error(`Invalid DXN: ${dxn}`);
56
+ throw new Error('Invalid DXN');
86
57
  }
87
58
 
88
59
  return new DXN(kind, parts);
@@ -152,44 +123,14 @@ export class DXN {
152
123
  return this.#kind === DXN.kind.TYPE && this.#parts.length === 1 && this.#parts[0] === typename;
153
124
  }
154
125
 
155
- asTypeDXN(): DXN.TypeDXN | undefined {
126
+ asTypeDXN() {
156
127
  if (this.kind !== DXN.kind.TYPE) {
157
128
  return undefined;
158
129
  }
159
130
 
160
- const [type, version] = this.#parts;
161
- return {
162
- type,
163
- version: version as string | undefined,
164
- };
165
- }
166
-
167
- asEchoDXN(): DXN.EchoDXN | undefined {
168
- if (this.kind !== DXN.kind.ECHO) {
169
- return undefined;
170
- }
171
-
172
- const [spaceId, echoId] = this.#parts;
173
- return {
174
- spaceId: spaceId === LOCAL_SPACE_TAG ? undefined : (spaceId as SpaceId | undefined),
175
- echoId,
176
- };
177
- }
178
-
179
- asQueueDXN(): DXN.QueueDXN | undefined {
180
- if (this.kind !== DXN.kind.QUEUE) {
181
- return undefined;
182
- }
183
-
184
- const [subspaceTag, spaceId, queueId, objectId] = this.#parts;
185
- if (typeof queueId !== 'string') {
186
- return undefined;
187
- }
188
131
  return {
189
- subspaceTag,
190
- spaceId: spaceId as SpaceId,
191
- queueId,
192
- objectId: objectId as string | undefined,
132
+ type: this.#parts[0],
133
+ version: this.#parts[1] as string | undefined,
193
134
  };
194
135
  }
195
136
 
@@ -215,31 +156,7 @@ export class DXN {
215
156
  }
216
157
  }
217
158
 
218
- export declare namespace DXN {
219
- export type TypeDXN = {
220
- type: string;
221
- version?: string;
222
- };
223
-
224
- export type EchoDXN = {
225
- spaceId?: SpaceId;
226
- echoId: string; // TODO(dmaretskyi): ObjectId.
227
- };
228
-
229
- export type QueueDXN = {
230
- subspaceTag: string;
231
- spaceId: SpaceId;
232
- queueId: string; // TODO(dmaretskyi): ObjectId.
233
- objectId?: string; // TODO(dmaretskyi): ObjectId.
234
- };
235
- }
236
-
237
159
  /**
238
160
  * Tags for ECHO DXNs that should resolve the object ID in the local space.
239
161
  */
240
162
  export const LOCAL_SPACE_TAG = '@';
241
-
242
- export const QueueSubspaceTags = Object.freeze({
243
- DATA: 'data',
244
- TRACE: 'trace',
245
- });