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

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.566+7e4647b",
30
30
  },
31
31
  fhirVersion: "4.0.1",
32
32
  format: ["json"],
@@ -46,6 +46,7 @@ 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";
@@ -62,6 +63,7 @@ export type { BotsResource } from "./resources/bots/bots-resource";
62
63
  export type { ChatResource, ChatSettings } from "./resources/chat/chat-resource";
63
64
  export type { ChatThreadMessagesResource } from "./resources/chat/chat-messages-resource";
64
65
  export type { ChatThreadsResource } from "./resources/chat/chat-threads-resource";
66
+ export type { CmsAuthoringResource } from "./resources/cms/cms-authoring-resource";
65
67
  export type { CmsResource } from "./resources/cms/cms-resource";
66
68
  export type { ConsentResource } from "./resources/consent/consent-resource";
67
69
  export type { ContentResource } from "./resources/content/content-resource";
@@ -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.566+7e4647b",
4
4
  "private": false,
5
5
  "main": "dist/next/index.js",
6
6
  "types": "dist/next/index.d.ts",