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