zinkee 0.1.43 → 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 +9 -4
- 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/navigation.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { ApiClient } from "../client.js";
|
|
2
|
-
import type { NormalizedUuidOrSlug } from "../parsers/selectors.js";
|
|
3
|
-
|
|
4
|
-
export interface NavigationFolder {
|
|
5
|
-
id: string;
|
|
6
|
-
order?: number;
|
|
7
|
-
name?: string;
|
|
8
|
-
resources?: Array<Record<string, unknown>>;
|
|
9
|
-
additionalProperties?: Record<string, unknown>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface NavigationFolderMutation {
|
|
13
|
-
folderId?: string;
|
|
14
|
-
name?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface NavigationMoveResourceInput {
|
|
18
|
-
resourceId: string;
|
|
19
|
-
targetFolderId: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function jsonOptions(body: unknown, method: string): RequestInit {
|
|
23
|
-
return {
|
|
24
|
-
method,
|
|
25
|
-
headers: {
|
|
26
|
-
"content-type": "application/json",
|
|
27
|
-
},
|
|
28
|
-
body: JSON.stringify(body),
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function selectorValue(selector: NormalizedUuidOrSlug): string {
|
|
33
|
-
return selector.value;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class NavigationApi {
|
|
37
|
-
constructor(private readonly client: ApiClient) {}
|
|
38
|
-
|
|
39
|
-
listFolders(): Promise<NavigationFolder[]> {
|
|
40
|
-
return this.client.getJson<NavigationFolder[]>("/api/v2/navigation/folders");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
createFolder(body: Record<string, unknown>): Promise<NavigationFolderMutation> {
|
|
44
|
-
return this.client.requestJson<NavigationFolderMutation>(
|
|
45
|
-
"/api/v2/navigation/folders",
|
|
46
|
-
jsonOptions(body, "POST"),
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
updateFolder(folder: NormalizedUuidOrSlug, body: Record<string, unknown>): Promise<NavigationFolderMutation> {
|
|
51
|
-
return this.client.requestJson<NavigationFolderMutation>(
|
|
52
|
-
`/api/v2/navigation/folders/${selectorValue(folder)}`,
|
|
53
|
-
jsonOptions(body, "PATCH"),
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
deleteFolder(folder: NormalizedUuidOrSlug): Promise<NavigationFolderMutation> {
|
|
58
|
-
return this.client.requestJson<NavigationFolderMutation>(
|
|
59
|
-
`/api/v2/navigation/folders/${selectorValue(folder)}`,
|
|
60
|
-
{ method: "DELETE" },
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
moveResource(body: NavigationMoveResourceInput): Promise<Record<string, unknown>> {
|
|
65
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
66
|
-
"/api/v2/navigation/resources:move",
|
|
67
|
-
jsonOptions(body, "POST"),
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
}
|
package/src/api/records.ts
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { ApiClient } from "../client.js";
|
|
2
|
-
import type { NormalizedUuidOrSlug } from "../parsers/selectors.js";
|
|
3
|
-
|
|
4
|
-
export interface ApiRecord {
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
recordId?: string;
|
|
7
|
-
values?: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface RecordQueryExpression {
|
|
11
|
-
field: string;
|
|
12
|
-
comparator: string;
|
|
13
|
-
value: unknown;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface RecordQuerySort {
|
|
17
|
-
field: string;
|
|
18
|
-
direction: "ASC" | "DESC";
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface RecordQueryResult {
|
|
22
|
-
records: ApiRecord[];
|
|
23
|
-
page?: Record<string, unknown>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface RecordQueryInput {
|
|
27
|
-
[key: string]: unknown;
|
|
28
|
-
select?: string[];
|
|
29
|
-
where?: RecordQueryExpression[];
|
|
30
|
-
search?: { term: string };
|
|
31
|
-
sort?: string[];
|
|
32
|
-
limit?: number;
|
|
33
|
-
offset?: number;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type CreateRecordValues = Record<string, unknown>;
|
|
37
|
-
|
|
38
|
-
export interface CreateRecordError {
|
|
39
|
-
index: number;
|
|
40
|
-
reason: string;
|
|
41
|
-
message: string;
|
|
42
|
-
action: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface CreateRecordsResult {
|
|
46
|
-
created: string[];
|
|
47
|
-
errors: CreateRecordError[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface UpdateRecordInput {
|
|
51
|
-
set?: Record<string, unknown>;
|
|
52
|
-
unset?: string[];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function jsonOptions(body: unknown, method: string): RequestInit {
|
|
56
|
-
return {
|
|
57
|
-
method,
|
|
58
|
-
headers: {
|
|
59
|
-
"content-type": "application/json",
|
|
60
|
-
},
|
|
61
|
-
body: JSON.stringify(body),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function selectorValue(selector: NormalizedUuidOrSlug): string {
|
|
66
|
-
return selector.value;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export class RecordsApi {
|
|
70
|
-
constructor(private readonly client: ApiClient) {}
|
|
71
|
-
|
|
72
|
-
listRecords(
|
|
73
|
-
schema: NormalizedUuidOrSlug,
|
|
74
|
-
query: RecordQueryInput,
|
|
75
|
-
): Promise<RecordQueryResult> {
|
|
76
|
-
const params = new URLSearchParams();
|
|
77
|
-
|
|
78
|
-
if (query.limit !== undefined) {
|
|
79
|
-
params.set("limit", String(query.limit));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (query.offset !== undefined) {
|
|
83
|
-
params.set("offset", String(query.offset));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const path = `/api/v2/schemas/${selectorValue(schema)}/records`;
|
|
87
|
-
const queryString = params.toString();
|
|
88
|
-
|
|
89
|
-
return this.client.getJson<RecordQueryResult>(
|
|
90
|
-
queryString ? `${path}?${queryString}` : path,
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
queryRecords(
|
|
95
|
-
schema: NormalizedUuidOrSlug,
|
|
96
|
-
query: RecordQueryInput,
|
|
97
|
-
): Promise<RecordQueryResult> {
|
|
98
|
-
const body = this.normalizeQueryInput(query);
|
|
99
|
-
|
|
100
|
-
return this.client.requestJson<RecordQueryResult>(
|
|
101
|
-
`/api/v2/schemas/${selectorValue(schema)}/records:query`,
|
|
102
|
-
jsonOptions(body, "POST"),
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
getRecord(
|
|
107
|
-
schema: NormalizedUuidOrSlug,
|
|
108
|
-
record: NormalizedUuidOrSlug,
|
|
109
|
-
): Promise<ApiRecord> {
|
|
110
|
-
return this.client.getJson<ApiRecord>(
|
|
111
|
-
`/api/v2/schemas/${selectorValue(schema)}/records/${selectorValue(record)}`,
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
createRecords(
|
|
116
|
-
schema: NormalizedUuidOrSlug,
|
|
117
|
-
records: CreateRecordValues[],
|
|
118
|
-
): Promise<CreateRecordsResult> {
|
|
119
|
-
return this.client.requestJson<CreateRecordsResult>(
|
|
120
|
-
`/api/v2/schemas/${selectorValue(schema)}/records`,
|
|
121
|
-
jsonOptions({ records }, "POST"),
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
updateRecord(
|
|
126
|
-
schema: NormalizedUuidOrSlug,
|
|
127
|
-
record: NormalizedUuidOrSlug,
|
|
128
|
-
input: UpdateRecordInput,
|
|
129
|
-
): Promise<ApiRecord> {
|
|
130
|
-
return this.client.requestJson<ApiRecord>(
|
|
131
|
-
`/api/v2/schemas/${selectorValue(schema)}/records/${selectorValue(record)}`,
|
|
132
|
-
jsonOptions(input, "PATCH"),
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
deleteRecords(
|
|
137
|
-
schema: NormalizedUuidOrSlug,
|
|
138
|
-
recordIds: string[],
|
|
139
|
-
): Promise<Record<string, unknown>> {
|
|
140
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
141
|
-
`/api/v2/schemas/${selectorValue(schema)}/records:delete`,
|
|
142
|
-
jsonOptions({ recordIds }, "POST"),
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
clearRecords(schema: NormalizedUuidOrSlug): Promise<Record<string, unknown>> {
|
|
147
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
148
|
-
`/api/v2/schemas/${selectorValue(schema)}/records:clear`,
|
|
149
|
-
{ method: "DELETE" },
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
private normalizeQueryInput(query: RecordQueryInput): Record<string, unknown> {
|
|
154
|
-
const where = query.where?.map((expression) => ({
|
|
155
|
-
field: expression.field,
|
|
156
|
-
op: expression.comparator,
|
|
157
|
-
value: expression.value,
|
|
158
|
-
}));
|
|
159
|
-
|
|
160
|
-
const sort = query.sort?.map((entry) => {
|
|
161
|
-
const [field, direction = "asc"] = entry.split(":");
|
|
162
|
-
return {
|
|
163
|
-
field,
|
|
164
|
-
direction: direction.toUpperCase(),
|
|
165
|
-
};
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
...query,
|
|
170
|
-
select: query.select,
|
|
171
|
-
where,
|
|
172
|
-
sort,
|
|
173
|
-
page:
|
|
174
|
-
query.limit !== undefined || query.offset !== undefined
|
|
175
|
-
? {
|
|
176
|
-
offset: query.offset,
|
|
177
|
-
limit: query.limit,
|
|
178
|
-
}
|
|
179
|
-
: undefined,
|
|
180
|
-
limit: undefined,
|
|
181
|
-
offset: undefined,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
}
|
package/src/api/schemas.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { ApiClient } from "../client.js";
|
|
2
|
-
import type { NormalizedUuidOrSlug } from "../parsers/selectors.js";
|
|
3
|
-
|
|
4
|
-
export interface ApiSchemaField {
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
id?: string;
|
|
7
|
-
type?: string;
|
|
8
|
-
slug?: string;
|
|
9
|
-
label?: string;
|
|
10
|
-
description?: string;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ApiSchema {
|
|
15
|
-
[key: string]: unknown;
|
|
16
|
-
id?: string;
|
|
17
|
-
name?: string;
|
|
18
|
-
slug?: string;
|
|
19
|
-
auditable?: boolean;
|
|
20
|
-
commentable?: boolean;
|
|
21
|
-
highlightedField?: string;
|
|
22
|
-
fields?: ApiSchemaField[];
|
|
23
|
-
uniqueFields?: string[];
|
|
24
|
-
folder?: { id?: string; name?: string | null; isRoot?: boolean };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface CreateSchemaInput {
|
|
28
|
-
name: string;
|
|
29
|
-
slug: string;
|
|
30
|
-
auditable?: boolean;
|
|
31
|
-
commentable?: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface UpdateSchemaInput {
|
|
35
|
-
name?: string;
|
|
36
|
-
slug?: string;
|
|
37
|
-
auditable?: boolean;
|
|
38
|
-
commentable?: boolean;
|
|
39
|
-
highlightedField?: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface SetUniqueFieldsInput {
|
|
43
|
-
fieldIds: string[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface CreateSchemaFieldInput {
|
|
47
|
-
[key: string]: unknown;
|
|
48
|
-
type: string;
|
|
49
|
-
slug: string;
|
|
50
|
-
label: string;
|
|
51
|
-
description?: string;
|
|
52
|
-
required?: boolean;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface UpdateSchemaFieldInput {
|
|
56
|
-
[key: string]: unknown;
|
|
57
|
-
label?: string;
|
|
58
|
-
description?: string;
|
|
59
|
-
required?: boolean;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function jsonOptions(body: unknown, method: string): RequestInit {
|
|
63
|
-
return {
|
|
64
|
-
method,
|
|
65
|
-
headers: {
|
|
66
|
-
"content-type": "application/json",
|
|
67
|
-
},
|
|
68
|
-
body: JSON.stringify(body),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function selectorValue(selector: NormalizedUuidOrSlug): string {
|
|
73
|
-
return selector.value;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export class SchemasApi {
|
|
77
|
-
constructor(private readonly client: ApiClient) {}
|
|
78
|
-
|
|
79
|
-
listSchemas(): Promise<ApiSchema[]> {
|
|
80
|
-
return this.client.getJson<ApiSchema[]>("/api/v2/schemas");
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
getSchema(schema: NormalizedUuidOrSlug): Promise<ApiSchema> {
|
|
84
|
-
return this.client.getJson<ApiSchema>(`/api/v2/schemas/${selectorValue(schema)}`);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
createSchema(input: CreateSchemaInput): Promise<ApiSchema> {
|
|
88
|
-
return this.client.requestJson<ApiSchema>("/api/v2/schemas", jsonOptions(input, "POST"));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
updateSchema(schema: NormalizedUuidOrSlug, input: UpdateSchemaInput): Promise<ApiSchema> {
|
|
92
|
-
return this.client.requestJson<ApiSchema>(
|
|
93
|
-
`/api/v2/schemas/${selectorValue(schema)}`,
|
|
94
|
-
jsonOptions(input, "PATCH"),
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
setUniqueFields(schema: NormalizedUuidOrSlug, input: SetUniqueFieldsInput): Promise<ApiSchema> {
|
|
99
|
-
return this.client.requestJson<ApiSchema>(
|
|
100
|
-
`/api/v2/schemas/${selectorValue(schema)}/unique-fields`,
|
|
101
|
-
jsonOptions(input, "PUT"),
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
deleteSchema(schema: NormalizedUuidOrSlug): Promise<Record<string, unknown>> {
|
|
106
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
107
|
-
`/api/v2/schemas/${selectorValue(schema)}`,
|
|
108
|
-
{ method: "DELETE" },
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async listFields(schema: NormalizedUuidOrSlug): Promise<ApiSchemaField[]> {
|
|
113
|
-
const result = await this.getSchema(schema);
|
|
114
|
-
|
|
115
|
-
return Array.isArray(result.fields) ? result.fields : [];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
getField(schema: NormalizedUuidOrSlug, field: NormalizedUuidOrSlug): Promise<ApiSchemaField> {
|
|
119
|
-
return this.client.getJson<ApiSchemaField>(
|
|
120
|
-
`/api/v2/schemas/${selectorValue(schema)}/fields/${selectorValue(field)}`,
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
createField(schema: NormalizedUuidOrSlug, input: CreateSchemaFieldInput): Promise<ApiSchemaField> {
|
|
125
|
-
return this.client.requestJson<ApiSchemaField>(
|
|
126
|
-
`/api/v2/schemas/${selectorValue(schema)}/fields`,
|
|
127
|
-
jsonOptions(input, "POST"),
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
updateField(
|
|
132
|
-
schema: NormalizedUuidOrSlug,
|
|
133
|
-
field: NormalizedUuidOrSlug,
|
|
134
|
-
input: UpdateSchemaFieldInput,
|
|
135
|
-
): Promise<ApiSchemaField> {
|
|
136
|
-
return this.client.requestJson<ApiSchemaField>(
|
|
137
|
-
`/api/v2/schemas/${selectorValue(schema)}/fields/${selectorValue(field)}`,
|
|
138
|
-
jsonOptions(input, "PATCH"),
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
deleteField(schema: NormalizedUuidOrSlug, field: NormalizedUuidOrSlug): Promise<Record<string, unknown>> {
|
|
143
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
144
|
-
`/api/v2/schemas/${selectorValue(schema)}/fields/${selectorValue(field)}`,
|
|
145
|
-
{ method: "DELETE" },
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
}
|
package/src/api/teamspace.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { ApiClient } from "../client.js";
|
|
2
|
-
import type { NormalizedUuidOrSlug } from "../parsers/selectors.js";
|
|
3
|
-
import type { JsonObject } from "../types.js";
|
|
4
|
-
|
|
5
|
-
export interface ApiTeamspaceResource {
|
|
6
|
-
[key: string]: unknown;
|
|
7
|
-
id?: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ApiTeamspaceFolder {
|
|
12
|
-
[key: string]: unknown;
|
|
13
|
-
id?: string;
|
|
14
|
-
name?: string;
|
|
15
|
-
order?: number;
|
|
16
|
-
additionalProperties?: JsonObject;
|
|
17
|
-
resources?: ApiTeamspaceResource[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface CreateTeamspaceFolderInput {
|
|
21
|
-
[key: string]: unknown;
|
|
22
|
-
name: string;
|
|
23
|
-
order?: number;
|
|
24
|
-
additionalProperties?: JsonObject;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface UpdateTeamspaceFolderInput {
|
|
28
|
-
[key: string]: unknown;
|
|
29
|
-
name?: string;
|
|
30
|
-
order?: number;
|
|
31
|
-
additionalProperties?: JsonObject;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface PublishTeamspaceResourceInput {
|
|
35
|
-
resourceId: string;
|
|
36
|
-
targetFolderId: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function jsonOptions(body: unknown, method: string): RequestInit {
|
|
40
|
-
return {
|
|
41
|
-
method,
|
|
42
|
-
headers: {
|
|
43
|
-
"content-type": "application/json",
|
|
44
|
-
},
|
|
45
|
-
body: JSON.stringify(body),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function selectorValue(selector: NormalizedUuidOrSlug): string {
|
|
50
|
-
return selector.value;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export class TeamspaceApi {
|
|
54
|
-
constructor(private readonly client: ApiClient) {}
|
|
55
|
-
|
|
56
|
-
listFolders(includeResources: boolean = false): Promise<ApiTeamspaceFolder[]> {
|
|
57
|
-
const params = new URLSearchParams();
|
|
58
|
-
|
|
59
|
-
if (includeResources) {
|
|
60
|
-
params.set("include", "resources");
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const path = "/api/v2/teamspaces/folders";
|
|
64
|
-
const queryString = params.toString();
|
|
65
|
-
|
|
66
|
-
return this.client.getJson<ApiTeamspaceFolder[]>(
|
|
67
|
-
queryString ? `${path}?${queryString}` : path,
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
createFolder(input: CreateTeamspaceFolderInput): Promise<ApiTeamspaceFolder> {
|
|
72
|
-
return this.client.requestJson<ApiTeamspaceFolder>(
|
|
73
|
-
"/api/v2/teamspaces/folders",
|
|
74
|
-
jsonOptions(input, "POST"),
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
updateFolder(
|
|
79
|
-
folder: NormalizedUuidOrSlug,
|
|
80
|
-
input: UpdateTeamspaceFolderInput,
|
|
81
|
-
): Promise<ApiTeamspaceFolder> {
|
|
82
|
-
return this.client.requestJson<ApiTeamspaceFolder>(
|
|
83
|
-
`/api/v2/teamspaces/folders/${selectorValue(folder)}`,
|
|
84
|
-
jsonOptions(input, "PATCH"),
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
deleteFolder(folder: NormalizedUuidOrSlug): Promise<Record<string, unknown>> {
|
|
89
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
90
|
-
`/api/v2/teamspaces/folders/${selectorValue(folder)}`,
|
|
91
|
-
{ method: "DELETE" },
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
publishResource(
|
|
96
|
-
input: PublishTeamspaceResourceInput,
|
|
97
|
-
): Promise<Record<string, unknown>> {
|
|
98
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
99
|
-
"/api/v2/teamspaces/resources:publish",
|
|
100
|
-
jsonOptions(input, "POST"),
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
unpublishResource(resourceId: string): Promise<Record<string, unknown>> {
|
|
105
|
-
return this.client.requestJson<Record<string, unknown>>(
|
|
106
|
-
"/api/v2/teamspaces/resources:unpublish",
|
|
107
|
-
jsonOptions({ resourceId }, "POST"),
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
}
|
package/src/cli-examples.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { commandRegistry } from "./command-registry.js";
|
|
2
|
-
import {
|
|
3
|
-
collectOperandTokens,
|
|
4
|
-
createDefaultOptionMetadata,
|
|
5
|
-
findCommandPath,
|
|
6
|
-
type OptionMetadata,
|
|
7
|
-
} from "./utils/argv-rewrite.js";
|
|
8
|
-
import { CliError } from "./utils/errors.js";
|
|
9
|
-
import { getResolvedCommandExamples } from "./utils/examples.js";
|
|
10
|
-
import { buildJsonSuccess } from "./utils/output.js";
|
|
11
|
-
|
|
12
|
-
interface CommandIo {
|
|
13
|
-
write(chunk: string): unknown;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface ExampleRequest {
|
|
17
|
-
commandName: string;
|
|
18
|
-
filters: {
|
|
19
|
-
type?: string;
|
|
20
|
-
};
|
|
21
|
-
json: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function getStdout(stdout?: CommandIo): CommandIo {
|
|
25
|
-
return stdout ?? process.stdout;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function extractExampleFilters(tokens: readonly string[]): { type?: string } {
|
|
29
|
-
const filters: { type?: string } = {};
|
|
30
|
-
|
|
31
|
-
for (let index = 0; index < tokens.length; index += 1) {
|
|
32
|
-
const token = tokens[index];
|
|
33
|
-
|
|
34
|
-
if (token === "--type") {
|
|
35
|
-
const value = tokens[index + 1];
|
|
36
|
-
if (value && !value.startsWith("-")) {
|
|
37
|
-
filters.type = value;
|
|
38
|
-
index += 1;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return filters;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function extractExampleRequest(
|
|
47
|
-
argv: readonly string[],
|
|
48
|
-
optionMeta: OptionMetadata = createDefaultOptionMetadata(),
|
|
49
|
-
): ExampleRequest | null {
|
|
50
|
-
if (!argv.includes("--example")) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const userArgs = argv.slice(2);
|
|
55
|
-
const operands = collectOperandTokens(userArgs, optionMeta, { skipFlag: "--example" });
|
|
56
|
-
const cmdPath = findCommandPath(operands, commandRegistry);
|
|
57
|
-
|
|
58
|
-
if (!cmdPath) {
|
|
59
|
-
const typed = operands.map((operand) => operand.token).join(" ");
|
|
60
|
-
|
|
61
|
-
if (typed.length === 0) {
|
|
62
|
-
throw new CliError("invalid_cli_usage", 'Provide a command after "--example".');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// The token(s) didn't resolve to a runnable command. If they form the prefix
|
|
66
|
-
// of one or more registered commands, the user named a command group (e.g.
|
|
67
|
-
// "schemas") — list its subcommands instead of the generic error.
|
|
68
|
-
const subcommands = Object.keys(commandRegistry).filter((name) =>
|
|
69
|
-
name.startsWith(`${typed} `),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
if (subcommands.length > 0) {
|
|
73
|
-
const list = subcommands.map((name) => ` zinkee --example ${name}`).join("\n");
|
|
74
|
-
throw new CliError(
|
|
75
|
-
"invalid_cli_usage",
|
|
76
|
-
`"${typed}" is a command group, not a runnable command. Available subcommands:\n${list}`,
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
throw new CliError("invalid_cli_usage", `Unknown command "${typed}".`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const remainingTokens = userArgs.slice(cmdPath.lastArgvIndex + 1);
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
commandName: cmdPath.commandName,
|
|
87
|
-
filters: extractExampleFilters(remainingTokens),
|
|
88
|
-
json: argv.includes("--json"),
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function showExamples(
|
|
93
|
-
commandName: string,
|
|
94
|
-
json: boolean,
|
|
95
|
-
stdout?: CommandIo,
|
|
96
|
-
filters: { type?: string } = {},
|
|
97
|
-
): void {
|
|
98
|
-
const examples = getResolvedCommandExamples(commandName, filters);
|
|
99
|
-
|
|
100
|
-
if (examples.length === 0) {
|
|
101
|
-
throw new CliError("invalid_cli_usage", `No examples registered for "${commandName}".`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const writer = getStdout(stdout);
|
|
105
|
-
|
|
106
|
-
if (json) {
|
|
107
|
-
writer.write(`${JSON.stringify(buildJsonSuccess({ examples }, { command: commandName }))}\n`);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
writer.write("Examples:\n");
|
|
112
|
-
for (const [index, example] of examples.entries()) {
|
|
113
|
-
writer.write(`\n${index + 1}. ${example.description}\n`);
|
|
114
|
-
writer.write(` ${example.command}\n`);
|
|
115
|
-
|
|
116
|
-
if (example.raw) {
|
|
117
|
-
writer.write(" Equivalent JSON payload:\n");
|
|
118
|
-
for (const line of example.raw.split("\n")) {
|
|
119
|
-
writer.write(` ${line}\n`);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (example.response) {
|
|
124
|
-
writer.write(" Example response:\n");
|
|
125
|
-
for (const line of example.response.split("\n")) {
|
|
126
|
-
writer.write(` ${line}\n`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|