@thatopen/services 0.28.1 → 0.29.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/cli.js +122 -0
- package/dist/cli.js.map +1 -1
- package/dist/core/documents.d.ts +59 -0
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1105 -972
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/core/documents.d.ts
CHANGED
|
@@ -93,4 +93,63 @@ export declare class ProjectDocuments {
|
|
|
93
93
|
addView(folderId: string, view: DocumentView): Promise<void>;
|
|
94
94
|
/** Writes the descriptor, creating or replacing `document.json`. */
|
|
95
95
|
setDescriptor(folderId: string, descriptor: Omit<DocumentDescriptor, 'schema'> & Partial<Pick<DocumentDescriptor, 'schema'>>): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* The document's DRAFTS: each user's working copy, kept so that closing the
|
|
98
|
+
* browser never loses work. A draft is not a version — it never enters the
|
|
99
|
+
* history and never shows in the CDE. See {@link DocumentDrafts}.
|
|
100
|
+
*/
|
|
101
|
+
drafts(folderId: string): DocumentDrafts;
|
|
102
|
+
}
|
|
103
|
+
/** One user's draft of a document, as listed — no download involved. */
|
|
104
|
+
export interface DraftInfo {
|
|
105
|
+
userId: string;
|
|
106
|
+
/** When the server stored it: read from the hidden file's own id, not a client clock. */
|
|
107
|
+
savedAt: Date;
|
|
108
|
+
}
|
|
109
|
+
/** One user's draft, downloaded. */
|
|
110
|
+
export interface Draft<Meta = Record<string, unknown>> extends DraftInfo {
|
|
111
|
+
blob: Blob;
|
|
112
|
+
/** Whatever the app put next to the bytes: base version, app, app version… */
|
|
113
|
+
meta: Meta;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* A document's drafts: one working copy per user, stored as a HIDDEN file under
|
|
117
|
+
* the document's `document.json`. Hidden files are what make this possible —
|
|
118
|
+
* a visible file cannot be overwritten without becoming a new version, and a
|
|
119
|
+
* draft written every few seconds must not fill the history or the CDE.
|
|
120
|
+
*
|
|
121
|
+
* Hidden files cannot be edited, so `put` uploads the new draft FIRST and then
|
|
122
|
+
* deletes that user's previous ones: a failure in between leaves two, and
|
|
123
|
+
* reads take the newest, never none. Every project member can read every draft;
|
|
124
|
+
* each app decides whose to offer.
|
|
125
|
+
*/
|
|
126
|
+
export declare class DocumentDrafts {
|
|
127
|
+
#private;
|
|
128
|
+
private readonly client;
|
|
129
|
+
private readonly holder;
|
|
130
|
+
constructor(client: EngineServicesClient, holder: () => Promise<{
|
|
131
|
+
id: string;
|
|
132
|
+
} | undefined>);
|
|
133
|
+
/** Every user's latest draft, without downloading any. Newest first. */
|
|
134
|
+
list(): Promise<DraftInfo[]>;
|
|
135
|
+
/**
|
|
136
|
+
* One user's draft, downloaded — or, without `userId`, the newest of anyone.
|
|
137
|
+
* Null when there is none.
|
|
138
|
+
*/
|
|
139
|
+
get<Meta = Record<string, unknown>>(options?: {
|
|
140
|
+
userId?: string;
|
|
141
|
+
}): Promise<Draft<Meta> | null>;
|
|
142
|
+
/**
|
|
143
|
+
* Stores this user's draft, replacing their previous one: only the latest is
|
|
144
|
+
* kept. Needs the document to have a descriptor (convert loose files first
|
|
145
|
+
* with `fromFile`).
|
|
146
|
+
*/
|
|
147
|
+
put(blob: Blob, options: {
|
|
148
|
+
userId: string;
|
|
149
|
+
meta?: Record<string, unknown>;
|
|
150
|
+
}): Promise<DraftInfo>;
|
|
151
|
+
/** Deletes every draft of this user (on an explicit save, typically). */
|
|
152
|
+
delete(options: {
|
|
153
|
+
userId: string;
|
|
154
|
+
}): Promise<void>;
|
|
96
155
|
}
|