@webx-ui/module-admin 0.18.2 → 0.20.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.
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Who changed a record, when, through which door, and what exactly (WEBX_UI_HISTORY.md §5).
3
+ *
4
+ * The frame's and not a section's, like the notes: the catalogue wants it first, and a copy per
5
+ * module is a copy of the rule about who may read it. On a screen it is the `wx-history` node —
6
+ * a tab of a form is one line of the description or one patch of a project — and the id comes
7
+ * from the editor hosting the screen (`provideHistorySubject`), since the same JSON describes
8
+ * every record.
9
+ *
10
+ * A row made inside an import or a bulk action links to the run: the run is where the journal
11
+ * says what was done to all of them at once, and the row only says what this record got.
12
+ */
13
+ type __VLS_Props = {
14
+ /** The type the module registered: `catalog.product`. */
15
+ type: string;
16
+ /** The record; the hosting editor's when omitted. */
17
+ id?: number | string | null;
18
+ /** Heading above the feed; the panel's own word by default, none with `''`. */
19
+ title?: string;
20
+ };
21
+ declare function load(): Promise<void>;
22
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {
23
+ reload: typeof load;
24
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
25
+ id: number | string | null;
26
+ title: string;
27
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLElement>;
28
+ export default _default;
@@ -0,0 +1,90 @@
1
+ import { InjectionKey, Ref } from 'vue';
2
+ import { AdminContext } from './admin';
3
+ /** What happened to a record. `run` is the parent row of an import or a bulk action. */
4
+ export type HistoryEvent = 'created' | 'updated' | 'deleted' | 'restored' | 'published' | 'unpublished' | 'run';
5
+ /** Which door the change came through. */
6
+ export type HistorySource = 'panel' | 'mcp' | 'import' | 'bulk' | 'api' | 'console';
7
+ /**
8
+ * One field of one save. A long value (rich text, a repeater) comes without `from` and `to`:
9
+ * the journal keeps that it changed and how long it was, and the versions keep the text.
10
+ */
11
+ export interface HistoryChange {
12
+ /** `price`, or `name.ru` for one language of a translated field. */
13
+ field: string;
14
+ /** The module's word for it, in the reader's language. */
15
+ label: string;
16
+ from: unknown;
17
+ to: unknown;
18
+ long?: boolean;
19
+ from_length?: number;
20
+ to_length?: number;
21
+ }
22
+ export interface HistoryEntry {
23
+ id: number;
24
+ event: HistoryEvent;
25
+ source: HistorySource;
26
+ subject: {
27
+ type: string;
28
+ id: number | null;
29
+ };
30
+ /** The name as it was signed; `null` when nobody was signed in (a console command). */
31
+ admin: {
32
+ id: number | null;
33
+ name: string | null;
34
+ } | null;
35
+ /** The agent's connection, when the source is `mcp`. */
36
+ grant_id: number | null;
37
+ changes: HistoryChange[];
38
+ /** The run this save was made in, with what the run was when the server had it at hand. */
39
+ run: {
40
+ id: number;
41
+ summary: Record<string, unknown> | null;
42
+ } | null;
43
+ created_at: string | null;
44
+ /** A run's own: what was done, with which profile, how many rows. */
45
+ summary?: Record<string, unknown>;
46
+ rows?: number;
47
+ }
48
+ /** A page as `->paginate()` has it. */
49
+ export interface HistoryPage {
50
+ data: HistoryEntry[];
51
+ current_page: number;
52
+ last_page: number;
53
+ total: number;
54
+ }
55
+ export interface HistoryRun {
56
+ run: HistoryEntry;
57
+ rows: HistoryPage;
58
+ }
59
+ export interface HistoryApi {
60
+ list(page?: number): Promise<HistoryPage>;
61
+ /** A run and its rows, or only the rows about one record. */
62
+ run(id: number, page?: number, search?: number | null): Promise<HistoryRun>;
63
+ }
64
+ /**
65
+ * The journal of one record.
66
+ *
67
+ * `type` is what the module registered (`catalog.product`) — never a class name — and the
68
+ * address is the panel's own, like the notes': one feed for every section, and the server says
69
+ * which permission each type is behind.
70
+ */
71
+ export declare function createHistoryApi(admin: AdminContext, type: string, id: number | string): HistoryApi;
72
+ /**
73
+ * The id of the record an editor is showing, for a `wx-history` node on its screen.
74
+ *
75
+ * A described screen is the same JSON for every record, so the id cannot be written into it:
76
+ * the page that hosts the screen knows it, and provides it here — the way it provides the
77
+ * address to `wx-slug`. `null` is a record not saved yet, which has no history.
78
+ */
79
+ export interface HistorySubject {
80
+ id: Ref<number | string | null | undefined>;
81
+ }
82
+ export declare const historySubjectKey: InjectionKey<HistorySubject>;
83
+ export declare function provideHistorySubject(subject: HistorySubject): void;
84
+ /** The editor above the node, or `null` outside one. */
85
+ export declare function useHistorySubject(): HistorySubject | null;
86
+ /**
87
+ * A value as a line of text. Words for "nothing" are the caller's; a list or an object is shown
88
+ * as JSON, cut, because a repeater row printed whole is a paragraph in a feed of one-liners.
89
+ */
90
+ export declare function historyValue(value: unknown, empty: string, max?: number): string;
package/dist/http.d.ts CHANGED
@@ -44,14 +44,26 @@ export declare class HttpError extends Error {
44
44
  get isUnauthenticated(): boolean;
45
45
  get isThrottled(): boolean;
46
46
  }
47
+ export interface SendOptions extends RequestOptions {
48
+ /** Sent as it is — bytes, a `Blob`, a string — with no `Content-Type` added for it. */
49
+ body?: BodyInit | null;
50
+ }
47
51
  export interface Http {
48
52
  get<T>(path: string, options?: RequestOptions): Promise<T>;
49
53
  post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
50
54
  put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
51
55
  patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
52
56
  delete<T>(path: string, options?: RequestOptions): Promise<T>;
57
+ /**
58
+ * A request with the panel's conventions (the CSRF cookie, the standing headers, 419 and 401)
59
+ * and nothing else: the body goes as it is and the response comes back whatever its status.
60
+ * For what JSON does not fit — the pieces of a chunked upload, a `HEAD` asked for a header.
61
+ * Optional so that a hand-made client in a test or a project does not have to grow one.
62
+ */
63
+ send?(method: string, path: string, options?: SendOptions): Promise<Response>;
53
64
  }
54
65
  export declare function createHttp(options?: HttpOptions): Http;
66
+ export declare function toError(response: Response): Promise<HttpError>;
55
67
  /**
56
68
  * Laravel writes the token URL-encoded, and it is read back the same way it was written.
57
69
  */
package/dist/index.d.ts CHANGED
@@ -8,8 +8,10 @@ export { createDates, useDates, type DateLike, type Dates } from './dates';
8
8
  export { errorText, useErrorText } from './errors';
9
9
  export { useBodyKeys } from './keys';
10
10
  export { createNotesApi, type EntityNote, type NoteAuthor, type NotesApi } from './notes';
11
+ export { createHistoryApi, historySubjectKey, historyValue, provideHistorySubject, useHistorySubject, type HistoryApi, type HistoryChange, type HistoryEntry, type HistoryEvent, type HistoryPage, type HistoryRun, type HistorySource, type HistorySubject, } from './history';
11
12
  export { createLinksApi, emptyLink, type LinkCandidate, type LinkRel, type LinkSourceInfo, type LinkTarget, type LinkValue, type LinksApi, type ResolvedLink, } from './links';
12
- export { createHttp, readCookie, HttpError, type Http, type HttpOptions, type RequestOptions, } from './http';
13
+ export { createHttp, readCookie, HttpError, type Http, type HttpOptions, type RequestOptions, type SendOptions, } from './http';
14
+ export { forgetUnfinishedUpload, MIN_CHUNK, unfinishedUploads, uploadFingerprint, useChunkedUpload, type ChunkedUpload, type ChunkedUploadOptions, type ChunkedUploadState, type UnfinishedUpload, } from './uploads';
13
15
  export { adminTypes } from './screenTypes';
14
16
  export { categoryRoutes, createCategoriesApi, itemOrderMode, reorderItems, useCategoryEditor, useCategoryWords, useItemOrder, type CategoriesApi, type CategoriesOptions, type CategoriesPayload, type CategoryDetail, type CategoryEditorContext, type CategoryRow, type CategoryWord, type ItemOrder, type ItemOrderMode, type ItemOrderState, } from './categories';
15
17
  export { COLLECTION_MAX_LIMIT, collectionSources, defaultMarkup, normaliseCollection, type CollectionRelated, type CollectionRelationTarget, type CollectionSourceInfo, type CollectionValue, } from './collections/api';
@@ -30,6 +32,7 @@ export { default as WxRenameButton } from './RenameButton';
30
32
  export { default as WxHelpButton } from './HelpButton';
31
33
  export { default as WxDate } from './DateText';
32
34
  export { default as WxNotes } from './NotesFeed';
35
+ export { default as WxHistory } from './HistoryFeed';
33
36
  export { default as WxBackupNote } from './BackupNote';
34
37
  export { default as WxRichTextField } from './RichTextField';
35
38
  export { default as WxLinkPicker } from './LinkPicker';