@ovok/core 0.4.59-dev.565 → 0.4.59-dev.567

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.
@@ -53,6 +53,29 @@ export type OvokCmsPage<T = OvokCmsDocument> = {
53
53
  /** `null` on the last page. */
54
54
  nextPage: number | null;
55
55
  };
56
+ /**
57
+ * A published item of a content type defined in the Console. `data` holds its fields, keyed by each field's `key`.
58
+ *
59
+ * @category cms
60
+ */
61
+ export type OvokCmsContentItem<T extends object = Record<string, unknown>> = {
62
+ /** Item id. */
63
+ id: number | string;
64
+ /** The content type: its id, or the type itself when the CMS fills it in. */
65
+ contentType: unknown;
66
+ /** Display title. */
67
+ title: string;
68
+ /** URL slug, unique within the content type; `null` when it has none. */
69
+ slug?: string | null;
70
+ /** Always `published` from the delivery API. */
71
+ status: string;
72
+ /** The field values, as written. */
73
+ data: T;
74
+ /** ISO 8601 creation time. */
75
+ createdAt?: string;
76
+ /** ISO 8601 time of the last change. */
77
+ updatedAt?: string;
78
+ };
56
79
  /**
57
80
  * Options shared by every CMS read.
58
81
  *
@@ -104,6 +104,12 @@ exports.OVOK_CORE_API_REQUIREMENTS = {
104
104
  { method: "GET", path: "/cms/:type/:language", group: "Content" },
105
105
  { method: "GET", path: "/v1/public/cms/collections/:collection/items", group: "Cms" },
106
106
  { method: "GET", path: "/v1/public/cms/collections/:collection/items/:slug", group: "Cms" },
107
+ { method: "GET", path: "/v1/public/cms/:contentTypeSlug/items", group: "Cms" },
108
+ { method: "GET", path: "/v1/content/:collection", group: "Cms" },
109
+ { method: "POST", path: "/v1/content/:collection", group: "Cms" },
110
+ { method: "GET", path: "/v1/content/:collection/:id", group: "Cms" },
111
+ { method: "PATCH", path: "/v1/content/:collection/:id", group: "Cms" },
112
+ { method: "DELETE", path: "/v1/content/:collection/:id", group: "Cms" },
107
113
  { method: "GET", path: "/video-call/livekit/access-permission/:appointmentId", group: "Video" },
108
114
  { method: "POST", path: "/video-call/livekit/guest-access/:appointmentId", group: "Video" },
109
115
  { method: "POST", path: "/video-call/livekit/user-access/:appointmentId", group: "Video" },
@@ -26,7 +26,7 @@ exports.OVOK_CORE_REQUIREMENTS = {
26
26
  description: "The FHIR surface a server must provide for the @ovok/core client library's own methods to function.",
27
27
  software: {
28
28
  name: "@ovok/core",
29
- version: "0.4.59-dev.565+16c360c",
29
+ version: "0.4.59-dev.567+06fe40c",
30
30
  },
31
31
  fhirVersion: "4.0.1",
32
32
  format: ["json"],
@@ -46,12 +46,13 @@ export type { AiFhirSearchRequest } from "./resources/ai/ai-resource";
46
46
  export type { ChatSessionRetrieveParams } from "./resources/ai/chat-sessions-resource";
47
47
  export type { VideoCallAccessPermission } from "./resources/video-calls/video-call-access-resource";
48
48
  export type { ActiveCallNotification } from "./resources/video-calls/video-calls-resource";
49
+ export type { CmsAuthoringListParams, CmsWhere } from "./resources/cms/cms-authoring-resource";
49
50
  export type { CmsListParams, CmsReadParams } from "./resources/cms/cms-delivery";
50
51
  export type { DeletedDocument, DocumentDownloadParams } from "./resources/documents/documents-resource";
51
52
  export type { BotInput, BotOutput } from "./resources/bots/bots-resource";
52
53
  export type { PushDevice, PushDeviceList, PushPlatform, RegisterPushDeviceRequest, } from "./resources/push/push-devices-resource";
53
54
  export type { ApnsEnvironment, ApnsPushProvider, ApnsPushProviderChange, CreatePushProviderRequest, ExpoPushProvider, FcmPushProvider, PushProviderName, PushProviderSettings, RelayPushProvider, UpdatePushProviderRequest, } from "./resources/push/push-provider-resource";
54
- export type { ChatEvent, ChatEventHandler, ChatMessage, ChatMessageListParams, ChatParticipant, ChatRead, ChatReadRequest, ChatStopListening, ChatThread, ChatThreadListParams, OpenChatThreadRequest, SendChatMessageRequest, } from "./resources/chat/chat-types";
55
+ export type { ChatAttachment, ChatAttachmentContentType, ChatAttachmentLink, ChatAttachmentUploadRequest, ChatEvent, ChatEventHandler, ChatMessage, ChatMessageListParams, ChatParticipant, ChatRead, ChatReadRequest, ChatStopListening, ChatThread, ChatThreadListParams, OpenChatThreadRequest, SendChatMessageRequest, } from "./resources/chat/chat-types";
55
56
  export type { NotificationsRule, NotificationsRuleResponse } from "./resources/omnichannel-alerts/notifications-rules-resource";
56
57
  export type { NotificationsPreviewAlert, NotificationsPreviewNotify, NotificationsPreviewRecipient, NotificationsPreviewRequest, NotificationsPreviewResponse, OmnichannelAlertEvent, } from "./resources/omnichannel-alerts/omnichannel-alerts-resource";
57
58
  export type * from "./resources/slim/slim-queries";
@@ -60,8 +61,10 @@ export type { AiResource } from "./resources/ai/ai-resource";
60
61
  export type { AuthResource } from "./resources/auth-resource";
61
62
  export type { BotsResource } from "./resources/bots/bots-resource";
62
63
  export type { ChatResource, ChatSettings } from "./resources/chat/chat-resource";
64
+ export type { ChatAttachmentsResource } from "./resources/chat/chat-attachments-resource";
63
65
  export type { ChatThreadMessagesResource } from "./resources/chat/chat-messages-resource";
64
66
  export type { ChatThreadsResource } from "./resources/chat/chat-threads-resource";
67
+ export type { CmsAuthoringResource } from "./resources/cms/cms-authoring-resource";
65
68
  export type { CmsResource } from "./resources/cms/cms-resource";
66
69
  export type { ConsentResource } from "./resources/consent/consent-resource";
67
70
  export type { ContentResource } from "./resources/content/content-resource";
@@ -0,0 +1,28 @@
1
+ import { OvokFetch } from "../../config/ovok-config";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ import { ChatAttachment, ChatAttachmentLink, ChatAttachmentUploadRequest } from "./chat-types";
5
+ /**
6
+ * Files the signed-in person uploads to send in their chat threads.
7
+ *
8
+ * @category chat
9
+ */
10
+ export declare class ChatAttachmentsResource {
11
+ private readonly chat;
12
+ private readonly fetchFile;
13
+ constructor(chat: HttpClient, fetchFile: OvokFetch);
14
+ /**
15
+ * Uploads a PDF, PNG, JPEG or WebP of up to 10 MB, kept private. Send it with `messages.send(threadId, { text,
16
+ * attachments: [attachment.id] })`, in as many threads as you like. Calls `POST v1/chat/attachments`, then stores the
17
+ * file where the server says.
18
+ *
19
+ * @throws OvokServiceError when the store refuses the file, for example because it is larger than 10 MB.
20
+ */
21
+ upload(request: ChatAttachmentUploadRequest, options?: RequestOptions): Promise<ChatAttachment>;
22
+ /**
23
+ * A link that downloads one of the signed-in person's own uploads for the next hour. Calls
24
+ * `GET v1/chat/attachments/{attachmentId}`.
25
+ */
26
+ link(attachmentId: string, options?: RequestOptions): Promise<ChatAttachmentLink>;
27
+ private store;
28
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatAttachmentsResource = void 0;
4
+ const ovok_errors_1 = require("../../errors/ovok-errors");
5
+ const url_1 = require("../../http/url");
6
+ const ATTACHMENTS_PATH = "attachments";
7
+ /**
8
+ * Files the signed-in person uploads to send in their chat threads.
9
+ *
10
+ * @category chat
11
+ */
12
+ class ChatAttachmentsResource {
13
+ constructor(chat, fetchFile) {
14
+ this.chat = chat;
15
+ this.fetchFile = fetchFile;
16
+ }
17
+ /**
18
+ * Uploads a PDF, PNG, JPEG or WebP of up to 10 MB, kept private. Send it with `messages.send(threadId, { text,
19
+ * attachments: [attachment.id] })`, in as many threads as you like. Calls `POST v1/chat/attachments`, then stores the
20
+ * file where the server says.
21
+ *
22
+ * @throws OvokServiceError when the store refuses the file, for example because it is larger than 10 MB.
23
+ */
24
+ async upload(request, options) {
25
+ const { file, fileName, contentType } = request;
26
+ const { upload, ...attachment } = await this.chat.post(ATTACHMENTS_PATH, { fileName, contentType }, options);
27
+ const form = new FormData();
28
+ for (const [name, value] of Object.entries(upload.fields)) {
29
+ form.append(name, value);
30
+ }
31
+ form.append("file", file, fileName);
32
+ await this.store(upload.url, form, options);
33
+ return attachment;
34
+ }
35
+ /**
36
+ * A link that downloads one of the signed-in person's own uploads for the next hour. Calls
37
+ * `GET v1/chat/attachments/{attachmentId}`.
38
+ */
39
+ link(attachmentId, options) {
40
+ return this.chat.get(`${ATTACHMENTS_PATH}/${(0, url_1.pathSegment)(attachmentId)}`, options);
41
+ }
42
+ async store(url, form, options) {
43
+ var _a;
44
+ const stored = await this.fetchFile(url, { method: "POST", body: form, signal: options === null || options === void 0 ? void 0 : options.signal }).catch((error) => {
45
+ throw new ovok_errors_1.OvokConnectionError((0, ovok_errors_1.detailsFor)("Could not reach the file store."), error);
46
+ });
47
+ await ((_a = stored.body) === null || _a === void 0 ? void 0 : _a.cancel().catch(() => undefined));
48
+ if (!stored.ok) {
49
+ throw new ovok_errors_1.OvokServiceError({ ...(0, ovok_errors_1.detailsFor)(`The file store refused the file (${stored.status}).`), status: stored.status });
50
+ }
51
+ }
52
+ }
53
+ exports.ChatAttachmentsResource = ChatAttachmentsResource;
@@ -2,7 +2,7 @@ import { HttpClient } from "../../http/http-client";
2
2
  import { RequestOptions } from "../../http/transmit";
3
3
  import { PagePromise } from "../../paging/page";
4
4
  import { ChatHistory } from "./chat-history";
5
- import { ChatMessage, ChatMessageListParams, SendChatMessageRequest } from "./chat-types";
5
+ import { ChatAttachmentLink, ChatMessage, ChatMessageListParams, SendChatMessageRequest } from "./chat-types";
6
6
  /**
7
7
  * Messages in a chat thread.
8
8
  *
@@ -18,8 +18,13 @@ export declare class ChatThreadMessagesResource {
18
18
  */
19
19
  list(threadId: string, params?: ChatMessageListParams, options?: RequestOptions): PagePromise<ChatMessage>;
20
20
  /**
21
- * Sends a text message. It carries a client id the server remembers, so a retried send is stored once. Calls
22
- * `POST v1/chat/threads/{threadId}/messages`.
21
+ * Sends a message, with any of the signed-in person's own uploads. It carries a client id the server remembers, so a
22
+ * retried send is stored once. Calls `POST v1/chat/threads/{threadId}/messages`.
23
23
  */
24
24
  send(threadId: string, body: SendChatMessageRequest, options?: RequestOptions): Promise<ChatMessage>;
25
+ /**
26
+ * A link that downloads a file sent with a message, for the next hour. Calls
27
+ * `GET v1/chat/threads/{threadId}/messages/{messageId}/attachments/{attachmentId}`.
28
+ */
29
+ attachmentLink(threadId: string, messageId: string, attachmentId: string, options?: RequestOptions): Promise<ChatAttachmentLink>;
25
30
  }
