1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ sbom.json
|
|||||||
sbom-docker.json
|
sbom-docker.json
|
||||||
*_sbom.json
|
*_sbom.json
|
||||||
*.out
|
*.out
|
||||||
|
*.DS_Store
|
||||||
|
|||||||
279
apps/console/src/hooks/graph/AuditGraph.ts
Normal file
279
apps/console/src/hooks/graph/AuditGraph.ts
Normal file
@@ -0,0 +1,279 @@
|
|||||||
|
import { graphql } from "relay-runtime";
|
||||||
|
import { useMutation } from "react-relay";
|
||||||
|
import { useConfirm } from "@probo/ui";
|
||||||
|
import { useTranslate } from "@probo/i18n";
|
||||||
|
import { promisifyMutation, sprintf } from "@probo/helpers";
|
||||||
|
import { useMutationWithToasts } from "../useMutationWithToasts";
|
||||||
|
|
||||||
|
export const auditsQuery = graphql`
|
||||||
|
query AuditGraphListQuery($organizationId: ID!) {
|
||||||
|
node(id: $organizationId) {
|
||||||
|
... on Organization {
|
||||||
|
...AuditsPageFragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const auditNodeQuery = graphql`
|
||||||
|
query AuditGraphNodeQuery($auditId: ID!) {
|
||||||
|
node(id: $auditId) {
|
||||||
|
... on Audit {
|
||||||
|
id
|
||||||
|
validFrom
|
||||||
|
validUntil
|
||||||
|
report {
|
||||||
|
id
|
||||||
|
filename
|
||||||
|
mimeType
|
||||||
|
size
|
||||||
|
downloadUrl
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
reportUrl
|
||||||
|
state
|
||||||
|
framework {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
organization {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const createAuditMutation = graphql`
|
||||||
|
mutation AuditGraphCreateMutation(
|
||||||
|
$input: CreateAuditInput!
|
||||||
|
$connections: [ID!]!
|
||||||
|
) {
|
||||||
|
createAudit(input: $input) {
|
||||||
|
auditEdge @prependEdge(connections: $connections) {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
validFrom
|
||||||
|
validUntil
|
||||||
|
report {
|
||||||
|
id
|
||||||
|
filename
|
||||||
|
}
|
||||||
|
state
|
||||||
|
framework {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const updateAuditMutation = graphql`
|
||||||
|
mutation AuditGraphUpdateMutation($input: UpdateAuditInput!) {
|
||||||
|
updateAudit(input: $input) {
|
||||||
|
audit {
|
||||||
|
id
|
||||||
|
validFrom
|
||||||
|
validUntil
|
||||||
|
report {
|
||||||
|
id
|
||||||
|
filename
|
||||||
|
}
|
||||||
|
state
|
||||||
|
framework {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const deleteAuditMutation = graphql`
|
||||||
|
mutation AuditGraphDeleteMutation(
|
||||||
|
$input: DeleteAuditInput!
|
||||||
|
$connections: [ID!]!
|
||||||
|
) {
|
||||||
|
deleteAudit(input: $input) {
|
||||||
|
deletedAuditId @deleteEdge(connections: $connections)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const useDeleteAudit = (
|
||||||
|
audit: { id: string; framework: { name: string } },
|
||||||
|
connectionId: string
|
||||||
|
) => {
|
||||||
|
const { __ } = useTranslate();
|
||||||
|
const [mutate] = useMutationWithToasts(deleteAuditMutation, {
|
||||||
|
successMessage: __("Audit deleted successfully"),
|
||||||
|
errorMessage: __("Failed to delete audit"),
|
||||||
|
});
|
||||||
|
const confirm = useConfirm();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
confirm(
|
||||||
|
() =>
|
||||||
|
mutate({
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
auditId: audit.id!,
|
||||||
|
},
|
||||||
|
connections: [connectionId],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
message: sprintf(
|
||||||
|
__(
|
||||||
|
"This will permanently delete the audit for %s. This action cannot be undone."
|
||||||
|
),
|
||||||
|
audit.framework.name
|
||||||
|
),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useCreateAudit = (connectionId: string) => {
|
||||||
|
const [mutate] = useMutation(createAuditMutation);
|
||||||
|
const { __ } = useTranslate();
|
||||||
|
|
||||||
|
return (input: {
|
||||||
|
organizationId: string;
|
||||||
|
frameworkId: string;
|
||||||
|
validFrom?: string;
|
||||||
|
validUntil?: string;
|
||||||
|
reportKey?: string;
|
||||||
|
state?: string;
|
||||||
|
}) => {
|
||||||
|
if (!input.organizationId) {
|
||||||
|
return alert(__("Failed to create audit: organization is required"));
|
||||||
|
}
|
||||||
|
if (!input.frameworkId) {
|
||||||
|
return alert(__("Failed to create audit: framework is required"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return promisifyMutation(mutate)({
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
organizationId: input.organizationId,
|
||||||
|
frameworkId: input.frameworkId,
|
||||||
|
validFrom: input.validFrom,
|
||||||
|
validUntil: input.validUntil,
|
||||||
|
reportKey: input.reportKey,
|
||||||
|
state: input.state || "NOT_STARTED",
|
||||||
|
},
|
||||||
|
connections: [connectionId],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useUpdateAudit = () => {
|
||||||
|
const [mutate] = useMutation(updateAuditMutation);
|
||||||
|
const { __ } = useTranslate();
|
||||||
|
|
||||||
|
return (input: {
|
||||||
|
id: string;
|
||||||
|
validFrom?: string;
|
||||||
|
validUntil?: string;
|
||||||
|
state?: string;
|
||||||
|
}) => {
|
||||||
|
if (!input.id) {
|
||||||
|
return alert(__("Failed to update audit: audit ID is required"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return promisifyMutation(mutate)({
|
||||||
|
variables: {
|
||||||
|
input,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const uploadAuditReportMutation = graphql`
|
||||||
|
mutation AuditGraphUploadReportMutation($input: UploadAuditReportInput!) {
|
||||||
|
uploadAuditReport(input: $input) {
|
||||||
|
audit {
|
||||||
|
id
|
||||||
|
report {
|
||||||
|
id
|
||||||
|
filename
|
||||||
|
downloadUrl
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const useUploadAuditReport = () => {
|
||||||
|
const { __ } = useTranslate();
|
||||||
|
const [mutate, isLoading] = useMutationWithToasts(uploadAuditReportMutation, {
|
||||||
|
successMessage: __("Audit report uploaded successfully"),
|
||||||
|
errorMessage: __("Failed to upload audit report"),
|
||||||
|
});
|
||||||
|
|
||||||
|
const uploadAuditReport = (input: { auditId: string; file: File }) => {
|
||||||
|
if (!input.auditId) {
|
||||||
|
return alert(__("Failed to upload report: audit ID is required"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return mutate({
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
auditId: input.auditId,
|
||||||
|
file: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
uploadables: {
|
||||||
|
"input.file": input.file,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return [uploadAuditReport, isLoading] as const;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteAuditReportMutation = graphql`
|
||||||
|
mutation AuditGraphDeleteReportMutation($input: DeleteAuditReportInput!) {
|
||||||
|
deleteAuditReport(input: $input) {
|
||||||
|
audit {
|
||||||
|
id
|
||||||
|
report {
|
||||||
|
id
|
||||||
|
filename
|
||||||
|
downloadUrl
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const useDeleteAuditReport = () => {
|
||||||
|
const { __ } = useTranslate();
|
||||||
|
const [mutate] = useMutationWithToasts(deleteAuditReportMutation, {
|
||||||
|
successMessage: __("Audit report deleted successfully"),
|
||||||
|
errorMessage: __("Failed to delete audit report"),
|
||||||
|
});
|
||||||
|
|
||||||
|
return (input: { auditId: string }) => {
|
||||||
|
return mutate({
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
auditId: input.auditId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
242
apps/console/src/hooks/graph/__generated__/AuditGraphCreateMutation.graphql.ts
generated
Normal file
242
apps/console/src/hooks/graph/__generated__/AuditGraphCreateMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<fd92d4fe2e50fc37c5ae6eda9058f650>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type AuditState = "COMPLETED" | "IN_PROGRESS" | "NOT_STARTED" | "OUTDATED" | "REJECTED";
|
||||||
|
export type CreateAuditInput = {
|
||||||
|
frameworkId: string;
|
||||||
|
organizationId: string;
|
||||||
|
state?: AuditState | null | undefined;
|
||||||
|
validFrom?: any | null | undefined;
|
||||||
|
validUntil?: any | null | undefined;
|
||||||
|
};
|
||||||
|
export type AuditGraphCreateMutation$variables = {
|
||||||
|
connections: ReadonlyArray<string>;
|
||||||
|
input: CreateAuditInput;
|
||||||
|
};
|
||||||
|
export type AuditGraphCreateMutation$data = {
|
||||||
|
readonly createAudit: {
|
||||||
|
readonly auditEdge: {
|
||||||
|
readonly node: {
|
||||||
|
readonly createdAt: any;
|
||||||
|
readonly framework: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
readonly id: string;
|
||||||
|
readonly report: {
|
||||||
|
readonly filename: string;
|
||||||
|
readonly id: string;
|
||||||
|
} | null | undefined;
|
||||||
|
readonly state: AuditState;
|
||||||
|
readonly validFrom: any | null | undefined;
|
||||||
|
readonly validUntil: any | null | undefined;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AuditGraphCreateMutation = {
|
||||||
|
response: AuditGraphCreateMutation$data;
|
||||||
|
variables: AuditGraphCreateMutation$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "connections"
|
||||||
|
},
|
||||||
|
v1 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "input"
|
||||||
|
},
|
||||||
|
v2 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "input",
|
||||||
|
"variableName": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v3 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v4 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "AuditEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "auditEdge",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Audit",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validFrom",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validUntil",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Report",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "report",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "filename",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "state",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Framework",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "framework",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "createdAt",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AuditGraphCreateMutation",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "CreateAuditPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "createAudit",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v4/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Mutation",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v0/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AuditGraphCreateMutation",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "CreateAuditPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "createAudit",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v4/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"filters": null,
|
||||||
|
"handle": "prependEdge",
|
||||||
|
"key": "",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "auditEdge",
|
||||||
|
"handleArgs": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "connections",
|
||||||
|
"variableName": "connections"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "5c941d42e42700b5e06a5a64c861054b",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AuditGraphCreateMutation",
|
||||||
|
"operationKind": "mutation",
|
||||||
|
"text": "mutation AuditGraphCreateMutation(\n $input: CreateAuditInput!\n) {\n createAudit(input: $input) {\n auditEdge {\n node {\n id\n validFrom\n validUntil\n report {\n id\n filename\n }\n state\n framework {\n id\n name\n }\n createdAt\n }\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "231fafa942acf107e2f0187bccc844da";
|
||||||
|
|
||||||
|
export default node;
|
||||||
132
apps/console/src/hooks/graph/__generated__/AuditGraphDeleteMutation.graphql.ts
generated
Normal file
132
apps/console/src/hooks/graph/__generated__/AuditGraphDeleteMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<abf5473524b2c61dd92c4975aa4b21f1>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type DeleteAuditInput = {
|
||||||
|
auditId: string;
|
||||||
|
};
|
||||||
|
export type AuditGraphDeleteMutation$variables = {
|
||||||
|
connections: ReadonlyArray<string>;
|
||||||
|
input: DeleteAuditInput;
|
||||||
|
};
|
||||||
|
export type AuditGraphDeleteMutation$data = {
|
||||||
|
readonly deleteAudit: {
|
||||||
|
readonly deletedAuditId: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AuditGraphDeleteMutation = {
|
||||||
|
response: AuditGraphDeleteMutation$data;
|
||||||
|
variables: AuditGraphDeleteMutation$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "connections"
|
||||||
|
},
|
||||||
|
v1 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "input"
|
||||||
|
},
|
||||||
|
v2 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "input",
|
||||||
|
"variableName": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v3 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "deletedAuditId",
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AuditGraphDeleteMutation",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "DeleteAuditPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "deleteAudit",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Mutation",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v0/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AuditGraphDeleteMutation",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v2/*: any*/),
|
||||||
|
"concreteType": "DeleteAuditPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "deleteAudit",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"filters": null,
|
||||||
|
"handle": "deleteEdge",
|
||||||
|
"key": "",
|
||||||
|
"kind": "ScalarHandle",
|
||||||
|
"name": "deletedAuditId",
|
||||||
|
"handleArgs": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "connections",
|
||||||
|
"variableName": "connections"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "48906b2f55360bea9a8fc7f0daea34be",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AuditGraphDeleteMutation",
|
||||||
|
"operationKind": "mutation",
|
||||||
|
"text": "mutation AuditGraphDeleteMutation(\n $input: DeleteAuditInput!\n) {\n deleteAudit(input: $input) {\n deletedAuditId\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "e0f3771289e512982adc900199820821";
|
||||||
|
|
||||||
|
export default node;
|
||||||
153
apps/console/src/hooks/graph/__generated__/AuditGraphDeleteReportMutation.graphql.ts
generated
Normal file
153
apps/console/src/hooks/graph/__generated__/AuditGraphDeleteReportMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<14b4821bc7eec6b85029d0aae3a3a271>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type DeleteAuditReportInput = {
|
||||||
|
auditId: string;
|
||||||
|
};
|
||||||
|
export type AuditGraphDeleteReportMutation$variables = {
|
||||||
|
input: DeleteAuditReportInput;
|
||||||
|
};
|
||||||
|
export type AuditGraphDeleteReportMutation$data = {
|
||||||
|
readonly deleteAuditReport: {
|
||||||
|
readonly audit: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly report: {
|
||||||
|
readonly createdAt: any;
|
||||||
|
readonly downloadUrl: string | null | undefined;
|
||||||
|
readonly filename: string;
|
||||||
|
readonly id: string;
|
||||||
|
} | null | undefined;
|
||||||
|
readonly updatedAt: any;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AuditGraphDeleteReportMutation = {
|
||||||
|
response: AuditGraphDeleteReportMutation$data;
|
||||||
|
variables: AuditGraphDeleteReportMutation$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v2 = [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "input",
|
||||||
|
"variableName": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"concreteType": "DeleteAuditReportPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "deleteAuditReport",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Audit",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "audit",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Report",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "report",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "filename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "downloadUrl",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "createdAt",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "updatedAt",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AuditGraphDeleteReportMutation",
|
||||||
|
"selections": (v2/*: any*/),
|
||||||
|
"type": "Mutation",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AuditGraphDeleteReportMutation",
|
||||||
|
"selections": (v2/*: any*/)
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "ebceb2fd2a2ffae09bc1578e37dde7e0",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AuditGraphDeleteReportMutation",
|
||||||
|
"operationKind": "mutation",
|
||||||
|
"text": "mutation AuditGraphDeleteReportMutation(\n $input: DeleteAuditReportInput!\n) {\n deleteAuditReport(input: $input) {\n audit {\n id\n report {\n id\n filename\n downloadUrl\n createdAt\n }\n updatedAt\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "4b5e9537b35458eb3daa313ead9ba655";
|
||||||
|
|
||||||
|
export default node;
|
||||||
307
apps/console/src/hooks/graph/__generated__/AuditGraphListQuery.graphql.ts
generated
Normal file
307
apps/console/src/hooks/graph/__generated__/AuditGraphListQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,307 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<421ff1807db813d87849e15e60fc958e>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
import { FragmentRefs } from "relay-runtime";
|
||||||
|
export type AuditGraphListQuery$variables = {
|
||||||
|
organizationId: string;
|
||||||
|
};
|
||||||
|
export type AuditGraphListQuery$data = {
|
||||||
|
readonly node: {
|
||||||
|
readonly " $fragmentSpreads": FragmentRefs<"AuditsPageFragment">;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AuditGraphListQuery = {
|
||||||
|
response: AuditGraphListQuery$data;
|
||||||
|
variables: AuditGraphListQuery$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "organizationId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "id",
|
||||||
|
"variableName": "organizationId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v2 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v3 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v4 = [
|
||||||
|
{
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "first",
|
||||||
|
"value": 10
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AuditGraphListQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"args": null,
|
||||||
|
"kind": "FragmentSpread",
|
||||||
|
"name": "AuditsPageFragment"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Query",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AuditGraphListQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v4/*: any*/),
|
||||||
|
"concreteType": "AuditConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "audits",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "AuditEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Audit",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validFrom",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validUntil",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Report",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "report",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "filename",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "state",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Framework",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "framework",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "createdAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v2/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "cursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "PageInfo",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "pageInfo",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "endCursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasNextPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasPreviousPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "startCursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ClientExtension",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__id",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": "audits(first:10)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v4/*: any*/),
|
||||||
|
"filters": [
|
||||||
|
"orderBy"
|
||||||
|
],
|
||||||
|
"handle": "connection",
|
||||||
|
"key": "AuditsPage_audits",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "audits"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "1c53759e5b25eb390345fee12e536896",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AuditGraphListQuery",
|
||||||
|
"operationKind": "query",
|
||||||
|
"text": "query AuditGraphListQuery(\n $organizationId: ID!\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n ...AuditsPageFragment\n }\n id\n }\n}\n\nfragment AuditsPageFragment on Organization {\n audits(first: 10) {\n edges {\n node {\n id\n validFrom\n validUntil\n report {\n id\n filename\n }\n state\n framework {\n id\n name\n }\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "3a082303ae15c8982a08c3bae8312846";
|
||||||
|
|
||||||
|
export default node;
|
||||||
278
apps/console/src/hooks/graph/__generated__/AuditGraphNodeQuery.graphql.ts
generated
Normal file
278
apps/console/src/hooks/graph/__generated__/AuditGraphNodeQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,278 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<597dc89a18faf5837517c12ab6046991>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type AuditState = "COMPLETED" | "IN_PROGRESS" | "NOT_STARTED" | "OUTDATED" | "REJECTED";
|
||||||
|
export type AuditGraphNodeQuery$variables = {
|
||||||
|
auditId: string;
|
||||||
|
};
|
||||||
|
export type AuditGraphNodeQuery$data = {
|
||||||
|
readonly node: {
|
||||||
|
readonly createdAt?: any;
|
||||||
|
readonly framework?: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
readonly id?: string;
|
||||||
|
readonly organization?: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
readonly report?: {
|
||||||
|
readonly createdAt: any;
|
||||||
|
readonly downloadUrl: string | null | undefined;
|
||||||
|
readonly filename: string;
|
||||||
|
readonly id: string;
|
||||||
|
readonly mimeType: string;
|
||||||
|
readonly size: number;
|
||||||
|
} | null | undefined;
|
||||||
|
readonly reportUrl?: string | null | undefined;
|
||||||
|
readonly state?: AuditState;
|
||||||
|
readonly updatedAt?: any;
|
||||||
|
readonly validFrom?: any | null | undefined;
|
||||||
|
readonly validUntil?: any | null | undefined;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AuditGraphNodeQuery = {
|
||||||
|
response: AuditGraphNodeQuery$data;
|
||||||
|
variables: AuditGraphNodeQuery$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "auditId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "id",
|
||||||
|
"variableName": "auditId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v2 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v3 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validFrom",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v4 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validUntil",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v5 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "createdAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v6 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Report",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "report",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "filename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "mimeType",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "size",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "downloadUrl",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v5/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v7 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "reportUrl",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v8 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "state",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v9 = [
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v10 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Framework",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "framework",
|
||||||
|
"plural": false,
|
||||||
|
"selections": (v9/*: any*/),
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v11 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Organization",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "organization",
|
||||||
|
"plural": false,
|
||||||
|
"selections": (v9/*: any*/),
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v12 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "updatedAt",
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AuditGraphNodeQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v3/*: any*/),
|
||||||
|
(v4/*: any*/),
|
||||||
|
(v6/*: any*/),
|
||||||
|
(v7/*: any*/),
|
||||||
|
(v8/*: any*/),
|
||||||
|
(v10/*: any*/),
|
||||||
|
(v11/*: any*/),
|
||||||
|
(v5/*: any*/),
|
||||||
|
(v12/*: any*/)
|
||||||
|
],
|
||||||
|
"type": "Audit",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Query",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AuditGraphNodeQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/),
|
||||||
|
(v4/*: any*/),
|
||||||
|
(v6/*: any*/),
|
||||||
|
(v7/*: any*/),
|
||||||
|
(v8/*: any*/),
|
||||||
|
(v10/*: any*/),
|
||||||
|
(v11/*: any*/),
|
||||||
|
(v5/*: any*/),
|
||||||
|
(v12/*: any*/)
|
||||||
|
],
|
||||||
|
"type": "Audit",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "8cab4d1083ea5990e42dbec0b435b7bd",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AuditGraphNodeQuery",
|
||||||
|
"operationKind": "query",
|
||||||
|
"text": "query AuditGraphNodeQuery(\n $auditId: ID!\n) {\n node(id: $auditId) {\n __typename\n ... on Audit {\n id\n validFrom\n validUntil\n report {\n id\n filename\n mimeType\n size\n downloadUrl\n createdAt\n }\n reportUrl\n state\n framework {\n id\n name\n }\n organization {\n id\n name\n }\n createdAt\n updatedAt\n }\n id\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "3263f3b8f244acf3c982464daa078f7b";
|
||||||
|
|
||||||
|
export default node;
|
||||||
188
apps/console/src/hooks/graph/__generated__/AuditGraphUpdateMutation.graphql.ts
generated
Normal file
188
apps/console/src/hooks/graph/__generated__/AuditGraphUpdateMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<f55547fed473a026bb7c43be28a2c6dc>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type AuditState = "COMPLETED" | "IN_PROGRESS" | "NOT_STARTED" | "OUTDATED" | "REJECTED";
|
||||||
|
export type UpdateAuditInput = {
|
||||||
|
id: string;
|
||||||
|
state?: AuditState | null | undefined;
|
||||||
|
validFrom?: any | null | undefined;
|
||||||
|
validUntil?: any | null | undefined;
|
||||||
|
};
|
||||||
|
export type AuditGraphUpdateMutation$variables = {
|
||||||
|
input: UpdateAuditInput;
|
||||||
|
};
|
||||||
|
export type AuditGraphUpdateMutation$data = {
|
||||||
|
readonly updateAudit: {
|
||||||
|
readonly audit: {
|
||||||
|
readonly framework: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
readonly id: string;
|
||||||
|
readonly report: {
|
||||||
|
readonly filename: string;
|
||||||
|
readonly id: string;
|
||||||
|
} | null | undefined;
|
||||||
|
readonly state: AuditState;
|
||||||
|
readonly updatedAt: any;
|
||||||
|
readonly validFrom: any | null | undefined;
|
||||||
|
readonly validUntil: any | null | undefined;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AuditGraphUpdateMutation = {
|
||||||
|
response: AuditGraphUpdateMutation$data;
|
||||||
|
variables: AuditGraphUpdateMutation$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v2 = [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "input",
|
||||||
|
"variableName": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"concreteType": "UpdateAuditPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "updateAudit",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Audit",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "audit",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validFrom",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validUntil",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Report",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "report",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "filename",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "state",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Framework",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "framework",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "updatedAt",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AuditGraphUpdateMutation",
|
||||||
|
"selections": (v2/*: any*/),
|
||||||
|
"type": "Mutation",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AuditGraphUpdateMutation",
|
||||||
|
"selections": (v2/*: any*/)
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "afd98ba771c6c437c46c275655333eb6",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AuditGraphUpdateMutation",
|
||||||
|
"operationKind": "mutation",
|
||||||
|
"text": "mutation AuditGraphUpdateMutation(\n $input: UpdateAuditInput!\n) {\n updateAudit(input: $input) {\n audit {\n id\n validFrom\n validUntil\n report {\n id\n filename\n }\n state\n framework {\n id\n name\n }\n updatedAt\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "3ddd17832768611675505d76da1839a1";
|
||||||
|
|
||||||
|
export default node;
|
||||||
154
apps/console/src/hooks/graph/__generated__/AuditGraphUploadReportMutation.graphql.ts
generated
Normal file
154
apps/console/src/hooks/graph/__generated__/AuditGraphUploadReportMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<39001f4e110ade4633319d2e71f1377f>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type UploadAuditReportInput = {
|
||||||
|
auditId: string;
|
||||||
|
file: any;
|
||||||
|
};
|
||||||
|
export type AuditGraphUploadReportMutation$variables = {
|
||||||
|
input: UploadAuditReportInput;
|
||||||
|
};
|
||||||
|
export type AuditGraphUploadReportMutation$data = {
|
||||||
|
readonly uploadAuditReport: {
|
||||||
|
readonly audit: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly report: {
|
||||||
|
readonly createdAt: any;
|
||||||
|
readonly downloadUrl: string | null | undefined;
|
||||||
|
readonly filename: string;
|
||||||
|
readonly id: string;
|
||||||
|
} | null | undefined;
|
||||||
|
readonly updatedAt: any;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AuditGraphUploadReportMutation = {
|
||||||
|
response: AuditGraphUploadReportMutation$data;
|
||||||
|
variables: AuditGraphUploadReportMutation$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v2 = [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "input",
|
||||||
|
"variableName": "input"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"concreteType": "UploadAuditReportPayload",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "uploadAuditReport",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Audit",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "audit",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Report",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "report",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "filename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "downloadUrl",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "createdAt",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "updatedAt",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AuditGraphUploadReportMutation",
|
||||||
|
"selections": (v2/*: any*/),
|
||||||
|
"type": "Mutation",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AuditGraphUploadReportMutation",
|
||||||
|
"selections": (v2/*: any*/)
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "05229f6e6fb7e64ceaf93c4bb8f144e6",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AuditGraphUploadReportMutation",
|
||||||
|
"operationKind": "mutation",
|
||||||
|
"text": "mutation AuditGraphUploadReportMutation(\n $input: UploadAuditReportInput!\n) {\n uploadAuditReport(input: $input) {\n audit {\n id\n report {\n id\n filename\n downloadUrl\n createdAt\n }\n updatedAt\n }\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "1acff19bbb4a2e0eeca934cc90040eda";
|
||||||
|
|
||||||
|
export default node;
|
||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
IconInboxEmpty,
|
IconInboxEmpty,
|
||||||
IconPageTextLine,
|
IconPageTextLine,
|
||||||
IconSettingsGear2,
|
IconSettingsGear2,
|
||||||
|
IconCheckmark1,
|
||||||
IconStore,
|
IconStore,
|
||||||
IconTodo,
|
IconTodo,
|
||||||
IconListStack,
|
IconListStack,
|
||||||
@@ -131,6 +132,11 @@ export function MainLayout() {
|
|||||||
icon={IconListStack}
|
icon={IconListStack}
|
||||||
to={`${prefix}/data`}
|
to={`${prefix}/data`}
|
||||||
/>
|
/>
|
||||||
|
<SidebarItem
|
||||||
|
label={__("Audits")}
|
||||||
|
icon={IconCheckmark1}
|
||||||
|
to={`${prefix}/audits`}
|
||||||
|
/>
|
||||||
<SidebarItem
|
<SidebarItem
|
||||||
label={__("Settings")}
|
label={__("Settings")}
|
||||||
icon={IconSettingsGear2}
|
icon={IconSettingsGear2}
|
||||||
|
|||||||
263
apps/console/src/pages/organizations/audits/AuditDetailsPage.tsx
Normal file
263
apps/console/src/pages/organizations/audits/AuditDetailsPage.tsx
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
import {
|
||||||
|
ConnectionHandler,
|
||||||
|
usePreloadedQuery,
|
||||||
|
type PreloadedQuery,
|
||||||
|
} from "react-relay";
|
||||||
|
import {
|
||||||
|
auditNodeQuery,
|
||||||
|
useDeleteAudit,
|
||||||
|
useUpdateAudit,
|
||||||
|
useUploadAuditReport,
|
||||||
|
useDeleteAuditReport,
|
||||||
|
} from "../../../hooks/graph/AuditGraph";
|
||||||
|
import {
|
||||||
|
ActionDropdown,
|
||||||
|
Badge,
|
||||||
|
Breadcrumb,
|
||||||
|
Button,
|
||||||
|
DropdownItem,
|
||||||
|
Field,
|
||||||
|
IconTrashCan,
|
||||||
|
Option,
|
||||||
|
Input,
|
||||||
|
Dropzone,
|
||||||
|
Card,
|
||||||
|
IconArrowInbox,
|
||||||
|
useConfirm,
|
||||||
|
useToast,
|
||||||
|
} from "@probo/ui";
|
||||||
|
import { useTranslate } from "@probo/i18n";
|
||||||
|
import { useOrganizationId } from "/hooks/useOrganizationId";
|
||||||
|
import { ControlledField } from "/components/form/ControlledField";
|
||||||
|
import { useFormWithSchema } from "/hooks/useFormWithSchema";
|
||||||
|
import z from "zod";
|
||||||
|
import { getAuditStateLabel, getAuditStateVariant, auditStates, fileSize, sprintf } from "@probo/helpers";
|
||||||
|
import type { AuditGraphNodeQuery } from "/hooks/graph/__generated__/AuditGraphNodeQuery.graphql";
|
||||||
|
|
||||||
|
const updateAuditSchema = z.object({
|
||||||
|
validFrom: z.string().optional(),
|
||||||
|
validUntil: z.string().optional(),
|
||||||
|
state: z.enum(["NOT_STARTED", "IN_PROGRESS", "COMPLETED", "REJECTED", "OUTDATED"]),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
queryRef: PreloadedQuery<AuditGraphNodeQuery>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function AuditDetailsPage(props: Props) {
|
||||||
|
const audit = usePreloadedQuery<AuditGraphNodeQuery>(auditNodeQuery, props.queryRef);
|
||||||
|
const auditEntry = audit.node;
|
||||||
|
const { __, dateFormat } = useTranslate();
|
||||||
|
const organizationId = useOrganizationId();
|
||||||
|
|
||||||
|
if (!auditEntry || !auditEntry.id || !auditEntry.framework) {
|
||||||
|
return <div>{__("Audit not found")}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteAudit = useDeleteAudit(
|
||||||
|
{ id: auditEntry.id!, framework: { name: auditEntry.framework!.name } },
|
||||||
|
ConnectionHandler.getConnectionID(organizationId, "AuditsPage_audits")
|
||||||
|
);
|
||||||
|
|
||||||
|
const { control, formState, handleSubmit, register, reset } = useFormWithSchema(updateAuditSchema, {
|
||||||
|
defaultValues: {
|
||||||
|
validFrom: auditEntry.validFrom?.split('T')[0] || "",
|
||||||
|
validUntil: auditEntry.validUntil?.split('T')[0] || "",
|
||||||
|
state: auditEntry.state || "NOT_STARTED",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateAudit = useUpdateAudit();
|
||||||
|
const [uploadAuditReport, isUploading] = useUploadAuditReport();
|
||||||
|
const deleteAuditReport = useDeleteAuditReport();
|
||||||
|
const confirm = useConfirm();
|
||||||
|
const { toast } = useToast();
|
||||||
|
|
||||||
|
const onSubmit = handleSubmit(async (formData) => {
|
||||||
|
if (!auditEntry.id) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const formatDatetime = (dateString?: string) => {
|
||||||
|
if (!dateString) return undefined;
|
||||||
|
return `${dateString}T00:00:00Z`;
|
||||||
|
};
|
||||||
|
|
||||||
|
await updateAudit({
|
||||||
|
id: auditEntry.id,
|
||||||
|
validFrom: formatDatetime(formData.validFrom),
|
||||||
|
validUntil: formatDatetime(formData.validUntil),
|
||||||
|
state: formData.state,
|
||||||
|
});
|
||||||
|
reset(formData);
|
||||||
|
toast({
|
||||||
|
title: __("Success"),
|
||||||
|
description: __("Audit updated successfully"),
|
||||||
|
variant: "success",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
title: __("Error"),
|
||||||
|
description: error instanceof Error ? error.message : __("Failed to update audit"),
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleDeleteReport = () => {
|
||||||
|
if (!auditEntry.report || !auditEntry.id) return;
|
||||||
|
|
||||||
|
confirm(
|
||||||
|
async () => {
|
||||||
|
await deleteAuditReport({ auditId: auditEntry.id! });
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: sprintf(
|
||||||
|
__(
|
||||||
|
'This will permanently delete the audit report "%s". This action cannot be undone.'
|
||||||
|
),
|
||||||
|
auditEntry.report.filename
|
||||||
|
),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-6">
|
||||||
|
<Breadcrumb
|
||||||
|
items={[
|
||||||
|
{
|
||||||
|
label: __("Audits"),
|
||||||
|
to: `/organizations/${organizationId}/audits`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: auditEntry.framework?.name ?? __("Unknown Audit"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="flex justify-between items-start">
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
<div className="text-2xl">{auditEntry.framework?.name}</div>
|
||||||
|
<Badge variant={getAuditStateVariant(auditEntry.state || "NOT_STARTED")}>
|
||||||
|
{getAuditStateLabel(__, auditEntry.state || "NOT_STARTED")}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
<ActionDropdown variant="secondary">
|
||||||
|
<DropdownItem
|
||||||
|
variant="danger"
|
||||||
|
icon={IconTrashCan}
|
||||||
|
onClick={deleteAudit}
|
||||||
|
>
|
||||||
|
{__("Delete")}
|
||||||
|
</DropdownItem>
|
||||||
|
</ActionDropdown>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
|
<form onSubmit={onSubmit} className="space-y-6">
|
||||||
|
<ControlledField
|
||||||
|
control={control}
|
||||||
|
name="state"
|
||||||
|
type="select"
|
||||||
|
label={__("State")}
|
||||||
|
>
|
||||||
|
{auditStates.map((state) => (
|
||||||
|
<Option key={state} value={state}>
|
||||||
|
{getAuditStateLabel(__, state)}
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
|
</ControlledField>
|
||||||
|
|
||||||
|
<Field label={__("Valid From")}>
|
||||||
|
<Input {...register("validFrom")} type="date" />
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<Field label={__("Valid Until")}>
|
||||||
|
<Input {...register("validUntil")} type="date" />
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<div className="flex justify-end">
|
||||||
|
{formState.isDirty && (
|
||||||
|
<Button type="submit" disabled={formState.isSubmitting}>
|
||||||
|
{formState.isSubmitting ? __("Updating...") : __("Update")}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<Card padded className="mt-6">
|
||||||
|
<div className="space-y-4">
|
||||||
|
<h3 className="text-lg font-medium">{__("Audit Report")}</h3>
|
||||||
|
|
||||||
|
{auditEntry.report ? (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="flex items-center justify-between p-4 bg-success-50 border border-success-200 rounded-lg">
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<IconArrowInbox className="text-success-600" size={20} />
|
||||||
|
<div className="flex-1">
|
||||||
|
<p className="font-medium text-success-900">
|
||||||
|
{auditEntry.report.filename}
|
||||||
|
</p>
|
||||||
|
<div className="flex items-center gap-4 text-sm text-success-700">
|
||||||
|
<span>
|
||||||
|
{fileSize(__, auditEntry.report.size)}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{__("Uploaded")} {dateFormat(auditEntry.report.createdAt)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ActionDropdown>
|
||||||
|
<DropdownItem
|
||||||
|
onClick={() => {
|
||||||
|
if (auditEntry.report?.downloadUrl) {
|
||||||
|
window.open(auditEntry.report.downloadUrl, '_blank');
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
icon={IconArrowInbox}
|
||||||
|
>
|
||||||
|
{__("Download")}
|
||||||
|
</DropdownItem>
|
||||||
|
<DropdownItem
|
||||||
|
variant="danger"
|
||||||
|
icon={IconTrashCan}
|
||||||
|
onClick={handleDeleteReport}
|
||||||
|
>
|
||||||
|
{__("Delete")}
|
||||||
|
</DropdownItem>
|
||||||
|
</ActionDropdown>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<p className="text-neutral-600">
|
||||||
|
{__("Upload the final audit report document (PDF recommended)")}
|
||||||
|
</p>
|
||||||
|
<Dropzone
|
||||||
|
description={__("Only PDF, DOCX files up to 25MB are allowed")}
|
||||||
|
isUploading={isUploading}
|
||||||
|
onDrop={async (files) => {
|
||||||
|
if (files.length > 0 && auditEntry.id) {
|
||||||
|
await uploadAuditReport({
|
||||||
|
auditId: auditEntry.id,
|
||||||
|
file: files[0],
|
||||||
|
});
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
accept={{
|
||||||
|
"application/pdf": [".pdf"],
|
||||||
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
||||||
|
[".docx"],
|
||||||
|
}}
|
||||||
|
maxSize={25}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
177
apps/console/src/pages/organizations/audits/AuditsPage.tsx
Normal file
177
apps/console/src/pages/organizations/audits/AuditsPage.tsx
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
import {
|
||||||
|
Button,
|
||||||
|
IconPlusLarge,
|
||||||
|
PageHeader,
|
||||||
|
Thead,
|
||||||
|
Tbody,
|
||||||
|
Tr,
|
||||||
|
Th,
|
||||||
|
Td,
|
||||||
|
Badge,
|
||||||
|
ActionDropdown,
|
||||||
|
DropdownItem,
|
||||||
|
IconTrashCan,
|
||||||
|
} from "@probo/ui";
|
||||||
|
import { useTranslate } from "@probo/i18n";
|
||||||
|
import { usePageTitle } from "@probo/hooks";
|
||||||
|
import {
|
||||||
|
graphql,
|
||||||
|
usePaginationFragment,
|
||||||
|
usePreloadedQuery,
|
||||||
|
type PreloadedQuery,
|
||||||
|
} from "react-relay";
|
||||||
|
import { useOrganizationId } from "/hooks/useOrganizationId";
|
||||||
|
import { CreateAuditDialog } from "./dialogs/CreateAuditDialog";
|
||||||
|
import { useDeleteAudit, auditsQuery } from "../../../hooks/graph/AuditGraph";
|
||||||
|
import type { AuditGraphListQuery } from "/hooks/graph/__generated__/AuditGraphListQuery.graphql";
|
||||||
|
import type { NodeOf } from "/types";
|
||||||
|
import { getAuditStateLabel, getAuditStateVariant } from "@probo/helpers";
|
||||||
|
import type {
|
||||||
|
AuditsPageFragment$data,
|
||||||
|
AuditsPageFragment$key,
|
||||||
|
} from "./__generated__/AuditsPageFragment.graphql";
|
||||||
|
import { SortableTable } from "/components/SortableTable";
|
||||||
|
|
||||||
|
const paginatedAuditsFragment = graphql`
|
||||||
|
fragment AuditsPageFragment on Organization
|
||||||
|
@refetchable(queryName: "AuditsListQuery")
|
||||||
|
@argumentDefinitions(
|
||||||
|
first: { type: "Int", defaultValue: 10 }
|
||||||
|
orderBy: { type: "AuditOrder", defaultValue: null }
|
||||||
|
after: { type: "CursorKey", defaultValue: null }
|
||||||
|
before: { type: "CursorKey", defaultValue: null }
|
||||||
|
last: { type: "Int", defaultValue: null }
|
||||||
|
) {
|
||||||
|
audits(
|
||||||
|
first: $first
|
||||||
|
after: $after
|
||||||
|
last: $last
|
||||||
|
before: $before
|
||||||
|
orderBy: $orderBy
|
||||||
|
) @connection(key: "AuditsPage_audits") {
|
||||||
|
__id
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
validFrom
|
||||||
|
validUntil
|
||||||
|
report {
|
||||||
|
id
|
||||||
|
filename
|
||||||
|
}
|
||||||
|
state
|
||||||
|
framework {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
type AuditEntry = NodeOf<AuditsPageFragment$data["audits"]>;
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
queryRef: PreloadedQuery<AuditGraphListQuery>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function AuditsPage(props: Props) {
|
||||||
|
const { __ } = useTranslate();
|
||||||
|
const organizationId = useOrganizationId();
|
||||||
|
|
||||||
|
const data = usePreloadedQuery(auditsQuery, props.queryRef);
|
||||||
|
const pagination = usePaginationFragment(
|
||||||
|
paginatedAuditsFragment,
|
||||||
|
data.node as AuditsPageFragment$key
|
||||||
|
);
|
||||||
|
const audits = pagination.data.audits?.edges?.map((edge) => edge.node) ?? [];
|
||||||
|
const connectionId = pagination.data.audits.__id;
|
||||||
|
|
||||||
|
usePageTitle(__("Audits"));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-6">
|
||||||
|
<PageHeader
|
||||||
|
title={__("Audits")}
|
||||||
|
description={__(
|
||||||
|
"Manage your organization's compliance audits and their progress."
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<CreateAuditDialog
|
||||||
|
connection={connectionId}
|
||||||
|
organizationId={organizationId}
|
||||||
|
>
|
||||||
|
<Button icon={IconPlusLarge}>{__("Add audit")}</Button>
|
||||||
|
</CreateAuditDialog>
|
||||||
|
</PageHeader>
|
||||||
|
<SortableTable {...pagination}>
|
||||||
|
<Thead>
|
||||||
|
<Tr>
|
||||||
|
<Th>{__("Framework")}</Th>
|
||||||
|
<Th>{__("State")}</Th>
|
||||||
|
<Th>{__("Valid From")}</Th>
|
||||||
|
<Th>{__("Valid Until")}</Th>
|
||||||
|
<Th>{__("Report")}</Th>
|
||||||
|
<Th></Th>
|
||||||
|
</Tr>
|
||||||
|
</Thead>
|
||||||
|
<Tbody>
|
||||||
|
{audits.map((entry) => (
|
||||||
|
<AuditRow
|
||||||
|
key={entry.id}
|
||||||
|
entry={entry}
|
||||||
|
connectionId={connectionId}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Tbody>
|
||||||
|
</SortableTable>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function AuditRow({
|
||||||
|
entry,
|
||||||
|
connectionId,
|
||||||
|
}: {
|
||||||
|
entry: AuditEntry;
|
||||||
|
connectionId: string;
|
||||||
|
}) {
|
||||||
|
const organizationId = useOrganizationId();
|
||||||
|
const { __, dateFormat } = useTranslate();
|
||||||
|
const deleteAudit = useDeleteAudit(entry, connectionId);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tr to={`/organizations/${organizationId}/audits/${entry.id}`}>
|
||||||
|
<Td>{entry.framework?.name ?? __("Unknown Framework")}</Td>
|
||||||
|
<Td>
|
||||||
|
<Badge variant={getAuditStateVariant(entry.state)}>
|
||||||
|
{getAuditStateLabel(__, entry.state)}
|
||||||
|
</Badge>
|
||||||
|
</Td>
|
||||||
|
<Td>{dateFormat(entry.validFrom, { year: "numeric", month: "short", day: "numeric" }) || __("Not set")}</Td>
|
||||||
|
<Td>{dateFormat(entry.validUntil, { year: "numeric", month: "short", day: "numeric" }) || __("Not set")}</Td>
|
||||||
|
<Td>
|
||||||
|
{entry.report ? (
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<Badge variant="success">{__("Uploaded")}</Badge>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<Badge variant="neutral">{__("Not uploaded")}</Badge>
|
||||||
|
)}
|
||||||
|
</Td>
|
||||||
|
<Td noLink width={50} className="text-end">
|
||||||
|
<ActionDropdown>
|
||||||
|
<DropdownItem
|
||||||
|
onClick={deleteAudit}
|
||||||
|
variant="danger"
|
||||||
|
icon={IconTrashCan}
|
||||||
|
>
|
||||||
|
{__("Delete")}
|
||||||
|
</DropdownItem>
|
||||||
|
</ActionDropdown>
|
||||||
|
</Td>
|
||||||
|
</Tr>
|
||||||
|
);
|
||||||
|
}
|
||||||
368
apps/console/src/pages/organizations/audits/__generated__/AuditsListQuery.graphql.ts
generated
Normal file
368
apps/console/src/pages/organizations/audits/__generated__/AuditsListQuery.graphql.ts
generated
Normal file
@@ -0,0 +1,368 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<273ddcd519e40c3d2af76944a1f93191>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
import { FragmentRefs } from "relay-runtime";
|
||||||
|
export type AuditOrderField = "CREATED_AT" | "STATE" | "VALID_FROM" | "VALID_UNTIL";
|
||||||
|
export type OrderDirection = "ASC" | "DESC";
|
||||||
|
export type AuditOrder = {
|
||||||
|
direction: OrderDirection;
|
||||||
|
field: AuditOrderField;
|
||||||
|
};
|
||||||
|
export type AuditsListQuery$variables = {
|
||||||
|
after?: any | null | undefined;
|
||||||
|
before?: any | null | undefined;
|
||||||
|
first?: number | null | undefined;
|
||||||
|
id: string;
|
||||||
|
last?: number | null | undefined;
|
||||||
|
orderBy?: AuditOrder | null | undefined;
|
||||||
|
};
|
||||||
|
export type AuditsListQuery$data = {
|
||||||
|
readonly node: {
|
||||||
|
readonly " $fragmentSpreads": FragmentRefs<"AuditsPageFragment">;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type AuditsListQuery = {
|
||||||
|
response: AuditsListQuery$data;
|
||||||
|
variables: AuditsListQuery$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "after"
|
||||||
|
},
|
||||||
|
v1 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "before"
|
||||||
|
},
|
||||||
|
v2 = {
|
||||||
|
"defaultValue": 10,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "first"
|
||||||
|
},
|
||||||
|
v3 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "id"
|
||||||
|
},
|
||||||
|
v4 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "last"
|
||||||
|
},
|
||||||
|
v5 = {
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "orderBy"
|
||||||
|
},
|
||||||
|
v6 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "id",
|
||||||
|
"variableName": "id"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v7 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "after",
|
||||||
|
"variableName": "after"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "before",
|
||||||
|
"variableName": "before"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "first",
|
||||||
|
"variableName": "first"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "last",
|
||||||
|
"variableName": "last"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "orderBy",
|
||||||
|
"variableName": "orderBy"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v8 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v9 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v3/*: any*/),
|
||||||
|
(v4/*: any*/),
|
||||||
|
(v5/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "AuditsListQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v6/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"args": (v7/*: any*/),
|
||||||
|
"kind": "FragmentSpread",
|
||||||
|
"name": "AuditsPageFragment"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Query",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
(v0/*: any*/),
|
||||||
|
(v1/*: any*/),
|
||||||
|
(v2/*: any*/),
|
||||||
|
(v4/*: any*/),
|
||||||
|
(v5/*: any*/),
|
||||||
|
(v3/*: any*/)
|
||||||
|
],
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "AuditsListQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v6/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v8/*: any*/),
|
||||||
|
(v9/*: any*/),
|
||||||
|
{
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v7/*: any*/),
|
||||||
|
"concreteType": "AuditConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "audits",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "AuditEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Audit",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v9/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validFrom",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validUntil",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Report",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "report",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v9/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "filename",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "state",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Framework",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "framework",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v9/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "createdAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v8/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "cursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "PageInfo",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "pageInfo",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "endCursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasNextPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasPreviousPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "startCursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ClientExtension",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__id",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": (v7/*: any*/),
|
||||||
|
"filters": [
|
||||||
|
"orderBy"
|
||||||
|
],
|
||||||
|
"handle": "connection",
|
||||||
|
"key": "AuditsPage_audits",
|
||||||
|
"kind": "LinkedHandle",
|
||||||
|
"name": "audits"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "120524c1493bac68d36318259531f84e",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "AuditsListQuery",
|
||||||
|
"operationKind": "query",
|
||||||
|
"text": "query AuditsListQuery(\n $after: CursorKey = null\n $before: CursorKey = null\n $first: Int = 10\n $last: Int = null\n $orderBy: AuditOrder = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...AuditsPageFragment_sdb03\n id\n }\n}\n\nfragment AuditsPageFragment_sdb03 on Organization {\n audits(first: $first, after: $after, last: $last, before: $before, orderBy: $orderBy) {\n edges {\n node {\n id\n validFrom\n validUntil\n report {\n id\n filename\n }\n state\n framework {\n id\n name\n }\n createdAt\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n id\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "ef15955eb51e30372c935dcc7dcd5099";
|
||||||
|
|
||||||
|
export default node;
|
||||||
298
apps/console/src/pages/organizations/audits/__generated__/AuditsPageFragment.graphql.ts
generated
Normal file
298
apps/console/src/pages/organizations/audits/__generated__/AuditsPageFragment.graphql.ts
generated
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<168c07116a618dbd9663e4072ec04139>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ReaderFragment } from 'relay-runtime';
|
||||||
|
export type AuditState = "COMPLETED" | "IN_PROGRESS" | "NOT_STARTED" | "OUTDATED" | "REJECTED";
|
||||||
|
import { FragmentRefs } from "relay-runtime";
|
||||||
|
export type AuditsPageFragment$data = {
|
||||||
|
readonly audits: {
|
||||||
|
readonly __id: string;
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly createdAt: any;
|
||||||
|
readonly framework: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
readonly id: string;
|
||||||
|
readonly report: {
|
||||||
|
readonly filename: string;
|
||||||
|
readonly id: string;
|
||||||
|
} | null | undefined;
|
||||||
|
readonly state: AuditState;
|
||||||
|
readonly validFrom: any | null | undefined;
|
||||||
|
readonly validUntil: any | null | undefined;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
readonly id: string;
|
||||||
|
readonly " $fragmentType": "AuditsPageFragment";
|
||||||
|
};
|
||||||
|
export type AuditsPageFragment$key = {
|
||||||
|
readonly " $data"?: AuditsPageFragment$data;
|
||||||
|
readonly " $fragmentSpreads": FragmentRefs<"AuditsPageFragment">;
|
||||||
|
};
|
||||||
|
|
||||||
|
import AuditsListQuery_graphql from './AuditsListQuery.graphql';
|
||||||
|
|
||||||
|
const node: ReaderFragment = (function(){
|
||||||
|
var v0 = [
|
||||||
|
"audits"
|
||||||
|
],
|
||||||
|
v1 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"argumentDefinitions": [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "after"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "before"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"defaultValue": 10,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "first"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "last"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "orderBy"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": {
|
||||||
|
"connection": [
|
||||||
|
{
|
||||||
|
"count": null,
|
||||||
|
"cursor": null,
|
||||||
|
"direction": "bidirectional",
|
||||||
|
"path": (v0/*: any*/)
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"refetch": {
|
||||||
|
"connection": {
|
||||||
|
"forward": {
|
||||||
|
"count": "first",
|
||||||
|
"cursor": "after"
|
||||||
|
},
|
||||||
|
"backward": {
|
||||||
|
"count": "last",
|
||||||
|
"cursor": "before"
|
||||||
|
},
|
||||||
|
"path": (v0/*: any*/)
|
||||||
|
},
|
||||||
|
"fragmentPathInResult": [
|
||||||
|
"node"
|
||||||
|
],
|
||||||
|
"operation": AuditsListQuery_graphql,
|
||||||
|
"identifierInfo": {
|
||||||
|
"identifierField": "id",
|
||||||
|
"identifierQueryVariableName": "id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "AuditsPageFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": "audits",
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "orderBy",
|
||||||
|
"variableName": "orderBy"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"concreteType": "AuditConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "__AuditsPage_audits_connection",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "AuditEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Audit",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validFrom",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "validUntil",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Report",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "report",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "filename",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "state",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Framework",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "framework",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v1/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "createdAt",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "cursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "PageInfo",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "pageInfo",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "endCursor",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasNextPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "hasPreviousPage",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "startCursor",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ClientExtension",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__id",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v1/*: any*/)
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "ef15955eb51e30372c935dcc7dcd5099";
|
||||||
|
|
||||||
|
export default node;
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogFooter,
|
||||||
|
Field,
|
||||||
|
Option,
|
||||||
|
useDialogRef,
|
||||||
|
Breadcrumb,
|
||||||
|
Input,
|
||||||
|
Select,
|
||||||
|
useToast,
|
||||||
|
} from "@probo/ui";
|
||||||
|
import { useTranslate } from "@probo/i18n";
|
||||||
|
import z from "zod";
|
||||||
|
import { useFormWithSchema } from "/hooks/useFormWithSchema";
|
||||||
|
import { ControlledField } from "/components/form/ControlledField";
|
||||||
|
import { useCreateAudit } from "/hooks/graph/AuditGraph";
|
||||||
|
import { auditStates, getAuditStateLabel } from "@probo/helpers";
|
||||||
|
import { useLazyLoadQuery } from "react-relay";
|
||||||
|
import { graphql } from "relay-runtime";
|
||||||
|
import { Suspense } from "react";
|
||||||
|
import { Controller, type Control } from "react-hook-form";
|
||||||
|
import type { CreateAuditDialogFrameworksQuery } from "./__generated__/CreateAuditDialogFrameworksQuery.graphql";
|
||||||
|
|
||||||
|
const frameworksQuery = graphql`
|
||||||
|
query CreateAuditDialogFrameworksQuery($organizationId: ID!) {
|
||||||
|
organization: node(id: $organizationId) {
|
||||||
|
... on Organization {
|
||||||
|
frameworks(first: 100) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const schema = z.object({
|
||||||
|
frameworkId: z.string().min(1, "Framework is required"),
|
||||||
|
validFrom: z.string().optional(),
|
||||||
|
validUntil: z.string().optional(),
|
||||||
|
state: z.enum(["NOT_STARTED", "IN_PROGRESS", "COMPLETED", "REJECTED", "OUTDATED"]),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
children: React.ReactNode;
|
||||||
|
connection: string;
|
||||||
|
organizationId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function CreateAuditDialog({
|
||||||
|
children,
|
||||||
|
connection,
|
||||||
|
organizationId,
|
||||||
|
}: Props) {
|
||||||
|
const { __ } = useTranslate();
|
||||||
|
const { toast } = useToast();
|
||||||
|
const { control, handleSubmit, register, formState, reset } =
|
||||||
|
useFormWithSchema(schema, {
|
||||||
|
defaultValues: {
|
||||||
|
frameworkId: "",
|
||||||
|
validFrom: "",
|
||||||
|
validUntil: "",
|
||||||
|
state: "NOT_STARTED",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const ref = useDialogRef();
|
||||||
|
const createAudit = useCreateAudit(connection);
|
||||||
|
|
||||||
|
const onSubmit = handleSubmit(async (data) => {
|
||||||
|
try {
|
||||||
|
// Convert date strings to datetime format
|
||||||
|
const formatDatetime = (dateString?: string) => {
|
||||||
|
if (!dateString) return undefined;
|
||||||
|
return `${dateString}T00:00:00Z`;
|
||||||
|
};
|
||||||
|
|
||||||
|
await createAudit({
|
||||||
|
organizationId,
|
||||||
|
frameworkId: data.frameworkId,
|
||||||
|
validFrom: formatDatetime(data.validFrom),
|
||||||
|
validUntil: formatDatetime(data.validUntil),
|
||||||
|
state: data.state,
|
||||||
|
});
|
||||||
|
ref.current?.close();
|
||||||
|
reset();
|
||||||
|
toast({
|
||||||
|
title: __("Success"),
|
||||||
|
description: __("Audit created successfully"),
|
||||||
|
variant: "success",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
title: __("Error"),
|
||||||
|
description: error instanceof Error ? error.message : __("Failed to create audit"),
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
ref={ref}
|
||||||
|
trigger={children}
|
||||||
|
title={<Breadcrumb items={[__("Audits"), __("New Audit")]} />}
|
||||||
|
>
|
||||||
|
<form onSubmit={onSubmit} className="space-y-4">
|
||||||
|
<DialogContent padded className="space-y-4">
|
||||||
|
<Field label={__("Framework")}>
|
||||||
|
<Suspense fallback={<Select variant="editor" disabled placeholder="Loading..." />}>
|
||||||
|
<FrameworkSelect
|
||||||
|
organizationId={organizationId}
|
||||||
|
control={control}
|
||||||
|
name="frameworkId"
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<ControlledField
|
||||||
|
control={control}
|
||||||
|
name="state"
|
||||||
|
type="select"
|
||||||
|
label={__("State")}
|
||||||
|
>
|
||||||
|
{auditStates.map((state) => (
|
||||||
|
<Option key={state} value={state}>
|
||||||
|
{getAuditStateLabel(__, state)}
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
|
</ControlledField>
|
||||||
|
|
||||||
|
<Field label={__("Valid From")}>
|
||||||
|
<Input {...register("validFrom")} type="date" />
|
||||||
|
</Field>
|
||||||
|
<Field label={__("Valid Until")}>
|
||||||
|
<Input {...register("validUntil")} type="date" />
|
||||||
|
</Field>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button disabled={formState.isSubmitting} type="submit">
|
||||||
|
{__("Create")}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</form>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type FormSchema = z.infer<typeof schema>;
|
||||||
|
|
||||||
|
function FrameworkSelect({
|
||||||
|
organizationId,
|
||||||
|
control,
|
||||||
|
name
|
||||||
|
}: {
|
||||||
|
organizationId: string;
|
||||||
|
control: Control<FormSchema>;
|
||||||
|
name: keyof FormSchema;
|
||||||
|
}) {
|
||||||
|
const { __ } = useTranslate();
|
||||||
|
const data = useLazyLoadQuery<CreateAuditDialogFrameworksQuery>(frameworksQuery, { organizationId });
|
||||||
|
const frameworks = data?.organization?.frameworks?.edges?.map((edge) => edge.node).filter((node): node is NonNullable<typeof node> => node !== null) ?? [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name={name}
|
||||||
|
render={({ field }) => (
|
||||||
|
<Select
|
||||||
|
id={name}
|
||||||
|
variant="editor"
|
||||||
|
placeholder={__("Select a framework")}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
{...field}
|
||||||
|
className="w-full"
|
||||||
|
value={field.value ?? ""}
|
||||||
|
>
|
||||||
|
{frameworks.map((framework) => (
|
||||||
|
<Option key={framework.id} value={framework.id}>
|
||||||
|
{framework.name}
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
/**
|
||||||
|
* @generated SignedSource<<e7f7a5781f356aaba7ec0ff1a60b43b6>>
|
||||||
|
* @lightSyntaxTransform
|
||||||
|
* @nogrep
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ConcreteRequest } from 'relay-runtime';
|
||||||
|
export type CreateAuditDialogFrameworksQuery$variables = {
|
||||||
|
organizationId: string;
|
||||||
|
};
|
||||||
|
export type CreateAuditDialogFrameworksQuery$data = {
|
||||||
|
readonly organization: {
|
||||||
|
readonly frameworks?: {
|
||||||
|
readonly edges: ReadonlyArray<{
|
||||||
|
readonly node: {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export type CreateAuditDialogFrameworksQuery = {
|
||||||
|
response: CreateAuditDialogFrameworksQuery$data;
|
||||||
|
variables: CreateAuditDialogFrameworksQuery$variables;
|
||||||
|
};
|
||||||
|
|
||||||
|
const node: ConcreteRequest = (function(){
|
||||||
|
var v0 = [
|
||||||
|
{
|
||||||
|
"defaultValue": null,
|
||||||
|
"kind": "LocalArgument",
|
||||||
|
"name": "organizationId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v1 = [
|
||||||
|
{
|
||||||
|
"kind": "Variable",
|
||||||
|
"name": "id",
|
||||||
|
"variableName": "organizationId"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
v2 = {
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "id",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
v3 = {
|
||||||
|
"kind": "InlineFragment",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"kind": "Literal",
|
||||||
|
"name": "first",
|
||||||
|
"value": 100
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"concreteType": "FrameworkConnection",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "frameworks",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "FrameworkEdge",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "edges",
|
||||||
|
"plural": true,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"concreteType": "Framework",
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v2/*: any*/),
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "name",
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"storageKey": "frameworks(first:100)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Organization",
|
||||||
|
"abstractKey": null
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
"fragment": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Fragment",
|
||||||
|
"metadata": null,
|
||||||
|
"name": "CreateAuditDialogFrameworksQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": "organization",
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
(v3/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "Query",
|
||||||
|
"abstractKey": null
|
||||||
|
},
|
||||||
|
"kind": "Request",
|
||||||
|
"operation": {
|
||||||
|
"argumentDefinitions": (v0/*: any*/),
|
||||||
|
"kind": "Operation",
|
||||||
|
"name": "CreateAuditDialogFrameworksQuery",
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": "organization",
|
||||||
|
"args": (v1/*: any*/),
|
||||||
|
"concreteType": null,
|
||||||
|
"kind": "LinkedField",
|
||||||
|
"name": "node",
|
||||||
|
"plural": false,
|
||||||
|
"selections": [
|
||||||
|
{
|
||||||
|
"alias": null,
|
||||||
|
"args": null,
|
||||||
|
"kind": "ScalarField",
|
||||||
|
"name": "__typename",
|
||||||
|
"storageKey": null
|
||||||
|
},
|
||||||
|
(v3/*: any*/),
|
||||||
|
(v2/*: any*/)
|
||||||
|
],
|
||||||
|
"storageKey": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"cacheID": "3b61e88adc92ac47ea6b5810a8d13f18",
|
||||||
|
"id": null,
|
||||||
|
"metadata": {},
|
||||||
|
"name": "CreateAuditDialogFrameworksQuery",
|
||||||
|
"operationKind": "query",
|
||||||
|
"text": "query CreateAuditDialogFrameworksQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n frameworks(first: 100) {\n edges {\n node {\n id\n name\n }\n }\n }\n }\n id\n }\n}\n"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
(node as any).hash = "ce9f84bb4e6e1e657cdf54bf8a3b4faa";
|
||||||
|
|
||||||
|
export default node;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @generated SignedSource<<5c976aa26b87b4f77dfcfeba71d3bbe3>>
|
* @generated SignedSource<<be64518840fd2564cffe1646a58c3762>>
|
||||||
* @lightSyntaxTransform
|
* @lightSyntaxTransform
|
||||||
* @nogrep
|
* @nogrep
|
||||||
*/
|
*/
|
||||||
@@ -17,7 +17,7 @@ export type CreateControlInput = {
|
|||||||
frameworkId: string;
|
frameworkId: string;
|
||||||
name: string;
|
name: string;
|
||||||
sectionTitle: string;
|
sectionTitle: string;
|
||||||
status?: ControlStatus | null | undefined;
|
status: ControlStatus;
|
||||||
};
|
};
|
||||||
export type FrameworkControlDialogCreateMutation$variables = {
|
export type FrameworkControlDialogCreateMutation$variables = {
|
||||||
connections: ReadonlyArray<string>;
|
connections: ReadonlyArray<string>;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { PageError } from "./components/PageError.tsx";
|
|||||||
import { taskRoutes } from "./routes/taskRoutes.ts";
|
import { taskRoutes } from "./routes/taskRoutes.ts";
|
||||||
import { dataRoutes } from "./routes/dataRoutes.ts";
|
import { dataRoutes } from "./routes/dataRoutes.ts";
|
||||||
import { assetRoutes } from "./routes/assetRoutes.ts";
|
import { assetRoutes } from "./routes/assetRoutes.ts";
|
||||||
|
import { auditRoutes } from "./routes/auditRoutes.ts";
|
||||||
import { lazy } from "@probo/react-lazy";
|
import { lazy } from "@probo/react-lazy";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,6 +135,7 @@ const routes = [
|
|||||||
...taskRoutes,
|
...taskRoutes,
|
||||||
...assetRoutes,
|
...assetRoutes,
|
||||||
...dataRoutes,
|
...dataRoutes,
|
||||||
|
...auditRoutes,
|
||||||
{
|
{
|
||||||
path: "*",
|
path: "*",
|
||||||
Component: PageError,
|
Component: PageError,
|
||||||
|
|||||||
26
apps/console/src/routes/auditRoutes.ts
Normal file
26
apps/console/src/routes/auditRoutes.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { loadQuery } from "react-relay";
|
||||||
|
import { relayEnvironment } from "/providers/RelayProviders";
|
||||||
|
import { PageSkeleton } from "/components/skeletons/PageSkeleton";
|
||||||
|
import { lazy } from "@probo/react-lazy";
|
||||||
|
import { auditsQuery, auditNodeQuery } from "../hooks/graph/AuditGraph";
|
||||||
|
|
||||||
|
export const auditRoutes = [
|
||||||
|
{
|
||||||
|
path: "audits",
|
||||||
|
fallback: PageSkeleton,
|
||||||
|
queryLoader: (params: Record<string, string>) =>
|
||||||
|
loadQuery(relayEnvironment, auditsQuery, { organizationId: params.organizationId }),
|
||||||
|
Component: lazy(
|
||||||
|
() => import("/pages/organizations/audits/AuditsPage")
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "audits/:auditId",
|
||||||
|
fallback: PageSkeleton,
|
||||||
|
queryLoader: (params: Record<string, string>) =>
|
||||||
|
loadQuery(relayEnvironment, auditNodeQuery, { auditId: params.auditId }),
|
||||||
|
Component: lazy(
|
||||||
|
() => import("/pages/organizations/audits/AuditDetailsPage")
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
43
packages/helpers/src/audits.ts
Normal file
43
packages/helpers/src/audits.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
type Translator = (s: string) => string;
|
||||||
|
|
||||||
|
export const auditStates = [
|
||||||
|
"NOT_STARTED",
|
||||||
|
"IN_PROGRESS",
|
||||||
|
"COMPLETED",
|
||||||
|
"REJECTED",
|
||||||
|
"OUTDATED",
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export function getAuditStateLabel(__: Translator, state: (typeof auditStates)[number]) {
|
||||||
|
switch (state) {
|
||||||
|
case "NOT_STARTED":
|
||||||
|
return __("Not Started");
|
||||||
|
case "IN_PROGRESS":
|
||||||
|
return __("In Progress");
|
||||||
|
case "COMPLETED":
|
||||||
|
return __("Completed");
|
||||||
|
case "REJECTED":
|
||||||
|
return __("Rejected");
|
||||||
|
case "OUTDATED":
|
||||||
|
return __("Outdated");
|
||||||
|
default:
|
||||||
|
return __("Unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAuditStateVariant(state: (typeof auditStates)[number]) {
|
||||||
|
switch (state) {
|
||||||
|
case "NOT_STARTED":
|
||||||
|
return "neutral";
|
||||||
|
case "IN_PROGRESS":
|
||||||
|
return "info";
|
||||||
|
case "COMPLETED":
|
||||||
|
return "success";
|
||||||
|
case "REJECTED":
|
||||||
|
return "danger";
|
||||||
|
case "OUTDATED":
|
||||||
|
return "warning";
|
||||||
|
default:
|
||||||
|
return "neutral";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,5 +15,6 @@ export { certificationCategoryLabel, certifications } from "./certifications";
|
|||||||
export { availableFrameworks } from "./frameworks";
|
export { availableFrameworks } from "./frameworks";
|
||||||
export { getDocumentTypeLabel, documentTypes } from "./documents";
|
export { getDocumentTypeLabel, documentTypes } from "./documents";
|
||||||
export { getAssetTypeVariant, getCriticityVariant } from "./assets";
|
export { getAssetTypeVariant, getCriticityVariant } from "./assets";
|
||||||
|
export { getAuditStateLabel, getAuditStateVariant, auditStates } from "./audits";
|
||||||
export { promisifyMutation } from "./relay";
|
export { promisifyMutation } from "./relay";
|
||||||
export { fileType, fileSize } from "./file";
|
export { fileType, fileSize } from "./file";
|
||||||
|
|||||||
297
pkg/coredata/audit.go
Normal file
297
pkg/coredata/audit.go
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"maps"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/getprobo/probo/pkg/gid"
|
||||||
|
"github.com/getprobo/probo/pkg/page"
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"go.gearno.de/kit/pg"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
Audit struct {
|
||||||
|
ID gid.GID `db:"id"`
|
||||||
|
OrganizationID gid.GID `db:"organization_id"`
|
||||||
|
FrameworkID gid.GID `db:"framework_id"`
|
||||||
|
ReportID *gid.GID `db:"report_id"`
|
||||||
|
ValidFrom *time.Time `db:"valid_from"`
|
||||||
|
ValidUntil *time.Time `db:"valid_until"`
|
||||||
|
State AuditState `db:"state"`
|
||||||
|
CreatedAt time.Time `db:"created_at"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
Audits []*Audit
|
||||||
|
)
|
||||||
|
|
||||||
|
func (a *Audit) CursorKey(field AuditOrderField) page.CursorKey {
|
||||||
|
switch field {
|
||||||
|
case AuditOrderFieldCreatedAt:
|
||||||
|
return page.NewCursorKey(a.ID, a.CreatedAt)
|
||||||
|
case AuditOrderFieldValidFrom:
|
||||||
|
return page.NewCursorKey(a.ID, a.ValidFrom)
|
||||||
|
case AuditOrderFieldValidUntil:
|
||||||
|
return page.NewCursorKey(a.ID, a.ValidUntil)
|
||||||
|
case AuditOrderFieldState:
|
||||||
|
return page.NewCursorKey(a.ID, a.State)
|
||||||
|
}
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unsupported order by: %s", field))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Audit) LoadByID(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
auditID gid.GID,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
organization_id,
|
||||||
|
framework_id,
|
||||||
|
report_id,
|
||||||
|
valid_from,
|
||||||
|
valid_until,
|
||||||
|
state,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM
|
||||||
|
audits
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND id = @audit_id
|
||||||
|
LIMIT 1;
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{"audit_id": auditID}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
|
||||||
|
rows, err := conn.Query(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot query audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
audit, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Audit])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot collect audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
*a = audit
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Audits) CountByOrganizationID(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
organizationID gid.GID,
|
||||||
|
) (int, error) {
|
||||||
|
q := `
|
||||||
|
SELECT
|
||||||
|
COUNT(id)
|
||||||
|
FROM
|
||||||
|
audits
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND organization_id = @organization_id
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
|
||||||
|
row := conn.QueryRow(ctx, q, args)
|
||||||
|
|
||||||
|
var count int
|
||||||
|
err := row.Scan(&count)
|
||||||
|
if err != nil {
|
||||||
|
return 0, fmt.Errorf("cannot count audits: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return count, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Audits) LoadByOrganizationID(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
organizationID gid.GID,
|
||||||
|
cursor *page.Cursor[AuditOrderField],
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
organization_id,
|
||||||
|
framework_id,
|
||||||
|
report_id,
|
||||||
|
valid_from,
|
||||||
|
valid_until,
|
||||||
|
state,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM
|
||||||
|
audits
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND organization_id = @organization_id
|
||||||
|
AND %s
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
maps.Copy(args, cursor.SQLArguments())
|
||||||
|
|
||||||
|
rows, err := conn.Query(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot query audits: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
audits, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Audit])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot collect audits: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
*a = audits
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Audit) Insert(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
INSERT INTO audits (
|
||||||
|
id,
|
||||||
|
tenant_id,
|
||||||
|
organization_id,
|
||||||
|
framework_id,
|
||||||
|
report_id,
|
||||||
|
valid_from,
|
||||||
|
valid_until,
|
||||||
|
state,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
@id,
|
||||||
|
@tenant_id,
|
||||||
|
@organization_id,
|
||||||
|
@framework_id,
|
||||||
|
@report_id,
|
||||||
|
@valid_from,
|
||||||
|
@valid_until,
|
||||||
|
@state,
|
||||||
|
@created_at,
|
||||||
|
@updated_at
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{
|
||||||
|
"id": a.ID,
|
||||||
|
"tenant_id": scope.GetTenantID(),
|
||||||
|
"organization_id": a.OrganizationID,
|
||||||
|
"framework_id": a.FrameworkID,
|
||||||
|
"report_id": a.ReportID,
|
||||||
|
"valid_from": a.ValidFrom,
|
||||||
|
"valid_until": a.ValidUntil,
|
||||||
|
"state": a.State,
|
||||||
|
"created_at": a.CreatedAt,
|
||||||
|
"updated_at": a.UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := conn.Exec(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot insert audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Audit) Update(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
UPDATE audits
|
||||||
|
SET
|
||||||
|
report_id = @report_id,
|
||||||
|
valid_from = @valid_from,
|
||||||
|
valid_until = @valid_until,
|
||||||
|
state = @state,
|
||||||
|
updated_at = @updated_at
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND id = @id
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{
|
||||||
|
"id": a.ID,
|
||||||
|
"report_id": a.ReportID,
|
||||||
|
"valid_from": a.ValidFrom,
|
||||||
|
"valid_until": a.ValidUntil,
|
||||||
|
"state": a.State,
|
||||||
|
"updated_at": a.UpdatedAt,
|
||||||
|
}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
|
||||||
|
_, err := conn.Exec(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot update audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Audit) Delete(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
DELETE FROM audits
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND id = @id
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{"id": a.ID}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
|
||||||
|
_, err := conn.Exec(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot delete audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
53
pkg/coredata/audit_order_field.go
Normal file
53
pkg/coredata/audit_order_field.go
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AuditOrderField string
|
||||||
|
|
||||||
|
const (
|
||||||
|
AuditOrderFieldCreatedAt AuditOrderField = "CREATED_AT"
|
||||||
|
AuditOrderFieldValidFrom AuditOrderField = "VALID_FROM"
|
||||||
|
AuditOrderFieldValidUntil AuditOrderField = "VALID_UNTIL"
|
||||||
|
AuditOrderFieldState AuditOrderField = "STATE"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p AuditOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p AuditOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p AuditOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *AuditOrderField) UnmarshalText(text []byte) error {
|
||||||
|
val := string(text)
|
||||||
|
switch val {
|
||||||
|
case string(AuditOrderFieldCreatedAt),
|
||||||
|
string(AuditOrderFieldValidFrom),
|
||||||
|
string(AuditOrderFieldValidUntil),
|
||||||
|
string(AuditOrderFieldState):
|
||||||
|
*p = AuditOrderField(val)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf("invalid AuditOrderField value: %q", val)
|
||||||
|
}
|
||||||
66
pkg/coredata/audit_state.go
Normal file
66
pkg/coredata/audit_state.go
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql/driver"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AuditState string
|
||||||
|
|
||||||
|
const (
|
||||||
|
AuditStateNotStarted AuditState = "NOT_STARTED"
|
||||||
|
AuditStateInProgress AuditState = "IN_PROGRESS"
|
||||||
|
AuditStateCompleted AuditState = "COMPLETED"
|
||||||
|
AuditStateRejected AuditState = "REJECTED"
|
||||||
|
AuditStateOutdated AuditState = "OUTDATED"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (as AuditState) String() string {
|
||||||
|
return string(as)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as *AuditState) Scan(value any) error {
|
||||||
|
var s string
|
||||||
|
switch v := value.(type) {
|
||||||
|
case string:
|
||||||
|
s = v
|
||||||
|
case []byte:
|
||||||
|
s = string(v)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unsupported type for AuditState: %T", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch s {
|
||||||
|
case "NOT_STARTED":
|
||||||
|
*as = AuditStateNotStarted
|
||||||
|
case "IN_PROGRESS":
|
||||||
|
*as = AuditStateInProgress
|
||||||
|
case "COMPLETED":
|
||||||
|
*as = AuditStateCompleted
|
||||||
|
case "REJECTED":
|
||||||
|
*as = AuditStateRejected
|
||||||
|
case "OUTDATED":
|
||||||
|
*as = AuditStateOutdated
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("invalid AuditState value: %q", s)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as AuditState) Value() (driver.Value, error) {
|
||||||
|
return as.String(), nil
|
||||||
|
}
|
||||||
@@ -35,4 +35,6 @@ const (
|
|||||||
DocumentVersionSignatureEntityType
|
DocumentVersionSignatureEntityType
|
||||||
AssetEntityType
|
AssetEntityType
|
||||||
DatumEntityType
|
DatumEntityType
|
||||||
|
AuditEntityType
|
||||||
|
ReportEntityType
|
||||||
)
|
)
|
||||||
|
|||||||
34
pkg/coredata/migrations/20250722T151525Z.sql
Normal file
34
pkg/coredata/migrations/20250722T151525Z.sql
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
-- Create audit state enum
|
||||||
|
CREATE TYPE audit_state AS ENUM (
|
||||||
|
'NOT_STARTED',
|
||||||
|
'IN_PROGRESS',
|
||||||
|
'COMPLETED',
|
||||||
|
'REJECTED',
|
||||||
|
'OUTDATED'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Create reports table
|
||||||
|
CREATE TABLE reports (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
tenant_id TEXT NOT NULL,
|
||||||
|
object_key TEXT NOT NULL,
|
||||||
|
mime_type TEXT NOT NULL,
|
||||||
|
filename TEXT NOT NULL,
|
||||||
|
size BIGINT NOT NULL,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Create audits table
|
||||||
|
CREATE TABLE audits (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
tenant_id TEXT NOT NULL,
|
||||||
|
organization_id TEXT NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
|
||||||
|
framework_id TEXT NOT NULL REFERENCES frameworks(id) ON DELETE CASCADE,
|
||||||
|
report_id TEXT REFERENCES reports(id) ON DELETE SET NULL,
|
||||||
|
valid_from DATE,
|
||||||
|
valid_until DATE,
|
||||||
|
state audit_state NOT NULL,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE NOT NULL
|
||||||
|
);
|
||||||
202
pkg/coredata/report.go
Normal file
202
pkg/coredata/report.go
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"maps"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/getprobo/probo/pkg/gid"
|
||||||
|
"github.com/getprobo/probo/pkg/page"
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
"go.gearno.de/kit/pg"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
Report struct {
|
||||||
|
ID gid.GID `db:"id"`
|
||||||
|
ObjectKey string `db:"object_key"`
|
||||||
|
MimeType string `db:"mime_type"`
|
||||||
|
Filename string `db:"filename"`
|
||||||
|
Size int64 `db:"size"`
|
||||||
|
CreatedAt time.Time `db:"created_at"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
Reports []*Report
|
||||||
|
)
|
||||||
|
|
||||||
|
func (r *Report) LoadByID(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
reportID gid.GID,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
object_key,
|
||||||
|
mime_type,
|
||||||
|
filename,
|
||||||
|
size,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM
|
||||||
|
reports
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND id = @report_id
|
||||||
|
LIMIT 1;
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{"report_id": reportID}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
|
||||||
|
rows, err := conn.Query(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot query report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
report, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Report])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot collect report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
*r = report
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Report) Insert(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
INSERT INTO reports (
|
||||||
|
id,
|
||||||
|
tenant_id,
|
||||||
|
object_key,
|
||||||
|
mime_type,
|
||||||
|
filename,
|
||||||
|
size,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
@id,
|
||||||
|
@tenant_id,
|
||||||
|
@object_key,
|
||||||
|
@mime_type,
|
||||||
|
@filename,
|
||||||
|
@size,
|
||||||
|
@created_at,
|
||||||
|
@updated_at
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{
|
||||||
|
"id": r.ID,
|
||||||
|
"tenant_id": scope.GetTenantID(),
|
||||||
|
"object_key": r.ObjectKey,
|
||||||
|
"mime_type": r.MimeType,
|
||||||
|
"filename": r.Filename,
|
||||||
|
"size": r.Size,
|
||||||
|
"created_at": r.CreatedAt,
|
||||||
|
"updated_at": r.UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := conn.Exec(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot insert report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Report) Update(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
UPDATE reports
|
||||||
|
SET
|
||||||
|
object_key = @object_key,
|
||||||
|
mime_type = @mime_type,
|
||||||
|
filename = @filename,
|
||||||
|
size = @size,
|
||||||
|
updated_at = @updated_at
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND id = @id
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{
|
||||||
|
"id": r.ID,
|
||||||
|
"object_key": r.ObjectKey,
|
||||||
|
"mime_type": r.MimeType,
|
||||||
|
"filename": r.Filename,
|
||||||
|
"size": r.Size,
|
||||||
|
"updated_at": r.UpdatedAt,
|
||||||
|
}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
|
||||||
|
_, err := conn.Exec(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot update report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Report) Delete(
|
||||||
|
ctx context.Context,
|
||||||
|
conn pg.Conn,
|
||||||
|
scope Scoper,
|
||||||
|
) error {
|
||||||
|
q := `
|
||||||
|
DELETE FROM reports
|
||||||
|
WHERE
|
||||||
|
%s
|
||||||
|
AND id = @id
|
||||||
|
`
|
||||||
|
|
||||||
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
|
args := pgx.StrictNamedArgs{"id": r.ID}
|
||||||
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
|
||||||
|
_, err := conn.Exec(ctx, q, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot delete report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Report) CursorKey(orderBy ReportOrderField) page.CursorKey {
|
||||||
|
switch orderBy {
|
||||||
|
case ReportOrderFieldID:
|
||||||
|
return page.NewCursorKey(r.ID, r.ID)
|
||||||
|
default:
|
||||||
|
return page.NewCursorKey(r.ID, r.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
40
pkg/coredata/report_order_field.go
Normal file
40
pkg/coredata/report_order_field.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package coredata
|
||||||
|
|
||||||
|
type (
|
||||||
|
ReportOrderField string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ReportOrderFieldID ReportOrderField = "ID"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p ReportOrderField) Column() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p ReportOrderField) String() string {
|
||||||
|
return string(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p ReportOrderField) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(p.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ReportOrderField) UnmarshalText(text []byte) error {
|
||||||
|
*p = ReportOrderField(text)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
336
pkg/probo/audit_service.go
Normal file
336
pkg/probo/audit_service.go
Normal file
@@ -0,0 +1,336 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package probo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/getprobo/probo/pkg/coredata"
|
||||||
|
"github.com/getprobo/probo/pkg/gid"
|
||||||
|
"github.com/getprobo/probo/pkg/page"
|
||||||
|
"go.gearno.de/kit/pg"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AuditService struct {
|
||||||
|
svc *TenantService
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
CreateAuditRequest struct {
|
||||||
|
OrganizationID gid.GID
|
||||||
|
FrameworkID gid.GID
|
||||||
|
ValidFrom *time.Time
|
||||||
|
ValidUntil *time.Time
|
||||||
|
State *coredata.AuditState
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateAuditRequest struct {
|
||||||
|
ID gid.GID
|
||||||
|
ValidFrom *time.Time
|
||||||
|
ValidUntil *time.Time
|
||||||
|
State *coredata.AuditState
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateAuditStateRequest struct {
|
||||||
|
ID gid.GID
|
||||||
|
State coredata.AuditState
|
||||||
|
}
|
||||||
|
|
||||||
|
UploadAuditReportRequest struct {
|
||||||
|
AuditID gid.GID
|
||||||
|
File File
|
||||||
|
}
|
||||||
|
|
||||||
|
DeleteAuditReportRequest struct {
|
||||||
|
ID gid.GID
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s AuditService) Get(
|
||||||
|
ctx context.Context,
|
||||||
|
auditID gid.GID,
|
||||||
|
) (*coredata.Audit, error) {
|
||||||
|
audit := &coredata.Audit{}
|
||||||
|
|
||||||
|
err := s.svc.pg.WithConn(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
return audit.LoadByID(ctx, conn, s.svc.scope, auditID)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return audit, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *AuditService) Create(
|
||||||
|
ctx context.Context,
|
||||||
|
req *CreateAuditRequest,
|
||||||
|
) (*coredata.Audit, error) {
|
||||||
|
now := time.Now()
|
||||||
|
|
||||||
|
audit := &coredata.Audit{
|
||||||
|
ID: gid.New(s.svc.scope.GetTenantID(), coredata.AuditEntityType),
|
||||||
|
OrganizationID: req.OrganizationID,
|
||||||
|
FrameworkID: req.FrameworkID,
|
||||||
|
ValidFrom: req.ValidFrom,
|
||||||
|
ValidUntil: req.ValidUntil,
|
||||||
|
State: coredata.AuditStateNotStarted,
|
||||||
|
CreatedAt: now,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.State != nil {
|
||||||
|
audit.State = *req.State
|
||||||
|
}
|
||||||
|
|
||||||
|
err := s.svc.pg.WithTx(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
organization := &coredata.Organization{}
|
||||||
|
if err := organization.LoadByID(ctx, conn, s.svc.scope, req.OrganizationID); err != nil {
|
||||||
|
return fmt.Errorf("cannot load organization: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
framework := &coredata.Framework{}
|
||||||
|
if err := framework.LoadByID(ctx, conn, s.svc.scope, req.FrameworkID); err != nil {
|
||||||
|
return fmt.Errorf("cannot load framework: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := audit.Insert(ctx, conn, s.svc.scope); err != nil {
|
||||||
|
return fmt.Errorf("cannot insert audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return audit, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *AuditService) Update(
|
||||||
|
ctx context.Context,
|
||||||
|
req *UpdateAuditRequest,
|
||||||
|
) (*coredata.Audit, error) {
|
||||||
|
audit := &coredata.Audit{}
|
||||||
|
|
||||||
|
err := s.svc.pg.WithTx(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
if err := audit.LoadByID(ctx, conn, s.svc.scope, req.ID); err != nil {
|
||||||
|
return fmt.Errorf("cannot load audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.ValidFrom != nil {
|
||||||
|
audit.ValidFrom = req.ValidFrom
|
||||||
|
}
|
||||||
|
if req.ValidUntil != nil {
|
||||||
|
audit.ValidUntil = req.ValidUntil
|
||||||
|
}
|
||||||
|
if req.State != nil {
|
||||||
|
audit.State = *req.State
|
||||||
|
}
|
||||||
|
|
||||||
|
audit.UpdatedAt = time.Now()
|
||||||
|
|
||||||
|
if err := audit.Update(ctx, conn, s.svc.scope); err != nil {
|
||||||
|
return fmt.Errorf("cannot update audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return audit, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AuditService) Delete(
|
||||||
|
ctx context.Context,
|
||||||
|
auditID gid.GID,
|
||||||
|
) error {
|
||||||
|
audit := coredata.Audit{ID: auditID}
|
||||||
|
return s.svc.pg.WithConn(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
err := audit.Delete(ctx, conn, s.svc.scope)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot delete audit: %w", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AuditService) ListForOrganizationID(
|
||||||
|
ctx context.Context,
|
||||||
|
organizationID gid.GID,
|
||||||
|
cursor *page.Cursor[coredata.AuditOrderField],
|
||||||
|
) (*page.Page[*coredata.Audit, coredata.AuditOrderField], error) {
|
||||||
|
var audits coredata.Audits
|
||||||
|
|
||||||
|
err := s.svc.pg.WithConn(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
err := audits.LoadByOrganizationID(ctx, conn, s.svc.scope, organizationID, cursor)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot load audits: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return page.NewPage(audits, cursor), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AuditService) CountForOrganizationID(
|
||||||
|
ctx context.Context,
|
||||||
|
organizationID gid.GID,
|
||||||
|
) (int, error) {
|
||||||
|
var count int
|
||||||
|
|
||||||
|
err := s.svc.pg.WithConn(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) (err error) {
|
||||||
|
audits := coredata.Audits{}
|
||||||
|
count, err = audits.CountByOrganizationID(ctx, conn, s.svc.scope, organizationID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot count audits: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return count, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AuditService) UploadReport(
|
||||||
|
ctx context.Context,
|
||||||
|
req UploadAuditReportRequest,
|
||||||
|
) (*coredata.Audit, error) {
|
||||||
|
audit := &coredata.Audit{}
|
||||||
|
|
||||||
|
err := s.svc.pg.WithTx(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
if err := audit.LoadByID(ctx, conn, s.svc.scope, req.AuditID); err != nil {
|
||||||
|
return fmt.Errorf("cannot load audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
report, err := s.svc.Reports.Create(ctx, req.File)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot create report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
audit.ReportID = &report.ID
|
||||||
|
audit.UpdatedAt = time.Now()
|
||||||
|
|
||||||
|
if err := audit.Update(ctx, conn, s.svc.scope); err != nil {
|
||||||
|
return fmt.Errorf("cannot update audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return audit, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AuditService) GenerateReportURL(
|
||||||
|
ctx context.Context,
|
||||||
|
auditID gid.GID,
|
||||||
|
expiresIn time.Duration,
|
||||||
|
) (*string, error) {
|
||||||
|
audit, err := s.Get(ctx, auditID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot get audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if audit.ReportID == nil {
|
||||||
|
return nil, fmt.Errorf("audit has no report")
|
||||||
|
}
|
||||||
|
|
||||||
|
url, err := s.svc.Reports.GenerateDownloadURL(ctx, *audit.ReportID, expiresIn)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot generate report download URL: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return url, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AuditService) DeleteReport(
|
||||||
|
ctx context.Context,
|
||||||
|
auditID gid.GID,
|
||||||
|
) (*coredata.Audit, error) {
|
||||||
|
audit := &coredata.Audit{}
|
||||||
|
|
||||||
|
err := s.svc.pg.WithTx(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
if err := audit.LoadByID(ctx, conn, s.svc.scope, auditID); err != nil {
|
||||||
|
return fmt.Errorf("cannot load audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if audit.ReportID != nil {
|
||||||
|
report := &coredata.Report{ID: *audit.ReportID}
|
||||||
|
|
||||||
|
if err := report.Delete(ctx, conn, s.svc.scope); err != nil {
|
||||||
|
return fmt.Errorf("cannot delete report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
audit.ReportID = nil
|
||||||
|
audit.UpdatedAt = time.Now()
|
||||||
|
|
||||||
|
if err := audit.Update(ctx, conn, s.svc.scope); err != nil {
|
||||||
|
return fmt.Errorf("cannot update audit: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return audit, nil
|
||||||
|
}
|
||||||
164
pkg/probo/report_service.go
Normal file
164
pkg/probo/report_service.go
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package probo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
|
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||||
|
"github.com/getprobo/probo/pkg/coredata"
|
||||||
|
"github.com/getprobo/probo/pkg/gid"
|
||||||
|
"go.gearno.de/crypto/uuid"
|
||||||
|
"go.gearno.de/kit/pg"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ReportService struct {
|
||||||
|
svc *TenantService
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s ReportService) Get(
|
||||||
|
ctx context.Context,
|
||||||
|
reportID gid.GID,
|
||||||
|
) (*coredata.Report, error) {
|
||||||
|
report := &coredata.Report{}
|
||||||
|
|
||||||
|
err := s.svc.pg.WithConn(
|
||||||
|
ctx,
|
||||||
|
func(conn pg.Conn) error {
|
||||||
|
err := report.LoadByID(ctx, conn, s.svc.scope, reportID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot load report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return report, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s ReportService) Create(
|
||||||
|
ctx context.Context,
|
||||||
|
file File,
|
||||||
|
) (*coredata.Report, error) {
|
||||||
|
reportID := gid.New(s.svc.scope.GetTenantID(), coredata.ReportEntityType)
|
||||||
|
now := time.Now()
|
||||||
|
|
||||||
|
objectKey, err := uuid.NewV7()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot generate object key: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = s.svc.s3.PutObject(ctx, &s3.PutObjectInput{
|
||||||
|
Bucket: aws.String(s.svc.bucket),
|
||||||
|
Key: aws.String(objectKey.String()),
|
||||||
|
Body: file.Content,
|
||||||
|
ContentType: aws.String(file.ContentType),
|
||||||
|
Metadata: map[string]string{
|
||||||
|
"report-id": reportID.String(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot upload report to S3: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
report := &coredata.Report{
|
||||||
|
ID: reportID,
|
||||||
|
ObjectKey: objectKey.String(),
|
||||||
|
MimeType: file.ContentType,
|
||||||
|
Filename: file.Filename,
|
||||||
|
Size: file.Size,
|
||||||
|
CreatedAt: now,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.svc.pg.WithConn(ctx, func(conn pg.Conn) error {
|
||||||
|
err := report.Insert(ctx, conn, s.svc.scope)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot insert report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return report, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s ReportService) Delete(
|
||||||
|
ctx context.Context,
|
||||||
|
reportID gid.GID,
|
||||||
|
) error {
|
||||||
|
return s.svc.pg.WithTx(ctx, func(conn pg.Conn) error {
|
||||||
|
report := &coredata.Report{}
|
||||||
|
err := report.LoadByID(ctx, conn, s.svc.scope, reportID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot get report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = s.svc.s3.DeleteObject(ctx, &s3.DeleteObjectInput{
|
||||||
|
Bucket: aws.String(s.svc.bucket),
|
||||||
|
Key: aws.String(report.ObjectKey),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot delete report from S3: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = report.Delete(ctx, conn, s.svc.scope)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot delete report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s ReportService) GenerateDownloadURL(
|
||||||
|
ctx context.Context,
|
||||||
|
reportID gid.GID,
|
||||||
|
expiresIn time.Duration,
|
||||||
|
) (*string, error) {
|
||||||
|
report, err := s.Get(ctx, reportID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot get report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
presignClient := s3.NewPresignClient(s.svc.s3)
|
||||||
|
|
||||||
|
presignedReq, err := presignClient.PresignGetObject(ctx, &s3.GetObjectInput{
|
||||||
|
Bucket: aws.String(s.svc.bucket),
|
||||||
|
Key: aws.String(report.ObjectKey),
|
||||||
|
ResponseCacheControl: aws.String("max-age=3600, public"),
|
||||||
|
ResponseContentType: aws.String(report.MimeType),
|
||||||
|
ResponseContentDisposition: aws.String(fmt.Sprintf("attachment; filename=\"%s\"", report.Filename)),
|
||||||
|
}, func(opts *s3.PresignOptions) {
|
||||||
|
opts.Expires = expiresIn
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot presign GetObject request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &presignedReq.URL, nil
|
||||||
|
}
|
||||||
@@ -63,6 +63,8 @@ type (
|
|||||||
Connectors *ConnectorService
|
Connectors *ConnectorService
|
||||||
Assets *AssetService
|
Assets *AssetService
|
||||||
Data *DatumService
|
Data *DatumService
|
||||||
|
Audits *AuditService
|
||||||
|
Reports *ReportService
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -140,5 +142,7 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
|
|||||||
tenantService.Connectors = &ConnectorService{svc: tenantService}
|
tenantService.Connectors = &ConnectorService{svc: tenantService}
|
||||||
tenantService.Assets = &AssetService{svc: tenantService}
|
tenantService.Assets = &AssetService{svc: tenantService}
|
||||||
tenantService.Data = &DatumService{svc: tenantService}
|
tenantService.Data = &DatumService{svc: tenantService}
|
||||||
|
tenantService.Audits = &AuditService{svc: tenantService}
|
||||||
|
tenantService.Reports = &ReportService{svc: tenantService}
|
||||||
return tenantService
|
return tenantService
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,30 @@ enum RiskTreatment
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum AuditState
|
||||||
|
@goModel(model: "github.com/getprobo/probo/pkg/coredata.AuditState") {
|
||||||
|
NOT_STARTED
|
||||||
|
@goEnum(
|
||||||
|
value: "github.com/getprobo/probo/pkg/coredata.AuditStateNotStarted"
|
||||||
|
)
|
||||||
|
IN_PROGRESS
|
||||||
|
@goEnum(
|
||||||
|
value: "github.com/getprobo/probo/pkg/coredata.AuditStateInProgress"
|
||||||
|
)
|
||||||
|
COMPLETED
|
||||||
|
@goEnum(
|
||||||
|
value: "github.com/getprobo/probo/pkg/coredata.AuditStateCompleted"
|
||||||
|
)
|
||||||
|
REJECTED
|
||||||
|
@goEnum(
|
||||||
|
value: "github.com/getprobo/probo/pkg/coredata.AuditStateRejected"
|
||||||
|
)
|
||||||
|
OUTDATED
|
||||||
|
@goEnum(
|
||||||
|
value: "github.com/getprobo/probo/pkg/coredata.AuditStateOutdated"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
# Order Field Enums
|
# Order Field Enums
|
||||||
enum UserOrderField
|
enum UserOrderField
|
||||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.UserOrderField") {
|
@goModel(model: "github.com/getprobo/probo/pkg/coredata.UserOrderField") {
|
||||||
@@ -521,6 +545,27 @@ enum ControlStatus
|
|||||||
value: "github.com/getprobo/probo/pkg/coredata.ControlStatusExcluded"
|
value: "github.com/getprobo/probo/pkg/coredata.ControlStatusExcluded"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum AuditOrderField
|
||||||
|
@goModel(model: "github.com/getprobo/probo/pkg/coredata.AuditOrderField") {
|
||||||
|
CREATED_AT
|
||||||
|
@goEnum(
|
||||||
|
value: "github.com/getprobo/probo/pkg/coredata.AuditOrderFieldCreatedAt"
|
||||||
|
)
|
||||||
|
VALID_FROM
|
||||||
|
@goEnum(
|
||||||
|
value: "github.com/getprobo/probo/pkg/coredata.AuditOrderFieldValidFrom"
|
||||||
|
)
|
||||||
|
VALID_UNTIL
|
||||||
|
@goEnum(
|
||||||
|
value: "github.com/getprobo/probo/pkg/coredata.AuditOrderFieldValidUntil"
|
||||||
|
)
|
||||||
|
STATE
|
||||||
|
@goEnum(
|
||||||
|
value: "github.com/getprobo/probo/pkg/coredata.AuditOrderFieldState"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
# Input Types
|
# Input Types
|
||||||
input UserOrder
|
input UserOrder
|
||||||
@goModel(
|
@goModel(
|
||||||
@@ -594,6 +639,14 @@ input RiskOrder
|
|||||||
field: RiskOrderField!
|
field: RiskOrderField!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input AuditOrder
|
||||||
|
@goModel(
|
||||||
|
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.AuditOrderBy"
|
||||||
|
) {
|
||||||
|
direction: OrderDirection!
|
||||||
|
field: AuditOrderField!
|
||||||
|
}
|
||||||
|
|
||||||
input EvidenceOrder
|
input EvidenceOrder
|
||||||
@goModel(
|
@goModel(
|
||||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.EvidenceOrderBy"
|
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.EvidenceOrderBy"
|
||||||
@@ -755,6 +808,14 @@ type Organization implements Node {
|
|||||||
orderBy: DatumOrder
|
orderBy: DatumOrder
|
||||||
): DatumConnection! @goField(forceResolver: true)
|
): DatumConnection! @goField(forceResolver: true)
|
||||||
|
|
||||||
|
audits(
|
||||||
|
first: Int
|
||||||
|
after: CursorKey
|
||||||
|
last: Int
|
||||||
|
before: CursorKey
|
||||||
|
orderBy: AuditOrder
|
||||||
|
): AuditConnection! @goField(forceResolver: true)
|
||||||
|
|
||||||
createdAt: Datetime!
|
createdAt: Datetime!
|
||||||
updatedAt: Datetime!
|
updatedAt: Datetime!
|
||||||
}
|
}
|
||||||
@@ -1064,6 +1125,30 @@ type Risk implements Node {
|
|||||||
updatedAt: Datetime!
|
updatedAt: Datetime!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Audit implements Node {
|
||||||
|
id: ID!
|
||||||
|
organization: Organization! @goField(forceResolver: true)
|
||||||
|
framework: Framework! @goField(forceResolver: true)
|
||||||
|
validFrom: Datetime
|
||||||
|
validUntil: Datetime
|
||||||
|
report: Report @goField(forceResolver: true)
|
||||||
|
reportUrl: String @goField(forceResolver: true)
|
||||||
|
state: AuditState!
|
||||||
|
createdAt: Datetime!
|
||||||
|
updatedAt: Datetime!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Report implements Node {
|
||||||
|
id: ID!
|
||||||
|
objectKey: String!
|
||||||
|
mimeType: String!
|
||||||
|
filename: String!
|
||||||
|
size: Int!
|
||||||
|
downloadUrl: String @goField(forceResolver: true)
|
||||||
|
createdAt: Datetime!
|
||||||
|
updatedAt: Datetime!
|
||||||
|
}
|
||||||
|
|
||||||
type Session {
|
type Session {
|
||||||
id: ID!
|
id: ID!
|
||||||
expiresAt: Datetime!
|
expiresAt: Datetime!
|
||||||
@@ -1283,6 +1368,20 @@ type DatumEdge {
|
|||||||
node: Datum!
|
node: Datum!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AuditConnection
|
||||||
|
@goModel(
|
||||||
|
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.AuditConnection"
|
||||||
|
) {
|
||||||
|
totalCount: Int! @goField(forceResolver: true)
|
||||||
|
edges: [AuditEdge!]!
|
||||||
|
pageInfo: PageInfo!
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuditEdge {
|
||||||
|
cursor: CursorKey!
|
||||||
|
node: Audit!
|
||||||
|
}
|
||||||
|
|
||||||
# Root Types
|
# Root Types
|
||||||
type Query {
|
type Query {
|
||||||
node(id: ID!): Node!
|
node(id: ID!): Node!
|
||||||
@@ -1437,6 +1536,12 @@ type Mutation {
|
|||||||
createDatum(input: CreateDatumInput!): CreateDatumPayload!
|
createDatum(input: CreateDatumInput!): CreateDatumPayload!
|
||||||
updateDatum(input: UpdateDatumInput!): UpdateDatumPayload!
|
updateDatum(input: UpdateDatumInput!): UpdateDatumPayload!
|
||||||
deleteDatum(input: DeleteDatumInput!): DeleteDatumPayload!
|
deleteDatum(input: DeleteDatumInput!): DeleteDatumPayload!
|
||||||
|
|
||||||
|
createAudit(input: CreateAuditInput!): CreateAuditPayload!
|
||||||
|
updateAudit(input: UpdateAuditInput!): UpdateAuditPayload!
|
||||||
|
deleteAudit(input: DeleteAuditInput!): DeleteAuditPayload!
|
||||||
|
uploadAuditReport(input: UploadAuditReportInput!): UploadAuditReportPayload!
|
||||||
|
deleteAuditReport(input: DeleteAuditReportInput!): DeleteAuditReportPayload!
|
||||||
}
|
}
|
||||||
|
|
||||||
# Input Types
|
# Input Types
|
||||||
@@ -1778,6 +1883,35 @@ input DeleteControlInput {
|
|||||||
controlId: ID!
|
controlId: ID!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Audit input types
|
||||||
|
input CreateAuditInput {
|
||||||
|
organizationId: ID!
|
||||||
|
frameworkId: ID!
|
||||||
|
validFrom: Datetime
|
||||||
|
validUntil: Datetime
|
||||||
|
state: AuditState
|
||||||
|
}
|
||||||
|
|
||||||
|
input UpdateAuditInput {
|
||||||
|
id: ID!
|
||||||
|
validFrom: Datetime
|
||||||
|
validUntil: Datetime
|
||||||
|
state: AuditState
|
||||||
|
}
|
||||||
|
|
||||||
|
input DeleteAuditInput {
|
||||||
|
auditId: ID!
|
||||||
|
}
|
||||||
|
|
||||||
|
input UploadAuditReportInput {
|
||||||
|
auditId: ID!
|
||||||
|
file: Upload!
|
||||||
|
}
|
||||||
|
|
||||||
|
input DeleteAuditReportInput {
|
||||||
|
auditId: ID!
|
||||||
|
}
|
||||||
|
|
||||||
# Payload Types
|
# Payload Types
|
||||||
type CreateOrganizationPayload {
|
type CreateOrganizationPayload {
|
||||||
organizationEdge: OrganizationEdge!
|
organizationEdge: OrganizationEdge!
|
||||||
@@ -2354,3 +2488,23 @@ type UpdateDatumPayload {
|
|||||||
type DeleteDatumPayload {
|
type DeleteDatumPayload {
|
||||||
deletedDatumId: ID!
|
deletedDatumId: ID!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CreateAuditPayload {
|
||||||
|
auditEdge: AuditEdge!
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateAuditPayload {
|
||||||
|
audit: Audit!
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteAuditPayload {
|
||||||
|
deletedAuditId: ID!
|
||||||
|
}
|
||||||
|
|
||||||
|
type UploadAuditReportPayload {
|
||||||
|
audit: Audit!
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteAuditReportPayload {
|
||||||
|
audit: Audit!
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
71
pkg/server/api/console/v1/types/audit.go
Normal file
71
pkg/server/api/console/v1/types/audit.go
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/getprobo/probo/pkg/coredata"
|
||||||
|
"github.com/getprobo/probo/pkg/gid"
|
||||||
|
"github.com/getprobo/probo/pkg/page"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
AuditOrderBy OrderBy[coredata.AuditOrderField]
|
||||||
|
|
||||||
|
AuditConnection struct {
|
||||||
|
TotalCount int
|
||||||
|
Edges []*AuditEdge
|
||||||
|
PageInfo PageInfo
|
||||||
|
|
||||||
|
Resolver any
|
||||||
|
ParentID gid.GID
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewAuditConnection(
|
||||||
|
p *page.Page[*coredata.Audit, coredata.AuditOrderField],
|
||||||
|
parentType any,
|
||||||
|
parentID gid.GID,
|
||||||
|
) *AuditConnection {
|
||||||
|
edges := make([]*AuditEdge, len(p.Data))
|
||||||
|
for i, audit := range p.Data {
|
||||||
|
edges[i] = NewAuditEdge(audit, p.Cursor.OrderBy.Field)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &AuditConnection{
|
||||||
|
Edges: edges,
|
||||||
|
PageInfo: *NewPageInfo(p),
|
||||||
|
|
||||||
|
Resolver: parentType,
|
||||||
|
ParentID: parentID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAudit(a *coredata.Audit) *Audit {
|
||||||
|
return &Audit{
|
||||||
|
ID: a.ID,
|
||||||
|
ValidFrom: a.ValidFrom,
|
||||||
|
ValidUntil: a.ValidUntil,
|
||||||
|
State: a.State,
|
||||||
|
CreatedAt: a.CreatedAt,
|
||||||
|
UpdatedAt: a.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAuditEdge(a *coredata.Audit, orderField coredata.AuditOrderField) *AuditEdge {
|
||||||
|
return &AuditEdge{
|
||||||
|
Node: NewAudit(a),
|
||||||
|
Cursor: a.CursorKey(orderField),
|
||||||
|
}
|
||||||
|
}
|
||||||
31
pkg/server/api/console/v1/types/report.go
Normal file
31
pkg/server/api/console/v1/types/report.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
|
// copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/getprobo/probo/pkg/coredata"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewReport(r *coredata.Report) *Report {
|
||||||
|
return &Report{
|
||||||
|
ID: r.ID,
|
||||||
|
ObjectKey: r.ObjectKey,
|
||||||
|
MimeType: r.MimeType,
|
||||||
|
Filename: r.Filename,
|
||||||
|
Size: int(r.Size),
|
||||||
|
CreatedAt: r.CreatedAt,
|
||||||
|
UpdatedAt: r.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,6 +56,27 @@ type AssignTaskPayload struct {
|
|||||||
Task *Task `json:"task"`
|
Task *Task `json:"task"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Audit struct {
|
||||||
|
ID gid.GID `json:"id"`
|
||||||
|
Organization *Organization `json:"organization"`
|
||||||
|
Framework *Framework `json:"framework"`
|
||||||
|
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||||
|
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||||
|
Report *Report `json:"report,omitempty"`
|
||||||
|
ReportURL *string `json:"reportUrl,omitempty"`
|
||||||
|
State coredata.AuditState `json:"state"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Audit) IsNode() {}
|
||||||
|
func (this Audit) GetID() gid.GID { return this.ID }
|
||||||
|
|
||||||
|
type AuditEdge struct {
|
||||||
|
Cursor page.CursorKey `json:"cursor"`
|
||||||
|
Node *Audit `json:"node"`
|
||||||
|
}
|
||||||
|
|
||||||
type BulkPublishDocumentVersionsInput struct {
|
type BulkPublishDocumentVersionsInput struct {
|
||||||
DocumentIds []gid.GID `json:"documentIds"`
|
DocumentIds []gid.GID `json:"documentIds"`
|
||||||
Changelog string `json:"changelog"`
|
Changelog string `json:"changelog"`
|
||||||
@@ -158,6 +179,18 @@ type CreateAssetPayload struct {
|
|||||||
AssetEdge *AssetEdge `json:"assetEdge"`
|
AssetEdge *AssetEdge `json:"assetEdge"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CreateAuditInput struct {
|
||||||
|
OrganizationID gid.GID `json:"organizationId"`
|
||||||
|
FrameworkID gid.GID `json:"frameworkId"`
|
||||||
|
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||||
|
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||||
|
State *coredata.AuditState `json:"state,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateAuditPayload struct {
|
||||||
|
AuditEdge *AuditEdge `json:"auditEdge"`
|
||||||
|
}
|
||||||
|
|
||||||
type CreateControlDocumentMappingInput struct {
|
type CreateControlDocumentMappingInput struct {
|
||||||
ControlID gid.GID `json:"controlId"`
|
ControlID gid.GID `json:"controlId"`
|
||||||
DocumentID gid.GID `json:"documentId"`
|
DocumentID gid.GID `json:"documentId"`
|
||||||
@@ -399,6 +432,22 @@ type DeleteAssetPayload struct {
|
|||||||
DeletedAssetID gid.GID `json:"deletedAssetId"`
|
DeletedAssetID gid.GID `json:"deletedAssetId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DeleteAuditInput struct {
|
||||||
|
AuditID gid.GID `json:"auditId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteAuditPayload struct {
|
||||||
|
DeletedAuditID gid.GID `json:"deletedAuditId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteAuditReportInput struct {
|
||||||
|
AuditID gid.GID `json:"auditId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteAuditReportPayload struct {
|
||||||
|
Audit *Audit `json:"audit"`
|
||||||
|
}
|
||||||
|
|
||||||
type DeleteControlDocumentMappingInput struct {
|
type DeleteControlDocumentMappingInput struct {
|
||||||
ControlID gid.GID `json:"controlId"`
|
ControlID gid.GID `json:"controlId"`
|
||||||
DocumentID gid.GID `json:"documentId"`
|
DocumentID gid.GID `json:"documentId"`
|
||||||
@@ -766,6 +815,7 @@ type Organization struct {
|
|||||||
Tasks *TaskConnection `json:"tasks"`
|
Tasks *TaskConnection `json:"tasks"`
|
||||||
Assets *AssetConnection `json:"assets"`
|
Assets *AssetConnection `json:"assets"`
|
||||||
Data *DatumConnection `json:"data"`
|
Data *DatumConnection `json:"data"`
|
||||||
|
Audits *AuditConnection `json:"audits"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
@@ -838,6 +888,20 @@ type RemoveUserPayload struct {
|
|||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Report struct {
|
||||||
|
ID gid.GID `json:"id"`
|
||||||
|
ObjectKey string `json:"objectKey"`
|
||||||
|
MimeType string `json:"mimeType"`
|
||||||
|
Filename string `json:"filename"`
|
||||||
|
Size int `json:"size"`
|
||||||
|
DownloadURL *string `json:"downloadUrl,omitempty"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Report) IsNode() {}
|
||||||
|
func (this Report) GetID() gid.GID { return this.ID }
|
||||||
|
|
||||||
type RequestEvidenceInput struct {
|
type RequestEvidenceInput struct {
|
||||||
TaskID gid.GID `json:"taskId"`
|
TaskID gid.GID `json:"taskId"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@@ -951,6 +1015,17 @@ type UpdateAssetPayload struct {
|
|||||||
Asset *Asset `json:"asset"`
|
Asset *Asset `json:"asset"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UpdateAuditInput struct {
|
||||||
|
ID gid.GID `json:"id"`
|
||||||
|
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||||
|
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||||
|
State *coredata.AuditState `json:"state,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateAuditPayload struct {
|
||||||
|
Audit *Audit `json:"audit"`
|
||||||
|
}
|
||||||
|
|
||||||
type UpdateControlInput struct {
|
type UpdateControlInput struct {
|
||||||
ID gid.GID `json:"id"`
|
ID gid.GID `json:"id"`
|
||||||
SectionTitle *string `json:"sectionTitle,omitempty"`
|
SectionTitle *string `json:"sectionTitle,omitempty"`
|
||||||
@@ -1102,6 +1177,15 @@ type UpdateVendorPayload struct {
|
|||||||
Vendor *Vendor `json:"vendor"`
|
Vendor *Vendor `json:"vendor"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UploadAuditReportInput struct {
|
||||||
|
AuditID gid.GID `json:"auditId"`
|
||||||
|
File graphql.Upload `json:"file"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UploadAuditReportPayload struct {
|
||||||
|
Audit *Audit `json:"audit"`
|
||||||
|
}
|
||||||
|
|
||||||
type UploadMeasureEvidenceInput struct {
|
type UploadMeasureEvidenceInput struct {
|
||||||
MeasureID gid.GID `json:"measureId"`
|
MeasureID gid.GID `json:"measureId"`
|
||||||
File graphql.Upload `json:"file"`
|
File graphql.Upload `json:"file"`
|
||||||
|
|||||||
@@ -107,6 +107,88 @@ func (r *assetConnectionResolver) TotalCount(ctx context.Context, obj *types.Ass
|
|||||||
panic(fmt.Errorf("unsupported resolver: %T", obj.Resolver))
|
panic(fmt.Errorf("unsupported resolver: %T", obj.Resolver))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Organization is the resolver for the organization field.
|
||||||
|
func (r *auditResolver) Organization(ctx context.Context, obj *types.Audit) (*types.Organization, error) {
|
||||||
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||||
|
|
||||||
|
audit, err := prb.Audits.Get(ctx, obj.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot load audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
organization, err := prb.Organizations.Get(ctx, audit.OrganizationID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot load organization: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return types.NewOrganization(organization), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Framework is the resolver for the framework field.
|
||||||
|
func (r *auditResolver) Framework(ctx context.Context, obj *types.Audit) (*types.Framework, error) {
|
||||||
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||||
|
|
||||||
|
audit, err := prb.Audits.Get(ctx, obj.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot load audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
framework, err := prb.Frameworks.Get(ctx, audit.FrameworkID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot load framework: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return types.NewFramework(framework), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Report is the resolver for the report field.
|
||||||
|
func (r *auditResolver) Report(ctx context.Context, obj *types.Audit) (*types.Report, error) {
|
||||||
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||||
|
|
||||||
|
audit, err := prb.Audits.Get(ctx, obj.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot load audit: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if audit.ReportID == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
report, err := prb.Reports.Get(ctx, *audit.ReportID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot load report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return types.NewReport(report), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReportURL is the resolver for the reportUrl field.
|
||||||
|
func (r *auditResolver) ReportURL(ctx context.Context, obj *types.Audit) (*string, error) {
|
||||||
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||||
|
|
||||||
|
if obj.Report == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
url, err := prb.Audits.GenerateReportURL(ctx, obj.ID, 15*time.Minute)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot generate report URL: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return url, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalCount is the resolver for the totalCount field.
|
||||||
|
func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.AuditConnection) (int, error) {
|
||||||
|
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||||
|
|
||||||
|
count, err := prb.Audits.CountForOrganizationID(ctx, obj.ParentID)
|
||||||
|
if err != nil {
|
||||||
|
return 0, fmt.Errorf("cannot count audits: %w", err)
|
||||||
|
}
|
||||||
|
return count, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Framework is the resolver for the framework field.
|
// Framework is the resolver for the framework field.
|
||||||
func (r *controlResolver) Framework(ctx context.Context, obj *types.Control) (*types.Framework, error) {
|
func (r *controlResolver) Framework(ctx context.Context, obj *types.Control) (*types.Framework, error) {
|
||||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||||
@@ -2191,6 +2273,101 @@ func (r *mutationResolver) DeleteDatum(ctx context.Context, input types.DeleteDa
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateAudit is the resolver for the createAudit field.
|
||||||
|
func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAuditInput) (*types.CreateAuditPayload, error) {
|
||||||
|
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||||
|
|
||||||
|
req := probo.CreateAuditRequest{
|
||||||
|
OrganizationID: input.OrganizationID,
|
||||||
|
FrameworkID: input.FrameworkID,
|
||||||
|
ValidFrom: input.ValidFrom,
|
||||||
|
ValidUntil: input.ValidUntil,
|
||||||
|
State: input.State,
|
||||||
|
}
|
||||||
|
|
||||||
|
audit, err := prb.Audits.Create(ctx, &req)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot create audit: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.CreateAuditPayload{
|
||||||
|
AuditEdge: types.NewAuditEdge(audit, coredata.AuditOrderFieldCreatedAt),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateAudit is the resolver for the updateAudit field.
|
||||||
|
func (r *mutationResolver) UpdateAudit(ctx context.Context, input types.UpdateAuditInput) (*types.UpdateAuditPayload, error) {
|
||||||
|
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||||
|
|
||||||
|
req := probo.UpdateAuditRequest{
|
||||||
|
ID: input.ID,
|
||||||
|
ValidFrom: input.ValidFrom,
|
||||||
|
ValidUntil: input.ValidUntil,
|
||||||
|
State: input.State,
|
||||||
|
}
|
||||||
|
|
||||||
|
audit, err := prb.Audits.Update(ctx, &req)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot update audit: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.UpdateAuditPayload{
|
||||||
|
Audit: types.NewAudit(audit),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteAudit is the resolver for the deleteAudit field.
|
||||||
|
func (r *mutationResolver) DeleteAudit(ctx context.Context, input types.DeleteAuditInput) (*types.DeleteAuditPayload, error) {
|
||||||
|
prb := r.ProboService(ctx, input.AuditID.TenantID())
|
||||||
|
|
||||||
|
err := prb.Audits.Delete(ctx, input.AuditID)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot delete audit: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.DeleteAuditPayload{
|
||||||
|
DeletedAuditID: input.AuditID,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UploadAuditReport is the resolver for the uploadAuditReport field.
|
||||||
|
func (r *mutationResolver) UploadAuditReport(ctx context.Context, input types.UploadAuditReportInput) (*types.UploadAuditReportPayload, error) {
|
||||||
|
prb := r.ProboService(ctx, input.AuditID.TenantID())
|
||||||
|
|
||||||
|
req := probo.UploadAuditReportRequest{
|
||||||
|
AuditID: input.AuditID,
|
||||||
|
File: probo.File{
|
||||||
|
Content: input.File.File,
|
||||||
|
Filename: input.File.Filename,
|
||||||
|
Size: input.File.Size,
|
||||||
|
ContentType: input.File.ContentType,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
audit, err := prb.Audits.UploadReport(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot upload audit report: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.UploadAuditReportPayload{
|
||||||
|
Audit: types.NewAudit(audit),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteAuditReport is the resolver for the deleteAuditReport field.
|
||||||
|
func (r *mutationResolver) DeleteAuditReport(ctx context.Context, input types.DeleteAuditReportInput) (*types.DeleteAuditReportPayload, error) {
|
||||||
|
prb := r.ProboService(ctx, input.AuditID.TenantID())
|
||||||
|
|
||||||
|
audit, err := prb.Audits.DeleteReport(ctx, input.AuditID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot delete audit report: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.DeleteAuditReportPayload{
|
||||||
|
Audit: types.NewAudit(audit),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// LogoURL is the resolver for the logoUrl field.
|
// LogoURL is the resolver for the logoUrl field.
|
||||||
func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organization) (*string, error) {
|
func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organization) (*string, error) {
|
||||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||||
@@ -2516,6 +2693,31 @@ func (r *organizationResolver) Data(ctx context.Context, obj *types.Organization
|
|||||||
return types.NewDataConnection(page, r, obj.ID), nil
|
return types.NewDataConnection(page, r, obj.ID), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Audits is the resolver for the audits field.
|
||||||
|
func (r *organizationResolver) Audits(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.AuditOrderBy) (*types.AuditConnection, error) {
|
||||||
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||||
|
|
||||||
|
pageOrderBy := page.OrderBy[coredata.AuditOrderField]{
|
||||||
|
Field: coredata.AuditOrderFieldCreatedAt,
|
||||||
|
Direction: page.OrderDirectionDesc,
|
||||||
|
}
|
||||||
|
if orderBy != nil {
|
||||||
|
pageOrderBy = page.OrderBy[coredata.AuditOrderField]{
|
||||||
|
Field: orderBy.Field,
|
||||||
|
Direction: orderBy.Direction,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||||
|
|
||||||
|
page, err := prb.Audits.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot list organization audits: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return types.NewAuditConnection(page, r, obj.ID), nil
|
||||||
|
}
|
||||||
|
|
||||||
// TotalCount is the resolver for the totalCount field.
|
// TotalCount is the resolver for the totalCount field.
|
||||||
func (r *peopleConnectionResolver) TotalCount(ctx context.Context, obj *types.PeopleConnection) (int, error) {
|
func (r *peopleConnectionResolver) TotalCount(ctx context.Context, obj *types.PeopleConnection) (int, error) {
|
||||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||||
@@ -2635,6 +2837,18 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
panic(fmt.Errorf("cannot get data: %w", err))
|
panic(fmt.Errorf("cannot get data: %w", err))
|
||||||
}
|
}
|
||||||
return types.NewDatum(datum), nil
|
return types.NewDatum(datum), nil
|
||||||
|
case coredata.AuditEntityType:
|
||||||
|
audit, err := prb.Audits.Get(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot get audit: %w", err))
|
||||||
|
}
|
||||||
|
return types.NewAudit(audit), nil
|
||||||
|
case coredata.ReportEntityType:
|
||||||
|
report, err := prb.Reports.Get(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("cannot get report: %w", err))
|
||||||
|
}
|
||||||
|
return types.NewReport(report), nil
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2652,6 +2866,18 @@ func (r *queryResolver) Viewer(ctx context.Context) (*types.Viewer, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DownloadURL is the resolver for the downloadUrl field.
|
||||||
|
func (r *reportResolver) DownloadURL(ctx context.Context, obj *types.Report) (*string, error) {
|
||||||
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||||
|
|
||||||
|
url, err := prb.Reports.GenerateDownloadURL(ctx, obj.ID, 15*time.Minute)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot generate download URL: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return url, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Owner is the resolver for the owner field.
|
// Owner is the resolver for the owner field.
|
||||||
func (r *riskResolver) Owner(ctx context.Context, obj *types.Risk) (*types.People, error) {
|
func (r *riskResolver) Owner(ctx context.Context, obj *types.Risk) (*types.People, error) {
|
||||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||||
@@ -3136,6 +3362,14 @@ func (r *Resolver) AssetConnection() schema.AssetConnectionResolver {
|
|||||||
return &assetConnectionResolver{r}
|
return &assetConnectionResolver{r}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Audit returns schema.AuditResolver implementation.
|
||||||
|
func (r *Resolver) Audit() schema.AuditResolver { return &auditResolver{r} }
|
||||||
|
|
||||||
|
// AuditConnection returns schema.AuditConnectionResolver implementation.
|
||||||
|
func (r *Resolver) AuditConnection() schema.AuditConnectionResolver {
|
||||||
|
return &auditConnectionResolver{r}
|
||||||
|
}
|
||||||
|
|
||||||
// Control returns schema.ControlResolver implementation.
|
// Control returns schema.ControlResolver implementation.
|
||||||
func (r *Resolver) Control() schema.ControlResolver { return &controlResolver{r} }
|
func (r *Resolver) Control() schema.ControlResolver { return &controlResolver{r} }
|
||||||
|
|
||||||
@@ -3208,6 +3442,9 @@ func (r *Resolver) PeopleConnection() schema.PeopleConnectionResolver {
|
|||||||
// Query returns schema.QueryResolver implementation.
|
// Query returns schema.QueryResolver implementation.
|
||||||
func (r *Resolver) Query() schema.QueryResolver { return &queryResolver{r} }
|
func (r *Resolver) Query() schema.QueryResolver { return &queryResolver{r} }
|
||||||
|
|
||||||
|
// Report returns schema.ReportResolver implementation.
|
||||||
|
func (r *Resolver) Report() schema.ReportResolver { return &reportResolver{r} }
|
||||||
|
|
||||||
// Risk returns schema.RiskResolver implementation.
|
// Risk returns schema.RiskResolver implementation.
|
||||||
func (r *Resolver) Risk() schema.RiskResolver { return &riskResolver{r} }
|
func (r *Resolver) Risk() schema.RiskResolver { return &riskResolver{r} }
|
||||||
|
|
||||||
@@ -3246,6 +3483,8 @@ func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
|
|||||||
|
|
||||||
type assetResolver struct{ *Resolver }
|
type assetResolver struct{ *Resolver }
|
||||||
type assetConnectionResolver struct{ *Resolver }
|
type assetConnectionResolver struct{ *Resolver }
|
||||||
|
type auditResolver struct{ *Resolver }
|
||||||
|
type auditConnectionResolver struct{ *Resolver }
|
||||||
type controlResolver struct{ *Resolver }
|
type controlResolver struct{ *Resolver }
|
||||||
type controlConnectionResolver struct{ *Resolver }
|
type controlConnectionResolver struct{ *Resolver }
|
||||||
type datumResolver struct{ *Resolver }
|
type datumResolver struct{ *Resolver }
|
||||||
@@ -3264,6 +3503,7 @@ type mutationResolver struct{ *Resolver }
|
|||||||
type organizationResolver struct{ *Resolver }
|
type organizationResolver struct{ *Resolver }
|
||||||
type peopleConnectionResolver struct{ *Resolver }
|
type peopleConnectionResolver struct{ *Resolver }
|
||||||
type queryResolver struct{ *Resolver }
|
type queryResolver struct{ *Resolver }
|
||||||
|
type reportResolver struct{ *Resolver }
|
||||||
type riskResolver struct{ *Resolver }
|
type riskResolver struct{ *Resolver }
|
||||||
type riskConnectionResolver struct{ *Resolver }
|
type riskConnectionResolver struct{ *Resolver }
|
||||||
type taskResolver struct{ *Resolver }
|
type taskResolver struct{ *Resolver }
|
||||||
|
|||||||
Reference in New Issue
Block a user