← back to Dw Material Filter
material writer: metafieldsSet to custom.material_category (non-destructive, GID-aware); purple pilot 548 ok
33c1a1f82b66f2d867b25191ce1a947beba2f91e · 2026-07-16 12:06:41 -0700 · Steve
Files touched
A data/purple-ids.txtA write-material.mjs
Diff
commit 33c1a1f82b66f2d867b25191ce1a947beba2f91e
Author: Steve <steve@designerwallcoverings.com>
Date: Thu Jul 16 12:06:41 2026 -0700
material writer: metafieldsSet to custom.material_category (non-destructive, GID-aware); purple pilot 548 ok
---
data/purple-ids.txt | 1156 +++++++++++++++++++++++++++++++++++++++++++++++++++
write-material.mjs | 80 ++++
2 files changed, 1236 insertions(+)
diff --git a/data/purple-ids.txt b/data/purple-ids.txt
new file mode 100644
index 0000000..c8b81e1
--- /dev/null
+++ b/data/purple-ids.txt
@@ -0,0 +1,1156 @@
+1494829269104
+1495007395952
+1495113826416
+1495224025200
+1495224287344
+1495333077104
+1495333273712
+1495333503088
+1495366402160
+1495367975024
+1495560945776
+1495588339824
+1495590797424
+1495960092784
+1495968120944
+1495977787504
+1496088117360
+1496120066160
+1496141463664
+1496145821808
+1496146182256
+1496147198064
+1496259297392
+1496311431280
+1496315297904
+1496338923632
+1496340922480
+1496444141680
+1496473665648
+1496532582512
+1496535728240
+1496545329264
+1496883495024
+1497064145008
+1497065947248
+1497159073904
+1497188008048
+1497196822640
+1497513853040
+1497518604400
+1497525158000
+1497604423792
+1497618710640
+1497627099248
+1497627983984
+1497667272816
+1497740804208
+1497812467824
+1497952288880
+1498085130352
+1498086834288
+1498114719856
+1498119405680
+1498120355952
+1498120781936
+1498121797744
+1498132152432
+1498260471920
+1498288881776
+1498299891824
+1498301497456
+1498303823984
+1498381910128
+1498727219312
+1498727448688
+1498727645296
+1498728661104
+1498728890480
+1498737868912
+1498739015792
+1498745733232
+1498893844592
+1499037696112
+1499109097584
+1499120009328
+1499157790832
+1499358068848
+1499363115120
+1499368030320
+1499489271920
+1499496185968
+1499722940528
+1501018980464
+1501195206768
+1501380837488
+1501582917744
+1501596549232
+1501668802672
+1502202396784
+1502222057584
+1502227464304
+1502255382640
+1502340808816
+1502406049904
+1502410637424
+1502412275824
+1502448877680
+1502449107056
+1502459592816
+1502459822192
+1502495965296
+1891578675265
+3668537212993
+3668538064961
+3668550418497
+3668551499841
+3740354773057
+3740355723329
+3740356870209
+3740357918785
+3740358377537
+3740358410305
+3740359065665
+3740360081473
+3740361195585
+3740361850945
+3740361883713
+3740361916481
+3951395078209
+3951396618305
+3951396749377
+4320943734835
+4320944554035
+4347268661299
+4395702616115
+4395706089523
+4395707105331
+4396398084147
+4396398182451
+4396398313523
+4396407947315
+4396410961971
+4396411093043
+4396411158579
+4396417220659
+4396422135859
+4466658115635
+4466659459123
+4466668404787
+4466668470323
+4466671157299
+4466671222835
+4466671255603
+4466674335795
+4466688819251
+4466692259891
+4469014691891
+4469014790195
+4469045821491
+4469053718579
+4469054079027
+4469054111795
+4469057814579
+4481152417843
+4484483973171
+4495784575027
+4495856336947
+4495856435251
+4509299048499
+4578109980723
+4693291794483
+4693298544691
+4705839906867
+4731600240691
+6555456864307
+6597466947635
+6597467209779
+6597467242547
+6599297466419
+6599297925171
+6604439420979
+6604440633395
+6604440698931
+6604442009651
+6604442566707
+6604442796083
+6604443222067
+6604444729395
+6604445941811
+6604447350835
+6604447645747
+6604449841203
+6604451774515
+6604452462643
+6604452724787
+6604453412915
+6604453609523
+6604454658099
+6604455051315
+6604455477299
+6604456099891
+6604456362035
+6604457574451
+6604458754099
+6604459343923
+6604459933747
+6604460556339
+6604460687411
+6604460949555
+6604462686259
+6604464422963
+6604464783411
+6604465438771
+6604465668147
+6604465700915
+6604465963059
+6604465995827
+6604467830835
+6604469174323
+6604469469235
+6604470059059
+6604470681651
+6604471205939
+6604471271475
+6604471631923
+6604471828531
+6604474155059
+6604474548275
+6604474744883
+6604475105331
+6604475662387
+6604476317747
+6604476350515
+6604476743731
+6604477694003
+6604477890611
+6604478382131
+6604487131187
+6604487655475
+6604488802355
+6604489982003
+6604490342451
+6604490506291
+6604490768435
+6604491227187
+6604491718707
+6604492734515
+6604493127731
+6604495355955
+6604495749171
+6604497453107
+6604498174003
+6604498370611
+6604498599987
+6604499189811
+6604499386419
+6604500369459
+6604502401075
+6604504498227
+6604504596531
+6604506234931
+6604507381811
+6604507742259
+6604509085747
+6604510822451
+6604512886835
+6604513837107
+6604514197555
+6604515016755
+6604515672115
+6604515934259
+6604516098099
+6604516524083
+6604517474355
+6604518850611
+6604518948915
+6604519374899
+6604519473203
+6604519604275
+6605285064755
+6605285097523
+6605285818419
+6605286146099
+6610836914227
+6611287277619
+6611287506995
+6621005938739
+6668210208819
+6668394659891
+6668394725427
+6668394823731
+6668394987571
+6668395118643
+6668395479091
+6668395741235
+6668395806771
+6668395839539
+6668396593203
+6668396625971
+6668397051955
+6679569727539
+6679570907187
+6679571103795
+6679576117299
+6679576215603
+6679578411059
+6679579557939
+6679580901427
+6679581130803
+6679585226803
+6679585587251
+6679587258419
+6679587520563
+6679589322803
+6679592468531
+6679596269619
+6679596826675
+6679597711411
+6679598792755
+6679603085363
+6679603937331
+6679604068403
+6679606165555
+6679606329395
+6679606427699
+6679606657075
+6679606722611
+6679606919219
+6679606951987
+6679607083059
+6679607476275
+6679607705651
+6679608262707
+6679608328243
+6679609409587
+6679609442355
+6679611834419
+6679611998259
+6679612522547
+6679612555315
+6679614554163
+6679615143987
+6679615930419
+6679616028723
+6679616290867
+6679616946227
+6679617044531
+6679617110067
+6679617142835
+6679623237683
+6679625891891
+6679632543795
+6679632838707
+6679633690675
+6679633756211
+6679644864563
+6679648239667
+6679650992179
+6679651614771
+6679654137907
+6679654858803
+6679663247411
+6679667081267
+6679667179571
+6679668162611
+6679668457523
+6679671799859
+6679671898163
+6679679139891
+6679683891251
+6679684186163
+6679684743219
+6679686217779
+6679688052787
+6679691460659
+6679691755571
+6679691952179
+6679693951027
+6679694802995
+6679701684275
+6679705255987
+6679705583667
+6679708139571
+6679709253683
+6679712268339
+6679713185843
+6679718101043
+6679718395955
+6679719378995
+6679720198195
+6679723376691
+6679724392499
+6679724490803
+6679724589107
+6679724785715
+6679725211699
+6679725998131
+6679726129203
+6679727177779
+6679727210547
+6679727374387
+6679727407155
+6679730159667
+6679733502003
+6679733862451
+6679733895219
+6679738646579
+6679738843187
+6679739990067
+6679741038643
+6679741202483
+6679742119987
+6679742677043
+6679743070259
+6679746412595
+6679748509747
+6679749034035
+6679749328947
+6679750803507
+6679750901811
+6679756374067
+6679756537907
+6679766073395
+6679774920755
+6679779147827
+6679813685299
+6679834198067
+6682333970483
+6682334167091
+6682334199859
+6682335313971
+6685617127475
+6685655924787
+6696631959603
+6702978859059
+6702996914227
+6733036388403
+6752392740915
+6754923151411
+6755352772659
+6755354181683
+6757073289267
+6757074468915
+6757075386419
+6757105008691
+6757161959475
+6761079767091
+6761083207731
+6761450242099
+6761504473139
+6761526951987
+6761532915763
+6761636200499
+6762143383603
+6765338296371
+6769113301043
+6775404855347
+6775795089459
+6790307053619
+6790307086387
+6790307217459
+6796632293427
+6798665220147
+6829037256755
+6829040336947
+6829043286067
+6829093584947
+6884330405939
+6884330962995
+6885843697715
+6927563489331
+6936683249715
+6936683315251
+6936683642931
+6936685183027
+6936693932083
+6936699240499
+6936700026931
+6936700846131
+6936705531955
+6936708415539
+6936708481075
+6936768774195
+6936776900659
+6941804134451
+6941804593203
+6941804724275
+6943885951027
+6944109330483
+6944109363251
+6944109396019
+6944679493683
+6944679559219
+6944692928563
+6944693059635
+6944742801459
+6944743194675
+6944749682739
+6948072161331
+6948075864115
+6948084744243
+6948086939699
+6951136395315
+6951137181747
+6962156306483
+6962157912115
+6962206965811
+6962207326259
+6962208276531
+6962221383731
+6962255265843
+6962302058547
+7236357455923
+7245726777395
+7245727399987
+7245729464371
+7245730775091
+7245735559219
+7252877770803
+7252882161715
+7252883669043
+7252887273523
+7252897103923
+7252897792051
+7273344794675
+7283806699571
+7283809255475
+7283810205747
+7283810566195
+7286641328179
+7292126363699
+7292129443891
+7292131016755
+7292218638387
+7292220276787
+7292221259827
+7292221980723
+7292224569395
+7292228993075
+7292230598707
+7292240756787
+7292244459571
+7292650094643
+7297268973619
+7297291124787
+7297328611379
+7382128066611
+7384902107187
+7384909119539
+7384920064051
+7391684657203
+7391803342899
+7393279803443
+7413449326643
+7413465251891
+7413465579571
+7413508964403
+7413509423155
+7413509554227
+7413515943987
+7413517549619
+7413517713459
+7413522104371
+7413546942515
+7413662416947
+7413666578483
+7413667299379
+7413673492531
+7413690662963
+7413691482163
+7413692170291
+7413697544243
+7413716254771
+7413716713523
+7413718745139
+7413719400499
+7413721464883
+7413724250163
+7413724807219
+7413724872755
+7413730639923
+7413734932531
+7413746565171
+7413754265651
+7414805528627
+7414806708275
+7416203935795
+7416788746291
+7416831934515
+7416832720947
+7416841470003
+7416854052915
+7416862703667
+7416870633523
+7416870764595
+7416872828979
+7416882626611
+7416883413043
+7416883871795
+7416885182515
+7416886427699
+7416891441203
+7416892194867
+7416893243443
+7416916344883
+7416918278195
+7417273483315
+7419491483699
+7419496693811
+7419499249715
+7419504197683
+7419504263219
+7419514650675
+7419514781747
+7419519303731
+7419519402035
+7419519533107
+7419643461683
+7419644149811
+7419648737331
+7419654832179
+7419902984243
+7419903967283
+7420023930931
+7420030320691
+7421205479475
+7421209477171
+7421218652211
+7421219274803
+7421256990771
+7421266362419
+7421275471923
+7421276848179
+7421276946483
+7421279535155
+7421283926067
+7421310173235
+7421312041011
+7421313318963
+7421323968563
+7421324722227
+7421450420275
+7421450453043
+7421451599923
+7421452615731
+7421454876723
+7421456744499
+7421466837043
+7421467066419
+7421478404147
+7421478502451
+7421483909171
+7421484105779
+7421484269619
+7421484826675
+7421485252659
+7421486759987
+7421487185971
+7421488037939
+7421488070707
+7421488300083
+7421488431155
+7421488562227
+7421496328243
+7421500293171
+7421500620851
+7421500719155
+7421500784691
+7421505404979
+7421506519091
+7421854482483
+7421854711859
+7421867851827
+7421869097011
+7421869228083
+7421871489075
+7421876011059
+7421876273203
+7421876764723
+7421880565811
+7421883744307
+7421886627891
+7421889052723
+7421889282099
+7421889773619
+7421890068531
+7421890330675
+7421890494515
+7421892853811
+7421915299891
+7421926309939
+7421948723251
+7421949607987
+7421974609971
+7421982179379
+7421984997427
+7422003052595
+7422010523699
+7422011899955
+7422013308979
+7422014029875
+7422104305715
+7422303207475
+7422305501235
+7422350721075
+7422361010227
+7422396858419
+7422398038067
+7422399709235
+7422409900083
+7422416912435
+7422422155315
+7422432411699
+7422456856627
+7422609752115
+7422610309171
+7422610341939
+7422611095603
+7422628266035
+7422628528179
+7422633148467
+7422636064819
+7422638522419
+7422649040947
+7422758322227
+7422826610739
+7422834180147
+7422849843251
+7422896439347
+7422900535347
+7422901289011
+7422949883955
+7424738164787
+7424740229171
+7424740917299
+7424741605427
+7424741998643
+7424746881075
+7424747110451
+7424747372595
+7424748552243
+7424748585011
+7424752091187
+7424773685299
+7424842072115
+7424842104883
+7424854523955
+7427739582515
+7429008982067
+7429009571891
+7429012127795
+7429087723571
+7429108564019
+7429108826163
+7429994414131
+7430000345139
+7430002933811
+7430003097651
+7430005850163
+7430006767667
+7430007029811
+7430794379315
+7430794608691
+7430802014259
+7433129394227
+7433130082355
+7433428271155
+7433442689075
+7433485746227
+7433520971827
+7471567863859
+7471569240115
+7471569764403
+7471570616371
+7471570780211
+7472050077747
+7472050864179
+7472051191859
+7502396751923
+7502401634355
+7513497174067
+7513497272371
+7513497370675
+7513497698355
+7513498320947
+7513499238451
+7513500713011
+7513502351411
+7513509265459
+7513509462067
+7513509494835
+7513509560371
+7513510346803
+7513511919667
+7513513525299
+7513513885747
+7513514639411
+7513516146739
+7513516245043
+7513516277811
+7513516310579
+7513516998707
+7513517064243
+7513517097011
+7513517588531
+7513518604339
+7513519030323
+7513519095859
+7513519128627
+7513519161395
+7513519194163
+7513520013363
+7513943179315
+7513944621107
+7513944686643
+7513945997363
+7513946030131
+7513946193971
+7513947799603
+7513948487731
+7513948553267
+7513948651571
+7513948848179
+7513949274163
+7513949569075
+7513949995059
+7513950322739
+7513950683187
+7513951830067
+7513951895603
+7513952223283
+7513952878643
+7513953140787
+7513953599539
+7513953796147
+7513954549811
+7513954811955
+7513955500083
+7513955794995
+7513956220979
+7513958481971
+7513958645811
+7513959301171
+7513959530547
+7513959628851
+7513959825459
+7513961070643
+7513961332787
+7513961726003
+7513961791539
+7513962250291
+7514183499827
+7514183761971
+7514183991347
+7514184908851
+7514184974387
+7514185039923
+7514185302067
+7514185629747
+7514187497523
+7514187792435
+7514187857971
+7514188644403
+7514191560755
+7514193952819
+7514195787827
+7514195951667
+7514196082739
+7514198245427
+7514198474803
+7514198507571
+7514199294003
+7514199326771
+7514199490611
+7514199687219
+7514199916595
+7514200014899
+7515272937523
+7515274641459
+7515275198515
+7515275296819
+7515275755571
+7515276771379
+7515276967987
+7515277361203
+7515277426739
+7515277590579
+7515277754419
+7515277787187
+7515278704691
+7515279360051
+7515279818803
+7515279884339
+7515281293363
+7515282309171
+7515283554355
+7515283652659
+7515286143027
+7515286274099
+7515288207411
+7515288305715
+7515288469555
+7515288633395
+7515288698931
+7515288731699
+7515289747507
+7515295449139
+7519949520947
+7519961317427
+7528624717875
+7528625045555
+7529371205683
+7534241742899
+7534250819635
+7548957556787
+7549409820723
+7549409951795
+7549410017331
+7549849960499
+7549850288179
+7549850353715
+7549850583091
+7552671023155
+7552672432179
+7552676790323
+7552677838899
+7552682295347
+7552685015091
+7552697434163
+7552701268019
+7552701890611
+7552715456563
+7552715784243
+7552719585331
+7552720830515
+7552726270003
+7552740950067
+7552742522931
+7582548492339
+7584916340787
+7584926105651
+7584935182387
+7584946126899
+7585002225715
+7589504516147
+7632462610483
+7632462643251
+7632465330227
+7632465657907
+7632465723443
+7632465821747
+7632466706483
+7632468115507
+7632468836403
+7632468901939
+7632468934707
+7632469786675
+7632470376499
+7632470507571
+7634018730035
+7634022760499
+7664462331955
+7664489955379
+7664489988147
+7664490053683
+7664495067187
+7664495394867
+7664496082995
+7664496214067
+7664496312371
+7664496345139
+7664511647795
+7664511909939
+7664512008243
+7664512106547
+7664513024051
+7664513351731
+7664514105395
+7664584327219
+7664584654899
+7664584851507
+7664586620979
+7664590389299
+7664592388147
+7664593338419
+7664593371187
+7664593403955
+7664593436723
+7664593469491
+7664596615219
+7664598057011
+7664598417459
+7664598843443
+7664616243251
+7664617062451
+7664626729011
+7664630956083
+7664639148083
+7664639279155
+7664649699379
+7664650125363
+7664650256435
+7674827440179
+7674830684211
+7691476336691
+7691476369459
+7691477188659
+7692032933939
+7692047908915
+7692049481779
+7692058656819
+7692070158387
+7692077432883
+7699645235251
+7699645366323
+7699645399091
+7700010893363
+7700011089971
+7700020625459
+7700073480243
+7700142981171
+7775012552755
+7775015239731
+7776864862259
+7776883769395
+7776884031539
+7778348597299
+7778348924979
+7778847096883
+7778860695603
+7779661152307
+7780860067891
+7781579456563
+7783123222579
+7784905474099
+7786023157811
+7786563338291
+7786568351795
+7786966057011
+7787007377459
+7787007574067
+7787008000051
+7787415994419
+7787418779699
+7787419762739
+7787420352563
+7787426480179
+7789635731507
+7789645070387
+7791126216755
+7791126904883
+7791127330867
+7791138930739
+7791141650483
+7791142273075
+7792263987251
+7793941577779
+7796254441523
+7796256866355
+7796262305843
+7796275707955
+7796826931251
+7796830568499
+7796833746995
+7796834402355
+7796835188787
+7796835254323
+7796835450931
+7796836991027
+7796837613619
+7796839022643
+7796841414707
+7796841578547
+7796842004531
+7796842168371
+7799387422771
+7799388110899
+7799402561587
+7799450173491
+7799450468403
+7799453941811
+7799836934195
+7799837294643
+7799845650483
+7799854170163
+7799854891059
+7800000610355
+7800003821619
+7800007229491
+7800008015923
+7800009228339
+7800009359411
+7800018534451
+7800018632755
+7800019714099
+7800260919347
+7800461525043
+7800465457203
+7800466964531
+7800467423283
+7800570019891
+7800570544179
+7800571658291
+7800571920435
+7801012617267
+7801015762995
+7801015894067
+7801016156211
+7801328173107
+7801329582131
+7801329680435
+7801847513139
+7802073382963
+7802073514035
+7802074398771
+7810448850995
+7810580414515
+7811698458675
+7811701866547
+7817251782707
+7817258303539
+7817261056051
+7817261449267
+7817261678643
+7817261776947
+7817264955443
+7822324432947
+7822324465715
+7858575147059
+7859481116723
+7859489046579
+7859491438643
+7863632691251
+7863633412147
+7863633969203
+7863634001971
+7863634067507
+7863634100275
+7863635476531
+7863635574835
+7863635607603
+7863635836979
+7863635935283
+7863636000819
+7863636066355
+7863636164659
+7863636361267
+7863637082163
+7863637835827
+7863638327347
+7863638753331
+7863638818867
+7863640227891
+7863640424499
+7863640555571
+7863640981555
+7863641178163
+7863641440307
+7863641604147
+7866875084851
+7867489681459
+7870934220851
+7873257078835
+7873338540083
+7876465033267
+7876503502899
diff --git a/write-material.mjs b/write-material.mjs
new file mode 100644
index 0000000..26253d3
--- /dev/null
+++ b/write-material.mjs
@@ -0,0 +1,80 @@
+#!/usr/bin/env node
+// Write the derived custom.material_category metafield to active products via
+// GraphQL metafieldsSet (25/batch, throttle-aware). NON-DESTRUCTIVE: a brand-new
+// namespace/key — never touches the PDP custom.material composition field.
+// node write-material.mjs --define # create the metafield definition (once)
+// node write-material.mjs --ids <file> # pilot: only shopify_ids listed in <file>
+// node write-material.mjs --all # write the whole plan
+// add --dry to preview counts without writing
+import https from 'node:https';
+import { readFileSync } from 'node:fs';
+
+const env = readFileSync('/Users/macstudio3/Projects/secrets-manager/.env', 'utf8');
+const TOKEN = (env.match(/^SHOPIFY_ADMIN_TOKEN=(.+)$/m) || [])[1].trim();
+const STORE = 'designer-laboratory-sandbox.myshopify.com', API = '2024-10';
+const args = process.argv.slice(2);
+const DRY = args.includes('--dry');
+
+function gql(query, variables) {
+ const body = JSON.stringify({ query, variables });
+ return new Promise((res, rej) => {
+ const r = https.request({ hostname: STORE, path: `/admin/api/${API}/graphql.json`, method: 'POST',
+ headers: { 'Content-Type': 'application/json', 'X-Shopify-Access-Token': TOKEN, 'Content-Length': Buffer.byteLength(body) } },
+ x => { let d = ''; x.on('data', c => d += c); x.on('end', () => { try { res(JSON.parse(d)); } catch (e) { rej(new Error(d.slice(0, 200))); } }); });
+ r.on('error', rej); r.write(body); r.end();
+ });
+}
+const sleep = ms => new Promise(r => setTimeout(r, ms));
+
+async function define() {
+ const q = `mutation($d:MetafieldDefinitionInput!){ metafieldDefinitionCreate(definition:$d){ createdDefinition{ id } userErrors{ code message } } }`;
+ const d = { name: 'Material Category', namespace: 'custom', key: 'material_category',
+ type: 'single_line_text_field', ownerType: 'PRODUCT',
+ description: 'Normalized material for filtering (Grasscloth, Silk, Vinyl, …). Separate from the PDP custom.material composition field.' };
+ const r = await gql(q, { d });
+ const err = r.data?.metafieldDefinitionCreate?.userErrors || [];
+ if (err.length && !err.some(e => e.code === 'TAKEN')) console.log('define userErrors:', err);
+ else console.log('metafield definition custom.material_category ready', err.length ? '(already existed)' : '(created)');
+}
+
+async function writeBatch(items) { // items: [{shopify_id, material}]
+ const metafields = items.map(it => ({
+ ownerId: String(it.shopify_id).startsWith('gid://') ? it.shopify_id : `gid://shopify/Product/${it.shopify_id}`,
+ namespace: 'custom', key: 'material_category', type: 'single_line_text_field', value: it.material }));
+ const q = `mutation($m:[MetafieldsSetInput!]!){ metafieldsSet(metafields:$m){ userErrors{ field message } } }`;
+ for (let attempt = 0; attempt < 5; attempt++) {
+ const r = await gql(q, { m: metafields });
+ if (r.errors && JSON.stringify(r.errors).includes('THROTTLED')) { await sleep(2000 * (attempt + 1)); continue; }
+ const ue = r.data?.metafieldsSet?.userErrors || [];
+ return ue;
+ }
+ return [{ message: 'throttled-giveup' }];
+}
+
+// ---- load plan
+const plan = readFileSync('data/material-plan.jsonl', 'utf8').trim().split('\n').filter(Boolean).map(l => JSON.parse(l));
+let work = plan;
+const idsFlag = args.indexOf('--ids');
+if (idsFlag >= 0) {
+ const wanted = new Set(readFileSync(args[idsFlag + 1], 'utf8').trim().split(/\s+/));
+ const numId = s => String(s).replace(/^.*\//, ''); // numeric tail of a GID
+ work = plan.filter(p => wanted.has(numId(p.shopify_id)));
+ console.log(`pilot: ${work.length} of ${plan.length} plan rows match the id list`);
+}
+if (!args.includes('--all') && idsFlag < 0 && !args.includes('--define')) {
+ console.log('specify --define, --ids <file>, or --all'); process.exit(0);
+}
+
+if (args.includes('--define')) { await define(); if (!args.includes('--all') && idsFlag < 0) process.exit(0); }
+if (DRY) { console.log(`DRY: would write ${work.length} products`); process.exit(0); }
+
+let done = 0, errs = 0;
+for (let i = 0; i < work.length; i += 25) {
+ const batch = work.slice(i, i + 25);
+ const ue = await writeBatch(batch);
+ if (ue.length) { errs += ue.length; if (errs <= 10) console.log('userErrors:', ue.slice(0, 2)); }
+ done += batch.length;
+ if (done % 1000 < 25) console.log(` ${done}/${work.length} written (${errs} errors)`);
+ await sleep(120); // gentle pacing
+}
+console.log(`DONE: ${done} products written, ${errs} errors`);
← 6d0d87c material classifier: derive custom.material_category from ta
·
back to Dw Material Filter
·
chore: lint (token guard), refactor (tighten glass-bead rege 5fc4e0d →