@mj-biz-apps/common-core-entities-server 0.0.1 → 5.30.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,55 @@
1
+ import { EntityDeleteOptions, EntitySaveOptions } from '@memberjunction/core';
2
+ import { mjBizAppsCommonPersonEntity } from '@mj-biz-apps/common-entities';
3
+ /**
4
+ * Server-side subclass of the BAC Person entity.
5
+ *
6
+ * Lifecycle hooks:
7
+ * - **Save (pre):** Auto-links to an MJ User record (creates one if needed)
8
+ * - **Save (post):** Syncs name/email changes to the linked User; assigns default "UI" UserRole
9
+ * - **Delete:** Deactivates the linked User (does not delete — preserves audit history)
10
+ */
11
+ export declare class PersonEntityServer extends mjBizAppsCommonPersonEntity {
12
+ Save(options?: EntitySaveOptions): Promise<boolean>;
13
+ Delete(options?: EntityDeleteOptions): Promise<boolean>;
14
+ /**
15
+ * Find an existing MJ User by email, or create a new one.
16
+ * Sets LinkedUserID on the Person entity (pre-save, so it's persisted atomically).
17
+ */
18
+ private autoLinkUser;
19
+ /**
20
+ * Find an existing MJ User by email using the cached UserCache.
21
+ * UserCache is populated at server startup and refreshed periodically.
22
+ */
23
+ private findCachedUserByEmail;
24
+ /**
25
+ * Create a new MJ User record from the Person's details.
26
+ * Returns the new User ID, or null on failure.
27
+ */
28
+ private createUser;
29
+ /**
30
+ * Assign the default MJ "UI" role to a User via the UserRole entity.
31
+ * Uses Metadata.Roles (cached) for role lookup instead of a DB query.
32
+ */
33
+ private assignDefaultUserRole;
34
+ /**
35
+ * Sync Person name/email changes to the linked MJ User record.
36
+ * Called post-save — updates name/email fields and ensures the
37
+ * bidirectional back-pointer (LinkedEntityID / LinkedEntityRecordID) is set.
38
+ */
39
+ private syncUserRecord;
40
+ /**
41
+ * Set the back-pointer fields on the User so the User → Person
42
+ * relationship is bidirectional. Only sets fields if not already populated.
43
+ */
44
+ private setUserBackPointer;
45
+ /**
46
+ * Deactivate the linked User on Person deletion.
47
+ * Sets IsActive=false rather than deleting, to preserve audit history.
48
+ */
49
+ private deactivateLinkedUser;
50
+ /**
51
+ * Build a display-friendly full name from Person fields.
52
+ */
53
+ private buildFullName;
54
+ }
55
+ //# sourceMappingURL=PersonEntityServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersonEntityServer.d.ts","sourceRoot":"","sources":["../src/PersonEntityServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,mBAAmB,EAAE,iBAAiB,EAAgC,MAAM,sBAAsB,CAAC;AAExH,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAW3E;;;;;;;GAOG;AACH,qBACa,kBAAmB,SAAQ,2BAA2B;IAEhD,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAwBnD,MAAM,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAStE;;;OAGG;YACW,YAAY;IAkB1B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAO7B;;;OAGG;YACW,UAAU;IA8BxB;;;OAGG;YACW,qBAAqB;IA+BnC;;;;OAIG;YACW,cAAc;IAyC5B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAU1B;;;OAGG;YACW,oBAAoB;IAqBlC;;OAEG;IACH,OAAO,CAAC,aAAa;CAMxB"}
@@ -0,0 +1,234 @@
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
+ import { BaseEntity, LogError, Metadata } from '@memberjunction/core';
8
+ import { RegisterClass } from '@memberjunction/global';
9
+ import { mjBizAppsCommonPersonEntity } from '@mj-biz-apps/common-entities';
10
+ import { UserCache } from '@memberjunction/sqlserver-dataprovider';
11
+ /**
12
+ * The standard MJ "UI" role name — assigned as a default when creating
13
+ * a new User linked to a Person. Downstream layers (e.g., BCSaaS) override
14
+ * this with more specific roles.
15
+ */
16
+ const DEFAULT_MJ_ROLE_NAME = 'UI';
17
+ /**
18
+ * Server-side subclass of the BAC Person entity.
19
+ *
20
+ * Lifecycle hooks:
21
+ * - **Save (pre):** Auto-links to an MJ User record (creates one if needed)
22
+ * - **Save (post):** Syncs name/email changes to the linked User; assigns default "UI" UserRole
23
+ * - **Delete:** Deactivates the linked User (does not delete — preserves audit history)
24
+ */
25
+ let PersonEntityServer = class PersonEntityServer extends mjBizAppsCommonPersonEntity {
26
+ async Save(options) {
27
+ const isNewRecord = !this.IsSaved;
28
+ const emailField = this.GetFieldByName('Email');
29
+ const emailChanged = emailField?.Dirty === true;
30
+ const needsUserLink = isNewRecord || emailChanged;
31
+ // Pre-save: auto-link to MJ User
32
+ if (needsUserLink && this.Email && !this.LinkedUserID) {
33
+ await this.autoLinkUser();
34
+ }
35
+ const saved = await super.Save(options);
36
+ if (!saved) {
37
+ return false;
38
+ }
39
+ // Post-save: sync person changes to linked User
40
+ if (this.LinkedUserID) {
41
+ await this.syncUserRecord(isNewRecord, emailChanged);
42
+ }
43
+ return true;
44
+ }
45
+ async Delete(options) {
46
+ // Pre-delete: deactivate linked User (don't delete — audit history)
47
+ if (this.LinkedUserID) {
48
+ await this.deactivateLinkedUser();
49
+ }
50
+ return super.Delete(options);
51
+ }
52
+ /**
53
+ * Find an existing MJ User by email, or create a new one.
54
+ * Sets LinkedUserID on the Person entity (pre-save, so it's persisted atomically).
55
+ */
56
+ async autoLinkUser() {
57
+ try {
58
+ const existingUser = this.findCachedUserByEmail(this.Email);
59
+ if (existingUser) {
60
+ this.LinkedUserID = existingUser.ID;
61
+ }
62
+ else {
63
+ const newUserID = await this.createUser();
64
+ if (newUserID) {
65
+ this.LinkedUserID = newUserID;
66
+ }
67
+ }
68
+ }
69
+ catch (error) {
70
+ LogError(`PersonEntityServer: Failed to auto-link User for email ${this.Email}: ${error}`);
71
+ // Don't block save — User linking is best-effort
72
+ }
73
+ }
74
+ /**
75
+ * Find an existing MJ User by email using the cached UserCache.
76
+ * UserCache is populated at server startup and refreshed periodically.
77
+ */
78
+ findCachedUserByEmail(email) {
79
+ const normalizedEmail = email.toLowerCase();
80
+ return UserCache.Users.find(u => u.Email.toLowerCase() === normalizedEmail);
81
+ }
82
+ /**
83
+ * Create a new MJ User record from the Person's details.
84
+ * Returns the new User ID, or null on failure.
85
+ */
86
+ async createUser() {
87
+ try {
88
+ const md = new Metadata();
89
+ const user = await md.GetEntityObject('MJ: Users', this.ContextCurrentUser);
90
+ user.NewRecord();
91
+ const fullName = this.buildFullName();
92
+ user.Name = fullName;
93
+ user.FirstName = this.FirstName;
94
+ user.LastName = this.LastName;
95
+ user.Email = this.Email;
96
+ user.Type = 'User';
97
+ user.IsActive = true;
98
+ const saved = await user.Save();
99
+ if (!saved) {
100
+ LogError(`PersonEntityServer: Failed to save new User for ${this.Email}`);
101
+ return null;
102
+ }
103
+ // Assign default "UI" role to the new user
104
+ await this.assignDefaultUserRole(user.ID);
105
+ return user.ID;
106
+ }
107
+ catch (error) {
108
+ LogError(`PersonEntityServer: Error creating User for ${this.Email}: ${error}`);
109
+ return null;
110
+ }
111
+ }
112
+ /**
113
+ * Assign the default MJ "UI" role to a User via the UserRole entity.
114
+ * Uses Metadata.Roles (cached) for role lookup instead of a DB query.
115
+ */
116
+ async assignDefaultUserRole(userID) {
117
+ try {
118
+ const md = new Metadata();
119
+ const role = md.Roles.find(r => r.Name.toLowerCase() === DEFAULT_MJ_ROLE_NAME.toLowerCase());
120
+ if (!role) {
121
+ LogError(`PersonEntityServer: MJ Role '${DEFAULT_MJ_ROLE_NAME}' not found in Metadata.Roles — cannot assign default UserRole`);
122
+ return;
123
+ }
124
+ // Check if the user already has this role via UserCache
125
+ const cachedUser = UserCache.Users.find(u => u.ID === userID);
126
+ if (cachedUser?.UserRoles?.find(ur => ur.RoleID === role.ID)) {
127
+ return; // Already has this role
128
+ }
129
+ const userRole = await md.GetEntityObject('MJ: User Roles', this.ContextCurrentUser);
130
+ userRole.NewRecord();
131
+ userRole.UserID = userID;
132
+ userRole.RoleID = role.ID;
133
+ const saved = await userRole.Save();
134
+ if (!saved) {
135
+ LogError(`PersonEntityServer: Failed to assign '${DEFAULT_MJ_ROLE_NAME}' role to User ${userID}`);
136
+ }
137
+ }
138
+ catch (error) {
139
+ LogError(`PersonEntityServer: Error assigning default UserRole: ${error}`);
140
+ }
141
+ }
142
+ /**
143
+ * Sync Person name/email changes to the linked MJ User record.
144
+ * Called post-save — updates name/email fields and ensures the
145
+ * bidirectional back-pointer (LinkedEntityID / LinkedEntityRecordID) is set.
146
+ */
147
+ async syncUserRecord(isNewRecord, emailChanged) {
148
+ const nameFields = ['FirstName', 'LastName', 'MiddleName', 'Prefix', 'Suffix'];
149
+ const nameChanged = nameFields.some(f => this.GetFieldByName(f)?.Dirty === true);
150
+ // For existing records with no field changes and no back-pointer work, skip
151
+ if (!isNewRecord && !nameChanged && !emailChanged) {
152
+ return;
153
+ }
154
+ try {
155
+ const md = new Metadata();
156
+ const user = await md.GetEntityObject('MJ: Users', this.ContextCurrentUser);
157
+ const loaded = await user.Load(this.LinkedUserID);
158
+ if (!loaded) {
159
+ LogError(`PersonEntityServer: Could not load linked User ${this.LinkedUserID} for sync`);
160
+ return;
161
+ }
162
+ if (nameChanged || isNewRecord) {
163
+ user.Name = this.buildFullName();
164
+ user.FirstName = this.FirstName;
165
+ user.LastName = this.LastName;
166
+ }
167
+ if (emailChanged && this.Email) {
168
+ user.Email = this.Email;
169
+ }
170
+ // Ensure bidirectional link: User → Person
171
+ this.setUserBackPointer(user);
172
+ const saved = await user.Save();
173
+ if (!saved) {
174
+ LogError(`PersonEntityServer: Failed to sync User ${this.LinkedUserID} after Person update`);
175
+ }
176
+ }
177
+ catch (error) {
178
+ LogError(`PersonEntityServer: Error syncing User record: ${error}`);
179
+ // Don't block — sync is best-effort
180
+ }
181
+ }
182
+ /**
183
+ * Set the back-pointer fields on the User so the User → Person
184
+ * relationship is bidirectional. Only sets fields if not already populated.
185
+ */
186
+ setUserBackPointer(user) {
187
+ if (user.LinkedEntityRecordID) {
188
+ return; // Already linked — nothing to do
189
+ }
190
+ user.LinkedRecordType = 'Person';
191
+ user.LinkedEntityID = this.EntityInfo.ID;
192
+ user.LinkedEntityRecordID = this.ID;
193
+ }
194
+ /**
195
+ * Deactivate the linked User on Person deletion.
196
+ * Sets IsActive=false rather than deleting, to preserve audit history.
197
+ */
198
+ async deactivateLinkedUser() {
199
+ try {
200
+ const md = new Metadata();
201
+ const user = await md.GetEntityObject('MJ: Users', this.ContextCurrentUser);
202
+ const loaded = await user.Load(this.LinkedUserID);
203
+ if (!loaded) {
204
+ return;
205
+ }
206
+ if (user.IsActive) {
207
+ user.IsActive = false;
208
+ const saved = await user.Save();
209
+ if (!saved) {
210
+ LogError(`PersonEntityServer: Failed to deactivate User ${this.LinkedUserID}`);
211
+ }
212
+ }
213
+ }
214
+ catch (error) {
215
+ LogError(`PersonEntityServer: Error deactivating linked User: ${error}`);
216
+ }
217
+ }
218
+ /**
219
+ * Build a display-friendly full name from Person fields.
220
+ */
221
+ buildFullName() {
222
+ const parts = [];
223
+ if (this.FirstName)
224
+ parts.push(this.FirstName);
225
+ if (this.LastName)
226
+ parts.push(this.LastName);
227
+ return parts.length > 0 ? parts.join(' ') : (this.Email ?? 'Unknown');
228
+ }
229
+ };
230
+ PersonEntityServer = __decorate([
231
+ RegisterClass(BaseEntity, 'MJ_BizApps_Common: People')
232
+ ], PersonEntityServer);
233
+ export { PersonEntityServer };
234
+ //# sourceMappingURL=PersonEntityServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersonEntity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CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC;IAC1E,CAAC;CACJ,CAAA;AAvOY,kBAAkB;IAD9B,aAAa,CAAC,UAAU,EAAE,2BAA2B,CAAC;GAC1C,kBAAkB,CAuO9B"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @mj-biz-apps/common-core-entities-server
3
+ *
4
+ * Server-side entity subclasses for BizApps Common entities.
5
+ * These classes override Save() and Delete() to add lifecycle hooks
6
+ * (User auto-linking, default role assignment, etc.) that only run on the server.
7
+ *
8
+ * Import this package from your server bootstrap to ensure @RegisterClass
9
+ * decorators fire at startup.
10
+ */
11
+ export { PersonEntityServer } from './PersonEntityServer.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @mj-biz-apps/common-core-entities-server
3
+ *
4
+ * Server-side entity subclasses for BizApps Common entities.
5
+ * These classes override Save() and Delete() to add lifecycle hooks
6
+ * (User auto-linking, default role assignment, etc.) that only run on the server.
7
+ *
8
+ * Import this package from your server bootstrap to ensure @RegisterClass
9
+ * decorators fire at startup.
10
+ */
11
+ export { PersonEntityServer } from './PersonEntityServer.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,36 @@
1
1
  {
2
2
  "name": "@mj-biz-apps/common-core-entities-server",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @mj-biz-apps/common-core-entities-server",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
3
+ "type": "module",
4
+ "version": "5.30.0",
5
+ "description": "Server-side entity subclasses for BizApps Common — lifecycle hooks for People, Organizations, etc.",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "files": [
12
+ "/dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc && tsc-alias -f",
16
+ "test": "echo \"No tests configured yet\""
17
+ },
18
+ "author": "MemberJunction.com",
19
+ "license": "ISC",
20
+ "devDependencies": {
21
+ "typescript": "^5.9.3"
22
+ },
23
+ "dependencies": {
24
+ "@mj-biz-apps/common-entities": "5.30.0"
25
+ },
26
+ "peerDependencies": {
27
+ "@memberjunction/core": "^5.33.0",
28
+ "@memberjunction/core-entities": "^5.33.0",
29
+ "@memberjunction/global": "^5.33.0",
30
+ "@memberjunction/sqlserver-dataprovider": "^5.33.0"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/MemberJunction/bizapps-common"
35
+ }
10
36
  }
package/README.md DELETED
@@ -1,45 +0,0 @@
1
- # @mj-biz-apps/common-core-entities-server
2
-
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@mj-biz-apps/common-core-entities-server`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**