code updates
parent
95bbfeba48
commit
4a529fad3c
|
|
@ -1,4 +1,4 @@
|
||||||
import type * as recordTypes from '../types/recordTypes';
|
import type * as recordTypes from '../types/recordTypes.js';
|
||||||
export declare function getLotOccupantTypes(): Promise<recordTypes.LotOccupantType[]>;
|
export declare function getLotOccupantTypes(): Promise<recordTypes.LotOccupantType[]>;
|
||||||
export declare function getLotOccupantTypeById(lotOccupantTypeId: number): Promise<recordTypes.LotOccupantType | undefined>;
|
export declare function getLotOccupantTypeById(lotOccupantTypeId: number): Promise<recordTypes.LotOccupantType | undefined>;
|
||||||
export declare function getLotOccupantTypeByLotOccupantType(lotOccupantType: string): Promise<recordTypes.LotOccupantType | undefined>;
|
export declare function getLotOccupantTypeByLotOccupantType(lotOccupantType: string): Promise<recordTypes.LotOccupantType | undefined>;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import cluster from 'node:cluster';
|
import cluster from 'node:cluster';
|
||||||
|
import Debug from 'debug';
|
||||||
import * as configFunctions from './functions.config.js';
|
import * as configFunctions from './functions.config.js';
|
||||||
import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from './lotOccupancyDB/getLotOccupantTypes.js';
|
import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from './lotOccupancyDB/getLotOccupantTypes.js';
|
||||||
import { getLotStatuses as getLotStatusesFromDatabase } from './lotOccupancyDB/getLotStatuses.js';
|
import { getLotStatuses as getLotStatusesFromDatabase } from './lotOccupancyDB/getLotStatuses.js';
|
||||||
import { getLotTypes as getLotTypesFromDatabase } from './lotOccupancyDB/getLotTypes.js';
|
import { getLotTypes as getLotTypesFromDatabase } from './lotOccupancyDB/getLotTypes.js';
|
||||||
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from './lotOccupancyDB/getOccupancyTypes.js';
|
|
||||||
import { getOccupancyTypeFields as getOccupancyTypeFieldsFromDatabase } from './lotOccupancyDB/getOccupancyTypeFields.js';
|
import { getOccupancyTypeFields as getOccupancyTypeFieldsFromDatabase } from './lotOccupancyDB/getOccupancyTypeFields.js';
|
||||||
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from './lotOccupancyDB/getWorkOrderTypes.js';
|
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from './lotOccupancyDB/getOccupancyTypes.js';
|
||||||
import { getWorkOrderMilestoneTypes as getWorkOrderMilestoneTypesFromDatabase } from './lotOccupancyDB/getWorkOrderMilestoneTypes.js';
|
import { getWorkOrderMilestoneTypes as getWorkOrderMilestoneTypesFromDatabase } from './lotOccupancyDB/getWorkOrderMilestoneTypes.js';
|
||||||
import Debug from 'debug';
|
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from './lotOccupancyDB/getWorkOrderTypes.js';
|
||||||
const debug = Debug(`lot-occupancy-system:functions.cache:${process.pid}`);
|
const debug = Debug(`lot-occupancy-system:functions.cache:${process.pid}`);
|
||||||
let lotOccupantTypes;
|
let lotOccupantTypes;
|
||||||
export async function getLotOccupantTypes() {
|
export async function getLotOccupantTypes() {
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,23 @@
|
||||||
|
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
||||||
/* eslint-disable @typescript-eslint/indent */
|
/* eslint-disable @typescript-eslint/indent */
|
||||||
|
|
||||||
import cluster from 'node:cluster'
|
import cluster from 'node:cluster'
|
||||||
|
|
||||||
|
import Debug from 'debug'
|
||||||
|
|
||||||
|
import type { ClearCacheWorkerMessage } from '../types/applicationTypes.js'
|
||||||
|
// eslint-disable-next-line import/namespace
|
||||||
|
import type * as recordTypes from '../types/recordTypes.js'
|
||||||
|
|
||||||
import * as configFunctions from './functions.config.js'
|
import * as configFunctions from './functions.config.js'
|
||||||
|
|
||||||
import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from './lotOccupancyDB/getLotOccupantTypes.js'
|
import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from './lotOccupancyDB/getLotOccupantTypes.js'
|
||||||
|
|
||||||
import { getLotStatuses as getLotStatusesFromDatabase } from './lotOccupancyDB/getLotStatuses.js'
|
import { getLotStatuses as getLotStatusesFromDatabase } from './lotOccupancyDB/getLotStatuses.js'
|
||||||
|
|
||||||
import { getLotTypes as getLotTypesFromDatabase } from './lotOccupancyDB/getLotTypes.js'
|
import { getLotTypes as getLotTypesFromDatabase } from './lotOccupancyDB/getLotTypes.js'
|
||||||
|
|
||||||
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from './lotOccupancyDB/getOccupancyTypes.js'
|
|
||||||
import { getOccupancyTypeFields as getOccupancyTypeFieldsFromDatabase } from './lotOccupancyDB/getOccupancyTypeFields.js'
|
import { getOccupancyTypeFields as getOccupancyTypeFieldsFromDatabase } from './lotOccupancyDB/getOccupancyTypeFields.js'
|
||||||
|
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from './lotOccupancyDB/getOccupancyTypes.js'
|
||||||
|
import { getWorkOrderMilestoneTypes as getWorkOrderMilestoneTypesFromDatabase } from './lotOccupancyDB/getWorkOrderMilestoneTypes.js'
|
||||||
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from './lotOccupancyDB/getWorkOrderTypes.js'
|
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from './lotOccupancyDB/getWorkOrderTypes.js'
|
||||||
|
|
||||||
import { getWorkOrderMilestoneTypes as getWorkOrderMilestoneTypesFromDatabase } from './lotOccupancyDB/getWorkOrderMilestoneTypes.js'
|
|
||||||
|
|
||||||
import type * as recordTypes from '../types/recordTypes'
|
|
||||||
import type { ClearCacheWorkerMessage } from '../types/applicationTypes'
|
|
||||||
|
|
||||||
import Debug from 'debug'
|
|
||||||
const debug = Debug(`lot-occupancy-system:functions.cache:${process.pid}`)
|
const debug = Debug(`lot-occupancy-system:functions.cache:${process.pid}`)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import type { User } from '../types/recordTypes';
|
|
||||||
export interface UserRequest {
|
export interface UserRequest {
|
||||||
session?: {
|
session?: {
|
||||||
user?: User;
|
user?: User;
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,9 @@ export async function apiKeyIsValid(request) {
|
||||||
if (userName === undefined) {
|
if (userName === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const canLogin = configFunctions
|
return configFunctions
|
||||||
.getProperty('users.canLogin')
|
.getProperty('users.canLogin')
|
||||||
.some((currentUserName) => {
|
.some((currentUserName) => {
|
||||||
return userName === currentUserName.toLowerCase();
|
return userName === currentUserName.toLowerCase();
|
||||||
});
|
});
|
||||||
return canLogin;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import { getUserNameFromApiKey } from './functions.api.js'
|
import { getUserNameFromApiKey } from './functions.api.js'
|
||||||
import * as configFunctions from './functions.config.js'
|
import * as configFunctions from './functions.config.js'
|
||||||
|
|
||||||
import type { User } from '../types/recordTypes'
|
|
||||||
|
|
||||||
export interface UserRequest {
|
export interface UserRequest {
|
||||||
session?: {
|
session?: {
|
||||||
user?: User
|
user?: User
|
||||||
|
|
@ -36,11 +34,9 @@ export async function apiKeyIsValid(request: APIRequest): Promise<boolean> {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const canLogin = configFunctions
|
return configFunctions
|
||||||
.getProperty('users.canLogin')
|
.getProperty('users.canLogin')
|
||||||
.some((currentUserName) => {
|
.some((currentUserName) => {
|
||||||
return userName === currentUserName.toLowerCase()
|
return userName === currentUserName.toLowerCase()
|
||||||
})
|
})
|
||||||
|
|
||||||
return canLogin
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
|
import Debug from 'debug';
|
||||||
import { lotOccupancyDB as databasePath } from '../data/databasePaths.js';
|
import { lotOccupancyDB as databasePath } from '../data/databasePaths.js';
|
||||||
import { initializeDatabase } from './initializer.database.js';
|
import { initializeDatabase } from './initializer.database.js';
|
||||||
import { addOccupancyTypeField } from './lotOccupancyDB/addOccupancyTypeField.js';
|
|
||||||
import { addLotOccupantType } from './lotOccupancyDB/addLotOccupantType.js';
|
import { addLotOccupantType } from './lotOccupancyDB/addLotOccupantType.js';
|
||||||
|
import { addOccupancyTypeField } from './lotOccupancyDB/addOccupancyTypeField.js';
|
||||||
import { addRecord } from './lotOccupancyDB/addRecord.js';
|
import { addRecord } from './lotOccupancyDB/addRecord.js';
|
||||||
import Debug from 'debug';
|
|
||||||
const debug = Debug('lot-occupancy-system:initialize');
|
const debug = Debug('lot-occupancy-system:initialize');
|
||||||
const session = {
|
const user = {
|
||||||
user: {
|
|
||||||
userName: 'init.cemetery',
|
userName: 'init.cemetery',
|
||||||
userProperties: {
|
userProperties: {
|
||||||
canUpdate: true,
|
canUpdate: true,
|
||||||
isAdmin: true,
|
isAdmin: true,
|
||||||
apiKey: ''
|
apiKey: ''
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
export async function initializeCemeteryDatabase() {
|
export async function initializeCemeteryDatabase() {
|
||||||
debug('Checking for ' + databasePath + '...');
|
debug('Checking for ' + databasePath + '...');
|
||||||
|
|
@ -24,39 +22,39 @@ export async function initializeCemeteryDatabase() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
debug('New database file created. Proceeding with initialization.');
|
debug('New database file created. Proceeding with initialization.');
|
||||||
await addRecord('LotTypes', 'Casket Grave', 1, session);
|
await addRecord('LotTypes', 'Casket Grave', 1, user);
|
||||||
await addRecord('LotTypes', 'Columbarium', 2, session);
|
await addRecord('LotTypes', 'Columbarium', 2, user);
|
||||||
await addRecord('LotTypes', 'Mausoleum', 2, session);
|
await addRecord('LotTypes', 'Mausoleum', 2, user);
|
||||||
await addRecord('LotTypes', 'Niche Wall', 2, session);
|
await addRecord('LotTypes', 'Niche Wall', 2, user);
|
||||||
await addRecord('LotTypes', 'Urn Garden', 2, session);
|
await addRecord('LotTypes', 'Urn Garden', 2, user);
|
||||||
await addRecord('LotTypes', 'Crematorium', 2, session);
|
await addRecord('LotTypes', 'Crematorium', 2, user);
|
||||||
await addRecord('LotStatuses', 'Available', 1, session);
|
await addRecord('LotStatuses', 'Available', 1, user);
|
||||||
await addRecord('LotStatuses', 'Reserved', 2, session);
|
await addRecord('LotStatuses', 'Reserved', 2, user);
|
||||||
await addRecord('LotStatuses', 'Taken', 3, session);
|
await addRecord('LotStatuses', 'Taken', 3, user);
|
||||||
await addLotOccupantType({
|
await addLotOccupantType({
|
||||||
lotOccupantType: 'Deceased',
|
lotOccupantType: 'Deceased',
|
||||||
fontAwesomeIconClass: 'cross',
|
fontAwesomeIconClass: 'cross',
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}, session);
|
}, user);
|
||||||
await addLotOccupantType({
|
await addLotOccupantType({
|
||||||
lotOccupantType: 'Funeral Director',
|
lotOccupantType: 'Funeral Director',
|
||||||
fontAwesomeIconClass: 'church',
|
fontAwesomeIconClass: 'church',
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}, session);
|
}, user);
|
||||||
await addLotOccupantType({
|
await addLotOccupantType({
|
||||||
lotOccupantType: 'Preneed Owner',
|
lotOccupantType: 'Preneed Owner',
|
||||||
fontAwesomeIconClass: 'user',
|
fontAwesomeIconClass: 'user',
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}, session);
|
}, user);
|
||||||
await addLotOccupantType({
|
await addLotOccupantType({
|
||||||
lotOccupantType: 'Purchaser',
|
lotOccupantType: 'Purchaser',
|
||||||
fontAwesomeIconClass: 'hand-holding-usd',
|
fontAwesomeIconClass: 'hand-holding-usd',
|
||||||
occupantCommentTitle: 'Relationship to Owner/Deceased',
|
occupantCommentTitle: 'Relationship to Owner/Deceased',
|
||||||
orderNumber: 4
|
orderNumber: 4
|
||||||
}, session);
|
}, user);
|
||||||
await addRecord('OccupancyTypes', 'Preneed', 1, session);
|
await addRecord('OccupancyTypes', 'Preneed', 1, user);
|
||||||
const intermentOccupancyTypeId = await addRecord('OccupancyTypes', 'Interment', 2, session);
|
const intermentOccupancyTypeId = await addRecord('OccupancyTypes', 'Interment', 2, user);
|
||||||
const cremationOccupancyTypeId = await addRecord('OccupancyTypes', 'Cremation', 3, session);
|
const cremationOccupancyTypeId = await addRecord('OccupancyTypes', 'Cremation', 3, user);
|
||||||
const deathDateField = {
|
const deathDateField = {
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: 'Death Date',
|
occupancyTypeField: 'Death Date',
|
||||||
|
|
@ -67,10 +65,10 @@ export async function initializeCemeteryDatabase() {
|
||||||
maximumLength: 10,
|
maximumLength: 10,
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
};
|
};
|
||||||
await addOccupancyTypeField(deathDateField, session);
|
await addOccupancyTypeField(deathDateField, user);
|
||||||
await addOccupancyTypeField(Object.assign(deathDateField, {
|
await addOccupancyTypeField(Object.assign(deathDateField, {
|
||||||
occupancyTypeId: cremationOccupancyTypeId
|
occupancyTypeId: cremationOccupancyTypeId
|
||||||
}), session);
|
}), user);
|
||||||
const deathAgeField = {
|
const deathAgeField = {
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: 'Death Age',
|
occupancyTypeField: 'Death Age',
|
||||||
|
|
@ -81,8 +79,8 @@ export async function initializeCemeteryDatabase() {
|
||||||
maximumLength: 3,
|
maximumLength: 3,
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
};
|
};
|
||||||
await addOccupancyTypeField(deathAgeField, session);
|
await addOccupancyTypeField(deathAgeField, user);
|
||||||
await addOccupancyTypeField(Object.assign(deathAgeField, { occupancyTypeId: cremationOccupancyTypeId }), session);
|
await addOccupancyTypeField(Object.assign(deathAgeField, { occupancyTypeId: cremationOccupancyTypeId }), user);
|
||||||
const deathAgePeriod = {
|
const deathAgePeriod = {
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: 'Death Age Period',
|
occupancyTypeField: 'Death Age Period',
|
||||||
|
|
@ -93,10 +91,10 @@ export async function initializeCemeteryDatabase() {
|
||||||
maximumLength: 10,
|
maximumLength: 10,
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
};
|
};
|
||||||
await addOccupancyTypeField(deathAgePeriod, session);
|
await addOccupancyTypeField(deathAgePeriod, user);
|
||||||
await addOccupancyTypeField(Object.assign(deathAgePeriod, {
|
await addOccupancyTypeField(Object.assign(deathAgePeriod, {
|
||||||
occupancyTypeId: cremationOccupancyTypeId
|
occupancyTypeId: cremationOccupancyTypeId
|
||||||
}), session);
|
}), user);
|
||||||
const deathPlace = {
|
const deathPlace = {
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: 'Death Place',
|
occupancyTypeField: 'Death Place',
|
||||||
|
|
@ -107,8 +105,8 @@ export async function initializeCemeteryDatabase() {
|
||||||
maximumLength: 100,
|
maximumLength: 100,
|
||||||
orderNumber: 4
|
orderNumber: 4
|
||||||
};
|
};
|
||||||
await addOccupancyTypeField(deathPlace, session);
|
await addOccupancyTypeField(deathPlace, user);
|
||||||
await addOccupancyTypeField(Object.assign(deathPlace, { occupancyTypeId: cremationOccupancyTypeId }), session);
|
await addOccupancyTypeField(Object.assign(deathPlace, { occupancyTypeId: cremationOccupancyTypeId }), user);
|
||||||
const funeralHome = {
|
const funeralHome = {
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: 'Funeral Home',
|
occupancyTypeField: 'Funeral Home',
|
||||||
|
|
@ -119,8 +117,8 @@ export async function initializeCemeteryDatabase() {
|
||||||
maximumLength: 100,
|
maximumLength: 100,
|
||||||
orderNumber: 10
|
orderNumber: 10
|
||||||
};
|
};
|
||||||
await addOccupancyTypeField(funeralHome, session);
|
await addOccupancyTypeField(funeralHome, user);
|
||||||
await addOccupancyTypeField(Object.assign(funeralHome, { occupancyTypeId: cremationOccupancyTypeId }), session);
|
await addOccupancyTypeField(Object.assign(funeralHome, { occupancyTypeId: cremationOccupancyTypeId }), user);
|
||||||
const funeralDate = {
|
const funeralDate = {
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: 'Funeral Date',
|
occupancyTypeField: 'Funeral Date',
|
||||||
|
|
@ -131,8 +129,8 @@ export async function initializeCemeteryDatabase() {
|
||||||
maximumLength: 10,
|
maximumLength: 10,
|
||||||
orderNumber: 11
|
orderNumber: 11
|
||||||
};
|
};
|
||||||
await addOccupancyTypeField(funeralDate, session);
|
await addOccupancyTypeField(funeralDate, user);
|
||||||
await addOccupancyTypeField(Object.assign(funeralDate, { occupancyTypeId: cremationOccupancyTypeId }), session);
|
await addOccupancyTypeField(Object.assign(funeralDate, { occupancyTypeId: cremationOccupancyTypeId }), user);
|
||||||
const containerType = {
|
const containerType = {
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: 'Container Type',
|
occupancyTypeField: 'Container Type',
|
||||||
|
|
@ -143,8 +141,8 @@ export async function initializeCemeteryDatabase() {
|
||||||
maximumLength: 100,
|
maximumLength: 100,
|
||||||
orderNumber: 20
|
orderNumber: 20
|
||||||
};
|
};
|
||||||
await addOccupancyTypeField(containerType, session);
|
await addOccupancyTypeField(containerType, user);
|
||||||
await addOccupancyTypeField(Object.assign(containerType, { occupancyTypeId: cremationOccupancyTypeId }), session);
|
await addOccupancyTypeField(Object.assign(containerType, { occupancyTypeId: cremationOccupancyTypeId }), user);
|
||||||
const committalType = {
|
const committalType = {
|
||||||
occupancyTypeId: intermentOccupancyTypeId,
|
occupancyTypeId: intermentOccupancyTypeId,
|
||||||
occupancyTypeField: 'Committal Type',
|
occupancyTypeField: 'Committal Type',
|
||||||
|
|
@ -155,17 +153,17 @@ export async function initializeCemeteryDatabase() {
|
||||||
maximumLength: 100,
|
maximumLength: 100,
|
||||||
orderNumber: 21
|
orderNumber: 21
|
||||||
};
|
};
|
||||||
await addOccupancyTypeField(committalType, session);
|
await addOccupancyTypeField(committalType, user);
|
||||||
await addOccupancyTypeField(Object.assign(committalType, { occupancyTypeId: cremationOccupancyTypeId }), session);
|
await addOccupancyTypeField(Object.assign(committalType, { occupancyTypeId: cremationOccupancyTypeId }), user);
|
||||||
await addRecord('FeeCategories', 'Interment Rights', 1, session);
|
await addRecord('FeeCategories', 'Interment Rights', 1, user);
|
||||||
await addRecord('FeeCategories', 'Cremation Services', 2, session);
|
await addRecord('FeeCategories', 'Cremation Services', 2, user);
|
||||||
await addRecord('FeeCategories', 'Burial Charges', 3, session);
|
await addRecord('FeeCategories', 'Burial Charges', 3, user);
|
||||||
await addRecord('FeeCategories', 'Disinterment of Human Remains', 4, session);
|
await addRecord('FeeCategories', 'Disinterment of Human Remains', 4, user);
|
||||||
await addRecord('FeeCategories', 'Additional Services', 5, session);
|
await addRecord('FeeCategories', 'Additional Services', 5, user);
|
||||||
await addRecord('WorkOrderTypes', 'Cemetry Work Order', 1, session);
|
await addRecord('WorkOrderTypes', 'Cemetery Work Order', 1, user);
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, session);
|
await addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, user);
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, session);
|
await addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, user);
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, session);
|
await addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, user);
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Interment', 4, session);
|
await addRecord('WorkOrderMilestoneTypes', 'Interment', 4, user);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,21 @@
|
||||||
|
import Debug from 'debug'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from '../data/databasePaths.js'
|
import { lotOccupancyDB as databasePath } from '../data/databasePaths.js'
|
||||||
|
|
||||||
import { initializeDatabase } from './initializer.database.js'
|
import { initializeDatabase } from './initializer.database.js'
|
||||||
|
|
||||||
import { addOccupancyTypeField } from './lotOccupancyDB/addOccupancyTypeField.js'
|
|
||||||
|
|
||||||
import { addLotOccupantType } from './lotOccupancyDB/addLotOccupantType.js'
|
import { addLotOccupantType } from './lotOccupancyDB/addLotOccupantType.js'
|
||||||
|
import { addOccupancyTypeField } from './lotOccupancyDB/addOccupancyTypeField.js'
|
||||||
import { addRecord } from './lotOccupancyDB/addRecord.js'
|
import { addRecord } from './lotOccupancyDB/addRecord.js'
|
||||||
|
|
||||||
import type { PartialSession } from '../types/recordTypes.js'
|
|
||||||
|
|
||||||
import Debug from 'debug'
|
|
||||||
const debug = Debug('lot-occupancy-system:initialize')
|
const debug = Debug('lot-occupancy-system:initialize')
|
||||||
|
|
||||||
const session: PartialSession = {
|
const user: User = {
|
||||||
user: {
|
|
||||||
userName: 'init.cemetery',
|
userName: 'init.cemetery',
|
||||||
userProperties: {
|
userProperties: {
|
||||||
canUpdate: true,
|
canUpdate: true,
|
||||||
isAdmin: true,
|
isAdmin: true,
|
||||||
apiKey: ''
|
apiKey: ''
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function initializeCemeteryDatabase(): Promise<boolean> {
|
export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
|
|
@ -46,20 +40,20 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
* Lot Types
|
* Lot Types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
await addRecord('LotTypes', 'Casket Grave', 1, session)
|
await addRecord('LotTypes', 'Casket Grave', 1, user)
|
||||||
await addRecord('LotTypes', 'Columbarium', 2, session)
|
await addRecord('LotTypes', 'Columbarium', 2, user)
|
||||||
await addRecord('LotTypes', 'Mausoleum', 2, session)
|
await addRecord('LotTypes', 'Mausoleum', 2, user)
|
||||||
await addRecord('LotTypes', 'Niche Wall', 2, session)
|
await addRecord('LotTypes', 'Niche Wall', 2, user)
|
||||||
await addRecord('LotTypes', 'Urn Garden', 2, session)
|
await addRecord('LotTypes', 'Urn Garden', 2, user)
|
||||||
await addRecord('LotTypes', 'Crematorium', 2, session)
|
await addRecord('LotTypes', 'Crematorium', 2, user)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lot Statuses
|
* Lot Statuses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
await addRecord('LotStatuses', 'Available', 1, session)
|
await addRecord('LotStatuses', 'Available', 1, user)
|
||||||
await addRecord('LotStatuses', 'Reserved', 2, session)
|
await addRecord('LotStatuses', 'Reserved', 2, user)
|
||||||
await addRecord('LotStatuses', 'Taken', 3, session)
|
await addRecord('LotStatuses', 'Taken', 3, user)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lot Occupant Types
|
* Lot Occupant Types
|
||||||
|
|
@ -71,7 +65,7 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
fontAwesomeIconClass: 'cross',
|
fontAwesomeIconClass: 'cross',
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
},
|
},
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
await addLotOccupantType(
|
await addLotOccupantType(
|
||||||
|
|
@ -80,7 +74,7 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
fontAwesomeIconClass: 'church',
|
fontAwesomeIconClass: 'church',
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
},
|
},
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
await addLotOccupantType(
|
await addLotOccupantType(
|
||||||
|
|
@ -89,7 +83,7 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
fontAwesomeIconClass: 'user',
|
fontAwesomeIconClass: 'user',
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
},
|
},
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
await addLotOccupantType(
|
await addLotOccupantType(
|
||||||
|
|
@ -99,25 +93,25 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
occupantCommentTitle: 'Relationship to Owner/Deceased',
|
occupantCommentTitle: 'Relationship to Owner/Deceased',
|
||||||
orderNumber: 4
|
orderNumber: 4
|
||||||
},
|
},
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Occupancy Types
|
* Occupancy Types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
await addRecord('OccupancyTypes', 'Preneed', 1, session)
|
await addRecord('OccupancyTypes', 'Preneed', 1, user)
|
||||||
const intermentOccupancyTypeId = await addRecord(
|
const intermentOccupancyTypeId = await addRecord(
|
||||||
'OccupancyTypes',
|
'OccupancyTypes',
|
||||||
'Interment',
|
'Interment',
|
||||||
2,
|
2,
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
const cremationOccupancyTypeId = await addRecord(
|
const cremationOccupancyTypeId = await addRecord(
|
||||||
'OccupancyTypes',
|
'OccupancyTypes',
|
||||||
'Cremation',
|
'Cremation',
|
||||||
3,
|
3,
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
// Death Date
|
// Death Date
|
||||||
|
|
@ -132,13 +126,13 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
orderNumber: 1
|
orderNumber: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
await addOccupancyTypeField(deathDateField, session)
|
await addOccupancyTypeField(deathDateField, user)
|
||||||
|
|
||||||
await addOccupancyTypeField(
|
await addOccupancyTypeField(
|
||||||
Object.assign(deathDateField, {
|
Object.assign(deathDateField, {
|
||||||
occupancyTypeId: cremationOccupancyTypeId
|
occupancyTypeId: cremationOccupancyTypeId
|
||||||
}),
|
}),
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
// Death Age
|
// Death Age
|
||||||
|
|
@ -153,11 +147,11 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
orderNumber: 2
|
orderNumber: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
await addOccupancyTypeField(deathAgeField, session)
|
await addOccupancyTypeField(deathAgeField, user)
|
||||||
|
|
||||||
await addOccupancyTypeField(
|
await addOccupancyTypeField(
|
||||||
Object.assign(deathAgeField, { occupancyTypeId: cremationOccupancyTypeId }),
|
Object.assign(deathAgeField, { occupancyTypeId: cremationOccupancyTypeId }),
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
// Death Age Period
|
// Death Age Period
|
||||||
|
|
@ -172,13 +166,13 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
orderNumber: 3
|
orderNumber: 3
|
||||||
}
|
}
|
||||||
|
|
||||||
await addOccupancyTypeField(deathAgePeriod, session)
|
await addOccupancyTypeField(deathAgePeriod, user)
|
||||||
|
|
||||||
await addOccupancyTypeField(
|
await addOccupancyTypeField(
|
||||||
Object.assign(deathAgePeriod, {
|
Object.assign(deathAgePeriod, {
|
||||||
occupancyTypeId: cremationOccupancyTypeId
|
occupancyTypeId: cremationOccupancyTypeId
|
||||||
}),
|
}),
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
// Death Place
|
// Death Place
|
||||||
|
|
@ -193,11 +187,11 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
orderNumber: 4
|
orderNumber: 4
|
||||||
}
|
}
|
||||||
|
|
||||||
await addOccupancyTypeField(deathPlace, session)
|
await addOccupancyTypeField(deathPlace, user)
|
||||||
|
|
||||||
await addOccupancyTypeField(
|
await addOccupancyTypeField(
|
||||||
Object.assign(deathPlace, { occupancyTypeId: cremationOccupancyTypeId }),
|
Object.assign(deathPlace, { occupancyTypeId: cremationOccupancyTypeId }),
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
// Funeral Home
|
// Funeral Home
|
||||||
|
|
@ -212,11 +206,11 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
orderNumber: 10
|
orderNumber: 10
|
||||||
}
|
}
|
||||||
|
|
||||||
await addOccupancyTypeField(funeralHome, session)
|
await addOccupancyTypeField(funeralHome, user)
|
||||||
|
|
||||||
await addOccupancyTypeField(
|
await addOccupancyTypeField(
|
||||||
Object.assign(funeralHome, { occupancyTypeId: cremationOccupancyTypeId }),
|
Object.assign(funeralHome, { occupancyTypeId: cremationOccupancyTypeId }),
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
// Funeral Date
|
// Funeral Date
|
||||||
|
|
@ -231,11 +225,11 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
orderNumber: 11
|
orderNumber: 11
|
||||||
}
|
}
|
||||||
|
|
||||||
await addOccupancyTypeField(funeralDate, session)
|
await addOccupancyTypeField(funeralDate, user)
|
||||||
|
|
||||||
await addOccupancyTypeField(
|
await addOccupancyTypeField(
|
||||||
Object.assign(funeralDate, { occupancyTypeId: cremationOccupancyTypeId }),
|
Object.assign(funeralDate, { occupancyTypeId: cremationOccupancyTypeId }),
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
// Container Type
|
// Container Type
|
||||||
|
|
@ -250,11 +244,11 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
orderNumber: 20
|
orderNumber: 20
|
||||||
}
|
}
|
||||||
|
|
||||||
await addOccupancyTypeField(containerType, session)
|
await addOccupancyTypeField(containerType, user)
|
||||||
|
|
||||||
await addOccupancyTypeField(
|
await addOccupancyTypeField(
|
||||||
Object.assign(containerType, { occupancyTypeId: cremationOccupancyTypeId }),
|
Object.assign(containerType, { occupancyTypeId: cremationOccupancyTypeId }),
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
// Committal Type
|
// Committal Type
|
||||||
|
|
@ -269,33 +263,33 @@ export async function initializeCemeteryDatabase(): Promise<boolean> {
|
||||||
orderNumber: 21
|
orderNumber: 21
|
||||||
}
|
}
|
||||||
|
|
||||||
await addOccupancyTypeField(committalType, session)
|
await addOccupancyTypeField(committalType, user)
|
||||||
|
|
||||||
await addOccupancyTypeField(
|
await addOccupancyTypeField(
|
||||||
Object.assign(committalType, { occupancyTypeId: cremationOccupancyTypeId }),
|
Object.assign(committalType, { occupancyTypeId: cremationOccupancyTypeId }),
|
||||||
session
|
user
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fee Categories
|
* Fee Categories
|
||||||
*/
|
*/
|
||||||
|
|
||||||
await addRecord('FeeCategories', 'Interment Rights', 1, session)
|
await addRecord('FeeCategories', 'Interment Rights', 1, user)
|
||||||
await addRecord('FeeCategories', 'Cremation Services', 2, session)
|
await addRecord('FeeCategories', 'Cremation Services', 2, user)
|
||||||
await addRecord('FeeCategories', 'Burial Charges', 3, session)
|
await addRecord('FeeCategories', 'Burial Charges', 3, user)
|
||||||
await addRecord('FeeCategories', 'Disinterment of Human Remains', 4, session)
|
await addRecord('FeeCategories', 'Disinterment of Human Remains', 4, user)
|
||||||
await addRecord('FeeCategories', 'Additional Services', 5, session)
|
await addRecord('FeeCategories', 'Additional Services', 5, user)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Work Orders
|
* Work Orders
|
||||||
*/
|
*/
|
||||||
|
|
||||||
await addRecord('WorkOrderTypes', 'Cemetry Work Order', 1, session)
|
await addRecord('WorkOrderTypes', 'Cemetery Work Order', 1, user)
|
||||||
|
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, session)
|
await addRecord('WorkOrderMilestoneTypes', 'Funeral', 1, user)
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, session)
|
await addRecord('WorkOrderMilestoneTypes', 'Arrival', 2, user)
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, session)
|
await addRecord('WorkOrderMilestoneTypes', 'Cremation', 3, user)
|
||||||
await addRecord('WorkOrderMilestoneTypes', 'Interment', 4, session)
|
await addRecord('WorkOrderMilestoneTypes', 'Interment', 4, user)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import sqlite from 'better-sqlite3';
|
import sqlite from 'better-sqlite3';
|
||||||
import { lotOccupancyDB as databasePath } from '../data/databasePaths.js';
|
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
import { lotOccupancyDB as databasePath } from '../data/databasePaths.js';
|
||||||
const debugSQL = debug('lot-occupancy-system:databaseInitializer');
|
const debugSQL = debug('lot-occupancy-system:databaseInitializer');
|
||||||
const recordColumns = `recordCreate_userName varchar(30) not null,
|
const recordColumns = `recordCreate_userName varchar(30) not null,
|
||||||
recordCreate_timeMillis integer not null,
|
recordCreate_timeMillis integer not null,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import sqlite from 'better-sqlite3'
|
import sqlite from 'better-sqlite3'
|
||||||
|
import debug from 'debug'
|
||||||
|
|
||||||
import { lotOccupancyDB as databasePath } from '../data/databasePaths.js'
|
import { lotOccupancyDB as databasePath } from '../data/databasePaths.js'
|
||||||
|
|
||||||
import debug from 'debug'
|
|
||||||
const debugSQL = debug('lot-occupancy-system:databaseInitializer')
|
const debugSQL = debug('lot-occupancy-system:databaseInitializer')
|
||||||
|
|
||||||
const recordColumns = `recordCreate_userName varchar(30) not null,
|
const recordColumns = `recordCreate_userName varchar(30) not null,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue