@driveflux/api-functions 0.0.7-next.5 → 0.0.7-next.7
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/auth/confirm.js +24 -29
- package/dist/auth/emails.js +12 -13
- package/dist/auth/formatter.js +5 -5
- package/dist/auth/otp.js +66 -50
- package/dist/auth/register.js +44 -36
- package/dist/auth/register.js.map +1 -1
- package/dist/auth/tokens.js +58 -55
- package/dist/auth/verifications.js +53 -52
- package/dist/constants.js +0 -1
- package/dist/mailjet/calls/manage-contacts-in-list.d.ts +2 -2
- package/dist/mailjet/calls/manage-contacts-in-list.d.ts.map +1 -1
- package/dist/mailjet/calls/manage-contacts-in-list.js +7 -8
- package/dist/mailjet/calls/manage-contacts-in-list.js.map +1 -1
- package/dist/mailjet/calls/manage-subscription-status.d.ts +2 -2
- package/dist/mailjet/calls/manage-subscription-status.d.ts.map +1 -1
- package/dist/mailjet/calls/manage-subscription-status.js +6 -7
- package/dist/mailjet/calls/manage-subscription-status.js.map +1 -1
- package/dist/mailjet/calls/request-service.js +7 -6
- package/dist/mailjet/refresh-email-preferences.js +11 -12
- package/dist/mailjet/set-contact.d.ts +2 -2
- package/dist/mailjet/set-contact.d.ts.map +1 -1
- package/dist/mailjet/set-contact.js +14 -15
- package/dist/mailjet/set-contact.js.map +1 -1
- package/dist/mailjet/types.d.ts +2 -2
- package/dist/mailjet/types.d.ts.map +1 -1
- package/dist/mailjet/types.js +1 -2
- package/dist/mailjet/utils/convert-to-array.d.ts +1 -1
- package/dist/mailjet/utils/convert-to-array.d.ts.map +1 -1
- package/dist/mailjet/utils/convert-to-array.js +8 -6
- package/dist/mailjet/utils/extract-email-preferences.d.ts +1 -1
- package/dist/mailjet/utils/extract-email-preferences.d.ts.map +1 -1
- package/dist/mailjet/utils/extract-email-preferences.js +14 -15
- package/dist/mailjet/utils/lists.js +7 -8
- package/dist/mailjet/utils/update-email-references.d.ts +2 -2
- package/dist/mailjet/utils/update-email-references.d.ts.map +1 -1
- package/dist/mailjet/utils/update-email-references.js +16 -15
- package/dist/mailjet/utils/update-email-references.js.map +1 -1
- package/dist/notion/client.js +22 -19
- package/dist/notion/helpful.js +6 -9
- package/dist/notion/schemas/block.js +42 -48
- package/dist/notion/schemas/common.js +9 -14
- package/dist/notion/schemas/database.js +62 -60
- package/dist/notion/schemas/emoji.js +1 -2
- package/dist/notion/schemas/file.js +9 -9
- package/dist/notion/schemas/kb.js +5 -6
- package/dist/notion/schemas/page.js +72 -61
- package/dist/notion/schemas/parent.js +4 -5
- package/dist/notion/schemas/user.js +18 -19
- package/dist/reservation/agree.d.ts +1 -1
- package/dist/reservation/agree.d.ts.map +1 -1
- package/dist/reservation/agree.js +6 -7
- package/dist/reservation/checks.d.ts +1 -1
- package/dist/reservation/checks.d.ts.map +1 -1
- package/dist/reservation/checks.js +3 -4
- package/dist/reservation/display-vehicle.d.ts +35 -35
- package/dist/reservation/display-vehicle.js +1 -1
- package/dist/reservation/display-vehicle.js.map +1 -1
- package/dist/reservation/fetch-or-create.d.ts +1 -1
- package/dist/reservation/fetch-or-create.d.ts.map +1 -1
- package/dist/reservation/fetch-or-create.js +49 -55
- package/dist/reservation/fetch-or-create.js.map +1 -1
- package/dist/reservation/invoice.d.ts +1 -1
- package/dist/reservation/invoice.d.ts.map +1 -1
- package/dist/reservation/invoice.js +62 -74
- package/dist/reservation/payer.d.ts +1 -1
- package/dist/reservation/payer.d.ts.map +1 -1
- package/dist/reservation/payer.js +5 -6
- package/dist/reservation/reserve.d.ts +1 -1
- package/dist/reservation/reserve.d.ts.map +1 -1
- package/dist/reservation/reserve.js +8 -9
- package/dist/reservation/reserve.js.map +1 -1
- package/dist/reservation/types.js +1 -2
- package/dist/reservation/vehicle.d.ts +1 -1
- package/dist/reservation/vehicle.d.ts.map +1 -1
- package/dist/reservation/vehicle.js +15 -18
- package/dist/reservation/vehicle.js.map +1 -1
- package/dist/slack.js +24 -29
- package/dist/validation.js +69 -71
- package/dist/vehicle/vehicle-pricing/constants.d.ts +1 -1
- package/dist/vehicle/vehicle-pricing/constants.d.ts.map +1 -1
- package/dist/vehicle/vehicle-pricing/constants.js +22 -19
- package/dist/vehicle/vehicle-pricing/index.d.ts +1 -1
- package/dist/vehicle/vehicle-pricing/index.d.ts.map +1 -1
- package/dist/vehicle/vehicle-pricing/index.js +30 -44
- package/dist/vehicle/vehicle-pricing/index.js.map +1 -1
- package/dist/vehicle/vehicle-pricing/types.js +1 -2
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { prisma } from '@driveflux/db';
|
|
2
2
|
import { makeProblem, PROBLEM_NOT_FOUND } from '@driveflux/problem';
|
|
3
3
|
import { Err, Ok } from '@driveflux/result';
|
|
4
|
-
import { manageSubscriptionStatus } from './calls/manage-subscription-status';
|
|
5
|
-
import { convertToArray } from './utils/convert-to-array';
|
|
6
|
-
import { updateEmailPreferences } from './utils/update-email-references';
|
|
4
|
+
import { manageSubscriptionStatus } from './calls/manage-subscription-status.js';
|
|
5
|
+
import { convertToArray } from './utils/convert-to-array.js';
|
|
6
|
+
import { updateEmailPreferences } from './utils/update-email-references.js';
|
|
7
7
|
const userForSetInContactListlPreferencesQuery = {
|
|
8
8
|
select: {
|
|
9
9
|
id: true,
|
|
@@ -13,18 +13,18 @@ const userForSetInContactListlPreferencesQuery = {
|
|
|
13
13
|
subscriptions: {
|
|
14
14
|
select: {
|
|
15
15
|
ended: true,
|
|
16
|
-
active: true
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
16
|
+
active: true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
20
|
};
|
|
21
|
-
export const setContactInList = async (idOrUserForSetInContactListlPreferences, preferences)
|
|
22
|
-
const user = typeof idOrUserForSetInContactListlPreferences === 'string'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
export const setContactInList = async (idOrUserForSetInContactListlPreferences, preferences)=>{
|
|
22
|
+
const user = typeof idOrUserForSetInContactListlPreferences === 'string' ? await prisma.user.findUnique({
|
|
23
|
+
where: {
|
|
24
|
+
id: idOrUserForSetInContactListlPreferences
|
|
25
|
+
},
|
|
26
|
+
...userForSetInContactListlPreferencesQuery
|
|
27
|
+
}) : idOrUserForSetInContactListlPreferences;
|
|
28
28
|
if (!user) {
|
|
29
29
|
return new Err(makeProblem(PROBLEM_NOT_FOUND, 'User not found'));
|
|
30
30
|
}
|
|
@@ -36,4 +36,3 @@ export const setContactInList = async (idOrUserForSetInContactListlPreferences,
|
|
|
36
36
|
const results = await manageSubscriptionStatus(user.email, items);
|
|
37
37
|
return new Ok(results);
|
|
38
38
|
};
|
|
39
|
-
//# sourceMappingURL=set-contact.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-contact.js","sourceRoot":"","sources":["../../src/mailjet/set-contact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"set-contact.js","sourceRoot":"","sources":["../../src/mailjet/set-contact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAA;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAM3E,MAAM,wCAAwC,GAAG;IAChD,MAAM,EAAE;QACP,EAAE,EAAE,IAAI;QACR,gBAAgB,EAAE,IAAI;QACtB,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,IAAI;QACX,aAAa,EAAE;YACd,MAAM,EAAE;gBACP,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,IAAI;aACZ;SACD;KACD;CACyC,CAAA;AAE3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACpC,uCAEsC,EACtC,WAA6B,EAC5B,EAAE;IACH,MAAM,IAAI,GACT,OAAO,uCAAuC,KAAK,QAAQ;QAC1D,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;YAC7B,KAAK,EAAE,EAAE,EAAE,EAAE,uCAAuC,EAAE;YACtD,GAAG,wCAAwC;SAC3C,CAAC;QACH,CAAC,CAAC,uCAAuC,CAAA;IAE3C,IAAI,CAAC,IAAI,EAAE,CAAC;QACX,OAAO,IAAI,GAAG,CAAC,WAAW,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC,CAAA;IACjE,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IAE/D,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,IAAI,EAAE,CAAC,4BAA4B,CAAC,CAAA;IAC5C,CAAC;IAED,MAAM,KAAK,GAAG,cAAc,CAAC,WAAW,CAAC,CAAA;IAEzC,MAAM,OAAO,GAAG,MAAM,wBAAwB,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAEjE,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC,CAAA;AACvB,CAAC,CAAA"}
|
package/dist/mailjet/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Subscription, User } from '@driveflux/db';
|
|
2
|
-
import type { ListName } from './utils/lists';
|
|
2
|
+
import type { ListName } from './utils/lists.js';
|
|
3
3
|
export type UserWithSubscription = User & {
|
|
4
4
|
subscriptions: Subscription[];
|
|
5
5
|
};
|
|
@@ -26,6 +26,6 @@ export type MailjetOptions = {
|
|
|
26
26
|
list: ListName;
|
|
27
27
|
unsub?: boolean;
|
|
28
28
|
};
|
|
29
|
-
export type { ListName, MailjetLists } from './utils/lists';
|
|
29
|
+
export type { ListName, MailjetLists } from './utils/lists.js';
|
|
30
30
|
export type StatusAction = 'addforce' | 'addnoforce' | 'remove' | 'unsub';
|
|
31
31
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mailjet/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mailjet/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG;IAAE,aAAa,EAAE,YAAY,EAAE,CAAA;CAAE,CAAA;AAE3E,MAAM,MAAM,OAAO,GAAG;IACrB,uBAAuB,EAAE,OAAO,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,IAAI,GAAG,MAAM,CAAA;IACxB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B,EAAE,IAAI,GAAG,MAAM,CAAA;IAC9C,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,iBAAiB,EAAE,KAAK,CAAA;IACxB,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,YAAY,EAAE,IAAI,GAAG,MAAM,CAAA;IAC3B,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;KAAG,GAAG,IAAI,QAAQ,CAAC,CAAC,EAAE,OAAO;CAAE,CAAA;AAE9D,MAAM,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,QAAQ,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE9D,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAA"}
|
package/dist/mailjet/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
export { };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EmailPreferences } from '../types';
|
|
1
|
+
import type { EmailPreferences } from '../types.js';
|
|
2
2
|
export declare const convertToArray: (preferences?: EmailPreferences, isBusiness?: boolean) => {
|
|
3
3
|
list: "generalMarketing" | "noActiveSubs" | "signUpOnly" | "signUpPaymentAdded" | "activeSub" | "expiredSub" | "activeSubBusiness" | "activeSubPersonal";
|
|
4
4
|
action: "addnoforce" | "unsub";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-to-array.d.ts","sourceRoot":"","sources":["../../../src/mailjet/utils/convert-to-array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAA0B,MAAM,
|
|
1
|
+
{"version":3,"file":"convert-to-array.d.ts","sourceRoot":"","sources":["../../../src/mailjet/utils/convert-to-array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAA0B,MAAM,aAAa,CAAA;AAE3E,eAAO,MAAM,cAAc,GAC1B,cAAc,gBAAgB,EAC9B,aAAa,OAAO;;;GA0BpB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const convertToArray = (preferences, isBusiness)
|
|
1
|
+
export const convertToArray = (preferences, isBusiness)=>{
|
|
2
2
|
if (!preferences) {
|
|
3
3
|
return [];
|
|
4
4
|
}
|
|
@@ -6,18 +6,20 @@ export const convertToArray = (preferences, isBusiness) => {
|
|
|
6
6
|
if (typeof isBusiness === 'boolean') {
|
|
7
7
|
preferencesArray.push([
|
|
8
8
|
'activeSubBusiness',
|
|
9
|
-
!!preferences?.activeSub && isBusiness
|
|
9
|
+
!!preferences?.activeSub && isBusiness
|
|
10
10
|
]);
|
|
11
11
|
preferencesArray.push([
|
|
12
12
|
'activeSubPersonal',
|
|
13
|
-
!!preferences?.activeSub && !isBusiness
|
|
13
|
+
!!preferences?.activeSub && !isBusiness
|
|
14
14
|
]);
|
|
15
15
|
}
|
|
16
|
-
const items = preferencesArray.map(([key, value])
|
|
16
|
+
const items = preferencesArray.map(([key, value])=>{
|
|
17
17
|
const list = key;
|
|
18
18
|
const action = value ? 'addnoforce' : 'unsub';
|
|
19
|
-
return {
|
|
19
|
+
return {
|
|
20
|
+
list,
|
|
21
|
+
action
|
|
22
|
+
};
|
|
20
23
|
});
|
|
21
24
|
return items;
|
|
22
25
|
};
|
|
23
|
-
//# sourceMappingURL=convert-to-array.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Prisma } from '@driveflux/db';
|
|
2
|
-
import type { EmailPreferences } from '../types';
|
|
2
|
+
import type { EmailPreferences } from '../types.js';
|
|
3
3
|
export type UserForEmailPreferences = Prisma.UserGetPayload<typeof userForEmailPreferencesQuery>;
|
|
4
4
|
export declare const userForEmailPreferencesQuery: {
|
|
5
5
|
readonly select: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-email-preferences.d.ts","sourceRoot":"","sources":["../../../src/mailjet/utils/extract-email-preferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"extract-email-preferences.d.ts","sourceRoot":"","sources":["../../../src/mailjet/utils/extract-email-preferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAY,MAAM,aAAa,CAAA;AAE7D,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,cAAc,CAC1D,OAAO,4BAA4B,CACnC,CAAA;AAED,eAAO,MAAM,4BAA4B;;;;;;;;;;;CAWE,CAAA;AAE3C,eAAO,MAAM,2BAA2B,GACvC,6BAA6B,MAAM,GAAG,uBAAuB,0CA8C7D,CAAA"}
|
|
@@ -6,18 +6,18 @@ export const userForEmailPreferencesQuery = {
|
|
|
6
6
|
subscriptions: {
|
|
7
7
|
select: {
|
|
8
8
|
ended: true,
|
|
9
|
-
active: true
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
9
|
+
active: true
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
13
|
};
|
|
14
|
-
export const extractUserEmailPreferences = async (idOrUserForEmailPreferences)
|
|
15
|
-
const user = typeof idOrUserForEmailPreferences === 'string'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
export const extractUserEmailPreferences = async (idOrUserForEmailPreferences)=>{
|
|
15
|
+
const user = typeof idOrUserForEmailPreferences === 'string' ? await prisma.user.findUnique({
|
|
16
|
+
where: {
|
|
17
|
+
id: idOrUserForEmailPreferences
|
|
18
|
+
},
|
|
19
|
+
...userForEmailPreferencesQuery
|
|
20
|
+
}) : idOrUserForEmailPreferences;
|
|
21
21
|
if (!user?.emailPreferences?.generalMarketing) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
@@ -26,13 +26,13 @@ export const extractUserEmailPreferences = async (idOrUserForEmailPreferences) =
|
|
|
26
26
|
if (subscriptions.length > 0) {
|
|
27
27
|
list = 'noActiveSubs';
|
|
28
28
|
}
|
|
29
|
-
for
|
|
29
|
+
for(let i = 0; i < subscriptions.length; i++){
|
|
30
30
|
if (subscriptions[i].ended) {
|
|
31
31
|
list = 'expiredSub';
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
for
|
|
35
|
+
for(let i = 0; i < subscriptions.length; i++){
|
|
36
36
|
if (subscriptions[i].active && !subscriptions[i].ended) {
|
|
37
37
|
list = 'activeSub';
|
|
38
38
|
break;
|
|
@@ -44,8 +44,7 @@ export const extractUserEmailPreferences = async (idOrUserForEmailPreferences) =
|
|
|
44
44
|
signUpPaymentAdded: false,
|
|
45
45
|
activeSub: false,
|
|
46
46
|
expiredSub: false,
|
|
47
|
-
[list]: true
|
|
47
|
+
[list]: true
|
|
48
48
|
};
|
|
49
49
|
return newList;
|
|
50
50
|
};
|
|
51
|
-
//# sourceMappingURL=extract-email-preferences.js.map
|
|
@@ -7,13 +7,13 @@ export const listsNames = [
|
|
|
7
7
|
'activeSub',
|
|
8
8
|
'expiredSub',
|
|
9
9
|
'activeSubBusiness',
|
|
10
|
-
'activeSubPersonal'
|
|
10
|
+
'activeSubPersonal'
|
|
11
11
|
];
|
|
12
|
-
export const getLists = async ()
|
|
12
|
+
export const getLists = async ()=>{
|
|
13
13
|
const listObject = await prisma.platformConfig.findFirst({
|
|
14
14
|
where: {
|
|
15
|
-
key: 'mailjetLists'
|
|
16
|
-
}
|
|
15
|
+
key: 'mailjetLists'
|
|
16
|
+
}
|
|
17
17
|
});
|
|
18
18
|
if (listObject?.value) {
|
|
19
19
|
const lists = JSON.parse(listObject.value);
|
|
@@ -21,14 +21,14 @@ export const getLists = async () => {
|
|
|
21
21
|
}
|
|
22
22
|
return {};
|
|
23
23
|
};
|
|
24
|
-
export const getListByRef = async (ref)
|
|
24
|
+
export const getListByRef = async (ref)=>{
|
|
25
25
|
const lists = await getLists();
|
|
26
26
|
let list;
|
|
27
|
-
for (const [name, id] of Object.entries(lists))
|
|
27
|
+
for (const [name, id] of Object.entries(lists)){
|
|
28
28
|
if (name === ref || id === ref) {
|
|
29
29
|
list = {
|
|
30
30
|
name: name,
|
|
31
|
-
id
|
|
31
|
+
id
|
|
32
32
|
};
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
@@ -38,4 +38,3 @@ export const getListByRef = async (ref) => {
|
|
|
38
38
|
}
|
|
39
39
|
return list;
|
|
40
40
|
};
|
|
41
|
-
//# sourceMappingURL=lists.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EmailPreferences } from '../types';
|
|
2
|
-
import { type UserForEmailPreferences } from './extract-email-preferences';
|
|
1
|
+
import type { EmailPreferences } from '../types.js';
|
|
2
|
+
import { type UserForEmailPreferences } from './extract-email-preferences.js';
|
|
3
3
|
export declare const updateEmailPreferences: <U extends string | UserForEmailPreferences>(idOrUserForEmailPreferences: U, preferences: EmailPreferences) => Promise<(U extends string ? UserForEmailPreferences : U) | null>;
|
|
4
4
|
//# sourceMappingURL=update-email-references.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-email-references.d.ts","sourceRoot":"","sources":["../../../src/mailjet/utils/update-email-references.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"update-email-references.d.ts","sourceRoot":"","sources":["../../../src/mailjet/utils/update-email-references.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EACN,KAAK,uBAAuB,EAE5B,MAAM,gCAAgC,CAAA;AAEvC,eAAO,MAAM,sBAAsB,GAClC,CAAC,SAAS,MAAM,GAAG,uBAAuB,EAE1C,6BAA6B,CAAC,EAC9B,aAAa,gBAAgB,KAC3B,OAAO,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,uBAAuB,GAAG,CAAC,CAAC,GAAG,IAAI,CA+BjE,CAAA"}
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { prisma } from '@driveflux/db';
|
|
2
|
-
import { userForEmailPreferencesQuery
|
|
3
|
-
export const updateEmailPreferences = async (idOrUserForEmailPreferences, preferences)
|
|
4
|
-
const user = typeof idOrUserForEmailPreferences === 'string'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { userForEmailPreferencesQuery } from './extract-email-preferences.js';
|
|
3
|
+
export const updateEmailPreferences = async (idOrUserForEmailPreferences, preferences)=>{
|
|
4
|
+
const user = typeof idOrUserForEmailPreferences === 'string' ? await prisma.user.findUnique({
|
|
5
|
+
where: {
|
|
6
|
+
id: idOrUserForEmailPreferences
|
|
7
|
+
},
|
|
8
|
+
...userForEmailPreferencesQuery
|
|
9
|
+
}) : idOrUserForEmailPreferences;
|
|
10
10
|
if (!user) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
13
|
const merged = {
|
|
14
14
|
...user.emailPreferences,
|
|
15
|
-
...preferences
|
|
15
|
+
...preferences
|
|
16
16
|
};
|
|
17
17
|
const updated = await prisma.user.update({
|
|
18
|
-
where: {
|
|
18
|
+
where: {
|
|
19
|
+
id: user.id
|
|
20
|
+
},
|
|
19
21
|
data: {
|
|
20
22
|
emailPreferences: {
|
|
21
23
|
upsert: {
|
|
22
24
|
set: merged,
|
|
23
|
-
update: merged
|
|
24
|
-
}
|
|
25
|
-
}
|
|
25
|
+
update: merged
|
|
26
|
+
}
|
|
27
|
+
}
|
|
26
28
|
},
|
|
27
|
-
...userForEmailPreferencesQuery
|
|
29
|
+
...userForEmailPreferencesQuery
|
|
28
30
|
});
|
|
29
31
|
return updated;
|
|
30
32
|
};
|
|
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,
|
|
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"}
|
package/dist/notion/client.js
CHANGED
|
@@ -2,20 +2,23 @@ import { slackLater } from '@driveflux/api-functions/slack';
|
|
|
2
2
|
import { config } from '@driveflux/config/backend';
|
|
3
3
|
import { initSingleton } from '@driveflux/singleton';
|
|
4
4
|
import { Client } from '@notionhq/client';
|
|
5
|
-
export const getNotion = ()
|
|
6
|
-
return initSingleton('notionClient', ()
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export const getNotion = ()=>{
|
|
6
|
+
return initSingleton('notionClient', ()=>new Client({
|
|
7
|
+
auth: config.notion.secret
|
|
8
|
+
}));
|
|
9
9
|
};
|
|
10
|
-
export const announceFluxstersAnniversaries = async (property, constructMessage)
|
|
10
|
+
export const announceFluxstersAnniversaries = async (property, constructMessage)=>{
|
|
11
11
|
if (!config.notion.fluxstersDatabaseId) {
|
|
12
|
-
return {
|
|
12
|
+
return {
|
|
13
|
+
counts: -1,
|
|
14
|
+
message: 'No fluxsters database id configured'
|
|
15
|
+
};
|
|
13
16
|
}
|
|
14
17
|
const notion = getNotion();
|
|
15
18
|
const { results } = await notion.databases.query({
|
|
16
|
-
database_id: config.notion.fluxstersDatabaseId
|
|
19
|
+
database_id: config.notion.fluxstersDatabaseId
|
|
17
20
|
});
|
|
18
|
-
const relevantPeople = results.filter((result)
|
|
21
|
+
const relevantPeople = results.filter((result)=>{
|
|
19
22
|
const resultPropperty = result.properties[property];
|
|
20
23
|
if (resultPropperty.type !== 'date' || !resultPropperty.date?.start) {
|
|
21
24
|
return false;
|
|
@@ -25,33 +28,34 @@ export const announceFluxstersAnniversaries = async (property, constructMessage)
|
|
|
25
28
|
}
|
|
26
29
|
const date = new Date(resultPropperty.date.start);
|
|
27
30
|
const todayDate = new Date();
|
|
28
|
-
if (todayDate.getDate() === date.getDate() &&
|
|
29
|
-
todayDate.getMonth() === date.getMonth()) {
|
|
31
|
+
if (todayDate.getDate() === date.getDate() && todayDate.getMonth() === date.getMonth()) {
|
|
30
32
|
return true;
|
|
31
33
|
}
|
|
32
34
|
// leap year
|
|
33
|
-
if (todayDate.getDate() === 28 &&
|
|
34
|
-
date.getDate() === 29 &&
|
|
35
|
-
todayDate.getMonth() === 1 &&
|
|
36
|
-
date.getMonth() === 1) {
|
|
35
|
+
if (todayDate.getDate() === 28 && date.getDate() === 29 && todayDate.getMonth() === 1 && date.getMonth() === 1) {
|
|
37
36
|
return true;
|
|
38
37
|
}
|
|
39
38
|
});
|
|
40
39
|
if (relevantPeople.length > 0) {
|
|
41
40
|
const message = constructMessage(relevantPeople);
|
|
42
41
|
slackLater(message, config.slack.mainFluxChannel);
|
|
43
|
-
return {
|
|
42
|
+
return {
|
|
43
|
+
counts: relevantPeople.length,
|
|
44
|
+
message
|
|
45
|
+
};
|
|
44
46
|
}
|
|
45
|
-
return {
|
|
47
|
+
return {
|
|
48
|
+
counts: relevantPeople.length
|
|
49
|
+
};
|
|
46
50
|
};
|
|
47
|
-
export const getNameFrom = (person)
|
|
51
|
+
export const getNameFrom = (person)=>{
|
|
48
52
|
const nameProperty = person.properties.Name;
|
|
49
53
|
if (nameProperty.type !== 'title') {
|
|
50
54
|
return '';
|
|
51
55
|
}
|
|
52
56
|
return nameProperty.title[0].plain_text;
|
|
53
57
|
};
|
|
54
|
-
export const calculateYears = (person, property)
|
|
58
|
+
export const calculateYears = (person, property)=>{
|
|
55
59
|
const joinedDateProperty = person.properties[property];
|
|
56
60
|
if (joinedDateProperty.type !== 'date' || !joinedDateProperty.date?.start) {
|
|
57
61
|
return 0;
|
|
@@ -60,4 +64,3 @@ export const calculateYears = (person, property) => {
|
|
|
60
64
|
const joinedDate = new Date(joinedDateProperty.date?.start);
|
|
61
65
|
return today.getFullYear() - joinedDate.getFullYear();
|
|
62
66
|
};
|
|
63
|
-
//# sourceMappingURL=client.js.map
|
package/dist/notion/helpful.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getNotion } from '@driveflux/api-functions/notion';
|
|
2
2
|
import { knowledgeBaseRetrievePageSchema } from './schemas/kb.js';
|
|
3
|
-
export const processHelpful = async (options)
|
|
3
|
+
export const processHelpful = async (options)=>{
|
|
4
4
|
const { pageId, isHelpful, hasSubmittedBefore } = options;
|
|
5
5
|
// get original page
|
|
6
6
|
const notion = getNotion();
|
|
7
7
|
const page = await notion.pages.retrieve({
|
|
8
|
-
page_id: pageId
|
|
8
|
+
page_id: pageId
|
|
9
9
|
});
|
|
10
10
|
// validate page
|
|
11
11
|
const kbPageValidation = knowledgeBaseRetrievePageSchema.safeParse(page);
|
|
@@ -18,15 +18,12 @@ export const processHelpful = async (options) => {
|
|
|
18
18
|
page_id: pageId,
|
|
19
19
|
properties: {
|
|
20
20
|
Helpful: {
|
|
21
|
-
number: (validatedPage.properties.Helpful.number || 0) +
|
|
22
|
-
(hasSubmittedBefore && !isHelpful ? -1 : isHelpful ? 1 : 0),
|
|
21
|
+
number: (validatedPage.properties.Helpful.number || 0) + (hasSubmittedBefore && !isHelpful ? -1 : isHelpful ? 1 : 0)
|
|
23
22
|
},
|
|
24
23
|
Unhelpful: {
|
|
25
|
-
number: (validatedPage.properties.Unhelpful.number || 0) +
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
24
|
+
number: (validatedPage.properties.Unhelpful.number || 0) + (hasSubmittedBefore && isHelpful ? -1 : !isHelpful ? 1 : 0)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
29
27
|
});
|
|
30
28
|
return true;
|
|
31
29
|
};
|
|
32
|
-
//# sourceMappingURL=helpful.js.map
|
|
@@ -2,59 +2,54 @@ import { z } from 'zod';
|
|
|
2
2
|
import { notionDateSchema } from './common.js';
|
|
3
3
|
import { notionPartialUserSchema } from './user.js';
|
|
4
4
|
export const notionRichTextSchema = z.object({
|
|
5
|
-
type: z.enum([
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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({
|
|
13
14
|
type: z.enum([
|
|
14
15
|
'database',
|
|
15
16
|
'date',
|
|
16
17
|
'link_preview',
|
|
17
18
|
'page',
|
|
18
19
|
'template_mention',
|
|
19
|
-
'user'
|
|
20
|
+
'user'
|
|
20
21
|
]),
|
|
21
|
-
database: z
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
-
.optional(),
|
|
22
|
+
database: z.object({
|
|
23
|
+
id: z.string()
|
|
24
|
+
}).optional(),
|
|
26
25
|
date: notionDateSchema.optional(),
|
|
27
|
-
link_preview: z
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.optional()
|
|
47
|
-
|
|
48
|
-
|
|
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({
|
|
49
48
|
content: z.string(),
|
|
50
|
-
link: z
|
|
51
|
-
.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.nullable()
|
|
55
|
-
.optional(),
|
|
56
|
-
})
|
|
57
|
-
.optional(),
|
|
49
|
+
link: z.object({
|
|
50
|
+
url: z.string().url()
|
|
51
|
+
}).nullable().optional()
|
|
52
|
+
}).optional(),
|
|
58
53
|
annotations: z.object({
|
|
59
54
|
bold: z.boolean(),
|
|
60
55
|
italic: z.boolean(),
|
|
@@ -80,10 +75,9 @@ export const notionRichTextSchema = z.object({
|
|
|
80
75
|
'red',
|
|
81
76
|
'red_background',
|
|
82
77
|
'yellow',
|
|
83
|
-
'yellow_background'
|
|
84
|
-
])
|
|
78
|
+
'yellow_background'
|
|
79
|
+
])
|
|
85
80
|
}),
|
|
86
81
|
plain_text: z.string(),
|
|
87
|
-
href: z.string().url().nullable().optional()
|
|
82
|
+
href: z.string().url().nullable().optional()
|
|
88
83
|
});
|
|
89
|
-
//# sourceMappingURL=block.js.map
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
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}))?$/);
|
|
2
|
+
export const notionDateOrTimeFormat = z.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?(Z|\+\d{2}:\d{2}))?$/);
|
|
5
3
|
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$/);
|
|
4
|
+
export const notionTimeFormat = z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/);
|
|
9
5
|
export const notionCommonColorEnum = z.enum([
|
|
10
6
|
'blue',
|
|
11
7
|
'brown',
|
|
@@ -16,16 +12,15 @@ export const notionCommonColorEnum = z.enum([
|
|
|
16
12
|
'pink',
|
|
17
13
|
'purple',
|
|
18
14
|
'red',
|
|
19
|
-
'yellow'
|
|
15
|
+
'yellow'
|
|
20
16
|
]);
|
|
21
17
|
export const notionDateSchema = z.object({
|
|
22
18
|
start: notionDateOrTimeFormat,
|
|
23
19
|
end: notionDateOrTimeFormat.nullable().optional(),
|
|
24
|
-
time_zone: z.string().nullable().optional()
|
|
20
|
+
time_zone: z.string().nullable().optional()
|
|
25
21
|
});
|
|
26
|
-
export const commonPropertyValues = (type)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=common.js.map
|
|
22
|
+
export const commonPropertyValues = (type)=>({
|
|
23
|
+
id: z.string(),
|
|
24
|
+
type: z.literal(type),
|
|
25
|
+
name: z.string().optional()
|
|
26
|
+
});
|