@shan8851/companies-house-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +54 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/chargesCommand.d.ts +4 -0
- package/dist/commands/chargesCommand.d.ts.map +1 -0
- package/dist/commands/chargesCommand.js +121 -0
- package/dist/commands/chargesCommand.js.map +1 -0
- package/dist/commands/companyInfoCommand.d.ts +4 -0
- package/dist/commands/companyInfoCommand.d.ts.map +1 -0
- package/dist/commands/companyInfoCommand.js +123 -0
- package/dist/commands/companyInfoCommand.js.map +1 -0
- package/dist/commands/filingsCommand.d.ts +4 -0
- package/dist/commands/filingsCommand.d.ts.map +1 -0
- package/dist/commands/filingsCommand.js +93 -0
- package/dist/commands/filingsCommand.js.map +1 -0
- package/dist/commands/index.d.ts +4 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +19 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/insolvencyCommand.d.ts +4 -0
- package/dist/commands/insolvencyCommand.d.ts.map +1 -0
- package/dist/commands/insolvencyCommand.js +48 -0
- package/dist/commands/insolvencyCommand.js.map +1 -0
- package/dist/commands/officersCommand.d.ts +4 -0
- package/dist/commands/officersCommand.d.ts.map +1 -0
- package/dist/commands/officersCommand.js +133 -0
- package/dist/commands/officersCommand.js.map +1 -0
- package/dist/commands/pscCommand.d.ts +4 -0
- package/dist/commands/pscCommand.d.ts.map +1 -0
- package/dist/commands/pscCommand.js +125 -0
- package/dist/commands/pscCommand.js.map +1 -0
- package/dist/commands/searchCompaniesCommand.d.ts +4 -0
- package/dist/commands/searchCompaniesCommand.d.ts.map +1 -0
- package/dist/commands/searchCompaniesCommand.js +76 -0
- package/dist/commands/searchCompaniesCommand.js.map +1 -0
- package/dist/commands/searchPeopleCommand.d.ts +4 -0
- package/dist/commands/searchPeopleCommand.d.ts.map +1 -0
- package/dist/commands/searchPeopleCommand.js +103 -0
- package/dist/commands/searchPeopleCommand.js.map +1 -0
- package/dist/commands/shared.d.ts +21 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +86 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/lib/companiesHouseClient.d.ts +50 -0
- package/dist/lib/companiesHouseClient.d.ts.map +1 -0
- package/dist/lib/companiesHouseClient.js +119 -0
- package/dist/lib/companiesHouseClient.js.map +1 -0
- package/dist/lib/companyNumber.d.ts +2 -0
- package/dist/lib/companyNumber.d.ts.map +1 -0
- package/dist/lib/companyNumber.js +8 -0
- package/dist/lib/companyNumber.js.map +1 -0
- package/dist/lib/config.d.ts +10 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +33 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/errors.d.ts +10 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +26 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/formatting.d.ts +19 -0
- package/dist/lib/formatting.d.ts.map +1 -0
- package/dist/lib/formatting.js +41 -0
- package/dist/lib/formatting.js.map +1 -0
- package/dist/lib/normalizers.d.ts +22 -0
- package/dist/lib/normalizers.d.ts.map +1 -0
- package/dist/lib/normalizers.js +235 -0
- package/dist/lib/normalizers.js.map +1 -0
- package/dist/lib/pagination.d.ts +15 -0
- package/dist/lib/pagination.d.ts.map +1 -0
- package/dist/lib/pagination.js +64 -0
- package/dist/lib/pagination.js.map +1 -0
- package/dist/types/api.d.ts +282 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +2 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/cli.d.ts +27 -0
- package/dist/types/cli.d.ts.map +1 -0
- package/dist/types/cli.js +2 -0
- package/dist/types/cli.js.map +1 -0
- package/dist/types/normalized.d.ts +229 -0
- package/dist/types/normalized.d.ts.map +1 -0
- package/dist/types/normalized.js +2 -0
- package/dist/types/normalized.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# 🏛️ companies-house-cli
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@shan8851/companies-house-cli)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org)
|
|
6
|
+
|
|
7
|
+
UK company data in your terminal. Built for AI agents, still useful for humans.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ch search "Revolut" # Find companies by name
|
|
11
|
+
ch info 09215862 # Company profile
|
|
12
|
+
ch officers 09215862 # Directors & secretaries
|
|
13
|
+
ch filings 09215862 --type accounts # Filing history
|
|
14
|
+
ch psc 09215862 # Beneficial owners
|
|
15
|
+
ch search-person "Nik Storonsky" # Find a person across companies
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g @shan8851/companies-house-cli
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or from source:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/shan8851/companies-house-cli.git
|
|
28
|
+
cd companies-house-cli
|
|
29
|
+
pnpm install && pnpm build
|
|
30
|
+
pnpm link --global
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## API Key
|
|
34
|
+
|
|
35
|
+
A free API key is required. Takes 30 seconds:
|
|
36
|
+
|
|
37
|
+
1. Register at [developer.company-information.service.gov.uk](https://developer.company-information.service.gov.uk/)
|
|
38
|
+
2. Create an application → select **REST API key**
|
|
39
|
+
3. Set it:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
export COMPANIES_HOUSE_API_KEY=your_key
|
|
43
|
+
# or add to .env in your project directory
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Commands
|
|
47
|
+
|
|
48
|
+
| Command | What it does |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| `ch search <query>` | Search companies by name |
|
|
51
|
+
| `ch info <number>` | Company profile — address, status, SIC codes, incorporation date |
|
|
52
|
+
| `ch officers <number>` | Directors, secretaries, appointments |
|
|
53
|
+
| `ch filings <number>` | Filing history with optional `--type` filter and `--include-links` |
|
|
54
|
+
| `ch psc <number>` | Persons with significant control (beneficial owners) |
|
|
55
|
+
| `ch search-person <name>` | Find a person across all UK companies with appointment enrichment |
|
|
56
|
+
| `ch charges <number>` | Registered charges and mortgages |
|
|
57
|
+
| `ch insolvency <number>` | Insolvency case history |
|
|
58
|
+
|
|
59
|
+
Company numbers are automatically zero-padded — `9215862` becomes `09215862`.
|
|
60
|
+
|
|
61
|
+
All list commands support `--items-per-page`, `--start-index`, and `--all` for pagination.
|
|
62
|
+
|
|
63
|
+
## Agent Integration
|
|
64
|
+
|
|
65
|
+
Add `--json` to any command for stable normalized output.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
ch search "Revolut" --json
|
|
69
|
+
ch officers 09215862 --all --json | jq
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Every response uses a stable envelope:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"command": "officers",
|
|
77
|
+
"input": { "companyNumber": "09215862" },
|
|
78
|
+
"pagination": { "startIndex": 0, "itemsPerPage": 10, "totalResults": 12 },
|
|
79
|
+
"data": { "officers": [...] }
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Works with [OpenClaw](https://github.com/openclaw/openclaw), Claude Desktop MCP, or any agent that can shell out.
|
|
84
|
+
|
|
85
|
+
## Examples
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Quick company lookup
|
|
89
|
+
$ ch search "Monzo"
|
|
90
|
+
07446590 Monzo Bank Limited Active LONDON
|
|
91
|
+
10561407 Monzo Support Limited Active LONDON
|
|
92
|
+
|
|
93
|
+
# Who runs Revolut?
|
|
94
|
+
$ ch officers 09215862
|
|
95
|
+
Nikolay Storonsky Director Appointed 2015-07-01 Active
|
|
96
|
+
Vladyslav Yatsenko Director Appointed 2015-07-01 Active
|
|
97
|
+
Martin Gilbert Director Appointed 2021-09-01 Active
|
|
98
|
+
...
|
|
99
|
+
|
|
100
|
+
# Get latest accounts with download links
|
|
101
|
+
$ ch filings 09215862 --type accounts --include-links
|
|
102
|
+
2024-12-15 Full accounts accounts [PDF: https://...]
|
|
103
|
+
2023-12-14 Full accounts accounts [PDF: https://...]
|
|
104
|
+
...
|
|
105
|
+
|
|
106
|
+
# Find someone across all UK companies
|
|
107
|
+
$ ch search-person "Tim Cook"
|
|
108
|
+
Tim Cook Director Apple (UK) Limited (03288373)
|
|
109
|
+
Tim Cook Secretary Cook Ventures Ltd (12345678)
|
|
110
|
+
...
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Development
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
pnpm typecheck # Type check
|
|
117
|
+
pnpm lint # ESLint
|
|
118
|
+
pnpm test # Vitest
|
|
119
|
+
pnpm check # All of the above
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT — Built by [@shan8851](https://x.com/shan8851)
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import type { RuntimeDependencies } from "./types/cli.js";
|
|
4
|
+
export declare const createProgram: (dependencies: RuntimeDependencies) => Command;
|
|
5
|
+
export declare const runCli: (argv: string[], dependencies?: RuntimeDependencies) => Promise<number>;
|
|
6
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAIpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,eAAO,MAAM,aAAa,GAAI,cAAc,mBAAmB,KAAG,OAuBjE,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,MAAM,MAAM,EAAE,EACd,eAAc,mBAAwD,KACrE,OAAO,CAAC,MAAM,CAwBhB,CAAC"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { Command, CommanderError } from "commander";
|
|
4
|
+
import { registerCommands } from "./commands/index.js";
|
|
5
|
+
import { CliHandledError } from "./lib/errors.js";
|
|
6
|
+
import { createDefaultRuntimeDependencies } from "./commands/shared.js";
|
|
7
|
+
export const createProgram = (dependencies) => {
|
|
8
|
+
const program = new Command();
|
|
9
|
+
program
|
|
10
|
+
.name("ch")
|
|
11
|
+
.description("Agent-friendly UK Companies House CLI.")
|
|
12
|
+
.version("0.1.0")
|
|
13
|
+
.option("--json", "Emit normalized JSON output.")
|
|
14
|
+
.showHelpAfterError()
|
|
15
|
+
.showSuggestionAfterError()
|
|
16
|
+
.configureOutput({
|
|
17
|
+
writeErr: (text) => {
|
|
18
|
+
dependencies.writeStderr(text);
|
|
19
|
+
},
|
|
20
|
+
writeOut: (text) => {
|
|
21
|
+
dependencies.writeStdout(text);
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
.exitOverride();
|
|
25
|
+
registerCommands(program, dependencies);
|
|
26
|
+
return program;
|
|
27
|
+
};
|
|
28
|
+
export const runCli = async (argv, dependencies = createDefaultRuntimeDependencies()) => {
|
|
29
|
+
const program = createProgram(dependencies);
|
|
30
|
+
try {
|
|
31
|
+
await program.parseAsync(argv, {
|
|
32
|
+
from: "user"
|
|
33
|
+
});
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (error instanceof CliHandledError) {
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
if (error instanceof CommanderError) {
|
|
41
|
+
return error.exitCode;
|
|
42
|
+
}
|
|
43
|
+
dependencies.writeStderr(`Error: ${error instanceof Error ? error.message : "Unexpected error."}\n`);
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const isEntrypoint = process.argv[1] !== undefined && fileURLToPath(import.meta.url) === process.argv[1];
|
|
48
|
+
if (isEntrypoint) {
|
|
49
|
+
const dependencies = createDefaultRuntimeDependencies();
|
|
50
|
+
void runCli(process.argv.slice(2), dependencies).then((exitCode) => {
|
|
51
|
+
process.exitCode = exitCode;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAExE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,YAAiC,EAAW,EAAE;IAC1E,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,IAAI,CAAC;SACV,WAAW,CAAC,wCAAwC,CAAC;SACrD,OAAO,CAAC,OAAO,CAAC;SAChB,MAAM,CAAC,QAAQ,EAAE,8BAA8B,CAAC;SAChD,kBAAkB,EAAE;SACpB,wBAAwB,EAAE;SAC1B,eAAe,CAAC;QACf,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;YACjB,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QACD,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;YACjB,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;KACF,CAAC;SACD,YAAY,EAAE,CAAC;IAElB,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAExC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,KAA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AAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAqF3D,eAAO,MAAM,sBAAsB,GACjC,SAAS,OAAO,EAChB,cAAc,mBAAmB,KAChC,IA6DF,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { normalizeCompanyNumber } from "../lib/companyNumber.js";
|
|
2
|
+
import { formatList, renderKeyValueRows, renderPaginationSummary } from "../lib/formatting.js";
|
|
3
|
+
import { normalizeCharge } from "../lib/normalizers.js";
|
|
4
|
+
import { fetchPaginatedItems } from "../lib/pagination.js";
|
|
5
|
+
import { addListOptions, executeCommand, resolveListOptions } from "./shared.js";
|
|
6
|
+
const renderChargesHuman = (envelope) => {
|
|
7
|
+
const summaryLines = [
|
|
8
|
+
renderPaginationSummary(envelope.pagination?.returnedCount ?? envelope.data.charges.length, envelope.pagination?.totalResults ?? envelope.data.summary.totalCount, envelope.pagination?.fetchedAll ?? false),
|
|
9
|
+
...renderKeyValueRows([
|
|
10
|
+
{
|
|
11
|
+
label: "Total charges",
|
|
12
|
+
value: envelope.data.summary.totalCount !== null ? String(envelope.data.summary.totalCount) : null
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Satisfied",
|
|
16
|
+
value: envelope.data.summary.satisfiedCount !== null
|
|
17
|
+
? String(envelope.data.summary.satisfiedCount)
|
|
18
|
+
: null
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: "Part satisfied",
|
|
22
|
+
value: envelope.data.summary.partSatisfiedCount !== null
|
|
23
|
+
? String(envelope.data.summary.partSatisfiedCount)
|
|
24
|
+
: null
|
|
25
|
+
}
|
|
26
|
+
])
|
|
27
|
+
];
|
|
28
|
+
const chargeLines = envelope.data.charges.length === 0
|
|
29
|
+
? ["No charges found."]
|
|
30
|
+
: envelope.data.charges.flatMap((charge, index) => [
|
|
31
|
+
`${index + 1}. Charge ${charge.chargeCode ?? charge.chargeNumber ?? "unknown"} | ${charge.status ?? "status unknown"}`,
|
|
32
|
+
...renderKeyValueRows([
|
|
33
|
+
{
|
|
34
|
+
label: " Created",
|
|
35
|
+
value: charge.createdOn
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: " Delivered",
|
|
39
|
+
value: charge.deliveredOn
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: " Classification",
|
|
43
|
+
value: charge.classification
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: " Type",
|
|
47
|
+
value: charge.type
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: " Persons entitled",
|
|
51
|
+
value: formatList(charge.personsEntitled)
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: " Description",
|
|
55
|
+
value: charge.briefDescription
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: " Satisfied",
|
|
59
|
+
value: charge.satisfiedOn
|
|
60
|
+
}
|
|
61
|
+
])
|
|
62
|
+
]);
|
|
63
|
+
return [...summaryLines, "", ...chargeLines].join("\n");
|
|
64
|
+
};
|
|
65
|
+
export const registerChargesCommand = (program, dependencies) => {
|
|
66
|
+
addListOptions(program.command("charges <companyNumber>").description("List company charges.")).action(async (companyNumber, options, command) => {
|
|
67
|
+
const normalizedCompanyNumber = normalizeCompanyNumber(companyNumber);
|
|
68
|
+
await executeCommand({
|
|
69
|
+
command,
|
|
70
|
+
commandName: "charges",
|
|
71
|
+
dependencies,
|
|
72
|
+
execute: async ({ client }) => {
|
|
73
|
+
const listOptions = resolveListOptions(options);
|
|
74
|
+
const firstPageSummary = await client.listCharges({
|
|
75
|
+
companyNumber: normalizedCompanyNumber,
|
|
76
|
+
itemsPerPage: (listOptions.all ?? false)
|
|
77
|
+
? listOptions.itemsPerPage ?? 100
|
|
78
|
+
: listOptions.itemsPerPage ?? 10,
|
|
79
|
+
startIndex: listOptions.startIndex ?? 0
|
|
80
|
+
});
|
|
81
|
+
const paginatedItems = listOptions.all
|
|
82
|
+
? await fetchPaginatedItems({
|
|
83
|
+
fetchPage: ({ itemsPerPage, startIndex }) => client.listCharges({
|
|
84
|
+
companyNumber: normalizedCompanyNumber,
|
|
85
|
+
itemsPerPage,
|
|
86
|
+
startIndex
|
|
87
|
+
}),
|
|
88
|
+
options: listOptions
|
|
89
|
+
})
|
|
90
|
+
: {
|
|
91
|
+
items: firstPageSummary.items ?? [],
|
|
92
|
+
pagination: {
|
|
93
|
+
fetchedAll: false,
|
|
94
|
+
itemsPerPage: listOptions.itemsPerPage ?? 10,
|
|
95
|
+
returnedCount: firstPageSummary.items?.length ?? 0,
|
|
96
|
+
startIndex: listOptions.startIndex ?? 0,
|
|
97
|
+
totalResults: firstPageSummary.total_count ?? null
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
command: "charges",
|
|
102
|
+
data: {
|
|
103
|
+
charges: paginatedItems.items.map(normalizeCharge),
|
|
104
|
+
summary: {
|
|
105
|
+
partSatisfiedCount: firstPageSummary.part_satisfied_count ?? null,
|
|
106
|
+
satisfiedCount: firstPageSummary.satisfied_count ?? null,
|
|
107
|
+
totalCount: firstPageSummary.total_count ?? null,
|
|
108
|
+
unfilteredCount: firstPageSummary.unfiletered_count ?? null
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
input: {
|
|
112
|
+
companyNumber: normalizedCompanyNumber
|
|
113
|
+
},
|
|
114
|
+
pagination: paginatedItems.pagination
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
renderHuman: renderChargesHuman
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=chargesCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chargesCommand.js","sourceRoot":"","sources":["../../src/commands/chargesCommand.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EA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AAE,WAAW,CAAC,UAAU,IAAI,CAAC;4BACvC,YAAY,EAAE,gBAAgB,CAAC,WAAW,IAAI,IAAI;yBACnD;qBACF,CAAC;gBAEN,OAAO;oBACL,OAAO,EAAE,SAAS;oBAClB,IAAI,EAAE;wBACJ,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC;wBAClD,OAAO,EAAE;4BACP,kBAAkB,EAAE,gBAAgB,CAAC,oBAAoB,IAAI,IAAI;4BACjE,cAAc,EAAE,gBAAgB,CAAC,eAAe,IAAI,IAAI;4BACxD,UAAU,EAAE,gBAAgB,CAAC,WAAW,IAAI,IAAI;4BAChD,eAAe,EAAE,gBAAgB,CAAC,iBAAiB,IAAI,IAAI;yBAC5D;qBACF;oBACD,KAAK,EAAE;wBACL,aAAa,EAAE,uBAAuB;qBACvC;oBACD,UAAU,EAAE,cAAc,CAAC,UAAU;iBACZ,CAAC;YAC9B,CAAC;YACD,WAAW,EAAE,kBAAkB;SAChC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"companyInfoCommand.d.ts","sourceRoot":"","sources":["../../src/commands/companyInfoCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAyG3D,eAAO,MAAM,0BAA0B,GACrC,SAAS,OAAO,EAChB,cAAc,mBAAmB,KAChC,IAyBF,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { formatBoolean, formatList, renderKeyValueRows } from "../lib/formatting.js";
|
|
2
|
+
import { normalizeCompanyNumber } from "../lib/companyNumber.js";
|
|
3
|
+
import { normalizeCompanyProfile } from "../lib/normalizers.js";
|
|
4
|
+
import { executeCommand } from "./shared.js";
|
|
5
|
+
const renderCompanyInfoHuman = (envelope) => {
|
|
6
|
+
const company = envelope.data.company;
|
|
7
|
+
const lines = [
|
|
8
|
+
`${company.companyName ?? "Unknown company"} (${company.companyNumber ?? "unknown"})`,
|
|
9
|
+
...renderKeyValueRows([
|
|
10
|
+
{
|
|
11
|
+
label: "Status",
|
|
12
|
+
value: company.companyStatus
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Status detail",
|
|
16
|
+
value: company.companyStatusDetail
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: "Type",
|
|
20
|
+
value: company.type
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: "Subtype",
|
|
24
|
+
value: company.subtype
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: "Created",
|
|
28
|
+
value: company.dateOfCreation
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: "Cessation",
|
|
32
|
+
value: company.dateOfCessation
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: "Jurisdiction",
|
|
36
|
+
value: company.jurisdiction
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "Registered office",
|
|
40
|
+
value: company.registeredOfficeAddress?.formatted ?? null
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: "SIC codes",
|
|
44
|
+
value: formatList(company.sicCodes)
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: "Has charges",
|
|
48
|
+
value: formatBoolean(company.hasCharges, {
|
|
49
|
+
false: "No",
|
|
50
|
+
true: "Yes"
|
|
51
|
+
})
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: "Has insolvency history",
|
|
55
|
+
value: formatBoolean(company.hasInsolvencyHistory, {
|
|
56
|
+
false: "No",
|
|
57
|
+
true: "Yes"
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: "Next accounts due",
|
|
62
|
+
value: company.accounts.nextAccountsDueOn
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: "Next accounts made up to",
|
|
66
|
+
value: company.accounts.nextAccountsMadeUpTo
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
label: "Accounts overdue",
|
|
70
|
+
value: formatBoolean(company.accounts.overdue, {
|
|
71
|
+
false: "No",
|
|
72
|
+
true: "Yes"
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: "Next confirmation statement due",
|
|
77
|
+
value: company.confirmationStatement.nextDueOn
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
label: "Next confirmation made up to",
|
|
81
|
+
value: company.confirmationStatement.nextMadeUpTo
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
label: "Confirmation overdue",
|
|
85
|
+
value: formatBoolean(company.confirmationStatement.overdue, {
|
|
86
|
+
false: "No",
|
|
87
|
+
true: "Yes"
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
])
|
|
91
|
+
];
|
|
92
|
+
if (company.previousCompanyNames.length > 0) {
|
|
93
|
+
lines.push("Previous names:");
|
|
94
|
+
company.previousCompanyNames.forEach((previousCompanyName, index) => {
|
|
95
|
+
lines.push(` ${index + 1}. ${previousCompanyName.name ?? "Unknown"} | from ${previousCompanyName.effectiveFrom ?? "unknown"} | ceased ${previousCompanyName.ceasedOn ?? "unknown"}`);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return lines.join("\n");
|
|
99
|
+
};
|
|
100
|
+
export const registerCompanyInfoCommand = (program, dependencies) => {
|
|
101
|
+
program
|
|
102
|
+
.command("info <companyNumber>")
|
|
103
|
+
.description("Get the company profile for a company number.")
|
|
104
|
+
.action(async (companyNumber, _options, command) => {
|
|
105
|
+
const normalizedCompanyNumber = normalizeCompanyNumber(companyNumber);
|
|
106
|
+
await executeCommand({
|
|
107
|
+
command,
|
|
108
|
+
commandName: "info",
|
|
109
|
+
dependencies,
|
|
110
|
+
execute: async ({ client }) => ({
|
|
111
|
+
command: "info",
|
|
112
|
+
data: {
|
|
113
|
+
company: normalizeCompanyProfile(await client.getCompanyProfile(normalizedCompanyNumber))
|
|
114
|
+
},
|
|
115
|
+
input: {
|
|
116
|
+
companyNumber: normalizedCompanyNumber
|
|
117
|
+
}
|
|
118
|
+
}),
|
|
119
|
+
renderHuman: renderCompanyInfoHuman
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=companyInfoCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"companyInfoCommand.js","sourceRoot":"","sources":["../../src/commands/companyInfoCommand.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,UAAU,EACV,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,sBAAsB,GAAG,CAAC,QAA6B,EAAU,EAAE;IACvE,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;IACtC,MAAM,KAAK,GAAG;QACZ,GAAG,OAAO,CAAC,WAAW,IAAI,iBAAiB,KAAK,OAAO,CAAC,aAAa,IAAI,SAAS,GAAG;QACrF,GAAG,kBAAkB,CAAC;YACpB;gBACE,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,OAAO,CAAC,aAAa;aAC7B;YACD;gBACE,KAAK,EAAE,eAAe;gBACtB,KAAK,EAAE,OAAO,CAAC,mBAAmB;aACnC;YACD;gBACE,KAAK,EAAE,MAAM;gBACb,KAAK,EAAE,OAAO,CAAC,IAAI;aACpB;YACD;gBACE,KAAK,EAAE,SAAS;gBAChB,KAAK,EAAE,OAAO,CAAC,OAAO;aACvB;YACD;gBACE,KAAK,EAAE,SAAS;gBAChB,KAAK,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AAC,CACxD;iBACF;gBACD,KAAK,EAAE;oBACL,aAAa,EAAE,uBAAuB;iBACvC;aACF,CAAC;YACF,WAAW,EAAE,sBAAsB;SACpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filingsCommand.d.ts","sourceRoot":"","sources":["../../src/commands/filingsCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAQzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AA2E3D,eAAO,MAAM,sBAAsB,GACjC,SAAS,OAAO,EAChB,cAAc,mBAAmB,KAChC,IAuDF,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { CommanderError } from "commander";
|
|
2
|
+
import { normalizeCompanyNumber } from "../lib/companyNumber.js";
|
|
3
|
+
import { renderKeyValueRows, renderPaginationSummary } from "../lib/formatting.js";
|
|
4
|
+
import { normalizeFiling } from "../lib/normalizers.js";
|
|
5
|
+
import { fetchPaginatedItems } from "../lib/pagination.js";
|
|
6
|
+
import { addListOptions, executeCommand, resolveListOptions } from "./shared.js";
|
|
7
|
+
const resolveCategoryFilter = (options) => {
|
|
8
|
+
if (options.category && options.type && options.category !== options.type) {
|
|
9
|
+
throw new CommanderError(1, "command.invalidOption", "--category and --type must match when both are provided.");
|
|
10
|
+
}
|
|
11
|
+
return options.category ?? options.type;
|
|
12
|
+
};
|
|
13
|
+
const renderFilingsHuman = (envelope) => {
|
|
14
|
+
const summary = envelope.pagination
|
|
15
|
+
? renderPaginationSummary(envelope.pagination.returnedCount, envelope.pagination.totalResults, envelope.pagination.fetchedAll)
|
|
16
|
+
: null;
|
|
17
|
+
const filingLines = envelope.data.filings.length === 0
|
|
18
|
+
? ["No filings found."]
|
|
19
|
+
: envelope.data.filings.flatMap((filing, index) => [
|
|
20
|
+
`${index + 1}. ${filing.date ?? "unknown date"} | ${filing.type ?? "unknown type"} | ${filing.description ?? "No description"}`,
|
|
21
|
+
...renderKeyValueRows([
|
|
22
|
+
{
|
|
23
|
+
label: " Category",
|
|
24
|
+
value: filing.category
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: " Subcategory",
|
|
28
|
+
value: filing.subcategory
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: " Pages",
|
|
32
|
+
value: filing.pages !== null ? String(filing.pages) : null
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: " Transaction",
|
|
36
|
+
value: filing.transactionId
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: " Document metadata",
|
|
40
|
+
value: filing.documentMetadataUrl
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: " Document download",
|
|
44
|
+
value: filing.documentContentUrl
|
|
45
|
+
}
|
|
46
|
+
])
|
|
47
|
+
]);
|
|
48
|
+
return [summary, ...filingLines].filter((line) => line !== null).join("\n");
|
|
49
|
+
};
|
|
50
|
+
export const registerFilingsCommand = (program, dependencies) => {
|
|
51
|
+
addListOptions(program
|
|
52
|
+
.command("filings <companyNumber>")
|
|
53
|
+
.description("List filing history for a company.")
|
|
54
|
+
.option("--category <category>", "Comma-separated filing categories.")
|
|
55
|
+
.option("--include-links", "Include direct document content URLs derived from Companies House document metadata links.")
|
|
56
|
+
.option("--type <category>", "Alias for --category.")).action(async (companyNumber, options, command) => {
|
|
57
|
+
const normalizedCompanyNumber = normalizeCompanyNumber(companyNumber);
|
|
58
|
+
await executeCommand({
|
|
59
|
+
command,
|
|
60
|
+
commandName: "filings",
|
|
61
|
+
dependencies,
|
|
62
|
+
execute: async ({ client }) => {
|
|
63
|
+
const listOptions = resolveListOptions(options);
|
|
64
|
+
const category = resolveCategoryFilter(options);
|
|
65
|
+
const result = await fetchPaginatedItems({
|
|
66
|
+
fetchPage: ({ itemsPerPage, startIndex }) => client.listFilings({
|
|
67
|
+
companyNumber: normalizedCompanyNumber,
|
|
68
|
+
itemsPerPage,
|
|
69
|
+
startIndex,
|
|
70
|
+
...(category !== undefined ? { category } : {})
|
|
71
|
+
}),
|
|
72
|
+
options: listOptions
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
command: "filings",
|
|
76
|
+
data: {
|
|
77
|
+
filings: result.items.map((item) => normalizeFiling(item, {
|
|
78
|
+
includeLinks: options.includeLinks ?? false
|
|
79
|
+
}))
|
|
80
|
+
},
|
|
81
|
+
input: {
|
|
82
|
+
category: category ?? null,
|
|
83
|
+
companyNumber: normalizedCompanyNumber,
|
|
84
|
+
includeLinks: options.includeLinks ?? false
|
|
85
|
+
},
|
|
86
|
+
pagination: result.pagination
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
renderHuman: renderFilingsHuman
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=filingsCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filingsCommand.js","sourceRoot":"","sources":["../../src/commands/filingsCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,WAAW,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAI3D,OAAO,EACL,cAAc,EACd,cAAc,EACd,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAWrB,MAAM,qBAAqB,GAAG,CAAC,OAA8B,EAAsB,EAAE;IACnF,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1E,MA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ACtC,YAAY;wBACZ,UAAU;wBACV,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBAChD,CAAC;oBACJ,OAAO,EAAE,WAAW;iBACrB,CAAC,CAAC;gBAEH,OAAO;oBACL,OAAO,EAAE,SAAS;oBAClB,IAAI,EAAE;wBACJ,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACjC,eAAe,CAAC,IAAI,EAAE;4BACpB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK;yBAC5C,CAAC,CACH;qBACF;oBACD,KAAK,EAAE;wBACL,QAAQ,EAAE,QAAQ,IAAI,IAAI;wBAC1B,aAAa,EAAE,uBAAuB;wBACtC,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK;qBAC5C;oBACD,UAAU,EAAE,MAAM,CAAC,UAAU;iBACJ,CAAC;YAC9B,CAAC;YACD,WAAW,EAAE,kBAAkB;SAChC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAU3D,eAAO,MAAM,gBAAgB,GAC3B,SAAS,OAAO,EAChB,cAAc,mBAAmB,KAChC,IASF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { registerChargesCommand } from "./chargesCommand.js";
|
|
2
|
+
import { registerCompanyInfoCommand } from "./companyInfoCommand.js";
|
|
3
|
+
import { registerFilingsCommand } from "./filingsCommand.js";
|
|
4
|
+
import { registerInsolvencyCommand } from "./insolvencyCommand.js";
|
|
5
|
+
import { registerOfficersCommand } from "./officersCommand.js";
|
|
6
|
+
import { registerPscCommand } from "./pscCommand.js";
|
|
7
|
+
import { registerSearchCompaniesCommand } from "./searchCompaniesCommand.js";
|
|
8
|
+
import { registerSearchPeopleCommand } from "./searchPeopleCommand.js";
|
|
9
|
+
export const registerCommands = (program, dependencies) => {
|
|
10
|
+
registerSearchCompaniesCommand(program, dependencies);
|
|
11
|
+
registerCompanyInfoCommand(program, dependencies);
|
|
12
|
+
registerOfficersCommand(program, dependencies);
|
|
13
|
+
registerFilingsCommand(program, dependencies);
|
|
14
|
+
registerPscCommand(program, dependencies);
|
|
15
|
+
registerSearchPeopleCommand(program, dependencies);
|
|
16
|
+
registerChargesCommand(program, dependencies);
|
|
17
|
+
registerInsolvencyCommand(program, dependencies);
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAAgB,EAChB,YAAiC,EAC3B,EAAE;IACR,8BAA8B,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACtD,0BAA0B,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAClD,uBAAuB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC/C,sBAAsB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9C,kBAAkB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1C,2BAA2B,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnD,sBAAsB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9C,yBAAyB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACnD,CAAC,CAAC"}
|