open-local-audit 0.61.0 → 0.62.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/CHANGELOG.md +6 -0
- package/README.md +30 -0
- package/dist/cli.js +82 -164
- package/dist/cli.js.map +1 -1
- package/dist/discovery-runner.d.ts +27 -0
- package/dist/discovery-runner.js +134 -0
- package/dist/discovery-runner.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/shortlist-runner.d.ts +10 -0
- package/dist/shortlist-runner.js +24 -0
- package/dist/shortlist-runner.js.map +1 -0
- package/dist/workflow-config.d.ts +151 -0
- package/dist/workflow-config.js +104 -0
- package/dist/workflow-config.js.map +1 -0
- package/dist/workflow.d.ts +85 -0
- package/dist/workflow.js +403 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export { runLighthouseAudit } from "./lighthouse.js";
|
|
|
13
13
|
export { renderPdfReport } from "./pdf.js";
|
|
14
14
|
export { renderHtmlReport, renderJsonReport, renderMarkdownReport } from "./reporters.js";
|
|
15
15
|
export { buildLeadShortlist, readShortlistReviewCsv, renderShortlistCsv, renderShortlistJson, renderShortlistMarkdown, renderShortlistSummaryJson } from "./shortlist.js";
|
|
16
|
+
export { readWorkflowConfig } from "./workflow-config.js";
|
|
17
|
+
export { WorkflowRunError, runWorkflow, safeLeadSlug } from "./workflow.js";
|
|
16
18
|
export { renderTerminalSummary } from "./summary.js";
|
|
17
19
|
export type { BatchAuditContext, BatchIndexOptions, BatchInputEntry, BatchReportOptions, BatchReportResult, BatchCsvExportPreset, FailedBatchReportResult, SuccessfulBatchReportResult } from "./batch.js";
|
|
18
20
|
export type { DiscoveryAuditResult, DiscoveryProviderName, DiscoverySummary, DuplicateProspectGroup, FetchGooglePlacesCandidatesOptions, FuzzyDuplicateConfidence, FuzzyDuplicateProspectGroup, LeadReviewRow, LeadSuppressionEntry, PlaceCandidate, ProspectExportRow, ProspectCsvExportPreset, ProspectRowInput, ReadManualDiscoveryCsvOptions, WebsiteResolution } from "./discovery.js";
|
|
@@ -20,4 +22,6 @@ export type { ExportValidationFormat, ExportValidationIssue, ExportValidationPre
|
|
|
20
22
|
export type { ReportPackManifest, ReportPackOptions, ReportPackResult } from "./report-pack.js";
|
|
21
23
|
export type { ReviewBulkUpsertInput, ReviewBulkUpsertResult, ReviewStatus, ReviewUpsertAction, ReviewUpsertInput, ReviewUpsertResult } from "./review.js";
|
|
22
24
|
export type { ShortlistFormat, ShortlistLead, ShortlistOptions, ShortlistResult, ShortlistReviewRow, ShortlistSort } from "./shortlist.js";
|
|
25
|
+
export type { RawWorkflowConfig as WorkflowConfig, ResolvedWorkflowConfig } from "./workflow-config.js";
|
|
26
|
+
export type { WorkflowDependencies, WorkflowDiscoveryStageSummary, WorkflowPackageEntry, WorkflowPackageStatus, WorkflowPackageSummary, WorkflowPackagingStageSummary, WorkflowReviewStageSummary, WorkflowShortlistStageSummary, WorkflowStageName, WorkflowStageStatus, WorkflowStatus, WorkflowSummary } from "./workflow.js";
|
|
23
27
|
export type { AuditOptions, AuditProfile, AuditReport, AuditSummary, Evidence, Finding, FindingCategory, LighthouseCategoryScores, LighthouseRunner, LighthouseSummary, PublicContact, ReportBrandConfig, ReportRenderOptions, PageSnapshot, Score, Severity } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -13,5 +13,7 @@ export { runLighthouseAudit } from "./lighthouse.js";
|
|
|
13
13
|
export { renderPdfReport } from "./pdf.js";
|
|
14
14
|
export { renderHtmlReport, renderJsonReport, renderMarkdownReport } from "./reporters.js";
|
|
15
15
|
export { buildLeadShortlist, readShortlistReviewCsv, renderShortlistCsv, renderShortlistJson, renderShortlistMarkdown, renderShortlistSummaryJson } from "./shortlist.js";
|
|
16
|
+
export { readWorkflowConfig } from "./workflow-config.js";
|
|
17
|
+
export { WorkflowRunError, runWorkflow, safeLeadSlug } from "./workflow.js";
|
|
16
18
|
export { renderTerminalSummary } from "./summary.js";
|
|
17
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,2BAA2B,EAC3B,gCAAgC,EAChC,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,aAAa,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,2BAA2B,EAC3B,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE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AO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC1F,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ShortlistFormat, type ShortlistOptions, type ShortlistResult } from "./shortlist.js";
|
|
2
|
+
export interface ShortlistRunOptions {
|
|
3
|
+
input: string;
|
|
4
|
+
out: string;
|
|
5
|
+
summaryJson?: string;
|
|
6
|
+
reviewCsv?: string;
|
|
7
|
+
format: ShortlistFormat;
|
|
8
|
+
shortlist: Omit<ShortlistOptions, "reviewRows">;
|
|
9
|
+
}
|
|
10
|
+
export declare function runShortlistReport(options: ShortlistRunOptions): Promise<ShortlistResult>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { buildLeadShortlist, readShortlistReviewCsv, renderShortlistCsv, renderShortlistJson, renderShortlistMarkdown, renderShortlistSummaryJson } from "./shortlist.js";
|
|
4
|
+
export async function runShortlistReport(options) {
|
|
5
|
+
const input = await readFile(options.input, "utf8");
|
|
6
|
+
const reviewRows = options.reviewCsv ? readShortlistReviewCsv(await readFile(options.reviewCsv, "utf8")) : [];
|
|
7
|
+
const result = buildLeadShortlist(input, {
|
|
8
|
+
...options.shortlist,
|
|
9
|
+
reviewRows
|
|
10
|
+
});
|
|
11
|
+
const output = options.format === "json"
|
|
12
|
+
? renderShortlistJson(result)
|
|
13
|
+
: options.format === "csv"
|
|
14
|
+
? renderShortlistCsv(result)
|
|
15
|
+
: renderShortlistMarkdown(result);
|
|
16
|
+
await mkdir(dirname(options.out), { recursive: true });
|
|
17
|
+
await writeFile(options.out, output, "utf8");
|
|
18
|
+
if (options.summaryJson) {
|
|
19
|
+
await mkdir(dirname(options.summaryJson), { recursive: true });
|
|
20
|
+
await writeFile(options.summaryJson, renderShortlistSummaryJson(result), "utf8");
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=shortlist-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortlist-runner.js","sourceRoot":"","sources":["../src/shortlist-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,0BAA0B,EAI3B,MAAM,gBAAgB,CAAC;AAWxB,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAA4B;IACnE,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACpD,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9G,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,EAAE;QACvC,GAAG,OAAO,CAAC,SAAS;QACpB,UAAU;KACX,CAAC,CAAC;IAEH,MAAM,MAAM,GACV,OAAO,CAAC,MAAM,KAAK,MAAM;QACvB,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC;QAC7B,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,KAAK;YACxB,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC;YAC5B,CAAC,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAExC,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7C,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,MAAM,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,0BAA0B,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IACnF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const workflowConfigSchema: z.ZodObject<{
|
|
3
|
+
version: z.ZodLiteral<1>;
|
|
4
|
+
outDir: z.ZodString;
|
|
5
|
+
discovery: z.ZodDiscriminatedUnion<"provider", [z.ZodObject<{
|
|
6
|
+
profile: z.ZodDefault<z.ZodEnum<["generic", "dental", "beauty", "restaurant", "contractor", "lawyer", "clinic", "gym", "hotel", "auto-service"]>>;
|
|
7
|
+
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
maxAudits: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
provider: z.ZodLiteral<"manual-csv">;
|
|
10
|
+
input: z.ZodString;
|
|
11
|
+
}, "strict", z.ZodTypeAny, {
|
|
12
|
+
profile: "generic" | "dental" | "beauty" | "restaurant" | "contractor" | "lawyer" | "clinic" | "gym" | "hotel" | "auto-service";
|
|
13
|
+
input: string;
|
|
14
|
+
concurrency: number;
|
|
15
|
+
provider: "manual-csv";
|
|
16
|
+
maxAudits?: number | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
input: string;
|
|
19
|
+
provider: "manual-csv";
|
|
20
|
+
profile?: "generic" | "dental" | "beauty" | "restaurant" | "contractor" | "lawyer" | "clinic" | "gym" | "hotel" | "auto-service" | undefined;
|
|
21
|
+
concurrency?: number | undefined;
|
|
22
|
+
maxAudits?: number | undefined;
|
|
23
|
+
}>, z.ZodObject<{
|
|
24
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
25
|
+
profile: z.ZodDefault<z.ZodEnum<["generic", "dental", "beauty", "restaurant", "contractor", "lawyer", "clinic", "gym", "hotel", "auto-service"]>>;
|
|
26
|
+
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
27
|
+
maxAudits: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
provider: z.ZodLiteral<"google-places">;
|
|
29
|
+
query: z.ZodString;
|
|
30
|
+
}, "strict", z.ZodTypeAny, {
|
|
31
|
+
profile: "generic" | "dental" | "beauty" | "restaurant" | "contractor" | "lawyer" | "clinic" | "gym" | "hotel" | "auto-service";
|
|
32
|
+
concurrency: number;
|
|
33
|
+
provider: "google-places";
|
|
34
|
+
limit: number;
|
|
35
|
+
query: string;
|
|
36
|
+
maxAudits?: number | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
provider: "google-places";
|
|
39
|
+
query: string;
|
|
40
|
+
profile?: "generic" | "dental" | "beauty" | "restaurant" | "contractor" | "lawyer" | "clinic" | "gym" | "hotel" | "auto-service" | undefined;
|
|
41
|
+
concurrency?: number | undefined;
|
|
42
|
+
limit?: number | undefined;
|
|
43
|
+
maxAudits?: number | undefined;
|
|
44
|
+
}>]>;
|
|
45
|
+
shortlist: z.ZodObject<{
|
|
46
|
+
top: z.ZodDefault<z.ZodNumber>;
|
|
47
|
+
minOpportunityScore: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
sort: z.ZodDefault<z.ZodEnum<["opportunity-desc", "score-desc", "company-asc", "last-reviewed-asc", "contact-confidence-desc", "priority-desc", "source-asc"]>>;
|
|
49
|
+
}, "strict", z.ZodTypeAny, {
|
|
50
|
+
sort: "opportunity-desc" | "score-desc" | "company-asc" | "last-reviewed-asc" | "contact-confidence-desc" | "priority-desc" | "source-asc";
|
|
51
|
+
top: number;
|
|
52
|
+
minOpportunityScore?: number | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
sort?: "opportunity-desc" | "score-desc" | "company-asc" | "last-reviewed-asc" | "contact-confidence-desc" | "priority-desc" | "source-asc" | undefined;
|
|
55
|
+
top?: number | undefined;
|
|
56
|
+
minOpportunityScore?: number | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
review: z.ZodOptional<z.ZodObject<{
|
|
59
|
+
csv: z.ZodString;
|
|
60
|
+
staleBefore: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
61
|
+
}, "strict", z.ZodTypeAny, {
|
|
62
|
+
csv: string;
|
|
63
|
+
staleBefore?: string | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
csv: string;
|
|
66
|
+
staleBefore?: string | undefined;
|
|
67
|
+
}>>;
|
|
68
|
+
packageReports: z.ZodDefault<z.ZodBoolean>;
|
|
69
|
+
}, "strict", z.ZodTypeAny, {
|
|
70
|
+
outDir: string;
|
|
71
|
+
version: 1;
|
|
72
|
+
discovery: {
|
|
73
|
+
profile: "generic" | "dental" | "beauty" | "restaurant" | "contractor" | "lawyer" | "clinic" | "gym" | "hotel" | "auto-service";
|
|
74
|
+
input: string;
|
|
75
|
+
concurrency: number;
|
|
76
|
+
provider: "manual-csv";
|
|
77
|
+
maxAudits?: number | undefined;
|
|
78
|
+
} | {
|
|
79
|
+
profile: "generic" | "dental" | "beauty" | "restaurant" | "contractor" | "lawyer" | "clinic" | "gym" | "hotel" | "auto-service";
|
|
80
|
+
concurrency: number;
|
|
81
|
+
provider: "google-places";
|
|
82
|
+
limit: number;
|
|
83
|
+
query: string;
|
|
84
|
+
maxAudits?: number | undefined;
|
|
85
|
+
};
|
|
86
|
+
shortlist: {
|
|
87
|
+
sort: "opportunity-desc" | "score-desc" | "company-asc" | "last-reviewed-asc" | "contact-confidence-desc" | "priority-desc" | "source-asc";
|
|
88
|
+
top: number;
|
|
89
|
+
minOpportunityScore?: number | undefined;
|
|
90
|
+
};
|
|
91
|
+
packageReports: boolean;
|
|
92
|
+
review?: {
|
|
93
|
+
csv: string;
|
|
94
|
+
staleBefore?: string | undefined;
|
|
95
|
+
} | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
outDir: string;
|
|
98
|
+
version: 1;
|
|
99
|
+
discovery: {
|
|
100
|
+
input: string;
|
|
101
|
+
provider: "manual-csv";
|
|
102
|
+
profile?: "generic" | "dental" | "beauty" | "restaurant" | "contractor" | "lawyer" | "clinic" | "gym" | "hotel" | "auto-service" | undefined;
|
|
103
|
+
concurrency?: number | undefined;
|
|
104
|
+
maxAudits?: number | undefined;
|
|
105
|
+
} | {
|
|
106
|
+
provider: "google-places";
|
|
107
|
+
query: string;
|
|
108
|
+
profile?: "generic" | "dental" | "beauty" | "restaurant" | "contractor" | "lawyer" | "clinic" | "gym" | "hotel" | "auto-service" | undefined;
|
|
109
|
+
concurrency?: number | undefined;
|
|
110
|
+
limit?: number | undefined;
|
|
111
|
+
maxAudits?: number | undefined;
|
|
112
|
+
};
|
|
113
|
+
shortlist: {
|
|
114
|
+
sort?: "opportunity-desc" | "score-desc" | "company-asc" | "last-reviewed-asc" | "contact-confidence-desc" | "priority-desc" | "source-asc" | undefined;
|
|
115
|
+
top?: number | undefined;
|
|
116
|
+
minOpportunityScore?: number | undefined;
|
|
117
|
+
};
|
|
118
|
+
review?: {
|
|
119
|
+
csv: string;
|
|
120
|
+
staleBefore?: string | undefined;
|
|
121
|
+
} | undefined;
|
|
122
|
+
packageReports?: boolean | undefined;
|
|
123
|
+
}>;
|
|
124
|
+
export type RawWorkflowConfig = z.input<typeof workflowConfigSchema>;
|
|
125
|
+
type ParsedWorkflowConfig = z.output<typeof workflowConfigSchema>;
|
|
126
|
+
export interface WorkflowManagedPaths {
|
|
127
|
+
leadsCsv: string;
|
|
128
|
+
discoverySummaryJson: string;
|
|
129
|
+
shortlistCsv: string;
|
|
130
|
+
shortlistSummaryJson: string;
|
|
131
|
+
reviewSummaryJson: string;
|
|
132
|
+
workflowSummaryJson: string;
|
|
133
|
+
reportsDir: string;
|
|
134
|
+
packagesDir: string;
|
|
135
|
+
}
|
|
136
|
+
export type ResolvedWorkflowConfig = Omit<ParsedWorkflowConfig, "outDir" | "discovery" | "review"> & {
|
|
137
|
+
outDir: string;
|
|
138
|
+
discovery: (Extract<ParsedWorkflowConfig["discovery"], {
|
|
139
|
+
provider: "manual-csv";
|
|
140
|
+
}> & {
|
|
141
|
+
input: string;
|
|
142
|
+
}) | Extract<ParsedWorkflowConfig["discovery"], {
|
|
143
|
+
provider: "google-places";
|
|
144
|
+
}>;
|
|
145
|
+
review?: ParsedWorkflowConfig["review"] & {
|
|
146
|
+
csv: string;
|
|
147
|
+
};
|
|
148
|
+
paths: WorkflowManagedPaths;
|
|
149
|
+
};
|
|
150
|
+
export declare function readWorkflowConfig(configPath: string): Promise<ResolvedWorkflowConfig>;
|
|
151
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { auditProfileSchema } from "./schema.js";
|
|
5
|
+
const nonblankStringSchema = z.string().trim().min(1);
|
|
6
|
+
const discoveryDefaults = {
|
|
7
|
+
profile: auditProfileSchema.default("generic"),
|
|
8
|
+
concurrency: z.number().int().positive().default(1),
|
|
9
|
+
maxAudits: z.number().int().min(0).optional()
|
|
10
|
+
};
|
|
11
|
+
const manualDiscoverySchema = z
|
|
12
|
+
.object({
|
|
13
|
+
provider: z.literal("manual-csv"),
|
|
14
|
+
input: nonblankStringSchema,
|
|
15
|
+
...discoveryDefaults
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
18
|
+
const googleDiscoverySchema = z
|
|
19
|
+
.object({
|
|
20
|
+
provider: z.literal("google-places"),
|
|
21
|
+
query: nonblankStringSchema,
|
|
22
|
+
...discoveryDefaults,
|
|
23
|
+
limit: z.number().int().positive().max(50).default(10)
|
|
24
|
+
})
|
|
25
|
+
.strict();
|
|
26
|
+
const shortlistSortValues = [
|
|
27
|
+
"opportunity-desc",
|
|
28
|
+
"score-desc",
|
|
29
|
+
"company-asc",
|
|
30
|
+
"last-reviewed-asc",
|
|
31
|
+
"contact-confidence-desc",
|
|
32
|
+
"priority-desc",
|
|
33
|
+
"source-asc"
|
|
34
|
+
];
|
|
35
|
+
function assertNoMissingShortlistSort() { }
|
|
36
|
+
assertNoMissingShortlistSort();
|
|
37
|
+
const shortlistSchema = z
|
|
38
|
+
.object({
|
|
39
|
+
top: z.number().int().positive().default(20),
|
|
40
|
+
minOpportunityScore: z.number().int().min(0).max(100).optional(),
|
|
41
|
+
sort: z.enum(shortlistSortValues).default("opportunity-desc")
|
|
42
|
+
})
|
|
43
|
+
.strict();
|
|
44
|
+
const calendarDateSchema = z.string().refine((value) => {
|
|
45
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const parsed = Date.parse(`${value}T00:00:00.000Z`);
|
|
49
|
+
return Number.isFinite(parsed) && new Date(parsed).toISOString().slice(0, 10) === value;
|
|
50
|
+
}, "Expected a real calendar date in YYYY-MM-DD format");
|
|
51
|
+
const reviewSchema = z
|
|
52
|
+
.object({
|
|
53
|
+
csv: nonblankStringSchema,
|
|
54
|
+
staleBefore: calendarDateSchema.optional()
|
|
55
|
+
})
|
|
56
|
+
.strict();
|
|
57
|
+
const workflowConfigSchema = z
|
|
58
|
+
.object({
|
|
59
|
+
version: z.literal(1),
|
|
60
|
+
outDir: nonblankStringSchema,
|
|
61
|
+
discovery: z.discriminatedUnion("provider", [manualDiscoverySchema, googleDiscoverySchema]),
|
|
62
|
+
shortlist: shortlistSchema,
|
|
63
|
+
review: reviewSchema.optional(),
|
|
64
|
+
packageReports: z.boolean().default(false)
|
|
65
|
+
})
|
|
66
|
+
.strict();
|
|
67
|
+
export async function readWorkflowConfig(configPath) {
|
|
68
|
+
const absoluteConfigPath = resolve(configPath);
|
|
69
|
+
const configDirectory = dirname(absoluteConfigPath);
|
|
70
|
+
const content = await readFile(absoluteConfigPath, "utf8");
|
|
71
|
+
let rawConfig;
|
|
72
|
+
try {
|
|
73
|
+
rawConfig = JSON.parse(content);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (error instanceof SyntaxError) {
|
|
77
|
+
throw new Error(`Workflow config ${absoluteConfigPath} contains invalid JSON`, { cause: error });
|
|
78
|
+
}
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
const config = workflowConfigSchema.parse(rawConfig);
|
|
82
|
+
const outDir = resolve(configDirectory, config.outDir);
|
|
83
|
+
return {
|
|
84
|
+
...config,
|
|
85
|
+
outDir,
|
|
86
|
+
discovery: config.discovery.provider === "manual-csv"
|
|
87
|
+
? { ...config.discovery, input: resolve(configDirectory, config.discovery.input) }
|
|
88
|
+
: config.discovery,
|
|
89
|
+
...(config.review
|
|
90
|
+
? { review: { ...config.review, csv: resolve(configDirectory, config.review.csv) } }
|
|
91
|
+
: {}),
|
|
92
|
+
paths: {
|
|
93
|
+
leadsCsv: join(outDir, "leads.csv"),
|
|
94
|
+
discoverySummaryJson: join(outDir, "discovery-summary.json"),
|
|
95
|
+
shortlistCsv: join(outDir, "shortlist.csv"),
|
|
96
|
+
shortlistSummaryJson: join(outDir, "shortlist-summary.json"),
|
|
97
|
+
reviewSummaryJson: join(outDir, "review-summary.json"),
|
|
98
|
+
workflowSummaryJson: join(outDir, "workflow-summary.json"),
|
|
99
|
+
reportsDir: join(outDir, "reports"),
|
|
100
|
+
packagesDir: join(outDir, "packages")
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=workflow-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-config.js","sourceRoot":"","sources":["../src/workflow-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEtD,MAAM,iBAAiB,GAAG;IACxB,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAAC;IAC9C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC9C,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC;KAC5B,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IACjC,KAAK,EAAE,oBAAoB;IAC3B,GAAG,iBAAiB;CACrB,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,qBAAqB,GAAG,CAAC;KAC5B,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IACpC,KAAK,EAAE,oBAAoB;IAC3B,GAAG,iBAAiB;IACpB,KA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AS,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAEvD,OAAO;QACL,GAAG,MAAM;QACT,MAAM;QACN,SAAS,EACP,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,YAAY;YACxC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAClF,CAAC,CAAC,MAAM,CAAC,SAAS;QACtB,GAAG,CAAC,MAAM,CAAC,MAAM;YACf,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE;YACpF,CAAC,CAAC,EAAE,CAAC;QACP,KAAK,EAAE;YACL,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC;YACnC,oBAAoB,EAAE,IAAI,CAAC,MAAM,EAAE,wBAAwB,CAAC;YAC5D,YAAY,EAAE,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC;YAC3C,oBAAoB,EAAE,IAAI,CAAC,MAAM,EAAE,wBAAwB,CAAC;YAC5D,iBAAiB,EAAE,IAAI,CAAC,MAAM,EAAE,qBAAqB,CAAC;YACtD,mBAAmB,EAAE,IAAI,CAAC,MAAM,EAAE,uBAAuB,CAAC;YAC1D,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC;YACnC,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC;SACtC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { runDiscovery, type DiscoveryRunResult } from "./discovery-runner.js";
|
|
2
|
+
import { packageReport, type ReportPackResult } from "./report-pack.js";
|
|
3
|
+
import { summarizeReviewCsvFile } from "./review.js";
|
|
4
|
+
import { type ShortlistRunOptions } from "./shortlist-runner.js";
|
|
5
|
+
import type { ShortlistResult } from "./shortlist.js";
|
|
6
|
+
import { resolveGoogleMapsApiKey } from "./secrets.js";
|
|
7
|
+
import { readWorkflowConfig, type ResolvedWorkflowConfig, type WorkflowManagedPaths } from "./workflow-config.js";
|
|
8
|
+
export type WorkflowStatus = "success" | "failed";
|
|
9
|
+
export type WorkflowStageStatus = "success" | "failed" | "skipped" | "not-run";
|
|
10
|
+
export type WorkflowStageName = "discovery" | "shortlist" | "review" | "packaging";
|
|
11
|
+
export type WorkflowPackageStatus = "packaged" | "skipped" | "failed";
|
|
12
|
+
export interface WorkflowDiscoveryStageSummary {
|
|
13
|
+
status: WorkflowStageStatus;
|
|
14
|
+
totalCandidates?: number;
|
|
15
|
+
suppressedCandidates?: number;
|
|
16
|
+
audited?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface WorkflowShortlistStageSummary {
|
|
19
|
+
status: WorkflowStageStatus;
|
|
20
|
+
totalRows?: number;
|
|
21
|
+
suppressedRows?: number;
|
|
22
|
+
filteredRows?: number;
|
|
23
|
+
selected?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface WorkflowReviewStageSummary {
|
|
26
|
+
status: WorkflowStageStatus;
|
|
27
|
+
totalRows?: number;
|
|
28
|
+
reviewedRows?: number;
|
|
29
|
+
actionableLeads?: number;
|
|
30
|
+
staleRows?: number;
|
|
31
|
+
invalidReviewedAtRows?: number;
|
|
32
|
+
unreviewedRows?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface WorkflowPackagingStageSummary {
|
|
35
|
+
status: WorkflowStageStatus;
|
|
36
|
+
packaged?: number;
|
|
37
|
+
skipped?: number;
|
|
38
|
+
failed?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface WorkflowPackageEntry {
|
|
41
|
+
leadKey: string;
|
|
42
|
+
companyName: string;
|
|
43
|
+
status: WorkflowPackageStatus;
|
|
44
|
+
outDir?: string;
|
|
45
|
+
error?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface WorkflowPackageSummary {
|
|
48
|
+
packaged: number;
|
|
49
|
+
skipped: number;
|
|
50
|
+
failed: number;
|
|
51
|
+
entries: WorkflowPackageEntry[];
|
|
52
|
+
}
|
|
53
|
+
export interface WorkflowSummary {
|
|
54
|
+
version: 1;
|
|
55
|
+
status: WorkflowStatus;
|
|
56
|
+
stages: {
|
|
57
|
+
discovery: WorkflowDiscoveryStageSummary;
|
|
58
|
+
shortlist: WorkflowShortlistStageSummary;
|
|
59
|
+
review: WorkflowReviewStageSummary;
|
|
60
|
+
packaging: WorkflowPackagingStageSummary;
|
|
61
|
+
};
|
|
62
|
+
outputs: WorkflowManagedPaths;
|
|
63
|
+
discoveredLeads: number;
|
|
64
|
+
selectedLeads: number;
|
|
65
|
+
packages: WorkflowPackageSummary;
|
|
66
|
+
error?: {
|
|
67
|
+
stage: WorkflowStageName;
|
|
68
|
+
message: string;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface WorkflowDependencies {
|
|
72
|
+
readWorkflowConfig: typeof readWorkflowConfig;
|
|
73
|
+
runDiscovery: (options: Parameters<typeof runDiscovery>[0]) => Promise<DiscoveryRunResult>;
|
|
74
|
+
runShortlistReport: (options: ShortlistRunOptions) => Promise<ShortlistResult>;
|
|
75
|
+
summarizeReviewCsvFile: typeof summarizeReviewCsvFile;
|
|
76
|
+
packageReport: (options: Parameters<typeof packageReport>[0]) => Promise<ReportPackResult>;
|
|
77
|
+
resolveGoogleMapsApiKey: typeof resolveGoogleMapsApiKey;
|
|
78
|
+
}
|
|
79
|
+
export declare class WorkflowRunError extends Error {
|
|
80
|
+
readonly summary: WorkflowSummary;
|
|
81
|
+
constructor(summary: WorkflowSummary);
|
|
82
|
+
}
|
|
83
|
+
export declare function safeLeadSlug(leadKey: string, companyName: string): string;
|
|
84
|
+
export declare function runWorkflow(configPath: string, dependencies?: Partial<WorkflowDependencies>): Promise<WorkflowSummary>;
|
|
85
|
+
export declare function runResolvedWorkflow(config: ResolvedWorkflowConfig, dependencies?: Partial<WorkflowDependencies>): Promise<WorkflowSummary>;
|