@supernova-studio/client 1.3.0 → 1.3.2

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.d.mts CHANGED
@@ -1824,7 +1824,7 @@ type LocalDocsPageGroup = OmitStrict<ElementGroup, "id" | "brandPersistentId" |
1824
1824
  };
1825
1825
  type LocalApproval = OmitStrict<DocumentationPageApproval, "id" | "pageId" | "persistentId">;
1826
1826
  type NarrowedUnion<T, U extends T> = U;
1827
- type SupportedActionType = NarrowedUnion<DTOElementActionInput["type"], "DocumentationPageCreate" | "DocumentationPageUpdate" | "DocumentationPageDelete" | "DocumentationPageMove" | "DocumentationGroupCreate" | "DocumentationGroupUpdate" | "DocumentationGroupDelete" | "DocumentationGroupMove" | "DocumentationPageApprovalStateChange">;
1827
+ type SupportedActionType = NarrowedUnion<DTOElementActionInput["type"], "DocumentationPageCreate" | "DocumentationPageUpdate" | "DocumentationPageDelete" | "DocumentationPageMove" | "DocumentationGroupCreate" | "DocumentationGroupUpdate" | "DocumentationGroupDelete" | "DocumentationGroupMove" | "DocumentationPageApprovalStateChange" | "DocumentationTabCreate">;
1828
1828
 
