@supernova-studio/client 1.16.2 → 1.17.0

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/index.mjs CHANGED
@@ -5263,13 +5263,19 @@ var ForgeProjectRoom = Entity.extend({
5263
5263
  });
5264
5264
  var ForgeProjectRoomInitialState = z183.object({
5265
5265
  artifacts: z183.array(ForgeProjectArtifact),
5266
- features: z183.array(ProjectFeature)
5266
+ features: z183.array(ProjectFeature),
5267
+ artifactSections: z183.array(ForgeSection),
5268
+ featureSections: z183.array(ForgeSection)
5267
5269
  });
5268
5270
  var ForgeProjectRoomUpdate = z183.object({
5269
5271
  artifacts: z183.array(ForgeProjectArtifact).optional(),
5270
5272
  artifactIdsToDelete: z183.array(z183.string()).optional(),
5271
5273
  features: z183.array(ProjectFeature).optional(),
5272
5274
  featureIdsToDelete: z183.array(z183.string()).optional(),
5275
+ artifactSections: z183.array(ForgeSection).optional(),
5276
+ artifactSectionIdsToDelete: z183.array(z183.string()).optional(),
5277
+ featureSections: z183.array(ForgeSection).optional(),
5278
+ featureSectionIdsToDelete: z183.array(z183.string()).optional(),
5273
5279
  executedTransactionIds: z183.string().array().optional()
5274
5280
  });
