pepr 0.42.0 → 0.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cli/build.d.ts +1 -0
  2. package/dist/cli/build.d.ts.map +1 -1
  3. package/dist/cli/build.helpers.d.ts +66 -0
  4. package/dist/cli/build.helpers.d.ts.map +1 -1
  5. package/dist/cli/monitor.d.ts +23 -0
  6. package/dist/cli/monitor.d.ts.map +1 -1
  7. package/dist/cli.js +341 -283
  8. package/dist/controller.js +1 -1
  9. package/dist/lib/assets/destroy.d.ts.map +1 -1
  10. package/dist/lib/assets/helm.d.ts +1 -1
  11. package/dist/lib/assets/helm.d.ts.map +1 -1
  12. package/dist/lib/assets/index.d.ts.map +1 -1
  13. package/dist/lib/assets/pods.d.ts +5 -19
  14. package/dist/lib/assets/pods.d.ts.map +1 -1
  15. package/dist/lib/assets/webhooks.d.ts.map +1 -1
  16. package/dist/lib/assets/yaml.d.ts.map +1 -1
  17. package/dist/lib/capability.d.ts.map +1 -1
  18. package/dist/lib/controller/index.d.ts.map +1 -1
  19. package/dist/lib/controller/store.d.ts +0 -1
  20. package/dist/lib/controller/store.d.ts.map +1 -1
  21. package/dist/lib/controller/storeCache.d.ts +1 -0
  22. package/dist/lib/controller/storeCache.d.ts.map +1 -1
  23. package/dist/lib/mutate-request.d.ts +2 -2
  24. package/dist/lib/mutate-request.d.ts.map +1 -1
  25. package/dist/lib/queue.d.ts.map +1 -1
  26. package/dist/lib/storage.d.ts +4 -4
  27. package/dist/lib/storage.d.ts.map +1 -1
  28. package/dist/lib/utils.d.ts.map +1 -1
  29. package/dist/lib/validate-processor.d.ts +4 -1
  30. package/dist/lib/validate-processor.d.ts.map +1 -1
  31. package/dist/lib/watch-processor.d.ts.map +1 -1
  32. package/dist/lib.js +136 -109
  33. package/dist/lib.js.map +3 -3
  34. package/package.json +1 -1
  35. package/src/cli/build.helpers.ts +180 -0
  36. package/src/cli/build.ts +85 -133
  37. package/src/cli/monitor.ts +108 -65
  38. package/src/lib/assets/deploy.ts +6 -6
  39. package/src/lib/assets/destroy.ts +1 -1
  40. package/src/lib/assets/helm.ts +6 -6
  41. package/src/lib/assets/index.ts +22 -22
  42. package/src/lib/assets/pods.ts +10 -5
  43. package/src/lib/assets/webhooks.ts +1 -1
  44. package/src/lib/assets/yaml.ts +12 -9
  45. package/src/lib/capability.ts +21 -10
  46. package/src/lib/controller/index.ts +9 -7
  47. package/src/lib/controller/store.ts +23 -10
  48. package/src/lib/controller/storeCache.ts +10 -1
  49. package/src/lib/mutate-request.ts +11 -11
  50. package/src/lib/queue.ts +12 -4
  51. package/src/lib/storage.ts +33 -24
  52. package/src/lib/utils.ts +5 -5
  53. package/src/lib/validate-processor.ts +47 -39
  54. package/src/lib/watch-processor.ts +11 -7
  55. package/src/sdk/cosign.ts +4 -4
package/dist/lib.js CHANGED
@@ -6,8 +6,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
9
+ for (var name2 in all)
10
+ __defProp(target, name2, { get: all[name2], enumerable: true });
11
11
  };
