@carlonicora/nestjs-neo4jsonapi 6.9.0 → 7.0.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/dist/common/decorators/cache-invalidate.decorator.d.ts +2 -1
- package/dist/common/decorators/cache-invalidate.decorator.d.ts.map +1 -1
- package/dist/common/decorators/cache-invalidate.decorator.js +23 -3
- package/dist/common/decorators/cache-invalidate.decorator.js.map +1 -1
- package/dist/common/decorators/validate-id.decorator.d.ts +4 -1
- package/dist/common/decorators/validate-id.decorator.d.ts.map +1 -1
- package/dist/common/decorators/validate-id.decorator.js +22 -2
- package/dist/common/decorators/validate-id.decorator.js.map +1 -1
- package/dist/foundations/foundations.modules.d.ts.map +1 -1
- package/dist/foundations/foundations.modules.js +2 -0
- package/dist/foundations/foundations.modules.js.map +1 -1
- package/dist/foundations/handbook/controllers/handbook.controller.d.ts +2 -1
- package/dist/foundations/handbook/controllers/handbook.controller.d.ts.map +1 -1
- package/dist/foundations/handbook/controllers/handbook.controller.js +5 -4
- package/dist/foundations/handbook/controllers/handbook.controller.js.map +1 -1
- package/dist/foundations/role/controllers/role.controller.d.ts +3 -2
- package/dist/foundations/role/controllers/role.controller.d.ts.map +1 -1
- package/dist/foundations/role/controllers/role.controller.js +9 -7
- package/dist/foundations/role/controllers/role.controller.js.map +1 -1
- package/dist/foundations/stripe/index.d.ts +1 -0
- package/dist/foundations/stripe/index.d.ts.map +1 -1
- package/dist/foundations/stripe/index.js +2 -0
- package/dist/foundations/stripe/index.js.map +1 -1
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon-code-checkout.controller.d.ts +14 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon-code-checkout.controller.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon-code-checkout.controller.js +62 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon-code-checkout.controller.js.map +1 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon-code.controller.d.ts +28 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon-code.controller.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon-code.controller.js +136 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon-code.controller.js.map +1 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon.controller.d.ts +26 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon.controller.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon.controller.js +131 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon.controller.js.map +1 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon.public.controller.d.ts +11 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon.public.controller.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon.public.controller.js +45 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon.public.controller.js.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.patch.dto.d.ts +13 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.patch.dto.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.patch.dto.js +55 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.patch.dto.js.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.post.dto.d.ts +24 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.post.dto.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.post.dto.js +105 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.post.dto.js.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.dto.d.ts +8 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.dto.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.dto.js +36 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.dto.js.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.patch.dto.d.ts +12 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.patch.dto.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.patch.dto.js +51 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.patch.dto.js.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.post.dto.d.ts +31 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.post.dto.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.post.dto.js +120 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon.post.dto.js.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-code.d.ts +28 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-code.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-code.js +35 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-code.js.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-code.meta.d.ts +5 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-code.meta.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-code.meta.js +12 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-code.meta.js.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-offer.d.ts +18 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-offer.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-offer.js +21 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-offer.js.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-offer.meta.d.ts +6 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-offer.meta.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-offer.meta.js +13 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon-offer.meta.js.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon.d.ts +32 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon.js +37 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon.js.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon.meta.d.ts +5 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon.meta.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon.meta.js +12 -0
- package/dist/foundations/stripe-coupon/entities/stripe-coupon.meta.js.map +1 -0
- package/dist/foundations/stripe-coupon/index.d.ts +21 -0
- package/dist/foundations/stripe-coupon/index.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/index.js +43 -0
- package/dist/foundations/stripe-coupon/index.js.map +1 -0
- package/dist/foundations/stripe-coupon/repositories/stripe-coupon-code.repository.d.ts +41 -0
- package/dist/foundations/stripe-coupon/repositories/stripe-coupon-code.repository.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/repositories/stripe-coupon-code.repository.js +97 -0
- package/dist/foundations/stripe-coupon/repositories/stripe-coupon-code.repository.js.map +1 -0
- package/dist/foundations/stripe-coupon/repositories/stripe-coupon.repository.d.ts +29 -0
- package/dist/foundations/stripe-coupon/repositories/stripe-coupon.repository.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/repositories/stripe-coupon.repository.js +55 -0
- package/dist/foundations/stripe-coupon/repositories/stripe-coupon.repository.js.map +1 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-api.service.d.ts +70 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-api.service.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-api.service.js +172 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-api.service.js.map +1 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-code-checkout.service.d.ts +81 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-code-checkout.service.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-code-checkout.service.js +206 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-code-checkout.service.js.map +1 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-code.service.d.ts +92 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-code.service.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-code.service.js +134 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-code.service.js.map +1 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-offer.service.d.ts +29 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-offer.service.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-offer.service.js +73 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon-offer.service.js.map +1 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon.service.d.ts +65 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon.service.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon.service.js +200 -0
- package/dist/foundations/stripe-coupon/services/stripe-coupon.service.js.map +1 -0
- package/dist/foundations/stripe-coupon/stripe-coupon.module.d.ts +14 -0
- package/dist/foundations/stripe-coupon/stripe-coupon.module.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/stripe-coupon.module.js +91 -0
- package/dist/foundations/stripe-coupon/stripe-coupon.module.js.map +1 -0
- package/dist/foundations/stripe-coupon/utils/places-left.d.ts +19 -0
- package/dist/foundations/stripe-coupon/utils/places-left.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/utils/places-left.js +33 -0
- package/dist/foundations/stripe-coupon/utils/places-left.js.map +1 -0
- package/dist/foundations/stripe-subscription/backfills/stripe-subscription-backfill.repository.d.ts +22 -0
- package/dist/foundations/stripe-subscription/backfills/stripe-subscription-backfill.repository.d.ts.map +1 -0
- package/dist/foundations/stripe-subscription/backfills/stripe-subscription-backfill.repository.js +48 -0
- package/dist/foundations/stripe-subscription/backfills/stripe-subscription-backfill.repository.js.map +1 -0
- package/dist/foundations/stripe-subscription/backfills/stripe-subscription-discount-backfill.service.d.ts +51 -0
- package/dist/foundations/stripe-subscription/backfills/stripe-subscription-discount-backfill.service.d.ts.map +1 -0
- package/dist/foundations/stripe-subscription/backfills/stripe-subscription-discount-backfill.service.js +129 -0
- package/dist/foundations/stripe-subscription/backfills/stripe-subscription-discount-backfill.service.js.map +1 -0
- package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.d.ts +7 -1
- package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.js +18 -5
- package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.js.map +1 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.discount.d.ts +30 -0
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.discount.d.ts.map +1 -0
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.discount.js +57 -0
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.discount.js.map +1 -0
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.entity.d.ts +7 -0
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.entity.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.map.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.map.js +6 -0
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.map.js.map +1 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.meta.d.ts +8 -0
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.meta.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.meta.js +9 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.meta.js.map +1 -1
- package/dist/foundations/stripe-subscription/index.d.ts +3 -2
- package/dist/foundations/stripe-subscription/index.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/index.js +5 -1
- package/dist/foundations/stripe-subscription/index.js.map +1 -1
- package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.d.ts +14 -0
- package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.js +32 -0
- package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.js.map +1 -1
- package/dist/foundations/stripe-subscription/serialisers/stripe-subscription.serialiser.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/serialisers/stripe-subscription.serialiser.js +6 -0
- package/dist/foundations/stripe-subscription/serialisers/stripe-subscription.serialiser.js.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.d.ts +34 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.js +165 -29
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.js.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.d.ts +7 -0
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.js +29 -2
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.js.map +1 -1
- package/dist/foundations/stripe-subscription/services/subscription-payment-confirmation.d.ts +27 -0
- package/dist/foundations/stripe-subscription/services/subscription-payment-confirmation.d.ts.map +1 -0
- package/dist/foundations/stripe-subscription/services/subscription-payment-confirmation.js +62 -0
- package/dist/foundations/stripe-subscription/services/subscription-payment-confirmation.js.map +1 -0
- package/dist/foundations/stripe-subscription/stripe-subscription.module.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/stripe-subscription.module.js +10 -0
- package/dist/foundations/stripe-subscription/stripe-subscription.module.js.map +1 -1
- package/dist/foundations/stripe-webhook/processors/stripe-webhook.processor.d.ts.map +1 -1
- package/dist/foundations/stripe-webhook/processors/stripe-webhook.processor.js +16 -1
- package/dist/foundations/stripe-webhook/processors/stripe-webhook.processor.js.map +1 -1
- package/dist/foundations/two-factor/controllers/passkey.controller.d.ts +1 -1
- package/dist/foundations/two-factor/controllers/passkey.controller.d.ts.map +1 -1
- package/dist/foundations/two-factor/controllers/passkey.controller.js +6 -5
- package/dist/foundations/two-factor/controllers/passkey.controller.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
// Module
|
|
18
|
+
__exportStar(require("./stripe-coupon.module"), exports);
|
|
19
|
+
// Entities + metas
|
|
20
|
+
__exportStar(require("./entities/stripe-coupon"), exports);
|
|
21
|
+
__exportStar(require("./entities/stripe-coupon.meta"), exports);
|
|
22
|
+
__exportStar(require("./entities/stripe-coupon-code"), exports);
|
|
23
|
+
__exportStar(require("./entities/stripe-coupon-code.meta"), exports);
|
|
24
|
+
__exportStar(require("./entities/stripe-coupon-offer"), exports);
|
|
25
|
+
__exportStar(require("./entities/stripe-coupon-offer.meta"), exports);
|
|
26
|
+
// DTOs
|
|
27
|
+
__exportStar(require("./dtos/stripe-coupon.dto"), exports);
|
|
28
|
+
__exportStar(require("./dtos/stripe-coupon.post.dto"), exports);
|
|
29
|
+
__exportStar(require("./dtos/stripe-coupon.patch.dto"), exports);
|
|
30
|
+
__exportStar(require("./dtos/stripe-coupon-code.post.dto"), exports);
|
|
31
|
+
__exportStar(require("./dtos/stripe-coupon-code.patch.dto"), exports);
|
|
32
|
+
// Repositories
|
|
33
|
+
__exportStar(require("./repositories/stripe-coupon.repository"), exports);
|
|
34
|
+
__exportStar(require("./repositories/stripe-coupon-code.repository"), exports);
|
|
35
|
+
// Services
|
|
36
|
+
__exportStar(require("./services/stripe-coupon-api.service"), exports);
|
|
37
|
+
__exportStar(require("./services/stripe-coupon.service"), exports);
|
|
38
|
+
__exportStar(require("./services/stripe-coupon-code.service"), exports);
|
|
39
|
+
__exportStar(require("./services/stripe-coupon-code-checkout.service"), exports);
|
|
40
|
+
__exportStar(require("./services/stripe-coupon-offer.service"), exports);
|
|
41
|
+
// Utils
|
|
42
|
+
__exportStar(require("./utils/places-left"), exports);
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/foundations/stripe-coupon/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS;AACT,yDAAuC;AAEvC,mBAAmB;AACnB,2DAAyC;AACzC,gEAA8C;AAC9C,gEAA8C;AAC9C,qEAAmD;AACnD,iEAA+C;AAC/C,sEAAoD;AAEpD,OAAO;AACP,2DAAyC;AACzC,gEAA8C;AAC9C,iEAA+C;AAC/C,qEAAmD;AACnD,sEAAoD;AAEpD,eAAe;AACf,0EAAwD;AACxD,+EAA6D;AAE7D,WAAW;AACX,uEAAqD;AACrD,mEAAiD;AACjD,wEAAsD;AACtD,iFAA+D;AAC/D,yEAAuD;AAEvD,QAAQ;AACR,sDAAoC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ClsService } from "nestjs-cls";
|
|
2
|
+
import { AbstractRepository } from "../../../core/neo4j/abstracts/abstract.repository";
|
|
3
|
+
import { Neo4jService } from "../../../core/neo4j/services/neo4j.service";
|
|
4
|
+
import { SecurityService } from "../../../core/security/services/security.service";
|
|
5
|
+
import { StripeCouponCode, StripeCouponCodeDescriptor } from "../entities/stripe-coupon-code";
|
|
6
|
+
export declare class StripeCouponCodeRepository extends AbstractRepository<StripeCouponCode, typeof StripeCouponCodeDescriptor.relationships> {
|
|
7
|
+
protected readonly descriptor: import("../../..").EntityDescriptor<StripeCouponCode, {
|
|
8
|
+
coupon: {
|
|
9
|
+
model: import("../../..").DataMeta;
|
|
10
|
+
direction: "in";
|
|
11
|
+
relationship: string;
|
|
12
|
+
cardinality: "one";
|
|
13
|
+
required: true;
|
|
14
|
+
dtoKey: string;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
constructor(neo4j: Neo4jService, securityService: SecurityService, clsService: ClsService);
|
|
18
|
+
/**
|
|
19
|
+
* The code with its coupon.
|
|
20
|
+
*/
|
|
21
|
+
protected buildReturnStatement(): string;
|
|
22
|
+
/**
|
|
23
|
+
* The active code marked "Apply automatically", with its coupon. At most one exists.
|
|
24
|
+
*/
|
|
25
|
+
findAutomatic(): Promise<StripeCouponCode | null>;
|
|
26
|
+
/**
|
|
27
|
+
* The code mirrored from a Stripe promotion code id.
|
|
28
|
+
*/
|
|
29
|
+
findByStripePromotionCodeId(params: {
|
|
30
|
+
stripePromotionCodeId: string;
|
|
31
|
+
}): Promise<StripeCouponCode | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Switches "Apply automatically" on one code in a single write. Turning it on clears it
|
|
34
|
+
* on every other code first, so two codes never have it; turning it off only clears the target.
|
|
35
|
+
*/
|
|
36
|
+
setAutomatic(params: {
|
|
37
|
+
id: string;
|
|
38
|
+
automatic: boolean;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=stripe-coupon-code.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon-code.repository.d.ts","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/repositories/stripe-coupon-code.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAI9F,qBACa,0BAA2B,SAAQ,kBAAkB,CAChE,gBAAgB,EAChB,OAAO,0BAA0B,CAAC,aAAa,CAChD;IACC,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;OAA8B;gBAE/C,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU;IAIzF;;OAEG;IACH,SAAS,CAAC,oBAAoB,IAAI,MAAM;IAUxC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAgBvD;;OAEG;IACG,2BAA2B,CAAC,MAAM,EAAE;QAAE,qBAAqB,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAa9G;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAwB9E"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.StripeCouponCodeRepository = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
15
|
+
const abstract_repository_1 = require("../../../core/neo4j/abstracts/abstract.repository");
|
|
16
|
+
const neo4j_service_1 = require("../../../core/neo4j/services/neo4j.service");
|
|
17
|
+
const security_service_1 = require("../../../core/security/services/security.service");
|
|
18
|
+
const stripe_coupon_code_1 = require("../entities/stripe-coupon-code");
|
|
19
|
+
const stripe_coupon_code_meta_1 = require("../entities/stripe-coupon-code.meta");
|
|
20
|
+
const stripe_coupon_meta_1 = require("../entities/stripe-coupon.meta");
|
|
21
|
+
let StripeCouponCodeRepository = class StripeCouponCodeRepository extends abstract_repository_1.AbstractRepository {
|
|
22
|
+
constructor(neo4j, securityService, clsService) {
|
|
23
|
+
super(neo4j, securityService, clsService);
|
|
24
|
+
this.descriptor = stripe_coupon_code_1.StripeCouponCodeDescriptor;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The code with its coupon.
|
|
28
|
+
*/
|
|
29
|
+
buildReturnStatement() {
|
|
30
|
+
const { nodeName } = stripe_coupon_code_meta_1.stripeCouponCodeMeta;
|
|
31
|
+
return `
|
|
32
|
+
MATCH (${nodeName})<-[:HAS_CODE]-(${nodeName}_coupon:${stripe_coupon_meta_1.stripeCouponMeta.labelName})
|
|
33
|
+
RETURN ${nodeName},
|
|
34
|
+
${nodeName}_coupon
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The active code marked "Apply automatically", with its coupon. At most one exists.
|
|
39
|
+
*/
|
|
40
|
+
async findAutomatic() {
|
|
41
|
+
const { nodeName } = stripe_coupon_code_meta_1.stripeCouponCodeMeta;
|
|
42
|
+
const query = this.neo4j.initQuery({ serialiser: stripe_coupon_code_1.StripeCouponCodeDescriptor.model });
|
|
43
|
+
query.query += `
|
|
44
|
+
${this.buildDefaultMatch()}
|
|
45
|
+
WHERE ${nodeName}.automatic = true AND ${nodeName}.active = true
|
|
46
|
+
WITH ${nodeName}
|
|
47
|
+
ORDER BY ${nodeName}.updatedAt DESC
|
|
48
|
+
LIMIT 1
|
|
49
|
+
${this.buildReturnStatement()}
|
|
50
|
+
`;
|
|
51
|
+
return this.neo4j.readOne(query);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The code mirrored from a Stripe promotion code id.
|
|
55
|
+
*/
|
|
56
|
+
async findByStripePromotionCodeId(params) {
|
|
57
|
+
const query = this.neo4j.initQuery({ serialiser: stripe_coupon_code_1.StripeCouponCodeDescriptor.model });
|
|
58
|
+
query.queryParams = { ...query.queryParams, searchValue: params.stripePromotionCodeId };
|
|
59
|
+
query.query += `
|
|
60
|
+
${this.buildDefaultMatch({ searchField: "stripePromotionCodeId" })}
|
|
61
|
+
${this.buildReturnStatement()}
|
|
62
|
+
`;
|
|
63
|
+
return this.neo4j.readOne(query);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Switches "Apply automatically" on one code in a single write. Turning it on clears it
|
|
67
|
+
* on every other code first, so two codes never have it; turning it off only clears the target.
|
|
68
|
+
*/
|
|
69
|
+
async setAutomatic(params) {
|
|
70
|
+
const { nodeName, labelName } = stripe_coupon_code_meta_1.stripeCouponCodeMeta;
|
|
71
|
+
const query = this.neo4j.initQuery({ serialiser: stripe_coupon_code_1.StripeCouponCodeDescriptor.model });
|
|
72
|
+
query.queryParams = { ...query.queryParams, searchValue: params.id };
|
|
73
|
+
if (!params.automatic) {
|
|
74
|
+
query.query += `
|
|
75
|
+
${this.buildDefaultMatch({ searchField: "id" })}
|
|
76
|
+
SET ${nodeName}.automatic = false, ${nodeName}.updatedAt = datetime()
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
query.query += `
|
|
81
|
+
${this.buildDefaultMatch({ searchField: "id" })}
|
|
82
|
+
OPTIONAL MATCH (${nodeName}_other:${labelName})
|
|
83
|
+
WHERE ${nodeName}_other.id <> $searchValue AND ${nodeName}_other.automatic = true
|
|
84
|
+
SET ${nodeName}_other.automatic = false, ${nodeName}_other.updatedAt = datetime()
|
|
85
|
+
WITH DISTINCT ${nodeName}
|
|
86
|
+
SET ${nodeName}.automatic = true, ${nodeName}.updatedAt = datetime()
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
await this.neo4j.writeOne(query);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.StripeCouponCodeRepository = StripeCouponCodeRepository;
|
|
93
|
+
exports.StripeCouponCodeRepository = StripeCouponCodeRepository = __decorate([
|
|
94
|
+
(0, common_1.Injectable)(),
|
|
95
|
+
__metadata("design:paramtypes", [neo4j_service_1.Neo4jService, security_service_1.SecurityService, nestjs_cls_1.ClsService])
|
|
96
|
+
], StripeCouponCodeRepository);
|
|
97
|
+
//# sourceMappingURL=stripe-coupon-code.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon-code.repository.js","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/repositories/stripe-coupon-code.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5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AsFtC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ClsService } from "nestjs-cls";
|
|
2
|
+
import { AbstractRepository } from "../../../core/neo4j/abstracts/abstract.repository";
|
|
3
|
+
import { Neo4jService } from "../../../core/neo4j/services/neo4j.service";
|
|
4
|
+
import { SecurityService } from "../../../core/security/services/security.service";
|
|
5
|
+
import { StripeCoupon, StripeCouponDescriptor } from "../entities/stripe-coupon";
|
|
6
|
+
export declare class StripeCouponRepository extends AbstractRepository<StripeCoupon, typeof StripeCouponDescriptor.relationships> {
|
|
7
|
+
protected readonly descriptor: import("../../..").EntityDescriptor<StripeCoupon, {
|
|
8
|
+
codes: {
|
|
9
|
+
model: import("../../..").DataMeta;
|
|
10
|
+
direction: "out";
|
|
11
|
+
relationship: string;
|
|
12
|
+
cardinality: "many";
|
|
13
|
+
required: false;
|
|
14
|
+
dtoKey: string;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
constructor(neo4j: Neo4jService, securityService: SecurityService, clsService: ClsService);
|
|
18
|
+
/**
|
|
19
|
+
* The coupon with its codes.
|
|
20
|
+
*/
|
|
21
|
+
protected buildReturnStatement(): string;
|
|
22
|
+
/**
|
|
23
|
+
* The coupon mirrored from a Stripe coupon id.
|
|
24
|
+
*/
|
|
25
|
+
findByStripeCouponId(params: {
|
|
26
|
+
stripeCouponId: string;
|
|
27
|
+
}): Promise<StripeCoupon | null>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=stripe-coupon.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon.repository.d.ts","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/repositories/stripe-coupon.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAIjF,qBACa,sBAAuB,SAAQ,kBAAkB,CAC5D,YAAY,EACZ,OAAO,sBAAsB,CAAC,aAAa,CAC5C;IACC,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;OAA0B;gBAE3C,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU;IAIzF;;OAEG;IACH,SAAS,CAAC,oBAAoB,IAAI,MAAM;IAUxC;;OAEG;IACG,oBAAoB,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CAY7F"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.StripeCouponRepository = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
15
|
+
const abstract_repository_1 = require("../../../core/neo4j/abstracts/abstract.repository");
|
|
16
|
+
const neo4j_service_1 = require("../../../core/neo4j/services/neo4j.service");
|
|
17
|
+
const security_service_1 = require("../../../core/security/services/security.service");
|
|
18
|
+
const stripe_coupon_1 = require("../entities/stripe-coupon");
|
|
19
|
+
const stripe_coupon_code_meta_1 = require("../entities/stripe-coupon-code.meta");
|
|
20
|
+
const stripe_coupon_meta_1 = require("../entities/stripe-coupon.meta");
|
|
21
|
+
let StripeCouponRepository = class StripeCouponRepository extends abstract_repository_1.AbstractRepository {
|
|
22
|
+
constructor(neo4j, securityService, clsService) {
|
|
23
|
+
super(neo4j, securityService, clsService);
|
|
24
|
+
this.descriptor = stripe_coupon_1.StripeCouponDescriptor;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The coupon with its codes.
|
|
28
|
+
*/
|
|
29
|
+
buildReturnStatement() {
|
|
30
|
+
const { nodeName } = stripe_coupon_meta_1.stripeCouponMeta;
|
|
31
|
+
return `
|
|
32
|
+
OPTIONAL MATCH (${nodeName})-[:HAS_CODE]->(${nodeName}_codes:${stripe_coupon_code_meta_1.stripeCouponCodeMeta.labelName})
|
|
33
|
+
RETURN ${nodeName},
|
|
34
|
+
${nodeName}_codes
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The coupon mirrored from a Stripe coupon id.
|
|
39
|
+
*/
|
|
40
|
+
async findByStripeCouponId(params) {
|
|
41
|
+
const query = this.neo4j.initQuery({ serialiser: stripe_coupon_1.StripeCouponDescriptor.model });
|
|
42
|
+
query.queryParams = { ...query.queryParams, searchValue: params.stripeCouponId };
|
|
43
|
+
query.query += `
|
|
44
|
+
${this.buildDefaultMatch({ searchField: "stripeCouponId" })}
|
|
45
|
+
${this.buildReturnStatement()}
|
|
46
|
+
`;
|
|
47
|
+
return this.neo4j.readOne(query);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.StripeCouponRepository = StripeCouponRepository;
|
|
51
|
+
exports.StripeCouponRepository = StripeCouponRepository = __decorate([
|
|
52
|
+
(0, common_1.Injectable)(),
|
|
53
|
+
__metadata("design:paramtypes", [neo4j_service_1.Neo4jService, security_service_1.SecurityService, nestjs_cls_1.ClsService])
|
|
54
|
+
], StripeCouponRepository);
|
|
55
|
+
//# sourceMappingURL=stripe-coupon.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon.repository.js","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/repositories/stripe-coupon.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAAwC;AACxC,2FAAuF;AACvF,8EAA0E;AAC1E,uFAAmF;AACnF,6DAAiF;AACjF,iFAA2E;AAC3E,uEAAkE;AAG3D,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,wCAG3C;IAGC,YAAY,KAAmB,EAAE,eAAgC,EAAE,UAAsB;QACvF,KAAK,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QAHzB,eAAU,GAAG,sCAAsB,CAAC;IAIvD,CAAC;IAED;;OAEG;IACO,oBAAoB;QAC5B,MAAM,EAAE,QAAQ,EAAE,GAAG,qCAAgB,CAAC;QAEtC,OAAO;wBACa,QAAQ,mBAAmB,QAAQ,UAAU,8CAAoB,CAAC,SAAS;eACpF,QAAQ;UACb,QAAQ;KACb,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB,CAAC,MAAkC;QAC3D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,sCAAsB,CAAC,KAAK,EAAE,CAAC,CAAC;QAEjF,KAAK,CAAC,WAAW,GAAG,EAAE,GAAG,KAAK,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC;QAEjF,KAAK,CAAC,KAAK,IAAI;QACX,IAAI,CAAC,iBAAiB,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;QACzD,IAAI,CAAC,oBAAoB,EAAE;KAC9B,CAAC;QAEF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACF,CAAA;AAtCY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAOQ,4BAAY,EAAmB,kCAAe,EAAc,uBAAU;GAN9E,sBAAsB,CAsClC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import Stripe from "stripe";
|
|
2
|
+
import { StripeService } from "../../stripe/services/stripe.service";
|
|
3
|
+
import type { StripeCouponDurationType } from "../entities/stripe-coupon";
|
|
4
|
+
/**
|
|
5
|
+
* Stripe Coupon API Service
|
|
6
|
+
*
|
|
7
|
+
* Thin wrapper over the Stripe SDK for coupons and their customer-facing promotion codes.
|
|
8
|
+
* Stripe only allows a coupon's name (and metadata) to change after creation, and a
|
|
9
|
+
* promotion code's `active` flag, so there is no general update method.
|
|
10
|
+
*/
|
|
11
|
+
export declare class StripeCouponApiService {
|
|
12
|
+
private readonly stripeService;
|
|
13
|
+
constructor(stripeService: StripeService);
|
|
14
|
+
/**
|
|
15
|
+
* Create a coupon. `percentOff` makes a percentage coupon; otherwise `amountOff` + `currency`
|
|
16
|
+
* make a fixed-amount one.
|
|
17
|
+
*/
|
|
18
|
+
createCoupon(params: {
|
|
19
|
+
id?: string;
|
|
20
|
+
name: string;
|
|
21
|
+
percentOff?: number;
|
|
22
|
+
amountOff?: number;
|
|
23
|
+
currency?: string;
|
|
24
|
+
duration: StripeCouponDurationType;
|
|
25
|
+
durationInMonths?: number;
|
|
26
|
+
stripeProductIds?: string[];
|
|
27
|
+
redeemBy?: Date;
|
|
28
|
+
maxRedemptions?: number;
|
|
29
|
+
}): Promise<Stripe.Coupon>;
|
|
30
|
+
/**
|
|
31
|
+
* Rename a coupon (the name is shown to customers on invoices).
|
|
32
|
+
*/
|
|
33
|
+
renameCoupon(params: {
|
|
34
|
+
stripeCouponId: string;
|
|
35
|
+
name: string;
|
|
36
|
+
}): Promise<Stripe.Coupon>;
|
|
37
|
+
/**
|
|
38
|
+
* Delete a coupon. Used to roll back a coupon whose first code could not be created.
|
|
39
|
+
*/
|
|
40
|
+
deleteCoupon(stripeCouponId: string): Promise<void>;
|
|
41
|
+
retrieveCoupon(stripeCouponId: string): Promise<Stripe.Coupon>;
|
|
42
|
+
/**
|
|
43
|
+
* Create a customer-facing promotion code on a coupon. With this API version the coupon
|
|
44
|
+
* goes under `promotion` (`{ type: "coupon", coupon }`), not on the code itself.
|
|
45
|
+
* Stripe generates the code text when `code` is empty.
|
|
46
|
+
*/
|
|
47
|
+
createPromotionCode(params: {
|
|
48
|
+
stripeCouponId: string;
|
|
49
|
+
code?: string;
|
|
50
|
+
firstTimeTransaction?: boolean;
|
|
51
|
+
minimumAmount?: number;
|
|
52
|
+
minimumAmountCurrency?: string;
|
|
53
|
+
stripeCustomerId?: string;
|
|
54
|
+
expiresAt?: Date;
|
|
55
|
+
maxRedemptions?: number;
|
|
56
|
+
}): Promise<Stripe.PromotionCode>;
|
|
57
|
+
/**
|
|
58
|
+
* Deactivate or reactivate a promotion code. An expired or used-up code stays unusable.
|
|
59
|
+
*/
|
|
60
|
+
setPromotionCodeActive(params: {
|
|
61
|
+
stripePromotionCodeId: string;
|
|
62
|
+
active: boolean;
|
|
63
|
+
}): Promise<Stripe.PromotionCode>;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieve a promotion code with its coupon expanded. The coupon hangs off `promotion`,
|
|
66
|
+
* so the expansion is `promotion.coupon` (expanding `coupon` is silently ignored).
|
|
67
|
+
*/
|
|
68
|
+
retrievePromotionCode(stripePromotionCodeId: string): Promise<Stripe.PromotionCode>;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=stripe-coupon-api.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon-api.service.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AC,EAAE,OAAO,CAAC;QAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,SAAS,CAAC,EAAE,IAAI,CAAC;QACjB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;IAyBjC;;OAEG;IAEG,sBAAsB,CAAC,MAAM,EAAE;QACnC,qBAAqB,EAAE,MAAM,CAAC;QAC9B,MAAM,EAAE,OAAO,CAAC;KACjB,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;IAKjC;;;OAGG;IAEG,qBAAqB,CAAC,qBAAqB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;CAI1F"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.StripeCouponApiService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const stripe_errors_1 = require("../../stripe/errors/stripe.errors");
|
|
15
|
+
const stripe_service_1 = require("../../stripe/services/stripe.service");
|
|
16
|
+
const toUnixSeconds = (date) => Math.floor(date.getTime() / 1000);
|
|
17
|
+
/**
|
|
18
|
+
* Stripe Coupon API Service
|
|
19
|
+
*
|
|
20
|
+
* Thin wrapper over the Stripe SDK for coupons and their customer-facing promotion codes.
|
|
21
|
+
* Stripe only allows a coupon's name (and metadata) to change after creation, and a
|
|
22
|
+
* promotion code's `active` flag, so there is no general update method.
|
|
23
|
+
*/
|
|
24
|
+
let StripeCouponApiService = class StripeCouponApiService {
|
|
25
|
+
constructor(stripeService) {
|
|
26
|
+
this.stripeService = stripeService;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a coupon. `percentOff` makes a percentage coupon; otherwise `amountOff` + `currency`
|
|
30
|
+
* make a fixed-amount one.
|
|
31
|
+
*/
|
|
32
|
+
async createCoupon(params) {
|
|
33
|
+
const stripe = this.stripeService.getClient();
|
|
34
|
+
const couponParams = {
|
|
35
|
+
name: params.name,
|
|
36
|
+
duration: params.duration,
|
|
37
|
+
};
|
|
38
|
+
if (params.id)
|
|
39
|
+
couponParams.id = params.id;
|
|
40
|
+
if (params.percentOff !== undefined && params.percentOff !== null) {
|
|
41
|
+
couponParams.percent_off = params.percentOff;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
couponParams.amount_off = params.amountOff;
|
|
45
|
+
couponParams.currency = params.currency;
|
|
46
|
+
}
|
|
47
|
+
if (params.duration === "repeating" && params.durationInMonths !== undefined) {
|
|
48
|
+
couponParams.duration_in_months = params.durationInMonths;
|
|
49
|
+
}
|
|
50
|
+
if (params.maxRedemptions !== undefined && params.maxRedemptions !== null) {
|
|
51
|
+
couponParams.max_redemptions = params.maxRedemptions;
|
|
52
|
+
}
|
|
53
|
+
if (params.stripeProductIds?.length) {
|
|
54
|
+
couponParams.applies_to = { products: params.stripeProductIds };
|
|
55
|
+
}
|
|
56
|
+
if (params.redeemBy)
|
|
57
|
+
couponParams.redeem_by = toUnixSeconds(params.redeemBy);
|
|
58
|
+
return stripe.coupons.create(couponParams);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Rename a coupon (the name is shown to customers on invoices).
|
|
62
|
+
*/
|
|
63
|
+
async renameCoupon(params) {
|
|
64
|
+
const stripe = this.stripeService.getClient();
|
|
65
|
+
return stripe.coupons.update(params.stripeCouponId, { name: params.name });
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Delete a coupon. Used to roll back a coupon whose first code could not be created.
|
|
69
|
+
*/
|
|
70
|
+
async deleteCoupon(stripeCouponId) {
|
|
71
|
+
const stripe = this.stripeService.getClient();
|
|
72
|
+
await stripe.coupons.del(stripeCouponId);
|
|
73
|
+
}
|
|
74
|
+
async retrieveCoupon(stripeCouponId) {
|
|
75
|
+
const stripe = this.stripeService.getClient();
|
|
76
|
+
return stripe.coupons.retrieve(stripeCouponId);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create a customer-facing promotion code on a coupon. With this API version the coupon
|
|
80
|
+
* goes under `promotion` (`{ type: "coupon", coupon }`), not on the code itself.
|
|
81
|
+
* Stripe generates the code text when `code` is empty.
|
|
82
|
+
*/
|
|
83
|
+
async createPromotionCode(params) {
|
|
84
|
+
const stripe = this.stripeService.getClient();
|
|
85
|
+
const codeParams = {
|
|
86
|
+
promotion: { type: "coupon", coupon: params.stripeCouponId },
|
|
87
|
+
};
|
|
88
|
+
if (params.code)
|
|
89
|
+
codeParams.code = params.code;
|
|
90
|
+
if (params.stripeCustomerId)
|
|
91
|
+
codeParams.customer = params.stripeCustomerId;
|
|
92
|
+
if (params.expiresAt)
|
|
93
|
+
codeParams.expires_at = toUnixSeconds(params.expiresAt);
|
|
94
|
+
if (params.maxRedemptions !== undefined && params.maxRedemptions !== null) {
|
|
95
|
+
codeParams.max_redemptions = params.maxRedemptions;
|
|
96
|
+
}
|
|
97
|
+
const restrictions = {};
|
|
98
|
+
if (params.firstTimeTransaction !== undefined)
|
|
99
|
+
restrictions.first_time_transaction = params.firstTimeTransaction;
|
|
100
|
+
if (params.minimumAmount !== undefined && params.minimumAmount !== null) {
|
|
101
|
+
restrictions.minimum_amount = params.minimumAmount;
|
|
102
|
+
if (params.minimumAmountCurrency)
|
|
103
|
+
restrictions.minimum_amount_currency = params.minimumAmountCurrency;
|
|
104
|
+
}
|
|
105
|
+
if (Object.keys(restrictions).length > 0)
|
|
106
|
+
codeParams.restrictions = restrictions;
|
|
107
|
+
return stripe.promotionCodes.create(codeParams);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Deactivate or reactivate a promotion code. An expired or used-up code stays unusable.
|
|
111
|
+
*/
|
|
112
|
+
async setPromotionCodeActive(params) {
|
|
113
|
+
const stripe = this.stripeService.getClient();
|
|
114
|
+
return stripe.promotionCodes.update(params.stripePromotionCodeId, { active: params.active });
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Retrieve a promotion code with its coupon expanded. The coupon hangs off `promotion`,
|
|
118
|
+
* so the expansion is `promotion.coupon` (expanding `coupon` is silently ignored).
|
|
119
|
+
*/
|
|
120
|
+
async retrievePromotionCode(stripePromotionCodeId) {
|
|
121
|
+
const stripe = this.stripeService.getClient();
|
|
122
|
+
return stripe.promotionCodes.retrieve(stripePromotionCodeId, { expand: ["promotion.coupon"] });
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
exports.StripeCouponApiService = StripeCouponApiService;
|
|
126
|
+
__decorate([
|
|
127
|
+
(0, stripe_errors_1.HandleStripeErrors)(),
|
|
128
|
+
__metadata("design:type", Function),
|
|
129
|
+
__metadata("design:paramtypes", [Object]),
|
|
130
|
+
__metadata("design:returntype", Promise)
|
|
131
|
+
], StripeCouponApiService.prototype, "createCoupon", null);
|
|
132
|
+
__decorate([
|
|
133
|
+
(0, stripe_errors_1.HandleStripeErrors)(),
|
|
134
|
+
__metadata("design:type", Function),
|
|
135
|
+
__metadata("design:paramtypes", [Object]),
|
|
136
|
+
__metadata("design:returntype", Promise)
|
|
137
|
+
], StripeCouponApiService.prototype, "renameCoupon", null);
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, stripe_errors_1.HandleStripeErrors)(),
|
|
140
|
+
__metadata("design:type", Function),
|
|
141
|
+
__metadata("design:paramtypes", [String]),
|
|
142
|
+
__metadata("design:returntype", Promise)
|
|
143
|
+
], StripeCouponApiService.prototype, "deleteCoupon", null);
|
|
144
|
+
__decorate([
|
|
145
|
+
(0, stripe_errors_1.HandleStripeErrors)(),
|
|
146
|
+
__metadata("design:type", Function),
|
|
147
|
+
__metadata("design:paramtypes", [String]),
|
|
148
|
+
__metadata("design:returntype", Promise)
|
|
149
|
+
], StripeCouponApiService.prototype, "retrieveCoupon", null);
|
|
150
|
+
__decorate([
|
|
151
|
+
(0, stripe_errors_1.HandleStripeErrors)(),
|
|
152
|
+
__metadata("design:type", Function),
|
|
153
|
+
__metadata("design:paramtypes", [Object]),
|
|
154
|
+
__metadata("design:returntype", Promise)
|
|
155
|
+
], StripeCouponApiService.prototype, "createPromotionCode", null);
|
|
156
|
+
__decorate([
|
|
157
|
+
(0, stripe_errors_1.HandleStripeErrors)(),
|
|
158
|
+
__metadata("design:type", Function),
|
|
159
|
+
__metadata("design:paramtypes", [Object]),
|
|
160
|
+
__metadata("design:returntype", Promise)
|
|
161
|
+
], StripeCouponApiService.prototype, "setPromotionCodeActive", null);
|
|
162
|
+
__decorate([
|
|
163
|
+
(0, stripe_errors_1.HandleStripeErrors)(),
|
|
164
|
+
__metadata("design:type", Function),
|
|
165
|
+
__metadata("design:paramtypes", [String]),
|
|
166
|
+
__metadata("design:returntype", Promise)
|
|
167
|
+
], StripeCouponApiService.prototype, "retrievePromotionCode", null);
|
|
168
|
+
exports.StripeCouponApiService = StripeCouponApiService = __decorate([
|
|
169
|
+
(0, common_1.Injectable)(),
|
|
170
|
+
__metadata("design:paramtypes", [stripe_service_1.StripeService])
|
|
171
|
+
], StripeCouponApiService);
|
|
172
|
+
//# sourceMappingURL=stripe-coupon-api.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon-api.service.js","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/services/stripe-coupon-api.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAE5C,qEAAuE;AACvE,yEAAqE;AAGrE,MAAM,aAAa,GAAG,CAAC,IAAU,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;AAEhF;;;;;;GAMG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D;;;OAGG;IAEG,AAAN,KAAK,CAAC,YAAY,CAAC,MAWlB;QACC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;QAE9C,MAAM,YAAY,GAA8B;YAC9C,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC;QAEF,IAAI,MAAM,CAAC,EAAE;YAAE,YAAY,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;QAE3C,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;YAClE,YAAY,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC;YAC3C,YAAY,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC1C,CAAC;QAED,IAAI,MAAM,CAAC,QAAQ,KAAK,WAAW,IAAI,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;YAC7E,YAAY,CAAC,kBAAkB,GAAG,MAAM,CAAC,gB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AK,CAAC,sBAAsB,CAAC,MAG5B;QACC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;QAC9C,OAAO,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED;;;OAGG;IAEG,AAAN,KAAK,CAAC,qBAAqB,CAAC,qBAA6B;QACvD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;QAC9C,OAAO,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,qBAAqB,EAAE,EAAE,MAAM,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IACjG,CAAC;CACF,CAAA;AA1IY,wDAAsB;AAQ3B;IADL,IAAA,kCAAkB,GAAE;;;;0DA4CpB;AAMK;IADL,IAAA,kCAAkB,GAAE;;;;0DAIpB;AAMK;IADL,IAAA,kCAAkB,GAAE;;;;0DAIpB;AAGK;IADL,IAAA,kCAAkB,GAAE;;;;4DAIpB;AAQK;IADL,IAAA,kCAAkB,GAAE;;;;iEAiCpB;AAMK;IADL,IAAA,kCAAkB,GAAE;;;;oEAOpB;AAOK;IADL,IAAA,kCAAkB,GAAE;;;;mEAIpB;iCAzIU,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAEiC,8BAAa;GAD9C,sBAAsB,CA0IlC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ClsService } from "nestjs-cls";
|
|
2
|
+
import { JsonApiListDocument } from "../../../core/jsonapi/interfaces/jsonapi.document.interface";
|
|
3
|
+
import { JsonApiService } from "../../../core/jsonapi/services/jsonapi.service";
|
|
4
|
+
import { AbstractService } from "../../../core/neo4j/abstracts/abstract.service";
|
|
5
|
+
import { StripeCustomerRepository } from "../../stripe-customer/repositories/stripe-customer.repository";
|
|
6
|
+
import { StripePriceRepository } from "../../stripe-price/repositories/stripe-price.repository";
|
|
7
|
+
import { StripeSubscriptionRepository } from "../../stripe-subscription/repositories/stripe-subscription.repository";
|
|
8
|
+
import { StripeCouponCode, StripeCouponCodeDescriptor } from "../entities/stripe-coupon-code";
|
|
9
|
+
import { StripeCouponCodeRepository } from "../repositories/stripe-coupon-code.repository";
|
|
10
|
+
import { StripeCouponRepository } from "../repositories/stripe-coupon.repository";
|
|
11
|
+
import { StripeCouponApiService } from "./stripe-coupon-api.service";
|
|
12
|
+
/**
|
|
13
|
+
* Checkout-side reads and writes on stored coupon codes: which code applies itself at a
|
|
14
|
+
* GM's first payment, whether Stripe has run out of places, and keeping our counts current.
|
|
15
|
+
*/
|
|
16
|
+
export declare class StripeCouponCodeCheckoutService extends AbstractService<StripeCouponCode, typeof StripeCouponCodeDescriptor.relationships> {
|
|
17
|
+
private readonly stripeCouponCodeRepository;
|
|
18
|
+
private readonly stripeCouponRepository;
|
|
19
|
+
private readonly stripeCouponApiService;
|
|
20
|
+
private readonly stripePriceRepository;
|
|
21
|
+
private readonly stripeCustomerRepository;
|
|
22
|
+
private readonly stripeSubscriptionRepository;
|
|
23
|
+
protected readonly descriptor: import("../../..").EntityDescriptor<StripeCouponCode, {
|
|
24
|
+
coupon: {
|
|
25
|
+
model: import("../../..").DataMeta;
|
|
26
|
+
direction: "in";
|
|
27
|
+
relationship: string;
|
|
28
|
+
cardinality: "one";
|
|
29
|
+
required: true;
|
|
30
|
+
dtoKey: string;
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
33
|
+
private readonly logger;
|
|
34
|
+
constructor(jsonApiService: JsonApiService, stripeCouponCodeRepository: StripeCouponCodeRepository, clsService: ClsService, stripeCouponRepository: StripeCouponRepository, stripeCouponApiService: StripeCouponApiService, stripePriceRepository: StripePriceRepository, stripeCustomerRepository: StripeCustomerRepository, stripeSubscriptionRepository: StripeSubscriptionRepository);
|
|
35
|
+
/**
|
|
36
|
+
* The automatic code, when it applies to this company paying this price for the first time.
|
|
37
|
+
* Returns null whenever any rule fails: the GM then pays the normal price, with no error.
|
|
38
|
+
*/
|
|
39
|
+
findAutomaticForPrice(params: {
|
|
40
|
+
companyId: string;
|
|
41
|
+
priceId: string;
|
|
42
|
+
}): Promise<StripeCouponCode | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Checks a promotion code the browser sent at checkout against our automatic code.
|
|
45
|
+
* - "not_automatic": not one of our automatic codes (typed or unknown); pass it to Stripe as is.
|
|
46
|
+
* - "eligible": it is the automatic code and it applies to this first payment right now.
|
|
47
|
+
* - "sold_out": it is the automatic code, it does not apply, and it has no places left.
|
|
48
|
+
* - "unavailable": it is the automatic code and it does not apply for any other reason.
|
|
49
|
+
* Uses the same rules as findAutomaticForPrice, so the review and the payment agree.
|
|
50
|
+
*/
|
|
51
|
+
checkAutomaticForPrice(params: {
|
|
52
|
+
companyId: string;
|
|
53
|
+
priceId: string;
|
|
54
|
+
stripePromotionCodeId: string;
|
|
55
|
+
firstPayment: boolean;
|
|
56
|
+
}): Promise<"eligible" | "sold_out" | "unavailable" | "not_automatic">;
|
|
57
|
+
/**
|
|
58
|
+
* The automatic code for a price as a JSON:API list of 0 or 1 code, coupon included.
|
|
59
|
+
*/
|
|
60
|
+
findAutomaticForPriceDocument(params: {
|
|
61
|
+
companyId: string;
|
|
62
|
+
priceId: string;
|
|
63
|
+
query: any;
|
|
64
|
+
}): Promise<JsonApiListDocument>;
|
|
65
|
+
/**
|
|
66
|
+
* Reads the promotion code and its coupon live from Stripe and tells whether either has run out.
|
|
67
|
+
*/
|
|
68
|
+
isExhausted(stripePromotionCodeId: string): Promise<boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* Re-reads a promotion code and its coupon from Stripe and writes the counts to our nodes.
|
|
71
|
+
* A no-op when the code is not one of ours; logs and never throws.
|
|
72
|
+
*/
|
|
73
|
+
refreshCountsByStripePromotionCodeId(stripePromotionCodeId: string): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* No places left: our copy says 0, or Stripe says so live. A failed live read counts as "has places".
|
|
76
|
+
*/
|
|
77
|
+
private hasNoPlacesLeft;
|
|
78
|
+
private limitReached;
|
|
79
|
+
private resolveCoupon;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=stripe-coupon-code-checkout.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon-code-checkout.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/services/stripe-coupon-code-checkout.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6DAA6D,CAAC;AAElG,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+DAA+D,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAChG,OAAO,EAAE,4BAA4B,EAAE,MAAM,uEAAuE,CAAC;AACrH,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;GAGG;AACH,qBACa,+BAAgC,SAAQ,eAAe,CAClE,gBAAgB,EAChB,OAAO,0BAA0B,CAAC,aAAa,CAChD;IAMG,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAE3C,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,wBAAwB;IACzC,OAAO,CAAC,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