@campfire-interactive/master-data-client 4.13.0 → 4.13.2

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.
Files changed (52) hide show
  1. package/dist/attributeDefinitions.d.ts +15 -0
  2. package/dist/attributeDefinitions.d.ts.map +1 -0
  3. package/dist/attributeDefinitions.js +70 -0
  4. package/dist/attributeDefinitions.js.map +1 -0
  5. package/dist/attributeGroups.d.ts +14 -0
  6. package/dist/attributeGroups.d.ts.map +1 -0
  7. package/dist/attributeGroups.js +51 -0
  8. package/dist/attributeGroups.js.map +1 -0
  9. package/dist/attributeOptions.d.ts +14 -0
  10. package/dist/attributeOptions.d.ts.map +1 -0
  11. package/dist/attributeOptions.js +53 -0
  12. package/dist/attributeOptions.js.map +1 -0
  13. package/dist/attributeValidation.d.ts +15 -0
  14. package/dist/attributeValidation.d.ts.map +1 -0
  15. package/dist/attributeValidation.js +141 -0
  16. package/dist/attributeValidation.js.map +1 -0
  17. package/dist/client.d.ts +12 -0
  18. package/dist/client.d.ts.map +1 -1
  19. package/dist/client.js +18 -0
  20. package/dist/client.js.map +1 -1
  21. package/dist/companies.d.ts.map +1 -1
  22. package/dist/companies.js +2 -0
  23. package/dist/companies.js.map +1 -1
  24. package/dist/http.d.ts.map +1 -1
  25. package/dist/http.js +5 -2
  26. package/dist/http.js.map +1 -1
  27. package/dist/index.d.ts +9 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +16 -1
  30. package/dist/index.js.map +1 -1
  31. package/dist/ownership.d.ts +21 -0
  32. package/dist/ownership.d.ts.map +1 -0
  33. package/dist/ownership.js +36 -0
  34. package/dist/ownership.js.map +1 -0
  35. package/dist/programs.d.ts.map +1 -1
  36. package/dist/programs.js +2 -0
  37. package/dist/programs.js.map +1 -1
  38. package/dist/quoteAsks.d.ts +66 -0
  39. package/dist/quoteAsks.d.ts.map +1 -0
  40. package/dist/quoteAsks.js +103 -0
  41. package/dist/quoteAsks.js.map +1 -0
  42. package/dist/quoteLines.d.ts +91 -0
  43. package/dist/quoteLines.d.ts.map +1 -0
  44. package/dist/quoteLines.js +147 -0
  45. package/dist/quoteLines.js.map +1 -0
  46. package/dist/quotes.d.ts +10 -5
  47. package/dist/quotes.d.ts.map +1 -1
  48. package/dist/quotes.js +10 -5
  49. package/dist/quotes.js.map +1 -1
  50. package/dist/types.d.ts +451 -4
  51. package/dist/types.d.ts.map +1 -1
  52. package/package.json +3 -2
package/dist/types.d.ts CHANGED
@@ -97,12 +97,16 @@ export interface ListProgramsOptions {
97
97
  customerCompanyId?: string;
98
98
  /** @deprecated Use customerCompanyId. Removed in the next major. */
99
99
  oemCompanyId?: string;
100
+ /** Batch-get a specific set of programs by id — returns them regardless of
101
+ * status. Comma-joined server-side; cap ~100/call for URL length and chunk
102
+ * larger sets. The server bumps the page size to cover the ids. */
103
+ ids?: string[];
100
104
  include?: ('customerCompany' | 'oemCompany')[];
101
105
  }
102
106
  export interface GetProgramOptions {
103
107
  include?: ('customerCompany' | 'oemCompany')[];
104
108
  }
