@api-client/core 0.18.55 → 0.18.57

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 (148) hide show
  1. package/build/src/modeling/Semantics.js +1 -1
  2. package/build/src/modeling/Semantics.js.map +1 -1
  3. package/build/src/modeling/helpers/Intelisense.d.ts +1 -0
  4. package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -1
  5. package/build/src/modeling/helpers/Intelisense.js +23 -0
  6. package/build/src/modeling/helpers/Intelisense.js.map +1 -1
  7. package/build/tsconfig.tsbuildinfo +1 -1
  8. package/data/models/example-generator-api.json +15 -15
  9. package/package.json +2 -7
  10. package/src/modeling/Semantics.ts +1 -1
  11. package/src/modeling/helpers/Intelisense.ts +23 -0
  12. package/tests/unit/modeling/helpers/intellisense.spec.ts +46 -0
  13. package/build/src/modeling/templates/index.d.ts +0 -21
  14. package/build/src/modeling/templates/index.d.ts.map +0 -1
  15. package/build/src/modeling/templates/index.js +0 -176
  16. package/build/src/modeling/templates/index.js.map +0 -1
  17. package/build/src/modeling/templates/meta/blog-publishing-platform.json +0 -1
  18. package/build/src/modeling/templates/meta/ecommerce-platform.json +0 -1
  19. package/build/src/modeling/templates/meta/education-management-platform.json +0 -1
  20. package/build/src/modeling/templates/meta/financial-services-platform.json +0 -1
  21. package/build/src/modeling/templates/meta/gaming-platform.json +0 -1
  22. package/build/src/modeling/templates/meta/healthcare-management-platform.json +0 -1
  23. package/build/src/modeling/templates/meta/hospitality-platform.json +0 -1
  24. package/build/src/modeling/templates/meta/index.d.ts +0 -64
  25. package/build/src/modeling/templates/meta/index.d.ts.map +0 -1
  26. package/build/src/modeling/templates/meta/index.js +0 -150
  27. package/build/src/modeling/templates/meta/index.js.map +0 -1
  28. package/build/src/modeling/templates/meta/iot-smart-home-platform.json +0 -1
  29. package/build/src/modeling/templates/meta/legal-services-platform.json +0 -1
  30. package/build/src/modeling/templates/meta/manufacturing-platform.json +0 -1
  31. package/build/src/modeling/templates/meta/non-profit-platform.json +0 -1
  32. package/build/src/modeling/templates/meta/real-estate-management-platform.json +0 -1
  33. package/build/src/modeling/templates/template-registry.d.ts +0 -55
  34. package/build/src/modeling/templates/template-registry.d.ts.map +0 -1
  35. package/build/src/modeling/templates/template-registry.js +0 -111
  36. package/build/src/modeling/templates/template-registry.js.map +0 -1
  37. package/build/src/modeling/templates/types.d.ts +0 -167
  38. package/build/src/modeling/templates/types.d.ts.map +0 -1
  39. package/build/src/modeling/templates/types.js +0 -2
  40. package/build/src/modeling/templates/types.js.map +0 -1
  41. package/build/src/modeling/templates/verticals/business-services/ecommerce-domain.d.ts +0 -39
  42. package/build/src/modeling/templates/verticals/business-services/ecommerce-domain.d.ts.map +0 -1
  43. package/build/src/modeling/templates/verticals/business-services/ecommerce-domain.js +0 -672
  44. package/build/src/modeling/templates/verticals/business-services/ecommerce-domain.js.map +0 -1
  45. package/build/src/modeling/templates/verticals/business-services/financial-services-domain.d.ts +0 -40
  46. package/build/src/modeling/templates/verticals/business-services/financial-services-domain.d.ts.map +0 -1
  47. package/build/src/modeling/templates/verticals/business-services/financial-services-domain.js +0 -942
  48. package/build/src/modeling/templates/verticals/business-services/financial-services-domain.js.map +0 -1
  49. package/build/src/modeling/templates/verticals/business-services/hospitality-domain.d.ts +0 -45
  50. package/build/src/modeling/templates/verticals/business-services/hospitality-domain.d.ts.map +0 -1
  51. package/build/src/modeling/templates/verticals/business-services/hospitality-domain.js +0 -797
  52. package/build/src/modeling/templates/verticals/business-services/hospitality-domain.js.map +0 -1
  53. package/build/src/modeling/templates/verticals/business-services/index.d.ts +0 -21
  54. package/build/src/modeling/templates/verticals/business-services/index.d.ts.map +0 -1
  55. package/build/src/modeling/templates/verticals/business-services/index.js +0 -50
  56. package/build/src/modeling/templates/verticals/business-services/index.js.map +0 -1
  57. package/build/src/modeling/templates/verticals/business-services/legal-services-domain.d.ts +0 -46
  58. package/build/src/modeling/templates/verticals/business-services/legal-services-domain.d.ts.map +0 -1
  59. package/build/src/modeling/templates/verticals/business-services/legal-services-domain.js +0 -837
  60. package/build/src/modeling/templates/verticals/business-services/legal-services-domain.js.map +0 -1
  61. package/build/src/modeling/templates/verticals/education-training/education-domain.d.ts +0 -40
  62. package/build/src/modeling/templates/verticals/education-training/education-domain.d.ts.map +0 -1
  63. package/build/src/modeling/templates/verticals/education-training/education-domain.js +0 -725
  64. package/build/src/modeling/templates/verticals/education-training/education-domain.js.map +0 -1
  65. package/build/src/modeling/templates/verticals/education-training/index.d.ts +0 -18
  66. package/build/src/modeling/templates/verticals/education-training/index.d.ts.map +0 -1
  67. package/build/src/modeling/templates/verticals/education-training/index.js +0 -21
  68. package/build/src/modeling/templates/verticals/education-training/index.js.map +0 -1
  69. package/build/src/modeling/templates/verticals/healthcare-life-sciences/healthcare-domain.d.ts +0 -40
  70. package/build/src/modeling/templates/verticals/healthcare-life-sciences/healthcare-domain.d.ts.map +0 -1
  71. package/build/src/modeling/templates/verticals/healthcare-life-sciences/healthcare-domain.js +0 -859
  72. package/build/src/modeling/templates/verticals/healthcare-life-sciences/healthcare-domain.js.map +0 -1
  73. package/build/src/modeling/templates/verticals/healthcare-life-sciences/index.d.ts +0 -18
  74. package/build/src/modeling/templates/verticals/healthcare-life-sciences/index.d.ts.map +0 -1
  75. package/build/src/modeling/templates/verticals/healthcare-life-sciences/index.js +0 -21
  76. package/build/src/modeling/templates/verticals/healthcare-life-sciences/index.js.map +0 -1
  77. package/build/src/modeling/templates/verticals/index.d.ts +0 -79
  78. package/build/src/modeling/templates/verticals/index.d.ts.map +0 -1
  79. package/build/src/modeling/templates/verticals/index.js +0 -186
  80. package/build/src/modeling/templates/verticals/index.js.map +0 -1
  81. package/build/src/modeling/templates/verticals/manufacturing-logistics/index.d.ts +0 -18
  82. package/build/src/modeling/templates/verticals/manufacturing-logistics/index.d.ts.map +0 -1
  83. package/build/src/modeling/templates/verticals/manufacturing-logistics/index.js +0 -22
  84. package/build/src/modeling/templates/verticals/manufacturing-logistics/index.js.map +0 -1
  85. package/build/src/modeling/templates/verticals/manufacturing-logistics/manufacturing-domain.d.ts +0 -45
  86. package/build/src/modeling/templates/verticals/manufacturing-logistics/manufacturing-domain.d.ts.map +0 -1
  87. package/build/src/modeling/templates/verticals/manufacturing-logistics/manufacturing-domain.js +0 -710
  88. package/build/src/modeling/templates/verticals/manufacturing-logistics/manufacturing-domain.js.map +0 -1
  89. package/build/src/modeling/templates/verticals/public-sector/index.d.ts +0 -18
  90. package/build/src/modeling/templates/verticals/public-sector/index.d.ts.map +0 -1
  91. package/build/src/modeling/templates/verticals/public-sector/index.js +0 -22
  92. package/build/src/modeling/templates/verticals/public-sector/index.js.map +0 -1
  93. package/build/src/modeling/templates/verticals/public-sector/non-profit-domain.d.ts +0 -47
  94. package/build/src/modeling/templates/verticals/public-sector/non-profit-domain.d.ts.map +0 -1
  95. package/build/src/modeling/templates/verticals/public-sector/non-profit-domain.js +0 -864
  96. package/build/src/modeling/templates/verticals/public-sector/non-profit-domain.js.map +0 -1
  97. package/build/src/modeling/templates/verticals/real-estate-construction/index.d.ts +0 -18
  98. package/build/src/modeling/templates/verticals/real-estate-construction/index.d.ts.map +0 -1
  99. package/build/src/modeling/templates/verticals/real-estate-construction/index.js +0 -21
  100. package/build/src/modeling/templates/verticals/real-estate-construction/index.js.map +0 -1
  101. package/build/src/modeling/templates/verticals/real-estate-construction/real-estate-domain.d.ts +0 -40
  102. package/build/src/modeling/templates/verticals/real-estate-construction/real-estate-domain.d.ts.map +0 -1
  103. package/build/src/modeling/templates/verticals/real-estate-construction/real-estate-domain.js +0 -727
  104. package/build/src/modeling/templates/verticals/real-estate-construction/real-estate-domain.js.map +0 -1
  105. package/build/src/modeling/templates/verticals/technology-media/blog-domain.d.ts +0 -40
  106. package/build/src/modeling/templates/verticals/technology-media/blog-domain.d.ts.map +0 -1
  107. package/build/src/modeling/templates/verticals/technology-media/blog-domain.js +0 -629
  108. package/build/src/modeling/templates/verticals/technology-media/blog-domain.js.map +0 -1
  109. package/build/src/modeling/templates/verticals/technology-media/gaming-domain.d.ts +0 -46
  110. package/build/src/modeling/templates/verticals/technology-media/gaming-domain.d.ts.map +0 -1
  111. package/build/src/modeling/templates/verticals/technology-media/gaming-domain.js +0 -1033
  112. package/build/src/modeling/templates/verticals/technology-media/gaming-domain.js.map +0 -1
  113. package/build/src/modeling/templates/verticals/technology-media/index.d.ts +0 -21
  114. package/build/src/modeling/templates/verticals/technology-media/index.d.ts.map +0 -1
  115. package/build/src/modeling/templates/verticals/technology-media/index.js +0 -42
  116. package/build/src/modeling/templates/verticals/technology-media/index.js.map +0 -1
  117. package/build/src/modeling/templates/verticals/technology-media/iot-smart-home-domain.d.ts +0 -47
  118. package/build/src/modeling/templates/verticals/technology-media/iot-smart-home-domain.d.ts.map +0 -1
  119. package/build/src/modeling/templates/verticals/technology-media/iot-smart-home-domain.js +0 -1029
  120. package/build/src/modeling/templates/verticals/technology-media/iot-smart-home-domain.js.map +0 -1
  121. package/src/modeling/templates/meta/blog-publishing-platform.json +0 -1
  122. package/src/modeling/templates/meta/ecommerce-platform.json +0 -1
  123. package/src/modeling/templates/meta/education-management-platform.json +0 -1
  124. package/src/modeling/templates/meta/financial-services-platform.json +0 -1
  125. package/src/modeling/templates/meta/gaming-platform.json +0 -1
  126. package/src/modeling/templates/meta/healthcare-management-platform.json +0 -1
  127. package/src/modeling/templates/meta/hospitality-platform.json +0 -1
  128. package/src/modeling/templates/meta/iot-smart-home-platform.json +0 -1
  129. package/src/modeling/templates/meta/legal-services-platform.json +0 -1
  130. package/src/modeling/templates/meta/manufacturing-platform.json +0 -1
  131. package/src/modeling/templates/meta/non-profit-platform.json +0 -1
  132. package/src/modeling/templates/meta/real-estate-management-platform.json +0 -1
  133. package/src/modeling/templates/readme.md +0 -260
  134. package/src/modeling/templates/template-registry.ts +0 -140
  135. package/src/modeling/templates/types.ts +0 -175
  136. package/src/modeling/templates/verticals/README.md +0 -122
  137. package/src/modeling/templates/verticals/business-services/ecommerce-domain.ts +0 -844
  138. package/src/modeling/templates/verticals/business-services/financial-services-domain.ts +0 -1177
  139. package/src/modeling/templates/verticals/business-services/hospitality-domain.ts +0 -994
  140. package/src/modeling/templates/verticals/business-services/legal-services-domain.ts +0 -1059
  141. package/src/modeling/templates/verticals/education-training/education-domain.ts +0 -922
  142. package/src/modeling/templates/verticals/healthcare-life-sciences/healthcare-domain.ts +0 -1111
  143. package/src/modeling/templates/verticals/manufacturing-logistics/manufacturing-domain.ts +0 -895
  144. package/src/modeling/templates/verticals/public-sector/non-profit-domain.ts +0 -1109
  145. package/src/modeling/templates/verticals/real-estate-construction/real-estate-domain.ts +0 -944
  146. package/src/modeling/templates/verticals/technology-media/blog-domain.ts +0 -796
  147. package/src/modeling/templates/verticals/technology-media/gaming-domain.ts +0 -1290
  148. package/src/modeling/templates/verticals/technology-media/iot-smart-home-domain.ts +0 -1289
