@social-mail/social-mail-web-server 1.8.494 → 1.8.499
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/server/model/SocialMailContext.d.ts +8 -0
- package/dist/server/model/SocialMailContext.d.ts.map +1 -1
- package/dist/server/model/SocialMailContext.js +8 -0
- package/dist/server/model/SocialMailContext.js.map +1 -1
- package/dist/server/model/SocialMailContextEvents.d.ts.map +1 -1
- package/dist/server/model/SocialMailContextEvents.js +9 -0
- package/dist/server/model/SocialMailContextEvents.js.map +1 -1
- package/dist/server/model/entities/HostedDomain.d.ts +2 -0
- package/dist/server/model/entities/HostedDomain.d.ts.map +1 -1
- package/dist/server/model/entities/HostedDomain.js.map +1 -1
- package/dist/server/model/entities/StoreAccount.d.ts +2 -0
- package/dist/server/model/entities/StoreAccount.d.ts.map +1 -1
- package/dist/server/model/entities/StoreAccount.js.map +1 -1
- package/dist/server/model/entities/StoreItem.d.ts +1 -1
- package/dist/server/model/entities/StoreItem.d.ts.map +1 -1
- package/dist/server/model/entities/StoreItem.js +1 -1
- package/dist/server/model/entities/StoreItem.js.map +1 -1
- package/dist/server/model/entities/StoreItemPrice.d.ts +10 -0
- package/dist/server/model/entities/StoreItemPrice.d.ts.map +1 -1
- package/dist/server/model/entities/StoreItemPrice.js +14 -0
- package/dist/server/model/entities/StoreItemPrice.js.map +1 -1
- package/dist/server/model/entities/StorePGItemPrice.d.ts +8 -0
- package/dist/server/model/entities/StorePGItemPrice.d.ts.map +1 -0
- package/dist/server/model/entities/StorePGItemPrice.js +36 -0
- package/dist/server/model/entities/StorePGItemPrice.js.map +1 -0
- package/dist/server/model/entities/StorePGSubscription.d.ts +13 -0
- package/dist/server/model/entities/StorePGSubscription.d.ts.map +1 -0
- package/dist/server/model/entities/StorePGSubscription.js +62 -0
- package/dist/server/model/entities/StorePGSubscription.js.map +1 -0
- package/dist/server/model/entities/StorePaymentGateway.d.ts +5 -1
- package/dist/server/model/entities/StorePaymentGateway.d.ts.map +1 -1
- package/dist/server/model/entities/StorePaymentGateway.js +1 -1
- package/dist/server/model/entities/StorePaymentGateway.js.map +1 -1
- package/dist/server/model/entities/StoreSubscription.d.ts +36 -0
- package/dist/server/model/entities/StoreSubscription.d.ts.map +1 -0
- package/dist/server/model/entities/StoreSubscription.js +81 -0
- package/dist/server/model/entities/StoreSubscription.js.map +1 -0
- package/dist/server/model/entities/WebSite.d.ts +4 -0
- package/dist/server/model/entities/WebSite.d.ts.map +1 -1
- package/dist/server/model/entities/WebSite.js.map +1 -1
- package/dist/server/model/entities/WebSiteSubscription.d.ts +12 -0
- package/dist/server/model/entities/WebSiteSubscription.d.ts.map +1 -0
- package/dist/server/model/entities/WebSiteSubscription.js +54 -0
- package/dist/server/model/entities/WebSiteSubscription.js.map +1 -0
- package/dist/server/model/events/StorePGItemPriceEvents.d.ts +5 -0
- package/dist/server/model/events/StorePGItemPriceEvents.d.ts.map +1 -0
- package/dist/server/model/events/StorePGItemPriceEvents.js +4 -0
- package/dist/server/model/events/StorePGItemPriceEvents.js.map +1 -0
- package/dist/server/model/events/StorePGSubscriptionEvents.d.ts +7 -0
- package/dist/server/model/events/StorePGSubscriptionEvents.d.ts.map +1 -0
- package/dist/server/model/events/StorePGSubscriptionEvents.js +12 -0
- package/dist/server/model/events/StorePGSubscriptionEvents.js.map +1 -0
- package/dist/server/model/events/StoreSubscriptionEvents.d.ts +7 -0
- package/dist/server/model/events/StoreSubscriptionEvents.d.ts.map +1 -0
- package/dist/server/model/events/StoreSubscriptionEvents.js +12 -0
- package/dist/server/model/events/StoreSubscriptionEvents.js.map +1 -0
- package/dist/server/model/events/VerificationTokenEvents.js +2 -2
- package/dist/server/model/events/VerificationTokenEvents.js.map +1 -1
- package/dist/server/seed/ui/seed-ui.js +1 -1
- package/dist/server/services/html/HtmlForEmailService.js +1 -1
- package/dist/server/services/store/LedgerPaymentGateway.d.ts +10 -0
- package/dist/server/services/store/LedgerPaymentGateway.d.ts.map +1 -1
- package/dist/server/services/store/LedgerPaymentGateway.js.map +1 -1
- package/dist/server/services/store/StorePaymentGatewayService.d.ts +16 -0
- package/dist/server/services/store/StorePaymentGatewayService.d.ts.map +1 -1
- package/dist/server/services/store/StorePaymentGatewayService.js +30 -0
- package/dist/server/services/store/StorePaymentGatewayService.js.map +1 -1
- package/dist/server/services/store/gateways/cashfree.d.ts +32 -0
- package/dist/server/services/store/gateways/cashfree.d.ts.map +1 -0
- package/dist/server/services/store/gateways/cashfree.js +192 -0
- package/dist/server/services/store/gateways/cashfree.js.map +1 -0
- package/dist/server/services/store/gateways/paypal.d.ts +6 -0
- package/dist/server/services/store/gateways/paypal.d.ts.map +1 -1
- package/dist/server/services/store/gateways/paypal.js +53 -1
- package/dist/server/services/store/gateways/paypal.js.map +1 -1
- package/dist/server/services/store/gateways/phone-pe.d.ts +4 -0
- package/dist/server/services/store/gateways/phone-pe.d.ts.map +1 -1
- package/dist/server/services/store/gateways/phone-pe.js +6 -0
- package/dist/server/services/store/gateways/phone-pe.js.map +1 -1
- package/dist/server/services/store/gateways/stripe.d.ts +4 -0
- package/dist/server/services/store/gateways/stripe.d.ts.map +1 -1
- package/dist/server/services/store/gateways/stripe.js +6 -0
- package/dist/server/services/store/gateways/stripe.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/wwwroot/routes/store/buy/[productID]/get.js +1 -1
- package/dist/wwwroot/routes/store/buy/[productID]/get.js.map +1 -1
- package/dist/wwwroot/routes/store/subscribe/[productID]/get.d.ts +14 -0
- package/dist/wwwroot/routes/store/subscribe/[productID]/get.d.ts.map +1 -0
- package/dist/wwwroot/routes/store/subscribe/[productID]/get.js +80 -0
- package/dist/wwwroot/routes/store/subscribe/[productID]/get.js.map +1 -0
- package/dist/wwwroot/routes/store/subscribe-callback/[subscriptionID]/get.d.ts +10 -0
- package/dist/wwwroot/routes/store/subscribe-callback/[subscriptionID]/get.d.ts.map +1 -0
- package/dist/wwwroot/routes/store/subscribe-callback/[subscriptionID]/get.js +38 -0
- package/dist/wwwroot/routes/store/subscribe-callback/[subscriptionID]/get.js.map +1 -0
- package/package.json +3 -2
- package/src/server/model/SocialMailContext.ts +12 -0
- package/src/server/model/SocialMailContextEvents.ts +10 -0
- package/src/server/model/entities/HostedDomain.ts +2 -0
- package/src/server/model/entities/StoreAccount.ts +2 -0
- package/src/server/model/entities/StoreItem.ts +1 -1
- package/src/server/model/entities/StoreItemPrice.ts +19 -0
- package/src/server/model/entities/StorePGItemPrice.ts +24 -0
- package/src/server/model/entities/StorePGSubscription.ts +48 -0
- package/src/server/model/entities/StorePaymentGateway.ts +5 -1
- package/src/server/model/entities/StoreSubscription.ts +75 -0
- package/src/server/model/entities/WebSite.ts +4 -0
- package/src/server/model/entities/WebSiteSubscription.ts +44 -0
- package/src/server/model/events/StorePGItemPriceEvents.ts +5 -0
- package/src/server/model/events/StorePGSubscriptionEvents.ts +17 -0
- package/src/server/model/events/StoreSubscriptionEvents.ts +16 -0
- package/src/server/model/events/VerificationTokenEvents.ts +2 -2
- package/src/server/seed/ui/seed-ui.ts +1 -1
- package/src/server/services/html/HtmlForEmailService.ts +1 -1
- package/src/server/services/store/LedgerPaymentGateway.ts +6 -0
- package/src/server/services/store/StorePaymentGatewayService.ts +42 -0
- package/src/server/services/store/gateways/cashfree.tsx +237 -0
- package/src/server/services/store/gateways/paypal.tsx +73 -2
- package/src/server/services/store/gateways/phone-pe.tsx +9 -0
- package/src/server/services/store/gateways/stripe.tsx +9 -0
- package/src/wwwroot/routes/store/buy/[productID]/get.tsx +1 -1
- package/src/wwwroot/routes/store/subscribe/[productID]/get.tsx +82 -0
- package/src/wwwroot/routes/store/subscribe-callback/[subscriptionID]/get.tsx +30 -0
|
@@ -29,7 +29,7 @@ let default_1 = class extends Page {
|
|
|
29
29
|
if (!currency) {
|
|
30
30
|
currency = w.currency;
|
|
31
31
|
}
|
|
32
|
-
const contact = await this.db.storeAccounts.where({ userID }, (p) => (x) => x.
|
|
32
|
+
const contact = await this.db.storeAccounts.where({ userID }, (p) => (x) => x.userID === p.userID)
|
|
33
33
|
.include((x) => x.addresses)
|
|
34
34
|
.first() ?? EntityAccessError.throw(`Please signup as a store user instead of backend user.`);
|
|
35
35
|
// todo: optimization
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../../../src/wwwroot/routes/store/buy/[productID]/get.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,4CAA4C,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,gDAAgD,CAAC;AACvE,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AACjF,OAAO,iBAAiB,MAAM,kDAAkD,CAAC;AACjF,OAAO,kBAAkB,MAAM,4DAA4D,CAAC;AAC5F,OAAO,iBAAiB,MAAM,+DAA+D,CAAC;AAC9F,OAAO,qBAAqB,MAAM,+DAA+D,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAI9D,gBAAA,KAAM,SAAQ,IAAI;IAc7B,KAAK,CAAC,GAAG;QAEL,uBAAuB;QACvB,kBAAkB;QAClB,uBAAuB;QAEvB,IAAI,CAAE,QAAQ,CAAE,GAAG,IAAI,CAAC,SAAkB,CAAC;QAE3C,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;QAEpC,IAAI,MAAM,EAAE,CAAC;YAET,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC1E,MAAM,OAAO,GAAG,CAAC,CAAC,QAAQ,CAAC;YAE3B,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACZ,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;YAC1B,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC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OAAO;wBAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ;qBACrC,CAAC;iBACL;aACJ,CAAC,CAAC;YAEH,MAAM,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;YAE5B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,gBAAgB,KAAK,CAAC,SAAS,EAAE,EAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnG,CAAC;QAED,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;QACjH,OAAO,IAAI,cAAc,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;CAEJ,CAAA;AAxEG;IADC,KAAK;;4CACI;AAGV;IADC,MAAM;8BACH,iBAAiB;qCAAC;AAGtB;IADC,MAAM;8BACa,kBAAkB;qDAAC;AAGvC;IADC,MAAM;8BACa,qBAAqB;qDAAC;AAZ/B;IADd,OAAO,CAAC,SAAS;aA4EjB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Page from "@entity-access/server-pages/dist/Page.js";
|
|
2
|
+
import SocialMailContext from "../../../../../server/model/SocialMailContext.js";
|
|
3
|
+
import StoreConfigService from "../../../../../server/services/store/StoreConfigService.js";
|
|
4
|
+
import WebSiteContentService from "../../../../../server/services/files/WebSiteContentService.js";
|
|
5
|
+
import StorePaymentGatewayService from "../../../../../server/services/store/StorePaymentGatewayService.js";
|
|
6
|
+
export default class extends Page {
|
|
7
|
+
productID: any;
|
|
8
|
+
db: SocialMailContext;
|
|
9
|
+
storeConfigService: StoreConfigService;
|
|
10
|
+
siteContentService: WebSiteContentService;
|
|
11
|
+
pgs: StorePaymentGatewayService;
|
|
12
|
+
run(): Promise<import("@entity-access/server-pages/dist/Content.js").default>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=get.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../../../src/wwwroot/routes/store/subscribe/[productID]/get.tsx"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAC5D,OAAO,iBAAiB,MAAM,kDAAkD,CAAC;AACjF,OAAO,kBAAkB,MAAM,4DAA4D,CAAC;AAC5F,OAAO,qBAAqB,MAAM,+DAA+D,CAAC;AAClG,OAAO,0BAA0B,MAAM,oEAAoE,CAAC;AAO5G,MAAM,CAAC,OAAO,MAAO,SAAQ,IAAI;IAG7B,SAAS,MAAC;IAGV,EAAE,EAAE,iBAAiB,CAAC;IAGtB,kBAAkB,EAAE,kBAAkB,CAAC;IAGvC,kBAAkB,EAAE,qBAAqB,CAAC;IAG1C,GAAG,EAAE,0BAA0B,CAAC;IAE1B,GAAG;CAmDZ"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import Inject from "@entity-access/entity-access/dist/di/di.js";
|
|
11
|
+
import { Route } from "@entity-access/server-pages/dist/core/Route.js";
|
|
12
|
+
import Page from "@entity-access/server-pages/dist/Page.js";
|
|
13
|
+
import SocialMailContext from "../../../../../server/model/SocialMailContext.js";
|
|
14
|
+
import StoreConfigService from "../../../../../server/services/store/StoreConfigService.js";
|
|
15
|
+
import WebSiteContentService from "../../../../../server/services/files/WebSiteContentService.js";
|
|
16
|
+
import StorePaymentGatewayService from "../../../../../server/services/store/StorePaymentGatewayService.js";
|
|
17
|
+
import { Symbols } from "../../../../../common/Symbols.js";
|
|
18
|
+
import { Prepare } from "@entity-access/server-pages/dist/decorators/Prepare.js";
|
|
19
|
+
import EntityAccessError from "@entity-access/entity-access/dist/common/EntityAccessError.js";
|
|
20
|
+
let default_1 = class extends Page {
|
|
21
|
+
async run() {
|
|
22
|
+
// only if logged in...
|
|
23
|
+
// 1. Create order
|
|
24
|
+
// 2. Route to Checkout
|
|
25
|
+
let [currency] = this.childPath;
|
|
26
|
+
const w = await this.siteContentService.getWebSite(this.request.hostName);
|
|
27
|
+
const storeID = w.folderID;
|
|
28
|
+
if (!currency) {
|
|
29
|
+
currency = w.currency;
|
|
30
|
+
}
|
|
31
|
+
// todo: optimization
|
|
32
|
+
// do not create new orders if new order for same item exists
|
|
33
|
+
// with only a single item...
|
|
34
|
+
const { productID } = this;
|
|
35
|
+
const { price } = await this.storeConfigService.getPrice(productID, currency, this.request.hostName, storeID);
|
|
36
|
+
const { userID } = this.sessionUser;
|
|
37
|
+
const contact = await this.db.storeAccounts.where({ userID }, (p) => (x) => x.userID === p.userID)
|
|
38
|
+
.include((x) => x.addresses)
|
|
39
|
+
.first() ?? EntityAccessError.throw(`Please signup as a store user instead of backend user.`);
|
|
40
|
+
const subscription = this.db.storeSubscriptions.add({
|
|
41
|
+
storeID,
|
|
42
|
+
buyerID: contact.accountID,
|
|
43
|
+
status: "pending",
|
|
44
|
+
itemPrice: price
|
|
45
|
+
});
|
|
46
|
+
subscription[Symbols.enableSaveWithoutLogin] = true;
|
|
47
|
+
await this.db.saveChanges();
|
|
48
|
+
const host = this.request.hostName;
|
|
49
|
+
const c = await this.pgs.createSubscription({ storeID, subscription, host, userID: this.sessionUser.userID });
|
|
50
|
+
if (c.url) {
|
|
51
|
+
return this.redirect(c.url);
|
|
52
|
+
}
|
|
53
|
+
return this.content({ body: c.content, contentType: "text/html" });
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
__decorate([
|
|
57
|
+
Route,
|
|
58
|
+
__metadata("design:type", Object)
|
|
59
|
+
], default_1.prototype, "productID", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
Inject,
|
|
62
|
+
__metadata("design:type", SocialMailContext)
|
|
63
|
+
], default_1.prototype, "db", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
Inject,
|
|
66
|
+
__metadata("design:type", StoreConfigService)
|
|
67
|
+
], default_1.prototype, "storeConfigService", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
Inject,
|
|
70
|
+
__metadata("design:type", WebSiteContentService)
|
|
71
|
+
], default_1.prototype, "siteContentService", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
Inject,
|
|
74
|
+
__metadata("design:type", StorePaymentGatewayService)
|
|
75
|
+
], default_1.prototype, "pgs", void 0);
|
|
76
|
+
default_1 = __decorate([
|
|
77
|
+
Prepare.authorize
|
|
78
|
+
], default_1);
|
|
79
|
+
export default default_1;
|
|
80
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../../../src/wwwroot/routes/store/subscribe/[productID]/get.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,4CAA4C,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,gDAAgD,CAAC;AACvE,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAC5D,OAAO,iBAAiB,MAAM,kDAAkD,CAAC;AACjF,OAAO,kBAAkB,MAAM,4DAA4D,CAAC;AAC5F,OAAO,qBAAqB,MAAM,+DAA+D,CAAC;AAClG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AI,iBAAiB,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAElG,MAAM,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC;YAChD,OAAO;YACP,OAAO,EAAE,OAAO,CAAC,SAAS;YAC1B,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE,KAAK;SACnB,CAAC,CAAC;QAEH,YAAY,CAAC,OAAO,CAAC,sBAAsB,CAAC,GAAG,IAAI,CAAC;QAEpD,MAAM,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;QAE5B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QAEnC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;QAE9G,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;YACR,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC;IACvE,CAAC;CAEJ,CAAA;AAjEG;IADC,KAAK;;4CACI;AAGV;IADC,MAAM;8BACH,iBAAiB;qCAAC;AAGtB;IADC,MAAM;8BACa,kBAAkB;qDAAC;AAGvC;IADC,MAAM;8BACa,qBAAqB;qDAAC;AAG1C;IADC,MAAM;8BACF,0BAA0B;sCAAC;AAfrB;IADd,OAAO,CAAC,SAAS;aAqEjB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Page from "@entity-access/server-pages/dist/Page.js";
|
|
2
|
+
import StorePaymentGatewayService from "../../../../../server/services/store/StorePaymentGatewayService.js";
|
|
3
|
+
import EncryptionService from "../../../../../server/services/encryption/EncryptionService.js";
|
|
4
|
+
export default class extends Page {
|
|
5
|
+
subscriptionID: any;
|
|
6
|
+
pgs: StorePaymentGatewayService;
|
|
7
|
+
ecs: EncryptionService;
|
|
8
|
+
run(): Promise<import("@entity-access/server-pages/dist/Content.js").Redirect>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=get.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../../../src/wwwroot/routes/store/subscribe-callback/[subscriptionID]/get.tsx"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAC5D,OAAO,0BAA0B,MAAM,oEAAoE,CAAC;AAC5G,OAAO,iBAAiB,MAAM,gEAAgE,CAAC;AAG/F,MAAM,CAAC,OAAO,MAAO,SAAQ,IAAI;IAG7B,cAAc,MAAC;IAGf,GAAG,EAAE,0BAA0B,CAAC;IAGhC,GAAG,EAAE,iBAAiB,CAAC;IAEjB,GAAG;CAWZ"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import Inject from "@entity-access/entity-access/dist/di/di.js";
|
|
11
|
+
import { Route } from "@entity-access/server-pages/dist/core/Route.js";
|
|
12
|
+
import Page from "@entity-access/server-pages/dist/Page.js";
|
|
13
|
+
import StorePaymentGatewayService from "../../../../../server/services/store/StorePaymentGatewayService.js";
|
|
14
|
+
import EncryptionService from "../../../../../server/services/encryption/EncryptionService.js";
|
|
15
|
+
export default class default_1 extends Page {
|
|
16
|
+
async run() {
|
|
17
|
+
let { subscriptionID } = this;
|
|
18
|
+
subscriptionID = this.ecs.general.decrypt(subscriptionID);
|
|
19
|
+
const c = await this.pgs.fetchSubscription(subscriptionID);
|
|
20
|
+
if (c.active) {
|
|
21
|
+
this.cacheControl = "public, max-age=8600";
|
|
22
|
+
}
|
|
23
|
+
return this.redirect("/store/subscriptions/" + c.subscription.subscriptionID);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
__decorate([
|
|
27
|
+
Route,
|
|
28
|
+
__metadata("design:type", Object)
|
|
29
|
+
], default_1.prototype, "subscriptionID", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
Inject,
|
|
32
|
+
__metadata("design:type", StorePaymentGatewayService)
|
|
33
|
+
], default_1.prototype, "pgs", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
Inject,
|
|
36
|
+
__metadata("design:type", EncryptionService)
|
|
37
|
+
], default_1.prototype, "ecs", void 0);
|
|
38
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../../../src/wwwroot/routes/store/subscribe-callback/[subscriptionID]/get.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,4CAA4C,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,gDAAgD,CAAC;AACvE,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAC5D,OAAO,0BAA0B,MAAM,oEAAoE,CAAC;AAC5G,OAAO,iBAAiB,MAAM,gEAAgE,CAAC;AAG/F,MAAM,CAAC,OAAO,gBAAO,SAAQ,IAAI;IAW7B,KAAK,CAAC,GAAG;QAEL,IAAI,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;QAC9B,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAC1D,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;QAC3D,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,GAAG,sBAAsB,CAAC;QAC/C,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,uBAAuB,GAAG,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IAElF,CAAC;CACJ;AAnBG;IADC,KAAK;;iDACS;AAGf;IADC,MAAM;8BACF,0BAA0B;sCAAC;AAGhC;IADC,MAAM;8BACF,iBAAiB;sCAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@social-mail/social-mail-web-server",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.499",
|
|
4
4
|
"description": "## Phase 1",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@entity-access/entity-access": "^1.0.532",
|
|
26
26
|
"@entity-access/server-pages": "^1.1.578",
|
|
27
27
|
"@parse/node-apn": "^6.5.0",
|
|
28
|
-
"@paypal/paypal-server-sdk": "^1.0
|
|
28
|
+
"@paypal/paypal-server-sdk": "^2.1.0",
|
|
29
29
|
"@peculiar/asn1-schema": "^2.3.15",
|
|
30
30
|
"@social-mail/shared": "^1.0.29",
|
|
31
31
|
"@socket.io/cluster-adapter": "^0.2.2",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"@sunknudsen/totp": "^1.1.0",
|
|
35
35
|
"@web-atoms/fetch-builder": "1.0.21",
|
|
36
36
|
"acme-client": "^5.4.0",
|
|
37
|
+
"cashfree-pg": "^5.1.0",
|
|
37
38
|
"clamscan": "^2.4.0",
|
|
38
39
|
"console-log-colors": "^0.4.0",
|
|
39
40
|
"decimal.js": "^10.6.0",
|
|
@@ -81,6 +81,10 @@ import WebSiteTag from "./entities/WebSiteTag.js";
|
|
|
81
81
|
import AppDbContext from "@entity-access/server-pages/dist/core/AppDbContext.js";
|
|
82
82
|
import AppPassword from "./entities/AppPassword.js";
|
|
83
83
|
import EmailText from "./entities/EmailText.js";
|
|
84
|
+
import StoreSubscription from "./entities/StoreSubscription.js";
|
|
85
|
+
import StorePGSubscription from "./entities/StorePGSubscription.js";
|
|
86
|
+
import WebSiteSubscription from "./entities/WebSiteSubscription.js";
|
|
87
|
+
import StorePGItemPrice from "./entities/StorePGItemPrice.js";
|
|
84
88
|
|
|
85
89
|
@RegisterScoped
|
|
86
90
|
export default class SocialMailContext extends AppDbContext {
|
|
@@ -201,6 +205,8 @@ export default class SocialMailContext extends AppDbContext {
|
|
|
201
205
|
|
|
202
206
|
public storeItemPrices = this.model.register(StoreItemPrice);
|
|
203
207
|
|
|
208
|
+
public storePgItemPrices = this.model.register(StorePGItemPrice);
|
|
209
|
+
|
|
204
210
|
public storePaymentAttempts = this.model.register(StorePaymentAttempt);
|
|
205
211
|
|
|
206
212
|
public storeMediaFiles = this.model.register(StoreMediaFile);
|
|
@@ -229,6 +235,12 @@ export default class SocialMailContext extends AppDbContext {
|
|
|
229
235
|
|
|
230
236
|
public storeItemTags = this.model.register(StoreItemTag);
|
|
231
237
|
|
|
238
|
+
public storeSubscriptions = this.model.register(StoreSubscription);
|
|
239
|
+
|
|
240
|
+
public webSiteSubscriptions = this.model.register(WebSiteSubscription);
|
|
241
|
+
|
|
242
|
+
public storePGSubscriptions = this.model.register(StorePGSubscription);
|
|
243
|
+
|
|
232
244
|
public users = this.model.register(User);
|
|
233
245
|
|
|
234
246
|
public userGroupMembers = this.model.register(UserGroupMember);
|
|
@@ -148,6 +148,12 @@ import AppPassword from "./entities/AppPassword.js";
|
|
|
148
148
|
import AppPasswordEvents from "./events/AppPasswordEvents.js";
|
|
149
149
|
import EmailText from "./entities/EmailText.js";
|
|
150
150
|
import EmailTextEvents from "./events/EmailTextEvents.js";
|
|
151
|
+
import StoreSubscription from "./entities/StoreSubscription.js";
|
|
152
|
+
import StoreSubscriptionEvents from "./events/StoreSubscriptionEvents.js";
|
|
153
|
+
import StorePGSubscription from "./entities/StorePGSubscription.js";
|
|
154
|
+
import StorePGSubscriptionEvents from "./events/StorePGSubscriptionEvents.js";
|
|
155
|
+
import StorePGItemPrice from "./entities/StorePGItemPrice.js";
|
|
156
|
+
import StorePGItemPriceEvents from "./events/StorePGItemPriceEvents.js";
|
|
151
157
|
|
|
152
158
|
|
|
153
159
|
@RegisterSingleton
|
|
@@ -214,9 +220,13 @@ export default class SocialMailContextEvents extends ContextEvents {
|
|
|
214
220
|
this.register(StoreJournalLineItem, StoreJournalLineItemEvents);
|
|
215
221
|
this.register(StoreItemFolder, StoreItemFolderEvents);
|
|
216
222
|
this.register(StoreItemFolderTag, StoreItemFolderTagEvents);
|
|
223
|
+
this.register(StorePGItemPrice, StorePGItemPriceEvents);
|
|
217
224
|
this.register(StoreMediaFile, StoreMediaFileEvents);
|
|
218
225
|
this.register(StoreItemTax, StoreItemTaxEvents);
|
|
219
226
|
this.register(StoreTag, StoreTagEvents);
|
|
227
|
+
|
|
228
|
+
this.register(StoreSubscription, StoreSubscriptionEvents);
|
|
229
|
+
this.register(StorePGSubscription, StorePGSubscriptionEvents);
|
|
220
230
|
// this.register(StorePriceAddOn, StorePriceAddOnEvents);
|
|
221
231
|
// this.register(StoreBill, StoreOrderEvents);
|
|
222
232
|
// this.register(StoreBillLine, StoreOrderItemEvents);
|
|
@@ -9,6 +9,7 @@ import type Contact from "./Contact.js";
|
|
|
9
9
|
import type EmailTemplate from "./EmailTemplate.js";
|
|
10
10
|
import { JsonProperty } from "@entity-access/server-pages/dist/services/ModelService.js";
|
|
11
11
|
import type { WebSiteChannelDomain } from "./WebSiteChannelDomain.js";
|
|
12
|
+
import type WebSiteSubscription from "./WebSiteSubscription.js";
|
|
12
13
|
|
|
13
14
|
@Table("HostedDomains")
|
|
14
15
|
export class HostedDomain {
|
|
@@ -62,5 +63,6 @@ export class HostedDomain {
|
|
|
62
63
|
public domainNameToCreate: string;
|
|
63
64
|
|
|
64
65
|
websiteChannelDomains: WebSiteChannelDomain[];
|
|
66
|
+
webSiteSubscriptions: WebSiteSubscription[];
|
|
65
67
|
|
|
66
68
|
}
|
|
@@ -15,6 +15,7 @@ import type StoreAccountPhone from "./StoreAccountPhone.js";
|
|
|
15
15
|
import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
|
|
16
16
|
import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
|
|
17
17
|
import type StorePaymentGateway from "./StorePaymentGateway.js";
|
|
18
|
+
import type StoreSubscription from "./StoreSubscription.js";
|
|
18
19
|
|
|
19
20
|
@Table("StoreAccounts")
|
|
20
21
|
@CheckConstraint({
|
|
@@ -145,4 +146,5 @@ export class StoreAccount {
|
|
|
145
146
|
emails: StoreAccountEmail[];
|
|
146
147
|
phones: StoreAccountPhone[];
|
|
147
148
|
storePaymentGateway: StorePaymentGateway;
|
|
149
|
+
boughtSubscriptions: StoreSubscription[];
|
|
148
150
|
}
|
|
@@ -17,7 +17,7 @@ import WebSite from "./WebSite.js";
|
|
|
17
17
|
import type StoreCoupon from "./StoreCoupon.js";
|
|
18
18
|
import type WebHook from "./WebHook.js";
|
|
19
19
|
|
|
20
|
-
export const itemTypeArray = ["product", "e-product", "shipping", "service", "tax", "fee", "commission", "variant", "size"] as const;
|
|
20
|
+
export const itemTypeArray = ["product", "e-product", "website", "shipping", "service", "tax", "fee", "commission", "variant", "size"] as const;
|
|
21
21
|
export type itemTypeArrayType = typeof itemTypeArray[number];
|
|
22
22
|
|
|
23
23
|
export const itemUnitTypeArray = ["year", "month", "kg", "lbs"] as const;
|
|
@@ -7,6 +7,15 @@ import { ReadOnlyJsonProperty } from "@entity-access/server-pages/dist/services/
|
|
|
7
7
|
import { StoreJournalLineItem } from "./StoreJournalLineItem.js";
|
|
8
8
|
import { StoreItem } from "./StoreItem.js";
|
|
9
9
|
import Index from "@entity-access/entity-access/dist/decorators/Index.js";
|
|
10
|
+
import type StoreSubscription from "./StoreSubscription.js";
|
|
11
|
+
|
|
12
|
+
const subscriptionTypeArray = [ "none", "on-demand", "periodic"] as const;
|
|
13
|
+
export type subscriptionTypeArrayType = typeof subscriptionTypeArray[number];
|
|
14
|
+
|
|
15
|
+
const intervalTypeArray = [ "none", "day", "month", "year", "week"] as const;
|
|
16
|
+
export type intervalTypeArrayType = typeof intervalTypeArray[number];
|
|
17
|
+
|
|
18
|
+
|
|
10
19
|
|
|
11
20
|
@Table("StoreItemPrices")
|
|
12
21
|
@Index({
|
|
@@ -58,6 +67,15 @@ export class StoreItemPrice {
|
|
|
58
67
|
@Column({ dataType: "Decimal", nullable: true })
|
|
59
68
|
maxAmount: number;
|
|
60
69
|
|
|
70
|
+
@Column({ dataType: "Char", length: 20, enum: subscriptionTypeArray, default: () => "none"})
|
|
71
|
+
type: subscriptionTypeArrayType;
|
|
72
|
+
|
|
73
|
+
@Column({ dataType: "Char", length: 40, enum: intervalTypeArray, default: () => "none"})
|
|
74
|
+
intervalType: intervalTypeArrayType;
|
|
75
|
+
|
|
76
|
+
@Column({ dataType: "Int", default: () => 1})
|
|
77
|
+
interval: number;
|
|
78
|
+
|
|
61
79
|
@Column({ dataType: "Decimal", default:() => 1 })
|
|
62
80
|
maxQuantity: number;
|
|
63
81
|
|
|
@@ -73,6 +91,7 @@ export class StoreItemPrice {
|
|
|
73
91
|
|
|
74
92
|
storeItem: StoreItem;
|
|
75
93
|
lineItems: StoreJournalLineItem[];
|
|
94
|
+
subscriptions: StoreSubscription[];
|
|
76
95
|
// storeOrderItems: StoreBillLine[];
|
|
77
96
|
|
|
78
97
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Column from "@entity-access/entity-access/dist/decorators/Column.js";
|
|
2
|
+
import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js";
|
|
3
|
+
import Table from "@entity-access/entity-access/dist/decorators/Table.js";
|
|
4
|
+
import StorePaymentGateway from "./StorePaymentGateway.js";
|
|
5
|
+
|
|
6
|
+
@Table("StorePgItemPrices")
|
|
7
|
+
export default class StorePGItemPrice {
|
|
8
|
+
|
|
9
|
+
@Column({ dataType: "BigInt", key: true })
|
|
10
|
+
itemPriceID: number;
|
|
11
|
+
|
|
12
|
+
@Column({ dataType: "BigInt", key: true })
|
|
13
|
+
@RelateTo(StorePaymentGateway, {
|
|
14
|
+
property: (x) => x.gateway,
|
|
15
|
+
inverseProperty: (x) => x.pgItemPrices
|
|
16
|
+
})
|
|
17
|
+
paymentGatewayID: number;
|
|
18
|
+
|
|
19
|
+
gateway: StorePaymentGateway;
|
|
20
|
+
|
|
21
|
+
@Column({ dataType: "Char", length: 400})
|
|
22
|
+
pgPriceID: string;
|
|
23
|
+
|
|
24
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import Column from "@entity-access/entity-access/dist/decorators/Column.js";
|
|
2
|
+
import Index from "@entity-access/entity-access/dist/decorators/Index.js";
|
|
3
|
+
import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js";
|
|
4
|
+
import Table from "@entity-access/entity-access/dist/decorators/Table.js";
|
|
5
|
+
import StorePaymentGateway from "./StorePaymentGateway.js";
|
|
6
|
+
import StoreSubscription from "./StoreSubscription.js";
|
|
7
|
+
|
|
8
|
+
@Table("StorePgSubscriptions")
|
|
9
|
+
@Index({
|
|
10
|
+
name: "UX_StorePgSubscription_Active",
|
|
11
|
+
columns: [
|
|
12
|
+
{ name: (x) => x.subscriptionID, descending: true },
|
|
13
|
+
],
|
|
14
|
+
unique: true,
|
|
15
|
+
filter: (x) => x.active === true
|
|
16
|
+
})
|
|
17
|
+
export default class StorePGSubscription {
|
|
18
|
+
|
|
19
|
+
@Column({ dataType: "BigInt", key: true })
|
|
20
|
+
@RelateTo(StoreSubscription, {
|
|
21
|
+
property: (x) => x.subscription,
|
|
22
|
+
inverseProperty: (x) => x.storePGSubscriptions
|
|
23
|
+
})
|
|
24
|
+
subscriptionID: number;
|
|
25
|
+
|
|
26
|
+
@Column({ dataType: "BigInt", key: true })
|
|
27
|
+
@RelateTo(StorePaymentGateway, {
|
|
28
|
+
property: (x) => x.gateway,
|
|
29
|
+
inverseProperty: (x) => x.pgSubscriptions
|
|
30
|
+
})
|
|
31
|
+
paymentGatewayID: number;
|
|
32
|
+
|
|
33
|
+
@Column({ dataType:"Char", length: 200, nullable: true})
|
|
34
|
+
gatewaySubscriptionID: string;
|
|
35
|
+
|
|
36
|
+
@Column({ dataType: "Boolean", default: () => false })
|
|
37
|
+
active: boolean;
|
|
38
|
+
|
|
39
|
+
gateway: StorePaymentGateway;
|
|
40
|
+
subscription: StoreSubscription;
|
|
41
|
+
|
|
42
|
+
@Column({ dataType: "Char", length: 50, nullable: true })
|
|
43
|
+
status: string;
|
|
44
|
+
|
|
45
|
+
@Column({ dataType: "Char", nullable: true})
|
|
46
|
+
details: string;
|
|
47
|
+
|
|
48
|
+
}
|
|
@@ -7,8 +7,10 @@ import Index from "@entity-access/entity-access/dist/decorators/Index.js";
|
|
|
7
7
|
import type StorePaymentAttempt from "./StorePaymentAttempt.js";
|
|
8
8
|
import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
|
|
9
9
|
import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
|
|
10
|
+
import type StorePGSubscription from "./StorePGSubscription.js";
|
|
11
|
+
import type StorePGItemPrice from "./StorePGItemPrice.js";
|
|
10
12
|
|
|
11
|
-
const gatewayTypeArray = [ "paypal", "phone-pe", "stripe"] as const;
|
|
13
|
+
const gatewayTypeArray = [ "paypal", "phone-pe", "stripe", "cashfree"] as const;
|
|
12
14
|
export type gatewayType = typeof gatewayTypeArray[number];
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -90,5 +92,7 @@ export default class StorePaymentGateway {
|
|
|
90
92
|
|
|
91
93
|
storeAccount: StoreAccount;
|
|
92
94
|
paymentAttempts: StorePaymentAttempt[];
|
|
95
|
+
pgSubscriptions: StorePGSubscription[];
|
|
96
|
+
pgItemPrices: StorePGItemPrice[];
|
|
93
97
|
|
|
94
98
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import Column from "@entity-access/entity-access/dist/decorators/Column.js";
|
|
2
|
+
import Table from "@entity-access/entity-access/dist/decorators/Table.js";
|
|
3
|
+
import WebSite from "./WebSite.js";
|
|
4
|
+
import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js";
|
|
5
|
+
import { StoreAccount } from "./StoreAccount.js";
|
|
6
|
+
import { StoreItemPrice } from "./StoreItemPrice.js";
|
|
7
|
+
import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
|
|
8
|
+
import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
|
|
9
|
+
import type WebSiteSubscription from "./WebSiteSubscription.js";
|
|
10
|
+
import type StorePGSubscription from "./StorePGSubscription.js";
|
|
11
|
+
|
|
12
|
+
const subscriptionStatusArray = [ "active", "pending", "cancelled"] as const;
|
|
13
|
+
export type subscriptionStatusArrayType = typeof subscriptionStatusArray[number];
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* There will be one subscription per one product, customer will have multiple active subscriptions.
|
|
18
|
+
* This is easier to maintain.
|
|
19
|
+
*
|
|
20
|
+
* The reason this class exists as we can switch between payment providers in future and still maintain
|
|
21
|
+
* the history as it is. The worker can fetch active subscriptions instead of webhook to activate/deactivate
|
|
22
|
+
* plans.
|
|
23
|
+
*/
|
|
24
|
+
@Table("StoreSubscriptions")
|
|
25
|
+
export default class StoreSubscription {
|
|
26
|
+
|
|
27
|
+
@Column({ dataType: "BigInt", key: true, generated: "identity"})
|
|
28
|
+
public subscriptionID: number;
|
|
29
|
+
|
|
30
|
+
@Column({ dataType: "BigInt"})
|
|
31
|
+
@RelateTo(WebSite, {
|
|
32
|
+
property: (x) => x.store,
|
|
33
|
+
inverseProperty: (x) => x.subscriptions
|
|
34
|
+
})
|
|
35
|
+
public storeID: number;
|
|
36
|
+
|
|
37
|
+
@Column({ dataType: "BigInt" ,nullable: true })
|
|
38
|
+
@RelateTo(StoreAccount, {
|
|
39
|
+
property: (x) => x.buyer,
|
|
40
|
+
inverseProperty: (x) => x.boughtSubscriptions,
|
|
41
|
+
foreignKeyConstraint: {
|
|
42
|
+
name: "FC_Subscription_BuyerID",
|
|
43
|
+
onDelete: "restrict"
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
buyerID: number;
|
|
47
|
+
|
|
48
|
+
@Column({ dataType: "BigInt"})
|
|
49
|
+
@RelateTo(StoreItemPrice, {
|
|
50
|
+
property: (x) => x.itemPrice,
|
|
51
|
+
inverseProperty: (x) => x.subscriptions
|
|
52
|
+
})
|
|
53
|
+
itemPriceID: number;
|
|
54
|
+
|
|
55
|
+
@Column({ dataType: "DateTime", default: () => Sql.date.now()})
|
|
56
|
+
dateCreated: DateTime;
|
|
57
|
+
|
|
58
|
+
@Column({ dataType: "DateTime", default: () => Sql.date.now()})
|
|
59
|
+
dateUpdated: DateTime;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Check every 15 days...
|
|
63
|
+
*/
|
|
64
|
+
@Column({ dataType: "DateTime", default: () => Sql.date.addDays(Sql.date.now(), 1)})
|
|
65
|
+
refreshTime: DateTime;
|
|
66
|
+
|
|
67
|
+
@Column({ dataType: "Char", length: 20, default: () => "pending"})
|
|
68
|
+
status: subscriptionStatusArrayType;
|
|
69
|
+
|
|
70
|
+
store: WebSite;
|
|
71
|
+
buyer: StoreAccount;
|
|
72
|
+
itemPrice: StoreItemPrice;
|
|
73
|
+
webSiteSubscriptions: WebSiteSubscription[];
|
|
74
|
+
storePGSubscriptions: StorePGSubscription[];
|
|
75
|
+
}
|
|
@@ -20,6 +20,8 @@ import type { WebSiteVersion } from "./WebSiteVersion.js";
|
|
|
20
20
|
import type { WebSiteHost } from "./WebSiteHost.js";
|
|
21
21
|
import type WebSiteTag from "./WebSiteTag.js";
|
|
22
22
|
import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
|
|
23
|
+
import type StoreSubscription from "./StoreSubscription.js";
|
|
24
|
+
import type WebSiteSubscription from "./WebSiteSubscription.js";
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Index Designs...
|
|
@@ -187,6 +189,8 @@ export default class WebSite {
|
|
|
187
189
|
webHooks: WebHook[];
|
|
188
190
|
channelDomains: WebSiteChannelDomain[];
|
|
189
191
|
webSiteTags: WebSiteTag[];
|
|
192
|
+
subscriptions: StoreSubscription[];
|
|
193
|
+
webSiteSubscription: WebSiteSubscription;
|
|
190
194
|
|
|
191
195
|
}
|
|
192
196
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import Column from "@entity-access/entity-access/dist/decorators/Column.js";
|
|
2
|
+
import { RelateTo, RelateToOne } from "@entity-access/entity-access/dist/decorators/Relate.js";
|
|
3
|
+
import Table from "@entity-access/entity-access/dist/decorators/Table.js";
|
|
4
|
+
import WebSite from "./WebSite.js";
|
|
5
|
+
import StoreSubscription from "./StoreSubscription.js";
|
|
6
|
+
import { HostedDomain } from "./HostedDomain.js";
|
|
7
|
+
|
|
8
|
+
@Table("WebSiteSubscriptions")
|
|
9
|
+
export default class WebSiteSubscription {
|
|
10
|
+
|
|
11
|
+
@Column({ dataType: "BigInt", key: true})
|
|
12
|
+
@RelateTo(StoreSubscription, {
|
|
13
|
+
property: (x) => x.subscription,
|
|
14
|
+
inverseProperty: (x) => x.webSiteSubscriptions,
|
|
15
|
+
foreignKeyConstraint: {
|
|
16
|
+
name: "FK_WebSiteSubscriptions_SubscriptionID",
|
|
17
|
+
onDelete: "restrict"
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
subscriptionID: number;
|
|
21
|
+
|
|
22
|
+
@Column({ dataType: "BigInt", key: true})
|
|
23
|
+
@RelateToOne(WebSite, {
|
|
24
|
+
property: (x) => x.webSite,
|
|
25
|
+
inverseProperty: (x) => x.webSiteSubscription,
|
|
26
|
+
foreignKeyConstraint: {
|
|
27
|
+
name: "FK_WebSiteSubscriptions_WebSiteID",
|
|
28
|
+
onDelete: "restrict"
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
webSiteID: number;
|
|
32
|
+
|
|
33
|
+
@Column({ dataType: "BigInt", nullable: true})
|
|
34
|
+
@RelateTo(HostedDomain, {
|
|
35
|
+
property: (x) => x.hostedDomain,
|
|
36
|
+
inverseProperty: (x) => x.webSiteSubscriptions
|
|
37
|
+
})
|
|
38
|
+
hostedDomainID: string;
|
|
39
|
+
|
|
40
|
+
webSite: WebSite;
|
|
41
|
+
subscription: StoreSubscription;
|
|
42
|
+
hostedDomain: HostedDomain;
|
|
43
|
+
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IEntityQuery } from "@entity-access/entity-access/dist/model/IFilterWithParameter.js";
|
|
2
|
+
import StorePGSubscription from "../entities/StorePGSubscription.js";
|
|
3
|
+
import AuthenticatedEvents from "./AuthenticatedEvents.js";
|
|
4
|
+
import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
|
|
5
|
+
|
|
6
|
+
export default class StorePGSubscriptionEvents extends AuthenticatedEvents<StorePGSubscription> {
|
|
7
|
+
|
|
8
|
+
filter(query: IEntityQuery<StorePGSubscription>) {
|
|
9
|
+
if(this.sessionUser.isAdmin) {
|
|
10
|
+
return query;
|
|
11
|
+
}
|
|
12
|
+
return query.where(this.sessionUser, (p) => (x) => x.subscription.buyerID === p.userID
|
|
13
|
+
|| Sql.text.likeAny(x.subscription.store.folder.path, p.readFileAccess)
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IEntityQuery } from "@entity-access/entity-access/dist/model/IFilterWithParameter.js";
|
|
2
|
+
import AuthenticatedEvents from "./AuthenticatedEvents.js";
|
|
3
|
+
import StoreSubscription from "../entities/StoreSubscription.js";
|
|
4
|
+
import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
|
|
5
|
+
|
|
6
|
+
export default class StoreSubscriptionEvents extends AuthenticatedEvents<StoreSubscription> {
|
|
7
|
+
|
|
8
|
+
filter(query: IEntityQuery<StoreSubscription>) {
|
|
9
|
+
if (this.sessionUser.isAdmin) {
|
|
10
|
+
return query;
|
|
11
|
+
}
|
|
12
|
+
return query.where(this.sessionUser, (p) => (x) => x.buyerID === p.userID
|
|
13
|
+
|| Sql.text.likeAny(x.store.folder.path, p.readFileAccess));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|