zinkee 0.1.52 → 0.1.54
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 +82 -5
- package/dist/{chunk-IEW5RTJV.js → chunk-FIWBICYE.js} +7 -3
- package/dist/chunk-FIWBICYE.js.map +1 -0
- package/dist/{examples-V3PR2VTY.js → examples-BZMVRE5P.js} +59 -3
- package/dist/examples-BZMVRE5P.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +486 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-IEW5RTJV.js.map +0 -1
- package/dist/examples-V3PR2VTY.js.map +0 -1
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ Implemented command groups:
|
|
|
8
8
|
|
|
9
9
|
- `profiles`
|
|
10
10
|
- `config`
|
|
11
|
+
- `login`, `logout` and `workspaces` (superadmin sessions)
|
|
11
12
|
- `schemas`
|
|
12
13
|
- `records`
|
|
13
14
|
- `files`
|
|
@@ -61,9 +62,13 @@ default_profile = "prod"
|
|
|
61
62
|
|
|
62
63
|
[profiles.prod]
|
|
63
64
|
api_key = "token"
|
|
64
|
-
base_url = "https://api.zinkee.com"
|
|
65
|
+
base_url = "https://api-z2.zinkee.com"
|
|
65
66
|
```
|
|
66
67
|
|
|
68
|
+
`zinkee login` adds session profiles to the same file (see
|
|
69
|
+
[Superadmin sessions](#superadmin-sessions)). The CLI writes the file with mode
|
|
70
|
+
`0600` because it holds credentials.
|
|
71
|
+
|
|
67
72
|
## Global Options
|
|
68
73
|
|
|
69
74
|
| Option | Description |
|
|
@@ -71,6 +76,7 @@ base_url = "https://api.zinkee.com"
|
|
|
71
76
|
| `--profile <name>` | Select a profile from config |
|
|
72
77
|
| `--base-url <url>` | Override the configured base URL |
|
|
73
78
|
| `--api-key <token>` | Override the configured API key |
|
|
79
|
+
| `--workspace <workspace>` | Workspace name or id for a session profile (also `ZINKEE_WORKSPACE`) |
|
|
74
80
|
| `--read-only` | Run in read-only mode |
|
|
75
81
|
| `--example` | Show examples for a command |
|
|
76
82
|
| `--json` | Emit JSON output |
|
|
@@ -91,12 +97,20 @@ After installing, restart your shell.
|
|
|
91
97
|
|
|
92
98
|
The CLI resolves runtime settings with this precedence:
|
|
93
99
|
|
|
94
|
-
1. CLI flags: `--profile`, `--base-url`, `--api-key`
|
|
95
|
-
2. Environment variables: `ZINKEE_PROFILE`, `ZINKEE_API_BASE_URL`, `ZINKEE_API_KEY`
|
|
100
|
+
1. CLI flags: `--profile`, `--base-url`, `--api-key`, `--workspace`
|
|
101
|
+
2. Environment variables: `ZINKEE_PROFILE`, `ZINKEE_API_BASE_URL`, `ZINKEE_API_KEY`, `ZINKEE_WORKSPACE`
|
|
96
102
|
3. `~/.config/zinkee/config.toml`
|
|
97
103
|
|
|
98
104
|
If a runtime API key is provided, a runtime base URL must also be provided.
|
|
99
|
-
If a runtime base URL is provided, a runtime API key must also be provided.
|
|
105
|
+
If a runtime base URL is provided, a runtime API key must also be provided. A
|
|
106
|
+
session profile does not accept a runtime base URL: its URLs come from
|
|
107
|
+
`zinkee login`, because its workspace tokens only work on the Public API of the
|
|
108
|
+
backend it logged in to.
|
|
109
|
+
|
|
110
|
+
A runtime API key ignores `ZINKEE_WORKSPACE`, so tools that pass their own key
|
|
111
|
+
keep working when that variable is set; combining it with `--workspace` is an
|
|
112
|
+
error. `--workspace` and `ZINKEE_WORKSPACE` only work with a session profile,
|
|
113
|
+
and a session profile requires one of them.
|
|
100
114
|
|
|
101
115
|
Example for local development without config:
|
|
102
116
|
|
|
@@ -112,6 +126,66 @@ Example using an env-selected profile:
|
|
|
112
126
|
ZINKEE_PROFILE=local zinkee --json schemas list
|
|
113
127
|
```
|
|
114
128
|
|
|
129
|
+
## Superadmin sessions
|
|
130
|
+
|
|
131
|
+
Zinkee superadmins can work on any client workspace with their own user instead
|
|
132
|
+
of one API-key profile per client:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
zinkee login # email + hidden password
|
|
136
|
+
zinkee workspaces list # organizations and workspaces
|
|
137
|
+
zinkee --workspace "Client X" schemas list # or ZINKEE_WORKSPACE="Client X"
|
|
138
|
+
zinkee logout
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`zinkee login` signs in against the web backend and stores a session profile,
|
|
142
|
+
named `superadmin` unless `--profile` says otherwise (`ZINKEE_PROFILE` is
|
|
143
|
+
ignored by `login` and `logout`). It becomes the default profile only when no
|
|
144
|
+
default is set, and it never overwrites an API-key profile.
|
|
145
|
+
|
|
146
|
+
```toml
|
|
147
|
+
[profiles.superadmin]
|
|
148
|
+
type = "session"
|
|
149
|
+
backend_url = "https://backend-z2.zinkee.com"
|
|
150
|
+
base_url = "https://api-z2.zinkee.com"
|
|
151
|
+
email = "user@zinkee.com"
|
|
152
|
+
session_token = "<jwt>"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
- The email comes from `--email`, the stored profile or a prompt. The password
|
|
156
|
+
is read with a hidden prompt on an interactive terminal, or from stdin with
|
|
157
|
+
`--password-stdin` (only one trailing newline is removed). Without a terminal
|
|
158
|
+
and without `--password-stdin`, `login` fails instead of waiting.
|
|
159
|
+
- A session involves two URLs: the web backend (`--backend-url`, default
|
|
160
|
+
`https://backend-z2.zinkee.com`) and the Public API (`--base-url`, default
|
|
161
|
+
`https://api-z2.zinkee.com`). They must belong to the same environment, so
|
|
162
|
+
pass both for any other environment. A new `login` without URL flags reuses
|
|
163
|
+
the stored URLs and email; with URL flags it needs both, never pairing a new
|
|
164
|
+
one with a stored one. `profiles update` does not accept session profiles: change their
|
|
165
|
+
environment with `login --backend-url ... --base-url ...`.
|
|
166
|
+
- On each run, a command with a session profile exchanges the session for a
|
|
167
|
+
short-lived token of the selected workspace on its first request and uses it
|
|
168
|
+
against the Public API; nothing is cached between runs. `--workspace` accepts
|
|
169
|
+
the exact name, a name with different casing or the workspace id; run
|
|
170
|
+
`zinkee workspaces list` to see them. Only superadmins can use this exchange.
|
|
171
|
+
- Every run checks the stored session first. If it is missing or expired, the
|
|
172
|
+
command fails with `authentication_required` and exit code `3` before any
|
|
173
|
+
network call; run `zinkee login --profile <name>` again.
|
|
174
|
+
- `zinkee logout` only removes the token from the config file. The backend
|
|
175
|
+
cannot revoke it, so it stays valid until it expires.
|
|
176
|
+
- `profiles` and `config show` list session profiles as `session <email>` and
|
|
177
|
+
always redact the token.
|
|
178
|
+
|
|
179
|
+
Local stack example (use the backend and Public API URLs printed by the runner):
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
zinkee login --profile local \
|
|
183
|
+
--backend-url http://127.0.0.1:<backend-port> \
|
|
184
|
+
--base-url http://127.0.0.1:<api-port> \
|
|
185
|
+
--email "<email>" --password-stdin < <private file or pipe>
|
|
186
|
+
zinkee --profile local --workspace "Template BBUU" --read-only schemas list
|
|
187
|
+
```
|
|
188
|
+
|
|
115
189
|
## JSON Contract
|
|
116
190
|
|
|
117
191
|
Successful commands emit:
|
|
@@ -328,7 +402,10 @@ Option values are written as numbers (`--set status=1`) but returned as strings
|
|
|
328
402
|
|
|
329
403
|
`records clear` removes every record from the schema's table. Heritage rules
|
|
330
404
|
(`CASCADE` / `SET NULL`) propagate to child schemas asynchronously through the
|
|
331
|
-
CDC pipeline, so related tables converge eventually.
|
|
405
|
+
CDC pipeline, so related tables converge eventually. A `RESTRICT` reference that
|
|
406
|
+
holds any child record refuses the clear (409 `data_dependency_conflict`), as it
|
|
407
|
+
refuses `records delete` of a record it points at; nothing is deleted. Blocked by
|
|
408
|
+
`--read-only`.
|
|
332
409
|
|
|
333
410
|
---
|
|
334
411
|
|
|
@@ -133,6 +133,7 @@ var ApiClient = class {
|
|
|
133
133
|
this.fetchImpl = options.fetch ?? fetch;
|
|
134
134
|
}
|
|
135
135
|
fetchImpl;
|
|
136
|
+
tokenPromise;
|
|
136
137
|
getJson(path, init = {}) {
|
|
137
138
|
return this.requestJson(path, { ...init, method: "GET" });
|
|
138
139
|
}
|
|
@@ -173,8 +174,9 @@ var ApiClient = class {
|
|
|
173
174
|
if (accept && !headers.has("accept")) {
|
|
174
175
|
headers.set("accept", accept);
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
const token = this.options.getToken ? await (this.tokenPromise ??= this.options.getToken()) : this.options.apiKey;
|
|
178
|
+
if (token && !headers.has("authorization")) {
|
|
179
|
+
headers.set("authorization", `Bearer ${token}`);
|
|
178
180
|
}
|
|
179
181
|
const controller = new AbortController();
|
|
180
182
|
const timeoutMs = init.timeoutMs ?? this.options.timeoutMs;
|
|
@@ -260,6 +262,7 @@ var cliExitCodeByErrorCode = {
|
|
|
260
262
|
unknown_error: 1,
|
|
261
263
|
invalid_cli_usage: 2,
|
|
262
264
|
configuration_error: 2,
|
|
265
|
+
authentication_required: 3,
|
|
263
266
|
command_not_allowed_in_read_only_mode: 7,
|
|
264
267
|
network_error: 1,
|
|
265
268
|
http_error: 1,
|
|
@@ -1249,6 +1252,7 @@ export {
|
|
|
1249
1252
|
folderColumns,
|
|
1250
1253
|
printTable,
|
|
1251
1254
|
CliError,
|
|
1255
|
+
toCliError,
|
|
1252
1256
|
getExitCode,
|
|
1253
1257
|
formatCliErrorText,
|
|
1254
1258
|
formatCliErrorJson,
|
|
@@ -1262,4 +1266,4 @@ export {
|
|
|
1262
1266
|
buildSchemaFieldCreateHelpText,
|
|
1263
1267
|
buildSchemaFieldCreateValidationMessage
|
|
1264
1268
|
};
|
|
1265
|
-
//# sourceMappingURL=chunk-
|
|
1269
|
+
//# sourceMappingURL=chunk-FIWBICYE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/output.ts","../src/client.ts","../src/utils/errors.ts","../src/utils/schema-fields.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport type {\n JsonEnvelopeMeta,\n JsonErrorEnvelope,\n JsonSuccessEnvelope,\n} from \"../types.js\";\n\nconst require = createRequire(import.meta.url);\n\nexport interface OutputWriter {\n write(chunk: string): unknown;\n}\n\nfunction stringifyCellValue(value: unknown): string {\n if (value === null || value === undefined) {\n return \"\";\n }\n\n if (typeof value === \"string\") {\n return value;\n }\n\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") {\n return String(value);\n }\n\n return JSON.stringify(value);\n}\n\nexport function buildJsonSuccess<TData, TMeta extends JsonEnvelopeMeta = JsonEnvelopeMeta>(\n data: TData,\n meta: TMeta = {} as TMeta,\n): JsonSuccessEnvelope<TData, TMeta> {\n return { data, meta };\n}\n\nexport function buildJsonError<TErr, TMeta extends JsonEnvelopeMeta = JsonEnvelopeMeta>(\n error: TErr,\n meta: TMeta = {} as TMeta,\n): JsonErrorEnvelope<TErr, TMeta> {\n return { error, meta };\n}\n\nexport interface FolderLocation {\n id?: string;\n name?: string | null;\n isRoot?: boolean;\n}\n\n/** Column keys, in order, produced by {@link folderColumns}. Append them to a table's key list. */\nexport const FOLDER_TABLE_KEYS = [\"folderId\", \"folderName\", \"folderIsRoot\"] as const;\n\n/**\n * Flattens the API `folder` object (`{ id, name, isRoot }`) into the folderId/folderName/folderIsRoot table columns.\n * The root folder arrives with a null name, so folderName renders it as \"(root)\". A missing folder (e.g. a workspace\n * without a default group) leaves every column empty.\n */\nexport function folderColumns(folder: FolderLocation | null | undefined): {\n folderId: string;\n folderName: string;\n folderIsRoot: string;\n} {\n if (!folder) {\n return { folderId: \"\", folderName: \"\", folderIsRoot: \"\" };\n }\n\n return {\n folderId: folder.id ?? \"\",\n folderName: folder.name ?? (folder.isRoot === true ? \"(root)\" : \"\"),\n folderIsRoot: folder.isRoot === undefined ? \"\" : String(folder.isRoot),\n };\n}\n\nexport function printTable(\n rows: readonly Record<string, unknown>[],\n keys?: readonly string[],\n writer?: OutputWriter,\n): void {\n const output = writer ?? process.stdout;\n const firstRow = rows[0];\n\n if (!firstRow) {\n output.write(\"No results.\\n\");\n return;\n }\n\n const headings = [...(keys ?? Object.keys(firstRow))];\n const Table = require(\"cli-table3\") as typeof import(\"cli-table3\");\n const table = new Table({\n head: headings,\n wordWrap: true,\n });\n\n for (const row of rows) {\n table.push(headings.map((heading) => stringifyCellValue(row[heading])));\n }\n\n output.write(`${table.toString()}\\n`);\n}\n","import { createRequire } from \"node:module\";\nimport { Readable, Transform, type Writable } from \"node:stream\";\nimport { pipeline } from \"node:stream/promises\";\n\nconst require = createRequire(import.meta.url);\nconst { version } = require(\"../package.json\") as { version: string };\n\nexport interface ApiClientOptions {\n baseUrl: string;\n apiKey?: string;\n /** Resolves the bearer token on the first request instead of apiKey; called at most once. */\n getToken?: () => Promise<string>;\n timeoutMs?: number;\n fetch?: typeof fetch;\n}\n\nexport type ApiClientErrorCode =\n | \"network_error\"\n | \"http_error\"\n | \"timeout\"\n | \"invalid_json\";\n\nexport interface ApiClientErrorDetails {\n url: string;\n method: string;\n status?: number;\n responseBody?: unknown;\n responseText?: string;\n cause?: unknown;\n}\n\nexport class ApiClientError extends Error {\n override name = \"ApiClientError\";\n\n readonly code: ApiClientErrorCode;\n\n readonly url: string;\n\n readonly method: string;\n\n readonly status?: number;\n\n readonly responseBody?: unknown;\n\n readonly responseText?: string;\n\n override readonly cause?: unknown;\n\n constructor(\n code: ApiClientErrorCode,\n message: string,\n details: ApiClientErrorDetails,\n ) {\n super(message);\n this.code = code;\n this.url = details.url;\n this.method = details.method;\n this.status = details.status;\n this.responseBody = details.responseBody;\n this.responseText = details.responseText;\n this.cause = details.cause;\n }\n}\n\nexport interface ApiRequestOptions extends RequestInit {\n timeoutMs?: number;\n}\n\nfunction isJsonContentType(contentType: string | null): boolean {\n return contentType ? /(^|\\/|\\+)json\\b/i.test(contentType) : false;\n}\n\nfunction looksLikeJson(text: string): boolean {\n const trimmed = text.trim();\n\n return (\n trimmed.startsWith(\"{\") ||\n trimmed.startsWith(\"[\") ||\n trimmed === \"null\" ||\n trimmed === \"true\" ||\n trimmed === \"false\" ||\n /^-?(0|[1-9]\\d*)(\\.\\d+)?([eE][+-]?\\d+)?$/.test(trimmed) ||\n trimmed.startsWith('\"')\n );\n}\n\nfunction parseJsonBody<T>(text: string, url: string, method: string): T {\n const trimmed = text.trim();\n\n if (trimmed.length === 0) {\n return undefined as T;\n }\n\n try {\n return JSON.parse(trimmed) as T;\n } catch (cause) {\n throw new ApiClientError(\"invalid_json\", `Failed to parse JSON response from ${method} ${url}.`, {\n url,\n method,\n responseText: text,\n cause,\n });\n }\n}\n\nfunction parseErrorBody(text: string, contentType: string | null): unknown {\n if (text.trim().length === 0) {\n return undefined;\n }\n\n if (!isJsonContentType(contentType) && !looksLikeJson(text)) {\n return text;\n }\n\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n}\n\nfunction summarizeNetworkCause(cause: unknown): string | undefined {\n const seen = new Set<unknown>();\n let current: unknown = cause;\n\n while (current && typeof current === \"object\" && !seen.has(current)) {\n seen.add(current);\n\n const candidate = current as { message?: unknown; code?: unknown; cause?: unknown };\n const message = typeof candidate.message === \"string\" ? candidate.message.trim() : \"\";\n const code = typeof candidate.code === \"string\" ? candidate.code : undefined;\n\n if (message && message !== \"fetch failed\") {\n return code && !message.includes(code) ? `${message} (${code})` : message;\n }\n\n current = candidate.cause;\n }\n\n return undefined;\n}\n\nexport class ApiClient {\n private readonly fetchImpl: typeof fetch;\n\n private tokenPromise?: Promise<string>;\n\n constructor(private readonly options: ApiClientOptions) {\n this.fetchImpl = options.fetch ?? fetch;\n }\n\n getJson<T>(path: string, init: ApiRequestOptions = {}): Promise<T> {\n return this.requestJson<T>(path, { ...init, method: \"GET\" });\n }\n\n requestJson<T>(path: string, init: ApiRequestOptions = {}): Promise<T> {\n return this.request(\n path,\n init,\n async (response, url) => {\n const text = await response.text();\n return parseJsonBody<T>(text, url, init.method ?? \"GET\");\n },\n \"application/json\",\n );\n }\n\n download(\n path: string,\n destination: Writable,\n init: ApiRequestOptions = {},\n ): Promise<number> {\n return this.request(path, init, async (response, _url, signal) => {\n let bytes = 0;\n const counter = new Transform({\n transform(chunk: Buffer, _encoding, callback) {\n bytes += chunk.length;\n callback(null, chunk);\n },\n });\n const source = response.body\n ? Readable.fromWeb(response.body as Parameters<typeof Readable.fromWeb>[0])\n : Readable.from([]);\n\n await pipeline(source, counter, destination, { signal });\n return bytes;\n });\n }\n\n private buildUrl(path: string): string {\n const normalizedPath = path.startsWith(\"/\") ? path : `/${path}`;\n\n return new URL(normalizedPath, this.options.baseUrl).toString();\n }\n\n private async request<T>(\n path: string,\n init: ApiRequestOptions,\n consume: (response: Response, url: string, signal: AbortSignal) => Promise<T>,\n accept?: string,\n ): Promise<T> {\n const url = this.buildUrl(path);\n const method = init.method ?? \"GET\";\n const headers = new Headers(init.headers);\n headers.set(\"user-agent\", `zinkee-cli/${version}`);\n\n if (accept && !headers.has(\"accept\")) {\n headers.set(\"accept\", accept);\n }\n\n // Awaited outside the try below so its own errors are not reported as network errors.\n const token = this.options.getToken\n ? await (this.tokenPromise ??= this.options.getToken())\n : this.options.apiKey;\n\n if (token && !headers.has(\"authorization\")) {\n headers.set(\"authorization\", `Bearer ${token}`);\n }\n\n const controller = new AbortController();\n const timeoutMs = init.timeoutMs ?? this.options.timeoutMs;\n let timedOut = false;\n let timeoutHandle: ReturnType<typeof setTimeout> | undefined;\n\n const abortListener = (): void => {\n controller.abort(init.signal?.reason);\n };\n\n if (init.signal) {\n if (init.signal.aborted) {\n controller.abort(init.signal.reason);\n } else {\n init.signal.addEventListener(\"abort\", abortListener, { once: true });\n }\n }\n\n if (timeoutMs !== undefined) {\n timeoutHandle = setTimeout(() => {\n if (!controller.signal.aborted) {\n timedOut = true;\n controller.abort();\n }\n }, timeoutMs);\n }\n\n try {\n controller.signal.throwIfAborted();\n const response = await this.fetchImpl(url, {\n ...init,\n headers,\n signal: controller.signal,\n });\n const responseUrl = response.url || url;\n\n if (!response.ok) {\n const text = await response.text();\n throw this.buildHttpError(response, text, init, responseUrl);\n }\n\n return await consume(response, responseUrl, controller.signal);\n } catch (cause) {\n if (cause instanceof ApiClientError) {\n throw cause;\n }\n\n if (timedOut) {\n throw new ApiClientError(\"timeout\", `Request timed out after ${timeoutMs}ms.`, {\n url,\n method,\n cause,\n });\n }\n\n const causeSummary = summarizeNetworkCause(cause);\n const message = causeSummary\n ? `Request failed for ${method} ${url}: ${causeSummary}.`\n : `Request failed for ${method} ${url}.`;\n\n throw new ApiClientError(\"network_error\", message, {\n url,\n method,\n cause,\n });\n } finally {\n if (timeoutHandle !== undefined) {\n clearTimeout(timeoutHandle);\n }\n\n if (init.signal) {\n init.signal.removeEventListener(\"abort\", abortListener);\n }\n }\n }\n\n private buildHttpError(\n response: Response,\n text: string,\n init: ApiRequestOptions,\n url: string,\n ): ApiClientError {\n const method = init.method ?? \"GET\";\n const responseBody = parseErrorBody(text, response.headers.get(\"content-type\"));\n\n return new ApiClientError(\n \"http_error\",\n `Request failed with status ${response.status} for ${method} ${url}.`,\n {\n url,\n method,\n status: response.status,\n responseBody,\n responseText: responseBody === text ? text : undefined,\n },\n );\n }\n}\n","import { ApiClientError } from \"../client.js\";\nimport type { JsonEnvelopeMeta, JsonErrorEnvelope } from \"../types.js\";\n\nimport { buildJsonError } from \"./output.js\";\n\nexport type CliErrorCode =\n | \"unknown_error\"\n | \"invalid_cli_usage\"\n | \"configuration_error\"\n | \"authentication_required\"\n | \"command_not_allowed_in_read_only_mode\"\n | \"network_error\"\n | \"http_error\"\n | \"timeout\"\n | \"invalid_json\";\n\nexport const cliExitCodeByErrorCode = {\n unknown_error: 1,\n invalid_cli_usage: 2,\n configuration_error: 2,\n authentication_required: 3,\n command_not_allowed_in_read_only_mode: 7,\n network_error: 1,\n http_error: 1,\n timeout: 1,\n invalid_json: 1,\n} as const satisfies Record<CliErrorCode, number>;\n\nexport interface CliErrorDetails {\n [key: string]: unknown;\n}\n\nexport interface CliErrorPayload {\n code: CliErrorCode;\n message: string;\n exitCode: number;\n details?: CliErrorDetails;\n}\n\nconst errorCodeByName: Record<string, CliErrorCode> = {\n ProfileResolutionError: \"configuration_error\",\n};\n\nexport class CliError extends Error {\n override name = \"CliError\";\n\n readonly code: CliErrorCode;\n\n readonly exitCode: number;\n\n readonly details?: CliErrorDetails;\n\n constructor(\n code: CliErrorCode,\n message: string,\n details: CliErrorDetails = {},\n exitCode: number = cliExitCodeByErrorCode[code],\n ) {\n super(message);\n this.code = code;\n this.exitCode = exitCode;\n\n if (Object.keys(details).length > 0) {\n this.details = details;\n }\n }\n\n toJSON(): CliErrorPayload {\n const payload: CliErrorPayload = {\n code: this.code,\n message: this.message,\n exitCode: this.exitCode,\n };\n\n if (this.details) {\n payload.details = this.details;\n }\n\n return payload;\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction readString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim().length > 0 ? value : undefined;\n}\n\nfunction readNumber(value: unknown): number | undefined {\n return typeof value === \"number\" ? value : undefined;\n}\n\nfunction extractApiErrorDetails(error: ApiClientError): {\n message: string;\n details: CliErrorDetails;\n meta: JsonEnvelopeMeta;\n} {\n const details: CliErrorDetails = {};\n const meta: JsonEnvelopeMeta = {};\n const responseBody = isRecord(error.responseBody) ? error.responseBody : undefined;\n const errorBody = responseBody?.error;\n const backendError = isRecord(errorBody) ? errorBody : responseBody;\n const backendMeta = isRecord(responseBody?.meta) ? responseBody.meta : undefined;\n const reason =\n readString(backendError?.reason) ??\n readString(backendError?.code);\n const action = readString(backendError?.action);\n const requestId =\n readString(backendMeta?.requestId) ??\n readString(responseBody?.requestId) ??\n readString(backendError?.requestId);\n const status =\n readNumber(backendError?.status) ??\n readNumber(responseBody?.status) ??\n error.status;\n const backendMessage = readString(backendError?.message);\n\n if (reason !== undefined) {\n details.reason = reason;\n }\n\n if (action !== undefined) {\n details.action = action;\n }\n\n if (requestId !== undefined) {\n details.requestId = requestId;\n meta.requestId = requestId;\n }\n\n if (status !== undefined) {\n details.status = status;\n meta.status = status;\n }\n\n return {\n message: backendMessage ?? error.message,\n details,\n meta,\n };\n}\n\nexport function toCliError(error: unknown): CliError {\n if (error instanceof CliError) {\n return error;\n }\n\n if (error instanceof ApiClientError) {\n const apiError = extractApiErrorDetails(error);\n\n return new CliError(error.code, apiError.message, apiError.details);\n }\n\n if (error instanceof Error) {\n return new CliError(errorCodeByName[error.name] ?? \"unknown_error\", error.message);\n }\n\n return new CliError(\"unknown_error\", \"Unknown error\");\n}\n\nexport function getExitCode(error: unknown): number {\n return toCliError(error).exitCode;\n}\n\nexport function buildJsonCliError<TMeta extends JsonEnvelopeMeta = JsonEnvelopeMeta>(\n error: unknown,\n meta: TMeta = {} as TMeta,\n): JsonErrorEnvelope<CliErrorPayload, TMeta> {\n const cliError = toCliError(error);\n const apiErrorMeta =\n error instanceof ApiClientError\n ? extractApiErrorDetails(error).meta\n : {};\n\n return buildJsonError(cliError.toJSON(), { ...apiErrorMeta, ...meta } as TMeta);\n}\n\nexport function formatCliErrorText(error: unknown): string {\n return toCliError(error).message;\n}\n\nexport function formatCliErrorJson<TMeta extends JsonEnvelopeMeta = JsonEnvelopeMeta>(\n error: unknown,\n meta: TMeta = {} as TMeta,\n): string {\n return JSON.stringify(buildJsonCliError(error, meta));\n}\n","import type { JsonObject } from \"../types.js\";\nimport { CliError } from \"./errors.js\";\n\nexport type SchemaFieldTypeKey =\n | \"text\"\n | \"number\"\n | \"date\"\n | \"option\"\n | \"file\"\n | \"reference\"\n | \"formula\"\n | \"member\"\n | \"autoincremental\"\n | \"schedule\";\n\nexport interface SchemaFieldExamplePayload {\n name: string;\n payload: JsonObject;\n}\n\nexport interface SchemaFieldTypeDefinition {\n key: SchemaFieldTypeKey;\n className: string;\n aliases: readonly string[];\n description: string;\n rawShape: string;\n examplePayloads: readonly SchemaFieldExamplePayload[];\n}\n\nfunction isJsonObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction toJsonObject(value: unknown): JsonObject | undefined {\n return isJsonObject(value) ? value : undefined;\n}\n\nfunction toStringValue(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim().length > 0 ? value : undefined;\n}\n\nfunction toNumberValue(value: unknown): number | undefined {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n\n if (typeof value === \"string\" && value.trim().length > 0) {\n const parsed = Number(value);\n if (Number.isFinite(parsed)) {\n return parsed;\n }\n }\n\n return undefined;\n}\n\nconst fieldTypeDefinitions = [\n {\n key: \"text\",\n className: \"TextField\",\n aliases: [\"text\", \"TextField\"],\n description: \"Plain text field.\",\n rawShape:\n '{\"type\":\"TextField\",\"slug\":\"name\",\"label\":\"Name\",\"config\":{\"textType\":\"NORMAL\"}}',\n examplePayloads: [\n {\n name: \"Text field (normal)\",\n payload: {\n type: \"TextField\",\n slug: \"customer-name\",\n label: \"Customer Name\",\n required: true,\n config: {\n textType: \"NORMAL\",\n defaultValue: null,\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Text field (long)\",\n payload: {\n type: \"TextField\",\n slug: \"customer-notes\",\n label: \"Customer Notes\",\n required: false,\n config: {\n textType: \"LONG\",\n defaultValue: \"Add internal notes here...\",\n conditionalFormatting: [],\n },\n },\n },\n ],\n },\n {\n key: \"number\",\n className: \"NumberField\",\n aliases: [\"number\", \"NumberField\"],\n description: \"Numeric field.\",\n rawShape:\n '{\"type\":\"NumberField\",\"slug\":\"quantity\",\"label\":\"Quantity\",\"config\":{\"defaultValue\":\"0\",\"formatOptions\":{\"format\":\"number\",\"decimals\":0,\"thousandsSeparator\":false}}}',\n examplePayloads: [\n {\n name: \"Number field (plain integer)\",\n payload: {\n type: \"NumberField\",\n slug: \"quantity\",\n label: \"Quantity\",\n required: false,\n config: {\n defaultValue: \"0\",\n formatOptions: {\n format: \"number\",\n decimals: 0,\n thousandsSeparator: false,\n },\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Number field (decimal with thousands)\",\n payload: {\n type: \"NumberField\",\n slug: \"weight\",\n label: \"Weight (kg)\",\n required: false,\n config: {\n defaultValue: \"0\",\n formatOptions: {\n format: \"number\",\n decimals: 2,\n thousandsSeparator: true,\n negativesInRed: false,\n },\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Number field (currency € prefix)\",\n payload: {\n type: \"NumberField\",\n slug: \"amount-eur\",\n label: \"Amount (EUR)\",\n required: false,\n config: {\n defaultValue: \"0\",\n formatOptions: {\n format: \"currency\",\n decimals: 2,\n negativesInRed: true,\n thousandsSeparator: true,\n symbolEnabled: true,\n symbolPosition: \"before\",\n symbolValue: \"€\",\n },\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Number field (currency $ suffix)\",\n payload: {\n type: \"NumberField\",\n slug: \"amount-usd\",\n label: \"Amount (USD)\",\n required: false,\n config: {\n defaultValue: \"0\",\n formatOptions: {\n format: \"currency\",\n decimals: 2,\n negativesInRed: false,\n thousandsSeparator: true,\n symbolEnabled: true,\n symbolPosition: \"right\",\n symbolValue: \" $\",\n },\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Number field (percentage)\",\n payload: {\n type: \"NumberField\",\n slug: \"discount-rate\",\n label: \"Discount Rate\",\n required: false,\n config: {\n defaultValue: \"0\",\n formatOptions: {\n format: \"percentage\",\n decimals: 1,\n negativesInRed: true,\n },\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Number field (duration HH:MM)\",\n payload: {\n type: \"NumberField\",\n slug: \"tracked-time\",\n label: \"Tracked Time\",\n required: false,\n config: {\n defaultValue: \"0\",\n formatOptions: {\n format: \"duration\",\n durationFormat: \"HH:MM\",\n },\n conditionalFormatting: [],\n },\n },\n },\n ],\n },\n {\n key: \"date\",\n className: \"DateField\",\n aliases: [\"date\", \"DateField\"],\n description: \"Date or datetime field.\",\n rawShape:\n '{\"type\":\"DateField\",\"slug\":\"due-date\",\"label\":\"Due Date\",\"config\":{\"formatOptions\":{\"format\":\"date\",\"dateFormat\":\"YYYY-MM-DD\",\"showTime\":false}}}',\n examplePayloads: [\n {\n name: \"Date field (date only)\",\n payload: {\n type: \"DateField\",\n slug: \"birth-date\",\n label: \"Birth Date\",\n required: false,\n config: {\n defaultValue: null,\n formatOptions: {\n format: \"date\",\n dateFormat: \"YYYY-MM-DD\",\n showTime: false,\n },\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Date field (datetime EU)\",\n payload: {\n type: \"DateField\",\n slug: \"due-date\",\n label: \"Due Date\",\n required: false,\n config: {\n defaultValue: null,\n formatOptions: {\n format: \"datetime\",\n dateFormat: \"DD/MM/YYYY\",\n showTime: true,\n },\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Date field (datetime US)\",\n payload: {\n type: \"DateField\",\n slug: \"appointment-at\",\n label: \"Appointment\",\n required: false,\n config: {\n defaultValue: null,\n formatOptions: {\n format: \"datetime\",\n dateFormat: \"MM/DD/YYYY\",\n showTime: true,\n },\n conditionalFormatting: [],\n },\n },\n },\n ],\n },\n {\n key: \"option\",\n className: \"OptionField\",\n aliases: [\"option\", \"OptionField\"],\n description: \"Dropdown/select field with options.\",\n rawShape:\n '{\"type\":\"OptionField\",\"slug\":\"status\",\"label\":\"Status\",\"config\":{\"options\":[{\"id\":1,\"name\":\"Open\",\"color\":\"default\"},{\"id\":2,\"name\":\"Closed\",\"color\":\"success\"}]}}',\n examplePayloads: [\n {\n name: \"Option field (select dropdown)\",\n payload: {\n type: \"OptionField\",\n slug: \"priority\",\n label: \"Priority\",\n required: false,\n config: {\n options: [\n { id: 1, name: \"Low\", color: \"default\" },\n { id: 2, name: \"Medium\", color: \"warning\" },\n { id: 3, name: \"High\", color: \"cond-critico\" },\n ],\n defaultValue: 1,\n conditionalFormatting: [],\n buttonConfig: null,\n },\n },\n },\n {\n name: \"Option field (button cycle)\",\n payload: {\n type: \"OptionField\",\n slug: \"stage\",\n label: \"Stage\",\n required: false,\n config: {\n options: [\n { id: 1, name: \"To Do\", color: \"default\" },\n { id: 2, name: \"Doing\", color: \"warning\" },\n { id: 3, name: \"Done\", color: \"success\" },\n ],\n defaultValue: 1,\n conditionalFormatting: [],\n buttonConfig: {\n displayMode: \"button\",\n buttonBehavior: {\n mode: \"cycle\",\n cycleOrder: [1, 2, 3],\n requireConfirmation: false,\n lockAfterSelection: false,\n allowReselect: true,\n },\n },\n },\n },\n },\n {\n name: \"Option field (button dropdown w/ confirm)\",\n payload: {\n type: \"OptionField\",\n slug: \"status\",\n label: \"Status\",\n required: false,\n config: {\n options: [\n { id: 1, name: \"Open\", color: \"default\" },\n { id: 2, name: \"In Progress\", color: \"warning\" },\n { id: 3, name: \"Done\", color: \"success\" },\n ],\n defaultValue: 1,\n conditionalFormatting: [],\n buttonConfig: {\n displayMode: \"button\",\n buttonBehavior: {\n mode: \"dropdown\",\n requireConfirmation: true,\n confirmationMessage: \"Confirm status change\",\n useFixedLabel: true,\n buttonLabel: \"Set status\",\n allowReselect: true,\n },\n },\n },\n },\n },\n ],\n },\n {\n key: \"file\",\n className: \"FileField\",\n aliases: [\"file\", \"FileField\"],\n description: \"File attachment field.\",\n rawShape:\n '{\"type\":\"FileField\",\"slug\":\"attachment\",\"label\":\"Attachment\",\"config\":{}}',\n examplePayloads: [\n {\n name: \"File field\",\n payload: {\n type: \"FileField\",\n slug: \"attachment\",\n label: \"Attachment\",\n required: false,\n config: {},\n },\n },\n ],\n },\n {\n key: \"reference\",\n className: \"ReferenceField\",\n aliases: [\"reference\", \"ReferenceField\"],\n description: \"Reference to another schema.\",\n rawShape:\n '{\"type\":\"ReferenceField\",\"slug\":\"company-ref\",\"label\":\"Company\",\"config\":{\"targetSchema\":\"<schema-uuid>\",\"targetDisplayField\":\"<field-uuid>\"}}',\n examplePayloads: [\n {\n name: \"Reference field (minimal)\",\n payload: {\n type: \"ReferenceField\",\n slug: \"company-ref\",\n label: \"Company\",\n required: false,\n config: {\n targetSchema: \"5223cbc8-8c6c-4694-93bc-dd176364df9b\",\n targetDisplayField: \"c60b8526-5835-4c9f-aecd-9a16c7704a34\",\n },\n },\n },\n {\n name: \"Reference field (restrict + filter + description)\",\n payload: {\n type: \"ReferenceField\",\n slug: \"customer-ref\",\n label: \"Customer\",\n required: false,\n config: {\n targetSchema: \"5223cbc8-8c6c-4694-93bc-dd176364df9b\",\n targetDisplayField: \"c60b8526-5835-4c9f-aecd-9a16c7704a34\",\n deleteBehavior: \"RESTRICT\",\n defaultValue: \"CUST-12\",\n filterFields: [\n {\n fatherField: \"c60b8526-5835-4c9f-aecd-9a16c7704a34\",\n currentField: \"45c5da96-0dc2-4cc1-ba61-7660a9c6da32\",\n comparison: \"EQUAL\",\n value: null,\n },\n ],\n descriptionFields: [\n {\n id: \"c52efe3f-2825-4c60-a7e3-34dd4c1ce043\",\n fieldType: \"NumberField\",\n options: null,\n format: \"number\",\n },\n ],\n conditionalFormatting: [],\n },\n },\n },\n ],\n },\n {\n key: \"formula\",\n className: \"FormulaField\",\n aliases: [\"formula\", \"FormulaField\"],\n description: \"Calculated field from a formula.\",\n rawShape:\n '{\"type\":\"FormulaField\",\"slug\":\"formula-code\",\"label\":\"Formula Code\",\"config\":{\"formulaText\":\"concat(\\\\\"CUST-\\\\\", f1e1d000-0000-0000-0000-000000000005)\",\"uiFormatKind\":\"none\"}}',\n examplePayloads: [\n {\n name: \"Formula field (none)\",\n payload: {\n type: \"FormulaField\",\n slug: \"formula-code\",\n label: \"Formula Code\",\n required: false,\n config: {\n formulaText:\n 'concat(\"CUST-\", f1e1d000-0000-0000-0000-000000000005)',\n uiFormatKind: \"none\",\n status: \"ACTIVE\",\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Formula field (number)\",\n payload: {\n type: \"FormulaField\",\n slug: \"formula-total\",\n label: \"Formula Total\",\n required: false,\n config: {\n formulaText: \"c52efe3f-2825-4c60-a7e3-34dd4c1ce043 * 1.21\",\n uiFormatKind: \"number\",\n status: \"ACTIVE\",\n numberFormatOptions: {\n format: \"number\",\n decimals: 2,\n thousandsSeparator: true,\n },\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Formula field (date)\",\n payload: {\n type: \"FormulaField\",\n slug: \"formula-period\",\n label: \"Formula Period\",\n required: false,\n config: {\n formulaText:\n 'date_format(d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f90, \"AAAA-MM\")',\n uiFormatKind: \"date\",\n status: \"ACTIVE\",\n dateFormatOptions: {\n format: \"date\",\n dateFormat: \"DD/MM/YYYY\",\n showTime: false,\n },\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Formula field (member)\",\n payload: {\n type: \"FormulaField\",\n slug: \"formula-assignee\",\n label: \"Computed Assignee\",\n required: false,\n config: {\n formulaText: \"a7b8c9d0-e1f2-3a4b-5c6d-7e8f90123456\",\n uiFormatKind: \"member\",\n status: \"ACTIVE\",\n conditionalFormatting: [],\n },\n },\n },\n ],\n },\n {\n key: \"member\",\n className: \"MemberField\",\n aliases: [\"member\", \"MemberField\"],\n description: \"Workspace member field.\",\n rawShape:\n '{\"type\":\"MemberField\",\"slug\":\"owner\",\"label\":\"Owner\",\"config\":{\"defaultValue\":null}}',\n examplePayloads: [\n {\n name: \"Member field\",\n payload: {\n type: \"MemberField\",\n slug: \"owner\",\n label: \"Owner\",\n required: false,\n config: {\n defaultValue: null,\n conditionalFormatting: [],\n },\n },\n },\n ],\n },\n {\n key: \"autoincremental\",\n className: \"AutoIncrementalField\",\n aliases: [\n \"autoincremental\",\n \"auto-incremental\",\n \"auto_incremental\",\n \"AutoIncrementalField\",\n ],\n description: \"Auto-generated incremental counter.\",\n rawShape:\n '{\"type\":\"AutoIncrementalField\",\"slug\":\"order-number\",\"label\":\"Order Number\",\"config\":{\"segmentedByFieldId\":null}}',\n examplePayloads: [\n {\n name: \"Autoincremental (global counter)\",\n payload: {\n type: \"AutoIncrementalField\",\n slug: \"order-number\",\n label: \"Order Number\",\n required: false,\n config: {\n segmentedByFieldId: null,\n conditionalFormatting: [],\n },\n },\n },\n {\n name: \"Autoincremental (segmented)\",\n payload: {\n type: \"AutoIncrementalField\",\n slug: \"sequence-code\",\n label: \"Sequence Code\",\n required: false,\n config: {\n segmentedByFieldId: \"45c5da96-0dc2-4cc1-ba61-7660a9c6da32\",\n conditionalFormatting: [],\n },\n },\n },\n ],\n },\n {\n key: \"schedule\",\n className: \"ScheduleField\",\n aliases: [\"schedule\", \"ScheduleField\"],\n description:\n \"Recurrence/schedule field bound to a number reference and a date period (frequency: monthly or daily).\",\n rawShape:\n '{\"type\":\"ScheduleField\",\"slug\":\"recurrence\",\"label\":\"Recurrence\",\"config\":{\"referenceField\":\"<number-field-uuid>\",\"beginningPeriodField\":\"<date-field-uuid>\",\"endingPeriodField\":\"<date-field-uuid>\",\"frequency\":\"monthly\"}}',\n examplePayloads: [\n {\n name: \"Schedule field (monthly)\",\n payload: {\n type: \"ScheduleField\",\n slug: \"monthly-recurrence\",\n label: \"Monthly Recurrence\",\n required: false,\n config: {\n referenceField: \"c52efe3f-2825-4c60-a7e3-34dd4c1ce043\",\n beginningPeriodField: \"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f90\",\n endingPeriodField: \"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f90\",\n frequency: \"monthly\",\n },\n },\n },\n {\n name: \"Schedule field (daily)\",\n payload: {\n type: \"ScheduleField\",\n slug: \"daily-recurrence\",\n label: \"Daily Recurrence\",\n required: false,\n config: {\n referenceField: \"c52efe3f-2825-4c60-a7e3-34dd4c1ce043\",\n beginningPeriodField: \"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f90\",\n endingPeriodField: \"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f90\",\n frequency: \"daily\",\n },\n },\n },\n ],\n },\n] as const satisfies readonly SchemaFieldTypeDefinition[];\n\nconst fieldTypeDefinitionByAlias = new Map(\n fieldTypeDefinitions.flatMap((definition) =>\n definition.aliases.map((alias) => [alias.trim().toLowerCase(), definition] as const),\n ),\n);\n\nconst fieldTypeDefinitionByClassName = new Map<string, SchemaFieldTypeDefinition>(\n fieldTypeDefinitions.map((definition) => [definition.className, definition] as const),\n);\n\nconst optionValidationMessage =\n 'Option fields require an \"options\" array with at least one entry like {\"id\":1,\"name\":\"Open\",\"color\":\"default\"}.';\n\n// Mirrors the frontend OptionColorId palette; the UI rejects any other value.\nexport const OPTION_COLORS = [\n \"none\",\n \"default\",\n \"secondary\",\n \"success\",\n \"warning\",\n \"cond-verde-intenso\",\n \"cond-positivo\",\n \"cond-naranja\",\n \"cond-destacado\",\n \"cond-negativo\",\n \"cond-critico\",\n \"cond-morado\",\n \"cond-bajo\",\n \"cond-azul-intenso\",\n \"cond-vacio\",\n \"cond-gris-oscuro\",\n \"cond-rosa\",\n \"cond-morado-medio\",\n \"cond-azul-medio\",\n \"cond-amarillo-claro\",\n \"cond-amarillo-oscuro\",\n \"cond-naranja-medio\",\n] as const;\n\nconst optionColorSet = new Set<string>(OPTION_COLORS);\n\nexport function getSchemaFieldTypeDefinitions(): readonly SchemaFieldTypeDefinition[] {\n return fieldTypeDefinitions;\n}\n\nexport function listSchemaFieldTypes(): readonly SchemaFieldTypeKey[] {\n return fieldTypeDefinitions.map((definition) => definition.key);\n}\n\nexport function formatSchemaFieldTypes(): string {\n return listSchemaFieldTypes().join(\", \");\n}\n\nexport function resolveSchemaFieldType(\n input: string | undefined,\n): SchemaFieldTypeDefinition | undefined {\n if (!input) {\n return undefined;\n }\n\n return fieldTypeDefinitionByAlias.get(input.trim().toLowerCase());\n}\n\nexport function resolveSchemaFieldTypeByClassName(\n className: string | undefined,\n): SchemaFieldTypeDefinition | undefined {\n if (!className) {\n return undefined;\n }\n\n return fieldTypeDefinitionByClassName.get(className);\n}\n\nexport function normalizeSchemaFieldType(input: string): string {\n const definition = resolveSchemaFieldType(input);\n\n if (definition) {\n return definition.className;\n }\n\n if (/^[a-z]/.test(input) && !input.endsWith(\"Field\")) {\n return `${input.charAt(0).toUpperCase()}${input.slice(1)}Field`;\n }\n\n return input;\n}\n\nexport function assertSupportedSchemaFieldType(type: string): void {\n if (!resolveSchemaFieldTypeByClassName(type)) {\n throw new CliError(\n \"invalid_cli_usage\",\n `Unsupported field type \"${type}\". Valid types: ${formatSchemaFieldTypes()}.`,\n );\n }\n}\n\ninterface OptionEntry {\n [key: string]: string | number;\n id: number;\n name: string;\n color: string;\n}\n\nfunction normalizeOptionEntries(entries: readonly unknown[]): OptionEntry[] {\n return entries.flatMap((entry) => {\n if (!isJsonObject(entry)) {\n return [];\n }\n\n const id = toNumberValue(entry.id);\n const name = toStringValue(entry.name) ?? toStringValue(entry.label);\n const color = toStringValue(entry.color) ?? \"default\";\n\n if (id === undefined || !name) {\n return [];\n }\n\n if (!optionColorSet.has(color)) {\n throw new CliError(\n \"invalid_cli_usage\",\n `Invalid option color \"${color}\" for option \"${name}\". Valid colors: ${OPTION_COLORS.join(\", \")}.`,\n );\n }\n\n return [{ id, name, color }];\n });\n}\n\nfunction normalizeOptionPayload(input: JsonObject): JsonObject {\n const additionalProperties = toJsonObject(input.additionalProperties) ?? {};\n const config = toJsonObject(input.config);\n const rootOptions = Array.isArray(input.options) ? input.options : undefined;\n const nestedOptions = Array.isArray(additionalProperties.options)\n ? additionalProperties.options\n : Array.isArray(config?.options)\n ? config.options\n : undefined;\n const optionObjects = normalizeOptionEntries(\n nestedOptions ??\n (Array.isArray(rootOptions) ? rootOptions : []),\n );\n\n if (optionObjects.length === 0) {\n throw new CliError(\"invalid_cli_usage\", optionValidationMessage);\n }\n\n const { options: _options, additionalProperties: _additionalProperties, ...rest } = input;\n const defaultValue =\n config?.defaultValue ?? input.defaultValue ?? additionalProperties.defaultValue;\n const conditionalFormatting =\n config?.conditionalFormatting ?? additionalProperties.conditionalFormatting;\n const buttonConfig = config?.buttonConfig ?? additionalProperties.buttonConfig;\n\n return {\n ...rest,\n config: {\n ...(config ?? {}),\n options: optionObjects,\n ...(defaultValue !== undefined ? { defaultValue } : {}),\n ...(conditionalFormatting !== undefined ? { conditionalFormatting } : {}),\n ...(buttonConfig !== undefined ? { buttonConfig } : {}),\n },\n };\n}\n\nfunction normalizeReferencePayload(input: JsonObject): JsonObject {\n const additionalProperties = toJsonObject(input.additionalProperties) ?? {};\n const config = toJsonObject(input.config) ?? {};\n const targetSchema =\n config.targetSchema ?? input.targetSchema ?? additionalProperties.targetSchema;\n const targetDisplayField =\n config.targetDisplayField ??\n input.targetDisplayField ??\n additionalProperties.targetDisplayField;\n const deleteBehavior =\n config.deleteBehavior ?? input.deleteBehavior ?? additionalProperties.deleteBehavior;\n const defaultValue =\n config.defaultValue ?? input.defaultValue ?? additionalProperties.defaultValue;\n const filterFields =\n config.filterFields ?? input.filterFields ?? additionalProperties.filterFields;\n const descriptionFields =\n config.descriptionFields ??\n input.descriptionFields ??\n additionalProperties.descriptionFields;\n const conditionalFormatting =\n config.conditionalFormatting ??\n input.conditionalFormatting ??\n additionalProperties.conditionalFormatting;\n\n const normalized: JsonObject = {\n ...input,\n };\n\n normalized.config = {\n ...config,\n ...(targetSchema !== undefined ? { targetSchema } : {}),\n ...(targetDisplayField !== undefined ? { targetDisplayField } : {}),\n ...(deleteBehavior !== undefined ? { deleteBehavior } : {}),\n ...(defaultValue !== undefined ? { defaultValue } : {}),\n ...(filterFields !== undefined ? { filterFields } : {}),\n ...(descriptionFields !== undefined ? { descriptionFields } : {}),\n ...(conditionalFormatting !== undefined ? { conditionalFormatting } : {}),\n };\n\n const normalizedConfig = toJsonObject(normalized.config) ?? {};\n\n if (\n !toStringValue(normalizedConfig.targetSchema) ||\n !toStringValue(normalizedConfig.targetDisplayField)\n ) {\n const definition = resolveSchemaFieldType(\"reference\")!;\n throw new CliError(\n \"invalid_cli_usage\",\n `Reference fields require \"targetSchema\" and \"targetDisplayField\". Expected raw shape: ${definition.rawShape}`,\n );\n }\n\n return normalized;\n}\n\nconst scheduleAllowedFrequencies = new Set([\"monthly\", \"daily\"]);\n\nfunction normalizeSchedulePayload(input: JsonObject): JsonObject {\n const additionalProperties = toJsonObject(input.additionalProperties) ?? {};\n const config = toJsonObject(input.config) ?? {};\n const referenceField =\n config.referenceField ?? input.referenceField ?? additionalProperties.referenceField;\n const beginningPeriodField =\n config.beginningPeriodField ??\n input.beginningPeriodField ??\n additionalProperties.beginningPeriodField;\n const endingPeriodField =\n config.endingPeriodField ??\n input.endingPeriodField ??\n additionalProperties.endingPeriodField;\n const frequency =\n config.frequency ?? input.frequency ?? additionalProperties.frequency;\n\n const {\n referenceField: _referenceField,\n beginningPeriodField: _beginningPeriodField,\n endingPeriodField: _endingPeriodField,\n frequency: _frequency,\n additionalProperties: _additionalProperties,\n ...rest\n } = input;\n\n const normalized: JsonObject = {\n ...rest,\n config: {\n ...config,\n ...(referenceField !== undefined ? { referenceField } : {}),\n ...(beginningPeriodField !== undefined ? { beginningPeriodField } : {}),\n ...(endingPeriodField !== undefined ? { endingPeriodField } : {}),\n ...(frequency !== undefined ? { frequency } : {}),\n },\n };\n\n const normalizedConfig = toJsonObject(normalized.config) ?? {};\n const definition = resolveSchemaFieldType(\"schedule\")!;\n\n if (\n !toStringValue(normalizedConfig.referenceField) ||\n !toStringValue(normalizedConfig.beginningPeriodField) ||\n !toStringValue(normalizedConfig.endingPeriodField) ||\n !toStringValue(normalizedConfig.frequency)\n ) {\n throw new CliError(\n \"invalid_cli_usage\",\n `Schedule fields require \"referenceField\", \"beginningPeriodField\", \"endingPeriodField\" and \"frequency\". Expected raw shape: ${definition.rawShape}`,\n );\n }\n\n const frequencyValue = toStringValue(normalizedConfig.frequency)!;\n if (!scheduleAllowedFrequencies.has(frequencyValue)) {\n throw new CliError(\n \"invalid_cli_usage\",\n `Schedule \"frequency\" must be \"monthly\" or \"daily\" (received \"${frequencyValue}\").`,\n );\n }\n\n return normalized;\n}\n\nfunction normalizeFormulaPayload(input: JsonObject): JsonObject {\n const { status: _status, ...rest } = input;\n const rawAdditionalProperties = toJsonObject(input.additionalProperties);\n const rawConfig = toJsonObject(input.config);\n const { status: _additionalStatus, ...additionalProperties } =\n rawAdditionalProperties ?? {};\n const { status: _configStatus, ...config } = rawConfig ?? {};\n const formulaText =\n config.formulaText ??\n rest.formulaText ??\n rest.expression ??\n additionalProperties.formulaText ??\n additionalProperties.expression;\n\n const normalized: JsonObject = {\n ...rest,\n };\n\n normalized.config = {\n ...config,\n ...(formulaText !== undefined ? { formulaText } : {}),\n ...(config.uiFormatKind !== undefined ? { uiFormatKind: config.uiFormatKind } : {}),\n ...(config.defaultValue !== undefined ? { defaultValue: config.defaultValue } : {}),\n ...(config.numberFormatOptions !== undefined\n ? { numberFormatOptions: config.numberFormatOptions }\n : {}),\n ...(config.dateFormatOptions !== undefined\n ? { dateFormatOptions: config.dateFormatOptions }\n : {}),\n ...(config.conditionalFormatting !== undefined\n ? { conditionalFormatting: config.conditionalFormatting }\n : {}),\n };\n\n const normalizedConfig = toJsonObject(normalized.config) ?? {};\n\n if (!toStringValue(normalizedConfig.formulaText)) {\n const definition = resolveSchemaFieldType(\"formula\")!;\n throw new CliError(\n \"invalid_cli_usage\",\n `Formula fields require \"formulaText\". Expected raw shape: ${definition.rawShape}`,\n );\n }\n\n return normalized;\n}\n\nexport function normalizeSchemaFieldCreatePayload(input: JsonObject): JsonObject {\n const rawType = toStringValue(input.type);\n const normalizedType = rawType ? normalizeSchemaFieldType(rawType) : undefined;\n const definition = resolveSchemaFieldTypeByClassName(normalizedType);\n\n if (!definition) {\n return input;\n }\n\n const normalizedWithType: JsonObject = {\n ...input,\n type: definition.className,\n };\n\n switch (definition.key) {\n case \"option\":\n return normalizeOptionPayload(normalizedWithType);\n case \"reference\":\n return normalizeReferencePayload(normalizedWithType);\n case \"formula\":\n return normalizeFormulaPayload(normalizedWithType);\n case \"schedule\":\n return normalizeSchedulePayload(normalizedWithType);\n case \"autoincremental\": {\n const config = toJsonObject(normalizedWithType.config) ?? {};\n const segmentedByFieldId =\n config.segmentedByFieldId ??\n normalizedWithType.segmentedByFieldId ??\n null;\n return {\n ...normalizedWithType,\n config: {\n ...config,\n segmentedByFieldId,\n ...(config.conditionalFormatting !== undefined\n ? { conditionalFormatting: config.conditionalFormatting }\n : {}),\n },\n };\n }\n default:\n return normalizedWithType;\n }\n}\n\nexport function normalizeSchemaFieldUpdatePayload(\n type: string,\n input: JsonObject,\n): JsonObject {\n const definition = resolveSchemaFieldTypeByClassName(type);\n\n if (definition?.key === \"formula\") {\n return normalizeFormulaPayload(input);\n }\n\n return input;\n}\n\nexport function buildSchemaFieldCreateHelpText(): string {\n const sections = fieldTypeDefinitions.map(\n (definition) =>\n ` - ${definition.key}: ${definition.description}\\n raw: ${definition.rawShape}`,\n );\n\n return [\n \"\",\n \"Valid field types:\",\n ` ${formatSchemaFieldTypes()}`,\n \"\",\n \"Raw payload shapes by type:\",\n ...sections,\n \"\",\n 'Use \"zinkee --example schemas fields create --type <type>\" to show a concrete example for one type.',\n ].join(\"\\n\");\n}\n\nexport function buildSchemaFieldCreateValidationMessage(type: string): string {\n const definition = resolveSchemaFieldTypeByClassName(type);\n\n if (!definition) {\n return `Invalid payload for field type \"${type}\". Valid types: ${formatSchemaFieldTypes()}.`;\n }\n\n return `Invalid payload for field type \"${definition.key}\". Expected raw shape: ${definition.rawShape}`;\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;AAQ9B,IAAMA,WAAU,cAAc,YAAY,GAAG;AAM7C,SAAS,mBAAmB,OAAwB;AAClD,MAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AACxF,WAAO,OAAO,KAAK;AAAA,EACrB;AAEA,SAAO,KAAK,UAAU,KAAK;AAC7B;AAEO,SAAS,iBACd,MACA,OAAc,CAAC,GACoB;AACnC,SAAO,EAAE,MAAM,KAAK;AACtB;AAEO,SAAS,eACd,OACA,OAAc,CAAC,GACiB;AAChC,SAAO,EAAE,OAAO,KAAK;AACvB;AASO,IAAM,oBAAoB,CAAC,YAAY,cAAc,cAAc;AAOnE,SAAS,cAAc,QAI5B;AACA,MAAI,CAAC,QAAQ;AACX,WAAO,EAAE,UAA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,YAAY;AACf,WAAO,mCAAmC,IAAI,mBAAmB,uBAAuB,CAAC;AAAA,EAC3F;AAEA,SAAO,mCAAmC,WAAW,GAAG,0BAA0B,WAAW,QAAQ;AACvG;","names":["require","createRequire","require"]}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
buildJsonSuccess,
|
|
3
3
|
getSchemaFieldTypeDefinitions,
|
|
4
4
|
resolveSchemaFieldType
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FIWBICYE.js";
|
|
6
6
|
|
|
7
7
|
// src/utils/examples.ts
|
|
8
8
|
var SAMPLE_UUID = "550e8400-e29b-41d4-a716-446655440001";
|
|
@@ -194,6 +194,62 @@ var specificExamples = {
|
|
|
194
194
|
}`
|
|
195
195
|
}
|
|
196
196
|
],
|
|
197
|
+
login: [
|
|
198
|
+
{
|
|
199
|
+
description: 'Sign in as a superadmin against production and store the session in the "superadmin" profile. Prompts for the password (and the email if it is not stored); the token is never printed.',
|
|
200
|
+
command: "zinkee --json login --email user@zinkee.com",
|
|
201
|
+
response: `{
|
|
202
|
+
"profile": "superadmin",
|
|
203
|
+
"email": "user@zinkee.com",
|
|
204
|
+
"backendUrl": "https://backend-z2.zinkee.com",
|
|
205
|
+
"baseUrl": "https://api-z2.zinkee.com",
|
|
206
|
+
"expiresAt": "2026-10-09T08:30:00.000Z"
|
|
207
|
+
}`
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
description: "Sign in against a local stack without a prompt. Pass both URLs of the same environment: a session only works with that environment's Public API.",
|
|
211
|
+
command: "zinkee --json login --profile local --backend-url http://127.0.0.1:8080 --base-url http://127.0.0.1:8088 --email admin@zinkee.com --password-stdin < password.txt",
|
|
212
|
+
response: `{
|
|
213
|
+
"profile": "local",
|
|
214
|
+
"email": "admin@zinkee.com",
|
|
215
|
+
"backendUrl": "http://127.0.0.1:8080",
|
|
216
|
+
"baseUrl": "http://127.0.0.1:8088",
|
|
217
|
+
"expiresAt": "2026-10-09T08:30:00.000Z"
|
|
218
|
+
}`
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
logout: [
|
|
222
|
+
{
|
|
223
|
+
description: "Remove the stored session of the superadmin profile. The server cannot revoke it, so it stays valid until it expires.",
|
|
224
|
+
command: "zinkee --json logout",
|
|
225
|
+
response: `{
|
|
226
|
+
"profile": "superadmin",
|
|
227
|
+
"email": "user@zinkee.com"
|
|
228
|
+
}`
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
"workspaces list": [
|
|
232
|
+
{
|
|
233
|
+
description: 'List the organizations and workspaces visible to the session. Pass a name or id to --workspace (or ZINKEE_WORKSPACE) to work on one, e.g. zinkee --workspace "Acme" schemas list.',
|
|
234
|
+
command: "zinkee --json workspaces list",
|
|
235
|
+
response: `[
|
|
236
|
+
{
|
|
237
|
+
"organizationId": "0f9d6c2e-4b7a-4e1f-9a3c-2d5e8f1a6b7c",
|
|
238
|
+
"organizationName": "Acme",
|
|
239
|
+
"workspaceId": "${SAMPLE_UUID}",
|
|
240
|
+
"workspaceName": "Acme",
|
|
241
|
+
"active": true
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"organizationId": "0f9d6c2e-4b7a-4e1f-9a3c-2d5e8f1a6b7c",
|
|
245
|
+
"organizationName": "Acme",
|
|
246
|
+
"workspaceId": "7c1e2a4b-9d3f-4c5e-8a6b-1f2d3e4c5b6a",
|
|
247
|
+
"workspaceName": "Acme Sandbox",
|
|
248
|
+
"active": false
|
|
249
|
+
}
|
|
250
|
+
]`
|
|
251
|
+
}
|
|
252
|
+
],
|
|
197
253
|
"schemas create": [
|
|
198
254
|
{
|
|
199
255
|
description: "Create an auditable and commentable schema from flags.",
|
|
@@ -2609,7 +2665,7 @@ var specificExamples = {
|
|
|
2609
2665
|
],
|
|
2610
2666
|
"records clear": [
|
|
2611
2667
|
{
|
|
2612
|
-
description: "Delete every record from a schema's table. Heritage rules (CASCADE / SET NULL) propagate to child schemas asynchronously via the CDC pipeline.",
|
|
2668
|
+
description: "Delete every record from a schema's table. Heritage rules (CASCADE / SET NULL) propagate to child schemas asynchronously via the CDC pipeline. A RESTRICT reference holding any child record refuses the clear (409 data_dependency_conflict) and nothing is deleted.",
|
|
2613
2669
|
command: "zinkee --json records clear contacts",
|
|
2614
2670
|
response: `{
|
|
2615
2671
|
"schemaId": "2eb8bdcf-6d9c-4fbb-9018-7fa8180f4c5e",
|
|
@@ -4414,4 +4470,4 @@ function withResponseEnvelope(example, commandName) {
|
|
|
4414
4470
|
export {
|
|
4415
4471
|
getCommandExamples
|
|
4416
4472
|
};
|
|
4417
|
-
//# sourceMappingURL=examples-
|
|
4473
|
+
//# sourceMappingURL=examples-BZMVRE5P.js.map
|