@voyantjs/markets 0.5.0 → 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,21 +41,21 @@ export declare const marketsRoutes: import("hono/hono-base").HonoBase<Env, {
41
41
  input: {};
42
42
  output: {
43
43
  data: {
44
+ metadata: {
45
+ [x: string]: import("hono/utils/types").JSONValue;
46
+ } | null;
44
47
  id: string;
45
48
  name: string;
46
- code: string;
49
+ createdAt: string;
50
+ updatedAt: string;
47
51
  status: "active" | "inactive" | "archived";
52
+ timezone: string | null;
53
+ code: string;
48
54
  regionCode: string | null;
49
55
  countryCode: string | null;
50
56
  defaultLanguageTag: string;
51
57
  defaultCurrency: string;
52
- timezone: string | null;
53
58
  taxContext: string | null;
54
- metadata: {
55
- [x: string]: import("hono/utils/types").JSONValue;
56
- } | null;
57
- createdAt: string;
58
- updatedAt: string;
59
59
  } | null;
60
60
  };
61
61
  outputFormat: "json";
@@ -217,9 +217,9 @@ export declare const marketsRoutes: import("hono/hono-base").HonoBase<Env, {
217
217
  output: {
218
218
  data: {
219
219
  id: string;
220
- active: boolean;
221
220
  createdAt: string;
222
221
  updatedAt: string;
222
+ active: boolean;
223
223
  marketId: string;
224
224
  languageTag: string;
225
225
  isDefault: boolean;
@@ -338,9 +338,9 @@ export declare const marketsRoutes: import("hono/hono-base").HonoBase<Env, {
338
338
  output: {
339
339
  data: {
340
340
  id: string;
341
- active: boolean;
342
341
  createdAt: string;
343
342
  updatedAt: string;
343
+ active: boolean;
344
344
  marketId: string;
345
345
  isDefault: boolean;
346
346
  sortOrder: number;
@@ -423,7 +423,7 @@ export declare const marketsRoutes: import("hono/hono-base").HonoBase<Env, {
423
423
  output: {
424
424
  data: {
425
425
  id: string;
426
- source: "supplier" | "manual" | "ecb" | "custom" | "channel" | "other";
426
+ source: "supplier" | "custom" | "other" | "manual" | "ecb" | "channel";
427
427
  baseCurrency: string;
428
428
  effectiveAt: string;
429
429
  observedAt: string | null;
@@ -448,17 +448,17 @@ export declare const marketsRoutes: import("hono/hono-base").HonoBase<Env, {
448
448
  input: {};
449
449
  output: {
450
450
  data: {
451
- id: string;
451
+ source: "supplier" | "custom" | "other" | "manual" | "ecb" | "channel";
452
452
  metadata: {
453
453
  [x: string]: import("hono/utils/types").JSONValue;
454
454
  } | null;
455
+ id: string;
455
456
  createdAt: string;
456
- source: "supplier" | "manual" | "ecb" | "custom" | "channel" | "other";
457
+ notes: string | null;
457
458
  baseCurrency: string;
458
459
  effectiveAt: string;
459
460
  observedAt: string | null;
460
461
  sourceReference: string | null;
461
- notes: string | null;
462
462
  } | null;
463
463
  };
464
464
  outputFormat: "json";
@@ -487,7 +487,7 @@ export declare const marketsRoutes: import("hono/hono-base").HonoBase<Env, {
487
487
  output: {
488
488
  data: {
489
489
  id: string;
490
- source: "supplier" | "manual" | "ecb" | "custom" | "channel" | "other";
490
+ source: "supplier" | "custom" | "other" | "manual" | "ecb" | "channel";
491
491
  baseCurrency: string;
492
492
  effectiveAt: string;
493
493
  observedAt: string | null;
@@ -525,7 +525,7 @@ export declare const marketsRoutes: import("hono/hono-base").HonoBase<Env, {
525
525
  output: {
526
526
  data: {
527
527
  id: string;
528
- source: "supplier" | "manual" | "ecb" | "custom" | "channel" | "other";
528
+ source: "supplier" | "custom" | "other" | "manual" | "ecb" | "channel";
529
529
  baseCurrency: string;
530
530
  effectiveAt: string;
531
531
  observedAt: string | null;
@@ -726,16 +726,16 @@ export declare const marketsRoutes: import("hono/hono-base").HonoBase<Env, {
726
726
  input: {};
727
727
  output: {
728
728
  data: {
729
- id: string;
730
- active: boolean;
731
729
  metadata: {
732
730
  [x: string]: import("hono/utils/types").JSONValue;
733
731
  } | null;
732
+ id: string;
734
733
  createdAt: string;
735
734
  updatedAt: string;
735
+ notes: string | null;
736
+ active: boolean;
736
737
  marketId: string;
737
738
  isDefault: boolean;
738
- notes: string | null;
739
739
  priceCatalogId: string;
740
740
  priority: number;
741
741
  };
@@ -891,11 +891,11 @@ export declare const marketsRoutes: import("hono/hono-base").HonoBase<Env, {
891
891
  output: {
892
892
  data: {
893
893
  id: string;
894
- active: boolean;
895
894
  createdAt: string;
896
895
  updatedAt: string;
897
- marketId: string;
898
896
  notes: string | null;
897
+ active: boolean;
898
+ marketId: string;
899
899
  priceCatalogId: string | null;
900
900
  productId: string;
901
901
  optionId: string | null;
@@ -1058,11 +1058,11 @@ export declare const marketsRoutes: import("hono/hono-base").HonoBase<Env, {
1058
1058
  output: {
1059
1059
  data: {
1060
1060
  id: string;
1061
- active: boolean;
1062
1061
  createdAt: string;
1063
1062
  updatedAt: string;
1064
- marketId: string;
1065
1063
  notes: string | null;
1064
+ active: boolean;
1065
+ marketId: string;
1066
1066
  priceCatalogId: string | null;
1067
1067
  priority: number;
1068
1068
  visibility: "public" | "private" | "hidden";
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AA+BjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAkPtB,CAAA;AAEJ,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAA"}
package/dist/routes.js CHANGED
@@ -1,14 +1,15 @@
1
+ import { parseJsonBody, parseQuery } from "@voyantjs/hono";
1
2
  import { Hono } from "hono";
2
3
  import { marketsService } from "./service.js";
3
4
  import { exchangeRateListQuerySchema, fxRateSetListQuerySchema, insertExchangeRateSchema, insertFxRateSetSchema, insertMarketChannelRuleSchema, insertMarketCurrencySchema, insertMarketLocaleSchema, insertMarketPriceCatalogSchema, insertMarketProductRuleSchema, insertMarketSchema, marketChannelRuleListQuerySchema, marketCurrencyListQuerySchema, marketListQuerySchema, marketLocaleListQuerySchema, marketPriceCatalogListQuerySchema, marketProductRuleListQuerySchema, updateExchangeRateSchema, updateFxRateSetSchema, updateMarketChannelRuleSchema, updateMarketCurrencySchema, updateMarketLocaleSchema, updateMarketPriceCatalogSchema, updateMarketProductRuleSchema, updateMarketSchema, } from "./validation.js";
4
5
  export const marketsRoutes = new Hono()
5
6
  .get("/markets", async (c) => {
6
- const query = marketListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
7
+ const query = await parseQuery(c, marketListQuerySchema);
7
8
  return c.json(await marketsService.listMarkets(c.get("db"), query));
8
9
  })
9
10
  .post("/markets", async (c) => {
10
11
  return c.json({
11
- data: await marketsService.createMarket(c.get("db"), insertMarketSchema.parse(await c.req.json())),
12
+ data: await marketsService.createMarket(c.get("db"), await parseJsonBody(c, insertMarketSchema)),
12
13
  }, 201);
13
14
  })
14
15
  .get("/markets/:id", async (c) => {
@@ -18,7 +19,7 @@ export const marketsRoutes = new Hono()
18
19
  return c.json({ data: row });
19
20
  })
20
21
  .patch("/markets/:id", async (c) => {
21
- const row = await marketsService.updateMarket(c.get("db"), c.req.param("id"), updateMarketSchema.parse(await c.req.json()));
22
+ const row = await marketsService.updateMarket(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateMarketSchema));
22
23
  if (!row)
23
24
  return c.json({ error: "Market not found" }, 404);
24
25
  return c.json({ data: row });
@@ -30,17 +31,17 @@ export const marketsRoutes = new Hono()
30
31
  return c.json({ success: true });
31
32
  })
32
33
  .get("/market-locales", async (c) => {
33
- const query = marketLocaleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
34
+ const query = await parseQuery(c, marketLocaleListQuerySchema);
34
35
  return c.json(await marketsService.listMarketLocales(c.get("db"), query));
35
36
  })
36
37
  .post("/markets/:id/locales", async (c) => {
37
- const row = await marketsService.createMarketLocale(c.get("db"), c.req.param("id"), insertMarketLocaleSchema.parse(await c.req.json()));
38
+ const row = await marketsService.createMarketLocale(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertMarketLocaleSchema));
38
39
  if (!row)
39
40
  return c.json({ error: "Market not found" }, 404);
40
41
  return c.json({ data: row }, 201);
41
42
  })
42
43
  .patch("/market-locales/:id", async (c) => {
43
- const row = await marketsService.updateMarketLocale(c.get("db"), c.req.param("id"), updateMarketLocaleSchema.parse(await c.req.json()));
44
+ const row = await marketsService.updateMarketLocale(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateMarketLocaleSchema));
44
45
  if (!row)
45
46
  return c.json({ error: "Market locale not found" }, 404);
46
47
  return c.json({ data: row });
@@ -52,17 +53,17 @@ export const marketsRoutes = new Hono()
52
53
  return c.json({ success: true });
53
54
  })
54
55
  .get("/market-currencies", async (c) => {
55
- const query = marketCurrencyListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
56
+ const query = await parseQuery(c, marketCurrencyListQuerySchema);
56
57
  return c.json(await marketsService.listMarketCurrencies(c.get("db"), query));
57
58
  })
58
59
  .post("/markets/:id/currencies", async (c) => {
59
- const row = await marketsService.createMarketCurrency(c.get("db"), c.req.param("id"), insertMarketCurrencySchema.parse(await c.req.json()));
60
+ const row = await marketsService.createMarketCurrency(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertMarketCurrencySchema));
60
61
  if (!row)
61
62
  return c.json({ error: "Market not found" }, 404);
62
63
  return c.json({ data: row }, 201);
63
64
  })
64
65
  .patch("/market-currencies/:id", async (c) => {
65
- const row = await marketsService.updateMarketCurrency(c.get("db"), c.req.param("id"), updateMarketCurrencySchema.parse(await c.req.json()));
66
+ const row = await marketsService.updateMarketCurrency(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateMarketCurrencySchema));
66
67
  if (!row)
67
68
  return c.json({ error: "Market currency not found" }, 404);
68
69
  return c.json({ data: row });
@@ -74,12 +75,12 @@ export const marketsRoutes = new Hono()
74
75
  return c.json({ success: true });
75
76
  })
76
77
  .get("/fx-rate-sets", async (c) => {
77
- const query = fxRateSetListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
78
+ const query = await parseQuery(c, fxRateSetListQuerySchema);
78
79
  return c.json(await marketsService.listFxRateSets(c.get("db"), query));
79
80
  })
80
81
  .post("/fx-rate-sets", async (c) => {
81
82
  return c.json({
82
- data: await marketsService.createFxRateSet(c.get("db"), insertFxRateSetSchema.parse(await c.req.json())),
83
+ data: await marketsService.createFxRateSet(c.get("db"), await parseJsonBody(c, insertFxRateSetSchema)),
83
84
  }, 201);
84
85
  })
85
86
  .get("/fx-rate-sets/:id", async (c) => {
@@ -89,7 +90,7 @@ export const marketsRoutes = new Hono()
89
90
  return c.json({ data: row });
90
91
  })
91
92
  .patch("/fx-rate-sets/:id", async (c) => {
92
- const row = await marketsService.updateFxRateSet(c.get("db"), c.req.param("id"), updateFxRateSetSchema.parse(await c.req.json()));
93
+ const row = await marketsService.updateFxRateSet(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateFxRateSetSchema));
93
94
  if (!row)
94
95
  return c.json({ error: "FX rate set not found" }, 404);
95
96
  return c.json({ data: row });
@@ -101,17 +102,17 @@ export const marketsRoutes = new Hono()
101
102
  return c.json({ success: true });
102
103
  })
103
104
  .get("/exchange-rates", async (c) => {
104
- const query = exchangeRateListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
105
+ const query = await parseQuery(c, exchangeRateListQuerySchema);
105
106
  return c.json(await marketsService.listExchangeRates(c.get("db"), query));
106
107
  })
107
108
  .post("/fx-rate-sets/:id/exchange-rates", async (c) => {
108
- const row = await marketsService.createExchangeRate(c.get("db"), c.req.param("id"), insertExchangeRateSchema.parse(await c.req.json()));
109
+ const row = await marketsService.createExchangeRate(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertExchangeRateSchema));
109
110
  if (!row)
110
111
  return c.json({ error: "FX rate set not found" }, 404);
111
112
  return c.json({ data: row }, 201);
112
113
  })
113
114
  .patch("/exchange-rates/:id", async (c) => {
114
- const row = await marketsService.updateExchangeRate(c.get("db"), c.req.param("id"), updateExchangeRateSchema.parse(await c.req.json()));
115
+ const row = await marketsService.updateExchangeRate(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateExchangeRateSchema));
115
116
  if (!row)
116
117
  return c.json({ error: "Exchange rate not found" }, 404);
117
118
  return c.json({ data: row });
@@ -123,11 +124,11 @@ export const marketsRoutes = new Hono()
123
124
  return c.json({ success: true });
124
125
  })
125
126
  .get("/price-catalogs", async (c) => {
126
- const query = marketPriceCatalogListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
127
+ const query = await parseQuery(c, marketPriceCatalogListQuerySchema);
127
128
  return c.json(await marketsService.listMarketPriceCatalogs(c.get("db"), query));
128
129
  })
129
130
  .post("/price-catalogs", async (c) => {
130
- const row = await marketsService.createMarketPriceCatalog(c.get("db"), insertMarketPriceCatalogSchema.parse(await c.req.json()));
131
+ const row = await marketsService.createMarketPriceCatalog(c.get("db"), await parseJsonBody(c, insertMarketPriceCatalogSchema));
131
132
  if (!row)
132
133
  return c.json({ error: "Market not found" }, 404);
133
134
  return c.json({ data: row }, 201);
@@ -139,7 +140,7 @@ export const marketsRoutes = new Hono()
139
140
  return c.json({ data: row });
140
141
  })
141
142
  .patch("/price-catalogs/:id", async (c) => {
142
- const row = await marketsService.updateMarketPriceCatalog(c.get("db"), c.req.param("id"), updateMarketPriceCatalogSchema.parse(await c.req.json()));
143
+ const row = await marketsService.updateMarketPriceCatalog(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateMarketPriceCatalogSchema));
143
144
  if (!row)
144
145
  return c.json({ error: "Market price catalog not found" }, 404);
145
146
  return c.json({ data: row });
@@ -151,11 +152,11 @@ export const marketsRoutes = new Hono()
151
152
  return c.json({ success: true });
152
153
  })
153
154
  .get("/product-rules", async (c) => {
154
- const query = marketProductRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
155
+ const query = await parseQuery(c, marketProductRuleListQuerySchema);
155
156
  return c.json(await marketsService.listMarketProductRules(c.get("db"), query));
156
157
  })
157
158
  .post("/product-rules", async (c) => {
158
- const row = await marketsService.createMarketProductRule(c.get("db"), insertMarketProductRuleSchema.parse(await c.req.json()));
159
+ const row = await marketsService.createMarketProductRule(c.get("db"), await parseJsonBody(c, insertMarketProductRuleSchema));
159
160
  if (!row)
160
161
  return c.json({ error: "Market not found" }, 404);
161
162
  return c.json({ data: row }, 201);
@@ -167,7 +168,7 @@ export const marketsRoutes = new Hono()
167
168
  return c.json({ data: row });
168
169
  })
169
170
  .patch("/product-rules/:id", async (c) => {
170
- const row = await marketsService.updateMarketProductRule(c.get("db"), c.req.param("id"), updateMarketProductRuleSchema.parse(await c.req.json()));
171
+ const row = await marketsService.updateMarketProductRule(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateMarketProductRuleSchema));
171
172
  if (!row)
172
173
  return c.json({ error: "Market product rule not found" }, 404);
173
174
  return c.json({ data: row });
@@ -179,11 +180,11 @@ export const marketsRoutes = new Hono()
179
180
  return c.json({ success: true });
180
181
  })
181
182
  .get("/channel-rules", async (c) => {
182
- const query = marketChannelRuleListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
183
+ const query = await parseQuery(c, marketChannelRuleListQuerySchema);
183
184
  return c.json(await marketsService.listMarketChannelRules(c.get("db"), query));
184
185
  })
185
186
  .post("/channel-rules", async (c) => {
186
- const row = await marketsService.createMarketChannelRule(c.get("db"), insertMarketChannelRuleSchema.parse(await c.req.json()));
187
+ const row = await marketsService.createMarketChannelRule(c.get("db"), await parseJsonBody(c, insertMarketChannelRuleSchema));
187
188
  if (!row)
188
189
  return c.json({ error: "Market not found" }, 404);
189
190
  return c.json({ data: row }, 201);
@@ -195,7 +196,7 @@ export const marketsRoutes = new Hono()
195
196
  return c.json({ data: row });
196
197
  })
197
198
  .patch("/channel-rules/:id", async (c) => {
198
- const row = await marketsService.updateMarketChannelRule(c.get("db"), c.req.param("id"), updateMarketChannelRuleSchema.parse(await c.req.json()));
199
+ const row = await marketsService.updateMarketChannelRule(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateMarketChannelRuleSchema));
199
200
  if (!row)
200
201
  return c.json({ error: "Market channel rule not found" }, 404);
201
202
  return c.json({ data: row });
package/dist/schema.d.ts CHANGED
@@ -579,7 +579,7 @@ export declare const fxRateSets: import("drizzle-orm/pg-core").PgTableWithColumn
579
579
  tableName: "fx_rate_sets";
580
580
  dataType: "string";
581
581
  columnType: "PgEnumColumn";
582
- data: "supplier" | "manual" | "ecb" | "custom" | "channel" | "other";
582
+ data: "supplier" | "custom" | "other" | "manual" | "ecb" | "channel";
583
583
  driverParam: string;
584
584
  notNull: true;
585
585
  hasDefault: true;
@@ -36,19 +36,19 @@ export declare function getMarketById(db: PostgresJsDatabase, id: string): Promi
36
36
  updatedAt: Date;
37
37
  } | null>;
38
38
  export declare function createMarket(db: PostgresJsDatabase, data: CreateMarketInput): Promise<{
39
+ metadata: Record<string, unknown> | null;
39
40
  id: string;
40
41
  name: string;
41
- code: string;
42
+ createdAt: Date;
43
+ updatedAt: Date;
42
44
  status: "active" | "inactive" | "archived";
45
+ timezone: string | null;
46
+ code: string;
43
47
  regionCode: string | null;
44
48
  countryCode: string | null;
45
49
  defaultLanguageTag: string;
46
50
  defaultCurrency: string;
47
- timezone: string | null;
48
51
  taxContext: string | null;
49
- metadata: Record<string, unknown> | null;
50
- createdAt: Date;
51
- updatedAt: Date;
52
52
  } | null>;
53
53
  export declare function updateMarket(db: PostgresJsDatabase, id: string, data: UpdateMarketInput): Promise<{
54
54
  id: string;
@@ -85,9 +85,9 @@ export declare function listMarketLocales(db: PostgresJsDatabase, query: MarketL
85
85
  }>;
86
86
  export declare function createMarketLocale(db: PostgresJsDatabase, marketId: string, data: CreateMarketLocaleInput): Promise<{
87
87
  id: string;
88
- active: boolean;
89
88
  createdAt: Date;
90
89
  updatedAt: Date;
90
+ active: boolean;
91
91
  marketId: string;
92
92
  languageTag: string;
93
93
  isDefault: boolean;
@@ -125,9 +125,9 @@ export declare function listMarketCurrencies(db: PostgresJsDatabase, query: Mark
125
125
  }>;
126
126
  export declare function createMarketCurrency(db: PostgresJsDatabase, marketId: string, data: CreateMarketCurrencyInput): Promise<{
127
127
  id: string;
128
- active: boolean;
129
128
  createdAt: Date;
130
129
  updatedAt: Date;
130
+ active: boolean;
131
131
  marketId: string;
132
132
  isDefault: boolean;
133
133
  sortOrder: number;
@@ -153,7 +153,7 @@ export declare function deleteMarketCurrency(db: PostgresJsDatabase, id: string)
153
153
  export declare function listFxRateSets(db: PostgresJsDatabase, query: FxRateSetListQuery): Promise<{
154
154
  data: {
155
155
  id: string;
156
- source: "supplier" | "manual" | "ecb" | "custom" | "channel" | "other";
156
+ source: "supplier" | "custom" | "other" | "manual" | "ecb" | "channel";
157
157
  baseCurrency: string;
158
158
  effectiveAt: Date;
159
159
  observedAt: Date | null;
@@ -168,7 +168,7 @@ export declare function listFxRateSets(db: PostgresJsDatabase, query: FxRateSetL
168
168
  }>;
169
169
  export declare function getFxRateSetById(db: PostgresJsDatabase, id: string): Promise<{
170
170
  id: string;
171
- source: "supplier" | "manual" | "ecb" | "custom" | "channel" | "other";
171
+ source: "supplier" | "custom" | "other" | "manual" | "ecb" | "channel";
172
172
  baseCurrency: string;
173
173
  effectiveAt: Date;
174
174
  observedAt: Date | null;
@@ -178,19 +178,19 @@ export declare function getFxRateSetById(db: PostgresJsDatabase, id: string): Pr
178
178
  createdAt: Date;
179
179
  } | null>;
180
180
  export declare function createFxRateSet(db: PostgresJsDatabase, data: CreateFxRateSetInput): Promise<{
181
- id: string;
181
+ source: "supplier" | "custom" | "other" | "manual" | "ecb" | "channel";
182
182
  metadata: Record<string, unknown> | null;
183
+ id: string;
183
184
  createdAt: Date;
184
- source: "supplier" | "manual" | "ecb" | "custom" | "channel" | "other";
185
+ notes: string | null;
185
186
  baseCurrency: string;
186
187
  effectiveAt: Date;
187
188
  observedAt: Date | null;
188
189
  sourceReference: string | null;
189
- notes: string | null;
190
190
  } | null>;
191
191
  export declare function updateFxRateSet(db: PostgresJsDatabase, id: string, data: UpdateFxRateSetInput): Promise<{
192
192
  id: string;
193
- source: "supplier" | "manual" | "ecb" | "custom" | "channel" | "other";
193
+ source: "supplier" | "custom" | "other" | "manual" | "ecb" | "channel";
194
194
  baseCurrency: string;
195
195
  effectiveAt: Date;
196
196
  observedAt: Date | null;
@@ -30,14 +30,14 @@ export declare function getMarketPriceCatalogById(db: PostgresJsDatabase, id: st
30
30
  updatedAt: Date;
31
31
  } | null>;
32
32
  export declare function createMarketPriceCatalog(db: PostgresJsDatabase, data: CreateMarketPriceCatalogInput): Promise<{
33
- id: string;
34
- active: boolean;
35
33
  metadata: Record<string, unknown> | null;
34
+ id: string;
36
35
  createdAt: Date;
37
36
  updatedAt: Date;
37
+ notes: string | null;
38
+ active: boolean;
38
39
  marketId: string;
39
40
  isDefault: boolean;
40
- notes: string | null;
41
41
  priceCatalogId: string;
42
42
  priority: number;
43
43
  } | null>;
@@ -95,11 +95,11 @@ export declare function getMarketProductRuleById(db: PostgresJsDatabase, id: str
95
95
  } | null>;
96
96
  export declare function createMarketProductRule(db: PostgresJsDatabase, data: CreateMarketProductRuleInput): Promise<{
97
97
  id: string;
98
- active: boolean;
99
98
  createdAt: Date;
100
99
  updatedAt: Date;
101
- marketId: string;
102
100
  notes: string | null;
101
+ active: boolean;
102
+ marketId: string;
103
103
  priceCatalogId: string | null;
104
104
  productId: string;
105
105
  optionId: string | null;
@@ -161,11 +161,11 @@ export declare function getMarketChannelRuleById(db: PostgresJsDatabase, id: str
161
161
  } | null>;
162
162
  export declare function createMarketChannelRule(db: PostgresJsDatabase, data: CreateMarketChannelRuleInput): Promise<{
163
163
  id: string;
164
- active: boolean;
165
164
  createdAt: Date;
166
165
  updatedAt: Date;
167
- marketId: string;
168
166
  notes: string | null;
167
+ active: boolean;
168
+ marketId: string;
169
169
  priceCatalogId: string | null;
170
170
  priority: number;
171
171
  visibility: "public" | "private" | "hidden";
@@ -22,11 +22,11 @@ export declare const marketChannelScopeSchema: z.ZodEnum<{
22
22
  }>;
23
23
  export declare const fxRateSourceSchema: z.ZodEnum<{
24
24
  supplier: "supplier";
25
+ custom: "custom";
26
+ other: "other";
25
27
  manual: "manual";
26
28
  ecb: "ecb";
27
- custom: "custom";
28
29
  channel: "channel";
29
- other: "other";
30
30
  }>;
31
31
  export declare const marketCoreSchema: z.ZodObject<{
32
32
  code: z.ZodString;
@@ -156,11 +156,11 @@ export declare const marketCurrencyListQuerySchema: z.ZodObject<{
156
156
  export declare const fxRateSetCoreSchema: z.ZodObject<{
157
157
  source: z.ZodDefault<z.ZodEnum<{
158
158
  supplier: "supplier";
159
+ custom: "custom";
160
+ other: "other";
159
161
  manual: "manual";
160
162
  ecb: "ecb";
161
- custom: "custom";
162
163
  channel: "channel";
163
- other: "other";
164
164
  }>>;
165
165
  baseCurrency: z.ZodString;
166
166
  effectiveAt: z.ZodString;
@@ -172,11 +172,11 @@ export declare const fxRateSetCoreSchema: z.ZodObject<{
172
172
  export declare const insertFxRateSetSchema: z.ZodObject<{
173
173
  source: z.ZodDefault<z.ZodEnum<{
174
174
  supplier: "supplier";
175
+ custom: "custom";
176
+ other: "other";
175
177
  manual: "manual";
176
178
  ecb: "ecb";
177
- custom: "custom";
178
179
  channel: "channel";
179
- other: "other";
180
180
  }>>;
181
181
  baseCurrency: z.ZodString;
182
182
  effectiveAt: z.ZodString;
@@ -188,11 +188,11 @@ export declare const insertFxRateSetSchema: z.ZodObject<{
188
188
  export declare const updateFxRateSetSchema: z.ZodObject<{
189
189
  source: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
190
190
  supplier: "supplier";
191
+ custom: "custom";
192
+ other: "other";
191
193
  manual: "manual";
192
194
  ecb: "ecb";
193
- custom: "custom";
194
195
  channel: "channel";
195
- other: "other";
196
196
  }>>>;
197
197
  baseCurrency: z.ZodOptional<z.ZodString>;
198
198
  effectiveAt: z.ZodOptional<z.ZodString>;
@@ -206,11 +206,11 @@ export declare const fxRateSetListQuerySchema: z.ZodObject<{
206
206
  offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
207
207
  source: z.ZodOptional<z.ZodEnum<{
208
208
  supplier: "supplier";
209
+ custom: "custom";
210
+ other: "other";
209
211
  manual: "manual";
210
212
  ecb: "ecb";
211
- custom: "custom";
212
213
  channel: "channel";
213
- other: "other";
214
214
  }>>;
215
215
  baseCurrency: z.ZodOptional<z.ZodString>;
216
216
  }, z.core.$strip>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/markets",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "license": "FSL-1.1-Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -25,14 +25,14 @@
25
25
  "drizzle-orm": "^0.45.2",
26
26
  "hono": "^4.12.10",
27
27
  "zod": "^4.3.6",
28
- "@voyantjs/core": "0.5.0",
29
- "@voyantjs/db": "0.5.0",
30
- "@voyantjs/hono": "0.5.0"
28
+ "@voyantjs/core": "0.6.0",
29
+ "@voyantjs/db": "0.6.0",
30
+ "@voyantjs/hono": "0.6.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "typescript": "^6.0.2",
34
- "@voyantjs/distribution": "0.5.0",
35
- "@voyantjs/products": "0.5.0",
34
+ "@voyantjs/distribution": "0.6.0",
35
+ "@voyantjs/products": "0.6.0",
36
36
  "@voyantjs/voyant-typescript-config": "0.1.0"
37
37
  },
38
38
  "files": [