@dxos/echo-protocol 0.5.9-main.44fe51d → 0.5.9-main.5d72625
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/dist/lib/browser/index.mjs +9 -66
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +10 -64
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/document-structure.d.ts +0 -2
- package/dist/types/src/document-structure.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/reference.d.ts +4 -8
- package/dist/types/src/reference.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/document-structure.ts +0 -3
- package/src/index.ts +0 -2
- package/src/reference.ts +13 -41
- package/dist/types/src/legacy.d.ts +0 -13
- package/dist/types/src/legacy.d.ts.map +0 -1
- package/dist/types/src/space-doc-version.d.ts +0 -17
- package/dist/types/src/space-doc-version.d.ts.map +0 -1
- package/src/legacy.ts +0 -20
- package/src/space-doc-version.ts +0 -20
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
// packages/core/echo/echo-protocol/src/reference.ts
|
|
2
|
-
import { DXN, LOCAL_SPACE_TAG } from "@dxos/keys";
|
|
3
2
|
var Reference = class _Reference {
|
|
4
|
-
static {
|
|
5
|
-
/**
|
|
6
|
-
* Protocol references to runtime registered types.
|
|
7
|
-
*/
|
|
8
|
-
this.TYPE_PROTOCOL = "protobuf";
|
|
9
|
-
}
|
|
10
3
|
static fromValue(value) {
|
|
11
4
|
return new _Reference(value.itemId, value.protocol, value.host);
|
|
12
5
|
}
|
|
@@ -15,21 +8,7 @@ var Reference = class _Reference {
|
|
|
15
8
|
*/
|
|
16
9
|
// TODO(burdon): Document/remove?
|
|
17
10
|
static fromLegacyTypename(type) {
|
|
18
|
-
return new _Reference(type,
|
|
19
|
-
}
|
|
20
|
-
static fromDXN(dxn) {
|
|
21
|
-
switch (dxn.kind) {
|
|
22
|
-
case DXN.kind.TYPE:
|
|
23
|
-
return _Reference.fromLegacyTypename(dxn.parts[0]);
|
|
24
|
-
case DXN.kind.ECHO:
|
|
25
|
-
if (dxn.parts[0] === LOCAL_SPACE_TAG) {
|
|
26
|
-
return new _Reference(dxn.parts[1]);
|
|
27
|
-
} else {
|
|
28
|
-
return new _Reference(dxn.parts[1], void 0, dxn.parts[0]);
|
|
29
|
-
}
|
|
30
|
-
default:
|
|
31
|
-
throw new Error(`Unsupported DXN kind: ${dxn.kind}`);
|
|
32
|
-
}
|
|
11
|
+
return new _Reference(type, "protobuf", "dxos.org");
|
|
33
12
|
}
|
|
34
13
|
// prettier-ignore
|
|
35
14
|
constructor(itemId, protocol, host) {
|
|
@@ -44,58 +23,22 @@ var Reference = class _Reference {
|
|
|
44
23
|
protocol: this.protocol
|
|
45
24
|
};
|
|
46
25
|
}
|
|
47
|
-
toDXN() {
|
|
48
|
-
if (this.protocol === _Reference.TYPE_PROTOCOL) {
|
|
49
|
-
return new DXN(DXN.kind.TYPE, [
|
|
50
|
-
this.itemId
|
|
51
|
-
]);
|
|
52
|
-
} else {
|
|
53
|
-
if (this.host) {
|
|
54
|
-
return new DXN(DXN.kind.ECHO, [
|
|
55
|
-
this.host,
|
|
56
|
-
this.itemId
|
|
57
|
-
]);
|
|
58
|
-
} else {
|
|
59
|
-
return new DXN(DXN.kind.ECHO, [
|
|
60
|
-
LOCAL_SPACE_TAG,
|
|
61
|
-
this.itemId
|
|
62
|
-
]);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
26
|
};
|
|
67
27
|
var REFERENCE_TYPE_TAG = "dxos.echo.model.document.Reference";
|
|
68
28
|
var encodeReference = (reference) => ({
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// packages/core/echo/echo-protocol/src/space-doc-version.ts
|
|
75
|
-
var SpaceDocVersion = Object.freeze({
|
|
76
|
-
/**
|
|
77
|
-
* For the documents created before the versioning was introduced.
|
|
78
|
-
*/
|
|
79
|
-
LEGACY: 0,
|
|
80
|
-
/**
|
|
81
|
-
* Current version.
|
|
82
|
-
*/
|
|
83
|
-
CURRENT: 1
|
|
29
|
+
"@type": REFERENCE_TYPE_TAG,
|
|
30
|
+
// NOTE: Automerge do not support undefined values, so we need to use null instead.
|
|
31
|
+
itemId: reference.itemId ?? null,
|
|
32
|
+
protocol: reference.protocol ?? null,
|
|
33
|
+
host: reference.host ?? null
|
|
84
34
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
var LEGACY_REFERENCE_TYPE_TAG = "dxos.echo.model.document.Reference";
|
|
88
|
-
var isLegacyReference = (value) => typeof value === "object" && value !== null && value["@type"] === LEGACY_REFERENCE_TYPE_TAG;
|
|
89
|
-
var LEGACY_TYPE_PROPERTIES = "dxos.sdk.client.Properties";
|
|
35
|
+
var decodeReference = (value) => new Reference(value.itemId, value.protocol ?? void 0, value.host ?? void 0);
|
|
36
|
+
var isEncodedReferenceObject = (value) => typeof value === "object" && value !== null && value["@type"] === REFERENCE_TYPE_TAG;
|
|
90
37
|
export {
|
|
91
|
-
LEGACY_REFERENCE_TYPE_TAG,
|
|
92
|
-
LEGACY_TYPE_PROPERTIES,
|
|
93
38
|
REFERENCE_TYPE_TAG,
|
|
94
39
|
Reference,
|
|
95
|
-
SpaceDocVersion,
|
|
96
40
|
decodeReference,
|
|
97
41
|
encodeReference,
|
|
98
|
-
isEncodedReferenceObject
|
|
99
|
-
isLegacyReference
|
|
42
|
+
isEncodedReferenceObject
|
|
100
43
|
};
|
|
101
44
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/reference.ts"
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport {
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/reference.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { type ItemID } from '@dxos/protocols';\nimport { type Reference as ReferenceValue } from '@dxos/protocols/proto/dxos/echo/model/document';\n\n// TODO(burdon): Comment.\nexport class Reference {\n static fromValue(value: ReferenceValue): Reference {\n return new Reference(value.itemId, value.protocol, value.host);\n }\n\n /**\n * @deprecated\n */\n // TODO(burdon): Document/remove?\n static fromLegacyTypename(type: string): Reference {\n return new Reference(type, 'protobuf', 'dxos.org');\n }\n\n // prettier-ignore\n constructor(\n // TODO(burdon): Change to objectId (and typename).\n public readonly itemId: ItemID,\n public readonly protocol?: string,\n public readonly host?: string\n ) {}\n\n encode(): ReferenceValue {\n return { itemId: this.itemId, host: this.host, protocol: this.protocol };\n }\n}\n\nexport const REFERENCE_TYPE_TAG = 'dxos.echo.model.document.Reference';\n\n/**\n * Reference as it is stored in Automerge document.\n */\nexport type EncodedReferenceObject = {\n '@type': typeof REFERENCE_TYPE_TAG;\n itemId: string | null;\n protocol: string | null;\n host: string | null;\n};\n\nexport const encodeReference = (reference: Reference): EncodedReferenceObject => ({\n '@type': REFERENCE_TYPE_TAG,\n // NOTE: Automerge do not support undefined values, so we need to use null instead.\n itemId: reference.itemId ?? null,\n protocol: reference.protocol ?? null,\n host: reference.host ?? null,\n});\n\nexport const decodeReference = (value: any) =>\n new Reference(value.itemId, value.protocol ?? undefined, value.host ?? undefined);\n\nexport const isEncodedReferenceObject = (value: any): value is EncodedReferenceObject =>\n typeof value === 'object' && value !== null && value['@type'] === REFERENCE_TYPE_TAG;\n"],
|
|
5
|
+
"mappings": ";AAQO,IAAMA,YAAN,MAAMA,WAAAA;EACX,OAAOC,UAAUC,OAAkC;AACjD,WAAO,IAAIF,WAAUE,MAAMC,QAAQD,MAAME,UAAUF,MAAMG,IAAI;EAC/D;;;;;EAMA,OAAOC,mBAAmBC,MAAyB;AACjD,WAAO,IAAIP,WAAUO,MAAM,YAAY,UAAA;EACzC;;EAGAC,YAEkBL,QACAC,UACAC,MAChB;SAHgBF,SAAAA;SACAC,WAAAA;SACAC,OAAAA;EACf;EAEHI,SAAyB;AACvB,WAAO;MAAEN,QAAQ,KAAKA;MAAQE,MAAM,KAAKA;MAAMD,UAAU,KAAKA;IAAS;EACzE;AACF;AAEO,IAAMM,qBAAqB;AAY3B,IAAMC,kBAAkB,CAACC,eAAkD;EAChF,SAASF;;EAETP,QAAQS,UAAUT,UAAU;EAC5BC,UAAUQ,UAAUR,YAAY;EAChCC,MAAMO,UAAUP,QAAQ;AAC1B;AAEO,IAAMQ,kBAAkB,CAACX,UAC9B,IAAIF,UAAUE,MAAMC,QAAQD,MAAME,YAAYU,QAAWZ,MAAMG,QAAQS,MAAAA;AAElE,IAAMC,2BAA2B,CAACb,UACvC,OAAOA,UAAU,YAAYA,UAAU,QAAQA,MAAM,OAAA,MAAaQ;",
|
|
6
|
+
"names": ["Reference", "fromValue", "value", "itemId", "protocol", "host", "fromLegacyTypename", "type", "constructor", "encode", "REFERENCE_TYPE_TAG", "encodeReference", "reference", "decodeReference", "undefined", "isEncodedReferenceObject"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo-protocol/src/document-structure.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/core/echo/echo-protocol/src/document-structure.ts":{"bytes":2420,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/reference.ts":{"bytes":5696,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/index.ts":{"bytes":623,"imports":[{"path":"packages/core/echo/echo-protocol/src/document-structure.ts","kind":"import-statement","original":"./document-structure"},{"path":"packages/core/echo/echo-protocol/src/reference.ts","kind":"import-statement","original":"./reference"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-protocol/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2847},"packages/core/echo/echo-protocol/dist/lib/browser/index.mjs":{"imports":[],"exports":["REFERENCE_TYPE_TAG","Reference","decodeReference","encodeReference","isEncodedReferenceObject"],"entryPoint":"packages/core/echo/echo-protocol/src/index.ts","inputs":{"packages/core/echo/echo-protocol/src/index.ts":{"bytesInOutput":0},"packages/core/echo/echo-protocol/src/reference.ts":{"bytesInOutput":1128}},"bytes":1328}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -18,22 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var node_exports = {};
|
|
20
20
|
__export(node_exports, {
|
|
21
|
-
LEGACY_REFERENCE_TYPE_TAG: () => LEGACY_REFERENCE_TYPE_TAG,
|
|
22
|
-
LEGACY_TYPE_PROPERTIES: () => LEGACY_TYPE_PROPERTIES,
|
|
23
21
|
REFERENCE_TYPE_TAG: () => REFERENCE_TYPE_TAG,
|
|
24
22
|
Reference: () => Reference,
|
|
25
|
-
SpaceDocVersion: () => SpaceDocVersion,
|
|
26
23
|
decodeReference: () => decodeReference,
|
|
27
24
|
encodeReference: () => encodeReference,
|
|
28
|
-
isEncodedReferenceObject: () => isEncodedReferenceObject
|
|
29
|
-
isLegacyReference: () => isLegacyReference
|
|
25
|
+
isEncodedReferenceObject: () => isEncodedReferenceObject
|
|
30
26
|
});
|
|
31
27
|
module.exports = __toCommonJS(node_exports);
|
|
32
|
-
var import_keys = require("@dxos/keys");
|
|
33
28
|
var Reference = class _Reference {
|
|
34
|
-
static {
|
|
35
|
-
this.TYPE_PROTOCOL = "protobuf";
|
|
36
|
-
}
|
|
37
29
|
static fromValue(value) {
|
|
38
30
|
return new _Reference(value.itemId, value.protocol, value.host);
|
|
39
31
|
}
|
|
@@ -42,21 +34,7 @@ var Reference = class _Reference {
|
|
|
42
34
|
*/
|
|
43
35
|
// TODO(burdon): Document/remove?
|
|
44
36
|
static fromLegacyTypename(type) {
|
|
45
|
-
return new _Reference(type,
|
|
46
|
-
}
|
|
47
|
-
static fromDXN(dxn) {
|
|
48
|
-
switch (dxn.kind) {
|
|
49
|
-
case import_keys.DXN.kind.TYPE:
|
|
50
|
-
return _Reference.fromLegacyTypename(dxn.parts[0]);
|
|
51
|
-
case import_keys.DXN.kind.ECHO:
|
|
52
|
-
if (dxn.parts[0] === import_keys.LOCAL_SPACE_TAG) {
|
|
53
|
-
return new _Reference(dxn.parts[1]);
|
|
54
|
-
} else {
|
|
55
|
-
return new _Reference(dxn.parts[1], void 0, dxn.parts[0]);
|
|
56
|
-
}
|
|
57
|
-
default:
|
|
58
|
-
throw new Error(`Unsupported DXN kind: ${dxn.kind}`);
|
|
59
|
-
}
|
|
37
|
+
return new _Reference(type, "protobuf", "dxos.org");
|
|
60
38
|
}
|
|
61
39
|
// prettier-ignore
|
|
62
40
|
constructor(itemId, protocol, host) {
|
|
@@ -71,55 +49,23 @@ var Reference = class _Reference {
|
|
|
71
49
|
protocol: this.protocol
|
|
72
50
|
};
|
|
73
51
|
}
|
|
74
|
-
toDXN() {
|
|
75
|
-
if (this.protocol === _Reference.TYPE_PROTOCOL) {
|
|
76
|
-
return new import_keys.DXN(import_keys.DXN.kind.TYPE, [
|
|
77
|
-
this.itemId
|
|
78
|
-
]);
|
|
79
|
-
} else {
|
|
80
|
-
if (this.host) {
|
|
81
|
-
return new import_keys.DXN(import_keys.DXN.kind.ECHO, [
|
|
82
|
-
this.host,
|
|
83
|
-
this.itemId
|
|
84
|
-
]);
|
|
85
|
-
} else {
|
|
86
|
-
return new import_keys.DXN(import_keys.DXN.kind.ECHO, [
|
|
87
|
-
import_keys.LOCAL_SPACE_TAG,
|
|
88
|
-
this.itemId
|
|
89
|
-
]);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
52
|
};
|
|
94
53
|
var REFERENCE_TYPE_TAG = "dxos.echo.model.document.Reference";
|
|
95
54
|
var encodeReference = (reference) => ({
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* For the documents created before the versioning was introduced.
|
|
103
|
-
*/
|
|
104
|
-
LEGACY: 0,
|
|
105
|
-
/**
|
|
106
|
-
* Current version.
|
|
107
|
-
*/
|
|
108
|
-
CURRENT: 1
|
|
55
|
+
"@type": REFERENCE_TYPE_TAG,
|
|
56
|
+
// NOTE: Automerge do not support undefined values, so we need to use null instead.
|
|
57
|
+
itemId: reference.itemId ?? null,
|
|
58
|
+
protocol: reference.protocol ?? null,
|
|
59
|
+
host: reference.host ?? null
|
|
109
60
|
});
|
|
110
|
-
var
|
|
111
|
-
var
|
|
112
|
-
var LEGACY_TYPE_PROPERTIES = "dxos.sdk.client.Properties";
|
|
61
|
+
var decodeReference = (value) => new Reference(value.itemId, value.protocol ?? void 0, value.host ?? void 0);
|
|
62
|
+
var isEncodedReferenceObject = (value) => typeof value === "object" && value !== null && value["@type"] === REFERENCE_TYPE_TAG;
|
|
113
63
|
// Annotate the CommonJS export names for ESM import in node:
|
|
114
64
|
0 && (module.exports = {
|
|
115
|
-
LEGACY_REFERENCE_TYPE_TAG,
|
|
116
|
-
LEGACY_TYPE_PROPERTIES,
|
|
117
65
|
REFERENCE_TYPE_TAG,
|
|
118
66
|
Reference,
|
|
119
|
-
SpaceDocVersion,
|
|
120
67
|
decodeReference,
|
|
121
68
|
encodeReference,
|
|
122
|
-
isEncodedReferenceObject
|
|
123
|
-
isLegacyReference
|
|
69
|
+
isEncodedReferenceObject
|
|
124
70
|
});
|
|
125
71
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/reference.ts"
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Reference", "
|
|
3
|
+
"sources": ["../../../src/reference.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { type ItemID } from '@dxos/protocols';\nimport { type Reference as ReferenceValue } from '@dxos/protocols/proto/dxos/echo/model/document';\n\n// TODO(burdon): Comment.\nexport class Reference {\n static fromValue(value: ReferenceValue): Reference {\n return new Reference(value.itemId, value.protocol, value.host);\n }\n\n /**\n * @deprecated\n */\n // TODO(burdon): Document/remove?\n static fromLegacyTypename(type: string): Reference {\n return new Reference(type, 'protobuf', 'dxos.org');\n }\n\n // prettier-ignore\n constructor(\n // TODO(burdon): Change to objectId (and typename).\n public readonly itemId: ItemID,\n public readonly protocol?: string,\n public readonly host?: string\n ) {}\n\n encode(): ReferenceValue {\n return { itemId: this.itemId, host: this.host, protocol: this.protocol };\n }\n}\n\nexport const REFERENCE_TYPE_TAG = 'dxos.echo.model.document.Reference';\n\n/**\n * Reference as it is stored in Automerge document.\n */\nexport type EncodedReferenceObject = {\n '@type': typeof REFERENCE_TYPE_TAG;\n itemId: string | null;\n protocol: string | null;\n host: string | null;\n};\n\nexport const encodeReference = (reference: Reference): EncodedReferenceObject => ({\n '@type': REFERENCE_TYPE_TAG,\n // NOTE: Automerge do not support undefined values, so we need to use null instead.\n itemId: reference.itemId ?? null,\n protocol: reference.protocol ?? null,\n host: reference.host ?? null,\n});\n\nexport const decodeReference = (value: any) =>\n new Reference(value.itemId, value.protocol ?? undefined, value.host ?? undefined);\n\nexport const isEncodedReferenceObject = (value: any): value is EncodedReferenceObject =>\n typeof value === 'object' && value !== null && value['@type'] === REFERENCE_TYPE_TAG;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,IAAMA,YAAN,MAAMA,WAAAA;EACX,OAAOC,UAAUC,OAAkC;AACjD,WAAO,IAAIF,WAAUE,MAAMC,QAAQD,MAAME,UAAUF,MAAMG,IAAI;EAC/D;;;;;EAMA,OAAOC,mBAAmBC,MAAyB;AACjD,WAAO,IAAIP,WAAUO,MAAM,YAAY,UAAA;EACzC;;EAGAC,YAEkBL,QACAC,UACAC,MAChB;SAHgBF,SAAAA;SACAC,WAAAA;SACAC,OAAAA;EACf;EAEHI,SAAyB;AACvB,WAAO;MAAEN,QAAQ,KAAKA;MAAQE,MAAM,KAAKA;MAAMD,UAAU,KAAKA;IAAS;EACzE;AACF;AAEO,IAAMM,qBAAqB;AAY3B,IAAMC,kBAAkB,CAACC,eAAkD;EAChF,SAASF;;EAETP,QAAQS,UAAUT,UAAU;EAC5BC,UAAUQ,UAAUR,YAAY;EAChCC,MAAMO,UAAUP,QAAQ;AAC1B;AAEO,IAAMQ,kBAAkB,CAACX,UAC9B,IAAIF,UAAUE,MAAMC,QAAQD,MAAME,YAAYU,QAAWZ,MAAMG,QAAQS,MAAAA;AAElE,IAAMC,2BAA2B,CAACb,UACvC,OAAOA,UAAU,YAAYA,UAAU,QAAQA,MAAM,OAAA,MAAaQ;",
|
|
6
|
+
"names": ["Reference", "fromValue", "value", "itemId", "protocol", "host", "fromLegacyTypename", "type", "constructor", "encode", "REFERENCE_TYPE_TAG", "encodeReference", "reference", "decodeReference", "undefined", "isEncodedReferenceObject"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo-protocol/src/document-structure.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/core/echo/echo-protocol/src/document-structure.ts":{"bytes":2420,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/reference.ts":{"bytes":5696,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/index.ts":{"bytes":623,"imports":[{"path":"packages/core/echo/echo-protocol/src/document-structure.ts","kind":"import-statement","original":"./document-structure"},{"path":"packages/core/echo/echo-protocol/src/reference.ts","kind":"import-statement","original":"./reference"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-protocol/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2847},"packages/core/echo/echo-protocol/dist/lib/node/index.cjs":{"imports":[],"exports":["REFERENCE_TYPE_TAG","Reference","decodeReference","encodeReference","isEncodedReferenceObject"],"entryPoint":"packages/core/echo/echo-protocol/src/index.ts","inputs":{"packages/core/echo/echo-protocol/src/index.ts":{"bytesInOutput":0},"packages/core/echo/echo-protocol/src/reference.ts":{"bytesInOutput":1128}},"bytes":1328}}}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { type EncodedReferenceObject } from './reference';
|
|
2
|
-
import type { SpaceDocVersion } from './space-doc-version';
|
|
3
2
|
export type SpaceState = {
|
|
4
3
|
rootUrl?: string;
|
|
5
4
|
};
|
|
6
5
|
export interface SpaceDoc {
|
|
7
|
-
version?: SpaceDocVersion;
|
|
8
6
|
access?: {
|
|
9
7
|
spaceKey: string;
|
|
10
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-structure.d.ts","sourceRoot":"","sources":["../../../src/document-structure.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"document-structure.d.ts","sourceRoot":"","sources":["../../../src/document-structure.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,MAAM,UAAU,GAAG;IAEvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF,MAAM,WAAW,QAAQ;IACvB,MAAM,CAAC,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,CAAC;KAC/B,CAAC;IACF;;OAEG;IACH,KAAK,CAAC,EAAE;QACN,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;KAC1B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,UAAU,EAAE,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAE9B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC"}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import { DXN } from '@dxos/keys';
|
|
2
1
|
import { type ItemID } from '@dxos/protocols';
|
|
3
2
|
import { type Reference as ReferenceValue } from '@dxos/protocols/proto/dxos/echo/model/document';
|
|
4
3
|
export declare class Reference {
|
|
5
4
|
readonly itemId: ItemID;
|
|
6
5
|
readonly protocol?: string | undefined;
|
|
7
6
|
readonly host?: string | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* Protocol references to runtime registered types.
|
|
10
|
-
*/
|
|
11
|
-
static TYPE_PROTOCOL: string;
|
|
12
7
|
static fromValue(value: ReferenceValue): Reference;
|
|
13
8
|
/**
|
|
14
9
|
* @deprecated
|
|
15
10
|
*/
|
|
16
11
|
static fromLegacyTypename(type: string): Reference;
|
|
17
|
-
static fromDXN(dxn: DXN): Reference;
|
|
18
12
|
constructor(itemId: ItemID, protocol?: string | undefined, host?: string | undefined);
|
|
19
13
|
encode(): ReferenceValue;
|
|
20
|
-
toDXN(): DXN;
|
|
21
14
|
}
|
|
22
15
|
export declare const REFERENCE_TYPE_TAG = "dxos.echo.model.document.Reference";
|
|
23
16
|
/**
|
|
24
17
|
* Reference as it is stored in Automerge document.
|
|
25
18
|
*/
|
|
26
19
|
export type EncodedReferenceObject = {
|
|
27
|
-
'
|
|
20
|
+
'@type': typeof REFERENCE_TYPE_TAG;
|
|
21
|
+
itemId: string | null;
|
|
22
|
+
protocol: string | null;
|
|
23
|
+
host: string | null;
|
|
28
24
|
};
|
|
29
25
|
export declare const encodeReference: (reference: Reference) => EncodedReferenceObject;
|
|
30
26
|
export declare const decodeReference: (value: any) => Reference;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/reference.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/reference.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,KAAK,SAAS,IAAI,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAGlG,qBAAa,SAAS;aAgBF,MAAM,EAAE,MAAM;aACd,QAAQ,CAAC;aACT,IAAI,CAAC;IAjBvB,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS;IAIlD;;OAEG;IAEH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;gBAOhC,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,oBAAQ,EACjB,IAAI,CAAC,oBAAQ;IAG/B,MAAM,IAAI,cAAc;CAGzB;AAED,eAAO,MAAM,kBAAkB,uCAAuC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,OAAO,kBAAkB,CAAC;IACnC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,eAAe,cAAe,SAAS,KAAG,sBAMrD,CAAC;AAEH,eAAO,MAAM,eAAe,UAAW,GAAG,cACyC,CAAC;AAEpF,eAAO,MAAM,wBAAwB,UAAW,GAAG,oCACmC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-protocol",
|
|
3
|
-
"version": "0.5.9-main.
|
|
3
|
+
"version": "0.5.9-main.5d72625",
|
|
4
4
|
"description": "Core ECHO APIs.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
"src"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@dxos/
|
|
26
|
-
"@dxos/protocols": "0.5.9-main.44fe51d"
|
|
25
|
+
"@dxos/protocols": "0.5.9-main.5d72625"
|
|
27
26
|
},
|
|
28
27
|
"publishConfig": {
|
|
29
28
|
"access": "public"
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type EncodedReferenceObject } from './reference';
|
|
6
|
-
import type { SpaceDocVersion } from './space-doc-version';
|
|
7
6
|
|
|
8
7
|
export type SpaceState = {
|
|
9
8
|
// Url of the root automerge document.
|
|
@@ -12,8 +11,6 @@ export type SpaceState = {
|
|
|
12
11
|
|
|
13
12
|
// TODO(dmaretskyi): Rename DatabaseRootDoc.
|
|
14
13
|
export interface SpaceDoc {
|
|
15
|
-
version?: SpaceDocVersion;
|
|
16
|
-
|
|
17
14
|
access?: {
|
|
18
15
|
spaceKey: string;
|
|
19
16
|
};
|
package/src/index.ts
CHANGED
package/src/reference.ts
CHANGED
|
@@ -2,17 +2,11 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { DXN, LOCAL_SPACE_TAG } from '@dxos/keys';
|
|
6
5
|
import { type ItemID } from '@dxos/protocols';
|
|
7
6
|
import { type Reference as ReferenceValue } from '@dxos/protocols/proto/dxos/echo/model/document';
|
|
8
7
|
|
|
9
8
|
// TODO(burdon): Comment.
|
|
10
9
|
export class Reference {
|
|
11
|
-
/**
|
|
12
|
-
* Protocol references to runtime registered types.
|
|
13
|
-
*/
|
|
14
|
-
static TYPE_PROTOCOL = 'protobuf';
|
|
15
|
-
|
|
16
10
|
static fromValue(value: ReferenceValue): Reference {
|
|
17
11
|
return new Reference(value.itemId, value.protocol, value.host);
|
|
18
12
|
}
|
|
@@ -22,22 +16,7 @@ export class Reference {
|
|
|
22
16
|
*/
|
|
23
17
|
// TODO(burdon): Document/remove?
|
|
24
18
|
static fromLegacyTypename(type: string): Reference {
|
|
25
|
-
return new Reference(type,
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static fromDXN(dxn: DXN): Reference {
|
|
29
|
-
switch (dxn.kind) {
|
|
30
|
-
case DXN.kind.TYPE:
|
|
31
|
-
return Reference.fromLegacyTypename(dxn.parts[0]);
|
|
32
|
-
case DXN.kind.ECHO:
|
|
33
|
-
if (dxn.parts[0] === LOCAL_SPACE_TAG) {
|
|
34
|
-
return new Reference(dxn.parts[1]);
|
|
35
|
-
} else {
|
|
36
|
-
return new Reference(dxn.parts[1], undefined, dxn.parts[0]);
|
|
37
|
-
}
|
|
38
|
-
default:
|
|
39
|
-
throw new Error(`Unsupported DXN kind: ${dxn.kind}`);
|
|
40
|
-
}
|
|
19
|
+
return new Reference(type, 'protobuf', 'dxos.org');
|
|
41
20
|
}
|
|
42
21
|
|
|
43
22
|
// prettier-ignore
|
|
@@ -51,21 +30,6 @@ export class Reference {
|
|
|
51
30
|
encode(): ReferenceValue {
|
|
52
31
|
return { itemId: this.itemId, host: this.host, protocol: this.protocol };
|
|
53
32
|
}
|
|
54
|
-
|
|
55
|
-
toDXN(): DXN {
|
|
56
|
-
if (this.protocol === Reference.TYPE_PROTOCOL) {
|
|
57
|
-
return new DXN(DXN.kind.TYPE, [this.itemId]);
|
|
58
|
-
} else {
|
|
59
|
-
if (this.host) {
|
|
60
|
-
// Host is assumed to be the space key.
|
|
61
|
-
// The DXN should actually have the space ID.
|
|
62
|
-
// TODO(dmaretskyi): Migrate to space id.
|
|
63
|
-
return new DXN(DXN.kind.ECHO, [this.host, this.itemId]);
|
|
64
|
-
} else {
|
|
65
|
-
return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, this.itemId]);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
33
|
}
|
|
70
34
|
|
|
71
35
|
export const REFERENCE_TYPE_TAG = 'dxos.echo.model.document.Reference';
|
|
@@ -74,14 +38,22 @@ export const REFERENCE_TYPE_TAG = 'dxos.echo.model.document.Reference';
|
|
|
74
38
|
* Reference as it is stored in Automerge document.
|
|
75
39
|
*/
|
|
76
40
|
export type EncodedReferenceObject = {
|
|
77
|
-
'
|
|
41
|
+
'@type': typeof REFERENCE_TYPE_TAG;
|
|
42
|
+
itemId: string | null;
|
|
43
|
+
protocol: string | null;
|
|
44
|
+
host: string | null;
|
|
78
45
|
};
|
|
79
46
|
|
|
80
47
|
export const encodeReference = (reference: Reference): EncodedReferenceObject => ({
|
|
81
|
-
'
|
|
48
|
+
'@type': REFERENCE_TYPE_TAG,
|
|
49
|
+
// NOTE: Automerge do not support undefined values, so we need to use null instead.
|
|
50
|
+
itemId: reference.itemId ?? null,
|
|
51
|
+
protocol: reference.protocol ?? null,
|
|
52
|
+
host: reference.host ?? null,
|
|
82
53
|
});
|
|
83
54
|
|
|
84
|
-
export const decodeReference = (value: any) =>
|
|
55
|
+
export const decodeReference = (value: any) =>
|
|
56
|
+
new Reference(value.itemId, value.protocol ?? undefined, value.host ?? undefined);
|
|
85
57
|
|
|
86
58
|
export const isEncodedReferenceObject = (value: any): value is EncodedReferenceObject =>
|
|
87
|
-
typeof value === 'object' && value !== null &&
|
|
59
|
+
typeof value === 'object' && value !== null && value['@type'] === REFERENCE_TYPE_TAG;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const LEGACY_REFERENCE_TYPE_TAG = "dxos.echo.model.document.Reference";
|
|
2
|
-
/**
|
|
3
|
-
* Reference as it is stored in Automerge document.
|
|
4
|
-
*/
|
|
5
|
-
export type LegacyEncodedReferenceObject = {
|
|
6
|
-
'@type': typeof LEGACY_REFERENCE_TYPE_TAG;
|
|
7
|
-
itemId: string;
|
|
8
|
-
protocol?: string;
|
|
9
|
-
host?: string;
|
|
10
|
-
};
|
|
11
|
-
export declare const isLegacyReference: (value: any) => boolean;
|
|
12
|
-
export declare const LEGACY_TYPE_PROPERTIES = "dxos.sdk.client.Properties";
|
|
13
|
-
//# sourceMappingURL=legacy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../../src/legacy.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,yBAAyB,uCAAuC,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,OAAO,EAAE,OAAO,yBAAyB,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAAW,GAAG,KAAG,OAC8C,CAAC;AAE9F,eAAO,MAAM,sBAAsB,+BAA+B,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Denotes the data version of the space automerge document as well as the leaf documents for each individual ECHO object.
|
|
3
|
-
*/
|
|
4
|
-
export type SpaceDocVersion = number & {
|
|
5
|
-
__type: 'SpaceDocVersion';
|
|
6
|
-
};
|
|
7
|
-
export declare const SpaceDocVersion: Readonly<{
|
|
8
|
-
/**
|
|
9
|
-
* For the documents created before the versioning was introduced.
|
|
10
|
-
*/
|
|
11
|
-
LEGACY: SpaceDocVersion;
|
|
12
|
-
/**
|
|
13
|
-
* Current version.
|
|
14
|
-
*/
|
|
15
|
-
CURRENT: SpaceDocVersion;
|
|
16
|
-
}>;
|
|
17
|
-
//# sourceMappingURL=space-doc-version.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"space-doc-version.d.ts","sourceRoot":"","sources":["../../../src/space-doc-version.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAE,MAAM,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAErE,eAAO,MAAM,eAAe;IAC1B;;OAEG;;IAGH;;OAEG;;EAEH,CAAC"}
|
package/src/legacy.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
export const LEGACY_REFERENCE_TYPE_TAG = 'dxos.echo.model.document.Reference';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Reference as it is stored in Automerge document.
|
|
9
|
-
*/
|
|
10
|
-
export type LegacyEncodedReferenceObject = {
|
|
11
|
-
'@type': typeof LEGACY_REFERENCE_TYPE_TAG;
|
|
12
|
-
itemId: string;
|
|
13
|
-
protocol?: string;
|
|
14
|
-
host?: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const isLegacyReference = (value: any): boolean =>
|
|
18
|
-
typeof value === 'object' && value !== null && value['@type'] === LEGACY_REFERENCE_TYPE_TAG;
|
|
19
|
-
|
|
20
|
-
export const LEGACY_TYPE_PROPERTIES = 'dxos.sdk.client.Properties';
|
package/src/space-doc-version.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Denotes the data version of the space automerge document as well as the leaf documents for each individual ECHO object.
|
|
7
|
-
*/
|
|
8
|
-
export type SpaceDocVersion = number & { __type: 'SpaceDocVersion' };
|
|
9
|
-
|
|
10
|
-
export const SpaceDocVersion = Object.freeze({
|
|
11
|
-
/**
|
|
12
|
-
* For the documents created before the versioning was introduced.
|
|
13
|
-
*/
|
|
14
|
-
LEGACY: 0 as SpaceDocVersion,
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Current version.
|
|
18
|
-
*/
|
|
19
|
-
CURRENT: 1 as SpaceDocVersion,
|
|
20
|
-
});
|