compfn 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 (134) hide show
  1. package/README.md +705 -0
  2. package/cli/dist/commands/attest.d.ts +7 -0
  3. package/cli/dist/commands/attest.d.ts.map +1 -0
  4. package/cli/dist/commands/attest.js +26 -0
  5. package/cli/dist/commands/attest.js.map +1 -0
  6. package/cli/dist/commands/export.d.ts +6 -0
  7. package/cli/dist/commands/export.d.ts.map +1 -0
  8. package/cli/dist/commands/export.js +30 -0
  9. package/cli/dist/commands/export.js.map +1 -0
  10. package/cli/dist/commands/init.d.ts +4 -0
  11. package/cli/dist/commands/init.d.ts.map +1 -0
  12. package/cli/dist/commands/init.js +22 -0
  13. package/cli/dist/commands/init.js.map +1 -0
  14. package/cli/dist/commands/run-checks.d.ts +5 -0
  15. package/cli/dist/commands/run-checks.d.ts.map +1 -0
  16. package/cli/dist/commands/run-checks.js +53 -0
  17. package/cli/dist/commands/run-checks.js.map +1 -0
  18. package/cli/dist/config.d.ts +7 -0
  19. package/cli/dist/config.d.ts.map +1 -0
  20. package/cli/dist/config.js +28 -0
  21. package/cli/dist/config.js.map +1 -0
  22. package/cli/dist/index.d.ts +3 -0
  23. package/cli/dist/index.d.ts.map +1 -0
  24. package/cli/dist/index.js +39 -0
  25. package/cli/dist/index.js.map +1 -0
  26. package/dist/adapters/authfn.d.ts +43 -0
  27. package/dist/adapters/authfn.d.ts.map +1 -0
  28. package/dist/adapters/authfn.js +67 -0
  29. package/dist/adapters/authfn.js.map +1 -0
  30. package/dist/adapters/secfn.d.ts +44 -0
  31. package/dist/adapters/secfn.d.ts.map +1 -0
  32. package/dist/adapters/secfn.js +68 -0
  33. package/dist/adapters/secfn.js.map +1 -0
  34. package/dist/adapters/types.d.ts +46 -0
  35. package/dist/adapters/types.d.ts.map +1 -0
  36. package/dist/adapters/types.js +7 -0
  37. package/dist/adapters/types.js.map +1 -0
  38. package/dist/api.d.ts +72 -0
  39. package/dist/api.d.ts.map +1 -0
  40. package/dist/api.js +5 -0
  41. package/dist/api.js.map +1 -0
  42. package/dist/bundles/loader.d.ts +39 -0
  43. package/dist/bundles/loader.d.ts.map +1 -0
  44. package/dist/bundles/loader.js +80 -0
  45. package/dist/bundles/loader.js.map +1 -0
  46. package/dist/check.d.ts +23 -0
  47. package/dist/check.d.ts.map +1 -0
  48. package/dist/check.js +5 -0
  49. package/dist/check.js.map +1 -0
  50. package/dist/checks/service.d.ts +31 -0
  51. package/dist/checks/service.d.ts.map +1 -0
  52. package/dist/checks/service.js +286 -0
  53. package/dist/checks/service.js.map +1 -0
  54. package/dist/compfn.d.ts +9 -0
  55. package/dist/compfn.d.ts.map +1 -0
  56. package/dist/compfn.js +94 -0
  57. package/dist/compfn.js.map +1 -0
  58. package/dist/constants.d.ts +14 -0
  59. package/dist/constants.d.ts.map +1 -0
  60. package/dist/constants.js +14 -0
  61. package/dist/constants.js.map +1 -0
  62. package/dist/control.d.ts +25 -0
  63. package/dist/control.d.ts.map +1 -0
  64. package/dist/control.js +5 -0
  65. package/dist/control.js.map +1 -0
  66. package/dist/controls/service.d.ts +22 -0
  67. package/dist/controls/service.d.ts.map +1 -0
  68. package/dist/controls/service.js +248 -0
  69. package/dist/controls/service.js.map +1 -0
  70. package/dist/errors.d.ts +23 -0
  71. package/dist/errors.d.ts.map +1 -0
  72. package/dist/errors.js +5 -0
  73. package/dist/errors.js.map +1 -0
  74. package/dist/evidence/service.d.ts +34 -0
  75. package/dist/evidence/service.d.ts.map +1 -0
  76. package/dist/evidence/service.js +218 -0
  77. package/dist/evidence/service.js.map +1 -0
  78. package/dist/evidence.d.ts +30 -0
  79. package/dist/evidence.d.ts.map +1 -0
  80. package/dist/evidence.js +20 -0
  81. package/dist/evidence.js.map +1 -0
  82. package/dist/export/service.d.ts +39 -0
  83. package/dist/export/service.d.ts.map +1 -0
  84. package/dist/export/service.js +108 -0
  85. package/dist/export/service.js.map +1 -0
  86. package/dist/export-types.d.ts +18 -0
  87. package/dist/export-types.d.ts.map +1 -0
  88. package/dist/export-types.js +5 -0
  89. package/dist/export-types.js.map +1 -0
  90. package/dist/framework.d.ts +24 -0
  91. package/dist/framework.d.ts.map +1 -0
  92. package/dist/framework.js +5 -0
  93. package/dist/framework.js.map +1 -0
  94. package/dist/frameworks/service.d.ts +22 -0
  95. package/dist/frameworks/service.d.ts.map +1 -0
  96. package/dist/frameworks/service.js +255 -0
  97. package/dist/frameworks/service.js.map +1 -0
  98. package/dist/http/routes.d.ts +4 -0
  99. package/dist/http/routes.d.ts.map +1 -0
  100. package/dist/http/routes.js +256 -0
  101. package/dist/http/routes.js.map +1 -0
  102. package/dist/index.d.ts +22 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/index.js +15 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/logger.d.ts +19 -0
  107. package/dist/logger.d.ts.map +1 -0
  108. package/dist/logger.js +39 -0
  109. package/dist/logger.js.map +1 -0
  110. package/dist/readiness/service.d.ts +34 -0
  111. package/dist/readiness/service.d.ts.map +1 -0
  112. package/dist/readiness/service.js +160 -0
  113. package/dist/readiness/service.js.map +1 -0
  114. package/dist/readiness.d.ts +18 -0
  115. package/dist/readiness.d.ts.map +1 -0
  116. package/dist/readiness.js +5 -0
  117. package/dist/readiness.js.map +1 -0
  118. package/dist/storage/adapter.d.ts +21 -0
  119. package/dist/storage/adapter.d.ts.map +1 -0
  120. package/dist/storage/adapter.js +37 -0
  121. package/dist/storage/adapter.js.map +1 -0
  122. package/dist/storage/schema.d.ts +14 -0
  123. package/dist/storage/schema.d.ts.map +1 -0
  124. package/dist/storage/schema.js +92 -0
  125. package/dist/storage/schema.js.map +1 -0
  126. package/dist/types.d.ts +12 -0
  127. package/dist/types.d.ts.map +1 -0
  128. package/dist/types.js +5 -0
  129. package/dist/types.js.map +1 -0
  130. package/dist/validation.d.ts +52 -0
  131. package/dist/validation.d.ts.map +1 -0
  132. package/dist/validation.js +550 -0
  133. package/dist/validation.js.map +1 -0
  134. package/package.json +54 -0
