@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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -0
  3. package/dist/cli.d.ts +6 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +54 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/chargesCommand.d.ts +4 -0
  8. package/dist/commands/chargesCommand.d.ts.map +1 -0
  9. package/dist/commands/chargesCommand.js +121 -0
  10. package/dist/commands/chargesCommand.js.map +1 -0
  11. package/dist/commands/companyInfoCommand.d.ts +4 -0
  12. package/dist/commands/companyInfoCommand.d.ts.map +1 -0
  13. package/dist/commands/companyInfoCommand.js +123 -0
  14. package/dist/commands/companyInfoCommand.js.map +1 -0
  15. package/dist/commands/filingsCommand.d.ts +4 -0
  16. package/dist/commands/filingsCommand.d.ts.map +1 -0
  17. package/dist/commands/filingsCommand.js +93 -0
  18. package/dist/commands/filingsCommand.js.map +1 -0
  19. package/dist/commands/index.d.ts +4 -0
  20. package/dist/commands/index.d.ts.map +1 -0
  21. package/dist/commands/index.js +19 -0
  22. package/dist/commands/index.js.map +1 -0
  23. package/dist/commands/insolvencyCommand.d.ts +4 -0
  24. package/dist/commands/insolvencyCommand.d.ts.map +1 -0
  25. package/dist/commands/insolvencyCommand.js +48 -0
  26. package/dist/commands/insolvencyCommand.js.map +1 -0
  27. package/dist/commands/officersCommand.d.ts +4 -0
  28. package/dist/commands/officersCommand.d.ts.map +1 -0
  29. package/dist/commands/officersCommand.js +133 -0
  30. package/dist/commands/officersCommand.js.map +1 -0
  31. package/dist/commands/pscCommand.d.ts +4 -0
  32. package/dist/commands/pscCommand.d.ts.map +1 -0
  33. package/dist/commands/pscCommand.js +125 -0
  34. package/dist/commands/pscCommand.js.map +1 -0
  35. package/dist/commands/searchCompaniesCommand.d.ts +4 -0
  36. package/dist/commands/searchCompaniesCommand.d.ts.map +1 -0
  37. package/dist/commands/searchCompaniesCommand.js +76 -0
  38. package/dist/commands/searchCompaniesCommand.js.map +1 -0
  39. package/dist/commands/searchPeopleCommand.d.ts +4 -0
  40. package/dist/commands/searchPeopleCommand.d.ts.map +1 -0
  41. package/dist/commands/searchPeopleCommand.js +103 -0
  42. package/dist/commands/searchPeopleCommand.js.map +1 -0
  43. package/dist/commands/shared.d.ts +21 -0
  44. package/dist/commands/shared.d.ts.map +1 -0
  45. package/dist/commands/shared.js +86 -0
  46. package/dist/commands/shared.js.map +1 -0
  47. package/dist/lib/companiesHouseClient.d.ts +50 -0
  48. package/dist/lib/companiesHouseClient.d.ts.map +1 -0
  49. package/dist/lib/companiesHouseClient.js +119 -0
  50. package/dist/lib/companiesHouseClient.js.map +1 -0
  51. package/dist/lib/companyNumber.d.ts +2 -0
  52. package/dist/lib/companyNumber.d.ts.map +1 -0
  53. package/dist/lib/companyNumber.js +8 -0
  54. package/dist/lib/companyNumber.js.map +1 -0
  55. package/dist/lib/config.d.ts +10 -0
  56. package/dist/lib/config.d.ts.map +1 -0
  57. package/dist/lib/config.js +33 -0
  58. package/dist/lib/config.js.map +1 -0
  59. package/dist/lib/errors.d.ts +10 -0
  60. package/dist/lib/errors.d.ts.map +1 -0
  61. package/dist/lib/errors.js +26 -0
  62. package/dist/lib/errors.js.map +1 -0
  63. package/dist/lib/formatting.d.ts +19 -0
  64. package/dist/lib/formatting.d.ts.map +1 -0
  65. package/dist/lib/formatting.js +41 -0
  66. package/dist/lib/formatting.js.map +1 -0
  67. package/dist/lib/normalizers.d.ts +22 -0
  68. package/dist/lib/normalizers.d.ts.map +1 -0
  69. package/dist/lib/normalizers.js +235 -0
  70. package/dist/lib/normalizers.js.map +1 -0
  71. package/dist/lib/pagination.d.ts +15 -0
  72. package/dist/lib/pagination.d.ts.map +1 -0
  73. package/dist/lib/pagination.js +64 -0
  74. package/dist/lib/pagination.js.map +1 -0
  75. package/dist/types/api.d.ts +282 -0
  76. package/dist/types/api.d.ts.map +1 -0
  77. package/dist/types/api.js +2 -0
  78. package/dist/types/api.js.map +1 -0
  79. package/dist/types/cli.d.ts +27 -0
  80. package/dist/types/cli.d.ts.map +1 -0
  81. package/dist/types/cli.js +2 -0
  82. package/dist/types/cli.js.map +1 -0
  83. package/dist/types/normalized.d.ts +229 -0
  84. package/dist/types/normalized.d.ts.map +1 -0
  85. package/dist/types/normalized.js +2 -0
  86. package/dist/types/normalized.js.map +1 -0
  87. package/package.json +64 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insolvencyCommand.d.ts","sourceRoot":"","sources":["../../src/commands/insolvencyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AA+B3D,eAAO,MAAM,yBAAyB,GACpC,SAAS,OAAO,EAChB,cAAc,mBAAmB,KAChC,IA4BF,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { normalizeCompanyNumber } from "../lib/companyNumber.js";
