@driveflux/api-functions 0.0.3 → 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.
Files changed (50) hide show
  1. package/dist/auth/confirm.js +73 -327
  2. package/dist/auth/emails.js +43 -210
  3. package/dist/auth/formatter.js +11 -11
  4. package/dist/auth/otp.js +122 -392
  5. package/dist/auth/register.d.ts +1 -1
  6. package/dist/auth/register.js +100 -396
  7. package/dist/auth/tokens.js +115 -430
  8. package/dist/auth/verifications.js +154 -512
  9. package/dist/constants.js +5 -4
  10. package/dist/mailjet/calls/manage-contacts-in-list.js +22 -166
  11. package/dist/mailjet/calls/manage-subscription-status.js +13 -153
  12. package/dist/mailjet/calls/request-service.js +18 -183
  13. package/dist/mailjet/refresh-email-preferences.js +26 -225
  14. package/dist/mailjet/set-contact.js +23 -214
  15. package/dist/mailjet/types.js +2 -1
  16. package/dist/mailjet/utils/convert-to-array.js +9 -58
  17. package/dist/mailjet/utils/extract-email-preferences.js +41 -217
  18. package/dist/mailjet/utils/lists.js +30 -249
  19. package/dist/mailjet/utils/update-email-references.js +27 -208
  20. package/dist/notion/client.js +48 -197
  21. package/dist/notion/helpful.js +29 -170
  22. package/dist/notion/schemas/block.js +49 -43
  23. package/dist/notion/schemas/common.js +17 -14
  24. package/dist/notion/schemas/database.js +125 -159
  25. package/dist/notion/schemas/emoji.js +3 -2
  26. package/dist/notion/schemas/file.js +10 -10
  27. package/dist/notion/schemas/kb.js +9 -8
  28. package/dist/notion/schemas/page.js +126 -171
  29. package/dist/notion/schemas/parent.js +9 -8
  30. package/dist/notion/schemas/user.js +21 -20
  31. package/dist/reservation/agree.js +19 -158
  32. package/dist/reservation/checks.js +23 -178
  33. package/dist/reservation/display-vehicle.js +142 -514
  34. package/dist/reservation/fetch-or-create.js +197 -482
  35. package/dist/reservation/invoice.d.ts.map +1 -1
  36. package/dist/reservation/invoice.js +199 -501
  37. package/dist/reservation/invoice.js.map +1 -1
  38. package/dist/reservation/payer.js +28 -177
  39. package/dist/reservation/reserve.js +31 -191
  40. package/dist/reservation/types.js +2 -1
  41. package/dist/reservation/vehicle.js +24 -186
  42. package/dist/slack.js +67 -273
  43. package/dist/validation.d.ts +11 -11
  44. package/dist/validation.d.ts.map +1 -1
  45. package/dist/validation.js +63 -96
  46. package/dist/validation.js.map +1 -1
  47. package/dist/vehicle/vehicle-pricing/constants.js +33 -36
  48. package/dist/vehicle/vehicle-pricing/index.js +99 -257
  49. package/dist/vehicle/vehicle-pricing/types.js +2 -1
  50. package/package.json +10 -10
@@ -1,123 +1,81 @@
1
- function _define_property(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
14
- function _object_spread(target) {
15
- for(var i = 1; i < arguments.length; i++){
16
- var source = arguments[i] != null ? arguments[i] : {};
17
- var ownKeys = Object.keys(source);
18
- if (typeof Object.getOwnPropertySymbols === "function") {
19
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
- }));
22
- }
23
- ownKeys.forEach(function(key) {
24
- _define_property(target, key, source[key]);
25
- });
26
- }
27
- return target;
28
- }
29
- function ownKeys(object, enumerableOnly) {
30
- var keys = Object.keys(object);
31
- if (Object.getOwnPropertySymbols) {
32
- var symbols = Object.getOwnPropertySymbols(object);
33
- if (enumerableOnly) {
34
- symbols = symbols.filter(function(sym) {
35
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
36
- });
37
- }
38
- keys.push.apply(keys, symbols);
39
- }
40
- return keys;
41
- }
42
- function _object_spread_props(target, source) {
43
- source = source != null ? source : {};
44
- if (Object.getOwnPropertyDescriptors) {
45
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
46
- } else {
47
- ownKeys(Object(source)).forEach(function(key) {
48
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
49
- });
50
- }
51
- return target;
52
- }
53
1
  import { z } from 'zod';
54
2
  import { notionRichTextSchema } from './block.js';