12
12
  var __copyProps = (to, from, except, desc) => {
13
13
  if (from && typeof from === "object" || typeof from === "function") {
@@ -142,34 +142,34 @@ var MetricsCollector = class {
142
142
  this.addGauge(this.#metricNames.cacheMiss, "Number of cache misses per window", ["window"]);
143
143
  this.addGauge(this.#metricNames.resyncFailureCount, "Number of failures per resync operation", ["count"]);
144
144
  }
145
- #getMetricName = (name) => `${this.#prefix}_${name}`;
146
- #addMetric = (collection, MetricType, name, help, labelNames) => {
147
- if (collection.has(this.#getMetricName(name))) {
148
- logger_default.debug(`Metric for ${name} already exists`, loggingPrefix);
145
+ #getMetricName = (name2) => `${this.#prefix}_${name2}`;
146
+ #addMetric = (collection, MetricType, name2, help, labelNames) => {
147
+ if (collection.has(this.#getMetricName(name2))) {
148
+ logger_default.debug(`Metric for ${name2} already exists`, loggingPrefix);
149
149
  return;
150
150
  }
151
151
  const metric = new MetricType({
152
- name: this.#getMetricName(name),
152
+ name: this.#getMetricName(name2),
153
153
  help,
154
154
  registers: [this.#registry],
155
155
  labelNames
156
156
  });
157
- collection.set(this.#getMetricName(name), metric);
157
+ collection.set(this.#getMetricName(name2), metric);
158
158
  };
159
- addCounter = (name, help) => {
160
- this.#addMetric(this.#counters, import_prom_client.default.Counter, name, help, []);
159
+ addCounter = (name2, help) => {
160
+ this.#addMetric(this.#counters, import_prom_client.default.Counter, name2, help, []);
161
161
  };
162
- addSummary = (name, help) => {
163
- this.#addMetric(this.#summaries, import_prom_client.default.Summary, name, help, []);
162
+ addSummary = (name2, help) => {
163
+ this.#addMetric(this.#summaries, import_prom_client.default.Summary, name2, help, []);
164
164
  };
165
- addGauge = (name, help, labelNames) => {
166
- this.#addMetric(this.#gauges, import_prom_client.default.Gauge, name, help, labelNames);
165
+ addGauge = (name2, help, labelNames) => {
166
+ this.#addMetric(this.#gauges, import_prom_client.default.Gauge, name2, help, labelNames);
167
167
  };
168
- incCounter = (name) => {
169
- this.#counters.get(this.#getMetricName(name))?.inc();
168
+ incCounter = (name2) => {
169
+ this.#counters.get(this.#getMetricName(name2))?.inc();
170
170
  };
171
- incGauge = (name, labels, value = 1) => {
172
- this.#gauges.get(this.#getMetricName(name))?.inc(labels || {}, value);
171
+ incGauge = (name2, labels, value = 1) => {
172
+ this.#gauges.get(this.#getMetricName(name2))?.inc(labels || {}, value);
173
173
  };
174
174
  /**
175
175
  * Increments the error counter.
@@ -184,8 +184,8 @@ var MetricsCollector = class {
184
184
  * @param startTime - The start time.
185
185
  * @param name - The metrics summary to increment.
186
186
  */
187
- observeEnd = (startTime, name = this.#metricNames.mutate) => {
188
- this.#summaries.get(this.#getMetricName(name))?.observe(import_perf_hooks.performance.now() - startTime);
187
+ observeEnd = (startTime, name2 = this.#metricNames.mutate) => {
188
+ this.#summaries.get(this.#getMetricName(name2))?.observe(import_perf_hooks.performance.now() - startTime);
189
189
  };
190
190
  /**
191
191
  * Fetches the current metrics from the registry.
@@ -577,8 +577,8 @@ async function mutateProcessor(config, capabilities, req, reqMetadata) {
577
577
  skipDecode = convertFromBase64Map(wrapped.Raw);
578
578
  }
579
579
  logger_default.info(reqMetadata, `Processing request`);
580
- for (const { name, bindings, namespaces } of capabilities) {
581
- const actionMetadata = { ...reqMetadata, name };
580
+ for (const { name: name2, bindings, namespaces } of capabilities) {
581
+ const actionMetadata = { ...reqMetadata, name: name2 };
582
582
  for (const action of bindings) {
583
583
  if (!action.mutateCallback) {
584
584
  continue;
@@ -595,7 +595,7 @@ async function mutateProcessor(config, capabilities, req, reqMetadata) {
595
595
  if (req.operation === "DELETE") {
596
596
  return;
597
597
  }
598
- const identifier = `${config.uuid}.pepr.dev/${name}`;
598
+ const identifier = `${config.uuid}.pepr.dev/${name2}`;
599
599
  wrapped.Raw.metadata = wrapped.Raw.metadata || {};
600
600
  wrapped.Raw.metadata.annotations = wrapped.Raw.metadata.annotations || {};
601
601
  wrapped.Raw.metadata.annotations[identifier] = status;
@@ -738,6 +738,35 @@ var PeprValidateRequest = class {
738
738
  };
739
739
 
740
740
  // src/lib/validate-processor.ts
741
+ async function processRequest(binding, actionMetadata, peprValidateRequest) {
742
+ const label = binding.validateCallback.name;
743
+ logger_default.info(actionMetadata, `Processing validation action (${label})`);
744
+ const valResp = {
745
+ uid: peprValidateRequest.Request.uid,
746
+ allowed: true
747
+ // Assume it's allowed until a validation check fails
748
+ };
749
+ try {
750
+ const callbackResp = await binding.validateCallback(peprValidateRequest);
751
+ valResp.allowed = callbackResp.allowed;
752
+ if (callbackResp.statusCode || callbackResp.statusMessage) {
753
+ valResp.status = {
754
+ code: callbackResp.statusCode || 400,
755
+ message: callbackResp.statusMessage || `Validation failed for ${name}`
756
+ };
757
+ }
758
+ logger_default.info(actionMetadata, `Validation action complete (${label}): ${callbackResp.allowed ? "allowed" : "denied"}`);
759
+ return valResp;
760
+ } catch (e) {
761
+ logger_default.error(actionMetadata, `Action failed: ${JSON.stringify(e)}`);
762
+ valResp.allowed = false;
763
+ valResp.status = {
764
+ code: 500,
765
+ message: `Action failed with error: ${JSON.stringify(e)}`
766
+ };
767
+ return valResp;
768
+ }
769
+ }
741
770
  async function validateProcessor(config, capabilities, req, reqMetadata) {
742
771
  const wrapped = new PeprValidateRequest(req);
743
772
  const response = [];
@@ -746,44 +775,19 @@ async function validateProcessor(config, capabilities, req, reqMetadata) {
746
775
  convertFromBase64Map(wrapped.Raw);
747
776
  }
748
777
  logger_default.info(reqMetadata, `Processing validation request`);
749
- for (const { name, bindings, namespaces } of capabilities) {
750
- const actionMetadata = { ...reqMetadata, name };
751
- for (const action of bindings) {
752
- if (!action.validateCallback) {
778
+ for (const { name: name2, bindings, namespaces } of capabilities) {
779
+ const actionMetadata = { ...reqMetadata, name: name2 };
780
+ for (const binding of bindings) {
781
+ if (!binding.validateCallback) {
753
782
  continue;
754
783
  }
755
- const localResponse = {
756
- uid: req.uid,
757
- allowed: true
758
- // Assume it's allowed until a validation check fails
759
- };
760
- const shouldSkip = shouldSkipRequest(action, req, namespaces, config?.alwaysIgnore?.namespaces);
784
+ const shouldSkip = shouldSkipRequest(binding, req, namespaces, config?.alwaysIgnore?.namespaces);
761
785
  if (shouldSkip !== "") {
762
786
  logger_default.debug(shouldSkip);
763
787
  continue;
764
788
  }
765
- const label = action.validateCallback.name;
766
- logger_default.info(actionMetadata, `Processing validation action (${label})`);
767
- try {
768
- const resp = await action.validateCallback(wrapped);
769
- localResponse.allowed = resp.allowed;
770
- if (resp.statusCode || resp.statusMessage) {
771
- localResponse.status = {
772
- code: resp.statusCode || 400,
773
- message: resp.statusMessage || `Validation failed for ${name}`
774
- };
775
- }
776
- logger_default.info(actionMetadata, `Validation action complete (${label}): ${resp.allowed ? "allowed" : "denied"}`);
777
- } catch (e) {
778
- logger_default.error(actionMetadata, `Action failed: ${JSON.stringify(e)}`);
779
- localResponse.allowed = false;
780
- localResponse.status = {
781
- code: 500,
782
- message: `Action failed with error: ${JSON.stringify(e)}`
783
- };
784
- return [localResponse];
785
- }
786
- response.push(localResponse);
789
+ const resp = await processRequest(binding, actionMetadata, wrapped);
790
+ response.push(resp);
787
791
  }
788
792
  }
789
793
  return response;
@@ -807,12 +811,12 @@ var peprStoreGVK = {
807
811
  // src/lib/controller/storeCache.ts
808
812
  var import_kubernetes_fluent_client2 = require("kubernetes-fluent-client");
809
813
  var import_http_status_codes = require("http-status-codes");
810
- var sendUpdatesAndFlushCache = async (cache, namespace2, name) => {
814
+ var sendUpdatesAndFlushCache = async (cache, namespace2, name2) => {
811
815
  const indexes = Object.keys(cache);
812
816
  const payload = Object.values(cache);
813
817
  try {
814
818
  if (payload.length > 0) {
815
- await (0, import_kubernetes_fluent_client2.K8s)(Store, { namespace: namespace2, name }).Patch(payload);
819
+ await (0, import_kubernetes_fluent_client2.K8s)(Store, { namespace: namespace2, name: name2 }).Patch(updateCacheID(payload));
816
820
  Object.keys(cache).forEach((key) => delete cache[key]);
817
821
  }
818
822
  } catch (err) {
@@ -844,32 +848,41 @@ var fillStoreCache = (cache, capabilityName, op, cacheItem) => {
844
848
  }
845
849
  return cache;
846
850
  };
851
+ function updateCacheID(payload) {
852
+ payload.push({
853
+ op: "replace",
854
+ path: "/metadata/labels/pepr.dev-cacheID",
855
+ value: `${Date.now()}`
856
+ });
857
+ return payload;
858
+ }
847
859
 
848
860
  // src/lib/controller/store.ts
849
861
  var namespace = "pepr-system";
850
- var debounceBackoff = 1e3;
862
+ var debounceBackoffReceive = 1e3;
863
+ var debounceBackoffSend = 4e3;
851
864
  var StoreController = class {
852
865
  #name;
853
866
  #stores = {};
854
867
  #sendDebounce;
855
868
  #onReady;
856
- constructor(capabilities, name, onReady) {
869
+ constructor(capabilities, name2, onReady) {
857
870
  this.#onReady = onReady;
858
- this.#name = name;
859
- const setStorageInstance = (registrationFunction, name2) => {
871
+ this.#name = name2;
872
+ const setStorageInstance = (registrationFunction, name3) => {
860
873
  const scheduleStore = registrationFunction();
861
- scheduleStore.registerSender(this.#send(name2));
862
- this.#stores[name2] = scheduleStore;
874
+ scheduleStore.registerSender(this.#send(name3));
875
+ this.#stores[name3] = scheduleStore;
863
876
  };
864
- if (name.includes("schedule")) {
865
- for (const { name: name2, registerScheduleStore, hasSchedule } of capabilities) {
877
+ if (name2.includes("schedule")) {
878
+ for (const { name: name3, registerScheduleStore, hasSchedule } of capabilities) {
866
879
  if (hasSchedule === true) {
867
- setStorageInstance(registerScheduleStore, name2);
880
+ setStorageInstance(registerScheduleStore, name3);
868
881
  }
869
882
  }
870
883
  } else {
871
- for (const { name: name2, registerStore } of capabilities) {
872
- setStorageInstance(registerStore, name2);
884
+ for (const { name: name3, registerStore } of capabilities) {
885
+ setStorageInstance(registerStore, name3);
873
886
  }
874
887
  }
875
888
  setTimeout(
@@ -884,17 +897,24 @@ var StoreController = class {
884
897
  };
885
898
  #migrateAndSetupWatch = async (store) => {
886
899
  logger_default.debug(redactedStore(store), "Pepr Store migration");
900
+ await (0, import_kubernetes_fluent_client3.K8s)(Store, { namespace, name: this.#name }).Patch([
901
+ {
902
+ op: "add",
903
+ path: "/metadata/labels/pepr.dev-cacheID",
904
+ value: `${Date.now()}`
905
+ }
906
+ ]);
887
907
  const data = store.data || {};
888
908
  let storeCache = {};
889
- for (const name of Object.keys(this.#stores)) {
890
- const offset = `${name}-`.length;
909
+ for (const name2 of Object.keys(this.#stores)) {
910
+ const offset = `${name2}-`.length;
891
911
  for (const key of Object.keys(data)) {
892
- if ((0, import_ramda4.startsWith)(name, key) && !(0, import_ramda4.startsWith)(`${name}-v2`, key)) {
893
- storeCache = fillStoreCache(storeCache, name, "remove", {
912
+ if ((0, import_ramda4.startsWith)(name2, key) && !(0, import_ramda4.startsWith)(`${name2}-v2`, key)) {
913
+ storeCache = fillStoreCache(storeCache, name2, "remove", {
894
914
  key: [key.slice(offset)],
895
915
  value: data[key]
896
916
  });
897
- storeCache = fillStoreCache(storeCache, name, "add", {
917
+ storeCache = fillStoreCache(storeCache, name2, "add", {
898
918
  key: [key.slice(offset)],
899
919
  value: data[key],
900
920
  version: "v2"
@@ -909,15 +929,15 @@ var StoreController = class {
909
929
  logger_default.debug(redactedStore(store), "Pepr Store update");
910
930
  const debounced = () => {
911
931
  const data = store.data || {};
912
- for (const name of Object.keys(this.#stores)) {
913
- const offset = `${name}-`.length;
932
+ for (const name2 of Object.keys(this.#stores)) {
933
+ const offset = `${name2}-`.length;
914
934
  const filtered = {};
915
935
  for (const key of Object.keys(data)) {
916
- if ((0, import_ramda4.startsWith)(name, key)) {
936
+ if ((0, import_ramda4.startsWith)(name2, key)) {
917
937
  filtered[key.slice(offset)] = data[key];
918
938
  }
919
939
  }
920
- this.#stores[name].receive(filtered);
940
+ this.#stores[name2].receive(filtered);
921
941
  }
922
942
  if (this.#onReady) {
923
943
  this.#onReady();
@@ -925,7 +945,7 @@ var StoreController = class {
925
945
  }
926
946
  };
927
947
  clearTimeout(this.#sendDebounce);
928
- this.#sendDebounce = setTimeout(debounced, this.#onReady ? 0 : debounceBackoff);
948
+ this.#sendDebounce = setTimeout(debounced, this.#onReady ? 0 : debounceBackoffReceive);
929
949
  };
930
950
  #send = (capabilityName) => {
931
951
  let storeCache = {};
@@ -937,7 +957,7 @@ var StoreController = class {
937
957
  logger_default.debug(redactedPatch(storeCache), "Sending updates to Pepr store");
938
958
  void sendUpdatesAndFlushCache(storeCache, namespace, this.#name);
939
959
  }
940
- }, debounceBackoff);
960
+ }, debounceBackoffSend);
941
961
  return sender;
942
962
  };
943
963
  #createStoreResource = async (e) => {
@@ -947,7 +967,10 @@ var StoreController = class {
947
967
  await (0, import_kubernetes_fluent_client3.K8s)(Store).Apply({
948
968
  metadata: {
949
969
  name: this.#name,
950
- namespace
970
+ namespace,
971
+ labels: {
972
+ "pepr.dev-cacheID": `${Date.now()}`
973
+ }
951
974
  },
952
975
  data: {
953
976
  // JSON Patch will die if the data is empty, so we need to add a placeholder
@@ -1125,12 +1148,12 @@ var Controller = class _Controller {
1125
1148
  const startTime = MetricsCollector.observeStart();
1126
1149
  try {
1127
1150
  const request = req.body?.request || {};
1128
- const { name, namespace: namespace2, gvk } = {
1151
+ const { name: name2, namespace: namespace2, gvk } = {
1129
1152
  name: request?.name ? `/${request.name}` : "",
1130
1153
  namespace: request?.namespace || "",
1131
1154
  gvk: request?.kind || { group: "", version: "", kind: "" }
1132
1155
  };
1133
- const reqMetadata = { uid: request.uid, namespace: namespace2, name };
1156
+ const reqMetadata = { uid: request.uid, namespace: namespace2, name: name2 };
1134
1157
  logger_default.info({ ...reqMetadata, gvk, operation: request.operation, admissionKind }, "Incoming request");
1135
1158
  logger_default.debug({ ...reqMetadata, request }, "Incoming request body");
1136
1159
  this.#beforeHook && this.#beforeHook(request || {});
@@ -1244,20 +1267,20 @@ async function writeEvent(cr, event, eventType, eventReason, reportingComponent,
1244
1267
  }
1245
1268
  function getOwnerRefFrom(customResource, blockOwnerDeletion, controller) {
1246
1269
  const { apiVersion, kind: kind3, metadata } = customResource;
1247
- const { name, uid } = metadata;
1270
+ const { name: name2, uid } = metadata;
1248
1271
  return [
1249
1272
  {
1250
1273
  apiVersion,
1251
1274
  kind: kind3,
1252
1275
  uid,
1253
- name,
1276
+ name: name2,
1254
1277
  ...blockOwnerDeletion !== void 0 && { blockOwnerDeletion },
1255
1278
  ...controller !== void 0 && { controller }
1256
1279
  }
1257
1280
  ];
1258
1281
  }
1259
- function sanitizeResourceName(name) {
1260
- return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").slice(0, 250).replace(/^[^a-z]+|[^a-z]+$/g, "");
1282
+ function sanitizeResourceName(name2) {
1283
+ return name2.toLowerCase().replace(/[^a-z0-9]+/g, "-").slice(0, 250).replace(/^[^a-z]+|[^a-z]+$/g, "");
1261
1284
  }
1262
1285
 
1263
1286
  // src/lib/helpers.ts
@@ -1315,8 +1338,8 @@ var Queue = class {
1315
1338
  #uid;
1316
1339
  #queue = [];
1317
1340
  #pendingPromise = false;
1318
- constructor(name) {
1319
- this.#name = name;
1341
+ constructor(name2) {
1342
+ this.#name = name2;
1320
1343
  this.#uid = `${Date.now()}-${(0, import_node_crypto.randomBytes)(2).toString("hex")}`;
1321
1344
  }
1322
1345
  label() {
@@ -1405,11 +1428,11 @@ function queueKey(obj) {
1405
1428
  strat = options.includes(strat) ? strat : d3fault;
1406
1429
  const ns = obj.metadata?.namespace ?? "cluster-scoped";
1407
1430
  const kind3 = obj.kind ?? "UnknownKind";
1408
- const name = obj.metadata?.name ?? "Unnamed";
1431
+ const name2 = obj.metadata?.name ?? "Unnamed";
1409
1432
  const lookup = {
1410
1433
  kind: `${kind3}`,
1411
1434
  kindNs: `${kind3}/${ns}`,
1412
- kindNsName: `${kind3}/${ns}/${name}`,
1435
+ kindNsName: `${kind3}/${ns}/${name2}`,
1413
1436
  global: "global"
1414
1437
  };
1415
1438
  return lookup[strat];
@@ -1641,17 +1664,19 @@ var Storage = class {
1641
1664
  */
1642
1665
  setItemAndWait = (key, value) => {
1643
1666
  this.#dispatchUpdate("add", [v2StoreKey(key)], value);
1667
+ const record = {};
1644
1668
  return new Promise((resolve, reject) => {
1645
- const unsubscribe = this.subscribe((data) => {
1669
+ record.timeout = setTimeout(() => {
1670
+ record.unsubscribe();
1671
+ return reject(`MAX_WAIT_TIME elapsed: Key ${key} not seen in ${MAX_WAIT_TIME / 1e3}s`);
1672
+ }, MAX_WAIT_TIME);
1673
+ record.unsubscribe = this.subscribe((data) => {
1646
1674
  if (data[`${v2UnescapedStoreKey(key)}`] === value) {
1647
- unsubscribe();
1648
- resolve();
1675
+ record.unsubscribe();
1676
+ clearTimeout(record.timeout);
1677
+ resolve("ok");
1649
1678
  }
1650
1679
  });
1651
- setTimeout(() => {
1652
- unsubscribe();
1653
- return reject();
1654
- }, MAX_WAIT_TIME);
1655
1680
  });
1656
1681
  };
1657
1682
  /**
@@ -1663,17 +1688,19 @@ var Storage = class {
1663
1688
  */
1664
1689
  removeItemAndWait = (key) => {
1665
1690
  this.#dispatchUpdate("remove", [v2StoreKey(key)]);
1691
+ const record = {};
1666
1692
  return new Promise((resolve, reject) => {
1667
- const unsubscribe = this.subscribe((data) => {
1693
+ record.timeout = setTimeout(() => {
1694
+ record.unsubscribe();
1695
+ return reject(`MAX_WAIT_TIME elapsed: Key ${key} still seen after ${MAX_WAIT_TIME / 1e3}s`);
1696
+ }, MAX_WAIT_TIME);
1697
+ record.unsubscribe = this.subscribe((data) => {
1668
1698
  if (!Object.hasOwn(data, `${v2UnescapedStoreKey(key)}`)) {
1669
- unsubscribe();
1670
- resolve();
1699
+ record.unsubscribe();
1700
+ clearTimeout(record.timeout);
1701
+ resolve("ok");
1671
1702
  }
1672
1703
  });
1673
- setTimeout(() => {
1674
- unsubscribe();
1675
- return reject();
1676
- }, MAX_WAIT_TIME);
1677
1704
  });
1678
1705
  };
1679
1706
  subscribe = (subscriber) => {
@@ -1857,11 +1884,11 @@ var Capability = class {
1857
1884
  * @returns
1858
1885
  */
1859
1886
  OnSchedule = (schedule) => {
1860
- const { name, every, unit, run, startTime, completions } = schedule;
1887
+ const { name: name2, every, unit, run, startTime, completions } = schedule;
1861
1888
  this.hasSchedule = true;
1862
1889
  if (process.env.PEPR_WATCH_MODE === "true" || process.env.PEPR_MODE === "dev") {
1863
1890
  const newSchedule = {
1864
- name,
1891
+ name: name2,
1865
1892
  every,
1866
1893
  unit,
1867
1894
  run,
@@ -2101,9 +2128,9 @@ var Capability = class {
2101
2128
  binding.filters.regexName = regexName.source;
2102
2129
  return commonChain;
2103
2130
  }
2104
- function WithName(name) {
2105
- logger_default.debug(`Add name filter ${name}`, prefix);
2106
- binding.filters.name = name;
2131
+ function WithName(name2) {
2132
+ logger_default.debug(`Add name filter ${name2}`, prefix);
2133
+ binding.filters.name = name2;
2107
2134
  return commonChain;
2108
2135
  }
2109
2136
  function WithLabel(key, value = "") {