@webiny/api-headless-cms-ddb-es
Version:
DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.
70 lines (69 loc) • 1.29 kB
JavaScript
import { parseIdentifier, zeroPad } from "@webiny/utils";
export const createPartitionKey = params => {
const {
tenant,
id: initialId
} = params;
const {
id
} = parseIdentifier(initialId);
return `T#${tenant}#CMS#CME#${id}`;
};
export const createRevisionSortKey = params => {
return `REV#${zeroPad(params.version)}`;
};
export const createLatestSortKey = () => {
return "L";
};
export const createPublishedSortKey = () => {
return "P";
};
export const createEntryPublishedKeys = params => {
const {
id,
tenant
} = params;
return {
PK: createPartitionKey({
id,
tenant
}),
SK: createPublishedSortKey(),
TYPE: `cms.entry.p`,
GSI_TENANT: tenant
};
};
export const createEntryLatestKeys = params => {
const {
id,
tenant
} = params;
return {
PK: createPartitionKey({
id,
tenant
}),
SK: createLatestSortKey(),
TYPE: `cms.entry.l`,
GSI_TENANT: tenant
};
};
export const createEntryRevisionKeys = params => {
const {
id,
tenant,
version
} = params;
return {
PK: createPartitionKey({
id,
tenant
}),
SK: createRevisionSortKey({
version
}),
TYPE: `cms.entry`,
GSI_TENANT: tenant
};
};
//# sourceMappingURL=keys.js.map