@dxos/client-services 0.4.4 → 0.4.5-main.60c9234

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.
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_DZARJVRB_exports = {};
30
- __export(chunk_DZARJVRB_exports, {
29
+ var chunk_G6IFLZAA_exports = {};
30
+ __export(chunk_G6IFLZAA_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -60,7 +60,7 @@ __export(chunk_DZARJVRB_exports, {
60
60
  subscribeToSpaces: () => subscribeToSpaces,
61
61
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
62
  });
63
- module.exports = __toCommonJS(chunk_DZARJVRB_exports);
63
+ module.exports = __toCommonJS(chunk_G6IFLZAA_exports);
64
64
  var import_async = require("@dxos/async");
65
65
  var import_codec_protobuf = require("@dxos/codec-protobuf");
66
66
  var import_feed_store = require("@dxos/feed-store");
@@ -238,6 +238,7 @@ var import_protocols14 = require("@dxos/protocols");
238
238
  var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
239
239
  var import_text_model = require("@dxos/text-model");
240
240
  var import_tracing7 = require("@dxos/tracing");
241
+ var import_util9 = require("@dxos/util");
241
242
  var import_websocket_rpc = require("@dxos/websocket-rpc");
242
243
  var import_async16 = require("@dxos/async");
243
244
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
@@ -246,11 +247,11 @@ var import_async17 = require("@dxos/async");
246
247
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
247
248
  var import_log16 = require("@dxos/log");
248
249
  var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
249
- var import_util9 = require("@dxos/util");
250
+ var import_util10 = require("@dxos/util");
250
251
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
251
252
  var import_codec_protobuf15 = require("@dxos/codec-protobuf");
252
253
  var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
253
- var import_util10 = require("@dxos/util");
254
+ var import_util11 = require("@dxos/util");
254
255
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
255
256
  return new import_codec_protobuf.Stream(({ next }) => {
256
257
  const subscriptions = new import_async.EventSubscriptions();
@@ -1202,7 +1203,6 @@ IdentityManager = _ts_decorate2([
1202
1203
  import_tracing2.trace.resource()
1203
1204
  ], IdentityManager);
1204
1205
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1205
- var CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT = true;
1206
1206
  var IdentityServiceImpl = class {
1207
1207
  constructor(_createIdentity, _identityManager, _keyring, _onProfileUpdate) {
1208
1208
  this._createIdentity = _createIdentity;
@@ -1211,7 +1211,7 @@ var IdentityServiceImpl = class {
1211
1211
  this._onProfileUpdate = _onProfileUpdate;
1212
1212
  }
1213
1213
  async createIdentity(request) {
1214
- await this._createIdentity(request.profile ?? {}, request.useAutomerge ?? CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT);
1214
+ await this._createIdentity(request.profile ?? {});
1215
1215
  return this._getIdentity();
1216
1216
  }
1217
1217
  async recoverIdentity(request) {
@@ -1239,7 +1239,7 @@ var IdentityServiceImpl = class {
1239
1239
  async updateProfile(profile) {
1240
1240
  (0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
1241
1241
  F: __dxlog_file4,
1242
- L: 63,
1242
+ L: 61,
1243
1243
  S: this,
1244
1244
  A: [
1245
1245
  "this._identityManager.identity",
@@ -1253,7 +1253,7 @@ var IdentityServiceImpl = class {
1253
1253
  async signPresentation({ presentation, nonce }) {
1254
1254
  (0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
1255
1255
  F: __dxlog_file4,
1256
- L: 70,
1256
+ L: 68,
1257
1257
  S: this,
1258
1258
  A: [
1259
1259
  "this._identityManager.identity",
@@ -2675,7 +2675,7 @@ var getPlatform = () => {
2675
2675
  };
2676
2676
  }
2677
2677
  };
2678
- var DXOS_VERSION = "0.4.4";
2678
+ var DXOS_VERSION = "0.4.5-main.60c9234";
2679
2679
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2680
2680
  var DEFAULT_TIMEOUT = 1e3;
2681
2681
  var createDiagnostics = async (clientServices, serviceContext, config) => {
@@ -3397,9 +3397,11 @@ var DataSpace = class {
3397
3397
  return;
3398
3398
  }
3399
3399
  const doc = handle.docSync() ?? (0, import_invariant10.failedInvariant)();
3400
- if (!doc.experimental_spaceKey) {
3400
+ if (!doc.access?.spaceKey) {
3401
3401
  handle.change((doc2) => {
3402
- doc2.experimental_spaceKey = this.key.toHex();
3402
+ doc2.access = {
3403
+ spaceKey: this.key.toHex()
3404
+ };
3403
3405
  });
3404
3406
  }
3405
3407
  } catch (err) {
@@ -3758,7 +3760,9 @@ var DataSpaceManager = class {
3758
3760
  });
3759
3761
  const automergeRoot = this._automergeHost.repo.create();
3760
3762
  automergeRoot.change((doc) => {
3761
- doc.experimental_spaceKey = spaceKey.toHex();
3763
+ doc.access = {
3764
+ spaceKey: spaceKey.toHex()
3765
+ };
3762
3766
  });
3763
3767
  const space = await this._constructSpace(metadata);
3764
3768
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
@@ -4599,15 +4603,15 @@ var LoggingServiceImpl = class {
4599
4603
  }
4600
4604
  async controlMetrics({ reset, record }) {
4601
4605
  if (reset) {
4602
- import_util9.tracer.clear();
4606
+ import_util10.tracer.clear();
4603
4607
  }
4604
4608
  if (record === true) {
4605
- import_util9.tracer.start();
4609
+ import_util10.tracer.start();
4606
4610
  } else if (record === false) {
4607
- import_util9.tracer.stop();
4611
+ import_util10.tracer.stop();
4608
4612
  }
4609
4613
  return {
4610
- recording: import_util9.tracer.recording
4614
+ recording: import_util10.tracer.recording
4611
4615
  };
4612
4616
  }
4613
4617
  /**
@@ -4615,10 +4619,10 @@ var LoggingServiceImpl = class {
4615
4619
  */
4616
4620
  queryMetrics({ interval = 5e3 }) {
4617
4621
  const getNumericalValues = (key) => {
4618
- const events = import_util9.tracer.get(key) ?? [];
4622
+ const events = import_util10.tracer.get(key) ?? [];
4619
4623
  return {
4620
4624
  key,
4621
- stats: (0, import_util9.numericalValues)(events, "duration")
4625
+ stats: (0, import_util10.numericalValues)(events, "duration")
4622
4626
  };
4623
4627
  };
4624
4628
  return new import_codec_protobuf13.Stream(({ next }) => {
@@ -4656,7 +4660,7 @@ var LoggingServiceImpl = class {
4656
4660
  }
4657
4661
  const record = {
4658
4662
  ...entry2,
4659
- context: (0, import_util9.jsonify)((0, import_log16.getContextFromEntry)(entry2)),
4663
+ context: (0, import_util10.jsonify)((0, import_log16.getContextFromEntry)(entry2)),
4660
4664
  timestamp: /* @__PURE__ */ new Date(),
4661
4665
  meta: {
4662
4666
  // TODO(dmaretskyi): Fix proto.
@@ -4741,7 +4745,7 @@ var SystemServiceImpl = class {
4741
4745
  const diagnostics = await this._getDiagnostics();
4742
4746
  return {
4743
4747
  timestamp: /* @__PURE__ */ new Date(),
4744
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util10.jsonKeyReplacer)({
4748
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util11.jsonKeyReplacer)({
4745
4749
  truncate: keys === import_services15.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4746
4750
  humanize: keys === import_services15.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
4747
4751
  })))
@@ -4788,18 +4792,6 @@ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
4788
4792
  var createDefaultModelFactory = () => {
4789
4793
  return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
4790
4794
  };
4791
- var createGenesisMutationFromTypedObject = (obj) => {
4792
- const snapshot = obj[import_echo_schema.base]._createSnapshot();
4793
- return {
4794
- objectId: obj[import_echo_schema.base]._id,
4795
- genesis: {
4796
- modelType: obj[import_echo_schema.base]._modelConstructor.meta.type
4797
- },
4798
- snapshot: {
4799
- model: snapshot
4800
- }
4801
- };
4802
- };
4803
4795
  var ClientServicesHost = class {
4804
4796
  constructor({
4805
4797
  config,
@@ -4886,7 +4878,7 @@ var ClientServicesHost = class {
4886
4878
  initialize({ config, ...options }) {
4887
4879
  (0, import_invariant16.invariant)(!this._open, "service host is open", {
4888
4880
  F: __dxlog_file17,
4889
- L: 201,
4881
+ L: 186,
4890
4882
  S: this,
4891
4883
  A: [
4892
4884
  "!this._open",
@@ -4895,14 +4887,14 @@ var ClientServicesHost = class {
4895
4887
  });
4896
4888
  (0, import_log15.log)("initializing...", void 0, {
4897
4889
  F: __dxlog_file17,
4898
- L: 202,
4890
+ L: 187,
4899
4891
  S: this,
4900
4892
  C: (f, a) => f(...a)
4901
4893
  });
4902
4894
  if (config) {
4903
4895
  (0, import_invariant16.invariant)(!this._config, "config already set", {
4904
4896
  F: __dxlog_file17,
4905
- L: 205,
4897
+ L: 190,
4906
4898
  S: this,
4907
4899
  A: [
4908
4900
  "!this._config",
@@ -4920,7 +4912,7 @@ var ClientServicesHost = class {
4920
4912
  this._signalManager = signalManager;
4921
4913
  (0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
4922
4914
  F: __dxlog_file17,
4923
- L: 221,
4915
+ L: 206,
4924
4916
  S: this,
4925
4917
  A: [
4926
4918
  "!this._networkManager",
@@ -4934,7 +4926,7 @@ var ClientServicesHost = class {
4934
4926
  });
4935
4927
  (0, import_log15.log)("initialized", void 0, {
4936
4928
  F: __dxlog_file17,
4937
- L: 228,
4929
+ L: 213,
4938
4930
  S: this,
4939
4931
  C: (f, a) => f(...a)
4940
4932
  });
@@ -4948,13 +4940,13 @@ var ClientServicesHost = class {
4948
4940
  id: traceId
4949
4941
  }), {
4950
4942
  F: __dxlog_file17,
4951
- L: 239,
4943
+ L: 224,
4952
4944
  S: this,
4953
4945
  C: (f, a) => f(...a)
4954
4946
  });
4955
4947
  (0, import_invariant16.invariant)(this._config, "config not set", {
4956
4948
  F: __dxlog_file17,
4957
- L: 241,
4949
+ L: 226,
4958
4950
  S: this,
4959
4951
  A: [
4960
4952
  "this._config",
@@ -4963,7 +4955,7 @@ var ClientServicesHost = class {
4963
4955
  });
4964
4956
  (0, import_invariant16.invariant)(this._storage, "storage not set", {
4965
4957
  F: __dxlog_file17,
4966
- L: 242,
4958
+ L: 227,
4967
4959
  S: this,
4968
4960
  A: [
4969
4961
  "this._storage",
@@ -4972,7 +4964,7 @@ var ClientServicesHost = class {
4972
4964
  });
4973
4965
  (0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
4974
4966
  F: __dxlog_file17,
4975
- L: 243,
4967
+ L: 228,
4976
4968
  S: this,
4977
4969
  A: [
4978
4970
  "this._signalManager",
@@ -4981,7 +4973,7 @@ var ClientServicesHost = class {
4981
4973
  });
4982
4974
  (0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
4983
4975
  F: __dxlog_file17,
4984
- L: 244,
4976
+ L: 229,
4985
4977
  S: this,
4986
4978
  A: [
4987
4979
  "this._networkManager",
@@ -4993,7 +4985,7 @@ var ClientServicesHost = class {
4993
4985
  lockKey: this._resourceLock?.lockKey
4994
4986
  }, {
4995
4987
  F: __dxlog_file17,
4996
- L: 247,
4988
+ L: 232,
4997
4989
  S: this,
4998
4990
  C: (f, a) => f(...a)
4999
4991
  });
@@ -5002,7 +4994,7 @@ var ClientServicesHost = class {
5002
4994
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
5003
4995
  this._serviceRegistry.setServices({
5004
4996
  SystemService: this._systemService,
5005
- IdentityService: new IdentityServiceImpl((params, useAutomerge) => this._createIdentity(params, useAutomerge), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
4997
+ IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
5006
4998
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
5007
4999
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
5008
5000
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
@@ -5039,7 +5031,7 @@ var ClientServicesHost = class {
5039
5031
  deviceKey
5040
5032
  }, {
5041
5033
  F: __dxlog_file17,
5042
- L: 320,
5034
+ L: 305,
5043
5035
  S: this,
5044
5036
  C: (f, a) => f(...a)
5045
5037
  });
@@ -5047,7 +5039,7 @@ var ClientServicesHost = class {
5047
5039
  id: traceId
5048
5040
  }), {
5049
5041
  F: __dxlog_file17,
5050
- L: 321,
5042
+ L: 306,
5051
5043
  S: this,
5052
5044
  C: (f, a) => f(...a)
5053
5045
  });
@@ -5061,7 +5053,7 @@ var ClientServicesHost = class {
5061
5053
  deviceKey
5062
5054
  }, {
5063
5055
  F: __dxlog_file17,
5064
- L: 332,
5056
+ L: 317,
5065
5057
  S: this,
5066
5058
  C: (f, a) => f(...a)
5067
5059
  });
@@ -5077,7 +5069,7 @@ var ClientServicesHost = class {
5077
5069
  deviceKey
5078
5070
  }, {
5079
5071
  F: __dxlog_file17,
5080
- L: 339,
5072
+ L: 324,
5081
5073
  S: this,
5082
5074
  C: (f, a) => f(...a)
5083
5075
  });
@@ -5088,13 +5080,13 @@ var ClientServicesHost = class {
5088
5080
  id: traceId
5089
5081
  }), {
5090
5082
  F: __dxlog_file17,
5091
- L: 344,
5083
+ L: 329,
5092
5084
  S: this,
5093
5085
  C: (f, a) => f(...a)
5094
5086
  });
5095
5087
  (0, import_log15.log)("resetting...", void 0, {
5096
5088
  F: __dxlog_file17,
5097
- L: 346,
5089
+ L: 331,
5098
5090
  S: this,
5099
5091
  C: (f, a) => f(...a)
5100
5092
  });
@@ -5102,7 +5094,7 @@ var ClientServicesHost = class {
5102
5094
  await this._storage.reset();
5103
5095
  (0, import_log15.log)("reset", void 0, {
5104
5096
  F: __dxlog_file17,
5105
- L: 349,
5097
+ L: 334,
5106
5098
  S: this,
5107
5099
  C: (f, a) => f(...a)
5108
5100
  });
@@ -5110,50 +5102,36 @@ var ClientServicesHost = class {
5110
5102
  id: traceId
5111
5103
  }), {
5112
5104
  F: __dxlog_file17,
5113
- L: 350,
5105
+ L: 335,
5114
5106
  S: this,
5115
5107
  C: (f, a) => f(...a)
5116
5108
  });
5117
5109
  await this._callbacks?.onReset?.();
5118
5110
  }
5119
- async _createIdentity(params, useAutomerge) {
5111
+ async _createIdentity(params) {
5120
5112
  const identity = await this._serviceContext.createIdentity(params);
5121
5113
  await this._serviceContext.initialized.wait();
5122
5114
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5123
- const obj = new import_client_protocol5.Properties(void 0, {
5124
- automerge: useAutomerge
5125
- });
5115
+ const obj = new import_client_protocol5.Properties(void 0);
5126
5116
  obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
5127
- if (!useAutomerge) {
5128
- await this._serviceRegistry.services.DataService.write({
5129
- spaceKey: space.key,
5130
- batch: {
5131
- objects: [
5132
- createGenesisMutationFromTypedObject(obj)
5133
- ]
5134
- }
5135
- });
5136
- await this._serviceRegistry.services.DataService.flush({
5137
- spaceKey: space.key
5138
- });
5139
- } else {
5140
- const automergeIndex = space.automergeSpaceState.rootUrl;
5141
- (0, import_invariant16.invariant)(automergeIndex, void 0, {
5142
- F: __dxlog_file17,
5143
- L: 375,
5144
- S: this,
5145
- A: [
5146
- "automergeIndex",
5147
- ""
5148
- ]
5149
- });
5150
- const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5151
- await document.whenReady();
5152
- document.change((doc) => {
5153
- doc.objects ??= {};
5154
- doc.objects[obj[import_echo_schema.base]._id] = (0, import_echo_schema.getRawDoc)(obj).handle.docSync();
5155
- });
5156
- }
5117
+ const automergeIndex = space.automergeSpaceState.rootUrl;
5118
+ (0, import_invariant16.invariant)(automergeIndex, void 0, {
5119
+ F: __dxlog_file17,
5120
+ L: 350,
5121
+ S: this,
5122
+ A: [
5123
+ "automergeIndex",
5124
+ ""
5125
+ ]
5126
+ });
5127
+ const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5128
+ await document.whenReady();
5129
+ document.change((doc) => {
5130
+ (0, import_util9.assignDeep)(doc, [
5131
+ "objects",
5132
+ obj[import_echo_schema.base]._id
5133
+ ], (0, import_echo_schema.getRawDoc)(obj).handle.docSync());
5134
+ });
5157
5135
  return identity;
5158
5136
  }
5159
5137
  };
@@ -5208,4 +5186,4 @@ ClientServicesHost = _ts_decorate8([
5208
5186
  subscribeToSpaces,
5209
5187
  subscribeToSwarmInfo
5210
5188
  });
5211
- //# sourceMappingURL=chunk-DZARJVRB.cjs.map
5189
+ //# sourceMappingURL=chunk-G6IFLZAA.cjs.map