pepr 0.33.0 → 0.34.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 (146) hide show
  1. package/README.md +2 -1
  2. package/dist/cli/banner.d.ts +2 -0
  3. package/dist/cli/banner.d.ts.map +1 -0
  4. package/dist/cli/build.d.ts +19 -0
  5. package/dist/cli/build.d.ts.map +1 -0
  6. package/dist/cli/deploy.d.ts +3 -0
  7. package/dist/cli/deploy.d.ts.map +1 -0
  8. package/dist/cli/dev.d.ts +3 -0
  9. package/dist/cli/dev.d.ts.map +1 -0
  10. package/dist/cli/format.d.ts +9 -0
  11. package/dist/cli/format.d.ts.map +1 -0
  12. package/dist/cli/init/index.d.ts +3 -0
  13. package/dist/cli/init/index.d.ts.map +1 -0
  14. package/dist/cli/init/templates.d.ts +196 -0
  15. package/dist/cli/init/templates.d.ts.map +1 -0
  16. package/dist/cli/init/utils.d.ts +21 -0
  17. package/dist/cli/init/utils.d.ts.map +1 -0
  18. package/dist/cli/init/utils.test.d.ts +2 -0
  19. package/dist/cli/init/utils.test.d.ts.map +1 -0
  20. package/dist/cli/init/walkthrough.d.ts +8 -0
  21. package/dist/cli/init/walkthrough.d.ts.map +1 -0
  22. package/dist/cli/init/walkthrough.test.d.ts +2 -0
  23. package/dist/cli/init/walkthrough.test.d.ts.map +1 -0
  24. package/dist/cli/kfc.d.ts +3 -0
  25. package/dist/cli/kfc.d.ts.map +1 -0
  26. package/dist/cli/monitor.d.ts +3 -0
  27. package/dist/cli/monitor.d.ts.map +1 -0
  28. package/dist/cli/root.d.ts +5 -0
  29. package/dist/cli/root.d.ts.map +1 -0
  30. package/dist/cli/update.d.ts +3 -0
  31. package/dist/cli/update.d.ts.map +1 -0
  32. package/dist/cli/uuid.d.ts +3 -0
  33. package/dist/cli/uuid.d.ts.map +1 -0
  34. package/dist/cli.js +69 -39
  35. package/dist/controller.js +1 -2
  36. package/dist/fixtures/loader.d.ts +5 -0
  37. package/dist/fixtures/loader.d.ts.map +1 -0
  38. package/dist/lib/assets/helm.d.ts +1 -0
  39. package/dist/lib/assets/helm.d.ts.map +1 -1
  40. package/dist/lib/assets/helm.test.d.ts +2 -0
  41. package/dist/lib/assets/helm.test.d.ts.map +1 -0
  42. package/dist/lib/assets/index.d.ts.map +1 -1
  43. package/dist/lib/assets/pods.d.ts +3 -0
  44. package/dist/lib/assets/pods.d.ts.map +1 -1
  45. package/dist/lib/assets/pods.test.d.ts +2 -0
  46. package/dist/lib/assets/pods.test.d.ts.map +1 -0
  47. package/dist/lib/assets/yaml.d.ts.map +1 -1
  48. package/dist/lib/controller/store.d.ts.map +1 -1
  49. package/dist/lib/errors.test.d.ts +2 -0
  50. package/dist/lib/errors.test.d.ts.map +1 -0
  51. package/dist/lib/filter.test.d.ts +2 -0
  52. package/dist/lib/filter.test.d.ts.map +1 -0
  53. package/dist/lib/helpers.d.ts +0 -5
  54. package/dist/lib/helpers.d.ts.map +1 -1
  55. package/dist/lib/helpers.test.d.ts +2 -0
  56. package/dist/lib/helpers.test.d.ts.map +1 -0
  57. package/dist/lib/included-files.test.d.ts +2 -0
  58. package/dist/lib/included-files.test.d.ts.map +1 -0
  59. package/dist/lib/logger.test.d.ts +2 -0
  60. package/dist/lib/logger.test.d.ts.map +1 -0
  61. package/dist/lib/metrics.d.ts +18 -0
  62. package/dist/lib/metrics.d.ts.map +1 -1
  63. package/dist/lib/metrics.test.d.ts +2 -0
  64. package/dist/lib/metrics.test.d.ts.map +1 -0
  65. package/dist/lib/module.test.d.ts +2 -0
  66. package/dist/lib/module.test.d.ts.map +1 -0
  67. package/dist/lib/mutate-request.test.d.ts +2 -0
  68. package/dist/lib/mutate-request.test.d.ts.map +1 -0
  69. package/dist/lib/queue.test.d.ts +2 -0
  70. package/dist/lib/queue.test.d.ts.map +1 -0
  71. package/dist/lib/schedule.test.d.ts +15 -0
  72. package/dist/lib/schedule.test.d.ts.map +1 -0
  73. package/dist/lib/storage.d.ts +1 -0
  74. package/dist/lib/storage.d.ts.map +1 -1
  75. package/dist/lib/storage.test.d.ts +2 -0
  76. package/dist/lib/storage.test.d.ts.map +1 -0
  77. package/dist/lib/tls.test.d.ts +2 -0
  78. package/dist/lib/tls.test.d.ts.map +1 -0
  79. package/dist/lib/utils.test.d.ts +2 -0
  80. package/dist/lib/utils.test.d.ts.map +1 -0
  81. package/dist/lib/validate-request.test.d.ts +2 -0
  82. package/dist/lib/validate-request.test.d.ts.map +1 -0
  83. package/dist/lib/watch-processor.d.ts.map +1 -1
  84. package/dist/lib/watch-processor.test.d.ts +2 -0
  85. package/dist/lib/watch-processor.test.d.ts.map +1 -0
  86. package/dist/lib.js +86 -24
  87. package/dist/lib.js.map +3 -3
  88. package/dist/sdk/sdk.test.d.ts +2 -0
  89. package/dist/sdk/sdk.test.d.ts.map +1 -0
  90. package/package.json +22 -16
  91. package/src/cli/banner.ts +63 -0
  92. package/src/cli/build.ts +370 -0
  93. package/src/cli/deploy.ts +105 -0
  94. package/src/cli/dev.ts +118 -0
  95. package/src/cli/format.ts +83 -0
  96. package/src/cli/init/index.ts +99 -0
  97. package/src/cli/init/templates.ts +124 -0
  98. package/src/cli/init/utils.test.ts +28 -0
  99. package/src/cli/init/utils.ts +55 -0
  100. package/src/cli/init/walkthrough.test.ts +21 -0
  101. package/src/cli/init/walkthrough.ts +96 -0
  102. package/src/cli/kfc.ts +45 -0
  103. package/src/cli/monitor.ts +101 -0
  104. package/src/cli/root.ts +12 -0
  105. package/src/cli/update.ts +95 -0
  106. package/src/cli/uuid.ts +44 -0
  107. package/src/fixtures/data/create-pod.json +271 -0
  108. package/src/fixtures/data/delete-pod.json +271 -0
  109. package/src/fixtures/loader.ts +18 -0
  110. package/src/lib/.prettierrc +14 -0
  111. package/src/lib/assets/helm.test.ts +64 -0
  112. package/src/lib/assets/helm.ts +35 -0
  113. package/src/lib/assets/index.ts +5 -1
  114. package/src/lib/assets/pods.test.ts +553 -0
  115. package/src/lib/assets/pods.ts +14 -6
  116. package/src/lib/assets/yaml.ts +15 -15
  117. package/src/lib/controller/index.ts +2 -2
  118. package/src/lib/controller/store.ts +0 -2
  119. package/src/lib/errors.test.ts +85 -0
  120. package/src/lib/filter.test.ts +384 -0
  121. package/src/lib/helpers.test.ts +1192 -0
  122. package/src/lib/helpers.ts +0 -17
  123. package/src/lib/included-files.test.ts +22 -0
  124. package/src/lib/logger.test.ts +18 -0
  125. package/src/lib/metrics.test.ts +132 -0
  126. package/src/lib/metrics.ts +68 -6
  127. package/src/lib/module.test.ts +126 -0
  128. package/src/lib/mutate-request.test.ts +188 -0
  129. package/src/lib/queue.test.ts +58 -0
  130. package/src/lib/schedule.test.ts +217 -0
  131. package/src/lib/storage.test.ts +216 -0
  132. package/src/lib/storage.ts +12 -4
  133. package/src/lib/tls.test.ts +18 -0
  134. package/src/lib/utils.test.ts +69 -0
  135. package/src/lib/validate-request.test.ts +124 -0
  136. package/src/lib/watch-processor.test.ts +322 -0
  137. package/src/lib/watch-processor.ts +20 -4
  138. package/src/sdk/sdk.test.ts +243 -0
  139. package/src/templates/.eslintrc.json +6 -0
  140. package/src/templates/capabilities/hello-pepr.ts +26 -11
  141. package/.prettierignore +0 -1
  142. package/CODE_OF_CONDUCT.md +0 -133
  143. package/SECURITY.md +0 -18
  144. package/SUPPORT.md +0 -16
  145. package/codecov.yaml +0 -19
  146. package/commitlint.config.js +0 -1
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=metrics.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.test.d.ts","sourceRoot":"","sources":["../../src/lib/metrics.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=module.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.test.d.ts","sourceRoot":"","sources":["../../src/lib/module.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mutate-request.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutate-request.test.d.ts","sourceRoot":"","sources":["../../src/lib/mutate-request.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=queue.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.test.d.ts","sourceRoot":"","sources":["../../src/lib/queue.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { Unsubscribe } from "./storage";
2
+ export declare class MockStorage {
3
+ private storage;
4
+ subscription: string;
5
+ constructor();
6
+ getItem(key: string): string | null;
7
+ setItem(key: string, value: string): void;
8
+ setItemAndWait(key: string, value: string): Promise<void>;
9
+ removeItem(key: string): void;
10
+ removeItemAndWait(key: string): Promise<void>;
11
+ clear(): void;
12
+ subscribe(): Unsubscribe;
13
+ onReady(): void;
14
+ }
15
+ //# sourceMappingURL=schedule.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.test.d.ts","sourceRoot":"","sources":["../../src/lib/schedule.test.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAA8B;IAC7C,YAAY,EAAE,MAAM,CAAC;;IAKrB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAInC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAIzC,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI7B,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO7C,KAAK,IAAI,IAAI;IAIb,SAAS,IAAI,WAAW;IAMxB,OAAO,IAAI,IAAI;CAKhB"}
@@ -4,6 +4,7 @@ export type DataSender = (op: DataOp, keys: string[], value?: string) => void;
4
4
  export type DataReceiver = (data: DataStore) => void;
