diff --git a/README.md b/README.md index d16a8e8..b53bcaa 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ The default file looks like this: ```yml projects: [] variants: [] +statuses: [] components: folders: [] outputs: diff --git a/lib/src/commands/pull.test.ts b/lib/src/commands/pull.test.ts index 1970675..215e3ea 100644 --- a/lib/src/commands/pull.test.ts +++ b/lib/src/commands/pull.test.ts @@ -21,7 +21,7 @@ const createMockTextItem = (overrides: Partial = {}) => ({ id: "text-1", text: "Plain text content", richText: "

Rich HTML content

", - status: "active", + status: "FINAL", notes: "", tags: [], variableIds: [], @@ -34,7 +34,7 @@ const createMockComponent = (overrides: Partial = {}) => ({ id: "component-1", text: "Plain text content", richText: "

Rich HTML content

", - status: "active", + status: "FINAL", notes: "", tags: [], variableIds: [], diff --git a/lib/src/formatters/json.ts b/lib/src/formatters/json.ts index 8c189f3..f52ebab 100644 --- a/lib/src/formatters/json.ts +++ b/lib/src/formatters/json.ts @@ -89,6 +89,7 @@ export default class JSONFormatter extends applyMixins( let filters: PullFilters = { projects: this.projectConfig.projects, variants: this.projectConfig.variants, + statuses: this.projectConfig.statuses }; if (this.output.projects) { @@ -99,6 +100,10 @@ export default class JSONFormatter extends applyMixins( filters.variants = this.output.variants; } + if (this.output.statuses) { + filters.statuses = this.output.statuses; + } + return filters; } @@ -106,6 +111,7 @@ export default class JSONFormatter extends applyMixins( let filters: PullFilters = { ...(this.projectConfig.components?.folders && { folders: this.projectConfig.components.folders }), variants: this.projectConfig.variants, + statuses: this.projectConfig.statuses }; if (this.output.components) { @@ -116,6 +122,10 @@ export default class JSONFormatter extends applyMixins( filters.variants = this.output.variants; } + if (this.output.statuses) { + filters.statuses = this.output.statuses; + } + return filters; } diff --git a/lib/src/http/components.test.ts b/lib/src/http/components.test.ts index acd3698..1521345 100644 --- a/lib/src/http/components.test.ts +++ b/lib/src/http/components.test.ts @@ -24,7 +24,7 @@ describe("fetchComponents", () => { id: "text1", text: "Plain text", richText: "

Rich HTML text

", - status: "active", + status: "FINAL", notes: "Test note", tags: ["tag1"], variableIds: ["var1"], @@ -53,7 +53,7 @@ describe("fetchComponents", () => { { id: "text1", text: "Plain text only", - status: "active", + status: "FINAL", notes: "", tags: [], variableIds: [], diff --git a/lib/src/http/textItems.test.ts b/lib/src/http/textItems.test.ts index d2a7e22..f1054ee 100644 --- a/lib/src/http/textItems.test.ts +++ b/lib/src/http/textItems.test.ts @@ -24,7 +24,7 @@ describe("fetchText", () => { id: "text1", text: "Plain text", richText: "

Rich HTML text

", - status: "active", + status: "FINAL", notes: "Test note", tags: ["tag1"], variableIds: ["var1"], @@ -49,7 +49,7 @@ describe("fetchText", () => { id: "text1", text: "Plain text", richText: "

Rich HTML text

", - status: "active", + status: "FINAL", notes: "Test note", tags: ["tag1"], variableIds: ["var1"], @@ -65,7 +65,7 @@ describe("fetchText", () => { { id: "text1", text: "Plain text only", - status: "active", + status: "FINAL", notes: "", tags: [], variableIds: [], @@ -90,7 +90,7 @@ describe("fetchText", () => { id: "text1", text: "Plain text only", richText: undefined, - status: "active", + status: "FINAL", notes: "", tags: [], variableIds: [], diff --git a/lib/src/http/types.ts b/lib/src/http/types.ts index bd11c07..218d600 100644 --- a/lib/src/http/types.ts +++ b/lib/src/http/types.ts @@ -7,12 +7,15 @@ export interface PullFilters { excludeNestedFolders?: boolean; }[]; variants?: { id: string }[]; + statuses?: ITextStatus[]; } export interface PullQueryParams { filter: string; // Stringified PullFilters richText?: "html"; } +export const ZTextStatus = z.enum(["NONE", "WIP", "REVIEW", "FINAL"]); +export type ITextStatus = z.infer; const ZBaseTextEntity = z.object({ id: z.string(), diff --git a/lib/src/outputs/shared.ts b/lib/src/outputs/shared.ts index cd23afa..b43f89c 100644 --- a/lib/src/outputs/shared.ts +++ b/lib/src/outputs/shared.ts @@ -1,4 +1,5 @@ import { z } from "zod"; +import { ZTextStatus } from "../http/types"; /** * These filters that are common to all outputs, used to filter the text items and components that are fetched from the API. @@ -6,12 +7,19 @@ import { z } from "zod"; */ export const ZBaseOutputFilters = z.object({ projects: z.array(z.object({ id: z.string() })).optional(), - components: z.object({ - folders: z.array(z.object({ - id: z.string(), - excludeNestedFolders: z.boolean().optional(), - })).optional(), - }).optional(), + components: z + .object({ + folders: z + .array( + z.object({ + id: z.string(), + excludeNestedFolders: z.boolean().optional(), + }) + ) + .optional(), + }) + .optional(), + statuses: z.array(ZTextStatus).optional(), variants: z.array(z.object({ id: z.string() })).optional(), outDir: z.string().optional(), richText: z.union([z.literal("html"), z.literal(false)]).optional(), diff --git a/lib/src/services/projectConfig.ts b/lib/src/services/projectConfig.ts index eef4bec..2b10549 100644 --- a/lib/src/services/projectConfig.ts +++ b/lib/src/services/projectConfig.ts @@ -16,6 +16,7 @@ export type ProjectConfigYAML = z.infer; export const DEFAULT_PROJECT_CONFIG_JSON: ProjectConfigYAML = { projects: [], variants: [], + statuses: [], components: { folders: [], }, diff --git a/package.json b/package.json index 6a210bf..86d06a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dittowords/cli", - "version": "5.1.0", + "version": "5.2.0", "description": "Command Line Interface for Ditto (dittowords.com).", "license": "MIT", "main": "bin/ditto.js",