5275
5281
  var RoomTypeEnum = /* @__PURE__ */ ((RoomTypeEnum2) => {
@@ -16794,12 +16800,16 @@ var ForgeProjectRoomBaseYDoc = class {
16794
16800
  getState() {
16795
16801
  const artifacts = this.getArtifacts();
16796
16802
  const features = this.getFeatures();
16803
+ const artifactSections = this.getArtifactSections();
16804
+ const featureSections = this.getFeatureSections();
16797
16805
  const executedTransactionIds = this.getExecutedTransactionIds();
16798
16806
  const isLoaded = true;
16799
16807
  return {
16800
16808
  isLoaded,
16801
16809
  artifacts,
16802
16810
  features,
16811
+ artifactSections,
16812
+ featureSections,
16803
16813
  executedTransactionIds
16804
16814
  };
16805
16815
  }
@@ -16834,6 +16844,33 @@ var ForgeProjectRoomBaseYDoc = class {
16834
16844
  return this.yDoc.getMap("forgeProjectFeatures");
16835
16845
  }
16836
16846
  //
16847
+ // Sections
16848
+ //
16849
+ getArtifactSections() {
16850
+ return this.getObjects(this.artifactSectionsYMap, ForgeSection);
16851
+ }
16852
+ updateArtifactSections(sections) {
16853
+ this.setObjects(this.artifactSectionsYMap, sections);
16854
+ }
16855
+ deleteArtifactSections(ids) {
16856
+ this.deleteObjects(this.artifactSectionsYMap, ids);
16857
+ }
16858
+ get artifactSectionsYMap() {
16859
+ return this.yDoc.getMap("forgeProjectArtifactSections");
16860
+ }
16861
+ getFeatureSections() {
16862
+ return this.getObjects(this.featureSectionsYMap, ForgeSection);
16863
+ }
16864
+ updateFeatureSections(sections) {
16865
+ this.setObjects(this.featureSectionsYMap, sections);
16866
+ }
16867
+ deleteFeatureSections(ids) {
16868
+ this.deleteObjects(this.featureSectionsYMap, ids);
16869
+ }
16870
+ get featureSectionsYMap() {
16871
+ return this.yDoc.getMap("forgeProjectFeatureSections");
16872
+ }
16873
+ //
16837
16874
  // Executed transactions
16838
16875
  //
16839
16876
  updateExecutedTransactionIds(transactionIds) {
@@ -16863,7 +16900,7 @@ var ForgeProjectRoomBaseYDoc = class {
16863
16900
  return objects;
16864
16901
  }
16865
16902
  setObjects(map, objects) {
16866
- objects.forEach((obj) => map.set(obj.id, obj));
16903
+ objects.forEach((o) => map.set(o.id, JSON.parse(JSON.stringify(o))));
16867
16904
  }
16868
16905
  deleteObjects(map, ids) {
16869
16906
  ids.forEach((id) => map.delete(id));
@@ -16883,6 +16920,10 @@ var BackendForgeProjectRoomYDoc = class {
16883
16920
  transaction.artifacts && yDoc.updateArtifacts(transaction.artifacts);
16884
16921
  transaction.featureIdsToDelete && yDoc.deleteFeatures(transaction.featureIdsToDelete);
16885
16922
  transaction.features && yDoc.updateFeatures(transaction.features);
16923
+ transaction.artifactSectionIdsToDelete && yDoc.deleteArtifactSections(transaction.artifactSectionIdsToDelete);
16924
+ transaction.artifactSections && yDoc.updateArtifactSections(transaction.artifactSections);
16925
+ transaction.featureSectionIdsToDelete && yDoc.deleteFeatureSections(transaction.featureSectionIdsToDelete);
16926
+ transaction.featureSections && yDoc.updateFeatureSections(transaction.featureSections);
16886
16927
  transaction.executedTransactionIds && yDoc.updateExecutedTransactionIds(transaction.executedTransactionIds);
16887
16928
  });
16888
16929
  }
@@ -17121,16 +17162,22 @@ var LocalProjectActionExecutor = class {
17121
17162
  __publicField(this, "projectId");
17122
17163
  __publicField(this, "artifacts");
17123
17164
  __publicField(this, "features");
17165
+ __publicField(this, "artifactSections");
17166
+ __publicField(this, "featureSections");
17124
17167
  const { projectId, remoteState, userId } = config;
17125
17168
  this.userId = userId;
17126
17169
  this.projectId = projectId;
17127
17170
  this.artifacts = mapByUnique(remoteState.artifacts, (p) => p.id);
17128
17171
  this.features = mapByUnique(remoteState.features, (p) => p.id);
17172
+ this.artifactSections = mapByUnique(remoteState.artifactSections, (p) => p.id);
17173
+ this.featureSections = mapByUnique(remoteState.featureSections, (p) => p.id);
17129
17174
  }
17130
17175
  get localState() {
17131
17176
  return {
17132
17177
  artifacts: Array.from(this.artifacts.values()),
17133
- features: Array.from(this.features.values())
17178
+ features: Array.from(this.features.values()),
17179
+ artifactSections: Array.from(this.artifactSections.values()),
17180
+ featureSections: Array.from(this.featureSections.values())
17134
17181
  };
17135
17182
  }
17136
17183
  applyActions(trx) {
@@ -17150,6 +17197,12 @@ var LocalProjectActionExecutor = class {
17150
17197
  return this.featureDelete(trx);
17151
17198
  case "FeatureUpdate":
17152
17199
  return this.featureUpdate(trx);
17200
+ case "SectionCreate":
17201
+ return this.sectionCreate(trx);
17202
+ case "SectionUpdate":
17203
+ return this.sectionUpdate(trx);
17204
+ case "SectionDelete":
17205
+ return this.sectionDelete(trx);
17153
17206
  }
17154
17207
  }
17155
17208
  //
@@ -17231,6 +17284,48 @@ var LocalProjectActionExecutor = class {
17231
17284
  throw new Error(`Cannot delete feature: feature ${id} was not found in local storage`);
17232
17285
  }
17233
17286
  }
17287
+ //
17288
+ // Sections
17289
+ //
17290
+ sectionCreate(trx) {
17291
+ const { input } = trx;
17292
+ const { id } = input;
17293
+ const sections = input.childType === "Artifact" ? this.artifactSections : this.featureSections;
17294
+ sections.set(id, {
17295
+ id,
17296
+ projectId: this.projectId,
17297
+ name: input.name,
17298
+ childType: input.childType,
17299
+ sortOrder: 0,
17300
+ // TODO: Use Roman's calculate functions
17301
+ updatedAt: /* @__PURE__ */ new Date(),
17302
+ createdAt: /* @__PURE__ */ new Date()
17303
+ });
17304
+ }
17305
+ sectionUpdate(trx) {
17306
+ const { input } = trx;
17307
+ const { id } = input;
17308
+ const existingSection = this.artifactSections.get(id) ?? this.featureSections.get(id);
17309
+ if (!existingSection) {
17310
+ throw new Error(`Cannot update section: section ${id} was not found in local storage`);
17311
+ }
17312
+ const mergedSection = {
17313
+ ...existingSection,
17314
+ name: input.name ?? existingSection.name,
17315
+ updatedAt: /* @__PURE__ */ new Date()
17316
+ };
17317
+ const sections = existingSection.childType === "Artifact" ? this.artifactSections : this.featureSections;
17318
+ sections.set(id, mergedSection);
17319
+ }
17320
+ sectionDelete(trx) {
17321
+ const { input } = trx;
17322
+ const { id } = input;
17323
+ const isArtifactSection = this.artifactSections.delete(id);
17324
+ const isFeatureSection = this.featureSections.delete(id);
17325
+ if (!isArtifactSection && !isFeatureSection) {
17326
+ throw new Error(`Cannot delete section: section ${id} was not found in local storage`);
17327
+ }
17328
+ }
17234
17329
  };
17235
17330
 
17236
17331
  // src/sync/project-content-repo.ts
@@ -17344,7 +17439,9 @@ var ForgeProjectContentRepository = class {
17344
17439
  });
17345
17440
  return {
17346
17441
  artifacts: state.artifacts,
17347
- features: state.features
17442
+ features: state.features,
17443
+ artifactSections: state.artifactSections,
17444
+ featureSections: state.featureSections
17348
17445
  };
17349
17446
  }
17350
17447
  onYUpdate() {