@@ -1,844 +0,0 @@
1
- /**
2
- * E-Commerce Data Domain Example
3
- *
4
- * This file demonstrates how to create a comprehensive e-commerce data domain
5
- * using the API Client Core modeling system. It follows the business-first approach
6
- * and demonstrates proper use of namespaces, models, entities, properties,
7
- * associations, and semantic annotations.
8
- *
9
- * The example includes:
10
- * - User Management domain with proper authentication setup
11
- * - Product Catalog with categories and inventory
12
- * - Order Management with cart functionality and payment processing
13
- * - Proper semantic annotations for security, timestamps, and business logic
14
- * - Realistic associations between entities with proper cardinality
15
- *
16
- * @example
17
- * ```typescript
18
- * import { createEcommerceDomain } from './ecommerce-domain.js'
19
- *
20
- * const domain = createEcommerceDomain()
21
- * console.log('Domain created with', domain.graph.nodeCount(), 'nodes')
22
- * ```
23
- */
24
-
25
- import { DataDomain } from '../../../DataDomain.js'
26
- import { SemanticType } from '../../../Semantics.js'
27
- import { createCalculatedSemantic } from '../../../definitions/Calculated.js'
28
- import { createCountrySemantic, DEFAULT_COUNTRY_CONFIG } from '../../../definitions/Country.js'
29
- import { createCurrencySemantic } from '../../../definitions/Currency.js'
30
- import { createPostalCodeSemantic, DEFAULT_POSTAL_CODE_CONFIG } from '../../../definitions/PostalCode.js'
31
- import { createSummarySemantic } from '../../../definitions/Summary.js'
32
- import {
33
- addAvatarUrlField,
34
- addCreatedAtField,
35
- addDescriptionField,
36
- addEmailField,
37
- addFirstNameField,
38
- addIdField,
39
- addLastNameField,
40
- addNameField,
41
- addPasswordField,
42
- addPhoneField,
43
- addPublicUniqueNameField,
44
- addUpdatedAtField,
45
- addSkuField,
46
- addPriceField,
47
- addQuantityField,
48
- addWeightField,
49
- addImagesField,
50
- addCustomStatusField,
51
- addBooleanField,
52
- addSessionIdField,
53
- addExpiresAtField,
54
- addUnitPriceField,
55
- addCurrencyAmountField,
56
- } from '../../../helpers/Intelisense.js'
57
- import type { CreateTemplateOptions } from '../../types.js'
58
-
59
- function createDomain(): DataDomain {
60
- return new DataDomain({
61
- info: {
62
- name: 'E-Commerce Platform',
63
- displayName: 'E-Commerce Platform',
64
- description:
65
- 'A comprehensive e-commerce platform with user management, product catalog, and order processing capabilities',
66
- },
67
- })
68
- }
69
-
70
- /**
71
- * Creates a comprehensive e-commerce data domain following domain-driven design principles.
72
- *
73
- * This function demonstrates the proper hierarchy and organization for a business domain:
74
- * 1. Creates the root DataDomain
75
- * 2. Organizes functionality into logical namespaces (User Management, Product Catalog, etc.)
76
- * 3. Groups related entities into models within each namespace
77
- * 4. Defines entities with proper semantic annotations
78
- * 5. Establishes associations with appropriate cardinality and business rules
79
- *
80
- * @returns A fully configured DataDomain with all e-commerce entities and relationships
81
- */
82
- export default function createEcommerceDomain(options: CreateTemplateOptions = {}): DataDomain {
83
- // Ensure the root data domain
84
- const domain = options.domain ?? createDomain()
85
-
86
- //
87
- // 1. USER MANAGEMENT NAMESPACE
88
- //
89
- const userManagement = domain.addNamespace({
90
- info: {
91
- name: 'UserManagement',
92
- displayName: 'User Management',
93
- description: 'Handles user authentication, authorization, and profile management',
94
- },
95
- })
96
-
97
- // User Authentication Model
98
- const authModel = userManagement.addModel({
99
- info: {
100
- name: 'Authentication',
101
- displayName: 'User Authentication',
102
- description: 'User accounts and authentication data',
103
- },
104
- })
105
-
106
- // User Entity - The core user account
107
- const userEntity = authModel.addEntity({
108
- info: {
109
- name: 'User',
110
- displayName: 'User Account',
111
- description: 'Represents a user account in the system',
112
- },
113
- semantics: [{ id: SemanticType.User }], // Mark this as a User entity for system-wide recognition
114
- })
115
-
116
- // User properties with proper semantic annotations
117
- addIdField(userEntity, { displayName: 'User ID', description: 'Unique identifier for the user' })
118
- addEmailField(userEntity, { description: 'User email address for login and communication' })
119
- addPasswordField(userEntity, { description: 'User password for authentication' })
120
-
121
- const fName = addFirstNameField(userEntity, { description: 'User first name' })
122
- fName.required = true
123
-
124
- const lName = addLastNameField(userEntity, { description: 'User last name' })
125
- lName.required = true
126
-
127
- userEntity.addProperty({
128
- info: { name: 'role', displayName: 'User Role', description: 'User role for permission management' },
129
- type: 'string',
130
- required: true,
131
- schema: {
132
- enum: ['customer', 'admin', 'moderator'],
133
- defaultValue: {
134
- type: 'literal',
135
- value: 'customer',
136
- },
137
- },
138
- semantics: [{ id: SemanticType.UserRole }],
139
- })
140
-
141
- userEntity.addProperty({
142
- info: {
143
- name: 'email_verified',
144
- displayName: 'Email Verified',
145
- description: 'Whether the user has verified their email address',
146
- },
147
- type: 'boolean',
148
- required: true,
149
- schema: {
150
- defaultValue: {
151
- type: 'literal',
152
- value: 'false',
153
- },
154
- },
155
- })
156
-
157
- addCreatedAtField(userEntity, { description: 'When the user account was created' })
158
- addUpdatedAtField(userEntity, { description: 'When the user account was last updated' })
159
-
160
- // User Profile Model
161
- const profileModel = userManagement.addModel({
162
- info: {
163
- name: 'UserProfile',
164
- displayName: 'User Profile',
165
- description: 'Extended user profile information',
166
- },
167
- })
168
-
169
- // User Profile Entity
170
- const userProfileEntity = profileModel.addEntity({
171
- info: {
172
- name: 'user_profile',
173
- displayName: 'User Profile',
174
- description: 'Extended profile information for users',
175
- },
176
- })
177
-
178
- addIdField(userProfileEntity, { displayName: 'Profile ID', description: 'Unique identifier for the profile' })
179
-
180
- userProfileEntity.addProperty({
181
- info: { name: 'birthdate', displayName: 'Date of Birth', description: 'User date of birth' },
182
- type: 'date',
183
- })
184
-
185
- addPhoneField(userProfileEntity, { description: 'User phone number' })
186
- addAvatarUrlField(userProfileEntity, { description: 'URL to user profile picture' })
187
-
188
- // User-Profile Association (One-to-One), not required for registration flows.
189
- userEntity.addAssociation(
190
- { key: userProfileEntity.key },
191
- {
192
- info: { name: 'profile', displayName: 'User Profile', description: 'Link to extended profile information' },
193
- required: false,
194
- multiple: false,
195
- }
196
- )
197
-
198
- // Address Entity
199
- const addressEntity = profileModel.addEntity({
200
- info: {
201
- name: 'address',
202
- displayName: 'Address',
203
- description: 'Physical address information',
204
- },
205
- semantics: [{ id: SemanticType.Address }],
206
- })
207
-
208
- addIdField(addressEntity, { displayName: 'Address ID', description: 'Unique identifier for the address' })
209
-
210
- addressEntity.addProperty({
211
- info: { name: 'type', displayName: 'Address Type', description: 'Type of address (shipping, billing, etc.)' },
212
- type: 'string',
213
- required: true,
214
- schema: {
215
- enum: ['shipping', 'billing', 'both'],
216
- },
217
- })
218
-
219
- addressEntity.addProperty({
220
- info: {
221
- name: 'line1',
222
- displayName: 'Address Line 1',
223
- description: 'Primary street address, including house number and street name',
224
- },
225
- type: 'string',
226
- required: true,
227
- semantics: [{ id: SemanticType.StreetAddress }],
228
- })
229
-
230
- addressEntity.addProperty({
231
- info: {
232
- name: 'line2',
233
- displayName: 'Address Line 2',
234
- description: 'Optional field for additional street-level information like apartment numbers or building names.',
235
- },
236
- type: 'string',
237
- required: false,
238
- semantics: [{ id: SemanticType.StreetAddressSupplemental }],
239
- })
240
-
241
- addressEntity.addProperty({
242
- info: {
243
- name: 'line3',
244
- displayName: 'Address Line 3',
245
- description: 'Optional field for additional street-level information like apartment numbers or building names.',
246
- },
247
- type: 'string',
248
- required: false,
249
- semantics: [{ id: SemanticType.StreetAddressSupplemental }],
250
- })
251
-
252
- addressEntity.addProperty({
253
- info: { name: 'city', displayName: 'City', description: 'City name' },
254
- type: 'string',
255
- required: true,
256
- semantics: [{ id: SemanticType.City }],
257
- })
258
-
259
- addressEntity.addProperty({
260
- info: { name: 'state', displayName: 'State/Province', description: 'State or province' },
261
- type: 'string',
262
- required: true,
263
- semantics: [{ id: SemanticType.Region }],
264
- })
265
-
266
- addressEntity.addProperty({
267
- info: { name: 'postal_code', displayName: 'ZIP/Postal Code', description: 'ZIP or postal code' },
268
- type: 'string',
269
- required: true,
270
- semantics: [createPostalCodeSemantic(DEFAULT_POSTAL_CODE_CONFIG)],
271
- })
272
-
273
- addressEntity.addProperty({
274
- info: { name: 'country', displayName: 'Country', description: 'Country name' },
275
- type: 'string',
276
- required: true,
277
- semantics: [createCountrySemantic(DEFAULT_COUNTRY_CONFIG)],
278
- })
279
-
280
- // User-Address Association (One-to-Many)
281
- userEntity.addAssociation(
282
- { key: addressEntity.key },
283
- {
284
- info: { name: 'addresses', displayName: 'User Addresses', description: 'User shipping and billing addresses' },
285
- required: false,
286
- multiple: true,
287
- }
288
- )
289
-
290
- //
291
- // 2. PRODUCT CATALOG NAMESPACE
292
- //
293
- const productCatalog = domain.addNamespace({
294
- info: {
295
- name: 'ProductCatalog',
296
- displayName: 'Product Catalog',
297
- description: 'Product information, categories, and inventory management',
298
- },
299
- })
300
-
301
- // Product Management Model
302
- const productModel = productCatalog.addModel({
303
- info: {
304
- name: 'Products',
305
- displayName: 'Product Management',
306
- description: 'Core product entities and relationships',
307
- },
308
- })
309
-
310
- // Category Entity
311
- const categoryEntity = productModel.addEntity({
312
- info: {
313
- name: 'category',
314
- displayName: 'Product Category',
315
- description: 'Product categorization for organization and navigation',
316
- },
317
- })
318
- addIdField(categoryEntity, { displayName: 'Category ID', description: 'Unique identifier for the category' })
319
- addNameField(categoryEntity, { displayName: 'Category Name', description: 'Display name of the category' })
320
- addPublicUniqueNameField(categoryEntity, {
321
- displayName: 'URL Slug',
322
- description: 'URL-friendly identifier for the category',
323
- })
324
- addDescriptionField(categoryEntity, { description: 'Category description' })
325
-
326
- // Self-referencing association for category hierarchy
327
- categoryEntity.addAssociation(
328
- { key: categoryEntity.key },
329
- {
330
- info: {
331
- name: 'parent_category',
332
- displayName: 'Parent Category',
333
- description: 'Parent category for hierarchical organization',
334
- },
335
- required: false,
336
- multiple: false,
337
- }
338
- )
339
-
340
- // Product Entity
341
- const productEntity = productModel.addEntity({
342
- info: {
343
- name: 'product',
344
- displayName: 'Product',
345
- description: 'Core product information and specifications',
346
- },
347
- })
348
-
349
- addIdField(productEntity, { displayName: 'Product ID', description: 'Unique identifier for the product' })
350
- addNameField(productEntity, { displayName: 'Product Name', description: 'Display name of the product' })
351
- addPublicUniqueNameField(productEntity, {
352
- displayName: 'URL Slug',
353
- description: 'URL-friendly identifier for the product',
354
- })
355
- addDescriptionField(productEntity, { description: 'Detailed product description' })
356
-
357
- productEntity.addProperty({
358
- info: { name: 'short_description', displayName: 'Short Description', description: 'Brief product summary' },
359
- type: 'string',
360
- semantics: [createSummarySemantic()],
361
- })
362
-
363
- addSkuField(productEntity, { description: 'Stock Keeping Unit - unique product identifier' })
364
-
365
- addPriceField(productEntity, { description: 'Product price in cents (USD)' })
366
-
367
- productEntity.addProperty({
368
- info: {
369
- name: 'compare_at_price',
370
- displayName: 'Compare at Price',
371
- description: 'Original price for discount display',
372
- },
373
- type: 'number',
374
- schema: {
375
- maximum: 0,
376
- },
377
- bindings: [
378
- {
379
- type: 'web',
380
- schema: {
381
- dataType: 'float',
382
- },
383
- },
384
- ],
385
- semantics: [
386
- createCurrencySemantic({
387
- storageFormat: 'integer_cents',
388
- defaultCurrency: 'USD',
389
- decimalPlaces: 2,
390
- allowNegative: false,
391
- validateCurrencyCode: true,
392
- }),
393
- ],
394
- })
395
-
396
- addCustomStatusField(productEntity, ['inactive', 'active', 'pending', 'archived'], {
397
- description: 'Current status of the product',
398
- })
399
-
400
- addWeightField(productEntity, { description: 'Product weight in grams' })
401
-
402
- addImagesField(productEntity, { description: 'Array of product image URLs' })
403
-
404
- addCreatedAtField(productEntity, { description: 'When the product was created' })
405
- addUpdatedAtField(productEntity, { description: 'When the product was last updated' })
406
-
407
- // Product-Category Association (Many-to-Many)
408
- productEntity.addAssociation(
409
- { key: categoryEntity.key },
410
- {
411
- info: {
412
- name: 'categories',
413
- displayName: 'Product Categories',
414
- description: 'Categories this product belongs to',
415
- },
416
- required: true,
417
- multiple: true,
418
- semantics: [{ id: SemanticType.Categories }],
419
- }
420
- )
421
-
422
- // Inventory Model
423
- const inventoryModel = productCatalog.addModel({
424
- info: {
425
- name: 'Inventory',
426
- displayName: 'Inventory Management',
427
- description: 'Stock levels and inventory tracking',
428
- },
429
- })
430
-
431
- // Inventory Entity
432
- const inventoryEntity = inventoryModel.addEntity({
433
- info: {
434
- name: 'inventory',
435
- displayName: 'Inventory',
436
- description: 'Stock levels and inventory information for products',
437
- },
438
- })
439
-
440
- addIdField(inventoryEntity, {
441
- displayName: 'Inventory ID',
442
- description: 'Unique identifier for the inventory record',
443
- })
444
-
445
- addQuantityField(inventoryEntity, { displayName: 'Stock Quantity', description: 'Available stock quantity' })
446
-
447
- const reservedQty = addQuantityField(inventoryEntity, {
448
- name: 'reserved_quantity',
449
- displayName: 'Reserved Quantity',
450
- description: 'Quantity reserved for pending orders',
451
- })
452
- reservedQty.schema = {
453
- defaultValue: {
454
- type: 'literal',
455
- value: '0',
456
- },
457
- minimum: 0,
458
- }
459
-
460
- addBooleanField(inventoryEntity, 'trackQuantity', 'true', {
461
- displayName: 'Track Quantity',
462
- description: 'Whether to track inventory for this product',
463
- })
464
-
465
- addBooleanField(inventoryEntity, 'allowBackorder', 'false', {
466
- displayName: 'Allow Backorder',
467
- description: 'Whether to allow ordering when out of stock',
468
- })
469
-
470
- // Product-Inventory Association (One-to-One)
471
- productEntity.addAssociation(
472
- { key: inventoryEntity.key },
473
- {
474
- info: {
475
- name: 'inventory',
476
- displayName: 'Product Inventory',
477
- description: 'Inventory information for this product',
478
- },
479
- required: true,
480
- multiple: false,
481
- }
482
- )
483
-
484
- //
485
- // 3. ORDER MANAGEMENT NAMESPACE
486
- //
487
- const orderManagement = domain.addNamespace({
488
- info: {
489
- name: 'OrderManagement',
490
- displayName: 'Order Management',
491
- description: 'Shopping cart, orders, and payment processing',
492
- },
493
- })
494
-
495
- // Shopping Cart Model
496
- const cartModel = orderManagement.addModel({
497
- info: {
498
- name: 'ShoppingCart',
499
- displayName: 'Shopping Cart',
500
- description: 'Shopping cart and cart items',
501
- },
502
- })
503
-
504
- // Cart Entity
505
- const cartEntity = cartModel.addEntity({
506
- info: {
507
- name: 'cart',
508
- displayName: 'Shopping Cart',
509
- description: 'User shopping cart',
510
- },
511
- })
512
-
513
- addIdField(cartEntity, { displayName: 'Cart ID', description: 'Unique identifier for the cart' })
514
-
515
- addSessionIdField(cartEntity, { description: 'Session identifier for guest carts' })
516
-
517
- addExpiresAtField(cartEntity, { description: 'When the cart expires for cleanup' })
518
-
519
- addCreatedAtField(cartEntity, { description: 'When the cart was created' })
520
- addUpdatedAtField(cartEntity, { description: 'When the cart was last updated' })
521
-
522
- // Cart-User Association (Many-to-One)
523
- cartEntity.addAssociation(
524
- { key: userEntity.key },
525
- {
526
- info: { name: 'user', displayName: 'Cart Owner', description: 'User who owns this cart' },
527
- required: false,
528
- multiple: false,
529
- semantics: [{ id: SemanticType.ResourceOwnerIdentifier }],
530
- }
531
- )
532
-
533
- // Cart Item Entity
534
- const cartItemEntity = cartModel.addEntity({
535
- info: {
536
- name: 'cart_item',
537
- displayName: 'Cart Item',
538
- description: 'Individual items in a shopping cart',
539
- },
540
- })
541
-
542
- addIdField(cartItemEntity, { displayName: 'Cart Item ID', description: 'Unique identifier for the cart item' })
543
-
544
- const cartItemQuantity = addQuantityField(cartItemEntity, { description: 'Number of items' })
545
- cartItemQuantity.schema = { minimum: 1 }
546
-
547
- const cartUnitPrice = addUnitPriceField(cartItemEntity, { description: 'Price per unit at time of adding to cart' })
548
-
549
- cartItemEntity.addProperty({
550
- info: { name: 'total_price', displayName: 'Total Price', description: 'Total price for this line item' },
551
- type: 'number',
552
- required: true,
553
- readOnly: true,
554
- semantics: [
555
- createCurrencySemantic({
556
- storageFormat: 'integer_cents',
557
- defaultCurrency: 'USD',
558
- decimalPlaces: 2,
559
- allowNegative: false,
560
- }),
561
- createCalculatedSemantic({
562
- formula: `{{${cartUnitPrice.key}}} * {{${cartItemQuantity.key}}}`,
563
- dependencies: [cartUnitPrice.key, cartItemQuantity.key],
564
- recalculateOnUpdate: true,
565
- }),
566
- ],
567
- })
568
-
569
- // Cart-CartItem Association (One-to-Many)
570
- cartEntity.addAssociation(
571
- { key: cartItemEntity.key },
572
- {
573
- info: { name: 'items', displayName: 'Cart Items', description: 'Items in this cart' },
574
- required: false,
575
- multiple: true,
576
- onDelete: 'cascade',
577
- }
578
- )
579
-
580
- // CartItem-Product Association (Many-to-One)
581
- cartItemEntity.addAssociation(
582
- { key: productEntity.key },
583
- {
584
- info: { name: 'product', displayName: 'Product', description: 'Product for this cart item' },
585
- required: true,
586
- multiple: false,
587
- }
588
- )
589
-
590
- // Order Processing Model
591
- const orderModel = orderManagement.addModel({
592
- info: {
593
- name: 'Orders',
594
- displayName: 'Order Processing',
595
- description: 'Orders and order fulfillment',
596
- },
597
- })
598
-
599
- // Order Entity
600
- const orderEntity = orderModel.addEntity({
601
- info: {
602
- name: 'order',
603
- displayName: 'Order',
604
- description: 'Customer order',
605
- },
606
- })
607
-
608
- addIdField(orderEntity, { displayName: 'Order ID', description: 'Unique identifier for the order' })
609
-
610
- orderEntity.addProperty({
611
- info: { name: 'order_number', displayName: 'Order Number', description: 'Human-readable order number' },
612
- type: 'string',
613
- required: true,
614
- unique: true,
615
- })
616
-
617
- addCustomStatusField(
618
- orderEntity,
619
- ['pending', 'confirmed', 'processing', 'shipped', 'delivered', 'cancelled', 'refunded'],
620
- {
621
- displayName: 'Order Status',
622
- description: 'Current status of the order',
623
- }
624
- )
625
-
626
- const subtotal = addCurrencyAmountField(orderEntity, 'subtotal', 'Subtotal', {
627
- description: 'Order subtotal before taxes and shipping',
628
- })
629
-
630
- const taxAmount = addCurrencyAmountField(orderEntity, 'taxAmount', 'Tax Amount', {
631
- description: 'Total tax amount',
632
- })
633
-
634
- const shippingAmount = addCurrencyAmountField(orderEntity, 'shippingAmount', 'Shipping Amount', {
635
- description: 'Shipping cost',
636
- })
637
-
638
- orderEntity.addProperty({
639
- info: { name: 'total_amount', displayName: 'Total Amount', description: 'Final order total' },
640
- type: 'number',
641
- required: true,
642
- semantics: [
643
- createCurrencySemantic({
644
- storageFormat: 'integer_cents',
645
- defaultCurrency: 'USD',
646
- decimalPlaces: 2,
647
- allowNegative: false,
648
- }),
649
- createCalculatedSemantic({
650
- formula: `{{${subtotal.key}}} + {{${taxAmount.key}}} + {{${shippingAmount.key}}}`,
651
- dependencies: [subtotal.key, taxAmount.key, shippingAmount.key],
652
- recalculateOnUpdate: true,
653
- }),
654
- ],
655
- })
656
-
657
- orderEntity.addProperty({
658
- info: { name: 'notes', displayName: 'Order Notes', description: 'Customer notes or special instructions' },
659
- type: 'string',
660
- })
661
-
662
- addCreatedAtField(orderEntity, { description: 'When the order was created' })
663
- addUpdatedAtField(orderEntity, { description: 'When the order was last updated' })
664
-
665
- // Order-User Association (Many-to-One)
666
- orderEntity.addAssociation(
667
- { key: userEntity.key },
668
- {
669
- info: { name: 'customer', displayName: 'Customer', description: 'Customer who placed this order' },
670
- required: true,
671
- multiple: false,
672
- semantics: [{ id: SemanticType.ResourceOwnerIdentifier }],
673
- }
674
- )
675
-
676
- // Order-Address Associations (Many-to-One)
677
- orderEntity.addAssociation(
678
- { key: addressEntity.key },
679
- {
680
- info: { name: 'shipping_address', displayName: 'Shipping Address', description: 'Address for order delivery' },
681
- required: true,
682
- multiple: false,
683
- }
684
- )
685
-
686
- orderEntity.addAssociation(
687
- { key: addressEntity.key },
688
- {
689
- info: { name: 'billing_address', displayName: 'Billing Address', description: 'Address for billing purposes' },
690
- required: true,
691
- multiple: false,
692
- }
693
- )
694
-
695
- // Order Line Item Entity
696
- const orderItemEntity = orderModel.addEntity({
697
- info: {
698
- name: 'order_item',
699
- displayName: 'Order Line Item',
700
- description: 'Individual line items in an order',
701
- },
702
- })
703
-
704
- addIdField(orderItemEntity, { displayName: 'Order Item ID', description: 'Unique identifier for the order item' })
705
-
706
- const quantity = addQuantityField(orderItemEntity, { description: 'Number of items ordered' })
707
- quantity.schema = { minimum: 1 }
708
-
709
- const unitPrice = addUnitPriceField(orderItemEntity, { description: 'Price per unit at time of order' })
710
-
711
- orderItemEntity.addProperty({
712
- info: { name: 'total_price', displayName: 'Total Price', description: 'Total price for this line item' },
713
- type: 'number',
714
- required: true,
715
- readOnly: true,
716
- semantics: [
717
- createCurrencySemantic({
718
- storageFormat: 'integer_cents',
719
- defaultCurrency: 'USD',
720
- decimalPlaces: 2,
721
- allowNegative: false,
722
- }),
723
- createCalculatedSemantic({
724
- formula: `{{${quantity.key}}} * {{${unitPrice.key}}}`,
725
- dependencies: [quantity.key, unitPrice.key],
726
- recalculateOnUpdate: true,
727
- }),
728
- ],
729
- })
730
-
731
- // orderItemEntity.addProperty({
732
- // info: {
733
- // name: 'productSnapshot',
734
- // displayName: 'Product Snapshot',
735
- // description: 'Snapshot of product data at time of order',
736
- // },
737
- // type: 'object',
738
- // required: true,
739
- // readOnly: true,
740
- // })
741
-
742
- // Order-OrderItem Association (One-to-Many)
743
- orderEntity.addAssociation(
744
- { key: orderItemEntity.key },
745
- {
746
- info: { name: 'items', displayName: 'Order Items', description: 'Items in this order' },
747
- required: true,
748
- multiple: true,
749
- onDelete: 'cascade',
750
- }
751
- )
752
-
753
- // OrderItem-Product Association (Many-to-One)
754
- orderItemEntity.addAssociation(
755
- { key: productEntity.key },
756
- {
757
- info: { name: 'product', displayName: 'Product', description: 'Product for this order item' },
758
- required: true,
759
- multiple: false,
760
- }
761
- )
762
-
763
- // Payment Model
764
- const paymentModel = orderManagement.addModel({
765
- info: {
766
- name: 'Payments',
767
- displayName: 'Payment Processing',
768
- description: 'Payment methods and transactions',
769
- },
770
- })
771
-
772
- // Payment Entity
773
- const paymentEntity = paymentModel.addEntity({
774
- info: {
775
- name: 'payment',
776
- displayName: 'Payment',
777
- description: 'Payment transaction record',
778
- },
779
- })
780
-
781
- addIdField(paymentEntity, { displayName: 'Payment ID', description: 'Unique identifier for the payment' })
782
-
783
- paymentEntity.addProperty({
784
- info: { name: 'method', displayName: 'Payment Method', description: 'Method used for payment' },
785
- type: 'string',
786
- required: true,
787
- schema: {
788
- enum: ['credit_card', 'debit_card', 'paypal', 'bank_transfer', 'apple_pay', 'google_pay'],
789
- },
790
- })
791
-
792
- addCustomStatusField(paymentEntity, ['pending', 'authorized', 'captured', 'failed', 'cancelled', 'refunded'], {
793
- displayName: 'Payment Status',
794
- description: 'Current status of the payment',
795
- })
796
-
797
- addCurrencyAmountField(paymentEntity, 'amount', 'Payment Amount', { description: 'Amount charged' })
798
-
799
- paymentEntity.addProperty({
800
- info: { name: 'currency', displayName: 'Currency', description: 'Currency code for the payment' },
801
- type: 'string',
802
- required: true,
803
- schema: {
804
- defaultValue: {
805
- type: 'literal',
806
- value: 'USD',
807
- },
808
- },
809
- })
810
-
811
- paymentEntity.addProperty({
812
- info: {
813
- name: 'transaction_id',
814
- displayName: 'Transaction ID',
815
- description: 'External payment processor transaction ID',
816
- },
817
- type: 'string',
818
- })
819
-
820
- // paymentEntity.addProperty({
821
- // info: {
822
- // name: 'gatewayResponse',
823
- // displayName: 'Gateway Response',
824
- // description: 'Raw response from payment gateway',
825
- // },
826
- // type: 'object',
827
- // readOnly: true,
828
- // })
829
-
830
- addCreatedAtField(paymentEntity, { description: 'When the payment was created' })
831
-
832
- // Order-Payment Association (One-to-Many)
833
- orderEntity.addAssociation(
834
- { key: paymentEntity.key },
835
- {
836
- info: { name: 'payments', displayName: 'Order Payments', description: 'Payment transactions for this order' },
837
- required: false,
838
- multiple: true,
839
- onDelete: 'restrict', // Don't allow order deletion if payments exist
840
- }
841
- )
842
-
843
- return domain
844
- }