@cardano-sdk/cardano-services 0.11.1 → 0.11.2
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/README.md +17 -17
- package/dist/cjs/Asset/DbSyncAssetProvider/DbSyncAssetProvider.js +2 -2
- package/dist/cjs/Asset/DbSyncAssetProvider/DbSyncAssetProvider.js.map +1 -1
- package/dist/cjs/ChainHistory/DbSyncChainHistory/mappers.d.ts +1 -1
- package/dist/cjs/ChainHistory/DbSyncChainHistory/mappers.d.ts.map +1 -1
- package/dist/cjs/ChainHistory/DbSyncChainHistory/mappers.js +2 -2
- package/dist/cjs/ChainHistory/DbSyncChainHistory/mappers.js.map +1 -1
- package/dist/cjs/PgBoss/stakePoolMetadataHandler.d.ts +16 -0
- package/dist/cjs/PgBoss/stakePoolMetadataHandler.d.ts.map +1 -0
- package/dist/cjs/PgBoss/stakePoolMetadataHandler.js +59 -0
- package/dist/cjs/PgBoss/stakePoolMetadataHandler.js.map +1 -0
- package/dist/cjs/PgBoss/types.d.ts +7 -0
- package/dist/cjs/PgBoss/types.d.ts.map +1 -0
- package/dist/cjs/PgBoss/types.js +6 -0
- package/dist/cjs/PgBoss/types.js.map +1 -0
- package/dist/cjs/PgBoss/util.d.ts +4 -0
- package/dist/cjs/PgBoss/util.d.ts.map +1 -0
- package/dist/cjs/PgBoss/util.js +12 -0
- package/dist/cjs/PgBoss/util.js.map +1 -0
- package/dist/cjs/Program/options/postgres.d.ts +7 -2
- package/dist/cjs/Program/options/postgres.d.ts.map +1 -1
- package/dist/cjs/Program/options/postgres.js +49 -41
- package/dist/cjs/Program/options/postgres.js.map +1 -1
- package/dist/cjs/Program/programs/blockfrostWorker.d.ts +1 -1
- package/dist/cjs/Program/programs/blockfrostWorker.d.ts.map +1 -1
- package/dist/cjs/Program/programs/pgBossWorker.d.ts +25 -0
- package/dist/cjs/Program/programs/pgBossWorker.d.ts.map +1 -0
- package/dist/cjs/Program/programs/pgBossWorker.js +40 -0
- package/dist/cjs/Program/programs/pgBossWorker.js.map +1 -0
- package/dist/cjs/Program/programs/projector.d.ts +1 -1
- package/dist/cjs/Program/programs/projector.d.ts.map +1 -1
- package/dist/cjs/Program/programs/projector.js +1 -1
- package/dist/cjs/Program/programs/projector.js.map +1 -1
- package/dist/cjs/Program/programs/types.d.ts +1 -1
- package/dist/cjs/Program/programs/types.d.ts.map +1 -1
- package/dist/cjs/Program/services/pgboss.d.ts +27 -0
- package/dist/cjs/Program/services/pgboss.d.ts.map +1 -0
- package/dist/cjs/Program/services/pgboss.js +114 -0
- package/dist/cjs/Program/services/pgboss.js.map +1 -0
- package/dist/cjs/Program/services/postgres.d.ts +4 -4
- package/dist/cjs/Program/services/postgres.d.ts.map +1 -1
- package/dist/cjs/Program/services/postgres.js +42 -28
- package/dist/cjs/Program/services/postgres.js.map +1 -1
- package/dist/cjs/Projection/createTypeormProjection.d.ts +2 -1
- package/dist/cjs/Projection/createTypeormProjection.d.ts.map +1 -1
- package/dist/cjs/Projection/createTypeormProjection.js +4 -3
- package/dist/cjs/Projection/createTypeormProjection.js.map +1 -1
- package/dist/cjs/Projection/prepareTypeormProjection.d.ts +1 -1
- package/dist/cjs/Projection/prepareTypeormProjection.d.ts.map +1 -1
- package/dist/cjs/Projection/prepareTypeormProjection.js +1 -3
- package/dist/cjs/Projection/prepareTypeormProjection.js.map +1 -1
- package/dist/cjs/StakePool/HttpStakePoolMetadata/HttpStakePoolMetadataService.d.ts.map +1 -1
- package/dist/cjs/StakePool/HttpStakePoolMetadata/HttpStakePoolMetadataService.js +31 -28
- package/dist/cjs/StakePool/HttpStakePoolMetadata/HttpStakePoolMetadataService.js.map +1 -1
- package/dist/cjs/StakePool/HttpStakePoolMetadata/errors.d.ts +2 -1
- package/dist/cjs/StakePool/HttpStakePoolMetadata/errors.d.ts.map +1 -1
- package/dist/cjs/StakePool/HttpStakePoolMetadata/errors.js +1 -0
- package/dist/cjs/StakePool/HttpStakePoolMetadata/errors.js.map +1 -1
- package/dist/cjs/StakePool/types.d.ts +2 -0
- package/dist/cjs/StakePool/types.d.ts.map +1 -1
- package/dist/cjs/StakePool/types.js.map +1 -1
- package/dist/cjs/cli.js +34 -27
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/original-package.json +14 -12
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -12
|
@@ -17,7 +17,7 @@ const createProjectionHttpService = async (options) => {
|
|
|
17
17
|
ogmiosSrvServiceName: args.ogmiosSrvServiceName,
|
|
18
18
|
ogmiosUrl: args.ogmiosUrl
|
|
19
19
|
});
|
|
20
|
-
const connectionConfig$ = (0, services_1.getConnectionConfig)(dnsResolver, args);
|
|
20
|
+
const connectionConfig$ = (0, services_1.getConnectionConfig)(dnsResolver, 'projector', args);
|
|
21
21
|
const buffer = new projection_typeorm_1.TypeormStabilityWindowBuffer({ logger });
|
|
22
22
|
const projection$ = (0, Projection_1.createTypeormProjection)({
|
|
23
23
|
buffer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projector.js","sourceRoot":"","sources":["../../../../src/Program/programs/projector.ts"],"names":[],"mappings":";;;AAAA,wDAAoD;AAEpD,oCAA0D;AAC1D,qCAA0D;AAE1D,iDAAkG;AAElG,wEAA+E;AAC/E,6BAA0B;AAC1B,sCAA+C;AAC/C,mCAAsC;AACtC,0CAAkF;AAErE,QAAA,yBAAyB,GAAG,IAAI,SAAG,CAAC,uBAAuB,CAAC,CAAC;AAoB1E,MAAM,2BAA2B,GAAG,KAAK,EAAE,OAAoC,EAAE,EAAE;IACjF,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC9C,MAAM,WAAW,GAAG,IAAA,yCAA8B,EAAC,WAAW,EAAE,MAAM,EAAE;QACtE,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;QAC/C,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B,CAAC,CAAC;IACH,MAAM,iBAAi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E;KACrD,CAAC;IACF,IAAI,IAAI,CAAC,aAAa,EAAE;QACtB,MAAM,CAAC,OAAO,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC;KAClD;IACD,OAAO,IAAI,iBAAU,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACjE,CAAC,CAAC;AAlCW,QAAA,aAAa,iBAkCxB"}
|
|
@@ -34,7 +34,7 @@ export declare enum ProviderServerOptionDescriptions {
|
|
|
34
34
|
UseQueue = "Enables RabbitMQ",
|
|
35
35
|
PaginationPageSizeLimit = "Pagination page size limit shared across all providers"
|
|
36
36
|
}
|
|
37
|
-
export declare type ProviderServerArgs = CommonProgramOptions & PosgresProgramOptions & OgmiosProgramOptions & RabbitMqProgramOptions & {
|
|
37
|
+
export declare type ProviderServerArgs = CommonProgramOptions & PosgresProgramOptions<'DbSync'> & OgmiosProgramOptions & RabbitMqProgramOptions & {
|
|
38
38
|
allowedOrigins?: string[];
|
|
39
39
|
cardanoNodeConfigPath?: string;
|
|
40
40
|
disableDbCache?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/Program/programs/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAK7D,oBAAY,QAAQ;IAClB,gBAAgB,sBAAsB;IACtC,cAAc,oBAAoB;IAClC,cAAc,oBAAoB;IAClC,SAAS,cAAc;CACxB;AAMD,oBAAY,YAAY;IACtB,KAAK,UAAU;IACf,SAAS,eAAe;IACxB,WAAW,iBAAiB;IAC5B,QAAQ,cAAc;IACtB,IAAI,SAAS;IACb,YAAY,kBAAkB;IAC9B,OAAO,YAAY;CACpB;AAED,oBAAY,2BAA2B;IACrC,UAAU,6DAA6D;IACvE,MAAM,mDAAmD;CAC1D;AAED,oBAAY,gCAAgC;IAC1C,qBAAqB,6BAA6B;IAClD,UAAU,qGAAqG;IAC/G,cAAc,oDAAoD;IAClE,cAAc,qBAAqB;IACnC,yBAAyB,oDAAoD;IAC7E,iBAAiB,wBAAwB;IACzC,qBAAqB,4CAA4C;IACjE,sBAAsB,kCAAkC;IACxD,aAAa,sCAAsC;IACnD,QAAQ,qBAAqB;IAC7B,uBAAuB,2DAA2D;CACnF;AAED,oBAAY,kBAAkB,GAAG,oBAAoB,GACnD,qBAAqB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/Program/programs/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAK7D,oBAAY,QAAQ;IAClB,gBAAgB,sBAAsB;IACtC,cAAc,oBAAoB;IAClC,cAAc,oBAAoB;IAClC,SAAS,cAAc;CACxB;AAMD,oBAAY,YAAY;IACtB,KAAK,UAAU;IACf,SAAS,eAAe;IACxB,WAAW,iBAAiB;IAC5B,QAAQ,cAAc;IACtB,IAAI,SAAS;IACb,YAAY,kBAAkB;IAC9B,OAAO,YAAY;CACpB;AAED,oBAAY,2BAA2B;IACrC,UAAU,6DAA6D;IACvE,MAAM,mDAAmD;CAC1D;AAED,oBAAY,gCAAgC;IAC1C,qBAAqB,6BAA6B;IAClD,UAAU,qGAAqG;IAC/G,cAAc,oDAAoD;IAClE,cAAc,qBAAqB;IACnC,yBAAyB,oDAAoD;IAC7E,iBAAiB,wBAAwB;IACzC,qBAAqB,4CAA4C;IACjE,sBAAsB,kCAAkC;IACxD,aAAa,sCAAsC;IACnD,QAAQ,qBAAqB;IAC7B,uBAAuB,2DAA2D;CACnF;AAED,oBAAY,kBAAkB,GAAG,oBAAoB,GACnD,qBAAqB,CAAC,QAAQ,CAAC,GAC/B,oBAAoB,GACpB,sBAAsB,GAAG;IACvB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,YAAY,EAAE,YAAY,EAAE,CAAC;CAC9B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BlockEntity, PgConnectionConfig, PoolMetadataEntity, PoolRegistrationEntity, PoolRetirementEntity, StakePoolEntity } from '@cardano-sdk/projection-typeorm';
|
|
2
|
+
import { DataSource } from 'typeorm';
|
|
3
|
+
import { HttpService } from '../../Http/HttpService';
|
|
4
|
+
import { Logger } from 'ts-log';
|
|
5
|
+
import { Observable } from 'rxjs';
|
|
6
|
+
import { PgBossQueue } from '../../PgBoss/types';
|
|
7
|
+
import { Pool } from 'pg';
|
|
8
|
+
export declare const pgBossEntities: (typeof BlockEntity | typeof PoolMetadataEntity | typeof PoolRegistrationEntity | typeof PoolRetirementEntity | typeof StakePoolEntity)[];
|
|
9
|
+
export declare const createPgBossDataSource: (connectionConfig$: Observable<PgConnectionConfig>, logger: Logger) => Observable<DataSource>;
|
|
10
|
+
export interface PgBossServiceConfig {
|
|
11
|
+
parallelJobs: number;
|
|
12
|
+
queues: PgBossQueue[];
|
|
13
|
+
}
|
|
14
|
+
export interface PgBossServiceDependencies {
|
|
15
|
+
connectionConfig$: Observable<PgConnectionConfig>;
|
|
16
|
+
db: Pool;
|
|
17
|
+
logger: Logger;
|
|
18
|
+
}
|
|
19
|
+
export declare class PgBossHttpService extends HttpService {
|
|
20
|
+
#private;
|
|
21
|
+
constructor(cfg: PgBossServiceConfig, deps: PgBossServiceDependencies);
|
|
22
|
+
protected startImpl(): Promise<void>;
|
|
23
|
+
protected shutdownImpl(): Promise<void>;
|
|
24
|
+
private work;
|
|
25
|
+
private workQueue;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=pgboss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pgboss.d.ts","sourceRoot":"","sources":["../../../../src/Program/services/pgboss.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EAGhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EACL,UAAU,EAWX,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAW1B,eAAO,MAAM,cAAc,2IAM1B,CAAC;AAEF,eAAO,MAAM,sBAAsB,sBAAuB,WAAW,kBAAkB,CAAC,UAAU,MAAM,2BACH,CAAC;AAEtG,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACxC,iBAAiB,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAClD,EAAE,EAAE,IAAI,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,iBAAkB,SAAQ,WAAW;;gBAMpC,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,yBAAyB;cASrD,SAAS;cAkBT,YAAY;IAM5B,OAAO,CAAC,IAAI;IAoCZ,OAAO,CAAC,SAAS;CA8ClB"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
+
};
|
|
13
|
+
var _PgBossHttpService_config, _PgBossHttpService_dataSource$, _PgBossHttpService_subscription, _PgBossHttpService_health;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PgBossHttpService = exports.createPgBossDataSource = exports.pgBossEntities = void 0;
|
|
16
|
+
const projection_typeorm_1 = require("@cardano-sdk/projection-typeorm");
|
|
17
|
+
const HttpService_1 = require("../../Http/HttpService");
|
|
18
|
+
const rxjs_1 = require("rxjs");
|
|
19
|
+
const express_1 = require("express");
|
|
20
|
+
const util_1 = require("@cardano-sdk/util");
|
|
21
|
+
const createTypeormProjection_1 = require("../../Projection/createTypeormProjection");
|
|
22
|
+
const util_2 = require("../../PgBoss/util");
|
|
23
|
+
const backoff_rxjs_1 = require("backoff-rxjs");
|
|
24
|
+
exports.pgBossEntities = [
|
|
25
|
+
projection_typeorm_1.BlockEntity,
|
|
26
|
+
projection_typeorm_1.PoolMetadataEntity,
|
|
27
|
+
projection_typeorm_1.PoolRegistrationEntity,
|
|
28
|
+
projection_typeorm_1.PoolRetirementEntity,
|
|
29
|
+
projection_typeorm_1.StakePoolEntity
|
|
30
|
+
];
|
|
31
|
+
const createPgBossDataSource = (connectionConfig$, logger) => (0, createTypeormProjection_1.createObservableDataSource)({ connectionConfig$, entities: exports.pgBossEntities, extensions: {}, logger });
|
|
32
|
+
exports.createPgBossDataSource = createPgBossDataSource;
|
|
33
|
+
class PgBossHttpService extends HttpService_1.HttpService {
|
|
34
|
+
constructor(cfg, deps) {
|
|
35
|
+
const { connectionConfig$, logger } = deps;
|
|
36
|
+
super('pg-boss-service', { healthCheck: async () => __classPrivateFieldGet(this, _PgBossHttpService_health, "f") }, (0, express_1.Router)(), logger);
|
|
37
|
+
_PgBossHttpService_config.set(this, void 0);
|
|
38
|
+
_PgBossHttpService_dataSource$.set(this, void 0);
|
|
39
|
+
_PgBossHttpService_subscription.set(this, void 0);
|
|
40
|
+
_PgBossHttpService_health.set(this, { ok: false, reason: 'PgBossHttpService not started' });
|
|
41
|
+
__classPrivateFieldSet(this, _PgBossHttpService_config, cfg, "f");
|
|
42
|
+
__classPrivateFieldSet(this, _PgBossHttpService_dataSource$, (0, exports.createPgBossDataSource)(connectionConfig$, this.logger), "f");
|
|
43
|
+
}
|
|
44
|
+
async startImpl() {
|
|
45
|
+
await super.startImpl();
|
|
46
|
+
if (__classPrivateFieldGet(this, _PgBossHttpService_subscription, "f")) {
|
|
47
|
+
this.logger.warn('Unsubscribing from an observable which should never happen');
|
|
48
|
+
__classPrivateFieldGet(this, _PgBossHttpService_subscription, "f").unsubscribe();
|
|
49
|
+
}
|
|
50
|
+
const sharedWork$ = this.work().pipe((0, rxjs_1.share)());
|
|
51
|
+
__classPrivateFieldSet(this, _PgBossHttpService_subscription, sharedWork$.subscribe(), "f");
|
|
52
|
+
await (0, rxjs_1.firstValueFrom)(sharedWork$);
|
|
53
|
+
}
|
|
54
|
+
async shutdownImpl() {
|
|
55
|
+
await super.shutdownImpl();
|
|
56
|
+
__classPrivateFieldGet(this, _PgBossHttpService_subscription, "f")?.unsubscribe();
|
|
57
|
+
}
|
|
58
|
+
work() {
|
|
59
|
+
return __classPrivateFieldGet(this, _PgBossHttpService_dataSource$, "f").pipe((0, rxjs_1.switchMap)((dataSource) => {
|
|
60
|
+
const pgBoss = (0, projection_typeorm_1.createPgBoss)(null, this.logger, dataSource);
|
|
61
|
+
return (0, rxjs_1.concat)((0, rxjs_1.from)(pgBoss.start()), (0, rxjs_1.merge)(...__classPrivateFieldGet(this, _PgBossHttpService_config, "f").queues.map((queue) => this.workQueue(dataSource, pgBoss, queue)))).pipe((0, rxjs_1.finalize)(() => pgBoss.stop().catch((error) => this.logger.warn('Error stopping pgBoss', error))));
|
|
62
|
+
}), (0, rxjs_1.tap)(() => (__classPrivateFieldSet(this, _PgBossHttpService_health, { ok: true }, "f"))), (0, backoff_rxjs_1.retryBackoff)({
|
|
63
|
+
initialInterval: 10,
|
|
64
|
+
maxInterval: 5000,
|
|
65
|
+
resetOnSuccess: true,
|
|
66
|
+
shouldRetry: (error) => {
|
|
67
|
+
const retry = (0, projection_typeorm_1.isRecoverableTypeormError)(error);
|
|
68
|
+
__classPrivateFieldSet(this, _PgBossHttpService_health, {
|
|
69
|
+
ok: false,
|
|
70
|
+
reason: retry ? 'DataBase error: reconnecting...' : 'Fatal error! Shutting down'
|
|
71
|
+
}, "f");
|
|
72
|
+
return retry;
|
|
73
|
+
}
|
|
74
|
+
}), (0, rxjs_1.catchError)((error) => {
|
|
75
|
+
this.logger.error('Fatal worker error', error);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
workQueue(dataSource, pgBoss, queue) {
|
|
80
|
+
const logger = (0, util_1.contextLogger)(this.logger, queue);
|
|
81
|
+
const handler = util_2.queueHandlers[queue](dataSource, logger);
|
|
82
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
83
|
+
const workOption = {
|
|
84
|
+
teamConcurrency: __classPrivateFieldGet(this, _PgBossHttpService_config, "f").parallelJobs,
|
|
85
|
+
teamRefill: true,
|
|
86
|
+
teamSize: __classPrivateFieldGet(this, _PgBossHttpService_config, "f").parallelJobs
|
|
87
|
+
};
|
|
88
|
+
const baseHandler = async (job) => {
|
|
89
|
+
const { id, data } = job;
|
|
90
|
+
try {
|
|
91
|
+
logger.info(`Job ${id} started`, data);
|
|
92
|
+
await handler(data);
|
|
93
|
+
subscriber.next(null);
|
|
94
|
+
logger.info(`Job ${id} successfully completed`, data);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
logger.error(`Job ${id} got error`, error);
|
|
98
|
+
if ((0, projection_typeorm_1.isRecoverableTypeormError)(error)) {
|
|
99
|
+
logger.info('The error is recoverable: re-creating DB connection');
|
|
100
|
+
subscriber.error(error);
|
|
101
|
+
}
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
pgBoss.work(queue, workOption, baseHandler).catch((error) => {
|
|
106
|
+
logger.error(`Error while starting worker for queue '${queue}'`, error);
|
|
107
|
+
subscriber.error(error);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.PgBossHttpService = PgBossHttpService;
|
|
113
|
+
_PgBossHttpService_config = new WeakMap(), _PgBossHttpService_dataSource$ = new WeakMap(), _PgBossHttpService_subscription = new WeakMap(), _PgBossHttpService_health = new WeakMap();
|
|
114
|
+
//# sourceMappingURL=pgboss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pgboss.js","sourceRoot":"","sources":["../../../../src/Program/services/pgboss.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wEASyC;AAGzC,wDAAqD;AAErD,+BAYc;AAGd,qCAAiC;AACjC,4CAAkD;AAClD,sFAAsF;AACtF,4CAAkD;AAClD,+CAA4C;AAM/B,QAAA,cAAc,GAAG;IAC5B,gCAAW;IACX,uCAAkB;IAClB,2CAAsB;IACtB,yCAAoB;IACpB,oCAAe;CAChB,CAAC;AAEK,MAAM,sBAAsB,GAAG,CAAC,iBAAiD,EAAE,MAAc,EAAE,EAAE,CAC1G,IAAA,oDAA0B,EAAC,EAAE,iBAAiB,EAAE,QAAQ,EAAE,sBAAc,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AADzF,QAAA,sBAAsB,0BACmE;AAatG,MAAa,iBAAkB,SAAQ,yBAAW;IAMhD,YAAY,GAAwB,EAAE,IAA+B;QACnE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAE3C,KAAK,CAAC,iBAAiB,EAAE,EAAE,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,uBAAA,IAAI,iCAAQ,EAAE,EAAE,IAAA,gBAAM,GAAE,EAAE,MAAM,CAAC,CAAC;QARxF,4CAA6B;QAC7B,iDAAqC;QACrC,kDAA6B;QAC7B,oCAA+B,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,+BAA+B,EAAE,EAAC;QAOpF,uBAAA,IAAI,6BAAW,GAAG,MAAA,CAAC;QACnB,uBAAA,IAAI,kCAAgB,IAAA,8BAAsB,EAAC,iBAAiB,EAAE,IAAI,CAAC,MAAM,CAAC,MAAA,CAAC;I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pC,CAAC;YAEF,MAAM,WAAW,GAAG,KAAK,EAAE,GAAiD,EAAE,EAAE;gBAC9E,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC;gBAEzB,IAAI;oBACF,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;oBAEvC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;oBAKpB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBAEtB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,yBAAyB,EAAE,IAAI,CAAC,CAAC;iBACvD;gBAAC,OAAO,KAAK,EAAE;oBAGd,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;oBAE3C,IAAI,IAAA,8CAAyB,EAAC,KAAK,CAAC,EAAE;wBACpC,MAAM,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;wBAEnE,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;qBACzB;oBAED,MAAM,KAAK,CAAC;iBACb;YACH,CAAC,CAAC;YAEF,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBACnE,MAAM,CAAC,KAAK,CAAC,0CAA0C,KAAK,GAAG,EAAE,KAAK,CAAC,CAAC;gBACxE,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAzHD,8CAyHC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { ConnectionNames, PosgresProgramOptions } from '../options';
|
|
1
2
|
import { DnsResolver } from '../utils';
|
|
2
3
|
import { Logger } from 'ts-log';
|
|
3
4
|
import { Observable } from 'rxjs';
|
|
4
5
|
import { PgConnectionConfig } from '@cardano-sdk/projection-typeorm';
|
|
5
6
|
import { Pool, PoolConfig } from 'pg';
|
|
6
|
-
import { PosgresProgramOptions } from '../options';
|
|
7
7
|
export declare const getPoolWithServiceDiscovery: (dnsResolver: DnsResolver, logger: Logger, { host, database, max, password, ssl, user }: PoolConfig) => Promise<Pool>;
|
|
8
8
|
export declare const loadSecret: (path: string) => string;
|
|
9
|
-
export declare const getConnectionConfig: (dnsResolver: DnsResolver, options?: PosgresProgramOptions) => Observable<PgConnectionConfig>;
|
|
10
|
-
export declare const getPool: (dnsResolver: DnsResolver, logger: Logger, options?: PosgresProgramOptions) => Promise<Pool | undefined>;
|
|
11
|
-
export declare const connectionStringFromArgs: (args: PosgresProgramOptions) => string | undefined;
|
|
9
|
+
export declare const getConnectionConfig: (dnsResolver: DnsResolver, program: string, options?: PosgresProgramOptions<'StakePool'>) => Observable<PgConnectionConfig>;
|
|
10
|
+
export declare const getPool: (dnsResolver: DnsResolver, logger: Logger, options?: PosgresProgramOptions<'DbSync'>) => Promise<Pool | undefined>;
|
|
11
|
+
export declare const connectionStringFromArgs: <Suffix extends ConnectionNames>(args: PosgresProgramOptions<Suffix, keyof import("../options").BasePosgresProgramOptions>, suffix: Suffix) => string | undefined;
|
|
12
12
|
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../../src/Program/services/postgres.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAmB,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAe,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../../src/Program/services/postgres.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAqB,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAmB,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAe,MAAM,IAAI,CAAC;AAwBnD,eAAO,MAAM,2BAA2B,gBACzB,WAAW,UAChB,MAAM,gDACgC,UAAU,KACvD,QAAQ,IAAI,CA4Bd,CAAC;AAEF,eAAO,MAAM,UAAU,SAAU,MAAM,WAA6C,CAAC;AAerF,eAAO,MAAM,mBAAmB,gBACjB,WAAW,WACf,MAAM,YACL,sBAAsB,WAAW,CAAC,KAC3C,WAAW,kBAAkB,CA8C/B,CAAC;AAEF,eAAO,MAAM,OAAO,gBACL,WAAW,UAChB,MAAM,YACJ,sBAAsB,QAAQ,CAAC,KACxC,QAAQ,IAAI,GAAG,SAAS,CA4C1B,CAAC;AAKF,eAAO,MAAM,wBAAwB,mKAgCpC,CAAC"}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.connectionStringFromArgs = exports.getPool = exports.getConnectionConfig = exports.loadSecret = exports.getPoolWithServiceDiscovery = void 0;
|
|
7
|
+
const options_1 = require("../options");
|
|
7
8
|
const errors_1 = require("../errors");
|
|
8
9
|
const rxjs_1 = require("rxjs");
|
|
9
10
|
const pg_1 = require("pg");
|
|
@@ -52,10 +53,10 @@ const mergeTlsOptions = (conn, ssl) => typeof conn.ssl === 'object'
|
|
|
52
53
|
ca: ssl?.ca || conn.ssl.ca
|
|
53
54
|
}
|
|
54
55
|
: conn.ssl;
|
|
55
|
-
const getConnectionConfig = (dnsResolver, options) => {
|
|
56
|
-
const ssl = options?.
|
|
57
|
-
if (options?.
|
|
58
|
-
const conn = pg_connection_string_1.default.parse(options.
|
|
56
|
+
const getConnectionConfig = (dnsResolver, program, options) => {
|
|
57
|
+
const ssl = options?.postgresSslCaFileStakePool ? { ca: (0, exports.loadSecret)(options.postgresSslCaFileStakePool) } : undefined;
|
|
58
|
+
if (options?.postgresConnectionStringStakePool) {
|
|
59
|
+
const conn = pg_connection_string_1.default.parse(options.postgresConnectionStringStakePool);
|
|
59
60
|
if (!conn.database || !conn.host) {
|
|
60
61
|
throw new errors_1.InvalidProgramOption('postgresConnectionString');
|
|
61
62
|
}
|
|
@@ -68,17 +69,20 @@ const getConnectionConfig = (dnsResolver, options) => {
|
|
|
68
69
|
username: conn.user
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
|
-
if (options?.
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
if (options?.postgresSrvServiceNameStakePool &&
|
|
73
|
+
options.postgresUserStakePool &&
|
|
74
|
+
options.postgresDbStakePool &&
|
|
75
|
+
options.postgresPasswordStakePool) {
|
|
76
|
+
return (0, rxjs_1.defer)(() => (0, rxjs_1.from)(dnsResolver(options.postgresSrvServiceNameStakePool).then((record) => ({
|
|
77
|
+
database: options.postgresDbStakePool,
|
|
74
78
|
host: record.name,
|
|
75
|
-
password: options.
|
|
79
|
+
password: options.postgresPasswordStakePool,
|
|
76
80
|
port: record.port,
|
|
77
81
|
ssl,
|
|
78
|
-
username: options.
|
|
82
|
+
username: options.postgresUserStakePool
|
|
79
83
|
}))));
|
|
80
84
|
}
|
|
81
|
-
throw new errors_1.MissingProgramOption(
|
|
85
|
+
throw new errors_1.MissingProgramOption(program, [
|
|
82
86
|
'postgresConnectionString',
|
|
83
87
|
'postgresSrvServiceName',
|
|
84
88
|
'postgresUser',
|
|
@@ -88,9 +92,13 @@ const getConnectionConfig = (dnsResolver, options) => {
|
|
|
88
92
|
};
|
|
89
93
|
exports.getConnectionConfig = getConnectionConfig;
|
|
90
94
|
const getPool = async (dnsResolver, logger, options) => {
|
|
91
|
-
const ssl = options?.
|
|
92
|
-
if (options?.
|
|
93
|
-
const pool = new pg_1.Pool({
|
|
95
|
+
const ssl = options?.postgresSslCaFileDbSync ? { ca: (0, exports.loadSecret)(options.postgresSslCaFileDbSync) } : undefined;
|
|
96
|
+
if (options?.postgresConnectionStringDbSync) {
|
|
97
|
+
const pool = new pg_1.Pool({
|
|
98
|
+
connectionString: options.postgresConnectionStringDbSync,
|
|
99
|
+
max: options.postgresPoolMaxDbSync,
|
|
100
|
+
ssl
|
|
101
|
+
});
|
|
94
102
|
return new Proxy({}, {
|
|
95
103
|
get(_, prop) {
|
|
96
104
|
if (prop === 'then')
|
|
@@ -106,30 +114,36 @@ const getPool = async (dnsResolver, logger, options) => {
|
|
|
106
114
|
}
|
|
107
115
|
});
|
|
108
116
|
}
|
|
109
|
-
if (options?.
|
|
117
|
+
if (options?.postgresSrvServiceNameDbSync &&
|
|
118
|
+
options.postgresUserDbSync &&
|
|
119
|
+
options.postgresDbDbSync &&
|
|
120
|
+
options.postgresPasswordDbSync) {
|
|
110
121
|
return (0, exports.getPoolWithServiceDiscovery)(dnsResolver, logger, {
|
|
111
|
-
database: options.
|
|
112
|
-
host: options.
|
|
113
|
-
max: options.
|
|
114
|
-
password: options.
|
|
122
|
+
database: options.postgresDbDbSync,
|
|
123
|
+
host: options.postgresSrvServiceNameDbSync,
|
|
124
|
+
max: options.postgresPoolMaxDbSync,
|
|
125
|
+
password: options.postgresPasswordDbSync,
|
|
115
126
|
ssl,
|
|
116
|
-
user: options.
|
|
127
|
+
user: options.postgresUserDbSync
|
|
117
128
|
});
|
|
118
129
|
}
|
|
119
130
|
return undefined;
|
|
120
131
|
};
|
|
121
132
|
exports.getPool = getPool;
|
|
122
133
|
const getSecret = (secretFilePath, secret) => secretFilePath ? (0, exports.loadSecret)(secretFilePath) : secret ? secret : undefined;
|
|
123
|
-
const connectionStringFromArgs = (args) => {
|
|
124
|
-
const dbName = getSecret(
|
|
125
|
-
const dbUser = getSecret(
|
|
126
|
-
const dbPassword = getSecret(
|
|
127
|
-
let postgresConnectionString;
|
|
128
|
-
if (
|
|
129
|
-
postgresConnectionString = new url_1.URL(
|
|
134
|
+
const connectionStringFromArgs = (args, suffix) => {
|
|
135
|
+
const dbName = getSecret((0, options_1.getPostgresOption)(suffix, 'postgresDbFile', args), (0, options_1.getPostgresOption)(suffix, 'postgresDb', args));
|
|
136
|
+
const dbUser = getSecret((0, options_1.getPostgresOption)(suffix, 'postgresUserFile', args), (0, options_1.getPostgresOption)(suffix, 'postgresUser', args));
|
|
137
|
+
const dbPassword = getSecret((0, options_1.getPostgresOption)(suffix, 'postgresPasswordFile', args), (0, options_1.getPostgresOption)(suffix, 'postgresPassword', args));
|
|
138
|
+
let postgresConnectionString = (0, options_1.getPostgresOption)(suffix, 'postgresConnectionString', args);
|
|
139
|
+
if (postgresConnectionString) {
|
|
140
|
+
postgresConnectionString = new url_1.URL(postgresConnectionString).toString();
|
|
130
141
|
}
|
|
131
|
-
else
|
|
132
|
-
|
|
142
|
+
else {
|
|
143
|
+
const postgresHost = (0, options_1.getPostgresOption)(suffix, 'postgresHost', args);
|
|
144
|
+
const postgresPort = (0, options_1.getPostgresOption)(suffix, 'postgresPort', args);
|
|
145
|
+
if (dbName && dbPassword && dbUser && postgresHost && postgresPort)
|
|
146
|
+
postgresConnectionString = `postgresql://${dbUser}:${dbPassword}@${postgresHost}:${postgresPort}/${dbName}`;
|
|
133
147
|
}
|
|
134
148
|
return postgresConnectionString;
|
|
135
149
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../../../src/Program/services/postgres.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../../../src/Program/services/postgres.ts"],"names":[],"mappings":";;;;;;AAGA,wCAAuF;AAEvF,sCAAuE;AAEvE,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D,IAAA,2BAAiB,EAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,CAAC,CACpD,CAAC;IAIF,IAAI,wBAAwB,GAAG,IAAA,2BAAiB,EAAC,MAAM,EAAE,0BAA0B,EAAE,IAAI,CAAC,CAAC;IAE3F,IAAI,wBAAwB,EAAE;QAC5B,wBAAwB,GAAG,IAAI,SAAG,CAAC,wBAAwB,CAAC,CAAC,QAAQ,EAAE,CAAC;KACzE;SAAM;QACL,MAAM,YAAY,GAAG,IAAA,2BAAiB,EAAC,MAAM,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;QACrE,MAAM,YAAY,GAAG,IAAA,2BAAiB,EAAC,MAAM,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;QAErE,IAAI,MAAM,IAAI,UAAU,IAAI,MAAM,IAAI,YAAY,IAAI,YAAY;YAChE,wBAAwB,GAAG,gBAAgB,MAAM,IAAI,UAAU,IAAI,YAAY,IAAI,YAAY,IAAI,MAAM,EAAE,CAAC;KAC/G;IAED,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAC;AAhCW,QAAA,wBAAwB,4BAgCnC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger } from 'ts-log';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { PgConnectionConfig, TypeormDevOptions, TypeormStabilityWindowBuffer, WithTypeormContext } from '@cardano-sdk/projection-typeorm';
|
|
4
|
-
import { ProjectionName } from './prepareTypeormProjection';
|
|
4
|
+
import { PreparedProjection, ProjectionName } from './prepareTypeormProjection';
|
|
5
5
|
import { ProjectionEvent } from '@cardano-sdk/projection';
|
|
6
6
|
export interface CreateTypeormProjectionProps {
|
|
7
7
|
projections: ProjectionName[];
|
|
@@ -11,5 +11,6 @@ export interface CreateTypeormProjectionProps {
|
|
|
11
11
|
devOptions?: TypeormDevOptions;
|
|
12
12
|
logger: Logger;
|
|
13
13
|
}
|
|
14
|
+
export declare const createObservableDataSource: ({ connectionConfig$, logger, buffer, devOptions, entities, extensions }: Omit<CreateTypeormProjectionProps, 'projections' | 'projectionSource$'> & Pick<PreparedProjection, 'entities' | 'extensions'>) => Observable<import("typeorm").DataSource>;
|
|
14
15
|
export declare const createTypeormProjection: ({ projections, projectionSource$, connectionConfig$, logger, devOptions, buffer }: CreateTypeormProjectionProps) => Observable<Omit<ProjectionEvent<Omit<WithTypeormContext, keyof WithTypeormContext | "pgBoss">>, "requestNext">>;
|
|
15
16
|
//# sourceMappingURL=createTypeormProjection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTypeormProjection.d.ts","sourceRoot":"","sources":["../../../src/Projection/createTypeormProjection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAmB,MAAM,MAAM,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,EAKnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"createTypeormProjection.d.ts","sourceRoot":"","sources":["../../../src/Projection/createTypeormProjection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAmB,MAAM,MAAM,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,EAKnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAA4B,MAAM,4BAA4B,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAsC,MAAM,yBAAyB,CAAC;AAI9F,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,MAAM,CAAC,EAAE,4BAA4B,CAAC;IACtC,iBAAiB,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;IAC/C,iBAAiB,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAClD,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAWD,eAAO,MAAM,0BAA0B,4EAOpC,KAAK,4BAA4B,EAAE,aAAa,GAAG,mBAAmB,CAAC,GACxE,KAAK,kBAAkB,EAAE,UAAU,GAAG,YAAY,CAAC,6CA2BlD,CAAC;AASJ,eAAO,MAAM,uBAAuB,sFAOjC,4BAA4B,oHAwB9B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTypeormProjection = void 0;
|
|
3
|
+
exports.createTypeormProjection = exports.createObservableDataSource = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const projection_typeorm_1 = require("@cardano-sdk/projection-typeorm");
|
|
6
6
|
const prepareTypeormProjection_1 = require("./prepareTypeormProjection");
|
|
@@ -9,7 +9,7 @@ const migrations_1 = require("./migrations");
|
|
|
9
9
|
const util_rxjs_1 = require("@cardano-sdk/util-rxjs");
|
|
10
10
|
const applyMappers = (selectedMappers) => (evt$) => evt$.pipe.apply(evt$, selectedMappers);
|
|
11
11
|
const applyStores = (selectedStores) => (evt$) => evt$.pipe.apply(evt$, selectedStores);
|
|
12
|
-
const
|
|
12
|
+
const createObservableDataSource = ({ connectionConfig$, logger, buffer, devOptions, entities, extensions }) => connectionConfig$.pipe((0, rxjs_1.switchMap)((connectionConfig) => (0, rxjs_1.from)((async () => {
|
|
13
13
|
const dataSource = (0, projection_typeorm_1.createDataSource)({
|
|
14
14
|
connectionConfig,
|
|
15
15
|
devOptions,
|
|
@@ -30,9 +30,10 @@ const createProjectionDataSource = ({ connectionConfig$, logger, buffer, devOpti
|
|
|
30
30
|
}
|
|
31
31
|
return dataSource;
|
|
32
32
|
})())));
|
|
33
|
+
exports.createObservableDataSource = createObservableDataSource;
|
|
33
34
|
const createTypeormProjection = ({ projections, projectionSource$, connectionConfig$, logger, devOptions, buffer }) => {
|
|
34
35
|
const { mappers, entities, stores, extensions } = (0, prepareTypeormProjection_1.prepareTypeormProjection)({ buffer, projections });
|
|
35
|
-
const dataSource$ =
|
|
36
|
+
const dataSource$ = (0, exports.createObservableDataSource)({
|
|
36
37
|
buffer,
|
|
37
38
|
connectionConfig$,
|
|
38
39
|
devOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTypeormProjection.js","sourceRoot":"","sources":["../../../src/Projection/createTypeormProjection.ts"],"names":[],"mappings":";;;AAGA,+BAAmD;AACnD,wEASyC;AACzC,yEAA0G;AAC1G,wDAA8F;AAC9F,6CAA0C;AAC1C,sDAA2D;AAW3D,MAAM,YAAY,GAChB,CAAS,eAA8C,EAAE,EAAE,CAC3D,CAAC,IAAiC,EAAE,EAAE,CACpC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,eAAsB,CAAmC,CAAC;AACpF,MAAM,WAAW,GACf,CAA+B,cAA4C,EAAE,EAAE,CAC/E,CAAC,IAAmB,EAAE,EAAE,CACtB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,cAAqB,CAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"createTypeormProjection.js","sourceRoot":"","sources":["../../../src/Projection/createTypeormProjection.ts"],"names":[],"mappings":";;;AAGA,+BAAmD;AACnD,wEASyC;AACzC,yEAA0G;AAC1G,wDAA8F;AAC9F,6CAA0C;AAC1C,sDAA2D;AAW3D,MAAM,YAAY,GAChB,CAAS,eAA8C,EAAE,EAAE,CAC3D,CAAC,IAAiC,EAAE,EAAE,CACpC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,eAAsB,CAAmC,CAAC;AACpF,MAAM,WAAW,GACf,CAA+B,cAA4C,EAAE,EAAE,CAC/E,CAAC,IAAmB,EAAE,EAAE,CACtB,IAAI,CAAC,IAA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AM,WAAW,GAAG,IAAA,kCAA0B,EAAC;QAC7C,MAAM;QACN,iBAAiB;QACjB,UAAU;QACV,QAAQ;QACR,UAAU;QACV,MAAM;KACP,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC,IAAI,CAC3B,YAAY,CAAC,OAAO,CAAC,EACrB,IAAA,6BAAiB,EACf,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,IAAI,CACP,IAAA,2CAAsB,EAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC,EAC3D,WAAW,CAAC,MAAM,CAAC,EACnB,IAAA,6CAAwB,GAAE,CAC3B,EACH,EAAE,WAAW,EAAE,8CAAyB,EAAE,CAC3C,EACD,IAAA,wBAAW,GAAE,EACb,IAAA,kCAAqB,EAAC,MAAM,CAAC,CAC9B,CAAC;AACJ,CAAC,CAAC;AA/BW,QAAA,uBAAuB,2BA+BlC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AssetEntity, BlockDataEntity, BlockEntity, DataSourceExtensions, OutputEntity, PoolMetadataEntity, PoolRegistrationEntity, PoolRetirementEntity, StakePoolEntity, TokensEntity, TypeormStabilityWindowBuffer } from '@cardano-sdk/projection-typeorm';
|
|
2
2
|
import { Mappers as Mapper } from '@cardano-sdk/projection';
|
|
3
|
-
export { DataSource } from 'typeorm';
|
|
4
3
|
export declare enum ProjectionName {
|
|
5
4
|
StakePool = "stake-pool",
|
|
6
5
|
StakePoolMetadataJob = "stake-pool-metadata-job",
|
|
@@ -56,4 +55,5 @@ export declare const prepareTypeormProjection: ({ projections, buffer }: Prepare
|
|
|
56
55
|
stores: StoreOperator[];
|
|
57
56
|
};
|
|
58
57
|
export declare type PreparedProjection = ReturnType<typeof prepareTypeormProjection>;
|
|
58
|
+
export {};
|
|
59
59
|
//# sourceMappingURL=prepareTypeormProjection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareTypeormProjection.d.ts","sourceRoot":"","sources":["../../../src/Projection/prepareTypeormProjection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,4BAA4B,EAM7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"prepareTypeormProjection.d.ts","sourceRoot":"","sources":["../../../src/Projection/prepareTypeormProjection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,4BAA4B,EAM7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAO5D,oBAAY,cAAc;IACxB,SAAS,eAAe;IACxB,oBAAoB,4BAA4B;IAChD,IAAI,SAAS;CACd;AAMD,QAAA,MAAM,eAAe;;;;;CAKpB,CAAC;AACF,aAAK,eAAe,GAAG,OAAO,eAAe,CAAC;AAC9C,aAAK,UAAU,GAAG,MAAM,eAAe,CAAC;AACxC,aAAK,cAAc,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;AAElD,QAAA,MAAM,cAAc;;;;;;CAMnB,CAAC;AACF,aAAK,cAAc,GAAG,OAAO,cAAc,CAAC;AAC5C,aAAK,SAAS,GAAG,MAAM,cAAc,CAAC;AACtC,aAAK,aAAa,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AAE/C,QAAA,MAAM,QAAQ;;;;;;;;;;CAUb,CAAC;AACF,eAAO,MAAM,WAAW,qOAA0B,CAAC;AACnD,aAAK,QAAQ,GAAG,OAAO,QAAQ,CAAC;AAChC,aAAK,UAAU,GAAG,MAAM,QAAQ,CAAC;AACjC,aAAK,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AA0GnC,MAAM,WAAW,6BAA6B;IAC5C,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,MAAM,CAAC,EAAE,4BAA4B,CAAC;CACvC;AAMD,eAAO,MAAM,wBAAwB,4BAA6B,6BAA6B;;;;;;;;;;CA4B9F,CAAC;AAEF,oBAAY,kBAAkB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prepareTypeormProjection = exports.allEntities = exports.ProjectionName =
|
|
3
|
+
exports.prepareTypeormProjection = exports.allEntities = exports.ProjectionName = void 0;
|
|
4
4
|
const projection_typeorm_1 = require("@cardano-sdk/projection-typeorm");
|
|
5
5
|
const projection_1 = require("@cardano-sdk/projection");
|
|
6
6
|
const topo_1 = require("@hapi/topo");
|
|
7
|
-
var typeorm_1 = require("typeorm");
|
|
8
|
-
Object.defineProperty(exports, "DataSource", { enumerable: true, get: function () { return typeorm_1.DataSource; } });
|
|
9
7
|
var ProjectionName;
|
|
10
8
|
(function (ProjectionName) {
|
|
11
9
|
ProjectionName["StakePool"] = "stake-pool";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareTypeormProjection.js","sourceRoot":"","sources":["../../../src/Projection/prepareTypeormProjection.ts"],"names":[],"mappings":";;;AAAA,wEAiByC;AACzC,wDAA4D;AAC5D,qCAAoC;
|
|
1
|
+
{"version":3,"file":"prepareTypeormProjection.js","sourceRoot":"","sources":["../../../src/Projection/prepareTypeormProjection.ts"],"names":[],"mappings":";;;AAAA,wEAiByC;AACzC,wDAA4D;AAC5D,qCAAoC;AAMpC,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,0CAAwB,CAAA;IACxB,kEAAgD,CAAA;IAChD,+BAA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Ae,GAAG,YAAY,CAAC,KAAK,CAAC;IAC3C,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC;IACzC,IAAI,MAAM,EAAE;QACV,gBAAgB,CAAC,IAAI,CAAC,oCAAe,CAAC,CAAC;QACvC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;KAC9C;IACD,MAAM,UAAU,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACnD,OAAO;QACL,OAAO,EAAE;YACP,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACnE,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;YACxE,MAAM,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;SACpE;QACD,QAAQ,EAAE,gBAAgB;QAC1B,UAAU;QACV,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE,cAAc;KACvB,CAAC;AACJ,CAAC,CAAC;AA5BW,QAAA,wBAAwB,4BA4BnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpStakePoolMetadataService.d.ts","sourceRoot":"","sources":["../../../../src/StakePool/HttpStakePoolMetadata/HttpStakePoolMetadataService.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAgC,wBAAwB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"HttpStakePoolMetadataService.d.ts","sourceRoot":"","sources":["../../../../src/StakePool/HttpStakePoolMetadata/HttpStakePoolMetadataService.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAgC,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAKlF,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAM7C,eAAO,MAAM,kCAAkC,WACrC,MAAM,gBACD,aAAa,KAIzB,wBA2JD,CAAC"}
|
|
@@ -81,34 +81,7 @@ const createHttpStakePoolMetadataService = (logger, axiosClient = axios_1.defaul
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
metadata = JSON.parse(data.toString());
|
|
84
|
-
|
|
85
|
-
if (metadata.extDataUrl && (!metadata.extSigUrl || !metadata.extVkey)) {
|
|
86
|
-
return {
|
|
87
|
-
errors: [
|
|
88
|
-
new errors_1.StakePoolMetadataServiceError(errors_1.StakePoolMetadataServiceFailure.InvalidMetadata, null, 'Missing ext signature or public key')
|
|
89
|
-
],
|
|
90
|
-
metadata
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
extMetadata = await this.getStakePoolExtendedMetadata(metadata);
|
|
94
|
-
if (metadata.extDataUrl && metadata.extSigUrl && metadata.extVkey) {
|
|
95
|
-
try {
|
|
96
|
-
const signature = (await axiosClient.get(metadata.extSigUrl)).data;
|
|
97
|
-
const message = util_1.HexBlob.fromBytes(Buffer.from(JSON.stringify(extMetadata)));
|
|
98
|
-
const publicKey = Crypto.Ed25519PublicKeyHex(metadata.extVkey);
|
|
99
|
-
const bip32Ed25519 = new Crypto.CmlBip32Ed25519(core_1.CML);
|
|
100
|
-
const isSignatureValid = await bip32Ed25519.verify(signature, message, publicKey);
|
|
101
|
-
if (!isSignatureValid) {
|
|
102
|
-
extMetadata = undefined;
|
|
103
|
-
errors.push(new errors_1.StakePoolMetadataServiceError(errors_1.StakePoolMetadataServiceFailure.InvalidExtendedMetadataSignature, null, 'Invalid extended metadata signature'));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
extMetadata = undefined;
|
|
108
|
-
errors.push(new errors_1.StakePoolMetadataServiceError(errors_1.StakePoolMetadataServiceFailure.FailedToFetchExtendedSignature, error, `${SERVICE_NAME} failed to fetch extended signature from ${metadata.extSigUrl} due to connection error`));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
84
|
+
extMetadata = await this.validateStakePoolExtendedMetadata(errors, metadata);
|
|
112
85
|
}
|
|
113
86
|
catch (error) {
|
|
114
87
|
if (axios_1.default.isAxiosError(error)) {
|
|
@@ -117,8 +90,38 @@ const createHttpStakePoolMetadataService = (logger, axiosClient = axios_1.defaul
|
|
|
117
90
|
else if (error instanceof errors_1.StakePoolMetadataServiceError) {
|
|
118
91
|
errors.push(error);
|
|
119
92
|
}
|
|
93
|
+
else {
|
|
94
|
+
errors.push(new errors_1.StakePoolMetadataServiceError(errors_1.StakePoolMetadataServiceFailure.Unknown, JSON.stringify(error), `${SERVICE_NAME} failed to fetch metadata JSON from ${url} due to ${error instanceof Error ? error.message : 'unknown error'}`));
|
|
95
|
+
}
|
|
120
96
|
}
|
|
121
97
|
return { errors, metadata: { ...metadata, ext: extMetadata } };
|
|
98
|
+
},
|
|
99
|
+
async validateStakePoolExtendedMetadata(errors, metadata) {
|
|
100
|
+
if (!metadata?.extDataUrl && !metadata?.extended)
|
|
101
|
+
return;
|
|
102
|
+
if (metadata.extDataUrl && (!metadata.extSigUrl || !metadata.extVkey)) {
|
|
103
|
+
errors.push(new errors_1.StakePoolMetadataServiceError(errors_1.StakePoolMetadataServiceFailure.InvalidMetadata, null, 'Missing ext signature or public key'));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
let extMetadata = await this.getStakePoolExtendedMetadata(metadata);
|
|
107
|
+
if (metadata.extDataUrl && metadata.extSigUrl && metadata.extVkey) {
|
|
108
|
+
try {
|
|
109
|
+
const signature = (await axiosClient.get(metadata.extSigUrl)).data;
|
|
110
|
+
const message = util_1.HexBlob.fromBytes(Buffer.from(JSON.stringify(extMetadata)));
|
|
111
|
+
const publicKey = Crypto.Ed25519PublicKeyHex(metadata.extVkey);
|
|
112
|
+
const bip32Ed25519 = new Crypto.CmlBip32Ed25519(core_1.CML);
|
|
113
|
+
const isSignatureValid = await bip32Ed25519.verify(signature, message, publicKey);
|
|
114
|
+
if (!isSignatureValid) {
|
|
115
|
+
extMetadata = undefined;
|
|
116
|
+
errors.push(new errors_1.StakePoolMetadataServiceError(errors_1.StakePoolMetadataServiceFailure.InvalidExtendedMetadataSignature, null, 'Invalid extended metadata signature'));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
extMetadata = undefined;
|
|
121
|
+
errors.push(new errors_1.StakePoolMetadataServiceError(errors_1.StakePoolMetadataServiceFailure.FailedToFetchExtendedSignature, error, `${SERVICE_NAME} failed to fetch extended signature from ${metadata.extSigUrl} due to connection error`));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return extMetadata;
|
|
122
125
|
}
|
|
123
126
|
});
|
|
124
127
|
exports.createHttpStakePoolMetadataService = createHttpStakePoolMetadataService;
|