package/dist/logger.js ADDED
@@ -0,0 +1,39 @@
1
+ export class ConsoleLogger {
2
+ minLevel;
3
+ constructor(minLevel = "info") {
4
+ this.minLevel = minLevel;
5
+ }
6
+ shouldLog(level) {
7
+ const levels = ["debug", "info", "warn", "error"];
8
+ const minIndex = levels.indexOf(this.minLevel);
9
+ const currentIndex = levels.indexOf(level);
10
+ return currentIndex >= minIndex;
11
+ }
12
+ formatMessage(level, message, context) {
13
+ const timestamp = new Date().toISOString();
14
+ const contextStr = context ? ` ${JSON.stringify(context)}` : "";
15
+ return `[${timestamp}] [${level.toUpperCase()}] ${message}${contextStr}`;
16
+ }
17
+ debug(message, context) {
18
+ if (this.shouldLog("debug")) {
19
+ console.debug(this.formatMessage("debug", message, context));
20
+ }
21
+ }
22
+ info(message, context) {
23
+ if (this.shouldLog("info")) {
24
+ console.info(this.formatMessage("info", message, context));
25
+ }
26
+ }
27
+ warn(message, context) {
28
+ if (this.shouldLog("warn")) {
29
+ console.warn(this.formatMessage("warn", message, context));
30
+ }
31
+ }
32
+ error(message, context) {
33
+ if (this.shouldLog("error")) {
34
+ console.error(this.formatMessage("error", message, context));
35
+ }
36
+ }
37
+ }
38
+ export const defaultLogger = new ConsoleLogger("info");
39
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,WAAqB,MAAM;QAA3B,aAAQ,GAAR,QAAQ,CAAmB;IAAG,CAAC;IAE3C,SAAS,CAAC,KAAe;QAC/B,MAAM,MAAM,GAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,C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AAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Readiness service: forControl, forFramework.
3
+ *
4
+ * Policy (deterministic; same evidence set + config → same status):
5
+ * - not_applicable: when the latest scoping_decision evidence (by evidence.timestamp) for the control
6
+ * has payload.status === "not_applicable". Latest = highest timestamp; tie-break by createdAt then id.
7
+ * - compliant: when applicable and there is at least one evidence record with outcome "pass"
8
+ * (excluding type scoping_decision) and evidence.timestamp within the policy window
9
+ * (readinessWindowDays days from now; config.readinessWindowDays ?? 90).
10
+ * - not_compliant: when applicable and no such pass evidence exists within the window.
11
+ *
12
+ * All timestamps in ms (Unix). Window: now - (readinessWindowDays * 24 * 60 * 60 * 1000).
13
+ */
14
+ import type { CompfnEnvelope } from "../errors.js";
15
+ import type { ControlReadiness, FrameworkReadiness } from "../readiness.js";
16
+ import type { Evidence } from "../evidence.js";
17
+ import type { Framework } from "../framework.js";
18
+ export interface ReadinessServiceConfig {
19
+ /** Get control by id; returns envelope (CONTROL_NOT_FOUND when missing). */
20
+ getControl: (id: string) => Promise<CompfnEnvelope<{
21
+ id: string;
22
+ }>>;
23
+ /** Get framework by id; returns envelope (FRAMEWORK_NOT_FOUND when missing). */
24
+ getFramework: (id: string) => Promise<CompfnEnvelope<Framework>>;
25
+ /** List evidence for a control (no since filter; we apply window in logic). */
26
+ listEvidence: (controlId: string) => Promise<CompfnEnvelope<Evidence[]>>;
27
+ /** Policy window in days. Evidence with timestamp within this many days from now counts for compliant. */
28
+ readinessWindowDays?: number;
29
+ }
30
+ export declare function createReadinessService(config: ReadinessServiceConfig): {
31
+ forControl(controlId: string, frameworkId?: string): Promise<CompfnEnvelope<ControlReadiness>>;
32
+ forFramework(frameworkId: string): Promise<CompfnEnvelope<FrameworkReadiness>>;
33
+ };
34
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/readiness/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAmB,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,WAAW,sBAAsB;IACrC,4EAA4E;IAC5E,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACpE,gFAAgF;IAChF,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;IACjE,+EAA+E;IAC/E,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IACzE,0GAA0G;IAC1G,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AA6DD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB;0BAgEpD,MAAM,gBACH,MAAM,GACnB,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;8BAK7B,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;EAsCjD"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Readiness service: forControl, forFramework.
3
+ *
4
+ * Policy (deterministic; same evidence set + config → same status):
5
+ * - not_applicable: when the latest scoping_decision evidence (by evidence.timestamp) for the control
6
+ * has payload.status === "not_applicable". Latest = highest timestamp; tie-break by createdAt then id.
7
+ * - compliant: when applicable and there is at least one evidence record with outcome "pass"
8
+ * (excluding type scoping_decision) and evidence.timestamp within the policy window
9
+ * (readinessWindowDays days from now; config.readinessWindowDays ?? 90).
10
+ * - not_compliant: when applicable and no such pass evidence exists within the window.
11
+ *
12
+ * All timestamps in ms (Unix). Window: now - (readinessWindowDays * 24 * 60 * 60 * 1000).
13
+ */
14
+ import { READINESS_WINDOW_DAYS_DEFAULT } from "../constants.js";
15
+ function now() {
16
+ return Date.now();
17
+ }
18
+ /**
19
+ * Latest scoping_decision for control: the one with greatest timestamp; tie-break by createdAt, then id.
20
+ * Returns undefined if no scoping_decision evidence.
21
+ */
22
+ function latestScopingDecision(evidence) {
23
+ const scoping = evidence.filter((e) => e.type === "scoping_decision");
24
+ if (scoping.length === 0)
25
+ return undefined;
26
+ scoping.sort((a, b) => {
27
+ if (b.timestamp !== a.timestamp)
28
+ return b.timestamp - a.timestamp;
29
+ if (b.createdAt !== a.createdAt)
30
+ return b.createdAt - a.createdAt;
31
+ return b.id.localeCompare(a.id);
32
+ });
33
+ return scoping[0];
34
+ }
35
+ /**
36
+ * Evidence that counts for pass-within-window: type !== scoping_decision, outcome === "pass", timestamp >= windowStart.
37
+ */
38
+ function hasPassInWindow(evidence, windowStartMs) {
39
+ let maxTs = -1;
40
+ let lastEvidenceId;
41
+ let foundPassInWindow = false;
42
+ for (const e of evidence) {
43
+ if (e.timestamp > maxTs) {
44
+ maxTs = e.timestamp;
45
+ lastEvidenceId = e.id;
46
+ }
47
+ if (e.type === "scoping_decision")
48
+ continue;
49
+ if (e.outcome === "pass" && e.timestamp >= windowStartMs) {
50
+ foundPassInWindow = true;
51
+ }
52
+ }
53
+ return {
54
+ compliant: foundPassInWindow,
55
+ lastEvidenceAt: maxTs >= 0 ? maxTs : undefined,
56
+ lastEvidenceId,
57
+ };
58
+ }
59
+ /**
60
+ * Requirement IDs (from the given framework) that map to this controlId.
61
+ */
62
+ function requirementIdsForControl(framework, controlId) {
63
+ const ids = [];
64
+ for (const req of framework.requirements) {
65
+ if (req.controlIds.includes(controlId)) {
66
+ ids.push(req.requirementId);
67
+ }
68
+ }
69
+ return ids;
70
+ }
71
+ export function createReadinessService(config) {
72
+ const windowDays = config.readinessWindowDays ?? READINESS_WINDOW_DAYS_DEFAULT;
73
+ const windowMs = windowDays * 24 * 60 * 60 * 1000;
74
+ async function computeControlReadiness(controlId, frameworkId) {
75
+ const controlRes = await config.getControl(controlId);
76
+ if (!controlRes.ok) {
77
+ return controlRes;
78
+ }
79
+ const evidenceRes = await config.listEvidence(controlId);
80
+ if (!evidenceRes.ok) {
81
+ return evidenceRes;
82
+ }
83
+ const evidence = evidenceRes.result;
84
+ const latestScoping = latestScopingDecision(evidence);
85
+ if (latestScoping &&
86
+ latestScoping.payload?.status === "not_applicable") {
87
+ const byTs = [...evidence].sort((a, b) => b.timestamp - a.timestamp);
88
+ const last = byTs[0];
89
+ const result = {
90
+ controlId,
91
+ status: "not_applicable",
92
+ lastEvidenceAt: last ? last.timestamp : undefined,
93
+ lastEvidenceId: last ? last.id : undefined,
94
+ };
95
+ if (frameworkId) {
96
+ const fwRes = await config.getFramework(frameworkId);
97
+ if (fwRes.ok) {
98
+ result.requirementIds = requirementIdsForControl(fwRes.result, controlId);
99
+ }
100
+ }
101
+ return { ok: true, result };
102
+ }
103
+ const windowStart = now() - windowMs;
104
+ const { compliant, lastEvidenceAt, lastEvidenceId } = hasPassInWindow(evidence, windowStart);
105
+ const status = compliant ? "compliant" : "not_compliant";
106
+ const result = {
107
+ controlId,
108
+ status,
109
+ lastEvidenceAt,
110
+ lastEvidenceId,
111
+ };
112
+ if (frameworkId) {
113
+ const fwRes = await config.getFramework(frameworkId);
114
+ if (fwRes.ok) {
115
+ result.requirementIds = requirementIdsForControl(fwRes.result, controlId);
116
+ }
117
+ }
118
+ return { ok: true, result };
119
+ }
120
+ return {
121
+ async forControl(controlId, frameworkId) {
122
+ return computeControlReadiness(controlId, frameworkId);
123
+ },
124
+ async forFramework(frameworkId) {
125
+ const fwRes = await config.getFramework(frameworkId);
126
+ if (!fwRes.ok) {
127
+ return fwRes;
128
+ }
129
+ const framework = fwRes.result;
130
+ const controlIds = new Set();
131
+ for (const req of framework.requirements) {
132
+ for (const cid of req.controlIds) {
133
+ controlIds.add(cid);
134
+ }
135
+ }
136
+ const controlReadiness = [];
137
+ let frameworkStatus = "compliant";
138
+ for (const cid of controlIds) {
139
+ const cr = await computeControlReadiness(cid, frameworkId);
140
+ if (!cr.ok) {
141
+ return cr;
142
+ }
143
+ controlReadiness.push(cr.result);
144
+ if (cr.result.status === "not_compliant") {
145
+ frameworkStatus = "not_compliant";
146
+ }
147
+ }
148
+ return {
149
+ ok: true,
150
+ result: {
151
+ frameworkId,
152
+ status: frameworkStatus,
153
+ controlReadiness,
154
+ lastUpdated: now(),
155
+ },
156
+ };
157
+ },
158
+ };
159
+ }
160
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/readiness/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAahE,SAAS,GAAG;IACV,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,SAAS,qBAAqB,CAAC,QAAoB;IACjD,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC;IACtE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACpB,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS;YAAE,OAAO,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAA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AEnB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;YACrD,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;gBACd,OAAO,KAAK,CAAC;YACf,CAAC;YACD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;YAE/B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;YACrC,KAAK,MAAM,GAAG,IAAI,SAAS,CAAC,YAAY,EAAE,CAAC;gBACzC,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;oBACjC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;YAED,MAAM,gBAAgB,GAAuB,EAAE,CAAC;YAChD,IAAI,eAAe,GAAoB,WAAW,CAAC;YACnD,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;gBAC7B,MAAM,EAAE,GAAG,MAAM,uBAAuB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;gBAC3D,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;oBACX,OAAO,EAAE,CAAC;gBACZ,CAAC;gBACD,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;gBACjC,IAAI,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,eAAe,EAAE,CAAC;oBACzC,eAAe,GAAG,eAAe,CAAC;gBACpC,CAAC;YACH,CAAC;YAED,OAAO;gBACL,EAAE,EAAE,IAAI;gBACR,MAAM,EAAE;oBACN,WAAW;oBACX,MAAM,EAAE,eAAe;oBACvB,gBAAgB;oBAChB,WAAW,EAAE,GAAG,EAAE;iBACnB;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Readiness types: ControlReadiness, FrameworkReadiness, ReadinessStatus.
3
+ */
4
+ export type ReadinessStatus = "compliant" | "not_compliant" | "not_applicable";
5
+ export interface ControlReadiness {
6
+ controlId: string;
7
+ status: ReadinessStatus;
8
+ lastEvidenceAt?: number;
9
+ lastEvidenceId?: string;
10
+ requirementIds?: string[];
11
+ }
12
+ export interface FrameworkReadiness {
13
+ frameworkId: string;
14
+ status: ReadinessStatus;
15
+ controlReadiness: ControlReadiness[];
16
+ lastUpdated: number;
17
+ }
18
+ //# sourceMappingURL=readiness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAE/E,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC;IACxB,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;IACrC,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Readiness types: ControlReadiness, FrameworkReadiness, ReadinessStatus.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=readiness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readiness.js","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Storage adapter integration: compfn schema + @superfunctions/db adapter.
3
+ * Callers pass Adapter in CompFnConfig; this module provides schema and helpers for namespace.
4
+ */
5
+ import type { Adapter, TableSchemaMap } from "@superfunctions/db";
6
+ import { type CompfnSchemaOptions } from "./schema.js";
7
+ export type { CompfnSchemaOptions } from "./schema.js";
8
+ export { getCompfnSchema, getCompfnSchemaMap } from "./schema.js";
9
+ /**
10
+ * Get schema map for the given namespace (for createSchema / validateSchema with the db adapter).
11
+ */
12
+ export declare function getSchemaForAdapter(options?: CompfnSchemaOptions): TableSchemaMap;
13
+ /**
14
+ * Create or migrate schema using the provided adapter.
15
+ * Adapter must support createSchema (e.g. drizzle/kysely); memory adapter may only validate.
16
+ */
17
+ export declare function createSchemaIfSupported(database: Adapter, options?: CompfnSchemaOptions): Promise<{
18
+ success: boolean;
19
+ errors?: string[];
20
+ }>;
21
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/storage/adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE3E,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAElE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,mBAAwB,GAAG,cAAc,CAErF;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,OAAO,EACjB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAqBlD"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Storage adapter integration: compfn schema + @superfunctions/db adapter.
3
+ * Callers pass Adapter in CompFnConfig; this module provides schema and helpers for namespace.
4
+ */
5
+ import { getCompfnSchemaMap } from "./schema.js";
6
+ export { getCompfnSchema, getCompfnSchemaMap } from "./schema.js";
7
+ /**
8
+ * Get schema map for the given namespace (for createSchema / validateSchema with the db adapter).
9
+ */
10
+ export function getSchemaForAdapter(options = {}) {
11
+ return getCompfnSchemaMap(options);
12
+ }
13
+ /**
14
+ * Create or migrate schema using the provided adapter.
15
+ * Adapter must support createSchema (e.g. drizzle/kysely); memory adapter may only validate.
16
+ */
17
+ export async function createSchemaIfSupported(database, options = {}) {
18
+ const schema = getCompfnSchemaMap(options);
19
+ const namespace = options.namespace ?? "compfn";
20
+ if (typeof database.createSchema !== "function") {
21
+ // Validate each table instead
22
+ const tables = Object.values(schema);
23
+ for (const table of tables) {
24
+ const result = await database.validateSchema(table);
25
+ if (!result.valid && result.errors?.length) {
26
+ return { success: false, errors: result.errors };
27
+ }
28
+ }
29
+ return { success: true };
30
+ }
31
+ const result = await database.createSchema({ schema, namespace });
32
+ return {
33
+ success: result.success,
34
+ errors: result.errors,
35
+ };
36
+ }
37
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/storage/adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,kBAAkB,EAA4B,MAAM,aAAa,CAAC;AAG3E,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAElE;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAA+B,EAAE;IACnE,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,QAAiB,EACjB,UAA+B,EAAE;IAEjC,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,QAAQ,CAAC;IAEhD,IAAI,OAAO,QAAQ,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;QAChD,8BAA8B;QAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACpD,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;gBAC3C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;YACnD,CAAC;QACH,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAClE,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Storage schema for compfn: controls, frameworks, evidence, checks.
3
+ * Tables are namespaced (e.g. compfn_controls) via adapter namespace.
4
+ */
5
+ import type { TableSchema, TableSchemaMap } from "@superfunctions/db";
6
+ export interface CompfnSchemaOptions {
7
+ namespace?: string;
8
+ }
9
+ export declare function getCompfnSchema(options?: CompfnSchemaOptions): {
10
+ version: number;
11
+ schemas: TableSchema[];
12
+ };
13
+ export declare function getCompfnSchemaMap(options?: CompfnSchemaOptions): TableSchemaMap;
14
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/storage/schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD,wBAAgB,eAAe,CAAC,OAAO,GAAE,mBAAwB,GAAG;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,CAiFA;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,cAAc,CAGpF"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Storage schema for compfn: controls, frameworks, evidence, checks.
3
+ * Tables are namespaced (e.g. compfn_controls) via adapter namespace.
4
+ */
5
+ const DEFAULT_NAMESPACE = "compfn";
6
+ function ns(options, suffix) {
7
+ const prefix = options.namespace ?? DEFAULT_NAMESPACE;
8
+ return `${prefix}_${suffix}`;
9
+ }
10
+ export function getCompfnSchema(options = {}) {
11
+ const controls = {
12
+ modelName: "controls",
13
+ fields: {
14
+ id: { type: "string", required: true, unique: true },
15
+ name: { type: "string", required: true },
16
+ description: { type: "string", required: true },
17
+ category: { type: "string", required: true },
18
+ tags: { type: "json", required: false },
19
+ createdAt: { type: "number", required: true },
20
+ updatedAt: { type: "number", required: true },
21
+ },
22
+ indexes: [
23
+ { name: ns(options, "controls_category_idx"), fields: ["category"] },
24
+ { name: ns(options, "controls_updated_idx"), fields: ["updatedAt"] },
25
+ ],
26
+ };
27
+ const frameworks = {
28
+ modelName: "frameworks",
29
+ fields: {
30
+ id: { type: "string", required: true, unique: true },
31
+ name: { type: "string", required: true },
32
+ version: { type: "string", required: false },
33
+ description: { type: "string", required: false },
34
+ requirements: { type: "json", required: true },
35
+ createdAt: { type: "number", required: true },
36
+ updatedAt: { type: "number", required: true },
37
+ },
38
+ indexes: [
39
+ { name: ns(options, "frameworks_updated_idx"), fields: ["updatedAt"] },
40
+ ],
41
+ };
42
+ const evidence = {
43
+ modelName: "evidence",
44
+ fields: {
45
+ id: { type: "string", required: true, unique: true },
46
+ controlId: { type: "string", required: true },
47
+ type: { type: "string", required: true },
48
+ sourceId: { type: "string", required: false },
49
+ frameworkRequirementId: { type: "string", required: false },
50
+ timestamp: { type: "number", required: true },
51
+ actorId: { type: "string", required: true },
52
+ outcome: { type: "string", required: true },
53
+ payload: { type: "json", required: false },
54
+ artifactRef: { type: "string", required: false },
55
+ createdAt: { type: "number", required: true },
56
+ },
57
+ indexes: [
58
+ { name: ns(options, "evidence_control_idx"), fields: ["controlId"] },
59
+ { name: ns(options, "evidence_timestamp_idx"), fields: ["timestamp"] },
60
+ { name: ns(options, "evidence_type_idx"), fields: ["type"] },
61
+ { name: ns(options, "evidence_created_idx"), fields: ["createdAt"] },
62
+ ],
63
+ };
64
+ const checks = {
65
+ modelName: "checks",
66
+ fields: {
67
+ id: { type: "string", required: true, unique: true },
68
+ name: { type: "string", required: true },
69
+ controlId: { type: "string", required: true },
70
+ schedule: { type: "string", required: false },
71
+ trigger: { type: "string", required: false },
72
+ adapterName: { type: "string", required: false },
73
+ adapterMethod: { type: "string", required: false },
74
+ customConfig: { type: "json", required: false },
75
+ createdAt: { type: "number", required: true },
76
+ updatedAt: { type: "number", required: true },
77
+ },
78
+ indexes: [
79
+ { name: ns(options, "checks_control_idx"), fields: ["controlId"] },
80
+ { name: ns(options, "checks_updated_idx"), fields: ["updatedAt"] },
81
+ ],
82
+ };
83
+ return {
84
+ version: 1,
85
+ schemas: [controls, frameworks, evidence, checks],
86
+ };
87
+ }
88
+ export function getCompfnSchemaMap(options = {}) {
89
+ const { schemas } = getCompfnSchema(options);
90
+ return Object.fromEntries(schemas.map((s) => [s.modelName, s]));
91
+ }
92
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/storage/schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAEnC,SAAS,EAAE,CAAC,OAA4B,EAAE,MAAc;IACtD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,IAAI,iBAAiB,CAAC;IACtD,OAAO,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAC/B,CAAC;AAED,MA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,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE;YAC/C,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC7C,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC9C;QACD,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC,WAAW,CAAC,EAAE;YAClE,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC,WAAW,CAAC,EAAE;SACnE;KACF,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC;KAClD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,UAA+B,EAAE;IAClE,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAC7C,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Re-export all CompFn types from a single entry point.
3
+ */
4
+ export type { CompfnErrorCode, CompfnError, CompfnEnvelope, } from "./errors.js";
5
+ export type { Control, CreateControlInput, UpdateControlInput, } from "./control.js";
6
+ export type { FrameworkRequirement, Framework, CreateFrameworkInput, } from "./framework.js";
7
+ export type { EvidenceType, Evidence, CreateEvidenceInput, } from "./evidence.js";
8
+ export type { CheckDefinition, RunCheckResult } from "./check.js";
9
+ export type { ReadinessStatus, ControlReadiness, FrameworkReadiness, } from "./readiness.js";
10
+ export type { AuditorPack } from "./export-types.js";
11
+ export type { CompFnConfig, AdapterCheckInput, AdapterEvidence, EvidenceAdapter, CompFnAPI, } from "./api.js";
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,eAAe,EACf,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,OAAO,EACP,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,oBAAoB,EACpB,SAAS,EACT,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAElE,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,SAAS,GACV,MAAM,UAAU,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Re-export all CompFn types from a single entry point.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Validation for CompFn create/update inputs.
3
+ * CreateControlInput: name, description, category required; tags optional array.
4
+ * UpdateControlInput: all optional (partial update).
5
+ * CreateFrameworkInput: name required; requirements array with requirementId, controlIds; limits (LIMIT-001).
6
+ */
7
+ import type { CreateControlInput, UpdateControlInput } from "./control.js";
8
+ import type { CreateFrameworkInput } from "./framework.js";
9
+ import type { CreateEvidenceInput } from "./evidence.js";
10
+ import type { CompfnError } from "./errors.js";
11
+ import type { CheckDefinition } from "./check.js";
12
+ export interface ValidationResult<T> {
13
+ ok: true;
14
+ value: T;
15
+ }
16
+ export interface ValidationFailure {
17
+ ok: false;
18
+ error: CompfnError;
19
+ }
20
+ export type ValidationOutcome<T> = ValidationResult<T> | ValidationFailure;
21
+ /**
22
+ * Validate CreateControlInput. Required: name, description, category (non-empty strings).
23
+ * Optional: tags (array of strings).
24
+ */
25
+ export declare function validateCreateControlInput(input: unknown, path?: string): ValidationOutcome<CreateControlInput>;
26
+ /**
27
+ * Validate UpdateControlInput. All fields optional; if present must be correct type.
28
+ * name, description, category: non-empty string if provided. tags: array of strings if provided.
29
+ */
30
+ export declare function validateUpdateControlInput(input: unknown, path?: string): ValidationOutcome<UpdateControlInput>;
31
+ /**
32
+ * Validate CreateFrameworkInput. Required: name (non-empty), requirements (array; each requirementId + controlIds; limits).
33
+ */
34
+ export declare function validateCreateFrameworkInput(input: unknown, path?: string): ValidationOutcome<CreateFrameworkInput>;
35
+ /**
36
+ * Validate partial framework input for update. Same rules for name/requirements when provided.
37
+ */
38
+ export declare function validateUpdateFrameworkInput(input: unknown, path?: string): ValidationOutcome<Partial<CreateFrameworkInput>>;
39
+ /**
40
+ * Validate CreateEvidenceInput. Required: controlId, type (EvidenceType), actorId, outcome.
41
+ * Optional: sourceId, frameworkRequirementId, timestamp, payload, artifactRef.
42
+ * For type "scoping_decision": outcome MUST be "unknown"; payload.status MUST be "applicable" or "not_applicable".
43
+ */
44
+ export declare function validateCreateEvidenceInput(input: unknown, path?: string): ValidationOutcome<CreateEvidenceInput>;
45
+ /** Create check input: Omit<CheckDefinition, "id" | "createdAt" | "updatedAt"> */
46
+ export type CreateCheckInput = Omit<CheckDefinition, "id" | "createdAt" | "updatedAt">;
47
+ /**
48
+ * Validate CreateCheckInput. Required: name, controlId (non-empty).
49
+ * At least one of: schedule, trigger, (adapterName and adapterMethod), or customConfig must be present.
50
+ */
51
+ export declare function validateCreateCheckInput(input: unknown, path?: string): ValidationOutcome<CreateCheckInput>;
52
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAwB,MAAM,gBAAgB,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAgB,MAAM,eAAe,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC;AAE3E;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,MAAgB,GACrB,iBAAiB,CAAC,kBAAkB,CAAC,CAgFvC;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,MAAgB,GACrB,iBAAiB,CAAC,kBAAkB,CAAC,CAmFvC;AA+FD;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,MAAgB,GACrB,iBAAiB,CAAC,oBAAoB,CAAC,CAgCzC;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,EACd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