@@ -30,13 +30,26 @@ class ChatThreadMessagesResource {
30
30
  });
31
31
  }
32
32
  /**
33
- * Sends a text message. It carries a client id the server remembers, so a retried send is stored once. Calls
34
- * `POST v1/chat/threads/{threadId}/messages`.
33
+ * Sends a message, with any of the signed-in person's own uploads. It carries a client id the server remembers, so a
34
+ * retried send is stored once. Calls `POST v1/chat/threads/{threadId}/messages`.
35
35
  */
36
36
  async send(threadId, body, options) {
37
- const message = await this.chat.send({ method: "POST", path: messagesPath(threadId), body: { ...body, clientId: newClientId() }, idempotent: true }, options);
37
+ var _a;
38
+ const message = await this.chat.send({
39
+ method: "POST",
40
+ path: messagesPath(threadId),
41
+ body: { ...body, clientId: (_a = body.clientId) !== null && _a !== void 0 ? _a : newClientId() },
42
+ idempotent: true,
43
+ }, options);
38
44
  this.history.seed([message.sentAt]);
39
45
  return message;
40
46
  }
47
+ /**
48
+ * A link that downloads a file sent with a message, for the next hour. Calls
49
+ * `GET v1/chat/threads/{threadId}/messages/{messageId}/attachments/{attachmentId}`.
50
+ */
51
+ attachmentLink(threadId, messageId, attachmentId, options) {
52
+ return this.chat.get(`${messagesPath(threadId)}/${(0, url_1.pathSegment)(messageId)}/attachments/${(0, url_1.pathSegment)(attachmentId)}`, options);
53
+ }
41
54
  }
42
55
  exports.ChatThreadMessagesResource = ChatThreadMessagesResource;
@@ -1,7 +1,9 @@
1
+ import { OvokFetch } from "../../config/ovok-config";
1
2
  import { HttpClient } from "../../http/http-client";
2
3
  import { RequestOptions } from "../../http/transmit";
3
4
  import { OvokLogger } from "../../logging/ovok-logger";
4
5
  import { SessionResource } from "../session/session-resource";
6
+ import { ChatAttachmentsResource } from "./chat-attachments-resource";
5
7
  import { OpenSocket } from "./chat-connection";
6
8
  import { ChatThreadMessagesResource } from "./chat-messages-resource";
7
9
  import { ChatThreadsResource } from "./chat-threads-resource";
@@ -16,6 +18,8 @@ export type ChatSettings = {
16
18
  baseUrl: string;
17
19
  /** Receives structured log entries. */
18
20
  logger: OvokLogger;
21
+ /** Stores uploaded files where the server says. */
22
+ fetch: OvokFetch;
19
23
  };
20
24
  /**
21
25
  * Person-to-person chat between patients and their care team. Calls routes under `v1/chat`.
@@ -27,6 +31,8 @@ export declare class ChatResource {
27
31
  readonly threads: ChatThreadsResource;
28
32
  /** Messages in a thread. */
