@koda-sl/baker-cli 0.332.0-dev.ecbd884ad → 0.333.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -67,7 +67,7 @@ import {
67
67
  validateCanvasDeep,
68
68
  withoutCastName,
69
69
  ytDlpBlockSignal
70
- } from "./chunk-G3MMW2YJ.js";
70
+ } from "./chunk-FFOURYP5.js";
71
71
  import {
72
72
  csvOrJson,
73
73
  daysAgoIso,
@@ -5919,6 +5919,321 @@ var historyListResponseSchema = z17.object({
5919
5919
 
5920
5920
  // ../api/src/hubspot.ts
5921
5921
  import { z as z18 } from "zod";
5922
+
5923
+ // ../api/src/event-ingest/currency.ts
5924
+ var MINOR_UNITS = {
5925
+ AED: 2,
5926
+ AFN: 2,
5927
+ ALL: 2,
5928
+ AMD: 2,
5929
+ ANG: 2,
5930
+ AOA: 2,
5931
+ ARS: 2,
5932
+ AUD: 2,
5933
+ AWG: 2,
5934
+ AZN: 2,
5935
+ BAM: 2,
5936
+ BBD: 2,
5937
+ BDT: 2,
5938
+ BGN: 2,
5939
+ BHD: 3,
5940
+ BIF: 0,
5941
+ BMD: 2,
5942
+ BND: 2,
5943
+ BOB: 2,
5944
+ BOV: 2,
5945
+ BRL: 2,
5946
+ BSD: 2,
5947
+ BTN: 2,
5948
+ BWP: 2,
5949
+ BYN: 2,
5950
+ BZD: 2,
5951
+ CAD: 2,
5952
+ CDF: 2,
5953
+ CHE: 2,
5954
+ CHF: 2,
5955
+ CHW: 2,
5956
+ CLF: 4,
5957
+ CLP: 0,
5958
+ CNY: 2,
5959
+ COP: 2,
5960
+ COU: 4,
5961
+ CRC: 2,
5962
+ CUP: 2,
5963
+ CVE: 2,
5964
+ CZK: 2,
5965
+ DJF: 0,
5966
+ DKK: 2,
5967
+ DOP: 2,
5968
+ DZD: 2,
5969
+ EGP: 2,
5970
+ ERN: 2,
5971
+ ETB: 2,
5972
+ EUR: 2,
5973
+ FJD: 2,
5974
+ FKP: 2,
5975
+ GBP: 2,
5976
+ GEL: 2,
5977
+ GHS: 2,
5978
+ GIP: 2,
5979
+ GMD: 2,
5980
+ GNF: 0,
5981
+ GTQ: 2,
5982
+ GYD: 2,
5983
+ HKD: 2,
5984
+ HNL: 2,
5985
+ HTG: 2,
5986
+ HUF: 2,
5987
+ IDR: 2,
5988
+ ILS: 2,
5989
+ INR: 2,
5990
+ IQD: 3,
5991
+ IRR: 2,
5992
+ ISK: 0,
5993
+ JMD: 2,
5994
+ JOD: 3,
5995
+ JPY: 0,
5996
+ KES: 2,
5997
+ KGS: 2,
5998
+ KHR: 2,
5999
+ KMF: 0,
6000
+ KPW: 2,
6001
+ KRW: 0,
6002
+ KWD: 3,
6003
+ KYD: 2,
6004
+ KZT: 2,
6005
+ LAK: 2,
6006
+ LBP: 2,
6007
+ LKR: 2,
6008
+ LRD: 2,
6009
+ LSL: 2,
6010
+ LYD: 3,
6011
+ MAD: 2,
6012
+ MDL: 2,
6013
+ MGA: 2,
6014
+ MKD: 2,
6015
+ MMK: 2,
6016
+ MNT: 2,
6017
+ MOP: 2,
6018
+ MRU: 2,
6019
+ MUR: 2,
6020
+ MVR: 2,
6021
+ MWK: 2,
6022
+ MXN: 2,
6023
+ MXV: 2,
6024
+ MYR: 2,
6025
+ MZN: 2,
6026
+ NAD: 2,
6027
+ NGN: 2,
6028
+ NIO: 2,
6029
+ NOK: 2,
6030
+ NPR: 2,
6031
+ NZD: 2,
6032
+ OMR: 3,
6033
+ PAB: 2,
6034
+ PEN: 2,
6035
+ PGK: 2,
6036
+ PHP: 2,
6037
+ PKR: 2,
6038
+ PLN: 2,
6039
+ PYG: 0,
6040
+ QAR: 2,
6041
+ RON: 2,
6042
+ RSD: 2,
6043
+ RUB: 2,
6044
+ RWF: 0,
6045
+ SAR: 2,
6046
+ SBD: 2,
6047
+ SCR: 2,
6048
+ SDG: 2,
6049
+ SEK: 2,
6050
+ SGD: 2,
6051
+ SHP: 2,
6052
+ SLE: 2,
6053
+ SOS: 2,
6054
+ SRD: 2,
6055
+ SSP: 2,
6056
+ STN: 2,
6057
+ SVC: 2,
6058
+ SYP: 2,
6059
+ SZL: 2,
6060
+ THB: 2,
6061
+ TJS: 2,
6062
+ TMT: 2,
6063
+ TND: 3,
6064
+ TOP: 2,
6065
+ TRY: 2,
6066
+ TTD: 2,
6067
+ TWD: 2,
6068
+ TZS: 2,
6069
+ UAH: 2,
6070
+ UGX: 0,
6071
+ USD: 2,
6072
+ USN: 2,
6073
+ UYI: 0,
6074
+ UYU: 2,
6075
+ UYW: 4,
6076
+ UZS: 2,
6077
+ VED: 2,
6078
+ VES: 2,
6079
+ VND: 0,
6080
+ VUV: 0,
6081
+ WST: 2,
6082
+ XAF: 0,
6083
+ XAG: 0,
6084
+ XAU: 0,
6085
+ XBA: 0,
6086
+ XBB: 0,
6087
+ XBC: 0,
6088
+ XBD: 0,
6089
+ XCD: 2,
6090
+ XCG: 2,
6091
+ XDR: 0,
6092
+ XOF: 0,
6093
+ XPD: 0,
6094
+ XPF: 0,
6095
+ XPT: 0,
6096
+ XSU: 0,
6097
+ XTS: 0,
6098
+ XUA: 0,
6099
+ XXX: 0,
6100
+ YER: 2,
6101
+ ZAR: 2,
6102
+ ZMW: 2,
6103
+ ZWG: 2,
6104
+ // Withdrawn recently enough that a client's CRM still carries them. Accepting
6105
+ // a code that was legal tender last year costs nothing; rejecting a real
6106
+ // historical `won` costs the client a reconciliation they cannot fix.
6107
+ SLL: 2,
6108
+ ZWL: 2,
6109
+ CUC: 2,
6110
+ HRK: 2
6111
+ };
6112
+ var ISO_4217_CODES = new Set(Object.keys(MINOR_UNITS));
6113
+
6114
+ // ../api/src/event-ingest/names.ts
6115
+ var STANDARD_EVENT_NAMES = [
6116
+ { name: "page_view", means: "A page was served somewhere Baker does not run." },
6117
+ { name: "view_content", means: "Someone looked at a specific thing \u2014 a listing, a property, an article." },
6118
+ { name: "lead", means: "Someone became a lead: they handed over a way to reach them." },
6119
+ { name: "contact", means: "Someone got in touch \u2014 a call, a chat, an email in." },
6120
+ { name: "schedule", means: "A meeting, viewing or call was booked." },
6121
+ { name: "sign_up", means: "An account was created." },
6122
+ { name: "start_trial", means: "A trial began." },
6123
+ { name: "subscribe", means: "A subscription started." },
6124
+ { name: "qualified_lead", means: "Sales judged the lead worth working. The first event only you can send." },
6125
+ { name: "opportunity", means: "A deal was opened against the lead." },
6126
+ { name: "deal_won", means: "The deal closed. Send the money on it." },
6127
+ { name: "deal_lost", means: "The deal was lost. Send it \u2014 a campaign that only reports wins reads as free." },
6128
+ { name: "purchase", means: "Something was paid for. Send the money on it." },
6129
+ { name: "refund", means: "Money went back. A separate event, never a negative amount." }
6130
+ ];
6131
+
6132
+ // ../api/src/event-ingest/validation.ts
6133
+ var REJECTION_CODES = [
6134
+ "invalid_event_id",
6135
+ "invalid_name",
6136
+ "missing_identity",
6137
+ "invalid_timestamp",
6138
+ "invalid_value",
6139
+ "batch_too_large"
6140
+ ];
6141
+ var EVENT_INGEST_BATCH_MAX = 500;
6142
+ var EVENT_INGEST_BODY_MAX_BYTES = 8 * 1024 * 1024;
6143
+ var EVENT_INGEST_REQUESTS_PER_MINUTE = 60;
6144
+ var FUTURE_TOLERANCE_MS = 5 * 6e4;
6145
+ var MAX_EVENT_NAME = 80;
6146
+ var EVENT_NAME = /^[\p{L}\p{N}][\p{L}\p{M}\p{N} ._-]*$/u;
6147
+ function validateEventName(name) {
6148
+ const value = typeof name === "string" ? name.trim() : "";
6149
+ if (value === "" || value.length > MAX_EVENT_NAME || !EVENT_NAME.test(value)) return "invalid_name";
6150
+ return null;
6151
+ }
6152
+ var REJECTION_MESSAGES = {
6153
+ invalid_event_id: "event_id, when sent, must be 1-128 characters of A-Z a-z 0-9 . _ : -",
6154
+ invalid_name: "event_name is required: up to 80 characters of letters (any language), digits, spaces, . _ and -, starting with a letter or a digit",
6155
+ missing_identity: "user_data named nobody, and no url named a page",
6156
+ invalid_timestamp: "event_time must be an ISO-8601 instant with an offset or Unix seconds, and not in the future",
6157
+ invalid_value: "value and currency go together: a non-negative decimal and an ISO-4217 code",
6158
+ batch_too_large: `a request carries at most ${EVENT_INGEST_BATCH_MAX} events and ${EVENT_INGEST_BODY_MAX_BYTES / (1024 * 1024)} MB`
6159
+ };
6160
+
6161
+ // ../api/src/event-sources/hubspotTrigger.ts
6162
+ var HUBSPOT_PROPERTY_KINDS = ["string", "number", "date", "boolean", "select"];
6163
+ var EMPTY = [
6164
+ { value: "isEmpty", label: "is empty", hubspotLabel: "is unknown", arity: "none" },
6165
+ { value: "isNotEmpty", label: "is not empty", hubspotLabel: "is known", arity: "none" }
6166
+ ];
6167
+ var HUBSPOT_OPERATORS = {
6168
+ string: [
6169
+ { value: "is", label: "is", hubspotLabel: "is equal to", arity: "one" },
6170
+ { value: "isNot", label: "is not", hubspotLabel: "is not equal to", arity: "one" },
6171
+ { value: "contains", label: "contains", hubspotLabel: "contains", arity: "one" },
6172
+ { value: "doesNotContain", label: "does not contain", hubspotLabel: "doesn't contain", arity: "one" },
6173
+ { value: "startsWith", label: "starts with", hubspotLabel: "starts with", arity: "one" },
6174
+ { value: "endsWith", label: "ends with", hubspotLabel: "ends with", arity: "one" },
6175
+ ...EMPTY
6176
+ ],
6177
+ number: [
6178
+ { value: "equal", label: "=", hubspotLabel: "is equal to", arity: "one" },
6179
+ { value: "notEqual", label: "\u2260", hubspotLabel: "is not equal to", arity: "one" },
6180
+ { value: "lessThan", label: "<", hubspotLabel: "is less than", arity: "one" },
6181
+ { value: "lessThanOrEqual", label: "\u2264", hubspotLabel: "is less than or equal to", arity: "one" },
6182
+ { value: "greaterThan", label: ">", hubspotLabel: "is greater than", arity: "one" },
6183
+ { value: "greaterThanOrEqual", label: "\u2265", hubspotLabel: "is greater than or equal to", arity: "one" },
6184
+ ...EMPTY
6185
+ ],
6186
+ date: [
6187
+ { value: "is", label: "is", hubspotLabel: "is equal to", arity: "one" },
6188
+ { value: "isBefore", label: "is before", hubspotLabel: "is before", arity: "one" },
6189
+ { value: "isAfter", label: "is after", hubspotLabel: "is after", arity: "one" },
6190
+ { value: "isOnOrBefore", label: "is on or before", hubspotLabel: "is on or before", arity: "one" },
6191
+ { value: "isOnOrAfter", label: "is on or after", hubspotLabel: "is on or after", arity: "one" },
6192
+ { value: "isBetween", label: "is between", hubspotLabel: "is between", arity: "two" },
6193
+ ...EMPTY
6194
+ ],
6195
+ boolean: [
6196
+ { value: "is", label: "is", hubspotLabel: "is equal to", arity: "one" },
6197
+ { value: "isNot", label: "is not", hubspotLabel: "is not equal to", arity: "one" }
6198
+ ],
6199
+ select: [
6200
+ { value: "is", label: "is", hubspotLabel: "is any of", arity: "many" },
6201
+ { value: "isNot", label: "is not", hubspotLabel: "is none of", arity: "many" },
6202
+ ...EMPTY
6203
+ ]
6204
+ };
6205
+ var CONDITION_LOGICS = ["And", "Or"];
6206
+ var TRIGGER_CONDITIONS_MAX = 10;
6207
+ function isConditionGroup(item) {
6208
+ return "logic" in item && "conditions" in item && Array.isArray(item.conditions);
6209
+ }
6210
+ function onlyCondition(condition) {
6211
+ return { logic: "And", conditions: [condition] };
6212
+ }
6213
+ function triggerConditions(trigger) {
6214
+ return trigger.conditions.flatMap((item) => isConditionGroup(item) ? item.conditions : [item]);
6215
+ }
6216
+ function triggerProblem(trigger) {
6217
+ if (trigger.conditions.length === 0) return "A trigger needs at least one condition.";
6218
+ for (const item of trigger.conditions) {
6219
+ if (!isConditionGroup(item)) continue;
6220
+ if (item.conditions.length === 0) return "A group needs at least one condition.";
6221
+ if (item.conditions.some((inner) => isConditionGroup(inner))) {
6222
+ return "Groups go one level deep, as in a Form's filter: a group cannot hold another group.";
6223
+ }
6224
+ }
6225
+ if (triggerConditions(trigger).length > TRIGGER_CONDITIONS_MAX) {
6226
+ return `A trigger takes at most ${TRIGGER_CONDITIONS_MAX} conditions.`;
6227
+ }
6228
+ return null;
6229
+ }
6230
+ var HUBSPOT_OBJECTS = ["contact", "deal", "lead"];
6231
+ var HUBSPOT_DEAL_CONTACTS = ["first", "every"];
6232
+ function readsAssociatedContact(object) {
6233
+ return object !== "contact";
6234
+ }
6235
+
6236
+ // ../api/src/hubspot.ts
5922
6237
  var hubspotEmbedTypeSchema = z18.enum(["legacy", "v4", "unknown"]);
5923
6238
  var hubspotPostSubmitActionSchema = z18.object({
5924
6239
  type: z18.enum(["redirect_url", "thank_you"]),
@@ -6161,7 +6476,7 @@ var hubspotContactLookupResponseSchema = z18.object({
6161
6476
  companyReadable: z18.boolean()
6162
6477
  })
6163
6478
  });
6164
- var hubspotObjectRequestSchema = z18.enum(["contact", "deal"]).default("contact");
6479
+ var hubspotObjectRequestSchema = z18.enum(HUBSPOT_OBJECTS).default("contact");
6165
6480
  var hubspotContactPropertiesListRequestSchema = z18.object({ object: hubspotObjectRequestSchema });
6166
6481
  var hubspotContactPropertyOptionSchema = z18.object({
6167
6482
  value: z18.string(),
@@ -29546,244 +29861,6 @@ function eventSourceCurl(url) {
29546
29861
  return [`curl -X POST ${url} \\`, ` -H 'Content-Type: application/json' \\`, ` -d '${body}'`].join("\n");
29547
29862
  }
29548
29863
 
29549
- // ../api/src/event-ingest/currency.ts
29550
- var MINOR_UNITS = {
29551
- AED: 2,
29552
- AFN: 2,
29553
- ALL: 2,
29554
- AMD: 2,
29555
- ANG: 2,
29556
- AOA: 2,
29557
- ARS: 2,
29558
- AUD: 2,
29559
- AWG: 2,
29560
- AZN: 2,
29561
- BAM: 2,
29562
- BBD: 2,
29563
- BDT: 2,
29564
- BGN: 2,
29565
- BHD: 3,
29566
- BIF: 0,
29567
- BMD: 2,
29568
- BND: 2,
29569
- BOB: 2,
29570
- BOV: 2,
29571
- BRL: 2,
29572
- BSD: 2,
29573
- BTN: 2,
29574
- BWP: 2,
29575
- BYN: 2,
29576
- BZD: 2,
29577
- CAD: 2,
29578
- CDF: 2,
29579
- CHE: 2,
29580
- CHF: 2,
29581
- CHW: 2,
29582
- CLF: 4,
29583
- CLP: 0,
29584
- CNY: 2,
29585
- COP: 2,
29586
- COU: 4,
29587
- CRC: 2,
29588
- CUP: 2,
29589
- CVE: 2,
29590
- CZK: 2,
29591
- DJF: 0,
29592
- DKK: 2,
29593
- DOP: 2,
29594
- DZD: 2,
29595
- EGP: 2,
29596
- ERN: 2,
29597
- ETB: 2,
29598
- EUR: 2,
29599
- FJD: 2,
29600
- FKP: 2,
29601
- GBP: 2,
29602
- GEL: 2,
29603
- GHS: 2,
29604
- GIP: 2,
29605
- GMD: 2,
29606
- GNF: 0,
29607
- GTQ: 2,
29608
- GYD: 2,
29609
- HKD: 2,
29610
- HNL: 2,
29611
- HTG: 2,
29612
- HUF: 2,
29613
- IDR: 2,
29614
- ILS: 2,
29615
- INR: 2,
29616
- IQD: 3,
29617
- IRR: 2,
29618
- ISK: 0,
29619
- JMD: 2,
29620
- JOD: 3,
29621
- JPY: 0,
29622
- KES: 2,
29623
- KGS: 2,
29624
- KHR: 2,
29625
- KMF: 0,
29626
- KPW: 2,
29627
- KRW: 0,
29628
- KWD: 3,
29629
- KYD: 2,
29630
- KZT: 2,
29631
- LAK: 2,
29632
- LBP: 2,
29633
- LKR: 2,
29634
- LRD: 2,
29635
- LSL: 2,
29636
- LYD: 3,
29637
- MAD: 2,
29638
- MDL: 2,
29639
- MGA: 2,
29640
- MKD: 2,
29641
- MMK: 2,
29642
- MNT: 2,
29643
- MOP: 2,
29644
- MRU: 2,
29645
- MUR: 2,
29646
- MVR: 2,
29647
- MWK: 2,
29648
- MXN: 2,
29649
- MXV: 2,
29650
- MYR: 2,
29651
- MZN: 2,
29652
- NAD: 2,
29653
- NGN: 2,
29654
- NIO: 2,
29655
- NOK: 2,
29656
- NPR: 2,
29657
- NZD: 2,
29658
- OMR: 3,
29659
- PAB: 2,
29660
- PEN: 2,
29661
- PGK: 2,
29662
- PHP: 2,
29663
- PKR: 2,
29664
- PLN: 2,
29665
- PYG: 0,
29666
- QAR: 2,
29667
- RON: 2,
29668
- RSD: 2,
29669
- RUB: 2,
29670
- RWF: 0,
29671
- SAR: 2,
29672
- SBD: 2,
29673
- SCR: 2,
29674
- SDG: 2,
29675
- SEK: 2,
29676
- SGD: 2,
29677
- SHP: 2,
29678
- SLE: 2,
29679
- SOS: 2,
29680
- SRD: 2,
29681
- SSP: 2,
29682
- STN: 2,
29683
- SVC: 2,
29684
- SYP: 2,
29685
- SZL: 2,
29686
- THB: 2,
29687
- TJS: 2,
29688
- TMT: 2,
29689
- TND: 3,
29690
- TOP: 2,
29691
- TRY: 2,
29692
- TTD: 2,
29693
- TWD: 2,
29694
- TZS: 2,
29695
- UAH: 2,
29696
- UGX: 0,
29697
- USD: 2,
29698
- USN: 2,
29699
- UYI: 0,
29700
- UYU: 2,
29701
- UYW: 4,
29702
- UZS: 2,
29703
- VED: 2,
29704
- VES: 2,
29705
- VND: 0,
29706
- VUV: 0,
29707
- WST: 2,
29708
- XAF: 0,
29709
- XAG: 0,
29710
- XAU: 0,
29711
- XBA: 0,
29712
- XBB: 0,
29713
- XBC: 0,
29714
- XBD: 0,
29715
- XCD: 2,
29716
- XCG: 2,
29717
- XDR: 0,
29718
- XOF: 0,
29719
- XPD: 0,
29720
- XPF: 0,
29721
- XPT: 0,
29722
- XSU: 0,
29723
- XTS: 0,
29724
- XUA: 0,
29725
- XXX: 0,
29726
- YER: 2,
29727
- ZAR: 2,
29728
- ZMW: 2,
29729
- ZWG: 2,
29730
- // Withdrawn recently enough that a client's CRM still carries them. Accepting
29731
- // a code that was legal tender last year costs nothing; rejecting a real
29732
- // historical `won` costs the client a reconciliation they cannot fix.
29733
- SLL: 2,
29734
- ZWL: 2,
29735
- CUC: 2,
29736
- HRK: 2
29737
- };
29738
- var ISO_4217_CODES = new Set(Object.keys(MINOR_UNITS));
29739
-
29740
- // ../api/src/event-ingest/names.ts
29741
- var STANDARD_EVENT_NAMES = [
29742
- { name: "page_view", means: "A page was served somewhere Baker does not run." },
29743
- { name: "view_content", means: "Someone looked at a specific thing \u2014 a listing, a property, an article." },
29744
- { name: "lead", means: "Someone became a lead: they handed over a way to reach them." },
29745
- { name: "contact", means: "Someone got in touch \u2014 a call, a chat, an email in." },
29746
- { name: "schedule", means: "A meeting, viewing or call was booked." },
29747
- { name: "sign_up", means: "An account was created." },
29748
- { name: "start_trial", means: "A trial began." },
29749
- { name: "subscribe", means: "A subscription started." },
29750
- { name: "qualified_lead", means: "Sales judged the lead worth working. The first event only you can send." },
29751
- { name: "opportunity", means: "A deal was opened against the lead." },
29752
- { name: "deal_won", means: "The deal closed. Send the money on it." },
29753
- { name: "deal_lost", means: "The deal was lost. Send it \u2014 a campaign that only reports wins reads as free." },
29754
- { name: "purchase", means: "Something was paid for. Send the money on it." },
29755
- { name: "refund", means: "Money went back. A separate event, never a negative amount." }
29756
- ];
29757
-
29758
- // ../api/src/event-ingest/validation.ts
29759
- var REJECTION_CODES = [
29760
- "invalid_event_id",
29761
- "invalid_name",
29762
- "missing_identity",
29763
- "invalid_timestamp",
29764
- "invalid_value",
29765
- "batch_too_large"
29766
- ];
29767
- var EVENT_INGEST_BATCH_MAX = 500;
29768
- var EVENT_INGEST_BODY_MAX_BYTES = 8 * 1024 * 1024;
29769
- var EVENT_INGEST_REQUESTS_PER_MINUTE = 60;
29770
- var FUTURE_TOLERANCE_MS = 5 * 6e4;
29771
- var MAX_EVENT_NAME = 80;
29772
- var EVENT_NAME = /^[\p{L}\p{N}][\p{L}\p{M}\p{N} ._-]*$/u;
29773
- function validateEventName(name) {
29774
- const value = typeof name === "string" ? name.trim() : "";
29775
- if (value === "" || value.length > MAX_EVENT_NAME || !EVENT_NAME.test(value)) return "invalid_name";
29776
- return null;
29777
- }
29778
- var REJECTION_MESSAGES = {
29779
- invalid_event_id: "event_id, when sent, must be 1-128 characters of A-Z a-z 0-9 . _ : -",
29780
- invalid_name: "event_name is required: up to 80 characters of letters (any language), digits, spaces, . _ and -, starting with a letter or a digit",
29781
- missing_identity: "user_data named nobody, and no url named a page",
29782
- invalid_timestamp: "event_time must be an ISO-8601 instant with an offset or Unix seconds, and not in the future",
29783
- invalid_value: "value and currency go together: a non-negative decimal and an ISO-4217 code",
29784
- batch_too_large: `a request carries at most ${EVENT_INGEST_BATCH_MAX} events and ${EVENT_INGEST_BODY_MAX_BYTES / (1024 * 1024)} MB`
29785
- };
29786
-
29787
29864
  // ../api/src/event-ingest/fields.ts
29788
29865
  var BODY_MAX_MB = EVENT_INGEST_BODY_MAX_BYTES / (1024 * 1024);
29789
29866
  var FUTURE_TOLERANCE_MINUTES = FUTURE_TOLERANCE_MS / 6e4;
@@ -31671,16 +31748,19 @@ var HUBSPOT_DEFAULT_PROPERTIES = {
31671
31748
  gclid: "hs_google_click_id",
31672
31749
  fbclid: "hs_facebook_click_id"
31673
31750
  };
31751
+ var throughContact = Object.fromEntries(
31752
+ Object.entries(HUBSPOT_DEFAULT_PROPERTIES).map(([field, property]) => [field, contactPath(property)])
31753
+ );
31674
31754
  var HUBSPOT_DEAL_DEFAULT_PROPERTIES = {
31675
- ...Object.fromEntries(
31676
- Object.entries(HUBSPOT_DEFAULT_PROPERTIES).map(([field, property]) => [field, contactPath(property)])
31677
- ),
31755
+ ...throughContact,
31678
31756
  value: "amount",
31679
31757
  currency: "deal_currency_code"
31680
31758
  };
31759
+ var HUBSPOT_LEAD_DEFAULT_PROPERTIES = throughContact;
31681
31760
  var DEFAULTS = {
31682
31761
  contact: HUBSPOT_DEFAULT_PROPERTIES,
31683
- deal: HUBSPOT_DEAL_DEFAULT_PROPERTIES
31762
+ deal: HUBSPOT_DEAL_DEFAULT_PROPERTIES,
31763
+ lead: HUBSPOT_LEAD_DEFAULT_PROPERTIES
31684
31764
  };
31685
31765
  function hubspotDefaultMapping(sourceName, object = "contact") {
31686
31766
  const mapping = { event_name: sourceName };
@@ -31690,78 +31770,6 @@ function hubspotDefaultMapping(sourceName, object = "contact") {
31690
31770
  return mapping;
31691
31771
  }
31692
31772
 
31693
- // ../api/src/event-sources/hubspotTrigger.ts
31694
- var HUBSPOT_PROPERTY_KINDS = ["string", "number", "date", "boolean", "select"];
31695
- var EMPTY = [
31696
- { value: "isEmpty", label: "is empty", hubspotLabel: "is unknown", arity: "none" },
31697
- { value: "isNotEmpty", label: "is not empty", hubspotLabel: "is known", arity: "none" }
31698
- ];
31699
- var HUBSPOT_OPERATORS = {
31700
- string: [
31701
- { value: "is", label: "is", hubspotLabel: "is equal to", arity: "one" },
31702
- { value: "isNot", label: "is not", hubspotLabel: "is not equal to", arity: "one" },
31703
- { value: "contains", label: "contains", hubspotLabel: "contains", arity: "one" },
31704
- { value: "doesNotContain", label: "does not contain", hubspotLabel: "doesn't contain", arity: "one" },
31705
- { value: "startsWith", label: "starts with", hubspotLabel: "starts with", arity: "one" },
31706
- { value: "endsWith", label: "ends with", hubspotLabel: "ends with", arity: "one" },
31707
- ...EMPTY
31708
- ],
31709
- number: [
31710
- { value: "equal", label: "=", hubspotLabel: "is equal to", arity: "one" },
31711
- { value: "notEqual", label: "\u2260", hubspotLabel: "is not equal to", arity: "one" },
31712
- { value: "lessThan", label: "<", hubspotLabel: "is less than", arity: "one" },
31713
- { value: "lessThanOrEqual", label: "\u2264", hubspotLabel: "is less than or equal to", arity: "one" },
31714
- { value: "greaterThan", label: ">", hubspotLabel: "is greater than", arity: "one" },
31715
- { value: "greaterThanOrEqual", label: "\u2265", hubspotLabel: "is greater than or equal to", arity: "one" },
31716
- ...EMPTY
31717
- ],
31718
- date: [
31719
- { value: "is", label: "is", hubspotLabel: "is equal to", arity: "one" },
31720
- { value: "isBefore", label: "is before", hubspotLabel: "is before", arity: "one" },
31721
- { value: "isAfter", label: "is after", hubspotLabel: "is after", arity: "one" },
31722
- { value: "isOnOrBefore", label: "is on or before", hubspotLabel: "is on or before", arity: "one" },
31723
- { value: "isOnOrAfter", label: "is on or after", hubspotLabel: "is on or after", arity: "one" },
31724
- { value: "isBetween", label: "is between", hubspotLabel: "is between", arity: "two" },
31725
- ...EMPTY
31726
- ],
31727
- boolean: [
31728
- { value: "is", label: "is", hubspotLabel: "is equal to", arity: "one" },
31729
- { value: "isNot", label: "is not", hubspotLabel: "is not equal to", arity: "one" }
31730
- ],
31731
- select: [
31732
- { value: "is", label: "is", hubspotLabel: "is any of", arity: "many" },
31733
- { value: "isNot", label: "is not", hubspotLabel: "is none of", arity: "many" },
31734
- ...EMPTY
31735
- ]
31736
- };
31737
- var CONDITION_LOGICS = ["And", "Or"];
31738
- var TRIGGER_CONDITIONS_MAX = 10;
31739
- function isConditionGroup(item) {
31740
- return "logic" in item && "conditions" in item && Array.isArray(item.conditions);
31741
- }
31742
- function onlyCondition(condition) {
31743
- return { logic: "And", conditions: [condition] };
31744
- }
31745
- function triggerConditions(trigger) {
31746
- return trigger.conditions.flatMap((item) => isConditionGroup(item) ? item.conditions : [item]);
31747
- }
31748
- function triggerProblem(trigger) {
31749
- if (trigger.conditions.length === 0) return "A trigger needs at least one condition.";
31750
- for (const item of trigger.conditions) {
31751
- if (!isConditionGroup(item)) continue;
31752
- if (item.conditions.length === 0) return "A group needs at least one condition.";
31753
- if (item.conditions.some((inner) => isConditionGroup(inner))) {
31754
- return "Groups go one level deep, as in a Form's filter: a group cannot hold another group.";
31755
- }
31756
- }
31757
- if (triggerConditions(trigger).length > TRIGGER_CONDITIONS_MAX) {
31758
- return `A trigger takes at most ${TRIGGER_CONDITIONS_MAX} conditions.`;
31759
- }
31760
- return null;
31761
- }
31762
- var HUBSPOT_OBJECTS = ["contact", "deal"];
31763
- var HUBSPOT_DEAL_CONTACTS = ["first", "every"];
31764
-
31765
31773
  // ../api/src/event-sources/wire.ts
31766
31774
  import { z as z37 } from "zod";
31767
31775
  var SOURCE_KINDS = ["webhook", "hubspot"];
@@ -31825,9 +31833,9 @@ var sampleRecordSchema = z37.strictObject({ id: z37.string(), properties: z37.re
31825
31833
  var hubspotPreviewRequestSchema = z37.strictObject({
31826
31834
  object: hubspotObjectSchema.default("contact"),
31827
31835
  trigger: hubspotTriggerInputSchema,
31828
- /** Property names to read off the sample; `id` is always there. On a deal, `contact.<name>` reads its first contact. */
31836
+ /** Property names to read off the sample; `id` is always there. On a deal or a lead, `contact.<name>` reads its first contact. */
31829
31837
  properties: z37.array(z37.string().trim().min(1)).max(60).optional(),
31830
- /** The record to draw the preview from — an id, or text to search (an email or a name for a contact, a deal's name). The one most recently at the trigger when unsaid. */
31838
+ /** The record to draw the preview from — an id, or text to search (an email or a name for a contact, a deal's or a lead's name). The one most recently at the trigger when unsaid. */
31831
31839
  contact: z37.string().trim().min(1).max(200).optional()
31832
31840
  });
31833
31841
  var hubspotPreviewSchema = z37.strictObject({
@@ -31835,10 +31843,16 @@ var hubspotPreviewSchema = z37.strictObject({
31835
31843
  total: z37.number(),
31836
31844
  /** False when the trigger has more combinations than HubSpot's search takes, so `total` is only near. */
31837
31845
  exact: z37.boolean().optional(),
31838
- /** The sample contact, with the properties asked for; none when nobody fits, or when the trigger is on a deal. */
31839
- contact: sampleRecordSchema.nullable(),
31840
- /** The sample deal, with the contacts on it (first first); none when no deal fits, or when the trigger is on a contact. */
31841
- deal: sampleRecordSchema.extend({ contacts: z37.array(sampleRecordSchema) }).nullable().optional()
31846
+ /**
31847
+ * The sample record the trigger is on, with the properties asked for and
31848
+ * the contacts behind it, first first; none when nothing fits.
31849
+ *
31850
+ * One field rather than one per object: a contact source's record *is* the
31851
+ * person and its `contacts` is empty, while a deal's and a lead's carry the
31852
+ * people the event is about. Three parallel nullable fields, exactly one of
31853
+ * them ever set, would say the same thing and let a caller read the wrong one.
31854
+ */
31855
+ record: sampleRecordSchema.extend({ contacts: z37.array(sampleRecordSchema) }).nullable()
31842
31856
  });
31843
31857
  var sourcesRequestSchema = z37.strictObject({
31844
31858
  /** The company's own server door: made once, `counting` from the start, the same address for ever after. */
@@ -31847,7 +31861,7 @@ var sourcesRequestSchema = z37.strictObject({
31847
31861
  /** A HubSpot event: read every five minutes, counting from now. The labels are looked up server-side. */
31848
31862
  createHubspot: z37.strictObject({
31849
31863
  name: sourceNameSchema.optional(),
31850
- /** A contact, or a deal. A deal's event is about its contact, read through `contact.<property>` rows. */
31864
+ /** A contact, a deal or a lead. A deal's and a lead's event is about its contact, read through `contact.<property>` rows. */
31851
31865
  object: hubspotObjectSchema.default("contact"),
31852
31866
  trigger: hubspotTriggerInputSchema,
31853
31867
  /** On a deal: the deal's first contact (the default), or every contact on it, each its own event. */
@@ -32061,17 +32075,17 @@ var args3 = {
32061
32075
  },
32062
32076
  object: {
32063
32077
  type: "string",
32064
- description: "With --create-hubspot or --preview: what the trigger is on \u2014 `contact` (the default) or `deal`. A deal's event is about the contact the deal is associated with: its rows read the deal's own properties bare ({{amount}}, {{dealstage}}) and the contact's as {{contact.<name>}} (`baker hubspot deals fields`); the amount defaults to the deal's amount in its currency",
32078
+ description: "With --create-hubspot or --preview: what the trigger is on \u2014 `contact` (the default), `deal` or `lead`. A deal's and a lead's event is about the contact the record is associated with: its rows read the record's own properties bare ({{amount}}, {{dealstage}}, {{hs_pipeline_stage}}) and the contact's as {{contact.<name>}} (`baker hubspot deals fields` / `baker hubspot leads fields`). A deal's amount defaults to its own amount in its currency; a lead has none, so it counts the step rather than money. Use `lead` for qualification and disqualification \u2014 HubSpot records both as a lead stage, and nothing on the contact or the deal says a lead was disqualified",
32065
32079
  required: false
32066
32080
  },
32067
32081
  contacts: {
32068
32082
  type: "string",
32069
- description: "With --object deal (on --create-hubspot or --set-trigger): whose event it is \u2014 `every` (the default: every contact on the deal, each its own event, each worth the deal's amount) or `first` (the deal's first contact only)",
32083
+ description: "With --object deal or --object lead (on --create-hubspot or --set-trigger): whose event it is \u2014 `every` (the default: every contact on the record, each its own event; on a deal each worth the deal's amount) or `first` (the record's first contact only)",
32070
32084
  required: false
32071
32085
  },
32072
32086
  property: {
32073
32087
  type: "string",
32074
- description: "With --create-hubspot, --set-trigger or --preview: the property to watch, by HubSpot's internal name (lifecyclestage, hs_lead_status, a custom one on a contact; dealstage, amount, closedate on a deal) \u2014 any property, whatever its kind",
32088
+ description: "With --create-hubspot, --set-trigger or --preview: the property to watch, by HubSpot's internal name (lifecyclestage, hs_lead_status, a custom one on a contact; dealstage, amount, closedate on a deal; hs_pipeline_stage, hs_lead_label on a lead) \u2014 any property, whatever its kind",
32075
32089
  required: false
32076
32090
  },
32077
32091
  operator: {
@@ -32091,7 +32105,7 @@ var args3 = {
32091
32105
  },
32092
32106
  contact: {
32093
32107
  type: "string",
32094
- description: "With --preview: the record to draw the sample from \u2014 a HubSpot id, or text to search (an email or a name for a contact, a deal's name for a deal). The one most recently satisfying the trigger when unsaid",
32108
+ description: "With --preview: the record to draw the sample from \u2014 a HubSpot id, or text to search (an email or a name for a contact, a deal's or a lead's name). The one most recently satisfying the trigger when unsaid",
32095
32109
  required: false
32096
32110
  },
32097
32111
  "amount-property": {
@@ -32260,8 +32274,10 @@ function createHubspotArgs(raw, argv, name) {
32260
32274
  const mapping = parseFieldArgs(argv);
32261
32275
  const object = objectArg(raw, argv);
32262
32276
  const contacts = contactsArg(raw, argv);
32263
- if (contacts !== void 0 && object !== "deal") {
32264
- throw new ConversionArgsError("--contacts says whose event a deal's is; it needs --object deal.");
32277
+ if (contacts !== void 0 && !readsAssociatedContact(object)) {
32278
+ throw new ConversionArgsError(
32279
+ "--contacts says whose event a deal's or a lead's is; it needs --object deal or --object lead."
32280
+ );
32265
32281
  }
32266
32282
  return {
32267
32283
  // A contact is the wire's default, so it is left unsaid — the way the schema reads it back.
@@ -51759,6 +51775,11 @@ var OBJECT_WORDS = {
51759
51775
  plural: "deals",
51760
51776
  command: "baker hubspot deals",
51761
51777
  rows: "`--field value={{amount}}`, `--field currency={{deal_currency_code}}`, `--field email={{contact.email}}` \u2014 a deal's own properties bare, its contact's as `contact.<name>`; `{{id}}` is the deal's own id, `{{contact.id}}` the contact's"
51778
+ },
51779
+ lead: {
51780
+ plural: "leads",
51781
+ command: "baker hubspot leads",
51782
+ rows: "`--field email={{contact.email}}`, `--field properties.stage={{hs_pipeline_stage}}` \u2014 a lead's own properties bare, its contact's as `contact.<name>`; `{{id}}` is the lead's own id, `{{contact.id}}` the contact's. A lead carries no amount of its own, so `value` is empty unless you point it at a property"
51762
51783
  }
51763
51784
  };
51764
51785
  function propertiesCommand2(object) {
@@ -51887,7 +51908,7 @@ function fieldsCommand(object) {
51887
51908
  return defineCommand143({
51888
51909
  meta: {
51889
51910
  name: "fields",
51890
- description: `List every property a HubSpot event on a ${object} can read into its rows, with HubSpot's type${object === "deal" ? " \u2014 the deal's own, and its contact's as contact.<name>" : ""}. Example: ${words2.command} fields`
51911
+ description: `List every property a HubSpot event on a ${object} can read into its rows, with HubSpot's type${object === "contact" ? "" : ` \u2014 the ${object}'s own, and its contact's as contact.<name>`}. Example: ${words2.command} fields`
51891
51912
  },
51892
51913
  args: {},
51893
51914
  run: async () => {
@@ -51915,6 +51936,13 @@ var dealsCommand = defineCommand143({
51915
51936
  },
51916
51937
  subCommands: { properties: propertiesCommand2("deal"), fields: fieldsCommand("deal") }
51917
51938
  });
51939
+ var leadsCommand3 = defineCommand143({
51940
+ meta: {
51941
+ name: "leads",
51942
+ description: "Leads on the connected HubSpot account: what a HubSpot event on a lead can watch (`properties`) and read (`fields`). Start here for qualification and disqualification \u2014 a lead's stage is where HubSpot records both, and `hs_pipeline_stage` lists the account's own stages with their labels. Needs Sales Hub Professional or Enterprise; on any other plan the account has no leads to read."
51943
+ },
51944
+ subCommands: { properties: propertiesCommand2("lead"), fields: fieldsCommand("lead") }
51945
+ });
51918
51946
  var contactsCommand = defineCommand143({
51919
51947
  meta: { name: "contacts", description: "Contacts on the connected HubSpot account." },
51920
51948
  subCommands: {
@@ -51976,6 +52004,7 @@ Full guide: __tooling__/docs/tools/baker/hubspot.md`
51976
52004
  pipelines: pipelinesCommand,
51977
52005
  contacts: contactsCommand,
51978
52006
  deals: dealsCommand,
52007
+ leads: leadsCommand3,
51979
52008
  meetings: meetingsCommand
51980
52009
  }
51981
52010
  });