@tenhaw/usecase-register 0.0.0-bootstrap
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/LICENSE-CONTENT +15 -0
- package/README.md +37 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +86 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tenhaw
|
|
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/LICENSE-CONTENT
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Tenhaw AI Readiness Framework and authored framework content in spec/content
|
|
2
|
+
are licensed under the Creative Commons Attribution 4.0 International licence.
|
|
3
|
+
Copyright (c) 2026 Tenhaw.
|
|
4
|
+
|
|
5
|
+
Licence: https://creativecommons.org/licenses/by/4.0/
|
|
6
|
+
Legal code: https://creativecommons.org/licenses/by/4.0/legalcode.en
|
|
7
|
+
|
|
8
|
+
When sharing or adapting this content, provide appropriate credit, a licence
|
|
9
|
+
link, and an indication of changes. A suitable credit is:
|
|
10
|
+
"Tenhaw AI Readiness Framework, CC BY 4.0, https://tenhaw.com."
|
|
11
|
+
|
|
12
|
+
Numerical results and user-supplied evidence remain the user's material.
|
|
13
|
+
The optional audit promotion can be suppressed independently of applicable
|
|
14
|
+
framework-content credits. Code is MIT; third-party sources retain their own
|
|
15
|
+
rights and are summarised with links rather than relicensed here.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
> Setup prerelease: `0.0.0-bootstrap`, intended for the `bootstrap` dist-tag.
|
|
2
|
+
> This package contains the actual built Tenhaw Kit code and establishes npm ownership before trusted publishing is configured. Use a verified stable release for regular installation. Hosted endpoints and stable release verification are separate setup steps.
|
|
3
|
+
|
|
4
|
+
# @tenhaw/usecase-register
|
|
5
|
+
|
|
6
|
+
Prioritise a validated AI use-case register with explicit governance gates.
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
|
|
10
|
+
- Use this when building an AI programme register, value/feasibility matrix or governed portfolio.
|
|
11
|
+
- Do not use this for automatically approving high-risk or prohibited applications.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @tenhaw/usecase-register
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { prioritiseUseCases, exportRegister } from '@tenhaw/usecase-register';
|
|
23
|
+
const register = prioritiseUseCases({ useCases: [] });
|
|
24
|
+
console.log(exportRegister(register, 'json'));
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
`prioritiseUseCases({useCases})` (alias `generateUsecaseRegister`), `exportRegister(report,"json"|"csv"|"md")`, `exportCsv(input)`, `parseRegisterCsv(csv)`. CSV supports quoted multiline text and structured JSON cells; potentially executable spreadsheet cells are neutralised.
|
|
30
|
+
|
|
31
|
+
## Methodology and sources
|
|
32
|
+
|
|
33
|
+
Priority = value (0 to 5) multiplied by feasibility (0 to 5). Governance gates take precedence: prohibited uses are blocked; high and unknown risk require review; other use cases follow standard review. Ties resolve by ID. Risk labels are indicative, not legal advice. Transparency and high-risk obligations can overlap. EU AI Act source: https://digital-strategy.ec.europa.eu/en/policies/regulatory-framework-ai. Dependencies must reference other use cases in the same register.
|
|
34
|
+
|
|
35
|
+
## Built by Tenhaw
|
|
36
|
+
|
|
37
|
+
Tenhaw is a founder-led UK AI consultancy and venture studio. For expert help applying this, [book an AI readiness audit](https://tenhaw.com/contact?utm_source=npm&utm_medium=readme&utm_campaign=tenhaw-kit&utm_content=usecase-register#book).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
type UseCase = {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
problem: string;
|
|
5
|
+
ownerRole: string;
|
|
6
|
+
businessUnit: string;
|
|
7
|
+
value: number;
|
|
8
|
+
feasibility: number;
|
|
9
|
+
riskTier: 'prohibited' | 'high' | 'limited' | 'minimal' | 'unknown';
|
|
10
|
+
status: 'idea' | 'assessed' | 'approved' | 'PoC' | 'pilot' | 'production' | 'retired';
|
|
11
|
+
dataRequired?: string[];
|
|
12
|
+
dataSensitivity?: 'public' | 'internal' | 'confidential' | 'restricted';
|
|
13
|
+
valueHypothesis?: string;
|
|
14
|
+
valueEstimate?: Record<string, unknown>;
|
|
15
|
+
dependencies?: string[];
|
|
16
|
+
kpis?: string[];
|
|
17
|
+
reviewDate?: string;
|
|
18
|
+
};
|
|
19
|
+
declare function prioritiseUseCases(input: {
|
|
20
|
+
useCases: UseCase[];
|
|
21
|
+
}): {
|
|
22
|
+
useCases: {
|
|
23
|
+
priority: number;
|
|
24
|
+
governanceGate: string;
|
|
25
|
+
id: string;
|
|
26
|
+
title: string;
|
|
27
|
+
problem: string;
|
|
28
|
+
ownerRole: string;
|
|
29
|
+
businessUnit: string;
|
|
30
|
+
value: number;
|
|
31
|
+
feasibility: number;
|
|
32
|
+
riskTier: "prohibited" | "high" | "limited" | "minimal" | "unknown";
|
|
33
|
+
status: "idea" | "assessed" | "approved" | "PoC" | "pilot" | "production" | "retired";
|
|
34
|
+
dataRequired?: string[];
|
|
35
|
+
dataSensitivity?: "public" | "internal" | "confidential" | "restricted";
|
|
36
|
+
valueHypothesis?: string;
|
|
37
|
+
valueEstimate?: Record<string, unknown>;
|
|
38
|
+
dependencies?: string[];
|
|
39
|
+
kpis?: string[];
|
|
40
|
+
reviewDate?: string;
|
|
41
|
+
}[];
|
|
42
|
+
methodology: string;
|
|
43
|
+
limitations: string[];
|
|
44
|
+
};
|
|
45
|
+
declare const generateUsecaseRegister: typeof prioritiseUseCases;
|
|
46
|
+
type UsecaseRegister = ReturnType<typeof prioritiseUseCases>;
|
|
47
|
+
declare function exportRegister(report: UsecaseRegister, format: 'json' | 'csv' | 'md'): string;
|
|
48
|
+
declare function parseRegisterCsv(csv: string): {
|
|
49
|
+
useCases: UseCase[];
|
|
50
|
+
};
|
|
51
|
+
declare function exportCsv(input: {
|
|
52
|
+
useCases: UseCase[];
|
|
53
|
+
} | UsecaseRegister): string;
|
|
54
|
+
|
|
55
|
+
export { type UseCase, type UsecaseRegister, exportCsv, exportRegister, generateUsecaseRegister, parseRegisterCsv, prioritiseUseCases };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { invariant, round, validateInput, escapeHtml } from "@tenhaw/core";
|
|
3
|
+
function prioritiseUseCases(input) {
|
|
4
|
+
const register = validateInput("usecase-register", input);
|
|
5
|
+
const ids = new Set(register.useCases.map((u) => u.id));
|
|
6
|
+
invariant(ids.size === register.useCases.length, "/useCases", "IDs must be unique");
|
|
7
|
+
for (const u of register.useCases) for (const dependency of u.dependencies ?? []) invariant(ids.has(dependency) && dependency !== u.id, `/useCases/${u.id}/dependencies`, "Dependencies must reference another use case in this register");
|
|
8
|
+
const useCases = register.useCases.map((u) => ({ ...u, priority: round(u.value * u.feasibility), governanceGate: u.riskTier === "prohibited" ? "blocked" : u.riskTier === "high" || u.riskTier === "unknown" ? "review-required" : "standard-review" })).sort((a, b) => {
|
|
9
|
+
const order = { "standard-review": 0, "review-required": 1, blocked: 2 };
|
|
10
|
+
return order[a.governanceGate] - order[b.governanceGate] || b.priority - a.priority || a.id.localeCompare(b.id);
|
|
11
|
+
});
|
|
12
|
+
return { useCases, methodology: "Priority = value (0 to 5) multiplied by feasibility (0 to 5). Governance gates take precedence over score.", limitations: ["Risk tiers are indicative, not legal advice.", "Transparency obligations can apply alongside high-risk obligations.", "Prohibited uses are blocked pending qualified legal review."] };
|
|
13
|
+
}
|
|
14
|
+
var generateUsecaseRegister = prioritiseUseCases;
|
|
15
|
+
function safeCell(value) {
|
|
16
|
+
let text = typeof value === "object" ? JSON.stringify(value) : String(value ?? "");
|
|
17
|
+
if (/^'|^\s*[=+\-@]|^[\t\r]/.test(text)) text = "'" + text;
|
|
18
|
+
return `"${text.replaceAll('"', '""')}"`;
|
|
19
|
+
}
|
|
20
|
+
var fields = ["id", "title", "problem", "ownerRole", "businessUnit", "value", "feasibility", "riskTier", "status", "dataRequired", "dataSensitivity", "valueHypothesis", "valueEstimate", "dependencies", "kpis", "reviewDate", "priority", "governanceGate"];
|
|
21
|
+
function exportRegister(report, format) {
|
|
22
|
+
if (format === "json") return JSON.stringify(report, null, 2);
|
|
23
|
+
if (format === "csv") return [fields.join(","), ...report.useCases.map((u) => fields.map((k) => safeCell(u[k])).join(","))].join("\r\n") + "\r\n";
|
|
24
|
+
const escape = (x) => escapeHtml(String(x ?? "")).replaceAll("|", "\\|").replaceAll("\n", " ");
|
|
25
|
+
return ["| " + fields.join(" | ") + " |", "| " + fields.map(() => "---").join(" | ") + " |", ...report.useCases.map((u) => "| " + fields.map((k) => escape(u[k])).join(" | ") + " |")].join("\n") + "\n";
|
|
26
|
+
}
|
|
27
|
+
function parseRegisterCsv(csv) {
|
|
28
|
+
const rows = [];
|
|
29
|
+
let row = [], cell = "", quoted = false;
|
|
30
|
+
for (let i = 0; i < csv.length; i++) {
|
|
31
|
+
const c = csv[i];
|
|
32
|
+
if (c === '"') {
|
|
33
|
+
if (quoted && csv[i + 1] === '"') {
|
|
34
|
+
cell += '"';
|
|
35
|
+
i++;
|
|
36
|
+
} else quoted = !quoted;
|
|
37
|
+
} else if (c === "," && !quoted) {
|
|
38
|
+
row.push(cell);
|
|
39
|
+
cell = "";
|
|
40
|
+
} else if ((c === "\r" || c === "\n") && !quoted) {
|
|
41
|
+
if (c === "\r" && csv[i + 1] === "\n") i++;
|
|
42
|
+
row.push(cell);
|
|
43
|
+
if (row.some(Boolean)) rows.push(row);
|
|
44
|
+
row = [];
|
|
45
|
+
cell = "";
|
|
46
|
+
} else cell += c;
|
|
47
|
+
}
|
|
48
|
+
invariant(!quoted, "/csv", "Unclosed quoted CSV field");
|
|
49
|
+
if (cell || row.length) {
|
|
50
|
+
row.push(cell);
|
|
51
|
+
rows.push(row);
|
|
52
|
+
}
|
|
53
|
+
const headers = rows.shift() ?? [];
|
|
54
|
+
invariant(new Set(headers).size === headers.length, "/csv", "Duplicate column names");
|
|
55
|
+
const useCases = rows.map((values, index) => {
|
|
56
|
+
invariant(values.length === headers.length, `/csv/${index + 2}`, "Column count differs from header");
|
|
57
|
+
const item = {};
|
|
58
|
+
headers.forEach((key, i) => {
|
|
59
|
+
if (!fields.includes(key) || key === "priority" || key === "governanceGate") return;
|
|
60
|
+
let value = values[i];
|
|
61
|
+
if (value.startsWith("'") && /^'|^\s*[=+\-@]|^[\t\r]/.test(value.slice(1))) value = value.slice(1);
|
|
62
|
+
if (value === "") return;
|
|
63
|
+
if (key === "value" || key === "feasibility") item[key] = Number(value);
|
|
64
|
+
else if (["dataRequired", "valueEstimate", "dependencies", "kpis"].includes(key)) {
|
|
65
|
+
try {
|
|
66
|
+
item[key] = JSON.parse(value);
|
|
67
|
+
} catch {
|
|
68
|
+
invariant(false, `/csv/${index + 2}/${key}`, "Expected JSON in structured CSV cell");
|
|
69
|
+
}
|
|
70
|
+
} else item[key] = value;
|
|
71
|
+
});
|
|
72
|
+
return item;
|
|
73
|
+
});
|
|
74
|
+
validateInput("usecase-register", { useCases });
|
|
75
|
+
return { useCases };
|
|
76
|
+
}
|
|
77
|
+
function exportCsv(input) {
|
|
78
|
+
return exportRegister(prioritiseUseCases(input), "csv");
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
exportCsv,
|
|
82
|
+
exportRegister,
|
|
83
|
+
generateUsecaseRegister,
|
|
84
|
+
parseRegisterCsv,
|
|
85
|
+
prioritiseUseCases
|
|
86
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tenhaw/usecase-register",
|
|
3
|
+
"version": "0.0.0-bootstrap",
|
|
4
|
+
"description": "Validated AI use-case registers with transparent prioritisation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"LICENSE-CONTENT"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup src/index.ts --format esm --dts",
|
|
22
|
+
"test": "vitest run --passWithNoTests",
|
|
23
|
+
"typecheck": "tsc --noEmit"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@tenhaw/core": "0.0.0-bootstrap"
|
|
27
|
+
},
|
|
28
|
+
"author": "Tenhaw (https://tenhaw.com)",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/Tenhaw/tenhaw-kit.git",
|
|
33
|
+
"directory": "packages/usecase-register"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://kit.tenhaw.com/tools/usecase-register",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public",
|
|
38
|
+
"tag": "bootstrap",
|
|
39
|
+
"provenance": false
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=22"
|
|
43
|
+
}
|
|
44
|
+
}
|