zinkee 0.1.23 → 0.1.24
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/AGENTS.md +1 -0
- package/README.md +54 -0
- package/dist/index.js +943 -318
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/document-templates.ts +110 -0
- package/src/command-registry.ts +56 -0
- package/src/commands/document-templates.test.ts +569 -0
- package/src/commands/document-templates.ts +563 -0
- package/src/program.ts +2 -0
- package/src/utils/examples.ts +185 -0
package/package.json
CHANGED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { ApiClient } from "../client.js";
|
|
2
|
+
import type { NormalizedUuidOrSlug } from "../parsers/selectors.js";
|
|
3
|
+
|
|
4
|
+
export interface ApiDocumentTemplateAsset {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
id?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
link?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ApiDocumentTemplate {
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
id?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
assets?: ApiDocumentTemplateAsset[];
|
|
16
|
+
createdAt?: string;
|
|
17
|
+
updatedAt?: string;
|
|
18
|
+
createdBy?: string;
|
|
19
|
+
updatedBy?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CreateDocumentTemplateInput {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
name: string;
|
|
25
|
+
assets?: ApiDocumentTemplateAsset[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface UpdateDocumentTemplateInput {
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
name?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function jsonOptions(body: unknown, method: string): RequestInit {
|
|
34
|
+
return {
|
|
35
|
+
method,
|
|
36
|
+
headers: {
|
|
37
|
+
"content-type": "application/json",
|
|
38
|
+
},
|
|
39
|
+
body: JSON.stringify(body),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function selectorValue(selector: NormalizedUuidOrSlug): string {
|
|
44
|
+
return encodeURIComponent(selector.value);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function segment(value: string): string {
|
|
48
|
+
return encodeURIComponent(value);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class DocumentTemplatesApi {
|
|
52
|
+
constructor(private readonly client: ApiClient) {}
|
|
53
|
+
|
|
54
|
+
listTemplates(): Promise<ApiDocumentTemplate[]> {
|
|
55
|
+
return this.client.getJson<ApiDocumentTemplate[]>("/api/v2/document-templates");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
createTemplate(input: CreateDocumentTemplateInput): Promise<ApiDocumentTemplate> {
|
|
59
|
+
return this.client.requestJson<ApiDocumentTemplate>(
|
|
60
|
+
"/api/v2/document-templates",
|
|
61
|
+
jsonOptions(input, "POST"),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
updateTemplate(
|
|
66
|
+
template: NormalizedUuidOrSlug,
|
|
67
|
+
input: UpdateDocumentTemplateInput,
|
|
68
|
+
): Promise<ApiDocumentTemplate> {
|
|
69
|
+
return this.client.requestJson<ApiDocumentTemplate>(
|
|
70
|
+
`/api/v2/document-templates/${selectorValue(template)}`,
|
|
71
|
+
jsonOptions(input, "PATCH"),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
deleteTemplate(template: NormalizedUuidOrSlug): Promise<Record<string, unknown>> {
|
|
76
|
+
return this.client.requestJson<Record<string, unknown>>(
|
|
77
|
+
`/api/v2/document-templates/${selectorValue(template)}`,
|
|
78
|
+
{ method: "DELETE" },
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
addAsset(
|
|
83
|
+
template: NormalizedUuidOrSlug,
|
|
84
|
+
input: FormData,
|
|
85
|
+
): Promise<ApiDocumentTemplate> {
|
|
86
|
+
return this.client.requestJson<ApiDocumentTemplate>(
|
|
87
|
+
`/api/v2/document-templates/${selectorValue(template)}/assets`,
|
|
88
|
+
{ method: "POST", body: input },
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
deleteAsset(
|
|
93
|
+
template: NormalizedUuidOrSlug,
|
|
94
|
+
assetId: string,
|
|
95
|
+
): Promise<Record<string, unknown>> {
|
|
96
|
+
return this.client.requestJson<Record<string, unknown>>(
|
|
97
|
+
`/api/v2/document-templates/${selectorValue(template)}/assets/${segment(assetId)}`,
|
|
98
|
+
{ method: "DELETE" },
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
downloadAsset(
|
|
103
|
+
template: NormalizedUuidOrSlug,
|
|
104
|
+
assetId: string,
|
|
105
|
+
): Promise<ArrayBuffer> {
|
|
106
|
+
return this.client.requestBinary(
|
|
107
|
+
`/api/v2/document-templates/${selectorValue(template)}/assets/${segment(assetId)}/download`,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
package/src/command-registry.ts
CHANGED
|
@@ -441,6 +441,62 @@ export const commandRegistry = {
|
|
|
441
441
|
supportsRaw: false,
|
|
442
442
|
output: writeOutput,
|
|
443
443
|
},
|
|
444
|
+
"document-templates list": {
|
|
445
|
+
command: "document-templates list",
|
|
446
|
+
accessLevel: "read",
|
|
447
|
+
supportsExample: true,
|
|
448
|
+
supportsRaw: false,
|
|
449
|
+
output: readOutput,
|
|
450
|
+
},
|
|
451
|
+
"document-templates get": {
|
|
452
|
+
command: "document-templates get",
|
|
453
|
+
accessLevel: "read",
|
|
454
|
+
supportsExample: true,
|
|
455
|
+
supportsRaw: false,
|
|
456
|
+
output: readOutput,
|
|
457
|
+
},
|
|
458
|
+
"document-templates create": {
|
|
459
|
+
command: "document-templates create",
|
|
460
|
+
accessLevel: "write",
|
|
461
|
+
supportsExample: true,
|
|
462
|
+
supportsRaw: true,
|
|
463
|
+
output: writeOutput,
|
|
464
|
+
},
|
|
465
|
+
"document-templates update": {
|
|
466
|
+
command: "document-templates update",
|
|
467
|
+
accessLevel: "write",
|
|
468
|
+
supportsExample: true,
|
|
469
|
+
supportsRaw: false,
|
|
470
|
+
output: writeOutput,
|
|
471
|
+
},
|
|
472
|
+
"document-templates delete": {
|
|
473
|
+
command: "document-templates delete",
|
|
474
|
+
accessLevel: "destructive",
|
|
475
|
+
supportsExample: true,
|
|
476
|
+
supportsRaw: false,
|
|
477
|
+
output: writeOutput,
|
|
478
|
+
},
|
|
479
|
+
"document-templates assets add": {
|
|
480
|
+
command: "document-templates assets add",
|
|
481
|
+
accessLevel: "write",
|
|
482
|
+
supportsExample: true,
|
|
483
|
+
supportsRaw: false,
|
|
484
|
+
output: writeOutput,
|
|
485
|
+
},
|
|
486
|
+
"document-templates assets delete": {
|
|
487
|
+
command: "document-templates assets delete",
|
|
488
|
+
accessLevel: "destructive",
|
|
489
|
+
supportsExample: true,
|
|
490
|
+
supportsRaw: false,
|
|
491
|
+
output: writeOutput,
|
|
492
|
+
},
|
|
493
|
+
"document-templates assets download": {
|
|
494
|
+
command: "document-templates assets download",
|
|
495
|
+
accessLevel: "read",
|
|
496
|
+
supportsExample: true,
|
|
497
|
+
supportsRaw: false,
|
|
498
|
+
output: "binary",
|
|
499
|
+
},
|
|
444
500
|
"files upload": {
|
|
445
501
|
command: "files upload",
|
|
446
502
|
accessLevel: "write",
|