@api-client/core 0.18.25 → 0.18.27

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 (44) hide show
  1. package/build/src/modeling/Semantics.d.ts +193 -0
  2. package/build/src/modeling/Semantics.d.ts.map +1 -1
  3. package/build/src/modeling/Semantics.js +134 -0
  4. package/build/src/modeling/Semantics.js.map +1 -1
  5. package/build/src/modeling/helpers/Intelisense.d.ts +7 -7
  6. package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -1
  7. package/build/src/modeling/helpers/Intelisense.js.map +1 -1
  8. package/build/src/modeling/templates/meta/blog-publishing-platform.json +1 -1
  9. package/build/src/modeling/templates/meta/financial-services-platform.json +1 -1
  10. package/build/src/modeling/templates/meta/index.d.ts +1 -1
  11. package/build/src/modeling/templates/meta/index.js +1 -1
  12. package/build/src/modeling/templates/meta/index.js.map +1 -1
  13. package/build/src/modeling/templates/meta/iot-smart-home-platform.json +1 -1
  14. package/build/src/modeling/templates/verticals/business-services/financial-services-domain.d.ts.map +1 -1
  15. package/build/src/modeling/templates/verticals/business-services/financial-services-domain.js +249 -63
  16. package/build/src/modeling/templates/verticals/business-services/financial-services-domain.js.map +1 -1
  17. package/build/src/modeling/templates/verticals/technology-media/blog-domain.d.ts.map +1 -1
  18. package/build/src/modeling/templates/verticals/technology-media/blog-domain.js +17 -9
  19. package/build/src/modeling/templates/verticals/technology-media/blog-domain.js.map +1 -1
  20. package/build/src/modeling/templates/verticals/technology-media/iot-smart-home-domain.d.ts.map +1 -1
  21. package/build/src/modeling/templates/verticals/technology-media/iot-smart-home-domain.js +2 -0
  22. package/build/src/modeling/templates/verticals/technology-media/iot-smart-home-domain.js.map +1 -1
  23. package/build/src/modeling/validation/postgresql.d.ts.map +1 -1
  24. package/build/src/modeling/validation/postgresql.js +0 -1
  25. package/build/src/modeling/validation/postgresql.js.map +1 -1
  26. package/build/src/runtime/modeling/Semantics.d.ts +84 -0
  27. package/build/src/runtime/modeling/Semantics.d.ts.map +1 -0
  28. package/build/src/runtime/modeling/Semantics.js +124 -0
  29. package/build/src/runtime/modeling/Semantics.js.map +1 -0
  30. package/build/tsconfig.tsbuildinfo +1 -1
  31. package/data/models/example-generator-api.json +14 -14
  32. package/package.json +1 -1
  33. package/src/modeling/Semantics.ts +262 -0
  34. package/src/modeling/helpers/Intelisense.ts +7 -7
  35. package/src/modeling/templates/meta/blog-publishing-platform.json +1 -1
  36. package/src/modeling/templates/meta/financial-services-platform.json +1 -1
  37. package/src/modeling/templates/meta/iot-smart-home-platform.json +1 -1
  38. package/src/modeling/templates/verticals/business-services/financial-services-domain.ts +286 -65
  39. package/src/modeling/templates/verticals/technology-media/blog-domain.ts +17 -9
  40. package/src/modeling/templates/verticals/technology-media/iot-smart-home-domain.ts +2 -0
  41. package/src/modeling/validation/postgresql.ts +0 -1
  42. package/src/runtime/modeling/Semantics.ts +196 -0
  43. package/tests/unit/modeling/client_ip_address_semantic.spec.ts +71 -0
  44. package/tests/unit/modeling/username_semantic.spec.ts +81 -0
