Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Dec 6, 2024
1 parent d6bacd7 commit ff9041d
Show file tree
Hide file tree
Showing 41 changed files with 140 additions and 125 deletions.
5 changes: 4 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import configCityssm from 'eslint-config-cityssm';
import tseslint from 'typescript-eslint';
export const config = tseslint.config(...configCityssm, {
rules: {
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'unicorn/no-null': 'warn'
}
});
Expand Down
5 changes: 4 additions & 1 deletion eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import tseslint from 'typescript-eslint'

export const config = tseslint.config(...configCityssm, {
rules: {
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'unicorn/no-null': 'warn'
}
})
Expand Down
4 changes: 2 additions & 2 deletions helpers/getAccountNumber.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { config as MSSQLConfig } from '@cityssm/mssql-multi-pool';
import type { mssqlTypes } from '@cityssm/mssql-multi-pool';
export interface AccountNumberSource {
accountNumber: string;
accountNumberSource: // eslint-disable-next-line no-secrets/no-secrets
Expand All @@ -11,4 +11,4 @@ export interface AccountNumberSource {
* @param optionalObjectCode - An optional object code.
* @returns - The account number and its source, if available.
*/
export declare function getAccountNumberByWorkOrderNumberAndObjectCode(mssqlConfig: MSSQLConfig, workOrderNumber: string, optionalObjectCode?: string): Promise<AccountNumberSource | undefined>;
export declare function getAccountNumberByWorkOrderNumberAndObjectCode(mssqlConfig: mssqlTypes.config, workOrderNumber: string, optionalObjectCode?: string): Promise<AccountNumberSource | undefined>;
4 changes: 2 additions & 2 deletions helpers/getAccountNumber.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { config as MSSQLConfig } from '@cityssm/mssql-multi-pool'
import type { mssqlTypes } from '@cityssm/mssql-multi-pool'

import { accountSegmentSeparator } from '../apiConfig.js'
import { getJobActivityObjectCodeByKeys } from '../queries/jobs/getJobActivityObjectCodes.js'
Expand All @@ -23,7 +23,7 @@ export interface AccountNumberSource {
* @returns - The account number and its source, if available.
*/
export async function getAccountNumberByWorkOrderNumberAndObjectCode(
mssqlConfig: MSSQLConfig,
mssqlConfig: mssqlTypes.config,
workOrderNumber: string,
optionalObjectCode?: string
): Promise<AccountNumberSource | undefined> {
Expand Down
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { config } from '@cityssm/mssql-multi-pool';
import type { mssqlTypes } from '@cityssm/mssql-multi-pool';
import type { DateString } from '@cityssm/utils-datetime';
import { type AccountNumberSource } from './helpers/getAccountNumber.js';
import { type AddEquipment } from './queries/equipment/addEquipment.js';
Expand All @@ -18,7 +18,7 @@ export declare class WorkTechAPI {
/**
* @param mssqlConfig - SQL Server configuration.
*/
constructor(mssqlConfig: config);
constructor(mssqlConfig: mssqlTypes.config);
/**
* Retrieves a piece of equipment.
* @param equipmentId - The equipment id.
Expand Down
6 changes: 3 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { config } from '@cityssm/mssql-multi-pool'
import type { mssqlTypes } from '@cityssm/mssql-multi-pool'
import type { DateString } from '@cityssm/utils-datetime'

import {
Expand Down Expand Up @@ -60,12 +60,12 @@ import {
* WorkTech API
*/
export class WorkTechAPI {
readonly #mssqlConfig: config
readonly #mssqlConfig: mssqlTypes.config

/**
* @param mssqlConfig - SQL Server configuration.
*/
constructor(mssqlConfig: config) {
constructor(mssqlConfig: mssqlTypes.config) {
this.#mssqlConfig = mssqlConfig
}

Expand Down
4 changes: 2 additions & 2 deletions queries/equipment/addEquipment.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { config as MSSQLConfig } from '@cityssm/mssql-multi-pool';
import type { mssqlTypes } from '@cityssm/mssql-multi-pool';
import type { BigIntString } from '../types.js';
import type { EquipmentItem } from './types.js';
export interface AddEquipment extends Partial<EquipmentItem> {
equipmentId: string;
equipmentClass: string;
equipmentDescription: string;
}
export declare function addEquipment(mssqlConfig: MSSQLConfig, equipment: AddEquipment): Promise<BigIntString>;
export declare function addEquipment(mssqlConfig: mssqlTypes.config, equipment: AddEquipment): Promise<BigIntString>;
2 changes: 1 addition & 1 deletion queries/equipment/addEquipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export async function addEquipment(mssqlConfig, equipment) {
itemId: equipment.equipmentId,
itemClass: equipment.equipmentClass,
itemDescription: equipment.equipmentDescription,
unit: 'km',
unit: 'km'
});
}
6 changes: 3 additions & 3 deletions queries/equipment/addEquipment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { config as MSSQLConfig } from '@cityssm/mssql-multi-pool'
import type { mssqlTypes } from '@cityssm/mssql-multi-pool'

import { addResourceItem } from '../items/addResourceItem.js'
import type { BigIntString } from '../types.js'
Expand All @@ -12,7 +12,7 @@ export interface AddEquipment extends Partial<EquipmentItem> {
}

export async function addEquipment(
mssqlConfig: MSSQLConfig,
mssqlConfig: mssqlTypes.config,
equipment: AddEquipment
): Promise<BigIntString> {
return await addResourceItem(mssqlConfig, {
Expand All @@ -21,6 +21,6 @@ export async function addEquipment(
itemId: equipment.equipmentId,
itemClass: equipment.equipmentClass,
itemDescription: equipment.equipmentDescription,
unit: 'km',
unit: 'km'
})
}
4 changes: 2 additions & 2 deletions queries/equipment/getEquipment.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type config as MSSQLConfig } from '@cityssm/mssql-multi-pool';
import { type mssqlTypes } from '@cityssm/mssql-multi-pool';
import type { EquipmentItem } from './types.js';
/**
* Retrieves a piece of equipment.
* @param mssqlConfig - SQL Server configuration.
* @param equipmentId - The equipment id.
* @returns - The equipment record, if available.
*/
export declare function getEquipmentByEquipmentId(mssqlConfig: MSSQLConfig, equipmentId: string): Promise<EquipmentItem | undefined>;
export declare function getEquipmentByEquipmentId(mssqlConfig: mssqlTypes.config, equipmentId: string): Promise<EquipmentItem | undefined>;
9 changes: 4 additions & 5 deletions queries/equipment/getEquipment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
type IResult,
type config as MSSQLConfig,
connect
connect,
type mssqlTypes
} from '@cityssm/mssql-multi-pool'
import NodeCache from 'node-cache'

Expand Down Expand Up @@ -54,7 +53,7 @@ const cache = new NodeCache({
* @returns - The equipment record, if available.
*/
export async function getEquipmentByEquipmentId(
mssqlConfig: MSSQLConfig,
mssqlConfig: mssqlTypes.config,
equipmentId: string
): Promise<EquipmentItem | undefined> {
let equipment: EquipmentItem | undefined = cache.get(equipmentId)
Expand All @@ -68,7 +67,7 @@ export async function getEquipmentByEquipmentId(
const equipmentResult = (await pool
.request()
.input('equipmentId', equipmentId)
.query(`${sql} and Item_ID = @equipmentId`)) as IResult<EquipmentItem>
.query(`${sql} and Item_ID = @equipmentId`)) as mssqlTypes.IResult<EquipmentItem>

if (equipmentResult.recordset.length === 0) {
return undefined
Expand Down
4 changes: 2 additions & 2 deletions queries/items/addResourceItem.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type config as MSSQLConfig } from '@cityssm/mssql-multi-pool';
import { type mssqlTypes } from '@cityssm/mssql-multi-pool';
import type { BigIntString } from '../types.js';
import type { ResourceItem } from './types.js';
export interface AddResourceItem extends Partial<ResourceItem> {
Expand All @@ -13,4 +13,4 @@ export interface AddResourceItem extends Partial<ResourceItem> {
* @param resourceItem - The resource item fields.
* @returns - The system id for the new resource item.
*/
export declare function addResourceItem(mssqlConfig: MSSQLConfig, resourceItem: AddResourceItem): Promise<BigIntString>;
export declare function addResourceItem(mssqlConfig: mssqlTypes.config, resourceItem: AddResourceItem): Promise<BigIntString>;
4 changes: 2 additions & 2 deletions queries/items/addResourceItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type config as MSSQLConfig, connect } from '@cityssm/mssql-multi-pool'
import { connect, type mssqlTypes } from '@cityssm/mssql-multi-pool'

import { getLastSystemId, incrementLastSystemId } from '../systemId.js'
import type { BigIntString } from '../types.js'
Expand All @@ -20,7 +20,7 @@ export interface AddResourceItem extends Partial<ResourceItem> {
* @returns - The system id for the new resource item.
*/
export async function addResourceItem(
mssqlConfig: MSSQLConfig,
mssqlConfig: mssqlTypes.config,
resourceItem: AddResourceItem
): Promise<BigIntString> {
if (resourceItem.itemId.length > 15) {
Expand Down
4 changes: 2 additions & 2 deletions queries/items/getItems.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type config as MSSQLConfig } from '@cityssm/mssql-multi-pool';
import { type mssqlTypes } from '@cityssm/mssql-multi-pool';
import type { ResourceItem } from './types.js';
/**
* Retrieves an item.
* @param mssqlConfig - SQL Server configuration.
* @param itemId - The item id.
* @returns - The item, if available.
*/
export declare function getItemByItemId(mssqlConfig: MSSQLConfig, itemId: string): Promise<ResourceItem | undefined>;
export declare function getItemByItemId(mssqlConfig: mssqlTypes.config, itemId: string): Promise<ResourceItem | undefined>;
12 changes: 4 additions & 8 deletions queries/items/getItems.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
type IResult,
type config as MSSQLConfig,
connect
} from '@cityssm/mssql-multi-pool'
import { connect, type mssqlTypes } from '@cityssm/mssql-multi-pool'
import NodeCache from 'node-cache'

import { cacheTimeToLiveSeconds } from '../../apiConfig.js'
Expand Down Expand Up @@ -49,21 +45,21 @@ const cache = new NodeCache({
* @returns - The item, if available.
*/
export async function getItemByItemId(
mssqlConfig: MSSQLConfig,
mssqlConfig: mssqlTypes.config,
itemId: string
): Promise<ResourceItem | undefined> {
let item: ResourceItem | undefined = cache.get(itemId)

if (item !== undefined) {
return item
}

const pool = await connect(mssqlConfig)

const itemResult = (await pool
.request()
.input('itemId', itemId)
.query(`${sql} and Item_ID = @itemId`)) as IResult<ResourceItem>
.query(`${sql} and Item_ID = @itemId`)) as mssqlTypes.IResult<ResourceItem>

if (itemResult.recordset.length === 0) {
return undefined
Expand Down
8 changes: 4 additions & 4 deletions queries/jobs/getActivities.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { type config as MSSQLConfig } from '@cityssm/mssql-multi-pool';
import { type mssqlTypes } from '@cityssm/mssql-multi-pool';
import type { Activity } from './types.js';
/**
* Retrieves an activity.
* @param mssqlConfig - SQL Server configuration.
* @param activityId - The activity id
* @returns - The activity, if available.
*/
export declare function getActivityByActivityId(mssqlConfig: MSSQLConfig, activityId: string): Promise<Activity | undefined>;
export declare function getActivityByActivityId(mssqlConfig: mssqlTypes.config, activityId: string): Promise<Activity | undefined>;
/**
* Retrieves the activity associated with a given job and fiscal year.
* @param mssqlConfig - SQL Server configuration
Expand All @@ -15,12 +15,12 @@ export declare function getActivityByActivityId(mssqlConfig: MSSQLConfig, activi
* @param fiscalYear - The fiscal year
* @returns - An array of activities.
*/
export declare function getActivityAssignedToJobByActivityIdAndFiscalYear(mssqlConfig: MSSQLConfig, jobId: string, activityId: string, fiscalYear: number | string): Promise<Activity | undefined>;
export declare function getActivityAssignedToJobByActivityIdAndFiscalYear(mssqlConfig: mssqlTypes.config, jobId: string, activityId: string, fiscalYear: number | string): Promise<Activity | undefined>;
/**
* Retrieves the activities associated with a given job and fiscal year.
* @param mssqlConfig - SQL Server configuration
* @param jobId - The job id
* @param fiscalYear - The fiscal year
* @returns - An array of activities.
*/
export declare function getActivitiesAssignedToJobByFiscalYear(mssqlConfig: MSSQLConfig, jobId: string, fiscalYear: number | string): Promise<Activity[]>;
export declare function getActivitiesAssignedToJobByFiscalYear(mssqlConfig: mssqlTypes.config, jobId: string, fiscalYear: number | string): Promise<Activity[]>;
2 changes: 2 additions & 0 deletions queries/jobs/getActivities.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { connect } from '@cityssm/mssql-multi-pool';
import NodeCache from 'node-cache';
import { cacheTimeToLiveSeconds } from '../../apiConfig.js';
Expand Down
20 changes: 11 additions & 9 deletions queries/jobs/getActivities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

import {
type IResult,
type config as MSSQLConfig,
connect
connect,
type mssqlTypes
} from '@cityssm/mssql-multi-pool'
import NodeCache from 'node-cache'

Expand Down Expand Up @@ -29,7 +31,7 @@ const cache = new NodeCache({
* @returns - The activity, if available.
*/
export async function getActivityByActivityId(
mssqlConfig: MSSQLConfig,
mssqlConfig: mssqlTypes.config,
activityId: string
): Promise<Activity | undefined> {
let activityObject: Activity | undefined = cache.get(activityId)
Expand All @@ -43,7 +45,7 @@ export async function getActivityByActivityId(
const result = (await pool
.request()
.input('activityId', activityId)
.query(`${sql} where Actv_ID = @activityId`)) as IResult<Activity>
.query(`${sql} where Actv_ID = @activityId`)) as mssqlTypes.IResult<Activity>

if (result.recordset.length === 0) {
return undefined
Expand All @@ -65,7 +67,7 @@ export async function getActivityByActivityId(
* @returns - An array of activities.
*/
export async function getActivityAssignedToJobByActivityIdAndFiscalYear(
mssqlConfig: MSSQLConfig,
mssqlConfig: mssqlTypes.config,
jobId: string,
activityId: string,
fiscalYear: number | string
Expand All @@ -80,7 +82,7 @@ export async function getActivityAssignedToJobByActivityIdAndFiscalYear(
.query(
`${sql} where Actv_ID = @activityId
and Actv_ID in (select Actv_ID from WMJACA with (nolock) where Job_ID = @jobId and Year = @fiscalYear)`
)) as IResult<Activity>
)) as mssqlTypes.IResult<Activity>

if (result.recordset.length === 0) {
return undefined
Expand All @@ -97,7 +99,7 @@ export async function getActivityAssignedToJobByActivityIdAndFiscalYear(
* @returns - An array of activities.
*/
export async function getActivitiesAssignedToJobByFiscalYear(
mssqlConfig: MSSQLConfig,
mssqlConfig: mssqlTypes.config,
jobId: string,
fiscalYear: number | string
): Promise<Activity[]> {
Expand All @@ -109,7 +111,7 @@ export async function getActivitiesAssignedToJobByFiscalYear(
.input('fiscalYear', fiscalYear)
.query(
`${sql} where Actv_ID in (select Actv_ID from WMJACA with (nolock) where Job_ID = @jobId and Year = @fiscalYear)`
)) as IResult<Activity>
)) as mssqlTypes.IResult<Activity>

return result.recordset
}
4 changes: 2 additions & 2 deletions queries/jobs/getJobActivityObjectCodes.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type config as MSSQLConfig } from '@cityssm/mssql-multi-pool';
import { type mssqlTypes } from '@cityssm/mssql-multi-pool';
import type { JobActivityObjectCode } from './types.js';
/**
* Retrieves a job - activity - object code.
Expand All @@ -10,7 +10,7 @@ import type { JobActivityObjectCode } from './types.js';
* @param keys.fiscalYear - The fiscal year.
* @returns - The job - activity - object code combination if available.
*/
export declare function getJobActivityObjectCodeByKeys(mssqlConfig: MSSQLConfig, keys: {
export declare function getJobActivityObjectCodeByKeys(mssqlConfig: mssqlTypes.config, keys: {
jobId: string;
activityId: string;
objectCode: string;
Expand Down
4 changes: 2 additions & 2 deletions queries/jobs/getJobActivityObjectCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const sql = `SELECT [Job_ID] as jobId,
export async function getJobActivityObjectCodeByKeys(mssqlConfig, keys) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const pool = await connect(mssqlConfig);
const result = await pool
const result = (await pool
.request()
.input('jobId', keys.jobId)
.input('activityId', keys.activityId)
Expand All @@ -27,7 +27,7 @@ export async function getJobActivityObjectCodeByKeys(mssqlConfig, keys) {
where Job_ID = @jobId
and Actv_ID = @activityId
and ObjCode = @objectCode
and Year = @fiscalYear`);
and Year = @fiscalYear`));
if (result.recordset.length === 0) {
return undefined;
}
Expand Down
Loading

0 comments on commit ff9041d

Please sign in to comment.