29
33
  readonly messages: ChatThreadMessagesResource;
34
+ /** Files to send in threads. */
35
+ readonly attachments: ChatAttachmentsResource;
30
36
  private readonly chat;
31
37
  private readonly connection;
32
38
  constructor(http: HttpClient, session: SessionResource, settings: ChatSettings, openSocket?: OpenSocket);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ChatResource = void 0;
4
4
  const socket_io_client_1 = require("socket.io-client");
5
5
  const ovok_logger_1 = require("../../logging/ovok-logger");
6
+ const chat_attachments_resource_1 = require("./chat-attachments-resource");
6
7
  const chat_connection_1 = require("./chat-connection");
7
8
  const chat_history_1 = require("./chat-history");
8
9
  const chat_messages_resource_1 = require("./chat-messages-resource");
@@ -19,6 +20,7 @@ class ChatResource {
19
20
  this.chat = http.under(CHAT_PATH);
20
21
  this.threads = new chat_threads_resource_1.ChatThreadsResource(this.chat, history);
21
22
  this.messages = new chat_messages_resource_1.ChatThreadMessagesResource(this.chat, history);
23
+ this.attachments = new chat_attachments_resource_1.ChatAttachmentsResource(this.chat, settings.fetch);
22
24
  this.connection = new chat_connection_1.ChatConnection({
23
25
  http,
24
26
  session,
@@ -19,6 +19,8 @@ export type ChatMessage = {
19
19
  sender: ChatParticipant;
20
20
  /** The message text. */
21
21
  text: string;
22
+ /** Files sent with the text. */
23
+ attachments: ChatAttachment[];
22
24
  /** When the server accepted it, as an ISO date-time. */
23
25
  sentAt: string;
24
26
  /** The id of the message it replies to, or null. */
@@ -26,6 +28,49 @@ export type ChatMessage = {
26
28
  /** The id the sending client gave it, which makes a repeated send safe; null when none was given. */
27
29
  clientId: string | null;
28
30
  };
31
+ /**
32
+ * A file sent with a chat message.
33
+ *
34
+ * @category chat
35
+ */
36
+ export type ChatAttachment = {
37
+ /** The attachment id. */
38
+ id: string;
39
+ /** The file's name. */
40
+ title: string;
41
+ /** The file's MIME type. */
42
+ contentType: string;
43
+ };
44
+ /**
45
+ * A link that downloads an attachment without a bearer, until it expires.
46
+ *
47
+ * @category chat
48
+ */
49
+ export type ChatAttachmentLink = {
50
+ /** Downloads the file; fits a browser tab, a download or a PDF viewer. */
51
+ url: string;
52
+ /** When the link stops working, as an ISO date-time. */
53
+ expiresAt: string;
54
+ };
55
+ /**
56
+ * The file types chat accepts.
57
+ *
58
+ * @category chat
59
+ */
60
+ export type ChatAttachmentContentType = "application/pdf" | "image/png" | "image/jpeg" | "image/webp";
61
+ /**
62
+ * A file to upload for chat.
63
+ *
64
+ * @category chat
65
+ */
66
+ export type ChatAttachmentUploadRequest = {
67
+ /** The file, at most 10 MB. */
68
+ file: Blob;
69
+ /** The file's name, as readers see it. */
70
+ fileName: string;
71
+ /** The file's type. */
72
+ contentType: ChatAttachmentContentType;
73
+ };
29
74
  /**
30
75
  * When one participant last read a thread.
31
76
  *
@@ -109,8 +154,12 @@ export type ChatMessageListParams = {
109
154
  export type SendChatMessageRequest = {
110
155
  /** The message text. */
111
156
  text: string;
157
+ /** Ids of the signed-in person's own uploads to send with the text, at most 5. */
158
+ attachments?: string[];
112
159
  /** The id of the message this one replies to. */
113
160
  replyTo?: string;
161
+ /** Your id for the message: the same id in the same thread again is the same message. Generated when omitted. */
162
+ clientId?: string;
114
163
  };
115
164
  /**
116
165
  * Request body for marking a thread read.
@@ -0,0 +1,49 @@
1
+ import { HttpClient } from "../../http/http-client";
2
+ import { RequestOptions } from "../../http/transmit";
3
+ import { PagePromise } from "../../paging/page";
4
+ /**
5
+ * Field conditions every listed document meets, by field (dots reach into relations, e.g. `contentType.slug`) and
6
+ * then by Payload operator (`equals`, `not_equals`, `in`, `exists`, …).
7
+ *
8
+ * @category cms
9
+ */
10
+ export type CmsWhere = Record<string, Record<string, string | number | boolean>>;
11
+ /**
12
+ * What a listing of documents being authored returns. `limit` is the page size; `depth` how far relations are filled in.
13
+ *
14
+ * @category cms
15
+ */
16
+ export type CmsAuthoringListParams = {
17
+ /** Conditions every document meets. */
18
+ where?: CmsWhere;
19
+ /** Page number to fetch. */
20
+ page?: number;
21
+ /** Documents per page. */
22
+ limit?: number;
23
+ /** Field to sort by; prefix with `-` for descending. */
24
+ sort?: string;
25
+ /** How deep to fill in related documents; 0 answers their ids. */
26
+ depth?: number;
27
+ /** The CMS locale to read localized fields in, such as `de`. */
28
+ locale?: string;
29
+ };
30
+ /**
31
+ * The project's own CMS documents in every status, drafts included, to read and write as the signed-in user. Calls
32
+ * routes under `v1/content`, which act on the caller's own project only.
33
+ *
34
+ * @category cms
35
+ */
36
+ export declare class CmsAuthoringResource {
37
+ private readonly http;
38
+ constructor(http: HttpClient);
39
+ /** Lists a collection's documents, page by page. Calls `GET v1/content/{collection}`. */
40
+ list<T extends object>(collection: string, params?: CmsAuthoringListParams, options?: RequestOptions): PagePromise<T>;
41
+ /** Reads one document by id. Calls `GET v1/content/{collection}/{id}`. */
42
+ retrieve<T extends object>(collection: string, id: number | string, options?: RequestOptions): Promise<T>;
43
+ /** Creates a document and answers it. Calls `POST v1/content/{collection}`. */
44
+ create<T extends object>(collection: string, document: object, options?: RequestOptions): Promise<T>;
45
+ /** Changes the fields given and answers the document; a field sent replaces its value whole. Calls `PATCH v1/content/{collection}/{id}`. */
46
+ update<T extends object>(collection: string, id: number | string, fields: object, options?: RequestOptions): Promise<T>;
47
+ /** Deletes a document. Calls `DELETE v1/content/{collection}/{id}`. */
48
+ delete(collection: string, id: number | string, options?: RequestOptions): Promise<void>;
49
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CmsAuthoringResource = void 0;
4
+ const query_string_1 = require("../../../client/query-string");
5
+ const url_1 = require("../../http/url");
6
+ const payload_pages_1 = require("./payload-pages");
7
+ const CONTENT_PATH = "v1/content";
8
+ const collectionPath = (collection) => `${CONTENT_PATH}/${(0, url_1.pathSegment)(collection)}`;
9
+ const documentPath = (collection, id) => `${collectionPath(collection)}/${(0, url_1.pathSegment)(String(id))}`;
10
+ const whereQuery = (where = {}) => Object.fromEntries(Object.entries(where).flatMap(([field, conditions]) => Object.entries(conditions).map(([operator, value]) => [`where[${field}][${operator}]`, value])));
11
+ /**
12
+ * The project's own CMS documents in every status, drafts included, to read and write as the signed-in user. Calls
13
+ * routes under `v1/content`, which act on the caller's own project only.
14
+ *
15
+ * @category cms
16
+ */
17
+ class CmsAuthoringResource {
18
+ constructor(http) {
19
+ this.http = http;
20
+ }
21
+ /** Lists a collection's documents, page by page. Calls `GET v1/content/{collection}`. */
22
+ list(collection, params = {}, options) {
23
+ const { where, ...rest } = params;
24
+ const query = (page) => (0, query_string_1.toQueryString)({ ...whereQuery(where), ...rest, page });
25
+ return (0, payload_pages_1.payloadPages)((page) => this.http.get(`${collectionPath(collection)}${query(page)}`, options), params.page);
26
+ }
27
+ /** Reads one document by id. Calls `GET v1/content/{collection}/{id}`. */
28
+ retrieve(collection, id, options) {
29
+ return this.http.get(documentPath(collection, id), options);
30
+ }
31
+ /** Creates a document and answers it. Calls `POST v1/content/{collection}`. */
32
+ async create(collection, document, options) {
33
+ const { doc } = await this.http.post(collectionPath(collection), document, options);
34
+ return doc;
35
+ }
36
+ /** Changes the fields given and answers the document; a field sent replaces its value whole. Calls `PATCH v1/content/{collection}/{id}`. */
37
+ async update(collection, id, fields, options) {
38
+ const { doc } = await this.http.patch(documentPath(collection, id), fields, options);
39
+ return doc;
40
+ }
41
+ /** Deletes a document. Calls `DELETE v1/content/{collection}/{id}`. */
42
+ async delete(collection, id, options) {
43
+ await this.http.delete(documentPath(collection, id), options);
44
+ }
45
+ }
46
+ exports.CmsAuthoringResource = CmsAuthoringResource;
@@ -1,4 +1,4 @@
1
- import type { OvokCmsPage } from "../../../client/cms/types";
1
+ import type { OvokCmsContentItem, OvokCmsPage } from "../../../client/cms/types";
2
2
  import { HttpClient } from "../../http/http-client";
3
3
  import { RequestOptions } from "../../http/transmit";
4
4
  /**
@@ -30,5 +30,6 @@ export declare class CmsDelivery {
30
30
  constructor(http: HttpClient, tenantCode: string);
31
31
  listPage<T extends object>(collection: string, params: CmsListParams, options?: RequestOptions): Promise<OvokCmsPage<T>>;
32
32
  retrieve<T extends object>(collection: string, slug: string, params: CmsReadParams, options?: RequestOptions): Promise<T>;
33
+ contentItems<T extends object>(contentTypeSlug: string, options?: RequestOptions): Promise<OvokCmsPage<OvokCmsContentItem<T>>>;
33
34
  private queryFor;
34
35
  }
@@ -5,7 +5,8 @@ const locale_1 = require("../../../client/cms/locale");
5
5
  const query_string_1 = require("../../../client/query-string");
6
6
  const ovok_errors_1 = require("../../errors/ovok-errors");
7
7
  const url_1 = require("../../http/url");
8
- const COLLECTIONS_PATH = "v1/public/cms/collections";
8
+ const CMS_PATH = "v1/public/cms";
9
+ const COLLECTIONS_PATH = `${CMS_PATH}/collections`;
9
10
  const itemsPath = (collection) => `${COLLECTIONS_PATH}/${(0, url_1.pathSegment)(collection)}/items`;
10
11
  /** Published documents, always read as the client's tenant: signed out, the CMS knows it only from `?tenant=`. */
11
12
  class CmsDelivery {
@@ -22,6 +23,13 @@ class CmsDelivery {
22
23
  }
23
24
  return this.http.get(`${itemsPath(collection)}/${(0, url_1.pathSegment)(slug)}${this.queryFor(params)}`, options);
24
25
  }
26
+ async contentItems(contentTypeSlug, options) {
27
+ if (contentTypeSlug === "") {
28
+ throw new ovok_errors_1.OvokValidationError((0, ovok_errors_1.detailsFor)("A content type read needs the type's slug."));
29
+ }
30
+ const query = (0, query_string_1.toQueryString)({ tenant: this.tenantCode });
31
+ return this.http.get(`${CMS_PATH}/${(0, url_1.pathSegment)(contentTypeSlug)}/items${query}`, options);
32
+ }
25
33
  // An empty locale or sort counts as absent.
26
34
  queryFor({ locale, page, limit, sort }) {
27
35
  return (0, query_string_1.toQueryString)({
@@ -1,13 +1,15 @@
1
- import type { OvokCmsDocument, OvokTranslations } from "../../../client/cms/types";
1
+ import type { OvokCmsContentItem, OvokCmsDocument, OvokCmsPage, OvokTranslations } from "../../../client/cms/types";
2
2
  import { HttpClient } from "../../http/http-client";
3
3
  import { RequestOptions } from "../../http/transmit";
4
+ import { CmsAuthoringResource } from "./cms-authoring-resource";
4
5
  import { CmsReadParams } from "./cms-delivery";
5
6
  import { CmsDocumentsResource } from "./cms-documents-resource";
6
7
  import { ReleaseNotesResource } from "./release-notes-resource";
7
8
  /** 25,000 documents: far beyond any real collection, so reaching it means the CMS never ends its pages. */
8
9
  export declare const MAX_TRANSLATION_PAGES = 500;
9
10
  /**
10
- * Published CMS content: documents, legal pages, release notes and translations. Calls routes under `v1/public/cms`.
11
+ * CMS content. Published documents, legal pages, release notes, translations and content type items come from routes
12
+ * under `v1/public/cms`; `authoring` reads and writes every status under `v1/content`.
11
13
  *
12
14
  * @category cms
13
15
  */
@@ -16,10 +18,19 @@ export declare class CmsResource {
16
18
  readonly documents: CmsDocumentsResource;
17
19
  /** Reads release notes. */
18
20
  readonly releaseNotes: ReleaseNotesResource;
21
+ /** Reads and writes the project's own documents in every status. */
22
+ readonly authoring: CmsAuthoringResource;
19
23
  private readonly delivery;
20
24
  constructor(http: HttpClient, tenantCode: string);
21
25
  /** "terms-and-conditions", "data-privacy", …: readable before sign-in. */
22
26
  legalPage(slug: string, params?: CmsReadParams, options?: RequestOptions): Promise<OvokCmsDocument>;
27
+ /**
28
+ * The published items of a content type defined in the Console, at most 100, in the CMS's order. Needs a signed-in
29
+ * user of the tenant: this route is never open.
30
+ *
31
+ * @throws OvokValidationError for an empty slug.
32
+ */
33
+ contentItems<T extends object = Record<string, unknown>>(contentTypeSlug: string, options?: RequestOptions): Promise<OvokCmsPage<OvokCmsContentItem<T>>>;
23
34
  /**
24
35
  * The `translations` collection as one tree, readable before sign-in; nothing is kept on the device.
25
36
  * Reads every page of the collection.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CmsResource = exports.MAX_TRANSLATION_PAGES = void 0;
4
4
  const ovok_errors_1 = require("../../errors/ovok-errors");
5
+ const cms_authoring_resource_1 = require("./cms-authoring-resource");
5
6
  const cms_delivery_1 = require("./cms-delivery");
6
7
  const cms_documents_resource_1 = require("./cms-documents-resource");
7
8
  const release_notes_resource_1 = require("./release-notes-resource");
@@ -14,7 +15,8 @@ const LARGEST_PAGE_SIZE = 50;
14
15
  exports.MAX_TRANSLATION_PAGES = 500;
15
16
  const TRANSLATION_PAGE_LIMIT_CODE = "cms_translations_page_limit";
16
17
  /**
17
- * Published CMS content: documents, legal pages, release notes and translations. Calls routes under `v1/public/cms`.
18
+ * CMS content. Published documents, legal pages, release notes, translations and content type items come from routes
19
+ * under `v1/public/cms`; `authoring` reads and writes every status under `v1/content`.
18
20
  *
19
21
  * @category cms
20
22
  */
@@ -23,11 +25,21 @@ class CmsResource {
23
25
  this.delivery = new cms_delivery_1.CmsDelivery(http, tenantCode);
24
26
  this.documents = new cms_documents_resource_1.CmsDocumentsResource(this.delivery);
25
27
  this.releaseNotes = new release_notes_resource_1.ReleaseNotesResource(this.documents);
28
+ this.authoring = new cms_authoring_resource_1.CmsAuthoringResource(http);
26
29
  }
27
30
  /** "terms-and-conditions", "data-privacy", …: readable before sign-in. */
28
31
  legalPage(slug, params = {}, options) {
29
32
  return this.documents.retrieve(LEGAL_PAGES, slug, params, options);
30
33
  }
34
+ /**
35
+ * The published items of a content type defined in the Console, at most 100, in the CMS's order. Needs a signed-in
36
+ * user of the tenant: this route is never open.
37
+ *
38
+ * @throws OvokValidationError for an empty slug.
39
+ */
40
+ contentItems(contentTypeSlug, options) {
41
+ return this.delivery.contentItems(contentTypeSlug, options);
42
+ }
31
43
  /**
32
44
  * The `translations` collection as one tree, readable before sign-in; nothing is kept on the device.
33
45
  * Reads every page of the collection.
@@ -35,7 +35,7 @@ export declare class DocumentsResource {
35
35
  /** Lists documents. Calls `GET document`. */
36
36
  list(params?: OvokDocumentSearchQuery, options?: RequestOptions): Promise<OvokDocumentSearchResponse>;
37
37
  /** Registers a document upload. Calls `POST document`. */
38
- createUpload(body: OvokDocumentUploadRequest, options?: RequestOptions): Promise<OvokDocumentFile>;
38
+ createUpload({ isPublic, ...body }: OvokDocumentUploadRequest, options?: RequestOptions): Promise<OvokDocumentFile>;
39
39
  /** Replaces the file of a document. Calls `POST document/{documentId}`. */
40
40
  replaceUpload(documentId: string, body: OvokDocumentReplacement, options?: RequestOptions): Promise<OvokDocumentFile>;
41
41
  /** Updates a document's metadata. Calls `PATCH document/{documentId}`. */
@@ -21,8 +21,10 @@ class DocumentsResource {
21
21
  return this.http.get(`${DOCUMENT_PATH}${(0, query_string_1.toQueryString)(params)}`, options);
22
22
  }
23
23
  /** Registers a document upload. Calls `POST document`. */
24
- createUpload(body, options) {
25
- return this.http.post(DOCUMENT_PATH, body, options);
24
+ createUpload({ isPublic, ...body }, options) {
25
+ // This route reads isPublic as the text "true" or "false" and refuses a JSON boolean.
26
+ const visibility = isPublic === undefined ? {} : { isPublic: String(isPublic) };
27
+ return this.http.post(DOCUMENT_PATH, { ...body, ...visibility }, options);
26
28
  }
27
29
  /** Replaces the file of a document. Calls `POST document/{documentId}`. */
28
30
  replaceUpload(documentId, body, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovok/core",
3
- "version": "0.4.59-dev.565+16c360c",
3
+ "version": "0.4.59-dev.567+06fe40c",
4
4
  "private": false,
5
5
  "main": "dist/next/index.js",
6
6
  "types": "dist/next/index.d.ts",