@financial-times/content-curation-client 4.0.0 → 4.1.0
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.
- package/dist/_tsup-dts-rollup.d.cts +2793 -5
- package/dist/_tsup-dts-rollup.d.ts +2793 -5
- package/dist/index.cjs +57 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +105 -70
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -278,11 +278,56 @@ var HomepageStructureOutputSchema = PageStructureOutputSchema.extend({
|
|
|
278
278
|
})
|
|
279
279
|
});
|
|
280
280
|
|
|
281
|
+
// src/schemas/ftpink/draft/index.ts
|
|
282
|
+
|
|
283
|
+
var DraftContributorInputSchema = _zod.z.object({
|
|
284
|
+
userId: _zod.z.string().min(1),
|
|
285
|
+
displayName: _zod.z.string().min(1),
|
|
286
|
+
email: _zod.z.string().email().optional()
|
|
287
|
+
});
|
|
288
|
+
var DraftContributorSchema = DraftContributorInputSchema.extend({
|
|
289
|
+
userId: _zod.z.string().min(1),
|
|
290
|
+
displayName: _zod.z.string().min(1),
|
|
291
|
+
firstTouchedAt: _zod.z.string().datetime(),
|
|
292
|
+
lastTouchedAt: _zod.z.string().datetime()
|
|
293
|
+
});
|
|
294
|
+
var DraftMetadataSchema = _zod.z.object({
|
|
295
|
+
draftId: _zod.z.string().uuid(),
|
|
296
|
+
createdAt: _zod.z.string().datetime(),
|
|
297
|
+
updatedAt: _zod.z.string().datetime(),
|
|
298
|
+
contributors: _zod.z.array(DraftContributorSchema)
|
|
299
|
+
});
|
|
300
|
+
var PageDraftSchema = DraftMetadataSchema.extend({
|
|
301
|
+
structure: PageStructureOutputSchema
|
|
302
|
+
});
|
|
303
|
+
var HomepageDraftSchema = DraftMetadataSchema.extend({
|
|
304
|
+
structure: HomepageStructureOutputSchema
|
|
305
|
+
});
|
|
306
|
+
var DraftSchema = _zod.z.union([PageDraftSchema, HomepageDraftSchema]);
|
|
307
|
+
var PersistPageDraftInputSchema = _zod.z.object({
|
|
308
|
+
structure: PageStructureInputSchema,
|
|
309
|
+
contributor: DraftContributorInputSchema
|
|
310
|
+
});
|
|
311
|
+
var PersistHomepageDraftInputSchema = _zod.z.object({
|
|
312
|
+
structure: HomepageStructureInputSchema,
|
|
313
|
+
contributor: DraftContributorInputSchema
|
|
314
|
+
});
|
|
315
|
+
|
|
281
316
|
// src/homepage.ts
|
|
282
317
|
var HomepageClient = class extends BaseApiClient {
|
|
283
318
|
async getStructure(pageId) {
|
|
284
319
|
return this.get(`/v1/homepage/${pageId}/structure`, HomepageStructureOutputSchema);
|
|
285
320
|
}
|
|
321
|
+
async getDraft(pageId) {
|
|
322
|
+
try {
|
|
323
|
+
return await this.get(`/v1/homepage/${pageId}/draft`, HomepageDraftSchema);
|
|
324
|
+
} catch (error) {
|
|
325
|
+
if (error instanceof ApiClientError && error.code === "NOT_FOUND") {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
throw error;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
286
331
|
async getStructuresByHomepageListId(homepageListId) {
|
|
287
332
|
return this.get(
|
|
288
333
|
`/v1/homepage/list/${homepageListId}/structures`,
|
|
@@ -378,6 +423,16 @@ var PageClient = class extends BaseApiClient {
|
|
|
378
423
|
async getStructure(pageId) {
|
|
379
424
|
return this.get(`/v1/page/${pageId}/structure`, PageStructureOutputSchema);
|
|
380
425
|
}
|
|
426
|
+
async getDraft(pageId) {
|
|
427
|
+
try {
|
|
428
|
+
return await this.get(`/v1/page/${pageId}/draft`, PageDraftSchema);
|
|
429
|
+
} catch (error) {
|
|
430
|
+
if (error instanceof ApiClientError && error.code === "NOT_FOUND") {
|
|
431
|
+
return null;
|
|
432
|
+
}
|
|
433
|
+
throw error;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
381
436
|
async getLegacyHubPageStructure(pageId) {
|
|
382
437
|
return this.get(`/v1/page/${pageId}/legacyHubPageStructure`, LegacyPageStructureOutputSchema);
|
|
383
438
|
}
|
|
@@ -405,28 +460,7 @@ var ApiClient = class extends BaseApiClient {
|
|
|
405
460
|
}
|
|
406
461
|
};
|
|
407
462
|
|
|
408
|
-
// src/schemas/ftpink/draft/index.ts
|
|
409
463
|
|
|
410
|
-
var DraftContributorSchema = _zod.z.object({
|
|
411
|
-
userId: _zod.z.string().min(1),
|
|
412
|
-
displayName: _zod.z.string().min(1),
|
|
413
|
-
email: _zod.z.string().email().optional(),
|
|
414
|
-
firstTouchedAt: _zod.z.string().datetime(),
|
|
415
|
-
lastTouchedAt: _zod.z.string().datetime()
|
|
416
|
-
});
|
|
417
|
-
var DraftMetadataSchema = _zod.z.object({
|
|
418
|
-
draftId: _zod.z.string().uuid(),
|
|
419
|
-
createdAt: _zod.z.string().datetime(),
|
|
420
|
-
updatedAt: _zod.z.string().datetime(),
|
|
421
|
-
contributors: _zod.z.array(DraftContributorSchema)
|
|
422
|
-
});
|
|
423
|
-
var PageDraftSchema = DraftMetadataSchema.extend({
|
|
424
|
-
structure: PageStructureOutputSchema
|
|
425
|
-
});
|
|
426
|
-
var HomepageDraftSchema = DraftMetadataSchema.extend({
|
|
427
|
-
structure: HomepageStructureOutputSchema
|
|
428
|
-
});
|
|
429
|
-
var DraftSchema = _zod.z.union([PageDraftSchema, HomepageDraftSchema]);
|
|
430
464
|
|
|
431
465
|
|
|
432
466
|
|
|
@@ -449,5 +483,6 @@ var DraftSchema = _zod.z.union([PageDraftSchema, HomepageDraftSchema]);
|
|
|
449
483
|
|
|
450
484
|
|
|
451
485
|
|
|
452
|
-
|
|
486
|
+
|
|
487
|
+
exports.ApiClient = ApiClient; exports.ApiClientError = ApiClientError; exports.ApiErrorCode = ApiErrorCode; exports.ApiErrorPayloadSchema = ApiErrorPayloadSchema; exports.ApiErrorResponseSchema = ApiErrorResponseSchema; exports.ApiResponseSchema = ApiResponseSchema; exports.ApiSuccessResponseSchema = ApiSuccessResponseSchema; exports.DraftContributorInputSchema = DraftContributorInputSchema; exports.DraftContributorSchema = DraftContributorSchema; exports.DraftSchema = DraftSchema; exports.HomepageClient = HomepageClient; exports.HomepageDraftSchema = HomepageDraftSchema; exports.HomepageStructureInputSchema = HomepageStructureInputSchema; exports.HomepageStructureOutputSchema = HomepageStructureOutputSchema; exports.LegacyPageStructureOutputSchema = LegacyPageStructureOutputSchema; exports.PageClient = PageClient; exports.PageDraftSchema = PageDraftSchema; exports.PageStructureInputSchema = PageStructureInputSchema; exports.PageStructureOutputSchema = PageStructureOutputSchema; exports.PersistHomepageDraftInputSchema = PersistHomepageDraftInputSchema; exports.PersistPageDraftInputSchema = PersistPageDraftInputSchema; exports.ProseMirrorDocSchema = ProseMirrorDocSchema; exports.SliceApiInputSchema = SliceApiInputSchema; exports.SliceApiOutputSchema = SliceApiOutputSchema;
|
|
453
488
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/circleci/repo/packages/content-curation-client/dist/index.cjs","../src/schemas/response.ts","../src/base.ts","../src/schemas/ftpink/page/index.ts","../src/schemas/prosemirror.ts","../src/homepage.ts","../src/schemas/ftpink/legacyHubPage/index.ts","../src/page.ts","../src/client.ts","../src/schemas/ftpink/draft/index.ts"],"names":[],"mappings":"AAAA;ACAA,0BAAmC;AAK5B,IAAM,aAAA,EAAe,MAAA,CAAE,IAAA,CAAK;AAAA,EAClC,cAAA;AAAA,EACA,WAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACD,CAAC,CAAA;AAKD,IAAM,mBAAA,EAAqB,MAAA,CAAE,MAAA,CAAO;AAAA,EACnC,UAAA,EAAY,MAAA,CAAE,MAAA,CAAO,CAAA;AAAA,EACrB,SAAA,EAAW,MAAA,CAAE,MAAA,CAAO;AACrB,CAAC,CAAA;AAKM,IAAM,sBAAA,EAAwB,MAAA,CACnC,MAAA,CAAO;AAAA,EACP,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D;AAC9C,EAAA;AACX;AAE6D;AAClD,EAAA;AACX;AAEwE;ATmZ6C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/circleci/repo/packages/content-curation-client/dist/index.cjs","sourcesContent":[null,"import { z, type ZodTypeAny } from \"zod\";\n\n/**\n * Strongly‐typed enum for all possible API error codes.\n */\nexport const ApiErrorCode = z.enum([\n\t\"UNAUTHORIZED\",\n\t\"NOT_FOUND\",\n\t\"INTERNAL_SERVER_ERROR\",\n\t\"INVALID_INPUT_DATA\",\n]);\n\n/**\n * Fields shared by both success and error envelopes (but not the discriminant).\n */\nconst BaseEnvelopeFields = z.object({\n\tstatusCode: z.number(),\n\trequestId: z.string(),\n});\n\n/**\n * Specific details carried in an error payload.\n */\nexport const ApiErrorPayloadSchema = z\n\t.object({\n\t\tcode: ApiErrorCode,\n\t\tmessage: z.string(),\n\t\tdetails: z.string().optional(),\n\t\tpath: z.string().optional(),\n\t\ttimestamp: z.string().optional(),\n\t})\n\t.strict();\n\nexport type ApiErrorPayload = z.infer<typeof ApiErrorPayloadSchema>;\n\n/**\n * Full “envelope” when the API has failed.\n */\nexport const ApiErrorResponseSchema = BaseEnvelopeFields.extend({\n\tstatus: z.literal(\"error\"),\n\terror: ApiErrorPayloadSchema,\n}).strict();\n\nexport type ApiErrorResponse = z.infer<typeof ApiErrorResponseSchema>;\n\n/**\n * Schema for a successful API response, given some data schema T.\n */\nexport function ApiSuccessResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\treturn BaseEnvelopeFields.extend({\n\t\tstatus: z.literal(\"success\"),\n\t\tdata: dataSchema,\n\t}).strict();\n}\n\n/**\n * Union of success or error envelopes, discriminated on `status`.\n */\nexport function ApiResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\tconst successSchema = ApiSuccessResponseSchema(dataSchema);\n\tconst errorSchema = ApiErrorResponseSchema;\n\treturn z.discriminatedUnion(\"status\", [successSchema, errorSchema]);\n}\n","import type { z, ZodTypeAny } from \"zod\";\nimport type { ApiErrorPayloadSchema } from \"./schemas/response\";\nimport { ApiResponseSchema } from \"./schemas/response\";\n\n/**\n * API-level error thrown when { status: 'error' } is returned\n */\nexport class ApiClientError extends Error {\n\tpublic code: string;\n\tpublic details?: string;\n\tpublic path?: string;\n\tpublic timestamp?: string;\n\n\tconstructor(\n\t\tpublic payload: z.infer<typeof ApiErrorPayloadSchema>,\n\t\tpublic statusCode: number,\n\t\tpublic requestId?: string,\n\t) {\n\t\tsuper(payload.message);\n\t\tthis.name = \"ApiError\";\n\t\tthis.code = payload.code;\n\t\tthis.details = payload.details;\n\t\tthis.path = payload.path;\n\t\tthis.timestamp = payload.timestamp;\n\t}\n}\n\n/**\n * Configuration options for the API client\n */\nexport type ApiClientConfig =\n\t| {\n\t\t\t// Standard configuration.\n\t\t\t// Intended for external clients using an API key issued via API Gateway.\n\t\t\tbaseUrl: string;\n\t\t\tapiKey: string;\n\t\t\tapiToken?: never;\n\t\t\tfetch?: typeof fetch;\n\t }\n\t| {\n\t\t\t// Alternative configuration.\n\t\t\t// Reserved for client with access to a bearer token (e.g. The e2e tests).\n\t\t\tbaseUrl: string;\n\t\t\tapiKey?: never;\n\t\t\tapiToken: string;\n\t\t\tfetch?: typeof fetch;\n\t };\n\nexport class BaseApiClient {\n\tprotected config: ApiClientConfig;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tthis.config = {\n\t\t\t...config,\n\t\t\tfetch: config.fetch || fetch,\n\t\t};\n\t\tthis.config.baseUrl = this.config.baseUrl.replace(/\\/+$/, \"\"); // strip trailing slashes\n\t}\n\n\t/**\n\t * Generic HTTP request to a JSON API\n\t */\n\tprotected async request<\n\t\tReqSchema extends ZodTypeAny | undefined,\n\t\tResponseDataSchema extends ZodTypeAny,\n\t>(\n\t\tmethod: \"GET\" | \"PUT\" | \"POST\" | \"DELETE\",\n\t\tpath: string,\n\t\topts: {\n\t\t\trequestSchema?: ReqSchema;\n\t\t\tbody?: ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown;\n\t\t\tresponseDataSchema: ResponseDataSchema;\n\t\t},\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\t// Validate request body if provided\n\t\tlet bodyPayload = opts.body;\n\t\tif (opts.requestSchema && opts.body !== undefined) {\n\t\t\tbodyPayload = opts.requestSchema.parse(opts.body);\n\t\t}\n\n\t\t// Build URL + query string\n\t\tconst url = new URL(this.config.baseUrl + path);\n\n\t\t// Perform fetch\n\t\tconst response = await this.config.fetch!(url.toString(), {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t...(this.config.apiKey\n\t\t\t\t\t? { \"x-api-key\": this.config.apiKey }\n\t\t\t\t\t: { Authorization: `Bearer ${this.config.apiToken}` }),\n\t\t\t},\n\t\t\tbody: bodyPayload ? JSON.stringify(bodyPayload) : undefined,\n\t\t});\n\n\t\tconst json = await response.json();\n\t\tconst parsedJson = ApiResponseSchema(opts.responseDataSchema).parse(json);\n\n\t\tif (\"error\" in parsedJson) {\n\t\t\tthrow new ApiClientError(parsedJson.error, parsedJson.statusCode, parsedJson.requestId);\n\t\t} else if (!(\"data\" in parsedJson)) {\n\t\t\tthrow new ApiClientError(\n\t\t\t\t{\n\t\t\t\t\tcode: \"INTERNAL_SERVER_ERROR\",\n\t\t\t\t\tmessage: \"Unexpected API response format\",\n\t\t\t\t\tdetails: 'Response did not contain expected \"data\" field',\n\t\t\t\t},\n\t\t\t\t500,\n\t\t\t\tparsedJson.requestId,\n\t\t\t);\n\t\t}\n\n\t\treturn parsedJson.data;\n\t}\n\n\t/**\n\t * GET convenience method inferring response type from schema\n\t */\n\tprotected get<ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"GET\", path, { responseDataSchema });\n\t}\n\n\t/**\n\t * PUT convenience method inferring both request and response types\n\t */\n\tprotected put<ReqSchema extends ZodTypeAny, ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tbody: z.infer<ReqSchema>,\n\t\trequestSchema: ReqSchema,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"PUT\", path, { body, requestSchema, responseDataSchema });\n\t}\n}\n","import { z } from \"zod\";\nimport { ProseMirrorDocSchema } from \"../../prosemirror\";\n\n//\n// 1) REUSABLE SCHEMAS FOR COMMON STRUCTURES\n//\n\n/**\n * A generic schema representing a heading used across various slices.\n * - `text`: The display text of the heading.\n * - `href`: An optional URL that the heading links to.\n */\nconst HeadingSchema = z.object({\n\ttext: z.string(),\n\thref: z.string().url().optional(),\n});\n\n/**\n * Base “properties” common to most page slices.\n * - `heading`: An optional heading object for slices that can display a title.\n */\nconst BasePageItemProps = z.object({\n\theading: HeadingSchema.optional(),\n});\n\n/**\n * A schema to validate that a string is valid JSON.\n */\nconst ValidJSONStringSchema = z.string().refine(\n\t(val) => {\n\t\ttry {\n\t\t\tJSON.parse(val);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t},\n\t{ message: \"Invalid JSON string\" },\n);\n\n//\n// 2) GENERIC HELPER TO DEFINE “SLICE” INPUT/OUTPUT SCHEMAS\n//\n\n/**\n * A union type to represent either a Zod object schema or an optional Zod object schema.\n */\ntype OptionalOrRequiredZodObject = z.AnyZodObject | z.ZodOptional<z.AnyZodObject>;\n\n/**\n * Helper function that, given:\n * - `typeName`: A string literal identifying the slice type.\n * - `propsShape`: A Zod schema describing the slice’s `properties`.\n *\n * Returns an object containing two schemas:\n * - `InputSchema`: For client-side input; `sliceId` is optional.\n * - `OutputSchema`: For server-side/output; `sliceId` is required.\n *\n * This is useful because when defining slices we often want to allow -\n * clients to submit slices without an ID (e.g., when creating new slices),\n */\nfunction defineSliceSchema<T extends string, P extends OptionalOrRequiredZodObject>(options: {\n\ttypeName: T;\n\tpropsShape: P;\n}) {\n\tconst { typeName, propsShape } = options;\n\n\t// Base schema shared by both input and output:\n\t// - `type`: Literal string identifying which slice this is.\n\t// - `hidden`: Optional flag to mark the slice as hidden.\n\t// - `properties`: The detailed properties shape for the slice.\n\tconst BaseSchema = z.object({\n\t\ttype: z.literal(typeName),\n\t\thidden: z.boolean().optional(),\n\t\tproperties: propsShape,\n\t});\n\n\t/**\n\t * Input schema: For client submissions.\n\t * - `sliceId` is optional because the client might not specify it yet.\n\t */\n\tconst InputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid().optional(),\n\t});\n\n\t/**\n\t * Output schema: For persisted or server-returned data.\n\t * - `sliceId` is required (each saved slice must have an ID).\n\t */\n\tconst OutputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid(),\n\t});\n\n\treturn { InputSchema, OutputSchema };\n}\n\n//\n// 3) DEFINE INDIVIDUAL SLICE TYPES (INPUT & OUTPUT) USING THE HELPER\n//\n\n// 3.A “HomepageSlice”\n// - A generic homepage slice that may include an optional heading.\n// - Input: Clients can pass `properties` or omit entirely.\n// - Output: Always includes a `properties` object (may be empty) and a required `sliceId`.\nconst HomepageSlice = defineSliceSchema({\n\ttypeName: \"HomepageSlice\",\n\tpropsShape: BasePageItemProps.optional(),\n});\n\n// 3.B “InteractiveSlice”\n// - A slice to embed or reference a Flourish graphic by its ID.\n// - Extends graphic base properties with `flourishId` and `flourishAltText`, with optional 'theme', 'flourishDescription' or 'storyUUID'.\nconst InteractiveSlice = defineSliceSchema({\n\ttypeName: \"Interactive\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tflourishDescription: z.string().optional(), // Optional description for the Flourish graphic\n\t\tflourishId: z.string().nonempty(),\n\t\tflourishAltText: z.string().nonempty(),\n\t\tstoryUUID: z.string().uuid().optional(),\n\t\ttheme: z.string().optional(),\n\t}),\n});\n\n// 3.C “ExperimentSlice”\n// - A slice for embedding experimental content.\n// - Requires an `experimentId`, `experimentName`, and a JSON string (`contentJson`).\nconst ExperimentSlice = defineSliceSchema({\n\ttypeName: \"Experiment\",\n\tpropsShape: BasePageItemProps.extend({\n\t\texperimentId: z.string().nonempty(), // Unique ID for the experiment\n\t\texperimentName: z.string().nonempty(), // Human-readable name of the experiment\n\t\tcontentJson: ValidJSONStringSchema, // The experiment’s JSON payload as a valid JSON string\n\t}),\n});\n\n// 3.D \"Strip\"\n// - A slice that displays a strip of content.\nconst StripSlice = defineSliceSchema({\n\ttypeName: \"Strip\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the strip to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the strip\n\t}),\n});\n\n// 3.E \"TopperSlice\"\n// - A slice that displays a topper section with description and optional strapline.\nconst TopperSlice = defineSliceSchema({\n\ttypeName: \"Topper\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tdescription: ProseMirrorDocSchema,\n\t\tstrapline: z.string().optional(),\n\t}),\n});\n\n// 3.F \"Hero\"\n// - A slice that represents a Hero on the page. It references a Spark List.\nconst HeroSlice = defineSliceSchema({\n\ttypeName: \"Hero\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the spark list to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the hero\n\t}),\n});\n\n//\n// 4) COMPOSE DISCRIMINATED UNIONS FOR “SLICE API” INPUT & OUTPUT\n//\n\n/**\n * All possible slice inputs for the Page API.\n * This discriminated union allows Zod to pick the correct schema based on the `type` field.\n */\nexport const SliceApiInputSchema = z.discriminatedUnion(\"type\", [\n\tHomepageSlice.InputSchema,\n\tInteractiveSlice.InputSchema,\n\tExperimentSlice.InputSchema,\n\tStripSlice.InputSchema,\n\tTopperSlice.InputSchema,\n\tHeroSlice.InputSchema,\n] as const);\n\n/**\n * All possible slice outputs for the Page API.\n * The same discriminated union but with each slice requiring `sliceId`.\n */\nexport const SliceApiOutputSchema = z.discriminatedUnion(\"type\", [\n\tHomepageSlice.OutputSchema,\n\tInteractiveSlice.OutputSchema,\n\tExperimentSlice.OutputSchema,\n\tStripSlice.OutputSchema,\n\tTopperSlice.OutputSchema,\n\tHeroSlice.OutputSchema,\n] as const);\n\n//\n// 5) WRAPPER SCHEMAS FOR THE ENTIRE PAGE STRUCTURE\n//\n\nconst BasePagePropertiesSchema = z.object({\n\ttitle: z.string(),\n\tpageId: z.string().uuid(),\n\tpublicationId: z.string(),\n\tconceptId: z.string().optional(),\n\tmetaDescription: z.string().optional(),\n\tpageTheme: z.string().optional(),\n\tsponsorText: z.string().optional(),\n\tsponsorImage: z.string().url().optional(),\n});\n\n/**\n * Page structure as submitted by clients.\n * - `properties`: Metadata about the page\n * - `children`: Array of slice inputs (each with an optional `sliceId`).\n */\nexport const PageStructureInputSchema = z.object({\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiInputSchema),\n});\n\n/**\n * Page structure as submitted by clients.\n * - `properties`: Metadata about the page (title, list ID, page ID).\n * - `children`: Array of slice inputs (each with an optional `sliceId`).\n */\nexport const HomepageStructureInputSchema = PageStructureInputSchema.extend({\n\tproperties: BasePagePropertiesSchema.extend({\n\t\t// This is optional for the input. If clients don't send it, we generate a uuid.\n\t\thomepageListId: z.string().uuid(),\n\t}),\n});\n\n/**\n * Page structure as stored or returned by the server.\n */\nexport const PageStructureOutputSchema = z.object({\n\ttype: z.literal(\"Page\"),\n\tschemaVersion: z.number(),\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiOutputSchema),\n});\n\nexport const HomepageStructureOutputSchema = PageStructureOutputSchema.extend({\n\ttype: z.literal(\"Homepage\"),\n\tproperties: BasePagePropertiesSchema.extend({\n\t\thomepageListId: z.string().uuid(),\n\t}),\n});\n\n//\n// 6) EXPORT TYPES FOR CONSUMPTION IN CODE\n//\n\n/** Client-side type for page structure input */\nexport type PageStructureInput = z.infer<typeof PageStructureInputSchema>;\n\n/** Server-side type for page structure output */\nexport type PageStructureOutput = z.infer<typeof PageStructureOutputSchema>;\n\n/** Client-side type for homepage structure input */\nexport type HomepageStructureInput = z.infer<typeof HomepageStructureInputSchema>;\n\n/** Server-side type for homepage structure output */\nexport type HomepageStructureOutput = z.infer<typeof HomepageStructureOutputSchema>;\n\n/** Union of all possible slice outputs for type-checking convenience */\nexport type Slice = z.infer<typeof SliceApiOutputSchema>;\n\n/** Individual slice output types */\nexport type HomepageSliceType = z.infer<typeof HomepageSlice.OutputSchema>;\nexport type InteractiveSliceType = z.infer<typeof InteractiveSlice.OutputSchema>;\nexport type ExperimentSliceType = z.infer<typeof ExperimentSlice.OutputSchema>;\nexport type StripSliceType = z.infer<typeof StripSlice.OutputSchema>;\nexport type TopperSliceType = z.infer<typeof TopperSlice.OutputSchema>;\nexport type HeroSliceType = z.infer<typeof HeroSlice.OutputSchema>;\n","import { z } from \"zod\";\n\n/** Accept http(s) and mailto: (matches your editor config) */\nconst HrefSchema = z.string().refine((v) => /^(https?:\\/\\/|mailto:).+/.test(v), {\n\tmessage: \"Expected http(s):// or mailto: URL\",\n});\n\n/** Link mark. */\nconst ProseMirrorLinkMark = z.object({\n\ttype: z.literal(\"link\"),\n\tattrs: z.object({\n\t\thref: HrefSchema,\n\t}),\n});\n\n/** Supported text marks */\nconst ProseMirrorMark = z.discriminatedUnion(\"type\", [\n\tProseMirrorLinkMark,\n\tz.object({ type: z.literal(\"bold\") }),\n\tz.object({ type: z.literal(\"italic\") }),\n\tz.object({ type: z.literal(\"underline\") }),\n\tz.object({ type: z.literal(\"strike\") }),\n]);\n\n/** Text node */\nconst ProseMirrorTextNode = z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string(),\n\tmarks: z.array(ProseMirrorMark).optional(),\n});\n\n/** Paragraph node — content can be empty/omitted */\nconst ProseMirrorParagraphNode = z.object({\n\ttype: z.literal(\"paragraph\"),\n\tcontent: z.array(ProseMirrorTextNode),\n});\n\n/** ProseMirror Node Union. */\nconst ProseMirrorNode = z.union([ProseMirrorParagraphNode, ProseMirrorTextNode]);\n\n/** Root node of a ProseMirror document - enforcing at least 1 paragraph */\nexport const ProseMirrorDocSchema = z.object({\n\ttype: z.literal(\"doc\"),\n\tcontent: z\n\t\t.array(ProseMirrorNode)\n\t\t.min(1, { message: \"Document must contain at least one paragraph\" }),\n});\n\n/** Rich text editor TS type. */\nexport type RichTextEditorType = z.infer<typeof ProseMirrorDocSchema>;\n\nexport {};\n","import { BaseApiClient } from \"./base\";\nimport {\n\tHomepageStructureInputSchema,\n\tHomepageStructureOutputSchema,\n\ttype HomepageStructureInput,\n\ttype HomepageStructureOutput,\n} from \"./schemas/ftpink/page\";\n\n/**\n * Client for Homepage structure endpoints\n */\nexport class HomepageClient extends BaseApiClient {\n\tasync getStructure(pageId: string): Promise<HomepageStructureOutput> {\n\t\treturn this.get(`/v1/homepage/${pageId}/structure`, HomepageStructureOutputSchema);\n\t}\n\n\tasync getStructuresByHomepageListId(homepageListId: string): Promise<HomepageStructureOutput[]> {\n\t\treturn this.get(\n\t\t\t`/v1/homepage/list/${homepageListId}/structures`,\n\t\t\tHomepageStructureOutputSchema.array(),\n\t\t);\n\t}\n\n\tasync upsertStructure(\n\t\tpageId: string,\n\t\tdata: Omit<HomepageStructureInput, \"type\">,\n\t): Promise<HomepageStructureOutput> {\n\t\treturn this.put(\n\t\t\t`/v1/homepage/${pageId}/structure`,\n\t\t\tdata,\n\t\t\tHomepageStructureInputSchema,\n\t\t\tHomepageStructureOutputSchema,\n\t\t);\n\t}\n}\n","import { z } from \"zod\";\n\n/**\n * -----------------------------------------\n * Legacy API Schemas & Types\n *\n * These schemas map to expected types for Hub Pages rendered by dotcom-pages.\n * -----------------------------------------\n */\n\nconst LegacyFlourishChildSchema = z.object({\n\tsource: z.literal(\"flourish\"),\n\tproperties: z.object({\n\t\tid: z.string().min(1), // e.g. \"visualisation/21901162\"\n\t}),\n});\n\nconst LegacyListChildSchema = z.object({\n\tsource: z.literal(\"list\"),\n\tproperties: z.object({\n\t\tid: z.string().uuid(),\n\t\tmaxItems: z.number().optional(),\n\t}),\n});\n\nconst LegacyContainerChildSchema = z.discriminatedUnion(\"source\", [\n\tLegacyFlourishChildSchema,\n\tLegacyListChildSchema,\n]);\n\nconst LegacyTopperSchema = z.object({\n\ttype: z.literal(\"topper-basic\"),\n\tproperties: z.object({\n\t\ttitle: z.string(),\n\t\tsponsorText: z.string().optional(),\n\t\tsponsorImage: z.string().url().optional(),\n\t}),\n});\n\nconst LegacyInfoBoxSchema = z.object({\n\ttype: z.literal(\"info-box\"),\n\tproperties: z.object({\n\t\tbodyHTML: z.string(),\n\t\ttitle: z.string().optional(),\n\t}),\n});\n\nconst LegacyContainerSchema = z.object({\n\ttype: z.literal(\"container\"),\n\tchildren: z.array(LegacyContainerChildSchema).min(1),\n\tproperties: z.object({\n\t\ttitle: z.string().optional(),\n\t\tdesign: z.enum([\"chart\", \"four-story\", \"freeform\", \"hero-lead\"]).default(\"freeform\"),\n\t\tbackgroundColor: z.string().optional(),\n\t}),\n});\n\nconst LegacyExperimentSchema = z.object({\n\ttype: z.literal(\"experiment\"),\n\tchildren: z.tuple([]),\n\tproperties: z.object({\n\t\texperimentName: z.string(),\n\t\tid: z.string(),\n\t\ttitle: z.string().optional(),\n\t\tconfig: z\n\t\t\t.object({\n\t\t\t\tvalue: z.unknown().optional(),\n\t\t\t\t// Hub pages support experiments with HTML and Text.\n\t\t\t\t// For now we just support JSON. As we migrate pages, this may change.\n\t\t\t\tformat: z.enum([\"json\"]).default(\"json\"),\n\t\t\t})\n\t\t\t.partial()\n\t\t\t.optional(),\n\t}),\n});\n\nconst LegacyBlockSchema = z.discriminatedUnion(\"type\", [\n\tLegacyTopperSchema,\n\tLegacyInfoBoxSchema,\n\tLegacyContainerSchema,\n\tLegacyExperimentSchema,\n]);\n\nexport const LegacyPageStructureOutputSchema = z.object({\n\tuuid: z.string().uuid(),\n\ttitle: z.string(),\n\tconceptId: z.string().uuid().optional(),\n\tthemeName: z.string().optional(),\n\tmetaDescription: z.string().optional(),\n\tblocks: z.array(LegacyBlockSchema),\n});\n\nexport type LegacyPageStructureOutput = z.infer<typeof LegacyPageStructureOutputSchema>;\nexport type LegacyBlock = z.infer<typeof LegacyBlockSchema>;\n","import { BaseApiClient } from \"./base\";\nimport type { LegacyPageStructureOutput } from \"./schemas/ftpink/legacyHubPage\";\nimport { LegacyPageStructureOutputSchema } from \"./schemas/ftpink/legacyHubPage\";\nimport {\n\tPageStructureInputSchema,\n\tPageStructureOutputSchema,\n\ttype PageStructureInput,\n\ttype PageStructureOutput,\n} from \"./schemas/ftpink/page\";\n\n/**\n * Client for Page structure endpoints\n */\nexport class PageClient extends BaseApiClient {\n\tasync getStructure(pageId: string): Promise<PageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/structure`, PageStructureOutputSchema);\n\t}\n\n\tasync getLegacyHubPageStructure(pageId: string): Promise<LegacyPageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/legacyHubPageStructure`, LegacyPageStructureOutputSchema);\n\t}\n\n\tasync upsertStructure(\n\t\tpageId: string,\n\t\tdata: Omit<PageStructureInput, \"type\">,\n\t): Promise<PageStructureOutput> {\n\t\treturn this.put(\n\t\t\t`/v1/page/${pageId}/structure`,\n\t\t\tdata,\n\t\t\tPageStructureInputSchema,\n\t\t\tPageStructureOutputSchema,\n\t\t);\n\t}\n}\n","import type { ApiClientConfig } from \"./base\";\nimport { BaseApiClient } from \"./base\";\nimport { HomepageClient } from \"./homepage\";\nimport { PageClient } from \"./page\";\n\n/**\n * Main API client that provides access to all API endpoints\n */\nexport class ApiClient extends BaseApiClient {\n\t/**\n\t * Homepage API endpoints\n\t */\n\thomepage: HomepageClient;\n\tpage: PageClient;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tsuper(config);\n\n\t\t// Initialize sub-clients\n\t\tthis.homepage = new HomepageClient(config);\n\t\tthis.page = new PageClient(config);\n\t}\n}\n","import { z } from \"zod\";\nimport { HomepageStructureOutputSchema, PageStructureOutputSchema } from \"../page\";\n\nexport const DraftContributorSchema = z.object({\n\tuserId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\temail: z.string().email().optional(),\n\tfirstTouchedAt: z.string().datetime(),\n\tlastTouchedAt: z.string().datetime(),\n});\n\nconst DraftMetadataSchema = z.object({\n\tdraftId: z.string().uuid(),\n\tcreatedAt: z.string().datetime(),\n\tupdatedAt: z.string().datetime(),\n\tcontributors: z.array(DraftContributorSchema),\n});\n\nexport const PageDraftSchema = DraftMetadataSchema.extend({\n\tstructure: PageStructureOutputSchema,\n});\n\nexport const HomepageDraftSchema = DraftMetadataSchema.extend({\n\tstructure: HomepageStructureOutputSchema,\n});\n\nexport const DraftSchema = z.union([PageDraftSchema, HomepageDraftSchema]);\n\nexport type DraftContributor = z.infer<typeof DraftContributorSchema>;\nexport type PageDraft = z.infer<typeof PageDraftSchema>;\nexport type HomepageDraft = z.infer<typeof HomepageDraftSchema>;\nexport type Draft = z.infer<typeof DraftSchema>;\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/circleci/repo/packages/content-curation-client/dist/index.cjs","../src/schemas/response.ts","../src/base.ts","../src/schemas/ftpink/page/index.ts","../src/schemas/prosemirror.ts","../src/schemas/ftpink/draft/index.ts","../src/homepage.ts","../src/schemas/ftpink/legacyHubPage/index.ts","../src/page.ts","../src/client.ts"],"names":[],"mappings":"AAAA;ACAA,0BAAmC;AAK5B,IAAM,aAAA,EAAe,MAAA,CAAE,IAAA,CAAK;AAAA,EAClC,cAAA;AAAA,EACA,WAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACD,CAAC,CAAA;AAKD,IAAM,mBAAA,EAAqB,MAAA,CAAE,MAAA,CAAO;AAAA,EACnC,UAAA,EAAY,MAAA,CAAE,MAAA,CAAO,CAAA;AAAA,EACrB,SAAA,EAAW,MAAA,CAAE,MAAA,CAAO;AACrB,CAAC,CAAA;AAKM,IAAM,sBAAA,EAAwB,MAAA,CACnC,MA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ACoB,EAAA;AACS,IAAA;AAC1E,EAAA;AAE0D,EAAA;AACrD,IAAA;AAC8D,MAAA;AAClD,IAAA;AACoD,MAAA;AAC3D,QAAA;AACR,MAAA;AACM,MAAA;AACP,IAAA;AACD,EAAA;AAEoF,EAAA;AACS,IAAA;AAC7F,EAAA;AAKgC,EAAA;AACnB,IAAA;AACO,MAAA;AAClB,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AACD,EAAA;AACD;ARkZsH;AACA;ASxbzE;AAAA;AAAA;AAAA;AAI5C,EAAA;AACA,EAAA;AAEqC,EAAA;AACxB,IAAA;AAG6B,IAAA;AACR,IAAA;AAClC,EAAA;AACD;ATubsH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/circleci/repo/packages/content-curation-client/dist/index.cjs","sourcesContent":[null,"import { z, type ZodTypeAny } from \"zod\";\n\n/**\n * Strongly‐typed enum for all possible API error codes.\n */\nexport const ApiErrorCode = z.enum([\n\t\"UNAUTHORIZED\",\n\t\"NOT_FOUND\",\n\t\"INTERNAL_SERVER_ERROR\",\n\t\"INVALID_INPUT_DATA\",\n]);\n\n/**\n * Fields shared by both success and error envelopes (but not the discriminant).\n */\nconst BaseEnvelopeFields = z.object({\n\tstatusCode: z.number(),\n\trequestId: z.string(),\n});\n\n/**\n * Specific details carried in an error payload.\n */\nexport const ApiErrorPayloadSchema = z\n\t.object({\n\t\tcode: ApiErrorCode,\n\t\tmessage: z.string(),\n\t\tdetails: z.string().optional(),\n\t\tpath: z.string().optional(),\n\t\ttimestamp: z.string().optional(),\n\t})\n\t.strict();\n\nexport type ApiErrorPayload = z.infer<typeof ApiErrorPayloadSchema>;\n\n/**\n * Full “envelope” when the API has failed.\n */\nexport const ApiErrorResponseSchema = BaseEnvelopeFields.extend({\n\tstatus: z.literal(\"error\"),\n\terror: ApiErrorPayloadSchema,\n}).strict();\n\nexport type ApiErrorResponse = z.infer<typeof ApiErrorResponseSchema>;\n\n/**\n * Schema for a successful API response, given some data schema T.\n */\nexport function ApiSuccessResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\treturn BaseEnvelopeFields.extend({\n\t\tstatus: z.literal(\"success\"),\n\t\tdata: dataSchema,\n\t}).strict();\n}\n\n/**\n * Union of success or error envelopes, discriminated on `status`.\n */\nexport function ApiResponseSchema<T extends ZodTypeAny>(dataSchema: T) {\n\tconst successSchema = ApiSuccessResponseSchema(dataSchema);\n\tconst errorSchema = ApiErrorResponseSchema;\n\treturn z.discriminatedUnion(\"status\", [successSchema, errorSchema]);\n}\n","import type { z, ZodTypeAny } from \"zod\";\nimport type { ApiErrorPayloadSchema } from \"./schemas/response\";\nimport { ApiResponseSchema } from \"./schemas/response\";\n\n/**\n * API-level error thrown when { status: 'error' } is returned\n */\nexport class ApiClientError extends Error {\n\tpublic code: string;\n\tpublic details?: string;\n\tpublic path?: string;\n\tpublic timestamp?: string;\n\n\tconstructor(\n\t\tpublic payload: z.infer<typeof ApiErrorPayloadSchema>,\n\t\tpublic statusCode: number,\n\t\tpublic requestId?: string,\n\t) {\n\t\tsuper(payload.message);\n\t\tthis.name = \"ApiError\";\n\t\tthis.code = payload.code;\n\t\tthis.details = payload.details;\n\t\tthis.path = payload.path;\n\t\tthis.timestamp = payload.timestamp;\n\t}\n}\n\n/**\n * Configuration options for the API client\n */\nexport type ApiClientConfig =\n\t| {\n\t\t\t// Standard configuration.\n\t\t\t// Intended for external clients using an API key issued via API Gateway.\n\t\t\tbaseUrl: string;\n\t\t\tapiKey: string;\n\t\t\tapiToken?: never;\n\t\t\tfetch?: typeof fetch;\n\t }\n\t| {\n\t\t\t// Alternative configuration.\n\t\t\t// Reserved for client with access to a bearer token (e.g. The e2e tests).\n\t\t\tbaseUrl: string;\n\t\t\tapiKey?: never;\n\t\t\tapiToken: string;\n\t\t\tfetch?: typeof fetch;\n\t };\n\nexport class BaseApiClient {\n\tprotected config: ApiClientConfig;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tthis.config = {\n\t\t\t...config,\n\t\t\tfetch: config.fetch || fetch,\n\t\t};\n\t\tthis.config.baseUrl = this.config.baseUrl.replace(/\\/+$/, \"\"); // strip trailing slashes\n\t}\n\n\t/**\n\t * Generic HTTP request to a JSON API\n\t */\n\tprotected async request<\n\t\tReqSchema extends ZodTypeAny | undefined,\n\t\tResponseDataSchema extends ZodTypeAny,\n\t>(\n\t\tmethod: \"GET\" | \"PUT\" | \"POST\" | \"DELETE\",\n\t\tpath: string,\n\t\topts: {\n\t\t\trequestSchema?: ReqSchema;\n\t\t\tbody?: ReqSchema extends ZodTypeAny ? z.infer<ReqSchema> : unknown;\n\t\t\tresponseDataSchema: ResponseDataSchema;\n\t\t},\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\t// Validate request body if provided\n\t\tlet bodyPayload = opts.body;\n\t\tif (opts.requestSchema && opts.body !== undefined) {\n\t\t\tbodyPayload = opts.requestSchema.parse(opts.body);\n\t\t}\n\n\t\t// Build URL + query string\n\t\tconst url = new URL(this.config.baseUrl + path);\n\n\t\t// Perform fetch\n\t\tconst response = await this.config.fetch!(url.toString(), {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t...(this.config.apiKey\n\t\t\t\t\t? { \"x-api-key\": this.config.apiKey }\n\t\t\t\t\t: { Authorization: `Bearer ${this.config.apiToken}` }),\n\t\t\t},\n\t\t\tbody: bodyPayload ? JSON.stringify(bodyPayload) : undefined,\n\t\t});\n\n\t\tconst json = await response.json();\n\t\tconst parsedJson = ApiResponseSchema(opts.responseDataSchema).parse(json);\n\n\t\tif (\"error\" in parsedJson) {\n\t\t\tthrow new ApiClientError(parsedJson.error, parsedJson.statusCode, parsedJson.requestId);\n\t\t} else if (!(\"data\" in parsedJson)) {\n\t\t\tthrow new ApiClientError(\n\t\t\t\t{\n\t\t\t\t\tcode: \"INTERNAL_SERVER_ERROR\",\n\t\t\t\t\tmessage: \"Unexpected API response format\",\n\t\t\t\t\tdetails: 'Response did not contain expected \"data\" field',\n\t\t\t\t},\n\t\t\t\t500,\n\t\t\t\tparsedJson.requestId,\n\t\t\t);\n\t\t}\n\n\t\treturn parsedJson.data;\n\t}\n\n\t/**\n\t * GET convenience method inferring response type from schema\n\t */\n\tprotected get<ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"GET\", path, { responseDataSchema });\n\t}\n\n\t/**\n\t * PUT convenience method inferring both request and response types\n\t */\n\tprotected put<ReqSchema extends ZodTypeAny, ResponseDataSchema extends ZodTypeAny>(\n\t\tpath: string,\n\t\tbody: z.infer<ReqSchema>,\n\t\trequestSchema: ReqSchema,\n\t\tresponseDataSchema: ResponseDataSchema,\n\t): Promise<z.infer<ResponseDataSchema>> {\n\t\treturn this.request(\"PUT\", path, { body, requestSchema, responseDataSchema });\n\t}\n}\n","import { z } from \"zod\";\nimport { ProseMirrorDocSchema } from \"../../prosemirror\";\n\n//\n// 1) REUSABLE SCHEMAS FOR COMMON STRUCTURES\n//\n\n/**\n * A generic schema representing a heading used across various slices.\n * - `text`: The display text of the heading.\n * - `href`: An optional URL that the heading links to.\n */\nconst HeadingSchema = z.object({\n\ttext: z.string(),\n\thref: z.string().url().optional(),\n});\n\n/**\n * Base “properties” common to most page slices.\n * - `heading`: An optional heading object for slices that can display a title.\n */\nconst BasePageItemProps = z.object({\n\theading: HeadingSchema.optional(),\n});\n\n/**\n * A schema to validate that a string is valid JSON.\n */\nconst ValidJSONStringSchema = z.string().refine(\n\t(val) => {\n\t\ttry {\n\t\t\tJSON.parse(val);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t},\n\t{ message: \"Invalid JSON string\" },\n);\n\n//\n// 2) GENERIC HELPER TO DEFINE “SLICE” INPUT/OUTPUT SCHEMAS\n//\n\n/**\n * A union type to represent either a Zod object schema or an optional Zod object schema.\n */\ntype OptionalOrRequiredZodObject = z.AnyZodObject | z.ZodOptional<z.AnyZodObject>;\n\n/**\n * Helper function that, given:\n * - `typeName`: A string literal identifying the slice type.\n * - `propsShape`: A Zod schema describing the slice’s `properties`.\n *\n * Returns an object containing two schemas:\n * - `InputSchema`: For client-side input; `sliceId` is optional.\n * - `OutputSchema`: For server-side/output; `sliceId` is required.\n *\n * This is useful because when defining slices we often want to allow -\n * clients to submit slices without an ID (e.g., when creating new slices),\n */\nfunction defineSliceSchema<T extends string, P extends OptionalOrRequiredZodObject>(options: {\n\ttypeName: T;\n\tpropsShape: P;\n}) {\n\tconst { typeName, propsShape } = options;\n\n\t// Base schema shared by both input and output:\n\t// - `type`: Literal string identifying which slice this is.\n\t// - `hidden`: Optional flag to mark the slice as hidden.\n\t// - `properties`: The detailed properties shape for the slice.\n\tconst BaseSchema = z.object({\n\t\ttype: z.literal(typeName),\n\t\thidden: z.boolean().optional(),\n\t\tproperties: propsShape,\n\t});\n\n\t/**\n\t * Input schema: For client submissions.\n\t * - `sliceId` is optional because the client might not specify it yet.\n\t */\n\tconst InputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid().optional(),\n\t});\n\n\t/**\n\t * Output schema: For persisted or server-returned data.\n\t * - `sliceId` is required (each saved slice must have an ID).\n\t */\n\tconst OutputSchema = BaseSchema.extend({\n\t\tsliceId: z.string().uuid(),\n\t});\n\n\treturn { InputSchema, OutputSchema };\n}\n\n//\n// 3) DEFINE INDIVIDUAL SLICE TYPES (INPUT & OUTPUT) USING THE HELPER\n//\n\n// 3.A “HomepageSlice”\n// - A generic homepage slice that may include an optional heading.\n// - Input: Clients can pass `properties` or omit entirely.\n// - Output: Always includes a `properties` object (may be empty) and a required `sliceId`.\nconst HomepageSlice = defineSliceSchema({\n\ttypeName: \"HomepageSlice\",\n\tpropsShape: BasePageItemProps.optional(),\n});\n\n// 3.B “InteractiveSlice”\n// - A slice to embed or reference a Flourish graphic by its ID.\n// - Extends graphic base properties with `flourishId` and `flourishAltText`, with optional 'theme', 'flourishDescription' or 'storyUUID'.\nconst InteractiveSlice = defineSliceSchema({\n\ttypeName: \"Interactive\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tflourishDescription: z.string().optional(), // Optional description for the Flourish graphic\n\t\tflourishId: z.string().nonempty(),\n\t\tflourishAltText: z.string().nonempty(),\n\t\tstoryUUID: z.string().uuid().optional(),\n\t\ttheme: z.string().optional(),\n\t}),\n});\n\n// 3.C “ExperimentSlice”\n// - A slice for embedding experimental content.\n// - Requires an `experimentId`, `experimentName`, and a JSON string (`contentJson`).\nconst ExperimentSlice = defineSliceSchema({\n\ttypeName: \"Experiment\",\n\tpropsShape: BasePageItemProps.extend({\n\t\texperimentId: z.string().nonempty(), // Unique ID for the experiment\n\t\texperimentName: z.string().nonempty(), // Human-readable name of the experiment\n\t\tcontentJson: ValidJSONStringSchema, // The experiment’s JSON payload as a valid JSON string\n\t}),\n});\n\n// 3.D \"Strip\"\n// - A slice that displays a strip of content.\nconst StripSlice = defineSliceSchema({\n\ttypeName: \"Strip\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the strip to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the strip\n\t}),\n});\n\n// 3.E \"TopperSlice\"\n// - A slice that displays a topper section with description and optional strapline.\nconst TopperSlice = defineSliceSchema({\n\ttypeName: \"Topper\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tdescription: ProseMirrorDocSchema,\n\t\tstrapline: z.string().optional(),\n\t}),\n});\n\n// 3.F \"Hero\"\n// - A slice that represents a Hero on the page. It references a Spark List.\nconst HeroSlice = defineSliceSchema({\n\ttypeName: \"Hero\",\n\tpropsShape: BasePageItemProps.extend({\n\t\tlistId: z.string().uuid(), // The ID of the spark list to display\n\t\tmaxStories: z.number().int().min(1).max(20), // Maximum number of stories to display in the hero\n\t}),\n});\n\n//\n// 4) COMPOSE DISCRIMINATED UNIONS FOR “SLICE API” INPUT & OUTPUT\n//\n\n/**\n * All possible slice inputs for the Page API.\n * This discriminated union allows Zod to pick the correct schema based on the `type` field.\n */\nexport const SliceApiInputSchema = z.discriminatedUnion(\"type\", [\n\tHomepageSlice.InputSchema,\n\tInteractiveSlice.InputSchema,\n\tExperimentSlice.InputSchema,\n\tStripSlice.InputSchema,\n\tTopperSlice.InputSchema,\n\tHeroSlice.InputSchema,\n] as const);\n\n/**\n * All possible slice outputs for the Page API.\n * The same discriminated union but with each slice requiring `sliceId`.\n */\nexport const SliceApiOutputSchema = z.discriminatedUnion(\"type\", [\n\tHomepageSlice.OutputSchema,\n\tInteractiveSlice.OutputSchema,\n\tExperimentSlice.OutputSchema,\n\tStripSlice.OutputSchema,\n\tTopperSlice.OutputSchema,\n\tHeroSlice.OutputSchema,\n] as const);\n\n//\n// 5) WRAPPER SCHEMAS FOR THE ENTIRE PAGE STRUCTURE\n//\n\nconst BasePagePropertiesSchema = z.object({\n\ttitle: z.string(),\n\tpageId: z.string().uuid(),\n\tpublicationId: z.string(),\n\tconceptId: z.string().optional(),\n\tmetaDescription: z.string().optional(),\n\tpageTheme: z.string().optional(),\n\tsponsorText: z.string().optional(),\n\tsponsorImage: z.string().url().optional(),\n});\n\n/**\n * Page structure as submitted by clients.\n * - `properties`: Metadata about the page\n * - `children`: Array of slice inputs (each with an optional `sliceId`).\n */\nexport const PageStructureInputSchema = z.object({\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiInputSchema),\n});\n\n/**\n * Page structure as submitted by clients.\n * - `properties`: Metadata about the page (title, list ID, page ID).\n * - `children`: Array of slice inputs (each with an optional `sliceId`).\n */\nexport const HomepageStructureInputSchema = PageStructureInputSchema.extend({\n\tproperties: BasePagePropertiesSchema.extend({\n\t\t// This is optional for the input. If clients don't send it, we generate a uuid.\n\t\thomepageListId: z.string().uuid(),\n\t}),\n});\n\n/**\n * Page structure as stored or returned by the server.\n */\nexport const PageStructureOutputSchema = z.object({\n\ttype: z.literal(\"Page\"),\n\tschemaVersion: z.number(),\n\tproperties: BasePagePropertiesSchema,\n\tchildren: z.array(SliceApiOutputSchema),\n});\n\nexport const HomepageStructureOutputSchema = PageStructureOutputSchema.extend({\n\ttype: z.literal(\"Homepage\"),\n\tproperties: BasePagePropertiesSchema.extend({\n\t\thomepageListId: z.string().uuid(),\n\t}),\n});\n\n//\n// 6) EXPORT TYPES FOR CONSUMPTION IN CODE\n//\n\n/** Client-side type for page structure input */\nexport type PageStructureInput = z.infer<typeof PageStructureInputSchema>;\n\n/** Server-side type for page structure output */\nexport type PageStructureOutput = z.infer<typeof PageStructureOutputSchema>;\n\n/** Client-side type for homepage structure input */\nexport type HomepageStructureInput = z.infer<typeof HomepageStructureInputSchema>;\n\n/** Server-side type for homepage structure output */\nexport type HomepageStructureOutput = z.infer<typeof HomepageStructureOutputSchema>;\n\n/** Union of all possible slice outputs for type-checking convenience */\nexport type Slice = z.infer<typeof SliceApiOutputSchema>;\n\n/** Individual slice output types */\nexport type HomepageSliceType = z.infer<typeof HomepageSlice.OutputSchema>;\nexport type InteractiveSliceType = z.infer<typeof InteractiveSlice.OutputSchema>;\nexport type ExperimentSliceType = z.infer<typeof ExperimentSlice.OutputSchema>;\nexport type StripSliceType = z.infer<typeof StripSlice.OutputSchema>;\nexport type TopperSliceType = z.infer<typeof TopperSlice.OutputSchema>;\nexport type HeroSliceType = z.infer<typeof HeroSlice.OutputSchema>;\n","import { z } from \"zod\";\n\n/** Accept http(s) and mailto: (matches your editor config) */\nconst HrefSchema = z.string().refine((v) => /^(https?:\\/\\/|mailto:).+/.test(v), {\n\tmessage: \"Expected http(s):// or mailto: URL\",\n});\n\n/** Link mark. */\nconst ProseMirrorLinkMark = z.object({\n\ttype: z.literal(\"link\"),\n\tattrs: z.object({\n\t\thref: HrefSchema,\n\t}),\n});\n\n/** Supported text marks */\nconst ProseMirrorMark = z.discriminatedUnion(\"type\", [\n\tProseMirrorLinkMark,\n\tz.object({ type: z.literal(\"bold\") }),\n\tz.object({ type: z.literal(\"italic\") }),\n\tz.object({ type: z.literal(\"underline\") }),\n\tz.object({ type: z.literal(\"strike\") }),\n]);\n\n/** Text node */\nconst ProseMirrorTextNode = z.object({\n\ttype: z.literal(\"text\"),\n\ttext: z.string(),\n\tmarks: z.array(ProseMirrorMark).optional(),\n});\n\n/** Paragraph node — content can be empty/omitted */\nconst ProseMirrorParagraphNode = z.object({\n\ttype: z.literal(\"paragraph\"),\n\tcontent: z.array(ProseMirrorTextNode),\n});\n\n/** ProseMirror Node Union. */\nconst ProseMirrorNode = z.union([ProseMirrorParagraphNode, ProseMirrorTextNode]);\n\n/** Root node of a ProseMirror document - enforcing at least 1 paragraph */\nexport const ProseMirrorDocSchema = z.object({\n\ttype: z.literal(\"doc\"),\n\tcontent: z\n\t\t.array(ProseMirrorNode)\n\t\t.min(1, { message: \"Document must contain at least one paragraph\" }),\n});\n\n/** Rich text editor TS type. */\nexport type RichTextEditorType = z.infer<typeof ProseMirrorDocSchema>;\n\nexport {};\n","import { z } from \"zod\";\nimport {\n\tHomepageStructureInputSchema,\n\tHomepageStructureOutputSchema,\n\tPageStructureInputSchema,\n\tPageStructureOutputSchema,\n} from \"../page\";\n\nexport const DraftContributorInputSchema = z.object({\n\tuserId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\temail: z.string().email().optional(),\n});\n\nexport const DraftContributorSchema = DraftContributorInputSchema.extend({\n\tuserId: z.string().min(1),\n\tdisplayName: z.string().min(1),\n\tfirstTouchedAt: z.string().datetime(),\n\tlastTouchedAt: z.string().datetime(),\n});\n\nconst DraftMetadataSchema = z.object({\n\tdraftId: z.string().uuid(),\n\tcreatedAt: z.string().datetime(),\n\tupdatedAt: z.string().datetime(),\n\tcontributors: z.array(DraftContributorSchema),\n});\n\nexport const PageDraftSchema = DraftMetadataSchema.extend({\n\tstructure: PageStructureOutputSchema,\n});\n\nexport const HomepageDraftSchema = DraftMetadataSchema.extend({\n\tstructure: HomepageStructureOutputSchema,\n});\n\nexport const DraftSchema = z.union([PageDraftSchema, HomepageDraftSchema]);\n\nexport const PersistPageDraftInputSchema = z.object({\n\tstructure: PageStructureInputSchema,\n\tcontributor: DraftContributorInputSchema,\n});\n\nexport const PersistHomepageDraftInputSchema = z.object({\n\tstructure: HomepageStructureInputSchema,\n\tcontributor: DraftContributorInputSchema,\n});\n\nexport type DraftContributorInput = z.infer<typeof DraftContributorInputSchema>;\nexport type DraftContributor = z.infer<typeof DraftContributorSchema>;\nexport type PageDraft = z.infer<typeof PageDraftSchema>;\nexport type HomepageDraft = z.infer<typeof HomepageDraftSchema>;\nexport type Draft = z.infer<typeof DraftSchema>;\nexport type PersistPageDraftInput = z.infer<typeof PersistPageDraftInputSchema>;\nexport type PersistHomepageDraftInput = z.infer<typeof PersistHomepageDraftInputSchema>;\n","import { ApiClientError, BaseApiClient } from \"./base\";\nimport {\n\tHomepageStructureInputSchema,\n\tHomepageStructureOutputSchema,\n\ttype HomepageStructureInput,\n\ttype HomepageStructureOutput,\n} from \"./schemas/ftpink/page\";\nimport { HomepageDraftSchema, type HomepageDraft } from \"./schemas/ftpink/draft\";\n\n/**\n * Client for Homepage structure endpoints\n */\nexport class HomepageClient extends BaseApiClient {\n\tasync getStructure(pageId: string): Promise<HomepageStructureOutput> {\n\t\treturn this.get(`/v1/homepage/${pageId}/structure`, HomepageStructureOutputSchema);\n\t}\n\n\tasync getDraft(pageId: string): Promise<HomepageDraft | null> {\n\t\ttry {\n\t\t\treturn await this.get(`/v1/homepage/${pageId}/draft`, HomepageDraftSchema);\n\t\t} catch (error) {\n\t\t\tif (error instanceof ApiClientError && error.code === \"NOT_FOUND\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync getStructuresByHomepageListId(homepageListId: string): Promise<HomepageStructureOutput[]> {\n\t\treturn this.get(\n\t\t\t`/v1/homepage/list/${homepageListId}/structures`,\n\t\t\tHomepageStructureOutputSchema.array(),\n\t\t);\n\t}\n\n\tasync upsertStructure(\n\t\tpageId: string,\n\t\tdata: Omit<HomepageStructureInput, \"type\">,\n\t): Promise<HomepageStructureOutput> {\n\t\treturn this.put(\n\t\t\t`/v1/homepage/${pageId}/structure`,\n\t\t\tdata,\n\t\t\tHomepageStructureInputSchema,\n\t\t\tHomepageStructureOutputSchema,\n\t\t);\n\t}\n}\n","import { z } from \"zod\";\n\n/**\n * -----------------------------------------\n * Legacy API Schemas & Types\n *\n * These schemas map to expected types for Hub Pages rendered by dotcom-pages.\n * -----------------------------------------\n */\n\nconst LegacyFlourishChildSchema = z.object({\n\tsource: z.literal(\"flourish\"),\n\tproperties: z.object({\n\t\tid: z.string().min(1), // e.g. \"visualisation/21901162\"\n\t}),\n});\n\nconst LegacyListChildSchema = z.object({\n\tsource: z.literal(\"list\"),\n\tproperties: z.object({\n\t\tid: z.string().uuid(),\n\t\tmaxItems: z.number().optional(),\n\t}),\n});\n\nconst LegacyContainerChildSchema = z.discriminatedUnion(\"source\", [\n\tLegacyFlourishChildSchema,\n\tLegacyListChildSchema,\n]);\n\nconst LegacyTopperSchema = z.object({\n\ttype: z.literal(\"topper-basic\"),\n\tproperties: z.object({\n\t\ttitle: z.string(),\n\t\tsponsorText: z.string().optional(),\n\t\tsponsorImage: z.string().url().optional(),\n\t}),\n});\n\nconst LegacyInfoBoxSchema = z.object({\n\ttype: z.literal(\"info-box\"),\n\tproperties: z.object({\n\t\tbodyHTML: z.string(),\n\t\ttitle: z.string().optional(),\n\t}),\n});\n\nconst LegacyContainerSchema = z.object({\n\ttype: z.literal(\"container\"),\n\tchildren: z.array(LegacyContainerChildSchema).min(1),\n\tproperties: z.object({\n\t\ttitle: z.string().optional(),\n\t\tdesign: z.enum([\"chart\", \"four-story\", \"freeform\", \"hero-lead\"]).default(\"freeform\"),\n\t\tbackgroundColor: z.string().optional(),\n\t}),\n});\n\nconst LegacyExperimentSchema = z.object({\n\ttype: z.literal(\"experiment\"),\n\tchildren: z.tuple([]),\n\tproperties: z.object({\n\t\texperimentName: z.string(),\n\t\tid: z.string(),\n\t\ttitle: z.string().optional(),\n\t\tconfig: z\n\t\t\t.object({\n\t\t\t\tvalue: z.unknown().optional(),\n\t\t\t\t// Hub pages support experiments with HTML and Text.\n\t\t\t\t// For now we just support JSON. As we migrate pages, this may change.\n\t\t\t\tformat: z.enum([\"json\"]).default(\"json\"),\n\t\t\t})\n\t\t\t.partial()\n\t\t\t.optional(),\n\t}),\n});\n\nconst LegacyBlockSchema = z.discriminatedUnion(\"type\", [\n\tLegacyTopperSchema,\n\tLegacyInfoBoxSchema,\n\tLegacyContainerSchema,\n\tLegacyExperimentSchema,\n]);\n\nexport const LegacyPageStructureOutputSchema = z.object({\n\tuuid: z.string().uuid(),\n\ttitle: z.string(),\n\tconceptId: z.string().uuid().optional(),\n\tthemeName: z.string().optional(),\n\tmetaDescription: z.string().optional(),\n\tblocks: z.array(LegacyBlockSchema),\n});\n\nexport type LegacyPageStructureOutput = z.infer<typeof LegacyPageStructureOutputSchema>;\nexport type LegacyBlock = z.infer<typeof LegacyBlockSchema>;\n","import { ApiClientError, BaseApiClient } from \"./base\";\nimport type { LegacyPageStructureOutput } from \"./schemas/ftpink/legacyHubPage\";\nimport { LegacyPageStructureOutputSchema } from \"./schemas/ftpink/legacyHubPage\";\nimport {\n\tPageStructureInputSchema,\n\tPageStructureOutputSchema,\n\ttype PageStructureInput,\n\ttype PageStructureOutput,\n} from \"./schemas/ftpink/page\";\nimport { PageDraftSchema, type PageDraft } from \"./schemas/ftpink/draft\";\n\n/**\n * Client for Page structure endpoints\n */\nexport class PageClient extends BaseApiClient {\n\tasync getStructure(pageId: string): Promise<PageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/structure`, PageStructureOutputSchema);\n\t}\n\n\tasync getDraft(pageId: string): Promise<PageDraft | null> {\n\t\ttry {\n\t\t\treturn await this.get(`/v1/page/${pageId}/draft`, PageDraftSchema);\n\t\t} catch (error) {\n\t\t\tif (error instanceof ApiClientError && error.code === \"NOT_FOUND\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync getLegacyHubPageStructure(pageId: string): Promise<LegacyPageStructureOutput> {\n\t\treturn this.get(`/v1/page/${pageId}/legacyHubPageStructure`, LegacyPageStructureOutputSchema);\n\t}\n\n\tasync upsertStructure(\n\t\tpageId: string,\n\t\tdata: Omit<PageStructureInput, \"type\">,\n\t): Promise<PageStructureOutput> {\n\t\treturn this.put(\n\t\t\t`/v1/page/${pageId}/structure`,\n\t\t\tdata,\n\t\t\tPageStructureInputSchema,\n\t\t\tPageStructureOutputSchema,\n\t\t);\n\t}\n}\n","import type { ApiClientConfig } from \"./base\";\nimport { BaseApiClient } from \"./base\";\nimport { HomepageClient } from \"./homepage\";\nimport { PageClient } from \"./page\";\n\n/**\n * Main API client that provides access to all API endpoints\n */\nexport class ApiClient extends BaseApiClient {\n\t/**\n\t * Homepage API endpoints\n\t */\n\thomepage: HomepageClient;\n\tpage: PageClient;\n\n\tconstructor(config: ApiClientConfig) {\n\t\tsuper(config);\n\n\t\t// Initialize sub-clients\n\t\tthis.homepage = new HomepageClient(config);\n\t\tthis.page = new PageClient(config);\n\t}\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -24,10 +24,16 @@ export { DraftSchema } from './_tsup-dts-rollup.cjs';
|
|
|
24
24
|
export { PageDraftSchema } from './_tsup-dts-rollup.cjs';
|
|
25
25
|
export { HomepageDraftSchema } from './_tsup-dts-rollup.cjs';
|
|
26
26
|
export { DraftContributorSchema } from './_tsup-dts-rollup.cjs';
|
|
27
|
+
export { DraftContributorInputSchema } from './_tsup-dts-rollup.cjs';
|
|
28
|
+
export { PersistPageDraftInputSchema } from './_tsup-dts-rollup.cjs';
|
|
29
|
+
export { PersistHomepageDraftInputSchema } from './_tsup-dts-rollup.cjs';
|
|
27
30
|
export { Draft } from './_tsup-dts-rollup.cjs';
|
|
28
31
|
export { PageDraft } from './_tsup-dts-rollup.cjs';
|
|
29
32
|
export { HomepageDraft } from './_tsup-dts-rollup.cjs';
|
|
30
33
|
export { DraftContributor } from './_tsup-dts-rollup.cjs';
|
|
34
|
+
export { DraftContributorInput } from './_tsup-dts-rollup.cjs';
|
|
35
|
+
export { PersistPageDraftInput } from './_tsup-dts-rollup.cjs';
|
|
36
|
+
export { PersistHomepageDraftInput } from './_tsup-dts-rollup.cjs';
|
|
31
37
|
export { LegacyBlock } from './_tsup-dts-rollup.cjs';
|
|
32
38
|
export { LegacyPageStructureOutput } from './_tsup-dts-rollup.cjs';
|
|
33
39
|
export { LegacyPageStructureOutputSchema } from './_tsup-dts-rollup.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -24,10 +24,16 @@ export { DraftSchema } from './_tsup-dts-rollup.js';
|
|
|
24
24
|
export { PageDraftSchema } from './_tsup-dts-rollup.js';
|
|
25
25
|
export { HomepageDraftSchema } from './_tsup-dts-rollup.js';
|
|
26
26
|
export { DraftContributorSchema } from './_tsup-dts-rollup.js';
|
|
27
|
+
export { DraftContributorInputSchema } from './_tsup-dts-rollup.js';
|
|
28
|
+
export { PersistPageDraftInputSchema } from './_tsup-dts-rollup.js';
|
|
29
|
+
export { PersistHomepageDraftInputSchema } from './_tsup-dts-rollup.js';
|
|
27
30
|
export { Draft } from './_tsup-dts-rollup.js';
|
|
28
31
|
export { PageDraft } from './_tsup-dts-rollup.js';
|
|
29
32
|
export { HomepageDraft } from './_tsup-dts-rollup.js';
|
|
30
33
|
export { DraftContributor } from './_tsup-dts-rollup.js';
|
|
34
|
+
export { DraftContributorInput } from './_tsup-dts-rollup.js';
|
|
35
|
+
export { PersistPageDraftInput } from './_tsup-dts-rollup.js';
|
|
36
|
+
export { PersistHomepageDraftInput } from './_tsup-dts-rollup.js';
|
|
31
37
|
export { LegacyBlock } from './_tsup-dts-rollup.js';
|
|
32
38
|
export { LegacyPageStructureOutput } from './_tsup-dts-rollup.js';
|
|
33
39
|
export { LegacyPageStructureOutputSchema } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -278,11 +278,56 @@ var HomepageStructureOutputSchema = PageStructureOutputSchema.extend({
|
|
|
278
278
|
})
|
|
279
279
|
});
|
|
280
280
|
|
|
281
|
+
// src/schemas/ftpink/draft/index.ts
|
|
282
|
+
import { z as z4 } from "zod";
|
|
283
|
+
var DraftContributorInputSchema = z4.object({
|
|
284
|
+
userId: z4.string().min(1),
|
|
285
|
+
displayName: z4.string().min(1),
|
|
286
|
+
email: z4.string().email().optional()
|
|
287
|
+
});
|
|
288
|
+
var DraftContributorSchema = DraftContributorInputSchema.extend({
|
|
289
|
+
userId: z4.string().min(1),
|
|
290
|
+
displayName: z4.string().min(1),
|
|
291
|
+
firstTouchedAt: z4.string().datetime(),
|
|
292
|
+
lastTouchedAt: z4.string().datetime()
|
|
293
|
+
});
|
|
294
|
+
var DraftMetadataSchema = z4.object({
|
|
295
|
+
draftId: z4.string().uuid(),
|
|
296
|
+
createdAt: z4.string().datetime(),
|
|
297
|
+
updatedAt: z4.string().datetime(),
|
|
298
|
+
contributors: z4.array(DraftContributorSchema)
|
|
299
|
+
});
|
|
300
|
+
var PageDraftSchema = DraftMetadataSchema.extend({
|
|
301
|
+
structure: PageStructureOutputSchema
|
|
302
|
+
});
|
|
303
|
+
var HomepageDraftSchema = DraftMetadataSchema.extend({
|
|
304
|
+
structure: HomepageStructureOutputSchema
|
|
305
|
+
});
|
|
306
|
+
var DraftSchema = z4.union([PageDraftSchema, HomepageDraftSchema]);
|
|
307
|
+
var PersistPageDraftInputSchema = z4.object({
|
|
308
|
+
structure: PageStructureInputSchema,
|
|
309
|
+
contributor: DraftContributorInputSchema
|
|
310
|
+
});
|
|
311
|
+
var PersistHomepageDraftInputSchema = z4.object({
|
|
312
|
+
structure: HomepageStructureInputSchema,
|
|
313
|
+
contributor: DraftContributorInputSchema
|
|
314
|
+
});
|
|
315
|
+
|
|
281
316
|
// src/homepage.ts
|
|
282
317
|
var HomepageClient = class extends BaseApiClient {
|
|
283
318
|
async getStructure(pageId) {
|
|
284
319
|
return this.get(`/v1/homepage/${pageId}/structure`, HomepageStructureOutputSchema);
|
|
285
320
|
}
|
|
321
|
+
async getDraft(pageId) {
|
|
322
|
+
try {
|
|
323
|
+
return await this.get(`/v1/homepage/${pageId}/draft`, HomepageDraftSchema);
|
|
324
|
+
} catch (error) {
|
|
325
|
+
if (error instanceof ApiClientError && error.code === "NOT_FOUND") {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
throw error;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
286
331
|
async getStructuresByHomepageListId(homepageListId) {
|
|
287
332
|
return this.get(
|
|
288
333
|
`/v1/homepage/list/${homepageListId}/structures`,
|
|
@@ -300,77 +345,77 @@ var HomepageClient = class extends BaseApiClient {
|
|
|
300
345
|
};
|
|
301
346
|
|
|
302
347
|
// src/schemas/ftpink/legacyHubPage/index.ts
|
|
303
|
-
import { z as
|
|
304
|
-
var LegacyFlourishChildSchema =
|
|
305
|
-
source:
|
|
306
|
-
properties:
|
|
307
|
-
id:
|
|
348
|
+
import { z as z5 } from "zod";
|
|
349
|
+
var LegacyFlourishChildSchema = z5.object({
|
|
350
|
+
source: z5.literal("flourish"),
|
|
351
|
+
properties: z5.object({
|
|
352
|
+
id: z5.string().min(1)
|
|
308
353
|
// e.g. "visualisation/21901162"
|
|
309
354
|
})
|
|
310
355
|
});
|
|
311
|
-
var LegacyListChildSchema =
|
|
312
|
-
source:
|
|
313
|
-
properties:
|
|
314
|
-
id:
|
|
315
|
-
maxItems:
|
|
356
|
+
var LegacyListChildSchema = z5.object({
|
|
357
|
+
source: z5.literal("list"),
|
|
358
|
+
properties: z5.object({
|
|
359
|
+
id: z5.string().uuid(),
|
|
360
|
+
maxItems: z5.number().optional()
|
|
316
361
|
})
|
|
317
362
|
});
|
|
318
|
-
var LegacyContainerChildSchema =
|
|
363
|
+
var LegacyContainerChildSchema = z5.discriminatedUnion("source", [
|
|
319
364
|
LegacyFlourishChildSchema,
|
|
320
365
|
LegacyListChildSchema
|
|
321
366
|
]);
|
|
322
|
-
var LegacyTopperSchema =
|
|
323
|
-
type:
|
|
324
|
-
properties:
|
|
325
|
-
title:
|
|
326
|
-
sponsorText:
|
|
327
|
-
sponsorImage:
|
|
367
|
+
var LegacyTopperSchema = z5.object({
|
|
368
|
+
type: z5.literal("topper-basic"),
|
|
369
|
+
properties: z5.object({
|
|
370
|
+
title: z5.string(),
|
|
371
|
+
sponsorText: z5.string().optional(),
|
|
372
|
+
sponsorImage: z5.string().url().optional()
|
|
328
373
|
})
|
|
329
374
|
});
|
|
330
|
-
var LegacyInfoBoxSchema =
|
|
331
|
-
type:
|
|
332
|
-
properties:
|
|
333
|
-
bodyHTML:
|
|
334
|
-
title:
|
|
375
|
+
var LegacyInfoBoxSchema = z5.object({
|
|
376
|
+
type: z5.literal("info-box"),
|
|
377
|
+
properties: z5.object({
|
|
378
|
+
bodyHTML: z5.string(),
|
|
379
|
+
title: z5.string().optional()
|
|
335
380
|
})
|
|
336
381
|
});
|
|
337
|
-
var LegacyContainerSchema =
|
|
338
|
-
type:
|
|
339
|
-
children:
|
|
340
|
-
properties:
|
|
341
|
-
title:
|
|
342
|
-
design:
|
|
343
|
-
backgroundColor:
|
|
382
|
+
var LegacyContainerSchema = z5.object({
|
|
383
|
+
type: z5.literal("container"),
|
|
384
|
+
children: z5.array(LegacyContainerChildSchema).min(1),
|
|
385
|
+
properties: z5.object({
|
|
386
|
+
title: z5.string().optional(),
|
|
387
|
+
design: z5.enum(["chart", "four-story", "freeform", "hero-lead"]).default("freeform"),
|
|
388
|
+
backgroundColor: z5.string().optional()
|
|
344
389
|
})
|
|
345
390
|
});
|
|
346
|
-
var LegacyExperimentSchema =
|
|
347
|
-
type:
|
|
348
|
-
children:
|
|
349
|
-
properties:
|
|
350
|
-
experimentName:
|
|
351
|
-
id:
|
|
352
|
-
title:
|
|
353
|
-
config:
|
|
354
|
-
value:
|
|
391
|
+
var LegacyExperimentSchema = z5.object({
|
|
392
|
+
type: z5.literal("experiment"),
|
|
393
|
+
children: z5.tuple([]),
|
|
394
|
+
properties: z5.object({
|
|
395
|
+
experimentName: z5.string(),
|
|
396
|
+
id: z5.string(),
|
|
397
|
+
title: z5.string().optional(),
|
|
398
|
+
config: z5.object({
|
|
399
|
+
value: z5.unknown().optional(),
|
|
355
400
|
// Hub pages support experiments with HTML and Text.
|
|
356
401
|
// For now we just support JSON. As we migrate pages, this may change.
|
|
357
|
-
format:
|
|
402
|
+
format: z5.enum(["json"]).default("json")
|
|
358
403
|
}).partial().optional()
|
|
359
404
|
})
|
|
360
405
|
});
|
|
361
|
-
var LegacyBlockSchema =
|
|
406
|
+
var LegacyBlockSchema = z5.discriminatedUnion("type", [
|
|
362
407
|
LegacyTopperSchema,
|
|
363
408
|
LegacyInfoBoxSchema,
|
|
364
409
|
LegacyContainerSchema,
|
|
365
410
|
LegacyExperimentSchema
|
|
366
411
|
]);
|
|
367
|
-
var LegacyPageStructureOutputSchema =
|
|
368
|
-
uuid:
|
|
369
|
-
title:
|
|
370
|
-
conceptId:
|
|
371
|
-
themeName:
|
|
372
|
-
metaDescription:
|
|
373
|
-
blocks:
|
|
412
|
+
var LegacyPageStructureOutputSchema = z5.object({
|
|
413
|
+
uuid: z5.string().uuid(),
|
|
414
|
+
title: z5.string(),
|
|
415
|
+
conceptId: z5.string().uuid().optional(),
|
|
416
|
+
themeName: z5.string().optional(),
|
|
417
|
+
metaDescription: z5.string().optional(),
|
|
418
|
+
blocks: z5.array(LegacyBlockSchema)
|
|
374
419
|
});
|
|
375
420
|
|
|
376
421
|
// src/page.ts
|
|
@@ -378,6 +423,16 @@ var PageClient = class extends BaseApiClient {
|
|
|
378
423
|
async getStructure(pageId) {
|
|
379
424
|
return this.get(`/v1/page/${pageId}/structure`, PageStructureOutputSchema);
|
|
380
425
|
}
|
|
426
|
+
async getDraft(pageId) {
|
|
427
|
+
try {
|
|
428
|
+
return await this.get(`/v1/page/${pageId}/draft`, PageDraftSchema);
|
|
429
|
+
} catch (error) {
|
|
430
|
+
if (error instanceof ApiClientError && error.code === "NOT_FOUND") {
|
|
431
|
+
return null;
|
|
432
|
+
}
|
|
433
|
+
throw error;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
381
436
|
async getLegacyHubPageStructure(pageId) {
|
|
382
437
|
return this.get(`/v1/page/${pageId}/legacyHubPageStructure`, LegacyPageStructureOutputSchema);
|
|
383
438
|
}
|
|
@@ -404,29 +459,6 @@ var ApiClient = class extends BaseApiClient {
|
|
|
404
459
|
this.page = new PageClient(config);
|
|
405
460
|
}
|
|
406
461
|
};
|
|
407
|
-
|
|
408
|
-
// src/schemas/ftpink/draft/index.ts
|
|
409
|
-
import { z as z5 } from "zod";
|
|
410
|
-
var DraftContributorSchema = z5.object({
|
|
411
|
-
userId: z5.string().min(1),
|
|
412
|
-
displayName: z5.string().min(1),
|
|
413
|
-
email: z5.string().email().optional(),
|
|
414
|
-
firstTouchedAt: z5.string().datetime(),
|
|
415
|
-
lastTouchedAt: z5.string().datetime()
|
|
416
|
-
});
|
|
417
|
-
var DraftMetadataSchema = z5.object({
|
|
418
|
-
draftId: z5.string().uuid(),
|
|
419
|
-
createdAt: z5.string().datetime(),
|
|
420
|
-
updatedAt: z5.string().datetime(),
|
|
421
|
-
contributors: z5.array(DraftContributorSchema)
|
|
422
|
-
});
|
|
423
|
-
var PageDraftSchema = DraftMetadataSchema.extend({
|
|
424
|
-
structure: PageStructureOutputSchema
|
|
425
|
-
});
|
|
426
|
-
var HomepageDraftSchema = DraftMetadataSchema.extend({
|
|
427
|
-
structure: HomepageStructureOutputSchema
|
|
428
|
-
});
|
|
429
|
-
var DraftSchema = z5.union([PageDraftSchema, HomepageDraftSchema]);
|
|
430
462
|
export {
|
|
431
463
|
ApiClient,
|
|
432
464
|
ApiClientError,
|
|
@@ -435,6 +467,7 @@ export {
|
|
|
435
467
|
ApiErrorResponseSchema,
|
|
436
468
|
ApiResponseSchema,
|
|
437
469
|
ApiSuccessResponseSchema,
|
|
470
|
+
DraftContributorInputSchema,
|
|
438
471
|
DraftContributorSchema,
|
|
439
472
|
DraftSchema,
|
|
440
473
|
HomepageClient,
|
|
@@ -446,6 +479,8 @@ export {
|
|
|
446
479
|
PageDraftSchema,
|
|
447
480
|
PageStructureInputSchema,
|
|
448
481
|
PageStructureOutputSchema,
|
|
482
|
+
PersistHomepageDraftInputSchema,
|
|
483
|
+
PersistPageDraftInputSchema,
|
|
449
484
|
ProseMirrorDocSchema,
|
|
450
485
|
SliceApiInputSchema,
|
|
451
486
|
SliceApiOutputSchema
|