@carlonicora/nestjs-neo4jsonapi 6.9.0 → 7.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/dist/common/decorators/audit.decorator.d.ts +3 -0
- package/dist/common/decorators/audit.decorator.d.ts.map +1 -1
- package/dist/common/decorators/audit.decorator.js +15 -2
- package/dist/common/decorators/audit.decorator.js.map +1 -1
- 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 +15 -3
- package/dist/common/decorators/cache-invalidate.decorator.js.map +1 -1
- package/dist/common/decorators/handler-wrapper.d.ts +13 -0
- package/dist/common/decorators/handler-wrapper.d.ts.map +1 -0
- package/dist/common/decorators/handler-wrapper.js +25 -0
- package/dist/common/decorators/handler-wrapper.js.map +1 -0
- 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 +14 -2
- package/dist/common/decorators/validate-id.decorator.js.map +1 -1
- package/dist/foundations/ai-connection/controllers/ai-connection.controller.d.ts +2 -1
- package/dist/foundations/ai-connection/controllers/ai-connection.controller.d.ts.map +1 -1
- package/dist/foundations/ai-connection/controllers/ai-connection.controller.js +5 -4
- package/dist/foundations/ai-connection/controllers/ai-connection.controller.js.map +1 -1
- package/dist/foundations/analytics/controllers/analytics.admin.controller.d.ts +2 -1
- package/dist/foundations/analytics/controllers/analytics.admin.controller.d.ts.map +1 -1
- package/dist/foundations/analytics/controllers/analytics.admin.controller.js +5 -4
- package/dist/foundations/analytics/controllers/analytics.admin.controller.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 +3 -2
- package/dist/foundations/handbook/controllers/handbook.controller.d.ts.map +1 -1
- package/dist/foundations/handbook/controllers/handbook.controller.js +10 -8
- package/dist/foundations/handbook/controllers/handbook.controller.js.map +1 -1
- package/dist/foundations/notification/controllers/notification.controller.d.ts.map +1 -1
- package/dist/foundations/notification/controllers/notification.controller.js +0 -1
- package/dist/foundations/notification/controllers/notification.controller.js.map +1 -1
- package/dist/foundations/role/controllers/role.controller.d.ts +4 -3
- package/dist/foundations/role/controllers/role.controller.d.ts.map +1 -1
- package/dist/foundations/role/controllers/role.controller.js +13 -10
- 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 +15 -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 +61 -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 +137 -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 +132 -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 +12 -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 +49 -0
- package/dist/foundations/stripe-coupon/controllers/stripe-coupon.public.controller.js.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.automatic.query.dto.d.ts +8 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.automatic.query.dto.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.automatic.query.dto.js +25 -0
- package/dist/foundations/stripe-coupon/dtos/stripe-coupon-code.automatic.query.dto.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 +23 -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 +55 -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 +22 -0
- package/dist/foundations/stripe-coupon/index.d.ts.map +1 -0
- package/dist/foundations/stripe-coupon/index.js +44 -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 +67 -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 +98 -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 +236 -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 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon-code.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/services/stripe-coupon-code.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,iCAAiC,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,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;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,iCAAiC,GAAG,IAAI,CAK9F;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,iCAAiC;;;;;;;;;EAW3G;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,iCAAiC,CAAC;IAC9C,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC;CACrC;;;;;;;;;;;;;;EAgBA;AAED;;;;;;GAMG;AACH,qBACa,uBAAwB,SAAQ,eAAe,CAC1D,gBAAgB,EAChB,OAAO,0BAA0B,CAAC,aAAa,CAChD;IAKG,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAE3C,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IAPzC,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;OAA8B;gBAGzD,cAAc,EAAE,cAAc,EACb,0BAA0B,EAAE,0BAA0B,EACvE,UAAU,EAAE,UAAU,EACL,sBAAsB,EAAE,sBAAsB,EAC9C,sBAAsB,EAAE,sBAAsB;IAK3D,eAAe,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,2BAA2B,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAuBpG;;;OAGG;IACG,WAAW,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,4BAA4B,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAoBjG;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAI5E"}
|
|
@@ -0,0 +1,134 @@
|
|
|
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.StripeCouponCodeService = void 0;
|
|
13
|
+
exports.assertCouponCodeAttributes = assertCouponCodeAttributes;
|
|
14
|
+
exports.couponCodeStripeParams = couponCodeStripeParams;
|
|
15
|
+
exports.couponCodeNodeParams = couponCodeNodeParams;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
18
|
+
const jsonapi_service_1 = require("../../../core/jsonapi/services/jsonapi.service");
|
|
19
|
+
const abstract_service_1 = require("../../../core/neo4j/abstracts/abstract.service");
|
|
20
|
+
const stripe_coupon_code_1 = require("../entities/stripe-coupon-code");
|
|
21
|
+
const stripe_coupon_code_repository_1 = require("../repositories/stripe-coupon-code.repository");
|
|
22
|
+
const stripe_coupon_repository_1 = require("../repositories/stripe-coupon.repository");
|
|
23
|
+
const stripe_coupon_api_service_1 = require("./stripe-coupon-api.service");
|
|
24
|
+
/**
|
|
25
|
+
* Cross-field checks on a code's attributes, run before any Stripe call.
|
|
26
|
+
*/
|
|
27
|
+
function assertCouponCodeAttributes(attributes) {
|
|
28
|
+
if (attributes.minimumAmount !== undefined && !attributes.minimumAmountCurrency)
|
|
29
|
+
throw new common_1.BadRequestException("A minimum amount needs a currency");
|
|
30
|
+
if (attributes.minimumAmount === undefined && attributes.minimumAmountCurrency)
|
|
31
|
+
throw new common_1.BadRequestException("A minimum amount currency needs a minimum amount");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The Stripe promotion code parameters for a code POST's attributes.
|
|
35
|
+
*/
|
|
36
|
+
function couponCodeStripeParams(stripeCouponId, attributes) {
|
|
37
|
+
return {
|
|
38
|
+
stripeCouponId,
|
|
39
|
+
code: attributes.code,
|
|
40
|
+
firstTimeTransaction: attributes.firstTimeTransaction,
|
|
41
|
+
minimumAmount: attributes.minimumAmount,
|
|
42
|
+
minimumAmountCurrency: attributes.minimumAmountCurrency?.toLowerCase(),
|
|
43
|
+
stripeCustomerId: attributes.stripeCustomerId,
|
|
44
|
+
expiresAt: attributes.expiresAt ? new Date(attributes.expiresAt) : undefined,
|
|
45
|
+
maxRedemptions: attributes.maxRedemptions,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The StripeCouponCode node parameters for a promotion code Stripe has just created.
|
|
50
|
+
*/
|
|
51
|
+
function couponCodeNodeParams(params) {
|
|
52
|
+
return {
|
|
53
|
+
id: params.id,
|
|
54
|
+
stripePromotionCodeId: params.promotionCode.id,
|
|
55
|
+
code: params.promotionCode.code,
|
|
56
|
+
active: params.promotionCode.active,
|
|
57
|
+
automatic: params.attributes.automatic ?? false,
|
|
58
|
+
firstTimeTransaction: params.attributes.firstTimeTransaction ?? false,
|
|
59
|
+
minimumAmount: params.attributes.minimumAmount,
|
|
60
|
+
minimumAmountCurrency: params.attributes.minimumAmountCurrency?.toLowerCase(),
|
|
61
|
+
stripeCustomerId: params.attributes.stripeCustomerId,
|
|
62
|
+
expiresAt: params.attributes.expiresAt,
|
|
63
|
+
maxRedemptions: params.attributes.maxRedemptions,
|
|
64
|
+
timesRedeemed: params.promotionCode.times_redeemed ?? 0,
|
|
65
|
+
coupon: params.couponId,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* StripeCouponCodeService
|
|
70
|
+
*
|
|
71
|
+
* Admin operations on the customer-facing codes of a coupon: add a code to an
|
|
72
|
+
* existing coupon, switch "Apply automatically", deactivate / reactivate.
|
|
73
|
+
* Every code is created in Stripe first, then mirrored as a node.
|
|
74
|
+
*/
|
|
75
|
+
let StripeCouponCodeService = class StripeCouponCodeService extends abstract_service_1.AbstractService {
|
|
76
|
+
constructor(jsonApiService, stripeCouponCodeRepository, clsService, stripeCouponRepository, stripeCouponApiService) {
|
|
77
|
+
super(jsonApiService, stripeCouponCodeRepository, clsService, stripe_coupon_code_1.StripeCouponCodeDescriptor.model);
|
|
78
|
+
this.stripeCouponCodeRepository = stripeCouponCodeRepository;
|
|
79
|
+
this.stripeCouponRepository = stripeCouponRepository;
|
|
80
|
+
this.stripeCouponApiService = stripeCouponApiService;
|
|
81
|
+
this.descriptor = stripe_coupon_code_1.StripeCouponCodeDescriptor;
|
|
82
|
+
}
|
|
83
|
+
async createForCoupon(params) {
|
|
84
|
+
const attributes = params.data.attributes;
|
|
85
|
+
const couponId = params.data.relationships.coupon.data.id;
|
|
86
|
+
assertCouponCodeAttributes(attributes);
|
|
87
|
+
const coupon = await this.stripeCouponRepository.findById({ id: couponId });
|
|
88
|
+
if (!coupon)
|
|
89
|
+
throw new common_1.NotFoundException("Coupon not found");
|
|
90
|
+
const promotionCode = await this.stripeCouponApiService.createPromotionCode(couponCodeStripeParams(coupon.stripeCouponId, attributes));
|
|
91
|
+
await this.stripeCouponCodeRepository.create(couponCodeNodeParams({ id: params.data.id, couponId, attributes, promotionCode }));
|
|
92
|
+
if (attributes.automatic)
|
|
93
|
+
await this.stripeCouponCodeRepository.setAutomatic({ id: params.data.id, automatic: true });
|
|
94
|
+
return this.findById({ id: params.data.id });
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Switches "active" (in Stripe, then on the node) and / or "Apply
|
|
98
|
+
* automatically" (ours only: turning it on clears every other code).
|
|
99
|
+
*/
|
|
100
|
+
async updateFlags(params) {
|
|
101
|
+
const attributes = params.data.attributes;
|
|
102
|
+
const code = await this.stripeCouponCodeRepository.findById({ id: params.data.id });
|
|
103
|
+
if (!code)
|
|
104
|
+
throw new common_1.NotFoundException("Code not found");
|
|
105
|
+
if (attributes.active !== undefined) {
|
|
106
|
+
await this.stripeCouponApiService.setPromotionCodeActive({
|
|
107
|
+
stripePromotionCodeId: code.stripePromotionCodeId,
|
|
108
|
+
active: attributes.active,
|
|
109
|
+
});
|
|
110
|
+
await this.stripeCouponCodeRepository.patch({ id: code.id, active: attributes.active });
|
|
111
|
+
}
|
|
112
|
+
if (attributes.automatic !== undefined)
|
|
113
|
+
await this.stripeCouponCodeRepository.setAutomatic({ id: code.id, automatic: attributes.automatic });
|
|
114
|
+
return this.findById({ id: code.id });
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The id of the coupon a code belongs to, so callers can refresh the
|
|
118
|
+
* coupon's cached entry after a change to one of its codes.
|
|
119
|
+
*/
|
|
120
|
+
async findCouponId(params) {
|
|
121
|
+
const code = await this.stripeCouponCodeRepository.findById({ id: params.codeId });
|
|
122
|
+
return code?.coupon?.id;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
exports.StripeCouponCodeService = StripeCouponCodeService;
|
|
126
|
+
exports.StripeCouponCodeService = StripeCouponCodeService = __decorate([
|
|
127
|
+
(0, common_1.Injectable)(),
|
|
128
|
+
__metadata("design:paramtypes", [jsonapi_service_1.JsonApiService,
|
|
129
|
+
stripe_coupon_code_repository_1.StripeCouponCodeRepository,
|
|
130
|
+
nestjs_cls_1.ClsService,
|
|
131
|
+
stripe_coupon_repository_1.StripeCouponRepository,
|
|
132
|
+
stripe_coupon_api_service_1.StripeCouponApiService])
|
|
133
|
+
], StripeCouponCodeService);
|
|
134
|
+
//# sourceMappingURL=stripe-coupon-code.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon-code.service.js","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/services/stripe-coupon-code.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgBA,gEAKC;AAKD,wDAWC;AAKD,oDAqBC;AA/DD,2CAAoF;AACpF,2CAAwC;AAGxC,oFAAgF;AAChF,qFAAiF;AAGjF,uEAA8F;AAC9F,iGAA2F;AAC3F,uFAAkF;AAClF,2EAAqE;AAErE;;GAEG;AACH,SAAgB,0BAA0B,CAAC,UAA6C;IACtF,IAAI,UAAU,CAAC,aAAa,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,qBAAq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C,SAAS,EAAE,CAAC,CAAC;QAEvG,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,YAAY,CAAC,MAA0B;QAC3C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACnF,OAAO,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,CAAC;CACF,CAAA;AAvEY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;qCAQO,gCAAc;QACe,0DAA0B;QAC3D,uBAAU;QACmB,iDAAsB;QACtB,kDAAsB;GAXtD,uBAAuB,CAuEnC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { StripeCouponCode, StripeCouponCodeDescriptor } from "../entities/stripe-coupon-code";
|
|
6
|
+
import { StripeCouponCodeRepository } from "../repositories/stripe-coupon-code.repository";
|
|
7
|
+
/**
|
|
8
|
+
* The public offer: places left on the automatic code, as a synthetic `stripe-coupon-offers`
|
|
9
|
+
* list of 0 or 1 offer. Reads our copy only, never Stripe.
|
|
10
|
+
*/
|
|
11
|
+
export declare class StripeCouponOfferService extends AbstractService<StripeCouponCode, typeof StripeCouponCodeDescriptor.relationships> {
|
|
12
|
+
private readonly stripeCouponCodeRepository;
|
|
13
|
+
protected readonly descriptor: import("../../..").EntityDescriptor<StripeCouponCode, {
|
|
14
|
+
coupon: {
|
|
15
|
+
model: import("../../..").DataMeta;
|
|
16
|
+
direction: "in";
|
|
17
|
+
relationship: string;
|
|
18
|
+
cardinality: "one";
|
|
19
|
+
required: true;
|
|
20
|
+
dtoKey: string;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
constructor(jsonApiService: JsonApiService, stripeCouponCodeRepository: StripeCouponCodeRepository, clsService: ClsService);
|
|
24
|
+
findPublicOffers(params: {
|
|
25
|
+
query: any;
|
|
26
|
+
}): Promise<JsonApiListDocument>;
|
|
27
|
+
private buildOffer;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=stripe-coupon-offer.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon-offer.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/services/stripe-coupon-offer.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,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,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAG3F;;;GAGG;AACH,qBACa,wBAAyB,SAAQ,eAAe,CAC3D,gBAAgB,EAChB,OAAO,0BAA0B,CAAC,aAAa,CAChD;IAKG,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAJ7C,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;OAA8B;gBAGzD,cAAc,EAAE,cAAc,EACb,0BAA0B,EAAE,0BAA0B,EACvE,UAAU,EAAE,UAAU;IAKlB,gBAAgB,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAO9D,UAAU;CA2BzB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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.StripeCouponOfferService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
15
|
+
const jsonapi_paginator_1 = require("../../../core/jsonapi/serialisers/jsonapi.paginator");
|
|
16
|
+
const jsonapi_service_1 = require("../../../core/jsonapi/services/jsonapi.service");
|
|
17
|
+
const abstract_service_1 = require("../../../core/neo4j/abstracts/abstract.service");
|
|
18
|
+
const stripe_coupon_code_1 = require("../entities/stripe-coupon-code");
|
|
19
|
+
const stripe_coupon_offer_1 = require("../entities/stripe-coupon-offer");
|
|
20
|
+
const stripe_coupon_code_repository_1 = require("../repositories/stripe-coupon-code.repository");
|
|
21
|
+
const places_left_1 = require("../utils/places-left");
|
|
22
|
+
/**
|
|
23
|
+
* The public offer: places left on the automatic code, as a synthetic `stripe-coupon-offers`
|
|
24
|
+
* list of 0 or 1 offer. Reads our copy only, never Stripe.
|
|
25
|
+
*/
|
|
26
|
+
let StripeCouponOfferService = class StripeCouponOfferService extends abstract_service_1.AbstractService {
|
|
27
|
+
constructor(jsonApiService, stripeCouponCodeRepository, clsService) {
|
|
28
|
+
super(jsonApiService, stripeCouponCodeRepository, clsService, stripe_coupon_code_1.StripeCouponCodeDescriptor.model);
|
|
29
|
+
this.stripeCouponCodeRepository = stripeCouponCodeRepository;
|
|
30
|
+
this.descriptor = stripe_coupon_code_1.StripeCouponCodeDescriptor;
|
|
31
|
+
}
|
|
32
|
+
async findPublicOffers(params) {
|
|
33
|
+
const paginator = new jsonapi_paginator_1.JsonApiPaginator(params.query);
|
|
34
|
+
const offer = await this.buildOffer();
|
|
35
|
+
return this.jsonApiService.buildList(stripe_coupon_offer_1.StripeCouponOfferDescriptor.model, offer ? [offer] : [], paginator);
|
|
36
|
+
}
|
|
37
|
+
async buildOffer() {
|
|
38
|
+
const code = await this.stripeCouponCodeRepository.findAutomatic();
|
|
39
|
+
if (!code || !code.active || !code.automatic)
|
|
40
|
+
return null;
|
|
41
|
+
const coupon = code.coupon;
|
|
42
|
+
if (!coupon || !coupon.valid)
|
|
43
|
+
return null;
|
|
44
|
+
const now = Date.now();
|
|
45
|
+
if (coupon.redeemBy && new Date(coupon.redeemBy).getTime() <= now)
|
|
46
|
+
return null;
|
|
47
|
+
if (code.expiresAt && new Date(code.expiresAt).getTime() <= now)
|
|
48
|
+
return null;
|
|
49
|
+
const left = (0, places_left_1.placesLeft)(code, coupon);
|
|
50
|
+
const total = (0, places_left_1.placesTotal)(code, coupon);
|
|
51
|
+
if (left === null || total === null || left <= 0)
|
|
52
|
+
return null;
|
|
53
|
+
return {
|
|
54
|
+
id: code.id,
|
|
55
|
+
discountType: coupon.discountType,
|
|
56
|
+
percentOff: coupon.percentOff,
|
|
57
|
+
amountOff: coupon.amountOff,
|
|
58
|
+
currency: coupon.currency,
|
|
59
|
+
duration: coupon.duration,
|
|
60
|
+
durationInMonths: coupon.durationInMonths,
|
|
61
|
+
placesLeft: left,
|
|
62
|
+
placesTotal: total,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.StripeCouponOfferService = StripeCouponOfferService;
|
|
67
|
+
exports.StripeCouponOfferService = StripeCouponOfferService = __decorate([
|
|
68
|
+
(0, common_1.Injectable)(),
|
|
69
|
+
__metadata("design:paramtypes", [jsonapi_service_1.JsonApiService,
|
|
70
|
+
stripe_coupon_code_repository_1.StripeCouponCodeRepository,
|
|
71
|
+
nestjs_cls_1.ClsService])
|
|
72
|
+
], StripeCouponOfferService);
|
|
73
|
+
//# sourceMappingURL=stripe-coupon-offer.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon-offer.service.js","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/services/stripe-coupon-offer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAAwC;AAExC,2FAAuF;AACvF,oFAAgF;AAChF,qFAAiF;AACjF,uEAA8F;AAC9F,yEAAuG;AACvG,iGAA2F;AAC3F,sDAA+D;AAE/D;;;GAGG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,kCAG7C;IAGC,YACE,cAA8B,EACb,0BAAsD,EACvE,UAAsB;QAEtB,KAAK,CAAC,cAAc,EAAE,0BAA0B,EAAE,UAAU,EAAE,+CAA0B,CAAC,KAAK,CAAC,CAAC;QAH/E,+BAA0B,GAA1B,0BAA0B,CAA4B;QAJtD,eAAU,GAAG,+CAA0B,CAAC;IAQ3D,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,MAAsB;QAC3C,MAAM,SAAS,GAAG,IAAI,oCAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAEtC,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,iDAA2B,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAA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ACzC,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,KAAK;SACnB,CAAC;IACJ,CAAC;CACF,CAAA;AAhDY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAQO,gCAAc;QACe,0DAA0B;QAC3D,uBAAU;GATb,wBAAwB,CAgDpC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ClsService } from "nestjs-cls";
|
|
2
|
+
import { JsonApiSingleDocument } 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 { StripeProductRepository } from "../../stripe-product/repositories/stripe-product.repository";
|
|
6
|
+
import { StripeCouponPatchDataDTO } from "../dtos/stripe-coupon.patch.dto";
|
|
7
|
+
import { StripeCouponPostAttributesDTO, StripeCouponPostDataDTO } from "../dtos/stripe-coupon.post.dto";
|
|
8
|
+
import { StripeCoupon, StripeCouponDescriptor, StripeCouponDiscountTerms, StripeCouponDurationTerms } from "../entities/stripe-coupon";
|
|
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
|
+
type CouponDiscountAttributes = Pick<StripeCouponPostAttributesDTO, "discountType" | "percentOff" | "amountOff" | "currency">;
|
|
13
|
+
type CouponDurationAttributes = Pick<StripeCouponPostAttributesDTO, "duration" | "durationInMonths">;
|
|
14
|
+
/**
|
|
15
|
+
* The POST's flat discount fields as one discount shape, run before any Stripe call.
|
|
16
|
+
* Refuses a mixed or incomplete discount; the currency is lowercased.
|
|
17
|
+
*/
|
|
18
|
+
export declare function toCouponDiscount(attributes: CouponDiscountAttributes): StripeCouponDiscountTerms;
|
|
19
|
+
/**
|
|
20
|
+
* The POST's flat duration fields as one duration shape, run before any Stripe call.
|
|
21
|
+
* Refuses a month count on anything but a repeating coupon.
|
|
22
|
+
*/
|
|
23
|
+
export declare function toCouponDuration(attributes: CouponDurationAttributes): StripeCouponDurationTerms;
|
|
24
|
+
/**
|
|
25
|
+
* A discount as the coupon node's flat fields; the fields of the other kind are undefined.
|
|
26
|
+
*/
|
|
27
|
+
export declare function couponDiscountFields(discount: StripeCouponDiscountTerms): {
|
|
28
|
+
discountType: "percent_off";
|
|
29
|
+
percentOff: number;
|
|
30
|
+
amountOff: any;
|
|
31
|
+
currency: any;
|
|
32
|
+
} | {
|
|
33
|
+
discountType: "amount_off";
|
|
34
|
+
percentOff: any;
|
|
35
|
+
amountOff: number;
|
|
36
|
+
currency: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A duration as the coupon node's flat fields; `durationInMonths` is undefined unless repeating.
|
|
40
|
+
*/
|
|
41
|
+
export declare function couponDurationFields(duration: StripeCouponDurationTerms): {
|
|
42
|
+
duration: "once" | "forever" | "repeating";
|
|
43
|
+
durationInMonths: number;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* StripeCouponService
|
|
47
|
+
*
|
|
48
|
+
* Admin operations on coupons. A coupon is created in Stripe together with its
|
|
49
|
+
* first customer-facing code, then both are mirrored as nodes. Stripe forbids
|
|
50
|
+
* changing a coupon's discount, duration and limits, so the only edit is a
|
|
51
|
+
* rename; counts are refreshed from Stripe on demand.
|
|
52
|
+
*/
|
|
53
|
+
export declare class StripeCouponService extends AbstractService<StripeCoupon, typeof StripeCouponDescriptor.relationships> {
|
|
54
|
+
private readonly stripeCouponRepository;
|
|
55
|
+
private readonly stripeCouponCodeRepository;
|
|
56
|
+
private readonly stripeCouponApiService;
|
|
57
|
+
private readonly stripeProductRepository;
|
|
58
|
+
protected readonly descriptor: import("../../..").EntityDescriptor<StripeCoupon, {
|
|
59
|
+
codes: {
|
|
60
|
+
model: import("../../..").DataMeta;
|
|
61
|
+
direction: "out";
|
|
62
|
+
relationship: string;
|
|
63
|
+
cardinality: "many";
|
|
64
|
+
required: false;
|
|
65
|
+
dtoKey: string;
|
|
66
|
+
};
|
|
67
|
+
}>;
|
|
68
|
+
private readonly logger;
|
|
69
|
+
constructor(jsonApiService: JsonApiService, stripeCouponRepository: StripeCouponRepository, clsService: ClsService, stripeCouponCodeRepository: StripeCouponCodeRepository, stripeCouponApiService: StripeCouponApiService, stripeProductRepository: StripeProductRepository);
|
|
70
|
+
/**
|
|
71
|
+
* Creates the Stripe coupon, then its first promotion code, then both nodes.
|
|
72
|
+
* When anything after the coupon fails, the Stripe coupon is deleted (which
|
|
73
|
+
* also deactivates any code already made from it) and the error re-thrown.
|
|
74
|
+
*/
|
|
75
|
+
createWithFirstCode(params: {
|
|
76
|
+
data: StripeCouponPostDataDTO;
|
|
77
|
+
}): Promise<JsonApiSingleDocument>;
|
|
78
|
+
/**
|
|
79
|
+
* Renames the coupon in Stripe, then on the node. Nothing else is editable.
|
|
80
|
+
*/
|
|
81
|
+
rename(params: {
|
|
82
|
+
data: StripeCouponPatchDataDTO;
|
|
83
|
+
}): Promise<JsonApiSingleDocument>;
|
|
84
|
+
/**
|
|
85
|
+
* Re-reads the coupon and each of its codes from Stripe and writes the
|
|
86
|
+
* redemption counts and status to the nodes.
|
|
87
|
+
*/
|
|
88
|
+
refreshCounts(params: {
|
|
89
|
+
id: string;
|
|
90
|
+
}): Promise<JsonApiSingleDocument>;
|
|
91
|
+
/**
|
|
92
|
+
* Maps our StripeProduct ids to Stripe product ids. Unknown ids are rejected.
|
|
93
|
+
*/
|
|
94
|
+
private mapProductIds;
|
|
95
|
+
private rollback;
|
|
96
|
+
}
|
|
97
|
+
export {};
|
|
98
|
+
//# sourceMappingURL=stripe-coupon.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/services/stripe-coupon.service.ts"],"names":[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CAAC,aAAa,CAAC;IAM/G,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IAEvC,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAC3C,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IAT1C,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;OAA0B;IACvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;gBAG7D,cAAc,EAAE,cAAc,EACb,sBAAsB,EAAE,sBAAsB,EAC/D,UAAU,EAAE,UAAU,EACL,0BAA0B,EAAE,0BAA0B,EACtD,sBAAsB,EAAE,sBAAsB,EAC9C,uBAAuB,EAAE,uBAAuB;IAKnE;;;;OAIG;IACG,mBAAmB,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,uBAAuB,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA0DpG;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,wBAAwB,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAYxF;;;OAGG;IACG,aAAa,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAuB3E;;OAEG;YACW,aAAa;YAab,QAAQ;CAevB"}
|
|
@@ -0,0 +1,236 @@
|
|
|
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
|
+
var StripeCouponService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.StripeCouponService = void 0;
|
|
14
|
+
exports.toCouponDiscount = toCouponDiscount;
|
|
15
|
+
exports.toCouponDuration = toCouponDuration;
|
|
16
|
+
exports.couponDiscountFields = couponDiscountFields;
|
|
17
|
+
exports.couponDurationFields = couponDurationFields;
|
|
18
|
+
const common_1 = require("@nestjs/common");
|
|
19
|
+
const crypto_1 = require("crypto");
|
|
20
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
21
|
+
const jsonapi_service_1 = require("../../../core/jsonapi/services/jsonapi.service");
|
|
22
|
+
const abstract_service_1 = require("../../../core/neo4j/abstracts/abstract.service");
|
|
23
|
+
const stripe_product_repository_1 = require("../../stripe-product/repositories/stripe-product.repository");
|
|
24
|
+
const stripe_coupon_1 = require("../entities/stripe-coupon");
|
|
25
|
+
const stripe_coupon_code_repository_1 = require("../repositories/stripe-coupon-code.repository");
|
|
26
|
+
const stripe_coupon_repository_1 = require("../repositories/stripe-coupon.repository");
|
|
27
|
+
const stripe_coupon_api_service_1 = require("./stripe-coupon-api.service");
|
|
28
|
+
const stripe_coupon_code_service_1 = require("./stripe-coupon-code.service");
|
|
29
|
+
/**
|
|
30
|
+
* The POST's flat discount fields as one discount shape, run before any Stripe call.
|
|
31
|
+
* Refuses a mixed or incomplete discount; the currency is lowercased.
|
|
32
|
+
*/
|
|
33
|
+
function toCouponDiscount(attributes) {
|
|
34
|
+
if (attributes.discountType === "percent_off") {
|
|
35
|
+
if (attributes.percentOff === undefined)
|
|
36
|
+
throw new common_1.BadRequestException("A percentage coupon needs percentOff");
|
|
37
|
+
if (attributes.amountOff !== undefined || attributes.currency !== undefined)
|
|
38
|
+
throw new common_1.BadRequestException("A percentage coupon cannot have amountOff or currency");
|
|
39
|
+
return { discountType: "percent_off", percentOff: attributes.percentOff };
|
|
40
|
+
}
|
|
41
|
+
if (attributes.amountOff === undefined || !attributes.currency)
|
|
42
|
+
throw new common_1.BadRequestException("A fixed-amount coupon needs amountOff and currency");
|
|
43
|
+
if (attributes.percentOff !== undefined)
|
|
44
|
+
throw new common_1.BadRequestException("A fixed-amount coupon cannot have percentOff");
|
|
45
|
+
return { discountType: "amount_off", amountOff: attributes.amountOff, currency: attributes.currency.toLowerCase() };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The POST's flat duration fields as one duration shape, run before any Stripe call.
|
|
49
|
+
* Refuses a month count on anything but a repeating coupon.
|
|
50
|
+
*/
|
|
51
|
+
function toCouponDuration(attributes) {
|
|
52
|
+
if (attributes.duration === "repeating") {
|
|
53
|
+
if (attributes.durationInMonths === undefined)
|
|
54
|
+
throw new common_1.BadRequestException("A repeating coupon needs durationInMonths");
|
|
55
|
+
return { duration: "repeating", durationInMonths: attributes.durationInMonths };
|
|
56
|
+
}
|
|
57
|
+
if (attributes.durationInMonths !== undefined)
|
|
58
|
+
throw new common_1.BadRequestException("durationInMonths applies only to a repeating coupon");
|
|
59
|
+
return { duration: attributes.duration };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A discount as the coupon node's flat fields; the fields of the other kind are undefined.
|
|
63
|
+
*/
|
|
64
|
+
function couponDiscountFields(discount) {
|
|
65
|
+
return discount.discountType === "percent_off"
|
|
66
|
+
? {
|
|
67
|
+
discountType: discount.discountType,
|
|
68
|
+
percentOff: discount.percentOff,
|
|
69
|
+
amountOff: undefined,
|
|
70
|
+
currency: undefined,
|
|
71
|
+
}
|
|
72
|
+
: {
|
|
73
|
+
discountType: discount.discountType,
|
|
74
|
+
percentOff: undefined,
|
|
75
|
+
amountOff: discount.amountOff,
|
|
76
|
+
currency: discount.currency,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A duration as the coupon node's flat fields; `durationInMonths` is undefined unless repeating.
|
|
81
|
+
*/
|
|
82
|
+
function couponDurationFields(duration) {
|
|
83
|
+
return {
|
|
84
|
+
duration: duration.duration,
|
|
85
|
+
durationInMonths: duration.duration === "repeating" ? duration.durationInMonths : undefined,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* StripeCouponService
|
|
90
|
+
*
|
|
91
|
+
* Admin operations on coupons. A coupon is created in Stripe together with its
|
|
92
|
+
* first customer-facing code, then both are mirrored as nodes. Stripe forbids
|
|
93
|
+
* changing a coupon's discount, duration and limits, so the only edit is a
|
|
94
|
+
* rename; counts are refreshed from Stripe on demand.
|
|
95
|
+
*/
|
|
96
|
+
let StripeCouponService = StripeCouponService_1 = class StripeCouponService extends abstract_service_1.AbstractService {
|
|
97
|
+
constructor(jsonApiService, stripeCouponRepository, clsService, stripeCouponCodeRepository, stripeCouponApiService, stripeProductRepository) {
|
|
98
|
+
super(jsonApiService, stripeCouponRepository, clsService, stripe_coupon_1.StripeCouponDescriptor.model);
|
|
99
|
+
this.stripeCouponRepository = stripeCouponRepository;
|
|
100
|
+
this.stripeCouponCodeRepository = stripeCouponCodeRepository;
|
|
101
|
+
this.stripeCouponApiService = stripeCouponApiService;
|
|
102
|
+
this.stripeProductRepository = stripeProductRepository;
|
|
103
|
+
this.descriptor = stripe_coupon_1.StripeCouponDescriptor;
|
|
104
|
+
this.logger = new common_1.Logger(StripeCouponService_1.name);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Creates the Stripe coupon, then its first promotion code, then both nodes.
|
|
108
|
+
* When anything after the coupon fails, the Stripe coupon is deleted (which
|
|
109
|
+
* also deactivates any code already made from it) and the error re-thrown.
|
|
110
|
+
*/
|
|
111
|
+
async createWithFirstCode(params) {
|
|
112
|
+
const attributes = params.data.attributes;
|
|
113
|
+
const firstCode = attributes.firstCode;
|
|
114
|
+
const discount = toCouponDiscount(attributes);
|
|
115
|
+
const duration = toCouponDuration(attributes);
|
|
116
|
+
(0, stripe_coupon_code_service_1.assertCouponCodeAttributes)(firstCode);
|
|
117
|
+
const stripeProductIds = await this.mapProductIds(attributes.productIds);
|
|
118
|
+
const stripeCoupon = await this.stripeCouponApiService.createCoupon({
|
|
119
|
+
id: attributes.stripeCouponId,
|
|
120
|
+
name: attributes.name,
|
|
121
|
+
discount,
|
|
122
|
+
duration,
|
|
123
|
+
stripeProductIds,
|
|
124
|
+
redeemBy: attributes.redeemBy ? new Date(attributes.redeemBy) : undefined,
|
|
125
|
+
maxRedemptions: attributes.maxRedemptions,
|
|
126
|
+
});
|
|
127
|
+
const codeId = (0, crypto_1.randomUUID)();
|
|
128
|
+
let couponNodeCreated = false;
|
|
129
|
+
try {
|
|
130
|
+
const promotionCode = await this.stripeCouponApiService.createPromotionCode((0, stripe_coupon_code_service_1.couponCodeStripeParams)(stripeCoupon.id, firstCode));
|
|
131
|
+
await this.stripeCouponRepository.create({
|
|
132
|
+
id: params.data.id,
|
|
133
|
+
stripeCouponId: stripeCoupon.id,
|
|
134
|
+
name: attributes.name,
|
|
135
|
+
...couponDiscountFields(discount),
|
|
136
|
+
...couponDurationFields(duration),
|
|
137
|
+
stripeProductIds,
|
|
138
|
+
redeemBy: attributes.redeemBy,
|
|
139
|
+
maxRedemptions: attributes.maxRedemptions,
|
|
140
|
+
timesRedeemed: stripeCoupon.times_redeemed ?? 0,
|
|
141
|
+
valid: stripeCoupon.valid,
|
|
142
|
+
});
|
|
143
|
+
couponNodeCreated = true;
|
|
144
|
+
await this.stripeCouponCodeRepository.create((0, stripe_coupon_code_service_1.couponCodeNodeParams)({ id: codeId, couponId: params.data.id, attributes: firstCode, promotionCode }));
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
await this.rollback({
|
|
148
|
+
stripeCouponId: stripeCoupon.id,
|
|
149
|
+
couponId: couponNodeCreated ? params.data.id : undefined,
|
|
150
|
+
});
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
if (firstCode.automatic)
|
|
154
|
+
await this.stripeCouponCodeRepository.setAutomatic({ id: codeId, automatic: true });
|
|
155
|
+
return this.findById({ id: params.data.id });
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Renames the coupon in Stripe, then on the node. Nothing else is editable.
|
|
159
|
+
*/
|
|
160
|
+
async rename(params) {
|
|
161
|
+
const coupon = await this.stripeCouponRepository.findById({ id: params.data.id });
|
|
162
|
+
if (!coupon)
|
|
163
|
+
throw new common_1.NotFoundException("Coupon not found");
|
|
164
|
+
const name = params.data.attributes.name;
|
|
165
|
+
if (name === undefined)
|
|
166
|
+
return this.findById({ id: coupon.id });
|
|
167
|
+
await this.stripeCouponApiService.renameCoupon({ stripeCouponId: coupon.stripeCouponId, name });
|
|
168
|
+
return this.patch({ id: coupon.id, name });
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Re-reads the coupon and each of its codes from Stripe and writes the
|
|
172
|
+
* redemption counts and status to the nodes.
|
|
173
|
+
*/
|
|
174
|
+
async refreshCounts(params) {
|
|
175
|
+
const coupon = await this.stripeCouponRepository.findById({ id: params.id });
|
|
176
|
+
if (!coupon)
|
|
177
|
+
throw new common_1.NotFoundException("Coupon not found");
|
|
178
|
+
const stripeCoupon = await this.stripeCouponApiService.retrieveCoupon(coupon.stripeCouponId);
|
|
179
|
+
await this.stripeCouponRepository.patch({
|
|
180
|
+
id: coupon.id,
|
|
181
|
+
timesRedeemed: stripeCoupon.times_redeemed ?? 0,
|
|
182
|
+
valid: stripeCoupon.valid,
|
|
183
|
+
});
|
|
184
|
+
for (const code of coupon.codes ?? []) {
|
|
185
|
+
const promotionCode = await this.stripeCouponApiService.retrievePromotionCode(code.stripePromotionCodeId);
|
|
186
|
+
await this.stripeCouponCodeRepository.patch({
|
|
187
|
+
id: code.id,
|
|
188
|
+
timesRedeemed: promotionCode.times_redeemed ?? 0,
|
|
189
|
+
active: promotionCode.active,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return this.findById({ id: coupon.id });
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Maps our StripeProduct ids to Stripe product ids. Unknown ids are rejected.
|
|
196
|
+
*/
|
|
197
|
+
async mapProductIds(productIds) {
|
|
198
|
+
if (!productIds?.length)
|
|
199
|
+
return undefined;
|
|
200
|
+
const stripeProductIds = [];
|
|
201
|
+
for (const id of productIds) {
|
|
202
|
+
const product = await this.stripeProductRepository.findById({ id });
|
|
203
|
+
if (!product)
|
|
204
|
+
throw new common_1.BadRequestException(`Product ${id} not found`);
|
|
205
|
+
stripeProductIds.push(product.stripeProductId);
|
|
206
|
+
}
|
|
207
|
+
return stripeProductIds;
|
|
208
|
+
}
|
|
209
|
+
async rollback(params) {
|
|
210
|
+
try {
|
|
211
|
+
await this.stripeCouponApiService.deleteCoupon(params.stripeCouponId);
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
this.logger.error(`Could not delete Stripe coupon ${params.stripeCouponId} after a failed create`, error);
|
|
215
|
+
}
|
|
216
|
+
if (!params.couponId)
|
|
217
|
+
return;
|
|
218
|
+
try {
|
|
219
|
+
await this.stripeCouponRepository.delete({ id: params.couponId });
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
this.logger.error(`Could not delete coupon node ${params.couponId} after a failed create`, error);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
exports.StripeCouponService = StripeCouponService;
|
|
227
|
+
exports.StripeCouponService = StripeCouponService = StripeCouponService_1 = __decorate([
|
|
228
|
+
(0, common_1.Injectable)(),
|
|
229
|
+
__metadata("design:paramtypes", [jsonapi_service_1.JsonApiService,
|
|
230
|
+
stripe_coupon_repository_1.StripeCouponRepository,
|
|
231
|
+
nestjs_cls_1.ClsService,
|
|
232
|
+
stripe_coupon_code_repository_1.StripeCouponCodeRepository,
|
|
233
|
+
stripe_coupon_api_service_1.StripeCouponApiService,
|
|
234
|
+
stripe_product_repository_1.StripeProductRepository])
|
|
235
|
+
], StripeCouponService);
|
|
236
|
+
//# sourceMappingURL=stripe-coupon.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon.service.js","sourceRoot":"","sources":["../../../../src/foundations/stripe-coupon/services/stripe-coupon.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA8BA,4CAaC;AAMD,4CAUC;AAKD,oDAcC;AAKD,oDAKC;AAxFD,2CAA4F;AAC5F,mCAAoC;AACpC,2CAAwC;AAExC,oFAAgF;AAChF,qFAAiF;AACjF,2GAAsG;AAGtG,6DAKmC;AACnC,iGAA2F;AAC3F,uFAAkF;AAClF,2EAAqE;AACrE,6EAAwH;AAQxH;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,UAAoC;IACnE,IAAI,UAAU,CAAC,YAAY,KAAK,aAAa,EAAE,CAAC;QAC9C,IAAI,UAAU,CAAC,UAAU,KAAK,SAAS;YAAE,MAAM,IAAI,4BAAmB,CAAC,sCAAsC,CAAC,CAAC;QAC/G,IAAI,UAAU,CAAC,SAAS,KAAK,SAAS,IAAI,UAAU,CAAC,QAAQ,KAAK,SAAS;YACzE,MAAM,IAAI,4BAAmB,CAAC,uDAAuD,CAAC,CAAC;QACzF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,CAAC,UAAU,EAAE,CAAC;IAC5E,CAAC;IAED,IAAI,UAAU,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,QAAQ;QAC5D,MAAM,IAAI,4BAAmB,CAAC,oDAAoD,CAAC,CAAC;IACtF,IAAI,UAAU,CAAC,UAAU,KAAK,SAAS;QACrC,MAAM,IAAI,4BAAmB,CAAC,8CAA8C,CAAC,CAAC;IAChF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,QAAQ,EAAE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,gBAAgB,CAAC;IAC1B,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,MAAqD;QAC1E,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,sBAAsB,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACxE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,MAAM,CAAC,cAAc,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC5G,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ;YAAE,OAAO;QAE7B,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QACpE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,MAAM,CAAC,QAAQ,wBAAwB,EAAE,KAAK,CAAC,CAAC;QACpG,CAAC;IACH,CAAC;CACF,CAAA;AAvJY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAMO,gCAAc;QACW,iDAAsB;QACnD,uBAAU;QACuB,0DAA0B;QAC9B,kDAAsB;QACrB,mDAAuB;GAVxD,mBAAmB,CAuJ/B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OnModuleInit } from "@nestjs/common";
|
|
2
|
+
/**
|
|
3
|
+
* StripeCouponModule — admin-managed Stripe coupons and their customer-facing codes.
|
|
4
|
+
*
|
|
5
|
+
* - Coupons and codes are created in Stripe first and mirrored as nodes
|
|
6
|
+
* (`StripeCoupon` -[:HAS_CODE]-> `StripeCouponCode`), like products
|
|
7
|
+
* - One code at a time can be "Apply automatically"; the subscription service
|
|
8
|
+
* attaches it at a GM's first payment (`StripeCouponCodeCheckoutService`)
|
|
9
|
+
* - A public read of the automatic code's places left (`StripeCouponPublicController`)
|
|
10
|
+
*/
|
|
11
|
+
export declare class StripeCouponModule implements OnModuleInit {
|
|
12
|
+
onModuleInit(): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=stripe-coupon.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-coupon.module.d.ts","sourceRoot":"","sources":["../../../src/foundations/stripe-coupon/stripe-coupon.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,YAAY,EAAc,MAAM,gBAAgB,CAAC;AA2BlE;;;;;;;;GAQG;AACH,qBAmCa,kBAAmB,YAAW,YAAY;IACrD,YAAY;CAMb"}
|