@@ -23,6 +23,7 @@
23
23
  * ```
24
24
  */
25
25
  import { DataDomain } from '../../../DataDomain.js';
26
+ import { SemanticType } from '../../../Semantics.js';
26
27
  import { addIdField, addNameField, addDescriptionField, addEmailField, addFirstNameField, addLastNameField, addPhoneField, addCustomStatusField, addCreatedAtField, addUpdatedAtField, addCurrencyAmountField, } from '../../../helpers/Intelisense.js';
27
28
  function createDomain() {
28
29
  return new DataDomain({
@@ -50,72 +51,187 @@ export default function createFinancialServicesDomain(options = {}) {
50
51
  // Ensure the root data domain
51
52
  const domain = options.domain ?? createDomain();
52
53
  //
53
- // 1. CUSTOMER MANAGEMENT NAMESPACE
54
+ // 1. USER & AUTHENTICATION NAMESPACE (Unified for customers and employees)
54
55
  //
55
- const customerManagement = domain.addNamespace({
56
+ const userManagement = domain.addNamespace({
56
57
  info: {
57
- name: 'CustomerManagement',
58
- displayName: 'Customer Management',
59
- description: 'Customer profiles, KYC, risk assessment, and segmentation',
58
+ name: 'User Management',
59
+ displayName: 'User & Authentication Management',
60
+ description: 'Unified user authentication, roles, and profile management for customers and employees',
60
61
  },
61
62
  });
62
- // Customer Model
63
- const customerModel = customerManagement.addModel({
63
+ // Authentication Model
64
+ const authModel = userManagement.addModel({
64
65
  info: {
65
- name: 'Customers',
66
- displayName: 'Customer Management',
67
- description: 'Customer profiles and information',
66
+ name: 'Authentication',
67
+ displayName: 'Authentication & Access Control',
68
+ description: 'User authentication, sessions, and access control',
68
69
  },
69
70
  });
70
- // Customer Entity
71
- const customerEntity = customerModel.addEntity({
71
+ // Unified User Entity (replaces separate Customer and Employee entities)
72
+ const userEntity = authModel.addEntity({
72
73
  info: {
73
- name: 'customer',
74
- displayName: 'Customer',
75
- description: 'Financial services customer with KYC and risk profile',
74
+ name: 'user',
75
+ displayName: 'User',
76
+ description: 'Unified user entity for both customers and employees with role-based access',
76
77
  },
78
+ semantics: [{ id: SemanticType.User }], // Mark as a user entity for automatic behaviors
77
79
  });
78
- addIdField(customerEntity, { displayName: 'Customer ID', description: 'Unique identifier for the customer' });
79
- addFirstNameField(customerEntity, { description: 'Customer first name' });
80
- addLastNameField(customerEntity, { description: 'Customer last name' });
81
- customerEntity.addProperty({
80
+ addIdField(userEntity, { displayName: 'User ID', description: 'Unique identifier for the user' });
81
+ // Authentication fields
82
+ userEntity.addProperty({
83
+ info: { name: 'username', displayName: 'Username', description: 'Unique username for login' },
84
+ type: 'string',
85
+ required: true,
86
+ unique: true,
87
+ });
88
+ userEntity.addProperty({
89
+ info: { name: 'password', displayName: 'Password', description: 'User password (hashed)' },
90
+ type: 'string',
91
+ required: true,
92
+ writeOnly: true,
93
+ semantics: [{ id: SemanticType.Password }], // Automatic password security behaviors
94
+ });
95
+ const emailProperty = addEmailField(userEntity, { description: 'User email address' });
96
+ emailProperty.required = true;
97
+ emailProperty.unique = true;
98
+ // Personal Information
99
+ addFirstNameField(userEntity, { description: 'User first name' });
100
+ addLastNameField(userEntity, { description: 'User last name' });
101
+ addPhoneField(userEntity, { description: 'User phone number' });
102
+ // User Type & Role (unified approach)
103
+ userEntity.addProperty({
104
+ info: { name: 'user_type', displayName: 'User Type', description: 'Type of user account' },
105
+ type: 'string',
106
+ required: true,
107
+ schema: {
108
+ enum: ['customer', 'employee', 'admin', 'system'],
109
+ },
110
+ });
111
+ userEntity.addProperty({
112
+ info: { name: 'role', displayName: 'User Role', description: 'User role defining permissions and access level' },
113
+ type: 'string',
114
+ required: true,
115
+ schema: {
116
+ enum: [
117
+ // Customer roles
118
+ 'individual_customer',
119
+ 'business_customer',
120
+ 'premium_customer',
121
+ 'private_banking_customer',
122
+ // Employee roles
123
+ 'teller',
124
+ 'loan_officer',
125
+ 'relationship_manager',
126
+ 'compliance_officer',
127
+ 'branch_manager',
128
+ 'investment_advisor',
129
+ 'risk_analyst',
130
+ // Admin roles
131
+ 'system_admin',
132
+ 'security_admin',
133
+ 'audit_admin',
134
+ ],
135
+ },
136
+ semantics: [{ id: SemanticType.UserRole }],
137
+ });
138
+ // Status and verification
139
+ addCustomStatusField(userEntity, ['active', 'inactive', 'suspended', 'pending_verification', 'locked'], {
140
+ displayName: 'User Status',
141
+ description: 'Current status of the user account',
142
+ });
143
+ userEntity.addProperty({
144
+ info: { name: 'email_verified', displayName: 'Email Verified', description: 'Whether user email is verified' },
145
+ type: 'boolean',
146
+ required: true,
147
+ });
148
+ userEntity.addProperty({
149
+ info: { name: 'last_login', displayName: 'Last Login', description: 'When user last logged in' },
150
+ type: 'datetime',
151
+ });
152
+ addCreatedAtField(userEntity, { description: 'When the user account was created' });
153
+ addUpdatedAtField(userEntity, { description: 'When the user account was last updated' });
154
+ // Session Entity for authentication management
155
+ const sessionEntity = authModel.addEntity({
156
+ info: {
157
+ name: 'user_session',
158
+ displayName: 'User Session',
159
+ description: 'Active user authentication sessions',
160
+ },
161
+ });
162
+ addIdField(sessionEntity, { displayName: 'Session ID', description: 'Unique session identifier' });
163
+ sessionEntity.addProperty({
164
+ info: { name: 'token', displayName: 'Session Token', description: 'Authentication token for the session' },
165
+ type: 'string',
166
+ required: true,
167
+ writeOnly: true,
168
+ });
169
+ sessionEntity.addProperty({
170
+ info: { name: 'expires_at', displayName: 'Expires At', description: 'When the session expires' },
171
+ type: 'datetime',
172
+ required: true,
173
+ });
174
+ sessionEntity.addProperty({
175
+ info: { name: 'ip_address', displayName: 'IP Address', description: 'IP address of the session' },
176
+ type: 'string',
177
+ semantics: [{ id: SemanticType.ClientIPAddress }],
178
+ });
179
+ addCreatedAtField(sessionEntity, { description: 'When the session was created' });
180
+ // User-Session Association
181
+ userEntity.addAssociation({ key: sessionEntity.key }, {
182
+ info: { name: 'sessions', displayName: 'User Sessions', description: 'Active sessions for this user' },
183
+ required: false,
184
+ multiple: true,
185
+ });
186
+ // Profile Model (for extended user information)
187
+ const profileModel = userManagement.addModel({
188
+ info: {
189
+ name: 'User Profiles',
190
+ displayName: 'User Profile Management',
191
+ description: 'Extended user profile information and preferences',
192
+ },
193
+ });
194
+ // Customer Profile Entity (for customer-specific information)
195
+ const customerProfileEntity = profileModel.addEntity({
196
+ info: {
197
+ name: 'customer_profile',
198
+ displayName: 'Customer Profile',
199
+ description: 'Additional profile information specific to customers',
200
+ },
201
+ });
202
+ addIdField(customerProfileEntity, { displayName: 'Profile ID', description: 'Unique profile identifier' });
203
+ customerProfileEntity.addProperty({
82
204
  info: { name: 'date_of_birth', displayName: 'Date of Birth', description: 'Customer date of birth' },
83
205
  type: 'date',
84
206
  required: true,
85
207
  });
86
- customerEntity.addProperty({
208
+ customerProfileEntity.addProperty({
87
209
  info: { name: 'ssn', displayName: 'Social Security Number', description: 'Customer SSN for identification' },
88
210
  type: 'string',
89
211
  required: true,
90
- writeOnly: true, // Sensitive data - write only
212
+ writeOnly: true,
91
213
  });
92
- addEmailField(customerEntity, { description: 'Customer email address' });
93
- addPhoneField(customerEntity, { description: 'Customer phone number' });
94
- customerEntity.addProperty({
214
+ customerProfileEntity.addProperty({
95
215
  info: { name: 'address', displayName: 'Address', description: 'Customer residential address' },
96
216
  type: 'string',
97
217
  required: true,
98
218
  });
99
- customerEntity.addProperty({
219
+ customerProfileEntity.addProperty({
100
220
  info: { name: 'city', displayName: 'City', description: 'Customer city' },
101
221
  type: 'string',
102
222
  required: true,
103
223
  });
104
- customerEntity.addProperty({
224
+ customerProfileEntity.addProperty({
105
225
  info: { name: 'state', displayName: 'State', description: 'Customer state' },
106
226
  type: 'string',
107
227
  required: true,
108
228
  });
109
- customerEntity.addProperty({
229
+ customerProfileEntity.addProperty({
110
230
  info: { name: 'zip_code', displayName: 'ZIP Code', description: 'Customer ZIP code' },
111
231
  type: 'string',
112
232
  required: true,
113
233
  });
114
- addCustomStatusField(customerEntity, ['active', 'inactive', 'suspended', 'pending_verification'], {
115
- displayName: 'Customer Status',
116
- description: 'Current status of the customer account',
117
- });
118
- customerEntity.addProperty({
234
+ customerProfileEntity.addProperty({
119
235
  info: { name: 'customer_type', displayName: 'Customer Type', description: 'Type of customer account' },
120
236
  type: 'string',
121
237
  required: true,
@@ -123,12 +239,79 @@ export default function createFinancialServicesDomain(options = {}) {
123
239
  enum: ['individual', 'business', 'trust', 'partnership'],
124
240
  },
125
241
  });
126
- addCreatedAtField(customerEntity, { description: 'When the customer account was created' });
127
- addUpdatedAtField(customerEntity, { description: 'When the customer account was last updated' });
128
- // KYC Entity
129
- const kycEntity = customerModel.addEntity({
242
+ addCreatedAtField(customerProfileEntity, { description: 'When the customer profile was created' });
243
+ addUpdatedAtField(customerProfileEntity, { description: 'When the customer profile was last updated' });
244
+ // User-CustomerProfile Association (one-to-one for customers)
245
+ userEntity.addAssociation({ key: customerProfileEntity.key }, {
246
+ info: {
247
+ name: 'customer_profile',
248
+ displayName: 'Customer Profile',
249
+ description: 'Extended customer profile information',
250
+ },
251
+ required: false, // Only for customers, not employees
252
+ multiple: false,
253
+ });
254
+ // Employee Profile Entity (for employee-specific information)
255
+ const employeeProfileEntity = profileModel.addEntity({
256
+ info: {
257
+ name: 'employee_profile',
258
+ displayName: 'Employee Profile',
259
+ description: 'Additional profile information specific to employees',
260
+ },
261
+ });
262
+ addIdField(employeeProfileEntity, {
263
+ displayName: 'Employee Profile ID',
264
+ description: 'Unique employee profile identifier',
265
+ });
266
+ employeeProfileEntity.addProperty({
267
+ info: { name: 'employee_id', displayName: 'Employee ID', description: 'Company employee identifier' },
268
+ type: 'string',
269
+ required: true,
270
+ unique: true,
271
+ });
272
+ employeeProfileEntity.addProperty({
273
+ info: { name: 'department', displayName: 'Department', description: 'Employee department' },
274
+ type: 'string',
275
+ required: true,
276
+ schema: {
277
+ enum: [
278
+ 'retail_banking',
279
+ 'commercial_banking',
280
+ 'investment_services',
281
+ 'risk_management',
282
+ 'compliance',
283
+ 'operations',
284
+ 'technology',
285
+ 'human_resources',
286
+ 'legal',
287
+ ],
288
+ },
289
+ });
290
+ employeeProfileEntity.addProperty({
291
+ info: { name: 'hire_date', displayName: 'Hire Date', description: 'Employee hire date' },
292
+ type: 'date',
293
+ required: true,
294
+ });
295
+ employeeProfileEntity.addProperty({
296
+ info: { name: 'manager_id', displayName: 'Manager ID', description: 'Employee manager identifier' },
297
+ type: 'string',
298
+ });
299
+ addCreatedAtField(employeeProfileEntity, { description: 'When the employee profile was created' });
300
+ addUpdatedAtField(employeeProfileEntity, { description: 'When the employee profile was last updated' });
301
+ // User-EmployeeProfile Association (one-to-one for employees)
302
+ userEntity.addAssociation({ key: employeeProfileEntity.key }, {
303
+ info: {
304
+ name: 'employee_profile',
305
+ displayName: 'Employee Profile',
306
+ description: 'Extended employee profile information',
307
+ },
308
+ required: false, // Only for employees, not customers
309
+ multiple: false,
310
+ });
311
+ // KYC Entity (enhanced for the unified approach)
312
+ const kycEntity = profileModel.addEntity({
130
313
  info: {
131
- name: 'kyc',
314
+ name: 'kyc_record',
132
315
  displayName: 'KYC Record',
133
316
  description: 'Know Your Customer verification and documentation',
134
317
  },
@@ -156,14 +339,15 @@ export default function createFinancialServicesDomain(options = {}) {
156
339
  required: true,
157
340
  });
158
341
  addCreatedAtField(kycEntity, { description: 'When the KYC record was created' });
159
- // KYC-Customer Association (One-to-One)
160
- kycEntity.addAssociation({ key: customerEntity.key }, {
161
- info: { name: 'customer', displayName: 'Customer', description: 'Customer for this KYC record' },
342
+ addUpdatedAtField(kycEntity, { description: 'When the KYC record was last updated' });
343
+ // KYC-User Association (One-to-One)
344
+ kycEntity.addAssociation({ key: userEntity.key }, {
345
+ info: { name: 'user', displayName: 'User', description: 'User for this KYC record' },
162
346
  required: true,
163
347
  multiple: false,
164
348
  });
165
349
  // Risk Profile Entity
166
- const riskProfileEntity = customerModel.addEntity({
350
+ const riskProfileEntity = profileModel.addEntity({
167
351
  info: {
168
352
  name: 'risk_profile',
169
353
  displayName: 'Risk Profile',
@@ -194,9 +378,10 @@ export default function createFinancialServicesDomain(options = {}) {
194
378
  });
195
379
  addDescriptionField(riskProfileEntity, { description: 'Risk assessment notes and factors' });
196
380
  addCreatedAtField(riskProfileEntity, { description: 'When the risk profile was created' });
197
- // RiskProfile-Customer Association (One-to-One)
198
- riskProfileEntity.addAssociation({ key: customerEntity.key }, {
199
- info: { name: 'customer', displayName: 'Customer', description: 'Customer for this risk profile' },
381
+ addUpdatedAtField(riskProfileEntity, { description: 'When the risk profile was last updated' });
382
+ // RiskProfile-User Association (One-to-One)
383
+ riskProfileEntity.addAssociation({ key: userEntity.key }, {
384
+ info: { name: 'user', displayName: 'User', description: 'User for this risk profile' },
200
385
  required: true,
201
386
  multiple: false,
202
387
  });
@@ -258,9 +443,9 @@ export default function createFinancialServicesDomain(options = {}) {
258
443
  });
259
444
  addCreatedAtField(bankAccountEntity, { description: 'When the account was created' });
260
445
  addUpdatedAtField(bankAccountEntity, { description: 'When the account was last updated' });
261
- // BankAccount-Customer Association (Many-to-One)
262
- bankAccountEntity.addAssociation({ key: customerEntity.key }, {
263
- info: { name: 'customer', displayName: 'Account Holder', description: 'Customer who owns this account' },
446
+ // BankAccount-User Association (Many-to-One)
447
+ bankAccountEntity.addAssociation({ key: userEntity.key }, {
448
+ info: { name: 'user', displayName: 'Account Holder', description: 'User who owns this account' },
264
449
  required: true,
265
450
  multiple: false,
266
451
  });
@@ -301,12 +486,12 @@ export default function createFinancialServicesDomain(options = {}) {
301
486
  description: 'Current status of the investment account',
302
487
  });
303
488
  addCreatedAtField(investmentAccountEntity, { description: 'When the investment account was created' });
304
- // InvestmentAccount-Customer Association (Many-to-One)
305
- investmentAccountEntity.addAssociation({ key: customerEntity.key }, {
489
+ // InvestmentAccount-User Association (Many-to-One)
490
+ investmentAccountEntity.addAssociation({ key: userEntity.key }, {
306
491
  info: {
307
- name: 'customer',
492
+ name: 'user',
308
493
  displayName: 'Account Holder',
309
- description: 'Customer who owns this investment account',
494
+ description: 'User who owns this investment account',
310
495
  },
311
496
  required: true,
312
497
  multiple: false,
@@ -349,9 +534,9 @@ export default function createFinancialServicesDomain(options = {}) {
349
534
  description: 'Current status of the credit card',
350
535
  });
351
536
  addCreatedAtField(creditCardEntity, { description: 'When the credit card was created' });
352
- // CreditCard-Customer Association (Many-to-One)
353
- creditCardEntity.addAssociation({ key: customerEntity.key }, {
354
- info: { name: 'customer', displayName: 'Cardholder', description: 'Customer who owns this credit card' },
537
+ // CreditCard-User Association (Many-to-One)
538
+ creditCardEntity.addAssociation({ key: userEntity.key }, {
539
+ info: { name: 'user', displayName: 'Cardholder', description: 'User who owns this credit card' },
355
540
  required: true,
356
541
  multiple: false,
357
542
  });
@@ -360,7 +545,7 @@ export default function createFinancialServicesDomain(options = {}) {
360
545
  //
361
546
  const transactionProcessing = domain.addNamespace({
362
547
  info: {
363
- name: 'TransactionProcessing',
548
+ name: 'Transaction Processing',
364
549
  displayName: 'Transaction Processing',
365
550
  description: 'Payments, transfers, deposits, and withdrawals',
366
551
  },
@@ -421,9 +606,9 @@ export default function createFinancialServicesDomain(options = {}) {
421
606
  type: 'string',
422
607
  });
423
608
  addCreatedAtField(transactionEntity, { description: 'When the transaction was created' });
424
- // Transaction-Customer Association (Many-to-One)
425
- transactionEntity.addAssociation({ key: customerEntity.key }, {
426
- info: { name: 'customer', displayName: 'Customer', description: 'Customer who initiated the transaction' },
609
+ // Transaction-User Association (Many-to-One)
610
+ transactionEntity.addAssociation({ key: userEntity.key }, {
611
+ info: { name: 'user', displayName: 'User', description: 'User who initiated the transaction' },
427
612
  required: true,
428
613
  multiple: false,
429
614
  });
@@ -472,7 +657,7 @@ export default function createFinancialServicesDomain(options = {}) {
472
657
  //
473
658
  const investmentPortfolio = domain.addNamespace({
474
659
  info: {
475
- name: 'InvestmentPortfolio',
660
+ name: 'Investment Portfolio',
476
661
  displayName: 'Investment Portfolio',
477
662
  description: 'Assets, positions, and performance tracking',
478
663
  },
@@ -596,7 +781,7 @@ export default function createFinancialServicesDomain(options = {}) {
596
781
  //
597
782
  const complianceReporting = domain.addNamespace({
598
783
  info: {
599
- name: 'ComplianceReporting',
784
+ name: 'Compliance Reporting',
600
785
  displayName: 'Compliance & Reporting',
601
786
  description: 'Regulatory reporting and audit trails',
602
787
  },
@@ -641,6 +826,7 @@ export default function createFinancialServicesDomain(options = {}) {
641
826
  auditTrailEntity.addProperty({
642
827
  info: { name: 'ip_address', displayName: 'IP Address', description: 'IP address of the user' },
643
828
  type: 'string',
829
+ semantics: [{ id: SemanticType.ClientIPAddress }],
644
830
  });
645
831
  addDescriptionField(auditTrailEntity, { description: 'Additional details about the action' });
646
832
  addCreatedAtField(auditTrailEntity, {
@@ -733,9 +919,9 @@ export default function createFinancialServicesDomain(options = {}) {
733
919
  required: false,
734
920
  multiple: false,
735
921
  });
736
- // FraudAlert-Customer Association (Many-to-One)
737
- fraudAlertEntity.addAssociation({ key: customerEntity.key }, {
738
- info: { name: 'customer', displayName: 'Customer', description: 'Customer associated with the alert' },
922
+ // FraudAlert-User Association (Many-to-One)
923
+ fraudAlertEntity.addAssociation({ key: userEntity.key }, {
924
+ info: { name: 'user', displayName: 'User', description: 'User associated with the alert' },
739
925
  required: true,
740
926
  multiple: false,
741
927
  });