@things-factory/survey 0.0.0-stage → 10.1.314
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/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/pages/my-surveys.d.ts +24 -0
- package/dist-client/pages/my-surveys.js +256 -0
- package/dist-client/pages/survey-editor.d.ts +62 -0
- package/dist-client/pages/survey-editor.js +668 -0
- package/dist-client/pages/survey-list.d.ts +15 -0
- package/dist-client/pages/survey-list.js +150 -0
- package/dist-client/pages/survey-trustee.d.ts +21 -0
- package/dist-client/pages/survey-trustee.js +170 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +17 -0
- package/dist-client/utils/survey-api.d.ts +16 -0
- package/dist-client/utils/survey-api.js +46 -0
- package/dist-client/utils/survey-result.d.ts +4 -0
- package/dist-client/utils/survey-result.js +79 -0
- package/dist-client/utils/survey-secret.d.ts +40 -0
- package/dist-client/utils/survey-secret.js +154 -0
- package/dist-server/index.d.ts +2 -0
- package/dist-server/index.js +27 -0
- package/dist-server/role-tasks.d.ts +2 -0
- package/dist-server/role-tasks.js +16 -0
- package/dist-server/service/index.d.ts +16 -0
- package/dist-server/service/index.js +30 -0
- package/dist-server/service/refusal.d.ts +57 -0
- package/dist-server/service/refusal.js +66 -0
- package/dist-server/service/survey/ballot-route.d.ts +1 -0
- package/dist-server/service/survey/ballot-route.js +30 -0
- package/dist-server/service/survey/ballot-worker.d.ts +1 -0
- package/dist-server/service/survey/ballot-worker.js +19 -0
- package/dist-server/service/survey/index.d.ts +10 -0
- package/dist-server/service/survey/index.js +14 -0
- package/dist-server/service/survey/survey-answer.d.ts +23 -0
- package/dist-server/service/survey/survey-answer.js +99 -0
- package/dist-server/service/survey/survey-attributes.d.ts +16 -0
- package/dist-server/service/survey/survey-attributes.js +39 -0
- package/dist-server/service/survey/survey-ballot.d.ts +14 -0
- package/dist-server/service/survey/survey-ballot.js +61 -0
- package/dist-server/service/survey/survey-class-key.d.ts +20 -0
- package/dist-server/service/survey/survey-class-key.js +92 -0
- package/dist-server/service/survey/survey-question.d.ts +27 -0
- package/dist-server/service/survey/survey-question.js +113 -0
- package/dist-server/service/survey/survey-resolver.d.ts +37 -0
- package/dist-server/service/survey/survey-resolver.js +492 -0
- package/dist-server/service/survey/survey-respondent.d.ts +17 -0
- package/dist-server/service/survey/survey-respondent.js +81 -0
- package/dist-server/service/survey/survey-rules.d.ts +169 -0
- package/dist-server/service/survey/survey-rules.js +299 -0
- package/dist-server/service/survey/survey-secret.d.ts +133 -0
- package/dist-server/service/survey/survey-secret.js +347 -0
- package/dist-server/service/survey/survey-service.d.ts +83 -0
- package/dist-server/service/survey/survey-service.js +384 -0
- package/dist-server/service/survey/survey-trustee.d.ts +25 -0
- package/dist-server/service/survey/survey-trustee.js +119 -0
- package/dist-server/service/survey/survey-types.d.ts +91 -0
- package/dist-server/service/survey/survey-types.js +319 -0
- package/dist-server/service/survey/survey.d.ts +47 -0
- package/dist-server/service/survey/survey.js +214 -0
- package/dist-shared/ballot.d.ts +54 -0
- package/dist-shared/ballot.js +146 -0
- package/dist-shared/blind-rsa.d.ts +18 -0
- package/dist-shared/blind-rsa.js +127 -0
- package/dist-shared/elgamal.d.ts +20 -0
- package/dist-shared/elgamal.js +54 -0
- package/dist-shared/group.d.ts +22 -0
- package/dist-shared/group.js +112 -0
- package/dist-shared/proofs.d.ts +20 -0
- package/dist-shared/proofs.js +94 -0
- package/dist-shared/threshold.d.ts +39 -0
- package/dist-shared/threshold.js +98 -0
- package/dist-shared/verify.d.ts +13 -0
- package/dist-shared/verify.js +73 -0
- package/package.json +63 -4
- package/things-factory.config.js +15 -0
- package/translations/en.json +202 -0
- package/translations/es.json +202 -0
- package/translations/ja.json +202 -0
- package/translations/ko.json +202 -0
- package/translations/ms.json +202 -0
- package/translations/zh.json +202 -0
- package/README.md +0 -3
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SurveySecretResolver = exports.SurveyResolver = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const organization_1 = require("@things-factory/organization");
|
|
8
|
+
const shell_1 = require("@things-factory/shell");
|
|
9
|
+
const refusal_1 = require("../refusal");
|
|
10
|
+
const survey_1 = require("./survey");
|
|
11
|
+
const survey_answer_1 = require("./survey-answer");
|
|
12
|
+
const survey_question_1 = require("./survey-question");
|
|
13
|
+
const survey_attributes_1 = require("./survey-attributes");
|
|
14
|
+
const survey_secret_1 = require("./survey-secret");
|
|
15
|
+
const survey_respondent_1 = require("./survey-respondent");
|
|
16
|
+
const survey_service_1 = require("./survey-service");
|
|
17
|
+
const survey_types_1 = require("./survey-types");
|
|
18
|
+
const SHOWN_TO_RESPONDENTS = ['OPEN', 'CLOSED', 'COUNTED', 'PUBLISHED'];
|
|
19
|
+
let SurveyResolver = class SurveyResolver {
|
|
20
|
+
/* ---- the operators (design §8) */
|
|
21
|
+
async surveys(context) {
|
|
22
|
+
return await (0, shell_1.getRepository)(survey_1.Survey).find({ where: { domain: { id: context.state.domain.id } }, order: { createdAt: 'DESC' } });
|
|
23
|
+
}
|
|
24
|
+
async surveyDetail(id, context) {
|
|
25
|
+
const manager = (0, shell_1.getRepository)(survey_1.Survey).manager;
|
|
26
|
+
const survey = await (0, survey_service_1.surveyOf)(manager, context.state.domain, id);
|
|
27
|
+
const respondents = (0, shell_1.getRepository)(survey_respondent_1.SurveyRespondent);
|
|
28
|
+
return {
|
|
29
|
+
survey,
|
|
30
|
+
questions: await (0, survey_service_1.questionsOf)(manager, id),
|
|
31
|
+
askedCount: await respondents.count({ where: { survey: { id } } }),
|
|
32
|
+
takenCount: await respondents.count({ where: { survey: { id }, taken: true } }),
|
|
33
|
+
result: survey.result ?? null,
|
|
34
|
+
published: survey.published ?? null
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async surveyAnswerSheets(id, context) {
|
|
38
|
+
const manager = (0, shell_1.getRepository)(survey_1.Survey).manager;
|
|
39
|
+
const survey = await (0, survey_service_1.surveyOf)(manager, context.state.domain, id);
|
|
40
|
+
if (survey.level !== 'NAMED')
|
|
41
|
+
throw (0, refusal_1.surveyRefusal)('survey-not-named');
|
|
42
|
+
const respondents = await (0, shell_1.getRepository)(survey_respondent_1.SurveyRespondent).find({ where: { survey: { id }, taken: true }, relations: ['user'] });
|
|
43
|
+
const answers = await (0, shell_1.getRepository)(survey_answer_1.SurveyAnswer).find({ where: { survey: { id } } });
|
|
44
|
+
return respondents.map(one => ({
|
|
45
|
+
userId: one.userId,
|
|
46
|
+
name: one.user?.name,
|
|
47
|
+
answers: Object.fromEntries(answers.filter(answer => answer.respondentId === one.id).map(answer => [answer.questionId, answer.value]))
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
async surveyAudienceChoices(context) {
|
|
51
|
+
const { domain, tx } = context.state;
|
|
52
|
+
const departments = await (0, shell_1.getRepository)(organization_1.Department, tx).find({ where: { domain: { id: domain.id } }, order: { name: 'ASC' } });
|
|
53
|
+
const roles = await (0, organization_1.domainRolesOf)(domain, undefined, tx);
|
|
54
|
+
const working = await (0, organization_1.workingEmployeeUserIds)(domain, tx);
|
|
55
|
+
const employees = working.length ? await (0, shell_1.getRepository)(organization_1.Employee, tx).find({ where: { domain: { id: domain.id }, user: { id: (0, typeorm_1.In)(working) } }, relations: ['user'], order: { name: 'ASC' } }) : [];
|
|
56
|
+
const people = new Map();
|
|
57
|
+
for (const one of employees)
|
|
58
|
+
if (one.user?.id && !people.has(one.user.id))
|
|
59
|
+
people.set(one.user.id, one.name ?? one.user.name ?? one.user.id);
|
|
60
|
+
return {
|
|
61
|
+
domainId: domain.id,
|
|
62
|
+
departments: departments.map(one => ({ id: one.id, name: one.name ?? one.id })),
|
|
63
|
+
roles: roles.map(one => ({ id: one.id, name: one.name })),
|
|
64
|
+
people: [...people].map(([id, name]) => ({ id, name }))
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async surveyAttributes() {
|
|
68
|
+
return (0, survey_attributes_1.surveyAttributes)().map(({ name, label, type }) => ({ name, label, type }));
|
|
69
|
+
}
|
|
70
|
+
async surveyClassPreview(id, context) {
|
|
71
|
+
return await (0, survey_service_1.classPreviewOf)((0, shell_1.getRepository)(survey_1.Survey).manager, context.state.domain, id);
|
|
72
|
+
}
|
|
73
|
+
async surveyPreviousChoices(id, context) {
|
|
74
|
+
const choices = await (0, survey_service_1.previousChoicesOf)((0, shell_1.getRepository)(survey_1.Survey).manager, context.state.domain, id);
|
|
75
|
+
return choices.map(one => ({ id: one.key, name: one.label }));
|
|
76
|
+
}
|
|
77
|
+
async carrySurveyForward(id, context) {
|
|
78
|
+
const { domain, user, tx } = context.state;
|
|
79
|
+
return await (0, survey_service_1.carryForward)(tx, domain, user, id);
|
|
80
|
+
}
|
|
81
|
+
async createSurvey(patch, context) {
|
|
82
|
+
const { domain, user, tx } = context.state;
|
|
83
|
+
return await (0, survey_service_1.createSurvey)(tx, domain, user, patch);
|
|
84
|
+
}
|
|
85
|
+
async updateSurvey(id, patch, context) {
|
|
86
|
+
const { domain, user, tx } = context.state;
|
|
87
|
+
return await (0, survey_service_1.updateSurvey)(tx, domain, user, id, patch);
|
|
88
|
+
}
|
|
89
|
+
async deleteSurvey(id, context) {
|
|
90
|
+
const { domain, tx } = context.state;
|
|
91
|
+
return await (0, survey_service_1.deleteSurvey)(tx, domain, id);
|
|
92
|
+
}
|
|
93
|
+
async setSurveyQuestions(id, questions, context) {
|
|
94
|
+
const { domain, user, tx } = context.state;
|
|
95
|
+
return await (0, survey_service_1.setSurveyQuestions)(tx, domain, user, id, questions);
|
|
96
|
+
}
|
|
97
|
+
async openSurvey(id, context) {
|
|
98
|
+
const { domain, user, tx } = context.state;
|
|
99
|
+
return await (0, survey_service_1.openSurvey)(tx, domain, user, id);
|
|
100
|
+
}
|
|
101
|
+
async closeSurvey(id, context) {
|
|
102
|
+
const { domain, user, tx } = context.state;
|
|
103
|
+
return await (0, survey_service_1.closeSurvey)(tx, domain, user, id);
|
|
104
|
+
}
|
|
105
|
+
async countSurvey(id, context) {
|
|
106
|
+
const { domain, user, tx } = context.state;
|
|
107
|
+
return await (0, survey_service_1.countSurvey)(tx, domain, user, id);
|
|
108
|
+
}
|
|
109
|
+
async publishSurvey(id, context) {
|
|
110
|
+
const { domain, user, tx } = context.state;
|
|
111
|
+
return await (0, survey_service_1.publishSurvey)(tx, domain, user, id);
|
|
112
|
+
}
|
|
113
|
+
async cancelSurvey(id, reason, context) {
|
|
114
|
+
const { domain, user, tx } = context.state;
|
|
115
|
+
return await (0, survey_service_1.cancelSurvey)(tx, domain, user, id, reason);
|
|
116
|
+
}
|
|
117
|
+
/* ---- each person (design §8) */
|
|
118
|
+
async mySurveys(context) {
|
|
119
|
+
const { domain, user } = context.state;
|
|
120
|
+
const mine = await (0, shell_1.getRepository)(survey_respondent_1.SurveyRespondent).find({ where: { domain: { id: domain.id }, user: { id: user.id } }, relations: ['survey'] });
|
|
121
|
+
const shown = mine.filter(one => one.survey && SHOWN_TO_RESPONDENTS.includes(one.survey.status));
|
|
122
|
+
const manager = (0, shell_1.getRepository)(survey_1.Survey).manager;
|
|
123
|
+
const out = [];
|
|
124
|
+
for (const one of shown.sort((a, b) => +new Date(b.survey.openedAt ?? 0) - +new Date(a.survey.openedAt ?? 0))) {
|
|
125
|
+
const survey = one.survey;
|
|
126
|
+
const readable = survey.status === 'PUBLISHED' && survey.resultReaders === 'RESPONDENTS';
|
|
127
|
+
out.push({
|
|
128
|
+
survey,
|
|
129
|
+
taken: one.taken,
|
|
130
|
+
questions: (survey.status === 'OPEN' && !one.taken) || readable ? await (0, survey_service_1.questionsOf)(manager, survey.id) : [],
|
|
131
|
+
published: readable ? survey.published : null
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
async answerSurvey(id, answers, context) {
|
|
137
|
+
const { domain, user, tx } = context.state;
|
|
138
|
+
return await (0, survey_service_1.answerSurvey)(tx, domain, user, id, answers);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
exports.SurveyResolver = SurveyResolver;
|
|
142
|
+
tslib_1.__decorate([
|
|
143
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "query", domainOwnerGranted: true)'),
|
|
144
|
+
(0, type_graphql_1.Query)(returns => [survey_1.Survey], { description: 'The surveys of this domain, newest first' }),
|
|
145
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
146
|
+
tslib_1.__metadata("design:type", Function),
|
|
147
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
148
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
149
|
+
], SurveyResolver.prototype, "surveys", null);
|
|
150
|
+
tslib_1.__decorate([
|
|
151
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "query", domainOwnerGranted: true)'),
|
|
152
|
+
(0, type_graphql_1.Query)(returns => survey_types_1.SurveyDetail, { description: 'A survey with its questions, how many were asked and answered, and its count' }),
|
|
153
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
154
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
155
|
+
tslib_1.__metadata("design:type", Function),
|
|
156
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
157
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
158
|
+
], SurveyResolver.prototype, "surveyDetail", null);
|
|
159
|
+
tslib_1.__decorate([
|
|
160
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "query", domainOwnerGranted: true)'),
|
|
161
|
+
(0, type_graphql_1.Query)(returns => [survey_types_1.SurveyAnswerSheet], { description: 'Who answered what - a named survey only' }),
|
|
162
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
163
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
164
|
+
tslib_1.__metadata("design:type", Function),
|
|
165
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
166
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
167
|
+
], SurveyResolver.prototype, "surveyAnswerSheets", null);
|
|
168
|
+
tslib_1.__decorate([
|
|
169
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "query", domainOwnerGranted: true)'),
|
|
170
|
+
(0, type_graphql_1.Query)(returns => survey_types_1.SurveyAudienceChoices, { description: 'The departments, roles and people a survey can ask here' }),
|
|
171
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
172
|
+
tslib_1.__metadata("design:type", Function),
|
|
173
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
174
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
175
|
+
], SurveyResolver.prototype, "surveyAudienceChoices", null);
|
|
176
|
+
tslib_1.__decorate([
|
|
177
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "query", domainOwnerGranted: true)'),
|
|
178
|
+
(0, type_graphql_1.Query)(returns => [survey_types_1.SurveyAttributeInfo], { description: 'The attributes a survey can weight by here' }),
|
|
179
|
+
tslib_1.__metadata("design:type", Function),
|
|
180
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
181
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
182
|
+
], SurveyResolver.prototype, "surveyAttributes", null);
|
|
183
|
+
tslib_1.__decorate([
|
|
184
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "query", domainOwnerGranted: true)'),
|
|
185
|
+
(0, type_graphql_1.Query)(returns => shell_1.ScalarObject, { description: 'How many people each weight class would hold if the draft opened now - sizes only' }),
|
|
186
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
187
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
188
|
+
tslib_1.__metadata("design:type", Function),
|
|
189
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
190
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
191
|
+
], SurveyResolver.prototype, "surveyClassPreview", null);
|
|
192
|
+
tslib_1.__decorate([
|
|
193
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "query", domainOwnerGranted: true)'),
|
|
194
|
+
(0, type_graphql_1.Query)(returns => [survey_types_1.SurveyChoice], { description: 'The choices of the round before - labels only, for marking who withdrew' }),
|
|
195
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
196
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
197
|
+
tslib_1.__metadata("design:type", Function),
|
|
198
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
199
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
200
|
+
], SurveyResolver.prototype, "surveyPreviousChoices", null);
|
|
201
|
+
tslib_1.__decorate([
|
|
202
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "mutation", domainOwnerGranted: true)'),
|
|
203
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
204
|
+
(0, type_graphql_1.Mutation)(returns => [survey_question_1.SurveyQuestion], { description: 'Takes this draft’s choices from the round before - its top choices not withdrawn' }),
|
|
205
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
206
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
207
|
+
tslib_1.__metadata("design:type", Function),
|
|
208
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
209
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
210
|
+
], SurveyResolver.prototype, "carrySurveyForward", null);
|
|
211
|
+
tslib_1.__decorate([
|
|
212
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "mutation", domainOwnerGranted: true)'),
|
|
213
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
214
|
+
(0, type_graphql_1.Mutation)(returns => survey_1.Survey, { description: 'Makes a draft survey' }),
|
|
215
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patch', type => survey_types_1.SurveyPatch)),
|
|
216
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
217
|
+
tslib_1.__metadata("design:type", Function),
|
|
218
|
+
tslib_1.__metadata("design:paramtypes", [survey_types_1.SurveyPatch, Object]),
|
|
219
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
220
|
+
], SurveyResolver.prototype, "createSurvey", null);
|
|
221
|
+
tslib_1.__decorate([
|
|
222
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "mutation", domainOwnerGranted: true)'),
|
|
223
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
224
|
+
(0, type_graphql_1.Mutation)(returns => survey_1.Survey, { description: 'Changes a draft survey' }),
|
|
225
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
226
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch', type => survey_types_1.SurveyPatch)),
|
|
227
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
228
|
+
tslib_1.__metadata("design:type", Function),
|
|
229
|
+
tslib_1.__metadata("design:paramtypes", [String, survey_types_1.SurveyPatch, Object]),
|
|
230
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
231
|
+
], SurveyResolver.prototype, "updateSurvey", null);
|
|
232
|
+
tslib_1.__decorate([
|
|
233
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "mutation", domainOwnerGranted: true)'),
|
|
234
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
235
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Deletes a draft survey' }),
|
|
236
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
237
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
238
|
+
tslib_1.__metadata("design:type", Function),
|
|
239
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
240
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
241
|
+
], SurveyResolver.prototype, "deleteSurvey", null);
|
|
242
|
+
tslib_1.__decorate([
|
|
243
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "mutation", domainOwnerGranted: true)'),
|
|
244
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
245
|
+
(0, type_graphql_1.Mutation)(returns => [survey_question_1.SurveyQuestion], { description: 'Replaces the questions of a draft survey, in the order given' }),
|
|
246
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
247
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('questions', type => [survey_types_1.SurveyQuestionInput])),
|
|
248
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
249
|
+
tslib_1.__metadata("design:type", Function),
|
|
250
|
+
tslib_1.__metadata("design:paramtypes", [String, Array, Object]),
|
|
251
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
252
|
+
], SurveyResolver.prototype, "setSurveyQuestions", null);
|
|
253
|
+
tslib_1.__decorate([
|
|
254
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "mutation", domainOwnerGranted: true)'),
|
|
255
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
256
|
+
(0, type_graphql_1.Mutation)(returns => survey_1.Survey, { description: 'Opens a draft survey - the people it asks are listed now' }),
|
|
257
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
258
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
259
|
+
tslib_1.__metadata("design:type", Function),
|
|
260
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
261
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
262
|
+
], SurveyResolver.prototype, "openSurvey", null);
|
|
263
|
+
tslib_1.__decorate([
|
|
264
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "mutation", domainOwnerGranted: true)'),
|
|
265
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
266
|
+
(0, type_graphql_1.Mutation)(returns => survey_1.Survey, { description: 'Closes an open survey before its time' }),
|
|
267
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
268
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
269
|
+
tslib_1.__metadata("design:type", Function),
|
|
270
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
271
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
272
|
+
], SurveyResolver.prototype, "closeSurvey", null);
|
|
273
|
+
tslib_1.__decorate([
|
|
274
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "mutation", domainOwnerGranted: true)'),
|
|
275
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
276
|
+
(0, type_graphql_1.Mutation)(returns => survey_1.Survey, { description: 'Counts a closed survey - the count is the operators’ until published' }),
|
|
277
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
278
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
279
|
+
tslib_1.__metadata("design:type", Function),
|
|
280
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
281
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
282
|
+
], SurveyResolver.prototype, "countSurvey", null);
|
|
283
|
+
tslib_1.__decorate([
|
|
284
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "mutation", domainOwnerGranted: true)'),
|
|
285
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
286
|
+
(0, type_graphql_1.Mutation)(returns => survey_1.Survey, { description: 'Publishes the figures a counted survey may publish' }),
|
|
287
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
288
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
289
|
+
tslib_1.__metadata("design:type", Function),
|
|
290
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
291
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
292
|
+
], SurveyResolver.prototype, "publishSurvey", null);
|
|
293
|
+
tslib_1.__decorate([
|
|
294
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "mutation", domainOwnerGranted: true)'),
|
|
295
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
296
|
+
(0, type_graphql_1.Mutation)(returns => survey_1.Survey, { description: 'Cancels a survey that is not yet published' }),
|
|
297
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
298
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('reason', { nullable: true })),
|
|
299
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
300
|
+
tslib_1.__metadata("design:type", Function),
|
|
301
|
+
tslib_1.__metadata("design:paramtypes", [String, String, Object]),
|
|
302
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
303
|
+
], SurveyResolver.prototype, "cancelSurvey", null);
|
|
304
|
+
tslib_1.__decorate([
|
|
305
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey", privilege: "query", domainOwnerGranted: true)'),
|
|
306
|
+
(0, type_graphql_1.Query)(returns => [survey_types_1.MySurvey], { description: 'The surveys that ask me' }),
|
|
307
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
308
|
+
tslib_1.__metadata("design:type", Function),
|
|
309
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
310
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
311
|
+
], SurveyResolver.prototype, "mySurveys", null);
|
|
312
|
+
tslib_1.__decorate([
|
|
313
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey", privilege: "mutation", domainOwnerGranted: true)'),
|
|
314
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
315
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Answers a named survey - every question, once' }),
|
|
316
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
317
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('answers', type => [survey_types_1.SurveyAnswerInput])),
|
|
318
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
319
|
+
tslib_1.__metadata("design:type", Function),
|
|
320
|
+
tslib_1.__metadata("design:paramtypes", [String, Array, Object]),
|
|
321
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
322
|
+
], SurveyResolver.prototype, "answerSurvey", null);
|
|
323
|
+
exports.SurveyResolver = SurveyResolver = tslib_1.__decorate([
|
|
324
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals),
|
|
325
|
+
(0, type_graphql_1.Resolver)(survey_1.Survey)
|
|
326
|
+
], SurveyResolver);
|
|
327
|
+
/* ---- the secret level (design §8) */
|
|
328
|
+
let SurveySecretResolver = class SurveySecretResolver {
|
|
329
|
+
async startSurveyKeying(id, context) {
|
|
330
|
+
const { domain, user, tx } = context.state;
|
|
331
|
+
return await (0, survey_secret_1.startKeying)(tx, domain, user, id);
|
|
332
|
+
}
|
|
333
|
+
async surveyBulletin(id, context) {
|
|
334
|
+
return await (0, survey_secret_1.bulletinOf)((0, shell_1.getRepository)(survey_1.Survey).manager, context.state.domain, id);
|
|
335
|
+
}
|
|
336
|
+
async surveyBallotKit(id, context) {
|
|
337
|
+
const { domain, user } = context.state;
|
|
338
|
+
return await (0, survey_secret_1.ballotKitOf)((0, shell_1.getRepository)(survey_1.Survey).manager, domain, user, id);
|
|
339
|
+
}
|
|
340
|
+
async issueSurveyBallot(id, blinded, context) {
|
|
341
|
+
const { domain, user, tx } = context.state;
|
|
342
|
+
return await (0, survey_secret_1.issueBallot)(tx, domain, user, id, blinded);
|
|
343
|
+
}
|
|
344
|
+
async surveyReceiptListed(id, receipt, context) {
|
|
345
|
+
return await (0, survey_secret_1.receiptListed)((0, shell_1.getRepository)(survey_1.Survey).manager, context.state.domain, id, receipt);
|
|
346
|
+
}
|
|
347
|
+
async myTrusteeSurveys(context) {
|
|
348
|
+
const { domain, user } = context.state;
|
|
349
|
+
return await (0, survey_secret_1.myTrusteeSurveys)((0, shell_1.getRepository)(survey_1.Survey).manager, domain, user);
|
|
350
|
+
}
|
|
351
|
+
async surveyTrusteeView(id, context) {
|
|
352
|
+
const { domain, user } = context.state;
|
|
353
|
+
return await (0, survey_secret_1.trusteeViewOf)((0, shell_1.getRepository)(survey_1.Survey).manager, domain, user, id);
|
|
354
|
+
}
|
|
355
|
+
async postSurveyTransportKey(id, key, proof, context) {
|
|
356
|
+
const { domain, user, tx } = context.state;
|
|
357
|
+
await (0, survey_secret_1.postTransportKey)(tx, domain, user, id, key, proof);
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
async postSurveyDealing(id, dealing, sealed, context) {
|
|
361
|
+
const { domain, user, tx } = context.state;
|
|
362
|
+
await (0, survey_secret_1.postDealing)(tx, domain, user, id, dealing, sealed);
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
async confirmSurveyShares(id, context) {
|
|
366
|
+
const { domain, user, tx } = context.state;
|
|
367
|
+
await (0, survey_secret_1.confirmShares)(tx, domain, user, id);
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
async postSurveyPartials(id, partials, context) {
|
|
371
|
+
const { domain, user, tx } = context.state;
|
|
372
|
+
await (0, survey_secret_1.postPartials)(tx, domain, user, id, partials);
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
exports.SurveySecretResolver = SurveySecretResolver;
|
|
377
|
+
tslib_1.__decorate([
|
|
378
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "mutation", domainOwnerGranted: true)'),
|
|
379
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
380
|
+
(0, type_graphql_1.Mutation)(returns => survey_1.Survey, { description: 'A secret draft starts its key - its key holders are named and its questions fixed' }),
|
|
381
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
382
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
383
|
+
tslib_1.__metadata("design:type", Function),
|
|
384
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
385
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
386
|
+
], SurveySecretResolver.prototype, "startSurveyKeying", null);
|
|
387
|
+
tslib_1.__decorate([
|
|
388
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-admin", privilege: "query", domainOwnerGranted: true)'),
|
|
389
|
+
(0, type_graphql_1.Query)(returns => shell_1.ScalarObject, { description: 'Everything a secret survey’s count can be checked from - no person' }),
|
|
390
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
391
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
392
|
+
tslib_1.__metadata("design:type", Function),
|
|
393
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
394
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
395
|
+
], SurveySecretResolver.prototype, "surveyBulletin", null);
|
|
396
|
+
tslib_1.__decorate([
|
|
397
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey", privilege: "query", domainOwnerGranted: true)'),
|
|
398
|
+
(0, type_graphql_1.Query)(returns => survey_types_1.SurveyBallotKit, { description: 'What my browser needs to seal my secret ballot' }),
|
|
399
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
400
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
401
|
+
tslib_1.__metadata("design:type", Function),
|
|
402
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
403
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
404
|
+
], SurveySecretResolver.prototype, "surveyBallotKit", null);
|
|
405
|
+
tslib_1.__decorate([
|
|
406
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey", privilege: "mutation", domainOwnerGranted: true)'),
|
|
407
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
408
|
+
(0, type_graphql_1.Mutation)(returns => String, { description: 'Signs my blinded ballot token - once; the serial stays in my browser' }),
|
|
409
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
410
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('blinded')),
|
|
411
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
412
|
+
tslib_1.__metadata("design:type", Function),
|
|
413
|
+
tslib_1.__metadata("design:paramtypes", [String, String, Object]),
|
|
414
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
415
|
+
], SurveySecretResolver.prototype, "issueSurveyBallot", null);
|
|
416
|
+
tslib_1.__decorate([
|
|
417
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey", privilege: "query", domainOwnerGranted: true)'),
|
|
418
|
+
(0, type_graphql_1.Query)(returns => Boolean, { description: 'Whether my receipt is on the survey’s ballots' }),
|
|
419
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
420
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('receipt')),
|
|
421
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
422
|
+
tslib_1.__metadata("design:type", Function),
|
|
423
|
+
tslib_1.__metadata("design:paramtypes", [String, String, Object]),
|
|
424
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
425
|
+
], SurveySecretResolver.prototype, "surveyReceiptListed", null);
|
|
426
|
+
tslib_1.__decorate([
|
|
427
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-trustee", privilege: "query", domainOwnerGranted: true)'),
|
|
428
|
+
(0, type_graphql_1.Query)(returns => [survey_types_1.MyTrusteeSurvey], { description: 'The secret surveys I hold a key of' }),
|
|
429
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
430
|
+
tslib_1.__metadata("design:type", Function),
|
|
431
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
432
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
433
|
+
], SurveySecretResolver.prototype, "myTrusteeSurveys", null);
|
|
434
|
+
tslib_1.__decorate([
|
|
435
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-trustee", privilege: "query", domainOwnerGranted: true)'),
|
|
436
|
+
(0, type_graphql_1.Query)(returns => shell_1.ScalarObject, { description: 'A secret survey as its key holder sees it - the key-making facts and the shares sealed to me' }),
|
|
437
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
438
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
439
|
+
tslib_1.__metadata("design:type", Function),
|
|
440
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
441
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
442
|
+
], SurveySecretResolver.prototype, "surveyTrusteeView", null);
|
|
443
|
+
tslib_1.__decorate([
|
|
444
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-trustee", privilege: "mutation", domainOwnerGranted: true)'),
|
|
445
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
446
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Posts my transport key, with the proof I know its secret' }),
|
|
447
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
448
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('key')),
|
|
449
|
+
tslib_1.__param(2, (0, type_graphql_1.Arg)('proof', type => shell_1.ScalarObject)),
|
|
450
|
+
tslib_1.__param(3, (0, type_graphql_1.Ctx)()),
|
|
451
|
+
tslib_1.__metadata("design:type", Function),
|
|
452
|
+
tslib_1.__metadata("design:paramtypes", [String, String, Object, Object]),
|
|
453
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
454
|
+
], SurveySecretResolver.prototype, "postSurveyTransportKey", null);
|
|
455
|
+
tslib_1.__decorate([
|
|
456
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-trustee", privilege: "mutation", domainOwnerGranted: true)'),
|
|
457
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
458
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Posts my dealing and a sealed share for every key holder' }),
|
|
459
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
460
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('dealing', type => shell_1.ScalarObject)),
|
|
461
|
+
tslib_1.__param(2, (0, type_graphql_1.Arg)('sealed', type => shell_1.ScalarObject)),
|
|
462
|
+
tslib_1.__param(3, (0, type_graphql_1.Ctx)()),
|
|
463
|
+
tslib_1.__metadata("design:type", Function),
|
|
464
|
+
tslib_1.__metadata("design:paramtypes", [String, Object, Object, Object]),
|
|
465
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
466
|
+
], SurveySecretResolver.prototype, "postSurveyDealing", null);
|
|
467
|
+
tslib_1.__decorate([
|
|
468
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-trustee", privilege: "mutation", domainOwnerGranted: true)'),
|
|
469
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
470
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Says every share sealed to me matched its dealer - my browser checked' }),
|
|
471
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
472
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
473
|
+
tslib_1.__metadata("design:type", Function),
|
|
474
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
475
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
476
|
+
], SurveySecretResolver.prototype, "confirmSurveyShares", null);
|
|
477
|
+
tslib_1.__decorate([
|
|
478
|
+
(0, type_graphql_1.Directive)('@privilege(category: "survey-trustee", privilege: "mutation", domainOwnerGranted: true)'),
|
|
479
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
480
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Posts my partial decryptions of the sums, with proofs' }),
|
|
481
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
482
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('partials', type => shell_1.ScalarObject)),
|
|
483
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
484
|
+
tslib_1.__metadata("design:type", Function),
|
|
485
|
+
tslib_1.__metadata("design:paramtypes", [String, Object, Object]),
|
|
486
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
487
|
+
], SurveySecretResolver.prototype, "postSurveyPartials", null);
|
|
488
|
+
exports.SurveySecretResolver = SurveySecretResolver = tslib_1.__decorate([
|
|
489
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals),
|
|
490
|
+
(0, type_graphql_1.Resolver)(survey_1.Survey)
|
|
491
|
+
], SurveySecretResolver);
|
|
492
|
+
//# sourceMappingURL=survey-resolver.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { User } from '@things-factory/auth-base';
|
|
2
|
+
import { Domain } from '@things-factory/shell';
|
|
3
|
+
import { Survey } from './survey';
|
|
4
|
+
export declare class SurveyRespondent {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
domain?: Domain;
|
|
7
|
+
domainId?: string;
|
|
8
|
+
survey?: Survey;
|
|
9
|
+
surveyId?: string;
|
|
10
|
+
user?: User;
|
|
11
|
+
userId?: string;
|
|
12
|
+
weightClass?: string;
|
|
13
|
+
taken: boolean;
|
|
14
|
+
createdAt?: Date;
|
|
15
|
+
creator?: User;
|
|
16
|
+
creatorId?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SurveyRespondent = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
8
|
+
const shell_1 = require("@things-factory/shell");
|
|
9
|
+
const survey_1 = require("./survey");
|
|
10
|
+
/*
|
|
11
|
+
* One person asked by a survey, with their weight class - the list is made once, when the survey opens (design §2-3).
|
|
12
|
+
* `taken` says they used their turn.
|
|
13
|
+
*
|
|
14
|
+
* No `updatedAt` and no `updater`: the only change after the list is made is `taken`, and its time would be the time a
|
|
15
|
+
* secret ballot was issued (charter §4-9 - the issue record keeps no time). The conventions test excuses the two.
|
|
16
|
+
*/
|
|
17
|
+
let SurveyRespondent = class SurveyRespondent {
|
|
18
|
+
};
|
|
19
|
+
exports.SurveyRespondent = SurveyRespondent;
|
|
20
|
+
tslib_1.__decorate([
|
|
21
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
22
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier' }),
|
|
23
|
+
tslib_1.__metadata("design:type", String)
|
|
24
|
+
], SurveyRespondent.prototype, "id", void 0);
|
|
25
|
+
tslib_1.__decorate([
|
|
26
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
27
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain' }),
|
|
28
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
29
|
+
], SurveyRespondent.prototype, "domain", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, typeorm_1.RelationId)((row) => row.domain),
|
|
32
|
+
tslib_1.__metadata("design:type", String)
|
|
33
|
+
], SurveyRespondent.prototype, "domainId", void 0);
|
|
34
|
+
tslib_1.__decorate([
|
|
35
|
+
(0, typeorm_1.ManyToOne)(type => survey_1.Survey, { onDelete: 'CASCADE' }),
|
|
36
|
+
tslib_1.__metadata("design:type", survey_1.Survey)
|
|
37
|
+
], SurveyRespondent.prototype, "survey", void 0);
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, typeorm_1.RelationId)((row) => row.survey),
|
|
40
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The survey' }),
|
|
41
|
+
tslib_1.__metadata("design:type", String)
|
|
42
|
+
], SurveyRespondent.prototype, "surveyId", void 0);
|
|
43
|
+
tslib_1.__decorate([
|
|
44
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User),
|
|
45
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
46
|
+
], SurveyRespondent.prototype, "user", void 0);
|
|
47
|
+
tslib_1.__decorate([
|
|
48
|
+
(0, typeorm_1.RelationId)((row) => row.user),
|
|
49
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The person asked' }),
|
|
50
|
+
tslib_1.__metadata("design:type", String)
|
|
51
|
+
], SurveyRespondent.prototype, "userId", void 0);
|
|
52
|
+
tslib_1.__decorate([
|
|
53
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
54
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Their weight class, when the survey is weighted' }),
|
|
55
|
+
tslib_1.__metadata("design:type", String)
|
|
56
|
+
], SurveyRespondent.prototype, "weightClass", void 0);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, typeorm_1.Column)({ default: false }),
|
|
59
|
+
(0, type_graphql_1.Field)({ description: 'Whether they used their turn' }),
|
|
60
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
61
|
+
], SurveyRespondent.prototype, "taken", void 0);
|
|
62
|
+
tslib_1.__decorate([
|
|
63
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
64
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When the list was made' }),
|
|
65
|
+
tslib_1.__metadata("design:type", Date)
|
|
66
|
+
], SurveyRespondent.prototype, "createdAt", void 0);
|
|
67
|
+
tslib_1.__decorate([
|
|
68
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
69
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who opened the survey' }),
|
|
70
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
71
|
+
], SurveyRespondent.prototype, "creator", void 0);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, typeorm_1.RelationId)((row) => row.creator),
|
|
74
|
+
tslib_1.__metadata("design:type", String)
|
|
75
|
+
], SurveyRespondent.prototype, "creatorId", void 0);
|
|
76
|
+
exports.SurveyRespondent = SurveyRespondent = tslib_1.__decorate([
|
|
77
|
+
(0, typeorm_1.Entity)({ name: 'survey_respondents' }),
|
|
78
|
+
(0, typeorm_1.Index)('ix_survey_respondent_0', (row) => [row.survey, row.user], { unique: true }),
|
|
79
|
+
(0, type_graphql_1.ObjectType)({ description: 'A person a survey asks, with their weight class and whether they used their turn' })
|
|
80
|
+
], SurveyRespondent);
|
|
81
|
+
//# sourceMappingURL=survey-respondent.js.map
|