55
- import { commonPropertyValues, notionCommonColorEnum, notionDateFormat, notionDateSchema, notionTimeFormat } from './common.js';
3
+ import { commonPropertyValues, notionCommonColorEnum, notionDateFormat, notionDateSchema, notionTimeFormat, } from './common.js';
56
4
  import { notionEmojiSchema } from './emoji.js';
57
5
  import { notionFileSchema } from './file.js';
58
6
  import { notionDatabaseParentSchema } from './parent.js';
59
7
  import { notionPartialUserSchema, notionUserSchema } from './user.js';
60
- export var notionPagePropertyCheckboxSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('checkbox')), {
61
- checkbox: z.boolean()
62
- }));
63
- export var notionPagePropertyCreatedBySchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('created_by')), {
64
- created_by: notionUserSchema
65
- }));
66
- export var notionPagePropertyCreatedTimeSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('created_time')), {
67
- created_time: notionTimeFormat
68
- }));
69
- export var notionPagePropertyDateSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('date')), {
70
- date: notionDateSchema.nullable()
71
- }));
72
- export var notionPagePropertyEmailSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('email')), {
73
- email: z.string()
74
- }));
75
- export var notionPagePropertyFilesSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('files')), {
76
- files: z.array(notionFileSchema)
77
- }));
78
- export var notionPagePropertyFormulaSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('formula')), {
8
+ export const notionPagePropertyCheckboxSchema = z.object({
9
+ ...commonPropertyValues('checkbox'),
10
+ checkbox: z.boolean(),
11
+ });
12
+ export const notionPagePropertyCreatedBySchema = z.object({
13
+ ...commonPropertyValues('created_by'),
14
+ created_by: notionUserSchema,
15
+ });
16
+ export const notionPagePropertyCreatedTimeSchema = z.object({
17
+ ...commonPropertyValues('created_time'),
18
+ created_time: notionTimeFormat,
19
+ });
20
+ export const notionPagePropertyDateSchema = z.object({
21
+ ...commonPropertyValues('date'),
22
+ date: notionDateSchema.nullable(),
23
+ });
24
+ export const notionPagePropertyEmailSchema = z.object({
25
+ ...commonPropertyValues('email'),
26
+ email: z.string(),
27
+ });
28
+ export const notionPagePropertyFilesSchema = z.object({
29
+ ...commonPropertyValues('files'),
30
+ files: z.array(notionFileSchema),
31
+ });
32
+ export const notionPagePropertyFormulaSchema = z.object({
33
+ ...commonPropertyValues('formula'),
79
34
  formula: z.object({
80
- type: z.enum([
81
- 'boolean',
82
- 'date',
83
- 'number',
84
- 'string'
85
- ]),
35
+ type: z.enum(['boolean', 'date', 'number', 'string']),
86
36
  boolean: z.boolean().optional(),
87
37
  date: notionDateFormat.optional(),
88
38
  number: z.number().optional(),
89
- string: z.string().optional()
90
- })
91
- }));
92
- export var notionPagePropertyLastEditedBySchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('last_edited_by')), {
93
- last_edited_by: notionUserSchema
94
- }));
95
- export var notionPagePropertyLastEditedTimeSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('last_edited_time')), {
96
- last_edited_time: notionTimeFormat
97
- }));
98
- export var notionPagePropertyMultiSelectSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('multi_select')), {
39
+ string: z.string().optional(),
40
+ }),
41
+ });
42
+ export const notionPagePropertyLastEditedBySchema = z.object({
43
+ ...commonPropertyValues('last_edited_by'),
44
+ last_edited_by: notionUserSchema,
45
+ });
46
+ export const notionPagePropertyLastEditedTimeSchema = z.object({
47
+ ...commonPropertyValues('last_edited_time'),
48
+ last_edited_time: notionTimeFormat,
49
+ });
50
+ export const notionPagePropertyMultiSelectSchema = z.object({
51
+ ...commonPropertyValues('multi_select'),
99
52
  multi_select: z.array(z.object({
100
53
  id: z.string(),
101
54
  name: z.string(),
102
- color: notionCommonColorEnum
103
- }))
104
- }));
105
- export var notionPagePropertyNumberSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('number')), {
106
- number: z.number().nullable()
107
- }));
108
- export var notionPagePropertyPeopleSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('people')), {
109
- people: z.array(notionUserSchema)
110
- }));
111
- export var notionPagePropertyPhoneNumberSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('phone_number')), {
112
- phone_number: z.string()
113
- }));
114
- export var notionPagePropertyRelationSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('relation')), {
55
+ color: notionCommonColorEnum,
56
+ })),
57
+ });
58
+ export const notionPagePropertyNumberSchema = z.object({
59
+ ...commonPropertyValues('number'),
60
+ number: z.number().nullable(),
61
+ });
62
+ export const notionPagePropertyPeopleSchema = z.object({
63
+ ...commonPropertyValues('people'),
64
+ people: z.array(notionUserSchema),
65
+ });
66
+ export const notionPagePropertyPhoneNumberSchema = z.object({
67
+ ...commonPropertyValues('phone_number'),
68
+ phone_number: z.string(),
69
+ });
70
+ export const notionPagePropertyRelationSchema = z.object({
71
+ ...commonPropertyValues('relation'),
115
72
  relation: z.array(z.object({
116
- id: z.string()
73
+ id: z.string(),
117
74
  })),
118
- has_more: z.boolean()
119
- }));
120
- export var notionPagePropertyRollupSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('rollup')), {
75
+ has_more: z.boolean(),
76
+ });
77
+ export const notionPagePropertyRollupSchema = z.object({
78
+ ...commonPropertyValues('rollup'),
121
79
  rollup: z.object({
122
80
  array: z.array(z.any()).optional(),
123
81
  date: notionDateFormat.optional(),
@@ -148,79 +106,76 @@ export var notionPagePropertyRollupSchema = z.object(_object_spread_props(_objec
148
106
  'show_unique',
149
107
  'sum',
150
108
  'unchecked',
151
- 'unique'
109
+ 'unique',
152
110
  ]),
153
- type: z.enum([
154
- 'array',
155
- 'date',
156
- 'incomplete',
157
- 'number',
158
- 'unsupported'
159
- ])
160
- })
161
- }));
162
- export var notionPagePropertyRichTextSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('rich_text')), {
163
- rich_text: z.array(notionRichTextSchema)
164
- }));
165
- export var notionPagePropertySelectSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('select')), {
166
- select: z.object({
111
+ type: z.enum(['array', 'date', 'incomplete', 'number', 'unsupported']),
112
+ }),
113
+ });
114
+ export const notionPagePropertyRichTextSchema = z.object({
115
+ ...commonPropertyValues('rich_text'),
116
+ rich_text: z.array(notionRichTextSchema),
117
+ });
118
+ export const notionPagePropertySelectSchema = z.object({
119
+ ...commonPropertyValues('select'),
120
+ select: z
121
+ .object({
167
122
  id: z.string(),
168
123
  name: z.string(),
169
- color: notionCommonColorEnum
170
- }).nullable()
171
- }));
172
- export var notionPagePropertyStatusSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('status')), {
124
+ color: notionCommonColorEnum,
125
+ })
126
+ .nullable(),
127
+ });
128
+ export const notionPagePropertyStatusSchema = z.object({
129
+ ...commonPropertyValues('status'),
173
130
  status: z.object({
174
131
  id: z.string(),
175
132
  name: z.string(),
176
- color: notionCommonColorEnum
177
- })
178
- }));
179
- export var notionPagePropertyTitleSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('title')), {
180
- title: z.array(notionRichTextSchema)
181
- }));
182
- export var notionPagePropertyUrlSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('url')), {
183
- url: z.string().url().nullable()
184
- }));
185
- export var notionPagePropertyUniqueIdSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('unique_id')), {
133
+ color: notionCommonColorEnum,
134
+ }),
135
+ });
136
+ export const notionPagePropertyTitleSchema = z.object({
137
+ ...commonPropertyValues('title'),
138
+ title: z.array(notionRichTextSchema),
139
+ });
140
+ export const notionPagePropertyUrlSchema = z.object({
141
+ ...commonPropertyValues('url'),
142
+ url: z.string().url().nullable(),
143
+ });
144
+ export const notionPagePropertyUniqueIdSchema = z.object({
145
+ ...commonPropertyValues('unique_id'),
186
146
  unique_id: z.object({
187
147
  number: z.number(),
188
- prefix: z.string().nullable().optional()
189
- })
190
- }));
191
- export var notionPagePropertyVerificationSchema = z.object(_object_spread_props(_object_spread({}, commonPropertyValues('verification')), {
148
+ prefix: z.string().nullable().optional(),
149
+ }),
150
+ });
151
+ export const notionPagePropertyVerificationSchema = z.object({
152
+ ...commonPropertyValues('verification'),
192
153
  verification: z.object({
193
- state: z.enum([
194
- 'verified',
195
- 'unverified'
196
- ]),
154
+ state: z.enum(['verified', 'unverified']),
197
155
  verified_by: notionUserSchema.nullable(),
198
- date: notionDateSchema
199
- })
200
- }));
201
- export var notionPageSchema = function(properties) {
202
- return z.object({
203
- object: z.literal('page'),
204
- id: z.string(),
205
- created_time: notionTimeFormat,
206
- created_by: notionPartialUserSchema,
207
- last_edited_time: notionTimeFormat,
208
- last_edited_by: notionPartialUserSchema,
209
- archived: z.boolean(),
210
- icon: notionFileSchema.or(notionEmojiSchema).nullable(),
211
- properties: properties,
212
- parent: notionDatabaseParentSchema,
213
- url: z.string().url(),
214
- public_url: z.string().nullable()
215
- });
216
- };
217
- export var notionPagesSchema = function(properties) {
218
- return z.object({
219
- has_more: z.boolean(),
220
- next_cursor: z.string().nullable(),
221
- object: z.literal('list'),
222
- page_or_database: z.object({}),
223
- type: z.literal('page_or_database'),
224
- results: z.array(notionPageSchema(properties))
225
- });
226
- };
156
+ date: notionDateSchema,
157
+ }),
158
+ });
159
+ export const notionPageSchema = (properties) => z.object({
160
+ object: z.literal('page'),
161
+ id: z.string(),
162
+ created_time: notionTimeFormat,
163
+ created_by: notionPartialUserSchema,
164
+ last_edited_time: notionTimeFormat,
165
+ last_edited_by: notionPartialUserSchema,
166
+ archived: z.boolean(),
167
+ icon: notionFileSchema.or(notionEmojiSchema).nullable(),
168
+ properties,
169
+ parent: notionDatabaseParentSchema,
170
+ url: z.string().url(),
171
+ public_url: z.string().nullable(),
172
+ });
173
+ export const notionPagesSchema = (properties) => z.object({
174
+ has_more: z.boolean(),
175
+ next_cursor: z.string().nullable(),
176
+ object: z.literal('list'),
177
+ page_or_database: z.object({}),
178
+ type: z.literal('page_or_database'),
179
+ results: z.array(notionPageSchema(properties)),
180
+ });
181
+ //# sourceMappingURL=page.js.map
@@ -1,17 +1,18 @@
1
1
  import { z } from 'zod';
