@mj-biz-apps/orders-server 5.17.0 → 5.18.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.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @fileoverview `Orders: Enforce Payment-Gated Access` — the nightly pass for bc-aidp-next-golive#223.
3
+ *
4
+ * A renewal goes past its cutoff with nothing being written; only a day passes. The payment path
5
+ * moves grants when cash moves, and this is the caller for the other half: MJ's scheduler dispatches
6
+ * Actions, so the Action is how the clock reaches `EnforcePaymentGatedAccess`.
7
+ *
8
+ * NO ACCESS LOGIC LIVES HERE. Candidate selection, the decision and the writes are all in
9
+ * `PaymentGatedAccess.ts`; this reads parameters, calls it, and reports what came back.
10
+ *
11
+ * PREVIEW IS A PARAMETER. The scheduled job ships set to Preview, so the first runs report what they
12
+ * would suspend and write nothing. Setting Preview to false is the act that starts cutting access.
13
+ *
14
+ * @module @mj-biz-apps/orders-server
15
+ */
16
+ import { BaseAction } from '@memberjunction/actions';
17
+ import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
18
+ /**
19
+ * Suspend renewals past the cutoff and restore grants whose payment has arrived.
20
+ *
21
+ * Inputs: `AsOfDate`, `Preview`, `MaxCount` — all optional.
22
+ * Outputs: `Activated`, `Suspended`, `Changes`, `Failures`, `PreviewedOnly`.
23
+ */
24
+ export declare class EnforcePaymentGatedAccessAction extends BaseAction {
25
+ /** An action must not throw at its caller — same reasoning as the other hand-authored actions. */
26
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
27
+ private enforce;
28
+ }
29
+ /** Tree-shaking anchor — without it the decorator never runs and the action has nothing behind it. */
30
+ export declare function LoadEnforcePaymentGatedAccessAction(): void;
31
+ //# sourceMappingURL=enforce-payment-gated-access.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enforce-payment-gated-access.action.d.ts","sourceRoot":"","sources":["../../src/custom/enforce-payment-gated-access.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAe,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AA0BrG;;;;;GAKG;AACH,qBACa,+BAAgC,SAAQ,UAAU;IAC3D,kGAAkG;cAClF,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAQzE,OAAO;CAkDxB;AAED,sGAAsG;AACtG,wBAAgB,mCAAmC,IAAI,IAAI,CAE1D"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @fileoverview `Orders: Enforce Payment-Gated Access` — the nightly pass for bc-aidp-next-golive#223.
3
+ *
4
+ * A renewal goes past its cutoff with nothing being written; only a day passes. The payment path
5
+ * moves grants when cash moves, and this is the caller for the other half: MJ's scheduler dispatches
6
+ * Actions, so the Action is how the clock reaches `EnforcePaymentGatedAccess`.
7
+ *
8
+ * NO ACCESS LOGIC LIVES HERE. Candidate selection, the decision and the writes are all in
9
+ * `PaymentGatedAccess.ts`; this reads parameters, calls it, and reports what came back.
10
+ *
11
+ * PREVIEW IS A PARAMETER. The scheduled job ships set to Preview, so the first runs report what they
12
+ * would suspend and write nothing. Setting Preview to false is the act that starts cutting access.
13
+ *
14
+ * @module @mj-biz-apps/orders-server
15
+ */
16
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
17
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
18
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
19
+ 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;
20
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
21
+ };
22
+ import { BaseAction } from '@memberjunction/actions';
23
+ import { Metadata } from '@memberjunction/core';
24
+ import { RegisterClass } from '@memberjunction/global';
25
+ import { EnforcePaymentGatedAccess } from '@mj-biz-apps/orders-core-entities-server';
26
+ function param(params, name) {
27
+ const raw = params.Params?.find((p) => p.Name?.toLowerCase() === name.toLowerCase())?.Value;
28
+ if (raw == null)
29
+ return null;
30
+ const value = String(raw).trim();
31
+ // A scheduler writes an unset parameter as an empty string, so blank is absent.
32
+ return value.length ? value : null;
33
+ }
34
+ function setOutput(params, name, value) {
35
+ const existing = params.Params?.find((p) => p.Name?.toLowerCase() === name.toLowerCase());
36
+ if (existing) {
37
+ existing.Value = value;
38
+ existing.Type = 'Output';
39
+ return;
40
+ }
41
+ params.Params = params.Params ?? [];
42
+ params.Params.push({ Name: name, Value: value, Type: 'Output' });
43
+ }
44
+ const refuse = (ResultCode, Message) => ({ Success: false, ResultCode, Message });
45
+ /**
46
+ * Suspend renewals past the cutoff and restore grants whose payment has arrived.
47
+ *
48
+ * Inputs: `AsOfDate`, `Preview`, `MaxCount` — all optional.
49
+ * Outputs: `Activated`, `Suspended`, `Changes`, `Failures`, `PreviewedOnly`.
50
+ */
51
+ let EnforcePaymentGatedAccessAction = class EnforcePaymentGatedAccessAction extends BaseAction {
52
+ /** An action must not throw at its caller — same reasoning as the other hand-authored actions. */
53
+ async InternalRunAction(params) {
54
+ try {
55
+ return await this.enforce(params);
56
+ }
57
+ catch (error) {
58
+ return refuse('ERROR', `The payment-gated access pass failed: ${error instanceof Error ? error.message : String(error)}`);
59
+ }
60
+ }
61
+ async enforce(params) {
62
+ const user = params.ContextUser;
63
+ if (!user)
64
+ return refuse('NO_CONTEXT_USER', 'ContextUser is required: suspending access has to be attributable to somebody.');
65
+ const input = {};
66
+ const asOf = param(params, 'AsOfDate');
67
+ if (asOf !== null) {
68
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(asOf) || Number.isNaN(new Date(asOf).getTime())) {
69
+ return refuse('INVALID_AS_OF_DATE', `'${asOf}' is not a date. AsOfDate takes YYYY-MM-DD, and is omitted for "today".`);
70
+ }
71
+ input.AsOfDate = asOf;
72
+ }
73
+ const preview = param(params, 'Preview');
74
+ if (preview !== null) {
75
+ // Refused rather than guessed: the wrong guess suspends customers.
76
+ const v = preview.toLowerCase();
77
+ if (['true', '1', 'yes', 'y'].includes(v))
78
+ input.Preview = true;
79
+ else if (['false', '0', 'no', 'n'].includes(v))
80
+ input.Preview = false;
81
+ else
82
+ return refuse('INVALID_PREVIEW', `Preview takes true or false — got '${preview}'.`);
83
+ }
84
+ const maxCount = param(params, 'MaxCount');
85
+ if (maxCount !== null) {
86
+ const n = Number(maxCount);
87
+ if (!Number.isInteger(n) || n < 1) {
88
+ return refuse('INVALID_MAX_COUNT', `MaxCount must be a whole number of at least 1 — got '${maxCount}'.`);
89
+ }
90
+ input.MaxCount = n;
91
+ }
92
+ const provider = params.Provider ?? Metadata.Provider;
93
+ const output = await EnforcePaymentGatedAccess(input, provider, user);
94
+ setOutput(params, 'Activated', output.Activated);
95
+ setOutput(params, 'Suspended', output.Suspended);
96
+ setOutput(params, 'Changes', output.Changes);
97
+ setOutput(params, 'Failures', output.Failures);
98
+ // Not named `Preview`: an output overwrites the param row of the same name, and whether a
99
+ // run was a rehearsal is the one fact the run record has to keep.
100
+ setOutput(params, 'PreviewedOnly', input.Preview === true);
101
+ return {
102
+ Success: output.Success,
103
+ ResultCode: !output.Success ? 'PARTIAL' : input.Preview ? 'PREVIEWED' : 'COMPLETED',
104
+ Params: params.Params,
105
+ Message: output.Message ?? '',
106
+ };
107
+ }
108
+ };
109
+ EnforcePaymentGatedAccessAction = __decorate([
110
+ RegisterClass(BaseAction, 'Orders.EnforcePaymentGatedAccess')
111
+ ], EnforcePaymentGatedAccessAction);
112
+ export { EnforcePaymentGatedAccessAction };
113
+ /** Tree-shaking anchor — without it the decorator never runs and the action has nothing behind it. */
114
+ export function LoadEnforcePaymentGatedAccessAction() {
115
+ void EnforcePaymentGatedAccessAction;
116
+ }
117
+ //# sourceMappingURL=enforce-payment-gated-access.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enforce-payment-gated-access.action.js","sourceRoot":"","sources":["../../src/custom/enforce-payment-gated-access.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAA0B,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAuC,MAAM,0CAA0C,CAAC;AAE1H,SAAS,KAAK,CAAC,MAAuB,EAAE,IAAY;IAChD,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,KAAK,CAAC;IAC5F,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,gFAAgF;IAChF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACvC,CAAC;AAED,SAAS,SAAS,CAAC,MAAuB,EAAE,IAAY,EAAE,KAAc;IACpE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC1F,IAAI,QAAQ,EAAE,CAAC;QACX,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QACvB,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC;QACzB,OAAO;IACX,CAAC;IACD,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,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E,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACjD,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACjD,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7C,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/C,0FAA0F;QAC1F,kEAAkE;QAClE,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;QAE3D,OAAO;YACH,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,UAAU,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;YACnF,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE;SAChC,CAAC;IACN,CAAC;CACJ,CAAA;AA5DY,+BAA+B;IAD3C,aAAa,CAAC,UAAU,EAAE,kCAAkC,CAAC;GACjD,+BAA+B,CA4D3C;;AAED,sGAAsG;AACtG,MAAM,UAAU,mCAAmC;IAC/C,KAAK,+BAA+B,CAAC;AACzC,CAAC"}
@@ -504,6 +504,9 @@ export declare class mjBizAppsOrdersEntitlementGrant_ {
504
504
  RevocationReason?: string;
505
505
  _mj__CreatedAt: Date;
506
506
  _mj__UpdatedAt: Date;
507
+ GrantTimingApplied?: string;
508
+ SuspendedAt?: Date;
509
+ SuspensionReason?: string;
507
510
  ProductEntitlement?: string;
508
511
  Subscription?: string;
509
512
  BeneficiaryPerson?: string;
@@ -526,6 +529,9 @@ export declare class CreatemjBizAppsOrdersEntitlementGrantInput {
526
529
  SubscriptionTermID: string | null;
527
530
  RevokedAt: Date | null;
528
531
  RevocationReason: string | null;
532
+ GrantTimingApplied: string | null;
533
+ SuspendedAt: Date | null;
534
+ SuspensionReason: string | null;
529
535
  RestoreContext___?: RestoreContextInput;
530
536
  }
531
537
  export declare class UpdatemjBizAppsOrdersEntitlementGrantInput {
@@ -544,6 +550,9 @@ export declare class UpdatemjBizAppsOrdersEntitlementGrantInput {
544
550
  SubscriptionTermID?: string | null;
545
551
  RevokedAt?: Date | null;
546
552
  RevocationReason?: string | null;
553
+ GrantTimingApplied?: string | null;
554
+ SuspendedAt?: Date | null;
555
+ SuspensionReason?: string | null;
547
556
  OldValues___?: KeyValuePairInput[];
548
557
  RestoreContext___?: RestoreContextInput;
549
558
  }
@@ -1797,6 +1806,7 @@ export declare class mjBizAppsOrdersPaymentHeader_ {
1797
1806
  IdempotencyKey?: string;
1798
1807
  _mj__CreatedAt: Date;
1799
1808
  _mj__UpdatedAt: Date;
1809
+ ReversalSource?: string;
1800
1810
  ReceivingCompany?: string;
1801
1811
  BillToPerson?: string;
1802
1812
  BillToOrganization?: string;
@@ -1831,6 +1841,7 @@ export declare class CreatemjBizAppsOrdersPaymentHeaderInput {
1831
1841
  Description: string | null;
1832
1842
  Notes: string | null;
1833
1843
  IdempotencyKey: string | null;
1844
+ ReversalSource: string | null;
1834
1845
  RestoreContext___?: RestoreContextInput;
1835
1846
  }
1836
1847
  export declare class UpdatemjBizAppsOrdersPaymentHeaderInput {
@@ -1856,6 +1867,7 @@ export declare class UpdatemjBizAppsOrdersPaymentHeaderInput {
1856
1867
  Description?: string | null;
1857
1868
  Notes?: string | null;
1858
1869
  IdempotencyKey?: string | null;
1870
+ ReversalSource?: string | null;
1859
1871
  OldValues___?: KeyValuePairInput[];
1860
1872
  RestoreContext___?: RestoreContextInput;
1861
1873
  }