@dxos/client-services 0.1.58-main.ca7a0bc → 0.1.58-main.d647118

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.
@@ -2498,7 +2498,7 @@ var getPlatform = () => {
2498
2498
  };
2499
2499
 
2500
2500
  // packages/sdk/client-services/src/version.ts
2501
- var DXOS_VERSION = "0.1.58-main.ca7a0bc";
2501
+ var DXOS_VERSION = "0.1.58-main.d647118";
2502
2502
 
2503
2503
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2504
2504
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -4358,10 +4358,11 @@ var toStorageType = (type) => {
4358
4358
 
4359
4359
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4360
4360
  import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
4361
- import { clientServiceBundle } from "@dxos/client-protocol";
4361
+ import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
4362
4362
  import { Context as Context10 } from "@dxos/context";
4363
4363
  import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
4364
4364
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4365
+ import { base } from "@dxos/echo-schema";
4365
4366
  import { invariant as invariant14 } from "@dxos/invariant";
4366
4367
  import { PublicKey as PublicKey10 } from "@dxos/keys";
4367
4368
  import { log as log16 } from "@dxos/log";
@@ -4635,6 +4636,18 @@ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
4635
4636
  var createDefaultModelFactory = () => {
4636
4637
  return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
4637
4638
  };
4639
+ var createGenesisMutationFromTypedObject = (obj) => {
4640
+ const snapshot = obj[base]._createSnapshot();
4641
+ return {
4642
+ objectId: obj[base]._id,
4643
+ genesis: {
4644
+ modelType: obj[base]._modelConstructor.meta.type
4645
+ },
4646
+ snapshot: {
4647
+ model: snapshot
4648
+ }
4649
+ };
4650
+ };
4638
4651
  var ClientServicesHost = class ClientServicesHost2 {
4639
4652
  constructor({
4640
4653
  config,
@@ -4721,7 +4734,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4721
4734
  initialize({ config, ...options }) {
4722
4735
  invariant14(!this._open, "service host is open", {
4723
4736
  F: __dxlog_file17,
4724
- L: 184,
4737
+ L: 201,
4725
4738
  S: this,
4726
4739
  A: [
4727
4740
  "!this._open",
@@ -4730,14 +4743,14 @@ var ClientServicesHost = class ClientServicesHost2 {
4730
4743
  });
4731
4744
  log16("initializing...", void 0, {
4732
4745
  F: __dxlog_file17,
4733
- L: 185,
4746
+ L: 202,
4734
4747
  S: this,
4735
4748
  C: (f, a) => f(...a)
4736
4749
  });
4737
4750
  if (config) {
4738
4751
  invariant14(!this._config, "config already set", {
4739
4752
  F: __dxlog_file17,
4740
- L: 188,
4753
+ L: 205,
4741
4754
  S: this,
4742
4755
  A: [
4743
4756
  "!this._config",
@@ -4755,7 +4768,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4755
4768
  this._signalManager = signalManager;
4756
4769
  invariant14(!this._networkManager, "network manager already set", {
4757
4770
  F: __dxlog_file17,
4758
- L: 204,
4771
+ L: 221,
4759
4772
  S: this,
4760
4773
  A: [
4761
4774
  "!this._networkManager",
@@ -4769,7 +4782,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4769
4782
  });
4770
4783
  log16("initialized", void 0, {
4771
4784
  F: __dxlog_file17,
4772
- L: 211,
4785
+ L: 228,
4773
4786
  S: this,
4774
4787
  C: (f, a) => f(...a)
4775
4788
  });
@@ -4783,13 +4796,13 @@ var ClientServicesHost = class ClientServicesHost2 {
4783
4796
  id: traceId
4784
4797
  }), {
4785
4798
  F: __dxlog_file17,
4786
- L: 222,
4799
+ L: 239,
4787
4800
  S: this,
4788
4801
  C: (f, a) => f(...a)
4789
4802
  });
4790
4803
  invariant14(this._config, "config not set", {
4791
4804
  F: __dxlog_file17,
4792
- L: 224,
4805
+ L: 241,
4793
4806
  S: this,
4794
4807
  A: [
4795
4808
  "this._config",
@@ -4798,7 +4811,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4798
4811
  });
4799
4812
  invariant14(this._storage, "storage not set", {
4800
4813
  F: __dxlog_file17,
4801
- L: 225,
4814
+ L: 242,
4802
4815
  S: this,
4803
4816
  A: [
4804
4817
  "this._storage",
@@ -4807,7 +4820,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4807
4820
  });
4808
4821
  invariant14(this._signalManager, "signal manager not set", {
4809
4822
  F: __dxlog_file17,
4810
- L: 226,
4823
+ L: 243,
4811
4824
  S: this,
4812
4825
  A: [
4813
4826
  "this._signalManager",
@@ -4816,7 +4829,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4816
4829
  });
4817
4830
  invariant14(this._networkManager, "network manager not set", {
4818
4831
  F: __dxlog_file17,
4819
- L: 227,
4832
+ L: 244,
4820
4833
  S: this,
4821
4834
  A: [
4822
4835
  "this._networkManager",
@@ -4828,7 +4841,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4828
4841
  lockKey: this._resourceLock?.lockKey
4829
4842
  }, {
4830
4843
  F: __dxlog_file17,
4831
- L: 230,
4844
+ L: 247,
4832
4845
  S: this,
4833
4846
  C: (f, a) => f(...a)
4834
4847
  });
@@ -4837,7 +4850,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4837
4850
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
4838
4851
  this._serviceRegistry.setServices({
4839
4852
  SystemService: this._systemService,
4840
- IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
4853
+ IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
4841
4854
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
4842
4855
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
4843
4856
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
@@ -4874,7 +4887,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4874
4887
  deviceKey
4875
4888
  }, {
4876
4889
  F: __dxlog_file17,
4877
- L: 299,
4890
+ L: 316,
4878
4891
  S: this,
4879
4892
  C: (f, a) => f(...a)
4880
4893
  });
@@ -4882,7 +4895,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4882
4895
  id: traceId
4883
4896
  }), {
4884
4897
  F: __dxlog_file17,
4885
- L: 300,
4898
+ L: 317,
4886
4899
  S: this,
4887
4900
  C: (f, a) => f(...a)
4888
4901
  });
@@ -4896,7 +4909,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4896
4909
  deviceKey
4897
4910
  }, {
4898
4911
  F: __dxlog_file17,
4899
- L: 311,
4912
+ L: 328,
4900
4913
  S: this,
4901
4914
  C: (f, a) => f(...a)
4902
4915
  });
@@ -4912,7 +4925,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4912
4925
  deviceKey
4913
4926
  }, {
4914
4927
  F: __dxlog_file17,
4915
- L: 318,
4928
+ L: 335,
4916
4929
  S: this,
4917
4930
  C: (f, a) => f(...a)
4918
4931
  });
@@ -4923,13 +4936,13 @@ var ClientServicesHost = class ClientServicesHost2 {
4923
4936
  id: traceId
4924
4937
  }), {
4925
4938
  F: __dxlog_file17,
4926
- L: 323,
4939
+ L: 340,
4927
4940
  S: this,
4928
4941
  C: (f, a) => f(...a)
4929
4942
  });
4930
4943
  log16("resetting...", void 0, {
4931
4944
  F: __dxlog_file17,
4932
- L: 325,
4945
+ L: 342,
4933
4946
  S: this,
4934
4947
  C: (f, a) => f(...a)
4935
4948
  });
@@ -4937,7 +4950,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4937
4950
  await this._storage.reset();
4938
4951
  log16("reset", void 0, {
4939
4952
  F: __dxlog_file17,
4940
- L: 328,
4953
+ L: 345,
4941
4954
  S: this,
4942
4955
  C: (f, a) => f(...a)
4943
4956
  });
@@ -4945,12 +4958,31 @@ var ClientServicesHost = class ClientServicesHost2 {
4945
4958
  id: traceId
4946
4959
  }), {
4947
4960
  F: __dxlog_file17,
4948
- L: 329,
4961
+ L: 346,
4949
4962
  S: this,
4950
4963
  C: (f, a) => f(...a)
4951
4964
  });
4952
4965
  await this._callbacks?.onReset?.();
4953
4966
  }
4967
+ async _createIdentity(params) {
4968
+ const identity = await this._serviceContext.createIdentity(params);
4969
+ await this._serviceContext.initialized.wait();
4970
+ const space = await this._serviceContext.dataSpaceManager.createSpace();
4971
+ const obj = new Properties();
4972
+ obj[defaultKey] = identity.identityKey.toHex();
4973
+ await this._serviceRegistry.services.DataService.write({
4974
+ spaceKey: space.key,
4975
+ batch: {
4976
+ objects: [
4977
+ createGenesisMutationFromTypedObject(obj)
4978
+ ]
4979
+ }
4980
+ });
4981
+ await this._serviceRegistry.services.DataService.flush({
4982
+ spaceKey: space.key
4983
+ });
4984
+ return identity;
4985
+ }
4954
4986
  };
4955
4987
  _ts_decorate7([
4956
4988
  Trace3.info()
@@ -5003,4 +5035,4 @@ export {
5003
5035
  createDefaultModelFactory,
5004
5036
  ClientServicesHost
5005
5037
  };
5006
- //# sourceMappingURL=chunk-VRV74Z4M.mjs.map
5038
+ //# sourceMappingURL=chunk-OOVT67MV.mjs.map