@shushed/helpers 0.0.192 → 0.0.193-action-log-20251010135404

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/index.d.ts CHANGED
@@ -1600,7 +1600,7 @@ declare const schema$l: {
1600
1600
  };
1601
1601
  readonly size_code: {
1602
1602
  readonly type: "string";
1603
- readonly minLength: 1;
1603
+ readonly pattern: "^(XXS|XS|S|M|L|XL|XXL|ONE|\\d{1,2})$";
1604
1604
  };
1605
1605
  readonly quantity: {
1606
1606
  readonly type: "integer";
package/dist/index.js CHANGED
@@ -105889,7 +105889,7 @@ var schema12 = { "$schema": "http://json-schema.org/draft-07/schema#", "title":
105889
105889
  var product_default = schema12;
105890
105890
 
105891
105891
  // dist-dereferenced/stock.ts
105892
- var schema13 = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Stock Schema", "type": "object", "additionalProperties": false, "properties": { "style_id": { "type": "string", "minLength": 1 }, "colour_id": { "type": "string", "minLength": 1 }, "size_code": { "type": "string", "minLength": 1 }, "quantity": { "type": "integer", "minimum": 0 }, "location_code": { "type": "string", "pattern": "^\\d{3}-[A-Z]+$|^[A-Z]{2,}-?[A-Z]*$|^[A-Z]{2,}\\d{3}$" }, "unit_cost": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "type": "object", "additionalProperties": false, "properties": { "value": { "type": "integer", "minimum": 0 }, "decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 }, "currency": { "title": "Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_value": { "type": "integer", "minimum": 0 }, "lcy_currency": { "title": "LCY Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 } }, "required": ["value", "currency", "lcy_value", "lcy_currency", "decimal_places", "lcy_decimal_places"] }, { "type": "null" }] } }, "required": ["style_id", "colour_id", "size_code", "quantity", "location_code", "unit_cost"], "$id": "https://shushed.example.com/stock.schema.json" };
105892
+ var schema13 = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Stock Schema", "type": "object", "additionalProperties": false, "properties": { "style_id": { "type": "string", "minLength": 1 }, "colour_id": { "type": "string", "minLength": 1 }, "size_code": { "type": "string", "pattern": "^(XXS|XS|S|M|L|XL|XXL|ONE|\\d{1,2})$" }, "quantity": { "type": "integer", "minimum": 0 }, "location_code": { "type": "string", "pattern": "^\\d{3}-[A-Z]+$|^[A-Z]{2,}-?[A-Z]*$|^[A-Z]{2,}\\d{3}$" }, "unit_cost": { "oneOf": [{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Money", "type": "object", "additionalProperties": false, "properties": { "value": { "type": "integer", "minimum": 0 }, "decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 }, "currency": { "title": "Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_value": { "type": "integer", "minimum": 0 }, "lcy_currency": { "title": "LCY Currency", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["AFN", "ALL", "DZD", "USD", "EUR", "AOA", "XCD", "ARS", "AMD", "AWG", "AUD", "AZN", "BSD", "BHD", "BDT", "BBD", "BYN", "BZD", "XOF", "BMD", "BTN", "INR", "BOB", "BOV", "BAM", "BWP", "NOK", "BRL", "BND", "BGN", "BIF", "CVE", "KHR", "XAF", "CAD", "KYD", "CLF", "CLP", "CNY", "COP", "COU", "KMF", "CDF", "NZD", "CRC", "CUC", "CUP", "ANG", "CZK", "DKK", "DJF", "DOP", "EGP", "SVC", "ERN", "ETB", "FKP", "FJD", "XPF", "GMD", "GEL", "GHS", "GIP", "GTQ", "GBP", "GNF", "GYD", "HTG", "HNL", "HKD", "HUF", "ISK", "IDR", "XDR", "IRR", "IQD", "ILS", "JMD", "JPY", "JOD", "KZT", "KES", "KPW", "KRW", "KWD", "KGS", "LAK", "LBP", "LSL", "ZAR", "LRD", "LYD", "CHF", "MOP", "MGA", "MWK", "MYR", "MVR", "MRU", "MUR", "XUA", "MXN", "MXV", "MDL", "MNT", "MAD", "MZN", "MMK", "NAD", "NPR", "NIO", "NGN", "OMR", "PKR", "PAB", "PGK", "PYG", "PEN", "PHP", "PLN", "QAR", "MKD", "RON", "RUB", "RWF", "SHP", "WST", "STN", "SAR", "RSD", "SCR", "SLE", "SGD", "XSU", "SBD", "SOS", "SSP", "LKR", "SDG", "SRD", "SZL", "SEK", "CHE", "CHW", "SYP", "TWD", "TJS", "TZS", "THB", "TOP", "TTD", "TND", "TRY", "TMT", "UGX", "UAH", "AED", "USN", "UYI", "UYU", "UZS", "VUV", "VEF", "VED", "VND", "YER", "ZMW", "ZWL"] }, "lcy_decimal_places": { "type": "integer", "minimum": 0, "maximum": 4 } }, "required": ["value", "currency", "lcy_value", "lcy_currency", "decimal_places", "lcy_decimal_places"] }, { "type": "null" }] } }, "required": ["style_id", "colour_id", "size_code", "quantity", "location_code", "unit_cost"], "$id": "https://shushed.example.com/stock.schema.json" };
105893
105893
  var stock_default = schema13;
105894
105894
 
105895
105895
  // dist-dereferenced/total.ts
@@ -106582,10 +106582,8 @@ function getRedisClient(sysEnv) {
106582
106582
  const redisEndpoint = jsonEnv["redis_host"];
106583
106583
  let REDIS_CLIENT = global.REDIS_CLIENTS;
106584
106584
  if (!REDIS_CLIENTS[redisEndpoint]) {
106585
- if (!redisEndpoint && process.env.K_REVISION) {
106585
+ if (!redisEndpoint) {
106586
106586
  throw new Error("Invariant: Redis endpoint is not set in the Environment Variables. Please set the redis_host with a value of IP:PORT i.e. 10.67.130.27:6379");
106587
- } else if (!redisEndpoint) {
106588
- return null;
106589
106587
  }
106590
106588
  REDIS_CLIENT = (0, import_redis.createClient)({
106591
106589
  url: `redis://${redisEndpoint}`
@@ -106596,9 +106594,6 @@ function getRedisClient(sysEnv) {
106596
106594
  }
106597
106595
  function getConnectedRedisClient(url) {
106598
106596
  const redisClient = getRedisClient(url);
106599
- if (!redisClient) {
106600
- return Promise.resolve(null);
106601
- }
106602
106597
  let race = Promise.resolve(redisClient);
106603
106598
  if (!redisClient.isOpen) {
106604
106599
  race = Promise.race([
@@ -108967,7 +108962,7 @@ var ActionHelper = class _ActionHelper {
108967
108962
  }
108968
108963
  getTopicName(internal) {
108969
108964
  if (!this.config || !this.config.topicName) {
108970
- throw new Error("Invariant. onExecute must be called first. topicName must be present in the trigger config");
108965
+ throw new Error("Invariant. onExecute must be called first. topicName must be present in the trigger config: " + JSON.stringify(this.config));
108971
108966
  }
108972
108967
  if (!this.runtime) {
108973
108968
  throw new Error("Invariant. preOnExecute must be called first");
@@ -109029,7 +109024,7 @@ var ActionHelper = class _ActionHelper {
109029
109024
  triggerId: rnWorkflowTriggerId.split("/")[1]
109030
109025
  })(async (token) => {
109031
109026
  const response = await fetch(this.runtime.runtimeUrl + `/executeWorkflow/${rnWorkflowTriggerId}`, {
109032
- method: "GET",
109027
+ method: "POST",
109033
109028
  headers: {
109034
109029
  "X-Buildship-Trigger-Authorization": `Bearer ${token}`,
109035
109030
  Authorization: `Bearer ${token}`,
@@ -109073,7 +109068,8 @@ var ActionHelper = class _ActionHelper {
109073
109068
  workflowId: rnWorkflowTriggerId.split("/")[0],
109074
109069
  triggerId: rnWorkflowTriggerId.split("/")[1]
109075
109070
  })(async (token) => {
109076
- if (!(await fetch(this.runtime.runtimeUrl + `/executeWorkflow/${rnWorkflowTriggerId}`, {
109071
+ const url = this.runtime.runtimeUrl + `/executeWorkflow/${rnWorkflowTriggerId}`;
109072
+ const resp = await fetch(url, {
109077
109073
  method: "POST",
109078
109074
  headers: {
109079
109075
  "X-Buildship-Trigger-Authorization": `Bearer ${token}`,
@@ -109086,8 +109082,14 @@ var ActionHelper = class _ActionHelper {
109086
109082
  pubsub_name: subscriptionName,
109087
109083
  listener_url: this.runtime.runtimeUrl + `/executeWorkflow/${this.runtime?.workflowId}/${this.runtime?.triggerId}?${topicName.indexOf(this.getInternalTopicName()) === -1 ? "direct-execution" : "direct-internal-execution"}=1`
109088
109084
  })
109089
- })).ok) {
109090
- throw new Error("Failed to register the main subscription with respectful nudge");
109085
+ });
109086
+ if (!resp.ok) {
109087
+ let body = "";
109088
+ try {
109089
+ body = await resp.text();
109090
+ } catch {
109091
+ }
109092
+ throw new Error(`Failed to register the main subscription with respectful nudge; status=${resp.status} ${resp.statusText}; url=${url}; subscription=${subscriptionName}; operation=${operation}; body=${body?.slice(0, 500)}`);
109091
109093
  }
109092
109094
  return true;
109093
109095
  });
@@ -109100,7 +109102,8 @@ var ActionHelper = class _ActionHelper {
109100
109102
  workflowId: rnConfig.rnWorkflowTriggerId.split("/")[0],
109101
109103
  triggerId: rnConfig.rnWorkflowTriggerId.split("/")[1]
109102
109104
  })(async (token) => {
109103
- if (!(await fetch(this.runtime.runtimeUrl + `/executeWorkflow/${rnConfig.rnWorkflowTriggerId}`, {
109105
+ const url = this.runtime.runtimeUrl + `/executeWorkflow/${rnConfig.rnWorkflowTriggerId}`;
109106
+ const resp = await fetch(url, {
109104
109107
  method: "POST",
109105
109108
  headers: {
109106
109109
  "X-Buildship-Trigger-Authorization": `Bearer ${token}`,
@@ -109119,8 +109122,14 @@ var ActionHelper = class _ActionHelper {
109119
109122
  ack_deadline: rnConfig.ackDeadline,
109120
109123
  max_outstanding_messages: rnConfig.maxOutstandingMessages
109121
109124
  })
109122
- })).ok) {
109123
- throw new Error("Failed to register the main subscription with respectful nudge");
109125
+ });
109126
+ if (!resp.ok) {
109127
+ let body = "";
109128
+ try {
109129
+ body = await resp.text();
109130
+ } catch {
109131
+ }
109132
+ throw new Error(`Failed to register the main subscription with respectful nudge; status=${resp.status} ${resp.statusText}; url=${url}; subscription=${subscriptionName}; operation=upsert; body=${body?.slice(0, 500)}`);
109124
109133
  }
109125
109134
  return true;
109126
109135
  });
@@ -109136,9 +109145,6 @@ var ActionHelper = class _ActionHelper {
109136
109145
  if (!rateLimitOpts) {
109137
109146
  return null;
109138
109147
  }
109139
- if (!getRedisClient(this.runtime.systemEnvName)) {
109140
- return null;
109141
- }
109142
109148
  if (!this._rateLimitersCache[this.runtime.systemEnvName]) {
109143
109149
  const rateLimiterMemory = new import_rate_limiter_flexible.RateLimiterMemory({
109144
109150
  points: rateLimitOpts.maxRequests,
@@ -109478,8 +109484,6 @@ var TriggerHelper = class {
109478
109484
  options.logging.log("Comparing to ", authHeader.slice("Bearer ".length));
109479
109485
  const matchingApiKeys = apiKeys.filter((x) => authHeader.slice("Bearer ".length) === x.apiKey);
109480
109486
  options.logging.log("Matching API keys", matchingApiKeys);
109481
- options.logging.log("Client IP", clientIp);
109482
- options.logging.log("Allowed CIDRs", matchingApiKeys.map((x) => x.allowedCIDRs));
109483
109487
  const allowedApiKeys = matchingApiKeys.filter((x) => isIpInCidrs(clientIp, x.allowedCIDRs));
109484
109488
  options.logging.log("Allowed API keys", allowedApiKeys);
109485
109489
  return {
@@ -109531,8 +109535,21 @@ var TriggerHelper = class {
109531
109535
  return;
109532
109536
  }
109533
109537
  }
109538
+ } else if (contentType?.startsWith("text/plain")) {
109539
+ try {
109540
+ rawBody = await parser2.text(optionsEnchanced.nodeReq, {
109541
+ limit: "2mb"
109542
+ });
109543
+ } catch (err) {
109544
+ optionsEnchanced.req.throw(400, `Unfetchable Body. ${err.message}`);
109545
+ return;
109546
+ }
109547
+ bodyAsJson = { text: rawBody };
109548
+ } else if (!contentType) {
109549
+ rawBody = "";
109550
+ bodyAsJson = {};
109534
109551
  } else {
109535
- optionsEnchanced.terminate(400, "Invalid Content-Type");
109552
+ optionsEnchanced.req.throw(400, `Invalid Content-Type expected: application/json | text/plain | undefined, got ${contentType}`);
109536
109553
  return;
109537
109554
  }
109538
109555
  message = {
@@ -109599,7 +109616,32 @@ var TriggerHelper = class {
109599
109616
  return result;
109600
109617
  }
109601
109618
  if (!atLeastOneHandlerMatched && !executionFinished) {
109602
- optionsEnchanced.terminate(404, "No matching handler found");
109619
+ const reqType = reqIsPubSub ? "pubsub" : reqIsScheduler ? "scheduler" : reqIsCloudTask ? "cloudtask" : reqIsRespectfulNudge ? "respectful-nudge" : "api";
109620
+ const method = optionsEnchanced?.nodeReq?.method || "";
109621
+ const path2 = optionsEnchanced?.nodeReq?.url || "";
109622
+ const query = optionsEnchanced.request.querystring || "";
109623
+ const host = optionsEnchanced.request.host || "";
109624
+ const handlersSummary = this.actions.map((a) => {
109625
+ const rc = a.actionOptions.routingConditions || {};
109626
+ const toStr = (v) => typeof v === "string" ? v : v && v.toString ? v.toString() : void 0;
109627
+ return {
109628
+ api: rc.api ? {
109629
+ havingApiKey: !!rc.api.havingApiKey,
109630
+ roles: rc.api.roles,
109631
+ match: toStr(rc.api.matchByPartialQueryString)
109632
+ } : void 0,
109633
+ pubsub: rc.pubsub ? {
109634
+ match: toStr(rc.pubsub.matchByPubSubSubscriptionName)
109635
+ } : void 0,
109636
+ scheduler: rc.scheduler ? {
109637
+ match: toStr(rc.scheduler.matchByPartialQueryString)
109638
+ } : void 0
109639
+ };
109640
+ });
109641
+ optionsEnchanced.terminate(
109642
+ 404,
109643
+ `No matching handler found; type=${reqType}; method=${method}; url=${host}${path2}; query=${query}; handlers=${JSON.stringify(handlersSummary).slice(0, 1e3)}`
109644
+ );
109603
109645
  }
109604
109646
  };
109605
109647
  fn.$TriggerHelper = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shushed/helpers",
3
- "version": "0.0.192",
3
+ "version": "0.0.193-action-log-20251010135404",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",