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