@dxos/echo-protocol 0.5.9-main.4cd994e → 0.5.9-main.4fc2821
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 +7 -7
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +7 -7
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/reference.d.ts +6 -9
- package/dist/types/src/reference.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/reference.ts +12 -13
|
@@ -8,7 +8,7 @@ var Reference = class _Reference {
|
|
|
8
8
|
this.TYPE_PROTOCOL = "protobuf";
|
|
9
9
|
}
|
|
10
10
|
static fromValue(value) {
|
|
11
|
-
return new _Reference(value.
|
|
11
|
+
return new _Reference(value.itemId, value.protocol, value.host);
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated
|
|
@@ -32,14 +32,14 @@ var Reference = class _Reference {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
// prettier-ignore
|
|
35
|
-
constructor(
|
|
36
|
-
this.
|
|
35
|
+
constructor(itemId, protocol, host) {
|
|
36
|
+
this.itemId = itemId;
|
|
37
37
|
this.protocol = protocol;
|
|
38
38
|
this.host = host;
|
|
39
39
|
}
|
|
40
40
|
encode() {
|
|
41
41
|
return {
|
|
42
|
-
|
|
42
|
+
itemId: this.itemId,
|
|
43
43
|
host: this.host,
|
|
44
44
|
protocol: this.protocol
|
|
45
45
|
};
|
|
@@ -47,18 +47,18 @@ var Reference = class _Reference {
|
|
|
47
47
|
toDXN() {
|
|
48
48
|
if (this.protocol === _Reference.TYPE_PROTOCOL) {
|
|
49
49
|
return new DXN(DXN.kind.TYPE, [
|
|
50
|
-
this.
|
|
50
|
+
this.itemId
|
|
51
51
|
]);
|
|
52
52
|
} else {
|
|
53
53
|
if (this.host) {
|
|
54
54
|
return new DXN(DXN.kind.ECHO, [
|
|
55
55
|
this.host,
|
|
56
|
-
this.
|
|
56
|
+
this.itemId
|
|
57
57
|
]);
|
|
58
58
|
} else {
|
|
59
59
|
return new DXN(DXN.kind.ECHO, [
|
|
60
60
|
LOCAL_SPACE_TAG,
|
|
61
|
-
this.
|
|
61
|
+
this.itemId
|
|
62
62
|
]);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/reference.ts", "../../../src/space-doc-version.ts", "../../../src/legacy.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { DXN, LOCAL_SPACE_TAG } from '@dxos/keys';\nimport { type
|
|
5
|
-
"mappings": ";AAIA,SAASA,KAAKC,uBAAuB;
|
|
6
|
-
"names": ["DXN", "LOCAL_SPACE_TAG", "Reference", "TYPE_PROTOCOL", "fromValue", "value", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { DXN, LOCAL_SPACE_TAG } from '@dxos/keys';\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 /**\n * Protocol references to runtime registered types.\n */\n static TYPE_PROTOCOL = 'protobuf';\n\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, Reference.TYPE_PROTOCOL, 'dxos.org');\n }\n\n static fromDXN(dxn: DXN): Reference {\n switch (dxn.kind) {\n case DXN.kind.TYPE:\n return Reference.fromLegacyTypename(dxn.parts[0]);\n case DXN.kind.ECHO:\n if (dxn.parts[0] === LOCAL_SPACE_TAG) {\n return new Reference(dxn.parts[1]);\n } else {\n return new Reference(dxn.parts[1], undefined, dxn.parts[0]);\n }\n default:\n throw new Error(`Unsupported DXN kind: ${dxn.kind}`);\n }\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 toDXN(): DXN {\n if (this.protocol === Reference.TYPE_PROTOCOL) {\n return new DXN(DXN.kind.TYPE, [this.itemId]);\n } else {\n if (this.host) {\n // Host is assumed to be the space key.\n // The DXN should actually have the space ID.\n // TODO(dmaretskyi): Migrate to space id.\n return new DXN(DXN.kind.ECHO, [this.host, this.itemId]);\n } else {\n return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, this.itemId]);\n }\n }\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 EncodedReference = {\n '/': string;\n};\n\nexport const encodeReference = (reference: Reference): EncodedReference => ({\n '/': reference.toDXN().toString(),\n});\n\nexport const decodeReference = (value: any) => Reference.fromDXN(DXN.parse(value['/']));\n\nexport const isEncodedReference = (value: any): value is EncodedReference =>\n typeof value === 'object' && value !== null && Object.keys(value).length === 1 && typeof value['/'] === 'string';\n", "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Denotes the data version of the space automerge document as well as the leaf documents for each individual ECHO object.\n */\nexport type SpaceDocVersion = number & { __type: 'SpaceDocVersion' };\n\nexport const SpaceDocVersion = Object.freeze({\n /**\n * For the documents created before the versioning was introduced.\n */\n LEGACY: 0 as SpaceDocVersion,\n\n /**\n * Current version.\n */\n CURRENT: 1 as SpaceDocVersion,\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport const LEGACY_REFERENCE_TYPE_TAG = 'dxos.echo.model.document.Reference';\n\n/**\n * Reference as it is stored in Automerge document.\n */\nexport type LegacyEncodedReferenceObject = {\n '@type': typeof LEGACY_REFERENCE_TYPE_TAG;\n itemId: string;\n protocol?: string;\n host?: string;\n};\n\nexport const isLegacyReference = (value: any): boolean =>\n typeof value === 'object' && value !== null && value['@type'] === LEGACY_REFERENCE_TYPE_TAG;\n\nexport const LEGACY_TYPE_PROPERTIES = 'dxos.sdk.client.Properties';\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,KAAKC,uBAAuB;AAK9B,IAAMC,YAAN,MAAMA,WAAAA;EAIX;;;;SAAOC,gBAAgB;;EAEvB,OAAOC,UAAUC,OAAkC;AACjD,WAAO,IAAIH,WAAUG,MAAMC,QAAQD,MAAME,UAAUF,MAAMG,IAAI;EAC/D;;;;;EAMA,OAAOC,mBAAmBC,MAAyB;AACjD,WAAO,IAAIR,WAAUQ,MAAMR,WAAUC,eAAe,UAAA;EACtD;EAEA,OAAOQ,QAAQC,KAAqB;AAClC,YAAQA,IAAIC,MAAI;MACd,KAAKC,IAAID,KAAKE;AACZ,eAAOb,WAAUO,mBAAmBG,IAAII,MAAM,CAAA,CAAE;MAClD,KAAKF,IAAID,KAAKI;AACZ,YAAIL,IAAII,MAAM,CAAA,MAAOE,iBAAiB;AACpC,iBAAO,IAAIhB,WAAUU,IAAII,MAAM,CAAA,CAAE;QACnC,OAAO;AACL,iBAAO,IAAId,WAAUU,IAAII,MAAM,CAAA,GAAIG,QAAWP,IAAII,MAAM,CAAA,CAAE;QAC5D;MACF;AACE,cAAM,IAAII,MAAM,yBAAyBR,IAAIC,IAAI,EAAE;IACvD;EACF;;EAGAQ,YAEkBf,QACAC,UACAC,MAChB;SAHgBF,SAAAA;SACAC,WAAAA;SACAC,OAAAA;EACf;EAEHc,SAAyB;AACvB,WAAO;MAAEhB,QAAQ,KAAKA;MAAQE,MAAM,KAAKA;MAAMD,UAAU,KAAKA;IAAS;EACzE;EAEAgB,QAAa;AACX,QAAI,KAAKhB,aAAaL,WAAUC,eAAe;AAC7C,aAAO,IAAIW,IAAIA,IAAID,KAAKE,MAAM;QAAC,KAAKT;OAAO;IAC7C,OAAO;AACL,UAAI,KAAKE,MAAM;AAIb,eAAO,IAAIM,IAAIA,IAAID,KAAKI,MAAM;UAAC,KAAKT;UAAM,KAAKF;SAAO;MACxD,OAAO;AACL,eAAO,IAAIQ,IAAIA,IAAID,KAAKI,MAAM;UAACC;UAAiB,KAAKZ;SAAO;MAC9D;IACF;EACF;AACF;AAEO,IAAMkB,qBAAqB;AAS3B,IAAMC,kBAAkB,CAACC,eAA4C;EAC1E,KAAKA,UAAUH,MAAK,EAAGI,SAAQ;AACjC;AAEO,IAAMC,kBAAkB,CAACvB,UAAeH,UAAUS,QAAQG,IAAIe,MAAMxB,MAAM,GAAA,CAAI,CAAA;AAE9E,IAAMyB,qBAAqB,CAACzB,UACjC,OAAOA,UAAU,YAAYA,UAAU,QAAQ0B,OAAOC,KAAK3B,KAAAA,EAAO4B,WAAW,KAAK,OAAO5B,MAAM,GAAA,MAAS;;;AC7EnG,IAAM6B,kBAAkBC,OAAOC,OAAO;;;;EAI3CC,QAAQ;;;;EAKRC,SAAS;AACX,CAAA;;;ACfO,IAAMC,4BAA4B;AAYlC,IAAMC,oBAAoB,CAACC,UAChC,OAAOA,UAAU,YAAYA,UAAU,QAAQA,MAAM,OAAA,MAAaF;AAE7D,IAAMG,yBAAyB;",
|
|
6
|
+
"names": ["DXN", "LOCAL_SPACE_TAG", "Reference", "TYPE_PROTOCOL", "fromValue", "value", "itemId", "protocol", "host", "fromLegacyTypename", "type", "fromDXN", "dxn", "kind", "DXN", "TYPE", "parts", "ECHO", "LOCAL_SPACE_TAG", "undefined", "Error", "constructor", "encode", "toDXN", "REFERENCE_TYPE_TAG", "encodeReference", "reference", "toString", "decodeReference", "parse", "isEncodedReference", "Object", "keys", "length", "SpaceDocVersion", "Object", "freeze", "LEGACY", "CURRENT", "LEGACY_REFERENCE_TYPE_TAG", "isLegacyReference", "value", "LEGACY_TYPE_PROPERTIES"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo-protocol/src/document-structure.ts":{"bytes":2528,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/reference.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/core/echo/echo-protocol/src/document-structure.ts":{"bytes":2528,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/reference.ts":{"bytes":9374,"imports":[{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-protocol/src/space-doc-version.ts":{"bytes":1591,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/legacy.ts":{"bytes":1719,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/index.ts":{"bytes":818,"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"},{"path":"packages/core/echo/echo-protocol/src/space-doc-version.ts","kind":"import-statement","original":"./space-doc-version"},{"path":"packages/core/echo/echo-protocol/src/legacy.ts","kind":"import-statement","original":"./legacy"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-protocol/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5994},"packages/core/echo/echo-protocol/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/keys","kind":"import-statement","external":true}],"exports":["LEGACY_REFERENCE_TYPE_TAG","LEGACY_TYPE_PROPERTIES","REFERENCE_TYPE_TAG","Reference","SpaceDocVersion","decodeReference","encodeReference","isEncodedReference","isLegacyReference"],"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":1951},"packages/core/echo/echo-protocol/src/space-doc-version.ts":{"bytesInOutput":179},"packages/core/echo/echo-protocol/src/legacy.ts":{"bytesInOutput":257}},"bytes":2789}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ var Reference = class _Reference {
|
|
|
35
35
|
this.TYPE_PROTOCOL = "protobuf";
|
|
36
36
|
}
|
|
37
37
|
static fromValue(value) {
|
|
38
|
-
return new _Reference(value.
|
|
38
|
+
return new _Reference(value.itemId, value.protocol, value.host);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* @deprecated
|
|
@@ -59,14 +59,14 @@ var Reference = class _Reference {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
// prettier-ignore
|
|
62
|
-
constructor(
|
|
63
|
-
this.
|
|
62
|
+
constructor(itemId, protocol, host) {
|
|
63
|
+
this.itemId = itemId;
|
|
64
64
|
this.protocol = protocol;
|
|
65
65
|
this.host = host;
|
|
66
66
|
}
|
|
67
67
|
encode() {
|
|
68
68
|
return {
|
|
69
|
-
|
|
69
|
+
itemId: this.itemId,
|
|
70
70
|
host: this.host,
|
|
71
71
|
protocol: this.protocol
|
|
72
72
|
};
|
|
@@ -74,18 +74,18 @@ var Reference = class _Reference {
|
|
|
74
74
|
toDXN() {
|
|
75
75
|
if (this.protocol === _Reference.TYPE_PROTOCOL) {
|
|
76
76
|
return new import_keys.DXN(import_keys.DXN.kind.TYPE, [
|
|
77
|
-
this.
|
|
77
|
+
this.itemId
|
|
78
78
|
]);
|
|
79
79
|
} else {
|
|
80
80
|
if (this.host) {
|
|
81
81
|
return new import_keys.DXN(import_keys.DXN.kind.ECHO, [
|
|
82
82
|
this.host,
|
|
83
|
-
this.
|
|
83
|
+
this.itemId
|
|
84
84
|
]);
|
|
85
85
|
} else {
|
|
86
86
|
return new import_keys.DXN(import_keys.DXN.kind.ECHO, [
|
|
87
87
|
import_keys.LOCAL_SPACE_TAG,
|
|
88
|
-
this.
|
|
88
|
+
this.itemId
|
|
89
89
|
]);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/reference.ts", "../../../src/space-doc-version.ts", "../../../src/legacy.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { DXN, LOCAL_SPACE_TAG } from '@dxos/keys';\nimport { type
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,kBAAqC;
|
|
6
|
-
"names": ["Reference", "TYPE_PROTOCOL", "fromValue", "value", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { DXN, LOCAL_SPACE_TAG } from '@dxos/keys';\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 /**\n * Protocol references to runtime registered types.\n */\n static TYPE_PROTOCOL = 'protobuf';\n\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, Reference.TYPE_PROTOCOL, 'dxos.org');\n }\n\n static fromDXN(dxn: DXN): Reference {\n switch (dxn.kind) {\n case DXN.kind.TYPE:\n return Reference.fromLegacyTypename(dxn.parts[0]);\n case DXN.kind.ECHO:\n if (dxn.parts[0] === LOCAL_SPACE_TAG) {\n return new Reference(dxn.parts[1]);\n } else {\n return new Reference(dxn.parts[1], undefined, dxn.parts[0]);\n }\n default:\n throw new Error(`Unsupported DXN kind: ${dxn.kind}`);\n }\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 toDXN(): DXN {\n if (this.protocol === Reference.TYPE_PROTOCOL) {\n return new DXN(DXN.kind.TYPE, [this.itemId]);\n } else {\n if (this.host) {\n // Host is assumed to be the space key.\n // The DXN should actually have the space ID.\n // TODO(dmaretskyi): Migrate to space id.\n return new DXN(DXN.kind.ECHO, [this.host, this.itemId]);\n } else {\n return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, this.itemId]);\n }\n }\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 EncodedReference = {\n '/': string;\n};\n\nexport const encodeReference = (reference: Reference): EncodedReference => ({\n '/': reference.toDXN().toString(),\n});\n\nexport const decodeReference = (value: any) => Reference.fromDXN(DXN.parse(value['/']));\n\nexport const isEncodedReference = (value: any): value is EncodedReference =>\n typeof value === 'object' && value !== null && Object.keys(value).length === 1 && typeof value['/'] === 'string';\n", "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Denotes the data version of the space automerge document as well as the leaf documents for each individual ECHO object.\n */\nexport type SpaceDocVersion = number & { __type: 'SpaceDocVersion' };\n\nexport const SpaceDocVersion = Object.freeze({\n /**\n * For the documents created before the versioning was introduced.\n */\n LEGACY: 0 as SpaceDocVersion,\n\n /**\n * Current version.\n */\n CURRENT: 1 as SpaceDocVersion,\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport const LEGACY_REFERENCE_TYPE_TAG = 'dxos.echo.model.document.Reference';\n\n/**\n * Reference as it is stored in Automerge document.\n */\nexport type LegacyEncodedReferenceObject = {\n '@type': typeof LEGACY_REFERENCE_TYPE_TAG;\n itemId: string;\n protocol?: string;\n host?: string;\n};\n\nexport const isLegacyReference = (value: any): boolean =>\n typeof value === 'object' && value !== null && value['@type'] === LEGACY_REFERENCE_TYPE_TAG;\n\nexport const LEGACY_TYPE_PROPERTIES = 'dxos.sdk.client.Properties';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,kBAAqC;AAK9B,IAAMA,YAAN,MAAMA,WAAAA;EAIX,OAAA;SAAOC,gBAAgB;;EAEvB,OAAOC,UAAUC,OAAkC;AACjD,WAAO,IAAIH,WAAUG,MAAMC,QAAQD,MAAME,UAAUF,MAAMG,IAAI;EAC/D;;;;;EAMA,OAAOC,mBAAmBC,MAAyB;AACjD,WAAO,IAAIR,WAAUQ,MAAMR,WAAUC,eAAe,UAAA;EACtD;EAEA,OAAOQ,QAAQC,KAAqB;AAClC,YAAQA,IAAIC,MAAI;MACd,KAAKC,gBAAID,KAAKE;AACZ,eAAOb,WAAUO,mBAAmBG,IAAII,MAAM,CAAA,CAAE;MAClD,KAAKF,gBAAID,KAAKI;AACZ,YAAIL,IAAII,MAAM,CAAA,MAAOE,6BAAiB;AACpC,iBAAO,IAAIhB,WAAUU,IAAII,MAAM,CAAA,CAAE;QACnC,OAAO;AACL,iBAAO,IAAId,WAAUU,IAAII,MAAM,CAAA,GAAIG,QAAWP,IAAII,MAAM,CAAA,CAAE;QAC5D;MACF;AACE,cAAM,IAAII,MAAM,yBAAyBR,IAAIC,IAAI,EAAE;IACvD;EACF;;EAGAQ,YAEkBf,QACAC,UACAC,MAChB;SAHgBF,SAAAA;SACAC,WAAAA;SACAC,OAAAA;EACf;EAEHc,SAAyB;AACvB,WAAO;MAAEhB,QAAQ,KAAKA;MAAQE,MAAM,KAAKA;MAAMD,UAAU,KAAKA;IAAS;EACzE;EAEAgB,QAAa;AACX,QAAI,KAAKhB,aAAaL,WAAUC,eAAe;AAC7C,aAAO,IAAIW,gBAAIA,gBAAID,KAAKE,MAAM;QAAC,KAAKT;OAAO;IAC7C,OAAO;AACL,UAAI,KAAKE,MAAM;AAIb,eAAO,IAAIM,gBAAIA,gBAAID,KAAKI,MAAM;UAAC,KAAKT;UAAM,KAAKF;SAAO;MACxD,OAAO;AACL,eAAO,IAAIQ,gBAAIA,gBAAID,KAAKI,MAAM;UAACC;UAAiB,KAAKZ;SAAO;MAC9D;IACF;EACF;AACF;AAEO,IAAMkB,qBAAqB;AAS3B,IAAMC,kBAAkB,CAACC,eAA4C;EAC1E,KAAKA,UAAUH,MAAK,EAAGI,SAAQ;AACjC;AAEO,IAAMC,kBAAkB,CAACvB,UAAeH,UAAUS,QAAQG,gBAAIe,MAAMxB,MAAM,GAAA,CAAI,CAAA;AAE9E,IAAMyB,qBAAqB,CAACzB,UACjC,OAAOA,UAAU,YAAYA,UAAU,QAAQ0B,OAAOC,KAAK3B,KAAAA,EAAO4B,WAAW,KAAK,OAAO5B,MAAM,GAAA,MAAS;AC7EnG,IAAM6B,kBAAkBH,OAAOI,OAAO;;;;EAI3CC,QAAQ;;;;EAKRC,SAAS;AACX,CAAA;ACfO,IAAMC,4BAA4B;AAYlC,IAAMC,oBAAoB,CAAClC,UAChC,OAAOA,UAAU,YAAYA,UAAU,QAAQA,MAAM,OAAA,MAAaiC;AAE7D,IAAME,yBAAyB;",
|
|
6
|
+
"names": ["Reference", "TYPE_PROTOCOL", "fromValue", "value", "itemId", "protocol", "host", "fromLegacyTypename", "type", "fromDXN", "dxn", "kind", "DXN", "TYPE", "parts", "ECHO", "LOCAL_SPACE_TAG", "undefined", "Error", "constructor", "encode", "toDXN", "REFERENCE_TYPE_TAG", "encodeReference", "reference", "toString", "decodeReference", "parse", "isEncodedReference", "Object", "keys", "length", "SpaceDocVersion", "freeze", "LEGACY", "CURRENT", "LEGACY_REFERENCE_TYPE_TAG", "isLegacyReference", "LEGACY_TYPE_PROPERTIES"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo-protocol/src/document-structure.ts":{"bytes":2528,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/reference.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/core/echo/echo-protocol/src/document-structure.ts":{"bytes":2528,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/reference.ts":{"bytes":9374,"imports":[{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo-protocol/src/space-doc-version.ts":{"bytes":1591,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/legacy.ts":{"bytes":1719,"imports":[],"format":"esm"},"packages/core/echo/echo-protocol/src/index.ts":{"bytes":818,"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"},{"path":"packages/core/echo/echo-protocol/src/space-doc-version.ts","kind":"import-statement","original":"./space-doc-version"},{"path":"packages/core/echo/echo-protocol/src/legacy.ts","kind":"import-statement","original":"./legacy"}],"format":"esm"}},"outputs":{"packages/core/echo/echo-protocol/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5994},"packages/core/echo/echo-protocol/dist/lib/node/index.cjs":{"imports":[{"path":"@dxos/keys","kind":"import-statement","external":true}],"exports":["LEGACY_REFERENCE_TYPE_TAG","LEGACY_TYPE_PROPERTIES","REFERENCE_TYPE_TAG","Reference","SpaceDocVersion","decodeReference","encodeReference","isEncodedReference","isLegacyReference"],"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":1951},"packages/core/echo/echo-protocol/src/space-doc-version.ts":{"bytesInOutput":179},"packages/core/echo/echo-protocol/src/legacy.ts":{"bytesInOutput":257}},"bytes":2789}}}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import { DXN } from '@dxos/keys';
|
|
2
|
-
import { type
|
|
3
|
-
import { type Reference as
|
|
4
|
-
/**
|
|
5
|
-
* Runtime representation of object reference.
|
|
6
|
-
*/
|
|
2
|
+
import { type ItemID } from '@dxos/protocols';
|
|
3
|
+
import { type Reference as ReferenceValue } from '@dxos/protocols/proto/dxos/echo/model/document';
|
|
7
4
|
export declare class Reference {
|
|
8
|
-
readonly
|
|
5
|
+
readonly itemId: ItemID;
|
|
9
6
|
readonly protocol?: string | undefined;
|
|
10
7
|
readonly host?: string | undefined;
|
|
11
8
|
/**
|
|
12
9
|
* Protocol references to runtime registered types.
|
|
13
10
|
*/
|
|
14
11
|
static TYPE_PROTOCOL: string;
|
|
15
|
-
static fromValue(value:
|
|
12
|
+
static fromValue(value: ReferenceValue): Reference;
|
|
16
13
|
/**
|
|
17
14
|
* @deprecated
|
|
18
15
|
*/
|
|
19
16
|
static fromLegacyTypename(type: string): Reference;
|
|
20
17
|
static fromDXN(dxn: DXN): Reference;
|
|
21
|
-
constructor(
|
|
22
|
-
encode():
|
|
18
|
+
constructor(itemId: ItemID, protocol?: string | undefined, host?: string | undefined);
|
|
19
|
+
encode(): ReferenceValue;
|
|
23
20
|
toDXN(): DXN;
|
|
24
21
|
}
|
|
25
22
|
export declare const REFERENCE_TYPE_TAG = "dxos.echo.model.document.Reference";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/reference.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAmB,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/reference.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAmB,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,KAAK,SAAS,IAAI,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAGlG,qBAAa,SAAS;aAoCF,MAAM,EAAE,MAAM;aACd,QAAQ,CAAC;aACT,IAAI,CAAC;IArCvB;;OAEG;IACH,MAAM,CAAC,aAAa,SAAc;IAElC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS;IAIlD;;OAEG;IAEH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAIlD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS;gBAkBjB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,oBAAQ,EACjB,IAAI,CAAC,oBAAQ;IAG/B,MAAM,IAAI,cAAc;IAIxB,KAAK,IAAI,GAAG;CAcb;AAED,eAAO,MAAM,kBAAkB,uCAAuC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,eAAO,MAAM,eAAe,cAAe,SAAS,KAAG,gBAErD,CAAC;AAEH,eAAO,MAAM,eAAe,UAAW,GAAG,cAA6C,CAAC;AAExF,eAAO,MAAM,kBAAkB,UAAW,GAAG,8BACqE,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.4fc2821",
|
|
4
4
|
"description": "Core ECHO APIs.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"src"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@dxos/
|
|
26
|
-
"@dxos/
|
|
25
|
+
"@dxos/protocols": "0.5.9-main.4fc2821",
|
|
26
|
+
"@dxos/keys": "0.5.9-main.4fc2821"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
package/src/reference.ts
CHANGED
|
@@ -3,20 +3,18 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { DXN, LOCAL_SPACE_TAG } from '@dxos/keys';
|
|
6
|
-
import { type
|
|
7
|
-
import { type Reference as
|
|
6
|
+
import { type ItemID } from '@dxos/protocols';
|
|
7
|
+
import { type Reference as ReferenceValue } from '@dxos/protocols/proto/dxos/echo/model/document';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
* Runtime representation of object reference.
|
|
11
|
-
*/
|
|
9
|
+
// TODO(burdon): Comment.
|
|
12
10
|
export class Reference {
|
|
13
11
|
/**
|
|
14
12
|
* Protocol references to runtime registered types.
|
|
15
13
|
*/
|
|
16
14
|
static TYPE_PROTOCOL = 'protobuf';
|
|
17
15
|
|
|
18
|
-
static fromValue(value:
|
|
19
|
-
return new Reference(value.
|
|
16
|
+
static fromValue(value: ReferenceValue): Reference {
|
|
17
|
+
return new Reference(value.itemId, value.protocol, value.host);
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
/**
|
|
@@ -44,26 +42,27 @@ export class Reference {
|
|
|
44
42
|
|
|
45
43
|
// prettier-ignore
|
|
46
44
|
constructor(
|
|
47
|
-
|
|
45
|
+
// TODO(burdon): Change to objectId (and typename).
|
|
46
|
+
public readonly itemId: ItemID,
|
|
48
47
|
public readonly protocol?: string,
|
|
49
48
|
public readonly host?: string
|
|
50
49
|
) {}
|
|
51
50
|
|
|
52
|
-
encode():
|
|
53
|
-
return {
|
|
51
|
+
encode(): ReferenceValue {
|
|
52
|
+
return { itemId: this.itemId, host: this.host, protocol: this.protocol };
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
toDXN(): DXN {
|
|
57
56
|
if (this.protocol === Reference.TYPE_PROTOCOL) {
|
|
58
|
-
return new DXN(DXN.kind.TYPE, [this.
|
|
57
|
+
return new DXN(DXN.kind.TYPE, [this.itemId]);
|
|
59
58
|
} else {
|
|
60
59
|
if (this.host) {
|
|
61
60
|
// Host is assumed to be the space key.
|
|
62
61
|
// The DXN should actually have the space ID.
|
|
63
62
|
// TODO(dmaretskyi): Migrate to space id.
|
|
64
|
-
return new DXN(DXN.kind.ECHO, [this.host, this.
|
|
63
|
+
return new DXN(DXN.kind.ECHO, [this.host, this.itemId]);
|
|
65
64
|
} else {
|
|
66
|
-
return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, this.
|
|
65
|
+
return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, this.itemId]);
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
}
|