Commit aa94bd4f authored by Ruben Seggers's avatar Ruben Seggers
Browse files

Update schema export iOS app for rollback realm version

parent d1d603b2
Showing with 28 additions and 118 deletions
+28 -118
# Output files
*schema.swift
*schema_target.swift
*schema_target2.swift
*schema.ts
*schema_target.ts
*autogenerated_database_schema.json
......
{
"description": "TBD",
"type": "Session"
}
\ No newline at end of file
{
"description": "TBD",
"type": "Session"
}
\ No newline at end of file
{
"description": "Item describing syncing information about this Item, like loading state, versioning, etc.",
"type": "SyncState"
}
\ No newline at end of file
{
"description": "TBD",
"type": "SessionView"
}
\ No newline at end of file
{
"description": "TBD",
"properties": [
"isPartiallyLoaded",
"actionNeeded",
"updatedFields",
"changedInThisSession"
],
"properties": [],
"relations": {},
"foregroundColor": "#ffffff",
"backgroundColor": "#93c47d"
......
......@@ -11,12 +11,7 @@
"version",
"edgeLabel"
],
"relations": {
"syncState": {
"sequenced": false,
"singular": true
}
},
"relations": {},
"foregroundColor": "#ffffff",
"backgroundColor": "#93c47d"
}
\ No newline at end of file
......@@ -24,10 +24,6 @@
"label": {
"sequenced": false,
"singular": false
},
"syncState": {
"sequenced": false,
"singular": true
}
},
"foregroundColor": "#ffffff",
......
{
"description": "TBD",
"properties": [
"currentViewIndex",
"editMode",
"name",
"showContextPane",
"showFilterPanel"
],
"relations": {
"screenshot": {
"sequenced": false,
"singular": true
},
"views": {
"sequenced": true,
"singular": false
}
},
"foregroundColor": "#ffffff",
"backgroundColor": "#93c47d"
}
\ No newline at end of file
{
"description": "TBD",
"properties": [
"name"
],
"relations": {
"datasource": {
"sequenced": false,
"singular": true
},
"session": {
"sequenced": false,
"singular": true
},
"userState": {
"sequenced": false,
"singular": true
},
"viewDefinition": {
"sequenced": false,
"singular": true
},
"viewArguments": {
"sequenced": false,
"singular": true
}
},
"foregroundColor": "#ffffff",
"backgroundColor": "#93c47d"
}
\ No newline at end of file
{
"description": "TBD",
"properties": [
"currentSessionIndex"
],
"relations": {
"sessions": {
"sequenced": true,
"singular": false
}
},
"foregroundColor": "#ffffff",
"backgroundColor": "#93c47d"
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ function getItemFamily() {
function getDataItemClasses() {
let dataItemClasses = [];
for (const entity of Object.keys(entityHierarchy)) {
if (['Datasource', 'UserState', 'ViewArguments'].includes(entity)) continue;
if (['Datasource', 'UserState', 'ViewArguments', 'CVUStateDefinition'].includes(entity)) continue;
let classDescription = `\n/// ${entityHierarchy[entity]['description']}\n`;
classDescription = helpers.wrapText(`/// ${entityHierarchy[entity]['description']}`, 100, '\n/// ');
......@@ -29,20 +29,11 @@ function getDataItemClasses() {
let classDefinition;
switch (entity) {
case 'Item':
classDefinition = `public class SchemaItem: Object, Codable, Identifiable {`;
break;
case 'Session':
classDefinition = `public class SchemaSession : Item {`;
break;
case 'Sessions':
classDefinition = `public class SchemaSessions : Item {`;
classDefinition = `public class SchemaItem: SyncableItem, Codable, Identifiable {`;
break;
case 'Person':
classDefinition = `public class SchemaPerson : Item {`;
break;
case 'SyncState':
classDefinition = 'public class SyncState: Object, Codable {\n let updatedFields = List<String>()';
break;
case 'Edge':
classDefinition = `public class Edge : Object, Codable {`;
break;
......@@ -72,7 +63,7 @@ function getDataItemClasses() {
relations += helpers.wrapText(` /// ${predicateHierarchy[field]['description']}\n`, 96);
}
if (['allEdges', 'currentViewIndex', 'currentSessionIndex', 'version', 'views', 'sessions', 'syncState'].includes(field)) {
if (['allEdges', 'currentViewIndex', 'currentSessionIndex', 'version'].includes(field)) {
switch (field) {
case 'allEdges':
properties += ' let allEdges = List<Edge>()\n';
......@@ -87,20 +78,6 @@ function getDataItemClasses() {
properties += ` @objc dynamic var ${field}:Int = 1\n`;
propertiesDecoder += ` ${field} = try decoder.decodeIfPresent("${field}") ?? ${field}\n`;
break;
case 'views':
relations += ` var ${field}: Results<${type}>? {\n` +
` edges("view")?.sorted(byKeyPath: "sequence").items(type:${type}.self)\n` +
' }\n\n';
break;
case 'sessions':
relations += ` var ${field}: Results<${type}>? {\n` +
` edges("session")?.sorted(byKeyPath: "sequence").items(type:${type}.self)\n` +
' }\n\n';
break;
case 'syncState':
properties += ` @objc dynamic var ${field}:${type}? = ${type}()\n`;
propertiesDecoder += ` ${field} = try decoder.decodeIfPresent("${field}") ?? ${field}\n`;
break;
}
} else {
switch (type) {
......@@ -257,6 +234,22 @@ enum ItemFamily: String, ClassFamily, CaseIterable {
}
}
public class SyncableItem: Object {
let _updated = List<String>()
/// TBD
@objc dynamic var _partial:Bool = false
/// TBD
@objc dynamic var _action:String? = nil
/// TBD
@objc dynamic var _changedInSession:Bool = false
}
public class CVUStateDefinition : CVUStoredDefinition {
required init () {
super.init()
}
}
${helpers.insertList(dataItemClasses)}
func dataItemListToArray(_ object: Any) -> [Item] {
var collection: [Item] = []
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment