@voyantjs/crm 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/routes/accounts.d.ts +1 -1
- package/dist/routes/index.d.ts +2 -2
- package/dist/routes/opportunities.d.ts +1 -1
- package/dist/schema-accounts.d.ts +1175 -0
- package/dist/schema-accounts.d.ts.map +1 -0
- package/dist/schema-accounts.js +112 -0
- package/dist/schema-activities.d.ts +821 -0
- package/dist/schema-activities.d.ts.map +1 -0
- package/dist/schema-activities.js +83 -0
- package/dist/schema-relations.d.ts +81 -0
- package/dist/schema-relations.d.ts.map +1 -0
- package/dist/schema-relations.js +123 -0
- package/dist/schema-sales.d.ts +1392 -0
- package/dist/schema-sales.d.ts.map +1 -0
- package/dist/schema-sales.js +142 -0
- package/dist/schema-shared.d.ts +13 -0
- package/dist/schema-shared.d.ts.map +1 -0
- package/dist/schema-shared.js +63 -0
- package/dist/schema.d.ts +5 -3477
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +5 -515
- package/dist/service/accounts-organizations.d.ts +93 -0
- package/dist/service/accounts-organizations.d.ts.map +1 -0
- package/dist/service/accounts-organizations.js +49 -0
- package/dist/service/accounts-people.d.ts +868 -0
- package/dist/service/accounts-people.d.ts.map +1 -0
- package/dist/service/accounts-people.js +311 -0
- package/dist/service/accounts-shared.d.ts +54 -0
- package/dist/service/accounts-shared.d.ts.map +1 -0
- package/dist/service/accounts-shared.js +152 -0
- package/dist/service/accounts.d.ts +121 -149
- package/dist/service/accounts.d.ts.map +1 -1
- package/dist/service/accounts.js +4 -507
- package/dist/service/index.d.ts +106 -297
- package/dist/service/index.d.ts.map +1 -1
- package/dist/service/opportunities.d.ts +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-activities.d.ts","sourceRoot":"","sources":["../src/schema-activities.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoBtB,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBzB,CAAA;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBhC,CAAA;AAED,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAUgB,MAAM;uBAAS,MAAM;;;;;;;;;;;;;;uBAArB,MAAM;uBAAS,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQvE,CAAA;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2B7B,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,UAAU,CAAC,YAAY,CAAA;AACrD,MAAM,MAAM,WAAW,GAAG,OAAO,UAAU,CAAC,YAAY,CAAA;AACxD,MAAM,MAAM,YAAY,GAAG,OAAO,aAAa,CAAC,YAAY,CAAA;AAC5D,MAAM,MAAM,eAAe,GAAG,OAAO,aAAa,CAAC,YAAY,CAAA;AAC/D,MAAM,MAAM,mBAAmB,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAA;AAC1E,MAAM,MAAM,sBAAsB,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAA;AAC7E,MAAM,MAAM,qBAAqB,GAAG,OAAO,sBAAsB,CAAC,YAAY,CAAA;AAC9E,MAAM,MAAM,wBAAwB,GAAG,OAAO,sBAAsB,CAAC,YAAY,CAAA;AACjF,MAAM,MAAM,gBAAgB,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAA;AACpE,MAAM,MAAM,mBAAmB,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { typeId, typeIdRef } from "@voyantjs/db/lib/typeid-column";
|
|
2
|
+
import { boolean, date, index, integer, jsonb, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
|
|
3
|
+
import { people } from "./schema-accounts";
|
|
4
|
+
import { activityLinkRoleEnum, activityStatusEnum, activityTypeEnum, customFieldTypeEnum, entityTypeEnum, } from "./schema-shared";
|
|
5
|
+
export const activities = pgTable("activities", {
|
|
6
|
+
id: typeId("activities"),
|
|
7
|
+
subject: text("subject").notNull(),
|
|
8
|
+
type: activityTypeEnum("type").notNull(),
|
|
9
|
+
ownerId: text("owner_id"),
|
|
10
|
+
status: activityStatusEnum("status").notNull().default("planned"),
|
|
11
|
+
dueAt: timestamp("due_at", { withTimezone: true }),
|
|
12
|
+
completedAt: timestamp("completed_at", { withTimezone: true }),
|
|
13
|
+
location: text("location"),
|
|
14
|
+
description: text("description"),
|
|
15
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
16
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
17
|
+
}, (table) => [
|
|
18
|
+
index("idx_activities_owner").on(table.ownerId),
|
|
19
|
+
index("idx_activities_status").on(table.status),
|
|
20
|
+
index("idx_activities_type").on(table.type),
|
|
21
|
+
]);
|
|
22
|
+
export const activityLinks = pgTable("activity_links", {
|
|
23
|
+
id: typeId("activity_links"),
|
|
24
|
+
activityId: typeIdRef("activity_id")
|
|
25
|
+
.notNull()
|
|
26
|
+
.references(() => activities.id, { onDelete: "cascade" }),
|
|
27
|
+
entityType: entityTypeEnum("entity_type").notNull(),
|
|
28
|
+
entityId: text("entity_id").notNull(),
|
|
29
|
+
role: activityLinkRoleEnum("role").notNull().default("related"),
|
|
30
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
31
|
+
}, (table) => [
|
|
32
|
+
index("idx_activity_links_activity").on(table.activityId),
|
|
33
|
+
index("idx_activity_links_entity").on(table.entityType, table.entityId),
|
|
34
|
+
]);
|
|
35
|
+
export const activityParticipants = pgTable("activity_participants", {
|
|
36
|
+
id: typeId("activity_participants"),
|
|
37
|
+
activityId: typeIdRef("activity_id")
|
|
38
|
+
.notNull()
|
|
39
|
+
.references(() => activities.id, { onDelete: "cascade" }),
|
|
40
|
+
personId: typeIdRef("person_id")
|
|
41
|
+
.notNull()
|
|
42
|
+
.references(() => people.id, { onDelete: "cascade" }),
|
|
43
|
+
isPrimary: boolean("is_primary").notNull().default(false),
|
|
44
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
45
|
+
}, (table) => [
|
|
46
|
+
index("idx_activity_participants_activity").on(table.activityId),
|
|
47
|
+
uniqueIndex("uidx_activity_participants_unique").on(table.activityId, table.personId),
|
|
48
|
+
]);
|
|
49
|
+
export const customFieldDefinitions = pgTable("custom_field_definitions", {
|
|
50
|
+
id: typeId("custom_field_definitions"),
|
|
51
|
+
entityType: entityTypeEnum("entity_type").notNull(),
|
|
52
|
+
key: text("key").notNull(),
|
|
53
|
+
label: text("label").notNull(),
|
|
54
|
+
fieldType: customFieldTypeEnum("field_type").notNull(),
|
|
55
|
+
isRequired: boolean("is_required").notNull().default(false),
|
|
56
|
+
isSearchable: boolean("is_searchable").notNull().default(false),
|
|
57
|
+
options: jsonb("options").$type(),
|
|
58
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
59
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
60
|
+
}, (table) => [
|
|
61
|
+
index("idx_custom_field_definitions_entity").on(table.entityType),
|
|
62
|
+
uniqueIndex("uidx_custom_field_definitions_key").on(table.entityType, table.key),
|
|
63
|
+
]);
|
|
64
|
+
export const customFieldValues = pgTable("custom_field_values", {
|
|
65
|
+
id: typeId("custom_field_values"),
|
|
66
|
+
definitionId: typeIdRef("definition_id")
|
|
67
|
+
.notNull()
|
|
68
|
+
.references(() => customFieldDefinitions.id, { onDelete: "cascade" }),
|
|
69
|
+
entityType: entityTypeEnum("entity_type").notNull(),
|
|
70
|
+
entityId: text("entity_id").notNull(),
|
|
71
|
+
textValue: text("text_value"),
|
|
72
|
+
numberValue: integer("number_value"),
|
|
73
|
+
dateValue: date("date_value"),
|
|
74
|
+
booleanValue: boolean("boolean_value"),
|
|
75
|
+
monetaryValueCents: integer("monetary_value_cents"),
|
|
76
|
+
currencyCode: text("currency_code"),
|
|
77
|
+
jsonValue: jsonb("json_value").$type(),
|
|
78
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
79
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
80
|
+
}, (table) => [
|
|
81
|
+
index("idx_custom_field_values_entity").on(table.entityType, table.entityId),
|
|
82
|
+
uniqueIndex("uidx_custom_field_values_unique").on(table.definitionId, table.entityType, table.entityId),
|
|
83
|
+
]);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export declare const organizationsRelations: import("drizzle-orm").Relations<"organizations", {
|
|
2
|
+
people: import("drizzle-orm").Many<"people">;
|
|
3
|
+
opportunities: import("drizzle-orm").Many<"opportunities">;
|
|
4
|
+
notes: import("drizzle-orm").Many<"organization_notes">;
|
|
5
|
+
communications: import("drizzle-orm").Many<"communication_log">;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const peopleRelations: import("drizzle-orm").Relations<"people", {
|
|
8
|
+
organization: import("drizzle-orm").One<"organizations", false>;
|
|
9
|
+
opportunities: import("drizzle-orm").Many<"opportunities">;
|
|
10
|
+
activityParticipants: import("drizzle-orm").Many<"activity_participants">;
|
|
11
|
+
opportunityParticipants: import("drizzle-orm").Many<"opportunity_participants">;
|
|
12
|
+
notes: import("drizzle-orm").Many<"person_notes">;
|
|
13
|
+
communications: import("drizzle-orm").Many<"communication_log">;
|
|
14
|
+
segmentMemberships: import("drizzle-orm").Many<"segment_members">;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const pipelinesRelations: import("drizzle-orm").Relations<"pipelines", {
|
|
17
|
+
stages: import("drizzle-orm").Many<"stages">;
|
|
18
|
+
opportunities: import("drizzle-orm").Many<"opportunities">;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const stagesRelations: import("drizzle-orm").Relations<"stages", {
|
|
21
|
+
pipeline: import("drizzle-orm").One<"pipelines", true>;
|
|
22
|
+
opportunities: import("drizzle-orm").Many<"opportunities">;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const opportunitiesRelations: import("drizzle-orm").Relations<"opportunities", {
|
|
25
|
+
person: import("drizzle-orm").One<"people", false>;
|
|
26
|
+
organization: import("drizzle-orm").One<"organizations", false>;
|
|
27
|
+
pipeline: import("drizzle-orm").One<"pipelines", true>;
|
|
28
|
+
stage: import("drizzle-orm").One<"stages", true>;
|
|
29
|
+
participants: import("drizzle-orm").Many<"opportunity_participants">;
|
|
30
|
+
products: import("drizzle-orm").Many<"opportunity_products">;
|
|
31
|
+
quotes: import("drizzle-orm").Many<"quotes">;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const opportunityParticipantsRelations: import("drizzle-orm").Relations<"opportunity_participants", {
|
|
34
|
+
opportunity: import("drizzle-orm").One<"opportunities", true>;
|
|
35
|
+
person: import("drizzle-orm").One<"people", true>;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const opportunityProductsRelations: import("drizzle-orm").Relations<"opportunity_products", {
|
|
38
|
+
opportunity: import("drizzle-orm").One<"opportunities", true>;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const quotesRelations: import("drizzle-orm").Relations<"quotes", {
|
|
41
|
+
opportunity: import("drizzle-orm").One<"opportunities", true>;
|
|
42
|
+
lines: import("drizzle-orm").Many<"quote_lines">;
|
|
43
|
+
}>;
|
|
44
|
+
export declare const quoteLinesRelations: import("drizzle-orm").Relations<"quote_lines", {
|
|
45
|
+
quote: import("drizzle-orm").One<"quotes", true>;
|
|
46
|
+
}>;
|
|
47
|
+
export declare const activitiesRelations: import("drizzle-orm").Relations<"activities", {
|
|
48
|
+
links: import("drizzle-orm").Many<"activity_links">;
|
|
49
|
+
participants: import("drizzle-orm").Many<"activity_participants">;
|
|
50
|
+
}>;
|
|
51
|
+
export declare const activityLinksRelations: import("drizzle-orm").Relations<"activity_links", {
|
|
52
|
+
activity: import("drizzle-orm").One<"activities", true>;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const activityParticipantsRelations: import("drizzle-orm").Relations<"activity_participants", {
|
|
55
|
+
activity: import("drizzle-orm").One<"activities", true>;
|
|
56
|
+
person: import("drizzle-orm").One<"people", true>;
|
|
57
|
+
}>;
|
|
58
|
+
export declare const customFieldDefinitionsRelations: import("drizzle-orm").Relations<"custom_field_definitions", {
|
|
59
|
+
values: import("drizzle-orm").Many<"custom_field_values">;
|
|
60
|
+
}>;
|
|
61
|
+
export declare const customFieldValuesRelations: import("drizzle-orm").Relations<"custom_field_values", {
|
|
62
|
+
definition: import("drizzle-orm").One<"custom_field_definitions", true>;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const personNotesRelations: import("drizzle-orm").Relations<"person_notes", {
|
|
65
|
+
person: import("drizzle-orm").One<"people", true>;
|
|
66
|
+
}>;
|
|
67
|
+
export declare const organizationNotesRelations: import("drizzle-orm").Relations<"organization_notes", {
|
|
68
|
+
organization: import("drizzle-orm").One<"organizations", true>;
|
|
69
|
+
}>;
|
|
70
|
+
export declare const communicationLogRelations: import("drizzle-orm").Relations<"communication_log", {
|
|
71
|
+
person: import("drizzle-orm").One<"people", true>;
|
|
72
|
+
organization: import("drizzle-orm").One<"organizations", false>;
|
|
73
|
+
}>;
|
|
74
|
+
export declare const segmentsRelations: import("drizzle-orm").Relations<"segments", {
|
|
75
|
+
members: import("drizzle-orm").Many<"segment_members">;
|
|
76
|
+
}>;
|
|
77
|
+
export declare const segmentMembersRelations: import("drizzle-orm").Relations<"segment_members", {
|
|
78
|
+
segment: import("drizzle-orm").One<"segments", true>;
|
|
79
|
+
person: import("drizzle-orm").One<"people", true>;
|
|
80
|
+
}>;
|
|
81
|
+
//# sourceMappingURL=schema-relations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-relations.d.ts","sourceRoot":"","sources":["../src/schema-relations.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,sBAAsB;;;;;EAKhC,CAAA;AAEH,eAAO,MAAM,eAAe;;;;;;;;EAWzB,CAAA;AAEH,eAAO,MAAM,kBAAkB;;;EAG5B,CAAA;AAEH,eAAO,MAAM,eAAe;;;EAGzB,CAAA;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;EAchC,CAAA;AAEH,eAAO,MAAM,gCAAgC;;;EAS1C,CAAA;AAEH,eAAO,MAAM,4BAA4B;;EAKtC,CAAA;AAEH,eAAO,MAAM,eAAe;;;EAMzB,CAAA;AAEH,eAAO,MAAM,mBAAmB;;EAE7B,CAAA;AAEH,eAAO,MAAM,mBAAmB;;;EAG7B,CAAA;AAEH,eAAO,MAAM,sBAAsB;;EAKhC,CAAA;AAEH,eAAO,MAAM,6BAA6B;;;EASvC,CAAA;AAEH,eAAO,MAAM,+BAA+B;;EAEzC,CAAA;AAEH,eAAO,MAAM,0BAA0B;;EAKpC,CAAA;AAEH,eAAO,MAAM,oBAAoB;;EAE9B,CAAA;AAEH,eAAO,MAAM,0BAA0B;;EAKpC,CAAA;AAEH,eAAO,MAAM,yBAAyB;;;EAMnC,CAAA;AAEH,eAAO,MAAM,iBAAiB;;EAE3B,CAAA;AAEH,eAAO,MAAM,uBAAuB;;;EAGjC,CAAA"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { relations } from "drizzle-orm";
|
|
2
|
+
import { communicationLog, organizationNotes, organizations, people, personNotes, segmentMembers, segments, } from "./schema-accounts";
|
|
3
|
+
import { activities, activityLinks, activityParticipants, customFieldDefinitions, customFieldValues, } from "./schema-activities";
|
|
4
|
+
import { opportunities, opportunityParticipants, opportunityProducts, pipelines, quoteLines, quotes, stages, } from "./schema-sales";
|
|
5
|
+
export const organizationsRelations = relations(organizations, ({ many }) => ({
|
|
6
|
+
people: many(people),
|
|
7
|
+
opportunities: many(opportunities),
|
|
8
|
+
notes: many(organizationNotes),
|
|
9
|
+
communications: many(communicationLog),
|
|
10
|
+
}));
|
|
11
|
+
export const peopleRelations = relations(people, ({ one, many }) => ({
|
|
12
|
+
organization: one(organizations, {
|
|
13
|
+
fields: [people.organizationId],
|
|
14
|
+
references: [organizations.id],
|
|
15
|
+
}),
|
|
16
|
+
opportunities: many(opportunities),
|
|
17
|
+
activityParticipants: many(activityParticipants),
|
|
18
|
+
opportunityParticipants: many(opportunityParticipants),
|
|
19
|
+
notes: many(personNotes),
|
|
20
|
+
communications: many(communicationLog),
|
|
21
|
+
segmentMemberships: many(segmentMembers),
|
|
22
|
+
}));
|
|
23
|
+
export const pipelinesRelations = relations(pipelines, ({ many }) => ({
|
|
24
|
+
stages: many(stages),
|
|
25
|
+
opportunities: many(opportunities),
|
|
26
|
+
}));
|
|
27
|
+
export const stagesRelations = relations(stages, ({ one, many }) => ({
|
|
28
|
+
pipeline: one(pipelines, { fields: [stages.pipelineId], references: [pipelines.id] }),
|
|
29
|
+
opportunities: many(opportunities),
|
|
30
|
+
}));
|
|
31
|
+
export const opportunitiesRelations = relations(opportunities, ({ one, many }) => ({
|
|
32
|
+
person: one(people, { fields: [opportunities.personId], references: [people.id] }),
|
|
33
|
+
organization: one(organizations, {
|
|
34
|
+
fields: [opportunities.organizationId],
|
|
35
|
+
references: [organizations.id],
|
|
36
|
+
}),
|
|
37
|
+
pipeline: one(pipelines, {
|
|
38
|
+
fields: [opportunities.pipelineId],
|
|
39
|
+
references: [pipelines.id],
|
|
40
|
+
}),
|
|
41
|
+
stage: one(stages, { fields: [opportunities.stageId], references: [stages.id] }),
|
|
42
|
+
participants: many(opportunityParticipants),
|
|
43
|
+
products: many(opportunityProducts),
|
|
44
|
+
quotes: many(quotes),
|
|
45
|
+
}));
|
|
46
|
+
export const opportunityParticipantsRelations = relations(opportunityParticipants, ({ one }) => ({
|
|
47
|
+
opportunity: one(opportunities, {
|
|
48
|
+
fields: [opportunityParticipants.opportunityId],
|
|
49
|
+
references: [opportunities.id],
|
|
50
|
+
}),
|
|
51
|
+
person: one(people, {
|
|
52
|
+
fields: [opportunityParticipants.personId],
|
|
53
|
+
references: [people.id],
|
|
54
|
+
}),
|
|
55
|
+
}));
|
|
56
|
+
export const opportunityProductsRelations = relations(opportunityProducts, ({ one }) => ({
|
|
57
|
+
opportunity: one(opportunities, {
|
|
58
|
+
fields: [opportunityProducts.opportunityId],
|
|
59
|
+
references: [opportunities.id],
|
|
60
|
+
}),
|
|
61
|
+
}));
|
|
62
|
+
export const quotesRelations = relations(quotes, ({ one, many }) => ({
|
|
63
|
+
opportunity: one(opportunities, {
|
|
64
|
+
fields: [quotes.opportunityId],
|
|
65
|
+
references: [opportunities.id],
|
|
66
|
+
}),
|
|
67
|
+
lines: many(quoteLines),
|
|
68
|
+
}));
|
|
69
|
+
export const quoteLinesRelations = relations(quoteLines, ({ one }) => ({
|
|
70
|
+
quote: one(quotes, { fields: [quoteLines.quoteId], references: [quotes.id] }),
|
|
71
|
+
}));
|
|
72
|
+
export const activitiesRelations = relations(activities, ({ many }) => ({
|
|
73
|
+
links: many(activityLinks),
|
|
74
|
+
participants: many(activityParticipants),
|
|
75
|
+
}));
|
|
76
|
+
export const activityLinksRelations = relations(activityLinks, ({ one }) => ({
|
|
77
|
+
activity: one(activities, {
|
|
78
|
+
fields: [activityLinks.activityId],
|
|
79
|
+
references: [activities.id],
|
|
80
|
+
}),
|
|
81
|
+
}));
|
|
82
|
+
export const activityParticipantsRelations = relations(activityParticipants, ({ one }) => ({
|
|
83
|
+
activity: one(activities, {
|
|
84
|
+
fields: [activityParticipants.activityId],
|
|
85
|
+
references: [activities.id],
|
|
86
|
+
}),
|
|
87
|
+
person: one(people, {
|
|
88
|
+
fields: [activityParticipants.personId],
|
|
89
|
+
references: [people.id],
|
|
90
|
+
}),
|
|
91
|
+
}));
|
|
92
|
+
export const customFieldDefinitionsRelations = relations(customFieldDefinitions, ({ many }) => ({
|
|
93
|
+
values: many(customFieldValues),
|
|
94
|
+
}));
|
|
95
|
+
export const customFieldValuesRelations = relations(customFieldValues, ({ one }) => ({
|
|
96
|
+
definition: one(customFieldDefinitions, {
|
|
97
|
+
fields: [customFieldValues.definitionId],
|
|
98
|
+
references: [customFieldDefinitions.id],
|
|
99
|
+
}),
|
|
100
|
+
}));
|
|
101
|
+
export const personNotesRelations = relations(personNotes, ({ one }) => ({
|
|
102
|
+
person: one(people, { fields: [personNotes.personId], references: [people.id] }),
|
|
103
|
+
}));
|
|
104
|
+
export const organizationNotesRelations = relations(organizationNotes, ({ one }) => ({
|
|
105
|
+
organization: one(organizations, {
|
|
106
|
+
fields: [organizationNotes.organizationId],
|
|
107
|
+
references: [organizations.id],
|
|
108
|
+
}),
|
|
109
|
+
}));
|
|
110
|
+
export const communicationLogRelations = relations(communicationLog, ({ one }) => ({
|
|
111
|
+
person: one(people, { fields: [communicationLog.personId], references: [people.id] }),
|
|
112
|
+
organization: one(organizations, {
|
|
113
|
+
fields: [communicationLog.organizationId],
|
|
114
|
+
references: [organizations.id],
|
|
115
|
+
}),
|
|
116
|
+
}));
|
|
117
|
+
export const segmentsRelations = relations(segments, ({ many }) => ({
|
|
118
|
+
members: many(segmentMembers),
|
|
119
|
+
}));
|
|
120
|
+
export const segmentMembersRelations = relations(segmentMembers, ({ one }) => ({
|
|
121
|
+
segment: one(segments, { fields: [segmentMembers.segmentId], references: [segments.id] }),
|
|
122
|
+
person: one(people, { fields: [segmentMembers.personId], references: [people.id] }),
|
|
123
|
+
}));
|