@live-change/survey-service 0.8.126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/config.js ADDED
@@ -0,0 +1,15 @@
1
+ import definition from './definition.js'
2
+
3
+ const {
4
+ adminRoles = ['admin', 'owner'],
5
+ memberRoles = ['admin', 'owner', 'member'],
6
+ } = definition.config
7
+
8
+ definition.clientConfig = {
9
+ }
10
+
11
+ const config = {
12
+ adminRoles, memberRoles
13
+ }
14
+
15
+ export default config
package/definition.js ADDED
@@ -0,0 +1,13 @@
1
+ import App from '@live-change/framework'
2
+ const app = App.app()
3
+
4
+ import userService from '@live-change/user-service'
5
+ import relationsPlugin from '@live-change/relations-plugin'
6
+ import accessControlService from '@live-change/access-control-service'
7
+
8
+ const definition = app.createServiceDefinition({
9
+ name: "survey",
10
+ use: [ userService, relationsPlugin, accessControlService ]
11
+ })
12
+
13
+ export default definition
package/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import App from '@live-change/framework'
2
+ const app = App.app()
3
+
4
+ import definition from './definition.js'
5
+
6
+ import './survey.js'
7
+
8
+ export default definition
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@live-change/survey-service",
3
+ "version": "0.8.126",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "NODE_ENV=test tape tests/*"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/live-change/live-change-stack.git"
12
+ },
13
+ "license": "MIT",
14
+ "bugs": {
15
+ "url": "https://github.com/live-change/live-change-stack/issues"
16
+ },
17
+ "homepage": "https://github.com/live-change/live-change-stack",
18
+ "author": {
19
+ "email": "michal@laszczewski.pl",
20
+ "name": "Michał Łaszczewski",
21
+ "url": "https://www.viamage.com/"
22
+ },
23
+ "dependencies": {
24
+ "@live-change/access-control-service": "^0.8.126",
25
+ "@live-change/framework": "^0.8.126",
26
+ "@live-change/relations-plugin": "^0.8.126",
27
+ "@live-change/user-service": "^0.8.126"
28
+ },
29
+ "gitHead": "2aa34c0589d115aeaa573bd2cae09bb43a66d162",
30
+ "type": "module"
31
+ }
package/survey.js ADDED
@@ -0,0 +1,115 @@
1
+ import App from '@live-change/framework'
2
+ const app = App.app()
3
+
4
+ import definition from './definition.js'
5
+ import config from './config.js'
6
+
7
+ const SurveyDesign = definition.model({
8
+ name: "SurveyDesign",
9
+ propertyOfAny: {
10
+ to: ['topic'],
11
+ writeAccessControl: {
12
+ roles: config.adminRoles
13
+ },
14
+ readAccessControl: {
15
+ roles: []
16
+ },
17
+ extendedWith: ['topic']
18
+ },
19
+ properties: {
20
+ name: {
21
+ type: String,
22
+ softValidation: ['nonEmpty', { name: 'maxLength', length: 128 }]
23
+ },
24
+ title: {
25
+ type: String,
26
+ softValidation: ['nonEmpty', { name: 'maxLength', length: 128 }]
27
+ },
28
+ introduction: {
29
+ type: String,
30
+ input: 'textarea',
31
+ softValidation: ['nonEmpty', { name: 'maxLength', length: 512 }]
32
+ },
33
+ questions: {
34
+ type: Array,
35
+ of: {
36
+ type: Object,
37
+ properties: {
38
+ type: {
39
+ type: String,
40
+ softValidation: ['nonEmpty'],
41
+ options: ['text', 'textarea', 'choice', 'multipleChoice'],
42
+ input: 'select'
43
+ },
44
+ name: {
45
+ type: String,
46
+ softValidation: ['nonEmpty', { name: 'maxLength', length: 128 }]
47
+ },
48
+ label: {
49
+ type: String,
50
+ softValidation: ['nonEmpty', { name: 'maxLength', length: 128 }]
51
+ },
52
+ description: {
53
+ type: String,
54
+ input: 'textarea',
55
+ softValidation: ['nonEmpty', { name: 'maxLength', length: 512 }]
56
+ },
57
+ required: {
58
+ type: Boolean,
59
+ default: false
60
+ },
61
+ minLength: {
62
+ if: App.isomorphic(
63
+ ({ props, propName }) => ['text', 'textarea']
64
+ .includes(props.questions[+(propName.split('.')[1])].type)
65
+ ),
66
+ input: 'integer',
67
+ type: Number
68
+ },
69
+ maxLength: {
70
+ if: App.isomorphic(
71
+ ({ props, propName }) => ['text', 'textarea']
72
+ .includes(props.questions[+(propName.split('.')[1])].type)
73
+ ),
74
+ input: 'integer',
75
+ type: Number
76
+ },
77
+ options: {
78
+ if: App.isomorphic(
79
+ ({ props, propName }) => ['choice', 'multipleChoice']
80
+ .includes(props.questions[+(propName.split('.')[1])].type)
81
+ ),
82
+ type: Array,
83
+ of: {
84
+ type: Object,
85
+ properties: {
86
+ name: {
87
+ type: String,
88
+ softValidation: ['nonEmpty', { name: 'maxLength', length: 128 }]
89
+ },
90
+ label: {
91
+ type: String,
92
+ input: 'textarea',
93
+ softValidation: ['nonEmpty', { name: 'maxLength', length: 512 }]
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ })
103
+
104
+ const Survey = definition.model({
105
+ name: "Survey",
106
+ sessionOrUserProperty: {
107
+ ownerCreateAccess: () => true,
108
+ extendedWith: ['topic']
109
+ },
110
+ properties: {
111
+
112
+ },
113
+ })
114
+
115
+ export { Survey }