first commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
CLARIZEN_BASE_URL=https://api.clarizen.com
|
||||
CLARIZEN_API_KEY=your-api-key-here
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,92 @@
|
||||
# Atualização em massa de campo — Clarizen
|
||||
|
||||
App terminal em Node.js para escolher um tipo de entidade e um campo via metadata do Adaptive Work, e atualizar esse campo em massa nos objetos do tipo selecionado (com filtros opcionais).
|
||||
|
||||
## Pré-requisitos
|
||||
|
||||
- Node.js 18+
|
||||
- API key do Adaptive Work (`CLARIZEN_API_KEY`)
|
||||
- Biblioteca `@arco/clarizen-lib` compilada no diretório irmão (`../clarizen-lib`)
|
||||
|
||||
## Instalação
|
||||
|
||||
```bash
|
||||
cd ../clarizen-lib && npm install && npm run build
|
||||
cd ../update_field_API
|
||||
cp .env.example .env
|
||||
# Edite .env com CLARIZEN_BASE_URL e CLARIZEN_API_KEY
|
||||
npm install
|
||||
```
|
||||
|
||||
## Uso
|
||||
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
|
||||
Fluxo interativo:
|
||||
|
||||
1. Autenticação com API key
|
||||
2. Escolha do tipo de entidade (nível) — lista completa ou filtro por texto
|
||||
3. **Filtro de objetos** — todos, por State (se o tipo tiver lifecycle), ou cláusula WHERE em CZQL
|
||||
4. Escolha do campo — cada opção mostra **label**, **nome** e **tipo**
|
||||
5. Exibição de exemplo de preenchimento conforme o tipo
|
||||
6. Informe o novo valor (ou limpe o campo, se nullable)
|
||||
7. Busca dos objetos conforme o filtro
|
||||
8. Confirmação com resumo (tipo, filtro, campo, valor, quantidade)
|
||||
9. Atualização em massa com barra de progresso, porcentagem e ETA
|
||||
|
||||
## Filtros de objetos
|
||||
|
||||
Após escolher o tipo de entidade, você pode limitar quais registros serão atualizados:
|
||||
|
||||
| Opção | Descrição |
|
||||
|-------|-----------|
|
||||
| Todos os objetos | Sem filtro (comportamento original) |
|
||||
| Filtrar por State | Disponível quando a metadata expõe `validStates` (ex.: Active, Completed) |
|
||||
| CZQL WHERE | Informe só a cláusula `WHERE`; o app valida contra a API antes de continuar |
|
||||
|
||||
### Exemplos de cláusula WHERE (CZQL)
|
||||
|
||||
```
|
||||
State = 'Active'
|
||||
Name LIKE 'Projeto%'
|
||||
State = 'Active' AND Name LIKE 'Test%'
|
||||
```
|
||||
|
||||
A cláusula é aplicada via `entityQuery` com filtro CZQL. Comandos de modificação (`DELETE`, `UPDATE`, etc.) são rejeitados.
|
||||
|
||||
## Exemplos de valor por tipo de campo
|
||||
|
||||
| Tipo | Como preencher no terminal |
|
||||
|------|---------------------------|
|
||||
| Boolean | `true`, `false`, `sim`, `não` |
|
||||
| String | texto livre, ex: `Meu valor` |
|
||||
| Integer / Long | `42` |
|
||||
| Double | `3.14` |
|
||||
| DateTime | `2026-06-09` ou `2026-06-09T14:30:00Z` |
|
||||
| Date | `2026-06-09` |
|
||||
| Entity | `/User/abc-123` ou `{"id":"/User/abc-123"}` |
|
||||
| Duration | `{"value":5,"unit":"Days"}` |
|
||||
| Money | `{"value":100,"currency":"BRL"}` |
|
||||
|
||||
Campos **nullable** permitem limpar o valor escolhendo "Limpar campo (null)" ou digitando `null`.
|
||||
|
||||
## Variáveis de ambiente
|
||||
|
||||
| Variável | Descrição |
|
||||
|----------|-----------|
|
||||
| `CLARIZEN_BASE_URL` | URL base da API (padrão: `https://api.clarizen.com`) |
|
||||
| `CLARIZEN_API_KEY` | API key (alternativa: `API_KEY_AW`) |
|
||||
|
||||
O app também tenta carregar `../clarizen-lib/.env` se não houver `.env` local.
|
||||
|
||||
## Erros
|
||||
|
||||
Objetos que falharem na atualização são listados ao final. Um arquivo `errors-<timestamp>.json` é gerado na pasta do projeto com os detalhes.
|
||||
|
||||
## Observações
|
||||
|
||||
- Apenas campos **atualizáveis** são listados (exclui calculados, create-only e internos).
|
||||
- A atualização usa `bulk.execute` em lotes de 20, com fallback individual em caso de falha no lote.
|
||||
- Rate limit da API: ~25 requisições/segundo por organização.
|
||||
+1
@@ -0,0 +1 @@
|
||||
../esbuild/bin/esbuild
|
||||
+1
@@ -0,0 +1 @@
|
||||
../typescript/bin/tsc
|
||||
+1
@@ -0,0 +1 @@
|
||||
../typescript/bin/tsserver
|
||||
+1
@@ -0,0 +1 @@
|
||||
../tsx/dist/cli.mjs
|
||||
+634
@@ -0,0 +1,634 @@
|
||||
{
|
||||
"name": "@arco/update-field-api",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@arco/clarizen-lib": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "git+https://gitea.rivuslab.com/leonardotoniolo/clarizen-lib.git#4fb90234021b0ed265285ad82bc246af08d035b1",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@clack/core": {
|
||||
"version": "0.4.2",
|
||||
"resolved": "https://registry.npmjs.org/@clack/core/-/core-0.4.2.tgz",
|
||||
"integrity": "sha512-NYQfcEy8MWIxrT5Fj8nIVchfRFA26yYKJcvBS7WlUIlw2OmQOY9DhGGXMovyI5J5PpxrCPGkgUi207EBrjpBvg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"picocolors": "^1.0.0",
|
||||
"sisteransi": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/@clack/prompts": {
|
||||
"version": "0.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@clack/prompts/-/prompts-0.10.1.tgz",
|
||||
"integrity": "sha512-Q0T02vx8ZM9XSv9/Yde0jTmmBQufZhPJfYAg2XrrrxWWaZgq1rr8nU8Hv710BQ1dhoP8rtY7YUdpGej2Qza/cw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@clack/core": "0.4.2",
|
||||
"picocolors": "^1.0.0",
|
||||
"sisteransi": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.0.tgz",
|
||||
"integrity": "sha512-lhRUCeuOyJQURhTxl4WkpFTjIsbDayJHih5kZC1giwE+MhIzAb7mEsQMqMf18rHLsrb5qI1tafG20mLxEWcWlA==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"aix"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.0.tgz",
|
||||
"integrity": "sha512-wqh0ByljabXLKHeWXYLqoJ5jKC4XBaw6Hk08OfMrCRd2nP2ZQ5eleDZC41XHyCNgktBGYMbqnrJKq/K/lzPMSQ==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-+WzIXQOSaGs33tLEgYPYe/yQHf0WTU0X42Jca3y8NWMbUVhp7rUnw+vAsRC/QiDrdD31IszMrZy+qwPOPjd+rw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-+VJggoaKhk2VNNqVL7f6S189UzShHC/mR9EE8rDdSkdpN0KflSwWY/gWjDrNxxisg8Fp1ZCD9jLMo4m0OUfeUA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-0T+A9WZm+bZ84nZBtk1ckYsOvyA3x7e2Acj1KdVfV4/2tdG4fzUp91YHx+GArWLtwqp77pBXVCPn2We7Letr0Q==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-fyzLm/DLDl/84OCfp2f/XQ4flmORsjU7VKt8HLjvIXChJoFFOIL6pLJPH4Yhd1n1gGFF9mPwtlN5Wf82DZs+LQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-l9GeW5UZBT9k9brBYI+0WDffcRxgHQD8ShN2Ur4xWq/NFzUKm3k5lsH4PdaRgb2w7mI9u61nr2gI2mLI27Nh3Q==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-BXoQai/A0wPO6Es3yFJ7APCiKGc1tdAEOgeTNy3SsB491S3aHn4S4r3e976eUnPdU+NbdtmBuLncYir2tMU9Nw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.0.tgz",
|
||||
"integrity": "sha512-CjaaREJagqJp7iTaNQjjidaNbCKYcd4IDkzbwwxtSvjI7NZm79qiHc8HqciMddQ6CKvJT6aBd8lO9kN/ZudLlw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-RVyzfb3FWsGA55n6WY0MEIEPURL1FcbhFE6BffZEMEekfCzCIMtB5yyDcFnVbTnwk+CLAgTujmV/Lgvih56W+A==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ia32": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.0.tgz",
|
||||
"integrity": "sha512-KBnSTt1kxl9x70q+ydterVdl+Cn0H18ngRMRCEQfrbqdUuntQQ0LoMZv47uB97NljZFzY6HcfqEZ2SAyIUTQBQ==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-loong64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.0.tgz",
|
||||
"integrity": "sha512-zpSlUce1mnxzgBADvxKXX5sl8aYQHo2ezvMNI8I0lbblJtp8V4odlm3Yzlj7gPyt3T8ReksE6bK+pT3WD+aJRg==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-mips64el": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.0.tgz",
|
||||
"integrity": "sha512-2jIfP6mmjkdmeTlsX/9vmdmhBmKADrWqN7zcdtHIeNSCH1SqIoNI63cYsjQR8J+wGa4Y5izRcSHSm8K3QWmk3w==",
|
||||
"cpu": [
|
||||
"mips64el"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ppc64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.0.tgz",
|
||||
"integrity": "sha512-bc0FE9wWeC0WBm49IQMPSPILRocGTQt3j5KPCA8os6VprfuJ7KD+5PzESSrJ6GmPIPJK965ZJHTUlSA6GNYEhg==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-riscv64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.0.tgz",
|
||||
"integrity": "sha512-SQPZOwoTTT/HXFXQJG/vBX8sOFagGqvZyXcgLA3NhIqcBv1BJU1d46c0rGcrij2B56Z2rNiSLaZOYW5cUk7yLQ==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-s390x": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.0.tgz",
|
||||
"integrity": "sha512-SCfR0HN8CEEjnYnySJTd2cw0k9OHB/YFzt5zgJEwa+wL/T/raGWYMBqwDNAC6dqFKmJYZoQBRfHjgwLHGSrn3Q==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-us0dSb9iFxIi8srnpl931Nvs65it/Jd2a2K3qs7fz2WfGPHqzfzZTfec7oxZJRNPXPnNYZtanmRc4AL/JwVzHQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-CR/RYotgtCKwtftMwJlUU7xCVNg3lMYZ0RzTmAHSfLCXw3NtZtNpswLEj/Kkf6kEL3Gw+BpOekRX0BYCtklhUw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-nU1yhmYutL+fQ71Kxnhg8uEOdC0pwEW9entHykTgEbna2pw2dkbFSMeqjjyHZoCmt8SBkOSvV+yNmm94aUrrqw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-cXb5vApOsRsxsEl4mcZ1XY3D4DzcoMxR/nnc4IyqYs0rTI8ZKmW6kyyg+11Z8yvgMfAEldKzP7AdP64HnSC/6g==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-8wZM2qqtv9UP3mzy7HiGYNH/zjTA355mpeuA+859TyR+e+Tc08IHYpLJuMsfpDJwoLo1ikIJI8jC3GFjnRClzA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openharmony-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-FLGfyizszcef5C3YtoyQDACyg95+dndv79i2EekILBofh5wpCa1KuBqOWKrEHZg3zrL3t5ouE5jgr94vA+Wb2w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openharmony"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/sunos-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-1ZgjUoEdHZZl/YlV76TSCz9Hqj9h9YmMGAgAPYd+q4SicWNX3G5GCyx9uhQWSLcbvPW8Ni7lj4gDa1T40akdlw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"sunos"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-Q9StnDmQ/enxnpxCCLSg0oo4+34B9TdXpuyPeTedN/6+iXBJ4J+zwfQI28u/Jl40nOYAxGoNi7mFP40RUtkmUA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-ia32": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.0.tgz",
|
||||
"integrity": "sha512-zF3ag/gfiCe6U2iczcRzSYJKH1DCI+ByzSENHlM2FcDbEeo5Zd2C86Aq0tKUYAJJ1obRP84ymxIAksZUcdztHA==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-pEl1bO9mfAmIC+tW5btTmrKaujg3zGtUmWNdCw/xs70FBjwAL3o9OEKNHvNmnyylD6ubxUERiEhdsL0xBQ9efw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"ideallyInert": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.19.20",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.20.tgz",
|
||||
"integrity": "sha512-6tELRwSDYWW9EdZhbeZmYGZ1/7Djkt+Ah3/ScEYT9cDord7UJzasR/4D3VONg9tQI5CDp+/CZC1AXj2pCFOvpw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.6.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz",
|
||||
"integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://dotenvx.com"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.0.tgz",
|
||||
"integrity": "sha512-sNR9MHpXSUV/XB4zmsFKN+QgVG82Cc7+/aaxJ8Adi8hyOac+EXptIp45QBPaVyX3N70664wRbTcLTOemCAnyqw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.28.0",
|
||||
"@esbuild/android-arm": "0.28.0",
|
||||
"@esbuild/android-arm64": "0.28.0",
|
||||
"@esbuild/android-x64": "0.28.0",
|
||||
"@esbuild/darwin-arm64": "0.28.0",
|
||||
"@esbuild/darwin-x64": "0.28.0",
|
||||
"@esbuild/freebsd-arm64": "0.28.0",
|
||||
"@esbuild/freebsd-x64": "0.28.0",
|
||||
"@esbuild/linux-arm": "0.28.0",
|
||||
"@esbuild/linux-arm64": "0.28.0",
|
||||
"@esbuild/linux-ia32": "0.28.0",
|
||||
"@esbuild/linux-loong64": "0.28.0",
|
||||
"@esbuild/linux-mips64el": "0.28.0",
|
||||
"@esbuild/linux-ppc64": "0.28.0",
|
||||
"@esbuild/linux-riscv64": "0.28.0",
|
||||
"@esbuild/linux-s390x": "0.28.0",
|
||||
"@esbuild/linux-x64": "0.28.0",
|
||||
"@esbuild/netbsd-arm64": "0.28.0",
|
||||
"@esbuild/netbsd-x64": "0.28.0",
|
||||
"@esbuild/openbsd-arm64": "0.28.0",
|
||||
"@esbuild/openbsd-x64": "0.28.0",
|
||||
"@esbuild/openharmony-arm64": "0.28.0",
|
||||
"@esbuild/sunos-x64": "0.28.0",
|
||||
"@esbuild/win32-arm64": "0.28.0",
|
||||
"@esbuild/win32-ia32": "0.28.0",
|
||||
"@esbuild/win32-x64": "0.28.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/sisteransi": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz",
|
||||
"integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tsx": {
|
||||
"version": "4.22.4",
|
||||
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.22.4.tgz",
|
||||
"integrity": "sha512-X8EX+XV4QR5xCsrgxaED954zTDfY8KqlDtskKEL0cHhyS/P8b4IFOvGDQpsC9Q1XnLq915wEfwwY/zzskCtmhg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "~0.28.0"
|
||||
},
|
||||
"bin": {
|
||||
"tsx": "dist/cli.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.3"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
# @arco/clarizen-lib
|
||||
|
||||
TypeScript client for the [Planview Adaptive Work REST API V2.0](https://api.clarizen.com/V2.0/services/).
|
||||
|
||||
Human-readable guide: [REST API Guide Version 2](https://success.planview.com/Planview_AdaptiveWork/API/REST_API_Guide_Version_2) — see also [docs/references/planview-rest-api-v2.md](docs/references/planview-rest-api-v2.md).
|
||||
|
||||
## Install (library)
|
||||
|
||||
```bash
|
||||
cd clarizen-lib
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
## Use from another package in this repo
|
||||
|
||||
From the ARCO root (npm workspaces):
|
||||
|
||||
```bash
|
||||
cd /path/to/ARCO
|
||||
npm install
|
||||
```
|
||||
|
||||
In your app `package.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"dependencies": {
|
||||
"@arco/clarizen-lib": "workspace:*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Without workspaces (sibling folder):
|
||||
|
||||
```json
|
||||
{
|
||||
"dependencies": {
|
||||
"@arco/clarizen-lib": "file:../clarizen-lib"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then build the library once (`npm run build` inside `clarizen-lib`) and import:
|
||||
|
||||
```typescript
|
||||
import { Clarizen } from "@arco/clarizen-lib";
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### API key (recommended)
|
||||
|
||||
```typescript
|
||||
import { Clarizen } from "@arco/clarizen-lib";
|
||||
|
||||
const clarizen = new Clarizen("https://api.clarizen.com", process.env.CLARIZEN_API_KEY);
|
||||
|
||||
const users = await clarizen.data.entityQuery({
|
||||
typeName: "User",
|
||||
fields: ["Name", "Email"],
|
||||
paging: { limit: 10, from: 0 },
|
||||
});
|
||||
```
|
||||
|
||||
Or with options:
|
||||
|
||||
```typescript
|
||||
const clarizen = new Clarizen({
|
||||
baseUrl: "https://api.clarizen.com",
|
||||
apiToken: process.env.CLARIZEN_API_KEY,
|
||||
});
|
||||
```
|
||||
|
||||
### Session (username + password)
|
||||
|
||||
```typescript
|
||||
const clarizen = Clarizen.createForLogin("https://api.clarizen.com");
|
||||
|
||||
const { sessionId } = await clarizen.loginWithDiscovery({
|
||||
userName: "user@company.com",
|
||||
password: "secret",
|
||||
});
|
||||
```
|
||||
|
||||
### Entity CRUD
|
||||
|
||||
```typescript
|
||||
const { id } = await clarizen.objects.create("Issue", { title: "Issue 1" });
|
||||
const issue = await clarizen.objects.get("Issue", id, {
|
||||
fields: ["CreatedOn", "CreatedBy.Name"],
|
||||
});
|
||||
```
|
||||
|
||||
Or construct directly with an existing session:
|
||||
|
||||
```typescript
|
||||
const clarizen = new Clarizen({
|
||||
baseUrl: "https://api.clarizen.com",
|
||||
sessionId: "abc123_28849473",
|
||||
});
|
||||
```
|
||||
|
||||
## Services
|
||||
|
||||
All documented operations are exposed under namespaces:
|
||||
|
||||
| Namespace | Example |
|
||||
|-----------|---------|
|
||||
| `authentication` | `clarizen.authentication.login({ userName, password })` |
|
||||
| `data` | `clarizen.data.entityQuery({ typeName, fields })` |
|
||||
| `objects` | `clarizen.objects.get("Issue", id, { fields: [...] })` |
|
||||
| `metadata` | `clarizen.metadata.fetchCatalog()` |
|
||||
| `files` | `clarizen.files.getUploadUrl()` |
|
||||
| `bulk` | `clarizen.bulk.execute({ ... })` |
|
||||
| `applications` | `clarizen.applications.getApplicationStatus()` |
|
||||
| `utils` | `clarizen.utils.sendEMail({ ... })` |
|
||||
|
||||
Generic call:
|
||||
|
||||
```typescript
|
||||
await clarizen.call("data", "EntityQuery", { typeName: "Project", fields: ["Name"] });
|
||||
```
|
||||
|
||||
## Environment
|
||||
|
||||
Copy `.env.example` to `.env`:
|
||||
|
||||
```
|
||||
CLARIZEN_BASE_URL=https://api.clarizen.com
|
||||
CLARIZEN_API_KEY=...
|
||||
CLARIZEN_USERNAME=...
|
||||
CLARIZEN_PASSWORD=...
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
npm run example:api-key
|
||||
npm run example:session
|
||||
```
|
||||
|
||||
## Regenerate endpoints from API docs
|
||||
|
||||
```bash
|
||||
npm run scrape
|
||||
```
|
||||
|
||||
## Regenerate API types (60 types, recursive crawl)
|
||||
|
||||
Crawls all operations and `/V2.0/services/types/*`, then generates `src/clarizen-api-types.ts`:
|
||||
|
||||
```bash
|
||||
npm run scrape:types # writes src/generated/clarizen-schema.json
|
||||
npm run generate:types # writes src/clarizen-api-types.ts
|
||||
```
|
||||
|
||||
Includes `Condition`, `Expression`, `Query` (11 variants), `EntityQuery`, enums (`Operator`, `ErrorCode`, …), and nested types referenced from each page.
|
||||
|
||||
## Org metadata catalog (runtime + codegen)
|
||||
|
||||
Fetches your tenant’s entity types, fields, and relations via `listEntities` + `describeMetadata` (`flags: ["fields", "relations"]`). Custom names containing `C_` or `R_` are excluded.
|
||||
|
||||
**Runtime:**
|
||||
|
||||
```typescript
|
||||
const catalog = await clarizen.metadata.fetchCatalog();
|
||||
const project = catalog.entities.find((e) => e.typeName === "Project");
|
||||
```
|
||||
|
||||
**Regenerate** (requires `.env` credentials):
|
||||
|
||||
```bash
|
||||
npm run scrape:metadata # writes src/generated/metadata-catalog.json + metadata-types.ts
|
||||
npm run build
|
||||
```
|
||||
|
||||
**Typed entity/field names** (after scrape):
|
||||
|
||||
```typescript
|
||||
import type { EntityTypeName } from "@arco/clarizen-lib";
|
||||
import { FIELDS_BY_ENTITY, entityFields } from "@arco/clarizen-lib/metadata";
|
||||
```
|
||||
|
||||
Commit `metadata-types.ts` (and optionally `metadata-catalog.json`) when refreshing against your reference tenant.
|
||||
+362
@@ -0,0 +1,362 @@
|
||||
import type { JsonValue } from "./types.js";
|
||||
export type EntityId = string;
|
||||
export type Operator = "Equal" | "NotEqual" | "LessThan" | "GreaterThan" | "LessThanOrEqual" | "GreaterThanOrEqual" | "BeginsWith" | "EndsWith" | "Contains" | "DoesNotContain" | "In" | "Like" | "InRange" | "NotInRange" | "NotIn";
|
||||
export type Order = "Ascending" | "Descending";
|
||||
export type DatePeriod = "ThisWeek" | "ThisMonth" | "ThisQuarter" | "ThisYear" | "NextWeek" | "NextMonth" | "NextQuarter" | "NextYear" | "LastWeek" | "LastMonth" | "LastQuarter" | "LastYear";
|
||||
export type FunctionType = "Count" | "Max" | "Min" | "Sum" | "Avg";
|
||||
export type LicenseType = "Full" | "Limited" | "Email" | "None" | "TeamMember" | "Social" | "ExternalCollaborator";
|
||||
export type NewsFeedMode = "Following" | "All";
|
||||
export type TimesheetState = "UnSubmitted" | "PendingApproval" | "Approved" | "All";
|
||||
export type ErrorCode = "EntityNotFound" | "InvalidArgument" | "MissingArgument" | "InvalidOperation" | "DuplicateKey" | "InvalidField" | "InvalidType" | "FileNotFound" | "VirusCheckFailed" | "Unauthorized" | "UnsupportedClient" | "General" | "Internal" | "ValidationRuleError" | "LoginFailure" | "SessionTimeout" | "Redirect" | "InvalidQuery" | "ExecutionThresholdExceeded" | "TooManyRequests";
|
||||
export type FieldType = "Boolean" | "String" | "Integer" | "Long" | "Double" | "DateTime" | "Date" | "Entity" | "Duration" | "Money";
|
||||
export type PresentationType = "Text" | "Numeric" | "Date" | "Time" | "Checkbox" | "TextArea" | "Currency" | "Duration" | "ReferenceToObject" | "PickList" | "Url" | "Percent" | "Other";
|
||||
export type RecipientType = "To" | "CC";
|
||||
export type AccessType = "Public" | "Private";
|
||||
export type TriggerType = "Create" | "CreateOrEdit" | "Delete" | "CreateOrEditWithPreviousValueNotEqual";
|
||||
export type HttpMethod = "DELETE" | "GET" | "POST" | "PUT";
|
||||
export interface AndCondition {
|
||||
and: Condition[];
|
||||
}
|
||||
export interface OrCondition {
|
||||
or: Condition[];
|
||||
}
|
||||
export interface NotCondition {
|
||||
not: Condition;
|
||||
}
|
||||
export interface CompareCondition {
|
||||
_type?: "Compare";
|
||||
leftExpression: Expression;
|
||||
operator: ComparisonOperator;
|
||||
rightExpression: Expression;
|
||||
}
|
||||
export interface CzqlCondition {
|
||||
text: string;
|
||||
parameters?: Parameters;
|
||||
}
|
||||
export type Condition = AndCondition | OrCondition | NotCondition | CompareCondition | CzqlCondition;
|
||||
export interface FieldExpression {
|
||||
fieldName: string;
|
||||
}
|
||||
export interface ConstantExpression {
|
||||
value: JsonValue;
|
||||
}
|
||||
export interface ConstantListExpression {
|
||||
values: JsonValue[];
|
||||
}
|
||||
export interface QueryExpression {
|
||||
query: Query;
|
||||
}
|
||||
export interface PredefinedDateRangeExpression {
|
||||
value?: DatePeriod;
|
||||
dateRangeValue?: DatePeriod;
|
||||
}
|
||||
export type Expression = FieldExpression | ConstantExpression | ConstantListExpression | QueryExpression | PredefinedDateRangeExpression;
|
||||
export type ApplyOnMembersResult = string;
|
||||
export type IFormat = Record<string, JsonValue>;
|
||||
export type RoleType = string;
|
||||
export interface Action {
|
||||
url: string;
|
||||
method: HttpMethod;
|
||||
headers?: string;
|
||||
body?: string;
|
||||
}
|
||||
export interface ApplyOnMembersResultItemStatus {
|
||||
userGroupId?: EntityId;
|
||||
userGroupName?: string;
|
||||
status?: ApplyOnMembersResult;
|
||||
failureStatusMessage?: FailureStatusMessage;
|
||||
}
|
||||
export interface CalendarException {
|
||||
id?: EntityId;
|
||||
name?: string;
|
||||
isWorkingDay?: boolean;
|
||||
isAllDay?: boolean;
|
||||
startHour?: number;
|
||||
endHour?: number;
|
||||
exceptionType?: EntityId;
|
||||
startDate?: DateTime;
|
||||
endDate?: DateTime;
|
||||
repeat?: Repeat;
|
||||
}
|
||||
export interface CreateResult {
|
||||
id?: EntityId;
|
||||
}
|
||||
export interface DateTime {
|
||||
}
|
||||
export interface DayInformation {
|
||||
isWorkingDay?: boolean;
|
||||
totalWorkingHours?: number;
|
||||
startHour?: number;
|
||||
endHour?: number;
|
||||
}
|
||||
export interface Entity {
|
||||
id?: EntityId;
|
||||
objectFields?: Record<string, JsonValue>;
|
||||
}
|
||||
export interface EntityDescription {
|
||||
typeName?: string;
|
||||
fields?: FieldDescription[];
|
||||
validStates?: string[];
|
||||
label?: string;
|
||||
labelPlural?: string;
|
||||
parentEntity?: string;
|
||||
displayField?: string;
|
||||
disabled?: boolean;
|
||||
relations?: RelationDescription[];
|
||||
}
|
||||
export interface EntityRelationsDescription {
|
||||
typeName?: string;
|
||||
relations?: RelationDescription[];
|
||||
}
|
||||
export interface Error {
|
||||
errorCode?: ErrorCode;
|
||||
message?: string;
|
||||
referenceId?: string;
|
||||
}
|
||||
export interface Every {
|
||||
recurrenceType?: string;
|
||||
period?: number;
|
||||
}
|
||||
export interface ExceptionDate {
|
||||
date?: DateTime;
|
||||
calendarExceptionId?: EntityId;
|
||||
}
|
||||
export interface FailureStatusMessage {
|
||||
failureMessage?: string;
|
||||
}
|
||||
export interface FieldAggregation {
|
||||
function?: FunctionType;
|
||||
fieldName?: string;
|
||||
alias?: string;
|
||||
}
|
||||
export interface FieldDescription {
|
||||
name?: string;
|
||||
type?: FieldType;
|
||||
presentationType?: PresentationType;
|
||||
label?: string;
|
||||
defaultValue?: JsonValue;
|
||||
system?: boolean;
|
||||
calculated?: boolean;
|
||||
nullable?: boolean;
|
||||
createOnly?: boolean;
|
||||
updateable?: boolean;
|
||||
internal?: boolean;
|
||||
custom?: boolean;
|
||||
visible?: boolean;
|
||||
decimalPlaces?: number;
|
||||
filterable?: boolean;
|
||||
sortable?: boolean;
|
||||
format?: IFormat;
|
||||
maxLength?: number;
|
||||
flags?: string[];
|
||||
restrictedFieldSetName?: string;
|
||||
manuallySetName?: string;
|
||||
}
|
||||
export interface FieldValue {
|
||||
fieldName?: string;
|
||||
value?: JsonValue;
|
||||
}
|
||||
export interface FileInformation {
|
||||
storage?: Storage;
|
||||
url?: string;
|
||||
fileName?: string;
|
||||
subType?: string;
|
||||
extendedInfo?: string;
|
||||
}
|
||||
export interface IdentifierMap {
|
||||
oid?: string;
|
||||
id?: string;
|
||||
}
|
||||
export interface LicenseConsumption {
|
||||
licenseTypeLabel?: string;
|
||||
licenseType?: LicenseType;
|
||||
assignedLicenses?: number;
|
||||
activeUsers?: number;
|
||||
allocatedLicenses?: number;
|
||||
}
|
||||
export interface LoginOptions {
|
||||
partnerId?: string;
|
||||
applicationId?: string;
|
||||
}
|
||||
export interface MissingTimesheets {
|
||||
date?: DateTime;
|
||||
workingHours?: number;
|
||||
reportedHours?: number;
|
||||
missingHours?: number;
|
||||
}
|
||||
export interface OrderBy {
|
||||
fieldName?: string;
|
||||
order?: Order;
|
||||
}
|
||||
export interface OrganizationLicenseConsumption {
|
||||
id?: EntityId;
|
||||
licenseConsumption?: LicenseConsumption;
|
||||
}
|
||||
export interface Paging {
|
||||
from?: number;
|
||||
limit?: number;
|
||||
hasMore?: boolean;
|
||||
}
|
||||
export interface Parameters {
|
||||
objectFields?: Record<string, JsonValue>;
|
||||
}
|
||||
export interface PostFeedItem {
|
||||
latestReplies?: ReplyFeedItem;
|
||||
pinned?: boolean;
|
||||
message?: Entity;
|
||||
likedByMe?: boolean;
|
||||
relatedEntities?: Entity;
|
||||
notify?: Entity;
|
||||
topics?: Entity;
|
||||
bodyMarkup?: string;
|
||||
summary?: string;
|
||||
}
|
||||
export interface Recipient {
|
||||
recipientType?: RecipientType;
|
||||
user?: EntityId;
|
||||
eMail?: string;
|
||||
}
|
||||
export interface Relation {
|
||||
name?: string;
|
||||
fields?: string[];
|
||||
where?: Condition;
|
||||
orders?: OrderBy[];
|
||||
fromLink?: boolean;
|
||||
}
|
||||
export interface RelationDescription {
|
||||
name?: string;
|
||||
label?: string;
|
||||
roleLabel?: string;
|
||||
readOnly?: boolean;
|
||||
linkTypeName?: string;
|
||||
relatedTypeName?: string;
|
||||
sourceFieldName?: string;
|
||||
}
|
||||
export interface Repeat {
|
||||
every?: Every;
|
||||
occurrences?: number;
|
||||
endBy?: DateTime;
|
||||
}
|
||||
export interface ReplyFeedItem {
|
||||
message?: Entity;
|
||||
likedByMe?: boolean;
|
||||
relatedEntities?: Entity;
|
||||
notify?: Entity;
|
||||
topics?: Entity;
|
||||
bodyMarkup?: string;
|
||||
summary?: string;
|
||||
}
|
||||
export interface Request {
|
||||
url?: string;
|
||||
method?: string;
|
||||
body?: JsonValue;
|
||||
}
|
||||
export interface Response {
|
||||
statusCode?: number;
|
||||
body?: JsonValue;
|
||||
}
|
||||
export interface RetrieveResult {
|
||||
entity?: Entity;
|
||||
}
|
||||
export interface RoleForResource {
|
||||
role: RoleType;
|
||||
resource: EntityId;
|
||||
}
|
||||
export interface EntityFeedQuery {
|
||||
entityId: EntityId;
|
||||
fields?: string[];
|
||||
feedItemOptions?: string[];
|
||||
paging?: Paging;
|
||||
}
|
||||
export interface GroupsQuery {
|
||||
fields?: string[];
|
||||
paging?: Paging;
|
||||
}
|
||||
export interface NewsFeedQuery {
|
||||
mode?: NewsFeedMode;
|
||||
fields?: string[];
|
||||
feedItemOptions?: string[];
|
||||
paging?: Paging;
|
||||
}
|
||||
export interface RepliesQuery {
|
||||
postId: EntityId;
|
||||
fields?: string[];
|
||||
feedItemOptions?: string[];
|
||||
paging?: Paging;
|
||||
}
|
||||
export interface AggregateQuery {
|
||||
typeName: string;
|
||||
groupBy?: string[];
|
||||
orders?: OrderBy[];
|
||||
where?: Condition;
|
||||
aggregations: FieldAggregation[];
|
||||
paging?: Paging;
|
||||
}
|
||||
export interface CzqlQuery {
|
||||
q?: string;
|
||||
parameters?: Parameters;
|
||||
paging?: Paging;
|
||||
}
|
||||
export interface EntityQuery {
|
||||
typeName: string;
|
||||
fields?: string[];
|
||||
orders?: OrderBy[];
|
||||
where?: Condition;
|
||||
relations?: Relation[];
|
||||
deleted?: boolean;
|
||||
originalExternalID?: boolean;
|
||||
paging?: Paging;
|
||||
}
|
||||
export interface RelationQuery {
|
||||
entityId: EntityId;
|
||||
relationName: string;
|
||||
fields?: string[];
|
||||
orders?: OrderBy[];
|
||||
where?: Condition;
|
||||
relations?: Relation[];
|
||||
fromLink?: boolean;
|
||||
paging?: Paging;
|
||||
}
|
||||
export interface ExpenseQuery {
|
||||
projectId?: EntityId;
|
||||
customerId?: EntityId;
|
||||
typeName: string;
|
||||
fields?: string[];
|
||||
orders?: OrderBy[];
|
||||
where?: Condition;
|
||||
relations?: Relation[];
|
||||
deleted?: boolean;
|
||||
originalExternalID?: boolean;
|
||||
paging?: Paging;
|
||||
}
|
||||
export interface TimesheetQuery {
|
||||
projectId?: EntityId;
|
||||
customerId?: EntityId;
|
||||
iAmTheApprover?: boolean;
|
||||
workItems?: EntityId[];
|
||||
timesheetState?: TimesheetState;
|
||||
typeName: string;
|
||||
fields?: string[];
|
||||
orders?: OrderBy[];
|
||||
where?: Condition;
|
||||
relations?: Relation[];
|
||||
deleted?: boolean;
|
||||
originalExternalID?: boolean;
|
||||
paging?: Paging;
|
||||
}
|
||||
export interface FindUserQuery {
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
eMail?: string;
|
||||
fuzzySearchUserName?: boolean;
|
||||
includeSuspendedUsers?: boolean;
|
||||
fields?: string[];
|
||||
orders?: OrderBy[];
|
||||
paging?: Paging;
|
||||
}
|
||||
export type Query = EntityFeedQuery | GroupsQuery | NewsFeedQuery | RepliesQuery | AggregateQuery | CzqlQuery | EntityQuery | RelationQuery | ExpenseQuery | TimesheetQuery | FindUserQuery;
|
||||
export type EntityQueryBody = EntityQuery;
|
||||
export type ComparisonOperator = Operator;
|
||||
export type SortOrder = Order;
|
||||
export type ConditionParameters = Parameters;
|
||||
//# sourceMappingURL=clarizen-api-types.d.ts.map
|
||||
+1
File diff suppressed because one or more lines are too long
+2
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=clarizen-api-types.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"clarizen-api-types.js","sourceRoot":"","sources":["../src/clarizen-api-types.ts"],"names":[],"mappings":""}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
import { type ClarizenNamespace } from "./endpoints.js";
|
||||
import { EntityObjectsService } from "./objects.js";
|
||||
import { type MetadataService } from "./metadata/service.js";
|
||||
import { type NamespaceService, type OperationCall } from "./service.js";
|
||||
import type { QueryParamValue } from "./http.js";
|
||||
import type { EntityQueryParams, EntityQueryResult, JsonObject, LoginParams, LoginResult, ServerDefinition, SessionInfo } from "./types.js";
|
||||
export interface ClarizenOptions {
|
||||
baseUrl?: string;
|
||||
apiToken?: string;
|
||||
sessionId?: string;
|
||||
}
|
||||
export interface AuthenticationService {
|
||||
getServerDefinition: (body?: JsonObject) => Promise<ServerDefinition>;
|
||||
getSessionInfo: () => Promise<SessionInfo>;
|
||||
login: (params: LoginParams) => Promise<LoginResult>;
|
||||
logout: OperationCall;
|
||||
}
|
||||
export interface DataService {
|
||||
entityQuery: (params: EntityQueryParams) => Promise<EntityQueryResult>;
|
||||
[operation: string]: OperationCall | ((params: EntityQueryParams) => Promise<EntityQueryResult>);
|
||||
}
|
||||
export type { MetadataService } from "./metadata/service.js";
|
||||
export declare class Clarizen {
|
||||
private readonly http;
|
||||
readonly authentication: AuthenticationService;
|
||||
readonly applications: NamespaceService;
|
||||
readonly bulk: NamespaceService;
|
||||
readonly data: DataService;
|
||||
readonly files: NamespaceService;
|
||||
readonly metadata: MetadataService;
|
||||
readonly utils: NamespaceService;
|
||||
readonly objects: EntityObjectsService;
|
||||
constructor(baseUrl: string, apiToken?: string);
|
||||
constructor(options: ClarizenOptions);
|
||||
get baseUrl(): string;
|
||||
loginWithDiscovery(params: LoginParams): Promise<LoginResult>;
|
||||
useSession(sessionId: string): void;
|
||||
useApiKey(apiToken: string): void;
|
||||
get sessionId(): string | undefined;
|
||||
call<T = unknown>(namespace: ClarizenNamespace, operation: string, body?: Record<string, unknown>, query?: Record<string, QueryParamValue>): Promise<T>;
|
||||
static createForLogin(baseUrl?: string): Clarizen;
|
||||
static readonly namespaces: readonly ["applications", "authentication", "bulk", "data", "files", "metadata", "utils"];
|
||||
}
|
||||
//# sourceMappingURL=clarizen.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"clarizen.d.ts","sourceRoot":"","sources":["../src/clarizen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAEV,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,UAAU,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACtE,cAAc,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3C,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IACrD,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACvE,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC;CAClG;AAED,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAElC,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;IAC/C,QAAQ,CAAC,YAAY,EAAE,gBAAgB,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;gBAE3B,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;gBAClC,OAAO,EAAE,eAAe;IAoDpC,IAAI,OAAO,IAAI,MAAM,CAEpB;IAEK,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAQnE,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAInC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIjC,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAGlC;IAED,IAAI,CAAC,CAAC,GAAG,OAAO,EACd,SAAS,EAAE,iBAAiB,EAC5B,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GACtC,OAAO,CAAC,CAAC,CAAC;IAKb,MAAM,CAAC,cAAc,CAAC,OAAO,SAA6B,GAAG,QAAQ;IAIrE,MAAM,CAAC,QAAQ,CAAC,UAAU,4FAAc;CACzC"}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
import { NAMESPACES } from "./endpoints.js";
|
||||
import { HttpClient } from "./http.js";
|
||||
import { EntityObjectsService } from "./objects.js";
|
||||
import { createMetadataService } from "./metadata/service.js";
|
||||
import { createNamespaceService, } from "./service.js";
|
||||
export class Clarizen {
|
||||
http;
|
||||
authentication;
|
||||
applications;
|
||||
bulk;
|
||||
data;
|
||||
files;
|
||||
metadata;
|
||||
utils;
|
||||
objects;
|
||||
constructor(baseUrlOrOptions, apiToken) {
|
||||
const options = typeof baseUrlOrOptions === "string"
|
||||
? { baseUrl: baseUrlOrOptions, apiToken }
|
||||
: baseUrlOrOptions;
|
||||
const baseUrl = (options.baseUrl ?? "https://api.clarizen.com").replace(/\/$/, "");
|
||||
let auth;
|
||||
if (options.sessionId) {
|
||||
auth = { type: "session", sessionId: options.sessionId };
|
||||
}
|
||||
else if (options.apiToken) {
|
||||
auth = { type: "apiKey", token: options.apiToken };
|
||||
}
|
||||
else {
|
||||
auth = { type: "none" };
|
||||
}
|
||||
this.http = new HttpClient(baseUrl, auth);
|
||||
const authBase = createNamespaceService(this.http, "authentication");
|
||||
this.authentication = {
|
||||
getServerDefinition: (body) => authBase.getServerDefinition(body),
|
||||
getSessionInfo: () => authBase.getSessionInfo(),
|
||||
logout: authBase.logout,
|
||||
login: async (params) => {
|
||||
const result = (await authBase.login(params));
|
||||
this.useSession(result.sessionId);
|
||||
return result;
|
||||
},
|
||||
};
|
||||
this.applications = createNamespaceService(this.http, "applications");
|
||||
this.bulk = createNamespaceService(this.http, "bulk");
|
||||
this.files = createNamespaceService(this.http, "files");
|
||||
this.metadata = createMetadataService(this.http);
|
||||
this.utils = createNamespaceService(this.http, "utils");
|
||||
this.objects = new EntityObjectsService(this.http);
|
||||
this.data = createNamespaceService(this.http, "data");
|
||||
}
|
||||
get baseUrl() {
|
||||
return this.http.getBaseUrl();
|
||||
}
|
||||
async loginWithDiscovery(params) {
|
||||
const definition = await this.authentication.getServerDefinition(params);
|
||||
this.http.setBaseUrl(definition.serverLocation);
|
||||
return this.authentication.login(params);
|
||||
}
|
||||
useSession(sessionId) {
|
||||
this.http.setAuth({ type: "session", sessionId });
|
||||
}
|
||||
useApiKey(apiToken) {
|
||||
this.http.setAuth({ type: "apiKey", token: apiToken });
|
||||
}
|
||||
get sessionId() {
|
||||
const auth = this.http.getAuth();
|
||||
return auth.type === "session" ? auth.sessionId : undefined;
|
||||
}
|
||||
call(namespace, operation, body, query) {
|
||||
const service = this[namespace];
|
||||
return service(operation, body, query);
|
||||
}
|
||||
static createForLogin(baseUrl = "https://api.clarizen.com") {
|
||||
return new Clarizen({ baseUrl });
|
||||
}
|
||||
static namespaces = NAMESPACES;
|
||||
}
|
||||
//# sourceMappingURL=clarizen.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"clarizen.js","sourceRoot":"","sources":["../src/clarizen.ts"],"names":[],"mappings":"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"}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type { EndpointDefinition } from "./types.js";
|
||||
export declare const ENDPOINTS: EndpointDefinition[];
|
||||
export declare const NAMESPACES: readonly ["applications", "authentication", "bulk", "data", "files", "metadata", "utils"];
|
||||
export type ClarizenNamespace = (typeof NAMESPACES)[number];
|
||||
//# sourceMappingURL=endpoints.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../src/endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,eAAO,MAAM,SAAS,EAAE,kBAAkB,EAqDzC,CAAC;AAEF,eAAO,MAAM,UAAU,2FAQb,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
export const ENDPOINTS = [
|
||||
{ namespace: "applications", operation: "GetApplicationStatus", path: "/V2.0/services/applications/getApplicationStatus", httpMethods: ["GET"], description: "Get application status" },
|
||||
{ namespace: "applications", operation: "InstallApplication", path: "/V2.0/services/applications/installApplication", httpMethods: ["POST"], description: "Install application" },
|
||||
{ namespace: "authentication", operation: "GetServerDefinition", path: "/V2.0/services/authentication/getServerDefinition", httpMethods: ["POST"], description: "Returns the URL where your organization API is located" },
|
||||
{ namespace: "authentication", operation: "GetSessionInfo", path: "/V2.0/services/authentication/getSessionInfo", httpMethods: ["GET", "POST"], description: "Returns information about the current session" },
|
||||
{ namespace: "authentication", operation: "Login", path: "/V2.0/services/authentication/login", httpMethods: ["POST"], description: "Login to the API" },
|
||||
{ namespace: "authentication", operation: "Logout", path: "/V2.0/services/authentication/logout", httpMethods: ["GET"], description: "Terminate the current API session" },
|
||||
{ namespace: "bulk", operation: "Execute", path: "/V2.0/services/bulk/execute", httpMethods: ["POST"], description: "Execute several API calls in a single round trip" },
|
||||
{ namespace: "data", operation: "AggregateQuery", path: "/V2.0/services/data/aggregateQuery", httpMethods: ["GET", "POST"], description: "Query and aggregate results" },
|
||||
{ namespace: "data", operation: "ApplyOnMembers", path: "/V2.0/services/data/applyOnMembers", httpMethods: ["POST"], description: "Apply settings from User Group to members" },
|
||||
{ namespace: "data", operation: "ChangeState", path: "/V2.0/services/data/changeState", httpMethods: ["POST"], description: "Change the state of an object" },
|
||||
{ namespace: "data", operation: "CloseFiscalMonth", path: "/V2.0/services/data/closeFiscalMonth", httpMethods: ["POST"], description: "Close the fiscal month" },
|
||||
{ namespace: "data", operation: "CountQuery", path: "/V2.0/services/data/countQuery", httpMethods: ["GET", "POST"], description: "Query and return result count" },
|
||||
{ namespace: "data", operation: "CreateAndRetrieve", path: "/V2.0/services/data/createAndRetrieve", httpMethods: ["POST"], description: "Create and immediately retrieve an entity" },
|
||||
{ namespace: "data", operation: "CreateDiscussion", path: "/V2.0/services/data/createDiscussion", httpMethods: ["POST"], description: "Create a discussion message" },
|
||||
{ namespace: "data", operation: "CreateFromTemplate", path: "/V2.0/services/data/createFromTemplate", httpMethods: ["POST"], description: "Create an entity from a template" },
|
||||
{ namespace: "data", operation: "CreateMultiply", path: "/V2.0/services/data/createMultiply", httpMethods: ["PUT"], description: "Create multiple entities" },
|
||||
{ namespace: "data", operation: "DeletePermissions", path: "/V2.0/services/data/deletePermissions", httpMethods: ["POST"], description: "Delete permission on entity" },
|
||||
{ namespace: "data", operation: "EntityFeedQuery", path: "/V2.0/services/data/entityFeedQuery", httpMethods: ["GET", "POST"], description: "Return the social feed of an object" },
|
||||
{ namespace: "data", operation: "EntityQuery", path: "/V2.0/services/data/entityQuery", httpMethods: ["GET", "POST"], description: "Retrieve entities by criteria" },
|
||||
{ namespace: "data", operation: "ExecuteCustomAction", path: "/V2.0/services/data/executeCustomAction", httpMethods: ["GET", "POST"], description: "Execute custom action" },
|
||||
{ namespace: "data", operation: "ExpenseQuery", path: "/V2.0/services/data/expenseQuery", httpMethods: ["POST"], description: "Retrieve expenses for a project or customer" },
|
||||
{ namespace: "data", operation: "FindUserQuery", path: "/V2.0/services/data/findUserQuery", httpMethods: ["POST"], description: "Find a user by criteria" },
|
||||
{ namespace: "data", operation: "GetCalendarExceptions", path: "/V2.0/services/data/getCalendarExceptions", httpMethods: ["GET"], description: "Retrieve calendar exceptions" },
|
||||
{ namespace: "data", operation: "GetCalendarInfo", path: "/V2.0/services/data/getCalendarInfo", httpMethods: ["GET"], description: "Calendar definitions info" },
|
||||
{ namespace: "data", operation: "GetTemplateDescriptions", path: "/V2.0/services/data/getTemplateDescriptions", httpMethods: ["GET"], description: "List templates for an entity type" },
|
||||
{ namespace: "data", operation: "GroupsQuery", path: "/V2.0/services/data/groupsQuery", httpMethods: ["GET", "POST"], description: "List groups the current user belongs to" },
|
||||
{ namespace: "data", operation: "LicenseConsumption", path: "/V2.0/services/data/licenseConsumption", httpMethods: ["GET", "POST"], description: "License consumption per organization" },
|
||||
{ namespace: "data", operation: "Lifecycle", path: "/V2.0/services/data/lifecycle", httpMethods: ["POST"], description: "Lifecycle operations (Activate, Cancel, etc.)" },
|
||||
{ namespace: "data", operation: "MissingTimesheets", path: "/V2.0/services/data/missingTimesheets", httpMethods: ["GET"], description: "Missing timesheets information" },
|
||||
{ namespace: "data", operation: "NewsFeedQuery", path: "/V2.0/services/data/newsFeedQuery", httpMethods: ["GET", "POST"], description: "Current user news feed" },
|
||||
{ namespace: "data", operation: "ObjectIds", path: "/V2.0/services/data/objectIds", httpMethods: ["POST"], description: "Resolve object IDs" },
|
||||
{ namespace: "data", operation: "Query", path: "/V2.0/services/data/query", httpMethods: ["GET", "POST"], description: "Execute a CZQL query" },
|
||||
{ namespace: "data", operation: "RelationQuery", path: "/V2.0/services/data/relationQuery", httpMethods: ["GET", "POST"], description: "Related entities from a relation" },
|
||||
{ namespace: "data", operation: "ReopenFiscalMonth", path: "/V2.0/services/data/reopenFiscalMonth", httpMethods: ["POST"], description: "Reopen fiscal month" },
|
||||
{ namespace: "data", operation: "RepliesQuery", path: "/V2.0/services/data/repliesQuery", httpMethods: ["GET", "POST"], description: "Reply feed of a discussion" },
|
||||
{ namespace: "data", operation: "RetrieveMultiple", path: "/V2.0/services/data/retrieveMultiple", httpMethods: ["POST"], description: "Retrieve multiple entities of the same type" },
|
||||
{ namespace: "data", operation: "Search", path: "/V2.0/services/data/search", httpMethods: ["GET"], description: "Text search in entity types" },
|
||||
{ namespace: "data", operation: "SetPermissions", path: "/V2.0/services/data/setPermissions", httpMethods: ["POST"], description: "Create or update permission on entity" },
|
||||
{ namespace: "data", operation: "TimesheetQuery", path: "/V2.0/services/data/timesheetQuery", httpMethods: ["GET", "POST"], description: "Retrieve timesheets" },
|
||||
{ namespace: "data", operation: "Upsert", path: "/V2.0/services/data/upsert", httpMethods: ["POST"], description: "Create or update an entity" },
|
||||
{ namespace: "files", operation: "Download", path: "/V2.0/services/files/download", httpMethods: ["GET"], description: "Download file attached to a document" },
|
||||
{ namespace: "files", operation: "GetUploadUrl", path: "/V2.0/services/files/getUploadUrl", httpMethods: ["GET"], description: "Get URL for uploading files" },
|
||||
{ namespace: "files", operation: "UpdateImage", path: "/V2.0/services/files/updateImage", httpMethods: ["POST"], description: "Set or reset object image" },
|
||||
{ namespace: "files", operation: "Upload", path: "/V2.0/services/files/upload", httpMethods: ["POST"], description: "Upload file to a document" },
|
||||
{ namespace: "metadata", operation: "DescribeEntities", path: "/V2.0/services/metadata/describeEntities", httpMethods: ["GET"], description: "Entity type fields, relations and states" },
|
||||
{ namespace: "metadata", operation: "DescribeEntityRelations", path: "/V2.0/services/metadata/describeEntityRelations", httpMethods: ["POST"], description: "Describe relation between entities" },
|
||||
{ namespace: "metadata", operation: "DescribeMetadata", path: "/V2.0/services/metadata/describeMetadata", httpMethods: ["GET"], description: "Entity types in your organization" },
|
||||
{ namespace: "metadata", operation: "GetSystemSettingsValues", path: "/V2.0/services/metadata/getSystemSettingsValues", httpMethods: ["GET"], description: "Retrieve system settings values" },
|
||||
{ namespace: "metadata", operation: "ListEntities", path: "/V2.0/services/metadata/listEntities", httpMethods: ["GET"], description: "List entity types for your organization" },
|
||||
{ namespace: "metadata", operation: "SetSystemSettingsValues", path: "/V2.0/services/metadata/setSystemSettingsValues", httpMethods: ["POST"], description: "Save system settings values" },
|
||||
{ namespace: "utils", operation: "AppLogin", path: "/V2.0/services/utils/appLogin", httpMethods: ["GET"], description: "Convert API session to web application session" },
|
||||
{ namespace: "utils", operation: "SendEMail", path: "/V2.0/services/utils/sendEMail", httpMethods: ["POST"], description: "Send email attached to an object" },
|
||||
];
|
||||
export const NAMESPACES = [
|
||||
"applications",
|
||||
"authentication",
|
||||
"bulk",
|
||||
"data",
|
||||
"files",
|
||||
"metadata",
|
||||
"utils",
|
||||
];
|
||||
//# sourceMappingURL=endpoints.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+9
@@ -0,0 +1,9 @@
|
||||
import type { ClarizenErrorBody } from "./types.js";
|
||||
export declare class ClarizenApiError extends Error {
|
||||
readonly errorCode: string;
|
||||
readonly referenceId?: string;
|
||||
readonly status: number;
|
||||
constructor(status: number, body: ClarizenErrorBody);
|
||||
isSessionTimeout(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=errors.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB;IAQnD,gBAAgB,IAAI,OAAO;CAG5B"}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
export class ClarizenApiError extends Error {
|
||||
errorCode;
|
||||
referenceId;
|
||||
status;
|
||||
constructor(status, body) {
|
||||
super(body.message);
|
||||
this.name = "ClarizenApiError";
|
||||
this.status = status;
|
||||
this.errorCode = body.errorCode;
|
||||
this.referenceId = body.referenceId;
|
||||
}
|
||||
isSessionTimeout() {
|
||||
return this.errorCode === "SessionTimeout";
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=errors.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,SAAS,CAAS;IAClB,WAAW,CAAU;IACrB,MAAM,CAAS;IAExB,YAAY,MAAc,EAAE,IAAuB;QACjD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IACtC,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,SAAS,KAAK,gBAAgB,CAAC;IAC7C,CAAC;CACF"}
|
||||
+6275
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1206
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+20
@@ -0,0 +1,20 @@
|
||||
import type { AuthMode, HttpMethod, JsonObject } from "./types.js";
|
||||
export type QueryParamValue = string | number | boolean | readonly (string | number | boolean)[] | undefined;
|
||||
export interface RequestOptions {
|
||||
method?: HttpMethod;
|
||||
query?: Record<string, QueryParamValue>;
|
||||
body?: JsonObject;
|
||||
}
|
||||
export declare class HttpClient {
|
||||
private baseUrl;
|
||||
private auth;
|
||||
constructor(baseUrl: string, auth: AuthMode);
|
||||
getBaseUrl(): string;
|
||||
setBaseUrl(baseUrl: string): void;
|
||||
setAuth(auth: AuthMode): void;
|
||||
getAuth(): AuthMode;
|
||||
private authorizationHeader;
|
||||
request<T>(path: string, options?: RequestOptions): Promise<T>;
|
||||
private executeOnce;
|
||||
}
|
||||
//# sourceMappingURL=http.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAqB,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEtF,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GACtC,SAAS,CAAC;AAEd,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACxC,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAmBD,qBAAa,UAAU;IAEnB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,IAAI;gBADJ,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,QAAQ;IAGxB,UAAU,IAAI,MAAM;IAIpB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAI7B,OAAO,IAAI,QAAQ;IAInB,OAAO,CAAC,mBAAmB;IAUrB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,CAAC,CAAC;YAe1D,WAAW;CAqD1B"}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
import { ClarizenApiError } from "./errors.js";
|
||||
function appendQueryParam(params, key, value) {
|
||||
if (value === undefined)
|
||||
return;
|
||||
if (Array.isArray(value)) {
|
||||
for (const item of value) {
|
||||
params.append(key, String(item));
|
||||
}
|
||||
return;
|
||||
}
|
||||
params.set(key, String(value));
|
||||
}
|
||||
const MAX_ATTEMPTS = 3;
|
||||
export class HttpClient {
|
||||
baseUrl;
|
||||
auth;
|
||||
constructor(baseUrl, auth) {
|
||||
this.baseUrl = baseUrl;
|
||||
this.auth = auth;
|
||||
}
|
||||
getBaseUrl() {
|
||||
return this.baseUrl;
|
||||
}
|
||||
setBaseUrl(baseUrl) {
|
||||
this.baseUrl = baseUrl.replace(/\/$/, "");
|
||||
}
|
||||
setAuth(auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
getAuth() {
|
||||
return this.auth;
|
||||
}
|
||||
authorizationHeader() {
|
||||
if (this.auth.type === "apiKey") {
|
||||
return `ApiKey ${this.auth.token}`;
|
||||
}
|
||||
if (this.auth.type === "session") {
|
||||
return `Session ${this.auth.sessionId}`;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
async request(path, options = {}) {
|
||||
for (let attempt = 1;; attempt++) {
|
||||
try {
|
||||
return await this.executeOnce(path, options);
|
||||
}
|
||||
catch (error) {
|
||||
if ((error instanceof ClarizenApiError && error.isSessionTimeout()) ||
|
||||
attempt >= MAX_ATTEMPTS) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
async executeOnce(path, options) {
|
||||
const method = options.method ?? "POST";
|
||||
const url = new URL(path, this.baseUrl);
|
||||
if (options.query) {
|
||||
for (const [key, value] of Object.entries(options.query)) {
|
||||
appendQueryParam(url.searchParams, key, value);
|
||||
}
|
||||
}
|
||||
const headers = {
|
||||
Accept: "application/json",
|
||||
"Accept-Encoding": "gzip",
|
||||
};
|
||||
const authHeader = this.authorizationHeader();
|
||||
if (authHeader) {
|
||||
headers.Authorization = authHeader;
|
||||
}
|
||||
const init = { method, headers };
|
||||
if (method !== "GET" && options.body !== undefined) {
|
||||
headers["Content-Type"] = "application/json";
|
||||
init.body = JSON.stringify(options.body);
|
||||
}
|
||||
const response = await fetch(url, init);
|
||||
const text = await response.text();
|
||||
if (!text) {
|
||||
if (!response.ok) {
|
||||
throw new ClarizenApiError(response.status, {
|
||||
errorCode: "HttpError",
|
||||
message: response.statusText,
|
||||
});
|
||||
}
|
||||
return {};
|
||||
}
|
||||
const data = JSON.parse(text);
|
||||
if (!response.ok || (data && typeof data === "object" && "errorCode" in data)) {
|
||||
const err = data;
|
||||
if (err.errorCode) {
|
||||
throw new ClarizenApiError(response.status || 400, err);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=http.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"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"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
export { Clarizen, type ClarizenOptions } from "./clarizen.js";
|
||||
export type { AuthenticationService, DataService, MetadataService, } from "./clarizen.js";
|
||||
export { ClarizenApiError } from "./errors.js";
|
||||
export { ENDPOINTS, NAMESPACES, type ClarizenNamespace } from "./endpoints.js";
|
||||
export { EntityObjectsService, entityObjectPath } from "./objects.js";
|
||||
export type { EntityGetOptions } from "./objects.js";
|
||||
export type { AuthMode, EntityQueryParams, EntityQueryResult, LoginParams, LoginResult, ServerDefinition, SessionInfo, EndpointDefinition, JsonObject, JsonValue, } from "./types.js";
|
||||
export * from "./clarizen-api-types.js";
|
||||
export { fetchMetadataCatalog, filterStandardTypeNames, isStandardMetadataName, sanitizeEntityDescription, } from "./metadata/index.js";
|
||||
export type { DescribeMetadataParams, DescribeMetadataResult, EntityMetadataEntry, FetchMetadataCatalogOptions, ListEntitiesResult, MetadataCatalog, MetadataFlag, } from "./metadata/index.js";
|
||||
export * from "./generated/metadata-types.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,YAAY,EACV,qBAAqB,EACrB,WAAW,EACX,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACtE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EACV,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,2BAA2B,EAC3B,kBAAkB,EAClB,eAAe,EACf,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,cAAc,+BAA+B,CAAC"}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
export { Clarizen } from "./clarizen.js";
|
||||
export { ClarizenApiError } from "./errors.js";
|
||||
export { ENDPOINTS, NAMESPACES } from "./endpoints.js";
|
||||
export { EntityObjectsService, entityObjectPath } from "./objects.js";
|
||||
export * from "./clarizen-api-types.js";
|
||||
export { fetchMetadataCatalog, filterStandardTypeNames, isStandardMetadataName, sanitizeEntityDescription, } from "./metadata/index.js";
|
||||
export * from "./generated/metadata-types.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwB,MAAM,eAAe,CAAC;AAM/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,UAAU,EAA0B,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AActE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAU7B,cAAc,+BAA+B,CAAC"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type { HttpClient } from "../http.js";
|
||||
import type { FetchMetadataCatalogOptions, MetadataCatalog } from "./types.js";
|
||||
export declare function fetchMetadataCatalog(http: HttpClient, options?: FetchMetadataCatalogOptions): Promise<MetadataCatalog>;
|
||||
//# sourceMappingURL=catalog.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/metadata/catalog.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAK7C,OAAO,KAAK,EAGV,2BAA2B,EAE3B,eAAe,EAEhB,MAAM,YAAY,CAAC;AAqHpB,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,eAAe,CAAC,CAyB1B"}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
import { ClarizenApiError } from "../errors.js";
|
||||
import { ENDPOINTS } from "../endpoints.js";
|
||||
import { filterStandardTypeNames, sanitizeEntityDescription, } from "./filter.js";
|
||||
const DEFAULT_FLAGS = ["fields", "relations"];
|
||||
const DEFAULT_BATCH_SIZE = 20;
|
||||
const DESCRIBE_METADATA_PATH = ENDPOINTS.find((e) => e.namespace === "metadata" && e.operation === "DescribeMetadata")?.path ?? "/V2.0/services/metadata/describeMetadata";
|
||||
const LIST_ENTITIES_PATH = ENDPOINTS.find((e) => e.namespace === "metadata" && e.operation === "ListEntities")?.path ?? "/V2.0/services/metadata/listEntities";
|
||||
function describeMetadataQuery(typeNames, flags) {
|
||||
const query = {
|
||||
flags,
|
||||
};
|
||||
if (typeNames !== undefined && typeNames.length > 0) {
|
||||
query.typeNames = typeNames;
|
||||
}
|
||||
return query;
|
||||
}
|
||||
async function listEntities(http) {
|
||||
const result = await http.request(LIST_ENTITIES_PATH, {
|
||||
method: "GET",
|
||||
});
|
||||
return result.typeNames ?? [];
|
||||
}
|
||||
async function describeMetadata(http, typeNames, flags) {
|
||||
const result = await http.request(DESCRIBE_METADATA_PATH, {
|
||||
method: "GET",
|
||||
query: describeMetadataQuery(typeNames, flags),
|
||||
});
|
||||
const entries = [];
|
||||
for (const desc of result.entityDescriptions ?? []) {
|
||||
const entry = sanitizeEntityDescription(desc);
|
||||
if (entry) {
|
||||
entries.push(entry);
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
function chunk(items, size) {
|
||||
const chunks = [];
|
||||
for (let i = 0; i < items.length; i += size) {
|
||||
chunks.push(items.slice(i, i + size));
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
function mergeEntries(batches) {
|
||||
const byType = new Map();
|
||||
for (const batch of batches) {
|
||||
for (const entry of batch) {
|
||||
byType.set(entry.typeName, entry);
|
||||
}
|
||||
}
|
||||
return [...byType.values()].sort((a, b) => a.typeName.localeCompare(b.typeName));
|
||||
}
|
||||
function needsBatchedFetch(error) {
|
||||
if (error instanceof ClarizenApiError) {
|
||||
return (error.errorCode === "MissingArgument" ||
|
||||
error.errorCode === "InvalidArgument");
|
||||
}
|
||||
if (error instanceof Error) {
|
||||
const msg = error.message.toLowerCase();
|
||||
return msg.includes("missing") || msg.includes("typenames");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
async function fetchBatched(http, flags, batchSize, log) {
|
||||
log("listEntities + batched describeMetadata...");
|
||||
const rawNames = await listEntities(http);
|
||||
const typeNames = filterStandardTypeNames(rawNames);
|
||||
log(` ${typeNames.length} standard entities (${rawNames.length} total)`);
|
||||
const batches = chunk(typeNames, batchSize);
|
||||
const batchResults = [];
|
||||
for (let i = 0; i < batches.length; i++) {
|
||||
const batch = batches[i];
|
||||
log(` batch ${i + 1}/${batches.length} (${batch.length} types)...`);
|
||||
batchResults.push(await describeMetadata(http, batch, flags));
|
||||
}
|
||||
return mergeEntries(batchResults);
|
||||
}
|
||||
export async function fetchMetadataCatalog(http, options = {}) {
|
||||
const flags = options.flags ?? DEFAULT_FLAGS;
|
||||
const batchSize = options.batchSize ?? DEFAULT_BATCH_SIZE;
|
||||
const log = options.onProgress ?? (() => { });
|
||||
let entries;
|
||||
try {
|
||||
log("describeMetadata (all entities)...");
|
||||
entries = await describeMetadata(http, undefined, flags);
|
||||
if (entries.length === 0) {
|
||||
entries = await fetchBatched(http, flags, batchSize, log);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
if (needsBatchedFetch(error)) {
|
||||
entries = await fetchBatched(http, flags, batchSize, log);
|
||||
}
|
||||
else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return {
|
||||
fetchedAt: new Date().toISOString(),
|
||||
entities: entries,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=catalog.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/metadata/catalog.ts"],"names":[],"mappings":"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"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import type { EntityDescription } from "../clarizen-api-types.js";
|
||||
import type { EntityMetadataEntry } from "./types.js";
|
||||
/** Standard (non-custom) metadata names exclude C_ and R_ segments. */
|
||||
export declare function isStandardMetadataName(name: string): boolean;
|
||||
export declare function filterStandardTypeNames(typeNames: string[]): string[];
|
||||
export declare function sanitizeEntityDescription(desc: EntityDescription): EntityMetadataEntry | null;
|
||||
//# sourceMappingURL=filter.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/metadata/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,uEAAuE;AACvE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAErE;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,iBAAiB,GACtB,mBAAmB,GAAG,IAAI,CAuB5B"}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/** Standard (non-custom) metadata names exclude C_ and R_ segments. */
|
||||
export function isStandardMetadataName(name) {
|
||||
return !name.includes("C_") && !name.includes("R_");
|
||||
}
|
||||
export function filterStandardTypeNames(typeNames) {
|
||||
return typeNames.filter(isStandardMetadataName);
|
||||
}
|
||||
export function sanitizeEntityDescription(desc) {
|
||||
const typeName = desc.typeName;
|
||||
if (!typeName || !isStandardMetadataName(typeName)) {
|
||||
return null;
|
||||
}
|
||||
const fields = (desc.fields ?? []).filter((f) => f.name && isStandardMetadataName(f.name));
|
||||
const relations = (desc.relations ?? []).filter((r) => r.name &&
|
||||
isStandardMetadataName(r.name) &&
|
||||
(!r.relatedTypeName || isStandardMetadataName(r.relatedTypeName)));
|
||||
return {
|
||||
typeName,
|
||||
label: desc.label,
|
||||
fields,
|
||||
relations,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=filter.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/metadata/filter.ts"],"names":[],"mappings":"AAGA,uEAAuE;AACvE,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,SAAmB;IACzD,OAAO,SAAS,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,IAAuB;IAEvB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,IAAI,CAAC,QAAQ,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM,CACvC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,CAChD,CAAC;IAEF,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,MAAM,CAC7C,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,IAAI;QACN,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC;QAC9B,CAAC,CAAC,CAAC,CAAC,eAAe,IAAI,sBAAsB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CACpE,CAAC;IAEF,OAAO;QACL,QAAQ;QACR,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM;QACN,SAAS;KACV,CAAC;AACJ,CAAC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import type { MetadataCatalog } from "./types.js";
|
||||
export declare function generateMetadataTypesFile(catalog: MetadataCatalog): string;
|
||||
//# sourceMappingURL=generate-types.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"generate-types.d.ts","sourceRoot":"","sources":["../../src/metadata/generate-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAUlD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CA2D1E"}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
function escapeString(value) {
|
||||
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
||||
}
|
||||
function objectKey(name) {
|
||||
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) ? name : JSON.stringify(name);
|
||||
}
|
||||
export function generateMetadataTypesFile(catalog) {
|
||||
const entityTypes = catalog.entities.map((e) => e.typeName);
|
||||
const fieldsLines = catalog.entities.map((e) => {
|
||||
const names = e.fields
|
||||
.map((f) => f.name)
|
||||
.filter((n) => Boolean(n));
|
||||
const literals = names.map((n) => `"${escapeString(n)}"`).join(", ");
|
||||
return ` ${objectKey(e.typeName)}: [${literals}] as const`;
|
||||
});
|
||||
const relationsLines = catalog.entities.map((e) => {
|
||||
const rels = e.relations
|
||||
.filter((r) => r.name && r.relatedTypeName)
|
||||
.map((r) => `{ name: "${escapeString(r.name)}", relatedTypeName: "${escapeString(r.relatedTypeName)}" }`);
|
||||
return ` ${objectKey(e.typeName)}: [${rels.join(", ")}] as const`;
|
||||
});
|
||||
return `// Auto-generated by npm run scrape:metadata. Do not edit manually.
|
||||
/* eslint-disable */
|
||||
|
||||
export const ENTITY_TYPES = [
|
||||
${entityTypes.map((t) => ` "${escapeString(t)}",`).join("\n")}
|
||||
] as const;
|
||||
|
||||
export type EntityTypeName = (typeof ENTITY_TYPES)[number];
|
||||
|
||||
export const FIELDS_BY_ENTITY = {
|
||||
${fieldsLines.join(",\n")},
|
||||
} as const;
|
||||
|
||||
export type EntityFieldName<T extends EntityTypeName> =
|
||||
(typeof FIELDS_BY_ENTITY)[T][number];
|
||||
|
||||
export const RELATIONS_BY_ENTITY = {
|
||||
${relationsLines.join(",\n")},
|
||||
} as const;
|
||||
|
||||
export type EntityRelationEntry<T extends EntityTypeName> =
|
||||
(typeof RELATIONS_BY_ENTITY)[T][number];
|
||||
|
||||
export type EntityRelationName<T extends EntityTypeName> =
|
||||
EntityRelationEntry<T>["name"];
|
||||
|
||||
export function entityFields<T extends EntityTypeName>(
|
||||
typeName: T,
|
||||
): readonly EntityFieldName<T>[] {
|
||||
return FIELDS_BY_ENTITY[typeName];
|
||||
}
|
||||
|
||||
export function entityRelations<T extends EntityTypeName>(
|
||||
typeName: T,
|
||||
): readonly EntityRelationEntry<T>[] {
|
||||
return RELATIONS_BY_ENTITY[typeName];
|
||||
}
|
||||
`;
|
||||
}
|
||||
//# sourceMappingURL=generate-types.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"generate-types.js","sourceRoot":"","sources":["../../src/metadata/generate-types.ts"],"names":[],"mappings":"AAEA,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,OAAwB;IAChE,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAE5D,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7C,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM;aACnB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aAClB,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,QAAQ,YAAY,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAChD,MAAM,IAAI,GAAG,CAAC,CAAC,SAAS;aACrB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,CAAC;aAC1C,GAAG,CACF,CAAC,CAAC,EAAE,EAAE,CACJ,YAAY,YAAY,CAAC,CAAC,CAAC,IAAK,CAAC,wBAAwB,YAAY,CAAC,CAAC,CAAC,eAAgB,CAAC,KAAK,CACjG,CAAC;QACJ,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,OAAO;;;;EAIP,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;EAM5D,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;;;;;;;EAOvB,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;CAoB3B,CAAC;AACF,CAAC"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export { fetchMetadataCatalog } from "./catalog.js";
|
||||
export { filterStandardTypeNames, isStandardMetadataName, sanitizeEntityDescription, } from "./filter.js";
|
||||
export type { DescribeMetadataParams, DescribeMetadataResult, EntityMetadataEntry, FetchMetadataCatalogOptions, ListEntitiesResult, MetadataCatalog, MetadataFlag, } from "./types.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metadata/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,2BAA2B,EAC3B,kBAAkB,EAClB,eAAe,EACf,YAAY,GACb,MAAM,YAAY,CAAC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export { fetchMetadataCatalog } from "./catalog.js";
|
||||
export { filterStandardTypeNames, isStandardMetadataName, sanitizeEntityDescription, } from "./filter.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/metadata/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,aAAa,CAAC"}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import type { HttpClient, QueryParamValue } from "../http.js";
|
||||
import { type OperationCall } from "../service.js";
|
||||
import type { JsonObject } from "../types.js";
|
||||
import type { DescribeMetadataParams, DescribeMetadataResult, FetchMetadataCatalogOptions, ListEntitiesResult, MetadataCatalog } from "./types.js";
|
||||
export interface MetadataService {
|
||||
listEntities: () => Promise<ListEntitiesResult>;
|
||||
describeMetadata: (params?: DescribeMetadataParams) => Promise<DescribeMetadataResult>;
|
||||
fetchCatalog: (options?: FetchMetadataCatalogOptions) => Promise<MetadataCatalog>;
|
||||
(operation: string, body?: JsonObject, query?: Record<string, QueryParamValue>): Promise<unknown>;
|
||||
[operation: string]: OperationCall | (() => Promise<ListEntitiesResult>) | ((params?: DescribeMetadataParams) => Promise<DescribeMetadataResult>) | ((options?: FetchMetadataCatalogOptions) => Promise<MetadataCatalog>);
|
||||
}
|
||||
export declare function createMetadataService(http: HttpClient): MetadataService;
|
||||
//# sourceMappingURL=service.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/metadata/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,eAAe,EAChB,MAAM,YAAY,CAAC;AAgBpB,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAChD,gBAAgB,EAAE,CAChB,MAAM,CAAC,EAAE,sBAAsB,KAC5B,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACrC,YAAY,EAAE,CACZ,OAAO,CAAC,EAAE,2BAA2B,KAClC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9B,CACE,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,UAAU,EACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GACtC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC,SAAS,EAAE,MAAM,GACd,aAAa,GACb,CAAC,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC,GACnC,CAAC,CAAC,MAAM,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC,GACtE,CAAC,CAAC,OAAO,CAAC,EAAE,2BAA2B,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;CAC3E;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,GAAG,eAAe,CAoBvE"}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import { createNamespaceService, } from "../service.js";
|
||||
import { fetchMetadataCatalog } from "./catalog.js";
|
||||
function describeMetadataQuery(params) {
|
||||
if (!params)
|
||||
return undefined;
|
||||
const query = {};
|
||||
if (params.typeNames?.length) {
|
||||
query.typeNames = params.typeNames;
|
||||
}
|
||||
if (params.flags?.length) {
|
||||
query.flags = params.flags;
|
||||
}
|
||||
return Object.keys(query).length > 0 ? query : undefined;
|
||||
}
|
||||
export function createMetadataService(http) {
|
||||
const base = createNamespaceService(http, "metadata");
|
||||
const invoke = base;
|
||||
const service = base;
|
||||
service.listEntities = () => invoke("ListEntities", undefined, undefined);
|
||||
service.describeMetadata = (params) => invoke("DescribeMetadata", undefined, describeMetadataQuery(params));
|
||||
service.fetchCatalog = (options) => fetchMetadataCatalog(http, options);
|
||||
return service;
|
||||
}
|
||||
//# sourceMappingURL=service.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/metadata/service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,GAGvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AASpD,SAAS,qBAAqB,CAC5B,MAA+B;IAE/B,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,MAAM,KAAK,GAAoC,EAAE,CAAC;IAClD,IAAI,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;QAC7B,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACrC,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACzB,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3D,CAAC;AAsBD,MAAM,UAAU,qBAAqB,CAAC,IAAgB;IACpD,MAAM,IAAI,GAAG,sBAAsB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,IAAwB,CAAC;IAExC,MAAM,OAAO,GAAG,IAAuB,CAAC;IAExC,OAAO,CAAC,YAAY,GAAG,GAAG,EAAE,CAC1B,MAAM,CAAC,cAAc,EAAE,SAAS,EAAE,SAAS,CAAgC,CAAC;IAE9E,OAAO,CAAC,gBAAgB,GAAG,CAAC,MAA+B,EAAE,EAAE,CAC7D,MAAM,CACJ,kBAAkB,EAClB,SAAS,EACT,qBAAqB,CAAC,MAAM,CAAC,CACK,CAAC;IAEvC,OAAO,CAAC,YAAY,GAAG,CAAC,OAAqC,EAAE,EAAE,CAC/D,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAEtC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
import type { EntityDescription, FieldDescription, RelationDescription } from "../clarizen-api-types.js";
|
||||
export type MetadataFlag = "fields" | "relations";
|
||||
export interface ListEntitiesResult {
|
||||
typeNames: string[];
|
||||
}
|
||||
export interface DescribeMetadataParams {
|
||||
typeNames?: string[];
|
||||
flags?: MetadataFlag[];
|
||||
}
|
||||
export interface DescribeMetadataResult {
|
||||
entityDescriptions: EntityDescription[];
|
||||
}
|
||||
export interface EntityMetadataEntry {
|
||||
typeName: string;
|
||||
label?: string;
|
||||
fields: FieldDescription[];
|
||||
relations: RelationDescription[];
|
||||
}
|
||||
export interface MetadataCatalog {
|
||||
fetchedAt: string;
|
||||
entities: EntityMetadataEntry[];
|
||||
}
|
||||
export interface FetchMetadataCatalogOptions {
|
||||
flags?: MetadataFlag[];
|
||||
batchSize?: number;
|
||||
onProgress?: (message: string) => void;
|
||||
}
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/metadata/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,WAAW,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,SAAS,EAAE,mBAAmB,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,mBAAmB,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,2BAA2B;IAC1C,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=types.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/metadata/types.ts"],"names":[],"mappings":""}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import type { Entity, EntityId } from "./clarizen-api-types.js";
|
||||
import type { HttpClient } from "./http.js";
|
||||
import type { JsonObject } from "./types.js";
|
||||
export declare function entityObjectPath(typeName: string, id?: string): string;
|
||||
export interface EntityGetOptions {
|
||||
fields?: string[];
|
||||
}
|
||||
export declare class EntityObjectsService {
|
||||
private readonly http;
|
||||
constructor(http: HttpClient);
|
||||
get(typeName: string, id: EntityId, options?: EntityGetOptions): Promise<Entity>;
|
||||
create(typeName: string, fields: JsonObject): Promise<{
|
||||
id: EntityId;
|
||||
}>;
|
||||
update(typeName: string, id: EntityId, fields: JsonObject): Promise<JsonObject>;
|
||||
delete(typeName: string, id: EntityId): Promise<JsonObject>;
|
||||
}
|
||||
//# sourceMappingURL=objects.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../src/objects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAOtE;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAWhF,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,QAAQ,CAAA;KAAE,CAAC;IAOvE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAO/E,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAK5D"}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
export function entityObjectPath(typeName, id) {
|
||||
const type = encodeURIComponent(typeName);
|
||||
if (id) {
|
||||
const entityId = id.includes("/") ? id.split("/").pop() : id;
|
||||
return `/V2.0/services/data/objects/${type}/${encodeURIComponent(entityId)}`;
|
||||
}
|
||||
return `/V2.0/services/data/objects/${type}`;
|
||||
}
|
||||
export class EntityObjectsService {
|
||||
http;
|
||||
constructor(http) {
|
||||
this.http = http;
|
||||
}
|
||||
get(typeName, id, options) {
|
||||
const query = {};
|
||||
if (options?.fields?.length) {
|
||||
query.fields = options.fields.join(",");
|
||||
}
|
||||
return this.http.request(entityObjectPath(typeName, id), {
|
||||
method: "GET",
|
||||
query,
|
||||
});
|
||||
}
|
||||
create(typeName, fields) {
|
||||
return this.http.request(entityObjectPath(typeName), {
|
||||
method: "PUT",
|
||||
body: fields,
|
||||
});
|
||||
}
|
||||
update(typeName, id, fields) {
|
||||
return this.http.request(entityObjectPath(typeName, id), {
|
||||
method: "POST",
|
||||
body: fields,
|
||||
});
|
||||
}
|
||||
delete(typeName, id) {
|
||||
return this.http.request(entityObjectPath(typeName, id), {
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=objects.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"objects.js","sourceRoot":"","sources":["../src/objects.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,EAAW;IAC5D,MAAM,IAAI,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,EAAE,EAAE,CAAC;QACP,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,OAAO,+BAA+B,IAAI,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC/E,CAAC;IACD,OAAO,+BAA+B,IAAI,EAAE,CAAC;AAC/C,CAAC;AAMD,MAAM,OAAO,oBAAoB;IACF;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,GAAG,CAAC,QAAgB,EAAE,EAAY,EAAE,OAA0B;QAC5D,MAAM,KAAK,GAA2B,EAAE,CAAC;QACzC,IAAI,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;YAC5B,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAS,gBAAgB,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE;YAC/D,MAAM,EAAE,KAAK;YACb,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,QAAgB,EAAE,MAAkB;QACzC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAmB,gBAAgB,CAAC,QAAQ,CAAC,EAAE;YACrE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,MAAM;SACb,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,QAAgB,EAAE,EAAY,EAAE,MAAkB;QACvD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;SACb,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,QAAgB,EAAE,EAAY;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE;YACvD,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;CACF"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import type { HttpClient, QueryParamValue } from "./http.js";
|
||||
import type { JsonObject } from "./types.js";
|
||||
export type OperationCall = <T = JsonObject>(body?: JsonObject, query?: Record<string, QueryParamValue>) => Promise<T>;
|
||||
export type ServiceCall = <T = JsonObject>(operation: string, body?: JsonObject, query?: Record<string, QueryParamValue>) => Promise<T>;
|
||||
export type NamespaceService = ServiceCall & Record<string, OperationCall>;
|
||||
export declare function createNamespaceService(http: HttpClient, namespace: string): NamespaceService;
|
||||
//# sourceMappingURL=service.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAkC,UAAU,EAAE,MAAM,YAAY,CAAC;AAa7E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,GAAG,UAAU,EACzC,IAAI,CAAC,EAAE,UAAU,EACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,KACpC,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhB,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,GAAG,UAAU,EACvC,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,UAAU,EACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,KACpC,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhB,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAE3E,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,MAAM,GAChB,gBAAgB,CAyBlB"}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import { ENDPOINTS } from "./endpoints.js";
|
||||
function toCamelCase(name) {
|
||||
return name.charAt(0).toLowerCase() + name.slice(1);
|
||||
}
|
||||
function pickMethod(endpoint) {
|
||||
if (endpoint.httpMethods.includes("POST"))
|
||||
return "POST";
|
||||
if (endpoint.httpMethods.includes("GET"))
|
||||
return "GET";
|
||||
if (endpoint.httpMethods.includes("PUT"))
|
||||
return "PUT";
|
||||
return endpoint.httpMethods[0];
|
||||
}
|
||||
export function createNamespaceService(http, namespace) {
|
||||
const endpoints = ENDPOINTS.filter((e) => e.namespace === namespace);
|
||||
const handler = async (operation, body, query) => {
|
||||
const endpoint = endpoints.find((e) => e.operation.toLowerCase() === operation.toLowerCase());
|
||||
if (!endpoint) {
|
||||
throw new Error(`Unknown ${namespace} operation: ${operation}`);
|
||||
}
|
||||
return http.request(endpoint.path, {
|
||||
method: pickMethod(endpoint),
|
||||
body,
|
||||
query,
|
||||
});
|
||||
};
|
||||
const service = handler;
|
||||
for (const endpoint of endpoints) {
|
||||
const methodName = toCamelCase(endpoint.operation);
|
||||
service[methodName] = (body, query) => handler(endpoint.operation, body, query);
|
||||
}
|
||||
return service;
|
||||
}
|
||||
//# sourceMappingURL=service.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,UAAU,CAAC,QAA4B;IAC9C,IAAI,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IACzD,IAAI,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvD,IAAI,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvD,OAAO,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC;AAeD,MAAM,UAAU,sBAAsB,CACpC,IAAgB,EAChB,SAAiB;IAEjB,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IACrE,MAAM,OAAO,GAAgB,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5D,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAC7B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,CAC7D,CAAC;QACF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,WAAW,SAAS,eAAe,SAAS,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE;YACjC,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC;YAC5B,IAAI;YACJ,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,OAA2B,CAAC;IAE5C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,UAAU,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACnD,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAK,EAAE,KAAM,EAAE,EAAE,CACtC,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
import type { Entity, EntityQuery, ErrorCode, LoginOptions, Paging } from "./clarizen-api-types.js";
|
||||
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
||||
[key: string]: JsonValue;
|
||||
};
|
||||
export type JsonObject = {
|
||||
[key: string]: JsonValue;
|
||||
};
|
||||
export interface ClarizenErrorBody {
|
||||
errorCode: ErrorCode | string;
|
||||
message: string;
|
||||
referenceId?: string;
|
||||
}
|
||||
export interface LoginParams {
|
||||
userName: string;
|
||||
password: string;
|
||||
loginOptions?: LoginOptions;
|
||||
}
|
||||
export interface ServerDefinition {
|
||||
serverLocation: string;
|
||||
appLocation?: string;
|
||||
organizationId?: number;
|
||||
}
|
||||
export interface LoginResult {
|
||||
sessionId: string;
|
||||
userId: string;
|
||||
organizationId: string;
|
||||
licenseType: string;
|
||||
serverTime?: string;
|
||||
}
|
||||
export interface SessionInfo {
|
||||
sessionId: string;
|
||||
userId: string;
|
||||
organizationId: string;
|
||||
serverTime?: string;
|
||||
licenseType?: string;
|
||||
customInfo?: Array<{
|
||||
fieldName: string;
|
||||
value: string;
|
||||
}>;
|
||||
}
|
||||
export type EntityQueryParams = EntityQuery;
|
||||
export interface EntityQueryResult {
|
||||
entities: Entity[];
|
||||
paging?: Paging;
|
||||
}
|
||||
export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE";
|
||||
export interface EndpointDefinition {
|
||||
namespace: string;
|
||||
operation: string;
|
||||
path: string;
|
||||
httpMethods: HttpMethod[];
|
||||
description: string;
|
||||
}
|
||||
export type AuthMode = {
|
||||
type: "apiKey";
|
||||
token: string;
|
||||
} | {
|
||||
type: "session";
|
||||
sessionId: string;
|
||||
} | {
|
||||
type: "none";
|
||||
};
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,MAAM,EACN,WAAW,EACX,SAAS,EACT,YAAY,EACZ,MAAM,EACP,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEjC,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1D;AAED,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAE5C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=types.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "@arco/clarizen-lib",
|
||||
"version": "0.1.0",
|
||||
"description": "TypeScript client for Clarizen / Planview Adaptive Work REST API V2.0",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"README.md"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
},
|
||||
"./metadata": {
|
||||
"types": "./dist/generated/metadata-types.d.ts",
|
||||
"import": "./dist/generated/metadata-types.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "npm run build",
|
||||
"build": "tsc",
|
||||
"scrape": "tsx scripts/scrape-api.ts",
|
||||
"scrape:types": "python3 scripts/scrape-types.py",
|
||||
"generate:types": "python3 scripts/generate-api-types.py",
|
||||
"scrape:metadata": "tsx scripts/scrape-metadata.ts",
|
||||
"generate:metadata": "tsx scripts/scrape-metadata.ts",
|
||||
"example:api-key": "tsx examples/api-key.ts",
|
||||
"example:session": "tsx examples/session-login.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.15.0",
|
||||
"dotenv": "^16.5.0",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.8.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
}
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
# @clack/core
|
||||
|
||||
## 0.4.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 30aa7ed: Adds a new `selectableGroups` boolean to the group multi-select prompt. Using `selectableGroups: false` will disable the ability to select a top-level group, but still allow every child to be selected individually.
|
||||
- 5dfce8a: Fixes an edge case for placeholder values. Previously, when pressing `enter` on an empty prompt, placeholder values would be ignored. Now, placeholder values are treated as the prompt value.
|
||||
- f574297: Fix "TTY initialization failed: uv_tty_init returned EBADF (bad file descriptor)" error happening on Windows for non-tty terminals.
|
||||
|
||||
## 0.4.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 8093f3c: Adds `Error` support to the `validate` function
|
||||
- e5ba09a: Fixes a cursor display bug in terminals that do not support the "hidden" escape sequence. See [Issue #127](https://github.com/bombshell-dev/clack/issues/127).
|
||||
- 8cba8e3: Fixes a rendering bug with cursor positions for `TextPrompt`
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- a83d2f8: Adds a new `updateSettings()` function to support new global keybindings.
|
||||
|
||||
`updateSettings()` accepts an `aliases` object that maps custom keys to an action (`up | down | left | right | space | enter | cancel`).
|
||||
|
||||
```ts
|
||||
import { updateSettings } from "@clack/core";
|
||||
|
||||
// Support custom keybindings
|
||||
updateSettings({
|
||||
aliases: {
|
||||
w: "up",
|
||||
a: "left",
|
||||
s: "down",
|
||||
d: "right",
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> In order to enforce consistent, user-friendly defaults across the ecosystem, `updateSettings` does not support disabling Clack's default keybindings.
|
||||
|
||||
- 801246b: Adds a new `signal` option to support programmatic prompt cancellation with an [abort controller](https://kettanaito.com/blog/dont-sleep-on-abort-controller).
|
||||
|
||||
- a83d2f8: Updates default keybindings to support Vim motion shortcuts and map the `escape` key to cancel (`ctrl+c`).
|
||||
|
||||
| alias | action |
|
||||
| ----- | ------ |
|
||||
| `k` | up |
|
||||
| `l` | right |
|
||||
| `j` | down |
|
||||
| `h` | left |
|
||||
| `esc` | cancel |
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 51e12bc: Improves types for events and interaction states.
|
||||
|
||||
## 0.3.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4845f4f: Fixes a bug which kept the terminal cursor hidden after a prompt is cancelled
|
||||
- d7b2fb9: Adds missing `LICENSE` file. Since the `package.json` file has always included `"license": "MIT"`, please consider this a licensing clarification rather than a licensing change.
|
||||
|
||||
## 0.3.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a04e418: fix(@clack/core): keyboard input not working after await in spinner
|
||||
- 4f6fcf5: feat(@clack/core): allow tab completion for placeholders
|
||||
|
||||
## 0.3.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cd79076: fix: restore raw mode on unblock
|
||||
|
||||
## 0.3.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c96eda5: Enable hard line-wrapping behavior for long words without spaces
|
||||
|
||||
## 0.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 58a1df1: Fix line duplication bug by automatically wrapping prompts to `process.stdout.columns`
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 8a4a12f: Add `GroupMultiSelect` prompt
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 8a4a12f: add `groupMultiselect` prompt
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ec812b6: fix `readline` hang on Windows
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- d74dd05: Adds a `selectKey` prompt type
|
||||
- 54c1bc3: **Breaking Change** `multiselect` has renamed `initialValue` to `initialValues`
|
||||
|
||||
## 0.1.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1251132: Multiselect: return `Value[]` instead of `Option[]`.
|
||||
- 8994382: Add a password prompt to `@clack/prompts`
|
||||
|
||||
## 0.1.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d96071c: Don't mutate `initialValue` in `multiselect`, fix parameter type for `validate()`.
|
||||
|
||||
Credits to @banjo for the bug report and initial PR!
|
||||
|
||||
## 0.1.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 6d9e675: Add support for neovim cursor motion (`hjkl`)
|
||||
|
||||
Thanks [@esau-morais](https://github.com/esau-morais) for the assist!
|
||||
|
||||
## 0.1.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 7fb5375: Adds a new `defaultValue` option to the text prompt, removes automatic usage of the placeholder value.
|
||||
|
||||
## 0.1.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- de1314e: Support `required` option for multi-select
|
||||
|
||||
## 0.1.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ca77da1: Fix multiselect initial value logic
|
||||
- 8aed606: Fix `MaxListenersExceededWarning` by detaching `stdin` listeners on close
|
||||
|
||||
## 0.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a99c458: Support `initialValue` option for text prompt
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Allow isCancel to type guard any unknown value
|
||||
- 7dcad8f: Allow placeholder to be passed to TextPrompt
|
||||
- 2242f13: Fix multiselect returning undefined
|
||||
- b1341d6: Improved placeholder handling
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4be7dbf: Ensure raw mode is unset on submit
|
||||
- b480679: Preserve value if validation fails
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 7015ec9: Create new prompt: multi-select
|
||||
|
||||
## 0.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9d371c3: Fix rendering bug when using y/n to confirm
|
||||
|
||||
## 0.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 441d5b7: fix select return undefined
|
||||
- d20ef2a: Update keywords, URLs
|
||||
- fe13c2f: fix cursor missing after submit
|
||||
|
||||
## 0.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a0cb382: Add `main` entrypoint
|
||||
|
||||
## 0.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix node@16 issue (cannot read "createInterface" of undefined)
|
||||
|
||||
## 0.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a4b5e13: Bug fixes, exposes `block` utility
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix cursor bug
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix error with character check
|
||||
|
||||
## 0.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 491f9e0: update readme
|
||||
|
||||
## 0.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 7372d5c: Fix bug with line deletion
|
||||
|
||||
## 0.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 5605d28: Do not bundle dependencies (take II)
|
||||
|
||||
## 0.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 2ee67cb: don't bundle deps
|
||||
|
||||
## 0.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 306598e: Initial publish, still WIP
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Nate Moore
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
# `@clack/core`
|
||||
|
||||
Clack contains low-level primitives for implementing your own command-line applications.
|
||||
|
||||
Currently, `TextPrompt`, `SelectPrompt`, and `ConfirmPrompt` are exposed as well as the base `Prompt` class.
|
||||
|
||||
Each `Prompt` accepts a `render` function.
|
||||
|
||||
```js
|
||||
import { TextPrompt, isCancel } from '@clack/core';
|
||||
|
||||
const p = new TextPrompt({
|
||||
render() {
|
||||
return `What's your name?\n${this.valueWithCursor}`;
|
||||
},
|
||||
});
|
||||
|
||||
const name = await p.prompt();
|
||||
if (isCancel(name)) {
|
||||
process.exit(0);
|
||||
}
|
||||
```
|
||||
+15
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+211
@@ -0,0 +1,211 @@
|
||||
import { Readable, Writable } from 'node:stream';
|
||||
|
||||
declare const actions: readonly ["up", "down", "left", "right", "space", "enter", "cancel"];
|
||||
type Action = (typeof actions)[number];
|
||||
interface ClackSettings {
|
||||
/**
|
||||
* Set custom global aliases for the default actions.
|
||||
* This will not overwrite existing aliases, it will only add new ones!
|
||||
*
|
||||
* @param aliases - An object that maps aliases to actions
|
||||
* @default { k: 'up', j: 'down', h: 'left', l: 'right', '\x03': 'cancel', 'escape': 'cancel' }
|
||||
*/
|
||||
aliases: Record<string, Action>;
|
||||
}
|
||||
declare function updateSettings(updates: ClackSettings): void;
|
||||
|
||||
/**
|
||||
* The state of the prompt
|
||||
*/
|
||||
type ClackState = 'initial' | 'active' | 'cancel' | 'submit' | 'error';
|
||||
/**
|
||||
* Typed event emitter for clack
|
||||
*/
|
||||
interface ClackEvents {
|
||||
initial: (value?: any) => void;
|
||||
active: (value?: any) => void;
|
||||
cancel: (value?: any) => void;
|
||||
submit: (value?: any) => void;
|
||||
error: (value?: any) => void;
|
||||
cursor: (key?: Action) => void;
|
||||
key: (key?: string) => void;
|
||||
value: (value?: string) => void;
|
||||
confirm: (value?: boolean) => void;
|
||||
finalize: () => void;
|
||||
}
|
||||
|
||||
interface PromptOptions<Self extends Prompt> {
|
||||
render(this: Omit<Self, 'prompt'>): string | undefined;
|
||||
placeholder?: string;
|
||||
initialValue?: any;
|
||||
validate?: ((value: any) => string | Error | undefined) | undefined;
|
||||
input?: Readable;
|
||||
output?: Writable;
|
||||
debug?: boolean;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
declare class Prompt {
|
||||
protected input: Readable;
|
||||
protected output: Writable;
|
||||
private _abortSignal?;
|
||||
private rl;
|
||||
private opts;
|
||||
private _render;
|
||||
private _track;
|
||||
private _prevFrame;
|
||||
private _subscribers;
|
||||
protected _cursor: number;
|
||||
state: ClackState;
|
||||
error: string;
|
||||
value: any;
|
||||
constructor(options: PromptOptions<Prompt>, trackValue?: boolean);
|
||||
/**
|
||||
* Unsubscribe all listeners
|
||||
*/
|
||||
protected unsubscribe(): void;
|
||||
/**
|
||||
* Set a subscriber with opts
|
||||
* @param event - The event name
|
||||
*/
|
||||
private setSubscriber;
|
||||
/**
|
||||
* Subscribe to an event
|
||||
* @param event - The event name
|
||||
* @param cb - The callback
|
||||
*/
|
||||
on<T extends keyof ClackEvents>(event: T, cb: ClackEvents[T]): void;
|
||||
/**
|
||||
* Subscribe to an event once
|
||||
* @param event - The event name
|
||||
* @param cb - The callback
|
||||
*/
|
||||
once<T extends keyof ClackEvents>(event: T, cb: ClackEvents[T]): void;
|
||||
/**
|
||||
* Emit an event with data
|
||||
* @param event - The event name
|
||||
* @param data - The data to pass to the callback
|
||||
*/
|
||||
emit<T extends keyof ClackEvents>(event: T, ...data: Parameters<ClackEvents[T]>): void;
|
||||
prompt(): Promise<string | symbol>;
|
||||
private onKeypress;
|
||||
protected close(): void;
|
||||
private restoreCursor;
|
||||
private render;
|
||||
}
|
||||
|
||||
interface ConfirmOptions extends PromptOptions<ConfirmPrompt> {
|
||||
active: string;
|
||||
inactive: string;
|
||||
initialValue?: boolean;
|
||||
}
|
||||
declare class ConfirmPrompt extends Prompt {
|
||||
get cursor(): 0 | 1;
|
||||
private get _value();
|
||||
constructor(opts: ConfirmOptions);
|
||||
}
|
||||
|
||||
interface GroupMultiSelectOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<GroupMultiSelectPrompt<T>> {
|
||||
options: Record<string, T[]>;
|
||||
initialValues?: T['value'][];
|
||||
required?: boolean;
|
||||
cursorAt?: T['value'];
|
||||
selectableGroups?: boolean;
|
||||
}
|
||||
declare class GroupMultiSelectPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
#private;
|
||||
options: (T & {
|
||||
group: string | boolean;
|
||||
})[];
|
||||
cursor: number;
|
||||
getGroupItems(group: string): T[];
|
||||
isGroupSelected(group: string): boolean;
|
||||
private toggleValue;
|
||||
constructor(opts: GroupMultiSelectOptions<T>);
|
||||
}
|
||||
|
||||
interface MultiSelectOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<MultiSelectPrompt<T>> {
|
||||
options: T[];
|
||||
initialValues?: T['value'][];
|
||||
required?: boolean;
|
||||
cursorAt?: T['value'];
|
||||
}
|
||||
declare class MultiSelectPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
options: T[];
|
||||
cursor: number;
|
||||
private get _value();
|
||||
private toggleAll;
|
||||
private toggleValue;
|
||||
constructor(opts: MultiSelectOptions<T>);
|
||||
}
|
||||
|
||||
interface PasswordOptions extends PromptOptions<PasswordPrompt> {
|
||||
mask?: string;
|
||||
}
|
||||
declare class PasswordPrompt extends Prompt {
|
||||
valueWithCursor: string;
|
||||
private _mask;
|
||||
get cursor(): number;
|
||||
get masked(): any;
|
||||
constructor({ mask, ...opts }: PasswordOptions);
|
||||
}
|
||||
|
||||
interface SelectOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<SelectPrompt<T>> {
|
||||
options: T[];
|
||||
initialValue?: T['value'];
|
||||
}
|
||||
declare class SelectPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
options: T[];
|
||||
cursor: number;
|
||||
private get _value();
|
||||
private changeValue;
|
||||
constructor(opts: SelectOptions<T>);
|
||||
}
|
||||
|
||||
interface SelectKeyOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<SelectKeyPrompt<T>> {
|
||||
options: T[];
|
||||
}
|
||||
declare class SelectKeyPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
options: T[];
|
||||
cursor: number;
|
||||
constructor(opts: SelectKeyOptions<T>);
|
||||
}
|
||||
|
||||
interface TextOptions extends PromptOptions<TextPrompt> {
|
||||
placeholder?: string;
|
||||
defaultValue?: string;
|
||||
}
|
||||
declare class TextPrompt extends Prompt {
|
||||
get valueWithCursor(): any;
|
||||
get cursor(): number;
|
||||
constructor(opts: TextOptions);
|
||||
}
|
||||
|
||||
declare function isCancel(value: unknown): value is symbol;
|
||||
declare function block({ input, output, overwrite, hideCursor, }?: {
|
||||
input?: (NodeJS.ReadStream & {
|
||||
fd: 0;
|
||||
}) | undefined;
|
||||
output?: (NodeJS.WriteStream & {
|
||||
fd: 1;
|
||||
}) | undefined;
|
||||
overwrite?: boolean | undefined;
|
||||
hideCursor?: boolean | undefined;
|
||||
}): () => void;
|
||||
|
||||
export { type ClackSettings, ConfirmPrompt, GroupMultiSelectPrompt, MultiSelectPrompt, PasswordPrompt, Prompt, SelectKeyPrompt, SelectPrompt, type ClackState as State, TextPrompt, block, isCancel, updateSettings };
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
import { Readable, Writable } from 'node:stream';
|
||||
|
||||
declare const actions: readonly ["up", "down", "left", "right", "space", "enter", "cancel"];
|
||||
type Action = (typeof actions)[number];
|
||||
interface ClackSettings {
|
||||
/**
|
||||
* Set custom global aliases for the default actions.
|
||||
* This will not overwrite existing aliases, it will only add new ones!
|
||||
*
|
||||
* @param aliases - An object that maps aliases to actions
|
||||
* @default { k: 'up', j: 'down', h: 'left', l: 'right', '\x03': 'cancel', 'escape': 'cancel' }
|
||||
*/
|
||||
aliases: Record<string, Action>;
|
||||
}
|
||||
declare function updateSettings(updates: ClackSettings): void;
|
||||
|
||||
/**
|
||||
* The state of the prompt
|
||||
*/
|
||||
type ClackState = 'initial' | 'active' | 'cancel' | 'submit' | 'error';
|
||||
/**
|
||||
* Typed event emitter for clack
|
||||
*/
|
||||
interface ClackEvents {
|
||||
initial: (value?: any) => void;
|
||||
active: (value?: any) => void;
|
||||
cancel: (value?: any) => void;
|
||||
submit: (value?: any) => void;
|
||||
error: (value?: any) => void;
|
||||
cursor: (key?: Action) => void;
|
||||
key: (key?: string) => void;
|
||||
value: (value?: string) => void;
|
||||
confirm: (value?: boolean) => void;
|
||||
finalize: () => void;
|
||||
}
|
||||
|
||||
interface PromptOptions<Self extends Prompt> {
|
||||
render(this: Omit<Self, 'prompt'>): string | undefined;
|
||||
placeholder?: string;
|
||||
initialValue?: any;
|
||||
validate?: ((value: any) => string | Error | undefined) | undefined;
|
||||
input?: Readable;
|
||||
output?: Writable;
|
||||
debug?: boolean;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
declare class Prompt {
|
||||
protected input: Readable;
|
||||
protected output: Writable;
|
||||
private _abortSignal?;
|
||||
private rl;
|
||||
private opts;
|
||||
private _render;
|
||||
private _track;
|
||||
private _prevFrame;
|
||||
private _subscribers;
|
||||
protected _cursor: number;
|
||||
state: ClackState;
|
||||
error: string;
|
||||
value: any;
|
||||
constructor(options: PromptOptions<Prompt>, trackValue?: boolean);
|
||||
/**
|
||||
* Unsubscribe all listeners
|
||||
*/
|
||||
protected unsubscribe(): void;
|
||||
/**
|
||||
* Set a subscriber with opts
|
||||
* @param event - The event name
|
||||
*/
|
||||
private setSubscriber;
|
||||
/**
|
||||
* Subscribe to an event
|
||||
* @param event - The event name
|
||||
* @param cb - The callback
|
||||
*/
|
||||
on<T extends keyof ClackEvents>(event: T, cb: ClackEvents[T]): void;
|
||||
/**
|
||||
* Subscribe to an event once
|
||||
* @param event - The event name
|
||||
* @param cb - The callback
|
||||
*/
|
||||
once<T extends keyof ClackEvents>(event: T, cb: ClackEvents[T]): void;
|
||||
/**
|
||||
* Emit an event with data
|
||||
* @param event - The event name
|
||||
* @param data - The data to pass to the callback
|
||||
*/
|
||||
emit<T extends keyof ClackEvents>(event: T, ...data: Parameters<ClackEvents[T]>): void;
|
||||
prompt(): Promise<string | symbol>;
|
||||
private onKeypress;
|
||||
protected close(): void;
|
||||
private restoreCursor;
|
||||
private render;
|
||||
}
|
||||
|
||||
interface ConfirmOptions extends PromptOptions<ConfirmPrompt> {
|
||||
active: string;
|
||||
inactive: string;
|
||||
initialValue?: boolean;
|
||||
}
|
||||
declare class ConfirmPrompt extends Prompt {
|
||||
get cursor(): 0 | 1;
|
||||
private get _value();
|
||||
constructor(opts: ConfirmOptions);
|
||||
}
|
||||
|
||||
interface GroupMultiSelectOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<GroupMultiSelectPrompt<T>> {
|
||||
options: Record<string, T[]>;
|
||||
initialValues?: T['value'][];
|
||||
required?: boolean;
|
||||
cursorAt?: T['value'];
|
||||
selectableGroups?: boolean;
|
||||
}
|
||||
declare class GroupMultiSelectPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
#private;
|
||||
options: (T & {
|
||||
group: string | boolean;
|
||||
})[];
|
||||
cursor: number;
|
||||
getGroupItems(group: string): T[];
|
||||
isGroupSelected(group: string): boolean;
|
||||
private toggleValue;
|
||||
constructor(opts: GroupMultiSelectOptions<T>);
|
||||
}
|
||||
|
||||
interface MultiSelectOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<MultiSelectPrompt<T>> {
|
||||
options: T[];
|
||||
initialValues?: T['value'][];
|
||||
required?: boolean;
|
||||
cursorAt?: T['value'];
|
||||
}
|
||||
declare class MultiSelectPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
options: T[];
|
||||
cursor: number;
|
||||
private get _value();
|
||||
private toggleAll;
|
||||
private toggleValue;
|
||||
constructor(opts: MultiSelectOptions<T>);
|
||||
}
|
||||
|
||||
interface PasswordOptions extends PromptOptions<PasswordPrompt> {
|
||||
mask?: string;
|
||||
}
|
||||
declare class PasswordPrompt extends Prompt {
|
||||
valueWithCursor: string;
|
||||
private _mask;
|
||||
get cursor(): number;
|
||||
get masked(): any;
|
||||
constructor({ mask, ...opts }: PasswordOptions);
|
||||
}
|
||||
|
||||
interface SelectOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<SelectPrompt<T>> {
|
||||
options: T[];
|
||||
initialValue?: T['value'];
|
||||
}
|
||||
declare class SelectPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
options: T[];
|
||||
cursor: number;
|
||||
private get _value();
|
||||
private changeValue;
|
||||
constructor(opts: SelectOptions<T>);
|
||||
}
|
||||
|
||||
interface SelectKeyOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<SelectKeyPrompt<T>> {
|
||||
options: T[];
|
||||
}
|
||||
declare class SelectKeyPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
options: T[];
|
||||
cursor: number;
|
||||
constructor(opts: SelectKeyOptions<T>);
|
||||
}
|
||||
|
||||
interface TextOptions extends PromptOptions<TextPrompt> {
|
||||
placeholder?: string;
|
||||
defaultValue?: string;
|
||||
}
|
||||
declare class TextPrompt extends Prompt {
|
||||
get valueWithCursor(): any;
|
||||
get cursor(): number;
|
||||
constructor(opts: TextOptions);
|
||||
}
|
||||
|
||||
declare function isCancel(value: unknown): value is symbol;
|
||||
declare function block({ input, output, overwrite, hideCursor, }?: {
|
||||
input?: (NodeJS.ReadStream & {
|
||||
fd: 0;
|
||||
}) | undefined;
|
||||
output?: (NodeJS.WriteStream & {
|
||||
fd: 1;
|
||||
}) | undefined;
|
||||
overwrite?: boolean | undefined;
|
||||
hideCursor?: boolean | undefined;
|
||||
}): () => void;
|
||||
|
||||
export { type ClackSettings, ConfirmPrompt, GroupMultiSelectPrompt, MultiSelectPrompt, PasswordPrompt, Prompt, SelectKeyPrompt, SelectPrompt, type ClackState as State, TextPrompt, block, isCancel, updateSettings };
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
import { Readable, Writable } from 'node:stream';
|
||||
|
||||
declare const actions: readonly ["up", "down", "left", "right", "space", "enter", "cancel"];
|
||||
type Action = (typeof actions)[number];
|
||||
interface ClackSettings {
|
||||
/**
|
||||
* Set custom global aliases for the default actions.
|
||||
* This will not overwrite existing aliases, it will only add new ones!
|
||||
*
|
||||
* @param aliases - An object that maps aliases to actions
|
||||
* @default { k: 'up', j: 'down', h: 'left', l: 'right', '\x03': 'cancel', 'escape': 'cancel' }
|
||||
*/
|
||||
aliases: Record<string, Action>;
|
||||
}
|
||||
declare function updateSettings(updates: ClackSettings): void;
|
||||
|
||||
/**
|
||||
* The state of the prompt
|
||||
*/
|
||||
type ClackState = 'initial' | 'active' | 'cancel' | 'submit' | 'error';
|
||||
/**
|
||||
* Typed event emitter for clack
|
||||
*/
|
||||
interface ClackEvents {
|
||||
initial: (value?: any) => void;
|
||||
active: (value?: any) => void;
|
||||
cancel: (value?: any) => void;
|
||||
submit: (value?: any) => void;
|
||||
error: (value?: any) => void;
|
||||
cursor: (key?: Action) => void;
|
||||
key: (key?: string) => void;
|
||||
value: (value?: string) => void;
|
||||
confirm: (value?: boolean) => void;
|
||||
finalize: () => void;
|
||||
}
|
||||
|
||||
interface PromptOptions<Self extends Prompt> {
|
||||
render(this: Omit<Self, 'prompt'>): string | undefined;
|
||||
placeholder?: string;
|
||||
initialValue?: any;
|
||||
validate?: ((value: any) => string | Error | undefined) | undefined;
|
||||
input?: Readable;
|
||||
output?: Writable;
|
||||
debug?: boolean;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
declare class Prompt {
|
||||
protected input: Readable;
|
||||
protected output: Writable;
|
||||
private _abortSignal?;
|
||||
private rl;
|
||||
private opts;
|
||||
private _render;
|
||||
private _track;
|
||||
private _prevFrame;
|
||||
private _subscribers;
|
||||
protected _cursor: number;
|
||||
state: ClackState;
|
||||
error: string;
|
||||
value: any;
|
||||
constructor(options: PromptOptions<Prompt>, trackValue?: boolean);
|
||||
/**
|
||||
* Unsubscribe all listeners
|
||||
*/
|
||||
protected unsubscribe(): void;
|
||||
/**
|
||||
* Set a subscriber with opts
|
||||
* @param event - The event name
|
||||
*/
|
||||
private setSubscriber;
|
||||
/**
|
||||
* Subscribe to an event
|
||||
* @param event - The event name
|
||||
* @param cb - The callback
|
||||
*/
|
||||
on<T extends keyof ClackEvents>(event: T, cb: ClackEvents[T]): void;
|
||||
/**
|
||||
* Subscribe to an event once
|
||||
* @param event - The event name
|
||||
* @param cb - The callback
|
||||
*/
|
||||
once<T extends keyof ClackEvents>(event: T, cb: ClackEvents[T]): void;
|
||||
/**
|
||||
* Emit an event with data
|
||||
* @param event - The event name
|
||||
* @param data - The data to pass to the callback
|
||||
*/
|
||||
emit<T extends keyof ClackEvents>(event: T, ...data: Parameters<ClackEvents[T]>): void;
|
||||
prompt(): Promise<string | symbol>;
|
||||
private onKeypress;
|
||||
protected close(): void;
|
||||
private restoreCursor;
|
||||
private render;
|
||||
}
|
||||
|
||||
interface ConfirmOptions extends PromptOptions<ConfirmPrompt> {
|
||||
active: string;
|
||||
inactive: string;
|
||||
initialValue?: boolean;
|
||||
}
|
||||
declare class ConfirmPrompt extends Prompt {
|
||||
get cursor(): 0 | 1;
|
||||
private get _value();
|
||||
constructor(opts: ConfirmOptions);
|
||||
}
|
||||
|
||||
interface GroupMultiSelectOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<GroupMultiSelectPrompt<T>> {
|
||||
options: Record<string, T[]>;
|
||||
initialValues?: T['value'][];
|
||||
required?: boolean;
|
||||
cursorAt?: T['value'];
|
||||
selectableGroups?: boolean;
|
||||
}
|
||||
declare class GroupMultiSelectPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
#private;
|
||||
options: (T & {
|
||||
group: string | boolean;
|
||||
})[];
|
||||
cursor: number;
|
||||
getGroupItems(group: string): T[];
|
||||
isGroupSelected(group: string): boolean;
|
||||
private toggleValue;
|
||||
constructor(opts: GroupMultiSelectOptions<T>);
|
||||
}
|
||||
|
||||
interface MultiSelectOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<MultiSelectPrompt<T>> {
|
||||
options: T[];
|
||||
initialValues?: T['value'][];
|
||||
required?: boolean;
|
||||
cursorAt?: T['value'];
|
||||
}
|
||||
declare class MultiSelectPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
options: T[];
|
||||
cursor: number;
|
||||
private get _value();
|
||||
private toggleAll;
|
||||
private toggleValue;
|
||||
constructor(opts: MultiSelectOptions<T>);
|
||||
}
|
||||
|
||||
interface PasswordOptions extends PromptOptions<PasswordPrompt> {
|
||||
mask?: string;
|
||||
}
|
||||
declare class PasswordPrompt extends Prompt {
|
||||
valueWithCursor: string;
|
||||
private _mask;
|
||||
get cursor(): number;
|
||||
get masked(): any;
|
||||
constructor({ mask, ...opts }: PasswordOptions);
|
||||
}
|
||||
|
||||
interface SelectOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<SelectPrompt<T>> {
|
||||
options: T[];
|
||||
initialValue?: T['value'];
|
||||
}
|
||||
declare class SelectPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
options: T[];
|
||||
cursor: number;
|
||||
private get _value();
|
||||
private changeValue;
|
||||
constructor(opts: SelectOptions<T>);
|
||||
}
|
||||
|
||||
interface SelectKeyOptions<T extends {
|
||||
value: any;
|
||||
}> extends PromptOptions<SelectKeyPrompt<T>> {
|
||||
options: T[];
|
||||
}
|
||||
declare class SelectKeyPrompt<T extends {
|
||||
value: any;
|
||||
}> extends Prompt {
|
||||
options: T[];
|
||||
cursor: number;
|
||||
constructor(opts: SelectKeyOptions<T>);
|
||||
}
|
||||
|
||||
interface TextOptions extends PromptOptions<TextPrompt> {
|
||||
placeholder?: string;
|
||||
defaultValue?: string;
|
||||
}
|
||||
declare class TextPrompt extends Prompt {
|
||||
get valueWithCursor(): any;
|
||||
get cursor(): number;
|
||||
constructor(opts: TextOptions);
|
||||
}
|
||||
|
||||
declare function isCancel(value: unknown): value is symbol;
|
||||
declare function block({ input, output, overwrite, hideCursor, }?: {
|
||||
input?: (NodeJS.ReadStream & {
|
||||
fd: 0;
|
||||
}) | undefined;
|
||||
output?: (NodeJS.WriteStream & {
|
||||
fd: 1;
|
||||
}) | undefined;
|
||||
overwrite?: boolean | undefined;
|
||||
hideCursor?: boolean | undefined;
|
||||
}): () => void;
|
||||
|
||||
export { type ClackSettings, ConfirmPrompt, GroupMultiSelectPrompt, MultiSelectPrompt, PasswordPrompt, Prompt, SelectKeyPrompt, SelectPrompt, type ClackState as State, TextPrompt, block, isCancel, updateSettings };
|
||||
+15
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+62
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "@clack/core",
|
||||
"version": "0.4.2",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"types": "./dist/index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/bombshell-dev/clack.git",
|
||||
"directory": "packages/core"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/bombshell-dev/clack/issues"
|
||||
},
|
||||
"homepage": "https://github.com/bombshell-dev/clack/tree/main/packages/core#readme",
|
||||
"files": [
|
||||
"dist",
|
||||
"CHANGELOG.md"
|
||||
],
|
||||
"keywords": [
|
||||
"ask",
|
||||
"clack",
|
||||
"cli",
|
||||
"command-line",
|
||||
"command",
|
||||
"input",
|
||||
"interact",
|
||||
"interface",
|
||||
"menu",
|
||||
"prompt",
|
||||
"prompts",
|
||||
"stdin",
|
||||
"ui"
|
||||
],
|
||||
"author": {
|
||||
"name": "Nate Moore",
|
||||
"email": "nate@natemoo.re",
|
||||
"url": "https://twitter.com/n_moore"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"picocolors": "^1.0.0",
|
||||
"sisteransi": "^1.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vitest": "^1.6.0",
|
||||
"wrap-ansi": "^8.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"test": "vitest run"
|
||||
}
|
||||
}
|
||||
+412
@@ -0,0 +1,412 @@
|
||||
# @clack/prompts
|
||||
|
||||
## 0.10.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 11a5dc1: Fixes multiselect only shows hints on the first item in the options list. Now correctly shows hints for all selected options with hint property.
|
||||
- 30aa7ed: Adds a new `selectableGroups` boolean to the group multi-select prompt. Using `selectableGroups: false` will disable the ability to select a top-level group, but still allow every child to be selected individually.
|
||||
- Updated dependencies [30aa7ed]
|
||||
- Updated dependencies [5dfce8a]
|
||||
- Updated dependencies [f574297]
|
||||
- @clack/core@0.4.2
|
||||
|
||||
## 0.10.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 613179d: Adds a new `indicator` option to `spinner`, which supports the original `"dots"` loading animation or a new `"timer"` loading animation.
|
||||
|
||||
```ts
|
||||
import * as p from "@clack/prompts";
|
||||
|
||||
const spin = p.spinner({ indicator: "timer" });
|
||||
spin.start("Loading");
|
||||
await sleep(3000);
|
||||
spin.stop("Loaded");
|
||||
```
|
||||
|
||||
- a38b2bc: Adds `stream` API which provides the same methods as `log`, but for iterable (even async) message streams. This is particularly useful for AI responses which are dynamically generated by LLMs.
|
||||
|
||||
```ts
|
||||
import * as p from "@clack/prompts";
|
||||
|
||||
await p.stream.step(
|
||||
(async function* () {
|
||||
yield* generateLLMResponse(question);
|
||||
})()
|
||||
);
|
||||
```
|
||||
|
||||
## 0.9.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 8093f3c: Adds `Error` support to the `validate` function
|
||||
- 98925e3: Exports the `Option` type and improves JSDocannotations
|
||||
- 1904e57: Replace custom utility for stripping ANSI control sequences with Node's built-in [`stripVTControlCharacters`](https://nodejs.org/docs/latest/api/util.html#utilstripvtcontrolcharactersstr) utility.
|
||||
- Updated dependencies [8093f3c]
|
||||
- Updated dependencies [e5ba09a]
|
||||
- Updated dependencies [8cba8e3]
|
||||
- @clack/core@0.4.1
|
||||
|
||||
## 0.9.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- a83d2f8: Adds a new `updateSettings()` function to support new global keybindings.
|
||||
|
||||
`updateSettings()` accepts an `aliases` object that maps custom keys to an action (`up | down | left | right | space | enter | cancel`).
|
||||
|
||||
```ts
|
||||
import { updateSettings } from "@clack/prompts";
|
||||
|
||||
// Support custom keybindings
|
||||
updateSettings({
|
||||
aliases: {
|
||||
w: "up",
|
||||
a: "left",
|
||||
s: "down",
|
||||
d: "right",
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> In order to enforce consistent, user-friendly defaults across the ecosystem, `updateSettings` does not support disabling Clack's default keybindings.
|
||||
|
||||
- 801246b: Adds a new `signal` option to support programmatic prompt cancellation with an [abort controller](https://kettanaito.com/blog/dont-sleep-on-abort-controller).
|
||||
|
||||
One example use case is automatically cancelling a prompt after a timeout.
|
||||
|
||||
```ts
|
||||
const shouldContinue = await confirm({
|
||||
message: "This message will self destruct in 5 seconds",
|
||||
signal: AbortSignal.timeout(5000),
|
||||
});
|
||||
```
|
||||
|
||||
Another use case is racing a long running task with a manual prompt.
|
||||
|
||||
```ts
|
||||
const abortController = new AbortController();
|
||||
|
||||
const projectType = await Promise.race([
|
||||
detectProjectType({
|
||||
signal: abortController.signal,
|
||||
}),
|
||||
select({
|
||||
message: "Pick a project type.",
|
||||
options: [
|
||||
{ value: "ts", label: "TypeScript" },
|
||||
{ value: "js", label: "JavaScript" },
|
||||
{ value: "coffee", label: "CoffeeScript", hint: "oh no" },
|
||||
],
|
||||
signal: abortController.signal,
|
||||
}),
|
||||
]);
|
||||
|
||||
abortController.abort();
|
||||
```
|
||||
|
||||
- a83d2f8: Updates default keybindings to support Vim motion shortcuts and map the `escape` key to cancel (`ctrl+c`).
|
||||
|
||||
| alias | action |
|
||||
| ----- | ------ |
|
||||
| `k` | up |
|
||||
| `l` | right |
|
||||
| `j` | down |
|
||||
| `h` | left |
|
||||
| `esc` | cancel |
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- f9f139d: Adapts `spinner` output for static CI environments
|
||||
- Updated dependencies [a83d2f8]
|
||||
- Updated dependencies [801246b]
|
||||
- Updated dependencies [a83d2f8]
|
||||
- Updated dependencies [51e12bc]
|
||||
- @clack/core@0.4.0
|
||||
|
||||
## 0.8.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4845f4f]
|
||||
- Updated dependencies [d7b2fb9]
|
||||
- @clack/core@0.3.5
|
||||
|
||||
## 0.8.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 360afeb: feat: adaptative max items
|
||||
|
||||
## 0.8.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 9acccde: Add tasks function for executing tasks in spinners
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b5c6b9b: Feat multiselect maxItems option
|
||||
- 50ed94a: fix: clear `spinner` hooks on `spinner.stop`
|
||||
- Updated dependencies [a04e418]
|
||||
- Updated dependencies [4f6fcf5]
|
||||
- @clack/core@0.3.4
|
||||
|
||||
## 0.7.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- b27a701: add maxItems option to select prompt
|
||||
- 89371be: added a new method called `spinner.message(msg: string)`
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 52183c4: Fix `spinner` conflict with terminal on error between `spinner.start()` and `spinner.stop()`
|
||||
- ab51d29: Fixes cases where the note title length was miscalculated due to ansi characters
|
||||
- Updated dependencies [cd79076]
|
||||
- @clack/core@0.3.3
|
||||
|
||||
## 0.6.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c96eda5: Enable hard line-wrapping behavior for long words without spaces
|
||||
- Updated dependencies [c96eda5]
|
||||
- @clack/core@0.3.2
|
||||
|
||||
## 0.6.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 58a1df1: Fix line duplication bug by automatically wrapping prompts to `process.stdout.columns`
|
||||
- Updated dependencies [58a1df1]
|
||||
- @clack/core@0.3.1
|
||||
|
||||
## 0.6.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ca08fb6: Support complex value types for `select`, `multiselect` and `groupMultiselect`.
|
||||
|
||||
## 0.6.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 8a4a12f: add `groupMultiselect` prompt
|
||||
- 165a1b3: Add `log` APIs. Supports `log.info`, `log.success`, `log.warn`, and `log.error`. For low-level control, `log.message` is also exposed.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [8a4a12f]
|
||||
- Updated dependencies [8a4a12f]
|
||||
- @clack/core@0.3.0
|
||||
|
||||
## 0.5.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cc11917: Update default `password` mask
|
||||
- Updated dependencies [ec812b6]
|
||||
- @clack/core@0.2.1
|
||||
|
||||
## 0.5.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- d74dd05: Adds a `selectKey` prompt type
|
||||
- 54c1bc3: **Breaking Change** `multiselect` has renamed `initialValue` to `initialValues`
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d74dd05]
|
||||
- Updated dependencies [54c1bc3]
|
||||
- @clack/core@0.2.0
|
||||
|
||||
## 0.4.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1251132: Multiselect: return `Value[]` instead of `Option[]`.
|
||||
- 8994382: Add a password prompt to `@clack/prompts`
|
||||
- Updated dependencies [1251132]
|
||||
- Updated dependencies [8994382]
|
||||
- @clack/core@0.1.9
|
||||
|
||||
## 0.4.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d96071c: Don't mutate `initialValue` in `multiselect`, fix parameter type for `validate()`.
|
||||
|
||||
Credits to @banjo for the bug report and initial PR!
|
||||
|
||||
- Updated dependencies [d96071c]
|
||||
- @clack/core@0.1.8
|
||||
|
||||
## 0.4.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 83d890e: Fix text cancel display bug
|
||||
|
||||
## 0.4.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update README
|
||||
|
||||
## 0.4.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 7fb5375: Adds a new `defaultValue` option to the text prompt, removes automatic usage of the placeholder value.
|
||||
- Updated dependencies [7fb5375]
|
||||
- @clack/core@0.1.6
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 61b88b6: Add `group` construct to group many prompts together
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- de1314e: Support `required` option for multi-select
|
||||
- Updated dependencies [de1314e]
|
||||
- @clack/core@0.1.5
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 493c592: Improve types for select/multiselect prompts. Numbers and booleans are now supported as the `value` option.
|
||||
- 15558e3: Improved Windows/non-unicode support
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ca77da1: Fix multiselect initial value logic
|
||||
- Updated dependencies [ca77da1]
|
||||
- Updated dependencies [8aed606]
|
||||
- @clack/core@0.1.4
|
||||
|
||||
## 0.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 94b24d9: Fix CJS `ansi-regex` interop
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a99c458: Support `initialValue` option for text prompt
|
||||
- Updated dependencies [a99c458]
|
||||
- @clack/core@0.1.3
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- Improved type safety
|
||||
- b1341d6: Updated styles, new note component
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [7dcad8f]
|
||||
- Updated dependencies [2242f13]
|
||||
- Updated dependencies [b1341d6]
|
||||
- @clack/core@0.1.2
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fa09bf5: Use circle for radio, square for checkbox
|
||||
- Updated dependencies [4be7dbf]
|
||||
- Updated dependencies [b480679]
|
||||
- @clack/core@0.1.1
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 7015ec9: Create new prompt: multi-select
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [7015ec9]
|
||||
- @clack/core@0.1.0
|
||||
|
||||
## 0.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- e0b49e5: Update spinner so it actually spins
|
||||
|
||||
## 0.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update README
|
||||
|
||||
## 0.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [9d371c3]
|
||||
- @clack/core@0.0.12
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update README
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d20ef2a: Update keywords, URLs
|
||||
- Updated dependencies [441d5b7]
|
||||
- Updated dependencies [d20ef2a]
|
||||
- Updated dependencies [fe13c2f]
|
||||
- @clack/core@0.0.11
|
||||
|
||||
## 0.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Update README
|
||||
|
||||
## 0.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 80404ab: Update README
|
||||
|
||||
## 0.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a0cb382: Add `main` entrypoint
|
||||
- Updated dependencies [a0cb382]
|
||||
- @clack/core@0.0.10
|
||||
|
||||
## 0.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @clack/core@0.0.9
|
||||
|
||||
## 0.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a4b5e13: Initial release
|
||||
- Updated dependencies [a4b5e13]
|
||||
- @clack/core@0.0.8
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Nate Moore
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
# `@clack/prompts`
|
||||
|
||||
Effortlessly build beautiful command-line apps 🪄 [Try the demo](https://stackblitz.com/edit/clack-prompts?file=index.js)
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
`@clack/prompts` is an opinionated, pre-styled wrapper around [`@clack/core`](https://www.npmjs.com/package/@clack/core).
|
||||
|
||||
- 🤏 80% smaller than other options
|
||||
- 💎 Beautiful, minimal UI
|
||||
- ✅ Simple API
|
||||
- 🧱 Comes with `text`, `confirm`, `select`, `multiselect`, and `spinner` components
|
||||
|
||||
## Basics
|
||||
|
||||
### Setup
|
||||
|
||||
The `intro` and `outro` functions will print a message to begin or end a prompt session, respectively.
|
||||
|
||||
```js
|
||||
import { intro, outro } from '@clack/prompts';
|
||||
|
||||
intro(`create-my-app`);
|
||||
// Do stuff
|
||||
outro(`You're all set!`);
|
||||
```
|
||||
|
||||
### Cancellation
|
||||
|
||||
The `isCancel` function is a guard that detects when a user cancels a question with `CTRL + C`. You should handle this situation for each prompt, optionally providing a nice cancellation message with the `cancel` utility.
|
||||
|
||||
```js
|
||||
import { isCancel, cancel, text } from '@clack/prompts';
|
||||
|
||||
const value = await text({
|
||||
message: 'What is the meaning of life?',
|
||||
});
|
||||
|
||||
if (isCancel(value)) {
|
||||
cancel('Operation cancelled.');
|
||||
process.exit(0);
|
||||
}
|
||||
```
|
||||
|
||||
## Components
|
||||
|
||||
### Text
|
||||
|
||||
The text component accepts a single line of text.
|
||||
|
||||
```js
|
||||
import { text } from '@clack/prompts';
|
||||
|
||||
const meaning = await text({
|
||||
message: 'What is the meaning of life?',
|
||||
placeholder: 'Not sure',
|
||||
initialValue: '42',
|
||||
validate(value) {
|
||||
if (value.length === 0) return `Value is required!`;
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Confirm
|
||||
|
||||
The confirm component accepts a yes or no answer. The result is a boolean value of `true` or `false`.
|
||||
|
||||
```js
|
||||
import { confirm } from '@clack/prompts';
|
||||
|
||||
const shouldContinue = await confirm({
|
||||
message: 'Do you want to continue?',
|
||||
});
|
||||
```
|
||||
|
||||
### Select
|
||||
|
||||
The select component allows a user to choose one value from a list of options. The result is the `value` prop of a given option.
|
||||
|
||||
```js
|
||||
import { select } from '@clack/prompts';
|
||||
|
||||
const projectType = await select({
|
||||
message: 'Pick a project type.',
|
||||
options: [
|
||||
{ value: 'ts', label: 'TypeScript' },
|
||||
{ value: 'js', label: 'JavaScript' },
|
||||
{ value: 'coffee', label: 'CoffeeScript', hint: 'oh no' },
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Multi-Select
|
||||
|
||||
The `multiselect` component allows a user to choose many values from a list of options. The result is an array with all selected `value` props.
|
||||
|
||||
```js
|
||||
import { multiselect } from '@clack/prompts';
|
||||
|
||||
const additionalTools = await multiselect({
|
||||
message: 'Select additional tools.',
|
||||
options: [
|
||||
{ value: 'eslint', label: 'ESLint', hint: 'recommended' },
|
||||
{ value: 'prettier', label: 'Prettier' },
|
||||
{ value: 'gh-action', label: 'GitHub Action' },
|
||||
],
|
||||
required: false,
|
||||
});
|
||||
```
|
||||
|
||||
### Spinner
|
||||
|
||||
The spinner component surfaces a pending action, such as a long-running download or dependency installation.
|
||||
|
||||
```js
|
||||
import { spinner } from '@clack/prompts';
|
||||
|
||||
const s = spinner();
|
||||
s.start('Installing via npm');
|
||||
// Do installation here
|
||||
s.stop('Installed via npm');
|
||||
```
|
||||
|
||||
## Utilities
|
||||
|
||||
### Grouping
|
||||
|
||||
Grouping prompts together is a great way to keep your code organized. This accepts a JSON object with a name that can be used to reference the group later. The second argument is an optional but has a `onCancel` callback that will be called if the user cancels one of the prompts in the group.
|
||||
|
||||
```js
|
||||
import * as p from '@clack/prompts';
|
||||
|
||||
const group = await p.group(
|
||||
{
|
||||
name: () => p.text({ message: 'What is your name?' }),
|
||||
age: () => p.text({ message: 'What is your age?' }),
|
||||
color: ({ results }) =>
|
||||
p.multiselect({
|
||||
message: `What is your favorite color ${results.name}?`,
|
||||
options: [
|
||||
{ value: 'red', label: 'Red' },
|
||||
{ value: 'green', label: 'Green' },
|
||||
{ value: 'blue', label: 'Blue' },
|
||||
],
|
||||
}),
|
||||
},
|
||||
{
|
||||
// On Cancel callback that wraps the group
|
||||
// So if the user cancels one of the prompts in the group this function will be called
|
||||
onCancel: ({ results }) => {
|
||||
p.cancel('Operation cancelled.');
|
||||
process.exit(0);
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
console.log(group.name, group.age, group.color);
|
||||
```
|
||||
|
||||
### Tasks
|
||||
|
||||
Execute multiple tasks in spinners.
|
||||
|
||||
```js
|
||||
await p.tasks([
|
||||
{
|
||||
title: 'Installing via npm',
|
||||
task: async (message) => {
|
||||
// Do installation here
|
||||
return 'Installed via npm';
|
||||
},
|
||||
},
|
||||
]);
|
||||
```
|
||||
|
||||
### Logs
|
||||
|
||||
```js
|
||||
import { log } from '@clack/prompts';
|
||||
|
||||
log.info('Info!');
|
||||
log.success('Success!');
|
||||
log.step('Step!');
|
||||
log.warn('Warn!');
|
||||
log.error('Error!');
|
||||
log.message('Hello, World', { symbol: color.cyan('~') });
|
||||
```
|
||||
|
||||
|
||||
### Stream
|
||||
|
||||
When interacting with dynamic LLMs or other streaming message providers, use the `stream` APIs to log messages from an iterable, even an async one.
|
||||
|
||||
```js
|
||||
import { stream } from '@clack/prompts';
|
||||
|
||||
stream.info((function *() { yield 'Info!'; })());
|
||||
stream.success((function *() { yield 'Success!'; })());
|
||||
stream.step((function *() { yield 'Step!'; })());
|
||||
stream.warn((function *() { yield 'Warn!'; })());
|
||||
stream.error((function *() { yield 'Error!'; })());
|
||||
stream.message((function *() { yield 'Hello'; yield ", World" })(), { symbol: color.cyan('~') });
|
||||
```
|
||||
|
||||

|
||||
+87
@@ -0,0 +1,87 @@
|
||||
"use strict";const node_util=require("node:util"),core=require("@clack/core"),process$1=require("node:process"),e=require("picocolors"),sisteransi=require("sisteransi");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const process__default=_interopDefaultCompat(process$1),e__default=_interopDefaultCompat(e);function isUnicodeSupported(){return process__default.platform!=="win32"?process__default.env.TERM!=="linux":!!process__default.env.CI||!!process__default.env.WT_SESSION||!!process__default.env.TERMINUS_SUBLIME||process__default.env.ConEmuTask==="{cmd::Cmder}"||process__default.env.TERM_PROGRAM==="Terminus-Sublime"||process__default.env.TERM_PROGRAM==="vscode"||process__default.env.TERM==="xterm-256color"||process__default.env.TERM==="alacritty"||process__default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const P=isUnicodeSupported(),u=(t,o)=>P?t:o,ie=u("\u25C6","*"),G=u("\u25A0","x"),L=u("\u25B2","x"),S=u("\u25C7","o"),ae=u("\u250C","T"),a=u("\u2502","|"),g=u("\u2514","\u2014"),_=u("\u25CF",">"),A=u("\u25CB"," "),C=u("\u25FB","[\u2022]"),V=u("\u25FC","[+]"),N=u("\u25FB","[ ]"),oe=u("\u25AA","\u2022"),j=u("\u2500","-"),le=u("\u256E","+"),ce=u("\u251C","+"),ue=u("\u256F","+"),B=u("\u25CF","\u2022"),W=u("\u25C6","*"),H=u("\u25B2","!"),q=u("\u25A0","x"),b=t=>{switch(t){case"initial":case"active":return e__default.cyan(ie);case"cancel":return e__default.red(G);case"error":return e__default.yellow(L);case"submit":return e__default.green(S)}},E=t=>{const{cursor:o,options:s,style:i}=t,r=t.maxItems??Number.POSITIVE_INFINITY,c=Math.max(process.stdout.rows-4,0),n=Math.min(c,Math.max(r,5));let l=0;o>=l+n-3?l=Math.max(Math.min(o-n+3,s.length-n),0):o<l+2&&(l=Math.max(o-2,0));const $=n<s.length&&l>0,h=n<s.length&&l+n<s.length;return s.slice(l,l+n).map((m,y,w)=>{const x=y===0&&$,M=y===w.length-1&&h;return x||M?e__default.dim("..."):i(m,y+l===o)})},text=t=>new core.TextPrompt({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){const o=`${e__default.gray(a)}
|
||||
${b(this.state)} ${t.message}
|
||||
`,s=t.placeholder?e__default.inverse(t.placeholder[0])+e__default.dim(t.placeholder.slice(1)):e__default.inverse(e__default.hidden("_")),i=this.value?this.valueWithCursor:s;switch(this.state){case"error":return`${o.trim()}
|
||||
${e__default.yellow(a)} ${i}
|
||||
${e__default.yellow(g)} ${e__default.yellow(this.error)}
|
||||
`;case"submit":return`${o}${e__default.gray(a)} ${e__default.dim(this.value||t.placeholder)}`;case"cancel":return`${o}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(this.value??""))}${this.value?.trim()?`
|
||||
${e__default.gray(a)}`:""}`;default:return`${o}${e__default.cyan(a)} ${i}
|
||||
${e__default.cyan(g)}
|
||||
`}}}).prompt(),password=t=>new core.PasswordPrompt({validate:t.validate,mask:t.mask??oe,render(){const o=`${e__default.gray(a)}
|
||||
${b(this.state)} ${t.message}
|
||||
`,s=this.valueWithCursor,i=this.masked;switch(this.state){case"error":return`${o.trim()}
|
||||
${e__default.yellow(a)} ${i}
|
||||
${e__default.yellow(g)} ${e__default.yellow(this.error)}
|
||||
`;case"submit":return`${o}${e__default.gray(a)} ${e__default.dim(i)}`;case"cancel":return`${o}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(i??""))}${i?`
|
||||
${e__default.gray(a)}`:""}`;default:return`${o}${e__default.cyan(a)} ${s}
|
||||
${e__default.cyan(g)}
|
||||
`}}}).prompt(),confirm=t=>{const o=t.active??"Yes",s=t.inactive??"No";return new core.ConfirmPrompt({active:o,inactive:s,initialValue:t.initialValue??!0,render(){const i=`${e__default.gray(a)}
|
||||
${b(this.state)} ${t.message}
|
||||
`,r=this.value?o:s;switch(this.state){case"submit":return`${i}${e__default.gray(a)} ${e__default.dim(r)}`;case"cancel":return`${i}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(r))}
|
||||
${e__default.gray(a)}`;default:return`${i}${e__default.cyan(a)} ${this.value?`${e__default.green(_)} ${o}`:`${e__default.dim(A)} ${e__default.dim(o)}`} ${e__default.dim("/")} ${this.value?`${e__default.dim(A)} ${e__default.dim(s)}`:`${e__default.green(_)} ${s}`}
|
||||
${e__default.cyan(g)}
|
||||
`}}}).prompt()},select=t=>{const o=(s,i)=>{const r=s.label??String(s.value);switch(i){case"selected":return`${e__default.dim(r)}`;case"active":return`${e__default.green(_)} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`;case"cancelled":return`${e__default.strikethrough(e__default.dim(r))}`;default:return`${e__default.dim(A)} ${e__default.dim(r)}`}};return new core.SelectPrompt({options:t.options,initialValue:t.initialValue,render(){const s=`${e__default.gray(a)}
|
||||
${b(this.state)} ${t.message}
|
||||
`;switch(this.state){case"submit":return`${s}${e__default.gray(a)} ${o(this.options[this.cursor],"selected")}`;case"cancel":return`${s}${e__default.gray(a)} ${o(this.options[this.cursor],"cancelled")}
|
||||
${e__default.gray(a)}`;default:return`${s}${e__default.cyan(a)} ${E({cursor:this.cursor,options:this.options,maxItems:t.maxItems,style:(i,r)=>o(i,r?"active":"inactive")}).join(`
|
||||
${e__default.cyan(a)} `)}
|
||||
${e__default.cyan(g)}
|
||||
`}}}).prompt()},selectKey=t=>{const o=(s,i="inactive")=>{const r=s.label??String(s.value);return i==="selected"?`${e__default.dim(r)}`:i==="cancelled"?`${e__default.strikethrough(e__default.dim(r))}`:i==="active"?`${e__default.bgCyan(e__default.gray(` ${s.value} `))} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`:`${e__default.gray(e__default.bgWhite(e__default.inverse(` ${s.value} `)))} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`};return new core.SelectKeyPrompt({options:t.options,initialValue:t.initialValue,render(){const s=`${e__default.gray(a)}
|
||||
${b(this.state)} ${t.message}
|
||||
`;switch(this.state){case"submit":return`${s}${e__default.gray(a)} ${o(this.options.find(i=>i.value===this.value)??t.options[0],"selected")}`;case"cancel":return`${s}${e__default.gray(a)} ${o(this.options[0],"cancelled")}
|
||||
${e__default.gray(a)}`;default:return`${s}${e__default.cyan(a)} ${this.options.map((i,r)=>o(i,r===this.cursor?"active":"inactive")).join(`
|
||||
${e__default.cyan(a)} `)}
|
||||
${e__default.cyan(g)}
|
||||
`}}}).prompt()},multiselect=t=>{const o=(s,i)=>{const r=s.label??String(s.value);return i==="active"?`${e__default.cyan(C)} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`:i==="selected"?`${e__default.green(V)} ${e__default.dim(r)} ${s.hint?e__default.dim(`(${s.hint})`):""}`:i==="cancelled"?`${e__default.strikethrough(e__default.dim(r))}`:i==="active-selected"?`${e__default.green(V)} ${r} ${s.hint?e__default.dim(`(${s.hint})`):""}`:i==="submitted"?`${e__default.dim(r)}`:`${e__default.dim(N)} ${e__default.dim(r)}`};return new core.MultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(s){if(this.required&&s.length===0)return`Please select at least one option.
|
||||
${e__default.reset(e__default.dim(`Press ${e__default.gray(e__default.bgWhite(e__default.inverse(" space ")))} to select, ${e__default.gray(e__default.bgWhite(e__default.inverse(" enter ")))} to submit`))}`},render(){const s=`${e__default.gray(a)}
|
||||
${b(this.state)} ${t.message}
|
||||
`,i=(r,c)=>{const n=this.value.includes(r.value);return c&&n?o(r,"active-selected"):n?o(r,"selected"):o(r,c?"active":"inactive")};switch(this.state){case"submit":return`${s}${e__default.gray(a)} ${this.options.filter(({value:r})=>this.value.includes(r)).map(r=>o(r,"submitted")).join(e__default.dim(", "))||e__default.dim("none")}`;case"cancel":{const r=this.options.filter(({value:c})=>this.value.includes(c)).map(c=>o(c,"cancelled")).join(e__default.dim(", "));return`${s}${e__default.gray(a)} ${r.trim()?`${r}
|
||||
${e__default.gray(a)}`:""}`}case"error":{const r=this.error.split(`
|
||||
`).map((c,n)=>n===0?`${e__default.yellow(g)} ${e__default.yellow(c)}`:` ${c}`).join(`
|
||||
`);return`${s+e__default.yellow(a)} ${E({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:i}).join(`
|
||||
${e__default.yellow(a)} `)}
|
||||
${r}
|
||||
`}default:return`${s}${e__default.cyan(a)} ${E({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:i}).join(`
|
||||
${e__default.cyan(a)} `)}
|
||||
${e__default.cyan(g)}
|
||||
`}}}).prompt()},groupMultiselect=t=>{const{selectableGroups:o=!0}=t,s=(i,r,c=[])=>{const n=i.label??String(i.value),l=typeof i.group=="string",$=l&&(c[c.indexOf(i)+1]??{group:!0}),h=l&&$.group===!0,m=l?o?`${h?g:a} `:" ":"";if(r==="active")return`${e__default.dim(m)}${e__default.cyan(C)} ${n} ${i.hint?e__default.dim(`(${i.hint})`):""}`;if(r==="group-active")return`${m}${e__default.cyan(C)} ${e__default.dim(n)}`;if(r==="group-active-selected")return`${m}${e__default.green(V)} ${e__default.dim(n)}`;if(r==="selected"){const w=l||o?e__default.green(V):"";return`${e__default.dim(m)}${w} ${e__default.dim(n)} ${i.hint?e__default.dim(`(${i.hint})`):""}`}if(r==="cancelled")return`${e__default.strikethrough(e__default.dim(n))}`;if(r==="active-selected")return`${e__default.dim(m)}${e__default.green(V)} ${n} ${i.hint?e__default.dim(`(${i.hint})`):""}`;if(r==="submitted")return`${e__default.dim(n)}`;const y=l||o?e__default.dim(N):"";return`${e__default.dim(m)}${y} ${e__default.dim(n)}`};return new core.GroupMultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,selectableGroups:o,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
|
||||
${e__default.reset(e__default.dim(`Press ${e__default.gray(e__default.bgWhite(e__default.inverse(" space ")))} to select, ${e__default.gray(e__default.bgWhite(e__default.inverse(" enter ")))} to submit`))}`},render(){const i=`${e__default.gray(a)}
|
||||
${b(this.state)} ${t.message}
|
||||
`;switch(this.state){case"submit":return`${i}${e__default.gray(a)} ${this.options.filter(({value:r})=>this.value.includes(r)).map(r=>s(r,"submitted")).join(e__default.dim(", "))}`;case"cancel":{const r=this.options.filter(({value:c})=>this.value.includes(c)).map(c=>s(c,"cancelled")).join(e__default.dim(", "));return`${i}${e__default.gray(a)} ${r.trim()?`${r}
|
||||
${e__default.gray(a)}`:""}`}case"error":{const r=this.error.split(`
|
||||
`).map((c,n)=>n===0?`${e__default.yellow(g)} ${e__default.yellow(c)}`:` ${c}`).join(`
|
||||
`);return`${i}${e__default.yellow(a)} ${this.options.map((c,n,l)=>{const $=this.value.includes(c.value)||c.group===!0&&this.isGroupSelected(`${c.value}`),h=n===this.cursor;return!h&&typeof c.group=="string"&&this.options[this.cursor].value===c.group?s(c,$?"group-active-selected":"group-active",l):h&&$?s(c,"active-selected",l):$?s(c,"selected",l):s(c,h?"active":"inactive",l)}).join(`
|
||||
${e__default.yellow(a)} `)}
|
||||
${r}
|
||||
`}default:return`${i}${e__default.cyan(a)} ${this.options.map((r,c,n)=>{const l=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),$=c===this.cursor;return!$&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?s(r,l?"group-active-selected":"group-active",n):$&&l?s(r,"active-selected",n):l?s(r,"selected",n):s(r,$?"active":"inactive",n)}).join(`
|
||||
${e__default.cyan(a)} `)}
|
||||
${e__default.cyan(g)}
|
||||
`}}}).prompt()},note=(t="",o="")=>{const s=`
|
||||
${t}
|
||||
`.split(`
|
||||
`),i=node_util.stripVTControlCharacters(o).length,r=Math.max(s.reduce((n,l)=>{const $=node_util.stripVTControlCharacters(l);return $.length>n?$.length:n},0),i)+2,c=s.map(n=>`${e__default.gray(a)} ${e__default.dim(n)}${" ".repeat(r-node_util.stripVTControlCharacters(n).length)}${e__default.gray(a)}`).join(`
|
||||
`);process.stdout.write(`${e__default.gray(a)}
|
||||
${e__default.green(S)} ${e__default.reset(o)} ${e__default.gray(j.repeat(Math.max(r-i-1,1))+le)}
|
||||
${c}
|
||||
${e__default.gray(ce+j.repeat(r+2)+ue)}
|
||||
`)},cancel=(t="")=>{process.stdout.write(`${e__default.gray(g)} ${e__default.red(t)}
|
||||
|
||||
`)},intro=(t="")=>{process.stdout.write(`${e__default.gray(ae)} ${t}
|
||||
`)},outro=(t="")=>{process.stdout.write(`${e__default.gray(a)}
|
||||
${e__default.gray(g)} ${t}
|
||||
|
||||
`)},log={message:(t="",{symbol:o=e__default.gray(a)}={})=>{const s=[`${e__default.gray(a)}`];if(t){const[i,...r]=t.split(`
|
||||
`);s.push(`${o} ${i}`,...r.map(c=>`${e__default.gray(a)} ${c}`))}process.stdout.write(`${s.join(`
|
||||
`)}
|
||||
`)},info:t=>{log.message(t,{symbol:e__default.blue(B)})},success:t=>{log.message(t,{symbol:e__default.green(W)})},step:t=>{log.message(t,{symbol:e__default.green(S)})},warn:t=>{log.message(t,{symbol:e__default.yellow(H)})},warning:t=>{log.warn(t)},error:t=>{log.message(t,{symbol:e__default.red(q)})}},D=`${e__default.gray(a)} `,stream={message:async(t,{symbol:o=e__default.gray(a)}={})=>{process.stdout.write(`${e__default.gray(a)}
|
||||
${o} `);let s=3;for await(let i of t){i=i.replace(/\n/g,`
|
||||
${D}`),i.includes(`
|
||||
`)&&(s=3+node_util.stripVTControlCharacters(i.slice(i.lastIndexOf(`
|
||||
`))).length);const r=node_util.stripVTControlCharacters(i).length;s+r<process.stdout.columns?(s+=r,process.stdout.write(i)):(process.stdout.write(`
|
||||
${D}${i.trimStart()}`),s=3+node_util.stripVTControlCharacters(i.trimStart()).length)}process.stdout.write(`
|
||||
`)},info:t=>stream.message(t,{symbol:e__default.blue(B)}),success:t=>stream.message(t,{symbol:e__default.green(W)}),step:t=>stream.message(t,{symbol:e__default.green(S)}),warn:t=>stream.message(t,{symbol:e__default.yellow(H)}),warning:t=>stream.warn(t),error:t=>stream.message(t,{symbol:e__default.red(q)})},spinner=({indicator:t="dots"}={})=>{const o=P?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],s=P?80:120,i=process.env.CI==="true";let r,c,n=!1,l="",$,h=performance.now();const m=p=>{const d=p>1?"Something went wrong":"Canceled";n&&R(d,p)},y=()=>m(2),w=()=>m(1),x=()=>{process.on("uncaughtExceptionMonitor",y),process.on("unhandledRejection",y),process.on("SIGINT",w),process.on("SIGTERM",w),process.on("exit",m)},M=()=>{process.removeListener("uncaughtExceptionMonitor",y),process.removeListener("unhandledRejection",y),process.removeListener("SIGINT",w),process.removeListener("SIGTERM",w),process.removeListener("exit",m)},T=()=>{if($===void 0)return;i&&process.stdout.write(`
|
||||
`);const p=$.split(`
|
||||
`);process.stdout.write(sisteransi.cursor.move(-999,p.length-1)),process.stdout.write(sisteransi.erase.down(p.length))},I=p=>p.replace(/\.+$/,""),k=p=>{const d=(performance.now()-p)/1e3,v=Math.floor(d/60),f=Math.floor(d%60);return v>0?`[${v}m ${f}s]`:`[${f}s]`},O=(p="")=>{n=!0,r=core.block(),l=I(p),h=performance.now(),process.stdout.write(`${e__default.gray(a)}
|
||||
`);let d=0,v=0;x(),c=setInterval(()=>{if(i&&l===$)return;T(),$=l;const f=e__default.magenta(o[d]);if(i)process.stdout.write(`${f} ${l}...`);else if(t==="timer")process.stdout.write(`${f} ${l} ${k(h)}`);else{const F=".".repeat(Math.floor(v)).slice(0,3);process.stdout.write(`${f} ${l}${F}`)}d=d+1<o.length?d+1:0,v=v<o.length?v+.125:0},s)},R=(p="",d=0)=>{n=!1,clearInterval(c),T();const v=d===0?e__default.green(S):d===1?e__default.red(G):e__default.red(L);l=I(p??l),t==="timer"?process.stdout.write(`${v} ${l} ${k(h)}
|
||||
`):process.stdout.write(`${v} ${l}
|
||||
`),M(),r()};return{start:O,stop:R,message:(p="")=>{l=I(p??l)}}},group=async(t,o)=>{const s={},i=Object.keys(t);for(const r of i){const c=t[r],n=await c({results:s})?.catch(l=>{throw l});if(typeof o?.onCancel=="function"&&core.isCancel(n)){s[r]="canceled",o.onCancel({results:s});continue}s[r]=n}return s},tasks=async t=>{for(const o of t){if(o.enabled===!1)continue;const s=spinner();s.start(o.title);const i=await o.task(s.message);s.stop(i||o.title)}};exports.isCancel=core.isCancel,exports.updateSettings=core.updateSettings,exports.cancel=cancel,exports.confirm=confirm,exports.group=group,exports.groupMultiselect=groupMultiselect,exports.intro=intro,exports.log=log,exports.multiselect=multiselect,exports.note=note,exports.outro=outro,exports.password=password,exports.select=select,exports.selectKey=selectKey,exports.spinner=spinner,exports.stream=stream,exports.tasks=tasks,exports.text=text;
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
+1
File diff suppressed because one or more lines are too long
+165
@@ -0,0 +1,165 @@
|
||||
export { ClackSettings, isCancel, updateSettings } from '@clack/core';
|
||||
|
||||
interface TextOptions {
|
||||
message: string;
|
||||
placeholder?: string;
|
||||
defaultValue?: string;
|
||||
initialValue?: string;
|
||||
validate?: (value: string) => string | Error | undefined;
|
||||
}
|
||||
declare const text: (opts: TextOptions) => Promise<string | symbol>;
|
||||
interface PasswordOptions {
|
||||
message: string;
|
||||
mask?: string;
|
||||
validate?: (value: string) => string | Error | undefined;
|
||||
}
|
||||
declare const password: (opts: PasswordOptions) => Promise<string | symbol>;
|
||||
interface ConfirmOptions {
|
||||
message: string;
|
||||
active?: string;
|
||||
inactive?: string;
|
||||
initialValue?: boolean;
|
||||
}
|
||||
declare const confirm: (opts: ConfirmOptions) => Promise<boolean | symbol>;
|
||||
type Primitive = Readonly<string | boolean | number>;
|
||||
type Option<Value> = Value extends Primitive ? {
|
||||
/**
|
||||
* Internal data for this option.
|
||||
*/
|
||||
value: Value;
|
||||
/**
|
||||
* The optional, user-facing text for this option.
|
||||
*
|
||||
* By default, the `value` is converted to a string.
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* An optional hint to display to the user when
|
||||
* this option might be selected.
|
||||
*
|
||||
* By default, no `hint` is displayed.
|
||||
*/
|
||||
hint?: string;
|
||||
} : {
|
||||
/**
|
||||
* Internal data for this option.
|
||||
*/
|
||||
value: Value;
|
||||
/**
|
||||
* Required. The user-facing text for this option.
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* An optional hint to display to the user when
|
||||
* this option might be selected.
|
||||
*
|
||||
* By default, no `hint` is displayed.
|
||||
*/
|
||||
hint?: string;
|
||||
};
|
||||
interface SelectOptions<Value> {
|
||||
message: string;
|
||||
options: Option<Value>[];
|
||||
initialValue?: Value;
|
||||
maxItems?: number;
|
||||
}
|
||||
declare const select: <Value>(opts: SelectOptions<Value>) => Promise<symbol | Value>;
|
||||
declare const selectKey: <Value extends string>(opts: SelectOptions<Value>) => Promise<symbol | Value>;
|
||||
interface MultiSelectOptions<Value> {
|
||||
message: string;
|
||||
options: Option<Value>[];
|
||||
initialValues?: Value[];
|
||||
maxItems?: number;
|
||||
required?: boolean;
|
||||
cursorAt?: Value;
|
||||
}
|
||||
declare const multiselect: <Value>(opts: MultiSelectOptions<Value>) => Promise<symbol | Value[]>;
|
||||
interface GroupMultiSelectOptions<Value> {
|
||||
message: string;
|
||||
options: Record<string, Option<Value>[]>;
|
||||
initialValues?: Value[];
|
||||
required?: boolean;
|
||||
cursorAt?: Value;
|
||||
selectableGroups?: boolean;
|
||||
}
|
||||
declare const groupMultiselect: <Value>(opts: GroupMultiSelectOptions<Value>) => Promise<symbol | Value[]>;
|
||||
declare const note: (message?: string, title?: string) => void;
|
||||
declare const cancel: (message?: string) => void;
|
||||
declare const intro: (title?: string) => void;
|
||||
declare const outro: (message?: string) => void;
|
||||
type LogMessageOptions = {
|
||||
symbol?: string;
|
||||
};
|
||||
declare const log: {
|
||||
message: (message?: string, { symbol }?: LogMessageOptions) => void;
|
||||
info: (message: string) => void;
|
||||
success: (message: string) => void;
|
||||
step: (message: string) => void;
|
||||
warn: (message: string) => void;
|
||||
/** alias for `log.warn()`. */
|
||||
warning: (message: string) => void;
|
||||
error: (message: string) => void;
|
||||
};
|
||||
declare const stream: {
|
||||
message: (iterable: Iterable<string> | AsyncIterable<string>, { symbol }?: LogMessageOptions) => Promise<void>;
|
||||
info: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
success: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
step: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
warn: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
/** alias for `log.warn()`. */
|
||||
warning: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
error: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
};
|
||||
interface SpinnerOptions {
|
||||
indicator?: 'dots' | 'timer';
|
||||
}
|
||||
declare const spinner: ({ indicator }?: SpinnerOptions) => {
|
||||
start: (msg?: string) => void;
|
||||
stop: (msg?: string, code?: number) => void;
|
||||
message: (msg?: string) => void;
|
||||
};
|
||||
type PromptGroupAwaitedReturn<T> = {
|
||||
[P in keyof T]: Exclude<Awaited<T[P]>, symbol>;
|
||||
};
|
||||
interface PromptGroupOptions<T> {
|
||||
/**
|
||||
* Control how the group can be canceled
|
||||
* if one of the prompts is canceled.
|
||||
*/
|
||||
onCancel?: (opts: {
|
||||
results: Prettify<Partial<PromptGroupAwaitedReturn<T>>>;
|
||||
}) => void;
|
||||
}
|
||||
type Prettify<T> = {
|
||||
[P in keyof T]: T[P];
|
||||
} & {};
|
||||
type PromptGroup<T> = {
|
||||
[P in keyof T]: (opts: {
|
||||
results: Prettify<Partial<PromptGroupAwaitedReturn<Omit<T, P>>>>;
|
||||
}) => undefined | Promise<T[P] | undefined>;
|
||||
};
|
||||
/**
|
||||
* Define a group of prompts to be displayed
|
||||
* and return a results of objects within the group
|
||||
*/
|
||||
declare const group: <T>(prompts: PromptGroup<T>, opts?: PromptGroupOptions<T> | undefined) => Promise<{ [P in keyof PromptGroupAwaitedReturn<T>]: PromptGroupAwaitedReturn<T>[P]; }>;
|
||||
type Task = {
|
||||
/**
|
||||
* Task title
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* Task function
|
||||
*/
|
||||
task: (message: (string: string) => void) => string | Promise<string> | void | Promise<void>;
|
||||
/**
|
||||
* If enabled === false the task will be skipped
|
||||
*/
|
||||
enabled?: boolean;
|
||||
};
|
||||
/**
|
||||
* Define a group of tasks to be executed
|
||||
*/
|
||||
declare const tasks: (tasks: Task[]) => Promise<void>;
|
||||
|
||||
export { type ConfirmOptions, type GroupMultiSelectOptions, type LogMessageOptions, type MultiSelectOptions, type Option, type PasswordOptions, type PromptGroup, type PromptGroupAwaitedReturn, type PromptGroupOptions, type SelectOptions, type SpinnerOptions, type Task, type TextOptions, cancel, confirm, group, groupMultiselect, intro, log, multiselect, note, outro, password, select, selectKey, spinner, stream, tasks, text };
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
export { ClackSettings, isCancel, updateSettings } from '@clack/core';
|
||||
|
||||
interface TextOptions {
|
||||
message: string;
|
||||
placeholder?: string;
|
||||
defaultValue?: string;
|
||||
initialValue?: string;
|
||||
validate?: (value: string) => string | Error | undefined;
|
||||
}
|
||||
declare const text: (opts: TextOptions) => Promise<string | symbol>;
|
||||
interface PasswordOptions {
|
||||
message: string;
|
||||
mask?: string;
|
||||
validate?: (value: string) => string | Error | undefined;
|
||||
}
|
||||
declare const password: (opts: PasswordOptions) => Promise<string | symbol>;
|
||||
interface ConfirmOptions {
|
||||
message: string;
|
||||
active?: string;
|
||||
inactive?: string;
|
||||
initialValue?: boolean;
|
||||
}
|
||||
declare const confirm: (opts: ConfirmOptions) => Promise<boolean | symbol>;
|
||||
type Primitive = Readonly<string | boolean | number>;
|
||||
type Option<Value> = Value extends Primitive ? {
|
||||
/**
|
||||
* Internal data for this option.
|
||||
*/
|
||||
value: Value;
|
||||
/**
|
||||
* The optional, user-facing text for this option.
|
||||
*
|
||||
* By default, the `value` is converted to a string.
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* An optional hint to display to the user when
|
||||
* this option might be selected.
|
||||
*
|
||||
* By default, no `hint` is displayed.
|
||||
*/
|
||||
hint?: string;
|
||||
} : {
|
||||
/**
|
||||
* Internal data for this option.
|
||||
*/
|
||||
value: Value;
|
||||
/**
|
||||
* Required. The user-facing text for this option.
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* An optional hint to display to the user when
|
||||
* this option might be selected.
|
||||
*
|
||||
* By default, no `hint` is displayed.
|
||||
*/
|
||||
hint?: string;
|
||||
};
|
||||
interface SelectOptions<Value> {
|
||||
message: string;
|
||||
options: Option<Value>[];
|
||||
initialValue?: Value;
|
||||
maxItems?: number;
|
||||
}
|
||||
declare const select: <Value>(opts: SelectOptions<Value>) => Promise<symbol | Value>;
|
||||
declare const selectKey: <Value extends string>(opts: SelectOptions<Value>) => Promise<symbol | Value>;
|
||||
interface MultiSelectOptions<Value> {
|
||||
message: string;
|
||||
options: Option<Value>[];
|
||||
initialValues?: Value[];
|
||||
maxItems?: number;
|
||||
required?: boolean;
|
||||
cursorAt?: Value;
|
||||
}
|
||||
declare const multiselect: <Value>(opts: MultiSelectOptions<Value>) => Promise<symbol | Value[]>;
|
||||
interface GroupMultiSelectOptions<Value> {
|
||||
message: string;
|
||||
options: Record<string, Option<Value>[]>;
|
||||
initialValues?: Value[];
|
||||
required?: boolean;
|
||||
cursorAt?: Value;
|
||||
selectableGroups?: boolean;
|
||||
}
|
||||
declare const groupMultiselect: <Value>(opts: GroupMultiSelectOptions<Value>) => Promise<symbol | Value[]>;
|
||||
declare const note: (message?: string, title?: string) => void;
|
||||
declare const cancel: (message?: string) => void;
|
||||
declare const intro: (title?: string) => void;
|
||||
declare const outro: (message?: string) => void;
|
||||
type LogMessageOptions = {
|
||||
symbol?: string;
|
||||
};
|
||||
declare const log: {
|
||||
message: (message?: string, { symbol }?: LogMessageOptions) => void;
|
||||
info: (message: string) => void;
|
||||
success: (message: string) => void;
|
||||
step: (message: string) => void;
|
||||
warn: (message: string) => void;
|
||||
/** alias for `log.warn()`. */
|
||||
warning: (message: string) => void;
|
||||
error: (message: string) => void;
|
||||
};
|
||||
declare const stream: {
|
||||
message: (iterable: Iterable<string> | AsyncIterable<string>, { symbol }?: LogMessageOptions) => Promise<void>;
|
||||
info: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
success: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
step: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
warn: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
/** alias for `log.warn()`. */
|
||||
warning: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
error: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
};
|
||||
interface SpinnerOptions {
|
||||
indicator?: 'dots' | 'timer';
|
||||
}
|
||||
declare const spinner: ({ indicator }?: SpinnerOptions) => {
|
||||
start: (msg?: string) => void;
|
||||
stop: (msg?: string, code?: number) => void;
|
||||
message: (msg?: string) => void;
|
||||
};
|
||||
type PromptGroupAwaitedReturn<T> = {
|
||||
[P in keyof T]: Exclude<Awaited<T[P]>, symbol>;
|
||||
};
|
||||
interface PromptGroupOptions<T> {
|
||||
/**
|
||||
* Control how the group can be canceled
|
||||
* if one of the prompts is canceled.
|
||||
*/
|
||||
onCancel?: (opts: {
|
||||
results: Prettify<Partial<PromptGroupAwaitedReturn<T>>>;
|
||||
}) => void;
|
||||
}
|
||||
type Prettify<T> = {
|
||||
[P in keyof T]: T[P];
|
||||
} & {};
|
||||
type PromptGroup<T> = {
|
||||
[P in keyof T]: (opts: {
|
||||
results: Prettify<Partial<PromptGroupAwaitedReturn<Omit<T, P>>>>;
|
||||
}) => undefined | Promise<T[P] | undefined>;
|
||||
};
|
||||
/**
|
||||
* Define a group of prompts to be displayed
|
||||
* and return a results of objects within the group
|
||||
*/
|
||||
declare const group: <T>(prompts: PromptGroup<T>, opts?: PromptGroupOptions<T> | undefined) => Promise<{ [P in keyof PromptGroupAwaitedReturn<T>]: PromptGroupAwaitedReturn<T>[P]; }>;
|
||||
type Task = {
|
||||
/**
|
||||
* Task title
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* Task function
|
||||
*/
|
||||
task: (message: (string: string) => void) => string | Promise<string> | void | Promise<void>;
|
||||
/**
|
||||
* If enabled === false the task will be skipped
|
||||
*/
|
||||
enabled?: boolean;
|
||||
};
|
||||
/**
|
||||
* Define a group of tasks to be executed
|
||||
*/
|
||||
declare const tasks: (tasks: Task[]) => Promise<void>;
|
||||
|
||||
export { type ConfirmOptions, type GroupMultiSelectOptions, type LogMessageOptions, type MultiSelectOptions, type Option, type PasswordOptions, type PromptGroup, type PromptGroupAwaitedReturn, type PromptGroupOptions, type SelectOptions, type SpinnerOptions, type Task, type TextOptions, cancel, confirm, group, groupMultiselect, intro, log, multiselect, note, outro, password, select, selectKey, spinner, stream, tasks, text };
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
export { ClackSettings, isCancel, updateSettings } from '@clack/core';
|
||||
|
||||
interface TextOptions {
|
||||
message: string;
|
||||
placeholder?: string;
|
||||
defaultValue?: string;
|
||||
initialValue?: string;
|
||||
validate?: (value: string) => string | Error | undefined;
|
||||
}
|
||||
declare const text: (opts: TextOptions) => Promise<string | symbol>;
|
||||
interface PasswordOptions {
|
||||
message: string;
|
||||
mask?: string;
|
||||
validate?: (value: string) => string | Error | undefined;
|
||||
}
|
||||
declare const password: (opts: PasswordOptions) => Promise<string | symbol>;
|
||||
interface ConfirmOptions {
|
||||
message: string;
|
||||
active?: string;
|
||||
inactive?: string;
|
||||
initialValue?: boolean;
|
||||
}
|
||||
declare const confirm: (opts: ConfirmOptions) => Promise<boolean | symbol>;
|
||||
type Primitive = Readonly<string | boolean | number>;
|
||||
type Option<Value> = Value extends Primitive ? {
|
||||
/**
|
||||
* Internal data for this option.
|
||||
*/
|
||||
value: Value;
|
||||
/**
|
||||
* The optional, user-facing text for this option.
|
||||
*
|
||||
* By default, the `value` is converted to a string.
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* An optional hint to display to the user when
|
||||
* this option might be selected.
|
||||
*
|
||||
* By default, no `hint` is displayed.
|
||||
*/
|
||||
hint?: string;
|
||||
} : {
|
||||
/**
|
||||
* Internal data for this option.
|
||||
*/
|
||||
value: Value;
|
||||
/**
|
||||
* Required. The user-facing text for this option.
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* An optional hint to display to the user when
|
||||
* this option might be selected.
|
||||
*
|
||||
* By default, no `hint` is displayed.
|
||||
*/
|
||||
hint?: string;
|
||||
};
|
||||
interface SelectOptions<Value> {
|
||||
message: string;
|
||||
options: Option<Value>[];
|
||||
initialValue?: Value;
|
||||
maxItems?: number;
|
||||
}
|
||||
declare const select: <Value>(opts: SelectOptions<Value>) => Promise<symbol | Value>;
|
||||
declare const selectKey: <Value extends string>(opts: SelectOptions<Value>) => Promise<symbol | Value>;
|
||||
interface MultiSelectOptions<Value> {
|
||||
message: string;
|
||||
options: Option<Value>[];
|
||||
initialValues?: Value[];
|
||||
maxItems?: number;
|
||||
required?: boolean;
|
||||
cursorAt?: Value;
|
||||
}
|
||||
declare const multiselect: <Value>(opts: MultiSelectOptions<Value>) => Promise<symbol | Value[]>;
|
||||
interface GroupMultiSelectOptions<Value> {
|
||||
message: string;
|
||||
options: Record<string, Option<Value>[]>;
|
||||
initialValues?: Value[];
|
||||
required?: boolean;
|
||||
cursorAt?: Value;
|
||||
selectableGroups?: boolean;
|
||||
}
|
||||
declare const groupMultiselect: <Value>(opts: GroupMultiSelectOptions<Value>) => Promise<symbol | Value[]>;
|
||||
declare const note: (message?: string, title?: string) => void;
|
||||
declare const cancel: (message?: string) => void;
|
||||
declare const intro: (title?: string) => void;
|
||||
declare const outro: (message?: string) => void;
|
||||
type LogMessageOptions = {
|
||||
symbol?: string;
|
||||
};
|
||||
declare const log: {
|
||||
message: (message?: string, { symbol }?: LogMessageOptions) => void;
|
||||
info: (message: string) => void;
|
||||
success: (message: string) => void;
|
||||
step: (message: string) => void;
|
||||
warn: (message: string) => void;
|
||||
/** alias for `log.warn()`. */
|
||||
warning: (message: string) => void;
|
||||
error: (message: string) => void;
|
||||
};
|
||||
declare const stream: {
|
||||
message: (iterable: Iterable<string> | AsyncIterable<string>, { symbol }?: LogMessageOptions) => Promise<void>;
|
||||
info: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
success: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
step: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
warn: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
/** alias for `log.warn()`. */
|
||||
warning: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
error: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
|
||||
};
|
||||
interface SpinnerOptions {
|
||||
indicator?: 'dots' | 'timer';
|
||||
}
|
||||
declare const spinner: ({ indicator }?: SpinnerOptions) => {
|
||||
start: (msg?: string) => void;
|
||||
stop: (msg?: string, code?: number) => void;
|
||||
message: (msg?: string) => void;
|
||||
};
|
||||
type PromptGroupAwaitedReturn<T> = {
|
||||
[P in keyof T]: Exclude<Awaited<T[P]>, symbol>;
|
||||
};
|
||||
interface PromptGroupOptions<T> {
|
||||
/**
|
||||
* Control how the group can be canceled
|
||||
* if one of the prompts is canceled.
|
||||
*/
|
||||
onCancel?: (opts: {
|
||||
results: Prettify<Partial<PromptGroupAwaitedReturn<T>>>;
|
||||
}) => void;
|
||||
}
|
||||
type Prettify<T> = {
|
||||
[P in keyof T]: T[P];
|
||||
} & {};
|
||||
type PromptGroup<T> = {
|
||||
[P in keyof T]: (opts: {
|
||||
results: Prettify<Partial<PromptGroupAwaitedReturn<Omit<T, P>>>>;
|
||||
}) => undefined | Promise<T[P] | undefined>;
|
||||
};
|
||||
/**
|
||||
* Define a group of prompts to be displayed
|
||||
* and return a results of objects within the group
|
||||
*/
|
||||
declare const group: <T>(prompts: PromptGroup<T>, opts?: PromptGroupOptions<T> | undefined) => Promise<{ [P in keyof PromptGroupAwaitedReturn<T>]: PromptGroupAwaitedReturn<T>[P]; }>;
|
||||
type Task = {
|
||||
/**
|
||||
* Task title
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* Task function
|
||||
*/
|
||||
task: (message: (string: string) => void) => string | Promise<string> | void | Promise<void>;
|
||||
/**
|
||||
* If enabled === false the task will be skipped
|
||||
*/
|
||||
enabled?: boolean;
|
||||
};
|
||||
/**
|
||||
* Define a group of tasks to be executed
|
||||
*/
|
||||
declare const tasks: (tasks: Task[]) => Promise<void>;
|
||||
|
||||
export { type ConfirmOptions, type GroupMultiSelectOptions, type LogMessageOptions, type MultiSelectOptions, type Option, type PasswordOptions, type PromptGroup, type PromptGroupAwaitedReturn, type PromptGroupOptions, type SelectOptions, type SpinnerOptions, type Task, type TextOptions, cancel, confirm, group, groupMultiselect, intro, log, multiselect, note, outro, password, select, selectKey, spinner, stream, tasks, text };
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
import{stripVTControlCharacters as S}from"node:util";import{TextPrompt as Q,PasswordPrompt as X,ConfirmPrompt as Z,SelectPrompt as ee,SelectKeyPrompt as te,MultiSelectPrompt as re,GroupMultiSelectPrompt as se,isCancel as ie,block as ne}from"@clack/core";export{isCancel,updateSettings}from"@clack/core";import y from"node:process";import e from"picocolors";import{cursor as oe,erase as ae}from"sisteransi";function ce(){return y.platform!=="win32"?y.env.TERM!=="linux":!!y.env.CI||!!y.env.WT_SESSION||!!y.env.TERMINUS_SUBLIME||y.env.ConEmuTask==="{cmd::Cmder}"||y.env.TERM_PROGRAM==="Terminus-Sublime"||y.env.TERM_PROGRAM==="vscode"||y.env.TERM==="xterm-256color"||y.env.TERM==="alacritty"||y.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const V=ce(),u=(t,n)=>V?t:n,le=u("\u25C6","*"),L=u("\u25A0","x"),W=u("\u25B2","x"),C=u("\u25C7","o"),ue=u("\u250C","T"),o=u("\u2502","|"),d=u("\u2514","\u2014"),k=u("\u25CF",">"),P=u("\u25CB"," "),A=u("\u25FB","[\u2022]"),T=u("\u25FC","[+]"),F=u("\u25FB","[ ]"),$e=u("\u25AA","\u2022"),_=u("\u2500","-"),me=u("\u256E","+"),de=u("\u251C","+"),pe=u("\u256F","+"),q=u("\u25CF","\u2022"),D=u("\u25C6","*"),U=u("\u25B2","!"),K=u("\u25A0","x"),b=t=>{switch(t){case"initial":case"active":return e.cyan(le);case"cancel":return e.red(L);case"error":return e.yellow(W);case"submit":return e.green(C)}},G=t=>{const{cursor:n,options:r,style:i}=t,s=t.maxItems??Number.POSITIVE_INFINITY,c=Math.max(process.stdout.rows-4,0),a=Math.min(c,Math.max(s,5));let l=0;n>=l+a-3?l=Math.max(Math.min(n-a+3,r.length-a),0):n<l+2&&(l=Math.max(n-2,0));const $=a<r.length&&l>0,g=a<r.length&&l+a<r.length;return r.slice(l,l+a).map((p,v,f)=>{const j=v===0&&$,E=v===f.length-1&&g;return j||E?e.dim("..."):i(p,v+l===n)})},he=t=>new Q({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){const n=`${e.gray(o)}
|
||||
${b(this.state)} ${t.message}
|
||||
`,r=t.placeholder?e.inverse(t.placeholder[0])+e.dim(t.placeholder.slice(1)):e.inverse(e.hidden("_")),i=this.value?this.valueWithCursor:r;switch(this.state){case"error":return`${n.trim()}
|
||||
${e.yellow(o)} ${i}
|
||||
${e.yellow(d)} ${e.yellow(this.error)}
|
||||
`;case"submit":return`${n}${e.gray(o)} ${e.dim(this.value||t.placeholder)}`;case"cancel":return`${n}${e.gray(o)} ${e.strikethrough(e.dim(this.value??""))}${this.value?.trim()?`
|
||||
${e.gray(o)}`:""}`;default:return`${n}${e.cyan(o)} ${i}
|
||||
${e.cyan(d)}
|
||||
`}}}).prompt(),ge=t=>new X({validate:t.validate,mask:t.mask??$e,render(){const n=`${e.gray(o)}
|
||||
${b(this.state)} ${t.message}
|
||||
`,r=this.valueWithCursor,i=this.masked;switch(this.state){case"error":return`${n.trim()}
|
||||
${e.yellow(o)} ${i}
|
||||
${e.yellow(d)} ${e.yellow(this.error)}
|
||||
`;case"submit":return`${n}${e.gray(o)} ${e.dim(i)}`;case"cancel":return`${n}${e.gray(o)} ${e.strikethrough(e.dim(i??""))}${i?`
|
||||
${e.gray(o)}`:""}`;default:return`${n}${e.cyan(o)} ${r}
|
||||
${e.cyan(d)}
|
||||
`}}}).prompt(),ye=t=>{const n=t.active??"Yes",r=t.inactive??"No";return new Z({active:n,inactive:r,initialValue:t.initialValue??!0,render(){const i=`${e.gray(o)}
|
||||
${b(this.state)} ${t.message}
|
||||
`,s=this.value?n:r;switch(this.state){case"submit":return`${i}${e.gray(o)} ${e.dim(s)}`;case"cancel":return`${i}${e.gray(o)} ${e.strikethrough(e.dim(s))}
|
||||
${e.gray(o)}`;default:return`${i}${e.cyan(o)} ${this.value?`${e.green(k)} ${n}`:`${e.dim(P)} ${e.dim(n)}`} ${e.dim("/")} ${this.value?`${e.dim(P)} ${e.dim(r)}`:`${e.green(k)} ${r}`}
|
||||
${e.cyan(d)}
|
||||
`}}}).prompt()},ve=t=>{const n=(r,i)=>{const s=r.label??String(r.value);switch(i){case"selected":return`${e.dim(s)}`;case"active":return`${e.green(k)} ${s} ${r.hint?e.dim(`(${r.hint})`):""}`;case"cancelled":return`${e.strikethrough(e.dim(s))}`;default:return`${e.dim(P)} ${e.dim(s)}`}};return new ee({options:t.options,initialValue:t.initialValue,render(){const r=`${e.gray(o)}
|
||||
${b(this.state)} ${t.message}
|
||||
`;switch(this.state){case"submit":return`${r}${e.gray(o)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${r}${e.gray(o)} ${n(this.options[this.cursor],"cancelled")}
|
||||
${e.gray(o)}`;default:return`${r}${e.cyan(o)} ${G({cursor:this.cursor,options:this.options,maxItems:t.maxItems,style:(i,s)=>n(i,s?"active":"inactive")}).join(`
|
||||
${e.cyan(o)} `)}
|
||||
${e.cyan(d)}
|
||||
`}}}).prompt()},we=t=>{const n=(r,i="inactive")=>{const s=r.label??String(r.value);return i==="selected"?`${e.dim(s)}`:i==="cancelled"?`${e.strikethrough(e.dim(s))}`:i==="active"?`${e.bgCyan(e.gray(` ${r.value} `))} ${s} ${r.hint?e.dim(`(${r.hint})`):""}`:`${e.gray(e.bgWhite(e.inverse(` ${r.value} `)))} ${s} ${r.hint?e.dim(`(${r.hint})`):""}`};return new te({options:t.options,initialValue:t.initialValue,render(){const r=`${e.gray(o)}
|
||||
${b(this.state)} ${t.message}
|
||||
`;switch(this.state){case"submit":return`${r}${e.gray(o)} ${n(this.options.find(i=>i.value===this.value)??t.options[0],"selected")}`;case"cancel":return`${r}${e.gray(o)} ${n(this.options[0],"cancelled")}
|
||||
${e.gray(o)}`;default:return`${r}${e.cyan(o)} ${this.options.map((i,s)=>n(i,s===this.cursor?"active":"inactive")).join(`
|
||||
${e.cyan(o)} `)}
|
||||
${e.cyan(d)}
|
||||
`}}}).prompt()},fe=t=>{const n=(r,i)=>{const s=r.label??String(r.value);return i==="active"?`${e.cyan(A)} ${s} ${r.hint?e.dim(`(${r.hint})`):""}`:i==="selected"?`${e.green(T)} ${e.dim(s)} ${r.hint?e.dim(`(${r.hint})`):""}`:i==="cancelled"?`${e.strikethrough(e.dim(s))}`:i==="active-selected"?`${e.green(T)} ${s} ${r.hint?e.dim(`(${r.hint})`):""}`:i==="submitted"?`${e.dim(s)}`:`${e.dim(F)} ${e.dim(s)}`};return new re({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(r){if(this.required&&r.length===0)return`Please select at least one option.
|
||||
${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){const r=`${e.gray(o)}
|
||||
${b(this.state)} ${t.message}
|
||||
`,i=(s,c)=>{const a=this.value.includes(s.value);return c&&a?n(s,"active-selected"):a?n(s,"selected"):n(s,c?"active":"inactive")};switch(this.state){case"submit":return`${r}${e.gray(o)} ${this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"submitted")).join(e.dim(", "))||e.dim("none")}`;case"cancel":{const s=this.options.filter(({value:c})=>this.value.includes(c)).map(c=>n(c,"cancelled")).join(e.dim(", "));return`${r}${e.gray(o)} ${s.trim()?`${s}
|
||||
${e.gray(o)}`:""}`}case"error":{const s=this.error.split(`
|
||||
`).map((c,a)=>a===0?`${e.yellow(d)} ${e.yellow(c)}`:` ${c}`).join(`
|
||||
`);return`${r+e.yellow(o)} ${G({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:i}).join(`
|
||||
${e.yellow(o)} `)}
|
||||
${s}
|
||||
`}default:return`${r}${e.cyan(o)} ${G({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:i}).join(`
|
||||
${e.cyan(o)} `)}
|
||||
${e.cyan(d)}
|
||||
`}}}).prompt()},be=t=>{const{selectableGroups:n=!0}=t,r=(i,s,c=[])=>{const a=i.label??String(i.value),l=typeof i.group=="string",$=l&&(c[c.indexOf(i)+1]??{group:!0}),g=l&&$.group===!0,p=l?n?`${g?d:o} `:" ":"";if(s==="active")return`${e.dim(p)}${e.cyan(A)} ${a} ${i.hint?e.dim(`(${i.hint})`):""}`;if(s==="group-active")return`${p}${e.cyan(A)} ${e.dim(a)}`;if(s==="group-active-selected")return`${p}${e.green(T)} ${e.dim(a)}`;if(s==="selected"){const f=l||n?e.green(T):"";return`${e.dim(p)}${f} ${e.dim(a)} ${i.hint?e.dim(`(${i.hint})`):""}`}if(s==="cancelled")return`${e.strikethrough(e.dim(a))}`;if(s==="active-selected")return`${e.dim(p)}${e.green(T)} ${a} ${i.hint?e.dim(`(${i.hint})`):""}`;if(s==="submitted")return`${e.dim(a)}`;const v=l||n?e.dim(F):"";return`${e.dim(p)}${v} ${e.dim(a)}`};return new se({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,selectableGroups:n,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
|
||||
${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){const i=`${e.gray(o)}
|
||||
${b(this.state)} ${t.message}
|
||||
`;switch(this.state){case"submit":return`${i}${e.gray(o)} ${this.options.filter(({value:s})=>this.value.includes(s)).map(s=>r(s,"submitted")).join(e.dim(", "))}`;case"cancel":{const s=this.options.filter(({value:c})=>this.value.includes(c)).map(c=>r(c,"cancelled")).join(e.dim(", "));return`${i}${e.gray(o)} ${s.trim()?`${s}
|
||||
${e.gray(o)}`:""}`}case"error":{const s=this.error.split(`
|
||||
`).map((c,a)=>a===0?`${e.yellow(d)} ${e.yellow(c)}`:` ${c}`).join(`
|
||||
`);return`${i}${e.yellow(o)} ${this.options.map((c,a,l)=>{const $=this.value.includes(c.value)||c.group===!0&&this.isGroupSelected(`${c.value}`),g=a===this.cursor;return!g&&typeof c.group=="string"&&this.options[this.cursor].value===c.group?r(c,$?"group-active-selected":"group-active",l):g&&$?r(c,"active-selected",l):$?r(c,"selected",l):r(c,g?"active":"inactive",l)}).join(`
|
||||
${e.yellow(o)} `)}
|
||||
${s}
|
||||
`}default:return`${i}${e.cyan(o)} ${this.options.map((s,c,a)=>{const l=this.value.includes(s.value)||s.group===!0&&this.isGroupSelected(`${s.value}`),$=c===this.cursor;return!$&&typeof s.group=="string"&&this.options[this.cursor].value===s.group?r(s,l?"group-active-selected":"group-active",a):$&&l?r(s,"active-selected",a):l?r(s,"selected",a):r(s,$?"active":"inactive",a)}).join(`
|
||||
${e.cyan(o)} `)}
|
||||
${e.cyan(d)}
|
||||
`}}}).prompt()},Me=(t="",n="")=>{const r=`
|
||||
${t}
|
||||
`.split(`
|
||||
`),i=S(n).length,s=Math.max(r.reduce((a,l)=>{const $=S(l);return $.length>a?$.length:a},0),i)+2,c=r.map(a=>`${e.gray(o)} ${e.dim(a)}${" ".repeat(s-S(a).length)}${e.gray(o)}`).join(`
|
||||
`);process.stdout.write(`${e.gray(o)}
|
||||
${e.green(C)} ${e.reset(n)} ${e.gray(_.repeat(Math.max(s-i-1,1))+me)}
|
||||
${c}
|
||||
${e.gray(de+_.repeat(s+2)+pe)}
|
||||
`)},xe=(t="")=>{process.stdout.write(`${e.gray(d)} ${e.red(t)}
|
||||
|
||||
`)},Ie=(t="")=>{process.stdout.write(`${e.gray(ue)} ${t}
|
||||
`)},Se=(t="")=>{process.stdout.write(`${e.gray(o)}
|
||||
${e.gray(d)} ${t}
|
||||
|
||||
`)},M={message:(t="",{symbol:n=e.gray(o)}={})=>{const r=[`${e.gray(o)}`];if(t){const[i,...s]=t.split(`
|
||||
`);r.push(`${n} ${i}`,...s.map(c=>`${e.gray(o)} ${c}`))}process.stdout.write(`${r.join(`
|
||||
`)}
|
||||
`)},info:t=>{M.message(t,{symbol:e.blue(q)})},success:t=>{M.message(t,{symbol:e.green(D)})},step:t=>{M.message(t,{symbol:e.green(C)})},warn:t=>{M.message(t,{symbol:e.yellow(U)})},warning:t=>{M.warn(t)},error:t=>{M.message(t,{symbol:e.red(K)})}},J=`${e.gray(o)} `,x={message:async(t,{symbol:n=e.gray(o)}={})=>{process.stdout.write(`${e.gray(o)}
|
||||
${n} `);let r=3;for await(let i of t){i=i.replace(/\n/g,`
|
||||
${J}`),i.includes(`
|
||||
`)&&(r=3+S(i.slice(i.lastIndexOf(`
|
||||
`))).length);const s=S(i).length;r+s<process.stdout.columns?(r+=s,process.stdout.write(i)):(process.stdout.write(`
|
||||
${J}${i.trimStart()}`),r=3+S(i.trimStart()).length)}process.stdout.write(`
|
||||
`)},info:t=>x.message(t,{symbol:e.blue(q)}),success:t=>x.message(t,{symbol:e.green(D)}),step:t=>x.message(t,{symbol:e.green(C)}),warn:t=>x.message(t,{symbol:e.yellow(U)}),warning:t=>x.warn(t),error:t=>x.message(t,{symbol:e.red(K)})},Y=({indicator:t="dots"}={})=>{const n=V?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],r=V?80:120,i=process.env.CI==="true";let s,c,a=!1,l="",$,g=performance.now();const p=m=>{const h=m>1?"Something went wrong":"Canceled";a&&N(h,m)},v=()=>p(2),f=()=>p(1),j=()=>{process.on("uncaughtExceptionMonitor",v),process.on("unhandledRejection",v),process.on("SIGINT",f),process.on("SIGTERM",f),process.on("exit",p)},E=()=>{process.removeListener("uncaughtExceptionMonitor",v),process.removeListener("unhandledRejection",v),process.removeListener("SIGINT",f),process.removeListener("SIGTERM",f),process.removeListener("exit",p)},B=()=>{if($===void 0)return;i&&process.stdout.write(`
|
||||
`);const m=$.split(`
|
||||
`);process.stdout.write(oe.move(-999,m.length-1)),process.stdout.write(ae.down(m.length))},R=m=>m.replace(/\.+$/,""),O=m=>{const h=(performance.now()-m)/1e3,w=Math.floor(h/60),I=Math.floor(h%60);return w>0?`[${w}m ${I}s]`:`[${I}s]`},H=(m="")=>{a=!0,s=ne(),l=R(m),g=performance.now(),process.stdout.write(`${e.gray(o)}
|
||||
`);let h=0,w=0;j(),c=setInterval(()=>{if(i&&l===$)return;B(),$=l;const I=e.magenta(n[h]);if(i)process.stdout.write(`${I} ${l}...`);else if(t==="timer")process.stdout.write(`${I} ${l} ${O(g)}`);else{const z=".".repeat(Math.floor(w)).slice(0,3);process.stdout.write(`${I} ${l}${z}`)}h=h+1<n.length?h+1:0,w=w<n.length?w+.125:0},r)},N=(m="",h=0)=>{a=!1,clearInterval(c),B();const w=h===0?e.green(C):h===1?e.red(L):e.red(W);l=R(m??l),t==="timer"?process.stdout.write(`${w} ${l} ${O(g)}
|
||||
`):process.stdout.write(`${w} ${l}
|
||||
`),E(),s()};return{start:H,stop:N,message:(m="")=>{l=R(m??l)}}},Ce=async(t,n)=>{const r={},i=Object.keys(t);for(const s of i){const c=t[s],a=await c({results:r})?.catch(l=>{throw l});if(typeof n?.onCancel=="function"&&ie(a)){r[s]="canceled",n.onCancel({results:r});continue}r[s]=a}return r},Te=async t=>{for(const n of t){if(n.enabled===!1)continue;const r=Y();r.start(n.title);const i=await n.task(r.message);r.stop(i||n.title)}};export{xe as cancel,ye as confirm,Ce as group,be as groupMultiselect,Ie as intro,M as log,fe as multiselect,Me as note,Se as outro,ge as password,ve as select,we as selectKey,Y as spinner,x as stream,Te as tasks,he as text};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
+1
File diff suppressed because one or more lines are too long
+61
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "@clack/prompts",
|
||||
"version": "0.10.1",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"types": "./dist/index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/bombshell-dev/clack.git",
|
||||
"directory": "packages/prompts"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/bombshell-dev/clack/issues"
|
||||
},
|
||||
"homepage": "https://github.com/bombshell-dev/clack/tree/main/packages/prompts#readme",
|
||||
"files": [
|
||||
"dist",
|
||||
"CHANGELOG.md"
|
||||
],
|
||||
"author": {
|
||||
"name": "Nate Moore",
|
||||
"email": "nate@natemoo.re",
|
||||
"url": "https://twitter.com/n_moore"
|
||||
},
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"ask",
|
||||
"clack",
|
||||
"cli",
|
||||
"command-line",
|
||||
"command",
|
||||
"input",
|
||||
"interact",
|
||||
"interface",
|
||||
"menu",
|
||||
"prompt",
|
||||
"prompts",
|
||||
"stdin",
|
||||
"ui"
|
||||
],
|
||||
"dependencies": {
|
||||
"picocolors": "^1.0.0",
|
||||
"sisteransi": "^1.0.5",
|
||||
"@clack/core": "0.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"is-unicode-supported": "^1.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild"
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# esbuild
|
||||
|
||||
This is the macOS ARM 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
||||
BIN
Binary file not shown.
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@esbuild/darwin-arm64",
|
||||
"version": "0.28.0",
|
||||
"description": "The macOS ARM 64-bit binary for esbuild, a JavaScript bundler.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/evanw/esbuild.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"preferUnplugged": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64"
|
||||
]
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user