@arbidocs/react 0.4.63 → 0.4.64
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/annotations/index.cjs +24 -23
- package/dist/annotations/index.cjs.map +1 -1
- package/dist/annotations/index.js +2 -1
- package/dist/annotations/index.js.map +1 -1
- package/dist/artifacts/index.cjs +79 -50
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.d.cts +52 -31
- package/dist/artifacts/index.d.ts +52 -31
- package/dist/artifacts/index.js +63 -37
- package/dist/artifacts/index.js.map +1 -1
- package/dist/{chunk-QS3Q5542.js → chunk-2VW47ADK.js} +10 -3
- package/dist/chunk-2VW47ADK.js.map +1 -0
- package/dist/chunk-4PRCRCQ5.cjs +41 -0
- package/dist/chunk-4PRCRCQ5.cjs.map +1 -0
- package/dist/{chunk-X3F5ABY2.cjs → chunk-6YKVIERB.cjs} +43 -21
- package/dist/chunk-6YKVIERB.cjs.map +1 -0
- package/dist/{chunk-Z4M7JB4L.cjs → chunk-D3CSLSGD.cjs} +9 -9
- package/dist/{chunk-Z4M7JB4L.cjs.map → chunk-D3CSLSGD.cjs.map} +1 -1
- package/dist/{chunk-N5SVBDLC.js → chunk-DIZC2XVB.js} +11 -4
- package/dist/chunk-DIZC2XVB.js.map +1 -0
- package/dist/{chunk-CVN7MAGQ.js → chunk-F5WHYJRB.js} +29 -7
- package/dist/chunk-F5WHYJRB.js.map +1 -0
- package/dist/{chunk-XDCRWZF2.cjs → chunk-GXQO3IJC.cjs} +10 -3
- package/dist/chunk-GXQO3IJC.cjs.map +1 -0
- package/dist/{chunk-OBNTJEEO.cjs → chunk-LCMCZS5Y.cjs} +11 -4
- package/dist/chunk-LCMCZS5Y.cjs.map +1 -0
- package/dist/{chunk-UDOPD3GK.js → chunk-NDABXDML.js} +3 -3
- package/dist/{chunk-UDOPD3GK.js.map → chunk-NDABXDML.js.map} +1 -1
- package/dist/chunk-QICALPFQ.js +18 -0
- package/dist/chunk-QICALPFQ.js.map +1 -0
- package/dist/{chunk-DSG3E7QX.js → chunk-SX7FCSON.js} +2 -2
- package/dist/chunk-SX7FCSON.js.map +1 -0
- package/dist/{chunk-UUE2R2E2.cjs → chunk-VH5ITITV.cjs} +2 -2
- package/dist/chunk-VH5ITITV.cjs.map +1 -0
- package/dist/{index-CUxIcC5j.d.ts → index-BWv_FKi3.d.cts} +18 -3
- package/dist/{index-CUxIcC5j.d.cts → index-BWv_FKi3.d.ts} +18 -3
- package/dist/index.cjs +356 -347
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -8
- package/dist/index.d.ts +42 -8
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/dist/shell/index.cjs +8 -7
- package/dist/shell/index.js +3 -2
- package/dist/ui/index.cjs +152 -143
- package/dist/ui/index.d.cts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +4 -3
- package/package.json +3 -3
- package/dist/chunk-CVN7MAGQ.js.map +0 -1
- package/dist/chunk-DSG3E7QX.js.map +0 -1
- package/dist/chunk-N5SVBDLC.js.map +0 -1
- package/dist/chunk-OBNTJEEO.cjs.map +0 -1
- package/dist/chunk-QS3Q5542.js.map +0 -1
- package/dist/chunk-UUE2R2E2.cjs.map +0 -1
- package/dist/chunk-X3F5ABY2.cjs.map +0 -1
- package/dist/chunk-XDCRWZF2.cjs.map +0 -1
|
@@ -57,51 +57,71 @@ interface UseRedlineResult {
|
|
|
57
57
|
declare function useRedline({ baseText, compareText, isLoading, withRegions, engine, }: UseRedlineOptions): UseRedlineResult;
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* Versions of a document.
|
|
61
|
-
* (`
|
|
62
|
-
*
|
|
63
|
-
*
|
|
60
|
+
* Versions of a document. A document keeps ONE id for its whole life; its versions live inside it
|
|
61
|
+
* (`current_version` + `versions`, numbered 1..n). A version is named by a version reference
|
|
62
|
+
* `doc-…@v{n}`; a plain document id means its current version. The workspace list carries every
|
|
63
|
+
* document's `versions`, and `GET /v1/document/{id}/versions` (`arbi.documents.versions`) the same
|
|
64
|
+
* list on its own.
|
|
64
65
|
*/
|
|
66
|
+
/** One version entry as the API returns it (a subset of `DocVersion`). */
|
|
67
|
+
interface DocVersionEntry {
|
|
68
|
+
n: number;
|
|
69
|
+
file_name?: string | null;
|
|
70
|
+
created_at?: string | null;
|
|
71
|
+
reason?: string | null;
|
|
72
|
+
/** The version an edit started from, when it was not the previous one. */
|
|
73
|
+
made_from?: number | null;
|
|
74
|
+
is_current?: boolean | null;
|
|
75
|
+
}
|
|
65
76
|
/** The fields of a workspace document the version list needs (a subset of the API type). */
|
|
66
77
|
interface VersionedDoc {
|
|
67
78
|
external_id?: string | null;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
is_current?: boolean | null;
|
|
71
|
-
/** Provenance: an `edit`/`sync` entry names the version this one was saved from. */
|
|
72
|
-
derived_from?: readonly {
|
|
73
|
-
doc_ext_id: string;
|
|
74
|
-
role: string;
|
|
75
|
-
}[] | null;
|
|
79
|
+
current_version?: number | null;
|
|
80
|
+
versions?: readonly DocVersionEntry[] | null;
|
|
76
81
|
file_name?: string | null;
|
|
77
82
|
created_at?: string | null;
|
|
78
83
|
}
|
|
79
84
|
/** One row of a version list. Matches `VersionEntry` of `@arbidocs/blocks/artifacts`. */
|
|
80
85
|
interface ArtifactVersion {
|
|
86
|
+
/** The version reference `doc-…@v{n}`: what opening or comparing this version names. */
|
|
81
87
|
id: string;
|
|
88
|
+
/** The document (the same for every version). */
|
|
89
|
+
docId: string;
|
|
82
90
|
/** File name as stored. */
|
|
83
91
|
name: string;
|
|
84
92
|
/** ISO timestamp. */
|
|
85
93
|
createdAt: string;
|
|
86
94
|
/** 1-based version number within the document. */
|
|
87
95
|
number: number;
|
|
96
|
+
/** upload | edit | signed | sync */
|
|
97
|
+
reason: string;
|
|
98
|
+
isCurrent: boolean;
|
|
88
99
|
/** The version this one was saved from (an older one than the previous version when restored). */
|
|
89
100
|
savedFromId?: string | null;
|
|
90
101
|
}
|
|
91
|
-
/**
|
|
92
|
-
declare function
|
|
102
|
+
/** `doc-…@v{n}`: a reference to version `n` of a document. */
|
|
103
|
+
declare function versionRef(docId: string, version: number): string;
|
|
93
104
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
105
|
+
* Split a reference into the document and the version it names. A plain document id (or anything
|
|
106
|
+
* else) names no version: the document's current one.
|
|
96
107
|
*/
|
|
97
|
-
declare function
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
declare function parseVersionRef(ref: string | null | undefined): {
|
|
109
|
+
docId: string;
|
|
110
|
+
version: number | null;
|
|
111
|
+
};
|
|
112
|
+
/** The version a version was saved from: `made_from`, else the one before it. */
|
|
113
|
+
declare function savedFromId(docId: string, entry: DocVersionEntry): string | null;
|
|
114
|
+
/** A document's version entries (oldest first) as plain version rows. */
|
|
115
|
+
declare function toArtifactVersions(docId: string | null | undefined, entries: readonly DocVersionEntry[] | null | undefined, currentVersion?: number | null): ArtifactVersion[];
|
|
116
|
+
/** The versions of a listed document, oldest first (`[]` when the document is not given). */
|
|
117
|
+
declare function documentVersions(doc: VersionedDoc | null | undefined): ArtifactVersion[];
|
|
118
|
+
/** The row `ref` names: an exact version, or (a plain document id) the current version. */
|
|
119
|
+
declare function findVersion(versions: readonly ArtifactVersion[], ref: string | null | undefined): ArtifactVersion | undefined;
|
|
100
120
|
/**
|
|
101
|
-
* "v2": the version number
|
|
121
|
+
* "v2": the version number `ref` names. `null` when there is nothing to tell apart (the document
|
|
102
122
|
* has a single version, or it is unknown), so unversioned documents stay unlabelled.
|
|
103
123
|
*/
|
|
104
|
-
declare function versionLabel(versions: readonly ArtifactVersion[],
|
|
124
|
+
declare function versionLabel(versions: readonly ArtifactVersion[], ref: string | null | undefined): string | null;
|
|
105
125
|
/**
|
|
106
126
|
* Join parsed chunks into one markdown text (blank line between chunks).
|
|
107
127
|
*
|
|
@@ -249,15 +269,16 @@ declare function useArtifactText(docId: string | null | undefined, options?: {
|
|
|
249
269
|
}): ArtifactText;
|
|
250
270
|
|
|
251
271
|
/**
|
|
252
|
-
* The versions of an artifact, oldest first.
|
|
253
|
-
*
|
|
272
|
+
* The versions of an artifact, oldest first. `docId` is a document id or a version reference
|
|
273
|
+
* (`doc-…@v2`). Every listed document carries its versions; a document that is not in the
|
|
274
|
+
* workspace list asks for its version list.
|
|
254
275
|
*/
|
|
255
276
|
declare function useArtifactVersions(workspaceId: string | undefined, docId: string | null | undefined): ArtifactVersion[];
|
|
256
277
|
interface SaveArtifactVersionInput {
|
|
257
278
|
/** File name of the new version (`.md` is added when missing). */
|
|
258
279
|
title: string;
|
|
259
280
|
content: string;
|
|
260
|
-
/** Save as the next version of this document (
|
|
281
|
+
/** Save as the next version of this document (it keeps its id); omit for a new document. */
|
|
261
282
|
versionOf?: string | null;
|
|
262
283
|
/** The processing config (auto-title, parsing) to run the upload with. */
|
|
263
284
|
configId?: string | null;
|
|
@@ -265,9 +286,8 @@ interface SaveArtifactVersionInput {
|
|
|
265
286
|
wpType?: 'artifact' | 'source';
|
|
266
287
|
}
|
|
267
288
|
/**
|
|
268
|
-
* Save markdown as a NEW immutable version (the next version of `versionOf`'s document
|
|
269
|
-
* the workspace document list
|
|
270
|
-
* known yet (the document is parsed asynchronously); it then arrives through the list.
|
|
289
|
+
* Save markdown as a NEW immutable version (the next version of `versionOf`'s document, which keeps
|
|
290
|
+
* its id) and refresh the workspace document list, version lists and the document's text.
|
|
271
291
|
*/
|
|
272
292
|
declare function useSaveArtifactVersion(): _tanstack_react_query.UseMutationResult<ArtifactSaveResult, Error, SaveArtifactVersionInput & {
|
|
273
293
|
workspaceId?: string;
|
|
@@ -275,8 +295,9 @@ declare function useSaveArtifactVersion(): _tanstack_react_query.UseMutationResu
|
|
|
275
295
|
interface ArtifactSessionOptions extends Pick<ArtifactEditSessionOptions, 'onSaved' | 'onSaveError' | 'onCompareChange' | 'compareId' | 'compareOpensEditor' | 'redlineEngine' | 'onDirtyChange'> {
|
|
276
296
|
workspaceId: string | undefined;
|
|
277
297
|
/**
|
|
278
|
-
* The open
|
|
279
|
-
* backend document id, i.e. does not start
|
|
298
|
+
* The open document (its current version), a version reference `doc-…@v{n}`, or the placeholder
|
|
299
|
+
* id of an unsaved local draft (anything that is not a backend document id, i.e. does not start
|
|
300
|
+
* with `doc`).
|
|
280
301
|
*/
|
|
281
302
|
docId: string | null | undefined;
|
|
282
303
|
/**
|
|
@@ -324,7 +345,7 @@ interface ArtifactSession extends ArtifactEditSession {
|
|
|
324
345
|
/** See `ArtifactTextStatus`. */
|
|
325
346
|
status: ArtifactTextStatus;
|
|
326
347
|
versions: ArtifactVersion[];
|
|
327
|
-
/** "v2" for any version
|
|
348
|
+
/** "v2" for any version (reference) of the document. */
|
|
328
349
|
labelOf: (id: string | null | undefined) => string | null;
|
|
329
350
|
/** Props for `<ArtifactEditor>`. */
|
|
330
351
|
view: ArtifactSessionView;
|
|
@@ -426,4 +447,4 @@ interface StreamedArtifact {
|
|
|
426
447
|
*/
|
|
427
448
|
declare function useStreamedArtifact({ artifacts, workspaceId, settled, clean, onCleaned, configId, parseRetry, }: UseStreamedArtifactOptions): StreamedArtifact;
|
|
428
449
|
|
|
429
|
-
export { type ArtifactEditSession, type ArtifactEditSessionOptions, type ArtifactRedlineComponents, type ArtifactSaveResult, type ArtifactSession, type ArtifactSessionOptions, type ArtifactSessionView, type ArtifactText, type ArtifactTextRetry, type ArtifactTextStatus, type ArtifactVersion, DEFAULT_ARTIFACT_TEXT_RETRY, DraftCleanReport, type RedlineEngine, RedlineRegion, type RedlineState, RedlineWithRegions, type SaveArtifactVersionInput, type StreamedArtifact, type StreamedArtifactPhase, type UseRedlineOptions, type UseRedlineResult, type UseStreamedArtifactOptions, type VersionedDoc,
|
|
450
|
+
export { type ArtifactEditSession, type ArtifactEditSessionOptions, type ArtifactRedlineComponents, type ArtifactSaveResult, type ArtifactSession, type ArtifactSessionOptions, type ArtifactSessionView, type ArtifactText, type ArtifactTextRetry, type ArtifactTextStatus, type ArtifactVersion, DEFAULT_ARTIFACT_TEXT_RETRY, type DocVersionEntry, DraftCleanReport, type RedlineEngine, RedlineRegion, type RedlineState, RedlineWithRegions, type SaveArtifactVersionInput, type StreamedArtifact, type StreamedArtifactPhase, type UseRedlineOptions, type UseRedlineResult, type UseStreamedArtifactOptions, type VersionedDoc, documentVersions, findVersion, flattenChunks, isDocumentId, mainThreadRedlineEngine, parseVersionRef, renderArtifactMarkdown, savedFromId, toArtifactVersions, useArtifactEditSession, useArtifactSession, useArtifactText, useArtifactVersions, useRedline, useSaveArtifactVersion, useStreamedArtifact, versionLabel, versionRef };
|
|
@@ -57,51 +57,71 @@ interface UseRedlineResult {
|
|
|
57
57
|
declare function useRedline({ baseText, compareText, isLoading, withRegions, engine, }: UseRedlineOptions): UseRedlineResult;
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* Versions of a document.
|
|
61
|
-
* (`
|
|
62
|
-
*
|
|
63
|
-
*
|
|
60
|
+
* Versions of a document. A document keeps ONE id for its whole life; its versions live inside it
|
|
61
|
+
* (`current_version` + `versions`, numbered 1..n). A version is named by a version reference
|
|
62
|
+
* `doc-…@v{n}`; a plain document id means its current version. The workspace list carries every
|
|
63
|
+
* document's `versions`, and `GET /v1/document/{id}/versions` (`arbi.documents.versions`) the same
|
|
64
|
+
* list on its own.
|
|
64
65
|
*/
|
|
66
|
+
/** One version entry as the API returns it (a subset of `DocVersion`). */
|
|
67
|
+
interface DocVersionEntry {
|
|
68
|
+
n: number;
|
|
69
|
+
file_name?: string | null;
|
|
70
|
+
created_at?: string | null;
|
|
71
|
+
reason?: string | null;
|
|
72
|
+
/** The version an edit started from, when it was not the previous one. */
|
|
73
|
+
made_from?: number | null;
|
|
74
|
+
is_current?: boolean | null;
|
|
75
|
+
}
|
|
65
76
|
/** The fields of a workspace document the version list needs (a subset of the API type). */
|
|
66
77
|
interface VersionedDoc {
|
|
67
78
|
external_id?: string | null;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
is_current?: boolean | null;
|
|
71
|
-
/** Provenance: an `edit`/`sync` entry names the version this one was saved from. */
|
|
72
|
-
derived_from?: readonly {
|
|
73
|
-
doc_ext_id: string;
|
|
74
|
-
role: string;
|
|
75
|
-
}[] | null;
|
|
79
|
+
current_version?: number | null;
|
|
80
|
+
versions?: readonly DocVersionEntry[] | null;
|
|
76
81
|
file_name?: string | null;
|
|
77
82
|
created_at?: string | null;
|
|
78
83
|
}
|
|
79
84
|
/** One row of a version list. Matches `VersionEntry` of `@arbidocs/blocks/artifacts`. */
|
|
80
85
|
interface ArtifactVersion {
|
|
86
|
+
/** The version reference `doc-…@v{n}`: what opening or comparing this version names. */
|
|
81
87
|
id: string;
|
|
88
|
+
/** The document (the same for every version). */
|
|
89
|
+
docId: string;
|
|
82
90
|
/** File name as stored. */
|
|
83
91
|
name: string;
|
|
84
92
|
/** ISO timestamp. */
|
|
85
93
|
createdAt: string;
|
|
86
94
|
/** 1-based version number within the document. */
|
|
87
95
|
number: number;
|
|
96
|
+
/** upload | edit | signed | sync */
|
|
97
|
+
reason: string;
|
|
98
|
+
isCurrent: boolean;
|
|
88
99
|
/** The version this one was saved from (an older one than the previous version when restored). */
|
|
89
100
|
savedFromId?: string | null;
|
|
90
101
|
}
|
|
91
|
-
/**
|
|
92
|
-
declare function
|
|
102
|
+
/** `doc-…@v{n}`: a reference to version `n` of a document. */
|
|
103
|
+
declare function versionRef(docId: string, version: number): string;
|
|
93
104
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
105
|
+
* Split a reference into the document and the version it names. A plain document id (or anything
|
|
106
|
+
* else) names no version: the document's current one.
|
|
96
107
|
*/
|
|
97
|
-
declare function
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
declare function parseVersionRef(ref: string | null | undefined): {
|
|
109
|
+
docId: string;
|
|
110
|
+
version: number | null;
|
|
111
|
+
};
|
|
112
|
+
/** The version a version was saved from: `made_from`, else the one before it. */
|
|
113
|
+
declare function savedFromId(docId: string, entry: DocVersionEntry): string | null;
|
|
114
|
+
/** A document's version entries (oldest first) as plain version rows. */
|
|
115
|
+
declare function toArtifactVersions(docId: string | null | undefined, entries: readonly DocVersionEntry[] | null | undefined, currentVersion?: number | null): ArtifactVersion[];
|
|
116
|
+
/** The versions of a listed document, oldest first (`[]` when the document is not given). */
|
|
117
|
+
declare function documentVersions(doc: VersionedDoc | null | undefined): ArtifactVersion[];
|
|
118
|
+
/** The row `ref` names: an exact version, or (a plain document id) the current version. */
|
|
119
|
+
declare function findVersion(versions: readonly ArtifactVersion[], ref: string | null | undefined): ArtifactVersion | undefined;
|
|
100
120
|
/**
|
|
101
|
-
* "v2": the version number
|
|
121
|
+
* "v2": the version number `ref` names. `null` when there is nothing to tell apart (the document
|
|
102
122
|
* has a single version, or it is unknown), so unversioned documents stay unlabelled.
|
|
103
123
|
*/
|
|
104
|
-
declare function versionLabel(versions: readonly ArtifactVersion[],
|
|
124
|
+
declare function versionLabel(versions: readonly ArtifactVersion[], ref: string | null | undefined): string | null;
|
|
105
125
|
/**
|
|
106
126
|
* Join parsed chunks into one markdown text (blank line between chunks).
|
|
107
127
|
*
|
|
@@ -249,15 +269,16 @@ declare function useArtifactText(docId: string | null | undefined, options?: {
|
|
|
249
269
|
}): ArtifactText;
|
|
250
270
|
|
|
251
271
|
/**
|
|
252
|
-
* The versions of an artifact, oldest first.
|
|
253
|
-
*
|
|
272
|
+
* The versions of an artifact, oldest first. `docId` is a document id or a version reference
|
|
273
|
+
* (`doc-…@v2`). Every listed document carries its versions; a document that is not in the
|
|
274
|
+
* workspace list asks for its version list.
|
|
254
275
|
*/
|
|
255
276
|
declare function useArtifactVersions(workspaceId: string | undefined, docId: string | null | undefined): ArtifactVersion[];
|
|
256
277
|
interface SaveArtifactVersionInput {
|
|
257
278
|
/** File name of the new version (`.md` is added when missing). */
|
|
258
279
|
title: string;
|
|
259
280
|
content: string;
|
|
260
|
-
/** Save as the next version of this document (
|
|
281
|
+
/** Save as the next version of this document (it keeps its id); omit for a new document. */
|
|
261
282
|
versionOf?: string | null;
|
|
262
283
|
/** The processing config (auto-title, parsing) to run the upload with. */
|
|
263
284
|
configId?: string | null;
|
|
@@ -265,9 +286,8 @@ interface SaveArtifactVersionInput {
|
|
|
265
286
|
wpType?: 'artifact' | 'source';
|
|
266
287
|
}
|
|
267
288
|
/**
|
|
268
|
-
* Save markdown as a NEW immutable version (the next version of `versionOf`'s document
|
|
269
|
-
* the workspace document list
|
|
270
|
-
* known yet (the document is parsed asynchronously); it then arrives through the list.
|
|
289
|
+
* Save markdown as a NEW immutable version (the next version of `versionOf`'s document, which keeps
|
|
290
|
+
* its id) and refresh the workspace document list, version lists and the document's text.
|
|
271
291
|
*/
|
|
272
292
|
declare function useSaveArtifactVersion(): _tanstack_react_query.UseMutationResult<ArtifactSaveResult, Error, SaveArtifactVersionInput & {
|
|
273
293
|
workspaceId?: string;
|
|
@@ -275,8 +295,9 @@ declare function useSaveArtifactVersion(): _tanstack_react_query.UseMutationResu
|
|
|
275
295
|
interface ArtifactSessionOptions extends Pick<ArtifactEditSessionOptions, 'onSaved' | 'onSaveError' | 'onCompareChange' | 'compareId' | 'compareOpensEditor' | 'redlineEngine' | 'onDirtyChange'> {
|
|
276
296
|
workspaceId: string | undefined;
|
|
277
297
|
/**
|
|
278
|
-
* The open
|
|
279
|
-
* backend document id, i.e. does not start
|
|
298
|
+
* The open document (its current version), a version reference `doc-…@v{n}`, or the placeholder
|
|
299
|
+
* id of an unsaved local draft (anything that is not a backend document id, i.e. does not start
|
|
300
|
+
* with `doc`).
|
|
280
301
|
*/
|
|
281
302
|
docId: string | null | undefined;
|
|
282
303
|
/**
|
|
@@ -324,7 +345,7 @@ interface ArtifactSession extends ArtifactEditSession {
|
|
|
324
345
|
/** See `ArtifactTextStatus`. */
|
|
325
346
|
status: ArtifactTextStatus;
|
|
326
347
|
versions: ArtifactVersion[];
|
|
327
|
-
/** "v2" for any version
|
|
348
|
+
/** "v2" for any version (reference) of the document. */
|
|
328
349
|
labelOf: (id: string | null | undefined) => string | null;
|
|
329
350
|
/** Props for `<ArtifactEditor>`. */
|
|
330
351
|
view: ArtifactSessionView;
|
|
@@ -426,4 +447,4 @@ interface StreamedArtifact {
|
|
|
426
447
|
*/
|
|
427
448
|
declare function useStreamedArtifact({ artifacts, workspaceId, settled, clean, onCleaned, configId, parseRetry, }: UseStreamedArtifactOptions): StreamedArtifact;
|
|
428
449
|
|
|
429
|
-
export { type ArtifactEditSession, type ArtifactEditSessionOptions, type ArtifactRedlineComponents, type ArtifactSaveResult, type ArtifactSession, type ArtifactSessionOptions, type ArtifactSessionView, type ArtifactText, type ArtifactTextRetry, type ArtifactTextStatus, type ArtifactVersion, DEFAULT_ARTIFACT_TEXT_RETRY, DraftCleanReport, type RedlineEngine, RedlineRegion, type RedlineState, RedlineWithRegions, type SaveArtifactVersionInput, type StreamedArtifact, type StreamedArtifactPhase, type UseRedlineOptions, type UseRedlineResult, type UseStreamedArtifactOptions, type VersionedDoc,
|
|
450
|
+
export { type ArtifactEditSession, type ArtifactEditSessionOptions, type ArtifactRedlineComponents, type ArtifactSaveResult, type ArtifactSession, type ArtifactSessionOptions, type ArtifactSessionView, type ArtifactText, type ArtifactTextRetry, type ArtifactTextStatus, type ArtifactVersion, DEFAULT_ARTIFACT_TEXT_RETRY, type DocVersionEntry, DraftCleanReport, type RedlineEngine, RedlineRegion, type RedlineState, RedlineWithRegions, type SaveArtifactVersionInput, type StreamedArtifact, type StreamedArtifactPhase, type UseRedlineOptions, type UseRedlineResult, type UseStreamedArtifactOptions, type VersionedDoc, documentVersions, findVersion, flattenChunks, isDocumentId, mainThreadRedlineEngine, parseVersionRef, renderArtifactMarkdown, savedFromId, toArtifactVersions, useArtifactEditSession, useArtifactSession, useArtifactText, useArtifactVersions, useRedline, useSaveArtifactVersion, useStreamedArtifact, versionLabel, versionRef };
|
package/dist/artifacts/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { repairParsedStructure, repairParsedTitle, unescapeMarkdown, arbiQueryKeys, useDocuments, useDocumentVersionList, cleanDraftWithReport } from '../chunk-
|
|
2
|
-
export { cleanDraftMarkdown, cleanDraftWithReport, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks } from '../chunk-
|
|
1
|
+
import { repairParsedStructure, repairParsedTitle, unescapeMarkdown, arbiQueryKeys, useDocuments, useDocumentVersionList, cleanDraftWithReport } from '../chunk-SX7FCSON.js';
|
|
2
|
+
export { cleanDraftMarkdown, cleanDraftWithReport, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks } from '../chunk-SX7FCSON.js';
|
|
3
3
|
import { revertRedlineRegion, buildHybridRedlineWithRegions, buildHybridRedlineMarkdown, normalizeMarkdown } from '../chunk-43AKLNBC.js';
|
|
4
4
|
export { buildHybridRedlineMarkdown, buildHybridRedlineWithRegions, normalizeMarkdown, revertRedlineRegion } from '../chunk-43AKLNBC.js';
|
|
5
5
|
import { MarkdownRenderer } from '../chunk-JPGV7NMY.js';
|
|
@@ -81,32 +81,46 @@ function useRedline({
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// src/artifacts/versions.ts
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
var VERSION_REF = /^(doc-[A-Za-z0-9]+)@v([1-9][0-9]*)$/;
|
|
85
|
+
function versionRef(docId, version) {
|
|
86
|
+
return `${docId}@v${version}`;
|
|
86
87
|
}
|
|
87
|
-
function
|
|
88
|
+
function parseVersionRef(ref) {
|
|
89
|
+
const match = VERSION_REF.exec(ref ?? "");
|
|
90
|
+
if (!match) return { docId: ref ?? "", version: null };
|
|
91
|
+
return { docId: match[1], version: Number(match[2]) };
|
|
92
|
+
}
|
|
93
|
+
function savedFromId(docId, entry) {
|
|
94
|
+
if (entry.made_from) return versionRef(docId, entry.made_from);
|
|
95
|
+
return entry.n > 1 ? versionRef(docId, entry.n - 1) : null;
|
|
96
|
+
}
|
|
97
|
+
function toArtifactVersions(docId, entries, currentVersion) {
|
|
88
98
|
if (!docId) return [];
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
const current = currentVersion ?? entries?.find((e) => e.is_current)?.n ?? null;
|
|
100
|
+
return [...entries ?? []].sort((a, b) => a.n - b.n).map((e) => ({
|
|
101
|
+
id: versionRef(docId, e.n),
|
|
102
|
+
docId,
|
|
103
|
+
name: e.file_name ?? "",
|
|
104
|
+
createdAt: e.created_at ?? "",
|
|
105
|
+
number: e.n,
|
|
106
|
+
reason: e.reason ?? "upload",
|
|
107
|
+
isCurrent: current != null ? e.n === current : !!e.is_current,
|
|
108
|
+
savedFromId: savedFromId(docId, e)
|
|
109
|
+
}));
|
|
93
110
|
}
|
|
94
|
-
function
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
id: d.external_id,
|
|
99
|
-
name: d.file_name ?? "",
|
|
100
|
-
createdAt: d.created_at ?? "",
|
|
101
|
-
number: d.version_number ?? i + 1,
|
|
102
|
-
savedFromId: savedFromId(d)
|
|
103
|
-
}
|
|
104
|
-
] : []
|
|
105
|
-
);
|
|
111
|
+
function documentVersions(doc) {
|
|
112
|
+
if (!doc?.external_id) return [];
|
|
113
|
+
const entries = doc.versions?.length ? doc.versions : [{ n: doc.current_version ?? 1, file_name: doc.file_name, created_at: doc.created_at }];
|
|
114
|
+
return toArtifactVersions(doc.external_id, entries, doc.current_version ?? null);
|
|
106
115
|
}
|
|
107
|
-
function
|
|
108
|
-
if (!
|
|
109
|
-
const version =
|
|
116
|
+
function findVersion(versions, ref) {
|
|
117
|
+
if (!ref) return void 0;
|
|
118
|
+
const { docId, version } = parseVersionRef(ref);
|
|
119
|
+
return version == null ? versions.find((v) => v.docId === docId && v.isCurrent) : versions.find((v) => v.docId === docId && v.number === version);
|
|
120
|
+
}
|
|
121
|
+
function versionLabel(versions, ref) {
|
|
122
|
+
if (!ref || versions.length <= 1) return null;
|
|
123
|
+
const version = findVersion(versions, ref);
|
|
110
124
|
return version ? `v${version.number}` : null;
|
|
111
125
|
}
|
|
112
126
|
function flattenChunks(chunks, options) {
|
|
@@ -323,7 +337,12 @@ function useArtifactText(docId, options) {
|
|
|
323
337
|
// Under the shared `parsedDoc` key, so a document's invalidation reaches it too.
|
|
324
338
|
queryKey: [...arbiQueryKeys.parsedDoc(docId ?? "", "marker"), "artifact-text"],
|
|
325
339
|
queryFn: async () => {
|
|
326
|
-
const
|
|
340
|
+
const { docId: plainId, version } = parseVersionRef(docId);
|
|
341
|
+
const parsed = await arbi.documents.getParsedContent(
|
|
342
|
+
plainId,
|
|
343
|
+
"marker",
|
|
344
|
+
version ?? void 0
|
|
345
|
+
);
|
|
327
346
|
if (!parsed.chunks?.some((c) => c.content?.trim())) throw new NotParsedYetError();
|
|
328
347
|
return flattenChunks(parsed.chunks, { unescape: true });
|
|
329
348
|
},
|
|
@@ -363,13 +382,18 @@ function useArtifactText(docId, options) {
|
|
|
363
382
|
|
|
364
383
|
// src/artifacts/useArtifactSession.ts
|
|
365
384
|
function useArtifactVersions(workspaceId, docId) {
|
|
385
|
+
const plainId = docId ? parseVersionRef(docId).docId : null;
|
|
366
386
|
const { data: documents } = useDocuments(workspaceId);
|
|
367
|
-
const listed = useMemo(
|
|
368
|
-
|
|
369
|
-
|
|
387
|
+
const listed = useMemo(
|
|
388
|
+
() => (documents ?? []).find((d) => d.external_id === plainId),
|
|
389
|
+
[documents, plainId]
|
|
390
|
+
);
|
|
391
|
+
const { data: history } = useDocumentVersionList(plainId, {
|
|
392
|
+
enabled: !!plainId && documents !== void 0 && !listed
|
|
393
|
+
});
|
|
370
394
|
return useMemo(
|
|
371
|
-
() =>
|
|
372
|
-
[
|
|
395
|
+
() => listed ? documentVersions(listed) : toArtifactVersions(plainId, history),
|
|
396
|
+
[listed, history, plainId]
|
|
373
397
|
);
|
|
374
398
|
}
|
|
375
399
|
function useSaveArtifactVersion() {
|
|
@@ -383,15 +407,17 @@ function useSaveArtifactVersion() {
|
|
|
383
407
|
fileName,
|
|
384
408
|
{
|
|
385
409
|
wpType: wpType ?? "artifact",
|
|
386
|
-
versionOf: versionOf
|
|
410
|
+
versionOf: versionOf ? parseVersionRef(versionOf).docId : void 0,
|
|
387
411
|
configExtId: configId ?? void 0
|
|
388
412
|
}
|
|
389
413
|
);
|
|
414
|
+
const docId = result.doc_ext_ids?.[0];
|
|
390
415
|
if (workspaceId) {
|
|
391
416
|
await queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documents(workspaceId) });
|
|
392
417
|
}
|
|
393
418
|
await queryClient.invalidateQueries({ queryKey: arbiQueryKeys.allDocumentVersions() });
|
|
394
|
-
|
|
419
|
+
if (docId) await queryClient.invalidateQueries({ queryKey: ["arbi", "parsedDoc", docId] });
|
|
420
|
+
return { docId, version: result.version ?? void 0 };
|
|
395
421
|
}
|
|
396
422
|
});
|
|
397
423
|
}
|
|
@@ -426,7 +452,7 @@ function useArtifactSession(options) {
|
|
|
426
452
|
enabled: !!activeCompareId
|
|
427
453
|
});
|
|
428
454
|
const saveVersion = useSaveArtifactVersion();
|
|
429
|
-
const current = versions
|
|
455
|
+
const current = findVersion(versions, docId);
|
|
430
456
|
const save = useCallback(
|
|
431
457
|
async (content) => {
|
|
432
458
|
const result = await saveVersion.mutateAsync({
|
|
@@ -437,9 +463,9 @@ function useArtifactSession(options) {
|
|
|
437
463
|
workspaceId
|
|
438
464
|
});
|
|
439
465
|
const latest = versions.reduce((n, v) => Math.max(n, v.number), 0);
|
|
440
|
-
return { ...result, version: isLocal ? 1 : latest + 1 };
|
|
466
|
+
return { ...result, version: result.version ?? (isLocal ? 1 : latest + 1) };
|
|
441
467
|
},
|
|
442
|
-
[saveVersion, title, current?.name, isLocal, docId, configId, workspaceId, versions
|
|
468
|
+
[saveVersion, title, current?.name, isLocal, docId, configId, workspaceId, versions]
|
|
443
469
|
);
|
|
444
470
|
const handleSaved = useCallback(
|
|
445
471
|
(result, content) => {
|
|
@@ -483,7 +509,7 @@ function useArtifactSession(options) {
|
|
|
483
509
|
compareId: session.compareId,
|
|
484
510
|
showTrackChanges: session.showTrackChanges,
|
|
485
511
|
versions,
|
|
486
|
-
currentVersionId: docId ?? "",
|
|
512
|
+
currentVersionId: current?.id ?? docId ?? "",
|
|
487
513
|
onStartEdit: session.startEdit,
|
|
488
514
|
onCancel: session.cancel,
|
|
489
515
|
onSave: () => void session.save(),
|
|
@@ -577,6 +603,6 @@ function useStreamedArtifact({
|
|
|
577
603
|
return { phase, artifact, docId, error, cleaned, retry };
|
|
578
604
|
}
|
|
579
605
|
|
|
580
|
-
export { DEFAULT_ARTIFACT_TEXT_RETRY,
|
|
606
|
+
export { DEFAULT_ARTIFACT_TEXT_RETRY, documentVersions, findVersion, flattenChunks, isDocumentId, mainThreadRedlineEngine, parseVersionRef, renderArtifactMarkdown, savedFromId, toArtifactVersions, useArtifactEditSession, useArtifactSession, useArtifactText, useArtifactVersions, useRedline, useSaveArtifactVersion, useStreamedArtifact, versionLabel, versionRef };
|
|
581
607
|
//# sourceMappingURL=index.js.map
|
|
582
608
|
//# sourceMappingURL=index.js.map
|