Skip to content

TypeScript API / laikacms/catalog-convention / ConventionCatalogProvider

Class: ConventionCatalogProvider ​

Source of truth for catalog configuration — collection settings, media settings, and per-collection JSON Schemas.

Cache-key stability invariant: for a given persisted catalog state, getDocumentCollectionSettings(collection).directory and getMediaCollectionSettings(collection).directory are pure, stable functions of the collection argument. Two provider instances pointed at the same underlying storage MUST return identical directory values for the same collection key — both within a single process and across rolling deploys.

This guarantee exists so consumers (e.g. CachedStorageRepository, webhook-invalidators) can safely derive cache keys from provider output without risking invalidation desync between replicas running different code versions.

Implementations that violate this invariant (e.g. by injecting a non-deterministic prefix) must document the deviation explicitly.

Extends ​

Constructors ​

Constructor ​

ts
new ConventionCatalogProvider(options): ConventionCatalogProvider;

Parameters ​

ParameterType
optionsConventionCatalogProviderOptions

Returns ​

ConventionCatalogProvider

Overrides ​

CatalogProvider.constructor

Methods ​

getCatalog() ​

ts
getCatalog(): LaikaTask<{
  collections?: {
   [key: string]: 
     | {
     directory?: string;
     documentDescriptionKey?: string;
     documentStatusKey?: string;
     documentTitleKey?: string;
     format?: string & Brand<"StorageFormat">;
     key: string;
     name?: string;
     recursive?: boolean;
     revisionDirectory?: string;
     type: "document";
     unpublishedStatuses?: {
      [key: string]: object;
     };
   }
     | {
     accept?: readonly string[];
     directory?: string;
     key: string;
     name?: string;
     pathFormat?: string;
     recursive?: boolean;
     type: "media";
     url?: string;
   };
  };
}>;

Returns ​

LaikaTask<{ collections?: { [key: string]: | { directory?: string; documentDescriptionKey?: string; documentStatusKey?: string; documentTitleKey?: string; format?: string & Brand<"StorageFormat">; key: string; name?: string; recursive?: boolean; revisionDirectory?: string; type: "document"; unpublishedStatuses?: { [key: string]: object; }; } | { accept?: readonly string[]; directory?: string; key: string; name?: string; pathFormat?: string; recursive?: boolean; type: "media"; url?: string; }; }; }>

Overrides ​

CatalogProvider.getCatalog


getCollectionSchema() ​

ts
getCollectionSchema(collection): LaikaTask<JSONSchema7>;

Parameters ​

ParameterType
collectionstring

Returns ​

LaikaTask<JSONSchema7>

Overrides ​

CatalogProvider.getCollectionSchema


getDocumentCollectionSettings() ​

ts
getDocumentCollectionSettings(collection): LaikaTask<{
  directory?: string;
  documentDescriptionKey?: string;
  documentStatusKey?: string;
  documentTitleKey?: string;
  format?: string & Brand<"StorageFormat">;
  key: string;
  name?: string;
  recursive?: boolean;
  revisionDirectory?: string;
  type: "document";
  unpublishedStatuses?: {
   [key: string]: object;
  };
}>;

Returns settings for a document collection. If the collection is not explicitly configured, a deterministic default derived solely from the collection key is returned (stable across instances — see class-level cache-key stability invariant).

Parameters ​

ParameterType
collectionstring

Returns ​

LaikaTask<{ directory?: string; documentDescriptionKey?: string; documentStatusKey?: string; documentTitleKey?: string; format?: string & Brand<"StorageFormat">; key: string; name?: string; recursive?: boolean; revisionDirectory?: string; type: "document"; unpublishedStatuses?: { [key: string]: object; }; }>

Overrides ​

CatalogProvider.getDocumentCollectionSettings


getMediaCollectionSettings() ​

