@driveflux/api-functions 0.0.7-next.2 → 0.0.7-next.21

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 (98) 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 +102 -398
  7. package/dist/auth/register.js.map +1 -1
  8. package/dist/auth/tokens.js +115 -430
  9. package/dist/auth/verifications.js +177 -583
  10. package/dist/constants.js +5 -4
  11. package/dist/mailjet/calls/manage-contacts-in-list.d.ts +2 -2
  12. package/dist/mailjet/calls/manage-contacts-in-list.d.ts.map +1 -1
  13. package/dist/mailjet/calls/manage-contacts-in-list.js +24 -168
  14. package/dist/mailjet/calls/manage-contacts-in-list.js.map +1 -1
  15. package/dist/mailjet/calls/manage-subscription-status.d.ts +2 -2
  16. package/dist/mailjet/calls/manage-subscription-status.d.ts.map +1 -1
  17. package/dist/mailjet/calls/manage-subscription-status.js +14 -154
  18. package/dist/mailjet/calls/manage-subscription-status.js.map +1 -1
  19. package/dist/mailjet/calls/request-service.d.ts +1 -1
  20. package/dist/mailjet/calls/request-service.d.ts.map +1 -1
  21. package/dist/mailjet/calls/request-service.js +18 -183
  22. package/dist/mailjet/refresh-email-preferences.js +26 -225
  23. package/dist/mailjet/set-contact.d.ts +2 -2
  24. package/dist/mailjet/set-contact.d.ts.map +1 -1
  25. package/dist/mailjet/set-contact.js +26 -217
  26. package/dist/mailjet/set-contact.js.map +1 -1
  27. package/dist/mailjet/types.d.ts +2 -2
  28. package/dist/mailjet/types.d.ts.map +1 -1
  29. package/dist/mailjet/types.js +2 -1
  30. package/dist/mailjet/utils/convert-to-array.d.ts +1 -1
  31. package/dist/mailjet/utils/convert-to-array.d.ts.map +1 -1
  32. package/dist/mailjet/utils/convert-to-array.js +9 -58
  33. package/dist/mailjet/utils/extract-email-preferences.d.ts +1 -1
  34. package/dist/mailjet/utils/extract-email-preferences.d.ts.map +1 -1
  35. package/dist/mailjet/utils/extract-email-preferences.js +41 -217
  36. package/dist/mailjet/utils/lists.js +30 -249
  37. package/dist/mailjet/utils/update-email-references.d.ts +2 -2
  38. package/dist/mailjet/utils/update-email-references.d.ts.map +1 -1
  39. package/dist/mailjet/utils/update-email-references.js +27 -208
  40. package/dist/mailjet/utils/update-email-references.js.map +1 -1
  41. package/dist/notion/client.js +48 -197
  42. package/dist/notion/helpful.js +29 -170
  43. package/dist/notion/schemas/block.js +49 -43
  44. package/dist/notion/schemas/common.js +17 -14
  45. package/dist/notion/schemas/database.js +125 -159
  46. package/dist/notion/schemas/emoji.js +3 -2
  47. package/dist/notion/schemas/file.js +10 -10
  48. package/dist/notion/schemas/kb.js +9 -8
  49. package/dist/notion/schemas/page.js +126 -171
  50. package/dist/notion/schemas/parent.js +9 -8
  51. package/dist/notion/schemas/user.js +21 -20
  52. package/dist/reservation/agree.d.ts +1 -1
  53. package/dist/reservation/agree.d.ts.map +1 -1
  54. package/dist/reservation/agree.js +19 -158
  55. package/dist/reservation/checks.d.ts +1 -1
  56. package/dist/reservation/checks.d.ts.map +1 -1
  57. package/dist/reservation/checks.js +23 -178
  58. package/dist/reservation/display-vehicle.d.ts +17 -17
  59. package/dist/reservation/display-vehicle.js +142 -514
  60. package/dist/reservation/display-vehicle.js.map +1 -1
  61. package/dist/reservation/fetch-or-create.d.ts +2 -2
  62. package/dist/reservation/fetch-or-create.d.ts.map +1 -1
  63. package/dist/reservation/fetch-or-create.js +199 -482
  64. package/dist/reservation/fetch-or-create.js.map +1 -1
  65. package/dist/reservation/invoice.d.ts +3 -3
  66. package/dist/reservation/invoice.d.ts.map +1 -1
  67. package/dist/reservation/invoice.js +198 -496
  68. package/dist/reservation/invoice.js.map +1 -1
  69. package/dist/reservation/payer.d.ts +1 -1
  70. package/dist/reservation/payer.d.ts.map +1 -1
  71. package/dist/reservation/payer.js +28 -177
  72. package/dist/reservation/reserve.d.ts +1 -1
  73. package/dist/reservation/reserve.d.ts.map +1 -1
  74. package/dist/reservation/reserve.js +36 -196
  75. package/dist/reservation/reserve.js.map +1 -1
  76. package/dist/reservation/types.d.ts +1 -0
  77. package/dist/reservation/types.d.ts.map +1 -1
  78. package/dist/reservation/types.js +2 -1
  79. package/dist/reservation/vehicle.d.ts +1 -1
  80. package/dist/reservation/vehicle.d.ts.map +1 -1
  81. package/dist/reservation/vehicle.js +26 -188
  82. package/dist/reservation/vehicle.js.map +1 -1
  83. package/dist/slack.d.ts +2 -2
  84. package/dist/slack.d.ts.map +1 -1
  85. package/dist/slack.js +67 -273
  86. package/dist/validation.d.ts +4 -4
  87. package/dist/validation.d.ts.map +1 -1
  88. package/dist/validation.js +89 -139
  89. package/dist/validation.js.map +1 -1
  90. package/dist/vehicle/vehicle-pricing/constants.d.ts +1 -1
  91. package/dist/vehicle/vehicle-pricing/constants.d.ts.map +1 -1
  92. package/dist/vehicle/vehicle-pricing/constants.js +33 -36
  93. package/dist/vehicle/vehicle-pricing/index.d.ts +1 -1
  94. package/dist/vehicle/vehicle-pricing/index.d.ts.map +1 -1
  95. package/dist/vehicle/vehicle-pricing/index.js +101 -259
  96. package/dist/vehicle/vehicle-pricing/index.js.map +1 -1
  97. package/dist/vehicle/vehicle-pricing/types.js +2 -1
  98. package/package.json +21 -21
