@driveflux/api-functions 0.0.6 → 0.0.7-next.1

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 (53) 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.js +100 -396
  6. package/dist/auth/tokens.d.ts +3 -3
  7. package/dist/auth/tokens.js +115 -430
  8. package/dist/auth/verifications.d.ts.map +1 -1
  9. package/dist/auth/verifications.js +191 -514
  10. package/dist/auth/verifications.js.map +1 -1
  11. package/dist/constants.js +5 -4
  12. package/dist/mailjet/calls/manage-contacts-in-list.js +22 -166
  13. package/dist/mailjet/calls/manage-subscription-status.js +13 -153
  14. package/dist/mailjet/calls/request-service.d.ts +1 -1
  15. package/dist/mailjet/calls/request-service.d.ts.map +1 -1
  16. package/dist/mailjet/calls/request-service.js +18 -183
  17. package/dist/mailjet/refresh-email-preferences.js +26 -225
  18. package/dist/mailjet/set-contact.js +23 -214
  19. package/dist/mailjet/types.js +2 -1
  20. package/dist/mailjet/utils/convert-to-array.js +9 -58
  21. package/dist/mailjet/utils/extract-email-preferences.js +41 -217
  22. package/dist/mailjet/utils/lists.js +30 -249
  23. package/dist/mailjet/utils/update-email-references.js +27 -208
  24. package/dist/notion/client.js +48 -197
  25. package/dist/notion/helpful.js +29 -170
  26. package/dist/notion/schemas/block.js +49 -43
  27. package/dist/notion/schemas/common.js +17 -14
  28. package/dist/notion/schemas/database.js +125 -159
  29. package/dist/notion/schemas/emoji.js +3 -2
  30. package/dist/notion/schemas/file.js +10 -10
  31. package/dist/notion/schemas/kb.js +9 -8
  32. package/dist/notion/schemas/page.js +126 -171
  33. package/dist/notion/schemas/parent.js +9 -8
  34. package/dist/notion/schemas/user.js +21 -20
  35. package/dist/reservation/agree.js +19 -158
  36. package/dist/reservation/checks.js +23 -178
  37. package/dist/reservation/display-vehicle.d.ts +37 -37
  38. package/dist/reservation/display-vehicle.d.ts.map +1 -1
  39. package/dist/reservation/display-vehicle.js +142 -514
  40. package/dist/reservation/fetch-or-create.js +197 -482
  41. package/dist/reservation/invoice.js +198 -496
  42. package/dist/reservation/payer.js +28 -177
  43. package/dist/reservation/reserve.js +31 -191
  44. package/dist/reservation/types.js +2 -1
  45. package/dist/reservation/vehicle.js +24 -186
  46. package/dist/slack.d.ts +2 -2
  47. package/dist/slack.d.ts.map +1 -1
  48. package/dist/slack.js +67 -273
  49. package/dist/validation.js +81 -139
  50. package/dist/vehicle/vehicle-pricing/constants.js +33 -36
  51. package/dist/vehicle/vehicle-pricing/index.js +99 -257
  52. package/dist/vehicle/vehicle-pricing/types.js +2 -1
  53. package/package.json +12 -12
@@ -1,173 +1,32 @@
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 { getNotion } from '@driveflux/api-functions/notion';
122
2
  import { knowledgeBaseRetrievePageSchema } from './schemas/kb.js';
