@assemblis/contracts 0.1.2 → 0.1.4
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 -347
- package/dist/schemas/api.d.ts +1187 -2433
- package/dist/schemas/base.d.ts +162 -362
- package/dist/schemas/legacy.d.ts +582 -1255
- package/dist/schemas/utils.d.ts +1 -9
- package/dist/types/api.d.ts +19 -45
- package/dist/types/enums.d.ts +19 -19
- package/dist/types/types.d.ts +2 -1
- package/package.json +1 -1
- package/src/schemas/api.ts +11 -9
- package/src/schemas/utils.ts +1 -1
- package/src/types/api.ts +1 -9
package/dist/schemas/utils.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
import z, { ZodType } from 'zod';
|
|
2
2
|
export declare const isoDateString: z.ZodISODateTime;
|
|
3
|
-
export declare const maybe: <T extends ZodType<unknown>>(
|
|
4
|
-
_: T
|
|
5
|
-
) => z.ZodPipe<
|
|
6
|
-
z.ZodOptional<z.ZodNullable<T>>,
|
|
7
|
-
z.ZodTransform<
|
|
8
|
-
Awaited<NonNullable<z.core.output<T>>> | null,
|
|
9
|
-
z.core.output<T> | null | undefined
|
|
10
|
-
>
|
|
11
|
-
>;
|
|
3
|
+
export declare const maybe: <T extends ZodType<unknown>>(_: T) => z.ZodPipe<z.ZodOptional<z.ZodNullable<T>>, z.ZodTransform<Awaited<NonNullable<z.core.output<T>>> | null, z.core.output<T> | null | undefined>>;
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,57 +1,31 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from '../schemas';
|
|
16
|
-
export type PublishReportPayload = z.infer<
|
|
17
|
-
(typeof PatchAccountReportsIdPublishSchema)['payload']
|
|
18
|
-
>;
|
|
19
|
-
export type ImageMetadataPayload = z.infer<
|
|
20
|
-
(typeof PostAccountReportsIdCoverImageSchema)['payload']
|
|
21
|
-
>;
|
|
22
|
-
export type AssemblyDetailPayload = z.infer<
|
|
23
|
-
(typeof AssemblyDetailSchema)['payload']
|
|
24
|
-
>;
|
|
25
|
-
export type AssemblyOverviewPayload = z.infer<
|
|
26
|
-
(typeof AssemblyOverviewSchema)['payload']
|
|
27
|
-
>;
|
|
28
|
-
export type AssembliesListPayload = z.infer<
|
|
29
|
-
(typeof AssembliesListSchema)['payload']
|
|
30
|
-
>;
|
|
1
|
+
import z, { ZodType } from 'zod';
|
|
2
|
+
import { AssembliesListSchema, AssemblyDetailSchema, AssemblyOverviewSchema, FeedbackSchema, LogSchema, PatchAccountReportsIdPublishSchema, PinListSchema, PinSchema, PostAccountReportsIdCoverImageSchema, RegisterSchema, SurveyResponseSchema, SurveySchema } from '../schemas';
|
|
3
|
+
import { ApiRestMethod } from './enums';
|
|
4
|
+
export type ApiEndpointSchema = {
|
|
5
|
+
endpoint: (...params: string[]) => string;
|
|
6
|
+
method: ApiRestMethod;
|
|
7
|
+
payload: ZodType;
|
|
8
|
+
response: ZodType;
|
|
9
|
+
};
|
|
10
|
+
export type PublishReportPayload = z.infer<(typeof PatchAccountReportsIdPublishSchema)['payload']>;
|
|
11
|
+
export type ImageMetadataPayload = z.infer<(typeof PostAccountReportsIdCoverImageSchema)['payload']>;
|
|
12
|
+
export type AssemblyDetailPayload = z.infer<(typeof AssemblyDetailSchema)['payload']>;
|
|
13
|
+
export type AssemblyOverviewPayload = z.infer<(typeof AssemblyOverviewSchema)['payload']>;
|
|
14
|
+
export type AssembliesListPayload = z.infer<(typeof AssembliesListSchema)['payload']>;
|
|
31
15
|
export type FeedbackPayload = z.infer<(typeof FeedbackSchema)['payload']>;
|
|
32
16
|
export type LogPayload = z.infer<(typeof LogSchema)['payload']>;
|
|
33
17
|
export type PinPayload = z.infer<(typeof PinSchema)['payload']>;
|
|
34
18
|
export type PinListPayload = z.infer<(typeof PinListSchema)['payload']>;
|
|
35
19
|
export type RegisterPayload = z.infer<(typeof RegisterSchema)['payload']>;
|
|
36
20
|
export type SurveyPayload = z.infer<(typeof SurveySchema)['payload']>;
|
|
37
|
-
export type SurveyResponsePayload = z.infer<
|
|
38
|
-
|
|
39
|
-
>;
|
|
40
|
-
export type
|
|
41
|
-
(typeof AssemblyDetailSchema)['response']
|
|
42
|
-
>;
|
|
43
|
-
export type AssemblyOverviewResponse = z.infer<
|
|
44
|
-
(typeof AssemblyOverviewSchema)['response']
|
|
45
|
-
>;
|
|
46
|
-
export type AssembliesListResponse = z.infer<
|
|
47
|
-
(typeof AssembliesListSchema)['response']
|
|
48
|
-
>;
|
|
21
|
+
export type SurveyResponsePayload = z.infer<(typeof SurveyResponseSchema)['payload']>;
|
|
22
|
+
export type AssemblyDetailResponse = z.infer<(typeof AssemblyDetailSchema)['response']>;
|
|
23
|
+
export type AssemblyOverviewResponse = z.infer<(typeof AssemblyOverviewSchema)['response']>;
|
|
24
|
+
export type AssembliesListResponse = z.infer<(typeof AssembliesListSchema)['response']>;
|
|
49
25
|
export type FeedbackResponse = z.infer<(typeof FeedbackSchema)['response']>;
|
|
50
26
|
export type LogResponse = z.infer<(typeof LogSchema)['response']>;
|
|
51
27
|
export type PinResponse = z.infer<(typeof PinSchema)['response']>;
|
|
52
28
|
export type PinListResponse = z.infer<(typeof PinListSchema)['response']>;
|
|
53
29
|
export type RegisterResponse = z.infer<(typeof RegisterSchema)['response']>;
|
|
54
30
|
export type SurveyResponse = z.infer<(typeof SurveySchema)['response']>;
|
|
55
|
-
export type SurveyResponseResponse = z.infer<
|
|
56
|
-
(typeof SurveyResponseSchema)['response']
|
|
57
|
-
>;
|
|
31
|
+
export type SurveyResponseResponse = z.infer<(typeof SurveyResponseSchema)['response']>;
|
package/dist/types/enums.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
export declare enum ApiRestMethod {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
GET = "GET",
|
|
3
|
+
POST = "POST",
|
|
4
|
+
PUT = "PUT",
|
|
5
|
+
PATCH = "PATCH"
|
|
6
6
|
}
|
|
7
7
|
export declare enum ApiRouteParameter {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
ID = ":ID",
|
|
9
|
+
NAME = ":NAME"
|
|
10
10
|
}
|
|
11
11
|
export declare enum ApiEndpoint {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
ACCOUNT_REPORTS = "/account/reports",
|
|
13
|
+
ASSEMBLIES = "/assemblies",
|
|
14
|
+
FEEDBACK = "/feedback",
|
|
15
|
+
INTEREST_ASSEMBLIS = "/interest/assemblis",
|
|
16
|
+
INTEREST_MUTIRAO = "/interest/mutirao",
|
|
17
|
+
LOGS = "/logs",
|
|
18
|
+
PINS = "/pins",
|
|
19
|
+
SURVEYS = "/surveys",
|
|
20
|
+
SURVEY_RESPONSES = "/assemblies/:ID/survey-responses/:NAME"
|
|
21
21
|
}
|
|
22
22
|
export declare enum SurveyName {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
DELIBERATION = "deliberation",
|
|
24
|
+
DEMOGRAPHIC_DATA = "demographic-data",
|
|
25
|
+
PRE_ASSEMBLY = "pre-assembly",
|
|
26
|
+
POST_ASSEMBLY = "post-assembly"
|
|
27
27
|
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
-
import { ReportSchema, UserSchema, ReportContentSchema } from '../schemas/base';
|
|
2
|
+
import { ReportSchema, UserSchema, ReportContentSchema, ImageSchema } from '../schemas/base';
|
|
3
|
+
export type Image = z.infer<typeof ImageSchema>;
|
|
3
4
|
export type Report = z.infer<typeof ReportSchema>;
|
|
4
5
|
export type ReportContent = z.infer<typeof ReportContentSchema>;
|
|
5
6
|
export type User = z.infer<typeof UserSchema>;
|
package/package.json
CHANGED
package/src/schemas/api.ts
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
+
|
|
3
|
+
import { ApiEndpoint, ApiRestMethod } from '../types';
|
|
4
|
+
|
|
2
5
|
import { ImageSchema, ReportContentSchema, ReportSchema } from './base';
|
|
3
6
|
import { isoDateString, maybe } from './utils';
|
|
4
|
-
import { ApiEndpoint, ApiEndpointSchema, ApiRestMethod } from '../types';
|
|
5
7
|
|
|
6
|
-
export const GetAccountReportsSchema
|
|
8
|
+
export const GetAccountReportsSchema = {
|
|
7
9
|
endpoint: () => ApiEndpoint.ACCOUNT_REPORTS,
|
|
8
10
|
method: ApiRestMethod.GET,
|
|
9
11
|
payload: z.never(),
|
|
10
12
|
response: z.object({ reports: ReportSchema.array() })
|
|
11
13
|
};
|
|
12
14
|
|
|
13
|
-
export const GetAccountReportsIdSchema
|
|
15
|
+
export const GetAccountReportsIdSchema = {
|
|
14
16
|
endpoint: (reportId: string) => `${ApiEndpoint.ACCOUNT_REPORTS}/${reportId}`,
|
|
15
17
|
method: ApiRestMethod.GET,
|
|
16
18
|
payload: z.never(),
|
|
17
19
|
response: ReportSchema
|
|
18
20
|
};
|
|
19
21
|
|
|
20
|
-
export const PostAccountReportsSchema
|
|
22
|
+
export const PostAccountReportsSchema = {
|
|
21
23
|
endpoint: () => ApiEndpoint.ACCOUNT_REPORTS,
|
|
22
24
|
method: ApiRestMethod.POST,
|
|
23
25
|
payload: maybe(ReportContentSchema.omit({ cover_image_id: true })),
|
|
24
26
|
response: ReportSchema
|
|
25
27
|
};
|
|
26
28
|
|
|
27
|
-
export const PutAccountReportsIdContentSchema
|
|
29
|
+
export const PutAccountReportsIdContentSchema = {
|
|
28
30
|
endpoint: (reportId: string) =>
|
|
29
31
|
`${ApiEndpoint.ACCOUNT_REPORTS}/${reportId}/content`,
|
|
30
32
|
method: ApiRestMethod.PUT,
|
|
@@ -32,7 +34,7 @@ export const PutAccountReportsIdContentSchema: ApiEndpointSchema = {
|
|
|
32
34
|
response: ReportSchema
|
|
33
35
|
};
|
|
34
36
|
|
|
35
|
-
export const PatchAccountReportsIdDiscardSchema
|
|
37
|
+
export const PatchAccountReportsIdDiscardSchema = {
|
|
36
38
|
endpoint: (reportId: string) =>
|
|
37
39
|
`${ApiEndpoint.ACCOUNT_REPORTS}/${reportId}/discard`,
|
|
38
40
|
method: ApiRestMethod.PATCH,
|
|
@@ -40,7 +42,7 @@ export const PatchAccountReportsIdDiscardSchema: ApiEndpointSchema = {
|
|
|
40
42
|
response: maybe(ReportSchema)
|
|
41
43
|
};
|
|
42
44
|
|
|
43
|
-
export const PatchAccountReportsIdPublishSchema
|
|
45
|
+
export const PatchAccountReportsIdPublishSchema = {
|
|
44
46
|
endpoint: (reportId: string) =>
|
|
45
47
|
`${ApiEndpoint.ACCOUNT_REPORTS}/${reportId}/publish`,
|
|
46
48
|
method: ApiRestMethod.PATCH,
|
|
@@ -48,7 +50,7 @@ export const PatchAccountReportsIdPublishSchema: ApiEndpointSchema = {
|
|
|
48
50
|
response: ReportSchema
|
|
49
51
|
};
|
|
50
52
|
|
|
51
|
-
export const PatchAccountReportsIdUnpublishSchema
|
|
53
|
+
export const PatchAccountReportsIdUnpublishSchema = {
|
|
52
54
|
endpoint: (reportId: string) =>
|
|
53
55
|
`${ApiEndpoint.ACCOUNT_REPORTS}/${reportId}/unpublish`,
|
|
54
56
|
method: ApiRestMethod.PATCH,
|
|
@@ -56,7 +58,7 @@ export const PatchAccountReportsIdUnpublishSchema: ApiEndpointSchema = {
|
|
|
56
58
|
response: ReportSchema
|
|
57
59
|
};
|
|
58
60
|
|
|
59
|
-
export const PostAccountReportsIdCoverImageSchema
|
|
61
|
+
export const PostAccountReportsIdCoverImageSchema = {
|
|
60
62
|
endpoint: (reportId: string) =>
|
|
61
63
|
`${ApiEndpoint.ACCOUNT_REPORTS}/${reportId}/cover-image`,
|
|
62
64
|
method: ApiRestMethod.POST,
|
package/src/schemas/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import z, { ZodType } from 'zod';
|
|
2
2
|
|
|
3
|
-
export const isoDateString = z.
|
|
3
|
+
export const isoDateString = z.coerce.date().transform((_) => _.toISOString());
|
|
4
4
|
export const maybe = <T extends ZodType<unknown>>(_: T) =>
|
|
5
5
|
_.nullish().transform((_) => _ ?? null);
|
package/src/types/api.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import z
|
|
1
|
+
import z from 'zod';
|
|
2
2
|
import {
|
|
3
3
|
AssembliesListSchema,
|
|
4
4
|
AssemblyDetailSchema,
|
|
@@ -13,14 +13,6 @@ import {
|
|
|
13
13
|
SurveyResponseSchema,
|
|
14
14
|
SurveySchema
|
|
15
15
|
} from '../schemas';
|
|
16
|
-
import { ApiRestMethod } from './enums';
|
|
17
|
-
|
|
18
|
-
export type ApiEndpointSchema = {
|
|
19
|
-
endpoint: (...params: string[]) => string;
|
|
20
|
-
method: ApiRestMethod;
|
|
21
|
-
payload: ZodType;
|
|
22
|
-
response: ZodType;
|
|
23
|
-
};
|
|
24
16
|
|
|
25
17
|
export type PublishReportPayload = z.infer<
|
|
26
18
|
(typeof PatchAccountReportsIdPublishSchema)['payload']
|