Initial commit
All checks were successful
Docker Build and Publish / build-and-push (push) Successful in 2m17s

This commit is contained in:
2026-01-11 18:55:03 -05:00
commit 493ea4688c
45 changed files with 7107 additions and 0 deletions

1110
backend/CHANGELOG.md Normal file

File diff suppressed because it is too large Load Diff

17
backend/LICENSE.md Normal file
View File

@@ -0,0 +1,17 @@
The MIT License (MIT)
Copyright (c) 2022 - present, Gani Georgiev
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

14
backend/download_pb.ps1 Normal file
View File

@@ -0,0 +1,14 @@
$pbVersion = "0.22.21"
$zipUrl = "https://github.com/pocketbase/pocketbase/releases/download/v${pbVersion}/pocketbase_${pbVersion}_windows_amd64.zip"
$outputZip = "pocketbase.zip"
Write-Host "Downloading PocketBase v${pbVersion}..."
Invoke-WebRequest -Uri $zipUrl -OutFile $outputZip
Write-Host "Extracting..."
Expand-Archive -Path $outputZip -DestinationPath . -Force
Write-Host "Cleaning up..."
Remove-Item $outputZip
Write-Host "PocketBase setup complete."

View File

@@ -0,0 +1,111 @@
migrate((db) => {
const dao = new Dao(db);
const collection = new Collection({
name: "time_entries",
type: "base",
schema: [
{
name: "user",
type: "relation",
required: true,
options: {
collectionId: "_pb_users_auth_",
cascadeDelete: true,
maxSelect: 1,
displayFields: []
}
},
{
name: "date",
type: "date",
required: true,
options: {
min: "",
max: ""
}
},
{
name: "start_time",
type: "date",
required: false,
options: {
min: "",
max: ""
}
},
{
name: "end_time",
type: "date",
required: false,
options: {
min: "",
max: ""
}
},
{
name: "duration",
type: "number",
required: true,
options: {
min: 0,
max: null,
noDecimal: false
}
},
{
name: "type",
type: "select",
required: true,
options: {
maxSelect: 1,
values: ["regular", "overtime", "standby", "callback"]
}
},
{
name: "day_type",
type: "select",
required: true,
options: {
maxSelect: 1,
values: ["workday", "rest_day_1", "rest_day_2", "holiday"]
}
},
{
name: "multiplier",
type: "number",
required: true,
options: {
min: 0,
max: null,
noDecimal: false
}
},
{
name: "notes",
type: "text",
required: false,
options: {
min: null,
max: null,
pattern: ""
}
}
],
listRule: "@request.auth.id = user.id",
viewRule: "@request.auth.id = user.id",
createRule: "@request.auth.id = user.id",
updateRule: "@request.auth.id = user.id",
deleteRule: "@request.auth.id = user.id",
});
return dao.saveCollection(collection);
}, (db) => {
const dao = new Dao(db);
try {
const collection = dao.findCollectionByNameOrId("time_entries");
return dao.deleteCollection(collection);
} catch (_) {
return null;
}
})

View File

@@ -0,0 +1,45 @@
migrate((db) => {
const dao = new Dao(db);
const collection = dao.findCollectionByNameOrId("time_entries");
// Add is_banked field
collection.schema.addField(new SchemaField({
name: "is_banked",
type: "bool",
required: false, // Default true handled in app logic or ignored for now
options: {}
}));
// Add manual_override field
collection.schema.addField(new SchemaField({
name: "manual_override",
type: "bool",
required: false,
options: {}
}));
// Add calculated_hours field
collection.schema.addField(new SchemaField({
name: "calculated_hours",
type: "number",
required: false,
options: {
min: null,
max: null,
noDecimal: false
}
}));
return dao.saveCollection(collection);
}, (db) => {
const dao = new Dao(db);
const collection = dao.findCollectionByNameOrId("time_entries");
// logic to remove fields if needed, usually tricky in PB migrations securely without losing data
// For now we just return null or attempt simple removal
collection.schema.removeField("is_banked");
collection.schema.removeField("manual_override");
collection.schema.removeField("calculated_hours");
return dao.saveCollection(collection);
})

View File

@@ -0,0 +1,53 @@
migrate((db) => {
const dao = new Dao(db);
// 1. Update 'users' collection
const usersCollection = dao.findCollectionByNameOrId("users");
usersCollection.schema.addField(new SchemaField({
name: "is_supervisor",
type: "bool",
required: false,
options: {}
}));
usersCollection.schema.addField(new SchemaField({
name: "supervisor",
type: "relation",
required: false,
options: {
collectionId: usersCollection.id,
cascadeDelete: false,
maxSelect: 1,
displayFields: ["name", "email"]
}
}));
dao.saveCollection(usersCollection);
// 2. Update 'time_entries' collection rules
const timeEntries = dao.findCollectionByNameOrId("time_entries");
// Allow if owner OR if user's supervisor is requestor
const rule = "@request.auth.id = user.id || user.supervisor.id = @request.auth.id";
timeEntries.listRule = rule;
timeEntries.viewRule = rule;
// create/update/delete usually restricted to owner, supervisors maybe read-only for now?
// Plan said "view", so list/view is enough.
dao.saveCollection(timeEntries);
}, (db) => {
// Revert logic (simplified)
const dao = new Dao(db);
const usersCollection = dao.findCollectionByNameOrId("users");
usersCollection.schema.removeField("is_supervisor");
usersCollection.schema.removeField("supervisor");
dao.saveCollection(usersCollection);
const timeEntries = dao.findCollectionByNameOrId("time_entries");
timeEntries.listRule = "@request.auth.id = user.id";
timeEntries.viewRule = "@request.auth.id = user.id";
dao.saveCollection(timeEntries);
})

BIN
backend/pocketbase.exe Normal file

Binary file not shown.