@mj-biz-apps/sales-entities 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.
Files changed (42) hide show
  1. package/LICENSE +183 -0
  2. package/dist/activities/activity-vocabulary.d.ts +103 -0
  3. package/dist/activities/activity-vocabulary.d.ts.map +1 -0
  4. package/dist/activities/activity-vocabulary.js +79 -0
  5. package/dist/activities/activity-vocabulary.js.map +1 -0
  6. package/dist/close-lock.d.ts +72 -0
  7. package/dist/close-lock.d.ts.map +1 -0
  8. package/dist/close-lock.js +94 -0
  9. package/dist/close-lock.js.map +1 -0
  10. package/dist/deal-draft.d.ts +207 -0
  11. package/dist/deal-draft.d.ts.map +1 -0
  12. package/dist/deal-draft.js +318 -0
  13. package/dist/deal-draft.js.map +1 -0
  14. package/dist/deal-entity.d.ts +236 -0
  15. package/dist/deal-entity.d.ts.map +1 -0
  16. package/dist/deal-entity.js +383 -0
  17. package/dist/deal-entity.js.map +1 -0
  18. package/dist/discount-conversion.d.ts +94 -0
  19. package/dist/discount-conversion.d.ts.map +1 -0
  20. package/dist/discount-conversion.js +128 -0
  21. package/dist/discount-conversion.js.map +1 -0
  22. package/dist/downstream-seams.d.ts +179 -0
  23. package/dist/downstream-seams.d.ts.map +1 -0
  24. package/dist/downstream-seams.js +77 -0
  25. package/dist/downstream-seams.js.map +1 -0
  26. package/dist/generated/entity_subclasses.d.ts +4208 -0
  27. package/dist/generated/entity_subclasses.d.ts.map +1 -0
  28. package/dist/generated/entity_subclasses.js +6073 -0
  29. package/dist/generated/entity_subclasses.js.map +1 -0
  30. package/dist/generated/remote_operations.d.ts +2396 -0
  31. package/dist/generated/remote_operations.d.ts.map +1 -0
  32. package/dist/generated/remote_operations.js +660 -0
  33. package/dist/generated/remote_operations.js.map +1 -0
  34. package/dist/index.d.ts +46 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +47 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/product-filter.d.ts +66 -0
  39. package/dist/product-filter.d.ts.map +1 -0
  40. package/dist/product-filter.js +63 -0
  41. package/dist/product-filter.js.map +1 -0
  42. package/package.json +37 -0