ts
getMediaCollectionSettings(collection): LaikaTask<{
  accept?: readonly string[];
  directory?: string;
  key: string;
  name?: string;
  pathFormat?: string;
  recursive?: boolean;
  type: "media";
  url?: string;
}>;

Returns settings for a media collection. If the collection is not explicitly configured, a deterministic default derived solely from the collection key is returned (stable across instances — see class-level cache-key stability invariant).

Parameters ​

ParameterType
collectionstring

Returns ​

LaikaTask<{ accept?: readonly string[]; directory?: string; key: string; name?: string; pathFormat?: string; recursive?: boolean; type: "media"; url?: string; }>

Overrides ​

CatalogProvider.getMediaCollectionSettings


putCatalog() ​

ts
putCatalog(settings): LaikaTask<void>;

Parameters ​

ParameterType
settings{ collections?: { [key: string]: | { directory?: string; documentDescriptionKey?: string; documentStatusKey?: string; documentTitleKey?: string; format?: string & Brand<"StorageFormat">; key: string; name?: string; recursive?: boolean; revisionDirectory?: string; type: "document"; unpublishedStatuses?: { [key: string]: object; }; } | { accept?: readonly string[]; directory?: string; key: string; name?: string; pathFormat?: string; recursive?: boolean; type: "media"; url?: string; }; }; }
settings.collections?{ [key: string]: | { directory?: string; documentDescriptionKey?: string; documentStatusKey?: string; documentTitleKey?: string; format?: string & Brand<"StorageFormat">; key: string; name?: string; recursive?: boolean; revisionDirectory?: string; type: "document"; unpublishedStatuses?: { [key: string]: object; }; } | { accept?: readonly string[]; directory?: string; key: string; name?: string; pathFormat?: string; recursive?: boolean; type: "media"; url?: string; }; }

Returns ​

LaikaTask<void>

Overrides ​

CatalogProvider.putCatalog


putCollectionSchema() ​

ts
putCollectionSchema(collection, schema): LaikaTask<void>;

Parameters ​

ParameterType
collectionstring
schemaJSONSchema7

Returns ​

LaikaTask<void>

Overrides ​

CatalogProvider.putCollectionSchema


putDocumentCollectionSettings() ​

ts
putDocumentCollectionSettings(collection, settings): LaikaTask<void>;

Parameters ​

ParameterTypeDescription
collectionstring-
settings{ directory?: string; documentDescriptionKey?: string; documentStatusKey?: string; documentTitleKey?: string; format?: string & Brand<"StorageFormat">; key: string; name?: string; recursive?: boolean; revisionDirectory?: string; type: "document"; unpublishedStatuses?: { [key: string]: object; }; }-
settings.directory?string-
settings.documentDescriptionKey?string-
settings.documentStatusKey?string-
settings.documentTitleKey?string-
settings.format?string & Brand<"StorageFormat">-
settings.keystring-
settings.name?string-
settings.recursive?boolean-
settings.revisionDirectory?stringDirectory for storing revisions (version history)
settings.type"document"-
settings.unpublishedStatuses?{ [key: string]: object; }Map of unpublished status values to their configuration The key is the status value stored in the 'unpublished' document type's 'status' field Documents with these statuses are stored in .laika/[collection]/[status.directory]

Returns ​

LaikaTask<void>

Overrides ​

CatalogProvider.putDocumentCollectionSettings


putMediaCollectionSettings() ​

ts
putMediaCollectionSettings(collection, settings): LaikaTask<void>;

Parameters ​

ParameterType
collectionstring
settings{ accept?: readonly string[]; directory?: string; key: string; name?: string; pathFormat?: string; recursive?: boolean; type: "media"; url?: string; }
settings.accept?readonly string[]
settings.directory?string
settings.keystring
settings.name?string
settings.pathFormat?string
settings.recursive?boolean
settings.type"media"
settings.url?string

Returns ​

LaikaTask<void>

Overrides ​

CatalogProvider.putMediaCollectionSettings

Released under the MIT License.