@voyantjs/distribution 0.1.1 → 0.3.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 +17 -17
- package/dist/schema-automation.d.ts +680 -0
- package/dist/schema-automation.d.ts.map +1 -0
- package/dist/schema-automation.js +73 -0
- package/dist/schema-core.d.ts +1113 -0
- package/dist/schema-core.d.ts.map +1 -0
- package/dist/schema-core.js +116 -0
- package/dist/schema-finance.d.ts +1372 -0
- package/dist/schema-finance.d.ts.map +1 -0
- package/dist/schema-finance.js +147 -0
- package/dist/schema-inventory.d.ts +855 -0
- package/dist/schema-inventory.d.ts.map +1 -0
- package/dist/schema-inventory.js +105 -0
- package/dist/schema-relations.d.ts +99 -0
- package/dist/schema-relations.d.ts.map +1 -0
- package/dist/schema-relations.js +220 -0
- package/dist/schema-shared.d.ts +24 -0
- package/dist/schema-shared.d.ts.map +1 -0
- package/dist/schema-shared.js +122 -0
- package/dist/schema.d.ts +6 -4137
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +6 -760
- package/dist/service.d.ts +16 -16
- package/dist/validation.d.ts +10 -10
- package/package.json +8 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-core.d.ts","sourceRoot":"","sources":["../src/schema-core.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBpB,CAAA;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAU,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAA;AACrD,MAAM,MAAM,eAAe,GAAG,OAAO,gBAAgB,CAAC,YAAY,CAAA;AAClE,MAAM,MAAM,kBAAkB,GAAG,OAAO,gBAAgB,CAAC,YAAY,CAAA;AACrE,MAAM,MAAM,qBAAqB,GAAG,OAAO,sBAAsB,CAAC,YAAY,CAAA;AAC9E,MAAM,MAAM,wBAAwB,GAAG,OAAO,sBAAsB,CAAC,YAAY,CAAA;AACjF,MAAM,MAAM,qBAAqB,GAAG,OAAO,sBAAsB,CAAC,YAAY,CAAA;AAC9E,MAAM,MAAM,wBAAwB,GAAG,OAAO,sBAAsB,CAAC,YAAY,CAAA;AACjF,MAAM,MAAM,kBAAkB,GAAG,OAAO,mBAAmB,CAAC,YAAY,CAAA;AACxE,MAAM,MAAM,qBAAqB,GAAG,OAAO,mBAAmB,CAAC,YAAY,CAAA;AAC3E,MAAM,MAAM,mBAAmB,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAA;AAC1E,MAAM,MAAM,sBAAsB,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAA"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { typeId, typeIdRef } from "@voyantjs/db/lib/typeid-column";
|
|
2
|
+
import { products } from "@voyantjs/products/schema";
|
|
3
|
+
import { suppliers } from "@voyantjs/suppliers/schema";
|
|
4
|
+
import { boolean, date, index, integer, jsonb, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
5
|
+
import { channelCommissionScopeEnum, channelCommissionTypeEnum, channelContractStatusEnum, channelKindEnum, channelStatusEnum, channelWebhookStatusEnum, distributionCancellationOwnerEnum, distributionPaymentOwnerEnum, } from "./schema-shared";
|
|
6
|
+
export const channels = pgTable("channels", {
|
|
7
|
+
id: typeId("channels"),
|
|
8
|
+
name: text("name").notNull(),
|
|
9
|
+
description: text("description"),
|
|
10
|
+
kind: channelKindEnum("kind").notNull(),
|
|
11
|
+
status: channelStatusEnum("status").notNull().default("active"),
|
|
12
|
+
metadata: jsonb("metadata").$type(),
|
|
13
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
14
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
15
|
+
}, (table) => [
|
|
16
|
+
index("idx_channels_kind").on(table.kind),
|
|
17
|
+
index("idx_channels_status").on(table.status),
|
|
18
|
+
]);
|
|
19
|
+
export const channelContracts = pgTable("channel_contracts", {
|
|
20
|
+
id: typeId("channel_contracts"),
|
|
21
|
+
channelId: typeIdRef("channel_id")
|
|
22
|
+
.notNull()
|
|
23
|
+
.references(() => channels.id, { onDelete: "cascade" }),
|
|
24
|
+
supplierId: typeIdRef("supplier_id").references(() => suppliers.id, { onDelete: "set null" }),
|
|
25
|
+
status: channelContractStatusEnum("status").notNull().default("draft"),
|
|
26
|
+
startsAt: date("starts_at").notNull(),
|
|
27
|
+
endsAt: date("ends_at"),
|
|
28
|
+
paymentOwner: distributionPaymentOwnerEnum("payment_owner").notNull().default("operator"),
|
|
29
|
+
cancellationOwner: distributionCancellationOwnerEnum("cancellation_owner")
|
|
30
|
+
.notNull()
|
|
31
|
+
.default("operator"),
|
|
32
|
+
settlementTerms: text("settlement_terms"),
|
|
33
|
+
notes: text("notes"),
|
|
34
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
35
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
36
|
+
}, (table) => [
|
|
37
|
+
index("idx_channel_contracts_channel").on(table.channelId),
|
|
38
|
+
index("idx_channel_contracts_supplier").on(table.supplierId),
|
|
39
|
+
index("idx_channel_contracts_status").on(table.status),
|
|
40
|
+
]);
|
|
41
|
+
export const channelCommissionRules = pgTable("channel_commission_rules", {
|
|
42
|
+
id: typeId("channel_commission_rules"),
|
|
43
|
+
contractId: typeIdRef("contract_id")
|
|
44
|
+
.notNull()
|
|
45
|
+
.references(() => channelContracts.id, { onDelete: "cascade" }),
|
|
46
|
+
scope: channelCommissionScopeEnum("scope").notNull(),
|
|
47
|
+
productId: typeIdRef("product_id").references(() => products.id, { onDelete: "set null" }),
|
|
48
|
+
externalRateId: text("external_rate_id"),
|
|
49
|
+
externalCategoryId: text("external_category_id"),
|
|
50
|
+
commissionType: channelCommissionTypeEnum("commission_type").notNull(),
|
|
51
|
+
amountCents: integer("amount_cents"),
|
|
52
|
+
percentBasisPoints: integer("percent_basis_points"),
|
|
53
|
+
validFrom: date("valid_from"),
|
|
54
|
+
validTo: date("valid_to"),
|
|
55
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
56
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
57
|
+
}, (table) => [
|
|
58
|
+
index("idx_channel_commission_rules_contract").on(table.contractId),
|
|
59
|
+
index("idx_channel_commission_rules_product").on(table.productId),
|
|
60
|
+
index("idx_channel_commission_rules_scope").on(table.scope),
|
|
61
|
+
]);
|
|
62
|
+
export const channelProductMappings = pgTable("channel_product_mappings", {
|
|
63
|
+
id: typeId("channel_product_mappings"),
|
|
64
|
+
channelId: typeIdRef("channel_id")
|
|
65
|
+
.notNull()
|
|
66
|
+
.references(() => channels.id, { onDelete: "cascade" }),
|
|
67
|
+
productId: typeIdRef("product_id")
|
|
68
|
+
.notNull()
|
|
69
|
+
.references(() => products.id, { onDelete: "cascade" }),
|
|
70
|
+
externalProductId: text("external_product_id"),
|
|
71
|
+
externalRateId: text("external_rate_id"),
|
|
72
|
+
externalCategoryId: text("external_category_id"),
|
|
73
|
+
active: boolean("active").notNull().default(true),
|
|
74
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
75
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
76
|
+
}, (table) => [
|
|
77
|
+
index("idx_channel_product_mappings_channel").on(table.channelId),
|
|
78
|
+
index("idx_channel_product_mappings_product").on(table.productId),
|
|
79
|
+
index("idx_channel_product_mappings_active").on(table.active),
|
|
80
|
+
]);
|
|
81
|
+
export const channelBookingLinks = pgTable("channel_booking_links", {
|
|
82
|
+
id: typeId("channel_booking_links"),
|
|
83
|
+
channelId: typeIdRef("channel_id")
|
|
84
|
+
.notNull()
|
|
85
|
+
.references(() => channels.id, { onDelete: "cascade" }),
|
|
86
|
+
bookingId: text("booking_id").notNull(),
|
|
87
|
+
externalBookingId: text("external_booking_id"),
|
|
88
|
+
externalReference: text("external_reference"),
|
|
89
|
+
externalStatus: text("external_status"),
|
|
90
|
+
bookedAtExternal: timestamp("booked_at_external", { withTimezone: true }),
|
|
91
|
+
lastSyncedAt: timestamp("last_synced_at", { withTimezone: true }),
|
|
92
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
93
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
94
|
+
}, (table) => [
|
|
95
|
+
index("idx_channel_booking_links_channel").on(table.channelId),
|
|
96
|
+
index("idx_channel_booking_links_booking").on(table.bookingId),
|
|
97
|
+
index("idx_channel_booking_links_external_booking").on(table.externalBookingId),
|
|
98
|
+
]);
|
|
99
|
+
export const channelWebhookEvents = pgTable("channel_webhook_events", {
|
|
100
|
+
id: typeId("channel_webhook_events"),
|
|
101
|
+
channelId: typeIdRef("channel_id")
|
|
102
|
+
.notNull()
|
|
103
|
+
.references(() => channels.id, { onDelete: "cascade" }),
|
|
104
|
+
eventType: text("event_type").notNull(),
|
|
105
|
+
externalEventId: text("external_event_id"),
|
|
106
|
+
payload: jsonb("payload").$type().notNull(),
|
|
107
|
+
receivedAt: timestamp("received_at", { withTimezone: true }).notNull().defaultNow(),
|
|
108
|
+
processedAt: timestamp("processed_at", { withTimezone: true }),
|
|
109
|
+
status: channelWebhookStatusEnum("status").notNull().default("pending"),
|
|
110
|
+
errorMessage: text("error_message"),
|
|
111
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
112
|
+
}, (table) => [
|
|
113
|
+
index("idx_channel_webhook_events_channel").on(table.channelId),
|
|
114
|
+
index("idx_channel_webhook_events_status").on(table.status),
|
|
115
|
+
index("idx_channel_webhook_events_external_event").on(table.externalEventId),
|
|
116
|
+
]);
|