1829
1829
  declare const DTOColorTokenInlineData: z.ZodObject<{
1830
1830
  value: z.ZodString;
@@ -103221,6 +103221,7 @@ declare function applyActionsLocally(input: Input): {
103221
103221
  pages: Page[];
103222
103222
  groups: Group[];
103223
103223
  approvals: ApprovalState[];
103224
+ pageLiveblockRoomIds: Record<string, string>;
103224
103225
  };
103225
103226
  type LocalExecutorConfig = {
103226
103227
  userId: string;
@@ -103233,11 +103234,13 @@ declare class LocalDocsElementActionExecutor {
103233
103234
  private readonly pages;
103234
103235
  private readonly groups;
103235
103236
  private readonly approvalStates;
103237
+ private readonly pageLiveblockRoomIds;
103236
103238
  constructor(config: LocalExecutorConfig);
103237
103239
  get localState(): {
103238
103240
  pages: Page[];
103239
103241
  groups: Group[];
103240
103242
  approvals: ApprovalState[];
103243
+ pageLiveblockRoomIds: Record<string, string>;
103241
103244
  };
103242
103245
  applyActions(trx: DTOElementActionInput[]): void;
103243
103246
  applyTransaction(trx: DTOElementActionInput): void;
@@ -103249,6 +103252,7 @@ declare class LocalDocsElementActionExecutor {
103249
103252
  private documentationGroupUpdate;
103250
103253
  private documentationGroupMove;
103251
103254
  private documentationGroupDelete;
103255
+ private documentationTabCreate;
103252
103256
  private documentationApprovalStateUpdate;
103253
103257
  private calculateSortOrder;
103254
103258
  }
package/dist/index.d.ts CHANGED
@@ -1824,7 +1824,7 @@ type LocalDocsPageGroup = OmitStrict<ElementGroup, "id" | "brandPersistentId" |
1824
1824
  };
1825
1825
  type LocalApproval = OmitStrict<DocumentationPageApproval, "id" | "pageId" | "persistentId">;
1826
1826
  type NarrowedUnion<T, U extends T> = U;
1827
- type SupportedActionType = NarrowedUnion<DTOElementActionInput["type"], "DocumentationPageCreate" | "DocumentationPageUpdate" | "DocumentationPageDelete" | "DocumentationPageMove" | "DocumentationGroupCreate" | "DocumentationGroupUpdate" | "DocumentationGroupDelete" | "DocumentationGroupMove" | "DocumentationPageApprovalStateChange">;
1827
+ type SupportedActionType = NarrowedUnion<DTOElementActionInput["type"], "DocumentationPageCreate" | "DocumentationPageUpdate" | "DocumentationPageDelete" | "DocumentationPageMove" | "DocumentationGroupCreate" | "DocumentationGroupUpdate" | "DocumentationGroupDelete" | "DocumentationGroupMove" | "DocumentationPageApprovalStateChange" | "DocumentationTabCreate">;
1828
1828
 
1829
1829
  declare const DTOColorTokenInlineData: z.ZodObject<{
1830
1830
  value: z.ZodString;
@@ -103221,6 +103221,7 @@ declare function applyActionsLocally(input: Input): {
103221
103221
  pages: Page[];
103222
103222
  groups: Group[];
103223
103223
  approvals: ApprovalState[];
103224
+ pageLiveblockRoomIds: Record<string, string>;
103224
103225
  };
103225
103226
  type LocalExecutorConfig = {
103226
103227
  userId: string;
@@ -103233,11 +103234,13 @@ declare class LocalDocsElementActionExecutor {
103233
103234
  private readonly pages;
103234
103235
  private readonly groups;
103235
103236
  private readonly approvalStates;
103237
+ private readonly pageLiveblockRoomIds;
103236
103238
  constructor(config: LocalExecutorConfig);
103237
103239
  get localState(): {
103238
103240
  pages: Page[];
103239
103241
  groups: Group[];
103240
103242
  approvals: ApprovalState[];
103243
+ pageLiveblockRoomIds: Record<string, string>;
103241
103244
  };
103242
103245
  applyActions(trx: DTOElementActionInput[]): void;
103243
103246
  applyTransaction(trx: DTOElementActionInput): void;
@@ -103249,6 +103252,7 @@ declare class LocalDocsElementActionExecutor {
103249
103252
  private documentationGroupUpdate;
103250
103253
  private documentationGroupMove;
103251
103254
  private documentationGroupDelete;
103255
+ private documentationTabCreate;
103252
103256
  private documentationApprovalStateUpdate;
103253
103257
  private calculateSortOrder;
103254
103258
  }
package/dist/index.js CHANGED
@@ -13586,18 +13586,21 @@ var LocalDocsElementActionExecutor = class {
13586
13586
  __publicField(this, "pages");
13587
13587
  __publicField(this, "groups");
13588
13588
  __publicField(this, "approvalStates");
13589
+ __publicField(this, "pageLiveblockRoomIds");
13589
13590
  const { designSystemVersionId, remoteState, userId } = config;
13590
13591
  this.userId = userId;
13591
13592
  this.designSystemVersionId = designSystemVersionId;
13592
13593
  this.pages = mapByUnique(remoteState.pages, (p) => p.persistentId);
13593
13594
  this.groups = mapByUnique(remoteState.groups, (p) => p.persistentId);
13594
13595
  this.approvalStates = mapByUnique(remoteState.approvals, (a) => a.pagePersistentId);
13596
+ this.pageLiveblockRoomIds = { ...remoteState.pageLiveblockRoomIds };
13595
13597
  }
13596
13598
  get localState() {
13597
13599
  return {
13598
13600
  pages: Array.from(this.pages.values()),
13599
13601
  groups: Array.from(this.groups.values()),
13600
- approvals: Array.from(this.approvalStates.values())
13602
+ approvals: Array.from(this.approvalStates.values()),
13603
+ pageLiveblockRoomIds: this.pageLiveblockRoomIds
13601
13604
  };
13602
13605
  }
13603
13606
  applyActions(trx) {
@@ -13630,6 +13633,7 @@ var LocalDocsElementActionExecutor = class {
13630
13633
  case "DocumentationPageRestore":
13631
13634
  throw new Error(`Transaction type ${trx.type} is not yet implemented`);
13632
13635
  case "DocumentationTabCreate":
13636
+ return this.documentationTabCreate(trx);
13633
13637
  case "DocumentationTabGroupDelete":
13634
13638
  throw new Error(`Transaction type ${trx.type} is not yet implemented`);
13635
13639
  case "FigmaNodeRender":
@@ -13642,6 +13646,7 @@ var LocalDocsElementActionExecutor = class {
13642
13646
  //
13643
13647
  documentationPageCreate(trx) {
13644
13648
  const { input } = trx;
13649
+ const { persistentId } = input;
13645
13650
  if (this.pages.has(input.persistentId)) {
13646
13651
  return;
13647
13652
  }
@@ -13649,9 +13654,9 @@ var LocalDocsElementActionExecutor = class {
13649
13654
  throw new Error(`Cannot create page: parent persistent id ${input.parentPersistentId} was not found`);
13650
13655
  }
13651
13656
  const localPage = {
13657
+ persistentId,
13652
13658
  createdAt: /* @__PURE__ */ new Date(),
13653
13659
  parentPersistentId: input.parentPersistentId,
13654
- persistentId: input.persistentId,
13655
13660
  shortPersistentId: generateShortPersistentId(),
13656
13661
  slug: slugify(input.title),
13657
13662
  meta: { name: input.title },
@@ -13663,7 +13668,9 @@ var LocalDocsElementActionExecutor = class {
13663
13668
  sortOrder: this.calculateSortOrder(input.parentPersistentId, input.afterPersistentId),
13664
13669
  designSystemVersionId: this.designSystemVersionId
13665
13670
  };
13666
- this.pages.set(localPage.persistentId, localPage);
13671
+ this.pages.set(persistentId, localPage);
13672
+ const roomId = `${RoomType.DocumentationPage}:${this.designSystemVersionId}:${persistentId}`;
13673
+ this.pageLiveblockRoomIds[persistentId] = roomId;
13667
13674
  }
13668
13675
  documentationPageUpdate(trx) {
13669
13676
  const { input } = trx;
@@ -13707,6 +13714,7 @@ var LocalDocsElementActionExecutor = class {
13707
13714
  if (!this.pages.delete(trx.input.id)) {
13708
13715
  throw new Error(`Cannot delete page: page id ${input.id} was not found`);
13709
13716
  }
13717
+ delete this.pageLiveblockRoomIds[trx.input.id];
13710
13718
  }
13711
13719
  //
13712
13720
  // Group
@@ -13780,6 +13788,40 @@ var LocalDocsElementActionExecutor = class {
13780
13788
  }
13781
13789
  }
13782
13790
  //
13791
+ // Tabs
13792
+ //
13793
+ documentationTabCreate(trx) {
13794
+ const { input } = trx;
13795
+ const page = this.pages.get(input.fromItemPersistentId);
13796
+ if (!page) {
13797
+ throw new Error(`Cannot create tab: page id ${input.fromItemPersistentId} was not found`);
13798
+ }
13799
+ const tabGroup = {
13800
+ parentPersistentId: page.parentPersistentId,
13801
+ persistentId: input.persistentId,
13802
+ shortPersistentId: generateShortPersistentId(),
13803
+ slug: page.slug,
13804
+ meta: page.meta,
13805
+ createdAt: /* @__PURE__ */ new Date(),
13806
+ updatedAt: /* @__PURE__ */ new Date(),
13807
+ data: {
13808
+ behavior: "Tabs",
13809
+ configuration: _optionalChain([page, 'optionalAccess', _90 => _90.data, 'access', _91 => _91.configuration])
13810
+ },
13811
+ sortOrder: page.sortOrder,
13812
+ designSystemVersionId: this.designSystemVersionId
13813
+ };
13814
+ this.groups.set(input.persistentId, tabGroup);
13815
+ const newLocalPage = {
13816
+ ...page,
13817
+ userSlug: void 0,
13818
+ sortOrder: 0,
13819
+ parentPersistentId: input.persistentId,
13820
+ meta: { name: input.tabName }
13821
+ };
13822
+ this.pages.set(newLocalPage.persistentId, newLocalPage);
13823
+ }
13824
+ //
13783
13825
  // Approval states
13784
13826
  //
13785
13827
  documentationApprovalStateUpdate(trx) {
@@ -13788,7 +13830,7 @@ var LocalDocsElementActionExecutor = class {
13788
13830
  if (input.approvalState) {
13789
13831
  this.approvalStates.set(input.persistentId, {
13790
13832
  approvalState: input.approvalState,
13791
- createdAt: _nullishCoalesce(_optionalChain([existingApproval, 'optionalAccess', _90 => _90.createdAt]), () => ( /* @__PURE__ */ new Date())),
13833
+ createdAt: _nullishCoalesce(_optionalChain([existingApproval, 'optionalAccess', _92 => _92.createdAt]), () => ( /* @__PURE__ */ new Date())),
13792
13834
  designSystemVersionId: this.designSystemVersionId,
13793
13835
  pagePersistentId: input.persistentId,
13794
13836
  updatedAt: /* @__PURE__ */ new Date(),
@@ -13819,7 +13861,7 @@ var LocalDocsElementActionExecutor = class {
13819
13861
  return neighbours[neighbours.length - 1].sortOrder + sortOrderStep;
13820
13862
  }
13821
13863
  const left = neighbours[index].sortOrder;
13822
- const right = _nullishCoalesce(_optionalChain([neighbours, 'access', _91 => _91[index + 1], 'optionalAccess', _92 => _92.sortOrder]), () => ( left + sortOrderStep * 2));
13864
+ const right = _nullishCoalesce(_optionalChain([neighbours, 'access', _93 => _93[index + 1], 'optionalAccess', _94 => _94.sortOrder]), () => ( left + sortOrderStep * 2));
13823
13865
  return (right + left) / 2;
13824
13866
  }
13825
13867
  };
@@ -13962,7 +14004,7 @@ var DocsStructureRepository = class {
13962
14004
  const executedTransactionIds = new Set(yState.executedTransactionIds);
13963
14005
  const localActions = this.localActions.filter((a) => a.tId && !executedTransactionIds.has(a.tId));
13964
14006
  this.localActions = localActions;
13965
- const { pages, groups, approvals } = applyActionsLocally({
14007
+ const { pages, groups, approvals, pageLiveblockRoomIds } = applyActionsLocally({
13966
14008
  userId: this.userId,
13967
14009
  designSystemVersionId: this.designSystemVersionId,
13968
14010
  remoteState: yState,
@@ -13970,14 +14012,16 @@ var DocsStructureRepository = class {
13970
14012
  });
13971
14013
  const hierarchy = computeDocsHierarchy(
13972
14014
  {
14015
+ // Merged remote + local
13973
14016
  pages,
13974
14017
  groups,
13975
14018
  approvals,
14019
+ pageLiveblockRoomIds,
14020
+ // Remote only
13976
14021
  groupSnapshots: yState.groupSnapshots,
13977
14022
  pageContentHashes: yState.pageContentHashes,
13978
14023
  pageSnapshots: yState.pageSnapshots,
13979
- settings: yState.settings,
13980
- pageLiveblockRoomIds: yState.pageLiveblockRoomIds
14024
+ settings: yState.settings
13981
14025
  },
13982
14026
  { includeDeletedContent: true }
13983
14027
  );