2
+ import { renderKeyValueRows } from "../lib/formatting.js";
3
+ import { normalizeInsolvencyCases } from "../lib/normalizers.js";
4
+ import { executeCommand } from "./shared.js";
5
+ const renderInsolvencyHuman = (envelope) => {
6
+ if (envelope.data.cases.length === 0) {
7
+ return envelope.data.status
8
+ ? `No insolvency cases found.\nStatus: ${envelope.data.status}`
9
+ : "No insolvency cases found.";
10
+ }
11
+ const caseLines = envelope.data.cases.flatMap((insolvencyCase, index) => [
12
+ `${index + 1}. ${insolvencyCase.type ?? "Unknown case type"} | ${insolvencyCase.number ?? "No case number"}`,
13
+ ...renderKeyValueRows(insolvencyCase.caseDates.map((caseDate, caseDateIndex) => ({
14
+ label: ` Date ${caseDateIndex + 1}`,
15
+ value: `${caseDate.type ?? "unknown"}: ${caseDate.date ?? "unknown"}`
16
+ }))),
17
+ ...insolvencyCase.practitioners.map((practitioner, practitionerIndex) => ` Practitioner ${practitionerIndex + 1}: ${practitioner.name ?? "Unknown"} | ${practitioner.role ?? "role unknown"}`)
18
+ ]);
19
+ return [`Status: ${envelope.data.status ?? "unknown"}`, ...caseLines].join("\n");
20
+ };
21
+ export const registerInsolvencyCommand = (program, dependencies) => {
22
+ program
23
+ .command("insolvency <companyNumber>")
24
+ .description("Show insolvency information for a company.")
25
+ .action(async (companyNumber, _options, command) => {
26
+ const normalizedCompanyNumber = normalizeCompanyNumber(companyNumber);
27
+ await executeCommand({
28
+ command,
29
+ commandName: "insolvency",
30
+ dependencies,
31
+ execute: async ({ client }) => {
32
+ const insolvency = await client.getInsolvency(normalizedCompanyNumber);
33
+ return {
34
+ command: "insolvency",
35
+ data: {
36
+ cases: normalizeInsolvencyCases(insolvency),
37
+ status: insolvency?.status ?? null
38
+ },
39
+ input: {
40
+ companyNumber: normalizedCompanyNumber
41
+ }
42
+ };
43
+ },
44
+ renderHuman: renderInsolvencyHuman
45
+ });
46
+ });
47
+ };
48
+ //# sourceMappingURL=insolvencyCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insolvencyCommand.js","sourceRoot":"","sources":["../../src/commands/insolvencyCommand.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,qBAAqB,GAAG,CAAC,QAA4B,EAAU,EAAE;IACrE,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM;YACzB,CAAC,CAAC,uCAAuC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE;YAC/D,CAAC,CAAC,4BAA4B,CAAC;IACnC,CAAC;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;YACzB,YAAY;YACZ,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;gBAC5B,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;gBAEvE,OAAO;oBACL,OAAO,EAAE,YAAY;oBACrB,IAAI,EAAE;wBACJ,KAAK,EAAE,wBAAwB,CAAC,UAAU,CAAC;wBAC3C,MAAM,EAAE,UAAU,EAAE,MAAM,IAAI,IAAI;qBACnC;oBACD,KAAK,EAAE;wBACL,aAAa,EAAE,uBAAuB;qBACvC;iBAC2B,CAAC;YACjC,CAAC;YACD,WAAW,EAAE,qBAAqB;SACnC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { RuntimeDependencies } from "../types/cli.js";
3
+ export declare const registerOfficersCommand: (program: Command, dependencies: RuntimeDependencies) => void;
4
+ //# sourceMappingURL=officersCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"officersCommand.d.ts","sourceRoot":"","sources":["../../src/commands/officersCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AA6E3D,eAAO,MAAM,uBAAuB,GAClC,SAAS,OAAO,EAChB,cAAc,mBAAmB,KAChC,IAiFF,CAAC"}
@@ -0,0 +1,133 @@
1
+ import { formatDateOfBirth, renderKeyValueRows, renderPaginationSummary } from "../lib/formatting.js";
2
+ import { normalizeCompanyNumber } from "../lib/companyNumber.js";
3
+ import { normalizeOfficer } from "../lib/normalizers.js";
4
+ import { fetchPaginatedItems } from "../lib/pagination.js";
5
+ import { addListOptions, executeCommand, resolveListOptions } from "./shared.js";
6
+ const renderOfficersHuman = (envelope) => {
7
+ const summaryLines = [
8
+ renderPaginationSummary(envelope.pagination?.returnedCount ?? envelope.data.officers.length, envelope.pagination?.totalResults ?? null, envelope.pagination?.fetchedAll ?? false),
9
+ ...renderKeyValueRows([
10
+ {
11
+ label: "Active officers",
12
+ value: envelope.data.summary.activeCount !== null
13
+ ? String(envelope.data.summary.activeCount)
14
+ : null
15
+ },
16
+ {
17
+ label: "Resigned officers",
18
+ value: envelope.data.summary.resignedCount !== null
19
+ ? String(envelope.data.summary.resignedCount)
20
+ : null
21
+ }
22
+ ])
23
+ ];
24
+ const officerLines = envelope.data.officers.length === 0
25
+ ? ["No officers found."]
26
+ : envelope.data.officers.flatMap((officer, index) => [
27
+ `${index + 1}. ${officer.name ?? "Unknown officer"} | ${officer.officerRole ?? "role unknown"}`,
28
+ ...renderKeyValueRows([
29
+ {
30
+ label: " Appointed",
31
+ value: officer.appointedOn
32
+ },
33
+ {
34
+ label: " Resigned",
35
+ value: officer.resignedOn
36
+ },
37
+ {
38
+ label: " Occupation",
39
+ value: officer.occupation
40
+ },
41
+ {
42
+ label: " Nationality",
43
+ value: officer.nationality
44
+ },
45
+ {
46
+ label: " Date of birth",
47
+ value: formatDateOfBirth(officer.dateOfBirth)
48
+ },
49
+ {
50
+ label: " Address",
51
+ value: officer.address?.formatted ?? officer.principalOfficeAddress?.formatted ?? null
52
+ }
53
+ ])
54
+ ]);
55
+ return [...summaryLines, "", ...officerLines].join("\n");
56
+ };
57
+ export const registerOfficersCommand = (program, dependencies) => {
58
+ addListOptions(program
59
+ .command("officers <companyNumber>")
60
+ .description("List company officers.")
61
+ .option("--order-by <orderBy>", "Sort order to request from Companies House.")
62
+ .option("--register-type <registerType>", "Register type filter.")
63
+ .option("--register-view <registerView>", "Register view filter.")).action(async (companyNumber, options, command) => {
64
+ const normalizedCompanyNumber = normalizeCompanyNumber(companyNumber);
65
+ await executeCommand({
66
+ command,
67
+ commandName: "officers",
68
+ dependencies,
69
+ execute: async ({ client }) => {
70
+ const listOptions = resolveListOptions(options);
71
+ const firstPageSummary = await client.listOfficers({
72
+ companyNumber: normalizedCompanyNumber,
73
+ itemsPerPage: (listOptions.all ?? false)
74
+ ? listOptions.itemsPerPage ?? 100
75
+ : listOptions.itemsPerPage ?? 10,
76
+ startIndex: listOptions.startIndex ?? 0,
77
+ ...(options.orderBy !== undefined ? { orderBy: options.orderBy } : {}),
78
+ ...(options.registerType !== undefined
79
+ ? { registerType: options.registerType }
80
+ : {}),
81
+ ...(options.registerView !== undefined
82
+ ? { registerView: options.registerView }
83
+ : {})
84
+ });
85
+ const paginatedItems = listOptions.all
86
+ ? await fetchPaginatedItems({
87
+ fetchPage: ({ itemsPerPage, startIndex }) => client.listOfficers({
88
+ companyNumber: normalizedCompanyNumber,
89
+ itemsPerPage,
90
+ startIndex,
91
+ ...(options.orderBy !== undefined ? { orderBy: options.orderBy } : {}),
92
+ ...(options.registerType !== undefined
93
+ ? { registerType: options.registerType }
94
+ : {}),
95
+ ...(options.registerView !== undefined
96
+ ? { registerView: options.registerView }
97
+ : {})
98
+ }),
99
+ options: listOptions
100
+ })
101
+ : {
102
+ items: firstPageSummary.items ?? [],
103
+ pagination: {
104
+ fetchedAll: false,
105
+ itemsPerPage: listOptions.itemsPerPage ?? 10,
106
+ returnedCount: firstPageSummary.items?.length ?? 0,
107
+ startIndex: listOptions.startIndex ?? 0,
108
+ totalResults: firstPageSummary.total_results ?? null
109
+ }
110
+ };
111
+ return {
112
+ command: "officers",
113
+ data: {
114
+ officers: paginatedItems.items.map(normalizeOfficer),
115
+ summary: {
116
+ activeCount: firstPageSummary.active_count ?? null,
117
+ resignedCount: firstPageSummary.resigned_count ?? null
118
+ }
119
+ },
120
+ input: {
121
+ companyNumber: normalizedCompanyNumber,
122
+ orderBy: options.orderBy ?? null,
123
+ registerType: options.registerType ?? null,
124
+ registerView: options.registerView ?? null
125
+ },
126
+ pagination: paginatedItems.pagination
127
+ };
128
+ },
129
+ renderHuman: renderOfficersHuman
130
+ });
131
+ });
132
+ };
133
+ //# sourceMappingURL=officersCommand.js.map
@@ -0,0 +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AE;wBACL,aAAa,EAAE,uBAAuB;wBACtC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI;wBAChC,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI;wBAC1C,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI;qBAC3C;oBACD,UAAU,EAAE,cAAc,CAAC,UAAU;iBACX,CAAC;YAC/B,CAAC;YACD,WAAW,EAAE,mBAAmB;SACjC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { RuntimeDependencies } from "../types/cli.js";
3
+ export declare const registerPscCommand: (program: Command, dependencies: RuntimeDependencies) => void;
4
+ //# sourceMappingURL=pscCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pscCommand.d.ts","sourceRoot":"","sources":["../../src/commands/pscCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAazC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AA+E3D,eAAO,MAAM,kBAAkB,GAC7B,SAAS,OAAO,EAChB,cAAc,mBAAmB,KAChC,IAqEF,CAAC"}
@@ -0,0 +1,125 @@
1
+ import { normalizeCompanyNumber } from "../lib/companyNumber.js";
2
+ import { formatDateOfBirth, formatList, renderKeyValueRows, renderPaginationSummary } from "../lib/formatting.js";
3
+ import { normalizePsc } from "../lib/normalizers.js";
4
+ import { fetchPaginatedItems } from "../lib/pagination.js";
5
+ import { addListOptions, executeCommand, resolveListOptions } from "./shared.js";
6
+ const renderPscHuman = (envelope) => {
7
+ const summaryLines = [
8
+ renderPaginationSummary(envelope.pagination?.returnedCount ?? envelope.data.psc.length, envelope.pagination?.totalResults ?? null, envelope.pagination?.fetchedAll ?? false),
9
+ ...renderKeyValueRows([
10
+ {
11
+ label: "Active PSC entries",
12
+ value: envelope.data.summary.activeCount !== null
13
+ ? String(envelope.data.summary.activeCount)
14
+ : null
15
+ },
16
+ {
17
+ label: "Ceased PSC entries",
18
+ value: envelope.data.summary.ceasedCount !== null
19
+ ? String(envelope.data.summary.ceasedCount)
20
+ : null
21
+ }
22
+ ])
23
+ ];
24
+ const pscLines = envelope.data.psc.length === 0
25
+ ? ["No persons with significant control found."]
26
+ : envelope.data.psc.flatMap((psc, index) => [
27
+ `${index + 1}. ${psc.name ?? psc.description ?? "Unknown PSC"} | ${psc.kind ?? "kind unknown"}`,
28
+ ...renderKeyValueRows([
29
+ {
30
+ label: " Notified",
31
+ value: psc.notifiedOn
32
+ },
33
+ {
34
+ label: " Ceased",
35
+ value: psc.ceasedOn
36
+ },
37
+ {
38
+ label: " Nationality",
39
+ value: psc.nationality
40
+ },
41
+ {
42
+ label: " Country of residence",
43
+ value: psc.countryOfResidence
44
+ },
45
+ {
46
+ label: " Date of birth",
47
+ value: formatDateOfBirth(psc.dateOfBirth)
48
+ },
49
+ {
50
+ label: " Address",
51
+ value: psc.address?.formatted ?? psc.principalOfficeAddress?.formatted ?? null
52
+ },
53
+ {
54
+ label: " Natures of control",
55
+ value: formatList(psc.naturesOfControl)
56
+ }
57
+ ])
58
+ ]);
59
+ return [...summaryLines, "", ...pscLines].join("\n");
60
+ };
61
+ export const registerPscCommand = (program, dependencies) => {
62
+ addListOptions(program
63
+ .command("psc <companyNumber>")
64
+ .description("List persons with significant control for a company.")
65
+ .option("--register-view <registerView>", "Register view filter.")).action(async (companyNumber, options, command) => {
66
+ const normalizedCompanyNumber = normalizeCompanyNumber(companyNumber);
67
+ await executeCommand({
68
+ command,
69
+ commandName: "psc",
70
+ dependencies,
71
+ execute: async ({ client }) => {
72
+ const listOptions = resolveListOptions(options);
73
+ const firstPageSummary = await client.listPsc({
74
+ companyNumber: normalizedCompanyNumber,
75
+ itemsPerPage: (listOptions.all ?? false)
76
+ ? listOptions.itemsPerPage ?? 100
77
+ : listOptions.itemsPerPage ?? 10,
78
+ startIndex: listOptions.startIndex ?? 0,
79
+ ...(options.registerView !== undefined
80
+ ? { registerView: options.registerView }
81
+ : {})
82
+ });
83
+ const paginatedItems = listOptions.all
84
+ ? await fetchPaginatedItems({
85
+ fetchPage: ({ itemsPerPage, startIndex }) => client.listPsc({
86
+ companyNumber: normalizedCompanyNumber,
87
+ itemsPerPage,
88
+ startIndex,
89
+ ...(options.registerView !== undefined
90
+ ? { registerView: options.registerView }
91
+ : {})
92
+ }),
93
+ options: listOptions
94
+ })
95
+ : {
96
+ items: firstPageSummary.items ?? [],
97
+ pagination: {
98
+ fetchedAll: false,
99
+ itemsPerPage: listOptions.itemsPerPage ?? 10,
100
+ returnedCount: firstPageSummary.items?.length ?? 0,
101
+ startIndex: listOptions.startIndex ?? 0,
102
+ totalResults: firstPageSummary.total_results ?? null
103
+ }
104
+ };
105
+ return {
106
+ command: "psc",
107
+ data: {
108
+ psc: paginatedItems.items.map(normalizePsc),
109
+ summary: {
110
+ activeCount: firstPageSummary.active_count ?? null,
111
+ ceasedCount: firstPageSummary.ceased_count ?? null
112
+ }
113
+ },
114
+ input: {
115
+ companyNumber: normalizedCompanyNumber,
116
+ registerView: options.registerView ?? null
117
+ },
118
+ pagination: paginatedItems.pagination
119
+ };
120
+ },
121
+ renderHuman: renderPscHuman
122
+ });
123
+ });
124
+ };
125
+ //# sourceMappingURL=pscCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pscCommand.js","sourceRoot":"","sources":["../../src/commands/pscCommand.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAI3D,OAAO,EACL,cAAc,EACd,cAAc,EACd,kBAA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,gBAAgB,CAAC,aAAa,IAAI,IAAI;yBACrD;qBACF,CAAC;gBAEN,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,IAAI,EAAE;wBACJ,GAAG,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC;wBAC3C,OAAO,EAAE;4BACP,WAAW,EAAE,gBAAgB,CAAC,YAAY,IAAI,IAAI;4BAClD,WAAW,EAAE,gBAAgB,CAAC,YAAY,IAAI,IAAI;yBACnD;qBACF;oBACD,KAAK,EAAE;wBACL,aAAa,EAAE,uBAAuB;wBACtC,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI;qBAC3C;oBACD,UAAU,EAAE,cAAc,CAAC,UAAU;iBAChB,CAAC;YAC1B,CAAC;YACD,WAAW,EAAE,cAAc;SAC5B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { RuntimeDependencies } from "../types/cli.js";
3
+ export declare const registerSearchCompaniesCommand: (program: Command, dependencies: RuntimeDependencies) => void;
4
+ //# sourceMappingURL=searchCompaniesCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchCompaniesCommand.d.ts","sourceRoot":"","sources":["../../src/commands/searchCompaniesCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAuD3D,eAAO,MAAM,8BAA8B,GACzC,SAAS,OAAO,EAChB,cAAc,mBAAmB,KAChC,IA+CF,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { renderPaginationSummary, renderKeyValueRows } from "../lib/formatting.js";
2
+ import { normalizeCompanySearchResult } from "../lib/normalizers.js";
3
+ import { fetchPaginatedItems } from "../lib/pagination.js";
4
+ import { addListOptions, executeCommand, resolveListOptions } from "./shared.js";
5
+ const renderSearchCompaniesHuman = (envelope) => {
6
+ const companyLines = envelope.data.companies.length === 0
7
+ ? ["No companies found."]
8
+ : envelope.data.companies.flatMap((company, index) => [
9
+ `${index + 1}. ${company.name ?? "Unknown company"} (${company.companyNumber ?? "unknown"})`,
10
+ ...renderKeyValueRows([
11
+ {
12
+ label: " Status",
13
+ value: company.companyStatus
14
+ },
15
+ {
16
+ label: " Type",
17
+ value: company.companyType
18
+ },
19
+ {
20
+ label: " Created",
21
+ value: company.dateOfCreation
22
+ },
23
+ {
24
+ label: " Address",
25
+ value: company.address?.formatted ?? null
26
+ },
27
+ {
28
+ label: " Description",
29
+ value: company.description
30
+ }
31
+ ])
32
+ ]);
33
+ const summary = envelope.pagination
34
+ ? renderPaginationSummary(envelope.pagination.returnedCount, envelope.pagination.totalResults, envelope.pagination.fetchedAll)
35
+ : null;
36
+ return [summary, ...companyLines].filter((line) => line !== null).join("\n");
37
+ };
38
+ export const registerSearchCompaniesCommand = (program, dependencies) => {
39
+ addListOptions(program
40
+ .command("search <query>")
41
+ .description("Search companies by name.")
42
+ .option("--restrictions <restrictions>", "Search restrictions to pass through to Companies House.")).action(async (query, options, command) => {
43
+ await executeCommand({
44
+ command,
45
+ commandName: "search",
46
+ dependencies,
47
+ execute: async ({ client }) => {
48
+ const listOptions = resolveListOptions(options);
49
+ const result = await fetchPaginatedItems({
50
+ fetchPage: ({ itemsPerPage, startIndex }) => client.searchCompanies({
51
+ itemsPerPage,
52
+ query,
53
+ startIndex,
54
+ ...(options.restrictions !== undefined
55
+ ? { restrictions: options.restrictions }
56
+ : {})
57
+ }),
58
+ options: listOptions
59
+ });
60
+ return {
61
+ command: "search",
62
+ data: {
63
+ companies: result.items.map(normalizeCompanySearchResult)
64
+ },
65
+ input: {
66
+ query,
67
+ restrictions: options.restrictions ?? null
68
+ },
69
+ pagination: result.pagination
70
+ };
71
+ },
72
+ renderHuman: renderSearchCompaniesHuman
73
+ });
74
+ });
75
+ };
76
+ //# sourceMappingURL=searchCompaniesCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchCompaniesCommand.js","sourceRoot":"","sources":["../../src/commands/searchCompaniesCommand.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAI3D,OAAO,EACL,cAAc,EACd,cAAc,EACd,kBAAkB,EACnB,MAAM,aAAa,CAAC;AASrB,MAAM,0BAA0B,GAAG,CAAC,QAAiC,EAAU,EAAE;IAC/E,MAAM,YAAY,GAChB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;QAClC,CAAC,CAAC,CAAC,qBAAqB,CAAC;QACzB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC;YAClD,GAAG,KAAK,GAAG,CAAC,KAAK,OAAO,CAAC,IAAI,IAAI,iBAAiB,KAAK,OAAO,CAAC,aAAa,IAAI,SAAS,GAAG;YAC5F,GAAG,kBAAkB,CAAC;gBACpB;oBACE,KAAK,EAAE,WAAW;oBAClB,KAAK,EAAE,OAAO,CAAC,aAAa;iBAC7B;gBACD;oBACE,KAAK,EAAE,SAAS;oBAChB,KAAK,EAAE,OAAO,CAAC,WAAW;iBAC3B;gBACD;oBACE,KAAK,EAAE,YAAY;oBACnB,KAAK,EAAE,OAAO,CAAC,cAAc;iBAC9B;gBACD;oBACE,KAAK,EAAE,YAAY;oBACnB,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,IAAI,IAAI;iBAC1C;gBACD;oBACE,KAAK,EAAE,gBAAgB;oBACvB,KAAK,EAAE,OAAO,CAAC,WAAW;iBAC3B;aACF,CAAC;SACH,CAAC,CAAC;IAET,MAAM,OAAO,G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AC,CAAC;gBAEH,OAAO;oBACL,OAAO,EAAE,QAAQ;oBACjB,IAAI,EAAE;wBACJ,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,4BAA4B,CAAC;qBAC1D;oBACD,KAAK,EAAE;wBACL,KAAK;wBACL,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI;qBAC3C;oBACD,UAAU,EAAE,MAAM,CAAC,UAAU;iBACI,CAAC;YACtC,CAAC;YACD,WAAW,EAAE,0BAA0B;SACxC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Command } from "commander";
2
+ import type { RuntimeDependencies } from "../types/cli.js";
3
+ export declare const registerSearchPeopleCommand: (program: Command, dependencies: RuntimeDependencies) => void;
4
+ //# sourceMappingURL=searchPeopleCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchPeopleCommand.d.ts","sourceRoot":"","sources":["../../src/commands/searchPeopleCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAwE3D,eAAO,MAAM,2BAA2B,GACtC,SAAS,OAAO,EAChB,cAAc,mBAAmB,KAChC,IAoFF,CAAC"}
@@ -0,0 +1,103 @@
1
+ import { formatDateOfBirth, renderKeyValueRows, renderPaginationSummary } from "../lib/formatting.js";
2
+ import { extractOfficerId, normalizeOfficerAppointment, normalizePersonSearchResult } from "../lib/normalizers.js";
3
+ import { fetchPaginatedItems } from "../lib/pagination.js";
4
+ import { addListOptions, executeCommand, parsePositiveInteger, resolveListOptions } from "./shared.js";
5
+ const DEFAULT_MATCH_LIMIT = 10;
6
+ const renderSearchPeopleHuman = (envelope) => {
7
+ const summary = renderPaginationSummary(envelope.data.results.length, envelope.data.totalSearchHits, envelope.pagination?.fetchedAll ?? false);
8
+ const resultLines = envelope.data.results.length === 0
9
+ ? ["No matching people found."]
10
+ : envelope.data.results.flatMap((result, index) => {
11
+ const appointmentLines = result.appointments.length === 0
12
+ ? [" Appointments: none found"]
13
+ : result.appointments.map((appointment, appointmentIndex) => ` Appointment ${appointmentIndex + 1}: ${appointment.companyName ?? "Unknown company"} (${appointment.companyNumber ?? "unknown"}) | ${appointment.officerRole ?? "role unknown"} | appointed ${appointment.appointedOn ?? "unknown"}`);
14
+ return [
15
+ `${index + 1}. ${result.name ?? "Unknown person"}`,
16
+ ...renderKeyValueRows([
17
+ {
18
+ label: " Officer ID",
19
+ value: result.officerId
20
+ },
21
+ {
22
+ label: " Date of birth",
23
+ value: formatDateOfBirth(result.dateOfBirth)
24
+ },
25
+ {
26
+ label: " Appointment count",
27
+ value: result.appointmentCount !== null ? String(result.appointmentCount) : null
28
+ },
29
+ {
30
+ label: " Address",
31
+ value: result.address?.formatted ?? null
32
+ },
33
+ {
34
+ label: " Description",
35
+ value: result.description
36
+ }
37
+ ]),
38
+ ...appointmentLines
39
+ ];
40
+ });
41
+ return [summary, ...resultLines].join("\n");
42
+ };
43
+ export const registerSearchPeopleCommand = (program, dependencies) => {
44
+ addListOptions(program
45
+ .command("search-person <query>")
46
+ .description("Search officers and resolve their company appointments.")
47
+ .option("--match-limit <number>", "Number of officer matches to enrich with appointments.", parsePositiveInteger, DEFAULT_MATCH_LIMIT)).action(async (query, options, command) => {
48
+ await executeCommand({
49
+ command,
50
+ commandName: "search-person",
51
+ dependencies,
52
+ execute: async ({ client }) => {
53
+ const listOptions = resolveListOptions(options);
54
+ const searchResults = await fetchPaginatedItems({
55
+ fetchPage: ({ itemsPerPage, startIndex }) => client.searchOfficers({
56
+ itemsPerPage,
57
+ query,
58
+ startIndex
59
+ }),
60
+ options: listOptions
61
+ });
62
+ const matchLimit = options.matchLimit ?? DEFAULT_MATCH_LIMIT;
63
+ const officerMatchesToEnrich = searchResults.items.slice(0, matchLimit);
64
+ const enrichedResults = await Promise.all(officerMatchesToEnrich.map(async (officerSearchResult) => {
65
+ const selfLink = typeof officerSearchResult.links?.self === "string"
66
+ ? officerSearchResult.links.self
67
+ : undefined;
68
+ const officerId = extractOfficerId(selfLink);
69
+ if (!officerId) {
70
+ return normalizePersonSearchResult(officerSearchResult, []);
71
+ }
72
+ const appointments = await fetchPaginatedItems({
73
+ fetchPage: ({ itemsPerPage, startIndex }) => client.listOfficerAppointments({
74
+ itemsPerPage,
75
+ officerId,
76
+ startIndex
77
+ }),
78
+ options: {
79
+ all: true,
80
+ itemsPerPage: 100,
81
+ startIndex: 0
82
+ }
83
+ });
84
+ return normalizePersonSearchResult(officerSearchResult, appointments.items.map(normalizeOfficerAppointment));
85
+ }));
86
+ return {
87
+ command: "search-person",
88
+ data: {
89
+ results: enrichedResults,
90
+ totalSearchHits: searchResults.pagination.totalResults
91
+ },
92
+ input: {
93
+ matchLimit,
94
+ query
95
+ },
96
+ pagination: searchResults.pagination
97
+ };
98
+ },
99
+ renderHuman: renderSearchPeopleHuman
100
+ });
101
+ });
102
+ };
103
+ //# sourceMappingURL=searchPeopleCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchPeopleCommand.js","sourceRoot":"","sources":["../../src/commands/searchPeopleCommand.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAS3D,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAS/B,MAAM,uBAAuB,GAAG,CAAC,QAA8B,EAAU,EAAE;IACzE,MAAM,OAAO,GAAG,uBAAuB,CACrC,QAAQ,CA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CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { Command } from "commander";
2
+ import { type CompaniesHouseClient } from "../lib/companiesHouseClient.js";
3
+ import type { CommandEnvelope, ListCommandOptions, OutputMode, RuntimeDependencies } from "../types/cli.js";
4
+ export declare const createDefaultRuntimeDependencies: () => RuntimeDependencies;
5
+ export declare const parsePositiveInteger: (value: string) => number;
6
+ export declare const parseNonNegativeInteger: (value: string) => number;
7
+ export declare const addListOptions: (command: Command) => Command;
8
+ export declare const resolveListOptions: (options: ListCommandOptions) => ListCommandOptions;
9
+ export declare const resolveOutputMode: (command: Command) => OutputMode;
10
+ export interface CommandExecutionContext {
11
+ client: CompaniesHouseClient;
12
+ }
13
+ export interface ExecuteCommandOptions<TInput, TData> {
14
+ command: Command;
15
+ commandName: string;
16
+ dependencies: RuntimeDependencies;
17
+ execute: (context: CommandExecutionContext) => Promise<CommandEnvelope<TInput, TData>>;
18
+ renderHuman: (envelope: CommandEnvelope<TInput, TData>) => string;
19
+ }
20
+ export declare const executeCommand: <TInput, TData>({ command, dependencies, execute, renderHuman }: ExecuteCommandOptions<TInput, TData>) => Promise<void>;
21
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAC;AAGxC,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,gCAAgC,QAAO,mBAUlD,CAAC;AAEH,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,MAQpD,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,OAAO,MAAM,KAAG,MAQvD,CAAC;AAEF,eAAO,MAAM,cAAc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