diff --git a/lib/db/derivedtables/accelerometer.ts b/lib/db/derivedtables/accelerometer.ts index bd67aeb..50d8493 100644 --- a/lib/db/derivedtables/accelerometer.ts +++ b/lib/db/derivedtables/accelerometer.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" import { BaseComponent } from "./component-base" @@ -102,6 +103,7 @@ export const accelerometerTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", supply_voltage_min: voltageMin, supply_voltage_max: voltageMax, diff --git a/lib/db/derivedtables/adc.ts b/lib/db/derivedtables/adc.ts index 008b533..9011096 100644 --- a/lib/db/derivedtables/adc.ts +++ b/lib/db/derivedtables/adc.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -115,6 +116,7 @@ export const adcTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", resolution_bits: resolution, sampling_rate_hz: samplingRate, diff --git a/lib/db/derivedtables/analog_multiplexer.ts b/lib/db/derivedtables/analog_multiplexer.ts index 1e4bb7d..a47809b 100644 --- a/lib/db/derivedtables/analog_multiplexer.ts +++ b/lib/db/derivedtables/analog_multiplexer.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -144,6 +145,7 @@ export const analogMultiplexerTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", num_channels: numChannels, num_bits: numBits, diff --git a/lib/db/derivedtables/battery_holder.ts b/lib/db/derivedtables/battery_holder.ts index c970eee..4b5de31 100644 --- a/lib/db/derivedtables/battery_holder.ts +++ b/lib/db/derivedtables/battery_holder.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -74,6 +75,7 @@ export const batteryHolderTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), connector_type: attrs["Connector Type"] || null, battery_type: attrs["Battery Type"] || null, diff --git a/lib/db/derivedtables/bjt_transistor.ts b/lib/db/derivedtables/bjt_transistor.ts index ae3a255..04cfc3e 100644 --- a/lib/db/derivedtables/bjt_transistor.ts +++ b/lib/db/derivedtables/bjt_transistor.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import type { KyselyDatabaseInstance } from "../kysely-types" import { BaseComponent } from "./component-base" @@ -74,6 +75,7 @@ export const bjtTransistorTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", current_gain: current_gain, collector_current: collector_current, diff --git a/lib/db/derivedtables/boost_converter.ts b/lib/db/derivedtables/boost_converter.ts index da3fad8..e2b7168 100644 --- a/lib/db/derivedtables/boost_converter.ts +++ b/lib/db/derivedtables/boost_converter.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" import { BaseComponent } from "./component-base" @@ -117,6 +118,7 @@ export const boostConverterTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", input_voltage_min: inputMin, input_voltage_max: inputMax, diff --git a/lib/db/derivedtables/buck_boost_converter.ts b/lib/db/derivedtables/buck_boost_converter.ts index 784ec02..ed62bcc 100644 --- a/lib/db/derivedtables/buck_boost_converter.ts +++ b/lib/db/derivedtables/buck_boost_converter.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" import { BaseComponent } from "./component-base" @@ -121,6 +122,7 @@ export const buckBoostConverterTableSpec: DerivedTableSpec = in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", input_voltage_min: inputMin, input_voltage_max: inputMax, diff --git a/lib/db/derivedtables/capacitor.ts b/lib/db/derivedtables/capacitor.ts index 971f055..1ae4078 100644 --- a/lib/db/derivedtables/capacitor.ts +++ b/lib/db/derivedtables/capacitor.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -115,6 +116,7 @@ export const capacitorTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), capacitance_farads: capacitance, tolerance_fraction: tolerance, voltage_rating: voltage, diff --git a/lib/db/derivedtables/component-base.ts b/lib/db/derivedtables/component-base.ts index c028aec..35f2fe6 100644 --- a/lib/db/derivedtables/component-base.ts +++ b/lib/db/derivedtables/component-base.ts @@ -7,5 +7,6 @@ export interface BaseComponent { in_stock: boolean is_basic: boolean is_preferred: boolean + is_extended_promotional: boolean attributes: Record } diff --git a/lib/db/derivedtables/dac.ts b/lib/db/derivedtables/dac.ts index a0388ad..27da719 100644 --- a/lib/db/derivedtables/dac.ts +++ b/lib/db/derivedtables/dac.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -129,6 +130,7 @@ export const dacTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", resolution_bits: resolution, num_channels: numChannels, diff --git a/lib/db/derivedtables/diode.ts b/lib/db/derivedtables/diode.ts index dad2916..34b2bb3 100644 --- a/lib/db/derivedtables/diode.ts +++ b/lib/db/derivedtables/diode.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -159,6 +160,7 @@ export const diodeTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", forward_voltage: forwardVoltage, reverse_voltage: reverseVoltage, diff --git a/lib/db/derivedtables/fpc_connector.ts b/lib/db/derivedtables/fpc_connector.ts index ced77e9..03f8fad 100644 --- a/lib/db/derivedtables/fpc_connector.ts +++ b/lib/db/derivedtables/fpc_connector.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -55,6 +56,7 @@ export const fpcConnectorTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), pitch_mm: parseNum(attrs["Pitch"]), number_of_contacts: isNaN(contacts) ? null : contacts, contact_type: attrs["Contact Type"] || null, diff --git a/lib/db/derivedtables/fpga.ts b/lib/db/derivedtables/fpga.ts index e7d0402..6ebea92 100644 --- a/lib/db/derivedtables/fpga.ts +++ b/lib/db/derivedtables/fpga.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" import type { DerivedTableSpec } from "./types" import { BaseComponent } from "./component-base" @@ -99,6 +100,7 @@ export const fpgaTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock ?? 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: extra?.package ?? c.package ?? "", type: attrs["Type"] ?? null, logic_array_blocks: parseNumericValue(attrs["Logic Array Blocks"]), diff --git a/lib/db/derivedtables/fuse.ts b/lib/db/derivedtables/fuse.ts index 0b56ac1..5569c9d 100644 --- a/lib/db/derivedtables/fuse.ts +++ b/lib/db/derivedtables/fuse.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import type { KyselyDatabaseInstance } from "../kysely-types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -90,6 +91,7 @@ export const fuseTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), current_rating: current_rating as number, voltage_rating: voltage_rating as number, response_time, diff --git a/lib/db/derivedtables/gas_sensor.ts b/lib/db/derivedtables/gas_sensor.ts index a44050b..fd6a32f 100644 --- a/lib/db/derivedtables/gas_sensor.ts +++ b/lib/db/derivedtables/gas_sensor.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" import { BaseComponent } from "./component-base" @@ -82,6 +83,7 @@ export const gasSensorTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", sensor_type: sensorType, measures_air_quality: measuresAirQuality, diff --git a/lib/db/derivedtables/gyroscope.ts b/lib/db/derivedtables/gyroscope.ts index 9671b5d..131d29a 100644 --- a/lib/db/derivedtables/gyroscope.ts +++ b/lib/db/derivedtables/gyroscope.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" import { BaseComponent } from "./component-base" @@ -106,6 +107,7 @@ export const gyroscopeTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", supply_voltage_min: voltageMin, supply_voltage_max: voltageMax, diff --git a/lib/db/derivedtables/header.ts b/lib/db/derivedtables/header.ts index 04bc7bb..e6b107d 100644 --- a/lib/db/derivedtables/header.ts +++ b/lib/db/derivedtables/header.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -197,6 +198,7 @@ export const headerTableSpec: DerivedTableSpec
= { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), price1: extractMinQPrice(c.price)!, package: c.package || "", pitch_mm: pitch, diff --git a/lib/db/derivedtables/io_expander.ts b/lib/db/derivedtables/io_expander.ts index e9bf2da..6a959e0 100644 --- a/lib/db/derivedtables/io_expander.ts +++ b/lib/db/derivedtables/io_expander.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -139,6 +140,7 @@ export const ioExpanderTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", num_gpios: numGpios, supply_voltage_min: voltageMin, diff --git a/lib/db/derivedtables/jst_connector.ts b/lib/db/derivedtables/jst_connector.ts index 0afd2aa..e3a78c2 100644 --- a/lib/db/derivedtables/jst_connector.ts +++ b/lib/db/derivedtables/jst_connector.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -69,6 +70,7 @@ export const jstConnectorTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), pitch_mm: parseNum(attrs["Pitch"]), num_rows: isNaN(numRows) ? null : numRows, diff --git a/lib/db/derivedtables/lcd_display.ts b/lib/db/derivedtables/lcd_display.ts index 15a34c5..9d07b5e 100644 --- a/lib/db/derivedtables/lcd_display.ts +++ b/lib/db/derivedtables/lcd_display.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import type { KyselyDatabaseInstance } from "../kysely-types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -64,6 +65,7 @@ export const lcdDisplayTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), display_size, resolution, diff --git a/lib/db/derivedtables/led.ts b/lib/db/derivedtables/led.ts index f12a12e..db72028 100644 --- a/lib/db/derivedtables/led.ts +++ b/lib/db/derivedtables/led.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -165,6 +166,7 @@ export const ledTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", forward_voltage: forwardVoltage, forward_current: forwardCurrent, diff --git a/lib/db/derivedtables/led_dot_matrix_display.ts b/lib/db/derivedtables/led_dot_matrix_display.ts index 2d32eda..74e8006 100644 --- a/lib/db/derivedtables/led_dot_matrix_display.ts +++ b/lib/db/derivedtables/led_dot_matrix_display.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import type { KyselyDatabaseInstance } from "../kysely-types" import { BaseComponent } from "./component-base" @@ -57,6 +58,7 @@ export const ledDotMatrixDisplayTableSpec: DerivedTableSpec in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), matrix_size, color, diff --git a/lib/db/derivedtables/led_driver.ts b/lib/db/derivedtables/led_driver.ts index 55f0e8c..382fc37 100644 --- a/lib/db/derivedtables/led_driver.ts +++ b/lib/db/derivedtables/led_driver.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import type { SelectQueryBuilder, Generated } from "kysely" import type { Component } from "../generated/kysely" @@ -77,6 +78,7 @@ export const ledDriverTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), supply_voltage_min: parseValue(attrs["Input Voltage"]?.split("~")[0]), supply_voltage_max: parseValue(attrs["Input Voltage"]?.split("~")[1]), diff --git a/lib/db/derivedtables/led_segment_display.ts b/lib/db/derivedtables/led_segment_display.ts index bf5f50e..d477eb5 100644 --- a/lib/db/derivedtables/led_segment_display.ts +++ b/lib/db/derivedtables/led_segment_display.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import type { KyselyDatabaseInstance } from "../kysely-types" import { BaseComponent } from "./component-base" @@ -70,6 +71,7 @@ export const ledSegmentDisplayTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), positions, type, diff --git a/lib/db/derivedtables/led_with_ic.ts b/lib/db/derivedtables/led_with_ic.ts index bba0faa..3bafbef 100644 --- a/lib/db/derivedtables/led_with_ic.ts +++ b/lib/db/derivedtables/led_with_ic.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import { BaseComponent } from "./component-base" import type { SelectQueryBuilder, Generated } from "kysely" @@ -99,6 +100,7 @@ export const ledWithICTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), forward_voltage: forwardVoltage, forward_current: forwardCurrent, diff --git a/lib/db/derivedtables/microcontroller.ts b/lib/db/derivedtables/microcontroller.ts index 6b7b083..aef2180 100644 --- a/lib/db/derivedtables/microcontroller.ts +++ b/lib/db/derivedtables/microcontroller.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -228,6 +229,7 @@ export const microcontrollerTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", cpu_core: cpuCore, cpu_speed_hz: cpuSpeed, diff --git a/lib/db/derivedtables/mosfet.ts b/lib/db/derivedtables/mosfet.ts index 31f5412..93d8fa0 100644 --- a/lib/db/derivedtables/mosfet.ts +++ b/lib/db/derivedtables/mosfet.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import type { SelectQueryBuilder, Generated } from "kysely" import type { Component } from "../generated/kysely" @@ -68,6 +69,7 @@ export const mosfetTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), drain_source_voltage: parseValue( attrs["Drain Source Voltage (Vdss)"], diff --git a/lib/db/derivedtables/oled_display.ts b/lib/db/derivedtables/oled_display.ts index dbabb65..277a277 100644 --- a/lib/db/derivedtables/oled_display.ts +++ b/lib/db/derivedtables/oled_display.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import type { KyselyDatabaseInstance } from "../kysely-types" import { BaseComponent } from "./component-base" @@ -65,6 +66,7 @@ export const oledDisplayTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), protocol: protocol || undefined, display_width, diff --git a/lib/db/derivedtables/pcie_m2_connector.ts b/lib/db/derivedtables/pcie_m2_connector.ts index 0e9bcc1..2ee5dbc 100644 --- a/lib/db/derivedtables/pcie_m2_connector.ts +++ b/lib/db/derivedtables/pcie_m2_connector.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" import { BaseComponent } from "./component-base" @@ -49,6 +50,7 @@ export const pcieM2ConnectorTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), key, is_right_angle: isRightAngle, attributes: attrs, diff --git a/lib/db/derivedtables/potentiometer.ts b/lib/db/derivedtables/potentiometer.ts index d7f1576..55e2eb8 100644 --- a/lib/db/derivedtables/potentiometer.ts +++ b/lib/db/derivedtables/potentiometer.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -54,6 +55,7 @@ export const potentiometerTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), max_resistance: maxResistance, pin_variant: pinVariant, package: c.package || "", diff --git a/lib/db/derivedtables/relay.ts b/lib/db/derivedtables/relay.ts index 944a5fe..dd48f7a 100644 --- a/lib/db/derivedtables/relay.ts +++ b/lib/db/derivedtables/relay.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import { parseIntOrNull } from "lib/util/parse-int-or-null" import type { DerivedTableSpec } from "./types" @@ -62,6 +63,7 @@ export const relayTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), relay_type: (c as any).subcategory || "", contact_form: attrs["Contact Form"] || null, diff --git a/lib/db/derivedtables/resistor.ts b/lib/db/derivedtables/resistor.ts index b6b437d..d1cbfb5 100644 --- a/lib/db/derivedtables/resistor.ts +++ b/lib/db/derivedtables/resistor.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -82,6 +83,7 @@ export const resistorTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), resistance: resistance, tolerance_fraction: tolerance, power_watts, diff --git a/lib/db/derivedtables/resistor_array.ts b/lib/db/derivedtables/resistor_array.ts index 5521d4d..fa3ea58 100644 --- a/lib/db/derivedtables/resistor_array.ts +++ b/lib/db/derivedtables/resistor_array.ts @@ -2,6 +2,7 @@ import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" import type { DerivedTableSpec } from "./types" import { BaseComponent } from "./component-base" +import { getIsExtendedPromotional } from "lib/util/component-utils" export interface ResistorArray extends BaseComponent { package: string @@ -124,6 +125,7 @@ export const resistorArrayTableSpec: DerivedTableSpec = { in_stock: component.stock > 0, is_basic: Boolean(component.basic), is_preferred: Boolean(component.preferred), + is_extended_promotional: getIsExtendedPromotional(component), package: component.package ?? "", resistance, tolerance_fraction: tolerance, diff --git a/lib/db/derivedtables/switch.ts b/lib/db/derivedtables/switch.ts index 5730306..111ded7 100644 --- a/lib/db/derivedtables/switch.ts +++ b/lib/db/derivedtables/switch.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -91,6 +92,7 @@ export const switchTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", switch_type: (c as any).subcategory || "", circuit: attrs["Circuit"] || null, diff --git a/lib/db/derivedtables/usb_c_connector.ts b/lib/db/derivedtables/usb_c_connector.ts index 6d7b317..892101c 100644 --- a/lib/db/derivedtables/usb_c_connector.ts +++ b/lib/db/derivedtables/usb_c_connector.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -69,6 +70,7 @@ export const usbCConnectorTableSpec: DerivedTableSpec = { in_stock: Boolean((c.stock || 0) > 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), mounting_style: attrs["Mounting Style"] || null, current_rating_a: parseNum(attrs["Current Rating - Power (Max)"]), diff --git a/lib/db/derivedtables/voltage_regulator.ts b/lib/db/derivedtables/voltage_regulator.ts index 86b0f14..c8b066e 100644 --- a/lib/db/derivedtables/voltage_regulator.ts +++ b/lib/db/derivedtables/voltage_regulator.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -184,6 +185,7 @@ export const voltageRegulatorTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", output_type: outputType, output_voltage_min: voltageMin, diff --git a/lib/db/derivedtables/wifi_module.ts b/lib/db/derivedtables/wifi_module.ts index f56be11..2b69e9a 100644 --- a/lib/db/derivedtables/wifi_module.ts +++ b/lib/db/derivedtables/wifi_module.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import type { DerivedTableSpec } from "./types" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" @@ -140,6 +141,7 @@ export const wifiModuleTableSpec: DerivedTableSpec = { in_stock: c.stock > 0, is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: c.package || "", core_processor: attrs["Core Processor"] || null, antenna_type: attrs["Antenna Type"] || null, diff --git a/lib/db/derivedtables/wire_to_board_connector.ts b/lib/db/derivedtables/wire_to_board_connector.ts index 48a30a6..0b6fad9 100644 --- a/lib/db/derivedtables/wire_to_board_connector.ts +++ b/lib/db/derivedtables/wire_to_board_connector.ts @@ -1,3 +1,4 @@ +import { getIsExtendedPromotional } from "lib/util/component-utils" import { parseAndConvertSiUnit } from "lib/util/parse-and-convert-si-unit" import { extractMinQPrice } from "lib/util/extract-min-quantity-price" import type { BaseComponent } from "./component-base" @@ -100,6 +101,7 @@ export const wireToBoardConnectorTableSpec: DerivedTableSpec 0), is_basic: Boolean(c.basic), is_preferred: Boolean(c.preferred), + is_extended_promotional: getIsExtendedPromotional(c), package: String(c.package || ""), pitch_mm: pitchMm, num_rows: numRows, diff --git a/lib/util/component-utils.ts b/lib/util/component-utils.ts new file mode 100644 index 0000000..c928679 --- /dev/null +++ b/lib/util/component-utils.ts @@ -0,0 +1,40 @@ +export const getIsExtendedPromotional = (component: any): boolean => { + try { + // Logic to determine if a component is "extended promotional" + // Since we don't have direct access to the source DB flags, we check attributes + // or description for hints. + // TODO: Verify exact column/flag in source DB. + + if (!component.extra) return false + + // Check for specific attributes if they exist in the JSON + // The component.extra is a JSON string in some contexts, but here 'component' + // usually refers to the raw row from 'components' table which has 'extra' as string(?). + // But in mapToTable, it's usually already parsed or we parse it. + // Let's assume this function takes the raw component or the parsed attributes. + + // If we look at resistor.ts: + // const extra = JSON.parse(c.extra ?? "{}") + + // We will design this to take the PARSED extra object for safety, + // OR the raw component and do the parsing. + + // Let's look at usage: + // return { ... is_extended_promotional: getIsExtendedPromotional(c /* raw */) } + + const extra = + typeof component.extra === "string" + ? JSON.parse(component.extra) + : component.extra + + if (!extra || !extra.attributes) return false + + // Hypothetical checks: + if (extra.attributes["Promotional Type"] === "Extended") return true + + // Until we know for sure, we return false to ensure the column exists but is empty/default. + return false + } catch (e) { + return false + } +} diff --git a/scripts/setup-derived-tables.ts b/scripts/setup-derived-tables.ts index a700ca2..cad2969 100644 --- a/scripts/setup-derived-tables.ts +++ b/scripts/setup-derived-tables.ts @@ -122,6 +122,7 @@ async function createTable( { name: "stock", type: "integer" }, { name: "price1", type: "real" }, { name: "in_stock", type: "boolean" }, + { name: "is_extended_promotional", type: "boolean" }, ].concat(spec.extraColumns as any, [{ name: "attributes", type: "text" }])) { tableCreator = tableCreator.addColumn( col.name as string,