core-services-sdk 1.3.37 → 1.3.39
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/package.json +2 -2
- package/src/http/HttpError.js +1 -1
- package/tests/http/HttpError.unit.test.js +2 -2
- package/tsconfig.json +3 -1
- package/types/core/combine-unique-arrays.d.ts +1 -1
- package/types/core/index.d.ts +9 -9
- package/types/core/normalize-array-operators.d.ts +1 -1
- package/types/core/normalize-min-max.d.ts +16 -10
- package/types/core/normalize-phone-number.d.ts +30 -24
- package/types/core/normalize-premitives-types-or-default.d.ts +17 -4
- package/types/core/normalize-to-array.d.ts +1 -1
- package/types/core/otp-generators.d.ts +22 -18
- package/types/core/regex-utils.d.ts +1 -1
- package/types/core/sanitize-objects.d.ts +13 -4
- package/types/crypto/crypto.d.ts +31 -18
- package/types/crypto/encryption.d.ts +14 -6
- package/types/crypto/index.d.ts +2 -2
- package/types/fastify/error-handlers/with-error-handling.d.ts +26 -15
- package/types/fastify/index.d.ts +2 -2
- package/types/http/HttpError.d.ts +3 -4
- package/types/http/http-method.d.ts +6 -6
- package/types/http/http.d.ts +58 -34
- package/types/http/index.d.ts +4 -4
- package/types/http/responseType.d.ts +6 -6
- package/types/ids/generators.d.ts +28 -28
- package/types/ids/index.d.ts +2 -2
- package/types/ids/prefixes.d.ts +54 -54
- package/types/index.d.ts +11 -11
- package/types/logger/get-logger.d.ts +23 -21
- package/types/logger/index.d.ts +1 -1
- package/types/mailer/index.d.ts +2 -2
- package/types/mailer/mailer.service.d.ts +29 -19
- package/types/mailer/transport.factory.d.ts +43 -43
- package/types/mongodb/connect.d.ts +12 -7
- package/types/mongodb/dsl-to-mongo.d.ts +2 -1
- package/types/mongodb/index.d.ts +5 -5
- package/types/mongodb/initialize-mongodb.d.ts +18 -13
- package/types/mongodb/paginate.d.ts +23 -13
- package/types/mongodb/validate-mongo-uri.d.ts +1 -1
- package/types/rabbit-mq/index.d.ts +1 -1
- package/types/rabbit-mq/rabbit-mq.d.ts +62 -37
- package/types/templates/index.d.ts +1 -1
- package/types/templates/template-loader.d.ts +7 -3
- package/types/util/context.d.ts +53 -53
- package/types/util/index.d.ts +6 -6
- package/types/util/mask-sensitive.d.ts +14 -2
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export function generateId(): string
|
|
2
|
-
export function generatePrefixedId(prefix: string): string
|
|
3
|
-
export function generateUserId(): string
|
|
4
|
-
export function generateTenantId(): string
|
|
5
|
-
export function generatePermissionId(): string
|
|
6
|
-
export function generateCorrelationId(): string
|
|
7
|
-
export function generateVerificationId(): string
|
|
8
|
-
export function generateRolePermissionsId(): string
|
|
9
|
-
export function generateOnboardingId(): string
|
|
10
|
-
export function generateSessionId(): string
|
|
11
|
-
export function generateFileId(): string
|
|
12
|
-
export function generateEventId(): string
|
|
13
|
-
export function generateJobId(): string
|
|
14
|
-
export function generateTaskId(): string
|
|
15
|
-
export function generateQueueId(): string
|
|
16
|
-
export function generateMessageId(): string
|
|
17
|
-
export function generateNotificationId(): string
|
|
18
|
-
export function generateLogId(): string
|
|
19
|
-
export function generateAuditId(): string
|
|
20
|
-
export function generateConfigId(): string
|
|
21
|
-
export function generateKeyId(): string
|
|
22
|
-
export function generateMetricId(): string
|
|
23
|
-
export function generateTagId(): string
|
|
24
|
-
export function generatePolicyId(): string
|
|
25
|
-
export function generateProfileId(): string
|
|
26
|
-
export function generateDeviceId(): string
|
|
27
|
-
export function generateAlertId(): string
|
|
28
|
-
export function generateResourceId(): string
|
|
1
|
+
export function generateId(): string
|
|
2
|
+
export function generatePrefixedId(prefix: string): string
|
|
3
|
+
export function generateUserId(): string
|
|
4
|
+
export function generateTenantId(): string
|
|
5
|
+
export function generatePermissionId(): string
|
|
6
|
+
export function generateCorrelationId(): string
|
|
7
|
+
export function generateVerificationId(): string
|
|
8
|
+
export function generateRolePermissionsId(): string
|
|
9
|
+
export function generateOnboardingId(): string
|
|
10
|
+
export function generateSessionId(): string
|
|
11
|
+
export function generateFileId(): string
|
|
12
|
+
export function generateEventId(): string
|
|
13
|
+
export function generateJobId(): string
|
|
14
|
+
export function generateTaskId(): string
|
|
15
|
+
export function generateQueueId(): string
|
|
16
|
+
export function generateMessageId(): string
|
|
17
|
+
export function generateNotificationId(): string
|
|
18
|
+
export function generateLogId(): string
|
|
19
|
+
export function generateAuditId(): string
|
|
20
|
+
export function generateConfigId(): string
|
|
21
|
+
export function generateKeyId(): string
|
|
22
|
+
export function generateMetricId(): string
|
|
23
|
+
export function generateTagId(): string
|
|
24
|
+
export function generatePolicyId(): string
|
|
25
|
+
export function generateProfileId(): string
|
|
26
|
+
export function generateDeviceId(): string
|
|
27
|
+
export function generateAlertId(): string
|
|
28
|
+
export function generateResourceId(): string
|
package/types/ids/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './prefixes.js'
|
|
2
|
+
export * from './generators.js'
|
package/types/ids/prefixes.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* These prefixes are prepended to ULIDs to create consistent and identifiable IDs across the system.
|
|
5
5
|
* For example: 'usr_01HZY3M7K4FJ9A8Q4Y1ZB5NX3T'
|
|
6
6
|
*/
|
|
7
|
-
export type ID_PREFIXES = string
|
|
7
|
+
export type ID_PREFIXES = string
|
|
8
8
|
/**
|
|
9
9
|
* Mapping of entity types to their unique ID prefixes.
|
|
10
10
|
*
|
|
@@ -15,56 +15,56 @@ export type ID_PREFIXES = string;
|
|
|
15
15
|
* @enum {string}
|
|
16
16
|
*/
|
|
17
17
|
export const ID_PREFIXES: Readonly<{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
}
|
|
18
|
+
/** User entity ID prefix */
|
|
19
|
+
USER: 'usr'
|
|
20
|
+
/** Tenant entity ID prefix */
|
|
21
|
+
TENANT: 'tnt'
|
|
22
|
+
/** Permission entity ID prefix */
|
|
23
|
+
PERMISSION: 'prm'
|
|
24
|
+
/** Correlation ID prefix (e.g., for tracing requests) */
|
|
25
|
+
CORRELATION: 'crln'
|
|
26
|
+
/** Verification entity ID prefix (e.g., email/phone code) */
|
|
27
|
+
VERIFICATION: 'vrf'
|
|
28
|
+
/** Role-permissions mapping ID prefix */
|
|
29
|
+
ROLE_PERMISSIONS: 'role'
|
|
30
|
+
/** Onboarding mapping ID prefix */
|
|
31
|
+
ONBOARDING: 'onb'
|
|
32
|
+
/** Session mapping ID prefix */
|
|
33
|
+
SESSION: 'sess'
|
|
34
|
+
/** File mapping ID prefix */
|
|
35
|
+
FILE: 'fil'
|
|
36
|
+
/** Event entity ID prefix */
|
|
37
|
+
EVENT: 'evt'
|
|
38
|
+
/** Job entity ID prefix */
|
|
39
|
+
JOB: 'job'
|
|
40
|
+
/** Task entity ID prefix */
|
|
41
|
+
TASK: 'task'
|
|
42
|
+
/** Queue entity ID prefix */
|
|
43
|
+
QUEUE: 'que'
|
|
44
|
+
/** Message entity ID prefix */
|
|
45
|
+
MESSAGE: 'msg'
|
|
46
|
+
/** Notification entity ID prefix */
|
|
47
|
+
NOTIFICATION: 'ntf'
|
|
48
|
+
/** Log entity ID prefix */
|
|
49
|
+
LOG: 'log'
|
|
50
|
+
/** Audit entity ID prefix */
|
|
51
|
+
AUDIT: 'adt'
|
|
52
|
+
/** Config entity ID prefix */
|
|
53
|
+
CONFIG: 'cfg'
|
|
54
|
+
/** Key entity ID prefix */
|
|
55
|
+
KEY: 'key'
|
|
56
|
+
/** Metric entity ID prefix */
|
|
57
|
+
METRIC: 'met'
|
|
58
|
+
/** Tag entity ID prefix */
|
|
59
|
+
TAG: 'tag'
|
|
60
|
+
/** Policy entity ID prefix */
|
|
61
|
+
POLICY: 'plc'
|
|
62
|
+
/** Profile entity ID prefix */
|
|
63
|
+
PROFILE: 'prf'
|
|
64
|
+
/** Device entity ID prefix */
|
|
65
|
+
DEVICE: 'dev'
|
|
66
|
+
/** Alert entity ID prefix */
|
|
67
|
+
ALERT: 'alr'
|
|
68
|
+
/** Resource entity ID prefix */
|
|
69
|
+
RESOURCE: 'res'
|
|
70
|
+
}>
|
package/types/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
1
|
+
export * from './core/index.js'
|
|
2
|
+
export * from './crypto/index.js'
|
|
3
|
+
export * from './fastify/index.js'
|
|
4
|
+
export * from './http/index.js'
|
|
5
|
+
export * from './ids/index.js'
|
|
6
|
+
export * from './mongodb/index.js'
|
|
7
|
+
export * from './logger/index.js'
|
|
8
|
+
export * from './mailer/index.js'
|
|
9
|
+
export * from './rabbit-mq/index.js'
|
|
10
|
+
export * from './templates/index.js'
|
|
11
|
+
export * from './util/index.js'
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
export function getLogger(
|
|
1
|
+
export function getLogger(
|
|
2
|
+
option: true | any | undefined,
|
|
3
|
+
): import('pino').Logger | typeof dummyLogger
|
|
2
4
|
declare namespace dummyLogger {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
function info(): void
|
|
6
|
+
function warn(): void
|
|
7
|
+
function trace(): void
|
|
8
|
+
function debug(): void
|
|
9
|
+
function error(): void
|
|
10
|
+
function fatal(): void
|
|
11
|
+
function levels(): void
|
|
12
|
+
function silent(): void
|
|
13
|
+
function child(): {
|
|
14
|
+
info: () => void
|
|
15
|
+
warn: () => void
|
|
16
|
+
trace: () => void
|
|
17
|
+
debug: () => void
|
|
18
|
+
error: () => void
|
|
19
|
+
fatal: () => void
|
|
20
|
+
levels: () => void
|
|
21
|
+
silent: () => void
|
|
22
|
+
child(): /*elided*/ any
|
|
23
|
+
}
|
|
22
24
|
}
|
|
23
|
-
export {}
|
|
25
|
+
export {}
|
package/types/logger/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './get-logger.js'
|
package/types/mailer/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function initMailer(config: any): Mailer
|
|
2
|
-
import { Mailer } from './mailer.service.js'
|
|
1
|
+
export function initMailer(config: any): Mailer
|
|
2
|
+
import { Mailer } from './mailer.service.js'
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
export class Mailer {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @param {object} transporter - Nodemailer transporter instance
|
|
4
|
+
*/
|
|
5
|
+
constructor(transporter: object)
|
|
6
|
+
transporter: any
|
|
7
|
+
/**
|
|
8
|
+
* Send an email
|
|
9
|
+
*/
|
|
10
|
+
send({
|
|
11
|
+
to,
|
|
12
|
+
subject,
|
|
13
|
+
html,
|
|
14
|
+
text,
|
|
15
|
+
from,
|
|
16
|
+
cc,
|
|
17
|
+
bcc,
|
|
18
|
+
replyTo,
|
|
19
|
+
attachments,
|
|
20
|
+
}: {
|
|
21
|
+
to: any
|
|
22
|
+
subject: any
|
|
23
|
+
html: any
|
|
24
|
+
text: any
|
|
25
|
+
from: any
|
|
26
|
+
cc: any
|
|
27
|
+
bcc: any
|
|
28
|
+
replyTo: any
|
|
29
|
+
attachments: any
|
|
30
|
+
}): Promise<any>
|
|
21
31
|
}
|
|
@@ -2,47 +2,47 @@
|
|
|
2
2
|
* Factory for creating email transporters based on configuration.
|
|
3
3
|
*/
|
|
4
4
|
export class TransportFactory {
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Create a Nodemailer transporter
|
|
7
|
+
*
|
|
8
|
+
* @param {object} config - Transport configuration object
|
|
9
|
+
* @param {'smtp' | 'gmail' | 'sendgrid' | 'ses'} config.type - Type of email transport
|
|
10
|
+
*
|
|
11
|
+
* For type 'smtp':
|
|
12
|
+
* @param {string} config.host - SMTP server host
|
|
13
|
+
* @param {number} config.port - SMTP server port
|
|
14
|
+
* @param {boolean} config.secure - Use TLS
|
|
15
|
+
* @param {{ user: string, pass: string }} config.auth - SMTP auth credentials
|
|
16
|
+
*
|
|
17
|
+
* For type 'gmail':
|
|
18
|
+
* @param {{ user: string, pass: string }} config.auth - Gmail credentials
|
|
19
|
+
*
|
|
20
|
+
* For type 'sendgrid':
|
|
21
|
+
* @param {string} config.apiKey - SendGrid API key
|
|
22
|
+
*
|
|
23
|
+
* For type 'ses':
|
|
24
|
+
* @param {string} config.accessKeyId - AWS access key
|
|
25
|
+
* @param {string} config.secretAccessKey - AWS secret
|
|
26
|
+
* @param {string} config.region - AWS region
|
|
27
|
+
*
|
|
28
|
+
* @returns {import('nodemailer').Transporter | typeof import('@sendgrid/mail')}
|
|
29
|
+
*/
|
|
30
|
+
static create(config: {
|
|
31
|
+
type: 'smtp' | 'gmail' | 'sendgrid' | 'ses'
|
|
32
|
+
host: string
|
|
33
|
+
port: number
|
|
34
|
+
secure: boolean
|
|
35
|
+
auth: {
|
|
36
|
+
user: string
|
|
37
|
+
pass: string
|
|
38
|
+
}
|
|
39
|
+
auth: {
|
|
40
|
+
user: string
|
|
41
|
+
pass: string
|
|
42
|
+
}
|
|
43
|
+
apiKey: string
|
|
44
|
+
accessKeyId: string
|
|
45
|
+
secretAccessKey: string
|
|
46
|
+
region: string
|
|
47
|
+
}): any | typeof import('@sendgrid/mail')
|
|
48
48
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
export function mongoConnect({
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
1
|
+
export function mongoConnect({
|
|
2
|
+
uri,
|
|
3
|
+
serverApi,
|
|
4
|
+
timeout,
|
|
5
|
+
retries,
|
|
6
|
+
}: {
|
|
7
|
+
uri: string
|
|
8
|
+
serverApi?: object
|
|
9
|
+
timeout?: number
|
|
10
|
+
retries?: number
|
|
11
|
+
}): Promise<MongoClient>
|
|
12
|
+
import { MongoClient } from 'mongodb'
|
|
@@ -4,4 +4,5 @@
|
|
|
4
4
|
* @param {Record<string, any>} query - normalized DSL query
|
|
5
5
|
* @returns {Record<string, any>} - MongoDB query object
|
|
6
6
|
*/
|
|
7
|
-
export function toMongo(query?: Record<string, any>): Record<string, any
|
|
7
|
+
export function toMongo(query?: Record<string, any>): Record<string, any>
|
|
8
|
+
export function castIsoDates(obj: any): any
|
package/types/mongodb/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from './connect.js'
|
|
2
|
+
export * from './paginate.js'
|
|
3
|
+
export * from './dsl-to-mongo.js'
|
|
4
|
+
export * from './initialize-mongodb.js'
|
|
5
|
+
export * from './validate-mongo-uri.js'
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
export function initializeMongoDb({
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
export function initializeMongoDb({
|
|
2
|
+
config,
|
|
3
|
+
collectionNames,
|
|
4
|
+
}: {
|
|
5
|
+
config: {
|
|
6
|
+
uri: string
|
|
7
|
+
options: {
|
|
8
|
+
dbName: string
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
collectionNames: Record<string, string>
|
|
12
|
+
}): Promise<
|
|
13
|
+
Record<string, import('mongodb').Collection> & {
|
|
14
|
+
withTransaction: <T>(action: {
|
|
15
|
+
session: import('mongodb').ClientSession
|
|
16
|
+
}) => Promise<T>
|
|
17
|
+
}
|
|
18
|
+
>
|
|
@@ -9,16 +9,26 @@
|
|
|
9
9
|
* @param {'asc'|'desc'} [options.order='asc']
|
|
10
10
|
* @param {number} [options.limit=10]
|
|
11
11
|
*/
|
|
12
|
-
export function paginate(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
order
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
export function paginate(
|
|
13
|
+
collection: import('mongodb').Collection,
|
|
14
|
+
{
|
|
15
|
+
limit,
|
|
16
|
+
projection,
|
|
17
|
+
filter,
|
|
18
|
+
cursor,
|
|
19
|
+
order,
|
|
20
|
+
cursorField,
|
|
21
|
+
}?: {
|
|
22
|
+
filter?: any
|
|
23
|
+
cursorField?: string
|
|
24
|
+
cursor?: string | Date | ObjectId
|
|
25
|
+
order?: 'asc' | 'desc'
|
|
26
|
+
limit?: number
|
|
27
|
+
},
|
|
28
|
+
): Promise<{
|
|
29
|
+
order: 'asc' | 'desc'
|
|
30
|
+
list: import('mongodb').WithId<import('bson').Document>[]
|
|
31
|
+
previous: any
|
|
32
|
+
next: any
|
|
33
|
+
}>
|
|
34
|
+
import { ObjectId } from 'mongodb'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './rabbit-mq.js'
|
|
@@ -1,40 +1,65 @@
|
|
|
1
|
-
export function connectQueueService({
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
nackOnError?: boolean;
|
|
15
|
-
prefetch?: number;
|
|
16
|
-
}): Promise<void>;
|
|
17
|
-
export function initializeQueue({ host, log }: {
|
|
18
|
-
host: string;
|
|
19
|
-
log: import("pino").Logger;
|
|
1
|
+
export function connectQueueService({
|
|
2
|
+
host,
|
|
3
|
+
log,
|
|
4
|
+
}: {
|
|
5
|
+
host: string
|
|
6
|
+
log: import('pino').Logger
|
|
7
|
+
}): Promise<amqp.Connection>
|
|
8
|
+
export function createChannel({
|
|
9
|
+
host,
|
|
10
|
+
log,
|
|
11
|
+
}: {
|
|
12
|
+
host: string
|
|
13
|
+
log: import('pino').Logger
|
|
20
14
|
}): Promise<{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
channel: amqp.Channel
|
|
16
|
+
connection: amqp.Connection
|
|
17
|
+
}>
|
|
18
|
+
export function subscribeToQueue({
|
|
19
|
+
log,
|
|
20
|
+
queue,
|
|
21
|
+
channel,
|
|
22
|
+
prefetch,
|
|
23
|
+
onReceive,
|
|
24
|
+
nackOnError,
|
|
25
|
+
}: {
|
|
26
|
+
channel: any
|
|
27
|
+
queue: string
|
|
28
|
+
onReceive: (data: any, correlationId?: string) => Promise<void>
|
|
29
|
+
log: import('pino').Logger
|
|
30
|
+
nackOnError?: boolean
|
|
31
|
+
prefetch?: number
|
|
32
|
+
}): Promise<string>
|
|
33
|
+
export function initializeQueue({
|
|
34
|
+
host,
|
|
35
|
+
log,
|
|
36
|
+
}: {
|
|
37
|
+
host: string
|
|
38
|
+
log: import('pino').Logger
|
|
39
|
+
}): Promise<{
|
|
40
|
+
publish: (
|
|
41
|
+
queue: string,
|
|
42
|
+
data: any,
|
|
43
|
+
correlationId?: string,
|
|
44
|
+
) => Promise<boolean>
|
|
45
|
+
subscribe: (options: {
|
|
46
|
+
queue: string
|
|
47
|
+
onReceive: (data: any, correlationId?: string) => Promise<void>
|
|
48
|
+
nackOnError?: boolean
|
|
49
|
+
}) => Promise<string>
|
|
50
|
+
channel: amqp.Channel
|
|
51
|
+
connection: amqp.Connection
|
|
52
|
+
close: () => Promise<void>
|
|
53
|
+
}>
|
|
29
54
|
export function rabbitUriFromEnv(env: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}): string
|
|
55
|
+
RABBIT_HOST: string
|
|
56
|
+
RABBIT_PORT: string | number
|
|
57
|
+
RABBIT_USERNAME: string
|
|
58
|
+
RABBIT_PASSWORD: string
|
|
59
|
+
RABBIT_PROTOCOL?: string
|
|
60
|
+
}): string
|
|
36
61
|
export type Log = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
62
|
+
info: (obj: any, msg?: string) => void
|
|
63
|
+
error: (obj: any, msg?: string) => void
|
|
64
|
+
debug: (obj: any, msg?: string) => void
|
|
65
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './template-loader.js'
|