@spottoai/types-package 1.0.2-beta.354 → 1.0.2-beta.357

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 (203) hide show
  1. package/README.md +37 -0
  2. package/dist/aws/commitments-planning.d.ts +3 -0
  3. package/dist/aws/commitments-planning.d.ts.map +1 -0
  4. package/dist/aws/commitments-planning.js +6 -0
  5. package/dist/aws/commitments-planning.js.map +1 -0
  6. package/dist/aws/relationships.d.ts +4 -0
  7. package/dist/aws/relationships.d.ts.map +1 -0
  8. package/dist/aws/relationships.js +6 -0
  9. package/dist/aws/relationships.js.map +1 -0
  10. package/dist/azure/billingArtifactCanonicalization.d.ts +28 -0
  11. package/dist/azure/billingArtifactCanonicalization.d.ts.map +1 -0
  12. package/dist/azure/billingArtifactCanonicalization.js +291 -0
  13. package/dist/azure/billingArtifactCanonicalization.js.map +1 -0
  14. package/dist/azure/billingArtifactEvidence.d.ts +39 -0
  15. package/dist/azure/billingArtifactEvidence.d.ts.map +1 -0
  16. package/dist/azure/billingArtifactEvidence.js +29 -0
  17. package/dist/azure/billingArtifactEvidence.js.map +1 -0
  18. package/dist/azure/billingArtifactGeneration.d.ts +114 -0
  19. package/dist/azure/billingArtifactGeneration.d.ts.map +1 -0
  20. package/dist/azure/billingArtifactGeneration.js +238 -0
  21. package/dist/azure/billingArtifactGeneration.js.map +1 -0
  22. package/dist/azure/billingPlots.d.ts +22 -0
  23. package/dist/azure/billingPlots.d.ts.map +1 -1
  24. package/dist/azure/billingPlots.js +186 -0
  25. package/dist/azure/billingPlots.js.map +1 -1
  26. package/dist/azure/views.d.ts +62 -1
  27. package/dist/azure/views.d.ts.map +1 -1
  28. package/dist/azure/views.js +152 -1
  29. package/dist/azure/views.js.map +1 -1
  30. package/dist/common/artifactControlData.d.ts +12 -0
  31. package/dist/common/artifactControlData.d.ts.map +1 -0
  32. package/dist/common/artifactControlData.js +102 -0
  33. package/dist/common/artifactControlData.js.map +1 -0
  34. package/dist/common/artifactEvidence.d.ts +144 -0
  35. package/dist/common/artifactEvidence.d.ts.map +1 -0
  36. package/dist/common/artifactEvidence.js +181 -0
  37. package/dist/common/artifactEvidence.js.map +1 -0
  38. package/dist/common/artifactEvidenceValidation.d.ts +16 -0
  39. package/dist/common/artifactEvidenceValidation.d.ts.map +1 -0
  40. package/dist/common/artifactEvidenceValidation.js +31 -0
  41. package/dist/common/artifactEvidenceValidation.js.map +1 -0
  42. package/dist/common/artifactGeneration.d.ts +4 -2
  43. package/dist/common/artifactGeneration.d.ts.map +1 -1
  44. package/dist/common/artifactGeneration.js.map +1 -1
  45. package/dist/common/capabilityPassport.d.ts +6 -11
  46. package/dist/common/capabilityPassport.d.ts.map +1 -1
  47. package/dist/common/capabilityPassport.js +2 -10
  48. package/dist/common/capabilityPassport.js.map +1 -1
  49. package/dist/esm/accounts/accounts.js +115 -0
  50. package/dist/esm/accounts/azureSpSetup.js +1 -0
  51. package/dist/esm/accounts/azureSpSetupDurable.js +1 -0
  52. package/dist/esm/accounts/index.js +5 -0
  53. package/dist/esm/accounts/readPermissions.js +198 -0
  54. package/dist/esm/accounts/validation.js +1 -0
  55. package/dist/esm/accounts/writePermissions.js +43 -0
  56. package/dist/esm/ai/index.js +2 -0
  57. package/dist/esm/assessments/artifact.js +1 -0
  58. package/dist/esm/assessments/catalogue.js +12 -0
  59. package/dist/esm/assessments/common.js +1 -0
  60. package/dist/esm/assessments/evidence.js +1 -0
  61. package/dist/esm/assessments/export.js +1 -0
  62. package/dist/esm/assessments/index.js +10 -0
  63. package/dist/esm/assessments/queue.js +2 -0
  64. package/dist/esm/assessments/review.js +1 -0
  65. package/dist/esm/assessments/run.js +1 -0
  66. package/dist/esm/assessments/sow.js +1 -0
  67. package/dist/esm/assessments/status.js +23 -0
  68. package/dist/esm/aws/commitments-planning.js +1 -0
  69. package/dist/esm/aws/commitmentsPlanningValidation.js +121 -0
  70. package/dist/esm/aws/estates.js +21 -0
  71. package/dist/esm/aws/index.js +18 -0
  72. package/dist/esm/aws/onboarding.js +1 -0
  73. package/dist/esm/aws/pluginPublicArtifactBodyValidation.js +217 -0
  74. package/dist/esm/aws/pluginPublicArtifactEvidence.js +1 -0
  75. package/dist/esm/aws/pluginPublicArtifactManifestValidation.js +255 -0
  76. package/dist/esm/aws/pluginPublicArtifactSectionValidation.js +464 -0
  77. package/dist/esm/aws/pluginPublicArtifactValidation.js +2 -0
  78. package/dist/esm/aws/pluginPublicArtifactValidationHelpers.js +216 -0
  79. package/dist/esm/aws/pluginPublicArtifacts.js +109 -0
  80. package/dist/esm/aws/portalCommitmentsPlanningPublicArtifactValidation.js +509 -0
  81. package/dist/esm/aws/portalCommitmentsPlanningPublicArtifacts.js +1 -0
  82. package/dist/esm/aws/portalPublicArtifactCurrentValidation.js +328 -0
  83. package/dist/esm/aws/portalPublicArtifactEvidenceValidation.js +294 -0
  84. package/dist/esm/aws/portalPublicArtifactHistoryAiValidation.js +368 -0
  85. package/dist/esm/aws/portalPublicArtifactHistoryTypes.js +40 -0
  86. package/dist/esm/aws/portalPublicArtifactNestedEvidence.js +1 -0
  87. package/dist/esm/aws/portalPublicArtifactNestedEvidenceValidation.js +397 -0
  88. package/dist/esm/aws/portalPublicArtifactValidation.js +2 -0
  89. package/dist/esm/aws/portalPublicArtifactValidationCommon.js +139 -0
  90. package/dist/esm/aws/portalPublicArtifacts.js +73 -0
  91. package/dist/esm/aws/portalRelationshipPublicArtifactValidation.js +334 -0
  92. package/dist/esm/aws/portalRelationshipPublicArtifacts.js +59 -0
  93. package/dist/esm/aws/portalRelationshipResourceNodeTypes.js +1 -0
  94. package/dist/esm/aws/portalRelationshipResourceNodeValidation.js +368 -0
  95. package/dist/esm/aws/publicArtifacts.js +13 -0
  96. package/dist/esm/aws/relationships.js +1 -0
  97. package/dist/esm/aws/requests.js +19 -0
  98. package/dist/esm/azure/activityLogs.js +2 -0
  99. package/dist/esm/azure/advisorScore.js +1 -0
  100. package/dist/esm/azure/benefits.js +1 -0
  101. package/dist/esm/azure/billingArtifactCanonicalization.js +281 -0
  102. package/dist/esm/azure/billingArtifactEvidence.js +23 -0
  103. package/dist/esm/azure/billingArtifactGeneration.js +229 -0
  104. package/dist/esm/azure/billingGeneration.js +1 -0
  105. package/dist/esm/azure/billingPlots.js +187 -0
  106. package/dist/esm/azure/budgets.js +1 -0
  107. package/dist/esm/azure/commitmentsPlanning.js +1 -0
  108. package/dist/esm/azure/common.js +1 -0
  109. package/dist/esm/azure/configs.js +1 -0
  110. package/dist/esm/azure/costComposition.js +1 -0
  111. package/dist/esm/azure/dataProtection.js +5 -0
  112. package/dist/esm/azure/governance.js +14 -0
  113. package/dist/esm/azure/licensing.js +1 -0
  114. package/dist/esm/azure/metrics.js +1 -0
  115. package/dist/esm/azure/payloads.js +1 -0
  116. package/dist/esm/azure/portalArtifacts.js +1 -0
  117. package/dist/esm/azure/prices.js +1 -0
  118. package/dist/esm/azure/publicIpAddresses.js +2 -0
  119. package/dist/esm/azure/recommendationAudit.js +16 -0
  120. package/dist/esm/azure/recommendationState.js +1 -0
  121. package/dist/esm/azure/recommendationTracks.js +40 -0
  122. package/dist/esm/azure/recommendationWorkflow.js +13 -0
  123. package/dist/esm/azure/recommendations.js +10 -0
  124. package/dist/esm/azure/regulatoryCompliance.js +6 -0
  125. package/dist/esm/azure/relationships.js +2 -0
  126. package/dist/esm/azure/reportingTemplates.js +1 -0
  127. package/dist/esm/azure/reports.js +12 -0
  128. package/dist/esm/azure/resourceHealth.js +12 -0
  129. package/dist/esm/azure/resourceOptimization.js +1 -0
  130. package/dist/esm/azure/resources.js +1 -0
  131. package/dist/esm/azure/reviewChecklist.js +1 -0
  132. package/dist/esm/azure/secureScore.js +1 -0
  133. package/dist/esm/azure/security.js +1 -0
  134. package/dist/esm/azure/serviceRetirement.js +1 -0
  135. package/dist/esm/azure/serviceRetirementState.js +1 -0
  136. package/dist/esm/azure/serviceRetirementWorkManagement.js +1 -0
  137. package/dist/esm/azure/storage-inventory.js +1 -0
  138. package/dist/esm/azure/subscriptions.js +1 -0
  139. package/dist/esm/azure/views.js +181 -0
  140. package/dist/esm/azure/workManagement.js +4 -0
  141. package/dist/esm/common/artifactControlData.js +95 -0
  142. package/dist/esm/common/artifactEvidence.js +173 -0
  143. package/dist/esm/common/artifactEvidenceValidation.js +24 -0
  144. package/dist/esm/common/artifactGeneration.js +1 -0
  145. package/dist/esm/common/capabilityPassport.js +206 -0
  146. package/dist/esm/common/index.js +7 -0
  147. package/dist/esm/common/pagination.js +1 -0
  148. package/dist/esm/common/provider.js +11 -0
  149. package/dist/esm/common/providerSyncProgress.js +1 -0
  150. package/dist/esm/common/relationships.js +1 -0
  151. package/dist/esm/common/syncProgress.js +1 -0
  152. package/dist/esm/company/billingAccount.js +1 -0
  153. package/dist/esm/company/company.js +1 -0
  154. package/dist/esm/company/companyHierarchy.js +1 -0
  155. package/dist/esm/company/companyNotes.js +38 -0
  156. package/dist/esm/company/customProperties.js +1 -0
  157. package/dist/esm/company/index.js +6 -0
  158. package/dist/esm/company/notification.js +43 -0
  159. package/dist/esm/company/survey.js +1 -0
  160. package/dist/esm/customProperties/customProperties.js +1 -0
  161. package/dist/esm/customProperties/index.js +1 -0
  162. package/dist/esm/entries/aws.js +3 -0
  163. package/dist/esm/entries/commitments-planning.js +3 -0
  164. package/dist/esm/entries/provider.js +3 -0
  165. package/dist/esm/entries/recommendations.js +3 -0
  166. package/dist/esm/entries/relationships.js +3 -0
  167. package/dist/esm/entries/root.js +3 -0
  168. package/dist/esm/events/actionGroups.js +1 -0
  169. package/dist/esm/events/alertDefinitionRun.js +1 -0
  170. package/dist/esm/events/baseAlert.js +1 -0
  171. package/dist/esm/events/cost.js +1 -0
  172. package/dist/esm/events/costAnomalies.js +1 -0
  173. package/dist/esm/events/costViews.js +1 -0
  174. package/dist/esm/events/eventStatus.js +1 -0
  175. package/dist/esm/events/index.js +8 -0
  176. package/dist/esm/events/quickAlerts.js +2 -0
  177. package/dist/esm/features-and-permissions/access.js +1 -0
  178. package/dist/esm/features-and-permissions/index.js +1 -0
  179. package/dist/esm/feedbacks/feedback.js +1 -0
  180. package/dist/esm/identity/apikey.js +1 -0
  181. package/dist/esm/identity/index.js +1 -0
  182. package/dist/esm/index.js +57 -0
  183. package/dist/esm/index.vite.js +48 -0
  184. package/dist/esm/integrations/autotask.js +1 -0
  185. package/dist/esm/integrations/azureDevOps.js +1 -0
  186. package/dist/esm/integrations/github.js +1 -0
  187. package/dist/esm/integrations/halo.js +1 -0
  188. package/dist/esm/integrations/index.js +5 -0
  189. package/dist/esm/integrations/integrationTickets.js +1 -0
  190. package/dist/esm/package.json +3 -0
  191. package/dist/esm/scheduler/index.js +1 -0
  192. package/dist/esm/scheduler/scheduler.js +1 -0
  193. package/dist/esm/tags/index.js +1 -0
  194. package/dist/esm/tags/tags.js +6 -0
  195. package/dist/esm/unknown/services.js +1 -0
  196. package/dist/esm/users/companyUser.js +2 -0
  197. package/dist/esm/users/index.js +2 -0
  198. package/dist/esm/users/user.js +1 -0
  199. package/dist/index.d.ts +3 -0
  200. package/dist/index.d.ts.map +1 -1
  201. package/dist/index.js +3 -0
  202. package/dist/index.js.map +1 -1
  203. package/package.json +25 -7
