@runnerpro/backend 1.0.25 → 1.0.26
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/lib/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCountNotificaciones = exports.chatExposed = exports.chatApi = exports.chat = exports.useTranslation = exports.LANGUAGES = exports.translate = exports.fetchIA = exports.err = exports.sendMail = exports.batchQuery = exports.query = exports.sleep = exports.sendNotification = void 0;
|
|
3
|
+
exports.NOTION_DATABASES_ID = exports.notionAddPage = exports.notionGetDatabase = exports.notionGetUsers = exports.getCountNotificaciones = exports.chatExposed = exports.chatApi = exports.chat = exports.useTranslation = exports.LANGUAGES = exports.translate = exports.fetchIA = exports.err = exports.sendMail = exports.batchQuery = exports.query = exports.sleep = exports.sendNotification = void 0;
|
|
4
4
|
const sendNotification_1 = require("./sendNotification");
|
|
5
5
|
Object.defineProperty(exports, "sendNotification", { enumerable: true, get: function () { return sendNotification_1.sendNotification; } });
|
|
6
6
|
const sleep_1 = require("./sleep");
|
|
@@ -23,3 +23,8 @@ Object.defineProperty(exports, "chat", { enumerable: true, get: function () { re
|
|
|
23
23
|
Object.defineProperty(exports, "chatApi", { enumerable: true, get: function () { return chat_1.chatApi; } });
|
|
24
24
|
Object.defineProperty(exports, "chatExposed", { enumerable: true, get: function () { return chat_1.chatExposed; } });
|
|
25
25
|
Object.defineProperty(exports, "getCountNotificaciones", { enumerable: true, get: function () { return chat_1.getCountNotificaciones; } });
|
|
26
|
+
const notion_1 = require("./notion");
|
|
27
|
+
Object.defineProperty(exports, "notionGetUsers", { enumerable: true, get: function () { return notion_1.notionGetUsers; } });
|
|
28
|
+
Object.defineProperty(exports, "notionGetDatabase", { enumerable: true, get: function () { return notion_1.notionGetDatabase; } });
|
|
29
|
+
Object.defineProperty(exports, "notionAddPage", { enumerable: true, get: function () { return notion_1.notionAddPage; } });
|
|
30
|
+
Object.defineProperty(exports, "NOTION_DATABASES_ID", { enumerable: true, get: function () { return notion_1.NOTION_DATABASES_ID; } });
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NOTION_DATABASES_ID = exports.notionAddPage = exports.notionGetDatabase = exports.notionGetUsers = void 0;
|
|
13
|
+
const client_1 = require("@notionhq/client");
|
|
14
|
+
const NOTION_DATABASES_ID = {
|
|
15
|
+
REGISTRADOS_PRUEBA_7_DIAS: '25732354-92bd-4bb5-8937-0ad583b795ab',
|
|
16
|
+
};
|
|
17
|
+
exports.NOTION_DATABASES_ID = NOTION_DATABASES_ID;
|
|
18
|
+
const getNotionDatabaseProperties = (databaseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const database = yield notion.databases.retrieve({
|
|
20
|
+
database_id: databaseId,
|
|
21
|
+
});
|
|
22
|
+
return database.properties;
|
|
23
|
+
});
|
|
24
|
+
const notion = new client_1.Client({
|
|
25
|
+
auth: process.env.NOTION_API_KEY,
|
|
26
|
+
});
|
|
27
|
+
const notionGetUsers = () => {
|
|
28
|
+
return notion.users.list({});
|
|
29
|
+
};
|
|
30
|
+
exports.notionGetUsers = notionGetUsers;
|
|
31
|
+
const notionGetDatabase = (databaseId) => {
|
|
32
|
+
return notion.databases
|
|
33
|
+
.query({
|
|
34
|
+
database_id: databaseId,
|
|
35
|
+
})
|
|
36
|
+
.then(({ results }) => results);
|
|
37
|
+
};
|
|
38
|
+
exports.notionGetDatabase = notionGetDatabase;
|
|
39
|
+
const notionAddPage = (databaseId, values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const properties = yield getNotionDatabaseProperties(databaseId);
|
|
41
|
+
console.log(properties);
|
|
42
|
+
// Transform values into properties format
|
|
43
|
+
const propertiesValues = {};
|
|
44
|
+
Object.keys(values).forEach((key) => {
|
|
45
|
+
if (properties[key].type === 'title') {
|
|
46
|
+
propertiesValues[key] = {
|
|
47
|
+
title: [
|
|
48
|
+
{
|
|
49
|
+
text: {
|
|
50
|
+
content: values[key],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
else if (properties[key].type === 'select') {
|
|
57
|
+
propertiesValues[key] = {
|
|
58
|
+
select: {
|
|
59
|
+
name: values[key],
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else if (properties[key].type === 'date') {
|
|
64
|
+
propertiesValues[key] = {
|
|
65
|
+
date: {
|
|
66
|
+
start: values[key],
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
propertiesValues[key] = {
|
|
72
|
+
[properties[key].type]: values[key],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
console.log(propertiesValues);
|
|
77
|
+
return notion.pages.create({
|
|
78
|
+
parent: {
|
|
79
|
+
database_id: databaseId,
|
|
80
|
+
},
|
|
81
|
+
properties: propertiesValues,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
exports.notionAddPage = notionAddPage;
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ import { err } from './err';
|
|
|
6
6
|
import { fetchIA } from './fetch/fetchIA';
|
|
7
7
|
import { translate, LANGUAGES, useTranslation } from './translation';
|
|
8
8
|
import { chat, chatApi, chatExposed, getCountNotificaciones } from './chat';
|
|
9
|
-
|
|
9
|
+
import { notionGetUsers, notionGetDatabase, notionAddPage, NOTION_DATABASES_ID } from './notion';
|
|
10
|
+
export { sendNotification, sleep, query, batchQuery, sendMail, err, fetchIA, translate, LANGUAGES, useTranslation, chat, chatApi, chatExposed, getCountNotificaciones, notionGetUsers, notionGetDatabase, notionAddPage, NOTION_DATABASES_ID, };
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEjG,OAAO,EACL,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,UAAU,EACV,QAAQ,EACR,GAAG,EACH,OAAO,EACP,SAAS,EACT,SAAS,EACT,cAAc,EACd,IAAI,EACJ,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,mBAAmB,GACpB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const NOTION_DATABASES_ID: {
|
|
2
|
+
REGISTRADOS_PRUEBA_7_DIAS: string;
|
|
3
|
+
};
|
|
4
|
+
declare const notionGetUsers: () => Promise<import("@notionhq/client/build/src/api-endpoints").ListUsersResponse>;
|
|
5
|
+
declare const notionGetDatabase: (databaseId: any) => Promise<(import("@notionhq/client/build/src/api-endpoints").PartialDatabaseObjectResponse | import("@notionhq/client/build/src/api-endpoints").DatabaseObjectResponse | import("@notionhq/client/build/src/api-endpoints").PageObjectResponse | import("@notionhq/client/build/src/api-endpoints").PartialPageObjectResponse)[]>;
|
|
6
|
+
declare const notionAddPage: (databaseId: any, values: any) => Promise<import("@notionhq/client/build/src/api-endpoints").CreatePageResponse>;
|
|
7
|
+
export { notionGetUsers, notionGetDatabase, notionAddPage, NOTION_DATABASES_ID };
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/notion/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,mBAAmB;;CAExB,CAAC;AAcF,QAAA,MAAM,cAAc,qFAEnB,CAAC;AAEF,QAAA,MAAM,iBAAiB,uVAMtB,CAAC;AAEF,QAAA,MAAM,aAAa,kHA2ClB,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runnerpro/backend",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "A collection of common backend functions",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/cjs/index.js"
|
|
@@ -56,12 +56,13 @@
|
|
|
56
56
|
"@parse/node-apn": "6.0.1",
|
|
57
57
|
"@runnerpro/common": "^1.2.10",
|
|
58
58
|
"axios": "^1.6.7",
|
|
59
|
+
"jimp": "^0.22.10",
|
|
59
60
|
"nodemailer": "6.9.9",
|
|
60
|
-
"pg": "8.11.3"
|
|
61
|
-
"jimp": "^0.22.10"
|
|
61
|
+
"pg": "8.11.3"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@google-cloud/translate": "^8.3.0",
|
|
65
|
+
"@notionhq/client": "^2.2.15",
|
|
65
66
|
"exifr": "^7.1.3",
|
|
66
67
|
"image-size": "^1.0.2",
|
|
67
68
|
"multer": "^1.4.5-lts.1",
|