5
5
  export type Unsubscribe = () => void;
6
6
  export declare function v2StoreKey(key: string): string;
7
+ export declare function v2UnescapedStoreKey(key: string): string;
7
8
  export declare function stripV2Prefix(key: string): string;
8
9
  export interface PeprStore {
9
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/lib/storage.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;AACtC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC/C,MAAM,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAC9E,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;AACrD,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAKrC,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,UAErC;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,UAExC;AACD,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpC;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1C;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,YAAY,GAAG,WAAW,CAAC;IAE/C;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,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.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.test.d.ts","sourceRoot":"","sources":["../../src/lib/storage.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tls.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tls.test.d.ts","sourceRoot":"","sources":["../../src/lib/tls.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../src/lib/utils.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=validate-request.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-request.test.d.ts","sourceRoot":"","sources":["../../src/lib/validate-request.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"watch-processor.d.ts","sourceRoot":"","sources":["../../src/lib/watch-processor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAO,gBAAgB,EAAY,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEvF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAwB1C;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,UAAU,EAAE,QAMpD;AA6ED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,MAAW,EAAE,GAAG,CAAC,EAAE,gBAAgB,QAOtF"}
1
+ {"version":3,"file":"watch-processor.d.ts","sourceRoot":"","sources":["../../src/lib/watch-processor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAO,gBAAgB,EAAY,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEvF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA4B1C;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,UAAU,EAAE,QAMpD;AAyFD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,MAAW,EAAE,GAAG,CAAC,EAAE,gBAAgB,QAOtF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=watch-processor.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch-processor.test.d.ts","sourceRoot":"","sources":["../../src/lib/watch-processor.test.ts"],"names":[],"mappings":""}
package/dist/lib.js CHANGED
@@ -51,7 +51,7 @@ var R = __toESM(require("ramda"));
51
51
 
52
52
  // src/lib/capability.ts
53
53
  var import_kubernetes_fluent_client6 = require("kubernetes-fluent-client");
54
- var import_ramda7 = require("ramda");
54
+ var import_ramda6 = require("ramda");
55
55
 
56
56
  // src/lib/logger.ts
57
57
  var import_pino = require("pino");
@@ -74,7 +74,7 @@ if (process.env.LOG_LEVEL) {
74
74
  var logger_default = Log;
75
75
 
76
76
  // src/lib/module.ts
77
- var import_ramda5 = require("ramda");
77
+ var import_ramda4 = require("ramda");
78
78
 
79
79
  // src/lib/controller/index.ts
80
80
  var import_express = __toESM(require("express"));
@@ -88,13 +88,17 @@ var loggingPrefix = "MetricsCollector";
88
88
  var MetricsCollector = class {
89
89
  #registry;
90
90
  #counters = /* @__PURE__ */ new Map();
91
+ #gauges = /* @__PURE__ */ new Map();
91
92
  #summaries = /* @__PURE__ */ new Map();
92
93
  #prefix;
94
+ #cacheMissWindows = /* @__PURE__ */ new Map();
93
95
  #metricNames = {
94
96
  errors: "errors",
95
97
  alerts: "alerts",
96
- mutate: "Mutate",
97
- validate: "Validate"
98
+ mutate: "mutate",
99
+ validate: "validate",
100
+ cacheMiss: "cache_miss",
101
+ resyncFailureCount: "resync_failure_count"
98
102
  };
99
103
  /**
100
104
  * Creates a MetricsCollector instance with prefixed metrics.
@@ -107,9 +111,11 @@ var MetricsCollector = class {
107
111
  this.addCounter(this.#metricNames.alerts, "Mutation/Validate bad api token received");
108
112
  this.addSummary(this.#metricNames.mutate, "Mutation operation summary");
109
113
  this.addSummary(this.#metricNames.validate, "Validation operation summary");
114
+ this.addGauge(this.#metricNames.cacheMiss, "Number of cache misses per window", ["window"]);
115
+ this.addGauge(this.#metricNames.resyncFailureCount, "Number of failures per resync operation", ["count"]);
110
116
  }
111
117
  #getMetricName = (name) => `${this.#prefix}_${name}`;
112
- #addMetric = (collection, MetricType, name, help) => {
118
+ #addMetric = (collection, MetricType, name, help, labelNames) => {
113
119
  if (collection.has(this.#getMetricName(name))) {
114
120
  logger_default.debug(`Metric for ${name} already exists`, loggingPrefix);
115
121
  return;
@@ -117,19 +123,26 @@ var MetricsCollector = class {
117
123
  const metric = new MetricType({
118
124
  name: this.#getMetricName(name),
119
125
  help,
120
- registers: [this.#registry]
126
+ registers: [this.#registry],
127
+ labelNames
121
128
  });
122
129
  collection.set(this.#getMetricName(name), metric);
123
130
  };
124
131
  addCounter = (name, help) => {
125
- this.#addMetric(this.#counters, import_prom_client.default.Counter, name, help);
132
+ this.#addMetric(this.#counters, import_prom_client.default.Counter, name, help, []);
126
133
  };
127
134
  addSummary = (name, help) => {
128
- this.#addMetric(this.#summaries, import_prom_client.default.Summary, name, help);
135
+ this.#addMetric(this.#summaries, import_prom_client.default.Summary, name, help, []);
136
+ };
137
+ addGauge = (name, help, labelNames) => {
138
+ this.#addMetric(this.#gauges, import_prom_client.default.Gauge, name, help, labelNames);
129
139
  };
130
140
  incCounter = (name) => {
131
141
  this.#counters.get(this.#getMetricName(name))?.inc();
132
142
  };
143
+ incGauge = (name, labels, value = 1) => {
144
+ this.#gauges.get(this.#getMetricName(name))?.inc(labels || {}, value);
145
+ };
133
146
  /**
134
147
  * Increments the error counter.
135
148
  */
@@ -158,7 +171,42 @@ var MetricsCollector = class {
158
171
  static observeStart() {
159
172
  return import_perf_hooks.performance.now();
160
173
  }
174
+ /**
175
+ * Increments the cache miss gauge for a given label.
176
+ * @param label - The label for the cache miss.
177
+ */
178
+ incCacheMiss = (window) => {
179
+ this.incGauge(this.#metricNames.cacheMiss, { window });
180
+ };
181
+ /**
182
+ * Increments the retry count gauge.
183
+ * @param count - The count to increment by.
184
+ */
185
+ incRetryCount = (count) => {
186
+ this.incGauge(this.#metricNames.resyncFailureCount, { count });
187
+ };
188
+ /**
189
+ * Initializes the cache miss gauge for a given label.
190
+ * @param label - The label for the cache miss.
191
+ */
192
+ initCacheMissWindow = (window) => {
193
+ this.#rollCacheMissWindows();
194
+ this.#gauges.get(this.#getMetricName(this.#metricNames.cacheMiss))?.set({ window }, 0);
195
+ this.#cacheMissWindows.set(window, 0);
196
+ };
197
+ /**
198
+ * Manages the size of the cache miss gauge map.
199
+ */
200
+ #rollCacheMissWindows = () => {
201
+ const maxCacheMissWindows = process.env.PEPR_MAX_CACHE_MISS_WINDOWS ? parseInt(process.env.PEPR_MAX_CACHE_MISS_WINDOWS, 10) : void 0;
202
+ if (maxCacheMissWindows !== void 0 && this.#cacheMissWindows.size >= maxCacheMissWindows) {
203
+ const firstKey = this.#cacheMissWindows.keys().next().value;
204
+ this.#cacheMissWindows.delete(firstKey);
205
+ this.#gauges.get(this.#getMetricName(this.#metricNames.cacheMiss))?.remove({ window: firstKey });
206
+ }
207
+ };
161
208
  };
209
+ var metricsCollector = new MetricsCollector("pepr");
162
210
 
163
211
  // src/lib/mutate-processor.ts
164
212
  var import_fast_json_patch = __toESM(require("fast-json-patch"));
@@ -830,7 +878,7 @@ var Controller = class _Controller {
830
878
  // Track whether the server is running
831
879
  #running = false;
832
880
  // Metrics collector
833
- #metricsCollector = new MetricsCollector("pepr");
881
+ #metricsCollector = metricsCollector;
834
882
  // The token used to authenticate requests
835
883
  #token = "";
836
884
  // The express app instance
@@ -1122,7 +1170,6 @@ function sanitizeResourceName(name) {
1122
1170
  }
1123
1171
 
1124
1172
  // src/lib/helpers.ts
1125
- var import_ramda4 = require("ramda");
1126
1173
  function checkOverlap(bindingFilters, objectFilters) {
1127
1174
  if (Object.keys(bindingFilters).length === 0) {
1128
1175
  return true;
@@ -1235,9 +1282,10 @@ var Queue = class {
1235
1282
 
1236
1283
  // src/lib/watch-processor.ts
1237
1284
  var watchCfg = {
1238
- retryMax: process.env.PEPR_RETRYMAX ? parseInt(process.env.PEPR_RETRYMAX, 10) : 5,
1239
- retryDelaySec: process.env.PEPR_RETRYDELAYSECONDS ? parseInt(process.env.PEPR_RETRYDELAYSECONDS, 10) : 5,
1240
- resyncIntervalSec: process.env.PEPR_RESYNCINTERVALSECONDS ? parseInt(process.env.PEPR_RESYNCINTERVALSECONDS, 10) : 300
1285
+ resyncFailureMax: process.env.PEPR_RESYNC_FAILURE_MAX ? parseInt(process.env.PEPR_RESYNC_FAILURE_MAX, 10) : 5,
1286
+ resyncDelaySec: process.env.PEPR_RESYNC_DELAY_SECONDS ? parseInt(process.env.PEPR_RESYNC_DELAY_SECONDS, 10) : 5,
1287
+ lastSeenLimitSeconds: process.env.PEPR_LAST_SEEN_LIMIT_SECONDS ? parseInt(process.env.PEPR_LAST_SEEN_LIMIT_SECONDS, 10) : 300,
1288
+ relistIntervalSec: process.env.PEPR_RELIST_INTERVAL_SECONDS ? parseInt(process.env.PEPR_RELIST_INTERVAL_SECONDS, 10) : 1800
1241
1289
  };
1242
1290
  var eventToPhaseMap = {
1243
1291
  ["CREATE" /* Create */]: [import_types2.WatchPhase.Added],
@@ -1295,6 +1343,15 @@ async function runBinding(binding, capabilityNamespaces) {
1295
1343
  watcher.events.on(import_kubernetes_fluent_client5.WatchEvent.NETWORK_ERROR, (err) => logEvent(import_kubernetes_fluent_client5.WatchEvent.NETWORK_ERROR, err.message));
1296
1344
  watcher.events.on(import_kubernetes_fluent_client5.WatchEvent.LIST_ERROR, (err) => logEvent(import_kubernetes_fluent_client5.WatchEvent.LIST_ERROR, err.message));
1297
1345
  watcher.events.on(import_kubernetes_fluent_client5.WatchEvent.LIST, (list) => logEvent(import_kubernetes_fluent_client5.WatchEvent.LIST, JSON.stringify(list, void 0, 2)));
1346
+ watcher.events.on(import_kubernetes_fluent_client5.WatchEvent.CACHE_MISS, (windowName) => {
1347
+ metricsCollector.incCacheMiss(windowName);
1348
+ });
1349
+ watcher.events.on(import_kubernetes_fluent_client5.WatchEvent.INIT_CACHE_MISS, (windowName) => {
1350
+ metricsCollector.initCacheMissWindow(windowName);
1351
+ });
1352
+ watcher.events.on(import_kubernetes_fluent_client5.WatchEvent.INC_RESYNC_FAILURE_COUNT, (retryCount) => {
1353
+ metricsCollector.incRetryCount(retryCount);
1354
+ });
1298
1355
  try {
1299
1356
  await watcher.start();
1300
1357
  } catch (err) {
@@ -1325,7 +1382,7 @@ var PeprModule = class {
1325
1382
  * @param opts Options for the Pepr runtime
1326
1383
  */
1327
1384
  constructor({ description, pepr }, capabilities = [], opts = {}) {
1328
- const config = (0, import_ramda5.clone)(pepr);
1385
+ const config = (0, import_ramda4.clone)(pepr);
1329
1386
  config.description = description;
1330
1387
  ValidateError(config.onError);
1331
1388
  if (isBuildMode()) {
@@ -1372,13 +1429,16 @@ var PeprModule = class {
1372
1429
  };
1373
1430
 
1374
1431
  // src/lib/storage.ts
1375
- var import_ramda6 = require("ramda");
1432
+ var import_ramda5 = require("ramda");
1376
1433
  var import_json_pointer = __toESM(require("json-pointer"));
1377
1434
  var MAX_WAIT_TIME = 15e3;
1378
1435
  var STORE_VERSION_PREFIX = "v2";
1379
1436
  function v2StoreKey(key) {
1380
1437
  return `${STORE_VERSION_PREFIX}-${import_json_pointer.default.escape(key)}`;
1381
1438
  }
1439
+ function v2UnescapedStoreKey(key) {
1440
+ return `${STORE_VERSION_PREFIX}-${key}`;
1441
+ }
1382
1442
  var Storage = class {
1383
1443
  #store = {};
1384
1444
  #send;
@@ -1393,18 +1453,21 @@ var Storage = class {
1393
1453
  this.#store = data || {};
1394
1454
  this.#onReady();
1395
1455
  for (const idx in this.#subscribers) {
1396
- this.#subscribers[idx]((0, import_ramda6.clone)(this.#store));
1456
+ this.#subscribers[idx]((0, import_ramda5.clone)(this.#store));
1397
1457
  }
1398
1458
  };
1399
1459
  getItem = (key) => {
1400
- const result = this.#store[v2StoreKey(key)] || null;
1460
+ const result = this.#store[v2UnescapedStoreKey(key)] || null;
1401
1461
  if (result !== null && typeof result !== "function" && typeof result !== "object") {
1402
1462
  return result;
1403
1463
  }
1404
1464
  return null;
1405
1465
  };
1406
1466
  clear = () => {
1407
- this.#dispatchUpdate("remove", Object.keys(this.#store));
1467
+ this.#dispatchUpdate(
1468
+ "remove",
1469
+ Object.keys(this.#store).map((key) => import_json_pointer.default.escape(key))
1470
+ );
1408
1471
  };
1409
1472
  removeItem = (key) => {
1410
1473
  this.#dispatchUpdate("remove", [v2StoreKey(key)]);
@@ -1424,7 +1487,7 @@ var Storage = class {
1424
1487
  this.#dispatchUpdate("add", [v2StoreKey(key)], value);
1425
1488
  return new Promise((resolve, reject) => {
1426
1489
  const unsubscribe = this.subscribe((data) => {
1427
- if (data[`${v2StoreKey(key)}`] === value) {
1490
+ if (data[`${v2UnescapedStoreKey(key)}`] === value) {
1428
1491
  unsubscribe();
1429
1492
  resolve();
1430
1493
  }
@@ -1446,7 +1509,7 @@ var Storage = class {
1446
1509
  this.#dispatchUpdate("remove", [v2StoreKey(key)]);
1447
1510
  return new Promise((resolve, reject) => {
1448
1511
  const unsubscribe = this.subscribe((data) => {
1449
- if (!Object.hasOwn(data, `${v2StoreKey(key)}`)) {
1512
+ if (!Object.hasOwn(data, `${v2UnescapedStoreKey(key)}`)) {
1450
1513
  unsubscribe();
1451
1514
  resolve();
1452
1515
  }
@@ -1474,7 +1537,7 @@ var Storage = class {
1474
1537
  };
1475
1538
  #onReady = () => {
1476
1539
  for (const handler of this.#readyHandlers) {
1477
- handler((0, import_ramda6.clone)(this.#store));
1540
+ handler((0, import_ramda5.clone)(this.#store));
1478
1541
  }
1479
1542
  this.#onReady = () => {
1480
1543
  };
@@ -1551,8 +1614,7 @@ var OnSchedule = class {
1551
1614
  getDuration() {
1552
1615
  switch (this.unit) {
1553
1616
  case "seconds":
1554
- if (this.every < 10)
1555
- throw new Error("10 Seconds in the smallest interval allowed");
1617
+ if (this.every < 10) throw new Error("10 Seconds in the smallest interval allowed");
1556
1618
  this.duration = 1e3 * this.every;
1557
1619
  break;
1558
1620
  case "minutes":
@@ -1770,7 +1832,7 @@ var Capability = class {
1770
1832
  const commonChain = { WithLabel, WithAnnotation, Mutate, Validate, Watch, Reconcile };
1771
1833
  const isNotEmpty = (value) => Object.keys(value).length > 0;
1772
1834
  const log = (message, cbString) => {
1773
- const filteredObj = (0, import_ramda7.pickBy)(isNotEmpty, binding.filters);
1835
+ const filteredObj = (0, import_ramda6.pickBy)(isNotEmpty, binding.filters);
1774
1836
  logger_default.info(`${message} configured for ${binding.event}`, prefix);
1775
1837
  logger_default.info(filteredObj, prefix);
1776
1838
  logger_default.debug(cbString, prefix);