@campfire-interactive/platform-events 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.
@@ -0,0 +1,460 @@
1
+ import { z } from 'zod';
2
+ export interface EventDef<TSchema extends z.ZodTypeAny = z.ZodTypeAny> {
3
+ entityType: string;
4
+ /** payload field holding the affected entity's id (survivor id for merges) */
5
+ entityIdField: string;
6
+ /** false → platform-global event; envelope tenantId must be null */
7
+ tenantScoped: boolean;
8
+ payload: TSchema;
9
+ }
10
+ export declare const masterDataEvents: {
11
+ readonly 'company.created': EventDef<z.ZodObject<{
12
+ companyId: z.ZodString;
13
+ name: z.ZodString;
14
+ code: z.ZodNullable<z.ZodString>;
15
+ roles: z.ZodArray<z.ZodEnum<["supplier", "customer", "oem"]>, "many">;
16
+ }, "strip", z.ZodTypeAny, {
17
+ code: string | null;
18
+ companyId: string;
19
+ name: string;
20
+ roles: ("supplier" | "customer" | "oem")[];
21
+ }, {
22
+ code: string | null;
23
+ companyId: string;
24
+ name: string;
25
+ roles: ("supplier" | "customer" | "oem")[];
26
+ }>>;
27
+ readonly 'company.updated': EventDef<z.ZodObject<{
28
+ companyId: z.ZodString;
29
+ changedFields: z.ZodArray<z.ZodString, "many">;
30
+ }, "strip", z.ZodTypeAny, {
31
+ companyId: string;
32
+ changedFields: string[];
33
+ }, {
34
+ companyId: string;
35
+ changedFields: string[];
36
+ }>>;
37
+ readonly 'company.archived': EventDef<z.ZodObject<{
38
+ companyId: z.ZodString;
39
+ }, "strip", z.ZodTypeAny, {
40
+ companyId: string;
41
+ }, {
42
+ companyId: string;
43
+ }>>;
44
+ readonly 'company.merged': EventDef<z.ZodObject<{
45
+ survivorId: z.ZodString;
46
+ mergedIds: z.ZodArray<z.ZodString, "many">;
47
+ }, "strip", z.ZodTypeAny, {
48
+ survivorId: string;
49
+ mergedIds: string[];
50
+ }, {
51
+ survivorId: string;
52
+ mergedIds: string[];
53
+ }>>;
54
+ readonly 'contact.created': EventDef<z.ZodObject<{
55
+ contactId: z.ZodString;
56
+ companyId: z.ZodString;
57
+ name: z.ZodString;
58
+ }, "strip", z.ZodTypeAny, {
59
+ companyId: string;
60
+ name: string;
61
+ contactId: string;
62
+ }, {
63
+ companyId: string;
64
+ name: string;
65
+ contactId: string;
66
+ }>>;
67
+ readonly 'contact.updated': EventDef<z.ZodObject<{
68
+ contactId: z.ZodString;
69
+ companyId: z.ZodString;
70
+ changedFields: z.ZodArray<z.ZodString, "many">;
71
+ }, "strip", z.ZodTypeAny, {
72
+ companyId: string;
73
+ changedFields: string[];
74
+ contactId: string;
75
+ }, {
76
+ companyId: string;
77
+ changedFields: string[];
78
+ contactId: string;
79
+ }>>;
80
+ readonly 'contact.deleted': EventDef<z.ZodObject<{
81
+ contactId: z.ZodString;
82
+ companyId: z.ZodString;
83
+ }, "strip", z.ZodTypeAny, {
84
+ companyId: string;
85
+ contactId: string;
86
+ }, {
87
+ companyId: string;
88
+ contactId: string;
89
+ }>>;
90
+ readonly 'quote.created': EventDef<z.ZodObject<{
91
+ quoteId: z.ZodString;
92
+ quoteNumber: z.ZodString;
93
+ customerCompanyId: z.ZodString;
94
+ programId: z.ZodNullable<z.ZodString>;
95
+ status: z.ZodString;
96
+ }, "strip", z.ZodTypeAny, {
97
+ status: string;
98
+ quoteId: string;
99
+ quoteNumber: string;
100
+ customerCompanyId: string;
101
+ programId: string | null;
102
+ }, {
103
+ status: string;
104
+ quoteId: string;
105
+ quoteNumber: string;
106
+ customerCompanyId: string;
107
+ programId: string | null;
108
+ }>>;
109
+ readonly 'quote.updated': EventDef<z.ZodObject<{
110
+ quoteId: z.ZodString;
111
+ changedFields: z.ZodArray<z.ZodString, "many">;
112
+ }, "strip", z.ZodTypeAny, {
113
+ changedFields: string[];
114
+ quoteId: string;
115
+ }, {
116
+ changedFields: string[];
117
+ quoteId: string;
118
+ }>>;
119
+ readonly 'quote.status_changed': EventDef<z.ZodObject<{
120
+ quoteId: z.ZodString;
121
+ from: z.ZodString;
122
+ to: z.ZodString;
123
+ callerRole: z.ZodString;
124
+ reason: z.ZodNullable<z.ZodString>;
125
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
126
+ quoteId: z.ZodString;
127
+ from: z.ZodString;
128
+ to: z.ZodString;
129
+ callerRole: z.ZodString;
130
+ reason: z.ZodNullable<z.ZodString>;
131
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
132
+ quoteId: z.ZodString;
133
+ from: z.ZodString;
134
+ to: z.ZodString;
135
+ callerRole: z.ZodString;
136
+ reason: z.ZodNullable<z.ZodString>;
137
+ }, z.ZodTypeAny, "passthrough">>>;
138
+ readonly 'quote.effective_cost_set': EventDef<z.ZodObject<{
139
+ quoteId: z.ZodString;
140
+ unitCost: z.ZodNumber;
141
+ costSource: z.ZodString;
142
+ costBasis: z.ZodNullable<z.ZodString>;
143
+ clearsPriorValue: z.ZodBoolean;
144
+ }, "strip", z.ZodTypeAny, {
145
+ quoteId: string;
146
+ unitCost: number;
147
+ costSource: string;
148
+ costBasis: string | null;
149
+ clearsPriorValue: boolean;
150
+ }, {
151
+ quoteId: string;
152
+ unitCost: number;
153
+ costSource: string;
154
+ costBasis: string | null;
155
+ clearsPriorValue: boolean;
156
+ }>>;
157
+ readonly 'quote.effective_price_set': EventDef<z.ZodObject<{
158
+ quoteId: z.ZodString;
159
+ unitPrice: z.ZodNumber;
160
+ priceSource: z.ZodString;
161
+ priceBasis: z.ZodNullable<z.ZodString>;
162
+ clearsPriorValue: z.ZodBoolean;
163
+ }, "strip", z.ZodTypeAny, {
164
+ quoteId: string;
165
+ clearsPriorValue: boolean;
166
+ unitPrice: number;
167
+ priceSource: string;
168
+ priceBasis: string | null;
169
+ }, {
170
+ quoteId: string;
171
+ clearsPriorValue: boolean;
172
+ unitPrice: number;
173
+ priceSource: string;
174
+ priceBasis: string | null;
175
+ }>>;
176
+ readonly 'quote.archived': EventDef<z.ZodObject<{
177
+ quoteId: z.ZodString;
178
+ previousStatus: z.ZodString;
179
+ reason: z.ZodNullable<z.ZodString>;
180
+ }, "strip", z.ZodTypeAny, {
181
+ quoteId: string;
182
+ reason: string | null;
183
+ previousStatus: string;
184
+ }, {
185
+ quoteId: string;
186
+ reason: string | null;
187
+ previousStatus: string;
188
+ }>>;
189
+ readonly 'program.created': EventDef<z.ZodObject<{
190
+ programId: z.ZodString;
191
+ name: z.ZodString;
192
+ code: z.ZodString;
193
+ customerCompanyId: z.ZodString;
194
+ }, "strip", z.ZodTypeAny, {
195
+ code: string;
196
+ name: string;
197
+ customerCompanyId: string;
198
+ programId: string;
199
+ }, {
200
+ code: string;
201
+ name: string;
202
+ customerCompanyId: string;
203
+ programId: string;
204
+ }>>;
205
+ readonly 'program.updated': EventDef<z.ZodObject<{
206
+ programId: z.ZodString;
207
+ changedFields: z.ZodArray<z.ZodString, "many">;
208
+ }, "strip", z.ZodTypeAny, {
209
+ changedFields: string[];
210
+ programId: string;
211
+ }, {
212
+ changedFields: string[];
213
+ programId: string;
214
+ }>>;
215
+ readonly 'program.archived': EventDef<z.ZodObject<{
216
+ programId: z.ZodString;
217
+ }, "strip", z.ZodTypeAny, {
218
+ programId: string;
219
+ }, {
220
+ programId: string;
221
+ }>>;
222
+ readonly 'plant.created': EventDef<z.ZodObject<{
223
+ plantId: z.ZodString;
224
+ name: z.ZodString;
225
+ code: z.ZodString;
226
+ companyId: z.ZodNullable<z.ZodString>;
227
+ locationId: z.ZodNullable<z.ZodString>;
228
+ }, "strip", z.ZodTypeAny, {
229
+ code: string;
230
+ companyId: string | null;
231
+ name: string;
232
+ plantId: string;
233
+ locationId: string | null;
234
+ }, {
235
+ code: string;
236
+ companyId: string | null;
237
+ name: string;
238
+ plantId: string;
239
+ locationId: string | null;
240
+ }>>;
241
+ readonly 'plant.updated': EventDef<z.ZodObject<{
242
+ plantId: z.ZodString;
243
+ changedFields: z.ZodArray<z.ZodString, "many">;
244
+ }, "strip", z.ZodTypeAny, {
245
+ changedFields: string[];
246
+ plantId: string;
247
+ }, {
248
+ changedFields: string[];
249
+ plantId: string;
250
+ }>>;
251
+ readonly 'plant.archived': EventDef<z.ZodObject<{
252
+ plantId: z.ZodString;
253
+ }, "strip", z.ZodTypeAny, {
254
+ plantId: string;
255
+ }, {
256
+ plantId: string;
257
+ }>>;
258
+ readonly 'plant.merged': EventDef<z.ZodObject<{
259
+ survivorId: z.ZodString;
260
+ mergedIds: z.ZodArray<z.ZodString, "many">;
261
+ }, "strip", z.ZodTypeAny, {
262
+ survivorId: string;
263
+ mergedIds: string[];
264
+ }, {
265
+ survivorId: string;
266
+ mergedIds: string[];
267
+ }>>;
268
+ readonly 'location.created': EventDef<z.ZodObject<{
269
+ locationId: z.ZodString;
270
+ companyId: z.ZodString;
271
+ type: z.ZodEnum<["hq", "plant", "warehouse", "sales_office", "remit_to"]>;
272
+ name: z.ZodString;
273
+ }, "strip", z.ZodTypeAny, {
274
+ type: "plant" | "hq" | "warehouse" | "sales_office" | "remit_to";
275
+ companyId: string;
276
+ name: string;
277
+ locationId: string;
278
+ }, {
279
+ type: "plant" | "hq" | "warehouse" | "sales_office" | "remit_to";
280
+ companyId: string;
281
+ name: string;
282
+ locationId: string;
283
+ }>>;
284
+ readonly 'location.updated': EventDef<z.ZodObject<{
285
+ locationId: z.ZodString;
286
+ companyId: z.ZodString;
287
+ changedFields: z.ZodArray<z.ZodString, "many">;
288
+ }, "strip", z.ZodTypeAny, {
289
+ companyId: string;
290
+ changedFields: string[];
291
+ locationId: string;
292
+ }, {
293
+ companyId: string;
294
+ changedFields: string[];
295
+ locationId: string;
296
+ }>>;
297
+ readonly 'location.deleted': EventDef<z.ZodObject<{
298
+ locationId: z.ZodString;
299
+ companyId: z.ZodString;
300
+ }, "strip", z.ZodTypeAny, {
301
+ companyId: string;
302
+ locationId: string;
303
+ }, {
304
+ companyId: string;
305
+ locationId: string;
306
+ }>>;
307
+ readonly 'material.created': EventDef<z.ZodObject<{
308
+ materialId: z.ZodString;
309
+ name: z.ZodString;
310
+ code: z.ZodString;
311
+ category: z.ZodNullable<z.ZodString>;
312
+ }, "strip", z.ZodTypeAny, {
313
+ code: string;
314
+ name: string;
315
+ materialId: string;
316
+ category: string | null;
317
+ }, {
318
+ code: string;
319
+ name: string;
320
+ materialId: string;
321
+ category: string | null;
322
+ }>>;
323
+ readonly 'material.updated': EventDef<z.ZodObject<{
324
+ materialId: z.ZodString;
325
+ changedFields: z.ZodArray<z.ZodString, "many">;
326
+ mergedBy: z.ZodOptional<z.ZodString>;
327
+ }, "strip", z.ZodTypeAny, {
328
+ changedFields: string[];
329
+ materialId: string;
330
+ mergedBy?: string | undefined;
331
+ }, {
332
+ changedFields: string[];
333
+ materialId: string;
334
+ mergedBy?: string | undefined;
335
+ }>>;
336
+ readonly 'material.archived': EventDef<z.ZodObject<{
337
+ materialId: z.ZodString;
338
+ }, "strip", z.ZodTypeAny, {
339
+ materialId: string;
340
+ }, {
341
+ materialId: string;
342
+ }>>;
343
+ readonly 'region.created': EventDef<z.ZodObject<{
344
+ regionId: z.ZodString;
345
+ code: z.ZodString;
346
+ name: z.ZodString;
347
+ }, "strip", z.ZodTypeAny, {
348
+ code: string;
349
+ name: string;
350
+ regionId: string;
351
+ }, {
352
+ code: string;
353
+ name: string;
354
+ regionId: string;
355
+ }>>;
356
+ readonly 'region.updated': EventDef<z.ZodObject<{
357
+ regionId: z.ZodString;
358
+ changedFields: z.ZodArray<z.ZodString, "many">;
359
+ }, "strip", z.ZodTypeAny, {
360
+ changedFields: string[];
361
+ regionId: string;
362
+ }, {
363
+ changedFields: string[];
364
+ regionId: string;
365
+ }>>;
366
+ readonly 'region.deleted': EventDef<z.ZodObject<{
367
+ regionId: z.ZodString;
368
+ }, "strip", z.ZodTypeAny, {
369
+ regionId: string;
370
+ }, {
371
+ regionId: string;
372
+ }>>;
373
+ readonly 'part_family.created': EventDef<z.ZodObject<{
374
+ partFamilyId: z.ZodString;
375
+ code: z.ZodString;
376
+ name: z.ZodString;
377
+ }, "strip", z.ZodTypeAny, {
378
+ code: string;
379
+ name: string;
380
+ partFamilyId: string;
381
+ }, {
382
+ code: string;
383
+ name: string;
384
+ partFamilyId: string;
385
+ }>>;
386
+ readonly 'part_family.updated': EventDef<z.ZodObject<{
387
+ partFamilyId: z.ZodString;
388
+ changedFields: z.ZodArray<z.ZodString, "many">;
389
+ }, "strip", z.ZodTypeAny, {
390
+ changedFields: string[];
391
+ partFamilyId: string;
392
+ }, {
393
+ changedFields: string[];
394
+ partFamilyId: string;
395
+ }>>;
396
+ readonly 'part_family.deleted': EventDef<z.ZodObject<{
397
+ partFamilyId: z.ZodString;
398
+ }, "strip", z.ZodTypeAny, {
399
+ partFamilyId: string;
400
+ }, {
401
+ partFamilyId: string;
402
+ }>>;
403
+ readonly 'rate_library.created': EventDef<z.ZodObject<{
404
+ rateLibraryId: z.ZodString;
405
+ name: z.ZodString;
406
+ code: z.ZodString;
407
+ version: z.ZodNumber;
408
+ status: z.ZodString;
409
+ forkedFrom: z.ZodOptional<z.ZodString>;
410
+ }, "strip", z.ZodTypeAny, {
411
+ code: string;
412
+ status: string;
413
+ name: string;
414
+ rateLibraryId: string;
415
+ version: number;
416
+ forkedFrom?: string | undefined;
417
+ }, {
418
+ code: string;
419
+ status: string;
420
+ name: string;
421
+ rateLibraryId: string;
422
+ version: number;
423
+ forkedFrom?: string | undefined;
424
+ }>>;
425
+ readonly 'rate_library.updated': EventDef<z.ZodObject<{
426
+ rateLibraryId: z.ZodString;
427
+ changedFields: z.ZodArray<z.ZodString, "many">;
428
+ }, "strip", z.ZodTypeAny, {
429
+ changedFields: string[];
430
+ rateLibraryId: string;
431
+ }, {
432
+ changedFields: string[];
433
+ rateLibraryId: string;
434
+ }>>;
435
+ readonly 'rate_library.published': EventDef<z.ZodObject<{
436
+ rateLibraryId: z.ZodString;
437
+ code: z.ZodString;
438
+ version: z.ZodNumber;
439
+ effectiveDate: z.ZodString;
440
+ }, "strip", z.ZodTypeAny, {
441
+ code: string;
442
+ rateLibraryId: string;
443
+ version: number;
444
+ effectiveDate: string;
445
+ }, {
446
+ code: string;
447
+ rateLibraryId: string;
448
+ version: number;
449
+ effectiveDate: string;
450
+ }>>;
451
+ readonly 'rate_library.archived': EventDef<z.ZodObject<{
452
+ rateLibraryId: z.ZodString;
453
+ }, "strip", z.ZodTypeAny, {
454
+ rateLibraryId: string;
455
+ }, {
456
+ rateLibraryId: string;
457
+ }>>;
458
+ };
459
+ export type MasterDataEventType = keyof typeof masterDataEvents;
460
+ export type MasterDataPayload<T extends MasterDataEventType> = z.infer<(typeof masterDataEvents)[T]['payload']>;