133 lines
3.2 KiB
TypeScript
133 lines
3.2 KiB
TypeScript
// Generated by ts-to-zod
|
|
import { z } from "zod";
|
|
import { type DxtPart } from "./es6/docxtemplater.d";
|
|
|
|
const dxtIntegerSchema = z.number();
|
|
|
|
const dxtSimplePartSchema = z.record(z.any()).and(
|
|
z.object({
|
|
type: z.string(),
|
|
value: z.string(),
|
|
module: z.string().optional(),
|
|
})
|
|
);
|
|
|
|
const dxtPartSchema: z.ZodSchema<DxtPart> = z.lazy(() =>
|
|
z.object({
|
|
type: z.string(),
|
|
value: z.string(),
|
|
module: z.string(),
|
|
raw: z.string(),
|
|
offset: dxtIntegerSchema,
|
|
lIndex: dxtIntegerSchema,
|
|
num: dxtIntegerSchema,
|
|
inverted: z.boolean().optional(),
|
|
endLindex: dxtIntegerSchema.optional(),
|
|
expanded: z.array(dxtPartSchema).optional(),
|
|
subparsed: z.array(dxtPartSchema).optional(),
|
|
position: z.string().optional(),
|
|
tag: z.string().optional(),
|
|
})
|
|
);
|
|
|
|
const dxtRenderedSchema = z.object({
|
|
value: z.string(),
|
|
errors: z.array(z.any()),
|
|
});
|
|
|
|
const dxtErrorSchema = z.any();
|
|
|
|
const dxtCompressionSchema = z.union([
|
|
z.literal("STORE"),
|
|
z.literal("DEFLATE"),
|
|
]);
|
|
|
|
const dxtZipOptionsSchema = z.object({
|
|
compression: z
|
|
.union([dxtCompressionSchema, z.undefined()])
|
|
.optional()
|
|
.default("DEFLATE"),
|
|
compressionOptions: z
|
|
.union([
|
|
z.object({
|
|
level: z.union([
|
|
z.literal(1),
|
|
z.literal(2),
|
|
z.literal(3),
|
|
z.literal(4),
|
|
z.literal(5),
|
|
z.literal(6),
|
|
z.literal(7),
|
|
z.literal(8),
|
|
z.literal(9),
|
|
]),
|
|
}),
|
|
z.undefined(),
|
|
])
|
|
.optional()
|
|
.nullable(),
|
|
comment: z.union([z.string(), z.undefined()]).optional(),
|
|
platform: z
|
|
.union([
|
|
z.literal("DOS"),
|
|
z.literal("UNIX"),
|
|
z.literal(NodeJS.Platform),
|
|
z.undefined(),
|
|
])
|
|
.optional()
|
|
.default("DOS"),
|
|
});
|
|
|
|
const dxtModuleSchema = z.record(z.any());
|
|
|
|
const dxtParserContextSchema = z.object({
|
|
meta: z.object({
|
|
part: dxtPartSchema,
|
|
}),
|
|
scopeList: z.array(z.any()),
|
|
scopePath: z.array(z.string()),
|
|
scopePathItem: z.array(dxtIntegerSchema),
|
|
scopePathLength: z.array(dxtIntegerSchema),
|
|
num: dxtIntegerSchema,
|
|
});
|
|
|
|
const dxtParserSchema = z.object({});
|
|
|
|
const dxtSyntaxSchema = z.object({
|
|
allowUnopenedTag: z.boolean().optional(),
|
|
allowUnclosedTag: z.boolean().optional(),
|
|
changeDelimiterPrefix: z.string().optional().nullable(),
|
|
allowUnbalancedLoops: z.boolean().optional(),
|
|
});
|
|
|
|
const dxtOptionsSchema = z.object({
|
|
delimiters: z
|
|
.object({
|
|
start: z.string().nullable(),
|
|
end: z.string().nullable(),
|
|
})
|
|
.optional(),
|
|
paragraphLoop: z.boolean().optional(),
|
|
errorLogging: z.union([z.boolean(), z.string()]).optional(),
|
|
linebreaks: z.boolean().optional(),
|
|
fileTypeConfig: z.any().optional(),
|
|
syntax: dxtSyntaxSchema.optional(),
|
|
stripInvalidXMLChars: z.boolean().optional(),
|
|
});
|
|
|
|
const dxtConstructorOptionsSchema = dxtOptionsSchema.extend({
|
|
modules: z.array(dxtModuleSchema).optional(),
|
|
});
|
|
|
|
const dxtScopeManagerSchema = z.object({
|
|
scopeList: z.array(z.any()),
|
|
scopeLindex: z.array(dxtIntegerSchema),
|
|
scopePath: z.array(z.string()),
|
|
scopePathItem: z.array(dxtIntegerSchema),
|
|
scopePathLength: z.array(dxtIntegerSchema),
|
|
resolved: z.any(),
|
|
cachedParsers: z.record(
|
|
z.function().args(z.any(), dxtParserContextSchema).returns(z.any())
|
|
),
|
|
});
|