pipework 0.71.0 → 0.72.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/CHANGELOG.md +7 -0
- package/REFERENCE.md +54 -0
- package/dist/core/config/namespace.d.ts +1 -0
- package/dist/core/config/namespace.d.ts.map +1 -1
- package/dist/core/config/schema.d.ts +1 -0
- package/dist/core/config/schema.d.ts.map +1 -1
- package/dist/core/config/schema.js +2 -0
- package/dist/core/config/schema.js.map +1 -1
- package/dist/data/migrate/internal-definitions.d.ts.map +1 -1
- package/dist/data/migrate/internal-definitions.js +7 -0
- package/dist/data/migrate/internal-definitions.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/infra/alerts/handle.d.ts.map +1 -1
- package/dist/infra/alerts/handle.js +12 -76
- package/dist/infra/alerts/handle.js.map +1 -1
- package/dist/infra/alerts/sinks.d.ts +17 -21
- package/dist/infra/alerts/sinks.d.ts.map +1 -1
- package/dist/infra/alerts/sinks.js +0 -1
- package/dist/infra/alerts/sinks.js.map +1 -1
- package/dist/infra/outbox/core.d.ts +52 -0
- package/dist/infra/outbox/core.d.ts.map +1 -0
- package/dist/infra/outbox/core.js +91 -0
- package/dist/infra/outbox/core.js.map +1 -0
- package/dist/infra/support/handle.d.ts +271 -0
- package/dist/infra/support/handle.d.ts.map +1 -0
- package/dist/infra/support/handle.js +548 -0
- package/dist/infra/support/handle.js.map +1 -0
- package/dist/infra/support/index.d.ts +3 -0
- package/dist/infra/support/index.d.ts.map +1 -0
- package/dist/infra/support/index.js +2 -0
- package/dist/infra/support/index.js.map +1 -0
- package/dist/infra/support/namespace.d.ts +19 -0
- package/dist/infra/support/namespace.d.ts.map +1 -0
- package/dist/infra/support/namespace.js +9 -0
- package/dist/infra/support/namespace.js.map +1 -0
- package/dist/infra/support/schema.d.ts +214 -0
- package/dist/infra/support/schema.d.ts.map +1 -0
- package/dist/infra/support/schema.js +91 -0
- package/dist/infra/support/schema.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createSupport } from './handle.js';
|
|
2
|
+
/** Support namespace — tickets from email (and later chat), with replies sent only after an approval. */
|
|
3
|
+
export declare const support: {
|
|
4
|
+
/** Creates the support handle: tickets, messages, notes, links, drafts, `approve`, `receiveEmail`, and the events job. */
|
|
5
|
+
readonly create: typeof createSupport;
|
|
6
|
+
/** The reply template to spread into `mail.create({ templates })`; it renders the approved draft verbatim. */
|
|
7
|
+
readonly templates: {
|
|
8
|
+
readonly 'pipework.support.reply': ({ subject, text, html }: {
|
|
9
|
+
subject: string;
|
|
10
|
+
text: string;
|
|
11
|
+
html?: string | null;
|
|
12
|
+
}) => {
|
|
13
|
+
subject: string;
|
|
14
|
+
text: string;
|
|
15
|
+
html?: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/infra/support/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAA;AAE7D,yGAAyG;AACzG,eAAO,MAAM,OAAO;IAClB,0HAA0H;;IAE1H,8GAA8G;;;;;gBAGinb,CAAC;;;;gBAAyD,CAAC;;;CADlxb,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createSupport, supportTemplates } from './handle.js';
|
|
2
|
+
/** Support namespace — tickets from email (and later chat), with replies sent only after an approval. */
|
|
3
|
+
export const support = {
|
|
4
|
+
/** Creates the support handle: tickets, messages, notes, links, drafts, `approve`, `receiveEmail`, and the events job. */
|
|
5
|
+
create: createSupport,
|
|
6
|
+
/** The reply template to spread into `mail.create({ templates })`; it renders the approved draft verbatim. */
|
|
7
|
+
templates: supportTemplates,
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=namespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../src/infra/support/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE7D,yGAAyG;AACzG,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,0HAA0H;IAC1H,MAAM,EAAE,aAAa;IACrB,8GAA8G;IAC9G,SAAS,EAAE,gBAAgB;CACnB,CAAA"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
export declare const TICKET_STATES: readonly ["open", "triaged", "awaiting_approval", "answered", "closed"];
|
|
2
|
+
export declare const MESSAGE_KINDS: readonly ["inbound", "note", "draft", "outbound"];
|
|
3
|
+
export declare const MESSAGE_CHANNELS: readonly ["email", "chat", "api"];
|
|
4
|
+
export declare const DRAFT_STATUSES: readonly ["draft", "approved", "discarded"];
|
|
5
|
+
export declare const EVENT_KINDS: readonly ["ticket.created", "ticket.customer-replied", "draft.awaiting-approval"];
|
|
6
|
+
export declare const supportTicket: import("../../data/domain/types.js").DefinedTable<{
|
|
7
|
+
id: import("../../data/domain/types.js").FieldDescriptor<string, {
|
|
8
|
+
defaultRandom: true;
|
|
9
|
+
hasDefault: true;
|
|
10
|
+
} & {
|
|
11
|
+
primaryKey: true;
|
|
12
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string, {
|
|
13
|
+
defaultRandom: true;
|
|
14
|
+
hasDefault: true;
|
|
15
|
+
} & {
|
|
16
|
+
primaryKey: true;
|
|
17
|
+
}>;
|
|
18
|
+
tenantId: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
19
|
+
state: import("../../data/domain/types.js").FieldDescriptor<"open" | "closed" | "triaged" | "awaiting_approval" | "answered", {
|
|
20
|
+
hasDefault: true;
|
|
21
|
+
}> & import("../../data/domain/field.js").FieldModifiers<"open" | "closed" | "triaged" | "awaiting_approval" | "answered", {
|
|
22
|
+
hasDefault: true;
|
|
23
|
+
}>;
|
|
24
|
+
category: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
25
|
+
nullable: true;
|
|
26
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
27
|
+
nullable: true;
|
|
28
|
+
}>;
|
|
29
|
+
subject: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
30
|
+
contactEmail: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
31
|
+
contactName: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
32
|
+
nullable: true;
|
|
33
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
34
|
+
nullable: true;
|
|
35
|
+
}>;
|
|
36
|
+
userId: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
37
|
+
nullable: true;
|
|
38
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
39
|
+
nullable: true;
|
|
40
|
+
}>;
|
|
41
|
+
conversationId: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
42
|
+
nullable: true;
|
|
43
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
44
|
+
nullable: true;
|
|
45
|
+
}>;
|
|
46
|
+
createdAt: import("../../data/domain/types.js").FieldDescriptor<Date, {
|
|
47
|
+
hasDefault: true;
|
|
48
|
+
}> & import("../../data/domain/field.js").FieldModifiers<Date, {
|
|
49
|
+
hasDefault: true;
|
|
50
|
+
}>;
|
|
51
|
+
updatedAt: import("../../data/domain/types.js").FieldDescriptor<Date, {
|
|
52
|
+
hasDefault: true;
|
|
53
|
+
}> & import("../../data/domain/field.js").FieldModifiers<Date, {
|
|
54
|
+
hasDefault: true;
|
|
55
|
+
}>;
|
|
56
|
+
lastCustomerMessageAt: import("../../data/domain/types.js").FieldDescriptor<Date, {
|
|
57
|
+
hasDefault: true;
|
|
58
|
+
}> & import("../../data/domain/field.js").FieldModifiers<Date, {
|
|
59
|
+
hasDefault: true;
|
|
60
|
+
}>;
|
|
61
|
+
}, "support_ticket">;
|
|
62
|
+
export declare const supportMessage: import("../../data/domain/types.js").DefinedTable<{
|
|
63
|
+
id: import("../../data/domain/types.js").FieldDescriptor<string, {
|
|
64
|
+
defaultRandom: true;
|
|
65
|
+
hasDefault: true;
|
|
66
|
+
} & {
|
|
67
|
+
primaryKey: true;
|
|
68
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string, {
|
|
69
|
+
defaultRandom: true;
|
|
70
|
+
hasDefault: true;
|
|
71
|
+
} & {
|
|
72
|
+
primaryKey: true;
|
|
73
|
+
}>;
|
|
74
|
+
tenantId: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
75
|
+
ticketId: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
76
|
+
kind: import("../../data/domain/types.js").FieldDescriptor<"note" | "inbound" | "draft" | "outbound", {}> & import("../../data/domain/field.js").FieldModifiers<"note" | "inbound" | "draft" | "outbound", {}>;
|
|
77
|
+
channel: import("../../data/domain/types.js").FieldDescriptor<"email" | "chat" | "api", {}> & import("../../data/domain/field.js").FieldModifiers<"email" | "chat" | "api", {}>;
|
|
78
|
+
subject: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
79
|
+
nullable: true;
|
|
80
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
81
|
+
nullable: true;
|
|
82
|
+
}>;
|
|
83
|
+
text: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
84
|
+
html: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
85
|
+
nullable: true;
|
|
86
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
87
|
+
nullable: true;
|
|
88
|
+
}>;
|
|
89
|
+
fromAddress: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
90
|
+
nullable: true;
|
|
91
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
92
|
+
nullable: true;
|
|
93
|
+
}>;
|
|
94
|
+
inboundEmailId: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
95
|
+
nullable: true;
|
|
96
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
97
|
+
nullable: true;
|
|
98
|
+
}>;
|
|
99
|
+
attachments: import("../../data/domain/types.js").FieldDescriptor<import("zod/v4").JSONType, {
|
|
100
|
+
nullable: true;
|
|
101
|
+
}> & import("../../data/domain/field.js").FieldModifiers<import("zod/v4").JSONType, {
|
|
102
|
+
nullable: true;
|
|
103
|
+
}>;
|
|
104
|
+
draftStatus: import("../../data/domain/types.js").FieldDescriptor<"draft" | "approved" | "discarded" | null, {
|
|
105
|
+
nullable: true;
|
|
106
|
+
}> & import("../../data/domain/field.js").FieldModifiers<"draft" | "approved" | "discarded" | null, {
|
|
107
|
+
nullable: true;
|
|
108
|
+
}>;
|
|
109
|
+
version: import("../../data/domain/types.js").FieldDescriptor<number, {
|
|
110
|
+
hasDefault: true;
|
|
111
|
+
}> & import("../../data/domain/field.js").FieldModifiers<number, {
|
|
112
|
+
hasDefault: true;
|
|
113
|
+
}>;
|
|
114
|
+
approvedBy: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
115
|
+
nullable: true;
|
|
116
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
117
|
+
nullable: true;
|
|
118
|
+
}>;
|
|
119
|
+
approvedAt: import("../../data/domain/types.js").FieldDescriptor<Date | null, {
|
|
120
|
+
nullable: true;
|
|
121
|
+
}> & import("../../data/domain/field.js").FieldModifiers<Date | null, {
|
|
122
|
+
nullable: true;
|
|
123
|
+
}>;
|
|
124
|
+
emailMessageId: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
125
|
+
nullable: true;
|
|
126
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
127
|
+
nullable: true;
|
|
128
|
+
}>;
|
|
129
|
+
createdBy: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
130
|
+
nullable: true;
|
|
131
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
132
|
+
nullable: true;
|
|
133
|
+
}>;
|
|
134
|
+
createdAt: import("../../data/domain/types.js").FieldDescriptor<Date, {
|
|
135
|
+
hasDefault: true;
|
|
136
|
+
}> & import("../../data/domain/field.js").FieldModifiers<Date, {
|
|
137
|
+
hasDefault: true;
|
|
138
|
+
}>;
|
|
139
|
+
}, "support_message">;
|
|
140
|
+
export declare const supportLink: import("../../data/domain/types.js").DefinedTable<{
|
|
141
|
+
id: import("../../data/domain/types.js").FieldDescriptor<string, {
|
|
142
|
+
defaultRandom: true;
|
|
143
|
+
hasDefault: true;
|
|
144
|
+
} & {
|
|
145
|
+
primaryKey: true;
|
|
146
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string, {
|
|
147
|
+
defaultRandom: true;
|
|
148
|
+
hasDefault: true;
|
|
149
|
+
} & {
|
|
150
|
+
primaryKey: true;
|
|
151
|
+
}>;
|
|
152
|
+
tenantId: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
153
|
+
ticketId: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
154
|
+
kind: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
155
|
+
ref: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
156
|
+
label: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
157
|
+
nullable: true;
|
|
158
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
159
|
+
nullable: true;
|
|
160
|
+
}>;
|
|
161
|
+
createdAt: import("../../data/domain/types.js").FieldDescriptor<Date, {
|
|
162
|
+
hasDefault: true;
|
|
163
|
+
}> & import("../../data/domain/field.js").FieldModifiers<Date, {
|
|
164
|
+
hasDefault: true;
|
|
165
|
+
}>;
|
|
166
|
+
}, "support_link">;
|
|
167
|
+
export declare const supportEventDelivery: import("../../data/domain/types.js").DefinedTable<{
|
|
168
|
+
id: import("../../data/domain/types.js").FieldDescriptor<string, {
|
|
169
|
+
defaultRandom: true;
|
|
170
|
+
hasDefault: true;
|
|
171
|
+
} & {
|
|
172
|
+
primaryKey: true;
|
|
173
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string, {
|
|
174
|
+
defaultRandom: true;
|
|
175
|
+
hasDefault: true;
|
|
176
|
+
} & {
|
|
177
|
+
primaryKey: true;
|
|
178
|
+
}>;
|
|
179
|
+
ticketId: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
180
|
+
kind: import("../../data/domain/types.js").FieldDescriptor<"ticket.created" | "ticket.customer-replied" | "draft.awaiting-approval", {}> & import("../../data/domain/field.js").FieldModifiers<"ticket.created" | "ticket.customer-replied" | "draft.awaiting-approval", {}>;
|
|
181
|
+
sink: import("../../data/domain/types.js").FieldDescriptor<string, {}> & import("../../data/domain/field.js").FieldModifiers<string, {}>;
|
|
182
|
+
payload: import("../../data/domain/types.js").FieldDescriptor<import("zod/v4").JSONType, {}> & import("../../data/domain/field.js").FieldModifiers<import("zod/v4").JSONType, {}>;
|
|
183
|
+
attempts: import("../../data/domain/types.js").FieldDescriptor<number, {
|
|
184
|
+
hasDefault: true;
|
|
185
|
+
}> & import("../../data/domain/field.js").FieldModifiers<number, {
|
|
186
|
+
hasDefault: true;
|
|
187
|
+
}>;
|
|
188
|
+
nextAttemptAt: import("../../data/domain/types.js").FieldDescriptor<Date, {
|
|
189
|
+
hasDefault: true;
|
|
190
|
+
}> & import("../../data/domain/field.js").FieldModifiers<Date, {
|
|
191
|
+
hasDefault: true;
|
|
192
|
+
}>;
|
|
193
|
+
deliveredAt: import("../../data/domain/types.js").FieldDescriptor<Date | null, {
|
|
194
|
+
nullable: true;
|
|
195
|
+
}> & import("../../data/domain/field.js").FieldModifiers<Date | null, {
|
|
196
|
+
nullable: true;
|
|
197
|
+
}>;
|
|
198
|
+
failedAt: import("../../data/domain/types.js").FieldDescriptor<Date | null, {
|
|
199
|
+
nullable: true;
|
|
200
|
+
}> & import("../../data/domain/field.js").FieldModifiers<Date | null, {
|
|
201
|
+
nullable: true;
|
|
202
|
+
}>;
|
|
203
|
+
lastError: import("../../data/domain/types.js").FieldDescriptor<string | null, {
|
|
204
|
+
nullable: true;
|
|
205
|
+
}> & import("../../data/domain/field.js").FieldModifiers<string | null, {
|
|
206
|
+
nullable: true;
|
|
207
|
+
}>;
|
|
208
|
+
createdAt: import("../../data/domain/types.js").FieldDescriptor<Date, {
|
|
209
|
+
hasDefault: true;
|
|
210
|
+
}> & import("../../data/domain/field.js").FieldModifiers<Date, {
|
|
211
|
+
hasDefault: true;
|
|
212
|
+
}>;
|
|
213
|
+
}, "support_event_delivery">;
|
|
214
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/infra/support/schema.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,aAAa,yEAA0E,CAAA;AACpG,eAAO,MAAM,aAAa,mDAAoD,CAAA;AAC9E,eAAO,MAAM,gBAAgB,mCAAoC,CAAA;AACjE,eAAO,MAAM,cAAc,6CAA8C,CAAA;AACzE,eAAO,MAAM,WAAW,mFAAoF,CAAA;AAE5G,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAkBxB,CAAA;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAwBzB,CAAA;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;kBAYtB,CAAA;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAmB/B,CAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// The tables behind support tickets. Tickets, messages and links are tenant-scoped (forced
|
|
2
|
+
// row-level security in generated migrations); the event outbox is not, because one tick
|
|
3
|
+
// delivers every tenant's events.
|
|
4
|
+
import { define } from '../../data/domain/index.js';
|
|
5
|
+
import { field } from '../../data/domain/field.js';
|
|
6
|
+
import { schema } from '../../data/schema/namespace.js';
|
|
7
|
+
import { index, uniqueIndex } from '../../data/db/idx/index.js';
|
|
8
|
+
import { sql } from '../../data/db/sql.js';
|
|
9
|
+
export const TICKET_STATES = ['open', 'triaged', 'awaiting_approval', 'answered', 'closed'];
|
|
10
|
+
export const MESSAGE_KINDS = ['inbound', 'note', 'draft', 'outbound'];
|
|
11
|
+
export const MESSAGE_CHANNELS = ['email', 'chat', 'api'];
|
|
12
|
+
export const DRAFT_STATUSES = ['draft', 'approved', 'discarded'];
|
|
13
|
+
export const EVENT_KINDS = ['ticket.created', 'ticket.customer-replied', 'draft.awaiting-approval'];
|
|
14
|
+
export const supportTicket = define('support_ticket', {
|
|
15
|
+
id: field.uuid().defaultRandom().primaryKey(),
|
|
16
|
+
tenantId: field.uuid().tenant(),
|
|
17
|
+
state: field.enum(TICKET_STATES).default('open'),
|
|
18
|
+
category: field.text().nullable(),
|
|
19
|
+
subject: field.text(),
|
|
20
|
+
contactEmail: field.text(),
|
|
21
|
+
contactName: field.text().nullable(),
|
|
22
|
+
userId: field.text().nullable(),
|
|
23
|
+
conversationId: field.uuid().nullable(),
|
|
24
|
+
createdAt: field.timestamp().default('now'),
|
|
25
|
+
updatedAt: field.timestamp().default('now'),
|
|
26
|
+
lastCustomerMessageAt: field.timestamp().default('now'),
|
|
27
|
+
}, {
|
|
28
|
+
indexes: (t) => ({
|
|
29
|
+
byConversation: uniqueIndex('uq_support_ticket_conversation').on(t['tenantId'], t['conversationId']),
|
|
30
|
+
byState: index('idx_support_ticket_state').on(t['tenantId'], t['state'], t['createdAt']),
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
export const supportMessage = define('support_message', {
|
|
34
|
+
id: field.uuid().defaultRandom().primaryKey(),
|
|
35
|
+
tenantId: field.uuid().tenant(),
|
|
36
|
+
ticketId: field.uuid(),
|
|
37
|
+
kind: field.enum(MESSAGE_KINDS),
|
|
38
|
+
channel: field.enum(MESSAGE_CHANNELS),
|
|
39
|
+
subject: field.text().nullable(),
|
|
40
|
+
text: field.text(),
|
|
41
|
+
html: field.text().nullable(),
|
|
42
|
+
fromAddress: field.text().nullable(),
|
|
43
|
+
inboundEmailId: field.uuid().nullable(),
|
|
44
|
+
attachments: field.jsonb(schema.check.json()).nullable(),
|
|
45
|
+
draftStatus: field.enum(DRAFT_STATUSES).nullable(),
|
|
46
|
+
version: field.integer().default(1),
|
|
47
|
+
approvedBy: field.text().nullable(),
|
|
48
|
+
approvedAt: field.timestamp().nullable(),
|
|
49
|
+
emailMessageId: field.uuid().nullable(),
|
|
50
|
+
createdBy: field.text().nullable(),
|
|
51
|
+
createdAt: field.timestamp().default('now'),
|
|
52
|
+
}, {
|
|
53
|
+
indexes: (t) => ({
|
|
54
|
+
byInbound: uniqueIndex('uq_support_message_inbound').on(t['tenantId'], t['inboundEmailId']),
|
|
55
|
+
byTicket: index('idx_support_message_ticket').on(t['ticketId'], t['createdAt']),
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
export const supportLink = define('support_link', {
|
|
59
|
+
id: field.uuid().defaultRandom().primaryKey(),
|
|
60
|
+
tenantId: field.uuid().tenant(),
|
|
61
|
+
ticketId: field.uuid(),
|
|
62
|
+
kind: field.text(),
|
|
63
|
+
ref: field.text(),
|
|
64
|
+
label: field.text().nullable(),
|
|
65
|
+
createdAt: field.timestamp().default('now'),
|
|
66
|
+
}, {
|
|
67
|
+
indexes: (t) => ({
|
|
68
|
+
byTarget: uniqueIndex('uq_support_link_target').on(t['ticketId'], t['kind'], t['ref']),
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
export const supportEventDelivery = define('support_event_delivery', {
|
|
72
|
+
id: field.uuid().defaultRandom().primaryKey(),
|
|
73
|
+
ticketId: field.uuid(),
|
|
74
|
+
kind: field.enum(EVENT_KINDS),
|
|
75
|
+
sink: field.text(),
|
|
76
|
+
payload: field.jsonb(schema.check.json()),
|
|
77
|
+
attempts: field.integer().default(0),
|
|
78
|
+
nextAttemptAt: field.timestamp().default('now'),
|
|
79
|
+
deliveredAt: field.timestamp().nullable(),
|
|
80
|
+
failedAt: field.timestamp().nullable(),
|
|
81
|
+
lastError: field.text().nullable(),
|
|
82
|
+
createdAt: field.timestamp().default('now'),
|
|
83
|
+
}, {
|
|
84
|
+
indexes: (t) => ({
|
|
85
|
+
due: index('idx_support_event_delivery_due')
|
|
86
|
+
.on(t['nextAttemptAt'])
|
|
87
|
+
.where(sql.raw('delivered_at IS NULL AND failed_at IS NULL')),
|
|
88
|
+
byTicket: index('idx_support_event_delivery_ticket').on(t['ticketId']),
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/infra/support/schema.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,yFAAyF;AACzF,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAClD,OAAO,EAAE,MAAM,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