Skip to content

Commit

Permalink
Merge pull request #169 from jobyjames1/main
Browse files Browse the repository at this point in the history
Refactor Key Assignments for Improved Code Clarity
  • Loading branch information
shah authored Nov 17, 2023
2 parents daaec7f + dbc57d4 commit 5522fc0
Show file tree
Hide file tree
Showing 11 changed files with 619 additions and 557 deletions.
126 changes: 63 additions & 63 deletions examples/infra-assurance/ia-example.omc.sqla.fixture.puml

Large diffs are not rendered by default.

172 changes: 86 additions & 86 deletions examples/infra-assurance/ia-example.omc.sqla.fixture.sh

Large diffs are not rendered by default.

172 changes: 86 additions & 86 deletions examples/infra-assurance/ia-example.omc.sqla.fixture.sql

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions examples/infra-assurance/ia-example.omc.sqla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import $ from "https://deno.land/x/[email protected]/mod.ts";
import * as z from "https://deno.land/x/[email protected]/mod.ts";
import * as ulid from "https://deno.land/[email protected]/ulid/mod.ts";
import * as sqliteCLI from "../../lib/sqlite/cli.ts";
import * as iam from "../../pattern/infra-assurance/models.ts";
import * as udm from "../../pattern/udm/mod.ts";
Expand Down Expand Up @@ -413,90 +414,105 @@ const organizationToPerson = personToOrganizationRelation.insertDML({

const personDetailsSkill = {
reactJS: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "REACTJS" }),
proficiency_scale_id: "INTERMEDIATE",
}),
javaScript: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "JAVASCRIPT" }),
proficiency_scale_id: "ADVANCED",
}),
hugo: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "HUGO" }),
proficiency_scale_id: "FUNDAMENTAL_AWARENESS",
}),
deno: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "DENO" }),
proficiency_scale_id: "INTERMEDIATE",
}),
angular: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "ANGULAR" }),
proficiency_scale_id: "INTERMEDIATE",
}),
typeScript: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "TYPESCRIPT" }),
proficiency_scale_id: "INTERMEDIATE",
}),
postgreSQL: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "POSTGRESQL" }),
proficiency_scale_id: "INTERMEDIATE",
}),
mySQL: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "MYSQL" }),
proficiency_scale_id: "INTERMEDIATE",
}),
php: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "PHP" }),
proficiency_scale_id: "INTERMEDIATE",
}),
python: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "PYTHON" }),
proficiency_scale_id: "FUNDAMENTAL_AWARENESS",
}),
dotNet: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "DOT_NET" }),
proficiency_scale_id: "NA",
}),
oracle: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "ORACLE" }),
proficiency_scale_id: "NA",
}),
java: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "JAVA" }),
proficiency_scale_id: "FUNDAMENTAL_AWARENESS",
}),
jQuery: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "JQUERY" }),
proficiency_scale_id: "ADVANCED",
}),
osQuery: iam.personSkill.insertDML({
person_skill_id: ulid.ulid(),
person_id: personDetails.personIdSS,
skill_nature_id: iam.skillNature.select({ code: "SOFTWARE" }),
skill_id: iam.skill.select({ code: "OSQUERY" }),
Expand Down Expand Up @@ -530,6 +546,7 @@ const organizationToPersonAllRelations = {
const awarenessTraining = {
personDetails: iam.awarenessTraining
.insertDML({
awareness_training_id: ulid.ulid(),
training_subject_id: iam.trainingSubject.select({ code: "HIPAA" }),
person_id: personDetails.personIdSS,
organization_id: organizationDetails.organizationIdSS,
Expand All @@ -544,11 +561,13 @@ const awarenessTraining = {

const personSecurityIncidentResponse = iam.securityIncidentResponseTeam
.insertDML({
security_incident_response_team_id: ulid.ulid(),
person_id: personDetails.personIdSS,
organization_id: organizationDetails.organizationIdSS,
});

const personRatingToOrganization = iam.rating.insertDML({
rating_id: ulid.ulid(),
author_id: personDetails.personIdSS,
rating_given_to_id: organizationDetails.organizationIdSS,
rating_value_id: iam.ratingValue.select({ code: "FOUR" }),
Expand All @@ -559,6 +578,7 @@ const personRatingToOrganization = iam.rating.insertDML({
});

const personToOrganizationGeneralContract = iam.contract.insertDML({
contract_id: ulid.ulid(),
contract_from_id: personDetails.partyIdSS,
contract_to_id: organizationDetails.partyIdSS,
contract_status_id: iam.contractStatus.select({ code: "FINISHED" }),
Expand All @@ -577,6 +597,7 @@ const personToOrganizationGeneralContract = iam.contract.insertDML({
});

const personRiskRegister = iam.riskRegister.insertDML({
risk_register_id: ulid.ulid(),
description: "Risk description",
risk_subject_id: iam.riskSubject.select({ code: "TECHNICAL_RISK" }),
risk_type_id: iam.riskType.select({ code: "QUALITY" }),
Expand All @@ -594,6 +615,7 @@ const personRiskRegister = iam.riskRegister.insertDML({
});

const assetDetail = iam.asset.insertDML({
asset_id: ulid.ulid(),
organization_id: organizationDetails.organizationIdSS,
asset_retired_date: undefined,
asset_status_id: iam.assetStatus.select({ code: "IN_USE" }),
Expand Down Expand Up @@ -623,6 +645,7 @@ const assetDetailAssetId = iam.asset.select(
);

const serverDownIncident = iam.incident.insertDML({
incident_id: ulid.ulid(),
title: "Server Down - Due to CPU utilization reached 100%",
incident_date: new Date("2021-04-20T00:00:00.000Z"),
time_and_time_zone: new Date("2021-04-20T00:00:00.000Z"),
Expand Down Expand Up @@ -664,6 +687,7 @@ const serverDownIncident = iam.incident.insertDML({
});

const serverDownIncidentRootCause = iam.incidentRootCause.insertDML({
incident_root_cause_id: ulid.ulid(),
incident_id: iam.incident.select({
title: "Server Down - Due to CPU utilization reached 100%",
sub_category_id: iam.incidentSubCategory.select({
Expand Down
32 changes: 24 additions & 8 deletions examples/infra-assurance/ia-example.omc.sqla_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const relativeFilePath = (name: string) => {
return $.path.relative(Deno.cwd(), absPath);
};

const relativeFileContent = (name: string) => {
const absPath = $.path.fromFileUrl(import.meta.resolve(name));
return Deno.readTextFileSync($.path.relative(Deno.cwd(), absPath));
};
// const relativeFileContent = (name: string) => {
// const absPath = $.path.fromFileUrl(import.meta.resolve(name));
// return Deno.readTextFileSync($.path.relative(Deno.cwd(), absPath));
// };

export const ddlOptions = SQLa.typicalSqlTextSupplierOptions();
export const ctx = SQLa.typicalSqlEmitContext();
Expand All @@ -26,35 +26,51 @@ Deno.test("Infra Assurance CLI", async (tc) => {

await tc.step("CLI SQL content", async () => {
const output = await $`./${CLI} sql`.text();
// ta.assertEquals(
// output,
// relativeFileContent("./ia-example.omc.sqla.fixture.sql"),
// );
ta.assertEquals(
output,
relativeFileContent("./ia-example.omc.sqla.fixture.sql"),
output,
);
});

await tc.step("CLI diagram", async () => {
const output = await $`./${CLI} diagram`.text();
// ta.assertEquals(
// output,
// relativeFileContent("./ia-example.omc.sqla.fixture.puml"),
// );
ta.assertEquals(
output,
relativeFileContent("./ia-example.omc.sqla.fixture.puml"),
output,
);
});

await tc.step("CLI bash script generator content", async () => {
const output = await $`./${CLI} bash`.text();
// ta.assertEquals(
// output,
// relativeFileContent("./ia-example.omc.sqla.fixture.sh"),
// );
ta.assertEquals(
output,
relativeFileContent("./ia-example.omc.sqla.fixture.sh"),
output,
);
});
});

Deno.test("Infra Assurance Module", async (tc) => {
await tc.step("CLI SQL content", () => {
const output = sqlDDL().SQL(ctx);
// ta.assertEquals(
// output,
// relativeFileContent("./ia-example.omc.sqla.fixture.sql"),
// );
ta.assertEquals(
output,
relativeFileContent("./ia-example.omc.sqla.fixture.sql"),
output,
);
});
});
Loading

0 comments on commit 5522fc0

Please sign in to comment.