@mj-biz-apps/contracts-actions 0.11.0 → 0.12.1

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/index.d.ts CHANGED
@@ -1,31 +1,3 @@
1
- /**
2
- * @mj-biz-apps/contracts-actions — the app's ACTIONS package (OPTIONAL — delete the
3
- * package + its manifest entry if your app exposes no Actions).
4
- *
5
- * Actions are metadata-driven integration points for agents / workflows /
6
- * low-code — NOT for code-to-code calls (import classes directly for that).
7
- *
8
- * WHAT LIVES HERE
9
- * src/generated/ — CodeGen ActionSubclasses output (do not hand-edit)
10
- * src/ — your hand-written BaseAction subclasses
11
- *
12
- * EXAMPLE — a hand-written action (uncomment once @memberjunction/* deps are
13
- * present in your workspace, register the action row via metadata + a
14
- * migration, then run codegen):
15
- *
16
- * import { RegisterClass } from '@memberjunction/global';
17
- * import { BaseAction } from '@memberjunction/actions';
18
- * import { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
19
- *
20
- * @RegisterClass(BaseAction, 'MJ_BizApps_Contracts: Do Something')
21
- * export class DoSomethingAction extends BaseAction {
22
- * protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
23
- * return { Success: true, ResultCode: 'SUCCESS' };
24
- * }
25
- * }
26
- *
27
- * The Load function below is imported by the server bootstrap so bundlers
28
- * cannot tree-shake the @RegisterClass side effects away.
29
- */
1
+ export { RECORD_NON_RENEWAL_OUTCOMES_SQL, RecordNonRenewalOutcomesAction } from './record-nonrenewal-outcomes.action.js';
30
2
  export declare function LoadMjBizappsContractsActions(): void;
31
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,+BAA+B,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAEzH,wBAAgB,6BAA6B,IAAI,IAAI,CAGpD"}
package/dist/index.js CHANGED
@@ -27,7 +27,10 @@
27
27
  * The Load function below is imported by the server bootstrap so bundlers
28
28
  * cannot tree-shake the @RegisterClass side effects away.
29
29
  */
30
+ import { LoadRecordNonRenewalOutcomesAction } from './record-nonrenewal-outcomes.action.js';
31
+ export { RECORD_NON_RENEWAL_OUTCOMES_SQL, RecordNonRenewalOutcomesAction } from './record-nonrenewal-outcomes.action.js';
30
32
  export function LoadMjBizappsContractsActions() {
31
- // No-op: importing this module registers the action classes above.
33
+ // Importing this module registers the action classes; the call keeps bundlers from dropping them.
34
+ LoadRecordNonRenewalOutcomesAction();
32
35
  }
