@assemblis/contracts 0.0.8 → 0.0.10

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 CHANGED
@@ -1,2 +1 @@
1
- export * from './schemas';
2
- export * from './types';
1
+ import{coerce as e,object as a,string as t,boolean as i,undefined as d,number as s,record as r,unknown as n,literal as o}from"zod";const p=e.date,u=e=>e.nullish().transform(e=>e??null),_=a({label:t(),value:e.number().int()}),l={payload:d(),response:a({id:t().uuid(),created_at:p(),updated_at:p(),sub:t(),is_mutirao:i()})},y=a({id:t().uuid(),text:t()}),c={payload:d(),response:a({id:t().uuid(),created_at:p(),updated_at:p(),name:t(),sections:a({primary:y,secondary:y.array(),options:_.array()}).array()})},m={payload:a({answers:a({question_id:t().uuid(),answer_value:e.number().int()}).array()}),response:a({total:s().int()})},b=a({visible_on_profile:i(),description:u(t())}),x=a({text:t(),agreed:u(e.number().int()),against:u(e.number().int()),abstained:u(e.number().int()),include_in_action_plan:i().default(!0),assembly_id:t().uuid()}),f=a({text:t(),complete:i().default(!1),action_id:t().uuid(),assembly_id:t().uuid()}),v=a({published_at:u(p()),name:t(),about:u(t()),topics:t().array(),country:u(t()),hide:i().default(!1)}),E={payload:v,response:v.extend({id:t().uuid(),created_at:p(),updated_at:p(),has_image:i(),image_src:u(t())})},S={payload:d(),response:a({assemblies:E.response.array()})},g=a({visible_on_profile:i(),name:u(t()),description:u(t()),type:u(t())}),T=a({visible_on_profile:i(),registration_link:u(t()),start_date:u(p())}),A=a({visible_on_profile:i(),background:u(t())}),I=a({visible_on_profile:i(),organisation_types:t().array(),description:u(t())}),h=a({visible_on_profile:i(),organisation_types:t().array(),description:u(t())}),P=a({visible_on_profile:i(),decision_method:u(t())}),N=a({visible_on_profile:i(),recruitment_method:u(t()),community:u(t())}),M=a({visible_on_profile:i(),support_options:t().array()}),R=a({visible_on_profile:i()}),k={payload:E.payload.extend({organisation:u(g.extend({id:t().uuid().optional()})),event_details:u(T),story:u(A),supporters:u(I),funders:u(h),facilitation:u(P),participants:u(N),support:u(M),action_plan:u(b.extend({actions:x.omit({assembly_id:!0}).extend({id:t().uuid().optional(),tasks:f.omit({action_id:!0,assembly_id:!0}).extend({id:t().uuid().optional()}).array(),updates:n().array()}).array(),updates:n().array()})),surveys:u(R)}),response:E.response.extend({is_own:i(),organisation:u(g.extend({id:t().uuid(),created_at:p(),updated_at:p()})),event_details:u(T.extend({created_at:p(),updated_at:p()})),story:u(A.extend({created_at:p(),updated_at:p()})),supporters:u(I.extend({created_at:p(),updated_at:p()})),funders:u(h.extend({created_at:p(),updated_at:p()})),facilitation:u(P.extend({created_at:p(),updated_at:p()})),participants:u(N.extend({created_at:p(),updated_at:p()})),support:u(M.extend({created_at:p(),updated_at:p()})),action_plan:u(b.extend({actions:x.omit({assembly_id:!0}).extend({id:t().uuid(),created_at:p(),updated_at:p(),tasks:f.omit({action_id:!0,assembly_id:!0}).extend({id:t().uuid(),created_at:p(),updated_at:p()}).array(),updates:n().array()}).extend({created_at:p(),updated_at:p()}).array(),updates:n().array()}).and(a({created_at:p(),updated_at:p()}))),surveys:u(R.extend({created_at:p(),updated_at:p()}).extend({data:r(t(),a({total:s().int(),responses:r(t(),_.array())}))}))})},O={payload:a({route:t(),text:t(),metadata:n()}),response:t()},U={payload:a({message:t().optional(),data:r(t(),t().optional()).optional(),metadata:a({origin:t(),route:t(),status:s()})}),response:t()},D={payload:a({type:o("user.created"),object:o("event"),data:a({id:t(),email_addresses:a({email_address:t()}).array()})}),response:t()},w={payload:a({country:t(),email:t(),text:u(t())}),response:a({id:t().uuid(),created_at:p(),updated_at:p(),country:t(),text:u(t()),hide:i(),has_image:i(),image_src:u(t())})},B={payload:d(),response:a({assemblies:E.response.array(),pins:w.response.array()})};var C,G,L;!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH"}(C||(C={})),function(e){e.ID=":ID",e.NAME=":NAME"}(G||(G={})),function(e){e.ASSEMBLIES="/assemblies",e.FEEDBACK="/feedback",e.INTEREST_ASSEMBLIS="/interest/assemblis",e.INTEREST_MUTIRAO="/interest/mutirao",e.LOGS="/logs",e.PINS="/pins",e.SURVEYS="/surveys",e.SURVEY_RESPONSES="/assemblies/:ID/survey-responses/:NAME"}(L||(L={}));export{S as AssembliesListSchema,k as AssemblyDetailSchema,E as AssemblyOverviewSchema,L as Endpoint,O as FeedbackSchema,U as LogSchema,C as Method,B as PinListSchema,w as PinSchema,D as RegisterSchema,G as RouteParameters,m as SurveyResponseSchema,c as SurveySchema,l as UserSchema};
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "@assemblis/contracts",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
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
+ "@rollup/plugin-terser": "^0.4.4",
10
+ "@rollup/plugin-typescript": "^11.1.6",
11
+ "rollup": "^4.20.0",
9
12
  "typescript": "^5.5.0"
10
13
  },
11
14
  "dependencies": {
12
15
  "zod": "^3.25.42"
13
16
  },
14
17
  "scripts": {
15
- "build": "yarn clean && tsc",
18
+ "build": "rollup --config rollup.config.ts --configPlugin typescript -o 'dist/index.js' src/index.ts",
16
19
  "clean": "rm -rf ./dist"
17
20
  }
18
21
  }
@@ -0,0 +1,10 @@
1
+ import typescript from '@rollup/plugin-typescript';
2
+ import terser from '@rollup/plugin-terser';
3
+
4
+ export default {
5
+ output: {
6
+ format: 'es',
7
+ compact: true
8
+ },
9
+ plugins: [typescript(), terser()]
10
+ };
package/tsconfig.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
- "extends": "../tsconfig.json",
3
2
  "compilerOptions": {
3
+ "importHelpers": true,
4
+ "moduleResolution": "node",
5
+ "module": "ES2022",
6
+ "target": "ES2021",
7
+ "strictNullChecks": true,
8
+ "skipLibCheck": true,
9
+ "strict": true,
4
10
  "declaration": true,
11
+ "esModuleInterop": true,
5
12
  "baseUrl": ".",
6
13
  "outDir": "dist"
7
14
  },
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 = {}));