@supernova-studio/client 1.0.0-alpha.2 → 1.0.0-alpha.3
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 +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +81 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1135,10 +1135,14 @@ type LocalDocsPageGroup = OmitStrict<ElementGroup, "id" | "brandPersistentId" |
|
|
|
1135
1135
|
};
|
|
1136
1136
|
declare class LocalStorage {
|
|
1137
1137
|
private readonly pages;
|
|
1138
|
+
private readonly deletedPageIds;
|
|
1138
1139
|
private readonly groups;
|
|
1139
|
-
|
|
1140
|
+
setPage(page: LocalDocsPage): void;
|
|
1141
|
+
deletePage(persistentId: string): void;
|
|
1142
|
+
tryGetPage(persistentId: string): LocalDocsPage | undefined;
|
|
1140
1143
|
getPage(persistentId: string): LocalDocsPage;
|
|
1141
1144
|
getAllPages(): LocalDocsPage[];
|
|
1145
|
+
getAllDeletedPages(): Set<string>;
|
|
1142
1146
|
removePage(persistentId: string): void;
|
|
1143
1147
|
}
|
|
1144
1148
|
|
|
@@ -92474,6 +92478,11 @@ type DocPageCreate = {
|
|
|
92474
92478
|
parentPersistentId: string;
|
|
92475
92479
|
afterPersistentId?: string;
|
|
92476
92480
|
};
|
|
92481
|
+
type DocPageUpdate = {
|
|
92482
|
+
persistentId: string;
|
|
92483
|
+
title?: string;
|
|
92484
|
+
configuration?: DTODocumentationItemConfigurationV2;
|
|
92485
|
+
};
|
|
92477
92486
|
type TransactionExecutor = (trx: DTOElementActionInput) => Promise<void>;
|
|
92478
92487
|
declare class DocsStructureRepository {
|
|
92479
92488
|
private readonly localState;
|
|
@@ -92488,6 +92497,13 @@ declare class DocsStructureRepository {
|
|
|
92488
92497
|
dispose(): void;
|
|
92489
92498
|
createPage(input: DocPageCreate): void;
|
|
92490
92499
|
createPagePromise(input: DocPageCreate): Promise<void>;
|
|
92500
|
+
updatePage(update: DocPageUpdate): void;
|
|
92501
|
+
updatePagePromise(update: DocPageUpdate): Promise<void>;
|
|
92502
|
+
private updatePageLocally;
|
|
92503
|
+
deletePagePromise(persistentId: string): Promise<void>;
|
|
92504
|
+
deletePage(persistentId: string): void;
|
|
92505
|
+
private createLocalPageUpdate;
|
|
92506
|
+
private lookupPage;
|
|
92491
92507
|
private recalculateHierarchy;
|
|
92492
92508
|
private onYUpdate;
|
|
92493
92509
|
private calculateSortOrder;
|
package/dist/index.d.ts
CHANGED
|
@@ -1135,10 +1135,14 @@ type LocalDocsPageGroup = OmitStrict<ElementGroup, "id" | "brandPersistentId" |
|
|
|
1135
1135
|
};
|
|
1136
1136
|
declare class LocalStorage {
|
|
1137
1137
|
private readonly pages;
|
|
1138
|
+
private readonly deletedPageIds;
|
|
1138
1139
|
private readonly groups;
|
|
1139
|
-
|
|
1140
|
+
setPage(page: LocalDocsPage): void;
|
|
1141
|
+
deletePage(persistentId: string): void;
|
|
1142
|
+
tryGetPage(persistentId: string): LocalDocsPage | undefined;
|
|
1140
1143
|
getPage(persistentId: string): LocalDocsPage;
|
|
1141
1144
|
getAllPages(): LocalDocsPage[];
|
|
1145
|
+
getAllDeletedPages(): Set<string>;
|
|
1142
1146
|
removePage(persistentId: string): void;
|
|
1143
1147
|
}
|
|
1144
1148
|
|
|
@@ -92474,6 +92478,11 @@ type DocPageCreate = {
|
|
|
92474
92478
|
parentPersistentId: string;
|
|
92475
92479
|
afterPersistentId?: string;
|
|
92476
92480
|
};
|
|
92481
|
+
type DocPageUpdate = {
|
|
92482
|
+
persistentId: string;
|
|
92483
|
+
title?: string;
|
|
92484
|
+
configuration?: DTODocumentationItemConfigurationV2;
|
|
92485
|
+
};
|
|
92477
92486
|
type TransactionExecutor = (trx: DTOElementActionInput) => Promise<void>;
|
|
92478
92487
|
declare class DocsStructureRepository {
|
|
92479
92488
|
private readonly localState;
|
|
@@ -92488,6 +92497,13 @@ declare class DocsStructureRepository {
|
|
|
92488
92497
|
dispose(): void;
|
|
92489
92498
|
createPage(input: DocPageCreate): void;
|
|
92490
92499
|
createPagePromise(input: DocPageCreate): Promise<void>;
|
|
92500
|
+
updatePage(update: DocPageUpdate): void;
|
|
92501
|
+
updatePagePromise(update: DocPageUpdate): Promise<void>;
|
|
92502
|
+
private updatePageLocally;
|
|
92503
|
+
deletePagePromise(persistentId: string): Promise<void>;
|
|
92504
|
+
deletePage(persistentId: string): void;
|
|
92505
|
+
private createLocalPageUpdate;
|
|
92506
|
+
private lookupPage;
|
|
92491
92507
|
private recalculateHierarchy;
|
|
92492
92508
|
private onYUpdate;
|
|
92493
92509
|
private calculateSortOrder;
|
package/dist/index.js
CHANGED
|
@@ -12900,24 +12900,34 @@ var BackendVersionRoomYDoc = class {
|
|
|
12900
12900
|
var LocalStorage = class {
|
|
12901
12901
|
constructor() {
|
|
12902
12902
|
__publicField(this, "pages", /* @__PURE__ */ new Map());
|
|
12903
|
+
__publicField(this, "deletedPageIds", /* @__PURE__ */ new Set());
|
|
12903
12904
|
__publicField(this, "groups", /* @__PURE__ */ new Map());
|
|
12904
12905
|
}
|
|
12905
|
-
|
|
12906
|
+
setPage(page) {
|
|
12906
12907
|
if (this.pages.has(page.persistentId)) {
|
|
12907
12908
|
throw new Error(`Page with id ${page.persistentId} already exists`);
|
|
12908
12909
|
}
|
|
12909
12910
|
this.pages.set(page.persistentId, page);
|
|
12910
12911
|
}
|
|
12912
|
+
deletePage(persistentId) {
|
|
12913
|
+
this.pages.delete(persistentId);
|
|
12914
|
+
this.deletedPageIds.add(persistentId);
|
|
12915
|
+
}
|
|
12916
|
+
tryGetPage(persistentId) {
|
|
12917
|
+
return this.pages.get(persistentId);
|
|
12918
|
+
}
|
|
12911
12919
|
getPage(persistentId) {
|
|
12912
|
-
const page = this.
|
|
12913
|
-
if (!page)
|
|
12920
|
+
const page = this.tryGetPage(persistentId);
|
|
12921
|
+
if (!page)
|
|
12914
12922
|
throw new Error(`Page with id ${persistentId} doesn't exist`);
|
|
12915
|
-
}
|
|
12916
12923
|
return page;
|
|
12917
12924
|
}
|
|
12918
12925
|
getAllPages() {
|
|
12919
12926
|
return Array.from(this.pages.values());
|
|
12920
12927
|
}
|
|
12928
|
+
getAllDeletedPages() {
|
|
12929
|
+
return this.deletedPageIds;
|
|
12930
|
+
}
|
|
12921
12931
|
removePage(persistentId) {
|
|
12922
12932
|
this.pages.delete(persistentId);
|
|
12923
12933
|
}
|
|
@@ -12960,7 +12970,7 @@ var DocsStructureRepository = class {
|
|
|
12960
12970
|
void this.createPage(input);
|
|
12961
12971
|
}
|
|
12962
12972
|
createPagePromise(input) {
|
|
12963
|
-
this.localState.
|
|
12973
|
+
this.localState.setPage({
|
|
12964
12974
|
createdAt: /* @__PURE__ */ new Date(),
|
|
12965
12975
|
parentPersistentId: input.parentPersistentId,
|
|
12966
12976
|
persistentId: input.persistentId,
|
|
@@ -12972,7 +12982,8 @@ var DocsStructureRepository = class {
|
|
|
12972
12982
|
sortOrder: this.calculateSortOrder(input.parentPersistentId, input.afterPersistentId),
|
|
12973
12983
|
designSystemVersionId: ""
|
|
12974
12984
|
});
|
|
12975
|
-
|
|
12985
|
+
this.recalculateHierarchy();
|
|
12986
|
+
return this.trxQueue.enqueue({
|
|
12976
12987
|
type: "DocumentationPageCreate",
|
|
12977
12988
|
input: {
|
|
12978
12989
|
persistentId: input.persistentId,
|
|
@@ -12982,19 +12993,81 @@ var DocsStructureRepository = class {
|
|
|
12982
12993
|
configuration: input.configuration
|
|
12983
12994
|
}
|
|
12984
12995
|
});
|
|
12996
|
+
}
|
|
12997
|
+
updatePage(update) {
|
|
12998
|
+
void this.updatePagePromise(update);
|
|
12999
|
+
}
|
|
13000
|
+
updatePagePromise(update) {
|
|
13001
|
+
this.updatePageLocally(update);
|
|
13002
|
+
this.recalculateHierarchy();
|
|
13003
|
+
return this.trxQueue.enqueue({
|
|
13004
|
+
type: "DocumentationPageUpdate",
|
|
13005
|
+
input: {
|
|
13006
|
+
id: update.persistentId,
|
|
13007
|
+
configuration: update.configuration,
|
|
13008
|
+
title: update.title
|
|
13009
|
+
}
|
|
13010
|
+
});
|
|
13011
|
+
}
|
|
13012
|
+
updatePageLocally(update) {
|
|
13013
|
+
const basePage = this.lookupPage(update.persistentId);
|
|
13014
|
+
this.localState.setPage(this.createLocalPageUpdate(basePage, update));
|
|
13015
|
+
}
|
|
13016
|
+
deletePagePromise(persistentId) {
|
|
13017
|
+
this.lookupPage(persistentId);
|
|
13018
|
+
this.localState.deletePage(persistentId);
|
|
12985
13019
|
this.recalculateHierarchy();
|
|
12986
|
-
return
|
|
13020
|
+
return this.trxQueue.enqueue({
|
|
13021
|
+
type: "DocumentationPageDelete",
|
|
13022
|
+
input: {
|
|
13023
|
+
id: persistentId
|
|
13024
|
+
}
|
|
13025
|
+
});
|
|
13026
|
+
}
|
|
13027
|
+
deletePage(persistentId) {
|
|
13028
|
+
void this.deletePagePromise(persistentId);
|
|
13029
|
+
}
|
|
13030
|
+
createLocalPageUpdate(basePage, update) {
|
|
13031
|
+
const { title, configuration } = update;
|
|
13032
|
+
return {
|
|
13033
|
+
createdAt: basePage.createdAt,
|
|
13034
|
+
data: {
|
|
13035
|
+
configuration: _nullishCoalesce(configuration, () => ( basePage.data.configuration))
|
|
13036
|
+
},
|
|
13037
|
+
designSystemVersionId: basePage.designSystemVersionId,
|
|
13038
|
+
meta: { name: _nullishCoalesce(title, () => ( basePage.meta.name)) },
|
|
13039
|
+
parentPersistentId: basePage.parentPersistentId,
|
|
13040
|
+
persistentId: basePage.persistentId,
|
|
13041
|
+
shortPersistentId: basePage.shortPersistentId,
|
|
13042
|
+
sortOrder: basePage.sortOrder,
|
|
13043
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
13044
|
+
slug: basePage.slug
|
|
13045
|
+
};
|
|
13046
|
+
}
|
|
13047
|
+
lookupPage(persistentId) {
|
|
13048
|
+
const localPageToUpdate = this.localState.tryGetPage(persistentId);
|
|
13049
|
+
if (localPageToUpdate)
|
|
13050
|
+
return localPageToUpdate;
|
|
13051
|
+
const remotePage = this.yState.pages.find((p) => p.persistentId === persistentId);
|
|
13052
|
+
if (remotePage)
|
|
13053
|
+
return remotePage;
|
|
13054
|
+
throw SupernovaException.notFound(`Page ${persistentId} was not found`);
|
|
12987
13055
|
}
|
|
12988
13056
|
//
|
|
12989
13057
|
// Reactions
|
|
12990
13058
|
//
|
|
12991
13059
|
recalculateHierarchy() {
|
|
13060
|
+
const allPagesById = mapByUnique(this.yState.pages, (p) => p.persistentId);
|
|
13061
|
+
this.localState.getAllPages().forEach((p) => {
|
|
13062
|
+
allPagesById.set(p.persistentId, p);
|
|
13063
|
+
});
|
|
13064
|
+
this.localState.getAllDeletedPages().forEach((id) => allPagesById.delete(id));
|
|
12992
13065
|
const hierarchy = computeDocsHierarchy({
|
|
12993
13066
|
approvals: this.yState.approvals,
|
|
12994
13067
|
groups: this.yState.groups,
|
|
12995
13068
|
groupSnapshots: this.yState.groupSnapshots,
|
|
12996
13069
|
pageContentHashes: this.yState.pageContentHashes,
|
|
12997
|
-
pages:
|
|
13070
|
+
pages: Array.from(allPagesById.values()),
|
|
12998
13071
|
pageSnapshots: this.yState.pageSnapshots,
|
|
12999
13072
|
settings: this.yState.settings
|
|
13000
13073
|
});
|