@voyantjs/sellability 0.4.5 → 0.6.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.
package/dist/routes.d.ts CHANGED
@@ -41,7 +41,7 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
41
41
  } | null;
42
42
  channel: {
43
43
  id: string;
44
- kind: "direct" | "affiliate" | "ota" | "reseller" | "marketplace" | "api_partner";
44
+ kind: "reseller" | "direct" | "affiliate" | "ota" | "marketplace" | "api_partner";
45
45
  } | null;
46
46
  sellability: {
47
47
  mode: "on_request" | "sellable" | "unavailable";
@@ -115,16 +115,16 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
115
115
  output: {
116
116
  snapshot: {
117
117
  id: string;
118
- productId: string | null;
119
- optionId: string | null;
120
118
  createdAt: string;
121
119
  updatedAt: string;
120
+ expiresAt: string | null;
122
121
  status: "expired" | "resolved" | "offer_constructed";
122
+ productId: string | null;
123
+ optionId: string | null;
123
124
  slotId: string | null;
124
125
  channelId: string | null;
125
126
  marketId: string | null;
126
127
  fxRateSetId: string | null;
127
- expiresAt: string | null;
128
128
  offerId: string | null;
129
129
  requestedCurrencyCode: string | null;
130
130
  sourceCurrencyCode: string | null;
@@ -167,7 +167,7 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
167
167
  } | null;
168
168
  channel: {
169
169
  id: string;
170
- kind: "direct" | "affiliate" | "ota" | "reseller" | "marketplace" | "api_partner";
170
+ kind: "reseller" | "direct" | "affiliate" | "ota" | "marketplace" | "api_partner";
171
171
  } | null;
172
172
  sellability: {
173
173
  mode: "on_request" | "sellable" | "unavailable";
@@ -279,7 +279,7 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
279
279
  } | null;
280
280
  channel: {
281
281
  id: string;
282
- kind: "direct" | "affiliate" | "ota" | "reseller" | "marketplace" | "api_partner";
282
+ kind: "reseller" | "direct" | "affiliate" | "ota" | "marketplace" | "api_partner";
283
283
  } | null;
284
284
  sellability: {
285
285
  mode: "on_request" | "sellable" | "unavailable";
@@ -340,16 +340,16 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
340
340
  };
341
341
  snapshot: {
342
342
  id: string;
343
- productId: string | null;
344
- optionId: string | null;
345
343
  createdAt: string;
346
344
  updatedAt: string;
345
+ expiresAt: string | null;
347
346
  status: "expired" | "resolved" | "offer_constructed";
347
+ productId: string | null;
348
+ optionId: string | null;
348
349
  slotId: string | null;
349
350
  channelId: string | null;
350
351
  marketId: string | null;
351
352
  fxRateSetId: string | null;
352
- expiresAt: string | null;
353
353
  offerId: string | null;
354
354
  requestedCurrencyCode: string | null;
355
355
  sourceCurrencyCode: string | null;
@@ -361,20 +361,20 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
361
361
  };
362
362
  };
363
363
  offer: {
364
+ metadata: import("hono/utils/types").JSONValue;
364
365
  id: string;
365
366
  createdAt: string;
366
367
  updatedAt: string;
368
+ organizationId: string | null;
367
369
  status: "draft" | "expired" | "published" | "sent" | "accepted" | "withdrawn" | "converted";
370
+ currency: string;
368
371
  notes: string | null;
369
372
  costAmountCents: number;
370
373
  title: string;
371
- metadata: import("hono/utils/types").JSONValue;
372
374
  validFrom: string | null;
373
- currency: string;
374
375
  marketId: string | null;
375
376
  baseCurrency: string | null;
376
377
  fxRateSetId: string | null;
377
- organizationId: string | null;
378
378
  offerNumber: string;
379
379
  personId: string | null;
380
380
  opportunityId: string | null;
@@ -407,23 +407,23 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
407
407
  updatedAt: string;
408
408
  }[];
409
409
  items: {
410
+ metadata: import("hono/utils/types").JSONValue;
410
411
  id: string;
411
- productId: string | null;
412
- optionId: string | null;
413
412
  createdAt: string;
414
413
  updatedAt: string;
415
- startsAt: string | null;
416
- endsAt: string | null;
417
414
  status: "cancelled" | "draft" | "confirmed" | "fulfilled" | "priced";
418
415
  notes: string | null;
419
- slotId: string | null;
420
416
  description: string | null;
417
+ productId: string | null;
418
+ optionId: string | null;
419
+ startsAt: string | null;
420
+ endsAt: string | null;
421
+ slotId: string | null;
421
422
  sellCurrency: string;
422
423
  title: string;
423
424
  costCurrency: string | null;
424
425
  quantity: number;
425
426
  unitId: string | null;
426
- metadata: import("hono/utils/types").JSONValue;
427
427
  taxAmountCents: number | null;
428
428
  feeAmountCents: number | null;
429
429
  offerId: string;
@@ -437,8 +437,8 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
437
437
  itemParticipants: {
438
438
  id: string;
439
439
  createdAt: string;
440
- isPrimary: boolean;
441
440
  role: "other" | "traveler" | "occupant" | "primary_contact" | "beneficiary" | "service_assignee";
441
+ isPrimary: boolean;
442
442
  participantId: string;
443
443
  offerItemId: string;
444
444
  }[];
@@ -578,7 +578,7 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
578
578
  id: string;
579
579
  name: string;
580
580
  scope: "product" | "option" | "channel" | "market" | "global";
581
- policyType: "pickup" | "custom" | "capability" | "question" | "currency" | "allotment" | "occupancy" | "availability_window";
581
+ policyType: "custom" | "currency" | "pickup" | "capability" | "question" | "allotment" | "occupancy" | "availability_window";
582
582
  productId: string | null;
583
583
  optionId: string | null;
584
584
  marketId: string | null;
@@ -612,22 +612,22 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
612
612
  input: {};
613
613
  output: {
614
614
  data: {
615
+ metadata: {
616
+ [x: string]: import("hono/utils/types").JSONValue;
617
+ } | null;
615
618
  id: string;
616
619
  name: string;
617
- productId: string | null;
618
- optionId: string | null;
619
- active: boolean;
620
620
  createdAt: string;
621
621
  updatedAt: string;
622
+ scope: "product" | "option" | "channel" | "market" | "global";
622
623
  notes: string | null;
623
- metadata: {
624
- [x: string]: import("hono/utils/types").JSONValue;
625
- } | null;
624
+ productId: string | null;
625
+ optionId: string | null;
626
+ active: boolean;
626
627
  channelId: string | null;
627
- scope: "product" | "option" | "channel" | "market" | "global";
628
628
  marketId: string | null;
629
629
  priority: number;
630
- policyType: "pickup" | "custom" | "capability" | "question" | "currency" | "allotment" | "occupancy" | "availability_window";
630
+ policyType: "custom" | "currency" | "pickup" | "capability" | "question" | "allotment" | "occupancy" | "availability_window";
631
631
  conditions: {
632
632
  [x: string]: import("hono/utils/types").JSONValue;
633
633
  };
@@ -664,7 +664,7 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
664
664
  id: string;
665
665
  name: string;
666
666
  scope: "product" | "option" | "channel" | "market" | "global";
667
- policyType: "pickup" | "custom" | "capability" | "question" | "currency" | "allotment" | "occupancy" | "availability_window";
667
+ policyType: "custom" | "currency" | "pickup" | "capability" | "question" | "allotment" | "occupancy" | "availability_window";
668
668
  productId: string | null;
669
669
  optionId: string | null;
670
670
  marketId: string | null;
@@ -713,7 +713,7 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
713
713
  id: string;
714
714
  name: string;
715
715
  scope: "product" | "option" | "channel" | "market" | "global";
716
- policyType: "pickup" | "custom" | "capability" | "question" | "currency" | "allotment" | "occupancy" | "availability_window";
716
+ policyType: "custom" | "currency" | "pickup" | "capability" | "question" | "allotment" | "occupancy" | "availability_window";
717
717
  productId: string | null;
718
718
  optionId: string | null;
719
719
  marketId: string | null;
@@ -796,17 +796,17 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
796
796
  input: {};
797
797
  output: {
798
798
  data: {
799
- message: string | null;
800
799
  id: string;
801
800
  createdAt: string;
802
801
  status: "warning" | "passed" | "blocked" | "adjusted";
802
+ message: string | null;
803
+ details: {
804
+ [x: string]: import("hono/utils/types").JSONValue;
805
+ } | null;
803
806
  snapshotId: string;
804
807
  candidateIndex: number;
805
808
  snapshotItemId: string | null;
806
809
  policyId: string | null;
807
- details: {
808
- [x: string]: import("hono/utils/types").JSONValue;
809
- } | null;
810
810
  } | null;
811
811
  };
812
812
  outputFormat: "json";
@@ -948,14 +948,14 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
948
948
  input: {};
949
949
  output: {
950
950
  data: {
951
+ metadata: {
952
+ [x: string]: import("hono/utils/types").JSONValue;
953
+ } | null;
951
954
  id: string;
952
955
  createdAt: string;
953
956
  updatedAt: string;
954
957
  status: "pending" | "expired" | "failed" | "running" | "completed";
955
958
  notes: string | null;
956
- metadata: {
957
- [x: string]: import("hono/utils/types").JSONValue;
958
- } | null;
959
959
  startedAt: string;
960
960
  completedAt: string | null;
961
961
  offerId: string;
@@ -1103,15 +1103,15 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
1103
1103
  input: {};
1104
1104
  output: {
1105
1105
  data: {
1106
+ metadata: {
1107
+ [x: string]: import("hono/utils/types").JSONValue;
1108
+ } | null;
1106
1109
  id: string;
1107
1110
  createdAt: string;
1108
1111
  updatedAt: string;
1112
+ expiresAt: string;
1109
1113
  status: "cancelled" | "scheduled" | "expired" | "superseded";
1110
1114
  reason: string | null;
1111
- metadata: {
1112
- [x: string]: import("hono/utils/types").JSONValue;
1113
- } | null;
1114
- expiresAt: string;
1115
1115
  offerId: string;
1116
1116
  snapshotId: string | null;
1117
1117
  expiredAt: string | null;
@@ -1257,16 +1257,16 @@ export declare const sellabilityRoutes: import("hono/hono-base").HonoBase<Env, {
1257
1257
  input: {};
1258
1258
  output: {
1259
1259
  data: {
1260
- message: string;
1261
1260
  id: string;
1262
1261
  createdAt: string;
1262
+ message: string;
1263
1263
  code: string | null;
1264
- snapshotId: string;
1265
- candidateIndex: number;
1266
- snapshotItemId: string | null;
1267
1264
  details: {
1268
1265
  [x: string]: import("hono/utils/types").JSONValue;
1269
1266
  } | null;
1267
+ snapshotId: string;
1268
+ candidateIndex: number;
1269
+ snapshotItemId: string | null;
1270
1270
  explanationType: "pickup" | "policy" | "warning" | "allotment" | "sellable" | "pricing" | "blocked";
1271
1271
  } | null;
1272
1272
  };
@@ -1 +1 @@
1
- {"version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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAuM1B,CAAA;AAEJ,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAA"}
package/dist/routes.js CHANGED
@@ -1,17 +1,18 @@
1
+ import { parseJsonBody, parseQuery } from "@voyantjs/hono";
1
2
  import { Hono } from "hono";
2
3
  import { sellabilityService } from "./service.js";
3
4
  import { insertOfferExpirationEventSchema, insertOfferRefreshRunSchema, insertSellabilityExplanationSchema, insertSellabilityPolicyResultSchema, insertSellabilityPolicySchema, offerExpirationEventListQuerySchema, offerRefreshRunListQuerySchema, sellabilityConstructOfferSchema, sellabilityExplanationListQuerySchema, sellabilityPersistSnapshotSchema, sellabilityPolicyListQuerySchema, sellabilityPolicyResultListQuerySchema, sellabilityResolveQuerySchema, sellabilitySnapshotItemListQuerySchema, sellabilitySnapshotListQuerySchema, updateOfferExpirationEventSchema, updateOfferRefreshRunSchema, updateSellabilityExplanationSchema, updateSellabilityPolicyResultSchema, updateSellabilityPolicySchema, } from "./validation.js";
4
5
  export const sellabilityRoutes = new Hono()
5
6
  .post("/resolve", async (c) => {
6
- const input = sellabilityResolveQuerySchema.parse(await c.req.json());
7
+ const input = await parseJsonBody(c, sellabilityResolveQuerySchema);
7
8
  return c.json(await sellabilityService.resolve(c.get("db"), input));
8
9
  })
9
10
  .post("/resolve-and-persist", async (c) => {
10
- const input = sellabilityPersistSnapshotSchema.parse(await c.req.json());
11
+ const input = await parseJsonBody(c, sellabilityPersistSnapshotSchema);
11
12
  return c.json(await sellabilityService.persistSnapshot(c.get("db"), input), 201);
12
13
  })
13
14
  .post("/construct-offer", async (c) => {
14
- const input = sellabilityConstructOfferSchema.parse(await c.req.json());
15
+ const input = await parseJsonBody(c, sellabilityConstructOfferSchema);
15
16
  const result = await sellabilityService.constructOffer(c.get("db"), input);
16
17
  if (!result) {
17
18
  return c.json({ error: "Sellable candidate not found" }, 404);
@@ -19,7 +20,7 @@ export const sellabilityRoutes = new Hono()
19
20
  return c.json({ data: result }, 201);
20
21
  })
21
22
  .get("/snapshots", async (c) => {
22
- const query = sellabilitySnapshotListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
23
+ const query = parseQuery(c, sellabilitySnapshotListQuerySchema);
23
24
  return c.json(await sellabilityService.listSnapshots(c.get("db"), query));
24
25
  })
25
26
  .get("/snapshots/:id", async (c) => {
@@ -29,16 +30,16 @@ export const sellabilityRoutes = new Hono()
29
30
  return c.json({ data: row });
30
31
  })
31
32
  .get("/snapshot-items", async (c) => {
32
- const query = sellabilitySnapshotItemListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
33
+ const query = parseQuery(c, sellabilitySnapshotItemListQuerySchema);
33
34
  return c.json(await sellabilityService.listSnapshotItems(c.get("db"), query));
34
35
  })
35
36
  .get("/policies", async (c) => {
36
- const query = sellabilityPolicyListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
37
+ const query = parseQuery(c, sellabilityPolicyListQuerySchema);
37
38
  return c.json(await sellabilityService.listPolicies(c.get("db"), query));
38
39
  })
39
40
  .post("/policies", async (c) => {
40
41
  return c.json({
41
- data: await sellabilityService.createPolicy(c.get("db"), insertSellabilityPolicySchema.parse(await c.req.json())),
42
+ data: await sellabilityService.createPolicy(c.get("db"), await parseJsonBody(c, insertSellabilityPolicySchema)),
42
43
  }, 201);
43
44
  })
44
45
  .get("/policies/:id", async (c) => {
@@ -48,7 +49,7 @@ export const sellabilityRoutes = new Hono()
48
49
  return c.json({ data: row });
49
50
  })
50
51
  .patch("/policies/:id", async (c) => {
51
- const row = await sellabilityService.updatePolicy(c.get("db"), c.req.param("id"), updateSellabilityPolicySchema.parse(await c.req.json()));
52
+ const row = await sellabilityService.updatePolicy(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateSellabilityPolicySchema));
52
53
  if (!row)
53
54
  return c.json({ error: "Sellability policy not found" }, 404);
54
55
  return c.json({ data: row });
@@ -60,12 +61,12 @@ export const sellabilityRoutes = new Hono()
60
61
  return c.json({ success: true });
61
62
  })
62
63
  .get("/policy-results", async (c) => {
63
- const query = sellabilityPolicyResultListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
64
+ const query = parseQuery(c, sellabilityPolicyResultListQuerySchema);
64
65
  return c.json(await sellabilityService.listPolicyResults(c.get("db"), query));
65
66
  })
66
67
  .post("/policy-results", async (c) => {
67
68
  return c.json({
68
- data: await sellabilityService.createPolicyResult(c.get("db"), insertSellabilityPolicyResultSchema.parse(await c.req.json())),
69
+ data: await sellabilityService.createPolicyResult(c.get("db"), await parseJsonBody(c, insertSellabilityPolicyResultSchema)),
69
70
  }, 201);
70
71
  })
71
72
  .get("/policy-results/:id", async (c) => {
@@ -75,7 +76,7 @@ export const sellabilityRoutes = new Hono()
75
76
  return c.json({ data: row });
76
77
  })
77
78
  .patch("/policy-results/:id", async (c) => {
78
- const row = await sellabilityService.updatePolicyResult(c.get("db"), c.req.param("id"), updateSellabilityPolicyResultSchema.parse(await c.req.json()));
79
+ const row = await sellabilityService.updatePolicyResult(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateSellabilityPolicyResultSchema));
79
80
  if (!row)
80
81
  return c.json({ error: "Sellability policy result not found" }, 404);
81
82
  return c.json({ data: row });
@@ -87,12 +88,12 @@ export const sellabilityRoutes = new Hono()
87
88
  return c.json({ success: true });
88
89
  })
89
90
  .get("/offer-refresh-runs", async (c) => {
90
- const query = offerRefreshRunListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
91
+ const query = parseQuery(c, offerRefreshRunListQuerySchema);
91
92
  return c.json(await sellabilityService.listOfferRefreshRuns(c.get("db"), query));
92
93
  })
93
94
  .post("/offer-refresh-runs", async (c) => {
94
95
  return c.json({
95
- data: await sellabilityService.createOfferRefreshRun(c.get("db"), insertOfferRefreshRunSchema.parse(await c.req.json())),
96
+ data: await sellabilityService.createOfferRefreshRun(c.get("db"), await parseJsonBody(c, insertOfferRefreshRunSchema)),
96
97
  }, 201);
97
98
  })
98
99
  .get("/offer-refresh-runs/:id", async (c) => {
@@ -102,7 +103,7 @@ export const sellabilityRoutes = new Hono()
102
103
  return c.json({ data: row });
103
104
  })
104
105
  .patch("/offer-refresh-runs/:id", async (c) => {
105
- const row = await sellabilityService.updateOfferRefreshRun(c.get("db"), c.req.param("id"), updateOfferRefreshRunSchema.parse(await c.req.json()));
106
+ const row = await sellabilityService.updateOfferRefreshRun(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateOfferRefreshRunSchema));
106
107
  if (!row)
107
108
  return c.json({ error: "Offer refresh run not found" }, 404);
108
109
  return c.json({ data: row });
@@ -114,12 +115,12 @@ export const sellabilityRoutes = new Hono()
114
115
  return c.json({ success: true });
115
116
  })
116
117
  .get("/offer-expiration-events", async (c) => {
117
- const query = offerExpirationEventListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
118
+ const query = parseQuery(c, offerExpirationEventListQuerySchema);
118
119
  return c.json(await sellabilityService.listOfferExpirationEvents(c.get("db"), query));
119
120
  })
120
121
  .post("/offer-expiration-events", async (c) => {
121
122
  return c.json({
122
- data: await sellabilityService.createOfferExpirationEvent(c.get("db"), insertOfferExpirationEventSchema.parse(await c.req.json())),
123
+ data: await sellabilityService.createOfferExpirationEvent(c.get("db"), await parseJsonBody(c, insertOfferExpirationEventSchema)),
123
124
  }, 201);
124
125
  })
125
126
  .get("/offer-expiration-events/:id", async (c) => {
@@ -129,7 +130,7 @@ export const sellabilityRoutes = new Hono()
129
130
  return c.json({ data: row });
130
131
  })
131
132
  .patch("/offer-expiration-events/:id", async (c) => {
132
- const row = await sellabilityService.updateOfferExpirationEvent(c.get("db"), c.req.param("id"), updateOfferExpirationEventSchema.parse(await c.req.json()));
133
+ const row = await sellabilityService.updateOfferExpirationEvent(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateOfferExpirationEventSchema));
133
134
  if (!row)
134
135
  return c.json({ error: "Offer expiration event not found" }, 404);
135
136
  return c.json({ data: row });
@@ -141,12 +142,12 @@ export const sellabilityRoutes = new Hono()
141
142
  return c.json({ success: true });
142
143
  })
143
144
  .get("/explanations", async (c) => {
144
- const query = sellabilityExplanationListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
145
+ const query = parseQuery(c, sellabilityExplanationListQuerySchema);
145
146
  return c.json(await sellabilityService.listExplanations(c.get("db"), query));
146
147
  })
147
148
  .post("/explanations", async (c) => {
148
149
  return c.json({
149
- data: await sellabilityService.createExplanation(c.get("db"), insertSellabilityExplanationSchema.parse(await c.req.json())),
150
+ data: await sellabilityService.createExplanation(c.get("db"), await parseJsonBody(c, insertSellabilityExplanationSchema)),
150
151
  }, 201);
151
152
  })
152
153
  .get("/explanations/:id", async (c) => {
@@ -156,7 +157,7 @@ export const sellabilityRoutes = new Hono()
156
157
  return c.json({ data: row });
157
158
  })
158
159
  .patch("/explanations/:id", async (c) => {
159
- const row = await sellabilityService.updateExplanation(c.get("db"), c.req.param("id"), updateSellabilityExplanationSchema.parse(await c.req.json()));
160
+ const row = await sellabilityService.updateExplanation(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateSellabilityExplanationSchema));
160
161
  if (!row)
161
162
  return c.json({ error: "Sellability explanation not found" }, 404);
162
163
  return c.json({ data: row });
package/dist/schema.d.ts CHANGED
@@ -764,7 +764,7 @@ export declare const sellabilityPolicies: import("drizzle-orm/pg-core").PgTableW
764
764
  tableName: "sellability_policies";
765
765
  dataType: "string";
766
766
  columnType: "PgEnumColumn";
767
- data: "pickup" | "custom" | "capability" | "question" | "currency" | "allotment" | "occupancy" | "availability_window";
767
+ data: "custom" | "currency" | "pickup" | "capability" | "question" | "allotment" | "occupancy" | "availability_window";
768
768
  driverParam: string;
769
769
  notNull: true;
770
770
  hasDefault: true;
package/dist/service.d.ts CHANGED
@@ -99,7 +99,7 @@ export declare const sellabilityService: {
99
99
  } | null;
100
100
  channel: {
101
101
  id: string;
102
- kind: "direct" | "affiliate" | "ota" | "reseller" | "marketplace" | "api_partner";
102
+ kind: "reseller" | "direct" | "affiliate" | "ota" | "marketplace" | "api_partner";
103
103
  } | null;
104
104
  sellability: {
105
105
  mode: "on_request" | "sellable" | "unavailable";
@@ -132,16 +132,16 @@ export declare const sellabilityService: {
132
132
  };
133
133
  snapshot: {
134
134
  id: string;
135
- productId: string | null;
136
- optionId: string | null;
137
135
  createdAt: Date;
138
136
  updatedAt: Date;
137
+ expiresAt: Date | null;
139
138
  status: "expired" | "resolved" | "offer_constructed";
139
+ productId: string | null;
140
+ optionId: string | null;
140
141
  slotId: string | null;
141
142
  channelId: string | null;
142
143
  marketId: string | null;
143
144
  fxRateSetId: string | null;
144
- expiresAt: Date | null;
145
145
  offerId: string | null;
146
146
  requestedCurrencyCode: string | null;
147
147
  sourceCurrencyCode: string | null;
@@ -149,20 +149,20 @@ export declare const sellabilityService: {
149
149
  pricingSummary: Record<string, unknown>;
150
150
  };
151
151
  offer: {
152
+ metadata: unknown;
152
153
  id: string;
153
154
  createdAt: Date;
154
155
  updatedAt: Date;
156
+ organizationId: string | null;
155
157
  status: "draft" | "expired" | "published" | "sent" | "accepted" | "withdrawn" | "converted";
158
+ currency: string;
156
159
  notes: string | null;
157
160
  costAmountCents: number;
158
161
  title: string;
159
- metadata: unknown;
160
162
  validFrom: string | null;
161
- currency: string;
162
163
  marketId: string | null;
163
164
  baseCurrency: string | null;
164
165
  fxRateSetId: string | null;
165
- organizationId: string | null;
166
166
  offerNumber: string;
167
167
  personId: string | null;
168
168
  opportunityId: string | null;
@@ -195,23 +195,23 @@ export declare const sellabilityService: {
195
195
  updatedAt: Date;
196
196
  }[];
197
197
  items: {
198
+ metadata: unknown;
198
199
  id: string;
199
- productId: string | null;
200
- optionId: string | null;
201
200
  createdAt: Date;
202
201
  updatedAt: Date;
203
- startsAt: Date | null;
204
- endsAt: Date | null;
205
202
  status: "cancelled" | "draft" | "confirmed" | "fulfilled" | "priced";
206
203
  notes: string | null;
207
- slotId: string | null;
208
204
  description: string | null;
205
+ productId: string | null;
206
+ optionId: string | null;
207
+ startsAt: Date | null;
208
+ endsAt: Date | null;
209
+ slotId: string | null;
209
210
  sellCurrency: string;
210
211
  title: string;
211
212
  costCurrency: string | null;
212
213
  quantity: number;
213
214
  unitId: string | null;
214
- metadata: unknown;
215
215
  taxAmountCents: number | null;
216
216
  feeAmountCents: number | null;
217
217
  offerId: string;
@@ -225,8 +225,8 @@ export declare const sellabilityService: {
225
225
  itemParticipants: {
226
226
  id: string;
227
227
  createdAt: Date;
228
- isPrimary: boolean;
229
228
  role: "other" | "traveler" | "occupant" | "primary_contact" | "beneficiary" | "service_assignee";
229
+ isPrimary: boolean;
230
230
  participantId: string;
231
231
  offerItemId: string;
232
232
  }[];
@@ -234,16 +234,16 @@ export declare const sellabilityService: {
234
234
  persistSnapshot(db: PostgresJsDatabase, input: SellabilityPersistSnapshotInput): Promise<{
235
235
  snapshot: {
236
236
  id: string;
237
- productId: string | null;
238
- optionId: string | null;
239
237
  createdAt: Date;
240
238
  updatedAt: Date;
239
+ expiresAt: Date | null;
241
240
  status: "expired" | "resolved" | "offer_constructed";
241
+ productId: string | null;
242
+ optionId: string | null;
242
243
  slotId: string | null;
243
244
  channelId: string | null;
244
245
  marketId: string | null;
245
246
  fxRateSetId: string | null;
246
- expiresAt: Date | null;
247
247
  offerId: string | null;
248
248
  requestedCurrencyCode: string | null;
249
249
  sourceCurrencyCode: string | null;
@@ -282,7 +282,7 @@ export declare const sellabilityService: {
282
282
  } | null;
283
283
  channel: {
284
284
  id: string;
285
- kind: "direct" | "affiliate" | "ota" | "reseller" | "marketplace" | "api_partner";
285
+ kind: "reseller" | "direct" | "affiliate" | "ota" | "marketplace" | "api_partner";
286
286
  } | null;
287
287
  sellability: {
288
288
  mode: "on_request" | "sellable" | "unavailable";
@@ -395,7 +395,7 @@ export declare const sellabilityService: {
395
395
  id: string;
396
396
  name: string;
397
397
  scope: "product" | "option" | "channel" | "market" | "global";
398
- policyType: "pickup" | "custom" | "capability" | "question" | "currency" | "allotment" | "occupancy" | "availability_window";
398
+ policyType: "custom" | "currency" | "pickup" | "capability" | "question" | "allotment" | "occupancy" | "availability_window";
399
399
  productId: string | null;
400
400
  optionId: string | null;
401
401
  marketId: string | null;
@@ -417,7 +417,7 @@ export declare const sellabilityService: {
417
417
  id: string;
418
418
  name: string;
419
419
  scope: "product" | "option" | "channel" | "market" | "global";
420
- policyType: "pickup" | "custom" | "capability" | "question" | "currency" | "allotment" | "occupancy" | "availability_window";
420
+ policyType: "custom" | "currency" | "pickup" | "capability" | "question" | "allotment" | "occupancy" | "availability_window";
421
421
  productId: string | null;
422
422
  optionId: string | null;
423
423
  marketId: string | null;
@@ -432,20 +432,20 @@ export declare const sellabilityService: {
432
432
  updatedAt: Date;
433
433
  } | null>;
434
434
  createPolicy(db: PostgresJsDatabase, data: CreateSellabilityPolicyInput): Promise<{
435
+ metadata: Record<string, unknown> | null;
435
436
  id: string;
436
437
  name: string;
437
- productId: string | null;
438
- optionId: string | null;
439
- active: boolean;
440
438
  createdAt: Date;
441
439
  updatedAt: Date;
440
+ scope: "product" | "option" | "channel" | "market" | "global";
442
441
  notes: string | null;
443
- metadata: Record<string, unknown> | null;
442
+ productId: string | null;
443
+ optionId: string | null;
444
+ active: boolean;
444
445
  channelId: string | null;
445
- scope: "product" | "option" | "channel" | "market" | "global";
446
446
  marketId: string | null;
447
447
  priority: number;
448
- policyType: "pickup" | "custom" | "capability" | "question" | "currency" | "allotment" | "occupancy" | "availability_window";
448
+ policyType: "custom" | "currency" | "pickup" | "capability" | "question" | "allotment" | "occupancy" | "availability_window";
449
449
  conditions: Record<string, unknown>;
450
450
  effects: Record<string, unknown>;
451
451
  } | null>;
@@ -453,7 +453,7 @@ export declare const sellabilityService: {
453
453
  id: string;
454
454
  name: string;
455
455
  scope: "product" | "option" | "channel" | "market" | "global";
456
- policyType: "pickup" | "custom" | "capability" | "question" | "currency" | "allotment" | "occupancy" | "availability_window";
456
+ policyType: "custom" | "currency" | "pickup" | "capability" | "question" | "allotment" | "occupancy" | "availability_window";
457
457
  productId: string | null;
458
458
  optionId: string | null;
459
459
  marketId: string | null;
@@ -498,15 +498,15 @@ export declare const sellabilityService: {
498
498
  createdAt: Date;
499
499
  } | null>;
500
500
  createPolicyResult(db: PostgresJsDatabase, data: CreateSellabilityPolicyResultInput): Promise<{
501
- message: string | null;
502
501
  id: string;
503
502
  createdAt: Date;
504
503
  status: "warning" | "passed" | "blocked" | "adjusted";
504
+ message: string | null;
505
+ details: Record<string, unknown> | null;
505
506
  snapshotId: string;
506
507
  candidateIndex: number;
507
508
  snapshotItemId: string | null;
508
509
  policyId: string | null;
509
- details: Record<string, unknown> | null;
510
510
  } | null>;
511
511
  updatePolicyResult(db: PostgresJsDatabase, id: string, data: UpdateSellabilityPolicyResultInput): Promise<{
512
512
  id: string;
@@ -552,12 +552,12 @@ export declare const sellabilityService: {
552
552
  updatedAt: Date;
553
553
  } | null>;
554
554
  createOfferRefreshRun(db: PostgresJsDatabase, data: CreateOfferRefreshRunInput): Promise<{
555
+ metadata: Record<string, unknown> | null;
555
556
  id: string;
556
557
  createdAt: Date;
557
558
  updatedAt: Date;
558
559
  status: "pending" | "expired" | "failed" | "running" | "completed";
559
560
  notes: string | null;
560
- metadata: Record<string, unknown> | null;
561
561
  startedAt: Date;
562
562
  completedAt: Date | null;
563
563
  offerId: string;
@@ -608,13 +608,13 @@ export declare const sellabilityService: {
608
608
  updatedAt: Date;
609
609
  } | null>;
610
610
  createOfferExpirationEvent(db: PostgresJsDatabase, data: CreateOfferExpirationEventInput): Promise<{
611
+ metadata: Record<string, unknown> | null;
611
612
  id: string;
612
613
  createdAt: Date;
613
614
  updatedAt: Date;
615
+ expiresAt: Date;
614
616
  status: "cancelled" | "scheduled" | "expired" | "superseded";
615
617
  reason: string | null;
616
- metadata: Record<string, unknown> | null;
617
- expiresAt: Date;
618
618
  offerId: string;
619
619
  snapshotId: string | null;
620
620
  expiredAt: Date | null;
@@ -662,14 +662,14 @@ export declare const sellabilityService: {
662
662
  createdAt: Date;
663
663
  } | null>;
664
664
  createExplanation(db: PostgresJsDatabase, data: CreateSellabilityExplanationInput): Promise<{
665
- message: string;
666
665
  id: string;
667
666
  createdAt: Date;
667
+ message: string;
668
668
  code: string | null;
669
+ details: Record<string, unknown> | null;
669
670
  snapshotId: string;
670
671
  candidateIndex: number;
671
672
  snapshotItemId: string | null;
672
- details: Record<string, unknown> | null;
673
673
  explanationType: "pickup" | "policy" | "warning" | "allotment" | "sellable" | "pricing" | "blocked";
674
674
  } | null>;
675
675
  updateExplanation(db: PostgresJsDatabase, id: string, data: UpdateSellabilityExplanationInput): Promise<{
@@ -718,7 +718,7 @@ export declare const sellabilityService: {
718
718
  } | null;
719
719
  channel: {
720
720
  id: string;
721
- kind: "direct" | "affiliate" | "ota" | "reseller" | "marketplace" | "api_partner";
721
+ kind: "reseller" | "direct" | "affiliate" | "ota" | "marketplace" | "api_partner";
722
722
  } | null;
723
723
  sellability: {
724
724
  mode: "on_request" | "sellable" | "unavailable";
@@ -36,11 +36,11 @@ export declare const sellabilityPolicyScopeSchema: z.ZodEnum<{
36
36
  global: "global";
37
37
  }>;
38
38
  export declare const sellabilityPolicyTypeSchema: z.ZodEnum<{
39
- pickup: "pickup";
40
39
  custom: "custom";
40
+ currency: "currency";
41
+ pickup: "pickup";
41
42
  capability: "capability";
42
43
  question: "question";
43
- currency: "currency";
44
44
  allotment: "allotment";
45
45
  occupancy: "occupancy";
46
46
  availability_window: "availability_window";
@@ -243,11 +243,11 @@ export declare const sellabilityPolicyCoreSchema: z.ZodObject<{
243
243
  global: "global";
244
244
  }>>;
245
245
  policyType: z.ZodDefault<z.ZodEnum<{
246
- pickup: "pickup";
247
246
  custom: "custom";
247
+ currency: "currency";
248
+ pickup: "pickup";
248
249
  capability: "capability";
249
250
  question: "question";
250
- currency: "currency";
251
251
  allotment: "allotment";
252
252
  occupancy: "occupancy";
253
253
  availability_window: "availability_window";
@@ -273,11 +273,11 @@ export declare const insertSellabilityPolicySchema: z.ZodObject<{
273
273
  global: "global";
274
274
  }>>;
275
275
  policyType: z.ZodDefault<z.ZodEnum<{
276
- pickup: "pickup";
277
276
  custom: "custom";
277
+ currency: "currency";
278
+ pickup: "pickup";
278
279
  capability: "capability";
279
280
  question: "question";
280
- currency: "currency";
281
281
  allotment: "allotment";
282
282
  occupancy: "occupancy";
283
283
  availability_window: "availability_window";
@@ -303,11 +303,11 @@ export declare const updateSellabilityPolicySchema: z.ZodObject<{
303
303
  global: "global";
304
304
  }>>>;
305
305
  policyType: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
306
- pickup: "pickup";
307
306
  custom: "custom";
307
+ currency: "currency";
308
+ pickup: "pickup";
308
309
  capability: "capability";
309
310
  question: "question";
310
- currency: "currency";
311
311
  allotment: "allotment";
312
312
  occupancy: "occupancy";
313
313
  availability_window: "availability_window";
@@ -334,11 +334,11 @@ export declare const sellabilityPolicyListQuerySchema: z.ZodObject<{
334
334
  global: "global";
335
335
  }>>;
336
336
  policyType: z.ZodOptional<z.ZodEnum<{
337
- pickup: "pickup";
338
337
  custom: "custom";
338
+ currency: "currency";
339
+ pickup: "pickup";
339
340
  capability: "capability";
340
341
  question: "question";
341
- currency: "currency";
342
342
  allotment: "allotment";
343
343
  occupancy: "occupancy";
344
344
  availability_window: "availability_window";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/sellability",
3
- "version": "0.4.5",
3
+ "version": "0.6.0",
4
4
  "license": "FSL-1.1-Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -25,15 +25,15 @@
25
25
  "drizzle-orm": "^0.45.2",
26
26
  "hono": "^4.12.10",
27
27
  "zod": "^4.3.6",
28
- "@voyantjs/availability": "0.4.5",
29
- "@voyantjs/core": "0.4.5",
30
- "@voyantjs/db": "0.4.5",
31
- "@voyantjs/distribution": "0.4.5",
32
- "@voyantjs/hono": "0.4.5",
33
- "@voyantjs/markets": "0.4.5",
34
- "@voyantjs/pricing": "0.4.5",
35
- "@voyantjs/products": "0.4.5",
36
- "@voyantjs/transactions": "0.4.5"
28
+ "@voyantjs/availability": "0.6.0",
29
+ "@voyantjs/core": "0.6.0",
30
+ "@voyantjs/db": "0.6.0",
31
+ "@voyantjs/distribution": "0.6.0",
32
+ "@voyantjs/hono": "0.6.0",
33
+ "@voyantjs/markets": "0.6.0",
34
+ "@voyantjs/pricing": "0.6.0",
35
+ "@voyantjs/products": "0.6.0",
36
+ "@voyantjs/transactions": "0.6.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "typescript": "^6.0.2",