@betterinternship/core 2.2.4 → 2.3.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.
- package/dist/index.js +5 -21
- package/dist/index.js.map +1 -1
- package/dist/lib/broker/broker.d.ts +14 -9
- package/dist/lib/broker/broker.js +39 -77
- package/dist/lib/broker/broker.js.map +1 -1
- package/dist/lib/broker/index.js +1 -17
- package/dist/lib/broker/index.js.map +1 -1
- package/dist/lib/chat/chat.d.ts +51 -51
- package/dist/lib/chat/chat.js +183 -222
- package/dist/lib/chat/chat.js.map +1 -1
- package/dist/lib/chat/index.js +2 -18
- package/dist/lib/chat/index.js.map +1 -1
- package/dist/lib/chat/pb.js +15 -22
- package/dist/lib/chat/pb.js.map +1 -1
- package/dist/lib/email/email.js +66 -103
- package/dist/lib/email/email.js.map +1 -1
- package/dist/lib/email/index.js +1 -17
- package/dist/lib/email/index.js.map +1 -1
- package/dist/lib/env.js +3 -39
- package/dist/lib/env.js.map +1 -1
- package/dist/lib/forms/fields.client.d.ts +30 -30
- package/dist/lib/forms/fields.client.js +20 -27
- package/dist/lib/forms/fields.client.js.map +1 -1
- package/dist/lib/forms/fields.server.js +1 -2
- package/dist/lib/forms/form-metadata.js +320 -327
- package/dist/lib/forms/form-metadata.js.map +1 -1
- package/dist/lib/forms/index.js +3 -19
- package/dist/lib/forms/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./lib/chat/index.js"), exports);
|
|
18
|
-
__exportStar(require("./lib/env.js"), exports);
|
|
19
|
-
__exportStar(require("./lib/broker/index.js"), exports);
|
|
20
|
-
__exportStar(require("./lib/email/index.js"), exports);
|
|
21
|
-
__exportStar(require("./lib/forms/index.js"), exports);
|
|
1
|
+
export * from './lib/chat/index.js';
|
|
2
|
+
export * from './lib/env.js';
|
|
3
|
+
export * from './lib/broker/index.js';
|
|
4
|
+
export * from './lib/email/index.js';
|
|
5
|
+
export * from './lib/forms/index.js';
|
|
22
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as amqp from 'amqplib';
|
|
2
2
|
export declare const QueueName: (...args: string[]) => string;
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
export declare class BrokerAPI {
|
|
4
|
+
connection: amqp.ChannelModel;
|
|
5
|
+
channels: Record<string, amqp.Channel>;
|
|
6
|
+
private static __instance;
|
|
7
|
+
private constructor();
|
|
8
|
+
static instance(): Promise<BrokerAPI>;
|
|
9
|
+
assertQueue(queueId: string, options?: amqp.Options.AssertQueue): Promise<amqp.Replies.AssertQueue>;
|
|
10
|
+
sendToQueue(queueId: string, content: any): boolean;
|
|
11
|
+
readFromQueue<T>(queueId: string): Promise<{
|
|
12
|
+
content: T | null;
|
|
13
|
+
resolve: () => void;
|
|
14
|
+
reject: () => void;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
@@ -1,75 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.BrokerAPI = exports.QueueName = void 0;
|
|
37
|
-
const amqp = __importStar(require("amqplib"));
|
|
38
|
-
const env_js_1 = require("../env.js");
|
|
39
|
-
const RABBITMQ_URL = env_js_1.ENV.RABBITMQ_URL;
|
|
40
|
-
if (!RABBITMQ_URL && env_js_1.ENV.RABBITMQ_ENABLED)
|
|
1
|
+
import * as amqp from 'amqplib';
|
|
2
|
+
import { ENV } from '../env.js';
|
|
3
|
+
const RABBITMQ_ENABLED = ENV.RABBITMQ_ENABLED;
|
|
4
|
+
const RABBITMQ_URL = ENV.RABBITMQ_URL;
|
|
5
|
+
if (!RABBITMQ_URL && RABBITMQ_ENABLED)
|
|
41
6
|
throw new Error('[ERROR:ENV] Missing RabbitMQ configuration.');
|
|
42
|
-
const QueueName = (...args) => {
|
|
43
|
-
if (
|
|
7
|
+
export const QueueName = (...args) => {
|
|
8
|
+
if (ENV.ENVIRONMENT === 'production')
|
|
44
9
|
return args.join('.');
|
|
45
10
|
else
|
|
46
11
|
return ['dev', ...args].join('.');
|
|
47
12
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
13
|
+
export class BrokerAPI {
|
|
14
|
+
connection;
|
|
15
|
+
channels;
|
|
16
|
+
static __instance;
|
|
17
|
+
constructor() { }
|
|
18
|
+
static async instance() {
|
|
19
|
+
if (BrokerAPI.__instance || !RABBITMQ_ENABLED)
|
|
20
|
+
return BrokerAPI.__instance;
|
|
21
|
+
BrokerAPI.__instance = new BrokerAPI();
|
|
22
|
+
BrokerAPI.__instance.connection = await amqp.connect(RABBITMQ_URL);
|
|
23
|
+
BrokerAPI.__instance.channels = {
|
|
24
|
+
asserter: await BrokerAPI.__instance.connection.createChannel(),
|
|
25
|
+
reader: await BrokerAPI.__instance.connection.createChannel(),
|
|
26
|
+
writer: await BrokerAPI.__instance.connection.createChannel(),
|
|
55
27
|
};
|
|
28
|
+
return BrokerAPI.__instance;
|
|
56
29
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
asserter: await connection.createChannel(),
|
|
60
|
-
reader: await connection.createChannel(),
|
|
61
|
-
writer: await connection.createChannel(),
|
|
62
|
-
};
|
|
63
|
-
const assertQueue = async (queueId, options) => {
|
|
64
|
-
const result = await channels.asserter.assertQueue(queueId, {
|
|
30
|
+
async assertQueue(queueId, options) {
|
|
31
|
+
const result = await this.channels.asserter.assertQueue(queueId, {
|
|
65
32
|
durable: true,
|
|
66
33
|
...options,
|
|
67
34
|
});
|
|
68
35
|
console.log(`[BROKER] Queue "${queueId}" has been asserted.`);
|
|
69
36
|
return result;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const result = channels.writer.sendToQueue(queueId, Buffer.from(JSON.stringify(content)));
|
|
37
|
+
}
|
|
38
|
+
sendToQueue(queueId, content) {
|
|
39
|
+
const result = this.channels.writer.sendToQueue(queueId, Buffer.from(JSON.stringify(content)));
|
|
73
40
|
if (result) {
|
|
74
41
|
console.log(`[BROKER] Message sent to queue "${queueId}": ${JSON.stringify(content)}.`);
|
|
75
42
|
}
|
|
@@ -77,32 +44,27 @@ exports.BrokerAPI = await (async () => {
|
|
|
77
44
|
console.log(`[BROKER] Message could not sent to queue "${queueId}": ${JSON.stringify(content)}.`);
|
|
78
45
|
}
|
|
79
46
|
return result;
|
|
80
|
-
}
|
|
81
|
-
|
|
47
|
+
}
|
|
48
|
+
async readFromQueue(queueId) {
|
|
82
49
|
const resolveFromQueue = (message) => {
|
|
83
|
-
channels.writer.ack(message);
|
|
50
|
+
this.channels.writer.ack(message);
|
|
84
51
|
console.log(`[BROKER] Message "${message.properties.messageId}" resolved from queue "${queueId}".`);
|
|
85
52
|
};
|
|
86
53
|
const rejectFromQueue = (message) => {
|
|
87
|
-
channels.writer.nack(message);
|
|
54
|
+
this.channels.writer.nack(message);
|
|
88
55
|
console.log(`[BROKER] Message "${message.properties.messageId}" rejected from queue "${queueId}".`);
|
|
89
56
|
};
|
|
90
|
-
let
|
|
91
|
-
|
|
57
|
+
let resolveResultPromise;
|
|
58
|
+
const resultPromise = new Promise((r) => (resolveResultPromise = r));
|
|
59
|
+
await this.channels.reader.consume(queueId, (message) => {
|
|
92
60
|
const content = message?.content?.toString?.();
|
|
93
|
-
|
|
61
|
+
resolveResultPromise({
|
|
94
62
|
content: content ? JSON.parse(content) : null,
|
|
95
63
|
resolve: () => message && resolveFromQueue(message),
|
|
96
64
|
reject: () => message && rejectFromQueue(message),
|
|
97
|
-
};
|
|
98
|
-
return message ? result : null;
|
|
65
|
+
});
|
|
99
66
|
});
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
assertQueue,
|
|
104
|
-
sendToQueue,
|
|
105
|
-
readFromQueue,
|
|
106
|
-
};
|
|
107
|
-
})();
|
|
67
|
+
return resultPromise;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
108
70
|
//# sourceMappingURL=broker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker.js","sourceRoot":"","sources":["../../../lib/broker/broker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"broker.js","sourceRoot":"","sources":["../../../lib/broker/broker.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,MAAM,gBAAgB,GAAG,GAAG,CAAC,gBAAgB,CAAC;AAC9C,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC;AACtC,IAAI,CAAC,YAAY,IAAI,gBAAgB;IACnC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;AAKjE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAG,IAAc,EAAU,EAAE;IACrD,IAAI,GAAG,CAAC,WAAW,KAAK,YAAY;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;QACvD,OAAO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CAAC;gBACnB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAO,CAAC,CAAC,CAAC,IAAI;gBACpD,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC;gBACnD,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC;aAClD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACvB,CAAC;CACF"}
|
package/dist/lib/broker/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./broker.js"), exports);
|
|
1
|
+
export * from './broker.js';
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/broker/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/broker/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/dist/lib/chat/chat.d.ts
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { RecordModel } from 'pocketbase';
|
|
2
|
-
export interface Message {
|
|
3
|
-
message: string;
|
|
4
|
-
sender_id: string;
|
|
5
|
-
timestamp: number;
|
|
6
|
-
digested?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface Consumer extends RecordModel {
|
|
9
|
-
email: string;
|
|
10
|
-
last_reads: {
|
|
11
|
-
[conversationId: string]: Message;
|
|
12
|
-
};
|
|
13
|
-
last_unreads: {
|
|
14
|
-
[conversationId: string]: Message;
|
|
15
|
-
};
|
|
16
|
-
conversations: string[];
|
|
17
|
-
}
|
|
18
|
-
export interface Conversation extends RecordModel {
|
|
19
|
-
id: string;
|
|
20
|
-
subscribers: string[];
|
|
21
|
-
contents: Message[];
|
|
22
|
-
last_message: Message;
|
|
23
|
-
}
|
|
24
|
-
export declare class ConsumerService {
|
|
25
|
-
findOne(id: string): Promise<Consumer>;
|
|
26
|
-
findAll(): Promise<Consumer[]>;
|
|
27
|
-
register(id: string, email: string): Promise<Consumer>;
|
|
28
|
-
setLastRead(id: string, conversationId: string, message: Message): Promise<RecordModel>;
|
|
29
|
-
authenticateAs(id: string): Promise<{
|
|
30
|
-
token: string;
|
|
31
|
-
user: import("pocketbase"
|
|
32
|
-
}>;
|
|
33
|
-
}
|
|
34
|
-
export declare class MessageService {
|
|
35
|
-
private readonly consumerService;
|
|
36
|
-
private readonly conversationService;
|
|
37
|
-
private updateConversationUnread;
|
|
38
|
-
send(senderId: string, conversationId: string, messageContent: string): Promise<Message>;
|
|
39
|
-
read(consumerId: string, conversationId: string): Promise<Message>;
|
|
40
|
-
digest(consumerId: string, conversationId: string): Promise<Message>;
|
|
41
|
-
}
|
|
42
|
-
export declare class ConversationService {
|
|
43
|
-
consumerService: ConsumerService;
|
|
44
|
-
findOne(id: string): Promise<Conversation>;
|
|
45
|
-
appendMessage(conversationId: string, message: Message): Promise<Conversation>;
|
|
46
|
-
subscribe(subscriberId: string, conversationId: string): Promise<Conversation>;
|
|
47
|
-
getSubscriptions(subscriberId: any): Promise<Conversation[]>;
|
|
48
|
-
findExisting(userId: string, employerId: string): Promise<Conversation>;
|
|
49
|
-
checkIfSubscribed(subscriberId: string, conversationId: string): Promise<boolean>;
|
|
50
|
-
create(userId: string, employerId: string): Promise<Conversation>;
|
|
51
|
-
}
|
|
1
|
+
import { RecordModel } from 'pocketbase';
|
|
2
|
+
export interface Message {
|
|
3
|
+
message: string;
|
|
4
|
+
sender_id: string;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
digested?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface Consumer extends RecordModel {
|
|
9
|
+
email: string;
|
|
10
|
+
last_reads: {
|
|
11
|
+
[conversationId: string]: Message;
|
|
12
|
+
};
|
|
13
|
+
last_unreads: {
|
|
14
|
+
[conversationId: string]: Message;
|
|
15
|
+
};
|
|
16
|
+
conversations: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface Conversation extends RecordModel {
|
|
19
|
+
id: string;
|
|
20
|
+
subscribers: string[];
|
|
21
|
+
contents: Message[];
|
|
22
|
+
last_message: Message;
|
|
23
|
+
}
|
|
24
|
+
export declare class ConsumerService {
|
|
25
|
+
findOne(id: string): Promise<Consumer>;
|
|
26
|
+
findAll(): Promise<Consumer[]>;
|
|
27
|
+
register(id: string, email: string): Promise<Consumer>;
|
|
28
|
+
setLastRead(id: string, conversationId: string, message: Message): Promise<RecordModel>;
|
|
29
|
+
authenticateAs(id: string): Promise<{
|
|
30
|
+
token: string;
|
|
31
|
+
user: import("pocketbase").AuthRecord;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
export declare class MessageService {
|
|
35
|
+
private readonly consumerService;
|
|
36
|
+
private readonly conversationService;
|
|
37
|
+
private updateConversationUnread;
|
|
38
|
+
send(senderId: string, conversationId: string, messageContent: string): Promise<Message>;
|
|
39
|
+
read(consumerId: string, conversationId: string): Promise<Message>;
|
|
40
|
+
digest(consumerId: string, conversationId: string): Promise<Message>;
|
|
41
|
+
}
|
|
42
|
+
export declare class ConversationService {
|
|
43
|
+
consumerService: ConsumerService;
|
|
44
|
+
findOne(id: string): Promise<Conversation>;
|
|
45
|
+
appendMessage(conversationId: string, message: Message): Promise<Conversation>;
|
|
46
|
+
subscribe(subscriberId: string, conversationId: string): Promise<Conversation>;
|
|
47
|
+
getSubscriptions(subscriberId: any): Promise<Conversation[]>;
|
|
48
|
+
findExisting(userId: string, employerId: string): Promise<Conversation>;
|
|
49
|
+
checkIfSubscribed(subscriberId: string, conversationId: string): Promise<boolean>;
|
|
50
|
+
create(userId: string, employerId: string): Promise<Conversation>;
|
|
51
|
+
}
|