package/LICENSE ADDED
@@ -0,0 +1,183 @@
1
+ Business Source License 1.1
2
+
3
+ License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB plc.
5
+
6
+ -----------------------------------------------------------------------------
7
+
8
+ Parameters
9
+
10
+ Licensor: Blue Cypress, Inc.
11
+
12
+ Licensed Work: MemberJunction.
13
+ The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
14
+
15
+ Additional Use Grant: Subject to the terms of this License, Licensor grants
16
+ you the following additional rights to make Production
17
+ Use of the Licensed Work.
18
+
19
+ 1. Internal Use
20
+
21
+ You may make production use of the Licensed Work for
22
+ your own internal business or organizational operations.
23
+
24
+ 2. Nonprofit Use
25
+
26
+ If you are a Nonprofit, you may make production use of
27
+ the Licensed Work for the operations and activities of
28
+ your Organizational Family.
29
+
30
+ 3. MemberJunction Certified Program Use
31
+
32
+ If you are authorized by Licensor under the
33
+ MemberJunction Certified Program to provide professional
34
+ services using the Licensed Work, you may make
35
+ production use of the Licensed Work in providing such
36
+ professional services to a client, provided that:
37
+
38
+ (a) the Licensed Work is deployed in, and the applicable
39
+ production use occurs within, an environment owned,
40
+ leased, licensed, subscribed to, or otherwise controlled
41
+ by that client; and
42
+
43
+ (b) the production use is for that client's own internal
44
+ business or organizational operations or is otherwise
45
+ independently permitted to that client under this
46
+ Additional Use Grant.
47
+
48
+ 4. Definitions Applicable to the Additional Use Grant
49
+
50
+ "Affiliate" means, with respect to a specified Person,
51
+ any other Person that directly or indirectly Controls,
52
+ is Controlled by, or is under common Control with such
53
+ specified Person.
54
+
55
+ "Control" (including the terms "Controls," "Controlled
56
+ by," and "under common Control with") means the direct
57
+ or indirect possession of the power to direct or cause
58
+ the direction of the management and policies of a
59
+ Person, whether through ownership of voting interests,
60
+ by contract, or otherwise.
61
+
62
+ "Organizational Family" means, with respect to a Person,
63
+ (a) such Person and its Affiliates, and (b) any
64
+ nonprofit organization, governmental entity, chapter,
65
+ division, local affiliate, regional affiliate, state
66
+ affiliate, national affiliate, or other entity that is
67
+ formally affiliated with such Person through governing
68
+ documents, a charter, bylaws, a membership agreement, or
69
+ another written organizational instrument, and is
70
+ recognized under such documents as part of the same
71
+ organizational structure.
72
+
73
+ "Nonprofit" means a Person recognized by the Internal
74
+ Revenue Service as exempt from federal income taxation
75
+ under Section 501(c)(3), 501(c)(4), 501(c)(5), or
76
+ 501(c)(6) of the Internal Revenue Code, or a foreign
77
+ organization recognized under substantially equivalent
78
+ laws.
79
+
80
+ A Person claiming eligibility as a Nonprofit shall, upon
81
+ Licensor's reasonable request, provide documentation
82
+ reasonably sufficient to demonstrate that it qualifies
83
+ as a Nonprofit. If such Person materially misrepresents,
84
+ or is unable to demonstrate, its qualification as a
85
+ Nonprofit, the rights granted to such Person under
86
+ Section 2 of this Additional Use Grant shall terminate.
87
+
88
+ "MemberJunction Certified Program" means Licensor's
89
+ then-current program for certifying and authorizing a
90
+ Person to provide professional services using the
91
+ Licensed Work.
92
+
93
+ "Person" means any individual, corporation, limited
94
+ liability company, partnership, association, nonprofit
95
+ organization, governmental entity, or other legal or
96
+ organizational entity.
97
+
98
+ Change Date: Four (4) years from the date the Licensed Work is first
99
+ made available.
100
+
101
+ Change License: MIT License.
102
+
103
+ For information about alternative licensing arrangements for the Licensed
104
+ Work, please contact Blue Cypress, Inc.
105
+
106
+ -----------------------------------------------------------------------------
107
+
108
+ Terms
109
+
110
+ The Licensor hereby grants you the right to copy, modify, create derivative
111
+ works, redistribute, and make non-production use of the Licensed Work. The
112
+ Licensor may make an Additional Use Grant, above, permitting limited
113
+ production use.
114
+
115
+ Effective on the Change Date, or the fourth anniversary of the first publicly
116
+ available distribution of a specific version of the Licensed Work under this
117
+ License, whichever comes first, the Licensor hereby grants you rights under
118
+ the terms of the Change License, and the rights granted in the paragraph
119
+ above terminate.
120
+
121
+ If your use of the Licensed Work does not comply with the requirements
122
+ currently in effect as described in this License, you must purchase a
123
+ commercial license from the Licensor, its affiliated entities, or authorized
124
+ resellers, or you must refrain from using the Licensed Work.
125
+
126
+ All copies of the original and modified Licensed Work, and derivative works
127
+ of the Licensed Work, are subject to this License. This License applies
128
+ separately for each version of the Licensed Work and the Change Date may vary
129
+ for each version of the Licensed Work released by Licensor.
130
+
131
+ You must conspicuously display this License on each original or modified copy
132
+ of the Licensed Work. If you receive the Licensed Work in original or
133
+ modified form from a third party, the terms and conditions set forth in this
134
+ License apply to your use of that work.
135
+
136
+ Any use of the Licensed Work in violation of this License will automatically
137
+ terminate your rights under this License for the current and all other
138
+ versions of the Licensed Work.
139
+
140
+ This License does not grant you any right in any trademark or logo of
141
+ Licensor or its affiliates (provided that you may use a trademark or logo of
142
+ Licensor as expressly required by this License).
143
+
144
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
145
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
146
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
147
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
148
+ TITLE.
149
+
150
+ MariaDB hereby grants you permission to use this License's text to license
151
+ your works, and to refer to it using the trademark "Business Source License",
152
+ as long as you comply with the Covenants of Licensor below.
153
+
154
+ -----------------------------------------------------------------------------
155
+
156
+ Covenants of Licensor
157
+
158
+ In consideration of the right to use this License's text and the "Business
159
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
160
+ other recipients of the licensed work to be provided by Licensor:
161
+
162
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
163
+ or a license that is compatible with GPL Version 2.0 or a later version,
164
+ where "compatible" means that software provided under the Change License
165
+ can be included in a program with software provided under GPL Version 2.0
166
+ or a later version. Licensor may specify additional Change Licenses without
167
+ limitation.
168
+
169
+ 2. To either: (a) specify an additional grant of rights to use that does not
170
+ impose any additional restriction on the right granted in this License, as
171
+ the Additional Use Grant; or (b) insert the text "None".
172
+
173
+ 3. To specify a Change Date.
174
+
175
+ 4. Not to modify this License in any other way.
176
+
177
+ -----------------------------------------------------------------------------
178
+
179
+ Notice
180
+
181
+ The Business Source License (this document, or the "License") is not an Open
182
+ Source license. However, the Licensed Work will eventually be made available
183
+ under an Open Source License, as stated in this License.
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @fileoverview The activity vocabulary, and the one convention decision the whole feature turns on.
3
+ *
4
+ * Every union in this file is a CHECK constraint in `__mj_BizAppsCommon`, read off the live schema
5
+ * rather than guessed. They are declared as union types, not enums, so the values cross a package
6
+ * boundary as plain strings — and so a value the database would refuse cannot be constructed here.
7
+ *
8
+ * @module @mj-biz-apps/sales-core-entities-server
9
+ */
10
+ /** `CK_Activity_Direction`. */
11
+ export type ActivityDirection = 'Inbound' | 'Outbound' | 'Internal';
12
+ /** `CK_Activity_Status`. */
13
+ export type ActivityStatus = 'Logged' | 'Scheduled' | 'Completed' | 'Cancelled' | 'Failed';
14
+ /** `CK_Activity_Source`. Sales writes `Manual` by hand and `Integration` from the ingest. */
15
+ export type ActivitySource = 'Manual' | 'System' | 'Integration';
16
+ /** `CK_Activity_Visibility`. */
17
+ export type ActivityVisibility = 'Internal' | 'Private';
18
+ /** `CK_Activity_Outcome`. Nullable — most activities have no outcome to state. */
19
+ export type ActivityOutcome = 'Connected' | 'LeftVoicemail' | 'NoAnswer' | 'NoShow' | 'Bounced' | 'Interested' | 'NotInterested';
20
+ /** `CK_ActivityLink_Role`. */
21
+ export type ActivityLinkRole = 'Regarding' | 'Participant' | 'From' | 'To' | 'Cc' | 'Bcc' | 'Organizer' | 'Attendee' | 'LoggedFor';
22
+ /** `CK_ActivityLink_IdentityKind` — the unresolved half of a link. */
23
+ export type ActivityIdentityKind = 'Email' | 'Phone' | 'ExternalUser';
24
+ /**
25
+ * The seeded `ActivityType.Code` values.
26
+ *
27
+ * RESOLVED BY CODE, NEVER BY NAME. `Code` and `Name` happen to be identical strings in today's seed
28
+ * (Call, Chat, Email, Meeting, Note, SMS), which is exactly why this must be explicit: a lookup written
29
+ * against `Name` would pass every test today and break silently the first time somebody renames the
30
+ * display label of a row whose code never changed. The vocabulary gate exists for this class of
31
+ * mistake.
32
+ */
33
+ export type ActivityTypeCode = 'Call' | 'Chat' | 'Email' | 'Meeting' | 'Note' | 'SMS';
34
+ /** Entity names. These strings are the whole dependency surface on the other two apps. */
35
+ export declare const E_ACTIVITY = "MJ_BizApps_Common: Activities";
36
+ export declare const E_ACTIVITY_LINK = "MJ_BizApps_Common: Activity Links";
37
+ export declare const E_ACTIVITY_TYPE = "MJ_BizApps_Common: Activity Types";
38
+ export declare const E_ACTIVITY_SYNC_CONNECTION = "MJ_BizApps_Common: Activity Sync Connections";
39
+ export declare const E_ACTIVITY_SYNC_RULE = "MJ_BizApps_Common: Activity Sync Rules";
40
+ export declare const E_CONTACT_METHOD = "MJ_BizApps_Common: Contact Methods";
41
+ export declare const E_DEAL = "MJ_BizApps_Sales: Deals";
42
+ export declare const E_DEAL_STATUS_TYPE = "MJ_BizApps_Sales: Deal Status Types";
43
+ /**
44
+ * ─────────────────────────────────────────────────────────────────────────────────────────────────
45
+ * THE LINK CONVENTION. Decided here, once, because nothing in the schema decides it.
46
+ * ─────────────────────────────────────────────────────────────────────────────────────────────────
47
+ *
48
+ * `SalesAccount.ID` IS `Organization.ID` and `SalesContact.ID` IS `Person.ID` — verified as real
49
+ * foreign keys, `FK_SalesAccount_Organization` and `FK_SalesContact_Person`, both on the `ID` column.
50
+ * Shared-primary-key IsA. So an `ActivityLink` to `Organizations/<id>` and one to
51
+ * `Sales Accounts/<id>` name **the same human or company under two different `EntityID`s**, and
52
+ * nothing anywhere normalizes between them.
53
+ *
54
+ * Left unpicked, that does not produce an error. It produces two half-timelines: the ingest writes
55
+ * one convention, a person logging a call by hand writes the other, and each view shows the half it
56
+ * happens to query. That is the failure this constant exists to prevent.
57
+ *
58
+ * ── THE PARTIES ARE LINKED UNDER COMMON'S ENTITIES ──
59
+ *
60
+ * Three reasons, in the order that decided it:
61
+ *
62
+ * 1. **The ingest resolves to common natively, and the alternative can fail.** A participant is
63
+ * identified by matching an email address against `ContactMethod`, whose columns are `PersonID`
64
+ * and `OrganizationID` — common's parents. Translating those to the sales children would be a
65
+ * second lookup that can come back EMPTY: a Person with no `SalesContact` row is an ordinary
66
+ * thing (any employee, any contact belonging to another app). Under a sales-child convention
67
+ * that link would have to be dropped or a stub created, and the common migration explicitly
68
+ * forbids auto-creating stub People. Under this convention it is simply written.
69
+ *
70
+ * 2. **The row is common's.** `Activity` lives in `__mj_BizAppsCommon`. An activity involving a
71
+ * person is a fact about the person, not about their sales-contact role — and when a second app
72
+ * extends `Person`, its activities point at the same rows and that human has one timeline
73
+ * instead of one per app.
74
+ *
75
+ * 3. **It survives KI-1.** `AllowMultipleSubtypes` is still false on `Person` and `Organization`,
76
+ * so the sales children are the only children today. A convention anchored on them would need
77
+ * rewriting the day that changes; one anchored on the parents would not.
78
+ *
79
+ * ── WHAT SALES KEEPS ──
80
+ *
81
+ * The DEAL is still linked as a sales record — `MJ_BizApps_Sales: Deals`, role `Regarding`. That is
82
+ * the anchor every read starts from. So the split is clean rather than arbitrary: **sales owns the
83
+ * deal link, common owns the party links.**
84
+ *
85
+ * ── AND THE COST IS ZERO, WHICH IS WHY THIS IS NOT A TRADE-OFF ──
86
+ *
87
+ * The one argument for the sales children was that `Deal.AccountID` and `Deal.PrimaryContactID`
88
+ * already hold those IDs, so no translation is needed on the manual path. But because the PK is
89
+ * SHARED, those very same values ARE the Organization and Person IDs. `Deal.AccountID` can be used
90
+ * verbatim as a `RecordID` under `E_ORGANIZATION`. Nothing is converted in either direction.
91
+ */
92
+ export declare const E_PERSON = "MJ_BizApps_Common: People";
93
+ export declare const E_ORGANIZATION = "MJ_BizApps_Common: Organizations";
94
+ /**
95
+ * The source-system name stamped on every ingested row, and half of the dedupe key.
96
+ *
97
+ * `UQ_Activity_External` is unique on `(SourceSystem, ExternalID)` and filtered to
98
+ * `WHERE ExternalID IS NOT NULL`, with `CK_Activity_External` requiring both or neither. So this
99
+ * string is not a label — it is a namespace, and changing it would orphan every row already ingested
100
+ * and re-import the lot.
101
+ */
102
+ export declare const SOURCE_SYSTEM_M365 = "Microsoft365";
103
+ //# sourceMappingURL=activity-vocabulary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity-vocabulary.d.ts","sourceRoot":"","sources":["../../src/activities/activity-vocabulary.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,+BAA+B;AAC/B,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAEpE,4BAA4B;AAC5B,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE3F,6FAA6F;AAC7F,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEjE,gCAAgC;AAChC,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,SAAS,CAAC;AAExD,kFAAkF;AAClF,MAAM,MAAM,eAAe,GACrB,WAAW,GACX,eAAe,GACf,UAAU,GACV,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,eAAe,CAAC;AAEtB,8BAA8B;AAC9B,MAAM,MAAM,gBAAgB,GACtB,WAAW,GACX,aAAa,GACb,MAAM,GACN,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,WAAW,GACX,UAAU,GACV,WAAW,CAAC;AAElB,sEAAsE;AACtE,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,CAAC;AAEtE;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC;AAEtF,0FAA0F;AAC1F,eAAO,MAAM,UAAU,kCAAkC,CAAC;AAC1D,eAAO,MAAM,eAAe,sCAAsC,CAAC;AACnE,eAAO,MAAM,eAAe,sCAAsC,CAAC;AACnE,eAAO,MAAM,0BAA0B,iDAAiD,CAAC;AACzF,eAAO,MAAM,oBAAoB,2CAA2C,CAAC;AAC7E,eAAO,MAAM,gBAAgB,uCAAuC,CAAC;AACrE,eAAO,MAAM,MAAM,4BAA4B,CAAC;AAChD,eAAO,MAAM,kBAAkB,wCAAwC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAO,MAAM,QAAQ,8BAA8B,CAAC;AACpD,eAAO,MAAM,cAAc,qCAAqC,CAAC;AAEjE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,iBAAiB,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @fileoverview The activity vocabulary, and the one convention decision the whole feature turns on.
3
+ *
4
+ * Every union in this file is a CHECK constraint in `__mj_BizAppsCommon`, read off the live schema
5
+ * rather than guessed. They are declared as union types, not enums, so the values cross a package
6
+ * boundary as plain strings — and so a value the database would refuse cannot be constructed here.
7
+ *
8
+ * @module @mj-biz-apps/sales-core-entities-server
9
+ */
10
+ /** Entity names. These strings are the whole dependency surface on the other two apps. */
11
+ export const E_ACTIVITY = 'MJ_BizApps_Common: Activities';
12
+ export const E_ACTIVITY_LINK = 'MJ_BizApps_Common: Activity Links';
13
+ export const E_ACTIVITY_TYPE = 'MJ_BizApps_Common: Activity Types';
14
+ export const E_ACTIVITY_SYNC_CONNECTION = 'MJ_BizApps_Common: Activity Sync Connections';
15
+ export const E_ACTIVITY_SYNC_RULE = 'MJ_BizApps_Common: Activity Sync Rules';
16
+ export const E_CONTACT_METHOD = 'MJ_BizApps_Common: Contact Methods';
17
+ export const E_DEAL = 'MJ_BizApps_Sales: Deals';
18
+ export const E_DEAL_STATUS_TYPE = 'MJ_BizApps_Sales: Deal Status Types';
19
+ /**
20
+ * ─────────────────────────────────────────────────────────────────────────────────────────────────
21
+ * THE LINK CONVENTION. Decided here, once, because nothing in the schema decides it.
22
+ * ─────────────────────────────────────────────────────────────────────────────────────────────────
23
+ *
24
+ * `SalesAccount.ID` IS `Organization.ID` and `SalesContact.ID` IS `Person.ID` — verified as real
25
+ * foreign keys, `FK_SalesAccount_Organization` and `FK_SalesContact_Person`, both on the `ID` column.
26
+ * Shared-primary-key IsA. So an `ActivityLink` to `Organizations/<id>` and one to
27
+ * `Sales Accounts/<id>` name **the same human or company under two different `EntityID`s**, and
28
+ * nothing anywhere normalizes between them.
29
+ *
30
+ * Left unpicked, that does not produce an error. It produces two half-timelines: the ingest writes
31
+ * one convention, a person logging a call by hand writes the other, and each view shows the half it
32
+ * happens to query. That is the failure this constant exists to prevent.
33
+ *
34
+ * ── THE PARTIES ARE LINKED UNDER COMMON'S ENTITIES ──
35
+ *
36
+ * Three reasons, in the order that decided it:
37
+ *
38
+ * 1. **The ingest resolves to common natively, and the alternative can fail.** A participant is
39
+ * identified by matching an email address against `ContactMethod`, whose columns are `PersonID`
40
+ * and `OrganizationID` — common's parents. Translating those to the sales children would be a
41
+ * second lookup that can come back EMPTY: a Person with no `SalesContact` row is an ordinary
42
+ * thing (any employee, any contact belonging to another app). Under a sales-child convention
43
+ * that link would have to be dropped or a stub created, and the common migration explicitly
44
+ * forbids auto-creating stub People. Under this convention it is simply written.
45
+ *
46
+ * 2. **The row is common's.** `Activity` lives in `__mj_BizAppsCommon`. An activity involving a
47
+ * person is a fact about the person, not about their sales-contact role — and when a second app
48
+ * extends `Person`, its activities point at the same rows and that human has one timeline
49
+ * instead of one per app.
50
+ *
51
+ * 3. **It survives KI-1.** `AllowMultipleSubtypes` is still false on `Person` and `Organization`,
52
+ * so the sales children are the only children today. A convention anchored on them would need
53
+ * rewriting the day that changes; one anchored on the parents would not.
54
+ *
55
+ * ── WHAT SALES KEEPS ──
56
+ *
57
+ * The DEAL is still linked as a sales record — `MJ_BizApps_Sales: Deals`, role `Regarding`. That is
58
+ * the anchor every read starts from. So the split is clean rather than arbitrary: **sales owns the
59
+ * deal link, common owns the party links.**
60
+ *
61
+ * ── AND THE COST IS ZERO, WHICH IS WHY THIS IS NOT A TRADE-OFF ──
62
+ *
63
+ * The one argument for the sales children was that `Deal.AccountID` and `Deal.PrimaryContactID`
64
+ * already hold those IDs, so no translation is needed on the manual path. But because the PK is
65
+ * SHARED, those very same values ARE the Organization and Person IDs. `Deal.AccountID` can be used
66
+ * verbatim as a `RecordID` under `E_ORGANIZATION`. Nothing is converted in either direction.
67
+ */
68
+ export const E_PERSON = 'MJ_BizApps_Common: People';
69
+ export const E_ORGANIZATION = 'MJ_BizApps_Common: Organizations';
70
+ /**
71
+ * The source-system name stamped on every ingested row, and half of the dedupe key.
72
+ *
73
+ * `UQ_Activity_External` is unique on `(SourceSystem, ExternalID)` and filtered to
74
+ * `WHERE ExternalID IS NOT NULL`, with `CK_Activity_External` requiring both or neither. So this
75
+ * string is not a label — it is a namespace, and changing it would orphan every row already ingested
76
+ * and re-import the lot.
77
+ */
78
+ export const SOURCE_SYSTEM_M365 = 'Microsoft365';
79
+ //# sourceMappingURL=activity-vocabulary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity-vocabulary.js","sourceRoot":"","sources":["../../src/activities/activity-vocabulary.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkDH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,UAAU,GAAG,+BAA+B,CAAC;AAC1D,MAAM,CAAC,MAAM,eAAe,GAAG,mCAAmC,CAAC;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,mCAAmC,CAAC;AACnE,MAAM,CAAC,MAAM,0BAA0B,GAAG,8CAA8C,CAAC;AACzF,MAAM,CAAC,MAAM,oBAAoB,GAAG,wCAAwC,CAAC;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,oCAAoC,CAAC;AACrE,MAAM,CAAC,MAAM,MAAM,GAAG,yBAAyB,CAAC;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,qCAAqC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,2BAA2B,CAAC;AACpD,MAAM,CAAC,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @fileoverview The close lock's field rule, in ONE place.
3
+ *
4
+ * WHY THIS IS NOT A PRIVATE STATIC ANY MORE. The lock is enforced in
5
+ * `DealEntityServer.Save()` — deliberately, so an Action, an agent and a raw `BaseEntity.Save()` all hit
6
+ * the same wall (master plan §7.3, L-17). But the Explorer form has to know the SAME rule to be usable:
7
+ * a form that presents a frozen field as editable invites someone to type into it, press Save, and be
8
+ * refused by the server. That is a correct refusal delivered at the worst possible moment.
9
+ *
10
+ * Two copies of this list would drift, and the drift would be invisible until a user hit it — the form
11
+ * would offer a field the server refuses, or grey out one it would have accepted. So the server reads
12
+ * this and the form reads this, and there is nothing to keep in sync.
13
+ *
14
+ * It lives in `sales-entities` because that is the only package both the entity server and the Angular
15
+ * layer already depend on.
16
+ *
17
+ * ── THE RULE ────────────────────────────────────────────────────────────────────────────────────
18
+ *
19
+ * When a deal enters a status whose `DealStatusType.LocksDeal` is set, the deal, its lines and its team
20
+ * become immutable — **except** for these fields. The lock is field-by-field rather than a wall because
21
+ * a closed deal still needs notes: someone has to be able to write "customer asked about renewal"
22
+ * without reopening the deal and falsifying its provenance. Everything a contract or an order was
23
+ * derived from is frozen.
24
+ *
25
+ * Reopening is the one audited way back through, via `Sales.ReopenDeal`, which records a reason.
26
+ *
27
+ * @module @mj-biz-apps/sales-entities
28
+ */
29
+ import { type UserInfo } from '@memberjunction/core';
30
+ /**
31
+ * The deal fields that stay editable while the deal is locked.
32
+ *
33
+ * Pinned by integration check CD14, which closes a deal and then proves each of these is genuinely
34
+ * accepted and that a field outside the set is genuinely refused — so this constant cannot quietly
35
+ * stop describing what the server does.
36
+ */
37
+ export declare const DEAL_FIELDS_EDITABLE_WHILE_LOCKED: ReadonlySet<string>;
38
+ /**
39
+ * Whether `fieldName` may still be edited on a locked deal.
40
+ *
41
+ * Callers should prefer this to reaching into the set, so the membership test stays in one place if the
42
+ * rule ever grows a condition beyond simple membership.
43
+ */
44
+ export declare function IsDealFieldEditableWhileLocked(fieldName: string): boolean;
45
+ /** What a surface needs to know to render the lock: whether it is on, and what to say about it. */
46
+ export interface DealLockState {
47
+ IsLocked: boolean;
48
+ /** The status' display name, for the notice. Null when not locked. */
49
+ StatusName: string | null;
50
+ /** A ready-to-render explanation, or null when the deal is open. */
51
+ Notice: string | null;
52
+ }
53
+ /**
54
+ * Resolves whether a PERSISTED status locks the deal.
55
+ *
56
+ * ── WHY THE LOOKUP IS SHARED, NOT JUST THE FIELD LIST ───────────────────────────────────────────
57
+ *
58
+ * Sharing `DEAL_FIELDS_EDITABLE_WHILE_LOCKED` alone would still leave two copies of the more subtle
59
+ * half — *how you decide a deal is locked at all*: read `LocksDeal` off the status ROW, by FLAG, and
60
+ * off the **persisted** status rather than whatever the user just picked in a dropdown. Both of those
61
+ * are easy to get quietly wrong in a second implementation, and a surface that resolved the lock from
62
+ * the pending status would unlock a deal the moment someone changed the dropdown.
63
+ *
64
+ * So every surface calls this. The Explorer record form and the deal workspace now share one answer.
65
+ *
66
+ * Reads the FLAG, never a status name — a deployment may call its winning status "Signed" (§3).
67
+ *
68
+ * @param persistedStatusID - `DealStatusTypeID`'s **OldValue**, not its current value.
69
+ * @param contextUser - Server callers must pass one; the browser omits it.
70
+ */
71
+ export declare function ResolveDealLockState(persistedStatusID: string | null | undefined, contextUser?: UserInfo): Promise<DealLockState>;
72
+ //# sourceMappingURL=close-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"close-lock.d.ts","sourceRoot":"","sources":["../src/close-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,WAAW,CAAC,MAAM,CAGhE,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEzE;AAKD,mGAAmG;AACnG,MAAM,WAAW,aAAa;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oEAAoE;IACpE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,oBAAoB,CACtC,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC5C,WAAW,CAAC,EAAE,QAAQ,GACvB,OAAO,CAAC,aAAa,CAAC,CA6BxB"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @fileoverview The close lock's field rule, in ONE place.
3
+ *
4
+ * WHY THIS IS NOT A PRIVATE STATIC ANY MORE. The lock is enforced in
5
+ * `DealEntityServer.Save()` — deliberately, so an Action, an agent and a raw `BaseEntity.Save()` all hit
6
+ * the same wall (master plan §7.3, L-17). But the Explorer form has to know the SAME rule to be usable:
7
+ * a form that presents a frozen field as editable invites someone to type into it, press Save, and be
8
+ * refused by the server. That is a correct refusal delivered at the worst possible moment.
9
+ *
10
+ * Two copies of this list would drift, and the drift would be invisible until a user hit it — the form
11
+ * would offer a field the server refuses, or grey out one it would have accepted. So the server reads
12
+ * this and the form reads this, and there is nothing to keep in sync.
13
+ *
14
+ * It lives in `sales-entities` because that is the only package both the entity server and the Angular
15
+ * layer already depend on.
16
+ *
17
+ * ── THE RULE ────────────────────────────────────────────────────────────────────────────────────
18
+ *
19
+ * When a deal enters a status whose `DealStatusType.LocksDeal` is set, the deal, its lines and its team
20
+ * become immutable — **except** for these fields. The lock is field-by-field rather than a wall because
21
+ * a closed deal still needs notes: someone has to be able to write "customer asked about renewal"
22
+ * without reopening the deal and falsifying its provenance. Everything a contract or an order was
23
+ * derived from is frozen.
24
+ *
25
+ * Reopening is the one audited way back through, via `Sales.ReopenDeal`, which records a reason.
26
+ *
27
+ * @module @mj-biz-apps/sales-entities
28
+ */
29
+ import { RunView } from '@memberjunction/core';
30
+ /**
31
+ * The deal fields that stay editable while the deal is locked.
32
+ *
33
+ * Pinned by integration check CD14, which closes a deal and then proves each of these is genuinely
34
+ * accepted and that a field outside the set is genuinely refused — so this constant cannot quietly
35
+ * stop describing what the server does.
36
+ */
37
+ export const DEAL_FIELDS_EDITABLE_WHILE_LOCKED = new Set([
38
+ 'Description',
39
+ 'NextStep',
40
+ ]);
41
+ /**
42
+ * Whether `fieldName` may still be edited on a locked deal.
43
+ *
44
+ * Callers should prefer this to reaching into the set, so the membership test stays in one place if the
45
+ * rule ever grows a condition beyond simple membership.
46
+ */
47
+ export function IsDealFieldEditableWhileLocked(fieldName) {
48
+ return DEAL_FIELDS_EDITABLE_WHILE_LOCKED.has(fieldName);
49
+ }
50
+ /** Sales' deal-status type table. Named here so the lock lookup below has one spelling of it. */
51
+ const E_DEAL_STATUS_TYPE = 'MJ_BizApps_Sales: Deal Status Types';
52
+ /**
53
+ * Resolves whether a PERSISTED status locks the deal.
54
+ *
55
+ * ── WHY THE LOOKUP IS SHARED, NOT JUST THE FIELD LIST ───────────────────────────────────────────
56
+ *
57
+ * Sharing `DEAL_FIELDS_EDITABLE_WHILE_LOCKED` alone would still leave two copies of the more subtle
58
+ * half — *how you decide a deal is locked at all*: read `LocksDeal` off the status ROW, by FLAG, and
59
+ * off the **persisted** status rather than whatever the user just picked in a dropdown. Both of those
60
+ * are easy to get quietly wrong in a second implementation, and a surface that resolved the lock from
61
+ * the pending status would unlock a deal the moment someone changed the dropdown.
62
+ *
63
+ * So every surface calls this. The Explorer record form and the deal workspace now share one answer.
64
+ *
65
+ * Reads the FLAG, never a status name — a deployment may call its winning status "Signed" (§3).
66
+ *
67
+ * @param persistedStatusID - `DealStatusTypeID`'s **OldValue**, not its current value.
68
+ * @param contextUser - Server callers must pass one; the browser omits it.
69
+ */
70
+ export async function ResolveDealLockState(persistedStatusID, contextUser) {
71
+ const open = { IsLocked: false, StatusName: null, Notice: null };
72
+ if (!persistedStatusID) {
73
+ return open;
74
+ }
75
+ const result = await new RunView().RunView({
76
+ EntityName: E_DEAL_STATUS_TYPE,
77
+ ExtraFilter: `ID = '${String(persistedStatusID).replace(/'/g, "''")}'`,
78
+ ResultType: 'simple',
79
+ Fields: ['LocksDeal', 'Name'],
80
+ }, contextUser);
81
+ const row = result?.Success ? (result.Results ?? [])[0] : undefined;
82
+ if (!row?.LocksDeal) {
83
+ return open;
84
+ }
85
+ const editable = [...DEAL_FIELDS_EDITABLE_WHILE_LOCKED].join(' and ');
86
+ return {
87
+ IsLocked: true,
88
+ StatusName: row.Name,
89
+ Notice: `This deal is closed (${row.Name}) and locked. A contract or an order was derived from it, so ` +
90
+ `its terms are frozen — only ${editable} can still be changed. To change anything else, reopen ` +
91
+ 'the deal, which records a reason.',
92
+ };
93
+ }
94
+ //# sourceMappingURL=close-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"close-lock.js","sourceRoot":"","sources":["../src/close-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,OAAO,EAAiB,MAAM,sBAAsB,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAwB,IAAI,GAAG,CAAS;IAClF,aAAa;IACb,UAAU;CACb,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAAC,SAAiB;IAC5D,OAAO,iCAAiC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAC5D,CAAC;AAED,iGAAiG;AACjG,MAAM,kBAAkB,GAAG,qCAAqC,CAAC;AAWjE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACtC,iBAA4C,EAC5C,WAAsB;IAEtB,MAAM,IAAI,GAAkB,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAChF,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC,OAAO,CACtC;QACI,UAAU,EAAE,kBAAkB;QAC9B,WAAW,EAAE,SAAS,MAAM,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG;QACtE,UAAU,EAAE,QAAQ;QACpB,MAAM,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC;KAChC,EACD,WAAW,CACd,CAAC;IACF,MAAM,GAAG,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpE,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,GAAG,iCAAiC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtE,OAAO;QACH,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,GAAG,CAAC,IAAI;QACpB,MAAM,EACF,wBAAwB,GAAG,CAAC,IAAI,+DAA+D;YAC/F,+BAA+B,QAAQ,yDAAyD;YAChG,mCAAmC;KAC1C,CAAC;AACN,CAAC"}