zinkee 0.1.44 → 0.1.45
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/README.md +4 -0
- package/dist/chunk-MHEVRMDX.js +1230 -0
- package/dist/chunk-MHEVRMDX.js.map +1 -0
- package/{src/utils/examples.ts → dist/examples-E6FFEVBE.js} +856 -1141
- package/dist/examples-E6FFEVBE.js.map +1 -0
- package/dist/index.js +1145 -8456
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- package/.github/workflows/npm-publish.yml +0 -77
- package/.github/workflows/pr-checks.yml +0 -36
- package/AGENTS.md +0 -110
- package/docs/cli-contract.md +0 -41
- package/docs/npm-release.md +0 -64
- package/docs/superpowers/plans/2026-03-24-zinkee-cli-implementation.md +0 -837
- package/docs/superpowers/plans/2026-03-25-cli-backend-error-contract.md +0 -503
- package/docs/superpowers/plans/2026-03-26-display-freeform-create.md +0 -389
- package/docs/superpowers/specs/2026-03-24-zinkee-cli-backend-blockers.md +0 -172
- package/docs/superpowers/specs/2026-03-24-zinkee-cli-design.md +0 -1576
- package/docs/superpowers/specs/2026-03-24-zinkee-cli-e2e-checklist.md +0 -215
- package/docs/superpowers/specs/2026-03-24-zinkee-cli-e2e-design.md +0 -492
- package/docs/superpowers/specs/2026-03-24-zinkee-cli-e2e-status.md +0 -307
- package/docs/superpowers/specs/2026-07-30-cli-pr-checks-design.md +0 -37
- package/src/api/automations.ts +0 -404
- package/src/api/comments.ts +0 -51
- package/src/api/displays.ts +0 -337
- package/src/api/document-templates.ts +0 -110
- package/src/api/files.ts +0 -50
- package/src/api/formulas.test.ts +0 -65
- package/src/api/formulas.ts +0 -67
- package/src/api/logs.ts +0 -34
- package/src/api/navigation.ts +0 -70
- package/src/api/records.ts +0 -184
- package/src/api/schemas.ts +0 -148
- package/src/api/teamspace.ts +0 -110
- package/src/cli-examples.ts +0 -130
- package/src/cli-runner.ts +0 -95
- package/src/client.test.ts +0 -189
- package/src/client.ts +0 -269
- package/src/command-registry.ts +0 -882
- package/src/commands/automations.test.ts +0 -1030
- package/src/commands/automations.ts +0 -2102
- package/src/commands/comments.test.ts +0 -214
- package/src/commands/comments.ts +0 -303
- package/src/commands/config.test.ts +0 -81
- package/src/commands/config.ts +0 -150
- package/src/commands/displays.test.ts +0 -1105
- package/src/commands/displays.ts +0 -1442
- package/src/commands/document-templates.test.ts +0 -569
- package/src/commands/document-templates.ts +0 -563
- package/src/commands/files.test.ts +0 -284
- package/src/commands/files.ts +0 -280
- package/src/commands/formulas.test.ts +0 -194
- package/src/commands/formulas.ts +0 -243
- package/src/commands/logs.test.ts +0 -123
- package/src/commands/logs.ts +0 -159
- package/src/commands/navigation.test.ts +0 -211
- package/src/commands/navigation.ts +0 -348
- package/src/commands/profiles.test.ts +0 -191
- package/src/commands/profiles.ts +0 -303
- package/src/commands/records.test.ts +0 -860
- package/src/commands/records.ts +0 -883
- package/src/commands/schemas.test.ts +0 -1252
- package/src/commands/schemas.ts +0 -890
- package/src/commands/teamspace.test.ts +0 -229
- package/src/commands/teamspace.ts +0 -546
- package/src/completion/engine.test.ts +0 -138
- package/src/completion/engine.ts +0 -168
- package/src/completion/install.test.ts +0 -179
- package/src/completion/install.ts +0 -260
- package/src/completion/runtime.ts +0 -150
- package/src/completion/scripts.ts +0 -91
- package/src/config.test.ts +0 -362
- package/src/config.ts +0 -294
- package/src/index.test.ts +0 -217
- package/src/index.ts +0 -8
- package/src/parsers/expressions.test.ts +0 -95
- package/src/parsers/expressions.ts +0 -128
- package/src/parsers/kv.test.ts +0 -35
- package/src/parsers/kv.ts +0 -49
- package/src/parsers/selectors.test.ts +0 -23
- package/src/parsers/selectors.ts +0 -29
- package/src/program.ts +0 -64
- package/src/runtime-context.ts +0 -103
- package/src/types.ts +0 -76
- package/src/utils/argv-rewrite.test.ts +0 -149
- package/src/utils/argv-rewrite.ts +0 -269
- package/src/utils/errors.test.ts +0 -85
- package/src/utils/errors.ts +0 -191
- package/src/utils/examples.test.ts +0 -374
- package/src/utils/output.test.ts +0 -65
- package/src/utils/output.ts +0 -154
- package/src/utils/schema-fields.ts +0 -1016
- package/tsconfig.json +0 -20
- package/tsup.config.ts +0 -13
package/src/api/displays.ts
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import { ApiClient } from "../client.js";
|
|
2
|
-
import type { NormalizedUuidOrSlug } from "../parsers/selectors.js";
|
|
3
|
-
|
|
4
|
-
export interface ApiDisplay {
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
id?: string;
|
|
7
|
-
name?: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
layoutTemplate?: string;
|
|
10
|
-
layout?: {
|
|
11
|
-
template?: string;
|
|
12
|
-
freeformLayouts?: unknown;
|
|
13
|
-
slots?: Array<Record<string, unknown>>;
|
|
14
|
-
tabs?: Array<Record<string, unknown>>;
|
|
15
|
-
};
|
|
16
|
-
variables?: Array<Record<string, unknown>>;
|
|
17
|
-
widgets?: Array<Record<string, unknown>>;
|
|
18
|
-
navigationTargets?: Array<Record<string, unknown>>;
|
|
19
|
-
crossWidgetFilter?: Array<Record<string, unknown>> | null;
|
|
20
|
-
folder?: { id?: string; name?: string | null; isRoot?: boolean };
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface ApiDisplayTab {
|
|
24
|
-
[key: string]: unknown;
|
|
25
|
-
id?: string;
|
|
26
|
-
name?: string;
|
|
27
|
-
orientation?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface ApiDisplayVariable {
|
|
31
|
-
[key: string]: unknown;
|
|
32
|
-
id?: string;
|
|
33
|
-
name?: string;
|
|
34
|
-
type?: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface ApiDisplayWidget {
|
|
38
|
-
[key: string]: unknown;
|
|
39
|
-
id?: string;
|
|
40
|
-
name?: string;
|
|
41
|
-
type?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface ApiDisplayNavigationTarget {
|
|
45
|
-
[key: string]: unknown;
|
|
46
|
-
id?: string;
|
|
47
|
-
label?: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface ApiDisplayFolder {
|
|
51
|
-
[key: string]: unknown;
|
|
52
|
-
id?: string;
|
|
53
|
-
name?: string | null;
|
|
54
|
-
isRoot?: boolean;
|
|
55
|
-
displayCount?: number;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface MoveDisplayInput {
|
|
59
|
-
displayId: string;
|
|
60
|
-
targetFolderId: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export type DisplaySummary = ApiDisplay;
|
|
64
|
-
export type DisplayResource = ApiDisplay;
|
|
65
|
-
|
|
66
|
-
export interface CreateDisplayInput {
|
|
67
|
-
name: string;
|
|
68
|
-
description?: string;
|
|
69
|
-
layout: Record<string, unknown>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface UpdateDisplayInput {
|
|
73
|
-
name?: string;
|
|
74
|
-
description?: string;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function jsonOptions(body: unknown, method: string): RequestInit {
|
|
78
|
-
return {
|
|
79
|
-
method,
|
|
80
|
-
headers: {
|
|
81
|
-
"content-type": "application/json",
|
|
82
|
-
},
|
|
83
|
-
body: JSON.stringify(body),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function selectorValue(selector: NormalizedUuidOrSlug): string {
|
|
88
|
-
return encodeURIComponent(selector.value);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function segment(value: string): string {
|
|
92
|
-
return encodeURIComponent(value);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export class DisplaysApi {
|
|
96
|
-
constructor(private readonly client: ApiClient) {}
|
|
97
|
-
|
|
98
|
-
listDisplays(): Promise<ApiDisplay[]> {
|
|
99
|
-
return this.client.getJson<ApiDisplay[]>("/api/v2/displays");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
getDisplay(display: NormalizedUuidOrSlug): Promise<ApiDisplay> {
|
|
103
|
-
return this.client.getJson<ApiDisplay>(`/api/v2/displays/${selectorValue(display)}`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
createDisplay(body: CreateDisplayInput): Promise<ApiDisplay> {
|
|
107
|
-
return this.client.requestJson<ApiDisplay>("/api/v2/displays", jsonOptions(body, "POST"));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
updateDisplay(
|
|
111
|
-
display: NormalizedUuidOrSlug,
|
|
112
|
-
body: UpdateDisplayInput,
|
|
113
|
-
): Promise<ApiDisplay> {
|
|
114
|
-
return this.client.requestJson<ApiDisplay>(
|
|
115
|
-
`/api/v2/displays/${selectorValue(display)}`,
|
|
116
|
-
jsonOptions(body, "PATCH"),
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
deleteDisplay(display: NormalizedUuidOrSlug): Promise<Record<string, unknown>> {
|
|
121
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
122
|
-
`/api/v2/displays/${selectorValue(display)}`,
|
|
123
|
-
{ method: "DELETE" },
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
getLayout(display: NormalizedUuidOrSlug): Promise<Record<string, unknown>> {
|
|
128
|
-
return this.client.getJson<Record<string, unknown>>(
|
|
129
|
-
`/api/v2/displays/${selectorValue(display)}/layout`,
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
patchLayout(
|
|
134
|
-
display: NormalizedUuidOrSlug,
|
|
135
|
-
body: Record<string, unknown>,
|
|
136
|
-
): Promise<Record<string, unknown>> {
|
|
137
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
138
|
-
`/api/v2/displays/${selectorValue(display)}/layout`,
|
|
139
|
-
jsonOptions(body, "PATCH"),
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
listTabs(display: NormalizedUuidOrSlug): Promise<ApiDisplayTab[]> {
|
|
144
|
-
return this.client.getJson<ApiDisplayTab[]>(
|
|
145
|
-
`/api/v2/displays/${selectorValue(display)}/tabs`,
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
createTab(
|
|
150
|
-
display: NormalizedUuidOrSlug,
|
|
151
|
-
body: Record<string, unknown>,
|
|
152
|
-
): Promise<ApiDisplayTab> {
|
|
153
|
-
return this.client.requestJson<ApiDisplayTab>(
|
|
154
|
-
`/api/v2/displays/${selectorValue(display)}/tabs`,
|
|
155
|
-
jsonOptions(body, "POST"),
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
updateTab(
|
|
160
|
-
display: NormalizedUuidOrSlug,
|
|
161
|
-
tabId: string,
|
|
162
|
-
body: Record<string, unknown>,
|
|
163
|
-
): Promise<ApiDisplayTab> {
|
|
164
|
-
return this.client.requestJson<ApiDisplayTab>(
|
|
165
|
-
`/api/v2/displays/${selectorValue(display)}/tabs/${segment(tabId)}`,
|
|
166
|
-
jsonOptions(body, "PATCH"),
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
deleteTab(display: NormalizedUuidOrSlug, tabId: string): Promise<Record<string, unknown>> {
|
|
171
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
172
|
-
`/api/v2/displays/${selectorValue(display)}/tabs/${segment(tabId)}`,
|
|
173
|
-
{ method: "DELETE" },
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
listVariables(display: NormalizedUuidOrSlug): Promise<ApiDisplayVariable[]> {
|
|
178
|
-
return this.client.getJson<ApiDisplayVariable[]>(
|
|
179
|
-
`/api/v2/displays/${selectorValue(display)}/variables`,
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
getVariable(display: NormalizedUuidOrSlug, variableId: string): Promise<ApiDisplayVariable> {
|
|
184
|
-
return this.client.getJson<ApiDisplayVariable>(
|
|
185
|
-
`/api/v2/displays/${selectorValue(display)}/variables/${segment(variableId)}`,
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
createVariable(
|
|
190
|
-
display: NormalizedUuidOrSlug,
|
|
191
|
-
body: Record<string, unknown>,
|
|
192
|
-
): Promise<ApiDisplayVariable> {
|
|
193
|
-
return this.client.requestJson<ApiDisplayVariable>(
|
|
194
|
-
`/api/v2/displays/${selectorValue(display)}/variables`,
|
|
195
|
-
jsonOptions(body, "POST"),
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
updateVariable(display: NormalizedUuidOrSlug, variableId: string, body: Record<string, unknown>): Promise<ApiDisplayVariable> {
|
|
200
|
-
return this.client.requestJson<ApiDisplayVariable>(
|
|
201
|
-
`/api/v2/displays/${selectorValue(display)}/variables/${segment(variableId)}`,
|
|
202
|
-
jsonOptions(body, "PATCH"),
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
deleteVariable(display: NormalizedUuidOrSlug, variableId: string): Promise<Record<string, unknown>> {
|
|
207
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
208
|
-
`/api/v2/displays/${selectorValue(display)}/variables/${segment(variableId)}`,
|
|
209
|
-
{ method: "DELETE" },
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
listWidgets(display: NormalizedUuidOrSlug): Promise<ApiDisplayWidget[]> {
|
|
214
|
-
return this.client.getJson<ApiDisplayWidget[]>(
|
|
215
|
-
`/api/v2/displays/${selectorValue(display)}/widgets`,
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
getWidget(display: NormalizedUuidOrSlug, widgetId: string): Promise<ApiDisplayWidget> {
|
|
220
|
-
return this.client.getJson<ApiDisplayWidget>(
|
|
221
|
-
`/api/v2/displays/${selectorValue(display)}/widgets/${segment(widgetId)}`,
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
createWidget(
|
|
226
|
-
display: NormalizedUuidOrSlug,
|
|
227
|
-
body: Record<string, unknown>,
|
|
228
|
-
): Promise<ApiDisplayWidget> {
|
|
229
|
-
return this.client.requestJson<ApiDisplayWidget>(
|
|
230
|
-
`/api/v2/displays/${selectorValue(display)}/widgets`,
|
|
231
|
-
jsonOptions(body, "POST"),
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
updateWidget(display: NormalizedUuidOrSlug, widgetId: string, body: Record<string, unknown>): Promise<ApiDisplayWidget> {
|
|
236
|
-
return this.client.requestJson<ApiDisplayWidget>(
|
|
237
|
-
`/api/v2/displays/${selectorValue(display)}/widgets/${segment(widgetId)}`,
|
|
238
|
-
jsonOptions(body, "PATCH"),
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
deleteWidget(display: NormalizedUuidOrSlug, widgetId: string): Promise<Record<string, unknown>> {
|
|
243
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
244
|
-
`/api/v2/displays/${selectorValue(display)}/widgets/${segment(widgetId)}`,
|
|
245
|
-
{ method: "DELETE" },
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
createNavigationTarget(
|
|
250
|
-
display: NormalizedUuidOrSlug,
|
|
251
|
-
body: Record<string, unknown>,
|
|
252
|
-
): Promise<ApiDisplayNavigationTarget> {
|
|
253
|
-
return this.client.requestJson<ApiDisplayNavigationTarget>(
|
|
254
|
-
`/api/v2/displays/${selectorValue(display)}/navigation-targets`,
|
|
255
|
-
jsonOptions(body, "POST"),
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
updateNavigationTarget(
|
|
260
|
-
display: NormalizedUuidOrSlug,
|
|
261
|
-
targetId: string,
|
|
262
|
-
body: Record<string, unknown>,
|
|
263
|
-
): Promise<ApiDisplayNavigationTarget> {
|
|
264
|
-
return this.client.requestJson<ApiDisplayNavigationTarget>(
|
|
265
|
-
`/api/v2/displays/${selectorValue(display)}/navigation-targets/${segment(targetId)}`,
|
|
266
|
-
jsonOptions(body, "PATCH"),
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
deleteNavigationTarget(
|
|
271
|
-
display: NormalizedUuidOrSlug,
|
|
272
|
-
targetId: string,
|
|
273
|
-
): Promise<Record<string, unknown>> {
|
|
274
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
275
|
-
`/api/v2/displays/${selectorValue(display)}/navigation-targets/${segment(targetId)}`,
|
|
276
|
-
{ method: "DELETE" },
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
getCrossWidgetFilter(display: NormalizedUuidOrSlug): Promise<Record<string, unknown>> {
|
|
281
|
-
return this.client.getJson<Record<string, unknown>>(
|
|
282
|
-
`/api/v2/displays/${selectorValue(display)}/cross-widget-filter`,
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
setCrossWidgetFilter(
|
|
287
|
-
display: NormalizedUuidOrSlug,
|
|
288
|
-
body: unknown[],
|
|
289
|
-
): Promise<Record<string, unknown>> {
|
|
290
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
291
|
-
`/api/v2/displays/${selectorValue(display)}/cross-widget-filter`,
|
|
292
|
-
jsonOptions(body, "PUT"),
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
deleteCrossWidgetFilter(display: NormalizedUuidOrSlug): Promise<Record<string, unknown>> {
|
|
297
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
298
|
-
`/api/v2/displays/${selectorValue(display)}/cross-widget-filter`,
|
|
299
|
-
{ method: "DELETE" },
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
listFolders(): Promise<ApiDisplayFolder[]> {
|
|
304
|
-
return this.client.getJson<ApiDisplayFolder[]>("/api/v2/display-folders");
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
createFolder(body: Record<string, unknown>): Promise<ApiDisplayFolder> {
|
|
308
|
-
return this.client.requestJson<ApiDisplayFolder>(
|
|
309
|
-
"/api/v2/display-folders",
|
|
310
|
-
jsonOptions(body, "POST"),
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
updateFolder(
|
|
315
|
-
folder: NormalizedUuidOrSlug,
|
|
316
|
-
body: Record<string, unknown>,
|
|
317
|
-
): Promise<ApiDisplayFolder> {
|
|
318
|
-
return this.client.requestJson<ApiDisplayFolder>(
|
|
319
|
-
`/api/v2/display-folders/${selectorValue(folder)}`,
|
|
320
|
-
jsonOptions(body, "PATCH"),
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
deleteFolder(folder: NormalizedUuidOrSlug): Promise<Record<string, unknown>> {
|
|
325
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
326
|
-
`/api/v2/display-folders/${selectorValue(folder)}`,
|
|
327
|
-
{ method: "DELETE" },
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
moveDisplay(input: MoveDisplayInput): Promise<Record<string, unknown>> {
|
|
332
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
333
|
-
"/api/v2/display-folders/displays:move",
|
|
334
|
-
jsonOptions(input, "POST"),
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
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/api/files.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { ApiClient } from "../client.js";
|
|
2
|
-
import type { NormalizedUuidOrSlug } from "../parsers/selectors.js";
|
|
3
|
-
|
|
4
|
-
export interface ApiFile {
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
id?: string;
|
|
7
|
-
name?: string;
|
|
8
|
-
filename?: string;
|
|
9
|
-
size?: number;
|
|
10
|
-
mimeType?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface FileStorageInfo {
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
usedBytes?: number;
|
|
16
|
-
totalBytes?: number;
|
|
17
|
-
availableBytes?: number;
|
|
18
|
-
used?: number;
|
|
19
|
-
limitBytes?: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function selectorValue(selector: NormalizedUuidOrSlug): string {
|
|
23
|
-
return selector.value;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class FilesApi {
|
|
27
|
-
constructor(private readonly client: ApiClient) {}
|
|
28
|
-
|
|
29
|
-
uploadFile(input: FormData): Promise<ApiFile> {
|
|
30
|
-
return this.client.requestJson<ApiFile>("/api/v2/files", {
|
|
31
|
-
method: "POST",
|
|
32
|
-
body: input,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
downloadFile(file: NormalizedUuidOrSlug): Promise<ArrayBuffer> {
|
|
37
|
-
return this.client.requestBinary(`/api/v2/files/${selectorValue(file)}`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
deleteFile(file: NormalizedUuidOrSlug): Promise<Record<string, unknown>> {
|
|
41
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
42
|
-
`/api/v2/files/${selectorValue(file)}`,
|
|
43
|
-
{ method: "DELETE" },
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
getStorageInfo(): Promise<FileStorageInfo> {
|
|
48
|
-
return this.client.getJson<FileStorageInfo>("/api/v2/files/storage-info");
|
|
49
|
-
}
|
|
50
|
-
}
|
package/src/api/formulas.test.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { normalizeUuidOrSlug } from "../parsers/selectors.js";
|
|
4
|
-
import { ApiClient } from "../client.js";
|
|
5
|
-
import { FormulasApi } from "./formulas.js";
|
|
6
|
-
|
|
7
|
-
function jsonResponse(body: unknown): Response {
|
|
8
|
-
return new Response(JSON.stringify(body), {
|
|
9
|
-
status: 202,
|
|
10
|
-
headers: { "content-type": "application/json" },
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
describe("FormulasApi", () => {
|
|
15
|
-
it.each([
|
|
16
|
-
{
|
|
17
|
-
input: {
|
|
18
|
-
scope: "FIELD" as const,
|
|
19
|
-
schema: normalizeUuidOrSlug("invoices"),
|
|
20
|
-
field: normalizeUuidOrSlug("total"),
|
|
21
|
-
},
|
|
22
|
-
body: { scope: "FIELD", schema: "invoices", field: "total" },
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
input: {
|
|
26
|
-
scope: "SCHEMA" as const,
|
|
27
|
-
schema: normalizeUuidOrSlug("550e8400-e29b-41d4-a716-446655440001"),
|
|
28
|
-
},
|
|
29
|
-
body: {
|
|
30
|
-
scope: "SCHEMA",
|
|
31
|
-
schema: "550e8400-e29b-41d4-a716-446655440001",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
input: { scope: "WORKSPACE" as const },
|
|
36
|
-
body: { scope: "WORKSPACE" },
|
|
37
|
-
},
|
|
38
|
-
])("posts the $input.scope payload to the recompute endpoint", async ({ input, body }) => {
|
|
39
|
-
const fetchMock = vi.fn<typeof fetch>().mockResolvedValue(
|
|
40
|
-
jsonResponse({
|
|
41
|
-
requestId: "request-1",
|
|
42
|
-
scope: input.scope,
|
|
43
|
-
formulaCount: 1,
|
|
44
|
-
skippedFormulaCount: 0,
|
|
45
|
-
eventsQueued: 1,
|
|
46
|
-
status: "QUEUED",
|
|
47
|
-
}),
|
|
48
|
-
);
|
|
49
|
-
const api = new FormulasApi(
|
|
50
|
-
new ApiClient({
|
|
51
|
-
baseUrl: "https://api.zinkee.test",
|
|
52
|
-
apiKey: "test-token",
|
|
53
|
-
fetch: fetchMock,
|
|
54
|
-
}),
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
await api.recompute(input);
|
|
58
|
-
|
|
59
|
-
expect(fetchMock).toHaveBeenCalledOnce();
|
|
60
|
-
const [url, init] = fetchMock.mock.calls[0]!;
|
|
61
|
-
expect(url).toBe("https://api.zinkee.test/api/v2/formulas:recompute");
|
|
62
|
-
expect(init?.method).toBe("POST");
|
|
63
|
-
expect(JSON.parse(String(init?.body))).toEqual(body);
|
|
64
|
-
});
|
|
65
|
-
});
|
package/src/api/formulas.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { ApiClient } from "../client.js";
|
|
2
|
-
import type { NormalizedUuidOrSlug } from "../parsers/selectors.js";
|
|
3
|
-
|
|
4
|
-
export type FormulaRecomputeScope = "FIELD" | "SCHEMA" | "WORKSPACE";
|
|
5
|
-
|
|
6
|
-
export interface FormulaRecomputeResponse {
|
|
7
|
-
requestId: string;
|
|
8
|
-
scope: FormulaRecomputeScope;
|
|
9
|
-
formulaCount: number;
|
|
10
|
-
skippedFormulaCount: number;
|
|
11
|
-
eventsQueued: number;
|
|
12
|
-
status: "QUEUED";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type FormulaRecomputeInput =
|
|
16
|
-
| {
|
|
17
|
-
scope: "FIELD";
|
|
18
|
-
schema: NormalizedUuidOrSlug;
|
|
19
|
-
field: NormalizedUuidOrSlug;
|
|
20
|
-
}
|
|
21
|
-
| {
|
|
22
|
-
scope: "SCHEMA";
|
|
23
|
-
schema: NormalizedUuidOrSlug;
|
|
24
|
-
}
|
|
25
|
-
| {
|
|
26
|
-
scope: "WORKSPACE";
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
function selectorValue(selector: NormalizedUuidOrSlug): string {
|
|
30
|
-
return selector.value;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function toRequestBody(input: FormulaRecomputeInput): Record<string, string> {
|
|
34
|
-
if (input.scope === "FIELD") {
|
|
35
|
-
return {
|
|
36
|
-
scope: input.scope,
|
|
37
|
-
schema: selectorValue(input.schema),
|
|
38
|
-
field: selectorValue(input.field),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (input.scope === "SCHEMA") {
|
|
43
|
-
return {
|
|
44
|
-
scope: input.scope,
|
|
45
|
-
schema: selectorValue(input.schema),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return { scope: input.scope };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export class FormulasApi {
|
|
53
|
-
constructor(private readonly client: ApiClient) {}
|
|
54
|
-
|
|
55
|
-
recompute(input: FormulaRecomputeInput): Promise<FormulaRecomputeResponse> {
|
|
56
|
-
return this.client.requestJson<FormulaRecomputeResponse>(
|
|
57
|
-
"/api/v2/formulas:recompute",
|
|
58
|
-
{
|
|
59
|
-
method: "POST",
|
|
60
|
-
headers: {
|
|
61
|
-
"content-type": "application/json",
|
|
62
|
-
},
|
|
63
|
-
body: JSON.stringify(toRequestBody(input)),
|
|
64
|
-
},
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
package/src/api/logs.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ApiClient } from "../client.js";
|
|
2
|
-
import type { NormalizedUuidOrSlug } from "../parsers/selectors.js";
|
|
3
|
-
|
|
4
|
-
export interface ApiLogChange {
|
|
5
|
-
beforeValue?: string | null;
|
|
6
|
-
afterValue?: string | null;
|
|
7
|
-
author?: string;
|
|
8
|
-
operation?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ApiLog {
|
|
12
|
-
[key: string]: unknown;
|
|
13
|
-
recordId?: string;
|
|
14
|
-
timestamp?: string;
|
|
15
|
-
changeField?: string;
|
|
16
|
-
change?: ApiLogChange;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function selectorValue(selector: NormalizedUuidOrSlug): string {
|
|
20
|
-
return selector.value;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class LogsApi {
|
|
24
|
-
constructor(private readonly client: ApiClient) {}
|
|
25
|
-
|
|
26
|
-
listLogs(
|
|
27
|
-
schema: NormalizedUuidOrSlug,
|
|
28
|
-
recordId: string,
|
|
29
|
-
): Promise<ApiLog[]> {
|
|
30
|
-
return this.client.getJson<ApiLog[]>(
|
|
31
|
-
`/api/v2/schemas/${selectorValue(schema)}/records/${recordId}/logs`,
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
}
|