@ovok/core 0.4.59-dev.566 → 0.4.59-dev.568
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/conformance/capability-requirements.js +1 -1
- package/dist/next/config/ovok-config.d.ts +3 -0
- package/dist/next/config/settings.js +8 -6
- package/dist/next/index.d.ts +2 -1
- package/dist/next/ovok.js +1 -1
- package/dist/next/resources/chat/chat-attachments-resource.d.ts +28 -0
- package/dist/next/resources/chat/chat-attachments-resource.js +53 -0
- package/dist/next/resources/chat/chat-messages-resource.d.ts +8 -3
- package/dist/next/resources/chat/chat-messages-resource.js +16 -3
- package/dist/next/resources/chat/chat-resource.d.ts +6 -0
- package/dist/next/resources/chat/chat-resource.js +2 -0
- package/dist/next/resources/chat/chat-types.d.ts +49 -0
- package/dist/next/resources/cms/cms-delivery.d.ts +3 -1
- package/dist/next/resources/cms/cms-delivery.js +9 -4
- package/dist/next/resources/cms/cms-resource.d.ts +2 -2
- package/dist/next/resources/cms/cms-resource.js +3 -3
- package/package.json +1 -1
|
@@ -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.
|
|
29
|
+
version: "0.4.59-dev.568+f0114d4",
|
|
30
30
|
},
|
|
31
31
|
fhirVersion: "4.0.1",
|
|
32
32
|
format: ["json"],
|
|
@@ -51,6 +51,8 @@ type OvokBaseConfig = {
|
|
|
51
51
|
outboxRequestBudget?: number;
|
|
52
52
|
/** Receives the client's structured log entries. Defaults to none. */
|
|
53
53
|
logger?: OvokLogger;
|
|
54
|
+
/** Read-only CMS API key sent as `x-api-key` on public CMS reads, so a server reads them signed out. Rejected in a browser. */
|
|
55
|
+
cmsApiKey?: string;
|
|
54
56
|
};
|
|
55
57
|
/**
|
|
56
58
|
* Client configuration for end users, without a secret.
|
|
@@ -101,5 +103,6 @@ export type OvokSettings = {
|
|
|
101
103
|
lifecycle: OutboxLifecycle;
|
|
102
104
|
outboxRequestBudget: number;
|
|
103
105
|
logger: OvokLogger;
|
|
106
|
+
cmsApiKey: string | null;
|
|
104
107
|
};
|
|
105
108
|
export {};
|
|
@@ -33,6 +33,7 @@ function readSettings(config, environment) {
|
|
|
33
33
|
lifecycle: (_k = config.lifecycle) !== null && _k !== void 0 ? _k : outbox_triggers_1.browserLifecycle,
|
|
34
34
|
outboxRequestBudget: requirePositive((_l = config.outboxRequestBudget) !== null && _l !== void 0 ? _l : DEFAULT_OUTBOX_REQUEST_BUDGET, "outboxRequestBudget"),
|
|
35
35
|
logger: (_m = config.logger) !== null && _m !== void 0 ? _m : ovok_logger_1.silentLogger,
|
|
36
|
+
cmsApiKey: readServerSecret(config.cmsApiKey, "cmsApiKey", environment),
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
const configError = (message) => new ovok_errors_1.OvokConfigError((0, ovok_errors_1.detailsFor)(message));
|
|
@@ -43,16 +44,17 @@ const readBaseUrl = (baseUrl) => {
|
|
|
43
44
|
return baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
|
|
44
45
|
};
|
|
45
46
|
const readMachineClient = (config, environment) => {
|
|
46
|
-
|
|
47
|
+
const clientSecret = readServerSecret(config.clientSecret, "clientSecret", environment);
|
|
48
|
+
return clientSecret === null ? null : { clientId: requireText(config.clientId, "clientId"), clientSecret };
|
|
49
|
+
};
|
|
50
|
+
const readServerSecret = (value, name, environment) => {
|
|
51
|
+
if (value === undefined) {
|
|
47
52
|
return null;
|
|
48
53
|
}
|
|
49
54
|
if (environment.hasDocument) {
|
|
50
|
-
throw configError(
|
|
55
|
+
throw configError(`${name} is for servers only: a secret shipped to a browser is public.`);
|
|
51
56
|
}
|
|
52
|
-
return
|
|
53
|
-
clientId: requireText(config.clientId, "clientId"),
|
|
54
|
-
clientSecret: requireText(config.clientSecret, "clientSecret"),
|
|
55
|
-
};
|
|
57
|
+
return requireText(value, name);
|
|
56
58
|
};
|
|
57
59
|
const requireText = (value, name) => {
|
|
58
60
|
var _a;
|
package/dist/next/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export type { DeletedDocument, DocumentDownloadParams } from "./resources/docume
|
|
|
52
52
|
export type { BotInput, BotOutput } from "./resources/bots/bots-resource";
|
|
53
53
|
export type { PushDevice, PushDeviceList, PushPlatform, RegisterPushDeviceRequest, } from "./resources/push/push-devices-resource";
|
|
54
54
|
export type { ApnsEnvironment, ApnsPushProvider, ApnsPushProviderChange, CreatePushProviderRequest, ExpoPushProvider, FcmPushProvider, PushProviderName, PushProviderSettings, RelayPushProvider, UpdatePushProviderRequest, } from "./resources/push/push-provider-resource";
|
|
55
|
-
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";
|
|
56
56
|
export type { NotificationsRule, NotificationsRuleResponse } from "./resources/omnichannel-alerts/notifications-rules-resource";
|
|
57
57
|
export type { NotificationsPreviewAlert, NotificationsPreviewNotify, NotificationsPreviewRecipient, NotificationsPreviewRequest, NotificationsPreviewResponse, OmnichannelAlertEvent, } from "./resources/omnichannel-alerts/omnichannel-alerts-resource";
|
|
58
58
|
export type * from "./resources/slim/slim-queries";
|
|
@@ -61,6 +61,7 @@ export type { AiResource } from "./resources/ai/ai-resource";
|
|
|
61
61
|
export type { AuthResource } from "./resources/auth-resource";
|
|
62
62
|
export type { BotsResource } from "./resources/bots/bots-resource";
|
|
63
63
|
export type { ChatResource, ChatSettings } from "./resources/chat/chat-resource";
|
|
64
|
+
export type { ChatAttachmentsResource } from "./resources/chat/chat-attachments-resource";
|
|
64
65
|
export type { ChatThreadMessagesResource } from "./resources/chat/chat-messages-resource";
|
|
65
66
|
export type { ChatThreadsResource } from "./resources/chat/chat-threads-resource";
|
|
66
67
|
export type { CmsAuthoringResource } from "./resources/cms/cms-authoring-resource";
|
package/dist/next/ovok.js
CHANGED
|
@@ -85,7 +85,7 @@ class Ovok {
|
|
|
85
85
|
this.accounts = new accounts_resource_1.AccountsResource(http);
|
|
86
86
|
this.locales = new locales_resource_1.LocalesResource(http);
|
|
87
87
|
this.localizations = new localizations_resource_1.LocalizationsResource(http);
|
|
88
|
-
this.cms = new cms_resource_1.CmsResource(http, settings.tenantCode);
|
|
88
|
+
this.cms = new cms_resource_1.CmsResource(http, settings.tenantCode, settings.cmsApiKey);
|
|
89
89
|
this.content = new content_resource_1.ContentResource(http);
|
|
90
90
|
this.documents = new documents_resource_1.DocumentsResource(http, settings.baseUrl);
|
|
91
91
|
this.videoCalls = new video_calls_resource_1.VideoCallsResource(http);
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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.
|
|
@@ -27,9 +27,11 @@ export type CmsListParams = CmsReadParams & {
|
|
|
27
27
|
export declare class CmsDelivery {
|
|
28
28
|
private readonly http;
|
|
29
29
|
private readonly tenantCode;
|
|
30
|
-
|
|
30
|
+
private readonly headers;
|
|
31
|
+
constructor(http: HttpClient, tenantCode: string, apiKey: string | null);
|
|
31
32
|
listPage<T extends object>(collection: string, params: CmsListParams, options?: RequestOptions): Promise<OvokCmsPage<T>>;
|
|
32
33
|
retrieve<T extends object>(collection: string, slug: string, params: CmsReadParams, options?: RequestOptions): Promise<T>;
|
|
33
34
|
contentItems<T extends object>(contentTypeSlug: string, options?: RequestOptions): Promise<OvokCmsPage<OvokCmsContentItem<T>>>;
|
|
35
|
+
private get;
|
|
34
36
|
private queryFor;
|
|
35
37
|
}
|
|
@@ -6,29 +6,34 @@ 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
8
|
const CMS_PATH = "v1/public/cms";
|
|
9
|
+
const API_KEY_HEADER = "x-api-key";
|
|
9
10
|
const COLLECTIONS_PATH = `${CMS_PATH}/collections`;
|
|
10
11
|
const itemsPath = (collection) => `${COLLECTIONS_PATH}/${(0, url_1.pathSegment)(collection)}/items`;
|
|
11
12
|
/** Published documents, always read as the client's tenant: signed out, the CMS knows it only from `?tenant=`. */
|
|
12
13
|
class CmsDelivery {
|
|
13
|
-
constructor(http, tenantCode) {
|
|
14
|
+
constructor(http, tenantCode, apiKey) {
|
|
14
15
|
this.http = http;
|
|
15
16
|
this.tenantCode = tenantCode;
|
|
17
|
+
this.headers = apiKey === null ? {} : { [API_KEY_HEADER]: apiKey };
|
|
16
18
|
}
|
|
17
19
|
listPage(collection, params, options) {
|
|
18
|
-
return this.
|
|
20
|
+
return this.get(`${itemsPath(collection)}${this.queryFor(params)}`, options);
|
|
19
21
|
}
|
|
20
22
|
async retrieve(collection, slug, params, options) {
|
|
21
23
|
if (slug === "") {
|
|
22
24
|
throw new ovok_errors_1.OvokValidationError((0, ovok_errors_1.detailsFor)("A CMS document read needs a slug."));
|
|
23
25
|
}
|
|
24
|
-
return this.
|
|
26
|
+
return this.get(`${itemsPath(collection)}/${(0, url_1.pathSegment)(slug)}${this.queryFor(params)}`, options);
|
|
25
27
|
}
|
|
26
28
|
async contentItems(contentTypeSlug, options) {
|
|
27
29
|
if (contentTypeSlug === "") {
|
|
28
30
|
throw new ovok_errors_1.OvokValidationError((0, ovok_errors_1.detailsFor)("A content type read needs the type's slug."));
|
|
29
31
|
}
|
|
30
32
|
const query = (0, query_string_1.toQueryString)({ tenant: this.tenantCode });
|
|
31
|
-
return this.
|
|
33
|
+
return this.get(`${CMS_PATH}/${(0, url_1.pathSegment)(contentTypeSlug)}/items${query}`, options);
|
|
34
|
+
}
|
|
35
|
+
get(path, options) {
|
|
36
|
+
return this.http.send({ method: "GET", path, headers: this.headers }, options);
|
|
32
37
|
}
|
|
33
38
|
// An empty locale or sort counts as absent.
|
|
34
39
|
queryFor({ locale, page, limit, sort }) {
|
|
@@ -21,12 +21,12 @@ export declare class CmsResource {
|
|
|
21
21
|
/** Reads and writes the project's own documents in every status. */
|
|
22
22
|
readonly authoring: CmsAuthoringResource;
|
|
23
23
|
private readonly delivery;
|
|
24
|
-
constructor(http: HttpClient, tenantCode: string);
|
|
24
|
+
constructor(http: HttpClient, tenantCode: string, apiKey?: string | null);
|
|
25
25
|
/** "terms-and-conditions", "data-privacy", …: readable before sign-in. */
|
|
26
26
|
legalPage(slug: string, params?: CmsReadParams, options?: RequestOptions): Promise<OvokCmsDocument>;
|
|
27
27
|
/**
|
|
28
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
|
|
29
|
+
* user of the tenant or a client made with `cmsApiKey`: this route is never open.
|
|
30
30
|
*
|
|
31
31
|
* @throws OvokValidationError for an empty slug.
|
|
32
32
|
*/
|
|
@@ -21,8 +21,8 @@ const TRANSLATION_PAGE_LIMIT_CODE = "cms_translations_page_limit";
|
|
|
21
21
|
* @category cms
|
|
22
22
|
*/
|
|
23
23
|
class CmsResource {
|
|
24
|
-
constructor(http, tenantCode) {
|
|
25
|
-
this.delivery = new cms_delivery_1.CmsDelivery(http, tenantCode);
|
|
24
|
+
constructor(http, tenantCode, apiKey = null) {
|
|
25
|
+
this.delivery = new cms_delivery_1.CmsDelivery(http, tenantCode, apiKey);
|
|
26
26
|
this.documents = new cms_documents_resource_1.CmsDocumentsResource(this.delivery);
|
|
27
27
|
this.releaseNotes = new release_notes_resource_1.ReleaseNotesResource(this.documents);
|
|
28
28
|
this.authoring = new cms_authoring_resource_1.CmsAuthoringResource(http);
|
|
@@ -33,7 +33,7 @@ class CmsResource {
|
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
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
|
|
36
|
+
* user of the tenant or a client made with `cmsApiKey`: this route is never open.
|
|
37
37
|
*
|
|
38
38
|
* @throws OvokValidationError for an empty slug.
|
|
39
39
|
*/
|