@@ -1,212 +1,31 @@
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);
1
+ import { prisma } from '@driveflux/db';
2
+ import { userForEmailPreferencesQuery, } from './extract-email-preferences.js';
3
+ export const updateEmailPreferences = async (idOrUserForEmailPreferences, preferences) => {
4
+ const user = typeof idOrUserForEmailPreferences === 'string'
5
+ ? await prisma.user.findUnique({
6
+ where: { id: idOrUserForEmailPreferences },
7
+ ...userForEmailPreferencesQuery,
8
+ })
9
+ : idOrUserForEmailPreferences;
10
+ if (!user) {
11
+ return null;
13
12
  }
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
- });
13
+ const merged = {
14
+ ...user.emailPreferences,
15
+ ...preferences,
28
16
  };
29
- }
30
- function _define_property(obj, key, value) {
31
- if (key in obj) {
32
- Object.defineProperty(obj, key, {
33
- value: value,
34
- enumerable: true,
35
- configurable: true,
36
- writable: true
37
- });
38
- } else {
39
- obj[key] = value;
40
- }
41
- return obj;
42
- }
43
- function _object_spread(target) {
44
- for(var i = 1; i < arguments.length; i++){
45
- var source = arguments[i] != null ? arguments[i] : {};
46
- var ownKeys = Object.keys(source);
47
- if (typeof Object.getOwnPropertySymbols === "function") {
48
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
49
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
50
- }));
51
- }
52
- ownKeys.forEach(function(key) {
53
- _define_property(target, key, source[key]);
54
- });
55
- }
56
- return target;
57
- }
58
- function _ts_generator(thisArg, body) {
59
- var f, y, t, _ = {
60
- label: 0,
61
- sent: function() {
62
- if (t[0] & 1) throw t[1];
63
- return t[1];
17
+ const updated = await prisma.user.update({
18
+ where: { id: user.id },
19
+ data: {
20
+ emailPreferences: {
21
+ upsert: {
22
+ set: merged,
23
+ update: merged,
24
+ },
25
+ },
64
26
  },
65
- trys: [],
66
- ops: []
67
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
68
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
69
- return this;
70
- }), g;
71
- function verb(n) {
72
- return function(v) {
73
- return step([
74
- n,
75
- v
76
- ]);
77
- };
78
- }
79
- function step(op) {
80
- if (f) throw new TypeError("Generator is already executing.");
81
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
82
- 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;
83
- if (y = 0, t) op = [
84
- op[0] & 2,
85
- t.value
86
- ];
87
- switch(op[0]){
88
- case 0:
89
- case 1:
90
- t = op;
91
- break;
92
- case 4:
93
- _.label++;
94
- return {
95
- value: op[1],
96
- done: false
97
- };
98
- case 5:
99
- _.label++;
100
- y = op[1];
101
- op = [
102
- 0
103
- ];
104
- continue;
105
- case 7:
106
- op = _.ops.pop();
107
- _.trys.pop();
108
- continue;
109
- default:
110
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
111
- _ = 0;
112
- continue;
113
- }
114
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
115
- _.label = op[1];
116
- break;
117
- }
118
- if (op[0] === 6 && _.label < t[1]) {
119
- _.label = t[1];
120
- t = op;
121
- break;
122
- }
123
- if (t && _.label < t[2]) {
124
- _.label = t[2];
125
- _.ops.push(op);
126
- break;
127
- }
128
- if (t[2]) _.ops.pop();
129
- _.trys.pop();
130
- continue;
131
- }
132
- op = body.call(thisArg, _);
133
- } catch (e) {
134
- op = [
135
- 6,
136
- e
137
- ];
138
- y = 0;
139
- } finally{
140
- f = t = 0;
141
- }
142
- if (op[0] & 5) throw op[1];
143
- return {
144
- value: op[0] ? op[1] : void 0,
145
- done: true
146
- };
147
- }
148
- }
149
- import { prisma } from '@driveflux/db';
150
- import { userForEmailPreferencesQuery } from './extract-email-preferences';
151
- export var updateEmailPreferences = function(idOrUserForEmailPreferences, preferences) {
152
- return _async_to_generator(function() {
153
- var user, _tmp, merged, updated;
154
- return _ts_generator(this, function(_state) {
155
- switch(_state.label){
156
- case 0:
157
- if (!(typeof idOrUserForEmailPreferences === 'string')) return [
158
- 3,
159
- 2
160
- ];
161
- return [
162
- 4,
163
- prisma.user.findUnique(_object_spread({
164
- where: {
165
- id: idOrUserForEmailPreferences
166
- }
167
- }, userForEmailPreferencesQuery))
168
- ];
169
- case 1:
170
- _tmp = _state.sent();
171
- return [
172
- 3,
173
- 3
174
- ];
175
- case 2:
176
- _tmp = idOrUserForEmailPreferences;
177
- _state.label = 3;
178
- case 3:
179
- user = _tmp;
180
- if (!user) {
181
- return [
182
- 2,
183
- null
184
- ];
185
- }
186
- merged = _object_spread({}, user.emailPreferences, preferences);
187
- return [
188
- 4,
189
- prisma.user.update(_object_spread({
190
- where: {
191
- id: user.id
192
- },
193
- data: {
194
- emailPreferences: {
195
- upsert: {
196
- set: merged,
197
- update: merged
198
- }
199
- }
200
- }
201
- }, userForEmailPreferencesQuery))
202
- ];
203
- case 4:
204
- updated = _state.sent();
205
- return [
206
- 2,
207
- updated
208
- ];
209
- }
210
- });
211
- })();
27
+ ...userForEmailPreferencesQuery,
28
+ });
29
+ return updated;
212
30
  };
