Compare commits

..

1 Commits

Author SHA1 Message Date
Tom Moor b77f5b9fb2 fix: withoutState scope should include state as fallback 2025-05-07 08:52:59 -04:00
4 changed files with 16 additions and 26 deletions
+10 -11
View File
@@ -72,20 +72,12 @@ import Length from "./validators/Length";
export const DOCUMENT_VERSION = 2;
// If content (JSON) is null then we still need to return the state column (BINARY)
// as it's used as a fallback for content deserialization for older documents.
// This can be removed if content is 100% backfilled.
const stateIfContentEmpty = Sequelize.literal(
`CASE WHEN document.content IS NULL THEN document.state ELSE NULL END AS state`
);
type AdditionalFindOptions = {
userId?: string;
includeState?: boolean;
rejectOnEmpty?: boolean | Error;
};
// @ts-expect-error Type 'Literal' is not assignable to type 'string | ProjectionAlias'.
@DefaultScope(() => ({
include: [
{
@@ -110,14 +102,21 @@ type AdditionalFindOptions = {
},
},
attributes: {
include: [stateIfContentEmpty],
exclude: ["state"],
},
}))
// @ts-expect-error Type 'Literal' is not assignable to type 'string | ProjectionAlias'.
@Scopes(() => ({
withoutState: {
attributes: {
include: [stateIfContentEmpty],
include: [
Sequelize.literal(
// If content (JSON) is null then we still need to return the state column (BINARY)
// as it's used as a fallback for content deserialization for older documents.
// This can be removed if content is 100% backfilled.
`CASE WHEN document.content IS NULL THEN document.state ELSE NULL END AS state`
),
],
},
},
withCollection: {
@@ -131,7 +130,7 @@ type AdditionalFindOptions = {
withState: {
attributes: {
// resets to include the state column
include: [],
exclude: [],
},
},
withDrafts: {
@@ -171,8 +171,7 @@ export default abstract class ExportDocumentTreeTask extends ExportTask {
/**
* Generates a map of document urls to their path in the zip file.
*
* @param collections The collections to generate the path map for.
* @param format The format of the exported documents.
* @param collections
*/
private createPathMap(
collections: Collection[],
+5 -7
View File
@@ -44,13 +44,11 @@ export default abstract class ExportTask extends BaseTask<Props> {
? [fileOperation.collectionId]
: await user.collectionIds();
const collections = await Collection.scope("withDocumentStructure").findAll(
{
where: {
id: collectionIds,
},
}
);
const collections = await Collection.findAll({
where: {
id: collectionIds,
},
});
let filePath: string | undefined;
-6
View File
@@ -198,12 +198,6 @@ export const codeLanguages: Record<string, CodeLanguage> = {
label: "Powershell",
loader: () => import("refractor/lang/powershell").then((m) => m.default),
},
promql: {
lang: "promql",
label: "PromQL",
// @ts-expect-error PromQL is not in types but exists
loader: () => import("refractor/lang/promql").then((m) => m.default),
},
protobuf: {
lang: "protobuf",
label: "Protobuf",