@ovok/core 0.4.59-dev.567 → 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/ovok.js +1 -1
- 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/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);
|
|
@@ -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
|
*/
|