@@ -0,0 +1,464 @@
1
+ import { AWS_PLUGIN_SOURCE_ARTIFACT_TYPES, } from './pluginPublicArtifacts.js';
2
+ import { asRecord, assertAccount, assertExactKeys, assertJsonEqual, assertPublicJson, assertRequiredKeys, assertValue, isoTimestamp, requiredEnum, requiredString, sha256, stringArray, validateBilling, validateMetricWindow, validateSelector, validateTagRuleScope, } from './pluginPublicArtifactValidationHelpers.js';
3
+ export function validateSubscriptionSections(value, target, outputGeneratedAt) {
4
+ const sections = asRecord(value, 'artifact.sections');
5
+ assertExactKeys(sections, [
6
+ 'accountSummary',
7
+ 'resources',
8
+ 'aiCostSummary',
9
+ 'serviceRetirement',
10
+ 'recommendations',
11
+ 'commitmentAnalysis',
12
+ 'reliability',
13
+ 'accountGovernance',
14
+ ], 'artifact.sections');
15
+ validateSection(sections.accountSummary, 'account-summary', target, outputGeneratedAt);
16
+ validateSection(sections.resources, 'resources', target, outputGeneratedAt);
17
+ validateDeclaredOptionalSection(sections.aiCostSummary, 'ai-cost-summary', target.aiCostSummaryTargetKey, target, outputGeneratedAt);
18
+ validateSection(sections.serviceRetirement, 'service-retirement', target, outputGeneratedAt);
19
+ validateSection(sections.recommendations, 'recommendations', target, outputGeneratedAt);
20
+ validateDeclaredOptionalSection(sections.commitmentAnalysis, 'commitment-analysis', target.commitmentAnalysisTargetKey, target, outputGeneratedAt);
21
+ validateDeclaredOptionalSection(sections.reliability, 'reliability', target.reliabilityTargetKey, target, outputGeneratedAt);
22
+ validateDeclaredOptionalSection(sections.accountGovernance, 'account-governance', target.accountGovernanceTargetKey, target, outputGeneratedAt);
23
+ }
24
+ export function validateResourceSections(value, target, outputGeneratedAt) {
25
+ const sections = asRecord(value, 'artifact.sections');
26
+ assertExactKeys(sections, ['resource', 'relationships', 'serviceRetirement', 'recommendations'], 'artifact.sections');
27
+ const resource = validateSection(sections.resource, 'resource', target, outputGeneratedAt);
28
+ if (resource.status !== 'available')
29
+ throw new Error('artifact.sections.resource must be available.');
30
+ assertValue(resource.sourceGeneration.stableKey, target.stableKey, 'artifact.sections.resource.sourceGeneration.stableKey');
31
+ const item = asRecord(asRecord(resource.evidence, 'section.resource.evidence').item, 'section.resource.evidence.item');
32
+ assertValue(item.stableKey, target.stableKey, 'section.resource.evidence.item.stableKey');
33
+ validateSection(sections.relationships, 'relationships', target, outputGeneratedAt);
34
+ validateSection(sections.serviceRetirement, 'service-retirement', target, outputGeneratedAt);
35
+ validateSection(sections.recommendations, 'recommendations', target, outputGeneratedAt);
36
+ }
37
+ function validateDeclaredOptionalSection(value, section, targetKey, target, outputGeneratedAt) {
38
+ if (targetKey === undefined) {
39
+ if (value !== undefined)
40
+ throw new Error(`section.${section} is undeclared by its target.`);
41
+ return;
42
+ }
43
+ if (value === undefined)
44
+ throw new Error(`section.${section} is required by its declared target.`);
45
+ validateSection(value, section, target, outputGeneratedAt);
46
+ }
47
+ function validateSection(value, section, target, outputGeneratedAt) {
48
+ const field = `section.${section}`;
49
+ const bodySection = asRecord(value, field);
50
+ if (bodySection.status === 'available') {
51
+ assertExactKeys(bodySection, ['status', 'section', 'targetKey', 'generatedAt', 'sourceGeneration', 'additionalSourceGenerations', 'evidence'], field);
52
+ assertValue(bodySection.section, section, `${field}.section`);
53
+ const targetKey = requiredString(bodySection.targetKey, `${field}.targetKey`);
54
+ assertValue(targetKey, bodySectionTargetKey(section, target), `${field}.targetKey`);
55
+ const generatedAt = isoTimestamp(bodySection.generatedAt, `${field}.generatedAt`);
56
+ const source = validateSourceBinding(bodySection.sourceGeneration, target.accountId, section, `${field}.sourceGeneration`);
57
+ validateSourceBindingForTarget(source, target, `${field}.sourceGeneration`);
58
+ if (section !== 'recommendations') {
59
+ assertValue(source.targetKey, targetKey, `${field}.sourceGeneration.targetKey`);
60
+ assertValue(source.generatedAt, generatedAt, `${field}.sourceGeneration.generatedAt`);
61
+ }
62
+ if (generatedAt > outputGeneratedAt)
63
+ throw new Error(`${field}.generatedAt cannot exceed output generation time.`);
64
+ validateAdditionalSources(bodySection.additionalSourceGenerations, target, section, source);
65
+ const sources = [source, ...(bodySection.additionalSourceGenerations ?? [])];
66
+ if (section === 'recommendations')
67
+ validateCompleteRecommendationSources(sources, target, field);
68
+ validateEvidence(bodySection.evidence, section, target, source, generatedAt);
69
+ }
70
+ else if (bodySection.status === 'not-found') {
71
+ assertExactKeys(bodySection, ['status', 'section', 'targetKey'], field);
72
+ assertValue(bodySection.section, section, `${field}.section`);
73
+ assertValue(requiredString(bodySection.targetKey, `${field}.targetKey`), bodySectionTargetKey(section, target), `${field}.targetKey`);
74
+ }
75
+ else {
76
+ throw new Error(`${field}.status is not declared.`);
77
+ }
78
+ return bodySection;
79
+ }
80
+ function bodySectionTargetKey(section, target) {
81
+ if (section === 'recommendations')
82
+ return target.recommendationsTargetKey;
83
+ if (target.kind === 'resource-detail') {
84
+ if (section === 'resource')
85
+ return target.resourceCollectionTargetKey;
86
+ if (section === 'relationships')
87
+ return target.relationshipTargetKey;
88
+ if (section === 'service-retirement')
89
+ return target.serviceRetirementTargetKey;
90
+ }
91
+ else {
92
+ const keys = {
93
+ 'account-summary': target.accountSummaryTargetKey,
94
+ resources: target.resourceCollectionTargetKey,
95
+ 'ai-cost-summary': target.aiCostSummaryTargetKey,
96
+ 'service-retirement': target.serviceRetirementTargetKey,
97
+ 'commitment-analysis': target.commitmentAnalysisTargetKey,
98
+ reliability: target.reliabilityTargetKey,
99
+ 'account-governance': target.accountGovernanceTargetKey,
100
+ };
101
+ const key = keys[section];
102
+ if (key)
103
+ return key;
104
+ }
105
+ throw new Error(`section.${section} has no declared target key.`);
106
+ }
107
+ export function validateSourceBinding(value, accountId, section, field) {
108
+ const source = asRecord(value, field);
109
+ assertExactKeys(source, [
110
+ 'provider',
111
+ 'accountId',
112
+ 'section',
113
+ 'sourceArtifactType',
114
+ 'generationId',
115
+ 'generatedAt',
116
+ 'targetKey',
117
+ 'artifactSha256',
118
+ 'billing',
119
+ 'resourceRegions',
120
+ 'selector',
121
+ 'stableKey',
122
+ 'metricTimeWindow',
123
+ 'tagRuleScope',
124
+ ], field);
125
+ assertValue(source.provider, 'aws', `${field}.provider`);
126
+ assertAccount(source.accountId, accountId, `${field}.accountId`);
127
+ assertValue(source.section, section, `${field}.section`);
128
+ requiredEnum(source.sourceArtifactType, AWS_PLUGIN_SOURCE_ARTIFACT_TYPES, `${field}.sourceArtifactType`);
129
+ if (!sourceTypesForSection(section).includes(String(source.sourceArtifactType))) {
130
+ throw new Error(`${field}.sourceArtifactType does not match section ${section}.`);
131
+ }
132
+ requiredString(source.generationId, `${field}.generationId`);
133
+ isoTimestamp(source.generatedAt, `${field}.generatedAt`);
134
+ requiredString(source.targetKey, `${field}.targetKey`);
135
+ sha256(source.artifactSha256, `${field}.artifactSha256`);
136
+ validateBilling(source.billing, `${field}.billing`);
137
+ stringArray(source.resourceRegions, `${field}.resourceRegions`);
138
+ validateMetricWindow(source.metricTimeWindow, `${field}.metricTimeWindow`);
139
+ if (source.selector !== undefined)
140
+ validateSelector(source.selector, `${field}.selector`);
141
+ if (source.stableKey !== undefined)
142
+ requiredString(source.stableKey, `${field}.stableKey`);
143
+ validateTagRuleScope(source.tagRuleScope);
144
+ return value;
145
+ }
146
+ export function validateSourceBindingForTarget(source, target, field) {
147
+ assertJsonEqual(source.billing, target.billing, `${field}.billing`);
148
+ const expectedRegions = target.kind === 'subscription-detail' && source.section === 'service-retirement'
149
+ ? target.serviceRetirementRegions
150
+ : target.kind === 'subscription-detail' && source.section === 'commitment-analysis'
151
+ ? target.commitmentAnalysis?.resourceRegions
152
+ : target.resourceRegions;
153
+ assertJsonEqual(source.resourceRegions, expectedRegions, `${field}.resourceRegions`);
154
+ assertJsonEqual(source.metricTimeWindow, target.metricTimeWindow, `${field}.metricTimeWindow`);
155
+ const expectedTargetKeys = expectedSourceTargetKeys(source, target);
156
+ if (!expectedTargetKeys.includes(source.targetKey)) {
157
+ throw new Error(`${field}.targetKey does not match the exact declared section target.`);
158
+ }
159
+ if (target.kind === 'resource-detail') {
160
+ assertJsonEqual(source.selector, target.selector, `${field}.selector`);
161
+ assertValue(source.stableKey, target.stableKey, `${field}.stableKey`);
162
+ assertJsonEqual(source.tagRuleScope, target.tagRuleScope, `${field}.tagRuleScope`);
163
+ }
164
+ else if (source.selector !== undefined || source.stableKey !== undefined || source.tagRuleScope !== undefined) {
165
+ throw new Error(`${field} contains resource-only selector, stable-key, or tag-rule scope.`);
166
+ }
167
+ }
168
+ function expectedSourceTargetKeys(source, target) {
169
+ if (source.section === 'recommendations') {
170
+ return target.recommendationScopes.map(scope => source.sourceArtifactType === 'recommendation-actionability' ? scope.actionabilityTargetKey : scope.targetKey);
171
+ }
172
+ if (target.kind === 'resource-detail') {
173
+ if (source.section === 'resource')
174
+ return [target.resourceCollectionTargetKey];
175
+ if (source.section === 'relationships')
176
+ return [target.relationshipTargetKey];
177
+ if (source.section === 'service-retirement')
178
+ return [target.serviceRetirementTargetKey];
179
+ }
180
+ else {
181
+ const targetBySection = {
182
+ 'account-summary': target.accountSummaryTargetKey,
183
+ resources: target.resourceCollectionTargetKey,
184
+ 'ai-cost-summary': target.aiCostSummaryTargetKey,
185
+ 'service-retirement': target.serviceRetirementTargetKey,
186
+ 'commitment-analysis': target.commitmentAnalysisTargetKey,
187
+ reliability: target.reliabilityTargetKey,
188
+ 'account-governance': target.accountGovernanceTargetKey,
189
+ };
190
+ const targetKey = targetBySection[source.section];
191
+ if (targetKey)
192
+ return [targetKey];
193
+ }
194
+ throw new Error(`No exact target is declared for ${source.section}/${source.sourceArtifactType}.`);
195
+ }
196
+ function validateAdditionalSources(value, target, section, primary) {
197
+ if (value === undefined)
198
+ return;
199
+ if (!Array.isArray(value) || value.length === 0) {
200
+ throw new Error(`section.${section}.additionalSourceGenerations must be a non-empty array when declared.`);
201
+ }
202
+ const identities = new Set([sourceIdentity(primary)]);
203
+ value.forEach((source, index) => {
204
+ const field = `section.${section}.additionalSourceGenerations[${index}]`;
205
+ const binding = validateSourceBinding(source, target.accountId, section, field);
206
+ validateSourceBindingForTarget(binding, target, field);
207
+ const identity = sourceIdentity(binding);
208
+ if (identities.has(identity))
209
+ throw new Error(`section.${section} contains a duplicate source-generation binding.`);
210
+ identities.add(identity);
211
+ });
212
+ }
213
+ function sourceIdentity(source) {
214
+ return [source.section, source.sourceArtifactType, source.generationId, source.targetKey, source.artifactSha256].join('|');
215
+ }
216
+ function validateCompleteRecommendationSources(sources, target, field) {
217
+ const expected = target.recommendationScopes.flatMap(scope => [
218
+ `recommendations|${scope.targetKey}`,
219
+ `recommendation-actionability|${scope.actionabilityTargetKey}`,
220
+ ]);
221
+ const actual = sources.map(source => `${source.sourceArtifactType}|${source.targetKey}`);
222
+ assertJsonEqual([...actual].sort(), [...expected].sort(), `${field}.sourceGenerations complete recommendation source set`);
223
+ }
224
+ function sourceTypesForSection(section) {
225
+ const sourceBySection = {
226
+ 'account-summary': ['account-summary'],
227
+ resources: ['resource-collection'],
228
+ resource: ['resource-collection'],
229
+ 'ai-cost-summary': ['ai-cost-summary'],
230
+ relationships: ['relationships'],
231
+ 'service-retirement': ['lifecycle'],
232
+ recommendations: ['recommendations', 'recommendation-actionability'],
233
+ 'commitment-analysis': ['commitment-analysis'],
234
+ reliability: ['reliability'],
235
+ 'account-governance': ['account-governance'],
236
+ };
237
+ const source = sourceBySection[section];
238
+ if (!source)
239
+ throw new Error(`section ${section} is not declared.`);
240
+ return source;
241
+ }
242
+ function validateEvidence(value, section, target, source, generatedAt) {
243
+ const field = `section.${section}.evidence`;
244
+ const evidence = asRecord(value, field);
245
+ const shape = EVIDENCE_SHAPES[section];
246
+ if (!shape)
247
+ throw new Error(`section ${section} has no declared evidence contract.`);
248
+ assertExactKeys(evidence, shape.allowed, field);
249
+ const required = section === 'service-retirement'
250
+ ? 'summary' in evidence || 'entries' in evidence
251
+ ? ['summary', 'entries']
252
+ : ['stats', 'refreshMetadataBySource', 'refreshMetadataByFamily', 'highlights']
253
+ : shape.required;
254
+ assertRequiredKeys(evidence, required, field);
255
+ assertPublicJson(evidence, field);
256
+ validateEvidenceStructure(evidence, section, target, source, generatedAt, field);
257
+ }
258
+ function validateEvidenceStructure(evidence, section, target, source, generatedAt, field) {
259
+ if (section === 'account-summary') {
260
+ const artifact = asRecord(evidence.artifact, `${field}.artifact`);
261
+ assertExactKeys(artifact, ['artifactType', 'artifactVersion', 'generatedAt', 'scope', 'account', 'billing', 'discovery', 'metrics', 'recommendations'], `${field}.artifact`);
262
+ assertValue(artifact.artifactType, 'account-summary', `${field}.artifact.artifactType`);
263
+ assertValue(artifact.artifactVersion, 1, `${field}.artifact.artifactVersion`);
264
+ assertValue(isoTimestamp(artifact.generatedAt, `${field}.artifact.generatedAt`), generatedAt, `${field}.artifact.generatedAt`);
265
+ assertValue(source.generatedAt, generatedAt, `${field}.sourceGeneration.generatedAt`);
266
+ validatePortalScope(artifact.scope, target, `${field}.artifact.scope`);
267
+ }
268
+ else if (section === 'resources') {
269
+ validateResourceSummary(evidence.summary, `${field}.summary`);
270
+ asRecord(evidence.coverage, `${field}.coverage`);
271
+ validateResourceItems(evidence.highlights, `${field}.highlights`);
272
+ }
273
+ else if (section === 'resource') {
274
+ validateResourceItems([evidence.item], `${field}.item`);
275
+ }
276
+ else if (section === 'ai-cost-summary') {
277
+ requiredEnum(evidence.audience, ['portal', 'plugin'], `${field}.audience`);
278
+ assertValue(evidence.audience, target.kind === 'subscription-detail' ? target.aiCostSummaryAudience : undefined, `${field}.audience`);
279
+ isoTimestamp(evidence.sourceAccountSummaryGeneratedAt, `${field}.sourceAccountSummaryGeneratedAt`);
280
+ asRecord(evidence.artifact, `${field}.artifact`);
281
+ }
282
+ else if (section === 'recommendations') {
283
+ validateRecommendationEvidence(evidence, target, field);
284
+ }
285
+ else if (section === 'relationships') {
286
+ requiredString(evidence.anchorNodeId, `${field}.anchorNodeId`);
287
+ const stats = asRecord(evidence.stats, `${field}.stats`);
288
+ assertExactKeys(stats, ['directNodeCount', 'directEdgeCount', 'unresolvedCount'], `${field}.stats`);
289
+ ['directNodeCount', 'directEdgeCount', 'unresolvedCount'].forEach(key => nonNegativeInteger(stats[key], `${field}.stats.${key}`));
290
+ ['nodes', 'edges', 'unresolved'].forEach(key => jsonArray(evidence[key], `${field}.${key}`));
291
+ }
292
+ else if (section === 'service-retirement') {
293
+ if ('summary' in evidence) {
294
+ const summary = asRecord(evidence.summary, `${field}.summary`);
295
+ assertExactKeys(summary, ['matchedEntryCount', 'totalArtifactEntryCount'], `${field}.summary`);
296
+ nonNegativeInteger(summary.matchedEntryCount, `${field}.summary.matchedEntryCount`);
297
+ nonNegativeInteger(summary.totalArtifactEntryCount, `${field}.summary.totalArtifactEntryCount`);
298
+ jsonArray(evidence.entries, `${field}.entries`);
299
+ }
300
+ else {
301
+ const stats = asRecord(evidence.stats, `${field}.stats`);
302
+ assertExactKeys(stats, ['entryCount', 'matchedResourceCount', 'unmatchedSourceEntryCount', 'truncated'], `${field}.stats`);
303
+ ['entryCount', 'matchedResourceCount', 'unmatchedSourceEntryCount'].forEach(key => nonNegativeInteger(stats[key], `${field}.stats.${key}`));
304
+ assertValue(stats.truncated, false, `${field}.stats.truncated`);
305
+ jsonArray(evidence.highlights, `${field}.highlights`);
306
+ }
307
+ }
308
+ else if (section === 'reliability') {
309
+ asRecord(evidence.request, `${field}.request`);
310
+ asRecord(evidence.summary, `${field}.summary`);
311
+ jsonArray(evidence.sections, `${field}.sections`);
312
+ }
313
+ else if (section === 'account-governance') {
314
+ asRecord(evidence.workflow, `${field}.workflow`);
315
+ const checklist = asRecord(evidence.checklist, `${field}.checklist`);
316
+ assertRequiredKeys(checklist, ['present', 'targetKey'], `${field}.checklist`);
317
+ if (typeof checklist.present !== 'boolean')
318
+ throw new Error(`${field}.checklist.present must be boolean.`);
319
+ requiredString(checklist.targetKey, `${field}.checklist.targetKey`);
320
+ }
321
+ else {
322
+ for (const [key, child] of Object.entries(evidence)) {
323
+ if (key !== 'evidenceSource' && !Array.isArray(child))
324
+ asRecord(child, `${field}.${key}`);
325
+ }
326
+ }
327
+ }
328
+ function validatePortalScope(value, target, field) {
329
+ const scope = asRecord(value, field);
330
+ assertExactKeys(scope, ['provider', 'accountId', 'billing', 'resourceRegions', 'metricTimeWindow'], field);
331
+ assertValue(scope.provider, 'aws', `${field}.provider`);
332
+ assertAccount(scope.accountId, target.accountId, `${field}.accountId`);
333
+ assertJsonEqual(scope.billing, target.billing, `${field}.billing`);
334
+ assertJsonEqual(scope.resourceRegions, target.resourceRegions, `${field}.resourceRegions`);
335
+ assertJsonEqual(scope.metricTimeWindow, target.metricTimeWindow, `${field}.metricTimeWindow`);
336
+ }
337
+ function validateResourceSummary(value, field) {
338
+ const summary = asRecord(value, field);
339
+ const keys = [
340
+ 'totalDiscoveredResourceCount',
341
+ 'returnedResourceCount',
342
+ 'emptyCollection',
343
+ 'truncated',
344
+ 'unmatchedRecommendationResourceCount',
345
+ 'unmatchedBillingExpenseCount',
346
+ ];
347
+ assertExactKeys(summary, keys, field);
348
+ keys.filter(key => !['emptyCollection', 'truncated'].includes(key)).forEach(key => nonNegativeInteger(summary[key], `${field}.${key}`));
349
+ if (typeof summary.emptyCollection !== 'boolean' || typeof summary.truncated !== 'boolean')
350
+ throw new Error(`${field} flags must be boolean.`);
351
+ }
352
+ function validateResourceItems(value, field) {
353
+ jsonArray(value, field).forEach((item, index) => {
354
+ const itemField = `${field}[${index}]`;
355
+ const resource = asRecord(item, itemField);
356
+ assertRequiredKeys(resource, ['stableKey', 'family', 'resourceRegion', 'resourceType', 'discovery'], itemField);
357
+ ['stableKey', 'family', 'resourceRegion', 'resourceType'].forEach(key => requiredString(resource[key], `${itemField}.${key}`));
358
+ asRecord(resource.discovery, `${itemField}.discovery`);
359
+ });
360
+ }
361
+ function validateRecommendationEvidence(evidence, target, field) {
362
+ const summary = asRecord(evidence.summary, `${field}.summary`);
363
+ ['requestedScopeCount', 'availableScopeCount', 'notFoundScopeCount'].forEach(key => nonNegativeInteger(summary[key], `${field}.summary.${key}`));
364
+ const allowedSummary = ['requestedScopeCount', 'availableScopeCount', 'notFoundScopeCount', 'unsupportedScopeCount'];
365
+ assertExactKeys(summary, allowedSummary, `${field}.summary`);
366
+ assertValue(summary.requestedScopeCount, target.recommendationScopes.length, `${field}.summary.requestedScopeCount`);
367
+ const sections = jsonArray(evidence.sections, `${field}.sections`);
368
+ assertValue(sections.length, target.recommendationScopes.length, `${field}.sections.length`);
369
+ const matchedTargets = new Set();
370
+ const statusCounts = { available: 0, 'not-found': 0, 'unsupported-resource-identity': 0 };
371
+ sections.forEach((value, index) => {
372
+ const section = asRecord(value, `${field}.sections[${index}]`);
373
+ const status = requiredEnum(section.status, ['available', 'not-found', 'unsupported-resource-identity'], `${field}.sections[${index}].status`);
374
+ const source = requiredEnum(section.source, ['custom', 'compute-optimizer', 'cost-optimization-hub', 'resilience-hub', 'security-hub', 'trusted-advisor', 'well-architected'], `${field}.sections[${index}].source`);
375
+ statusCounts[status] += 1;
376
+ const targetKey = status === 'unsupported-resource-identity'
377
+ ? target.recommendationScopes.find(scope => scope.source === source && !matchedTargets.has(scope.targetKey))?.targetKey
378
+ : requiredString(section.targetKey, `${field}.sections[${index}].targetKey`);
379
+ const scope = target.recommendationScopes.find(candidate => candidate.targetKey === targetKey && candidate.source === source);
380
+ if (!scope || matchedTargets.has(scope.targetKey))
381
+ throw new Error(`${field}.sections[${index}] does not match one exact declared recommendation scope.`);
382
+ matchedTargets.add(scope.targetKey);
383
+ if (status === 'available') {
384
+ assertExactKeys(section, target.kind === 'subscription-detail'
385
+ ? [
386
+ 'status',
387
+ 'source',
388
+ 'targetKey',
389
+ 'generatedAt',
390
+ 'scope',
391
+ 'filters',
392
+ 'summary',
393
+ 'counts',
394
+ 'savings',
395
+ 'evidenceFreshness',
396
+ 'templateProvenance',
397
+ 'actionability',
398
+ 'highlights',
399
+ ]
400
+ : ['status', 'source', 'targetKey', 'generatedAt', 'evidenceFreshness', 'templateProvenance', 'actionability', 'artifact'], `${field}.sections[${index}]`);
401
+ isoTimestamp(section.generatedAt, `${field}.sections[${index}].generatedAt`);
402
+ if (target.kind === 'subscription-detail') {
403
+ assertRequiredKeys(section, ['scope', 'filters', 'summary', 'counts', 'savings', 'highlights'], `${field}.sections[${index}]`);
404
+ validateRecommendationScope(section.scope, scope, `${field}.sections[${index}].scope`);
405
+ jsonArray(section.highlights, `${field}.sections[${index}].highlights`);
406
+ }
407
+ else {
408
+ assertRequiredKeys(section, ['artifact'], `${field}.sections[${index}]`);
409
+ asRecord(section.artifact, `${field}.sections[${index}].artifact`);
410
+ }
411
+ }
412
+ else if (status === 'not-found') {
413
+ assertExactKeys(section, ['status', 'source', 'targetKey'], `${field}.sections[${index}]`);
414
+ }
415
+ else {
416
+ assertExactKeys(section, ['status', 'source'], `${field}.sections[${index}]`);
417
+ }
418
+ });
419
+ assertValue(summary.availableScopeCount, statusCounts.available, `${field}.summary.availableScopeCount`);
420
+ assertValue(summary.notFoundScopeCount, statusCounts['not-found'], `${field}.summary.notFoundScopeCount`);
421
+ if (summary.unsupportedScopeCount !== undefined) {
422
+ assertValue(summary.unsupportedScopeCount, statusCounts['unsupported-resource-identity'], `${field}.summary.unsupportedScopeCount`);
423
+ }
424
+ else if (statusCounts['unsupported-resource-identity'] > 0) {
425
+ throw new Error(`${field}.summary.unsupportedScopeCount is required.`);
426
+ }
427
+ }
428
+ function validateRecommendationScope(value, expected, field) {
429
+ const scope = asRecord(value, field);
430
+ assertExactKeys(scope, ['source', 'scope', 'accountId', 'scopeDiscriminator', 'computeOptimizerFamily', 'resourceRegions'], field);
431
+ for (const key of ['source', 'scope', 'accountId', 'scopeDiscriminator', 'computeOptimizerFamily', 'resourceRegions']) {
432
+ assertJsonEqual(scope[key], expected[key], `${field}.${key}`);
433
+ }
434
+ }
435
+ function jsonArray(value, field) {
436
+ if (!Array.isArray(value))
437
+ throw new Error(`${field} must be an array.`);
438
+ return value;
439
+ }
440
+ function nonNegativeInteger(value, field) {
441
+ if (!Number.isSafeInteger(value) || Number(value) < 0)
442
+ throw new Error(`${field} must be a non-negative safe integer.`);
443
+ }
444
+ const EVIDENCE_SHAPES = {
445
+ 'account-summary': { allowed: ['artifact'], required: ['artifact'] },
446
+ resources: { allowed: ['summary', 'coverage', 'highlights'], required: ['summary', 'coverage', 'highlights'] },
447
+ 'ai-cost-summary': {
448
+ allowed: ['audience', 'sourceAccountSummaryGeneratedAt', 'artifact'],
449
+ required: ['audience', 'sourceAccountSummaryGeneratedAt', 'artifact'],
450
+ },
451
+ 'service-retirement': {
452
+ allowed: ['stats', 'refreshMetadataBySource', 'refreshMetadataByFamily', 'highlights', 'summary', 'entries'],
453
+ required: [],
454
+ },
455
+ recommendations: { allowed: ['summary', 'sections'], required: ['summary', 'sections'] },
456
+ 'commitment-analysis': { allowed: ['request', 'billing', 'benefitExpiry', 'evidenceSource'], required: ['billing', 'benefitExpiry'] },
457
+ reliability: { allowed: ['request', 'summary', 'sections'], required: ['request', 'summary', 'sections'] },
458
+ 'account-governance': { allowed: ['workflow', 'checklist', 'complianceResults'], required: ['workflow', 'checklist'] },
459
+ resource: { allowed: ['item'], required: ['item'] },
460
+ relationships: {
461
+ allowed: ['anchorNodeId', 'stats', 'nodes', 'edges', 'unresolved'],
462
+ required: ['anchorNodeId', 'stats', 'nodes', 'edges', 'unresolved'],
463
+ },
464
+ };
@@ -0,0 +1,2 @@
1
+ export { validateAwsPluginResourceDetailArtifact, validateAwsPluginSubscriptionDetailArtifact } from './pluginPublicArtifactBodyValidation.js';
2
+ export { validateAwsPluginGenerationManifest } from './pluginPublicArtifactManifestValidation.js';