1
0
Fork 0
mirror of synced 2024-06-16 09:25:12 +12:00

extract constant

This commit is contained in:
Martin McKeaveney 2020-11-25 15:03:19 +00:00
parent 9f2832af94
commit e0071cabfd
2 changed files with 37 additions and 31 deletions

View file

@ -26,6 +26,7 @@ const {
const { MAIN, UNAUTHENTICATED, PageTypes } = require("../../constants/pages")
const { HOME_SCREEN } = require("../../constants/screens")
const { cloneDeep } = require("lodash/fp")
const { USERS_TABLE_SCHEMA } = require("../../constants")
const APP_PREFIX = DocumentTypes.APP + SEPARATOR
@ -69,37 +70,7 @@ async function createInstance(template) {
}
} else {
// create the users table
await db.put({
_id: "ta_users",
type: "table",
views: {},
name: "Users",
schema: {
username: {
type: "string",
constraints: {
type: "string",
length: {
maximum: "",
},
presence: true,
},
fieldName: "username",
name: "username",
},
accessLevelId: {
fieldName: "accessLevelId",
name: "accessLevelId",
type: "options",
constraints: {
type: "string",
presence: false,
inclusion: Object.values(BUILTIN_LEVEL_IDS),
},
},
},
primaryDisplay: "username",
})
await db.put(USERS_TABLE_SCHEMA)
}
return { _id: appId }

View file

@ -1,7 +1,42 @@
const { BUILTIN_LEVEL_IDS } = require("../utilities/security/accessLevels")
const AuthTypes = {
APP: "app",
BUILDER: "builder",
EXTERNAL: "external",
}
const USERS_TABLE_SCHEMA = {
_id: "ta_users",
type: "table",
views: {},
name: "Users",
schema: {
username: {
type: "string",
constraints: {
type: "string",
length: {
maximum: "",
},
presence: true,
},
fieldName: "username",
name: "username",
},
accessLevelId: {
fieldName: "accessLevelId",
name: "accessLevelId",
type: "options",
constraints: {
type: "string",
presence: false,
inclusion: Object.keys(BUILTIN_LEVEL_IDS),
},
},
},
primaryDisplay: "username",
}
exports.AuthTypes = AuthTypes
exports.USERS_TABLE_SCHEMA = USERS_TABLE_SCHEMA