Add data model and structure for swift graph executor, rework create products to bem ore general
This commit is contained in:
@@ -12,6 +12,14 @@
|
||||
5A1986FB2996502C00FA0471 /* FileButtonSelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A1986FA2996502C00FA0471 /* FileButtonSelector.swift */; };
|
||||
5A450751298CE6D500E3D402 /* CsvDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A450750298CE6D500E3D402 /* CsvDocument.swift */; };
|
||||
5A45075B298D01EF00E3D402 /* libcoster_rs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A45075A298D01EF00E3D402 /* libcoster_rs.a */; };
|
||||
5A53D5742BE4B4FB00563893 /* FileNodeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A53D5732BE4B4FB00563893 /* FileNodeView.swift */; };
|
||||
5A53D5772BE4B98300563893 /* SwiftCSV in Frameworks */ = {isa = PBXBuildFile; productRef = 5A53D5762BE4B98300563893 /* SwiftCSV */; };
|
||||
5A53D5792BE4C0C300563893 /* CsvEditor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A53D5782BE4C0C300563893 /* CsvEditor.swift */; };
|
||||
5A53D57B2BE4C1D400563893 /* OutputFilesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A53D57A2BE4C1D400563893 /* OutputFilesView.swift */; };
|
||||
5A53D5822BE507AD00563893 /* ChartEditor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A53D5812BE507AD00563893 /* ChartEditor.swift */; };
|
||||
5A53D5842BE507FF00563893 /* ChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A53D5832BE507FF00563893 /* ChartView.swift */; };
|
||||
5A53D5892BE5182C00563893 /* Tasks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A53D5882BE5182C00563893 /* Tasks.swift */; };
|
||||
5A53D58B2BE518CA00563893 /* Graph.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A53D58A2BE518CA00563893 /* Graph.swift */; };
|
||||
5ADD9F2D298A713300F998F5 /* FastCosterApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ADD9F2C298A713300F998F5 /* FastCosterApp.swift */; };
|
||||
5ADD9F2F298A713300F998F5 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ADD9F2E298A713300F998F5 /* ContentView.swift */; };
|
||||
5ADD9F31298A713400F998F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5ADD9F30298A713400F998F5 /* Assets.xcassets */; };
|
||||
@@ -48,6 +56,13 @@
|
||||
5A450755298CFFE400E3D402 /* create-lib.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "create-lib.sh"; sourceTree = "<group>"; };
|
||||
5A450756298D00AE00E3D402 /* remove-lib.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "remove-lib.sh"; sourceTree = "<group>"; };
|
||||
5A45075A298D01EF00E3D402 /* libcoster_rs.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcoster_rs.a; path = "../costerrs/target/aarch64-apple-ios/release/libcoster_rs.a"; sourceTree = "<group>"; };
|
||||
5A53D5732BE4B4FB00563893 /* FileNodeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileNodeView.swift; sourceTree = "<group>"; };
|
||||
5A53D5782BE4C0C300563893 /* CsvEditor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CsvEditor.swift; sourceTree = "<group>"; };
|
||||
5A53D57A2BE4C1D400563893 /* OutputFilesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OutputFilesView.swift; sourceTree = "<group>"; };
|
||||
5A53D5812BE507AD00563893 /* ChartEditor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartEditor.swift; sourceTree = "<group>"; };
|
||||
5A53D5832BE507FF00563893 /* ChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartView.swift; sourceTree = "<group>"; };
|
||||
5A53D5882BE5182C00563893 /* Tasks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tasks.swift; sourceTree = "<group>"; };
|
||||
5A53D58A2BE518CA00563893 /* Graph.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Graph.swift; sourceTree = "<group>"; };
|
||||
5ADD9F29298A713300F998F5 /* FastCoster.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FastCoster.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5ADD9F2C298A713300F998F5 /* FastCosterApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FastCosterApp.swift; sourceTree = "<group>"; };
|
||||
5ADD9F2E298A713300F998F5 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
@@ -67,6 +82,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5A45075B298D01EF00E3D402 /* libcoster_rs.a in Frameworks */,
|
||||
5A53D5772BE4B98300563893 /* SwiftCSV in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -106,6 +122,24 @@
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
5A53D5802BE4C26A00563893 /* Charts */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5A53D5812BE507AD00563893 /* ChartEditor.swift */,
|
||||
5A53D5832BE507FF00563893 /* ChartView.swift */,
|
||||
);
|
||||
path = Charts;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
5A53D5852BE50C7B00563893 /* Model */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5A53D5882BE5182C00563893 /* Tasks.swift */,
|
||||
5A53D58A2BE518CA00563893 /* Graph.swift */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
5ADD9F20298A713300F998F5 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -131,6 +165,8 @@
|
||||
5ADD9F2B298A713300F998F5 /* FastCoster */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5A53D5852BE50C7B00563893 /* Model */,
|
||||
5A53D5802BE4C26A00563893 /* Charts */,
|
||||
5ADD9F2C298A713300F998F5 /* FastCosterApp.swift */,
|
||||
5ADD9F2E298A713300F998F5 /* ContentView.swift */,
|
||||
5ADD9F30298A713400F998F5 /* Assets.xcassets */,
|
||||
@@ -140,6 +176,9 @@
|
||||
5A1986F62996436500FA0471 /* OverheadAllocation.swift */,
|
||||
5A1986F82996436D00FA0471 /* MoveMoney.swift */,
|
||||
5A1986FA2996502C00FA0471 /* FileButtonSelector.swift */,
|
||||
5A53D5732BE4B4FB00563893 /* FileNodeView.swift */,
|
||||
5A53D5782BE4C0C300563893 /* CsvEditor.swift */,
|
||||
5A53D57A2BE4C1D400563893 /* OutputFilesView.swift */,
|
||||
);
|
||||
path = FastCoster;
|
||||
sourceTree = "<group>";
|
||||
@@ -187,6 +226,9 @@
|
||||
dependencies = (
|
||||
);
|
||||
name = FastCoster;
|
||||
packageProductDependencies = (
|
||||
5A53D5762BE4B98300563893 /* SwiftCSV */,
|
||||
);
|
||||
productName = FastCoster;
|
||||
productReference = 5ADD9F29298A713300F998F5 /* FastCoster.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
@@ -259,6 +301,9 @@
|
||||
Base,
|
||||
);
|
||||
mainGroup = 5ADD9F20298A713300F998F5;
|
||||
packageReferences = (
|
||||
5A53D5752BE4B98300563893 /* XCRemoteSwiftPackageReference "SwiftCSV" */,
|
||||
);
|
||||
productRefGroup = 5ADD9F2A298A713300F998F5 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
@@ -344,11 +389,18 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5A1986FB2996502C00FA0471 /* FileButtonSelector.swift in Sources */,
|
||||
5A53D58B2BE518CA00563893 /* Graph.swift in Sources */,
|
||||
5ADD9F2F298A713300F998F5 /* ContentView.swift in Sources */,
|
||||
5A1986F92996436D00FA0471 /* MoveMoney.swift in Sources */,
|
||||
5A53D57B2BE4C1D400563893 /* OutputFilesView.swift in Sources */,
|
||||
5ADD9F2D298A713300F998F5 /* FastCosterApp.swift in Sources */,
|
||||
5A450751298CE6D500E3D402 /* CsvDocument.swift in Sources */,
|
||||
5A53D5822BE507AD00563893 /* ChartEditor.swift in Sources */,
|
||||
5A53D5842BE507FF00563893 /* ChartView.swift in Sources */,
|
||||
5A53D5792BE4C0C300563893 /* CsvEditor.swift in Sources */,
|
||||
5A53D5892BE5182C00563893 /* Tasks.swift in Sources */,
|
||||
5A1986F72996436500FA0471 /* OverheadAllocation.swift in Sources */,
|
||||
5A53D5742BE4B4FB00563893 /* FileNodeView.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -524,7 +576,7 @@
|
||||
"LIBRARY_SEARCH_PATHS[arch=*]" = "${DERIVED_FILES_DIR}";
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.1;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.Vato.FastCoster;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.michaelpivato.FastCoster;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = auto;
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
|
||||
@@ -564,7 +616,7 @@
|
||||
"LIBRARY_SEARCH_PATHS[arch=*]" = "${DERIVED_FILES_DIR}";
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.1;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.Vato.FastCoster;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.michaelpivato.FastCoster;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = auto;
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
|
||||
@@ -705,6 +757,25 @@
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCRemoteSwiftPackageReference section */
|
||||
5A53D5752BE4B98300563893 /* XCRemoteSwiftPackageReference "SwiftCSV" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/swiftcsv/SwiftCSV.git";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 0.9.1;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
5A53D5762BE4B98300563893 /* SwiftCSV */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 5A53D5752BE4B98300563893 /* XCRemoteSwiftPackageReference "SwiftCSV" */;
|
||||
productName = SwiftCSV;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = 5ADD9F21298A713300F998F5 /* Project object */;
|
||||
}
|
||||
|
||||
18
FastCoster/FastCoster/Charts/ChartEditor.swift
Normal file
18
FastCoster/FastCoster/Charts/ChartEditor.swift
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// ChartEditor.swift
|
||||
// FastCoster
|
||||
//
|
||||
// Created by Michael Pivato on 3/5/2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ChartEditor: View {
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ChartEditor()
|
||||
}
|
||||
19
FastCoster/FastCoster/Charts/ChartView.swift
Normal file
19
FastCoster/FastCoster/Charts/ChartView.swift
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// ChartView.swift
|
||||
// FastCoster
|
||||
//
|
||||
// Created by Michael Pivato on 3/5/2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ChartView: View {
|
||||
// View the chart for the given file and configuration: https://developer.apple.com/documentation/Charts
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ChartView()
|
||||
}
|
||||
@@ -11,6 +11,7 @@ enum ProcessType: String, Hashable {
|
||||
case MoveMoney = "Move Money"
|
||||
case OverheadAllocation = "Overhead Allocation"
|
||||
|
||||
// TODO: This needs to be the list of graphs
|
||||
static let values = [MoveMoney, OverheadAllocation]
|
||||
}
|
||||
|
||||
@@ -37,6 +38,7 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: Button to add a new graph
|
||||
|
||||
}
|
||||
|
||||
|
||||
20
FastCoster/FastCoster/CsvEditor.swift
Normal file
20
FastCoster/FastCoster/CsvEditor.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// CsvEditor.swift
|
||||
// FastCoster
|
||||
//
|
||||
// Created by Michael Pivato on 3/5/2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct CsvEditor: View {
|
||||
// A table to view data in a file: https://developer.apple.com/documentation/SwiftUI/Table
|
||||
// It's fine to load it all into memory to begin with, we'll probably want to change that later though.
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
CsvEditor()
|
||||
}
|
||||
33
FastCoster/FastCoster/FileNodeView.swift
Normal file
33
FastCoster/FastCoster/FileNodeView.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// FileNode.swift
|
||||
// FastCoster
|
||||
//
|
||||
// Created by Michael Pivato on 3/5/2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct FileNodeView: View {
|
||||
@State private var showPicker = false
|
||||
@State private var selectedFileUrl: URL?
|
||||
var body: some View {
|
||||
// Should basically show a file selector.
|
||||
Button {
|
||||
showPicker.toggle()
|
||||
} label: {
|
||||
Text("Select File")
|
||||
}.fileImporter(isPresented: $showPicker, allowedContentTypes: [.commaSeparatedText]) { result in
|
||||
|
||||
switch result {
|
||||
case .success(let fileUrl):
|
||||
selectedFileUrl = fileUrl
|
||||
case .failure(let error):
|
||||
print(error)
|
||||
}
|
||||
}.padding()
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
FileNodeView()
|
||||
}
|
||||
23
FastCoster/FastCoster/Model/Graph.swift
Normal file
23
FastCoster/FastCoster/Model/Graph.swift
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Graph.swift
|
||||
// FastCoster
|
||||
//
|
||||
// Created by Michael Pivato on 3/5/2024.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
// JSON for saving/loading configuration: https://www.avanderlee.com/swift/json-parsing-decoding/
|
||||
struct Node: Codable {
|
||||
var id: Int
|
||||
var info: NodeInfo
|
||||
var dependentNodeIds: [Int]
|
||||
|
||||
func hasDependentNodes() -> Bool {
|
||||
return !dependentNodeIds.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
struct Graph: Codable {
|
||||
var name: String
|
||||
var nodes: [Node]
|
||||
}
|
||||
118
FastCoster/FastCoster/Model/Tasks.swift
Normal file
118
FastCoster/FastCoster/Model/Tasks.swift
Normal file
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// InputFile.swift
|
||||
// FastCoster
|
||||
//
|
||||
// Created by Michael Pivato on 3/5/2024.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct NodeInfo: Codable {
|
||||
var name: String;
|
||||
var outputFiles: [String]
|
||||
var configuration: NodeConfiguration
|
||||
}
|
||||
|
||||
// Need to check if enums with data actually works with json serialisation/deserialisation, otherwise
|
||||
// can look into binary serialisation/deserialisation instead
|
||||
enum NodeConfiguration: Codable {
|
||||
case FileNode
|
||||
case MoveMoneyNode(MoveMoneyNode)
|
||||
case MergeNode(MergeNode)
|
||||
case DeriveNode(DeriveNode)
|
||||
}
|
||||
|
||||
enum MoveMoneyAmoutType: String, Codable {
|
||||
case Percent, Amount
|
||||
}
|
||||
|
||||
struct MoveMoneyRule: Codable {
|
||||
let fromAccout: String
|
||||
let fromCC: String
|
||||
let toAccount: String
|
||||
let toCC: String
|
||||
let value: Double
|
||||
let type: MoveMoneyAmoutType
|
||||
}
|
||||
|
||||
struct MoveMoneyNode: Codable {
|
||||
var departmentsPath: String
|
||||
var accountsPath: String
|
||||
var glPath: String
|
||||
var rules: [MoveMoneyRule]
|
||||
}
|
||||
|
||||
enum JoinType: Codable {
|
||||
case Left, Inner, Right
|
||||
}
|
||||
|
||||
struct MergeJoin: Codable {
|
||||
var type: JoinType
|
||||
var leftColumnName: String
|
||||
var rightColumnName: String
|
||||
}
|
||||
|
||||
struct MergeNode: Codable {
|
||||
var inputFiles: [String]
|
||||
var joins: [MergeJoin]
|
||||
}
|
||||
|
||||
enum DeriveColumnType: Codable {
|
||||
case Column(String)
|
||||
case Constant(String)
|
||||
}
|
||||
|
||||
struct MapOperation: Codable {
|
||||
var mappedValue: String
|
||||
}
|
||||
|
||||
enum DatePart: Codable {
|
||||
case Year, Month, Week, Day, Hour, Minute, Secod
|
||||
}
|
||||
|
||||
enum SplitType: Codable {
|
||||
case DateTime(String, DatePart)
|
||||
case Numeric(String, Int)
|
||||
}
|
||||
|
||||
enum MatchComparisonType: Codable {
|
||||
case Equal, GreaterThan, LessThan
|
||||
}
|
||||
|
||||
enum DeriveOperation: Codable {
|
||||
case Concat([DeriveColumnType])
|
||||
case Add([DeriveColumnType])
|
||||
case Multiply([DeriveColumnType])
|
||||
case Subtract(DeriveColumnType, DeriveColumnType)
|
||||
case Divide(DeriveColumnType, DeriveColumnType)
|
||||
case Map(String, [MapOperation])
|
||||
case Split(String, SplitType)
|
||||
}
|
||||
|
||||
struct DeriveFilter: Codable {
|
||||
var columnName: String
|
||||
var comparator: MatchComparisonType
|
||||
var matchValue: String
|
||||
}
|
||||
|
||||
struct DeriveRule: Codable {
|
||||
// Should this actually be an array though? It think it's fine?
|
||||
var operations: [DeriveOperation]
|
||||
// Filter to only specific values if required, if empty every value is considered a match
|
||||
var filters: [DeriveFilter]
|
||||
}
|
||||
|
||||
struct DeriveNode: Codable {
|
||||
var rules: [DeriveRule]
|
||||
}
|
||||
|
||||
|
||||
// Example json serialisation
|
||||
func tryJson() {
|
||||
do {
|
||||
let json = try JSONEncoder().encode(NodeInfo(name: "", outputFiles: [], configuration: NodeConfiguration.FileNode))
|
||||
let decoded = try JSONDecoder().decode(NodeInfo.self, from: json)
|
||||
}catch {
|
||||
|
||||
}
|
||||
}
|
||||
19
FastCoster/FastCoster/OutputFilesView.swift
Normal file
19
FastCoster/FastCoster/OutputFilesView.swift
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// OutputFilesView.swift
|
||||
// FastCoster
|
||||
//
|
||||
// Created by Michael Pivato on 3/5/2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct OutputFilesView: View {
|
||||
// List of files, with links to open a file editor to edit the linked files
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
OutputFilesView()
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
import SwiftUI
|
||||
|
||||
struct OverheadAllocation: View {
|
||||
// TODO: Refactor to take inputs from another task instead
|
||||
@State private var lines: String?
|
||||
@State private var accounts: String?
|
||||
@State private var areas: String?
|
||||
|
||||
Reference in New Issue
Block a user