@assemblis/contracts 0.0.9 → 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 -2
- package/dist/schemas.d.ts +378 -1503
- package/dist/types.d.ts +9 -3
- package/package.json +11 -5
- package/rollup.config.ts +10 -0
- package/src/schemas.ts +177 -183
- package/src/types.ts +10 -3
- package/tsconfig.json +0 -1
- package/dist/schemas.js +0 -292
- package/dist/types.js +0 -23
package/dist/schemas.js
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import { boolean, coerce, literal, number, object, record, string, unknown, undefined } from 'zod';
|
|
2
|
-
const coercedDate = coerce.date;
|
|
3
|
-
const maybe = (_) => _.nullish().transform((_) => _ ?? null);
|
|
4
|
-
const OptionSchema = object({ label: string(), value: coerce.number().int() });
|
|
5
|
-
export const UserSchema = {
|
|
6
|
-
payload: undefined(),
|
|
7
|
-
response: object({
|
|
8
|
-
id: string().uuid(),
|
|
9
|
-
created_at: coercedDate(),
|
|
10
|
-
updated_at: coercedDate(),
|
|
11
|
-
sub: string(),
|
|
12
|
-
is_mutirao: boolean()
|
|
13
|
-
})
|
|
14
|
-
};
|
|
15
|
-
// Surveys
|
|
16
|
-
const SurveyQuestionSchema = object({
|
|
17
|
-
id: string().uuid(),
|
|
18
|
-
text: string()
|
|
19
|
-
});
|
|
20
|
-
export const SurveySchema = {
|
|
21
|
-
payload: undefined(),
|
|
22
|
-
response: object({
|
|
23
|
-
id: string().uuid(),
|
|
24
|
-
created_at: coercedDate(),
|
|
25
|
-
updated_at: coercedDate(),
|
|
26
|
-
name: string(),
|
|
27
|
-
sections: object({
|
|
28
|
-
primary: SurveyQuestionSchema,
|
|
29
|
-
secondary: SurveyQuestionSchema.array(),
|
|
30
|
-
options: OptionSchema.array()
|
|
31
|
-
}).array()
|
|
32
|
-
})
|
|
33
|
-
};
|
|
34
|
-
export const SurveyResponseSchema = {
|
|
35
|
-
payload: object({
|
|
36
|
-
answers: object({
|
|
37
|
-
question_id: string().uuid(),
|
|
38
|
-
answer_value: coerce.number().int()
|
|
39
|
-
}).array()
|
|
40
|
-
}),
|
|
41
|
-
response: object({
|
|
42
|
-
total: number().int()
|
|
43
|
-
})
|
|
44
|
-
};
|
|
45
|
-
// Action Plans
|
|
46
|
-
const ActionPlanSchema = object({
|
|
47
|
-
visible_on_profile: boolean(),
|
|
48
|
-
description: maybe(string())
|
|
49
|
-
});
|
|
50
|
-
const ActionSchema = object({
|
|
51
|
-
text: string(),
|
|
52
|
-
agreed: maybe(coerce.number().int()),
|
|
53
|
-
against: maybe(coerce.number().int()),
|
|
54
|
-
abstained: maybe(coerce.number().int()),
|
|
55
|
-
include_in_action_plan: boolean().default(true),
|
|
56
|
-
assembly_id: string().uuid()
|
|
57
|
-
});
|
|
58
|
-
const TaskSchema = object({
|
|
59
|
-
text: string(),
|
|
60
|
-
complete: boolean().default(false),
|
|
61
|
-
action_id: string().uuid(),
|
|
62
|
-
assembly_id: string().uuid()
|
|
63
|
-
});
|
|
64
|
-
// Assembly Overviews
|
|
65
|
-
const BaseAssemblyOverviewSchema = object({
|
|
66
|
-
published_at: maybe(coercedDate()),
|
|
67
|
-
name: string(),
|
|
68
|
-
about: maybe(string()),
|
|
69
|
-
topics: string().array(),
|
|
70
|
-
country: maybe(string()),
|
|
71
|
-
hide: boolean().default(false)
|
|
72
|
-
});
|
|
73
|
-
export const AssemblyOverviewSchema = {
|
|
74
|
-
payload: BaseAssemblyOverviewSchema,
|
|
75
|
-
response: BaseAssemblyOverviewSchema.extend({
|
|
76
|
-
id: string().uuid(),
|
|
77
|
-
created_at: coercedDate(),
|
|
78
|
-
updated_at: coercedDate(),
|
|
79
|
-
has_image: boolean(),
|
|
80
|
-
image_src: maybe(string())
|
|
81
|
-
})
|
|
82
|
-
};
|
|
83
|
-
export const AssembliesListSchema = {
|
|
84
|
-
payload: undefined(),
|
|
85
|
-
response: object({
|
|
86
|
-
assemblies: AssemblyOverviewSchema.response.array()
|
|
87
|
-
})
|
|
88
|
-
};
|
|
89
|
-
// Assembly Details
|
|
90
|
-
const OrganisationSchema = object({
|
|
91
|
-
visible_on_profile: boolean(),
|
|
92
|
-
name: maybe(string()),
|
|
93
|
-
description: maybe(string()),
|
|
94
|
-
type: maybe(string())
|
|
95
|
-
});
|
|
96
|
-
const EventDetailsSchema = object({
|
|
97
|
-
visible_on_profile: boolean(),
|
|
98
|
-
registration_link: maybe(string()),
|
|
99
|
-
start_date: maybe(coercedDate())
|
|
100
|
-
});
|
|
101
|
-
const StorySchema = object({
|
|
102
|
-
visible_on_profile: boolean(),
|
|
103
|
-
background: maybe(string())
|
|
104
|
-
});
|
|
105
|
-
const SupportersSchema = object({
|
|
106
|
-
visible_on_profile: boolean(),
|
|
107
|
-
organisation_types: string().array(),
|
|
108
|
-
description: maybe(string())
|
|
109
|
-
});
|
|
110
|
-
const FundersSchema = object({
|
|
111
|
-
visible_on_profile: boolean(),
|
|
112
|
-
organisation_types: string().array(),
|
|
113
|
-
description: maybe(string())
|
|
114
|
-
});
|
|
115
|
-
const FacilitationSchema = object({
|
|
116
|
-
visible_on_profile: boolean(),
|
|
117
|
-
decision_method: maybe(string())
|
|
118
|
-
});
|
|
119
|
-
const ParticipantsSchema = object({
|
|
120
|
-
visible_on_profile: boolean(),
|
|
121
|
-
recruitment_method: maybe(string()),
|
|
122
|
-
community: maybe(string())
|
|
123
|
-
});
|
|
124
|
-
const SupportSchema = object({
|
|
125
|
-
visible_on_profile: boolean(),
|
|
126
|
-
support_options: string().array()
|
|
127
|
-
});
|
|
128
|
-
const SurveyDetailsSchema = object({
|
|
129
|
-
visible_on_profile: boolean()
|
|
130
|
-
});
|
|
131
|
-
export const AssemblyDetailSchema = {
|
|
132
|
-
payload: AssemblyOverviewSchema.payload.extend({
|
|
133
|
-
organisation: maybe(OrganisationSchema.extend({
|
|
134
|
-
id: string().uuid().optional()
|
|
135
|
-
})),
|
|
136
|
-
event_details: maybe(EventDetailsSchema),
|
|
137
|
-
story: maybe(StorySchema),
|
|
138
|
-
supporters: maybe(SupportersSchema),
|
|
139
|
-
funders: maybe(FundersSchema),
|
|
140
|
-
facilitation: maybe(FacilitationSchema),
|
|
141
|
-
participants: maybe(ParticipantsSchema),
|
|
142
|
-
support: maybe(SupportSchema),
|
|
143
|
-
action_plan: maybe(ActionPlanSchema.extend({
|
|
144
|
-
actions: ActionSchema.omit({ assembly_id: true })
|
|
145
|
-
.extend({
|
|
146
|
-
id: string().uuid().optional(),
|
|
147
|
-
tasks: TaskSchema.omit({
|
|
148
|
-
action_id: true,
|
|
149
|
-
assembly_id: true
|
|
150
|
-
})
|
|
151
|
-
.extend({
|
|
152
|
-
id: string().uuid().optional()
|
|
153
|
-
})
|
|
154
|
-
.array(),
|
|
155
|
-
updates: unknown().array()
|
|
156
|
-
})
|
|
157
|
-
.array(),
|
|
158
|
-
updates: unknown().array()
|
|
159
|
-
})),
|
|
160
|
-
surveys: maybe(SurveyDetailsSchema)
|
|
161
|
-
}),
|
|
162
|
-
response: AssemblyOverviewSchema.response.extend({
|
|
163
|
-
is_own: boolean(),
|
|
164
|
-
organisation: maybe(OrganisationSchema.extend({
|
|
165
|
-
id: string().uuid(),
|
|
166
|
-
created_at: coercedDate(),
|
|
167
|
-
updated_at: coercedDate()
|
|
168
|
-
})),
|
|
169
|
-
event_details: maybe(EventDetailsSchema.extend({
|
|
170
|
-
created_at: coercedDate(),
|
|
171
|
-
updated_at: coercedDate()
|
|
172
|
-
})),
|
|
173
|
-
story: maybe(StorySchema.extend({
|
|
174
|
-
created_at: coercedDate(),
|
|
175
|
-
updated_at: coercedDate()
|
|
176
|
-
})),
|
|
177
|
-
supporters: maybe(SupportersSchema.extend({
|
|
178
|
-
created_at: coercedDate(),
|
|
179
|
-
updated_at: coercedDate()
|
|
180
|
-
})),
|
|
181
|
-
funders: maybe(FundersSchema.extend({
|
|
182
|
-
created_at: coercedDate(),
|
|
183
|
-
updated_at: coercedDate()
|
|
184
|
-
})),
|
|
185
|
-
facilitation: maybe(FacilitationSchema.extend({
|
|
186
|
-
created_at: coercedDate(),
|
|
187
|
-
updated_at: coercedDate()
|
|
188
|
-
})),
|
|
189
|
-
participants: maybe(ParticipantsSchema.extend({
|
|
190
|
-
created_at: coercedDate(),
|
|
191
|
-
updated_at: coercedDate()
|
|
192
|
-
})),
|
|
193
|
-
support: maybe(SupportSchema.extend({
|
|
194
|
-
created_at: coercedDate(),
|
|
195
|
-
updated_at: coercedDate()
|
|
196
|
-
})),
|
|
197
|
-
action_plan: maybe(ActionPlanSchema.extend({
|
|
198
|
-
actions: ActionSchema.omit({ assembly_id: true })
|
|
199
|
-
.extend({
|
|
200
|
-
id: string().uuid(),
|
|
201
|
-
created_at: coercedDate(),
|
|
202
|
-
updated_at: coercedDate(),
|
|
203
|
-
tasks: TaskSchema.omit({
|
|
204
|
-
action_id: true,
|
|
205
|
-
assembly_id: true
|
|
206
|
-
})
|
|
207
|
-
.extend({
|
|
208
|
-
id: string().uuid(),
|
|
209
|
-
created_at: coercedDate(),
|
|
210
|
-
updated_at: coercedDate()
|
|
211
|
-
})
|
|
212
|
-
.array(),
|
|
213
|
-
updates: unknown().array()
|
|
214
|
-
})
|
|
215
|
-
.extend({
|
|
216
|
-
created_at: coercedDate(),
|
|
217
|
-
updated_at: coercedDate()
|
|
218
|
-
})
|
|
219
|
-
.array(),
|
|
220
|
-
updates: unknown().array()
|
|
221
|
-
}).and(object({
|
|
222
|
-
created_at: coercedDate(),
|
|
223
|
-
updated_at: coercedDate()
|
|
224
|
-
}))),
|
|
225
|
-
surveys: maybe(SurveyDetailsSchema.extend({
|
|
226
|
-
created_at: coercedDate(),
|
|
227
|
-
updated_at: coercedDate()
|
|
228
|
-
}).extend({
|
|
229
|
-
data: record(string(), object({
|
|
230
|
-
total: number().int(),
|
|
231
|
-
responses: record(string(), OptionSchema.array())
|
|
232
|
-
}))
|
|
233
|
-
}))
|
|
234
|
-
})
|
|
235
|
-
};
|
|
236
|
-
export const FeedbackSchema = {
|
|
237
|
-
payload: object({
|
|
238
|
-
route: string(),
|
|
239
|
-
text: string(),
|
|
240
|
-
metadata: unknown()
|
|
241
|
-
}),
|
|
242
|
-
response: string()
|
|
243
|
-
};
|
|
244
|
-
export const LogSchema = {
|
|
245
|
-
payload: object({
|
|
246
|
-
message: string().optional(),
|
|
247
|
-
data: record(string(), string().optional()).optional(),
|
|
248
|
-
metadata: object({
|
|
249
|
-
origin: string(),
|
|
250
|
-
route: string(),
|
|
251
|
-
status: number()
|
|
252
|
-
})
|
|
253
|
-
}),
|
|
254
|
-
response: string()
|
|
255
|
-
};
|
|
256
|
-
export const RegisterSchema = {
|
|
257
|
-
payload: object({
|
|
258
|
-
type: literal('user.created'),
|
|
259
|
-
object: literal('event'),
|
|
260
|
-
data: object({
|
|
261
|
-
id: string(),
|
|
262
|
-
email_addresses: object({
|
|
263
|
-
email_address: string()
|
|
264
|
-
}).array()
|
|
265
|
-
})
|
|
266
|
-
}),
|
|
267
|
-
response: string()
|
|
268
|
-
};
|
|
269
|
-
export const PinSchema = {
|
|
270
|
-
payload: object({
|
|
271
|
-
country: string(),
|
|
272
|
-
email: string(),
|
|
273
|
-
text: maybe(string())
|
|
274
|
-
}),
|
|
275
|
-
response: object({
|
|
276
|
-
id: string().uuid(),
|
|
277
|
-
created_at: coercedDate(),
|
|
278
|
-
updated_at: coercedDate(),
|
|
279
|
-
country: string(),
|
|
280
|
-
text: maybe(string()),
|
|
281
|
-
hide: boolean(),
|
|
282
|
-
has_image: boolean(),
|
|
283
|
-
image_src: maybe(string())
|
|
284
|
-
})
|
|
285
|
-
};
|
|
286
|
-
export const PinListSchema = {
|
|
287
|
-
payload: undefined(),
|
|
288
|
-
response: object({
|
|
289
|
-
assemblies: AssemblyOverviewSchema.response.array(),
|
|
290
|
-
pins: PinSchema.response.array()
|
|
291
|
-
})
|
|
292
|
-
};
|
package/dist/types.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export var Method;
|
|
2
|
-
(function (Method) {
|
|
3
|
-
Method["GET"] = "GET";
|
|
4
|
-
Method["POST"] = "POST";
|
|
5
|
-
Method["PUT"] = "PUT";
|
|
6
|
-
Method["PATCH"] = "PATCH";
|
|
7
|
-
})(Method || (Method = {}));
|
|
8
|
-
export var RouteParameters;
|
|
9
|
-
(function (RouteParameters) {
|
|
10
|
-
RouteParameters["ID"] = ":ID";
|
|
11
|
-
RouteParameters["NAME"] = ":NAME";
|
|
12
|
-
})(RouteParameters || (RouteParameters = {}));
|
|
13
|
-
export var Endpoint;
|
|
14
|
-
(function (Endpoint) {
|
|
15
|
-
Endpoint["ASSEMBLIES"] = "/assemblies";
|
|
16
|
-
Endpoint["FEEDBACK"] = "/feedback";
|
|
17
|
-
Endpoint["INTEREST_ASSEMBLIS"] = "/interest/assemblis";
|
|
18
|
-
Endpoint["INTEREST_MUTIRAO"] = "/interest/mutirao";
|
|
19
|
-
Endpoint["LOGS"] = "/logs";
|
|
20
|
-
Endpoint["PINS"] = "/pins";
|
|
21
|
-
Endpoint["SURVEYS"] = "/surveys";
|
|
22
|
-
Endpoint["SURVEY_RESPONSES"] = "/assemblies/:ID/survey-responses/:NAME";
|
|
23
|
-
})(Endpoint || (Endpoint = {}));
|