@saihu/common 1.1.28 → 1.1.30
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.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/messaging/bootstrap.d.ts +14 -0
- package/dist/messaging/bootstrap.d.ts.map +1 -0
- package/dist/messaging/bootstrap.js +28 -0
- package/dist/messaging/index.d.ts +3 -0
- package/dist/messaging/index.d.ts.map +1 -0
- package/dist/messaging/index.js +18 -0
- package/dist/messaging/topology.d.ts +19 -0
- package/dist/messaging/topology.d.ts.map +1 -0
- package/dist/messaging/topology.js +27 -0
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export
|
|
1
|
+
export * from './dto';
|
|
2
|
+
export * from './consts';
|
|
3
|
+
export * from './interceptors';
|
|
4
|
+
export * from './filters';
|
|
5
|
+
export * from './auth';
|
|
6
|
+
export * from './util';
|
|
7
|
+
export * from './logger';
|
|
8
|
+
export * from './messaging';
|
|
9
|
+
export { SaihuCommonModule } from './saihu-common.module';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -22,5 +22,6 @@ __exportStar(require("./filters"), exports);
|
|
|
22
22
|
__exportStar(require("./auth"), exports);
|
|
23
23
|
__exportStar(require("./util"), exports);
|
|
24
24
|
__exportStar(require("./logger"), exports);
|
|
25
|
+
__exportStar(require("./messaging"), exports);
|
|
25
26
|
var saihu_common_module_1 = require("./saihu-common.module");
|
|
26
27
|
Object.defineProperty(exports, "SaihuCommonModule", { enumerable: true, get: function () { return saihu_common_module_1.SaihuCommonModule; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RabbitMQConfig } from '@golevelup/nestjs-rabbitmq';
|
|
2
|
+
import { Exchanges } from './topology';
|
|
3
|
+
export interface RabbitMQBootstrapOptions {
|
|
4
|
+
uri: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
connectionInitOptions?: {
|
|
7
|
+
wait?: boolean;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
};
|
|
10
|
+
enableControllerDiscovery?: boolean;
|
|
11
|
+
exchanges?: Exchanges[];
|
|
12
|
+
}
|
|
13
|
+
export declare function createRabbitMQConfig(options: RabbitMQBootstrapOptions): Omit<RabbitMQConfig, 'inject' | 'useFactory'>;
|
|
14
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/messaging/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAkC,MAAM,YAAY,CAAC;AAEvE,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB,CAAC,EAAE;QACtB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC;CACzB;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,wBAAwB,GAChC,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,YAAY,CAAC,CAoB/C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRabbitMQConfig = createRabbitMQConfig;
|
|
4
|
+
const topology_1 = require("./topology");
|
|
5
|
+
function createRabbitMQConfig(options) {
|
|
6
|
+
var _a;
|
|
7
|
+
const exchangesToUse = options.exchanges || Object.values(topology_1.Exchanges);
|
|
8
|
+
return {
|
|
9
|
+
name: options.name || 'core',
|
|
10
|
+
uri: options.uri,
|
|
11
|
+
connectionInitOptions: options.connectionInitOptions || {
|
|
12
|
+
wait: true,
|
|
13
|
+
timeout: 30000,
|
|
14
|
+
},
|
|
15
|
+
exchanges: exchangesToUse.map((exchangeName) => {
|
|
16
|
+
var _a;
|
|
17
|
+
return ({
|
|
18
|
+
name: exchangeName,
|
|
19
|
+
type: topology_1.ExchangeTypes[exchangeName],
|
|
20
|
+
options: {
|
|
21
|
+
...topology_1.ExchangeOptions[exchangeName],
|
|
22
|
+
autoDelete: (_a = topology_1.ExchangeOptions[exchangeName].autoDelete) !== null && _a !== void 0 ? _a : false,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}),
|
|
26
|
+
enableControllerDiscovery: (_a = options.enableControllerDiscovery) !== null && _a !== void 0 ? _a : true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messaging/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./bootstrap"), exports);
|
|
18
|
+
__exportStar(require("./topology"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ExchangeType = 'topic' | 'direct' | 'fanout' | 'headers';
|
|
2
|
+
export declare enum Exchanges {
|
|
3
|
+
IM_PROCUREMENT_ORDER = "im.procurement.order",
|
|
4
|
+
SHOP = "shop",
|
|
5
|
+
OPER_LOG_EXCHANGE = "oper_log_exchange"
|
|
6
|
+
}
|
|
7
|
+
export declare enum RoutingKeys {
|
|
8
|
+
PROCUREMENT_ORDER_RETURN_APPROVED = "procurement.order.return.approved",
|
|
9
|
+
PROCUREMENT_ORDER_FINALIZED = "procurement.order.finalized",
|
|
10
|
+
SHOP_CREATED = "shop.created"
|
|
11
|
+
}
|
|
12
|
+
export declare const ExchangeTypes: Record<Exchanges, ExchangeType>;
|
|
13
|
+
export declare const ExchangeOptions: Record<Exchanges, {
|
|
14
|
+
durable: boolean;
|
|
15
|
+
internal?: boolean;
|
|
16
|
+
autoDelete?: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const q: (service: string, rk: string) => string;
|
|
19
|
+
//# sourceMappingURL=topology.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../src/messaging/topology.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAErE,oBAAY,SAAS;IACnB,oBAAoB,yBAAyB;IAC7C,IAAI,SAAS;IACb,iBAAiB,sBAAsB;CACxC;AAED,oBAAY,WAAW;IACrB,iCAAiC,sCAAsC;IACvE,2BAA2B,gCAAgC;IAC3D,YAAY,iBAAiB;CAC9B;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,SAAS,EAAE,YAAY,CAIzD,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,SAAS,EACT;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAK/D,CAAC;AAEF,eAAO,MAAM,CAAC,GAAI,SAAS,MAAM,EAAE,IAAI,MAAM,WAAyB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.q = exports.ExchangeOptions = exports.ExchangeTypes = exports.RoutingKeys = exports.Exchanges = void 0;
|
|
4
|
+
var Exchanges;
|
|
5
|
+
(function (Exchanges) {
|
|
6
|
+
Exchanges["IM_PROCUREMENT_ORDER"] = "im.procurement.order";
|
|
7
|
+
Exchanges["SHOP"] = "shop";
|
|
8
|
+
Exchanges["OPER_LOG_EXCHANGE"] = "oper_log_exchange";
|
|
9
|
+
})(Exchanges || (exports.Exchanges = Exchanges = {}));
|
|
10
|
+
var RoutingKeys;
|
|
11
|
+
(function (RoutingKeys) {
|
|
12
|
+
RoutingKeys["PROCUREMENT_ORDER_RETURN_APPROVED"] = "procurement.order.return.approved";
|
|
13
|
+
RoutingKeys["PROCUREMENT_ORDER_FINALIZED"] = "procurement.order.finalized";
|
|
14
|
+
RoutingKeys["SHOP_CREATED"] = "shop.created";
|
|
15
|
+
})(RoutingKeys || (exports.RoutingKeys = RoutingKeys = {}));
|
|
16
|
+
exports.ExchangeTypes = {
|
|
17
|
+
[Exchanges.IM_PROCUREMENT_ORDER]: 'topic',
|
|
18
|
+
[Exchanges.SHOP]: 'topic',
|
|
19
|
+
[Exchanges.OPER_LOG_EXCHANGE]: 'direct',
|
|
20
|
+
};
|
|
21
|
+
exports.ExchangeOptions = {
|
|
22
|
+
[Exchanges.IM_PROCUREMENT_ORDER]: { durable: true },
|
|
23
|
+
[Exchanges.SHOP]: { durable: true },
|
|
24
|
+
[Exchanges.OPER_LOG_EXCHANGE]: { durable: true },
|
|
25
|
+
};
|
|
26
|
+
const q = (service, rk) => `q.${rk}.${service}`; // e.g. q.procurement.order.delivered.imjobs
|
|
27
|
+
exports.q = q;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saihu/common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.30",
|
|
4
4
|
"description": "Common utilities for NestJS applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,9 +29,11 @@
|
|
|
29
29
|
"typescript": "^5.8.3"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@golevelup/nestjs-rabbitmq": "^6.0.2",
|
|
32
33
|
"@nestjs/config": "^4.0.2",
|
|
33
34
|
"@nestjs/core": "^11.1.1",
|
|
34
35
|
"@nestjs/jwt": "^11.0.0",
|
|
36
|
+
"amqp-connection-manager": "^5.0.0",
|
|
35
37
|
"amqplib": "^0.10.9",
|
|
36
38
|
"class-transformer": "^0.5.1",
|
|
37
39
|
"class-validator": "^0.14.2",
|