business-as-code 0.2.1 → 2.0.2
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/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +17 -0
- package/IMPLEMENTATION.md +226 -0
- package/README.md +1133 -193
- package/dist/business.d.ts +62 -0
- package/dist/business.d.ts.map +1 -0
- package/dist/business.js +109 -0
- package/dist/business.js.map +1 -0
- package/dist/dollar.d.ts +60 -0
- package/dist/dollar.d.ts.map +1 -0
- package/dist/dollar.js +107 -0
- package/dist/dollar.js.map +1 -0
- package/dist/entities/assets.d.ts +21 -0
- package/dist/entities/assets.d.ts.map +1 -0
- package/dist/entities/assets.js +323 -0
- package/dist/entities/assets.js.map +1 -0
- package/dist/entities/business.d.ts +36 -0
- package/dist/entities/business.d.ts.map +1 -0
- package/dist/entities/business.js +370 -0
- package/dist/entities/business.js.map +1 -0
- package/dist/entities/communication.d.ts +21 -0
- package/dist/entities/communication.d.ts.map +1 -0
- package/dist/entities/communication.js +255 -0
- package/dist/entities/communication.js.map +1 -0
- package/dist/entities/customers.d.ts +58 -0
- package/dist/entities/customers.d.ts.map +1 -0
- package/dist/entities/customers.js +989 -0
- package/dist/entities/customers.js.map +1 -0
- package/dist/entities/financials.d.ts +59 -0
- package/dist/entities/financials.d.ts.map +1 -0
- package/dist/entities/financials.js +932 -0
- package/dist/entities/financials.js.map +1 -0
- package/dist/entities/goals.d.ts +58 -0
- package/dist/entities/goals.d.ts.map +1 -0
- package/dist/entities/goals.js +800 -0
- package/dist/entities/goals.js.map +1 -0
- package/dist/entities/index.d.ts +299 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +198 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/entities/legal.d.ts +21 -0
- package/dist/entities/legal.d.ts.map +1 -0
- package/dist/entities/legal.js +301 -0
- package/dist/entities/legal.js.map +1 -0
- package/dist/entities/market.d.ts +21 -0
- package/dist/entities/market.d.ts.map +1 -0
- package/dist/entities/market.js +301 -0
- package/dist/entities/market.js.map +1 -0
- package/dist/entities/marketing.d.ts +67 -0
- package/dist/entities/marketing.d.ts.map +1 -0
- package/dist/entities/marketing.js +1157 -0
- package/dist/entities/marketing.js.map +1 -0
- package/dist/entities/offerings.d.ts +51 -0
- package/dist/entities/offerings.d.ts.map +1 -0
- package/dist/entities/offerings.js +727 -0
- package/dist/entities/offerings.js.map +1 -0
- package/dist/entities/operations.d.ts +58 -0
- package/dist/entities/operations.d.ts.map +1 -0
- package/dist/entities/operations.js +787 -0
- package/dist/entities/operations.js.map +1 -0
- package/dist/entities/organization.d.ts +57 -0
- package/dist/entities/organization.d.ts.map +1 -0
- package/dist/entities/organization.js +807 -0
- package/dist/entities/organization.js.map +1 -0
- package/dist/entities/partnerships.d.ts +21 -0
- package/dist/entities/partnerships.d.ts.map +1 -0
- package/dist/entities/partnerships.js +300 -0
- package/dist/entities/partnerships.js.map +1 -0
- package/dist/entities/planning.d.ts +87 -0
- package/dist/entities/planning.d.ts.map +1 -0
- package/dist/entities/planning.js +271 -0
- package/dist/entities/planning.js.map +1 -0
- package/dist/entities/projects.d.ts +25 -0
- package/dist/entities/projects.d.ts.map +1 -0
- package/dist/entities/projects.js +349 -0
- package/dist/entities/projects.js.map +1 -0
- package/dist/entities/risk.d.ts +21 -0
- package/dist/entities/risk.d.ts.map +1 -0
- package/dist/entities/risk.js +293 -0
- package/dist/entities/risk.js.map +1 -0
- package/dist/entities/sales.d.ts +72 -0
- package/dist/entities/sales.d.ts.map +1 -0
- package/dist/entities/sales.js +1248 -0
- package/dist/entities/sales.js.map +1 -0
- package/dist/financials.d.ts +130 -0
- package/dist/financials.d.ts.map +1 -0
- package/dist/financials.js +297 -0
- package/dist/financials.js.map +1 -0
- package/dist/goals.d.ts +87 -0
- package/dist/goals.d.ts.map +1 -0
- package/dist/goals.js +215 -0
- package/dist/goals.js.map +1 -0
- package/dist/index.d.ts +97 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +131 -1079
- package/dist/index.js.map +1 -1
- package/dist/kpis.d.ts +118 -0
- package/dist/kpis.d.ts.map +1 -0
- package/dist/kpis.js +232 -0
- package/dist/kpis.js.map +1 -0
- package/dist/metrics.d.ts +448 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +325 -0
- package/dist/metrics.js.map +1 -0
- package/dist/okrs.d.ts +123 -0
- package/dist/okrs.d.ts.map +1 -0
- package/dist/okrs.js +269 -0
- package/dist/okrs.js.map +1 -0
- package/dist/organization.d.ts +585 -0
- package/dist/organization.d.ts.map +1 -0
- package/dist/organization.js +173 -0
- package/dist/organization.js.map +1 -0
- package/dist/process.d.ts +112 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +241 -0
- package/dist/process.js.map +1 -0
- package/dist/product.d.ts +85 -0
- package/dist/product.d.ts.map +1 -0
- package/dist/product.js +145 -0
- package/dist/product.js.map +1 -0
- package/dist/queries.d.ts +304 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +415 -0
- package/dist/queries.js.map +1 -0
- package/dist/roles.d.ts +340 -0
- package/dist/roles.d.ts.map +1 -0
- package/dist/roles.js +255 -0
- package/dist/roles.js.map +1 -0
- package/dist/service.d.ts +61 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +140 -0
- package/dist/service.js.map +1 -0
- package/dist/types.d.ts +459 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/vision.d.ts +38 -0
- package/dist/vision.d.ts.map +1 -0
- package/dist/vision.js +68 -0
- package/dist/vision.js.map +1 -0
- package/dist/workflow.d.ts +115 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +247 -0
- package/dist/workflow.js.map +1 -0
- package/examples/basic-usage.ts +307 -0
- package/package.json +19 -60
- package/src/business.ts +121 -0
- package/src/dollar.ts +132 -0
- package/src/entities/assets.ts +332 -0
- package/src/entities/business.ts +406 -0
- package/src/entities/communication.ts +264 -0
- package/src/entities/customers.ts +1072 -0
- package/src/entities/financials.ts +1011 -0
- package/src/entities/goals.ts +871 -0
- package/src/entities/index.ts +383 -0
- package/src/entities/legal.ts +310 -0
- package/src/entities/market.ts +310 -0
- package/src/entities/marketing.ts +1249 -0
- package/src/entities/offerings.ts +789 -0
- package/src/entities/operations.ts +861 -0
- package/src/entities/organization.ts +876 -0
- package/src/entities/partnerships.ts +309 -0
- package/src/entities/planning.ts +307 -0
- package/src/entities/projects.ts +360 -0
- package/src/entities/risk.ts +302 -0
- package/src/entities/sales.ts +1352 -0
- package/src/financials.ts +352 -0
- package/src/goals.ts +250 -0
- package/src/index.test.ts +336 -0
- package/src/index.ts +530 -0
- package/src/kpis.ts +275 -0
- package/src/metrics.ts +825 -0
- package/src/okrs.ts +325 -0
- package/src/organization.ts +909 -0
- package/src/process.ts +272 -0
- package/src/product.ts +178 -0
- package/src/queries.ts +767 -0
- package/src/roles.ts +686 -0
- package/src/service.ts +164 -0
- package/src/types.ts +493 -0
- package/src/vision.ts +88 -0
- package/src/workflow.ts +280 -0
- package/tsconfig.json +9 -0
- package/dist/loaders/index.d.ts +0 -174
- package/dist/loaders/index.js +0 -366
- package/dist/loaders/index.js.map +0 -1
- package/dist/schema/index.d.ts +0 -146
- package/dist/schema/index.js +0 -716
- package/dist/schema/index.js.map +0 -1
- package/dist/types-CJ9eGS_C.d.ts +0 -86
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organization Structure - Flows to FGA/RBAC
|
|
3
|
+
*
|
|
4
|
+
* Defines the complete organizational hierarchy:
|
|
5
|
+
*
|
|
6
|
+
* Organization
|
|
7
|
+
* └── Department
|
|
8
|
+
* └── Team
|
|
9
|
+
* └── Position (Role + Worker)
|
|
10
|
+
* └── Permissions (FGA/RBAC)
|
|
11
|
+
*
|
|
12
|
+
* This structure enables:
|
|
13
|
+
* - Hierarchical permission inheritance
|
|
14
|
+
* - Role-based task assignment
|
|
15
|
+
* - Approval chains based on org structure
|
|
16
|
+
* - Resource access control based on department/team
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Resolve permissions for a position in the org hierarchy
|
|
22
|
+
*/
|
|
23
|
+
export function resolvePermissions(org, positionId) {
|
|
24
|
+
// Find the position
|
|
25
|
+
let position;
|
|
26
|
+
let team;
|
|
27
|
+
let department;
|
|
28
|
+
// Search through hierarchy
|
|
29
|
+
for (const dept of org.departments || []) {
|
|
30
|
+
for (const t of dept.teams || []) {
|
|
31
|
+
const pos = t.positions?.find(p => p.id === positionId);
|
|
32
|
+
if (pos) {
|
|
33
|
+
position = pos;
|
|
34
|
+
team = t;
|
|
35
|
+
department = dept;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (position)
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
// Also check standalone teams
|
|
43
|
+
if (!position) {
|
|
44
|
+
for (const t of org.teams || []) {
|
|
45
|
+
const pos = t.positions?.find(p => p.id === positionId);
|
|
46
|
+
if (pos) {
|
|
47
|
+
position = pos;
|
|
48
|
+
team = t;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!position)
|
|
54
|
+
return null;
|
|
55
|
+
// Find the role
|
|
56
|
+
const role = org.roles?.find(r => r.id === position.roleId);
|
|
57
|
+
// Build inheritance chain
|
|
58
|
+
const inheritanceChain = [];
|
|
59
|
+
const permissions = {};
|
|
60
|
+
const resourcePermissions = {};
|
|
61
|
+
const canApprove = [];
|
|
62
|
+
const canHandle = [];
|
|
63
|
+
// 1. Department defaults
|
|
64
|
+
if (department?.defaultPermissions) {
|
|
65
|
+
inheritanceChain.push(`department:${department.id}`);
|
|
66
|
+
mergePermissions(permissions, department.defaultPermissions);
|
|
67
|
+
}
|
|
68
|
+
// 2. Team defaults
|
|
69
|
+
if (team?.defaultPermissions) {
|
|
70
|
+
inheritanceChain.push(`team:${team.id}`);
|
|
71
|
+
mergePermissions(permissions, team.defaultPermissions);
|
|
72
|
+
}
|
|
73
|
+
// 3. Team resources (scoped permissions)
|
|
74
|
+
if (team?.resources) {
|
|
75
|
+
for (const [resourceType, resourceIds] of Object.entries(team.resources)) {
|
|
76
|
+
if (resourceIds) {
|
|
77
|
+
for (const resourceId of resourceIds) {
|
|
78
|
+
const key = `${resourceType}:${resourceId}`;
|
|
79
|
+
resourcePermissions[key] = resourcePermissions[key] || {};
|
|
80
|
+
mergePermissions(resourcePermissions[key], team.defaultPermissions || {});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// 4. Role permissions
|
|
86
|
+
if (role?.permissions) {
|
|
87
|
+
inheritanceChain.push(`role:${role.id}`);
|
|
88
|
+
mergePermissions(permissions, role.permissions);
|
|
89
|
+
}
|
|
90
|
+
// 5. Role capabilities
|
|
91
|
+
if (role?.canApprove) {
|
|
92
|
+
canApprove.push(...role.canApprove);
|
|
93
|
+
}
|
|
94
|
+
if (role?.canHandle) {
|
|
95
|
+
canHandle.push(...role.canHandle);
|
|
96
|
+
}
|
|
97
|
+
// 6. Position-specific permissions
|
|
98
|
+
if (position.additionalPermissions) {
|
|
99
|
+
inheritanceChain.push(`position:${position.id}`);
|
|
100
|
+
mergePermissions(permissions, position.additionalPermissions);
|
|
101
|
+
// Handle resource-specific permissions
|
|
102
|
+
for (const [key, perms] of Object.entries(position.additionalPermissions)) {
|
|
103
|
+
if (key.includes(':')) {
|
|
104
|
+
resourcePermissions[key] = resourcePermissions[key] || {};
|
|
105
|
+
resourcePermissions[key] = { ...resourcePermissions[key], _direct: perms };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
workerId: position.workerId || '',
|
|
111
|
+
positionId: position.id,
|
|
112
|
+
permissions,
|
|
113
|
+
resourcePermissions,
|
|
114
|
+
canApprove: [...new Set(canApprove)],
|
|
115
|
+
canHandle: [...new Set(canHandle)],
|
|
116
|
+
inheritanceChain,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Merge permissions into target
|
|
121
|
+
*/
|
|
122
|
+
function mergePermissions(target, source) {
|
|
123
|
+
for (const [key, perms] of Object.entries(source)) {
|
|
124
|
+
if (!target[key]) {
|
|
125
|
+
target[key] = [];
|
|
126
|
+
}
|
|
127
|
+
for (const perm of perms) {
|
|
128
|
+
if (!target[key].includes(perm)) {
|
|
129
|
+
target[key].push(perm);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get approval chain for a request
|
|
136
|
+
*/
|
|
137
|
+
export function getApprovalChainForRequest(org, requestType, amount) {
|
|
138
|
+
const chain = org.approvalChains?.find(c => c.type === requestType && c.active !== false);
|
|
139
|
+
if (!chain)
|
|
140
|
+
return [];
|
|
141
|
+
// Find the appropriate level based on amount
|
|
142
|
+
const levels = [...chain.levels].sort((a, b) => (a.threshold || 0) - (b.threshold || 0));
|
|
143
|
+
for (const level of levels.reverse()) {
|
|
144
|
+
if (amount === undefined || (level.threshold && amount <= level.threshold)) {
|
|
145
|
+
return level.approvers;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// Return highest level if amount exceeds all thresholds
|
|
149
|
+
return levels[levels.length - 1]?.approvers || [];
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Find manager for a position (follows reportsTo chain)
|
|
153
|
+
*/
|
|
154
|
+
export function findManager(org, positionId) {
|
|
155
|
+
// Find the position
|
|
156
|
+
for (const dept of org.departments || []) {
|
|
157
|
+
for (const team of dept.teams || []) {
|
|
158
|
+
const position = team.positions?.find(p => p.id === positionId);
|
|
159
|
+
if (position?.reportsTo) {
|
|
160
|
+
// Find the manager position
|
|
161
|
+
for (const d of org.departments || []) {
|
|
162
|
+
for (const t of d.teams || []) {
|
|
163
|
+
const manager = t.positions?.find(p => p.id === position.reportsTo);
|
|
164
|
+
if (manager)
|
|
165
|
+
return manager;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=organization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.js","sourceRoot":"","sources":["../src/organization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAssBH;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAiB,EACjB,UAAkB;IAElB,oBAAoB;IACpB,IAAI,QAA8B,CAAA;IAClC,IAAI,IAAsB,CAAA;IAC1B,IAAI,UAAkC,CAAA;IAEtC,2BAA2B;IAC3B,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC;QACzC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;YACjC,MAAM,GAAG,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,CAAA;YACvD,IAAI,GAAG,EAAE,CAAC;gBACR,QAAQ,GAAG,GAAG,CAAA;gBACd,IAAI,GAAG,CAAC,CAAA;gBACR,UAAU,GAAG,IAAI,CAAA;gBACjB,MAAK;YACP,CAAC;QACH,CAAC;QACD,IAAI,QAAQ;YAAE,MAAK;IACrB,CAAC;IAED,8BAA8B;IAC9B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;YAChC,MAAM,GAAG,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAA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AAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,SAAS,CAAC,CAAA;wBACnE,IAAI,OAAO;4BAAE,OAAO,OAAO,CAAA;oBAC7B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Business process definition and management
|
|
3
|
+
*/
|
|
4
|
+
import type { ProcessDefinition, ProcessStep, ProcessMetric } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Define a business process with steps, inputs, outputs, and metrics
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const process = Process({
|
|
11
|
+
* name: 'Customer Onboarding',
|
|
12
|
+
* description: 'Process for onboarding new customers',
|
|
13
|
+
* category: 'core',
|
|
14
|
+
* owner: 'Customer Success Team',
|
|
15
|
+
* steps: [
|
|
16
|
+
* {
|
|
17
|
+
* order: 1,
|
|
18
|
+
* name: 'Welcome Email',
|
|
19
|
+
* description: 'Send personalized welcome email',
|
|
20
|
+
* responsible: 'CS Manager',
|
|
21
|
+
* duration: '5 minutes',
|
|
22
|
+
* automationLevel: 'automated',
|
|
23
|
+
* },
|
|
24
|
+
* {
|
|
25
|
+
* order: 2,
|
|
26
|
+
* name: 'Initial Setup Call',
|
|
27
|
+
* description: 'Schedule and conduct setup call',
|
|
28
|
+
* responsible: 'CS Rep',
|
|
29
|
+
* duration: '30 minutes',
|
|
30
|
+
* automationLevel: 'manual',
|
|
31
|
+
* },
|
|
32
|
+
* {
|
|
33
|
+
* order: 3,
|
|
34
|
+
* name: 'Account Configuration',
|
|
35
|
+
* description: 'Configure customer account settings',
|
|
36
|
+
* responsible: 'CS Rep',
|
|
37
|
+
* duration: '15 minutes',
|
|
38
|
+
* automationLevel: 'semi-automated',
|
|
39
|
+
* },
|
|
40
|
+
* ],
|
|
41
|
+
* inputs: ['Customer Information', 'Subscription Plan'],
|
|
42
|
+
* outputs: ['Configured Account', 'Training Materials'],
|
|
43
|
+
* metrics: [
|
|
44
|
+
* {
|
|
45
|
+
* name: 'Time to First Value',
|
|
46
|
+
* description: 'Time from signup to first successful use',
|
|
47
|
+
* target: 24,
|
|
48
|
+
* unit: 'hours',
|
|
49
|
+
* },
|
|
50
|
+
* {
|
|
51
|
+
* name: 'Onboarding Completion Rate',
|
|
52
|
+
* description: 'Percentage of customers completing onboarding',
|
|
53
|
+
* target: 90,
|
|
54
|
+
* unit: 'percent',
|
|
55
|
+
* },
|
|
56
|
+
* ],
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function Process(definition: ProcessDefinition): ProcessDefinition;
|
|
61
|
+
/**
|
|
62
|
+
* Get process steps in order
|
|
63
|
+
*/
|
|
64
|
+
export declare function getStepsInOrder(process: ProcessDefinition): ProcessStep[];
|
|
65
|
+
/**
|
|
66
|
+
* Get steps by automation level
|
|
67
|
+
*/
|
|
68
|
+
export declare function getStepsByAutomationLevel(process: ProcessDefinition, level: ProcessStep['automationLevel']): ProcessStep[];
|
|
69
|
+
/**
|
|
70
|
+
* Calculate total process duration in minutes
|
|
71
|
+
*/
|
|
72
|
+
export declare function calculateTotalDuration(process: ProcessDefinition): number;
|
|
73
|
+
/**
|
|
74
|
+
* Format minutes to human-readable duration
|
|
75
|
+
*/
|
|
76
|
+
export declare function formatDuration(minutes: number): string;
|
|
77
|
+
/**
|
|
78
|
+
* Calculate automation percentage
|
|
79
|
+
*/
|
|
80
|
+
export declare function calculateAutomationPercentage(process: ProcessDefinition): number;
|
|
81
|
+
/**
|
|
82
|
+
* Get metric by name
|
|
83
|
+
*/
|
|
84
|
+
export declare function getMetric(process: ProcessDefinition, name: string): ProcessMetric | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Check if metric meets target
|
|
87
|
+
*/
|
|
88
|
+
export declare function meetsTarget(metric: ProcessMetric): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Calculate metric achievement percentage
|
|
91
|
+
*/
|
|
92
|
+
export declare function calculateMetricAchievement(metric: ProcessMetric): number;
|
|
93
|
+
/**
|
|
94
|
+
* Update metric current value
|
|
95
|
+
*/
|
|
96
|
+
export declare function updateMetric(process: ProcessDefinition, metricName: string, currentValue: number): ProcessDefinition;
|
|
97
|
+
/**
|
|
98
|
+
* Add step to process
|
|
99
|
+
*/
|
|
100
|
+
export declare function addStep(process: ProcessDefinition, step: ProcessStep): ProcessDefinition;
|
|
101
|
+
/**
|
|
102
|
+
* Remove step from process
|
|
103
|
+
*/
|
|
104
|
+
export declare function removeStep(process: ProcessDefinition, stepOrder: number): ProcessDefinition;
|
|
105
|
+
/**
|
|
106
|
+
* Validate process definition
|
|
107
|
+
*/
|
|
108
|
+
export declare function validateProcess(process: ProcessDefinition): {
|
|
109
|
+
valid: boolean;
|
|
110
|
+
errors: string[];
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,OAAO,CAAC,UAAU,EAAE,iBAAiB,GAAG,iBAAiB,CAcxE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,EAAE,CAEzE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,WAAW,CAAC,iBAAiB,CAAC,GACpC,WAAW,EAAE,CAEf;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAMzE;AAmCD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAYtD;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAQhF;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAE7F;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAG1D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAIxE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,iBAAiB,EAC1B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,iBAAiB,CASnB;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,WAAW,GAAG,iBAAiB,CAKxF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAK3F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAsChG"}
|
package/dist/process.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Business process definition and management
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Define a business process with steps, inputs, outputs, and metrics
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const process = Process({
|
|
10
|
+
* name: 'Customer Onboarding',
|
|
11
|
+
* description: 'Process for onboarding new customers',
|
|
12
|
+
* category: 'core',
|
|
13
|
+
* owner: 'Customer Success Team',
|
|
14
|
+
* steps: [
|
|
15
|
+
* {
|
|
16
|
+
* order: 1,
|
|
17
|
+
* name: 'Welcome Email',
|
|
18
|
+
* description: 'Send personalized welcome email',
|
|
19
|
+
* responsible: 'CS Manager',
|
|
20
|
+
* duration: '5 minutes',
|
|
21
|
+
* automationLevel: 'automated',
|
|
22
|
+
* },
|
|
23
|
+
* {
|
|
24
|
+
* order: 2,
|
|
25
|
+
* name: 'Initial Setup Call',
|
|
26
|
+
* description: 'Schedule and conduct setup call',
|
|
27
|
+
* responsible: 'CS Rep',
|
|
28
|
+
* duration: '30 minutes',
|
|
29
|
+
* automationLevel: 'manual',
|
|
30
|
+
* },
|
|
31
|
+
* {
|
|
32
|
+
* order: 3,
|
|
33
|
+
* name: 'Account Configuration',
|
|
34
|
+
* description: 'Configure customer account settings',
|
|
35
|
+
* responsible: 'CS Rep',
|
|
36
|
+
* duration: '15 minutes',
|
|
37
|
+
* automationLevel: 'semi-automated',
|
|
38
|
+
* },
|
|
39
|
+
* ],
|
|
40
|
+
* inputs: ['Customer Information', 'Subscription Plan'],
|
|
41
|
+
* outputs: ['Configured Account', 'Training Materials'],
|
|
42
|
+
* metrics: [
|
|
43
|
+
* {
|
|
44
|
+
* name: 'Time to First Value',
|
|
45
|
+
* description: 'Time from signup to first successful use',
|
|
46
|
+
* target: 24,
|
|
47
|
+
* unit: 'hours',
|
|
48
|
+
* },
|
|
49
|
+
* {
|
|
50
|
+
* name: 'Onboarding Completion Rate',
|
|
51
|
+
* description: 'Percentage of customers completing onboarding',
|
|
52
|
+
* target: 90,
|
|
53
|
+
* unit: 'percent',
|
|
54
|
+
* },
|
|
55
|
+
* ],
|
|
56
|
+
* })
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export function Process(definition) {
|
|
60
|
+
if (!definition.name) {
|
|
61
|
+
throw new Error('Process name is required');
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
...definition,
|
|
65
|
+
category: definition.category || 'support',
|
|
66
|
+
steps: definition.steps || [],
|
|
67
|
+
inputs: definition.inputs || [],
|
|
68
|
+
outputs: definition.outputs || [],
|
|
69
|
+
metrics: definition.metrics || [],
|
|
70
|
+
metadata: definition.metadata || {},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get process steps in order
|
|
75
|
+
*/
|
|
76
|
+
export function getStepsInOrder(process) {
|
|
77
|
+
return [...(process.steps || [])].sort((a, b) => a.order - b.order);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get steps by automation level
|
|
81
|
+
*/
|
|
82
|
+
export function getStepsByAutomationLevel(process, level) {
|
|
83
|
+
return process.steps?.filter(step => step.automationLevel === level) || [];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Calculate total process duration in minutes
|
|
87
|
+
*/
|
|
88
|
+
export function calculateTotalDuration(process) {
|
|
89
|
+
return (process.steps?.reduce((total, step) => {
|
|
90
|
+
return total + parseDurationToMinutes(step.duration);
|
|
91
|
+
}, 0) || 0);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Parse duration string to minutes
|
|
95
|
+
*/
|
|
96
|
+
function parseDurationToMinutes(duration) {
|
|
97
|
+
if (!duration)
|
|
98
|
+
return 0;
|
|
99
|
+
const lower = duration.toLowerCase();
|
|
100
|
+
const match = lower.match(/(\d+)\s*(minute|minutes|min|hour|hours|hr|day|days|week|weeks)/);
|
|
101
|
+
if (!match)
|
|
102
|
+
return 0;
|
|
103
|
+
const value = parseInt(match[1] || '0', 10);
|
|
104
|
+
const unit = match[2];
|
|
105
|
+
switch (unit) {
|
|
106
|
+
case 'minute':
|
|
107
|
+
case 'minutes':
|
|
108
|
+
case 'min':
|
|
109
|
+
return value;
|
|
110
|
+
case 'hour':
|
|
111
|
+
case 'hours':
|
|
112
|
+
case 'hr':
|
|
113
|
+
return value * 60;
|
|
114
|
+
case 'day':
|
|
115
|
+
case 'days':
|
|
116
|
+
return value * 60 * 24;
|
|
117
|
+
case 'week':
|
|
118
|
+
case 'weeks':
|
|
119
|
+
return value * 60 * 24 * 7;
|
|
120
|
+
default:
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Format minutes to human-readable duration
|
|
126
|
+
*/
|
|
127
|
+
export function formatDuration(minutes) {
|
|
128
|
+
if (minutes < 60) {
|
|
129
|
+
return `${minutes} minutes`;
|
|
130
|
+
}
|
|
131
|
+
else if (minutes < 60 * 24) {
|
|
132
|
+
const hours = Math.floor(minutes / 60);
|
|
133
|
+
const mins = minutes % 60;
|
|
134
|
+
return mins > 0 ? `${hours} hours ${mins} minutes` : `${hours} hours`;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
const days = Math.floor(minutes / (60 * 24));
|
|
138
|
+
const hours = Math.floor((minutes % (60 * 24)) / 60);
|
|
139
|
+
return hours > 0 ? `${days} days ${hours} hours` : `${days} days`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Calculate automation percentage
|
|
144
|
+
*/
|
|
145
|
+
export function calculateAutomationPercentage(process) {
|
|
146
|
+
if (!process.steps || process.steps.length === 0)
|
|
147
|
+
return 0;
|
|
148
|
+
const automatedSteps = process.steps.filter(step => step.automationLevel === 'automated' || step.automationLevel === 'semi-automated').length;
|
|
149
|
+
return (automatedSteps / process.steps.length) * 100;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get metric by name
|
|
153
|
+
*/
|
|
154
|
+
export function getMetric(process, name) {
|
|
155
|
+
return process.metrics?.find(m => m.name === name);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Check if metric meets target
|
|
159
|
+
*/
|
|
160
|
+
export function meetsTarget(metric) {
|
|
161
|
+
if (metric.target === undefined || metric.current === undefined)
|
|
162
|
+
return false;
|
|
163
|
+
return metric.current >= metric.target;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Calculate metric achievement percentage
|
|
167
|
+
*/
|
|
168
|
+
export function calculateMetricAchievement(metric) {
|
|
169
|
+
if (metric.target === undefined || metric.current === undefined)
|
|
170
|
+
return 0;
|
|
171
|
+
if (metric.target === 0)
|
|
172
|
+
return 100;
|
|
173
|
+
return (metric.current / metric.target) * 100;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Update metric current value
|
|
177
|
+
*/
|
|
178
|
+
export function updateMetric(process, metricName, currentValue) {
|
|
179
|
+
const metrics = process.metrics?.map(m => m.name === metricName ? { ...m, current: currentValue } : m);
|
|
180
|
+
return {
|
|
181
|
+
...process,
|
|
182
|
+
metrics,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Add step to process
|
|
187
|
+
*/
|
|
188
|
+
export function addStep(process, step) {
|
|
189
|
+
return {
|
|
190
|
+
...process,
|
|
191
|
+
steps: [...(process.steps || []), step],
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Remove step from process
|
|
196
|
+
*/
|
|
197
|
+
export function removeStep(process, stepOrder) {
|
|
198
|
+
return {
|
|
199
|
+
...process,
|
|
200
|
+
steps: process.steps?.filter(s => s.order !== stepOrder),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Validate process definition
|
|
205
|
+
*/
|
|
206
|
+
export function validateProcess(process) {
|
|
207
|
+
const errors = [];
|
|
208
|
+
if (!process.name) {
|
|
209
|
+
errors.push('Process name is required');
|
|
210
|
+
}
|
|
211
|
+
if (process.steps) {
|
|
212
|
+
const orders = new Set();
|
|
213
|
+
for (const step of process.steps) {
|
|
214
|
+
if (!step.name) {
|
|
215
|
+
errors.push(`Step at order ${step.order} must have a name`);
|
|
216
|
+
}
|
|
217
|
+
if (orders.has(step.order)) {
|
|
218
|
+
errors.push(`Duplicate step order: ${step.order}`);
|
|
219
|
+
}
|
|
220
|
+
orders.add(step.order);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (process.metrics) {
|
|
224
|
+
for (const metric of process.metrics) {
|
|
225
|
+
if (!metric.name) {
|
|
226
|
+
errors.push('Metric must have a name');
|
|
227
|
+
}
|
|
228
|
+
if (metric.target !== undefined && metric.target < 0) {
|
|
229
|
+
errors.push(`Metric ${metric.name} target cannot be negative`);
|
|
230
|
+
}
|
|
231
|
+
if (metric.current !== undefined && metric.current < 0) {
|
|
232
|
+
errors.push(`Metric ${metric.name} current value cannot be negative`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
valid: errors.length === 0,
|
|
238
|
+
errors,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,UAAU,OAAO,CAAC,UAA6B;IACnD,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO;QACL,GAAG,UAAU;QACb,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,SAAS;QAC1C,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,EAAE;QAC7B,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,EAAE;QAC/B,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,EAAE;QACjC,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,EAAE;QACjC,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,EAAE;KACpC,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU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,MAAM,CAAC,IAAI,CAAC,yBAAyB,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;YACpD,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACrC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBACjB,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAA;YACxC,CAAC;YACD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrD,MAAM,CAAC,IAAI,CAAC,UAAU,MAAM,CAAC,IAAI,4BAA4B,CAAC,CAAA;YAChE,CAAC;YACD,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;gBACvD,MAAM,CAAC,IAAI,CAAC,UAAU,MAAM,CAAC,IAAI,mCAAmC,CAAC,CAAA;YACvE,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;KACP,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product definition and management
|
|
3
|
+
*/
|
|
4
|
+
import type { ProductDefinition, RoadmapItem } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Define a product with pricing, features, and roadmap
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const product = Product({
|
|
11
|
+
* name: 'Widget Pro',
|
|
12
|
+
* description: 'Enterprise-grade widget management platform',
|
|
13
|
+
* category: 'SaaS',
|
|
14
|
+
* targetSegment: 'Enterprise',
|
|
15
|
+
* valueProposition: 'Reduce widget management costs by 50%',
|
|
16
|
+
* pricingModel: 'subscription',
|
|
17
|
+
* price: 99,
|
|
18
|
+
* currency: 'USD',
|
|
19
|
+
* cogs: 20,
|
|
20
|
+
* features: [
|
|
21
|
+
* 'Unlimited widgets',
|
|
22
|
+
* 'Advanced analytics',
|
|
23
|
+
* 'API access',
|
|
24
|
+
* '24/7 support',
|
|
25
|
+
* ],
|
|
26
|
+
* roadmap: [
|
|
27
|
+
* {
|
|
28
|
+
* name: 'Mobile app',
|
|
29
|
+
* description: 'Native iOS and Android apps',
|
|
30
|
+
* targetDate: new Date('2024-09-01'),
|
|
31
|
+
* priority: 'high',
|
|
32
|
+
* status: 'in-progress',
|
|
33
|
+
* },
|
|
34
|
+
* {
|
|
35
|
+
* name: 'AI-powered insights',
|
|
36
|
+
* description: 'Automated widget optimization suggestions',
|
|
37
|
+
* targetDate: new Date('2024-12-01'),
|
|
38
|
+
* priority: 'high',
|
|
39
|
+
* status: 'planned',
|
|
40
|
+
* },
|
|
41
|
+
* ],
|
|
42
|
+
* })
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function Product(definition: ProductDefinition): ProductDefinition;
|
|
46
|
+
/**
|
|
47
|
+
* Calculate gross margin for a product
|
|
48
|
+
*/
|
|
49
|
+
export declare function calculateGrossMargin(product: ProductDefinition): number;
|
|
50
|
+
/**
|
|
51
|
+
* Calculate gross profit for a product
|
|
52
|
+
*/
|
|
53
|
+
export declare function calculateGrossProfit(product: ProductDefinition, unitsSold: number): number;
|
|
54
|
+
/**
|
|
55
|
+
* Get roadmap items by status
|
|
56
|
+
*/
|
|
57
|
+
export declare function getRoadmapByStatus(product: ProductDefinition, status: RoadmapItem['status']): RoadmapItem[];
|
|
58
|
+
/**
|
|
59
|
+
* Get roadmap items by priority
|
|
60
|
+
*/
|
|
61
|
+
export declare function getRoadmapByPriority(product: ProductDefinition, priority: RoadmapItem['priority']): RoadmapItem[];
|
|
62
|
+
/**
|
|
63
|
+
* Get overdue roadmap items
|
|
64
|
+
*/
|
|
65
|
+
export declare function getOverdueRoadmapItems(product: ProductDefinition): RoadmapItem[];
|
|
66
|
+
/**
|
|
67
|
+
* Update roadmap item status
|
|
68
|
+
*/
|
|
69
|
+
export declare function updateRoadmapItem(product: ProductDefinition, itemName: string, updates: Partial<RoadmapItem>): ProductDefinition;
|
|
70
|
+
/**
|
|
71
|
+
* Add feature to product
|
|
72
|
+
*/
|
|
73
|
+
export declare function addFeature(product: ProductDefinition, feature: string): ProductDefinition;
|
|
74
|
+
/**
|
|
75
|
+
* Remove feature from product
|
|
76
|
+
*/
|
|
77
|
+
export declare function removeFeature(product: ProductDefinition, feature: string): ProductDefinition;
|
|
78
|
+
/**
|
|
79
|
+
* Validate product definition
|
|
80
|
+
*/
|
|
81
|
+
export declare function validateProduct(product: ProductDefinition): {
|
|
82
|
+
valid: boolean;
|
|
83
|
+
errors: string[];
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=product.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,OAAO,CAAC,UAAU,EAAE,iBAAiB,GAAG,iBAAiB,CAaxE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAGvE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAG1F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,GAC5B,WAAW,EAAE,CAEf;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