zinkee 0.1.68 → 0.1.69
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/index.js
CHANGED
|
@@ -253,7 +253,7 @@ ${list}`
|
|
|
253
253
|
};
|
|
254
254
|
}
|
|
255
255
|
async function showExamples(commandName, json, stdout, filters = {}) {
|
|
256
|
-
const { getCommandExamples } = await import("./examples-
|
|
256
|
+
const { getCommandExamples } = await import("./examples-AJAJZ6QM.js");
|
|
257
257
|
const examples = getCommandExamples(commandName, filters);
|
|
258
258
|
if (examples.length === 0) {
|
|
259
259
|
throw new CliError("invalid_cli_usage", `No examples registered for "${commandName}".`);
|
|
@@ -3933,6 +3933,7 @@ async function downloadToOutput(download, stdout, outputPath) {
|
|
|
3933
3933
|
}
|
|
3934
3934
|
|
|
3935
3935
|
// src/commands/document-templates.ts
|
|
3936
|
+
var FILE_NAME_PATTERN_HELP = 'generated file name: text plus record variables, e.g. "Budget {{ record.number }} - {{ record.client }}"; each PDF is named <resolved name>-vN.pdf';
|
|
3936
3937
|
function createDocumentTemplatesApi(command, filePath) {
|
|
3937
3938
|
const { client, ...runtime } = createCommandContext(command, filePath);
|
|
3938
3939
|
return { api: new DocumentTemplatesApi(client), ...runtime };
|
|
@@ -3975,6 +3976,7 @@ function templateRows(templates) {
|
|
|
3975
3976
|
return templates.map((template) => ({
|
|
3976
3977
|
id: template.id ?? "",
|
|
3977
3978
|
name: template.name ?? "",
|
|
3979
|
+
fileNamePattern: template.fileNamePattern ?? "",
|
|
3978
3980
|
assetCount: Array.isArray(template.assets) ? template.assets.length : 0,
|
|
3979
3981
|
updatedAt: template.updatedAt ?? ""
|
|
3980
3982
|
}));
|
|
@@ -4028,6 +4030,9 @@ function buildCreateInput(options) {
|
|
|
4028
4030
|
if (typeof input.name !== "string" || input.name.trim().length === 0) {
|
|
4029
4031
|
throw new CliError("invalid_cli_usage", 'Provide template name via "--name".');
|
|
4030
4032
|
}
|
|
4033
|
+
if (options.fileNamePattern !== void 0) {
|
|
4034
|
+
input.fileNamePattern = options.fileNamePattern;
|
|
4035
|
+
}
|
|
4031
4036
|
if (input.assets === void 0) {
|
|
4032
4037
|
input.assets = [];
|
|
4033
4038
|
}
|
|
@@ -4038,11 +4043,34 @@ function buildUpdateInput(options) {
|
|
|
4038
4043
|
if (options.name !== void 0) {
|
|
4039
4044
|
input.name = options.name;
|
|
4040
4045
|
}
|
|
4046
|
+
if (options.fileNamePattern !== void 0 && options.clearFileNamePattern) {
|
|
4047
|
+
throw new CliError(
|
|
4048
|
+
"invalid_cli_usage",
|
|
4049
|
+
'Use either "--file-name-pattern" or "--clear-file-name-pattern", not both.'
|
|
4050
|
+
);
|
|
4051
|
+
}
|
|
4052
|
+
if (options.fileNamePattern !== void 0) {
|
|
4053
|
+
input.fileNamePattern = options.fileNamePattern;
|
|
4054
|
+
} else if (options.clearFileNamePattern) {
|
|
4055
|
+
input.fileNamePattern = null;
|
|
4056
|
+
}
|
|
4041
4057
|
if (isEmptyObject(input)) {
|
|
4042
|
-
throw new CliError(
|
|
4058
|
+
throw new CliError(
|
|
4059
|
+
"invalid_cli_usage",
|
|
4060
|
+
'Provide template updates via "--name", "--file-name-pattern" or "--clear-file-name-pattern".'
|
|
4061
|
+
);
|
|
4043
4062
|
}
|
|
4044
4063
|
return input;
|
|
4045
4064
|
}
|
|
4065
|
+
function ensureFileNamePatternSupported(input, response) {
|
|
4066
|
+
if ("fileNamePattern" in input && !("fileNamePattern" in response)) {
|
|
4067
|
+
throw new CliError(
|
|
4068
|
+
"http_error",
|
|
4069
|
+
"The API saved the template but did not apply fileNamePattern: this server does not support generated file names yet.",
|
|
4070
|
+
{ template: response.id ?? null }
|
|
4071
|
+
);
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4046
4074
|
function registerDocumentTemplatesCommands(program, options = {}) {
|
|
4047
4075
|
const filePath = options.configPath ?? defaultConfigPath;
|
|
4048
4076
|
const stdout = options.stdout ?? process.stdout;
|
|
@@ -4054,7 +4082,11 @@ function registerDocumentTemplatesCommands(program, options = {}) {
|
|
|
4054
4082
|
emitJson(stdout, "document-templates list", data, filePath);
|
|
4055
4083
|
return;
|
|
4056
4084
|
}
|
|
4057
|
-
printTable(
|
|
4085
|
+
printTable(
|
|
4086
|
+
templateRows(data),
|
|
4087
|
+
["id", "name", "fileNamePattern", "assetCount", "updatedAt"],
|
|
4088
|
+
stdout
|
|
4089
|
+
);
|
|
4058
4090
|
});
|
|
4059
4091
|
templates.command("get").description("Get a document template by UUID or exact name").argument("<template>", "template UUID or exact name", parseUuidOrSlugSelector).action(async function action(template) {
|
|
4060
4092
|
const { api, json } = createDocumentTemplatesApi(this, filePath);
|
|
@@ -4066,21 +4098,28 @@ function registerDocumentTemplatesCommands(program, options = {}) {
|
|
|
4066
4098
|
}
|
|
4067
4099
|
printTable([data], void 0, stdout);
|
|
4068
4100
|
});
|
|
4069
|
-
templates.command("create").description("Create a document template").option("--name <name>", "template name").option("--raw <json>", "raw create JSON payload").option("--raw-file <path>", "path to raw create JSON payload").action(async function action(commandOptions) {
|
|
4101
|
+
templates.command("create").description("Create a document template").option("--name <name>", "template name").option("--file-name-pattern <pattern>", FILE_NAME_PATTERN_HELP).option("--raw <json>", "raw create JSON payload").option("--raw-file <path>", "path to raw create JSON payload").action(async function action(commandOptions) {
|
|
4070
4102
|
const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
|
|
4071
4103
|
ensureWritable("document-templates create", readOnly, "write");
|
|
4072
|
-
const
|
|
4104
|
+
const input = buildCreateInput(commandOptions);
|
|
4105
|
+
const data = await api.createTemplate(input);
|
|
4106
|
+
ensureFileNamePatternSupported(input, data);
|
|
4073
4107
|
if (json) {
|
|
4074
4108
|
emitJson(stdout, "document-templates create", data, filePath);
|
|
4075
4109
|
return;
|
|
4076
4110
|
}
|
|
4077
4111
|
writeLine(stdout, `Created document template "${String(data.name ?? commandOptions.name)}".`);
|
|
4078
4112
|
});
|
|
4079
|
-
templates.command("update").description("Rename a document template").argument("<template>", "template UUID or exact name", parseUuidOrSlugSelector).option("--name <name>", "new template name").
|
|
4113
|
+
templates.command("update").description("Rename a document template or set its generated file name").argument("<template>", "template UUID or exact name", parseUuidOrSlugSelector).option("--name <name>", "new template name").option("--file-name-pattern <pattern>", FILE_NAME_PATTERN_HELP).option(
|
|
4114
|
+
"--clear-file-name-pattern",
|
|
4115
|
+
"remove the generated file name: generated files are named after the template again"
|
|
4116
|
+
).action(async function action(template, commandOptions) {
|
|
4080
4117
|
const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
|
|
4081
4118
|
ensureWritable("document-templates update", readOnly, "write");
|
|
4119
|
+
const input = buildUpdateInput(commandOptions);
|
|
4082
4120
|
const resolved = await resolveTemplateSelector(api, template);
|
|
4083
|
-
const data = await api.updateTemplate(resolved,
|
|
4121
|
+
const data = await api.updateTemplate(resolved, input);
|
|
4122
|
+
ensureFileNamePatternSupported(input, data);
|
|
4084
4123
|
if (json) {
|
|
4085
4124
|
emitJson(stdout, "document-templates update", data, filePath);
|
|
4086
4125
|
return;
|