@cendo/database-schemas 2.1.9 → 2.2.1

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.
@@ -1,45 +1,57 @@
1
1
  const {Schema} = require('mongoose')
2
2
 
3
3
 
4
+ /**
5
+ * SourceOrder — Raw order data from the source platform.
6
+ * Used as a staging area before processing into internal Order records.
7
+ */
4
8
  const SourceOrder = new Schema({
9
+ /** Source platform type (default 'shopify') */
5
10
  type: {
6
11
  type: String,
7
12
  trim: true,
8
13
  default: 'shopify',
9
14
  },
10
15
 
16
+ /** Order ID on the source platform */
11
17
  id: {
12
18
  type: String,
13
19
  trim: true,
14
20
  index: true,
15
21
  },
16
22
 
23
+ /** Order display name on the source platform (e.g., "#1001") */
17
24
  name: {
18
25
  type: String,
19
26
  trim: true,
20
27
  },
21
28
 
29
+ /** Payment status from the source platform (lowercase) */
22
30
  financial_status: {
23
31
  type: String,
24
32
  trim: true,
25
33
  lowercase: true,
26
34
  },
27
35
 
36
+ /** Fulfillment status from the source platform (lowercase) */
28
37
  fulfillment_status: {
29
38
  type: String,
30
39
  trim: true,
31
40
  lowercase: true,
32
41
  },
33
42
 
43
+ /** Last time this record was synced from the platform */
34
44
  synced_at: {
35
45
  type: Date,
36
46
  },
37
47
 
48
+ /** Last modification timestamp */
38
49
  updated_at: {
39
50
  type: Date,
40
51
  default: Date.now
41
52
  },
42
53
 
54
+ /** Creation timestamp */
43
55
  created_at: {
44
56
  type: Date,
45
57
  default: Date.now,
@@ -1,30 +1,40 @@
1
1
  const {Schema} = require('mongoose')
2
2
 
3
3
 
4
+ /**
5
+ * TestResponse — Test/webhook response logging.
6
+ * Records HTTP responses for debugging webhook deliveries.
7
+ */
4
8
  const TestResponse = new Schema({
9
+ /** URL that was called */
5
10
  url: {
6
11
  type: String,
7
12
  trim: true,
8
13
  },
9
14
 
15
+ /** HTTP response status code */
10
16
  code: {
11
17
  type: Number,
12
18
  },
13
19
 
20
+ /** Response message or error description */
14
21
  message: {
15
22
  type: String,
16
23
  trim: true,
17
24
  },
18
25
 
26
+ /** Full response body/data */
19
27
  data: {
20
28
  type: Schema.Types.Mixed,
21
29
  },
22
30
 
31
+ /** Last modification timestamp */
23
32
  updated_at: {
24
33
  type: Date,
25
34
  default: Date.now
26
35
  },
27
36
 
37
+ /** Creation timestamp */
28
38
  created_at: {
29
39
  type: Date,
30
40
  default: Date.now,
@@ -1,39 +1,50 @@
1
1
  const {Schema} = require('mongoose')
2
2
 
3
3
 
4
+ /**
5
+ * WebhookEvent — Webhook event queue.
6
+ * Stores incoming webhook payloads for processing. Auto-deleted after 7 days via TTL index.
7
+ */
4
8
  const WebhookEvent = new Schema({
9
+ /** Processing status */
5
10
  status: {
6
11
  type: String,
7
12
  trim: true,
8
13
  index: true,
9
14
  },
10
15
 
16
+ /** Source platform type */
11
17
  type: {
12
18
  type: String,
13
19
  trim: true,
14
20
  index: true,
15
21
  },
16
22
 
23
+ /** Webhook topic/event name */
17
24
  topic: {
18
25
  type: String,
19
26
  index: true,
20
27
  required: true,
21
28
  },
22
29
 
30
+ /** Raw webhook payload data */
23
31
  payload: {
24
32
  type: Schema.Types.Mixed,
25
33
  default: {},
26
34
  },
27
35
 
36
+ /** Whether this is a test webhook event */
28
37
  is_test: {
29
38
  type: Boolean,
30
39
  default: false,
31
40
  },
32
41
 
42
+ /** Last modification timestamp */
33
43
  updated_at: {
34
44
  type: Date,
35
45
  },
36
46
 
47
+ /** Creation timestamp (TTL: 7 days) */
37
48
  created_at: {
38
49
  type: Date,
39
50
  default: Date.now,
@@ -44,4 +55,3 @@ const WebhookEvent = new Schema({
44
55
 
45
56
 
46
57
  module.exports = WebhookEvent
47
-
@@ -1,9 +1,14 @@
1
1
  const {Schema} = require('mongoose')
2
2
 
3
3
 
4
+ /**
5
+ * AttachmentObject — File attachment.
6
+ * Embedded as array in Order for customer-uploaded images.
7
+ */
4
8
  const AttachmentObject = new Schema({
5
9
  _id: false,
6
10
 
11
+ /** Attachment type: 'image' */
7
12
  type: {
8
13
  type: String,
9
14
  trim: true,
@@ -11,6 +16,7 @@ const AttachmentObject = new Schema({
11
16
  enum: ['image'],
12
17
  },
13
18
 
19
+ /** Public URL of the attachment */
14
20
  url: {
15
21
  type: String,
16
22
  trim: true,
@@ -1,13 +1,19 @@
1
1
  const {Schema} = require('mongoose')
2
2
 
3
3
 
4
+ /**
5
+ * DimensionObject — Image dimensions.
6
+ * Embedded in Media to store width/height in pixels.
7
+ */
4
8
  const DimensionObject = new Schema({
5
9
  _id: false,
6
10
 
11
+ /** Width in pixels */
7
12
  width: {
8
13
  type: Number,
9
14
  },
10
15
 
16
+ /** Height in pixels */
11
17
  height: {
12
18
  type: Number,
13
19
  }
@@ -1,14 +1,20 @@
1
1
  const {Schema} = require('mongoose')
2
2
 
3
3
 
4
+ /**
5
+ * FulfillmentObject — Fulfillment status summary.
6
+ * Embedded as array in Order to track fulfillment numbers and their production status.
7
+ */
4
8
  const FulfillmentObject = new Schema({
5
9
  _id: false,
6
10
 
11
+ /** Fulfillment/shipment number */
7
12
  number: {
8
13
  type: String,
9
14
  trim: true,
10
15
  },
11
16
 
17
+ /** Current production status */
12
18
  production_status: {
13
19
  type: String,
14
20
  trim: true,
@@ -1,13 +1,19 @@
1
1
  const {Schema} = require('mongoose')
2
2
 
3
3
 
4
+ /**
5
+ * MoneyObject — Currency-aware monetary amount.
6
+ * Embedded in Order. Default currency is VND (Vietnamese Dong).
7
+ */
4
8
  const MoneyObject = new Schema({
5
9
  _id: false,
6
10
 
11
+ /** Monetary value */
7
12
  amount: {
8
13
  type: Number,
9
14
  },
10
15
 
16
+ /** ISO currency code (default 'VND', uppercase) */
11
17
  currency: {
12
18
  type: String,
13
19
  trim: true,
@@ -1,73 +1,90 @@
1
1
  const {Schema} = require('mongoose')
2
2
 
3
3
 
4
+ /**
5
+ * ShippingAddress — Recipient's shipping/delivery address.
6
+ * Embedded in Order. Includes Vietnam-specific fields (district, commune).
7
+ */
4
8
  const ShippingAddress = new Schema({
5
9
  _id: false,
6
10
 
11
+ /** Customer username/account name on the platform */
7
12
  username: {
8
13
  type: String,
9
14
  trim: true,
10
15
  },
11
16
 
17
+ /** Full name of the recipient */
12
18
  name: {
13
19
  type: String,
14
20
  trim: true,
15
21
  },
16
22
 
23
+ /** Primary address line */
17
24
  address1: {
18
25
  type: String,
19
26
  trim: true,
20
27
  },
21
28
 
29
+ /** Secondary address line (apartment, suite, etc.) */
22
30
  address2: {
23
31
  type: String,
24
32
  trim: true,
25
33
  },
26
34
 
35
+ /** City name */
27
36
  city: {
28
37
  type: String,
29
38
  trim: true,
30
39
  },
31
40
 
41
+ /** Postal/ZIP code */
32
42
  zip: {
33
43
  type: String,
34
44
  trim: true,
35
45
  },
36
46
 
47
+ /** Province or state */
37
48
  province: {
38
49
  type: String,
39
50
  trim: true
40
51
  },
41
52
 
53
+ /** District (Vietnam-specific administrative division) */
42
54
  district: {
43
55
  type: String,
44
56
  trim: true
45
57
  },
46
58
 
59
+ /** Commune/ward (Vietnam-specific administrative division) */
47
60
  commune: {
48
61
  type: String,
49
62
  trim: true
50
63
  },
51
64
 
65
+ /** Country name or code */
52
66
  country: {
53
67
  type: String,
54
68
  trim: true,
55
69
  },
56
70
 
71
+ /** Phone number (may include formatting) */
57
72
  phone: {
58
73
  type: String,
59
74
  trim: true,
60
75
  },
61
76
 
77
+ /** Phone number without formatting (digits only) */
62
78
  phone_plain_text: {
63
79
  type: String,
64
80
  trim: true,
65
81
  },
66
82
 
83
+ /** Customer email address */
67
84
  email: {
68
85
  type: String,
69
86
  trim: true,
70
87
  }
71
88
  })
72
89
 
73
- module.exports = ShippingAddress
90
+ module.exports = ShippingAddress
@@ -1,23 +1,30 @@
1
1
  const {Schema} = require('mongoose')
2
2
 
3
3
 
4
+ /**
5
+ * TrackingObject — Shipping tracking info.
6
+ * Embedded in OrderFulfillment for carrier tracking details.
7
+ */
4
8
  const TrackingObject = new Schema({
5
9
  _id: false,
6
10
 
11
+ /** Carrier tracking number */
7
12
  tracking_number: {
8
13
  type: String,
9
14
  trim: true,
10
15
  },
11
16
 
17
+ /** URL to track the shipment */
12
18
  tracking_url: {
13
19
  type: String,
14
20
  trim: true,
15
21
  },
16
22
 
23
+ /** Carrier name or code */
17
24
  carrier: {
18
25
  type: String,
19
26
  trim: true,
20
27
  },
21
28
  })
22
29
 
23
- module.exports = TrackingObject
30
+ module.exports = TrackingObject