31
+ //# sourceMappingURL=update-email-references.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-email-references.js","sourceRoot":"","sources":["../../../src/mailjet/utils/update-email-references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,OAAO,EAEN,4BAA4B,GAC5B,MAAM,6BAA6B,CAAA;AAEpC,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAG1C,2BAA8B,EAC9B,WAA6B,EACsC,EAAE;IACrE,MAAM,IAAI,GACT,OAAO,2BAA2B,KAAK,QAAQ;QAC9C,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;YAC7B,KAAK,EAAE,EAAE,EAAE,EAAE,2BAA2B,EAAE;YAC1C,GAAG,4BAA4B;SAC/B,CAAC;QACH,CAAC,CAAE,2BAAuD,CAAA;IAE5D,IAAI,CAAC,IAAI,EAAE,CAAC;QACX,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,MAAM,GAAG;QACd,GAAG,IAAI,CAAC,gBAAgB;QACxB,GAAG,WAAW;KACd,CAAA;IACD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QACxC,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,IAAI,EAAE;YACL,gBAAgB,EAAE;gBACjB,MAAM,EAAE;oBACP,GAAG,EAAE,MAAM;oBACX,MAAM,EAAE,MAAM;iBACd;aACD;SACD;QACD,GAAG,4BAA4B;KAC/B,CAAC,CAAA;IAEF,OAAO,OAAyD,CAAA;AACjE,CAAC,CAAA"}
1
+ {"version":3,"file":"update-email-references.js","sourceRoot":"","sources":["../../../src/mailjet/utils/update-email-references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,OAAO,EAEN,4BAA4B,GAC5B,MAAM,gCAAgC,CAAA;AAEvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAG1C,2BAA8B,EAC9B,WAA6B,EACsC,EAAE;IACrE,MAAM,IAAI,GACT,OAAO,2BAA2B,KAAK,QAAQ;QAC9C,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;YAC7B,KAAK,EAAE,EAAE,EAAE,EAAE,2BAA2B,EAAE;YAC1C,GAAG,4BAA4B;SAC/B,CAAC;QACH,CAAC,CAAE,2BAAuD,CAAA;IAE5D,IAAI,CAAC,IAAI,EAAE,CAAC;QACX,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,MAAM,GAAG;QACd,GAAG,IAAI,CAAC,gBAAgB;QACxB,GAAG,WAAW;KACd,CAAA;IACD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QACxC,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,IAAI,EAAE;YACL,gBAAgB,EAAE;gBACjB,MAAM,EAAE;oBACP,GAAG,EAAE,MAAM;oBACX,MAAM,EAAE,MAAM;iBACd;aACD;SACD;QACD,GAAG,4BAA4B;KAC/B,CAAC,CAAA;IAEF,OAAO,OAAyD,CAAA;AACjE,CAAC,CAAA"}
@@ -1,212 +1,63 @@
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 { slackLater } from '@driveflux/api-functions/slack';
122
2
  import { config } from '@driveflux/config/backend';
123
3
  import { initSingleton } from '@driveflux/singleton';
124
4
  import { Client } from '@notionhq/client';
125
- export var getNotion = function() {
126
- return initSingleton('notionClient', function() {
127
- return new Client({
128
- auth: config.notion.secret
129
- });
130
- });
5
+ export const getNotion = () => {
6
+ return initSingleton('notionClient', () => new Client({
7
+ auth: config.notion.secret,
8
+ }));
131
9
  };
132
- export var announceFluxstersAnniversaries = function(property, constructMessage) {
133
- return _async_to_generator(function() {
134
- var notion, results, relevantPeople, message;
135
- return _ts_generator(this, function(_state) {
136
- switch(_state.label){
137
- case 0:
138
- if (!config.notion.fluxstersDatabaseId) {
139
- return [
140
- 2,
141
- {
142
- counts: -1,
143
- message: 'No fluxsters database id configured'
144
- }
145
- ];
146
- }
147
- notion = getNotion();
148
- return [
149
- 4,
150
- notion.databases.query({
151
- database_id: config.notion.fluxstersDatabaseId
152
- })
153
- ];
154
- case 1:
155
- results = _state.sent().results;
156
- relevantPeople = results.filter(function(result) {
157
- var _resultPropperty_date;
158
- var resultPropperty = result.properties[property];
159
- if (resultPropperty.type !== 'date' || !((_resultPropperty_date = resultPropperty.date) === null || _resultPropperty_date === void 0 ? void 0 : _resultPropperty_date.start)) {
160
- return false;
161
- }
162
- if (calculateYears(result, property) < 1) {
163
- return false;
164
- }
165
- var date = new Date(resultPropperty.date.start);
166
- var todayDate = new Date();
167
- if (todayDate.getDate() === date.getDate() && todayDate.getMonth() === date.getMonth()) {
168
- return true;
169
- }
170
- // leap year
171
- if (todayDate.getDate() === 28 && date.getDate() === 29 && todayDate.getMonth() === 1 && date.getMonth() === 1) {
172
- return true;
173
- }
174
- });
175
- if (relevantPeople.length > 0) {
176
- message = constructMessage(relevantPeople);
177
- slackLater(message, config.slack.mainFluxChannel);
178
- return [
179
- 2,
180
- {
181
- counts: relevantPeople.length,
182
- message: message
183
- }
184
- ];
185
- }
186
- return [
187
- 2,
188
- {
189
- counts: relevantPeople.length
190
- }
191
- ];
192
- }
193
- });
194
- })();
10
+ export const announceFluxstersAnniversaries = async (property, constructMessage) => {
11
+ if (!config.notion.fluxstersDatabaseId) {
12
+ return { counts: -1, message: 'No fluxsters database id configured' };
13
+ }
14
+ const notion = getNotion();
15
+ const { results } = await notion.databases.query({
16
+ database_id: config.notion.fluxstersDatabaseId,
17
+ });
18
+ const relevantPeople = results.filter((result) => {
19
+ const resultPropperty = result.properties[property];
20
+ if (resultPropperty.type !== 'date' || !resultPropperty.date?.start) {
21
+ return false;
22
+ }
23
+ if (calculateYears(result, property) < 1) {
24
+ return false;
25
+ }
26
+ const date = new Date(resultPropperty.date.start);
27
+ const todayDate = new Date();
28
+ if (todayDate.getDate() === date.getDate() &&
29
+ todayDate.getMonth() === date.getMonth()) {
30
+ return true;
31
+ }
32
+ // leap year
33
+ if (todayDate.getDate() === 28 &&
34
+ date.getDate() === 29 &&
35
+ todayDate.getMonth() === 1 &&
36
+ date.getMonth() === 1) {
37
+ return true;
38
+ }
39
+ });
40
+ if (relevantPeople.length > 0) {
41
+ const message = constructMessage(relevantPeople);
42
+ slackLater(message, config.slack.mainFluxChannel);
43
+ return { counts: relevantPeople.length, message };
44
+ }
45
+ return { counts: relevantPeople.length };
195
46
  };
196
- export var getNameFrom = function(person) {
197
- var nameProperty = person.properties.Name;
47
+ export const getNameFrom = (person) => {
48
+ const nameProperty = person.properties.Name;
198
49
  if (nameProperty.type !== 'title') {
199
50
  return '';
200
51
  }
201
52
  return nameProperty.title[0].plain_text;
202
53
  };
203
- export var calculateYears = function(person, property) {
204
- var _joinedDateProperty_date, _joinedDateProperty_date1;
205
- var joinedDateProperty = person.properties[property];
206
- if (joinedDateProperty.type !== 'date' || !((_joinedDateProperty_date = joinedDateProperty.date) === null || _joinedDateProperty_date === void 0 ? void 0 : _joinedDateProperty_date.start)) {
54
+ export const calculateYears = (person, property) => {
55
+ const joinedDateProperty = person.properties[property];
56
+ if (joinedDateProperty.type !== 'date' || !joinedDateProperty.date?.start) {
207
57
  return 0;
208
58
  }
209
- var today = new Date();
210
- var joinedDate = new Date((_joinedDateProperty_date1 = joinedDateProperty.date) === null || _joinedDateProperty_date1 === void 0 ? void 0 : _joinedDateProperty_date1.start);
59
+ const today = new Date();
60
+ const joinedDate = new Date(joinedDateProperty.date?.start);
211
61
  return today.getFullYear() - joinedDate.getFullYear();
212
62
  };
63
+ //# sourceMappingURL=client.js.map