Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linter config for schemas #415

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
9 changes: 7 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
data
dist
*
!*/
!*.js
!*.action
!*.category
!*.domains
!*.form
o-rumiantsev marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!*.form
!*.form
!*.application

?

10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
{
"files": [".babelrc", ".prettierrc", ".metadocrc"],
"options": { "parser": "json" }
},
{
"files": [
"*.action",
"*.category",
"*.domains",
"*.form",
"*.application"
],
"options": { "parser": "babel" }
}
]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
],
"scripts": {
"test": "npm run lint && metatests test/",
"lint": "eslint . --ignore-path .gitignore && prettier -c \"**/*.js\" \"**/*.json\" \"**/*.md\" \".*rc\" \"**/*.yml\"",
"fmt": "prettier --write \"**/*.js\" \"**/*.json\" \"**/*.md\" \".*rc\" \"**/*.yml\"",
"lint": "eslint . && prettier -c \"**/*\"",
"fmt": "eslint --fix . && prettier --write \"**/*\"",
"doc": "metadoc",
"build": "babel gs.js -d dist && babel lib -d dist/lib",
"prepublish": "npm run -s build"
Expand Down
23 changes: 23 additions & 0 deletions schemas/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
globals:
api: false
gs: false
Action: false
Many: false
Master: false
Validate: false
Unique: false
Index: false
System: false
Global: false
Registry: false
Local: false
Dictionary: false
Log: false
Enum: false
Flags: false
Catalog: false
Subsystem: false
Form: false
rules:
strict: off
new-cap: off
2 changes: 1 addition & 1 deletion schemas/system/Action.category
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ System({
CheckPublic: Validate(record => !record.Category !== !record.Public),

NaturalKey: Unique('Category', 'Name'),
})
});
2 changes: 1 addition & 1 deletion schemas/system/Application.category
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
System({
Name: { domain: 'Nomen', lookup: true, required: true, unique: true },
Categories: Many('Category'),
})
});
2 changes: 1 addition & 1 deletion schemas/system/Catalog.category
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ System({
Caption: { domain: 'Nomen', lookup: true, required: true, index: true },
Category: { category: 'Category', required: true },
Parent: { category: 'Catalog' },
})
});
4 changes: 2 additions & 2 deletions schemas/system/Category.category
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ System({
Realm: { domain: 'CategoryRealm', required: true },
Family: { domain: 'CategoryFamily', required: true },
Version: { domain: 'Version', default: 0, required: true },
Master: { category: 'Category' }
})
Master: { category: 'Category' },
});
4 changes: 2 additions & 2 deletions schemas/system/Config.category
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
System({
Name: { domain: 'Nomen', lookup: true, required: true, unique: true },
Config: { domain: 'JSON', required: true }
})
Config: { domain: 'JSON', required: true },
});
4 changes: 2 additions & 2 deletions schemas/system/Cursor.category
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Local({
Created: { domain: 'DateTime', required: true },
Query: { domain: 'JSON', required: true },
Version: { domain: 'Version', default: 0, required: true },
Subscribers: Many('Session')
})
Subscribers: Many('Session'),
});
6 changes: 3 additions & 3 deletions schemas/system/File.category
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Registry({
CompressedSize: { domain: 'DataSize', required: true },
CompressRatio: {
domain: 'Ratio',
expression: record => record.CompressedSize / record.OriginalSize
}
})
expression: record => record.CompressedSize / record.OriginalSize,
},
});
4 changes: 2 additions & 2 deletions schemas/system/Identifier.category
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Registry({
} else {
return !record.Category;
}
})
})
}),
});
4 changes: 2 additions & 2 deletions schemas/system/Language.category
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Dictionary({
Name: { domain: 'Nomen', lookup: true, required: true, unique: true },
Locale: { domain: 'Nomen', required: true, unique: true }
})
Locale: { domain: 'Nomen', required: true, unique: true },
});
4 changes: 2 additions & 2 deletions schemas/system/Localization.category
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ System({
Language: { category: 'Language', required: true, index: true },
Text: { domain: 'Text' },

NaturalKey: Unique('ResourceKey', 'Language')
})
NaturalKey: Unique('ResourceKey', 'Language'),
});
25 changes: 14 additions & 11 deletions schemas/system/Locking.category
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars, no-undef, handle-callback-err */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify the need for these?