105
- export type QuoteStatus = 'draft' | 'costing_requested' | 'costing_in_progress' | 'costing_complete' | 'pricing' | 'routed_for_approval' | 'in_review' | 'approved' | 'submitted' | 'negotiating' | 'awarded' | 'lost';
109
+ export type QuoteStatus = 'draft' | 'costing_requested' | 'costing_in_progress' | 'costing_complete' | 'pricing' | 'routed_for_approval' | 'in_review' | 'approved' | 'submitted' | 'negotiating' | 'awarded' | 'lost' | 'not_taken';
106
110
  /**
107
111
  * Who is driving the transition. Required on every status update so the
108
112
  * server can enforce role-gated transitions. `admin` is the escape hatch
@@ -133,6 +137,23 @@ export interface Quote {
133
137
  name: string | null;
134
138
  customerCompanyId: string;
135
139
  programId: string | null;
140
+ /**
141
+ * The OEM request this quote is one competing answer to — see {@link QuoteAsk}.
142
+ * Null means it competes with nothing and is awardable on its own, which is a
143
+ * legitimate state, not missing data.
144
+ */
145
+ askId: string | null;
146
+ /**
147
+ * @deprecated A DERIVED MIRROR of the quote's lines — read `quoteLines.list()`
148
+ * instead.
149
+ *
150
+ * Free text holding a part NUMBER (never a uuid), historically the quote's only
151
+ * part reference. A quote is multi-part now, and this reflects the FIRST line
152
+ * only, so it is lossy the moment a quote has more than one. Writes still work
153
+ * for the whole deprecation window (they transparently maintain the quote's
154
+ * single line), but new code should not read it as "the quote's part". Dropped
155
+ * in a later major. See the nextgen ADR `2026-08-05-multi-part-quotes.md`.
156
+ */
136
157
  partId: string | null;
137
158
  /**
138
159
  * The historical/parent quote this one was copied from. OMSF sets this when
@@ -211,6 +232,24 @@ export interface Quote {
211
232
  * column stays the canonical yearly curve.
212
233
  */
213
234
  effectiveVolumesByYear: EffectiveVolumeByYear[] | null;
235
+ /**
236
+ * The VEHICLE stream (added 2026-08-06) — how many vehicles the program
237
+ * builds, NOT how many parts we sell.
238
+ *
239
+ * This is what each {@link QuoteLine} bridges from: `vehicleAnnualVolume ×
240
+ * takeRate × partsPerVehicle` is that finished good's part volume. One quote
241
+ * covering four finished goods has ONE vehicle stream and four different part
242
+ * volumes, which is why the part columns above cannot serve as the input.
243
+ *
244
+ * **Null on every quote written before 2026-08-06**, and that is not a gap:
245
+ * those quotes' lines bridge from the part columns instead, at a 100/1 bridge
246
+ * that leaves the figure untouched. Read it as "does this quote calculate its
247
+ * line volumes, or carry them directly?" rather than as missing data.
248
+ */
249
+ vehicleAnnualVolume: number | null;
250
+ /** Per-year vehicle curve, same shape as {@link effectiveVolumesByYear}.
251
+ * Bridged year by year onto each line. */
252
+ vehicleVolumesByYear: EffectiveVolumeByYear[] | null;
214
253
  /**
215
254
  * Customer-committed PART volume on ARBITRARY periods — the general form of
216
255
  * {@link effectiveVolumesByYear}, for deals tracked at a granularity the year
@@ -302,6 +341,230 @@ export interface SetEffectivePriceInput {
302
341
  /** Which app is writing — gated to 'omsf' | 'cpq' | 'admin' server-side. */
303
342
  callerRole: 'omsf' | 'cpq' | 'admin';
304
343
  }
344
+ export type QuoteAskStatus = 'open' | 'resolved' | 'cancelled';
345
+ export interface QuoteAsk {
346
+ id: string;
347
+ tenantId: string;
348
+ /** `ASK-YYYY-NNN`, minted server-side from an atomic per-(tenant, year) counter. */
349
+ askNumber: string;
350
+ name: string | null;
351
+ customerCompanyId: string;
352
+ /** Reporting only — NEVER used to decide competition. An opportunity spans
353
+ * rounds; an ask is one round. */
354
+ opportunityId: string | null;
355
+ dueDate: string | null;
356
+ status: QuoteAskStatus;
357
+ /** Which quote won. A recorded fact — closing the siblings is a later phase. */
358
+ resolvedByQuoteId: string | null;
359
+ resolvedAt: string | null;
360
+ createdBy: string;
361
+ updatedBy: string;
362
+ createdAt: string;
363
+ updatedAt: string;
364
+ }
365
+ export interface QuoteAskSummary extends QuoteAsk {
366
+ /** How many quotes compete in this ask. Deliberately not a value aggregate. */
367
+ quoteCount: number;
368
+ }
369
+ /**
370
+ * A RANGE across the ask's quotes — deliberately not a total.
371
+ *
372
+ * The quotes are ALTERNATIVES: three of four lose on every multi-scenario RFQ by
373
+ * construction, so adding them multiply-counts the same business.
374
+ */
375
+ export interface QuoteAskRange {
376
+ quoteCount: number;
377
+ minValue: number | null;
378
+ maxValue: number | null;
379
+ minBlendedMarginPct: number | null;
380
+ maxBlendedMarginPct: number | null;
381
+ }
382
+ export interface QuoteAskCompetingQuote {
383
+ id: string;
384
+ quoteNumber: string;
385
+ name: string | null;
386
+ status: QuoteStatus;
387
+ lines: QuoteLine[];
388
+ rollUp: QuoteLineRollUp;
389
+ }
390
+ export interface QuoteAskDetail extends QuoteAsk {
391
+ quotes: QuoteAskCompetingQuote[];
392
+ range: QuoteAskRange;
393
+ }
394
+ export interface CreateQuoteAskInput {
395
+ customerCompanyId: string;
396
+ name?: string | null;
397
+ opportunityId?: string | null;
398
+ dueDate?: string | null;
399
+ }
400
+ export interface UpdateQuoteAskInput {
401
+ name?: string | null;
402
+ dueDate?: string | null;
403
+ opportunityId?: string | null;
404
+ status?: QuoteAskStatus;
405
+ /** Required when resolving; must be one of this ask's own quotes. */
406
+ resolvedByQuoteId?: string | null;
407
+ }
408
+ export interface ListQuoteAsksOptions {
409
+ status?: QuoteAskStatus;
410
+ customerCompanyId?: string;
411
+ opportunityId?: string;
412
+ }
413
+ /** A per-year volume point. Same shape the quote header uses. */
414
+ export interface QuoteLineVolumeByYear {
415
+ year: number;
416
+ effectiveVolume: number;
417
+ }
418
+ export interface QuoteLine {
419
+ id: string;
420
+ tenantId: string;
421
+ quoteId: string;
422
+ /** Document order. Also picks the line that supplies the deprecated `Quote.partId`. */
423
+ sortOrder: number;
424
+ /**
425
+ * The canonical master-data {@link Part}. NULL is legal — soft enforcement, so a
426
+ * part number not yet reconciled into the catalog can still be quoted. Denotes
427
+ * the BASE part per the part-identity ADR.
428
+ */
429
+ partId: string | null;
430
+ /** Required, denormalised. Carries the line on its own when `partId` is null. */
431
+ partNumber: string;
432
+ /** Engineering revision this line is quoted AT, when known. Never identity. */
433
+ revision: string | null;
434
+ /**
435
+ * Vehicle→part bridge, unique per line. At the defaults (100 / 1) the
436
+ * header→line volume projection is the IDENTITY.
437
+ */
438
+ takeRate: number | null;
439
+ partsPerVehicle: number | null;
440
+ /** Authored. Null inherits the header through the bridge. */
441
+ annualVolume: number | null;
442
+ /** Authored per-year series. Authoritative over `annualVolume` when present. */
443
+ effectiveVolumesByYear: QuoteLineVolumeByYear[] | null;
444
+ /** Authored offered price for this line. */
445
+ unitPrice: string | null;
446
+ /** Free text against an unhealthy line. Writable during review. */
447
+ note: string | null;
448
+ /** DERIVED — published only via `quoteLines.setEffectiveCost`. */
449
+ effectiveUnitCost: string | null;
450
+ effectiveCostSource: string | null;
451
+ effectiveCostBasis: string | null;
452
+ effectiveCostedAt: string | null;
453
+ effectiveCostedBy: string | null;
454
+ effectiveCostBreakdown: unknown | null;
455
+ /** DERIVED — published only via `quoteLines.setEffectivePrice`. */
456
+ effectiveUnitPrice: string | null;
457
+ effectivePriceSource: string | null;
458
+ effectivePriceBasis: string | null;
459
+ effectivePricedAt: string | null;
460
+ effectivePricedBy: string | null;
461
+ effectivePriceBreakdown: unknown | null;
462
+ createdBy: string;
463
+ updatedBy: string;
464
+ createdAt: string;
465
+ updatedAt: string;
466
+ /** Present when the line resolves to a catalog part. */
467
+ part?: {
468
+ id: string;
469
+ partNumber: string;
470
+ name: string;
471
+ partTypeId: string | null;
472
+ } | null;
473
+ /** Resolved figures — see {@link ResolvedQuoteLineTerms}. */
474
+ terms: ResolvedQuoteLineTerms;
475
+ }
476
+ /**
477
+ * A line's resolved terms. The `*Source` / `*FromLine` flags let a caller tell an
478
+ * authored figure from an inherited one without re-deriving the precedence.
479
+ */
480
+ export interface ResolvedQuoteLineTerms {
481
+ annualVolume: number;
482
+ volumesByYear: QuoteLineVolumeByYear[] | null;
483
+ unitCost: number | null;
484
+ unitPrice: number | null;
485
+ value: number;
486
+ marginPct: number | null;
487
+ /**
488
+ * Which tier the volume came from: the line's own series, the line's own annual
489
+ * figure, or the quote header bridged through take rate × parts per vehicle.
490
+ */
491
+ volumeSource: 'line_years' | 'line_annual' | 'header_bridged';
492
+ costFromLine: boolean;
493
+ priceFromLine: boolean;
494
+ }
495
+ /**
496
+ * Consolidated figures for ONE quote's lines, computed on read.
497
+ *
498
+ * `blendedMarginPct` is value-weighted over the lines whose margin is KNOWN, not
499
+ * over the whole quote value — a blend diluted by parts with no cost yet is a
500
+ * worse number that is equally false. `linesWithoutMargin` reports that gap.
501
+ */
502
+ export interface QuoteLineRollUp {
503
+ lineCount: number;
504
+ totalAnnualVolume: number;
505
+ totalValue: number;
506
+ blendedMarginPct: number | null;
507
+ linesWithoutMargin: number;
508
+ /** Lines whose part number isn't reconciled into the catalog yet. */
509
+ linesWithoutCatalogPart: number;
510
+ }
511
+ export interface QuoteLinesResponse {
512
+ quoteId: string;
513
+ quoteNumber: string;
514
+ lines: QuoteLine[];
515
+ rollUp: QuoteLineRollUp;
516
+ }
517
+ export interface QuoteLinesWithApprovalFlag extends QuoteLinesResponse {
518
+ /**
519
+ * True when the published figure landed on a quote already in approval — the
520
+ * approver signed off on a different number. Surfaced rather than silently
521
+ * absorbed; the caller decides whether to void and re-route.
522
+ */
523
+ invalidatesApproval: boolean;
524
+ }
525
+ export interface AddQuoteLineInput {
526
+ partNumber: string;
527
+ /** Omit to resolve from `partNumber`; pass `null` to pin it null. */
528
+ partId?: string | null;
529
+ revision?: string | null;
530
+ /** Defaults to the end of the list, so a new line can't take over the mirror. */
531
+ sortOrder?: number;
532
+ /** Percentage, 0–100. Defaults to 100. */
533
+ takeRate?: number;
534
+ /** Defaults to 1. */
535
+ partsPerVehicle?: number;
536
+ annualVolume?: number | null;
537
+ effectiveVolumesByYear?: QuoteLineVolumeByYear[] | null;
538
+ unitPrice?: number | null;
539
+ note?: string | null;
540
+ }
541
+ export interface UpdateQuoteLineInput {
542
+ partNumber?: string;
543
+ /** Omitted with a changed `partNumber` re-resolves the catalog link. */
544
+ partId?: string | null;
545
+ revision?: string | null;
546
+ sortOrder?: number;
547
+ takeRate?: number;
548
+ partsPerVehicle?: number;
549
+ annualVolume?: number | null;
550
+ effectiveVolumesByYear?: QuoteLineVolumeByYear[] | null;
551
+ unitPrice?: number | null;
552
+ note?: string | null;
553
+ }
554
+ export interface SetQuoteLineEffectiveCostInput {
555
+ unitCost: number;
556
+ /** Required — what the figure was costed against. */
557
+ costBasis: string;
558
+ /** Declared by the adapter. Defaults to 'cpq'. */
559
+ source?: string;
560
+ breakdown?: unknown;
561
+ }
562
+ export interface SetQuoteLineEffectivePriceInput {
563
+ unitPrice: number;
564
+ priceBasis: string;
565
+ source?: string;
566
+ breakdown?: unknown;
567
+ }
305
568
  export interface CreateQuoteInput {
306
569
  /**
307
570
  * MIGRATION ESCAPE HATCH — do not set this from production code.
@@ -319,6 +582,10 @@ export interface CreateQuoteInput {
319
582
  name?: string;
320
583
  customerCompanyId: string;
321
584
  programId?: string;
585
+ /** Join the quote to an OEM request ({@link QuoteAsk}). Optional — a quote with
586
+ * no ask competes with nothing and is awardable on its own. Validated to exist
587
+ * in-tenant AND to belong to the same customer as the quote. */
588
+ askId?: string | null;
322
589
  partId?: string;
323
590
  /** Historical/parent quote this one was copied from. Validated to exist
324
591
  * in-tenant on write; no DB FK. */
@@ -338,6 +605,12 @@ export interface CreateQuoteInput {
338
605
  eopPrecision?: SopEopPrecision;
339
606
  effectiveAnnualVolume?: number;
340
607
  effectiveVolumesByYear?: EffectiveVolumeByYear[];
608
+ /** The VEHICLE stream every line bridges from — vehicles the program builds,
609
+ * not parts sold. Each line turns it into its own part volume with its take
610
+ * rate and parts-per-vehicle. Omit it and the lines fall back to the part
611
+ * columns, which is what pre-2026-08-06 quotes do. (4.12.0) */
612
+ vehicleAnnualVolume?: number;
613
+ vehicleVolumesByYear?: EffectiveVolumeByYear[];
341
614
  /** Arbitrary-period committed volume. Non-empty makes the two fields above
342
615
  * derived — passing either alongside it is a 422. (4.8.0) */
343
616
  effectiveVolumesByPeriod?: EffectiveVolumeByPeriod[];
@@ -368,6 +641,9 @@ export interface UpdateQuoteInput {
368
641
  quoteNumber?: string;
369
642
  name?: string | null;
370
643
  programId?: string | null;
644
+ /** Join the quote to an OEM request ({@link QuoteAsk}), or `null` to detach it
645
+ * (it then competes with nothing). Validated to match the quote's customer. */
646
+ askId?: string | null;
371
647
  partId?: string | null;
372
648
  /** Set to a quote id to record provenance, or `null` to clear it. */
373
649
  referenceQuoteId?: string | null;
@@ -385,6 +661,11 @@ export interface UpdateQuoteInput {
385
661
  eopPrecision?: SopEopPrecision | null;
386
662
  effectiveAnnualVolume?: number | null;
387
663
  effectiveVolumesByYear?: EffectiveVolumeByYear[] | null;
664
+ /** The VEHICLE stream. Editing it moves EVERY line's calculated volume at
665
+ * once — one program build rate, many finished goods. `null` hands the lines
666
+ * back to the part columns. (4.12.0) */
667
+ vehicleAnnualVolume?: number | null;
668
+ vehicleVolumesByYear?: EffectiveVolumeByYear[] | null;
388
669
  /** Full replace. Non-empty makes the yearly fields derived (writing them is a
389
670
  * 422); `null` or `[]` clears the schedule and hands them back. The last
390
671
  * derived values are left in place — clearing stops maintaining them, it
@@ -1635,8 +1916,8 @@ export interface ListPartTypesOptions {
1635
1916
  /** When true, request only active types (drops archived). */
1636
1917
  activeOnly?: boolean;
1637
1918
  }
1638
- export type AttributeDataType = 'text' | 'number' | 'boolean' | 'enum' | 'date';
1639
- export type AttributeStatus = 'active' | 'archived';
1919
+ export type AttributeDataType = 'text' | 'number' | 'boolean' | 'enum' | 'date' | 'multi_select' | 'hierarchy';
1920
+ export type AttributeStatus = 'active' | 'deprecated' | 'archived';
1640
1921
  /** Typed rules stored per definition and enforced by the server on every
1641
1922
  * attribute write. `min`/`max` are value bounds for `number` and length bounds
1642
1923
  * for `text`; `regex` applies to `text`; `precision` is max decimal places for
@@ -1693,6 +1974,135 @@ export interface ListPartAttributesOptions {
1693
1974
  /** When true, request only active definitions (drops archived). */
1694
1975
  activeOnly?: boolean;
1695
1976
  }
1977
+ /** Per-type config + rules stored per definition (superset of AttributeValidation). */
1978
+ export interface AttributeValidationRules {
1979
+ required?: boolean;
1980
+ min?: number;
1981
+ max?: number;
1982
+ regex?: string;
1983
+ precision?: number;
1984
+ /** hierarchy: ordered level names, e.g. ["OEM","Platform","Program"]. */
1985
+ levels?: string[];
1986
+ minSelections?: number;
1987
+ maxSelections?: number;
1988
+ [k: string]: unknown;
1989
+ }
1990
+ export interface AttributeDefinition {
1991
+ id: string;
1992
+ tenantId: string;
1993
+ entityType: string;
1994
+ key: string;
1995
+ label: string;
1996
+ dataType: AttributeDataType;
1997
+ unit: string | null;
1998
+ /** Legacy inline enum values; prefer `attributeOptions` rows. */
1999
+ options: string[] | null;
2000
+ group: string | null;
2001
+ groupId: string | null;
2002
+ validation: AttributeValidationRules | null;
2003
+ filterable: boolean;
2004
+ analyticsVisible: boolean;
2005
+ status: AttributeStatus;
2006
+ sortOrder: number;
2007
+ createdBy: string;
2008
+ updatedBy: string;
2009
+ createdAt: string;
2010
+ updatedAt: string;
2011
+ /** Present when the definition is fetched with its options (select/hierarchy). */
2012
+ attributeOptions?: AttributeOption[];
2013
+ }
2014
+ export interface CreateAttributeDefinitionInput {
2015
+ entityType: string;
2016
+ key: string;
2017
+ label: string;
2018
+ dataType: AttributeDataType;
2019
+ unit?: string | null;
2020
+ options?: string[] | null;
2021
+ groupId?: string | null;
2022
+ validation?: AttributeValidationRules | null;
2023
+ filterable?: boolean;
2024
+ analyticsVisible?: boolean;
2025
+ sortOrder?: number;
2026
+ }
2027
+ export interface UpdateAttributeDefinitionInput {
2028
+ label?: string;
2029
+ dataType?: AttributeDataType;
2030
+ unit?: string | null;
2031
+ options?: string[] | null;
2032
+ groupId?: string | null;
2033
+ validation?: AttributeValidationRules | null;
2034
+ filterable?: boolean;
2035
+ analyticsVisible?: boolean;
2036
+ sortOrder?: number;
2037
+ status?: AttributeStatus;
2038
+ }
2039
+ export interface ListAttributeDefinitionsOptions {
2040
+ /** Required — the entity whose definitions to list ('opportunity', 'quote', …). */
2041
+ entityType: string;
2042
+ activeOnly?: boolean;
2043
+ groupId?: string;
2044
+ }
2045
+ export interface AttributeGroup {
2046
+ id: string;
2047
+ tenantId: string;
2048
+ entityType: string;
2049
+ name: string;
2050
+ sortOrder: number;
2051
+ createdBy: string;
2052
+ updatedBy: string;
2053
+ createdAt: string;
2054
+ updatedAt: string;
2055
+ }
2056
+ export interface CreateAttributeGroupInput {
2057
+ entityType: string;
2058
+ name: string;
2059
+ sortOrder?: number;
2060
+ }
2061
+ export interface UpdateAttributeGroupInput {
2062
+ name?: string;
2063
+ sortOrder?: number;
2064
+ }
2065
+ /** Disposition for a group's definitions when the group is deleted. */
2066
+ export interface DeleteAttributeGroupOptions {
2067
+ reassignTo?: string;
2068
+ archive?: boolean;
2069
+ }
2070
+ export interface AttributeOption {
2071
+ id: string;
2072
+ tenantId: string;
2073
+ definitionId: string;
2074
+ value: string;
2075
+ label: string;
2076
+ sortOrder: number;
2077
+ parentId: string | null;
2078
+ level: number;
2079
+ createdBy: string;
2080
+ updatedBy: string;
2081
+ createdAt: string;
2082
+ updatedAt: string;
2083
+ }
2084
+ export interface CreateAttributeOptionInput {
2085
+ value: string;
2086
+ label?: string;
2087
+ sortOrder?: number;
2088
+ parentId?: string | null;
2089
+ }
2090
+ export interface UpdateAttributeOptionInput {
2091
+ value?: string;
2092
+ label?: string;
2093
+ sortOrder?: number;
2094
+ }
2095
+ /** Result of the option Excel import (validate-preview or commit). */
2096
+ export interface ImportOptionsResult {
2097
+ summary: {
2098
+ rows: number;
2099
+ roots: number;
2100
+ total: number;
2101
+ byLevel: Record<number, number>;
2102
+ errors: string[];
2103
+ };
2104
+ committed: boolean;
2105
+ }
1696
2106
  export interface AuditLogEntry {
1697
2107
  id: string;
1698
2108
  tenantId: string | null;
@@ -1786,7 +2196,7 @@ export type SourceApp = 'master-data' | 'erfq' | 'cpq' | 'bom' | 'forecast' | 'o
1786
2196
  * "Empty" means SQL NULL only — a stored '', 0, false, or 0.0 counts as
1787
2197
  * populated and will not be overwritten by fill_empty. */
1788
2198
  export type MergePolicy = 'overwrite' | 'fill_empty';
1789
- export type ImportTargetField = 'name' | 'legalName' | 'code' | 'taxId' | 'dunsNumber' | 'website' | 'logoUrl' | 'roles' | 'email' | 'phone' | 'role' | 'type' | 'description' | 'street' | 'city' | 'stateProvince' | 'postalCode' | 'country' | 'category' | 'parent_company_ref' | 'companyCode' | 'locationCode' | 'region' | 'headcount' | 'annualCapacityHours' | 'currentUtilization' | 'riskLevel' | 'numShifts' | 'hoursPerShift' | 'workingDaysPerYear' | 'indirectHeadcountPct' | 'currency' | 'effectiveDate' | 'effectiveTo' | 'libraryCode' | 'kind' | 'plantCode' | 'skillTier' | 'materialCode' | 'regionCode' | 'lane' | 'rate' | 'unit' | 'sourcingMode' | 'indexRef' | 'notes' | 'partNumber' | 'manufacturingPartNumber' | 'customerPartNumber' | 'partType' | 'manufacturer' | 'partCategoryCode' | 'quality' | 'revision' | 'uom' | 'weightPerUnit' | 'recycledPct' | 'pcfPerUnit' | 'releaseStatus' | 'leadTime' | 'customerCompanyCode' | 'customerCompanyName' | 'sopDate' | 'eopDate' | 'displayOrder' | 'label' | 'sortOrder' | 'processFamily' | 'capacityHoursPerYear' | 'cavities' | 'availabilityPct' | 'performancePct' | 'defaultHeadcount' | 'defaultAutomationPct' | 'defaultMachinesPerOperator' | 'defaultSetupCrew' | 'perUsd' | 'effectiveFrom' | 'quoteNumber' | 'programCode' | 'partId' | 'regionName' | 'annualVolume' | 'apw' | 'mpw' | 'targetPrice' | 'dueDate' | 'key' | 'dataType' | 'options' | 'group' | 'required' | 'min' | 'max' | 'regex' | 'precision' | 'basis' | 'bindings' | 'perBaseFactor' | 'needsDensity' | 'binding' | 'allowedUoms' | 'defaultUom' | 'escalationDefault' | 'density' | 'densityUnit';
2199
+ export type ImportTargetField = 'name' | 'legalName' | 'code' | 'taxId' | 'dunsNumber' | 'website' | 'logoUrl' | 'roles' | 'email' | 'phone' | 'role' | 'type' | 'description' | 'street' | 'city' | 'stateProvince' | 'postalCode' | 'country' | 'category' | 'parent_company_ref' | 'companyCode' | 'companyName' | 'locationCode' | 'region' | 'headcount' | 'annualCapacityHours' | 'currentUtilization' | 'riskLevel' | 'numShifts' | 'hoursPerShift' | 'workingDaysPerYear' | 'indirectHeadcountPct' | 'currency' | 'effectiveDate' | 'effectiveTo' | 'libraryCode' | 'kind' | 'plantCode' | 'skillTier' | 'materialCode' | 'regionCode' | 'lane' | 'rate' | 'unit' | 'sourcingMode' | 'indexRef' | 'notes' | 'partNumber' | 'manufacturingPartNumber' | 'customerPartNumber' | 'partType' | 'manufacturer' | 'partCategoryCode' | 'quality' | 'revision' | 'uom' | 'weightPerUnit' | 'recycledPct' | 'pcfPerUnit' | 'releaseStatus' | 'leadTime' | 'customerCompanyCode' | 'customerCompanyName' | 'sopDate' | 'eopDate' | 'displayOrder' | 'label' | 'sortOrder' | 'processFamily' | 'capacityHoursPerYear' | 'cavities' | 'availabilityPct' | 'performancePct' | 'defaultHeadcount' | 'defaultAutomationPct' | 'defaultMachinesPerOperator' | 'defaultSetupCrew' | 'perUsd' | 'effectiveFrom' | 'quoteNumber' | 'programCode' | 'partId' | 'regionName' | 'annualVolume' | 'apw' | 'mpw' | 'targetPrice' | 'dueDate' | 'status' | 'key' | 'dataType' | 'options' | 'group' | 'required' | 'min' | 'max' | 'regex' | 'precision' | 'basis' | 'bindings' | 'perBaseFactor' | 'needsDensity' | 'binding' | 'allowedUoms' | 'defaultUom' | 'escalationDefault' | 'density' | 'densityUnit';
1790
2200
  export interface ImportSession {
1791
2201
  id: string;
1792
2202
  tenantId: string;
@@ -2062,10 +2472,20 @@ export interface BulkArchiveResult {
2062
2472
  errors: number;
2063
2473
  };
2064
2474
  }
2475
+ /** Ownership verdict carried on an *enforced* entity's read/list response
2476
+ * `meta` (Master Data Ownership Phase 4). Present only for enforced elements
2477
+ * (Plant today). `readOnly` ⇒ the element is externally owned and Campfire
2478
+ * edits are rejected server-side; the UI renders read-only + `editHint`. */
2479
+ export interface OwnershipMeta {
2480
+ readOnly: boolean;
2481
+ ownerSystem: string;
2482
+ editHint: string | null;
2483
+ }
2065
2484
  export interface ApiMeta {
2066
2485
  requestId: string;
2067
2486
  timestamp: string;
2068
2487
  resolvedFrom?: string;
2488
+ ownership?: OwnershipMeta;
2069
2489
  }
2070
2490
  export interface ListMeta extends ApiMeta {
2071
2491
  nextCursor: string | null;
@@ -2079,6 +2499,29 @@ export interface DuplicateWarning {
2079
2499
  matchName: string;
2080
2500
  score: number;
2081
2501
  }
2502
+ export type OwnerType = 'campfire' | 'external';
2503
+ /** One catalog element merged with its (optional) stored ownership row. The
2504
+ * GET response fills catalog defaults where a tenant has no row. */
2505
+ export interface MasterDataElementOwnership {
2506
+ element: string;
2507
+ label: string;
2508
+ category: string;
2509
+ ownerType: OwnerType;
2510
+ /** Owning system display name; 'Campfire' when Campfire-owned. */
2511
+ systemName: string;
2512
+ syncMethod: string | null;
2513
+ /** Opaque integrations Source id (external only) — traceability, not a FK. */
2514
+ sourceRef: string | null;
2515
+ updatedAt: string | null;
2516
+ updatedBy: string | null;
2517
+ }
2518
+ export interface SetOwnershipInput {
2519
+ ownerType: OwnerType;
2520
+ /** Required when ownerType is 'external'. */
2521
+ systemName?: string;
2522
+ syncMethod?: string;
2523
+ sourceRef?: string;
2524
+ }
2082
2525
  export interface SingleResponse<T> {
2083
2526
  data: T;
2084
2527
  meta: ApiMeta;
@@ -2100,6 +2543,10 @@ export interface ListCompaniesOptions {
2100
2543
  status?: 'active' | 'archived' | 'all';
2101
2544
  quality?: 'draft' | 'verified';
2102
2545
  role?: 'supplier' | 'customer' | 'oem';
2546
+ /** Batch-get a specific set of companies by id — returns them regardless of
2547
+ * status. Comma-joined server-side; cap ~100/call for URL length and chunk
2548
+ * larger sets. The server bumps the page size to cover the ids. */
2549
+ ids?: string[];
2103
2550
  include?: ('contacts' | 'locations')[];
2104
2551
  }
2105
2552
  export interface GetCompanyOptions {