2
- export var notionDatabaseParentSchema = z.object({
2
+ export const notionDatabaseParentSchema = z.object({
3
3
  type: z.literal('database_id'),
4
- database_id: z.string()
4
+ database_id: z.string(),
5
5
  });
6
- export var notionPageParentSchema = z.object({
6
+ export const notionPageParentSchema = z.object({
7
7
  type: z.literal('page_id'),
8
- page_id: z.string()
8
+ page_id: z.string(),
9
9
  });
10
- export var notionWorkspaceParentSchema = z.object({
10
+ export const notionWorkspaceParentSchema = z.object({
11
11
  type: z.literal('workspace'),
12
- workspace: z.literal(true)
12
+ workspace: z.literal(true),
13
13
  });
14
- export var notionBlockParentSchema = z.object({
14
+ export const notionBlockParentSchema = z.object({
15
15
  type: z.literal('block_id'),
16
- block_id: z.string()
16
+ block_id: z.string(),
17
17
  });
18
+ //# sourceMappingURL=parent.js.map
@@ -1,30 +1,31 @@
1
1
  import { z } from 'zod';
2
- export var notionPartialUserSchema = z.object({
2
+ export const notionPartialUserSchema = z.object({
3
3
  object: z.literal('user'),
4
- user: z.string().optional()
4
+ user: z.string().optional(),
5
5
  });
6
- export var notionUserSchema = z.object({
6
+ export const notionUserSchema = z.object({
7
7
  object: z.literal('user'),
8
8
  id: z.string(),
9
- type: z.enum([
10
- 'person',
11
- 'bot'
12
- ]).optional(),
9
+ type: z.enum(['person', 'bot']).optional(),
13
10
  name: z.string().optional(),
14
11
  avatar_url: z.string().nullable().optional(),
15
12
  // type person
16
- person: z.object({
17
- email: z.string().email()
18
- }).optional(),
13
+ person: z
14
+ .object({
15
+ email: z.string().email(),
16
+ })
17
+ .optional(),
19
18
  // type bot
20
- bot: z.object({
21
- owner: z.object({
22
- type: z.enum([
23
- 'workspace',
24
- 'user'
25
- ]),
26
- workspace: z.boolean()
27
- }).optional(),
28
- workspace_name: z.string().optional()
29
- }).optional()
19
+ bot: z
20
+ .object({
21
+ owner: z
22
+ .object({
23
+ type: z.enum(['workspace', 'user']),
24
+ workspace: z.boolean(),
25
+ })
26
+ .optional(),
27
+ workspace_name: z.string().optional(),
28
+ })
29
+ .optional(),
30
30
  });
31
+ //# sourceMappingURL=user.js.map
@@ -1,162 +1,23 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
8
- }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
13
- }
14
- }
15
- function _async_to_generator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
27
- });
28
- };
29
- }
30
- function _ts_generator(thisArg, body) {
31
- var f, y, t, _ = {
32
- label: 0,
33
- sent: function() {
34
- if (t[0] & 1) throw t[1];
35
- return t[1];
36
- },
37
- trys: [],
38
- ops: []
39
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
40
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
41
- return this;
42
- }), g;
43
- function verb(n) {
44
- return function(v) {
45
- return step([
46
- n,
47
- v
48
- ]);
49
- };
50
- }
51
- function step(op) {
52
- if (f) throw new TypeError("Generator is already executing.");
53
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
54
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
55
- if (y = 0, t) op = [
56
- op[0] & 2,
57
- t.value
58
- ];
59
- switch(op[0]){
60
- case 0:
61
- case 1:
62
- t = op;
63
- break;
64
- case 4:
65
- _.label++;
66
- return {
67
- value: op[1],
68
- done: false
69
- };
70
- case 5:
71
- _.label++;
72
- y = op[1];
73
- op = [
74
- 0
75
- ];
76
- continue;
77
- case 7:
78
- op = _.ops.pop();
79
- _.trys.pop();
80
- continue;
81
- default:
82
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
83
- _ = 0;
84
- continue;
85
- }
86
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
87
- _.label = op[1];
88
- break;
89
- }
90
- if (op[0] === 6 && _.label < t[1]) {
91
- _.label = t[1];
92
- t = op;
93
- break;
94
- }
95
- if (t && _.label < t[2]) {
96
- _.label = t[2];
97
- _.ops.push(op);
98
- break;
99
- }
100
- if (t[2]) _.ops.pop();
101
- _.trys.pop();
102
- continue;
103
- }
104
- op = body.call(thisArg, _);
105
- } catch (e) {
106
- op = [
107
- 6,
108
- e
109
- ];
110
- y = 0;
111
- } finally{
112
- f = t = 0;
113
- }
114
- if (op[0] & 5) throw op[1];
115
- return {
116
- value: op[0] ? op[1] : void 0,
117
- done: true
118
- };
119
- }
120
- }
121
1
  import { prisma } from '@driveflux/db';
122
2
  import { generateId } from '@driveflux/db/id';
123
- export var handleAgreeToTerms = function(param) {
124
- var agreedToTerms = param.agreedToTerms, subscribingUser = param.subscribingUser, ipAddress = param.ipAddress;
125
- return _async_to_generator(function() {
126
- return _ts_generator(this, function(_state) {
127
- switch(_state.label){
128
- case 0:
129
- if (!(agreedToTerms && !subscribingUser.consented)) return [
130
- 3,
131
- 2
132
- ];
133
- return [
134
- 4,
135
- prisma.user.update({
136
- where: {
137
- id: subscribingUser.id
138
- },
139
- data: {
140
- consented: true,
141
- consents: {
142
- create: {
143
- id: generateId('UserConsent'),
144
- ipAddress: ipAddress,
145
- consentType: 'terms',
146
- email: subscribingUser.email
147
- }
148
- }
149
- }
150
- })
151
- ];
152
- case 1:
153
- subscribingUser = _state.sent();
154
- _state.label = 2;
155
- case 2:
156
- return [
157
- 2
158
- ];
159
- }
3
+ export const handleAgreeToTerms = async ({ agreedToTerms, subscribingUser, ipAddress, }) => {
4
+ if (agreedToTerms && !subscribingUser.consented) {
5
+ subscribingUser = await prisma.user.update({
6
+ where: {
7
+ id: subscribingUser.id,
8
+ },
9
+ data: {
10
+ consented: true,
11
+ consents: {
12
+ create: {
13
+ id: generateId('UserConsent'),
14
+ ipAddress,
15
+ consentType: 'terms',
16
+ email: subscribingUser.email,
17
+ },
18
+ },
19
+ },
160
20
  });
161
- })();
21
+ }
162
22
  };
23
+ //# sourceMappingURL=agree.js.map