Skip to content

Commit

Permalink
final version
Browse files Browse the repository at this point in the history
  • Loading branch information
zoe-codez committed Apr 17, 2024
1 parent 9571375 commit c52cf61
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 83 deletions.
100 changes: 50 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
},
"license": "MIT",
"dependencies": {
"@digital-alchemy/core": "^0.3.12",
"@digital-alchemy/hass": "^0.3.10",
"@digital-alchemy/core": "^0.3.11",
"@digital-alchemy/hass": "^0.3.12",
"js-yaml": "^4.1.0"
},
"devDependencies": {
Expand All @@ -38,8 +38,8 @@
"@types/mute-stream": "^0.0.4",
"@types/node": "^20.12.7",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "7.6.0",
"@typescript-eslint/parser": "7.6.0",
"@typescript-eslint/eslint-plugin": "7.7.0",
"@typescript-eslint/parser": "7.7.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "^2.29.1",
Expand Down
31 changes: 29 additions & 2 deletions src/build.extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,36 @@ export function BuildTypes({
`// This file is generated, and is automatically updated as a npm post install step`,
"// Do not edit this file, it will only affect type definitions, not functional code",
`import { PICK_ENTITY } from "./helpers";`,
``,
`// #MARK: ENTITY_SETUP`,
`export const ENTITY_SETUP = ${JSON.stringify(entitySetup, undefined, " ")};`,
``,
`// #MARK: iCallService`,
typeInterface,
type_writer.identifiers(),
].join(`\n\n`);
``,
`// #MARK: REGISTRY_SETUP`,
type_writer.identifiers.RegistryDetails(),
``,
`// #MARK: TAreaId`,
type_writer.identifiers.area(),
``,
`// #MARK: TDeviceId`,
type_writer.identifiers.device(),
``,
`// #MARK: TFloorId`,
type_writer.identifiers.floor(),
``,
`// #MARK: TLabelId`,
type_writer.identifiers.label(),
``,
`// #MARK: TZoneId`,
type_writer.identifiers.zone(),
``,
`// #MARK: TRawEntityIds`,
type_writer.identifiers.entityIds(entities),
``,
`// #MARK: TRawDomains`,
type_writer.identifiers.domains(entities),
].join(`\n`);
}
}
25 changes: 15 additions & 10 deletions src/i-call-service.extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,17 +359,22 @@ export async function ICallServiceExtension({

// #MARK: BuildDomain
function buildDomain({ domain, services }: HassServiceDTO) {
return factory.createPropertySignature(
undefined,
factory.createIdentifier(domain),
undefined,
factory.createTypeLiteralNode(
// Create functions based on provided services
// { [...service_name](service_data): Promise<void> }
Object.entries(services)
.sort(([a], [b]) => (a > b ? UP : DOWN))
.map(([key, value]) => buildService(domain, key, value)),
return addSyntheticLeadingComment(
factory.createPropertySignature(
undefined,
factory.createIdentifier(domain),
undefined,
factory.createTypeLiteralNode(
// Create functions based on provided services
// { [...service_name](service_data): Promise<void> }
Object.entries(services)
.sort(([a], [b]) => (a > b ? UP : DOWN))
.map(([key, value]) => buildService(domain, key, value)),
),
),
SyntaxKind.SingleLineCommentTrivia,
`#MARK: ${domain}`,
true,
);
}

Expand Down
Loading

0 comments on commit c52cf61

Please sign in to comment.