33
36
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,6BAA6B;IACzC,mEAAmE;AACvE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,kCAAkC,EAAE,MAAM,wCAAwC,CAAC;AAE5F,OAAO,EAAE,+BAA+B,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAEzH,MAAM,UAAU,6BAA6B;IACzC,kGAAkG;IAClG,kCAAkC,EAAE,CAAC;AACzC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @fileoverview `Contracts.RecordNonRenewalOutcomes` — records the renewal-risk label on contracts whose
3
+ * end date has passed (issue #159).
4
+ *
5
+ * `Contract.NonRenewalOutcome` is a stored column. The database writes it on every save (a trigger) and
6
+ * holds the rule in one function, so a termination or a supersession is recorded by the save that makes
7
+ * it. An expiry has no save behind it: the end date passes. This action runs the procedure that applies
8
+ * the same rule to every row whose stored value differs from it today, and a scheduled job runs it hourly.
9
+ *
10
+ * The rule stays in SQL, in `fnContractNonRenewalOutcome`. This file only calls it.
11
+ *
12
+ * @module @mj-biz-apps/contracts-actions
13
+ */
14
+ import { BaseAction } from '@memberjunction/actions';
15
+ import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
16
+ import { type PlatformSQL } from '@memberjunction/core';
17
+ /**
18
+ * The call, one form per database. SQL Server: a procedure that ends with `SELECT @Changed AS Changed`.
19
+ * PostgreSQL: a function of the same name returning the count. The schema is unquoted and the function
20
+ * name quoted, the converter's convention (see `ASSIGN_CONTRACT_NUMBER_SQL` in CoreEntitiesServer).
21
+ */
22
+ export declare const RECORD_NON_RENEWAL_OUTCOMES_SQL: PlatformSQL;
23
+ export declare class RecordNonRenewalOutcomesAction extends BaseAction {
24
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
25
+ }
26
+ /** Anti-tree-shaking anchor — `@RegisterClass` is a side effect of import. */
27
+ export declare function LoadRecordNonRenewalOutcomesAction(): void;
28
+ //# sourceMappingURL=record-nonrenewal-outcomes.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-nonrenewal-outcomes.action.d.ts","sourceRoot":"","sources":["../src/record-nonrenewal-outcomes.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAe,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAuC,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAG7F;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,EAAE,WAG7C,CAAC;AAYF,qBACa,8BAA+B,SAAQ,UAAU;cAC1C,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA0B1F;AAED,8EAA8E;AAC9E,wBAAgB,kCAAkC,IAAI,IAAI,CAEzD"}
@@ -0,0 +1,73 @@
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
+ /**
8
+ * @fileoverview `Contracts.RecordNonRenewalOutcomes` — records the renewal-risk label on contracts whose
9
+ * end date has passed (issue #159).
10
+ *
11
+ * `Contract.NonRenewalOutcome` is a stored column. The database writes it on every save (a trigger) and
12
+ * holds the rule in one function, so a termination or a supersession is recorded by the save that makes
13
+ * it. An expiry has no save behind it: the end date passes. This action runs the procedure that applies
14
+ * the same rule to every row whose stored value differs from it today, and a scheduled job runs it hourly.
15
+ *
16
+ * The rule stays in SQL, in `fnContractNonRenewalOutcome`. This file only calls it.
17
+ *
18
+ * @module @mj-biz-apps/contracts-actions
19
+ */
20
+ import { BaseAction } from '@memberjunction/actions';
21
+ import { Metadata } from '@memberjunction/core';
22
+ import { RegisterClass } from '@memberjunction/global';
23
+ /**
24
+ * The call, one form per database. SQL Server: a procedure that ends with `SELECT @Changed AS Changed`.
25
+ * PostgreSQL: a function of the same name returning the count. The schema is unquoted and the function
26
+ * name quoted, the converter's convention (see `ASSIGN_CONTRACT_NUMBER_SQL` in CoreEntitiesServer).
27
+ */
28
+ export const RECORD_NON_RENEWAL_OUTCOMES_SQL = {
29
+ default: `EXEC __mj_BizAppsContracts.spRecordContractNonRenewalOutcomes;`,
30
+ postgresql: `SELECT __mj_BizAppsContracts."spRecordContractNonRenewalOutcomes"() AS "Changed";`,
31
+ };
32
+ function setOutput(params, name, value) {
33
+ const existing = params.Params?.find((p) => p.Name?.toLowerCase() === name.toLowerCase());
34
+ if (existing) {
35
+ existing.Value = value;
36
+ return;
37
+ }
38
+ params.Params = params.Params ?? [];
39
+ params.Params.push({ Name: name, Value: value, Type: 'Output' });
40
+ }
41
+ let RecordNonRenewalOutcomesAction = class RecordNonRenewalOutcomesAction extends BaseAction {
42
+ async InternalRunAction(params) {
43
+ try {
44
+ // A server-side action always runs on a database provider; the metadata-provider type does not
45
+ // declare ExecuteSQL, so this narrows to the base class that does.
46
+ const db = Metadata.Provider;
47
+ const rows = await db.ExecuteSQL(db.ResolveSQL(RECORD_NON_RENEWAL_OUTCOMES_SQL), undefined, { isMutation: true, description: 'spRecordContractNonRenewalOutcomes' }, params.ContextUser);
48
+ const changed = Number(rows?.[0]?.Changed ?? 0);
49
+ setOutput(params, 'Changed', changed);
50
+ return {
51
+ Success: true,
52
+ ResultCode: 'SUCCESS',
53
+ Message: `Recorded the renewal outcome on ${changed} contract(s).`,
54
+ };
55
+ }
56
+ catch (error) {
57
+ return {
58
+ Success: false,
59
+ ResultCode: 'ERROR',
60
+ Message: `Recording renewal outcomes failed: ${error instanceof Error ? error.message : String(error)}`,
61
+ };
62
+ }
63
+ }
64
+ };
65
+ RecordNonRenewalOutcomesAction = __decorate([
66
+ RegisterClass(BaseAction, 'Contracts.RecordNonRenewalOutcomes')
67
+ ], RecordNonRenewalOutcomesAction);
68
+ export { RecordNonRenewalOutcomesAction };
69
+ /** Anti-tree-shaking anchor — `@RegisterClass` is a side effect of import. */
70
+ export function LoadRecordNonRenewalOutcomesAction() {
71
+ void RecordNonRenewalOutcomesAction;
72
+ }
73
+ //# sourceMappingURL=record-nonrenewal-outcomes.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-nonrenewal-outcomes.action.js","sourceRoot":"","sources":["../src/record-nonrenewal-outcomes.action.ts"],"names":[],"mappings":";;;;;;AAAA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AAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,CAAC,CAAC,CAAC;YAChD,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YACtC,OAAO;gBACH,OAAO,EAAE,IAAI;gBACb,UAAU,EAAE,SAAS;gBACrB,OAAO,EAAE,mCAAmC,OAAO,eAAe;aACrE,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO;gBACH,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE,OAAO;gBACnB,OAAO,EAAE,sCAAsC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aAC1G,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AA3BY,8BAA8B;IAD1C,aAAa,CAAC,UAAU,EAAE,oCAAoC,CAAC;GACnD,8BAA8B,CA2B1C;;AAED,8EAA8E;AAC9E,MAAM,UAAU,kCAAkC;IAC9C,KAAK,8BAA8B,CAAC;AACxC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mj-biz-apps/contracts-actions",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "type": "module",
5
5
  "description": "MemberJunction Actions exposed by the Contracts application (generated subclasses and hand-written actions).",
6
6
  "main": "dist/index.js",