@voyant-travel/commerce 0.1.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/LICENSE +201 -0
- package/README.md +145 -0
- package/dist/accepted-quote-version-reservation-golden-flow.test.d.ts +2 -0
- package/dist/accepted-quote-version-reservation-golden-flow.test.d.ts.map +1 -0
- package/dist/accepted-quote-version-reservation-golden-flow.test.js +398 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/interface.d.ts +18 -0
- package/dist/interface.d.ts.map +1 -0
- package/dist/interface.js +246 -0
- package/dist/interface.test.d.ts +2 -0
- package/dist/interface.test.d.ts.map +1 -0
- package/dist/interface.test.js +357 -0
- package/dist/markets/index.d.ts +11 -0
- package/dist/markets/index.d.ts.map +1 -0
- package/dist/markets/index.js +12 -0
- package/dist/markets/routes.d.ts +1182 -0
- package/dist/markets/routes.d.ts.map +1 -0
- package/dist/markets/routes.js +209 -0
- package/dist/markets/schema.d.ts +1527 -0
- package/dist/markets/schema.d.ts.map +1 -0
- package/dist/markets/schema.js +240 -0
- package/dist/markets/service-core.d.ts +253 -0
- package/dist/markets/service-core.d.ts.map +1 -0
- package/dist/markets/service-core.js +242 -0
- package/dist/markets/service-rules.d.ts +191 -0
- package/dist/markets/service-rules.d.ts.map +1 -0
- package/dist/markets/service-rules.js +155 -0
- package/dist/markets/service-shared.d.ts +36 -0
- package/dist/markets/service-shared.d.ts.map +1 -0
- package/dist/markets/service-shared.js +7 -0
- package/dist/markets/service.d.ts +43 -0
- package/dist/markets/service.d.ts.map +1 -0
- package/dist/markets/service.js +42 -0
- package/dist/markets/validation.d.ts +451 -0
- package/dist/markets/validation.d.ts.map +1 -0
- package/dist/markets/validation.js +160 -0
- package/dist/pricing/events.d.ts +53 -0
- package/dist/pricing/events.d.ts.map +1 -0
- package/dist/pricing/events.js +28 -0
- package/dist/pricing/index.d.ts +15 -0
- package/dist/pricing/index.d.ts.map +1 -0
- package/dist/pricing/index.js +18 -0
- package/dist/pricing/routes-core.d.ts +981 -0
- package/dist/pricing/routes-core.d.ts.map +1 -0
- package/dist/pricing/routes-core.js +102 -0
- package/dist/pricing/routes-public.d.ts +136 -0
- package/dist/pricing/routes-public.d.ts.map +1 -0
- package/dist/pricing/routes-public.js +14 -0
- package/dist/pricing/routes-rules.d.ts +1339 -0
- package/dist/pricing/routes-rules.d.ts.map +1 -0
- package/dist/pricing/routes-rules.js +138 -0
- package/dist/pricing/routes-shared.d.ts +14 -0
- package/dist/pricing/routes-shared.d.ts.map +1 -0
- package/dist/pricing/routes-shared.js +3 -0
- package/dist/pricing/routes.d.ts +7 -0
- package/dist/pricing/routes.d.ts.map +1 -0
- package/dist/pricing/routes.js +6 -0
- package/dist/pricing/schema-catalogs.d.ts +467 -0
- package/dist/pricing/schema-catalogs.d.ts.map +1 -0
- package/dist/pricing/schema-catalogs.js +47 -0
- package/dist/pricing/schema-categories.d.ts +497 -0
- package/dist/pricing/schema-categories.d.ts.map +1 -0
- package/dist/pricing/schema-categories.js +54 -0
- package/dist/pricing/schema-departure-overrides.d.ts +228 -0
- package/dist/pricing/schema-departure-overrides.d.ts.map +1 -0
- package/dist/pricing/schema-departure-overrides.js +36 -0
- package/dist/pricing/schema-option-rules.d.ts +1770 -0
- package/dist/pricing/schema-option-rules.d.ts.map +1 -0
- package/dist/pricing/schema-option-rules.js +181 -0
- package/dist/pricing/schema-policies.d.ts +395 -0
- package/dist/pricing/schema-policies.d.ts.map +1 -0
- package/dist/pricing/schema-policies.js +41 -0
- package/dist/pricing/schema-relations.d.ts +59 -0
- package/dist/pricing/schema-relations.d.ts.map +1 -0
- package/dist/pricing/schema-relations.js +111 -0
- package/dist/pricing/schema-shared.d.ts +11 -0
- package/dist/pricing/schema-shared.d.ts.map +1 -0
- package/dist/pricing/schema-shared.js +67 -0
- package/dist/pricing/schema.d.ts +8 -0
- package/dist/pricing/schema.d.ts.map +1 -0
- package/dist/pricing/schema.js +7 -0
- package/dist/pricing/service-catalog-plane-pricing.d.ts +95 -0
- package/dist/pricing/service-catalog-plane-pricing.d.ts.map +1 -0
- package/dist/pricing/service-catalog-plane-pricing.js +382 -0
- package/dist/pricing/service-catalogs.d.ts +139 -0
- package/dist/pricing/service-catalogs.d.ts.map +1 -0
- package/dist/pricing/service-catalogs.js +89 -0
- package/dist/pricing/service-categories.d.ts +147 -0
- package/dist/pricing/service-categories.d.ts.map +1 -0
- package/dist/pricing/service-categories.js +105 -0
- package/dist/pricing/service-departure-overrides.d.ts +67 -0
- package/dist/pricing/service-departure-overrides.d.ts.map +1 -0
- package/dist/pricing/service-departure-overrides.js +54 -0
- package/dist/pricing/service-option-rules.d.ts +321 -0
- package/dist/pricing/service-option-rules.d.ts.map +1 -0
- package/dist/pricing/service-option-rules.js +340 -0
- package/dist/pricing/service-policies.d.ts +123 -0
- package/dist/pricing/service-policies.d.ts.map +1 -0
- package/dist/pricing/service-policies.js +95 -0
- package/dist/pricing/service-public.d.ts +89 -0
- package/dist/pricing/service-public.d.ts.map +1 -0
- package/dist/pricing/service-public.js +473 -0
- package/dist/pricing/service-rule-resolver.d.ts +67 -0
- package/dist/pricing/service-rule-resolver.d.ts.map +1 -0
- package/dist/pricing/service-rule-resolver.js +204 -0
- package/dist/pricing/service-shared.d.ts +53 -0
- package/dist/pricing/service-shared.d.ts.map +1 -0
- package/dist/pricing/service-shared.js +4 -0
- package/dist/pricing/service-transfer-rules.d.ts +211 -0
- package/dist/pricing/service-transfer-rules.d.ts.map +1 -0
- package/dist/pricing/service-transfer-rules.js +139 -0
- package/dist/pricing/service.d.ts +79 -0
- package/dist/pricing/service.d.ts.map +1 -0
- package/dist/pricing/service.js +78 -0
- package/dist/pricing/validation-public.d.ts +412 -0
- package/dist/pricing/validation-public.d.ts.map +1 -0
- package/dist/pricing/validation-public.js +111 -0
- package/dist/pricing/validation-shared.d.ts +71 -0
- package/dist/pricing/validation-shared.d.ts.map +1 -0
- package/dist/pricing/validation-shared.js +63 -0
- package/dist/pricing/validation.d.ts +987 -0
- package/dist/pricing/validation.d.ts.map +1 -0
- package/dist/pricing/validation.js +307 -0
- package/dist/promotions/events.d.ts +38 -0
- package/dist/promotions/events.d.ts.map +1 -0
- package/dist/promotions/events.js +25 -0
- package/dist/promotions/index.d.ts +12 -0
- package/dist/promotions/index.d.ts.map +1 -0
- package/dist/promotions/index.js +17 -0
- package/dist/promotions/routes-shared.d.ts +14 -0
- package/dist/promotions/routes-shared.d.ts.map +1 -0
- package/dist/promotions/routes-shared.js +3 -0
- package/dist/promotions/routes.d.ts +395 -0
- package/dist/promotions/routes.d.ts.map +1 -0
- package/dist/promotions/routes.js +55 -0
- package/dist/promotions/schema.d.ts +675 -0
- package/dist/promotions/schema.d.ts.map +1 -0
- package/dist/promotions/schema.js +126 -0
- package/dist/promotions/service-booking-confirmed.d.ts +77 -0
- package/dist/promotions/service-booking-confirmed.d.ts.map +1 -0
- package/dist/promotions/service-booking-confirmed.js +134 -0
- package/dist/promotions/service-boundary-scheduler.d.ts +85 -0
- package/dist/promotions/service-boundary-scheduler.d.ts.map +1 -0
- package/dist/promotions/service-boundary-scheduler.js +141 -0
- package/dist/promotions/service-catalog-evaluator.d.ts +22 -0
- package/dist/promotions/service-catalog-evaluator.d.ts.map +1 -0
- package/dist/promotions/service-catalog-evaluator.js +33 -0
- package/dist/promotions/service-catalog-plane-promotions.d.ts +73 -0
- package/dist/promotions/service-catalog-plane-promotions.d.ts.map +1 -0
- package/dist/promotions/service-catalog-plane-promotions.js +118 -0
- package/dist/promotions/service-evaluator.d.ts +134 -0
- package/dist/promotions/service-evaluator.d.ts.map +1 -0
- package/dist/promotions/service-evaluator.js +302 -0
- package/dist/promotions/service-storefront.d.ts +147 -0
- package/dist/promotions/service-storefront.d.ts.map +1 -0
- package/dist/promotions/service-storefront.js +326 -0
- package/dist/promotions/service.d.ts +143 -0
- package/dist/promotions/service.d.ts.map +1 -0
- package/dist/promotions/service.js +359 -0
- package/dist/promotions/validation.d.ts +195 -0
- package/dist/promotions/validation.d.ts.map +1 -0
- package/dist/promotions/validation.js +167 -0
- package/dist/promotions/workflow-bulk-reindex.d.ts +36 -0
- package/dist/promotions/workflow-bulk-reindex.d.ts.map +1 -0
- package/dist/promotions/workflow-bulk-reindex.js +53 -0
- package/dist/promotions/workflow-runtime.d.ts +17 -0
- package/dist/promotions/workflow-runtime.d.ts.map +1 -0
- package/dist/promotions/workflow-runtime.js +9 -0
- package/dist/runtime.d.ts +18 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +27 -0
- package/dist/runtime.test.d.ts +2 -0
- package/dist/runtime.test.d.ts.map +1 -0
- package/dist/runtime.test.js +25 -0
- package/dist/schema.d.ts +5 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +4 -0
- package/dist/sellability/index.d.ts +13 -0
- package/dist/sellability/index.d.ts.map +1 -0
- package/dist/sellability/index.js +17 -0
- package/dist/sellability/routes.d.ts +2332 -0
- package/dist/sellability/routes.d.ts.map +1 -0
- package/dist/sellability/routes.js +166 -0
- package/dist/sellability/schema.d.ts +1716 -0
- package/dist/sellability/schema.d.ts.map +1 -0
- package/dist/sellability/schema.js +278 -0
- package/dist/sellability/service-records.d.ts +316 -0
- package/dist/sellability/service-records.d.ts.map +1 -0
- package/dist/sellability/service-records.js +253 -0
- package/dist/sellability/service-resolve.d.ts +72 -0
- package/dist/sellability/service-resolve.d.ts.map +1 -0
- package/dist/sellability/service-resolve.js +580 -0
- package/dist/sellability/service-shared.d.ts +124 -0
- package/dist/sellability/service-shared.d.ts.map +1 -0
- package/dist/sellability/service-shared.js +96 -0
- package/dist/sellability/service-snapshots.d.ts +191 -0
- package/dist/sellability/service-snapshots.d.ts.map +1 -0
- package/dist/sellability/service-snapshots.js +153 -0
- package/dist/sellability/service.d.ts +1038 -0
- package/dist/sellability/service.d.ts.map +1 -0
- package/dist/sellability/service.js +17 -0
- package/dist/sellability/validation.d.ts +477 -0
- package/dist/sellability/validation.d.ts.map +1 -0
- package/dist/sellability/validation.js +192 -0
- package/dist/types.d.ts +239 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { and, asc, desc, eq, ilike, or, sql } from "drizzle-orm";
|
|
2
|
+
import { exchangeRates, fxRateSets, marketCurrencies, marketLocales, markets } from "./schema.js";
|
|
3
|
+
import { paginate, toTimestamp } from "./service-shared.js";
|
|
4
|
+
export async function listMarkets(db, query) {
|
|
5
|
+
const conditions = [];
|
|
6
|
+
if (query.status)
|
|
7
|
+
conditions.push(eq(markets.status, query.status));
|
|
8
|
+
if (query.countryCode)
|
|
9
|
+
conditions.push(eq(markets.countryCode, query.countryCode));
|
|
10
|
+
if (query.search) {
|
|
11
|
+
const term = `%${query.search}%`;
|
|
12
|
+
conditions.push(or(ilike(markets.name, term), ilike(markets.code, term)));
|
|
13
|
+
}
|
|
14
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
15
|
+
return paginate(db
|
|
16
|
+
.select()
|
|
17
|
+
.from(markets)
|
|
18
|
+
.where(where)
|
|
19
|
+
.limit(query.limit)
|
|
20
|
+
.offset(query.offset)
|
|
21
|
+
.orderBy(desc(markets.updatedAt)), db.select({ count: sql `count(*)::int` }).from(markets).where(where), query.limit, query.offset);
|
|
22
|
+
}
|
|
23
|
+
export async function getMarketById(db, id) {
|
|
24
|
+
const [row] = await db.select().from(markets).where(eq(markets.id, id)).limit(1);
|
|
25
|
+
return row ?? null;
|
|
26
|
+
}
|
|
27
|
+
export async function createMarket(db, data) {
|
|
28
|
+
const [row] = await db.insert(markets).values(data).returning();
|
|
29
|
+
return row ?? null;
|
|
30
|
+
}
|
|
31
|
+
export async function updateMarket(db, id, data) {
|
|
32
|
+
const [row] = await db
|
|
33
|
+
.update(markets)
|
|
34
|
+
.set({ ...data, updatedAt: new Date() })
|
|
35
|
+
.where(eq(markets.id, id))
|
|
36
|
+
.returning();
|
|
37
|
+
return row ?? null;
|
|
38
|
+
}
|
|
39
|
+
export async function deleteMarket(db, id) {
|
|
40
|
+
const [row] = await db.delete(markets).where(eq(markets.id, id)).returning({ id: markets.id });
|
|
41
|
+
return row ?? null;
|
|
42
|
+
}
|
|
43
|
+
export async function listMarketLocales(db, query) {
|
|
44
|
+
const conditions = [];
|
|
45
|
+
if (query.marketId)
|
|
46
|
+
conditions.push(eq(marketLocales.marketId, query.marketId));
|
|
47
|
+
if (query.languageTag)
|
|
48
|
+
conditions.push(eq(marketLocales.languageTag, query.languageTag));
|
|
49
|
+
if (query.active !== undefined)
|
|
50
|
+
conditions.push(eq(marketLocales.active, query.active));
|
|
51
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
52
|
+
return paginate(db
|
|
53
|
+
.select()
|
|
54
|
+
.from(marketLocales)
|
|
55
|
+
.where(where)
|
|
56
|
+
.limit(query.limit)
|
|
57
|
+
.offset(query.offset)
|
|
58
|
+
.orderBy(asc(marketLocales.sortOrder), asc(marketLocales.createdAt)), db.select({ count: sql `count(*)::int` }).from(marketLocales).where(where), query.limit, query.offset);
|
|
59
|
+
}
|
|
60
|
+
export async function createMarketLocale(db, marketId, data) {
|
|
61
|
+
const [market] = await db
|
|
62
|
+
.select({ id: markets.id })
|
|
63
|
+
.from(markets)
|
|
64
|
+
.where(eq(markets.id, marketId))
|
|
65
|
+
.limit(1);
|
|
66
|
+
if (!market)
|
|
67
|
+
return null;
|
|
68
|
+
const [row] = await db
|
|
69
|
+
.insert(marketLocales)
|
|
70
|
+
.values({ ...data, marketId })
|
|
71
|
+
.returning();
|
|
72
|
+
return row ?? null;
|
|
73
|
+
}
|
|
74
|
+
export async function updateMarketLocale(db, id, data) {
|
|
75
|
+
const [row] = await db
|
|
76
|
+
.update(marketLocales)
|
|
77
|
+
.set({ ...data, updatedAt: new Date() })
|
|
78
|
+
.where(eq(marketLocales.id, id))
|
|
79
|
+
.returning();
|
|
80
|
+
return row ?? null;
|
|
81
|
+
}
|
|
82
|
+
export async function deleteMarketLocale(db, id) {
|
|
83
|
+
const [row] = await db
|
|
84
|
+
.delete(marketLocales)
|
|
85
|
+
.where(eq(marketLocales.id, id))
|
|
86
|
+
.returning({ id: marketLocales.id });
|
|
87
|
+
return row ?? null;
|
|
88
|
+
}
|
|
89
|
+
export async function listMarketCurrencies(db, query) {
|
|
90
|
+
const conditions = [];
|
|
91
|
+
if (query.marketId)
|
|
92
|
+
conditions.push(eq(marketCurrencies.marketId, query.marketId));
|
|
93
|
+
if (query.currencyCode)
|
|
94
|
+
conditions.push(eq(marketCurrencies.currencyCode, query.currencyCode));
|
|
95
|
+
if (query.active !== undefined)
|
|
96
|
+
conditions.push(eq(marketCurrencies.active, query.active));
|
|
97
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
98
|
+
return paginate(db
|
|
99
|
+
.select()
|
|
100
|
+
.from(marketCurrencies)
|
|
101
|
+
.where(where)
|
|
102
|
+
.limit(query.limit)
|
|
103
|
+
.offset(query.offset)
|
|
104
|
+
.orderBy(asc(marketCurrencies.sortOrder), asc(marketCurrencies.createdAt)), db.select({ count: sql `count(*)::int` }).from(marketCurrencies).where(where), query.limit, query.offset);
|
|
105
|
+
}
|
|
106
|
+
export async function createMarketCurrency(db, marketId, data) {
|
|
107
|
+
const [market] = await db
|
|
108
|
+
.select({ id: markets.id })
|
|
109
|
+
.from(markets)
|
|
110
|
+
.where(eq(markets.id, marketId))
|
|
111
|
+
.limit(1);
|
|
112
|
+
if (!market)
|
|
113
|
+
return null;
|
|
114
|
+
const [row] = await db
|
|
115
|
+
.insert(marketCurrencies)
|
|
116
|
+
.values({ ...data, marketId })
|
|
117
|
+
.returning();
|
|
118
|
+
return row ?? null;
|
|
119
|
+
}
|
|
120
|
+
export async function updateMarketCurrency(db, id, data) {
|
|
121
|
+
const [row] = await db
|
|
122
|
+
.update(marketCurrencies)
|
|
123
|
+
.set({ ...data, updatedAt: new Date() })
|
|
124
|
+
.where(eq(marketCurrencies.id, id))
|
|
125
|
+
.returning();
|
|
126
|
+
return row ?? null;
|
|
127
|
+
}
|
|
128
|
+
export async function deleteMarketCurrency(db, id) {
|
|
129
|
+
const [row] = await db
|
|
130
|
+
.delete(marketCurrencies)
|
|
131
|
+
.where(eq(marketCurrencies.id, id))
|
|
132
|
+
.returning({ id: marketCurrencies.id });
|
|
133
|
+
return row ?? null;
|
|
134
|
+
}
|
|
135
|
+
export async function listFxRateSets(db, query) {
|
|
136
|
+
const conditions = [];
|
|
137
|
+
if (query.source)
|
|
138
|
+
conditions.push(eq(fxRateSets.source, query.source));
|
|
139
|
+
if (query.baseCurrency)
|
|
140
|
+
conditions.push(eq(fxRateSets.baseCurrency, query.baseCurrency));
|
|
141
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
142
|
+
return paginate(db
|
|
143
|
+
.select()
|
|
144
|
+
.from(fxRateSets)
|
|
145
|
+
.where(where)
|
|
146
|
+
.limit(query.limit)
|
|
147
|
+
.offset(query.offset)
|
|
148
|
+
.orderBy(desc(fxRateSets.effectiveAt)), db.select({ count: sql `count(*)::int` }).from(fxRateSets).where(where), query.limit, query.offset);
|
|
149
|
+
}
|
|
150
|
+
export async function getFxRateSetById(db, id) {
|
|
151
|
+
const [row] = await db.select().from(fxRateSets).where(eq(fxRateSets.id, id)).limit(1);
|
|
152
|
+
return row ?? null;
|
|
153
|
+
}
|
|
154
|
+
export async function createFxRateSet(db, data) {
|
|
155
|
+
const [row] = await db
|
|
156
|
+
.insert(fxRateSets)
|
|
157
|
+
.values({
|
|
158
|
+
...data,
|
|
159
|
+
effectiveAt: toTimestamp(data.effectiveAt) ?? new Date(),
|
|
160
|
+
observedAt: toTimestamp(data.observedAt),
|
|
161
|
+
})
|
|
162
|
+
.returning();
|
|
163
|
+
return row ?? null;
|
|
164
|
+
}
|
|
165
|
+
export async function updateFxRateSet(db, id, data) {
|
|
166
|
+
const { effectiveAt, observedAt, ...rest } = data;
|
|
167
|
+
const [row] = await db
|
|
168
|
+
.update(fxRateSets)
|
|
169
|
+
.set({
|
|
170
|
+
...rest,
|
|
171
|
+
effectiveAt: effectiveAt === undefined ? undefined : (toTimestamp(effectiveAt) ?? new Date()),
|
|
172
|
+
observedAt: observedAt === undefined ? undefined : toTimestamp(observedAt),
|
|
173
|
+
})
|
|
174
|
+
.where(eq(fxRateSets.id, id))
|
|
175
|
+
.returning();
|
|
176
|
+
return row ?? null;
|
|
177
|
+
}
|
|
178
|
+
export async function deleteFxRateSet(db, id) {
|
|
179
|
+
const [row] = await db
|
|
180
|
+
.delete(fxRateSets)
|
|
181
|
+
.where(eq(fxRateSets.id, id))
|
|
182
|
+
.returning({ id: fxRateSets.id });
|
|
183
|
+
return row ?? null;
|
|
184
|
+
}
|
|
185
|
+
export async function listExchangeRates(db, query) {
|
|
186
|
+
const conditions = [];
|
|
187
|
+
if (query.fxRateSetId)
|
|
188
|
+
conditions.push(eq(exchangeRates.fxRateSetId, query.fxRateSetId));
|
|
189
|
+
if (query.baseCurrency)
|
|
190
|
+
conditions.push(eq(exchangeRates.baseCurrency, query.baseCurrency));
|
|
191
|
+
if (query.quoteCurrency)
|
|
192
|
+
conditions.push(eq(exchangeRates.quoteCurrency, query.quoteCurrency));
|
|
193
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
194
|
+
return paginate(db
|
|
195
|
+
.select()
|
|
196
|
+
.from(exchangeRates)
|
|
197
|
+
.where(where)
|
|
198
|
+
.limit(query.limit)
|
|
199
|
+
.offset(query.offset)
|
|
200
|
+
.orderBy(asc(exchangeRates.createdAt)), db.select({ count: sql `count(*)::int` }).from(exchangeRates).where(where), query.limit, query.offset);
|
|
201
|
+
}
|
|
202
|
+
export async function getExchangeRateById(db, id) {
|
|
203
|
+
const [row] = await db.select().from(exchangeRates).where(eq(exchangeRates.id, id)).limit(1);
|
|
204
|
+
return row ?? null;
|
|
205
|
+
}
|
|
206
|
+
export async function createExchangeRate(db, fxRateSetId, data) {
|
|
207
|
+
const [rateSet] = await db
|
|
208
|
+
.select({ id: fxRateSets.id })
|
|
209
|
+
.from(fxRateSets)
|
|
210
|
+
.where(eq(fxRateSets.id, fxRateSetId))
|
|
211
|
+
.limit(1);
|
|
212
|
+
if (!rateSet)
|
|
213
|
+
return null;
|
|
214
|
+
const [row] = await db
|
|
215
|
+
.insert(exchangeRates)
|
|
216
|
+
.values({
|
|
217
|
+
...data,
|
|
218
|
+
fxRateSetId,
|
|
219
|
+
observedAt: toTimestamp(data.observedAt),
|
|
220
|
+
})
|
|
221
|
+
.returning();
|
|
222
|
+
return row ?? null;
|
|
223
|
+
}
|
|
224
|
+
export async function updateExchangeRate(db, id, data) {
|
|
225
|
+
const { observedAt, ...rest } = data;
|
|
226
|
+
const [row] = await db
|
|
227
|
+
.update(exchangeRates)
|
|
228
|
+
.set({
|
|
229
|
+
...rest,
|
|
230
|
+
observedAt: observedAt === undefined ? undefined : toTimestamp(observedAt),
|
|
231
|
+
})
|
|
232
|
+
.where(eq(exchangeRates.id, id))
|
|
233
|
+
.returning();
|
|
234
|
+
return row ?? null;
|
|
235
|
+
}
|
|
236
|
+
export async function deleteExchangeRate(db, id) {
|
|
237
|
+
const [row] = await db
|
|
238
|
+
.delete(exchangeRates)
|
|
239
|
+
.where(eq(exchangeRates.id, id))
|
|
240
|
+
.returning({ id: exchangeRates.id });
|
|
241
|
+
return row ?? null;
|
|
242
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { CreateMarketChannelRuleInput, CreateMarketPriceCatalogInput, CreateMarketProductRuleInput, MarketChannelRuleListQuery, MarketPriceCatalogListQuery, MarketProductRuleListQuery, UpdateMarketChannelRuleInput, UpdateMarketPriceCatalogInput, UpdateMarketProductRuleInput } from "./service-shared.js";
|
|
3
|
+
export declare function listMarketPriceCatalogs(db: PostgresJsDatabase, query: MarketPriceCatalogListQuery): Promise<{
|
|
4
|
+
data: {
|
|
5
|
+
id: string;
|
|
6
|
+
marketId: string;
|
|
7
|
+
priceCatalogId: string;
|
|
8
|
+
isDefault: boolean;
|
|
9
|
+
priority: number;
|
|
10
|
+
active: boolean;
|
|
11
|
+
notes: string | null;
|
|
12
|
+
metadata: Record<string, unknown> | null;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
}[];
|
|
16
|
+
total: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
offset: number;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function getMarketPriceCatalogById(db: PostgresJsDatabase, id: string): Promise<{
|
|
21
|
+
id: string;
|
|
22
|
+
marketId: string;
|
|
23
|
+
priceCatalogId: string;
|
|
24
|
+
isDefault: boolean;
|
|
25
|
+
priority: number;
|
|
26
|
+
active: boolean;
|
|
27
|
+
notes: string | null;
|
|
28
|
+
metadata: Record<string, unknown> | null;
|
|
29
|
+
createdAt: Date;
|
|
30
|
+
updatedAt: Date;
|
|
31
|
+
} | null>;
|
|
32
|
+
export declare function createMarketPriceCatalog(db: PostgresJsDatabase, data: CreateMarketPriceCatalogInput): Promise<{
|
|
33
|
+
metadata: Record<string, unknown> | null;
|
|
34
|
+
id: string;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
priority: number;
|
|
37
|
+
notes: string | null;
|
|
38
|
+
updatedAt: Date;
|
|
39
|
+
active: boolean;
|
|
40
|
+
marketId: string;
|
|
41
|
+
isDefault: boolean;
|
|
42
|
+
priceCatalogId: string;
|
|
43
|
+
} | null>;
|
|
44
|
+
export declare function updateMarketPriceCatalog(db: PostgresJsDatabase, id: string, data: UpdateMarketPriceCatalogInput): Promise<{
|
|
45
|
+
id: string;
|
|
46
|
+
marketId: string;
|
|
47
|
+
priceCatalogId: string;
|
|
48
|
+
isDefault: boolean;
|
|
49
|
+
priority: number;
|
|
50
|
+
active: boolean;
|
|
51
|
+
notes: string | null;
|
|
52
|
+
metadata: Record<string, unknown> | null;
|
|
53
|
+
createdAt: Date;
|
|
54
|
+
updatedAt: Date;
|
|
55
|
+
} | null>;
|
|
56
|
+
export declare function deleteMarketPriceCatalog(db: PostgresJsDatabase, id: string): Promise<{
|
|
57
|
+
id: string;
|
|
58
|
+
} | null>;
|
|
59
|
+
export declare function listMarketProductRules(db: PostgresJsDatabase, query: MarketProductRuleListQuery): Promise<{
|
|
60
|
+
data: {
|
|
61
|
+
id: string;
|
|
62
|
+
marketId: string;
|
|
63
|
+
productId: string;
|
|
64
|
+
optionId: string | null;
|
|
65
|
+
priceCatalogId: string | null;
|
|
66
|
+
visibility: "public" | "private" | "hidden";
|
|
67
|
+
sellability: "unavailable" | "sellable" | "on_request";
|
|
68
|
+
channelScope: "internal" | "all" | "b2c" | "b2b";
|
|
69
|
+
active: boolean;
|
|
70
|
+
availableFrom: string | null;
|
|
71
|
+
availableTo: string | null;
|
|
72
|
+
notes: string | null;
|
|
73
|
+
createdAt: Date;
|
|
74
|
+
updatedAt: Date;
|
|
75
|
+
}[];
|
|
76
|
+
total: number;
|
|
77
|
+
limit: number;
|
|
78
|
+
offset: number;
|
|
79
|
+
}>;
|
|
80
|
+
export declare function getMarketProductRuleById(db: PostgresJsDatabase, id: string): Promise<{
|
|
81
|
+
id: string;
|
|
82
|
+
marketId: string;
|
|
83
|
+
productId: string;
|
|
84
|
+
optionId: string | null;
|
|
85
|
+
priceCatalogId: string | null;
|
|
86
|
+
visibility: "public" | "private" | "hidden";
|
|
87
|
+
sellability: "unavailable" | "sellable" | "on_request";
|
|
88
|
+
channelScope: "internal" | "all" | "b2c" | "b2b";
|
|
89
|
+
active: boolean;
|
|
90
|
+
availableFrom: string | null;
|
|
91
|
+
availableTo: string | null;
|
|
92
|
+
notes: string | null;
|
|
93
|
+
createdAt: Date;
|
|
94
|
+
updatedAt: Date;
|
|
95
|
+
} | null>;
|
|
96
|
+
export declare function createMarketProductRule(db: PostgresJsDatabase, data: CreateMarketProductRuleInput): Promise<{
|
|
97
|
+
id: string;
|
|
98
|
+
createdAt: Date;
|
|
99
|
+
notes: string | null;
|
|
100
|
+
updatedAt: Date;
|
|
101
|
+
active: boolean;
|
|
102
|
+
marketId: string;
|
|
103
|
+
priceCatalogId: string | null;
|
|
104
|
+
productId: string;
|
|
105
|
+
optionId: string | null;
|
|
106
|
+
visibility: "public" | "private" | "hidden";
|
|
107
|
+
sellability: "unavailable" | "sellable" | "on_request";
|
|
108
|
+
channelScope: "internal" | "all" | "b2c" | "b2b";
|
|
109
|
+
availableFrom: string | null;
|
|
110
|
+
availableTo: string | null;
|
|
111
|
+
} | null>;
|
|
112
|
+
export declare function updateMarketProductRule(db: PostgresJsDatabase, id: string, data: UpdateMarketProductRuleInput): Promise<{
|
|
113
|
+
id: string;
|
|
114
|
+
marketId: string;
|
|
115
|
+
productId: string;
|
|
116
|
+
optionId: string | null;
|
|
117
|
+
priceCatalogId: string | null;
|
|
118
|
+
visibility: "public" | "private" | "hidden";
|
|
119
|
+
sellability: "unavailable" | "sellable" | "on_request";
|
|
120
|
+
channelScope: "internal" | "all" | "b2c" | "b2b";
|
|
121
|
+
active: boolean;
|
|
122
|
+
availableFrom: string | null;
|
|
123
|
+
availableTo: string | null;
|
|
124
|
+
notes: string | null;
|
|
125
|
+
createdAt: Date;
|
|
126
|
+
updatedAt: Date;
|
|
127
|
+
} | null>;
|
|
128
|
+
export declare function deleteMarketProductRule(db: PostgresJsDatabase, id: string): Promise<{
|
|
129
|
+
id: string;
|
|
130
|
+
} | null>;
|
|
131
|
+
export declare function listMarketChannelRules(db: PostgresJsDatabase, query: MarketChannelRuleListQuery): Promise<{
|
|
132
|
+
data: {
|
|
133
|
+
id: string;
|
|
134
|
+
marketId: string;
|
|
135
|
+
channelId: string;
|
|
136
|
+
priceCatalogId: string | null;
|
|
137
|
+
visibility: "public" | "private" | "hidden";
|
|
138
|
+
sellability: "unavailable" | "sellable" | "on_request";
|
|
139
|
+
active: boolean;
|
|
140
|
+
priority: number;
|
|
141
|
+
notes: string | null;
|
|
142
|
+
createdAt: Date;
|
|
143
|
+
updatedAt: Date;
|
|
144
|
+
}[];
|
|
145
|
+
total: number;
|
|
146
|
+
limit: number;
|
|
147
|
+
offset: number;
|
|
148
|
+
}>;
|
|
149
|
+
export declare function getMarketChannelRuleById(db: PostgresJsDatabase, id: string): Promise<{
|
|
150
|
+
id: string;
|
|
151
|
+
marketId: string;
|
|
152
|
+
channelId: string;
|
|
153
|
+
priceCatalogId: string | null;
|
|
154
|
+
visibility: "public" | "private" | "hidden";
|
|
155
|
+
sellability: "unavailable" | "sellable" | "on_request";
|
|
156
|
+
active: boolean;
|
|
157
|
+
priority: number;
|
|
158
|
+
notes: string | null;
|
|
159
|
+
createdAt: Date;
|
|
160
|
+
updatedAt: Date;
|
|
161
|
+
} | null>;
|
|
162
|
+
export declare function createMarketChannelRule(db: PostgresJsDatabase, data: CreateMarketChannelRuleInput): Promise<{
|
|
163
|
+
id: string;
|
|
164
|
+
createdAt: Date;
|
|
165
|
+
priority: number;
|
|
166
|
+
notes: string | null;
|
|
167
|
+
updatedAt: Date;
|
|
168
|
+
active: boolean;
|
|
169
|
+
marketId: string;
|
|
170
|
+
priceCatalogId: string | null;
|
|
171
|
+
visibility: "public" | "private" | "hidden";
|
|
172
|
+
sellability: "unavailable" | "sellable" | "on_request";
|
|
173
|
+
channelId: string;
|
|
174
|
+
} | null>;
|
|
175
|
+
export declare function updateMarketChannelRule(db: PostgresJsDatabase, id: string, data: UpdateMarketChannelRuleInput): Promise<{
|
|
176
|
+
id: string;
|
|
177
|
+
marketId: string;
|
|
178
|
+
channelId: string;
|
|
179
|
+
priceCatalogId: string | null;
|
|
180
|
+
visibility: "public" | "private" | "hidden";
|
|
181
|
+
sellability: "unavailable" | "sellable" | "on_request";
|
|
182
|
+
active: boolean;
|
|
183
|
+
priority: number;
|
|
184
|
+
notes: string | null;
|
|
185
|
+
createdAt: Date;
|
|
186
|
+
updatedAt: Date;
|
|
187
|
+
} | null>;
|
|
188
|
+
export declare function deleteMarketChannelRule(db: PostgresJsDatabase, id: string): Promise<{
|
|
189
|
+
id: string;
|
|
190
|
+
} | null>;
|
|
191
|
+
//# sourceMappingURL=service-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-rules.d.ts","sourceRoot":"","sources":["../../src/markets/service-rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,KAAK,EACV,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,EAC7B,MAAM,qBAAqB,CAAA;AAY5B,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,2BAA2B;;;;;;;;;;;;;;;;GAoBnC;AAED,wBAAsB,yBAAyB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;UAOjF;AAED,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,6BAA6B;;;;;;;;;;;UAKpC;AAED,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,6BAA6B;;;;;;;;;;;UAQpC;AAED,wBAAsB,wBAAwB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAMhF;AAED,wBAAsB,sBAAsB,CAC1C,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;GAqBlC;AAED,wBAAsB,wBAAwB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;UAOhF;AAED,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,4BAA4B;;;;;;;;;;;;;;;UAKnC;AAED,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,4BAA4B;;;;;;;;;;;;;;;UAQnC;AAED,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAM/E;AAED,wBAAsB,sBAAsB,CAC1C,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,0BAA0B;;;;;;;;;;;;;;;;;GAoBlC;AAED,wBAAsB,wBAAwB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;UAOhF;AAED,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,4BAA4B;;;;;;;;;;;;UAKnC;AAED,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,4BAA4B;;;;;;;;;;;;UAQnC;AAED,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAM/E"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { and, asc, eq, sql } from "drizzle-orm";
|
|
2
|
+
import { marketChannelRules, marketPriceCatalogs, marketProductRules, markets } from "./schema.js";
|
|
3
|
+
import { paginate } from "./service-shared.js";
|
|
4
|
+
async function marketExists(db, marketId) {
|
|
5
|
+
const [market] = await db
|
|
6
|
+
.select({ id: markets.id })
|
|
7
|
+
.from(markets)
|
|
8
|
+
.where(eq(markets.id, marketId))
|
|
9
|
+
.limit(1);
|
|
10
|
+
return market ?? null;
|
|
11
|
+
}
|
|
12
|
+
export async function listMarketPriceCatalogs(db, query) {
|
|
13
|
+
const conditions = [];
|
|
14
|
+
if (query.marketId)
|
|
15
|
+
conditions.push(eq(marketPriceCatalogs.marketId, query.marketId));
|
|
16
|
+
if (query.priceCatalogId)
|
|
17
|
+
conditions.push(eq(marketPriceCatalogs.priceCatalogId, query.priceCatalogId));
|
|
18
|
+
if (query.active !== undefined)
|
|
19
|
+
conditions.push(eq(marketPriceCatalogs.active, query.active));
|
|
20
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
21
|
+
return paginate(db
|
|
22
|
+
.select()
|
|
23
|
+
.from(marketPriceCatalogs)
|
|
24
|
+
.where(where)
|
|
25
|
+
.limit(query.limit)
|
|
26
|
+
.offset(query.offset)
|
|
27
|
+
.orderBy(asc(marketPriceCatalogs.createdAt)), db.select({ count: sql `count(*)::int` }).from(marketPriceCatalogs).where(where), query.limit, query.offset);
|
|
28
|
+
}
|
|
29
|
+
export async function getMarketPriceCatalogById(db, id) {
|
|
30
|
+
const [row] = await db
|
|
31
|
+
.select()
|
|
32
|
+
.from(marketPriceCatalogs)
|
|
33
|
+
.where(eq(marketPriceCatalogs.id, id))
|
|
34
|
+
.limit(1);
|
|
35
|
+
return row ?? null;
|
|
36
|
+
}
|
|
37
|
+
export async function createMarketPriceCatalog(db, data) {
|
|
38
|
+
if (!(await marketExists(db, data.marketId)))
|
|
39
|
+
return null;
|
|
40
|
+
const [row] = await db.insert(marketPriceCatalogs).values(data).returning();
|
|
41
|
+
return row ?? null;
|
|
42
|
+
}
|
|
43
|
+
export async function updateMarketPriceCatalog(db, id, data) {
|
|
44
|
+
const [row] = await db
|
|
45
|
+
.update(marketPriceCatalogs)
|
|
46
|
+
.set({ ...data, updatedAt: new Date() })
|
|
47
|
+
.where(eq(marketPriceCatalogs.id, id))
|
|
48
|
+
.returning();
|
|
49
|
+
return row ?? null;
|
|
50
|
+
}
|
|
51
|
+
export async function deleteMarketPriceCatalog(db, id) {
|
|
52
|
+
const [row] = await db
|
|
53
|
+
.delete(marketPriceCatalogs)
|
|
54
|
+
.where(eq(marketPriceCatalogs.id, id))
|
|
55
|
+
.returning({ id: marketPriceCatalogs.id });
|
|
56
|
+
return row ?? null;
|
|
57
|
+
}
|
|
58
|
+
export async function listMarketProductRules(db, query) {
|
|
59
|
+
const conditions = [];
|
|
60
|
+
if (query.marketId)
|
|
61
|
+
conditions.push(eq(marketProductRules.marketId, query.marketId));
|
|
62
|
+
if (query.productId)
|
|
63
|
+
conditions.push(eq(marketProductRules.productId, query.productId));
|
|
64
|
+
if (query.optionId)
|
|
65
|
+
conditions.push(eq(marketProductRules.optionId, query.optionId));
|
|
66
|
+
if (query.sellability)
|
|
67
|
+
conditions.push(eq(marketProductRules.sellability, query.sellability));
|
|
68
|
+
if (query.active !== undefined)
|
|
69
|
+
conditions.push(eq(marketProductRules.active, query.active));
|
|
70
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
71
|
+
return paginate(db
|
|
72
|
+
.select()
|
|
73
|
+
.from(marketProductRules)
|
|
74
|
+
.where(where)
|
|
75
|
+
.limit(query.limit)
|
|
76
|
+
.offset(query.offset)
|
|
77
|
+
.orderBy(asc(marketProductRules.createdAt)), db.select({ count: sql `count(*)::int` }).from(marketProductRules).where(where), query.limit, query.offset);
|
|
78
|
+
}
|
|
79
|
+
export async function getMarketProductRuleById(db, id) {
|
|
80
|
+
const [row] = await db
|
|
81
|
+
.select()
|
|
82
|
+
.from(marketProductRules)
|
|
83
|
+
.where(eq(marketProductRules.id, id))
|
|
84
|
+
.limit(1);
|
|
85
|
+
return row ?? null;
|
|
86
|
+
}
|
|
87
|
+
export async function createMarketProductRule(db, data) {
|
|
88
|
+
if (!(await marketExists(db, data.marketId)))
|
|
89
|
+
return null;
|
|
90
|
+
const [row] = await db.insert(marketProductRules).values(data).returning();
|
|
91
|
+
return row ?? null;
|
|
92
|
+
}
|
|
93
|
+
export async function updateMarketProductRule(db, id, data) {
|
|
94
|
+
const [row] = await db
|
|
95
|
+
.update(marketProductRules)
|
|
96
|
+
.set({ ...data, updatedAt: new Date() })
|
|
97
|
+
.where(eq(marketProductRules.id, id))
|
|
98
|
+
.returning();
|
|
99
|
+
return row ?? null;
|
|
100
|
+
}
|
|
101
|
+
export async function deleteMarketProductRule(db, id) {
|
|
102
|
+
const [row] = await db
|
|
103
|
+
.delete(marketProductRules)
|
|
104
|
+
.where(eq(marketProductRules.id, id))
|
|
105
|
+
.returning({ id: marketProductRules.id });
|
|
106
|
+
return row ?? null;
|
|
107
|
+
}
|
|
108
|
+
export async function listMarketChannelRules(db, query) {
|
|
109
|
+
const conditions = [];
|
|
110
|
+
if (query.marketId)
|
|
111
|
+
conditions.push(eq(marketChannelRules.marketId, query.marketId));
|
|
112
|
+
if (query.channelId)
|
|
113
|
+
conditions.push(eq(marketChannelRules.channelId, query.channelId));
|
|
114
|
+
if (query.sellability)
|
|
115
|
+
conditions.push(eq(marketChannelRules.sellability, query.sellability));
|
|
116
|
+
if (query.active !== undefined)
|
|
117
|
+
conditions.push(eq(marketChannelRules.active, query.active));
|
|
118
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
119
|
+
return paginate(db
|
|
120
|
+
.select()
|
|
121
|
+
.from(marketChannelRules)
|
|
122
|
+
.where(where)
|
|
123
|
+
.limit(query.limit)
|
|
124
|
+
.offset(query.offset)
|
|
125
|
+
.orderBy(asc(marketChannelRules.createdAt)), db.select({ count: sql `count(*)::int` }).from(marketChannelRules).where(where), query.limit, query.offset);
|
|
126
|
+
}
|
|
127
|
+
export async function getMarketChannelRuleById(db, id) {
|
|
128
|
+
const [row] = await db
|
|
129
|
+
.select()
|
|
130
|
+
.from(marketChannelRules)
|
|
131
|
+
.where(eq(marketChannelRules.id, id))
|
|
132
|
+
.limit(1);
|
|
133
|
+
return row ?? null;
|
|
134
|
+
}
|
|
135
|
+
export async function createMarketChannelRule(db, data) {
|
|
136
|
+
if (!(await marketExists(db, data.marketId)))
|
|
137
|
+
return null;
|
|
138
|
+
const [row] = await db.insert(marketChannelRules).values(data).returning();
|
|
139
|
+
return row ?? null;
|
|
140
|
+
}
|
|
141
|
+
export async function updateMarketChannelRule(db, id, data) {
|
|
142
|
+
const [row] = await db
|
|
143
|
+
.update(marketChannelRules)
|
|
144
|
+
.set({ ...data, updatedAt: new Date() })
|
|
145
|
+
.where(eq(marketChannelRules.id, id))
|
|
146
|
+
.returning();
|
|
147
|
+
return row ?? null;
|
|
148
|
+
}
|
|
149
|
+
export async function deleteMarketChannelRule(db, id) {
|
|
150
|
+
const [row] = await db
|
|
151
|
+
.delete(marketChannelRules)
|
|
152
|
+
.where(eq(marketChannelRules.id, id))
|
|
153
|
+
.returning({ id: marketChannelRules.id });
|
|
154
|
+
return row ?? null;
|
|
155
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { 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";
|
|
3
|
+
export type MarketListQuery = z.infer<typeof marketListQuerySchema>;
|
|
4
|
+
export type MarketLocaleListQuery = z.infer<typeof marketLocaleListQuerySchema>;
|
|
5
|
+
export type MarketCurrencyListQuery = z.infer<typeof marketCurrencyListQuerySchema>;
|
|
6
|
+
export type FxRateSetListQuery = z.infer<typeof fxRateSetListQuerySchema>;
|
|
7
|
+
export type ExchangeRateListQuery = z.infer<typeof exchangeRateListQuerySchema>;
|
|
8
|
+
export type MarketPriceCatalogListQuery = z.infer<typeof marketPriceCatalogListQuerySchema>;
|
|
9
|
+
export type MarketProductRuleListQuery = z.infer<typeof marketProductRuleListQuerySchema>;
|
|
10
|
+
export type MarketChannelRuleListQuery = z.infer<typeof marketChannelRuleListQuerySchema>;
|
|
11
|
+
export type CreateMarketInput = z.infer<typeof insertMarketSchema>;
|
|
12
|
+
export type UpdateMarketInput = z.infer<typeof updateMarketSchema>;
|
|
13
|
+
export type CreateMarketLocaleInput = z.infer<typeof insertMarketLocaleSchema>;
|
|
14
|
+
export type UpdateMarketLocaleInput = z.infer<typeof updateMarketLocaleSchema>;
|
|
15
|
+
export type CreateMarketCurrencyInput = z.infer<typeof insertMarketCurrencySchema>;
|
|
16
|
+
export type UpdateMarketCurrencyInput = z.infer<typeof updateMarketCurrencySchema>;
|
|
17
|
+
export type CreateFxRateSetInput = z.infer<typeof insertFxRateSetSchema>;
|
|
18
|
+
export type UpdateFxRateSetInput = z.infer<typeof updateFxRateSetSchema>;
|
|
19
|
+
export type CreateExchangeRateInput = z.infer<typeof insertExchangeRateSchema>;
|
|
20
|
+
export type UpdateExchangeRateInput = z.infer<typeof updateExchangeRateSchema>;
|
|
21
|
+
export type CreateMarketPriceCatalogInput = z.infer<typeof insertMarketPriceCatalogSchema>;
|
|
22
|
+
export type UpdateMarketPriceCatalogInput = z.infer<typeof updateMarketPriceCatalogSchema>;
|
|
23
|
+
export type CreateMarketProductRuleInput = z.infer<typeof insertMarketProductRuleSchema>;
|
|
24
|
+
export type UpdateMarketProductRuleInput = z.infer<typeof updateMarketProductRuleSchema>;
|
|
25
|
+
export type CreateMarketChannelRuleInput = z.infer<typeof insertMarketChannelRuleSchema>;
|
|
26
|
+
export type UpdateMarketChannelRuleInput = z.infer<typeof updateMarketChannelRuleSchema>;
|
|
27
|
+
export declare function paginate<T extends object>(rowsQuery: Promise<T[]>, countQuery: Promise<Array<{
|
|
28
|
+
count: number;
|
|
29
|
+
}>>, limit: number, offset: number): Promise<{
|
|
30
|
+
data: T[];
|
|
31
|
+
total: number;
|
|
32
|
+
limit: number;
|
|
33
|
+
offset: number;
|
|
34
|
+
}>;
|
|
35
|
+
export declare function toTimestamp(value?: string | null): Date | null;
|
|
36
|
+
//# sourceMappingURL=service-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-shared.d.ts","sourceRoot":"","sources":["../../src/markets/service-shared.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export async function paginate(rowsQuery, countQuery, limit, offset) {
|
|
2
|
+
const [data, countResult] = await Promise.all([rowsQuery, countQuery]);
|
|
3
|
+
return { data, total: countResult[0]?.count ?? 0, limit, offset };
|
|
4
|
+
}
|
|
5
|
+
export function toTimestamp(value) {
|
|
6
|
+
return value ? new Date(value) : null;
|
|
7
|
+
}
|