zinkee 0.1.29 → 0.1.30
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/.claude/settings.local.json +2 -1
- package/AGENTS.md +13 -0
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/schemas.ts +2 -0
- package/src/commands/schemas.test.ts +80 -0
- package/src/commands/schemas.ts +16 -1
- package/src/utils/examples.ts +10 -0
package/package.json
CHANGED
package/src/api/schemas.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface ApiSchema {
|
|
|
17
17
|
slug?: string;
|
|
18
18
|
auditable?: boolean;
|
|
19
19
|
commentable?: boolean;
|
|
20
|
+
highlightedField?: string;
|
|
20
21
|
fields?: ApiSchemaField[];
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -32,6 +33,7 @@ export interface UpdateSchemaInput {
|
|
|
32
33
|
slug?: string;
|
|
33
34
|
auditable?: boolean;
|
|
34
35
|
commentable?: boolean;
|
|
36
|
+
highlightedField?: string;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
export interface CreateSchemaFieldInput {
|
|
@@ -968,4 +968,84 @@ describe("schemas commands", () => {
|
|
|
968
968
|
},
|
|
969
969
|
});
|
|
970
970
|
});
|
|
971
|
+
|
|
972
|
+
it("updates a schema highlighted field by slug after resolving the field id", async () => {
|
|
973
|
+
const configPath = createApiConfig();
|
|
974
|
+
const output = createStdoutBuffer();
|
|
975
|
+
const fetchMock = createFetchMock();
|
|
976
|
+
mockSchemaLookup(fetchMock);
|
|
977
|
+
fetchMock.mockResolvedValueOnce(
|
|
978
|
+
jsonResponse({
|
|
979
|
+
id: "schema-1",
|
|
980
|
+
slug: "contacts",
|
|
981
|
+
fields: [
|
|
982
|
+
{
|
|
983
|
+
id: "550e8400-e29b-41d4-a716-446655440001",
|
|
984
|
+
slug: "email",
|
|
985
|
+
type: "TextField",
|
|
986
|
+
label: "Email",
|
|
987
|
+
},
|
|
988
|
+
],
|
|
989
|
+
}),
|
|
990
|
+
);
|
|
991
|
+
fetchMock.mockResolvedValueOnce(
|
|
992
|
+
jsonResponse({
|
|
993
|
+
id: "schema-1",
|
|
994
|
+
slug: "contacts",
|
|
995
|
+
highlightedField: "550e8400-e29b-41d4-a716-446655440001",
|
|
996
|
+
}),
|
|
997
|
+
);
|
|
998
|
+
const program = buildProgram({ configPath, stdout: output.stdout });
|
|
999
|
+
|
|
1000
|
+
await program.parseAsync([
|
|
1001
|
+
"node",
|
|
1002
|
+
"zinkee",
|
|
1003
|
+
"--json",
|
|
1004
|
+
"schemas",
|
|
1005
|
+
"update",
|
|
1006
|
+
"contacts",
|
|
1007
|
+
"--highlighted-field",
|
|
1008
|
+
"email",
|
|
1009
|
+
]);
|
|
1010
|
+
|
|
1011
|
+
expect(fetchMock.mock.calls[2]?.[0]).toBe("https://api.zinkee.test/api/v2/schemas/schema-1");
|
|
1012
|
+
expect(fetchMock.mock.calls[2]?.[1]?.method).toBe("PATCH");
|
|
1013
|
+
expect(JSON.parse(String(fetchMock.mock.calls[2]?.[1]?.body))).toEqual({
|
|
1014
|
+
highlightedField: "550e8400-e29b-41d4-a716-446655440001",
|
|
1015
|
+
});
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
it("updates a schema highlighted field by uuid without extra lookups", async () => {
|
|
1019
|
+
const configPath = createApiConfig();
|
|
1020
|
+
const output = createStdoutBuffer();
|
|
1021
|
+
const fetchMock = createFetchMock();
|
|
1022
|
+
fetchMock.mockResolvedValueOnce(
|
|
1023
|
+
jsonResponse({
|
|
1024
|
+
id: "550e8400-e29b-41d4-a716-446655440000",
|
|
1025
|
+
slug: "contacts",
|
|
1026
|
+
highlightedField: "550e8400-e29b-41d4-a716-446655440001",
|
|
1027
|
+
}),
|
|
1028
|
+
);
|
|
1029
|
+
const program = buildProgram({ configPath, stdout: output.stdout });
|
|
1030
|
+
|
|
1031
|
+
await program.parseAsync([
|
|
1032
|
+
"node",
|
|
1033
|
+
"zinkee",
|
|
1034
|
+
"--json",
|
|
1035
|
+
"schemas",
|
|
1036
|
+
"update",
|
|
1037
|
+
"550e8400-e29b-41d4-a716-446655440000",
|
|
1038
|
+
"--highlighted-field",
|
|
1039
|
+
"550e8400-e29b-41d4-a716-446655440001",
|
|
1040
|
+
]);
|
|
1041
|
+
|
|
1042
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
1043
|
+
expect(fetchMock.mock.calls[0]?.[0]).toBe(
|
|
1044
|
+
"https://api.zinkee.test/api/v2/schemas/550e8400-e29b-41d4-a716-446655440000",
|
|
1045
|
+
);
|
|
1046
|
+
expect(fetchMock.mock.calls[0]?.[1]?.method).toBe("PATCH");
|
|
1047
|
+
expect(JSON.parse(String(fetchMock.mock.calls[0]?.[1]?.body))).toEqual({
|
|
1048
|
+
highlightedField: "550e8400-e29b-41d4-a716-446655440001",
|
|
1049
|
+
});
|
|
1050
|
+
});
|
|
971
1051
|
});
|
package/src/commands/schemas.ts
CHANGED
|
@@ -56,6 +56,7 @@ interface SchemaUpdateCommandOptions {
|
|
|
56
56
|
slug?: string;
|
|
57
57
|
auditable?: boolean;
|
|
58
58
|
commentable?: boolean;
|
|
59
|
+
highlightedField?: NormalizedUuidOrSlug;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
interface FieldCreateCommandOptions {
|
|
@@ -568,6 +569,11 @@ export function registerSchemasCommands(
|
|
|
568
569
|
.option("--slug <slug>", "schema slug")
|
|
569
570
|
.option("--auditable <bool>", "auditable flag", parseBooleanFlag)
|
|
570
571
|
.option("--commentable <bool>", "commentable flag", parseBooleanFlag)
|
|
572
|
+
.option(
|
|
573
|
+
"--highlighted-field <field>",
|
|
574
|
+
"highlighted (main) field uuid or slug",
|
|
575
|
+
parseUuidOrSlugSelector,
|
|
576
|
+
)
|
|
571
577
|
.action(async function action(
|
|
572
578
|
this: Command,
|
|
573
579
|
schema: NormalizedUuidOrSlug,
|
|
@@ -579,10 +585,19 @@ export function registerSchemasCommands(
|
|
|
579
585
|
|
|
580
586
|
const input = buildSchemaUpdateInput(commandOptions);
|
|
581
587
|
|
|
588
|
+
if (commandOptions.highlightedField !== undefined) {
|
|
589
|
+
const resolvedField = await resolveFieldSelector(
|
|
590
|
+
api,
|
|
591
|
+
resolvedSchema,
|
|
592
|
+
commandOptions.highlightedField,
|
|
593
|
+
);
|
|
594
|
+
input.highlightedField = resolvedField.value;
|
|
595
|
+
}
|
|
596
|
+
|
|
582
597
|
if (isEmptyObject(input)) {
|
|
583
598
|
throw new CliError(
|
|
584
599
|
"invalid_cli_usage",
|
|
585
|
-
'Provide at least one schema field to update via "--name", "--slug", "--auditable", or "--
|
|
600
|
+
'Provide at least one schema field to update via "--name", "--slug", "--auditable", "--commentable", or "--highlighted-field".',
|
|
586
601
|
);
|
|
587
602
|
}
|
|
588
603
|
|
package/src/utils/examples.ts
CHANGED
|
@@ -228,6 +228,7 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
228
228
|
},
|
|
229
229
|
"auditable": true,
|
|
230
230
|
"commentable": true,
|
|
231
|
+
"highlightedField": "c60b8526-5835-4c9f-aecd-9a16c7704a34",
|
|
231
232
|
"fields": [
|
|
232
233
|
{
|
|
233
234
|
"id": "c60b8526-5835-4c9f-aecd-9a16c7704a34",
|
|
@@ -259,6 +260,14 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
259
260
|
command: 'zinkee --json schemas update contacts --auditable true',
|
|
260
261
|
raw: `{
|
|
261
262
|
"auditable": true
|
|
263
|
+
}`,
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
description: "Set the highlighted (main) field of a schema.",
|
|
267
|
+
command:
|
|
268
|
+
'zinkee --json schemas update contacts --highlighted-field contact-name',
|
|
269
|
+
raw: `{
|
|
270
|
+
"highlightedField": "c60b8526-5835-4c9f-aecd-9a16c7704a34"
|
|
262
271
|
}`,
|
|
263
272
|
},
|
|
264
273
|
]),
|
|
@@ -1904,6 +1913,7 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
1904
1913
|
},
|
|
1905
1914
|
"auditable": true,
|
|
1906
1915
|
"commentable": true,
|
|
1916
|
+
"highlightedField": "c60b8526-5835-4c9f-aecd-9a16c7704a34",
|
|
1907
1917
|
"fields": [
|
|
1908
1918
|
{
|
|
1909
1919
|
"id": "c60b8526-5835-4c9f-aecd-9a16c7704a34",
|