@nx-ddd/common 19.0.0-preview.8 → 19.1.0
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/domain/index.d.ts +117 -2
- package/fesm2022/nx-ddd-common-domain.mjs +262 -0
- package/fesm2022/nx-ddd-common-domain.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-chromium-impl.mjs +89 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-chromium-impl.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-chromium-token.mjs +10 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-chromium-token.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-chromium.mjs +10 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-chromium.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-cloud-storage.mjs +46 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-cloud-storage.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-crypto-impl-browser.mjs +12 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-crypto-impl-browser.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-crypto-impl-server.mjs +13 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-crypto-impl-server.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-crypto-token.mjs +10 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-crypto-token.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-crypto.mjs +10 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-crypto.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-firebase-admin-impl.mjs +16 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-firebase-admin-impl.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-firebase-admin-token.mjs +10 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-firebase-admin-token.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-firebase-admin.mjs +13 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-firebase-admin.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-openai-impl.mjs +37 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-openai-impl.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-openai-token.mjs +10 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-openai-token.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-openai.mjs +14 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-openai.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-stripe-impl.mjs +33 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-stripe-impl.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-stripe-token.mjs +10 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-stripe-token.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-stripe.mjs +13 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-stripe.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-websocket-impl-browser.mjs +15 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-websocket-impl-browser.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-websocket-impl-server.mjs +21 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-websocket-impl-server.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-websocket-token.mjs +11 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-websocket-token.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-websocket.mjs +11 -0
- package/fesm2022/nx-ddd-common-infrastructure-externals-websocket.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-logging.mjs +129 -0
- package/fesm2022/nx-ddd-common-infrastructure-logging.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure-queries.mjs +54 -0
- package/fesm2022/nx-ddd-common-infrastructure-queries.mjs.map +1 -0
- package/fesm2022/nx-ddd-common-infrastructure.mjs +31 -0
- package/fesm2022/nx-ddd-common-infrastructure.mjs.map +1 -0
- package/fesm2022/nx-ddd-common.mjs +58 -0
- package/fesm2022/nx-ddd-common.mjs.map +1 -0
- package/index.d.ts +8 -1
- package/infrastructure/externals/chromium/impl/index.d.ts +21 -0
- package/infrastructure/externals/chromium/index.d.ts +6 -1
- package/infrastructure/externals/chromium/token/index.d.ts +5 -0
- package/infrastructure/externals/cloud-storage/index.d.ts +19 -1
- package/infrastructure/externals/crypto/impl/browser/index.d.ts +5 -0
- package/infrastructure/externals/crypto/impl/server/index.d.ts +5 -0
- package/infrastructure/externals/crypto/index.d.ts +6 -0
- package/infrastructure/externals/crypto/token/index.d.ts +6 -0
- package/infrastructure/externals/firebase-admin/impl/index.d.ts +10 -0
- package/infrastructure/externals/firebase-admin/index.d.ts +5 -1
- package/infrastructure/externals/firebase-admin/token/index.d.ts +12 -0
- package/infrastructure/externals/openai/impl/index.d.ts +18 -0
- package/infrastructure/externals/openai/index.d.ts +7 -2
- package/infrastructure/externals/openai/token/index.d.ts +5 -0
- package/infrastructure/externals/stripe/impl/index.d.ts +28 -0
- package/infrastructure/externals/stripe/index.d.ts +5 -2
- package/infrastructure/externals/stripe/token/index.d.ts +5 -0
- package/infrastructure/externals/websocket/impl/browser/index.d.ts +5 -0
- package/infrastructure/externals/websocket/impl/server/index.d.ts +5 -0
- package/infrastructure/externals/websocket/index.d.ts +13 -0
- package/infrastructure/externals/websocket/token/index.d.ts +13 -0
- package/infrastructure/index.d.ts +37 -3
- package/infrastructure/logging/index.d.ts +114 -0
- package/infrastructure/queries/index.d.ts +50 -1
- package/package.json +118 -27
- package/README.md +0 -40
- package/domain/index.js +0 -6
- package/domain/index.js.map +0 -1
- package/domain/models.d.ts +0 -70
- package/domain/models.js +0 -129
- package/domain/models.js.map +0 -1
- package/domain/repository.d.ts +0 -11
- package/domain/repository.js +0 -27
- package/domain/repository.js.map +0 -1
- package/domain/resolver.d.ts +0 -8
- package/domain/resolver.js +0 -25
- package/domain/resolver.js.map +0 -1
- package/index.js +0 -5
- package/index.js.map +0 -1
- package/infrastructure/converter.d.ts +0 -4
- package/infrastructure/converter.js +0 -7
- package/infrastructure/converter.js.map +0 -1
- package/infrastructure/externals/backup/backup.service.d.ts +0 -24
- package/infrastructure/externals/backup/backup.service.js +0 -67
- package/infrastructure/externals/backup/backup.service.js.map +0 -1
- package/infrastructure/externals/backup/index.d.ts +0 -1
- package/infrastructure/externals/backup/index.js +0 -5
- package/infrastructure/externals/backup/index.js.map +0 -1
- package/infrastructure/externals/chromium/chromium.service.impl.d.ts +0 -18
- package/infrastructure/externals/chromium/chromium.service.impl.js +0 -58
- package/infrastructure/externals/chromium/chromium.service.impl.js.map +0 -1
- package/infrastructure/externals/chromium/chromuim.service.d.ts +0 -9
- package/infrastructure/externals/chromium/chromuim.service.js +0 -6
- package/infrastructure/externals/chromium/chromuim.service.js.map +0 -1
- package/infrastructure/externals/chromium/index.js +0 -5
- package/infrastructure/externals/chromium/index.js.map +0 -1
- package/infrastructure/externals/cloud-storage/cloud-storage.service.d.ts +0 -13
- package/infrastructure/externals/cloud-storage/cloud-storage.service.js +0 -43
- package/infrastructure/externals/cloud-storage/cloud-storage.service.js.map +0 -1
- package/infrastructure/externals/cloud-storage/index.js +0 -5
- package/infrastructure/externals/cloud-storage/index.js.map +0 -1
- package/infrastructure/externals/firebase-admin/firebase-admin.service.d.ts +0 -9
- package/infrastructure/externals/firebase-admin/firebase-admin.service.impl.d.ts +0 -5
- package/infrastructure/externals/firebase-admin/firebase-admin.service.impl.js +0 -13
- package/infrastructure/externals/firebase-admin/firebase-admin.service.impl.js.map +0 -1
- package/infrastructure/externals/firebase-admin/firebase-admin.service.js +0 -11
- package/infrastructure/externals/firebase-admin/firebase-admin.service.js.map +0 -1
- package/infrastructure/externals/firebase-admin/index.js +0 -5
- package/infrastructure/externals/firebase-admin/index.js.map +0 -1
- package/infrastructure/externals/openai/index.js +0 -6
- package/infrastructure/externals/openai/index.js.map +0 -1
- package/infrastructure/externals/openai/open-ai.config.d.ts +0 -7
- package/infrastructure/externals/openai/open-ai.config.js +0 -19
- package/infrastructure/externals/openai/open-ai.config.js.map +0 -1
- package/infrastructure/externals/openai/open-ai.service.d.ts +0 -4
- package/infrastructure/externals/openai/open-ai.service.impl.d.ts +0 -4
- package/infrastructure/externals/openai/open-ai.service.impl.js +0 -18
- package/infrastructure/externals/openai/open-ai.service.impl.js.map +0 -1
- package/infrastructure/externals/openai/open-ai.service.js +0 -11
- package/infrastructure/externals/openai/open-ai.service.js.map +0 -1
- package/infrastructure/externals/stripe/index.js +0 -6
- package/infrastructure/externals/stripe/index.js.map +0 -1
- package/infrastructure/externals/stripe/stripe.config.d.ts +0 -17
- package/infrastructure/externals/stripe/stripe.config.js +0 -15
- package/infrastructure/externals/stripe/stripe.config.js.map +0 -1
- package/infrastructure/externals/stripe/stripe.service.d.ts +0 -4
- package/infrastructure/externals/stripe/stripe.service.impl.d.ts +0 -5
- package/infrastructure/externals/stripe/stripe.service.impl.js +0 -44
- package/infrastructure/externals/stripe/stripe.service.impl.js.map +0 -1
- package/infrastructure/externals/stripe/stripe.service.js +0 -11
- package/infrastructure/externals/stripe/stripe.service.js.map +0 -1
- package/infrastructure/index.js +0 -7
- package/infrastructure/index.js.map +0 -1
- package/infrastructure/queries/cached-query.d.ts +0 -45
- package/infrastructure/queries/cached-query.js +0 -47
- package/infrastructure/queries/cached-query.js.map +0 -1
- package/infrastructure/queries/index.js +0 -5
- package/infrastructure/queries/index.js.map +0 -1
- package/infrastructure/repo/excel/excel.converter.d.ts +0 -29
- package/infrastructure/repo/excel/excel.converter.js +0 -71
- package/infrastructure/repo/excel/excel.converter.js.map +0 -1
- package/infrastructure/repo/excel/excel.decorators.d.ts +0 -29
- package/infrastructure/repo/excel/excel.decorators.js +0 -55
- package/infrastructure/repo/excel/excel.decorators.js.map +0 -1
- package/infrastructure/repo/excel/excel.repository.d.ts +0 -14
- package/infrastructure/repo/excel/excel.repository.js +0 -32
- package/infrastructure/repo/excel/excel.repository.js.map +0 -1
- package/infrastructure/repo/excel/excel.service.impl.d.ts +0 -17
- package/infrastructure/repo/excel/excel.service.impl.js +0 -61
- package/infrastructure/repo/excel/excel.service.impl.js.map +0 -1
- package/infrastructure/repo/excel/index.d.ts +0 -3
- package/infrastructure/repo/excel/index.js +0 -7
- package/infrastructure/repo/excel/index.js.map +0 -1
- package/infrastructure/synchronizer.d.ts +0 -16
- package/infrastructure/synchronizer.js +0 -18
- package/infrastructure/synchronizer.js.map +0 -1
- package/utilities/generate-id.d.ts +0 -1
- package/utilities/generate-id.js +0 -23
- package/utilities/generate-id.js.map +0 -1
- package/utilities/index.d.ts +0 -2
- package/utilities/index.js +0 -6
- package/utilities/index.js.map +0 -1
- package/utilities/message.d.ts +0 -1
- package/utilities/message.js +0 -26
- package/utilities/message.js.map +0 -1
- package/utilities/to-object.d.ts +0 -1
- package/utilities/to-object.js +0 -14
- package/utilities/to-object.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stripe.config.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/externals/stripe/stripe.config.ts"],"names":[],"mappings":";;;AAUA,sCAKC;AAfD,wCAAyD;AACzD,+DAA0D;AAC1D,qDAAkD;AAMrC,QAAA,aAAa,GAAG,IAAI,qBAAc,CAAe,eAAe,CAAC,CAAC;AAE/E,SAAgB,aAAa,CAAC,aAAmD;IAC/E,OAAO;QACL,EAAE,OAAO,EAAE,+BAAc,EAAE,QAAQ,EAAE,uCAAiB,EAAE,IAAI,EAAE,CAAC,qBAAa,CAAC,EAAE;QAC/E,EAAE,OAAO,EAAE,qBAAa,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,eAAQ,CAAC,EAAE;KACxE,CAAC;AACJ,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StripeServiceImpl = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const core_1 = require("@angular/core");
|
|
6
|
-
const stripe_config_1 = require("./stripe.config");
|
|
7
|
-
const stripe_1 = tslib_1.__importDefault(require("stripe"));
|
|
8
|
-
let StripeServiceImpl = class StripeServiceImpl extends stripe_1.default {
|
|
9
|
-
constructor(config) {
|
|
10
|
-
super(config.secretKey);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
exports.StripeServiceImpl = StripeServiceImpl;
|
|
14
|
-
exports.StripeServiceImpl = StripeServiceImpl = tslib_1.__decorate([
|
|
15
|
-
(0, core_1.Injectable)(),
|
|
16
|
-
tslib_1.__param(0, (0, core_1.Inject)(stripe_config_1.STRIPE_CONFIG)),
|
|
17
|
-
tslib_1.__metadata("design:paramtypes", [Object])
|
|
18
|
-
], StripeServiceImpl);
|
|
19
|
-
// @Injectable()
|
|
20
|
-
// export class StripeServiceImpl extends StripeService {
|
|
21
|
-
// constructor(
|
|
22
|
-
// @Inject(STRIPE_CONFIG) private config: StripeConfig,
|
|
23
|
-
// ) {
|
|
24
|
-
// super();
|
|
25
|
-
// }
|
|
26
|
-
// private stripe = new Stripe(this.config.secret, {apiVersion: '2022-11-15'});
|
|
27
|
-
// createCard(card: Card): Promise<Stripe.Token> {
|
|
28
|
-
// return this.stripe.tokens.create({
|
|
29
|
-
// card: {
|
|
30
|
-
// number: card.number,
|
|
31
|
-
// exp_month: `${card.expMonth}`,
|
|
32
|
-
// exp_year: `${card.expYear}`,
|
|
33
|
-
// cvc: card.cvc,
|
|
34
|
-
// }
|
|
35
|
-
// }, {});
|
|
36
|
-
// }
|
|
37
|
-
// createCustomer(metadata: {userId: string}): Promise<Stripe.Response<Stripe.Customer>> {
|
|
38
|
-
// return this.stripe.customers.create({metadata}, {});
|
|
39
|
-
// }
|
|
40
|
-
// createSource(customerId: string, source: string): Promise<Stripe.Response<Stripe.CustomerSource>> {
|
|
41
|
-
// return this.stripe.customers.createSource(customerId, {source});
|
|
42
|
-
// }
|
|
43
|
-
// }
|
|
44
|
-
//# sourceMappingURL=stripe.service.impl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stripe.service.impl.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/externals/stripe/stripe.service.impl.ts"],"names":[],"mappings":";;;;AAAA,wCAAmD;AACnD,mDAA8D;AAC9D,4DAA4B;AAGrB,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,gBAAM;IAC3C,YACyB,MAAoB;QAE3C,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;CACF,CAAA;AANY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,iBAAU,GAAE;IAGR,mBAAA,IAAA,aAAM,EAAC,6BAAa,CAAC,CAAA;;GAFb,iBAAiB,CAM7B;AAED,gBAAgB;AAChB,yDAAyD;AACzD,iBAAiB;AACjB,2DAA2D;AAC3D,QAAQ;AACR,eAAe;AACf,MAAM;AAEN,iFAAiF;AAEjF,oDAAoD;AACpD,yCAAyC;AACzC,gBAAgB;AAChB,+BAA+B;AAC/B,yCAAyC;AACzC,uCAAuC;AACvC,yBAAyB;AACzB,UAAU;AACV,cAAc;AACd,MAAM;AAEN,4FAA4F;AAC5F,2DAA2D;AAC3D,MAAM;AAEN,wGAAwG;AACxG,uEAAuE;AACvE,MAAM;AACN,IAAI"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.STRIPE_SERVICE = void 0;
|
|
4
|
-
exports.injectStripe = injectStripe;
|
|
5
|
-
const core_1 = require("@angular/core");
|
|
6
|
-
exports.STRIPE_SERVICE = new core_1.InjectionToken('STRIPE_SERVICE');
|
|
7
|
-
function injectStripe() {
|
|
8
|
-
var _a;
|
|
9
|
-
return (_a = (0, core_1.inject)(exports.STRIPE_SERVICE, { optional: true })) !== null && _a !== void 0 ? _a : {};
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=stripe.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stripe.service.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/externals/stripe/stripe.service.ts"],"names":[],"mappings":";;;AAKA,oCAEC;AAPD,wCAAuD;AAG1C,QAAA,cAAc,GAAG,IAAI,qBAAc,CAAS,gBAAgB,CAAC,CAAC;AAE3E,SAAgB,YAAY;;IAC1B,OAAO,MAAA,IAAA,aAAM,EAAC,sBAAc,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,mCAAI,EAAY,CAAC;AAClE,CAAC"}
|
package/infrastructure/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./converter"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./synchronizer"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./queries"), exports);
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/common/src/infrastructure/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,yDAA+B;AAC/B,oDAA0B"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import { RepositorySynchronizer } from '../synchronizer';
|
|
3
|
-
import { Observable } from 'rxjs';
|
|
4
|
-
export declare function getLastUpdatedAt<T extends {
|
|
5
|
-
updatedAt: dayjs.Dayjs;
|
|
6
|
-
}>(items: T[]): dayjs.Dayjs;
|
|
7
|
-
interface SrcRepository<T extends {
|
|
8
|
-
updatedAt: dayjs.Dayjs;
|
|
9
|
-
}> {
|
|
10
|
-
count: () => Promise<number>;
|
|
11
|
-
query: {
|
|
12
|
-
listChangesAfter: (updatedAt: dayjs.Dayjs, { limit }: {
|
|
13
|
-
limit?: number;
|
|
14
|
-
}) => Observable<T[]>;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
interface DestRepository<T extends {
|
|
18
|
-
updatedAt: dayjs.Dayjs;
|
|
19
|
-
}> {
|
|
20
|
-
listChanges: () => Observable<T[]>;
|
|
21
|
-
saveMany: (items: T[]) => void;
|
|
22
|
-
count: () => Observable<number>;
|
|
23
|
-
}
|
|
24
|
-
export declare class CachedQuery<T extends {
|
|
25
|
-
updatedAt: dayjs.Dayjs;
|
|
26
|
-
}> {
|
|
27
|
-
protected repository: SrcRepository<T>;
|
|
28
|
-
protected indexedDb: DestRepository<T>;
|
|
29
|
-
protected options: {
|
|
30
|
-
debounceTime?: number;
|
|
31
|
-
chunkSize?: number;
|
|
32
|
-
};
|
|
33
|
-
constructor(repository: SrcRepository<T>, indexedDb: DestRepository<T>, options?: {
|
|
34
|
-
debounceTime?: number;
|
|
35
|
-
chunkSize?: number;
|
|
36
|
-
});
|
|
37
|
-
readonly synchronizer: RepositorySynchronizer<T>;
|
|
38
|
-
list(): Observable<T[]>;
|
|
39
|
-
}
|
|
40
|
-
export declare class CachedQueryFactory {
|
|
41
|
-
create<T extends {
|
|
42
|
-
updatedAt: dayjs.Dayjs;
|
|
43
|
-
}>(repository: SrcRepository<T>, indexedDb: DestRepository<T>): CachedQuery<T>;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CachedQueryFactory = exports.CachedQuery = void 0;
|
|
4
|
-
exports.getLastUpdatedAt = getLastUpdatedAt;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const core_1 = require("@angular/core");
|
|
7
|
-
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
8
|
-
const synchronizer_1 = require("../synchronizer");
|
|
9
|
-
const rxjs_1 = require("rxjs");
|
|
10
|
-
function getLastUpdatedAt(items) {
|
|
11
|
-
return items.reduce((acc, entity) => {
|
|
12
|
-
if (!(entity === null || entity === void 0 ? void 0 : entity.updatedAt))
|
|
13
|
-
return acc;
|
|
14
|
-
return entity.updatedAt.isAfter(acc) ? entity.updatedAt : acc;
|
|
15
|
-
}, (0, dayjs_1.default)('1997-01-01'));
|
|
16
|
-
}
|
|
17
|
-
class CachedQuery {
|
|
18
|
-
constructor(repository, indexedDb, options = {
|
|
19
|
-
debounceTime: 5000,
|
|
20
|
-
chunkSize: 100,
|
|
21
|
-
}) {
|
|
22
|
-
this.repository = repository;
|
|
23
|
-
this.indexedDb = indexedDb;
|
|
24
|
-
this.options = options;
|
|
25
|
-
this.synchronizer = new synchronizer_1.RepositorySynchronizer({
|
|
26
|
-
lastUpdatedAtChanges: () => this.indexedDb.listChanges().pipe((0, rxjs_1.map)(getLastUpdatedAt)),
|
|
27
|
-
saveMany: (items) => this.indexedDb.saveMany(items),
|
|
28
|
-
listChangesAfter: (updatedAt) => this.repository.query.listChangesAfter(updatedAt, { limit: this.options.chunkSize }),
|
|
29
|
-
srcCount: () => (0, rxjs_1.from)(this.repository.count()),
|
|
30
|
-
destCount: () => this.indexedDb.count(),
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
list() {
|
|
34
|
-
return this.synchronizer.sync().pipe((0, rxjs_1.switchMap)(() => this.indexedDb.listChanges()), (0, rxjs_1.throttleTime)(this.options.debounceTime));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.CachedQuery = CachedQuery;
|
|
38
|
-
let CachedQueryFactory = class CachedQueryFactory {
|
|
39
|
-
create(repository, indexedDb) {
|
|
40
|
-
return new CachedQuery(repository, indexedDb);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
exports.CachedQueryFactory = CachedQueryFactory;
|
|
44
|
-
exports.CachedQueryFactory = CachedQueryFactory = tslib_1.__decorate([
|
|
45
|
-
(0, core_1.Injectable)({ providedIn: 'root' })
|
|
46
|
-
], CachedQueryFactory);
|
|
47
|
-
//# sourceMappingURL=cached-query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cached-query.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/common/src/infrastructure/queries/cached-query.ts"],"names":[],"mappings":";;;AAKA,4CAKC;;AAVD,wCAA2C;AAC3C,0DAA0B;AAC1B,kDAAyD;AACzD,+BAAyF;AAEzF,SAAgB,gBAAgB,CAAqC,KAAU;IAC7E,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QAClC,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAA;YAAE,OAAO,GAAG,CAAC;QACnC,OAAO,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;IAChE,CAAC,EAAE,IAAA,eAAK,EAAC,YAAY,CAAC,CAAC,CAAC;AAC1B,CAAC;AAeD,MAAa,WAAW;IACtB,YACY,UAA4B,EAC5B,SAA4B,EAC5B,UAGN;QACF,YAAY,EAAE,IAAK;QACnB,SAAS,EAAE,GAAG;KACf;QARS,eAAU,GAAV,UAAU,CAAkB;QAC5B,cAAS,GAAT,SAAS,CAAmB;QAC5B,YAAO,GAAP,OAAO,CAMhB;QAEM,iBAAY,GAAG,IAAI,qCAAsB,CAAC;YACjD,oBAAoB,EAAE,GAAG,EAAE,CAA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],"mappings":";;;AAAA,yDAA+B"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
export interface ExcelConverter<T> {
|
|
3
|
-
fromExcel(record: any): T;
|
|
4
|
-
fromExcelMany(records: any[]): T[];
|
|
5
|
-
toExcel(model: T): any;
|
|
6
|
-
toExcelMany(models: T[]): any[];
|
|
7
|
-
}
|
|
8
|
-
export declare class ExcelUtils {
|
|
9
|
-
static toDayjs(serial: number | null): dayjs.Dayjs;
|
|
10
|
-
static fromDayjs(date: dayjs.Dayjs | null): Date;
|
|
11
|
-
static fromExcel<E, D extends object>(record: any, type: {
|
|
12
|
-
new (): E;
|
|
13
|
-
}): D;
|
|
14
|
-
static toExcel<E, D extends object>(entity: E, type: {
|
|
15
|
-
new (): E;
|
|
16
|
-
}): D;
|
|
17
|
-
}
|
|
18
|
-
/** @deprecated use ExcelUtils.toDayjs instead. */
|
|
19
|
-
export declare function toDayjs(serial: number | null): dayjs.Dayjs;
|
|
20
|
-
/** @deprecated use ExcelUtils.fromDayjs instead. */
|
|
21
|
-
export declare function fromDayjs(date: dayjs.Dayjs | null): Date;
|
|
22
|
-
/** @deprecated use ExcelUtils.fromExcel instead. */
|
|
23
|
-
export declare function fromExcel<E, D extends object>(record: any, type: {
|
|
24
|
-
new (): E;
|
|
25
|
-
}): D;
|
|
26
|
-
/** @deprecated use ExcelUtils.toExcel instead. */
|
|
27
|
-
export declare function toExcel<E, D extends object>(entity: E, type: {
|
|
28
|
-
new (): E;
|
|
29
|
-
}): D;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExcelUtils = void 0;
|
|
4
|
-
exports.toDayjs = toDayjs;
|
|
5
|
-
exports.fromDayjs = fromDayjs;
|
|
6
|
-
exports.fromExcel = fromExcel;
|
|
7
|
-
exports.toExcel = toExcel;
|
|
8
|
-
const tslib_1 = require("tslib");
|
|
9
|
-
const excel_decorators_1 = require("./excel.decorators");
|
|
10
|
-
const lodash_es_1 = require("lodash-es");
|
|
11
|
-
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
12
|
-
class ExcelUtils {
|
|
13
|
-
static toDayjs(serial) {
|
|
14
|
-
if (typeof serial !== 'number')
|
|
15
|
-
return null;
|
|
16
|
-
const excelEpoch = (0, dayjs_1.default)('1899-12-30');
|
|
17
|
-
return excelEpoch.add(serial, 'day');
|
|
18
|
-
}
|
|
19
|
-
static fromDayjs(date) {
|
|
20
|
-
if (!dayjs_1.default.isDayjs(date))
|
|
21
|
-
return null;
|
|
22
|
-
return date.toDate();
|
|
23
|
-
}
|
|
24
|
-
static fromExcel(record, type) {
|
|
25
|
-
const annotations = (0, excel_decorators_1.getFlattenFieldAnnotations)(type);
|
|
26
|
-
const obj = Object.entries(annotations).reduce((acc, [key, annotation]) => {
|
|
27
|
-
var _a;
|
|
28
|
-
const value = (0, lodash_es_1.get)(record, annotation.fieldName);
|
|
29
|
-
switch (annotation.type) {
|
|
30
|
-
case 'number': return Object.assign(Object.assign({}, acc), { [annotation === null || annotation === void 0 ? void 0 : annotation.propName]: isNaN(Number(value)) ? null : Number(value) });
|
|
31
|
-
case 'date': return Object.assign(Object.assign({}, acc), { [annotation === null || annotation === void 0 ? void 0 : annotation.propName]: this.toDayjs(value) });
|
|
32
|
-
case 'array': return Object.assign(Object.assign({}, acc), { [annotation === null || annotation === void 0 ? void 0 : annotation.propName]: (_a = value === null || value === void 0 ? void 0 : value.split(',')) !== null && _a !== void 0 ? _a : [] });
|
|
33
|
-
case 'boolean': return Object.assign(Object.assign({}, acc), { [annotation === null || annotation === void 0 ? void 0 : annotation.propName]: value });
|
|
34
|
-
default: return Object.assign(Object.assign({}, acc), { [annotation === null || annotation === void 0 ? void 0 : annotation.propName]: value || null });
|
|
35
|
-
}
|
|
36
|
-
}, {});
|
|
37
|
-
return obj;
|
|
38
|
-
}
|
|
39
|
-
static toExcel(entity, type) {
|
|
40
|
-
const annotations = (0, excel_decorators_1.getFlattenFieldAnnotations)(type);
|
|
41
|
-
const obj = Object.entries(annotations).reduce((acc, [key, annotation]) => {
|
|
42
|
-
const value = (0, lodash_es_1.get)(entity, annotation.propName);
|
|
43
|
-
switch (annotation.type) {
|
|
44
|
-
case 'number': return Object.assign(Object.assign({}, acc), { [annotation.fieldName]: isNaN(Number(value)) ? null : Number(value) });
|
|
45
|
-
case 'date': return Object.assign(Object.assign({}, acc), { [annotation.fieldName]: this.fromDayjs(value) });
|
|
46
|
-
case 'array': return Object.assign(Object.assign({}, acc), { [annotation.fieldName]: Array.isArray(value) ? value.join(',') : value });
|
|
47
|
-
case 'boolean': return Object.assign(Object.assign({}, acc), { [annotation.fieldName]: value ? 'TRUE' : 'FALSE' });
|
|
48
|
-
default: return Object.assign(Object.assign({}, acc), { [annotation.fieldName]: value });
|
|
49
|
-
}
|
|
50
|
-
}, {});
|
|
51
|
-
return obj;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.ExcelUtils = ExcelUtils;
|
|
55
|
-
/** @deprecated use ExcelUtils.toDayjs instead. */
|
|
56
|
-
function toDayjs(serial) {
|
|
57
|
-
return ExcelUtils.toDayjs(serial);
|
|
58
|
-
}
|
|
59
|
-
/** @deprecated use ExcelUtils.fromDayjs instead. */
|
|
60
|
-
function fromDayjs(date) {
|
|
61
|
-
return ExcelUtils.fromDayjs(date);
|
|
62
|
-
}
|
|
63
|
-
/** @deprecated use ExcelUtils.fromExcel instead. */
|
|
64
|
-
function fromExcel(record, type) {
|
|
65
|
-
return ExcelUtils.fromExcel(record, type);
|
|
66
|
-
}
|
|
67
|
-
/** @deprecated use ExcelUtils.toExcel instead. */
|
|
68
|
-
function toExcel(entity, type) {
|
|
69
|
-
return ExcelUtils.toExcel(entity, type);
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=excel.converter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"excel.converter.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/repo/excel/excel.converter.ts"],"names":[],"mappings":";;;AAiEA,0BAEC;AAED,8BAEC;AAED,8BAEC;AAED,0BAEC;;AA/ED,yDAAgE;AAChE,yCAAgC;AAChC,0DAA0B;AAS1B,MAAa,UAAU;IACrB,MAAM,CAAC,OAAO,CAAC,MAAqB;QAClC,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC5C,MAAM,UAAU,GAAG,IAAA,eAAK,EAAC,YAAY,CAAC,CAAC;QACvC,OAAO,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,IAAwB;QACvC,IAAI,CAAC,eAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QACtC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,SAAS,CAAsB,MAAW,EAAE,IAAgB;QACjE,MAAM,WAAW,GAAG,IAAA,6CAA0B,EAK3C,IAAI,CAAC,CAAC;QACT,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,EAAE;;YACxE,MAAM,KAAK,GAAG,IAAA,eAAG,EAAC,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;YAChD,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;gBACxB,KAAK,QAAQ,CAAC,CAAC,uCAAY,GAAG,KAAE,CAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAG;gBACtG,KA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,29 +0,0 @@
|
|
|
1
|
-
export declare function getFlattenFieldAnnotations<Annotation>(T: any, prefix?: string): Record<string, Annotation>;
|
|
2
|
-
export declare function getFields(T: any, options?: {
|
|
3
|
-
prefix?: string;
|
|
4
|
-
case?: 'snake' | 'camel' | 'original';
|
|
5
|
-
}): string[];
|
|
6
|
-
export declare function getHeaders(T: any): string[];
|
|
7
|
-
export declare const Excel: {
|
|
8
|
-
Text: (nameOrProps?: {
|
|
9
|
-
name?: string;
|
|
10
|
-
} | string) => (target: any, propName: string) => void;
|
|
11
|
-
Date: (nameOrProps?: {
|
|
12
|
-
name?: string;
|
|
13
|
-
} | string) => (target: any, propName: string) => void;
|
|
14
|
-
Number: (nameOrProps?: {
|
|
15
|
-
name?: string;
|
|
16
|
-
} | string) => (target: any, propName: string) => void;
|
|
17
|
-
Array: (nameOrProps?: {
|
|
18
|
-
name?: string;
|
|
19
|
-
} | string) => (target: any, propName: string) => void;
|
|
20
|
-
Boolean: (nameOrProps?: {
|
|
21
|
-
name?: string;
|
|
22
|
-
} | string) => (target: any, propName: string) => void;
|
|
23
|
-
getAnnotations: (target: any) => {
|
|
24
|
-
type: string;
|
|
25
|
-
fieldName: string;
|
|
26
|
-
propName: string;
|
|
27
|
-
childType: any;
|
|
28
|
-
}[];
|
|
29
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Excel = void 0;
|
|
4
|
-
exports.getFlattenFieldAnnotations = getFlattenFieldAnnotations;
|
|
5
|
-
exports.getFields = getFields;
|
|
6
|
-
exports.getHeaders = getHeaders;
|
|
7
|
-
const create_decorator_1 = require("@nx-ddd/core/create-decorator");
|
|
8
|
-
const lodash_es_1 = require("lodash-es");
|
|
9
|
-
const { createDecorator, getAnnotations, } = (0, create_decorator_1.makeDecoratorFactories)((type, fieldName, propName, options) => ({ type, fieldName, propName, childType: options.childType }), '[@nx-ddd/excel] annotations');
|
|
10
|
-
function getFlattenFieldAnnotations(T, prefix = '') {
|
|
11
|
-
const annotations = getAnnotations(T);
|
|
12
|
-
return (annotations !== null && annotations !== void 0 ? annotations : []).reduce((acc, annotation) => {
|
|
13
|
-
const currentKey = prefix ? (0, lodash_es_1.camelCase)(`${prefix}_${annotation.fieldName}`) : annotation.fieldName;
|
|
14
|
-
if (annotation.childType) {
|
|
15
|
-
return Object.assign(Object.assign({}, acc), getFlattenFieldAnnotations(annotation.childType(), currentKey));
|
|
16
|
-
}
|
|
17
|
-
return Object.assign(Object.assign({}, acc), { [currentKey]: annotation });
|
|
18
|
-
}, {});
|
|
19
|
-
}
|
|
20
|
-
function getFields(T, options = {
|
|
21
|
-
prefix: '',
|
|
22
|
-
case: 'original'
|
|
23
|
-
}) {
|
|
24
|
-
const annotations = getAnnotations(T);
|
|
25
|
-
const changeCase = (options === null || options === void 0 ? void 0 : options.case) === 'snake'
|
|
26
|
-
? lodash_es_1.snakeCase
|
|
27
|
-
: (options === null || options === void 0 ? void 0 : options.case) === 'camel' ? lodash_es_1.camelCase
|
|
28
|
-
: (value) => value;
|
|
29
|
-
const fields = (annotations !== null && annotations !== void 0 ? annotations : []).flatMap((annotation) => {
|
|
30
|
-
const currentKey = changeCase((options === null || options === void 0 ? void 0 : options.prefix) ? `${options === null || options === void 0 ? void 0 : options.prefix}_${annotation.fieldName}` : annotation.fieldName);
|
|
31
|
-
if (annotation.childType) {
|
|
32
|
-
return [
|
|
33
|
-
...getFields(annotation.childType(), {
|
|
34
|
-
prefix: currentKey,
|
|
35
|
-
case: options === null || options === void 0 ? void 0 : options.case,
|
|
36
|
-
})
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
return [currentKey];
|
|
40
|
-
});
|
|
41
|
-
return fields;
|
|
42
|
-
}
|
|
43
|
-
function getHeaders(T) {
|
|
44
|
-
return getFields(T);
|
|
45
|
-
}
|
|
46
|
-
exports.Excel = {
|
|
47
|
-
Text: createDecorator('text'),
|
|
48
|
-
Date: createDecorator('date'),
|
|
49
|
-
Number: createDecorator('number'),
|
|
50
|
-
// JSON: createDecorator('json'),
|
|
51
|
-
Array: createDecorator('array'),
|
|
52
|
-
Boolean: createDecorator('boolean'),
|
|
53
|
-
getAnnotations,
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=excel.decorators.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"excel.decorators.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/repo/excel/excel.decorators.ts"],"names":[],"mappings":";;;AAWA,gEAeC;AAED,8BAyBC;AAED,gCAEC;AAzDD,oEAAuE;AACvE,yCAAiD;AAEjD,MAAM,EACJ,eAAe,EACf,cAAc,GACf,GAAG,IAAA,yCAAsB,EACxB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,EACrG,6BAA6B,CAC9B,CAAC;AAEF,SAAgB,0BAA0B,CAAa,CAAM,EAAE,MAAM,GAAG,EAAE;IACxE,MAAM,WAAW,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;IACtC,OAAO,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE;QACpD,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,IAAA,qBAAS,EAAC,GAAG,MAAM,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC;QAClG,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;YACzB,uCACK,GAAG,GACH,0BAA0B,CAAC,UAAU,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC,EACjE;QACJ,CAAC;QACD,uCACK,GAAG,KACN,C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,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC;AAEY,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC;IAC7B,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC;IAC7B,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC;IACjC,iCAAiC;IACjC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC;IAC/B,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC;IACnC,cAAc;CACf,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import { ExcelConverter } from './excel.converter';
|
|
3
|
-
import type { ExcelService } from './excel.service.impl';
|
|
4
|
-
export declare const EXCEL_SERVICE: InjectionToken<ExcelService>;
|
|
5
|
-
export declare function injectExcelService<T>(): ExcelService;
|
|
6
|
-
export declare abstract class ExcelRepository<T> {
|
|
7
|
-
protected abstract path: string;
|
|
8
|
-
protected abstract sheetName: string;
|
|
9
|
-
protected abstract converter: ExcelConverter<T>;
|
|
10
|
-
protected service: ExcelService;
|
|
11
|
-
protected headers?: string[];
|
|
12
|
-
list(): Promise<T[]>;
|
|
13
|
-
saveMany(entities: T[]): Promise<void>;
|
|
14
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExcelRepository = exports.EXCEL_SERVICE = void 0;
|
|
4
|
-
exports.injectExcelService = injectExcelService;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const core_1 = require("@angular/core");
|
|
7
|
-
exports.EXCEL_SERVICE = new core_1.InjectionToken('[@nx-ddd/common] EXCEL REPOSITORY');
|
|
8
|
-
function injectExcelService() {
|
|
9
|
-
var _a;
|
|
10
|
-
return (_a = (0, core_1.inject)(exports.EXCEL_SERVICE, { optional: true })) !== null && _a !== void 0 ? _a : null;
|
|
11
|
-
}
|
|
12
|
-
class ExcelRepository {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.service = injectExcelService();
|
|
15
|
-
}
|
|
16
|
-
list() {
|
|
17
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const records = this.service.getRecords(this.path, this.sheetName);
|
|
19
|
-
return this.converter.fromExcelMany(records);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
saveMany(entities) {
|
|
23
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const records = entities.map(entity => this.converter.toExcel(entity));
|
|
25
|
-
this.service.loadWorkbook(this.path, (workbook) => {
|
|
26
|
-
return this.service.writeSheet(workbook, this.sheetName, records, this.headers);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.ExcelRepository = ExcelRepository;
|
|
32
|
-
//# sourceMappingURL=excel.repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"excel.repository.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/repo/excel/excel.repository.ts"],"names":[],"mappings":";;;AAKA,gDAEC;;AAPD,wCAAuD;AAI1C,QAAA,aAAa,GAAG,IAAI,qBAAc,CAAe,mCAAmC,CAAC,CAAC;AACnG,SAAgB,kBAAkB;;IAChC,OAAO,MAAA,IAAA,aAAM,EAAC,qBAAa,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,mCAAI,IAAoB,CAAC;AACzE,CAAC;AAED,MAAsB,eAAe;IAArC;QAIY,YAAO,GAAG,kBAAkB,EAAE,CAAC;IAc3C,CAAC;IAXO,IAAI;;YACR,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YACnE,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAgB,CAAC,CAAC;QACxD,CAAC;KAAA;IAEK,QAAQ,CAAC,QAAa;;YAC1B,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YACvE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAChD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAClF,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAlBD,0CAkBC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Provider } from '@angular/core';
|
|
2
|
-
import xlsx, { WorkBook } from 'xlsx';
|
|
3
|
-
export declare class ExcelService {
|
|
4
|
-
protected readWorkBook(path: string): xlsx.WorkBook;
|
|
5
|
-
protected loadSheet(path: string, name: string): xlsx.WorkSheet;
|
|
6
|
-
getRecords(path: string, sheetName: string): unknown[];
|
|
7
|
-
export(data: Record<string, any[]>, path: string, headers?: string[]): Promise<{
|
|
8
|
-
path: string;
|
|
9
|
-
name: string;
|
|
10
|
-
}>;
|
|
11
|
-
writeSheet<T>(workbook: WorkBook, sheetName: string, records: T[], headers?: string[]): WorkBook;
|
|
12
|
-
loadWorkbook(path: string, callback: (workbook: WorkBook) => WorkBook): {
|
|
13
|
-
path: string;
|
|
14
|
-
name: string;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export declare function provideExcelService(): Provider[];
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExcelService = void 0;
|
|
4
|
-
exports.provideExcelService = provideExcelService;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const excel_repository_1 = require("./excel.repository");
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const xlsx_1 = tslib_1.__importStar(require("xlsx"));
|
|
10
|
-
const fs_2 = tslib_1.__importDefault(require("fs"));
|
|
11
|
-
const set_fs = (xlsx_1.default === null || xlsx_1.default === void 0 ? void 0 : xlsx_1.default.set_fs) || require('xlsx').set_fs;
|
|
12
|
-
if (set_fs) {
|
|
13
|
-
set_fs(fs_2.default);
|
|
14
|
-
}
|
|
15
|
-
class ExcelService {
|
|
16
|
-
readWorkBook(path) {
|
|
17
|
-
return (0, xlsx_1.readFile)(path);
|
|
18
|
-
}
|
|
19
|
-
loadSheet(path, name) {
|
|
20
|
-
return this.readWorkBook(path).Sheets[name];
|
|
21
|
-
}
|
|
22
|
-
getRecords(path, sheetName) {
|
|
23
|
-
const sheet = this.loadSheet(path, sheetName);
|
|
24
|
-
return xlsx_1.utils.sheet_to_json(sheet);
|
|
25
|
-
}
|
|
26
|
-
export(data, path, headers) {
|
|
27
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
this.loadWorkbook(path, (workbook) => {
|
|
29
|
-
for (const [sheetName, sheetData] of Object.entries(data)) {
|
|
30
|
-
this.writeSheet(workbook, sheetName, sheetData, headers);
|
|
31
|
-
}
|
|
32
|
-
return workbook;
|
|
33
|
-
});
|
|
34
|
-
return { path, name: path.split('/').pop() };
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
writeSheet(workbook, sheetName, records, headers) {
|
|
38
|
-
const worksheet = xlsx_1.utils.json_to_sheet(records, { cellDates: true, header: headers });
|
|
39
|
-
if (!workbook.SheetNames.includes(sheetName)) {
|
|
40
|
-
workbook.SheetNames.push(sheetName);
|
|
41
|
-
}
|
|
42
|
-
workbook.Sheets[sheetName] = worksheet;
|
|
43
|
-
return workbook;
|
|
44
|
-
}
|
|
45
|
-
loadWorkbook(path, callback) {
|
|
46
|
-
const dir = (0, path_1.dirname)(path);
|
|
47
|
-
if (!(0, fs_1.existsSync)(dir))
|
|
48
|
-
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
49
|
-
const workbook = (0, fs_1.existsSync)(path) ? (0, xlsx_1.readFile)(path, { cellDates: true }) : { SheetNames: [], Sheets: {} };
|
|
50
|
-
const result = callback(workbook);
|
|
51
|
-
(0, xlsx_1.writeFile)(result, path);
|
|
52
|
-
return { path, name: path.split('/').pop() };
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.ExcelService = ExcelService;
|
|
56
|
-
function provideExcelService() {
|
|
57
|
-
return [
|
|
58
|
-
{ provide: excel_repository_1.EXCEL_SERVICE, useClass: ExcelService },
|
|
59
|
-
];
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=excel.service.impl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"excel.service.impl.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/repo/excel/excel.service.impl.ts"],"names":[],"mappings":";;;AA2DA,kDAIC;;AA9DD,yDAAmD;AACnD,2BAA2C;AAC3C,+BAA+B;AAC/B,qDAAkE;AAClE,oDAAoB;AAEpB,MAAM,MAAM,GAAG,CAAA,cAAI,aAAJ,cAAI,uBAAJ,cAAI,CAAE,MAAM,KAAI,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;AACtD,IAAI,MAAM,EAAE,CAAC;IACX,MAAM,CAAC,YAAE,CAAC,CAAC;AACb,CAAC;AAED,MAAa,YAAY;IACb,YAAY,CAAC,IAAY;QACjC,OAAO,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAES,SAAS,CAAC,IAAY,EAAE,IAAY;QAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,UAAU,CAAC,IAAY,EAAE,SAAiB;QACxC,MAAM,KAAK,GAAG,IAA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AAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,MAAM,QAAQ,GAAa,IAAA,eAAU,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,eAAQ,EAAC,IAAI,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QACjH,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAA,gBAAS,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACxB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;IAC/C,CAAC;CACF;AA7CD,oCA6CC;AAED,SAAgB,mBAAmB;IACjC,OAAO;QACL,EAAE,OAAO,EAAE,gCAAa,EAAE,QAAQ,EAAE,YAAY,EAAE;KACnD,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./excel.converter"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./excel.decorators"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./excel.repository"), exports);
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/@nx-ddd/common/src/infrastructure/repo/excel/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,6DAAmC;AACnC,6DAAmC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
interface RepositorySynchronizerConfig<T> {
|
|
4
|
-
listChangesAfter: (updatedAt: dayjs.Dayjs) => Observable<T[]>;
|
|
5
|
-
lastUpdatedAtChanges: () => Observable<dayjs.Dayjs>;
|
|
6
|
-
saveMany: (entities: T[]) => void;
|
|
7
|
-
srcCount: () => Observable<number>;
|
|
8
|
-
destCount: () => Observable<number>;
|
|
9
|
-
}
|
|
10
|
-
export declare class RepositorySynchronizer<T> {
|
|
11
|
-
private config;
|
|
12
|
-
constructor(config: RepositorySynchronizerConfig<T>);
|
|
13
|
-
readonly progress$: Observable<number>;
|
|
14
|
-
sync(): Observable<any[]>;
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RepositorySynchronizer = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
class RepositorySynchronizer {
|
|
6
|
-
constructor(config) {
|
|
7
|
-
this.config = config;
|
|
8
|
-
this.progress$ = (0, rxjs_1.combineLatest)({
|
|
9
|
-
srcCount: (0, rxjs_1.of)(null).pipe((0, rxjs_1.switchMap)(() => this.config.srcCount())),
|
|
10
|
-
destCount: (0, rxjs_1.of)(null).pipe((0, rxjs_1.switchMap)(() => this.config.destCount())),
|
|
11
|
-
}).pipe((0, rxjs_1.map)(({ srcCount, destCount }) => destCount / srcCount), (0, rxjs_1.shareReplay)(1));
|
|
12
|
-
}
|
|
13
|
-
sync() {
|
|
14
|
-
return this.config.lastUpdatedAtChanges().pipe((0, rxjs_1.switchMap)((lastUpdatedAt) => this.config.listChangesAfter(lastUpdatedAt).pipe((0, rxjs_1.retry)(3), (0, rxjs_1.tap)((updated) => this.config.saveMany(updated)), (0, rxjs_1.catchError)((error) => (console.error(error), rxjs_1.NEVER)))));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.RepositorySynchronizer = RepositorySynchronizer;
|
|
18
|
-
//# sourceMappingURL=synchronizer.js.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