@paroicms/public-server-lib 0.48.6 → 0.49.1

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.
@@ -1,4 +1,4 @@
1
- export type ApiErrorStatus = 400 | 401 | 403 | 404 | 409 | 500 | 503;
1
+ export type ApiErrorStatus = 400 | 401 | 403 | 404 | 405 | 409 | 500 | 503;
2
2
  export declare class ApiError extends Error {
3
3
  readonly status: ApiErrorStatus;
4
4
  readonly statusLabel: string;
@@ -19,6 +19,8 @@ function getErrorLabel(status) {
19
19
  return "Forbidden";
20
20
  case 404:
21
21
  return "Not Found";
22
+ case 405:
23
+ return "Method Not Allowed";
22
24
  case 409:
23
25
  return "Conflict";
24
26
  case 500:
@@ -1 +1 @@
1
- {"version":3,"file":"api-error-handler.js","sourceRoot":"","sources":["../src/api-error-handler.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,MAAM,CAAiB;IACvB,WAAW,CAAS;IAI7B,YAAY,IAA6B,EAAE,IAAqB;QAC9D,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACtE,MAAM,MAAM,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,SAAS,aAAa,CAAC,MAAc;IACnC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,aAAa,CAAC;QACvB,KAAK,GAAG;YACN,OAAO,cAAc,CAAC;QACxB,KAAK,GAAG;YACN,OAAO,WAAW,CAAC;QACrB,KAAK,GAAG;YACN,OAAO,WAAW,CAAC;QACrB,KAAK,GAAG;YACN,OAAO,UAAU,CAAC;QACpB,KAAK,GAAG;YACN,OAAO,uBAAuB,CAAC;QACjC,KAAK,GAAG;YACN,OAAO,qBAAqB,CAAC;QAC/B;YACE,OAAO,eAAe,CAAC;IAC3B,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"api-error-handler.js","sourceRoot":"","sources":["../src/api-error-handler.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,MAAM,CAAiB;IACvB,WAAW,CAAS;IAI7B,YAAY,IAA6B,EAAE,IAAqB;QAC9D,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACtE,MAAM,MAAM,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,SAAS,aAAa,CAAC,MAAc;IACnC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,aAAa,CAAC;QACvB,KAAK,GAAG;YACN,OAAO,cAAc,CAAC;QACxB,KAAK,GAAG;YACN,OAAO,WAAW,CAAC;QACrB,KAAK,GAAG;YACN,OAAO,WAAW,CAAC;QACrB,KAAK,GAAG;YACN,OAAO,oBAAoB,CAAC;QAC9B,KAAK,GAAG;YACN,OAAO,UAAU,CAAC;QACpB,KAAK,GAAG;YACN,OAAO,uBAAuB,CAAC;QACjC,KAAK,GAAG;YACN,OAAO,qBAAqB,CAAC;QAC/B;YACE,OAAO,eAAe,CAAC;IAC3B,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export type * from "../types/load-descriptor-types.d.ts";
7
7
  export * from "./api-error-handler.js";
8
8
  export * from "./html-helpers.js";
9
9
  export * from "./load-descriptors.js";
10
+ export * from "./media-handle-helpers.js";
10
11
  export * from "./obfuscate.helper.js";
11
12
  export * from "./server-image-cache-engine.helper.js";
12
13
  export * from "./simple-i18n.js";
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./api-error-handler.js";
2
2
  export * from "./html-helpers.js";
3
3
  export * from "./load-descriptors.js";
4
+ export * from "./media-handle-helpers.js";
4
5
  export * from "./obfuscate.helper.js";
5
6
  export * from "./server-image-cache-engine.helper.js";
6
7
  export * from "./simple-i18n.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Get the media handle for a document's or part's featured image.
3
+ * @param nodeId The nodeId of a document or a part. Do not use with the site node id.
4
+ */
5
+ export declare function getHandleOfFeaturedImage(nodeId: string): string;
6
+ /**
7
+ * Get the media handle for a field on a node.
8
+ * Use this for non-localized media fields and for gallery fields.
9
+ * @param siteNodeId The nodeId of the site (from homeRoutingCluster.siteNodeId)
10
+ * @param nodeId The nodeId of the target node
11
+ * @param fieldName The name of the field
12
+ */
13
+ export declare function getHandleOfFieldOnNode({ siteNodeId, nodeId, fieldName, }: {
14
+ siteNodeId: string;
15
+ nodeId: string;
16
+ fieldName: string;
17
+ }): string;
18
+ /**
19
+ * Get the media handle for a site field.
20
+ * @param fieldName The name of the site field (e.g., "favicon", "ogImage", "logo")
21
+ */
22
+ export declare function getHandleOfSiteField(fieldName: string): string;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Get the media handle for a document's or part's featured image.
3
+ * @param nodeId The nodeId of a document or a part. Do not use with the site node id.
4
+ */
5
+ export function getHandleOfFeaturedImage(nodeId) {
6
+ return `node:${nodeId}:featuredImage`;
7
+ }
8
+ /**
9
+ * Get the media handle for a field on a node.
10
+ * Use this for non-localized media fields and for gallery fields.
11
+ * @param siteNodeId The nodeId of the site (from homeRoutingCluster.siteNodeId)
12
+ * @param nodeId The nodeId of the target node
13
+ * @param fieldName The name of the field
14
+ */
15
+ export function getHandleOfFieldOnNode({ siteNodeId, nodeId, fieldName, }) {
16
+ if (nodeId === siteNodeId)
17
+ return `site:${fieldName}`;
18
+ return `node:${nodeId}:${fieldName}`;
19
+ }
20
+ /**
21
+ * Get the media handle for a site field.
22
+ * @param fieldName The name of the site field (e.g., "favicon", "ogImage", "logo")
23
+ */
24
+ export function getHandleOfSiteField(fieldName) {
25
+ return `site:${fieldName}`;
26
+ }
27
+ //# sourceMappingURL=media-handle-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-handle-helpers.js","sourceRoot":"","sources":["../src/media-handle-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAc;IACrD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,UAAU,EACV,MAAM,EACN,SAAS,GAKV;IACC,IAAI,MAAM,KAAK,UAAU;QAAE,OAAO,QAAQ,SAAS,EAAE,CAAC;IACtD,OAAO,QAAQ,MAAM,IAAI,SAAS,EAAE,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAiB;IACpD,OAAO,QAAQ,SAAS,EAAE,CAAC;AAC7B,CAAC"}
@@ -3,4 +3,8 @@ export declare const siteSchemaFormatVersion = "10";
3
3
  * JSON types directory.
4
4
  */
5
5
  export declare const jtDir: string;
6
+ /**
7
+ * Docs directory.
8
+ */
9
+ export declare const docsDir: string;
6
10
  export declare const jsonTypeValidator: import("@typeonly/validator").TypeOnlyValidator;
@@ -8,6 +8,10 @@ export const siteSchemaFormatVersion = "10";
8
8
  * JSON types directory.
9
9
  */
10
10
  export const jtDir = join(packageDir, "typeonly");
11
+ /**
12
+ * Docs directory.
13
+ */
14
+ export const docsDir = join(packageDir, "docs");
11
15
  export const jsonTypeValidator = createValidator({
12
16
  bundle: JSON.parse(readFileSync(join(packageDir, "dist", "types.to.json"), "utf-8")),
13
17
  });
@@ -1 +1 @@
1
- {"version":3,"file":"typeonly-validator.js","sourceRoot":"","sources":["../src/typeonly-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;IAC/C,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC;CACrF,CAAC,CAAC"}
1
+ {"version":3,"file":"typeonly-validator.js","sourceRoot":"","sources":["../src/typeonly-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAEhD,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;IAC/C,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC;CACrF,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ We use **ParoiCMS** to power a website.
2
+
3
+ With this technology, a web page is called a **document**. A website is a tree of documents. The home page is a document, the site section with news posts is a document, each post is a document. Each document has its own path in the URL.
4
+
5
+ There is a special kind of documents that we want to detect: **routing documents** are the site sections. They can't be duplicated. They are never items of a list. For example, the homepage document, the search-page document, the "about us" document, the parent page of blog posts are _routing documents_. Other documents are **regular documents**, and they are always items of a list.
6
+
7
+ A document always has the following base attributes: a localized _title_, a _publish date_, an optional _featured image_, and a _draft_ flag. Additionally, a sequence of **fields** can be defined.
8
+
9
+ A document can contain lists of **parts**. A _part_ is a sub-section of a document, or of another _part_. A part always has a _publish date_ and a _draft_ flag. It may contain a sequence of fields and/or a sequence of child parts. A part is always an item of a list.
10
+
11
+ Any routing document which is parent of regular documents can be used as a **taxonomy**. Then, the terms are the regular child documents. Then a taxonomy can be used in any document or part, by declaring a **labeling field**. There is a special taxonomy: the **authors** taxonomy can be declared, but it is implicitly defined when it is omitted. But the authors labeling field must be explicitly declared in document and part types when needed.
12
+
13
+ Documents and parts are **nodes** in a tree. Children are part of the definition of a node type. When 2 node types appear identical, but their children types are not the same, then they are 2 different node types and they should have 2 different names.
14
+
15
+ The **site schema** is the representation of this ParoiCMS site structure.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paroicms/public-server-lib",
3
- "version": "0.48.6",
3
+ "version": "0.49.1",
4
4
  "description": "Common utilitaries for paroicms plugins (backend side).",
5
5
  "author": "Paroi Team",
6
6
  "repository": {
@@ -22,21 +22,22 @@
22
22
  "dev": "tsc --watch --preserveWatchOutput"
23
23
  },
24
24
  "dependencies": {
25
- "@paroicms/internal-anywhere-lib": "1.35.8",
26
- "@paroicms/public-anywhere-lib": "0.38.3",
27
- "@paroicms/script-lib": "0.3.8",
25
+ "@paroicms/internal-anywhere-lib": "1.36.0",
26
+ "@paroicms/public-anywhere-lib": "0.40.0",
27
+ "@paroicms/script-lib": "0.3.10",
28
28
  "@typeonly/validator": "~1.1.2",
29
29
  "arktype": "~2.1.27"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "~24.10.1",
33
- "rimraf": "~6.1.0",
33
+ "rimraf": "~6.1.2",
34
34
  "typeonly": "~1.1.3",
35
35
  "typescript": "~5.9.3",
36
- "vitest": "~4.0.10"
36
+ "vitest": "~4.0.13"
37
37
  },
38
38
  "files": [
39
39
  "dist",
40
+ "docs",
40
41
  "types",
41
42
  "typeonly"
42
43
  ]
@@ -1,19 +1,19 @@
1
1
  import type {
2
2
  HomeRoutingCluster,
3
3
  JsonFieldValue,
4
+ MAttachedData,
4
5
  MImageVariant,
5
6
  MSourceImage,
6
7
  MSourceMedia,
7
8
  Obj,
8
- ParsedLNodeId,
9
9
  ReadFieldValue,
10
+ ReadFieldValues,
10
11
  ResizeRule,
11
- ScFieldDataType,
12
12
  ScFieldType,
13
13
  ScSiteSchema,
14
14
  ThemeConf,
15
15
  UpdateFieldValue,
16
- UpdateLabelingFieldValue,
16
+ UpdateFieldValues,
17
17
  WithAttachedData,
18
18
  } from "@paroicms/public-anywhere-lib";
19
19
  import type Stream from "node:stream";
@@ -112,6 +112,10 @@ export interface BackendPluginInitService extends PluginStaticConfiguration {
112
112
  >,
113
113
  ): void;
114
114
  registerHook(hookName: "sendMail", handler: BackendHookHandler<MailData, undefined, void>): void;
115
+ registerHook(
116
+ hookName: "markdownToNative",
117
+ handler: BackendHookHandler<string, { language: string }, JsonFieldValue | string>,
118
+ ): void;
115
119
  registerRenderingHook(hookName: "fieldPreprocessor", handler: RenderingHookHandler): void;
116
120
  setPublicApiHandler(handler: PublicApiHandler): void;
117
121
  /** @deprecated Use `registerHeadTags` instead. */
@@ -132,10 +136,10 @@ export type BackendHookHandler<V = unknown, O = unknown, R = unknown> = (hookPay
132
136
  options: O;
133
137
  }) => Promise<R> | R;
134
138
 
135
- export type RenderingHookHandler = (hookPayload: {
139
+ export type RenderingHookHandler<V extends ReadFieldValue = ReadFieldValue> = (hookPayload: {
136
140
  service: PluginRenderingService;
141
+ value: V;
137
142
  options: RenderingHookOptions;
138
- value: ReadFieldValue;
139
143
  }) => ReadFieldValue | undefined | Promise<ReadFieldValue | undefined>;
140
144
 
141
145
  export interface RenderingHookOptions {
@@ -196,8 +200,9 @@ export interface BackendPluginService extends PluginStaticConfiguration {
196
200
  ): Promise<unknown> | unknown;
197
201
  registeredSite: RegisteredSite;
198
202
  pluginAssetsUrl: string;
199
- /** This is the connector of the running instance of ParoiCMS. */
200
- connector: RunningServerConnector;
203
+ getSiteConnector(input: { pat: string }): RunningSiteConnector;
204
+ getUnsafeSiteConnector(input: { fqdn: string }): RunningSiteConnector;
205
+ getServerConnector(): RunningServerConnector;
201
206
  getSiteFieldValue: (options: {
202
207
  fieldName: string;
203
208
  language?: string;
@@ -359,39 +364,163 @@ export interface SubDomainSitePackConfiguration extends SitePackConfigurationBas
359
364
 
360
365
  /* Running instance types */
361
366
 
367
+ export interface RunningSiteConnector {
368
+ loadSiteSchemaAndIds(): Promise<RiSiteSchemaAndIds>;
369
+ getSiteInfo(): Promise<SiteInfo>;
370
+ createAccount(account: RiNewAccount, options?: { asContactEmail?: boolean }): Promise<string>;
371
+ updateSiteFields(language: string, values: UpdateFieldValues): Promise<void>;
372
+ removeSite: () => Promise<void>;
373
+ searchDocuments(input: {
374
+ language: string;
375
+ words: string[];
376
+ limit?: number;
377
+ offset?: number;
378
+ }): Promise<{
379
+ items: DocumentInfo[];
380
+ total?: number;
381
+ }>;
382
+ deleteDocument(documentId: string): Promise<void>;
383
+ publishDocument(documentId: string, publishDate?: string): Promise<void>;
384
+ unpublishDocument(documentId: string): Promise<void>;
385
+ getDocument(documentId: string): Promise<FullDocument>;
386
+ updateDocument(documentId: string, values: UpdateDocumentValues): Promise<void>;
387
+ updateFields(lNodeId: string, values: UpdateFieldValues): Promise<void>;
388
+ createDocument(input: CreateDocumentInput): Promise<MinimalDocumentInfo>;
389
+ createDocumentTranslation(input: CreateDocumentTranslationInput): Promise<MinimalDocumentInfo>;
390
+ createPart(input: CreatePartInput): Promise<MinimalPartInfo>;
391
+ createPartTranslation(input: CreatePartTranslationInput): Promise<MinimalPartInfo>;
392
+ setMedia(input: SetMediaInput): Promise<MSourceMedia>;
393
+ }
394
+
395
+ export interface MinimalDocumentInfo {
396
+ documentId: string;
397
+ nodeId: string;
398
+ parentNodeId: string;
399
+ relativeId: string;
400
+ typeName: string;
401
+ /** ISO 8601 date string */
402
+ publishDate?: string;
403
+ /** If `false`, then it's a draft */
404
+ ready: boolean;
405
+ language: string;
406
+ title?: string;
407
+ slug?: string;
408
+ }
409
+
410
+ export interface SiteInfo {
411
+ siteNodeId: string;
412
+ title: { [language: string]: string | undefined };
413
+ siteSchema: ScSiteSchema;
414
+ mainCluster: ClusterNodeInfo;
415
+ }
416
+
417
+ export interface ClusterNodeInfo {
418
+ nodeId: string;
419
+ typeName: string;
420
+ relativeId?: string;
421
+ /** ISO 8601 date string */
422
+ publishDate?: string;
423
+ availableIn: { [language: string]: MinimalDocumentClusterInfo };
424
+ children?: { [typeName: string]: ClusterNodeInfo };
425
+ }
426
+
427
+ export interface MinimalDocumentClusterInfo {
428
+ documentId: string;
429
+ language: string;
430
+ /** If `false`, then it's a draft */
431
+ ready: boolean;
432
+ title?: string;
433
+ slug?: string;
434
+ }
435
+
436
+ export interface MinimalPartInfo {
437
+ partId: string;
438
+ nodeId: string;
439
+ parentNodeId: string;
440
+ relativeId: string;
441
+ typeName: string;
442
+ listName: string;
443
+ /** ISO 8601 date string */
444
+ publishDate?: string;
445
+ ready: boolean;
446
+ language: string;
447
+ }
448
+
449
+ export interface DocumentInfo extends MinimalDocumentInfo {
450
+ /** Absolute URL, only present when document is published (ready & publishDate in the past) */
451
+ url?: string;
452
+ relatedTerms: RelatedTermsInfo;
453
+ }
454
+
455
+ export interface RelatedTermsInfo {
456
+ [fieldName: string]: {
457
+ taxonomyTypeName: string;
458
+ terms: MinimalDocumentInfo[];
459
+ };
460
+ }
461
+
462
+ export interface UpdateDocumentValues {
463
+ title?: string;
464
+ slug?: string;
465
+ metaDescription?: string;
466
+ metaKeywords?: string;
467
+ }
468
+
469
+ export interface CreateDocumentInput {
470
+ parentLNodeId: string;
471
+ typeName: string;
472
+ title?: string;
473
+ slug?: string;
474
+ values?: UpdateFieldValues;
475
+ }
476
+
477
+ export interface CreatePartInput {
478
+ parentLNodeId: string;
479
+ typeName: string;
480
+ values?: UpdateFieldValues;
481
+ }
482
+
483
+ export interface CreateDocumentTranslationInput {
484
+ nodeId: string;
485
+ language: string;
486
+ title?: string;
487
+ slug?: string;
488
+ values?: UpdateFieldValues;
489
+ }
490
+
491
+ export interface CreatePartTranslationInput {
492
+ nodeId: string;
493
+ language: string;
494
+ values?: UpdateFieldValues;
495
+ }
496
+
497
+ export interface SetMediaInput {
498
+ /** The media handle - use helper functions to compute this */
499
+ handle: string;
500
+ /** Local file path to the media file */
501
+ filePath: string;
502
+ /** Optional attached data (caption, credit, etc.) */
503
+ attachedData?: MAttachedData;
504
+ /** If true, replaces existing media at this handle. If false (default), adds to handle (for galleries) */
505
+ replace?: boolean;
506
+ }
507
+
508
+ export interface FullDocument extends DocumentInfo {
509
+ fieldValues: ReadFieldValues;
510
+ parts: {
511
+ [listName: string]: FullPart[];
512
+ };
513
+ }
514
+
515
+ export interface FullPart extends MinimalPartInfo {
516
+ fieldValues: ReadFieldValues;
517
+ children?: FullPart[];
518
+ }
519
+
362
520
  export interface RunningServerConnector {
363
521
  getSitePackConf(packName: string): SitePackConfiguration;
364
- loadSiteSchemaAndIds(fqdn: string): Promise<RiSiteSchemaAndIds>;
365
- createAccount(
366
- fqdn: string,
367
- account: RiNewAccount,
368
- options?: { asContactEmail?: boolean },
369
- ): Promise<string>;
370
- updateSiteFields(fqdn: string, fields: RiFieldSetContent): Promise<void>;
371
- updateNodeContent(
372
- fqdn: string,
373
- options: {
374
- nodeId: string;
375
- content: RiNodeContent;
376
- },
377
- ): Promise<void>;
378
- addMultipleDocumentContents(
379
- fqdn: string,
380
- options: {
381
- parentNodeId: string;
382
- contents: RiDocumentContent[];
383
- },
384
- ): Promise<ParsedLNodeId[]>;
385
- addMultiplePartContents(
386
- fqdn: string,
387
- options: {
388
- parentNodeId: string;
389
- contents: RiPartContent[];
390
- },
391
- ): Promise<ParsedLNodeId[]>;
392
- registerNewSite: (options: NewSiteOptions) => Promise<RegisteredSite>;
393
- removeSite: (fqdn: string) => Promise<void>;
394
522
  migrateSiteSchemas(): Promise<void>;
523
+ registerNewSite: (options: NewSiteOptions) => Promise<RegisteredSite>;
395
524
  createBlankSiteFromExisting(options: CreateBlankSiteOptions): Promise<void>;
396
525
  }
397
526
 
@@ -421,66 +550,3 @@ export interface RiExternalNewAccount {
421
550
  name: string;
422
551
  roles: string[];
423
552
  }
424
-
425
- export type RiNodeContent = RiDocumentContent | RiPartContent;
426
-
427
- export interface RiDocumentContent {
428
- kind: "document";
429
- typeName: string;
430
- title?: { [language: string]: string };
431
- featuredImage?: RiMediaValue;
432
- fields: RiFieldSetContent;
433
- }
434
-
435
- export interface RiPartContent {
436
- kind: "part";
437
- typeName: string;
438
- fields: RiFieldSetContent;
439
- }
440
-
441
- export interface RiFieldSetContent {
442
- [fieldName: string]: RiFieldContent;
443
- }
444
-
445
- export type RiFieldContent =
446
- | RiStringContent
447
- | RiNumberContent
448
- | RiBooleanContent
449
- | RiJsonContent
450
- | RiMediaContent
451
- | RiGalleryContent
452
- | RiLabelingContent;
453
-
454
- export type RiStringContent = RiFieldContentTemplate<"string", string>;
455
- export type RiNumberContent = RiFieldContentTemplate<"number", number>;
456
- export type RiBooleanContent = RiFieldContentTemplate<"boolean", boolean>;
457
- export type RiJsonContent = RiFieldContentTemplate<"json", JsonFieldValue>;
458
- export type RiMediaContent = RiFieldContentTemplate<"media", RiMediaValue>;
459
- export type RiGalleryContent = RiFieldContentTemplate<"gallery", RiGalleryValue>;
460
- export type RiLabelingContent = RiUnlocalizedFieldContent<"labeling", UpdateLabelingFieldValue>;
461
-
462
- export type RiFieldContentTemplate<T extends ScFieldDataType, V> =
463
- | RiLocalizedFieldContent<T, V>
464
- | RiUnlocalizedFieldContent<T, V>;
465
-
466
- export interface RiLocalizedFieldContent<T extends ScFieldDataType, V> {
467
- dataType: T;
468
- localized: true;
469
- value: {
470
- [language: string]: V | null;
471
- };
472
- }
473
-
474
- export interface RiUnlocalizedFieldContent<T extends ScFieldDataType, V> {
475
- dataType: T;
476
- localized: false;
477
- value: V | null;
478
- }
479
-
480
- export interface RiMediaValue {
481
- file: string;
482
- }
483
-
484
- export interface RiGalleryValue {
485
- files: string[];
486
- }