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