If they were meant to handle the callback of Lock action then I'd prefer to just either put () => {} in there or comment out the arguments if they are needed for some reason.

Local({
Identifier: { category: 'Identifier', required: true, index: true },
Session: { category: 'Session', required: true, index: true },
Expand All @@ -9,14 +10,17 @@ Local({

Lock: Action(({ Identifier }, callback) => {
const now = new Date();
gs.create({
Identifier,
Session: client.sessionId,
SystemUser: client.systemUserId,
Request: now
}, (err, data) => {
// to be implemented
});
gs.create(
{
Identifier,
Session: client.sessionId,
SystemUser: client.systemUserId,
Request: now,
},
(err, data) => {
// to be implemented
}
);
}),

Unlock: Action(({ Identifier }, callback) => {
Expand All @@ -25,7 +29,7 @@ Local({
Session: client.sessionId,
SystemUser: client.systemUserId,
Start: gs.notNull,
Expire: gs.Null
Expire: gs.Null,
}).fetch((err, data) => {
// to be implemented
});
Expand All @@ -34,5 +38,4 @@ Local({
CheckLock: Action(({ Identifier }, callback) => {
// to be implemented
}),

})
});
2 changes: 1 addition & 1 deletion schemas/system/Log.category
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Log({
Query: { domain: 'JSON' },
Patch: { domain: 'JSON' },
Response: { domain: 'JSON' },
})
});
5 changes: 3 additions & 2 deletions schemas/system/Permission.category
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ System({

NaturalKey: Index('Role', 'Category'),

CheckBound: Validate(record => true)
})
/* eslint-disable no-unused-vars */
CheckBound: Validate(record => true),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

() => true?

});
4 changes: 2 additions & 2 deletions schemas/system/Replication.category
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ System({
Destination: { category: 'Subsystem', required: true },
Category: { category: 'Category', required: true },

NaturalKey: Unique('Source', 'Destination', 'Category')
})
NaturalKey: Unique('Source', 'Destination', 'Category'),
});
2 changes: 1 addition & 1 deletion schemas/system/Role.category
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ System({
Blocked: { domain: 'Logical', required: true, default: false },
Subsystem: Subsystem(),
Applications: Many('Application'),
})
});
4 changes: 2 additions & 2 deletions schemas/system/Schema.category
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ System({
Version: { domain: 'Version', required: true, index: true },
Schema: { domain: 'Source', required: true },

NaturalKey: Unique('Category', 'Version')
})
NaturalKey: Unique('Category', 'Version'),
});
4 changes: 2 additions & 2 deletions schemas/system/Server.category
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ System({
Name: { domain: 'Nomen', display: true, required: true, unique: true },
Suffix: { domain: 'Id', required: true, unique: true },
IP: { domain: 'IP', required: true, unique: true },
ServerType: { domain: 'ServerType', required: true, default: 'Server' }
})
ServerType: { domain: 'ServerType', required: true, default: 'Server' },
});
4 changes: 2 additions & 2 deletions schemas/system/ServerNode.category
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Local({

UniqueSequence: Unique('Server', 'Instance'),
UniqueProcess: Unique('Server', 'Process'),
UniquePort: Unique('Server', 'Port')
})
UniquePort: Unique('Server', 'Port'),
});
4 changes: 2 additions & 2 deletions schemas/system/Session.category
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ System({
SystemUser: { category: 'SystemUser', required: true, index: true },
Start: { domain: 'DateTime', required: true },
LastActivity: { domain: 'DateTime', required: true },
LastIP: { domain: 'IP', required: true }
})
LastIP: { domain: 'IP', required: true },
});
2 changes: 1 addition & 1 deletion schemas/system/Subsystem.category
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ System({
Code: { domain: 'Id', required: true, unique: true },
SystemType: { domain: 'SystemType', required: true, default: 'Autonomous' },
Parent: { category: 'Subsystem' },
})
});
4 changes: 2 additions & 2 deletions schemas/system/SystemUser.SignIn.form
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Form({
Login: { domain: 'Login', required: true },
Password: { domain: 'Password', required: true }
})
Password: { domain: 'Password', required: true },
});
6 changes: 3 additions & 3 deletions schemas/system/SystemUser.SignUp.form
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Form({

Check: Validate(record => {
return (
login.length > 5 &&
record.Login.length > 5 &&
record.Password.length > 7 &&
record.Password === record.PasswordConfirm
);
})
})
}),
});
10 changes: 5 additions & 5 deletions schemas/system/SystemUser.category
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars, no-undef */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Maybe just put SignUp: Action((/* data, callback */) => {?

System({
Login: {
domain: 'Login',
Expand All @@ -9,7 +10,7 @@ System({
validate: login => {
// TODO: implement OWASP recomendations
return login.length > 5;
}
},
},
Password: {
domain: 'PasswordHash',
Expand All @@ -19,7 +20,7 @@ System({
// TODO: implement OWASP recomendations
// See https://www.owasp.org/index.php/Authentication_Cheat_Sheet
return Auth.passwordStrength(password);
}
},
},
Subsystem: Subsystem(),
Roles: Many('Role'),
Expand All @@ -43,6 +44,5 @@ System({

SignUp: Action((data, callback) => {
// TODO: implement user registration
})

})
}),
});
29 changes: 22 additions & 7 deletions schemas/system/gs.domains
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
({
Id: {
type: 'object',
class: 'Uint64',
Expand All @@ -9,7 +9,7 @@
);
}
return new api.common.Uint64(x);
}
},
},
Lambda: { type: 'function' },
Logical: { type: 'boolean', control: 'CheckBox' },
Expand Down Expand Up @@ -67,12 +67,27 @@
CountryNumeric: { type: 'string', length: 3, comment: 'ISO 3166-1 numeric' },
Year: { type: 'number', length: 4 },
Month: Enum(
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
),
Day: Enum(
'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
'Saturday', 'Sunday'
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday'
),
Seconds: { type: 'number', unit: 'Second' },
Minutes: { type: 'number', unit: 'Minute', base: 'Second', mul: 60 },
Expand Down Expand Up @@ -115,4 +130,4 @@
Volume: { type: 'number', unit: 'Litre', symbol: 'l' },
Speed: { type: 'number', unit: 'Metres per second', symbol: 'm/s' },
Ratio: { type: 'number' },
}
});
20 changes: 15 additions & 5 deletions schemas/system/system.domains
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
({
IdStatus: Enum('Prealloc', 'Init', 'Actual', 'Historical'),
HistoryStatus: Enum('Future', 'Actual', 'Historical'),
StorageKind: Enum('Master', 'Cache', 'Backup', 'Replica'),
CategoryRealm: Enum('Global', 'System', 'Local'),
CategoryFamily: Enum(
'Registry', 'Dictionary', 'System', 'Log', 'Local', 'Table', 'History',
'View', 'Projection', 'Memory', 'Form', 'Arguments'
'Registry',
'Dictionary',
'System',
'Log',
'Local',
'Table',
'History',
'View',
'Projection',
'Memory',
'Form',
'Arguments'
),
UserAccess: Enum('Read', 'Insert', 'Update', 'Delete', 'Audit'),
AccessFlags: Flags.of('UserAccess'),
Expand All @@ -28,5 +38,5 @@
SystemType: Enum('Global', 'Autonomous', 'Standalone'),
ServerType: Enum('Root', 'Server', 'Backup', 'Reserve'),
NodeType: Enum('Master', 'Worker', 'Task'),
NodeStatus: Enum('Init', 'Active', 'Pause', 'Restart', 'Hang')
}
NodeStatus: Enum('Init', 'Active', 'Pause', 'Restart', 'Hang'),
});
Loading