@mj-biz-apps/sales-server 5.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/LICENSE +183 -0
- package/dist/custom/forecast-snapshot.action.d.ts +17 -0
- package/dist/custom/forecast-snapshot.action.d.ts.map +1 -0
- package/dist/custom/forecast-snapshot.action.js +112 -0
- package/dist/custom/forecast-snapshot.action.js.map +1 -0
- package/dist/custom/log-activity.action.d.ts +39 -0
- package/dist/custom/log-activity.action.d.ts.map +1 -0
- package/dist/custom/log-activity.action.js +168 -0
- package/dist/custom/log-activity.action.js.map +1 -0
- package/dist/custom/sync-activities.action.d.ts +37 -0
- package/dist/custom/sync-activities.action.d.ts.map +1 -0
- package/dist/custom/sync-activities.action.js +124 -0
- package/dist/custom/sync-activities.action.js.map +1 -0
- package/dist/generated/class-registrations-manifest.d.ts +20 -0
- package/dist/generated/class-registrations-manifest.d.ts.map +1 -0
- package/dist/generated/class-registrations-manifest.js +20 -0
- package/dist/generated/class-registrations-manifest.js.map +1 -0
- package/dist/generated/generated.d.ts +1396 -0
- package/dist/generated/generated.d.ts.map +1 -0
- package/dist/generated/generated.js +7178 -0
- package/dist/generated/generated.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,124 @@
|
|
|
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 `Sales.SyncActivities` — the MJ Action a `ScheduledJob` fires hourly.
|
|
9
|
+
*
|
|
10
|
+
* ── WHERE THIS LIVES, AND WHY NOT IN `packages/Actions` ─────────────────────────────────────────
|
|
11
|
+
*
|
|
12
|
+
* `packages/Actions` holds only CodeGen output. Orders puts its hand-written actions in
|
|
13
|
+
* `packages/Server/src/custom/*.action.ts` — `Orders.GenerateInvoice`, `Orders.SendDocument` — and this
|
|
14
|
+
* follows that exactly, because the alternative is a second convention for the same thing in the same
|
|
15
|
+
* workspace. Sales had no action of its own before this one, so there was nothing local to match.
|
|
16
|
+
*
|
|
17
|
+
* ── WHAT IT DOES, AND WHAT IT DELIBERATELY DOES NOT DECIDE ──────────────────────────────────────
|
|
18
|
+
*
|
|
19
|
+
* It calls `ActivitySyncJob.Run()` with whatever source factory is currently registered, and reports the
|
|
20
|
+
* tallies. It does NOT choose the source: that is `CurrentActivitySourceFactory()`, whose default is an
|
|
21
|
+
* empty fixture, and swapping it is the single change a scoped mailbox credential requires. An action
|
|
22
|
+
* that picked its own source would put that decision behind a metadata row nobody reads.
|
|
23
|
+
*
|
|
24
|
+
* @module @mj-biz-apps/sales-server
|
|
25
|
+
*/
|
|
26
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
27
|
+
import { Metadata } from '@memberjunction/core';
|
|
28
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
29
|
+
import { ActivitySyncJob, CurrentActivitySourceFactory } from '@mj-biz-apps/sales-core-entities-server';
|
|
30
|
+
/** The one input: how many items to pull per mailbox per run. */
|
|
31
|
+
const P_LIMIT = 'Limit';
|
|
32
|
+
/** Default matching `ActivitySyncJob.Run`'s own, so metadata and code cannot disagree silently. */
|
|
33
|
+
const DEFAULT_LIMIT = 100;
|
|
34
|
+
function readParam(params, name) {
|
|
35
|
+
return params.Params?.find((p) => p.Name?.toLowerCase() === name.toLowerCase())?.Value;
|
|
36
|
+
}
|
|
37
|
+
function setOutput(params, name, value) {
|
|
38
|
+
const existing = params.Params?.find((p) => p.Name?.toLowerCase() === name.toLowerCase());
|
|
39
|
+
if (existing) {
|
|
40
|
+
existing.Value = value;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
params.Params = params.Params ?? [];
|
|
44
|
+
params.Params.push({ Name: name, Value: value, Type: 'Output' });
|
|
45
|
+
}
|
|
46
|
+
let SyncActivitiesAction = class SyncActivitiesAction extends BaseAction {
|
|
47
|
+
/**
|
|
48
|
+
* AN ACTION MUST NOT THROW AT ITS CALLER. The scheduler, a workflow and a manual "run now" all want a
|
|
49
|
+
* result they can branch on; an exception loses the tallies from the mailboxes that did succeed. So
|
|
50
|
+
* the whole body runs behind this and every failure comes back as `Success: false` with a code.
|
|
51
|
+
*/
|
|
52
|
+
async InternalRunAction(params) {
|
|
53
|
+
try {
|
|
54
|
+
return await this.sync(params);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
return {
|
|
58
|
+
Success: false,
|
|
59
|
+
ResultCode: 'ERROR',
|
|
60
|
+
Message: `The activity sync failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async sync(params) {
|
|
65
|
+
const raw = readParam(params, P_LIMIT);
|
|
66
|
+
const parsed = raw === null || raw === undefined || raw === '' ? DEFAULT_LIMIT : Number(raw);
|
|
67
|
+
const limit = Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : DEFAULT_LIMIT;
|
|
68
|
+
/**
|
|
69
|
+
* `Metadata.Provider` rather than an injected provider, because there is exactly ONE provider per
|
|
70
|
+
* server process — the bootstrapped one. That is also what makes the writes join any ambient
|
|
71
|
+
* transaction, which is what lets the integration checks drive this inside a rollback.
|
|
72
|
+
*/
|
|
73
|
+
const provider = Metadata.Provider;
|
|
74
|
+
const result = await new ActivitySyncJob().Run(CurrentActivitySourceFactory(), provider, params.ContextUser, limit);
|
|
75
|
+
const totals = result.Runs.reduce((sum, run) => ({
|
|
76
|
+
Fetched: sum.Fetched + run.Result.Fetched,
|
|
77
|
+
Relevant: sum.Relevant + run.Result.Relevant,
|
|
78
|
+
Written: sum.Written + run.Result.Written,
|
|
79
|
+
Duplicates: sum.Duplicates + run.Result.Duplicates,
|
|
80
|
+
Unattributed: sum.Unattributed + run.Result.Unattributed,
|
|
81
|
+
}), { Fetched: 0, Relevant: 0, Written: 0, Duplicates: 0, Unattributed: 0 });
|
|
82
|
+
setOutput(params, 'ConnectionsAttempted', result.ConnectionsAttempted);
|
|
83
|
+
setOutput(params, 'Fetched', totals.Fetched);
|
|
84
|
+
setOutput(params, 'Written', totals.Written);
|
|
85
|
+
setOutput(params, 'Duplicates', totals.Duplicates);
|
|
86
|
+
setOutput(params, 'Unattributed', totals.Unattributed);
|
|
87
|
+
setOutput(params, 'Issues', JSON.stringify(result.Issues));
|
|
88
|
+
/**
|
|
89
|
+
* ZERO CONNECTIONS IS A SUCCESS, and the message says so rather than leaving a bare "0 written"
|
|
90
|
+
* to be read as a failure. A deployment that has not been given a mailbox is the ordinary state
|
|
91
|
+
* today, and an hourly job that reports failure for it would train everyone to ignore the job log
|
|
92
|
+
* before there was ever anything in it worth reading.
|
|
93
|
+
*/
|
|
94
|
+
if (result.ConnectionsAttempted === 0) {
|
|
95
|
+
return {
|
|
96
|
+
Success: true,
|
|
97
|
+
ResultCode: 'NO_CONNECTIONS',
|
|
98
|
+
Message: 'No Active Microsoft365 sync connection exists, so nothing was read. The chain is wired; '
|
|
99
|
+
+ 'it has no mailbox to point at.',
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
Success: result.Success,
|
|
104
|
+
ResultCode: result.Success ? 'SUCCESS' : 'PARTIAL',
|
|
105
|
+
Message: `${result.ConnectionsAttempted} connection(s): fetched ${totals.Fetched}, `
|
|
106
|
+
+ `relevant ${totals.Relevant}, written ${totals.Written}, `
|
|
107
|
+
+ `duplicates ${totals.Duplicates}, unattributed ${totals.Unattributed}.`
|
|
108
|
+
+ (result.Issues.length ? ` Issues: ${result.Issues.join(' | ')}` : ''),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
SyncActivitiesAction = __decorate([
|
|
113
|
+
RegisterClass(BaseAction, 'Sales.SyncActivities')
|
|
114
|
+
], SyncActivitiesAction);
|
|
115
|
+
export { SyncActivitiesAction };
|
|
116
|
+
/**
|
|
117
|
+
* WITHOUT THIS ANCHOR the class is tree-shaken out of the bundle, the `@RegisterClass` decorator never
|
|
118
|
+
* runs, and `ActionEngine` finds no implementation for `Sales.SyncActivities` — which surfaces as an
|
|
119
|
+
* action that exists in metadata, is scheduled, fires, and does nothing at all.
|
|
120
|
+
*/
|
|
121
|
+
export function LoadSyncActivitiesAction() {
|
|
122
|
+
void SyncActivitiesAction;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=sync-activities.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-activities.action.js","sourceRoot":"","sources":["../../src/custom/sync-activities.action.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAExG,iEAAiE;AACjE,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,mGAAmG;AACnG,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,SAAS,SAAS,CAAC,MAAuB,EAAE,IAAY;IACpD,OAAO,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,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0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anti-tree-shaking manifest for the SERVER bundle.
|
|
3
|
+
*
|
|
4
|
+
* HAND-AUTHORED STUB, not CodeGen output — despite living under generated/. `npm run mj:codegen`
|
|
5
|
+
* does not rewrite this file; it is kept here to match the sibling apps' layout.
|
|
6
|
+
*
|
|
7
|
+
* See the client-side counterpart in packages/Angular for the full account of why a manifest is
|
|
8
|
+
* needed at all. The server-side stakes are higher: a tree-shaken server class does not merely
|
|
9
|
+
* render the wrong component, it makes the ClassFactory fall back to a base implementation that
|
|
10
|
+
* declines the operation — so "nobody registered a driver" reads as "the operation refused", and
|
|
11
|
+
* the bug is hunted in the wrong place entirely.
|
|
12
|
+
*
|
|
13
|
+
* EMPTY IS CORRECT AT S1, because there are no server-side subclasses yet. The named anchors this
|
|
14
|
+
* app will need are already listed in sales-core-entities-server's index: `DealEntityServer` (the
|
|
15
|
+
* close lock, L-17, and the OwnerEmployeeID stamp) and `DealLineEntityServer` (the refusal to do
|
|
16
|
+
* local arithmetic). They arrive at S4 and are anchored by explicit `Load*()` calls from
|
|
17
|
+
* `LoadBizAppsSalesServer()`, which is the pattern this array supplements rather than replaces.
|
|
18
|
+
*/
|
|
19
|
+
export declare const CLASS_REGISTRATIONS: ReadonlyArray<unknown>;
|
|
20
|
+
//# sourceMappingURL=class-registrations-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-registrations-manifest.d.ts","sourceRoot":"","sources":["../../src/generated/class-registrations-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,OAAO,CAAM,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anti-tree-shaking manifest for the SERVER bundle.
|
|
3
|
+
*
|
|
4
|
+
* HAND-AUTHORED STUB, not CodeGen output — despite living under generated/. `npm run mj:codegen`
|
|
5
|
+
* does not rewrite this file; it is kept here to match the sibling apps' layout.
|
|
6
|
+
*
|
|
7
|
+
* See the client-side counterpart in packages/Angular for the full account of why a manifest is
|
|
8
|
+
* needed at all. The server-side stakes are higher: a tree-shaken server class does not merely
|
|
9
|
+
* render the wrong component, it makes the ClassFactory fall back to a base implementation that
|
|
10
|
+
* declines the operation — so "nobody registered a driver" reads as "the operation refused", and
|
|
11
|
+
* the bug is hunted in the wrong place entirely.
|
|
12
|
+
*
|
|
13
|
+
* EMPTY IS CORRECT AT S1, because there are no server-side subclasses yet. The named anchors this
|
|
14
|
+
* app will need are already listed in sales-core-entities-server's index: `DealEntityServer` (the
|
|
15
|
+
* close lock, L-17, and the OwnerEmployeeID stamp) and `DealLineEntityServer` (the refusal to do
|
|
16
|
+
* local arithmetic). They arrive at S4 and are anchored by explicit `Load*()` calls from
|
|
17
|
+
* `LoadBizAppsSalesServer()`, which is the pattern this array supplements rather than replaces.
|
|
18
|
+
*/
|
|
19
|
+
export const CLASS_REGISTRATIONS = [];
|
|
20
|
+
//# sourceMappingURL=class-registrations-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-registrations-manifest.js","sourceRoot":"","sources":["../../src/generated/class-registrations-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA2B,EAAE,CAAC"}
|