@betterinternship/core 2.2.2 → 2.2.4
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 +21 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/broker/broker.d.ts +11 -11
- package/dist/lib/broker/broker.js +107 -70
- package/dist/lib/broker/broker.js.map +1 -1
- package/dist/lib/broker/index.js +17 -1
- package/dist/lib/broker/index.js.map +1 -1
- package/dist/lib/chat/chat.d.ts +51 -51
- package/dist/lib/chat/chat.js +222 -183
- package/dist/lib/chat/chat.js.map +1 -1
- package/dist/lib/chat/index.d.ts +2 -2
- package/dist/lib/chat/index.js +18 -2
- package/dist/lib/chat/index.js.map +1 -1
- package/dist/lib/chat/pb.d.ts +3 -3
- package/dist/lib/chat/pb.js +22 -15
- package/dist/lib/chat/pb.js.map +1 -1
- package/dist/lib/email/email.js +103 -66
- package/dist/lib/email/email.js.map +1 -1
- package/dist/lib/email/index.d.ts +1 -1
- package/dist/lib/email/index.js +17 -1
- package/dist/lib/email/index.js.map +1 -1
- package/dist/lib/env.js +39 -3
- package/dist/lib/env.js.map +1 -1
- package/dist/lib/forms/fields.client.d.ts +2 -1
- package/dist/lib/forms/fields.client.js +10 -3
- package/dist/lib/forms/fields.client.js.map +1 -1
- package/dist/lib/forms/fields.server.js +2 -1
- package/dist/lib/forms/form-metadata.d.ts +127 -127
- package/dist/lib/forms/form-metadata.js +327 -320
- package/dist/lib/forms/form-metadata.js.map +1 -1
- package/dist/lib/forms/index.js +19 -3
- package/dist/lib/forms/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
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("./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);
|
|
6
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,+CAA6B;AAC7B,wDAAsC;AACtC,uDAAqC;AACrC,uDAAqC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as amqp from 'amqplib';
|
|
2
|
-
export declare const QueueName: (...args: string[]) => string;
|
|
3
|
-
export declare const BrokerAPI: {
|
|
4
|
-
assertQueue: (..._: any[]) => Promise<void>;
|
|
5
|
-
sendToQueue: (..._: any[]) => Promise<void>;
|
|
6
|
-
readFromQueue: (..._: any[]) => Promise<void>;
|
|
7
|
-
} | {
|
|
8
|
-
assertQueue: (queueId: string, options?: amqp.Options.AssertQueue) => Promise<amqp.Replies.AssertQueue>;
|
|
9
|
-
sendToQueue: (queueId: string, content: any) => boolean;
|
|
10
|
-
readFromQueue: <T>(queueId: string) => Promise<null>;
|
|
11
|
-
};
|
|
1
|
+
import * as amqp from 'amqplib';
|
|
2
|
+
export declare const QueueName: (...args: string[]) => string;
|
|
3
|
+
export declare const BrokerAPI: {
|
|
4
|
+
assertQueue: (..._: any[]) => Promise<void>;
|
|
5
|
+
sendToQueue: (..._: any[]) => Promise<void>;
|
|
6
|
+
readFromQueue: (..._: any[]) => Promise<void>;
|
|
7
|
+
} | {
|
|
8
|
+
assertQueue: (queueId: string, options?: amqp.Options.AssertQueue) => Promise<amqp.Replies.AssertQueue>;
|
|
9
|
+
sendToQueue: (queueId: string, content: any) => boolean;
|
|
10
|
+
readFromQueue: <T>(queueId: string) => Promise<null>;
|
|
11
|
+
};
|
|
@@ -1,71 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
1
|
+
"use strict";
|
|
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 __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)
|
|
41
|
+
throw new Error('[ERROR:ENV] Missing RabbitMQ configuration.');
|
|
42
|
+
const QueueName = (...args) => {
|
|
43
|
+
if (env_js_1.ENV.ENVIRONMENT === 'production')
|
|
44
|
+
return args.join('.');
|
|
45
|
+
else
|
|
46
|
+
return ['dev', ...args].join('.');
|
|
47
|
+
};
|
|
48
|
+
exports.QueueName = QueueName;
|
|
49
|
+
exports.BrokerAPI = await (async () => {
|
|
50
|
+
if (!RABBITMQ_URL) {
|
|
51
|
+
return {
|
|
52
|
+
assertQueue: async (..._) => { },
|
|
53
|
+
sendToQueue: async (..._) => { },
|
|
54
|
+
readFromQueue: async (..._) => { },
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const connection = await amqp.connect(RABBITMQ_URL);
|
|
58
|
+
const channels = {
|
|
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, {
|
|
65
|
+
durable: true,
|
|
66
|
+
...options,
|
|
67
|
+
});
|
|
68
|
+
console.log(`[BROKER] Queue "${queueId}" has been asserted.`);
|
|
69
|
+
return result;
|
|
70
|
+
};
|
|
71
|
+
const sendToQueue = (queueId, content) => {
|
|
72
|
+
const result = channels.writer.sendToQueue(queueId, Buffer.from(JSON.stringify(content)));
|
|
73
|
+
if (result) {
|
|
74
|
+
console.log(`[BROKER] Message sent to queue "${queueId}": ${JSON.stringify(content)}.`);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
console.log(`[BROKER] Message could not sent to queue "${queueId}": ${JSON.stringify(content)}.`);
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
const readFromQueue = async (queueId) => {
|
|
82
|
+
const resolveFromQueue = (message) => {
|
|
83
|
+
channels.writer.ack(message);
|
|
84
|
+
console.log(`[BROKER] Message "${message.properties.messageId}" resolved from queue "${queueId}".`);
|
|
85
|
+
};
|
|
86
|
+
const rejectFromQueue = (message) => {
|
|
87
|
+
channels.writer.nack(message);
|
|
88
|
+
console.log(`[BROKER] Message "${message.properties.messageId}" rejected from queue "${queueId}".`);
|
|
89
|
+
};
|
|
90
|
+
let result = null;
|
|
91
|
+
await channels.reader.consume(queueId, (message) => {
|
|
92
|
+
const content = message?.content?.toString?.();
|
|
93
|
+
result = {
|
|
94
|
+
content: content ? JSON.parse(content) : null,
|
|
95
|
+
resolve: () => message && resolveFromQueue(message),
|
|
96
|
+
reject: () => message && rejectFromQueue(message),
|
|
97
|
+
};
|
|
98
|
+
return message ? result : null;
|
|
99
|
+
});
|
|
100
|
+
return result;
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
assertQueue,
|
|
104
|
+
sendToQueue,
|
|
105
|
+
readFromQueue,
|
|
106
|
+
};
|
|
107
|
+
})();
|
|
71
108
|
//# sourceMappingURL=broker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker.js","sourceRoot":"","sources":["../../../lib/broker/broker.ts"],"names":[],"mappings":"AASA,
|
|
1
|
+
{"version":3,"file":"broker.js","sourceRoot":"","sources":["../../../lib/broker/broker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,8CAAgC;AAChC,sCA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CAAC,OAAO,EAAE,EAAE;YACjD,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,CAAC;YAG/C,MAAM,GAAG;gBACP,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;YAGF,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO;QACL,WAAW;QACX,WAAW;QACX,aAAa;KACd,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC"}
|
package/dist/lib/broker/index.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
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);
|
|
2
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/broker/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/broker/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B"}
|
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").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
|
-
}
|
|
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", { with: { "resolution-mode": "import" } }).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
|
+
}
|