123
- export var processHelpful = function(options) {
124
- return _async_to_generator(function() {
125
- var pageId, isHelpful, hasSubmittedBefore, notion, page, kbPageValidation, validatedPage;
126
- return _ts_generator(this, function(_state) {
127
- switch(_state.label){
128
- case 0:
129
- pageId = options.pageId, isHelpful = options.isHelpful, hasSubmittedBefore = options.hasSubmittedBefore;
130
- // get original page
131
- notion = getNotion();
132
- return [
133
- 4,
134
- notion.pages.retrieve({
135
- page_id: pageId
136
- })
137
- ];
138
- case 1:
139
- page = _state.sent();
140
- // validate page
141
- kbPageValidation = knowledgeBaseRetrievePageSchema.safeParse(page);
142
- if (!kbPageValidation.success) {
143
- return [
144
- 2,
145
- false
146
- ];
147
- }
148
- validatedPage = kbPageValidation.data;
149
- // update helpful/unhelpful number
150
- return [
151
- 4,
152
- notion.pages.update({
153
- page_id: pageId,
154
- properties: {
155
- Helpful: {
156
- number: (validatedPage.properties.Helpful.number || 0) + (hasSubmittedBefore && !isHelpful ? -1 : isHelpful ? 1 : 0)
157
- },
158
- Unhelpful: {
159
- number: (validatedPage.properties.Unhelpful.number || 0) + (hasSubmittedBefore && isHelpful ? -1 : !isHelpful ? 1 : 0)
160
- }
161
- }
162
- })
163
- ];
164
- case 2:
165
- _state.sent();
166
- return [
167
- 2,
168
- true
169
- ];
170
- }
171
- });
172
- })();
3
+ export const processHelpful = async (options) => {
4
+ const { pageId, isHelpful, hasSubmittedBefore } = options;
5
+ // get original page
6
+ const notion = getNotion();
7
+ const page = await notion.pages.retrieve({
8
+ page_id: pageId,
9
+ });
10
+ // validate page
11
+ const kbPageValidation = knowledgeBaseRetrievePageSchema.safeParse(page);
12
+ if (!kbPageValidation.success) {
13
+ return false;
14
+ }
15
+ const validatedPage = kbPageValidation.data;
16
+ // update helpful/unhelpful number
17
+ await notion.pages.update({
18
+ page_id: pageId,
19
+ properties: {
20
+ Helpful: {
21
+ number: (validatedPage.properties.Helpful.number || 0) +
22
+ (hasSubmittedBefore && !isHelpful ? -1 : isHelpful ? 1 : 0),
23
+ },
24
+ Unhelpful: {
25
+ number: (validatedPage.properties.Unhelpful.number || 0) +
26
+ (hasSubmittedBefore && isHelpful ? -1 : !isHelpful ? 1 : 0),
27
+ },
28
+ },
29
+ });
30
+ return true;
173
31
  };
32
+ //# sourceMappingURL=helpful.js.map
@@ -1,55 +1,60 @@
1
1
  import { z } from 'zod';
2
2
  import { notionDateSchema } from './common.js';
3
3
  import { notionPartialUserSchema } from './user.js';
4
- export var notionRichTextSchema = z.object({
5
- type: z.enum([
6
- 'text',
7
- 'mention',
8
- 'equation'
9
- ]),
10
- equation: z.object({
11
- expression: z.string()
12
- }).optional(),
13
- mention: z.object({
4
+ export const notionRichTextSchema = z.object({
5
+ type: z.enum(['text', 'mention', 'equation']),
6
+ equation: z
7
+ .object({
8
+ expression: z.string(),
9
+ })
10
+ .optional(),
11
+ mention: z
12
+ .object({
14
13
  type: z.enum([
15
14
  'database',
16
15
  'date',
17
16
  'link_preview',
18
17
  'page',
19
18
  'template_mention',
20
- 'user'
19
+ 'user',
21
20
  ]),
22
- database: z.object({
23
- id: z.string()
24
- }).optional(),
21
+ database: z
22
+ .object({
23
+ id: z.string(),
24
+ })
25
+ .optional(),
25
26
  date: notionDateSchema.optional(),
26
- link_preview: z.object({
27
- url: z.string().url()
28
- }).optional(),
29
- page: z.object({
30
- id: z.string()
31
- }).optional(),
32
- template_mention: z.object({
33
- type: z.enum([
34
- 'template_mention_date',
35
- 'template_mention_user'
36
- ]),
37
- template_mention_date: z.enum([
38
- 'today',
39
- 'now'
40
- ]).optional(),
41
- template_mention_user: z.enum([
42
- 'me'
43
- ]).optional()
44
- }).optional(),
45
- user: notionPartialUserSchema.optional()
46
- }).optional(),
47
- text: z.object({
27
+ link_preview: z
28
+ .object({
29
+ url: z.string().url(),
30
+ })
31
+ .optional(),
32
+ page: z
33
+ .object({
34
+ id: z.string(),
35
+ })
36
+ .optional(),
37
+ template_mention: z
38
+ .object({
39
+ type: z.enum(['template_mention_date', 'template_mention_user']),
40
+ template_mention_date: z.enum(['today', 'now']).optional(),
41
+ template_mention_user: z.enum(['me']).optional(),
42
+ })
43
+ .optional(),
44
+ user: notionPartialUserSchema.optional(),
45
+ })
46
+ .optional(),
47
+ text: z
48
+ .object({
48
49
  content: z.string(),
49
- link: z.object({
50
- url: z.string().url()
51
- }).nullable().optional()
52
- }).optional(),
50
+ link: z
51
+ .object({
52
+ url: z.string().url(),
53
+ })
54
+ .nullable()
55
+ .optional(),
56
+ })
57
+ .optional(),
53
58
  annotations: z.object({
54
59
  bold: z.boolean(),
55
60
  italic: z.boolean(),
@@ -75,9 +80,10 @@ export var notionRichTextSchema = z.object({
75
80
  'red',
76
81
  'red_background',
77
82
  'yellow',
78
- 'yellow_background'
79
- ])
83
+ 'yellow_background',
84
+ ]),
80
85
  }),
81
86
  plain_text: z.string(),
82
- href: z.string().url().nullable().optional()
87
+ href: z.string().url().nullable().optional(),
83
88
  });
89
+ //# sourceMappingURL=block.js.map
@@ -1,8 +1,12 @@
1
1
  import { z } from 'zod';
2
- export var notionDateOrTimeFormat = z.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?(Z|\+\d{2}:\d{2}))?$/);
3
- export var notionDateFormat = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
4
- export var notionTimeFormat = z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/);
5
- export var notionCommonColorEnum = z.enum([
2
+ export const notionDateOrTimeFormat = z
3
+ .string()
4
+ .regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?(Z|\+\d{2}:\d{2}))?$/);
5
+ export const notionDateFormat = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
6
+ export const notionTimeFormat = z
7
+ .string()
8
+ .regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/);
9
+ export const notionCommonColorEnum = z.enum([
6
10
  'blue',
7
11
  'brown',
8
12
  'default',
@@ -12,17 +16,16 @@ export var notionCommonColorEnum = z.enum([
12
16
  'pink',
13
17
  'purple',
14
18
  'red',
15
- 'yellow'
19
+ 'yellow',
16
20
  ]);
17
- export var notionDateSchema = z.object({
21
+ export const notionDateSchema = z.object({
18
22
  start: notionDateOrTimeFormat,
19
23
  end: notionDateOrTimeFormat.nullable().optional(),
20
- time_zone: z.string().nullable().optional()
24
+ time_zone: z.string().nullable().optional(),
21
25
  });
22
- export var commonPropertyValues = function(type) {
23
- return {
24
- id: z.string(),
25
- type: z.literal(type),
26
- name: z.string().optional()
27
- };
28
- };
26
+ export const commonPropertyValues = (type) => ({
27
+ id: z.string(),
28
+ type: z.literal(type),
29
+ name: z.string().optional(),
30
+ });
31
+ //# sourceMappingURL=common.js.map