@assemblis/contracts 0.0.10 → 0.0.11
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/index.js +1 -1
- package/dist/schemas.d.ts +378 -1503
- package/dist/types.d.ts +9 -3
- package/package.json +9 -6
- package/src/schemas.ts +177 -183
- package/src/types.ts +10 -3
- package/tsconfig.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { AssembliesListSchema, AssemblyDetailSchema, AssemblyOverviewSchema, FeedbackSchema, LogSchema, PinListSchema, PinSchema, RegisterSchema, SurveyResponseSchema, SurveySchema, UserSchema } from './schemas';
|
|
3
|
-
export declare enum
|
|
3
|
+
export declare enum ApiRestMethod {
|
|
4
4
|
GET = "GET",
|
|
5
5
|
POST = "POST",
|
|
6
6
|
PUT = "PUT",
|
|
7
7
|
PATCH = "PATCH"
|
|
8
8
|
}
|
|
9
|
-
export declare enum
|
|
9
|
+
export declare enum ApiRouteParameter {
|
|
10
10
|
ID = ":ID",
|
|
11
11
|
NAME = ":NAME"
|
|
12
12
|
}
|
|
13
|
-
export declare enum
|
|
13
|
+
export declare enum ApiEndpoint {
|
|
14
14
|
ASSEMBLIES = "/assemblies",
|
|
15
15
|
FEEDBACK = "/feedback",
|
|
16
16
|
INTEREST_ASSEMBLIS = "/interest/assemblis",
|
|
@@ -20,6 +20,12 @@ export declare enum Endpoint {
|
|
|
20
20
|
SURVEYS = "/surveys",
|
|
21
21
|
SURVEY_RESPONSES = "/assemblies/:ID/survey-responses/:NAME"
|
|
22
22
|
}
|
|
23
|
+
export declare enum SurveyName {
|
|
24
|
+
DELIBERATION = "deliberation",
|
|
25
|
+
DEMOGRAPHIC_DATA = "demographic-data",
|
|
26
|
+
PRE_ASSEMBLY = "pre-assembly",
|
|
27
|
+
POST_ASSEMBLY = "post-assembly"
|
|
28
|
+
}
|
|
23
29
|
export type AssemblyDetailPayload = z.infer<(typeof AssemblyDetailSchema)['payload']>;
|
|
24
30
|
export type AssemblyOverviewPayload = z.infer<(typeof AssemblyOverviewSchema)['payload']>;
|
|
25
31
|
export type AssembliesListPayload = z.infer<(typeof AssembliesListSchema)['payload']>;
|
package/package.json
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assemblis/contracts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@rollup/plugin-terser": "^0.4.4",
|
|
10
|
-
"@rollup/plugin-typescript": "^
|
|
11
|
-
"rollup": "^4.
|
|
12
|
-
"typescript": "^5.
|
|
10
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
11
|
+
"rollup": "^4.57.1",
|
|
12
|
+
"typescript": "^5.9.3"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"zod": "^3.
|
|
15
|
+
"zod": "^4.3.6"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "rollup --config rollup.config.ts --configPlugin typescript -o 'dist/index.js' src/index.ts",
|
|
19
|
-
"clean": "rm -rf ./dist"
|
|
19
|
+
"clean": "rm -rf ./dist",
|
|
20
|
+
"lint": "eslint .",
|
|
21
|
+
"format": "prettier --plugin-search-dir . --write .",
|
|
22
|
+
"typecheck": "tsc --noEmit"
|
|
20
23
|
}
|
|
21
24
|
}
|
package/src/schemas.ts
CHANGED
|
@@ -1,161 +1,154 @@
|
|
|
1
|
-
import {
|
|
2
|
-
boolean,
|
|
3
|
-
coerce,
|
|
4
|
-
literal,
|
|
5
|
-
number,
|
|
6
|
-
object,
|
|
7
|
-
record,
|
|
8
|
-
string,
|
|
9
|
-
unknown,
|
|
10
|
-
undefined,
|
|
11
|
-
type ZodType
|
|
12
|
-
} from 'zod';
|
|
1
|
+
import z, {type ZodType} from "zod";
|
|
13
2
|
|
|
14
|
-
const coercedDate = coerce.date;
|
|
15
3
|
const maybe = <T extends ZodType<unknown>>(_: T) =>
|
|
16
4
|
_.nullish().transform((_) => _ ?? null);
|
|
17
5
|
|
|
18
|
-
const OptionSchema = object({
|
|
6
|
+
const OptionSchema = z.object({
|
|
7
|
+
label: z.string(),
|
|
8
|
+
value: z.coerce.number().int()
|
|
9
|
+
});
|
|
19
10
|
|
|
20
11
|
export const UserSchema = {
|
|
21
|
-
payload: undefined(),
|
|
22
|
-
response: object({
|
|
23
|
-
id: string().uuid(),
|
|
24
|
-
created_at:
|
|
25
|
-
updated_at:
|
|
26
|
-
sub: string(),
|
|
27
|
-
is_mutirao: boolean()
|
|
12
|
+
payload: z.undefined(),
|
|
13
|
+
response: z.object({
|
|
14
|
+
id: z.string().uuid(),
|
|
15
|
+
created_at: z.coerce.date(),
|
|
16
|
+
updated_at: z.coerce.date(),
|
|
17
|
+
sub: z.string(),
|
|
18
|
+
is_mutirao: z.boolean()
|
|
28
19
|
})
|
|
29
20
|
};
|
|
30
21
|
|
|
31
22
|
// Surveys
|
|
32
|
-
const SurveyQuestionSchema = object({
|
|
33
|
-
id: string().uuid(),
|
|
34
|
-
text: string()
|
|
23
|
+
const SurveyQuestionSchema = z.object({
|
|
24
|
+
id: z.string().uuid(),
|
|
25
|
+
text: z.string()
|
|
35
26
|
});
|
|
36
27
|
|
|
37
28
|
export const SurveySchema = {
|
|
38
|
-
payload: undefined(),
|
|
39
|
-
response: object({
|
|
40
|
-
id: string().uuid(),
|
|
41
|
-
created_at:
|
|
42
|
-
updated_at:
|
|
43
|
-
name: string(),
|
|
44
|
-
sections: object({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
payload: z.undefined(),
|
|
30
|
+
response: z.object({
|
|
31
|
+
id: z.string().uuid(),
|
|
32
|
+
created_at: z.coerce.date(),
|
|
33
|
+
updated_at: z.coerce.date(),
|
|
34
|
+
name: z.string(),
|
|
35
|
+
sections: z.object({
|
|
36
|
+
primary: SurveyQuestionSchema,
|
|
37
|
+
secondary: SurveyQuestionSchema.array(),
|
|
38
|
+
options: OptionSchema.array()
|
|
39
|
+
})
|
|
40
|
+
.array()
|
|
49
41
|
})
|
|
50
42
|
};
|
|
51
43
|
|
|
52
44
|
export const SurveyResponseSchema = {
|
|
53
|
-
payload: object({
|
|
54
|
-
answers: object({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
payload: z.object({
|
|
46
|
+
answers: z.object({
|
|
47
|
+
question_id: z.string().uuid(),
|
|
48
|
+
answer_value: z.coerce.number().int()
|
|
49
|
+
})
|
|
50
|
+
.array()
|
|
58
51
|
}),
|
|
59
|
-
response: object({
|
|
60
|
-
total: number().int()
|
|
52
|
+
response: z.object({
|
|
53
|
+
total: z.number().int()
|
|
61
54
|
})
|
|
62
55
|
};
|
|
63
56
|
|
|
64
57
|
// Action Plans
|
|
65
|
-
const ActionPlanSchema = object({
|
|
66
|
-
visible_on_profile: boolean(),
|
|
67
|
-
description: maybe(string())
|
|
58
|
+
const ActionPlanSchema = z.object({
|
|
59
|
+
visible_on_profile: z.boolean(),
|
|
60
|
+
description: maybe(z.string())
|
|
68
61
|
});
|
|
69
62
|
|
|
70
|
-
const ActionSchema = object({
|
|
71
|
-
text: string(),
|
|
72
|
-
agreed: maybe(coerce.number().int()),
|
|
73
|
-
against: maybe(coerce.number().int()),
|
|
74
|
-
abstained: maybe(coerce.number().int()),
|
|
75
|
-
include_in_action_plan: boolean().default(true),
|
|
76
|
-
assembly_id: string().uuid()
|
|
63
|
+
const ActionSchema = z.object({
|
|
64
|
+
text: z.string(),
|
|
65
|
+
agreed: maybe(z.coerce.number().int()),
|
|
66
|
+
against: maybe(z.coerce.number().int()),
|
|
67
|
+
abstained: maybe(z.coerce.number().int()),
|
|
68
|
+
include_in_action_plan: z.boolean().default(true),
|
|
69
|
+
assembly_id: z.string().uuid()
|
|
77
70
|
});
|
|
78
71
|
|
|
79
|
-
const TaskSchema = object({
|
|
80
|
-
text: string(),
|
|
81
|
-
complete: boolean().default(false),
|
|
82
|
-
action_id: string().uuid(),
|
|
83
|
-
assembly_id: string().uuid()
|
|
72
|
+
const TaskSchema = z.object({
|
|
73
|
+
text: z.string(),
|
|
74
|
+
complete: z.boolean().default(false),
|
|
75
|
+
action_id: z.string().uuid(),
|
|
76
|
+
assembly_id: z.string().uuid()
|
|
84
77
|
});
|
|
85
78
|
|
|
86
79
|
// Assembly Overviews
|
|
87
|
-
const BaseAssemblyOverviewSchema = object({
|
|
88
|
-
published_at: maybe(
|
|
89
|
-
name: string(),
|
|
90
|
-
about: maybe(string()),
|
|
91
|
-
topics: string().array(),
|
|
92
|
-
country: maybe(string()),
|
|
93
|
-
hide: boolean().default(false)
|
|
80
|
+
const BaseAssemblyOverviewSchema = z.object({
|
|
81
|
+
published_at: maybe(z.coerce.date()),
|
|
82
|
+
name: z.string(),
|
|
83
|
+
about: maybe(z.string()),
|
|
84
|
+
topics: z.string().array(),
|
|
85
|
+
country: maybe(z.string()),
|
|
86
|
+
hide: z.boolean().default(false)
|
|
94
87
|
});
|
|
95
88
|
export const AssemblyOverviewSchema = {
|
|
96
89
|
payload: BaseAssemblyOverviewSchema,
|
|
97
90
|
response: BaseAssemblyOverviewSchema.extend({
|
|
98
|
-
id: string().uuid(),
|
|
99
|
-
created_at:
|
|
100
|
-
updated_at:
|
|
101
|
-
has_image: boolean(),
|
|
102
|
-
image_src: maybe(string())
|
|
91
|
+
id: z.string().uuid(),
|
|
92
|
+
created_at: z.coerce.date(),
|
|
93
|
+
updated_at: z.coerce.date(),
|
|
94
|
+
has_image: z.boolean(),
|
|
95
|
+
image_src: maybe(z.string())
|
|
103
96
|
})
|
|
104
97
|
};
|
|
105
98
|
export const AssembliesListSchema = {
|
|
106
|
-
payload: undefined(),
|
|
107
|
-
response: object({
|
|
99
|
+
payload: z.undefined(),
|
|
100
|
+
response: z.object({
|
|
108
101
|
assemblies: AssemblyOverviewSchema.response.array()
|
|
109
102
|
})
|
|
110
103
|
};
|
|
111
104
|
|
|
112
105
|
// Assembly Details
|
|
113
|
-
const OrganisationSchema = object({
|
|
114
|
-
visible_on_profile: boolean(),
|
|
115
|
-
name: maybe(string()),
|
|
116
|
-
description: maybe(string()),
|
|
117
|
-
type: maybe(string())
|
|
106
|
+
const OrganisationSchema = z.object({
|
|
107
|
+
visible_on_profile: z.boolean(),
|
|
108
|
+
name: maybe(z.string()),
|
|
109
|
+
description: maybe(z.string()),
|
|
110
|
+
type: maybe(z.string())
|
|
118
111
|
});
|
|
119
|
-
const EventDetailsSchema = object({
|
|
120
|
-
visible_on_profile: boolean(),
|
|
121
|
-
registration_link: maybe(string()),
|
|
122
|
-
start_date: maybe(
|
|
112
|
+
const EventDetailsSchema = z.object({
|
|
113
|
+
visible_on_profile: z.boolean(),
|
|
114
|
+
registration_link: maybe(z.string()),
|
|
115
|
+
start_date: maybe(z.coerce.date())
|
|
123
116
|
});
|
|
124
|
-
const StorySchema = object({
|
|
125
|
-
visible_on_profile: boolean(),
|
|
126
|
-
background: maybe(string())
|
|
117
|
+
const StorySchema = z.object({
|
|
118
|
+
visible_on_profile: z.boolean(),
|
|
119
|
+
background: maybe(z.string())
|
|
127
120
|
});
|
|
128
|
-
const SupportersSchema = object({
|
|
129
|
-
visible_on_profile: boolean(),
|
|
130
|
-
organisation_types: string().array(),
|
|
131
|
-
description: maybe(string())
|
|
121
|
+
const SupportersSchema = z.object({
|
|
122
|
+
visible_on_profile: z.boolean(),
|
|
123
|
+
organisation_types: z.string().array(),
|
|
124
|
+
description: maybe(z.string())
|
|
132
125
|
});
|
|
133
|
-
const FundersSchema = object({
|
|
134
|
-
visible_on_profile: boolean(),
|
|
135
|
-
organisation_types: string().array(),
|
|
136
|
-
description: maybe(string())
|
|
126
|
+
const FundersSchema = z.object({
|
|
127
|
+
visible_on_profile: z.boolean(),
|
|
128
|
+
organisation_types: z.string().array(),
|
|
129
|
+
description: maybe(z.string())
|
|
137
130
|
});
|
|
138
|
-
const FacilitationSchema = object({
|
|
139
|
-
visible_on_profile: boolean(),
|
|
140
|
-
decision_method: maybe(string())
|
|
131
|
+
const FacilitationSchema = z.object({
|
|
132
|
+
visible_on_profile: z.boolean(),
|
|
133
|
+
decision_method: maybe(z.string())
|
|
141
134
|
});
|
|
142
|
-
const ParticipantsSchema = object({
|
|
143
|
-
visible_on_profile: boolean(),
|
|
144
|
-
recruitment_method: maybe(string()),
|
|
145
|
-
community: maybe(string())
|
|
135
|
+
const ParticipantsSchema = z.object({
|
|
136
|
+
visible_on_profile: z.boolean(),
|
|
137
|
+
recruitment_method: maybe(z.string()),
|
|
138
|
+
community: maybe(z.string())
|
|
146
139
|
});
|
|
147
|
-
const SupportSchema = object({
|
|
148
|
-
visible_on_profile: boolean(),
|
|
149
|
-
support_options: string().array()
|
|
140
|
+
const SupportSchema = z.object({
|
|
141
|
+
visible_on_profile: z.boolean(),
|
|
142
|
+
support_options: z.string().array()
|
|
150
143
|
});
|
|
151
|
-
const SurveyDetailsSchema = object({
|
|
152
|
-
visible_on_profile: boolean()
|
|
144
|
+
const SurveyDetailsSchema = z.object({
|
|
145
|
+
visible_on_profile: z.boolean()
|
|
153
146
|
});
|
|
154
147
|
export const AssemblyDetailSchema = {
|
|
155
148
|
payload: AssemblyOverviewSchema.payload.extend({
|
|
156
149
|
organisation: maybe(
|
|
157
150
|
OrganisationSchema.extend({
|
|
158
|
-
id: string().uuid().optional()
|
|
151
|
+
id: z.string().uuid().optional()
|
|
159
152
|
})
|
|
160
153
|
),
|
|
161
154
|
event_details: maybe(EventDetailsSchema),
|
|
@@ -169,116 +162,116 @@ export const AssemblyDetailSchema = {
|
|
|
169
162
|
ActionPlanSchema.extend({
|
|
170
163
|
actions: ActionSchema.omit({ assembly_id: true })
|
|
171
164
|
.extend({
|
|
172
|
-
id: string().uuid().optional(),
|
|
165
|
+
id: z.string().uuid().optional(),
|
|
173
166
|
tasks: TaskSchema.omit({
|
|
174
167
|
action_id: true,
|
|
175
168
|
assembly_id: true
|
|
176
169
|
})
|
|
177
170
|
.extend({
|
|
178
|
-
id: string().uuid().optional()
|
|
171
|
+
id: z.string().uuid().optional()
|
|
179
172
|
})
|
|
180
173
|
.array(),
|
|
181
|
-
updates: unknown().array()
|
|
174
|
+
updates: z.unknown().array()
|
|
182
175
|
})
|
|
183
176
|
.array(),
|
|
184
|
-
updates: unknown().array()
|
|
177
|
+
updates: z.unknown().array()
|
|
185
178
|
})
|
|
186
179
|
),
|
|
187
180
|
surveys: maybe(SurveyDetailsSchema)
|
|
188
181
|
}),
|
|
189
182
|
response: AssemblyOverviewSchema.response.extend({
|
|
190
|
-
is_own: boolean(),
|
|
183
|
+
is_own: z.boolean(),
|
|
191
184
|
organisation: maybe(
|
|
192
185
|
OrganisationSchema.extend({
|
|
193
|
-
id: string().uuid(),
|
|
194
|
-
created_at:
|
|
195
|
-
updated_at:
|
|
186
|
+
id: z.string().uuid(),
|
|
187
|
+
created_at: z.coerce.date(),
|
|
188
|
+
updated_at: z.coerce.date()
|
|
196
189
|
})
|
|
197
190
|
),
|
|
198
191
|
event_details: maybe(
|
|
199
192
|
EventDetailsSchema.extend({
|
|
200
|
-
created_at:
|
|
201
|
-
updated_at:
|
|
193
|
+
created_at: z.coerce.date(),
|
|
194
|
+
updated_at: z.coerce.date()
|
|
202
195
|
})
|
|
203
196
|
),
|
|
204
197
|
story: maybe(
|
|
205
198
|
StorySchema.extend({
|
|
206
|
-
created_at:
|
|
207
|
-
updated_at:
|
|
199
|
+
created_at: z.coerce.date(),
|
|
200
|
+
updated_at: z.coerce.date()
|
|
208
201
|
})
|
|
209
202
|
),
|
|
210
203
|
supporters: maybe(
|
|
211
204
|
SupportersSchema.extend({
|
|
212
|
-
created_at:
|
|
213
|
-
updated_at:
|
|
205
|
+
created_at: z.coerce.date(),
|
|
206
|
+
updated_at: z.coerce.date()
|
|
214
207
|
})
|
|
215
208
|
),
|
|
216
209
|
funders: maybe(
|
|
217
210
|
FundersSchema.extend({
|
|
218
|
-
created_at:
|
|
219
|
-
updated_at:
|
|
211
|
+
created_at: z.coerce.date(),
|
|
212
|
+
updated_at: z.coerce.date()
|
|
220
213
|
})
|
|
221
214
|
),
|
|
222
215
|
facilitation: maybe(
|
|
223
216
|
FacilitationSchema.extend({
|
|
224
|
-
created_at:
|
|
225
|
-
updated_at:
|
|
217
|
+
created_at: z.coerce.date(),
|
|
218
|
+
updated_at: z.coerce.date()
|
|
226
219
|
})
|
|
227
220
|
),
|
|
228
221
|
participants: maybe(
|
|
229
222
|
ParticipantsSchema.extend({
|
|
230
|
-
created_at:
|
|
231
|
-
updated_at:
|
|
223
|
+
created_at: z.coerce.date(),
|
|
224
|
+
updated_at: z.coerce.date()
|
|
232
225
|
})
|
|
233
226
|
),
|
|
234
227
|
support: maybe(
|
|
235
228
|
SupportSchema.extend({
|
|
236
|
-
created_at:
|
|
237
|
-
updated_at:
|
|
229
|
+
created_at: z.coerce.date(),
|
|
230
|
+
updated_at: z.coerce.date()
|
|
238
231
|
})
|
|
239
232
|
),
|
|
240
233
|
action_plan: maybe(
|
|
241
234
|
ActionPlanSchema.extend({
|
|
242
235
|
actions: ActionSchema.omit({ assembly_id: true })
|
|
243
236
|
.extend({
|
|
244
|
-
id: string().uuid(),
|
|
245
|
-
created_at:
|
|
246
|
-
updated_at:
|
|
237
|
+
id: z.string().uuid(),
|
|
238
|
+
created_at: z.coerce.date(),
|
|
239
|
+
updated_at: z.coerce.date(),
|
|
247
240
|
tasks: TaskSchema.omit({
|
|
248
241
|
action_id: true,
|
|
249
242
|
assembly_id: true
|
|
250
243
|
})
|
|
251
244
|
.extend({
|
|
252
|
-
id: string().uuid(),
|
|
253
|
-
created_at:
|
|
254
|
-
updated_at:
|
|
245
|
+
id: z.string().uuid(),
|
|
246
|
+
created_at: z.coerce.date(),
|
|
247
|
+
updated_at: z.coerce.date()
|
|
255
248
|
})
|
|
256
249
|
.array(),
|
|
257
|
-
updates: unknown().array()
|
|
250
|
+
updates: z.unknown().array()
|
|
258
251
|
})
|
|
259
252
|
.extend({
|
|
260
|
-
created_at:
|
|
261
|
-
updated_at:
|
|
253
|
+
created_at: z.coerce.date(),
|
|
254
|
+
updated_at: z.coerce.date()
|
|
262
255
|
})
|
|
263
256
|
.array(),
|
|
264
|
-
updates: unknown().array()
|
|
257
|
+
updates: z.unknown().array()
|
|
265
258
|
}).and(
|
|
266
|
-
object({
|
|
267
|
-
created_at:
|
|
268
|
-
updated_at:
|
|
259
|
+
z.object({
|
|
260
|
+
created_at: z.coerce.date(),
|
|
261
|
+
updated_at: z.coerce.date()
|
|
269
262
|
})
|
|
270
263
|
)
|
|
271
264
|
),
|
|
272
265
|
surveys: maybe(
|
|
273
266
|
SurveyDetailsSchema.extend({
|
|
274
|
-
created_at:
|
|
275
|
-
updated_at:
|
|
267
|
+
created_at: z.coerce.date(),
|
|
268
|
+
updated_at: z.coerce.date()
|
|
276
269
|
}).extend({
|
|
277
|
-
data: record(
|
|
278
|
-
string(),
|
|
279
|
-
object({
|
|
280
|
-
total: number().int(),
|
|
281
|
-
responses: record(string(), OptionSchema.array())
|
|
270
|
+
data: z.record(
|
|
271
|
+
z.string(),
|
|
272
|
+
z.object({
|
|
273
|
+
total: z.number().int(),
|
|
274
|
+
responses: z.record(z.string(), OptionSchema.array())
|
|
282
275
|
})
|
|
283
276
|
)
|
|
284
277
|
})
|
|
@@ -287,61 +280,62 @@ export const AssemblyDetailSchema = {
|
|
|
287
280
|
};
|
|
288
281
|
|
|
289
282
|
export const FeedbackSchema = {
|
|
290
|
-
payload: object({
|
|
291
|
-
route: string(),
|
|
292
|
-
text: string(),
|
|
293
|
-
metadata: unknown()
|
|
283
|
+
payload: z.object({
|
|
284
|
+
route: z.string(),
|
|
285
|
+
text: z.string(),
|
|
286
|
+
metadata: z.unknown()
|
|
294
287
|
}),
|
|
295
|
-
response: string()
|
|
288
|
+
response: z.string()
|
|
296
289
|
};
|
|
297
290
|
|
|
298
291
|
export const LogSchema = {
|
|
299
|
-
payload: object({
|
|
300
|
-
message: string().optional(),
|
|
301
|
-
data: record(string(), string().optional()).optional(),
|
|
302
|
-
metadata: object({
|
|
303
|
-
origin: string(),
|
|
304
|
-
route: string(),
|
|
305
|
-
status: number()
|
|
292
|
+
payload: z.object({
|
|
293
|
+
message: z.string().optional(),
|
|
294
|
+
data: z.record(z.string(), z.string().optional()).optional(),
|
|
295
|
+
metadata: z.object({
|
|
296
|
+
origin: z.string(),
|
|
297
|
+
route: z.string(),
|
|
298
|
+
status: z.number()
|
|
306
299
|
})
|
|
307
300
|
}),
|
|
308
|
-
response: string()
|
|
301
|
+
response: z.string()
|
|
309
302
|
};
|
|
310
303
|
|
|
311
304
|
export const RegisterSchema = {
|
|
312
|
-
payload: object({
|
|
313
|
-
type: literal('user.created'),
|
|
314
|
-
object: literal('event'),
|
|
315
|
-
data: object({
|
|
316
|
-
id: string(),
|
|
317
|
-
email_addresses: object({
|
|
318
|
-
|
|
319
|
-
|
|
305
|
+
payload: z.object({
|
|
306
|
+
type: z.literal('user.created'),
|
|
307
|
+
object: z.literal('event'),
|
|
308
|
+
data: z.object({
|
|
309
|
+
id: z.string(),
|
|
310
|
+
email_addresses: z.object({
|
|
311
|
+
email_address: z.string()
|
|
312
|
+
})
|
|
313
|
+
.array()
|
|
320
314
|
})
|
|
321
315
|
}),
|
|
322
|
-
response: string()
|
|
316
|
+
response: z.string()
|
|
323
317
|
};
|
|
324
318
|
|
|
325
319
|
export const PinSchema = {
|
|
326
|
-
payload: object({
|
|
327
|
-
country: string(),
|
|
328
|
-
email: string(),
|
|
329
|
-
text: maybe(string())
|
|
320
|
+
payload: z.object({
|
|
321
|
+
country: z.string(),
|
|
322
|
+
email: z.string(),
|
|
323
|
+
text: maybe(z.string())
|
|
330
324
|
}),
|
|
331
|
-
response: object({
|
|
332
|
-
id: string().uuid(),
|
|
333
|
-
created_at:
|
|
334
|
-
updated_at:
|
|
335
|
-
country: string(),
|
|
336
|
-
text: maybe(string()),
|
|
337
|
-
hide: boolean(),
|
|
338
|
-
has_image: boolean(),
|
|
339
|
-
image_src: maybe(string())
|
|
325
|
+
response: z.object({
|
|
326
|
+
id: z.string().uuid(),
|
|
327
|
+
created_at: z.coerce.date(),
|
|
328
|
+
updated_at: z.coerce.date(),
|
|
329
|
+
country: z.string(),
|
|
330
|
+
text: maybe(z.string()),
|
|
331
|
+
hide: z.boolean(),
|
|
332
|
+
has_image: z.boolean(),
|
|
333
|
+
image_src: maybe(z.string())
|
|
340
334
|
})
|
|
341
335
|
};
|
|
342
336
|
export const PinListSchema = {
|
|
343
|
-
payload: undefined(),
|
|
344
|
-
response: object({
|
|
337
|
+
payload: z.undefined(),
|
|
338
|
+
response: z.object({
|
|
345
339
|
assemblies: AssemblyOverviewSchema.response.array(),
|
|
346
340
|
pins: PinSchema.response.array()
|
|
347
341
|
})
|
package/src/types.ts
CHANGED
|
@@ -13,19 +13,19 @@ import {
|
|
|
13
13
|
UserSchema
|
|
14
14
|
} from './schemas';
|
|
15
15
|
|
|
16
|
-
export enum
|
|
16
|
+
export enum ApiRestMethod {
|
|
17
17
|
GET = 'GET',
|
|
18
18
|
POST = 'POST',
|
|
19
19
|
PUT = 'PUT',
|
|
20
20
|
PATCH = 'PATCH'
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export enum
|
|
23
|
+
export enum ApiRouteParameter {
|
|
24
24
|
ID = ':ID',
|
|
25
25
|
NAME = ':NAME'
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export enum
|
|
28
|
+
export enum ApiEndpoint {
|
|
29
29
|
ASSEMBLIES = '/assemblies',
|
|
30
30
|
FEEDBACK = '/feedback',
|
|
31
31
|
INTEREST_ASSEMBLIS = '/interest/assemblis',
|
|
@@ -36,6 +36,13 @@ export enum Endpoint {
|
|
|
36
36
|
SURVEY_RESPONSES = '/assemblies/:ID/survey-responses/:NAME'
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export enum SurveyName {
|
|
40
|
+
DELIBERATION = 'deliberation',
|
|
41
|
+
DEMOGRAPHIC_DATA = 'demographic-data',
|
|
42
|
+
PRE_ASSEMBLY = 'pre-assembly',
|
|
43
|
+
POST_ASSEMBLY = 'post-assembly'
|
|
44
|
+
}
|
|
45
|
+
|
|
39
46
|
export type AssemblyDetailPayload = z.infer<
|
|
40
47
|
(typeof AssemblyDetailSchema)['payload']
|
|
41
48
|
>;
|