slotlock 0.6.3 → 0.7.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +467 -0
  2. package/CONTRIBUTING.md +12 -5
  3. package/README.md +50 -1551
  4. package/SECURITY.md +5 -2
  5. package/SPEC.md +1 -1
  6. package/agent-server.d.ts +160 -8
  7. package/agent-server.js +559 -44
  8. package/agent-store-backend.d.ts +34 -1
  9. package/agent-store-backend.js +1399 -38
  10. package/api-keys.d.ts +69 -3
  11. package/api-keys.js +217 -28
  12. package/application-api.d.ts +56 -3
  13. package/application-api.js +826 -15
  14. package/approvals.d.ts +88 -0
  15. package/approvals.js +293 -0
  16. package/assistant.d.ts +40 -0
  17. package/assistant.js +115 -0
  18. package/billing.d.ts +114 -0
  19. package/billing.js +258 -0
  20. package/config.d.ts +25 -4
  21. package/config.js +72 -3
  22. package/dashboard-icon.d.ts +1 -0
  23. package/dashboard-icon.js +5 -0
  24. package/dashboard.d.ts +203 -7
  25. package/dashboard.js +1545 -64
  26. package/ddl.d.ts +51 -12
  27. package/ddl.js +2566 -54
  28. package/event-feed.d.ts +30 -4
  29. package/event-feed.js +171 -19
  30. package/index.d.ts +15 -4
  31. package/index.js +8 -2
  32. package/maintenance.d.ts +10 -0
  33. package/maintenance.js +16 -2
  34. package/metrics.d.ts +41 -0
  35. package/metrics.js +22 -0
  36. package/openapi.json +14675 -5957
  37. package/otel.d.ts +86 -0
  38. package/otel.js +273 -0
  39. package/overage.d.ts +33 -0
  40. package/overage.js +115 -0
  41. package/package.json +1 -1
  42. package/partner-billing.d.ts +81 -0
  43. package/partner-billing.js +333 -0
  44. package/partner-names.d.ts +8 -0
  45. package/partner-names.js +10 -0
  46. package/partners.d.ts +147 -0
  47. package/partners.js +375 -0
  48. package/plans.d.ts +92 -0
  49. package/plans.js +115 -0
  50. package/quotas.d.ts +108 -0
  51. package/quotas.js +258 -0
  52. package/rate-limit.d.ts +21 -1
  53. package/rate-limit.js +82 -15
  54. package/resource-profile.d.ts +135 -0
  55. package/resource-profile.js +263 -0
  56. package/rest-api.d.ts +2 -0
  57. package/rest-api.js +68 -3
  58. package/sandbox.d.ts +70 -0
  59. package/sandbox.js +295 -0
  60. package/self-host.d.ts +33 -5
  61. package/self-host.js +950 -22
  62. package/slotlock.manifest.json +1 -1
  63. package/store.d.ts +373 -4
  64. package/store.js +1212 -118
  65. package/teams.d.ts +25 -0
  66. package/teams.js +63 -0
  67. package/timezone.js +13 -1
  68. package/types.d.ts +95 -1
  69. package/usage.d.ts +106 -0
  70. package/usage.js +238 -0
package/metrics.js CHANGED
@@ -7,6 +7,7 @@ const REFUSAL_REASONS = [
7
7
  'series_writes_busy',
8
8
  'maintenance_busy',
9
9
  'request_too_large',
10
+ 'quota_exceeded',
10
11
  ];
11
12
  const MAINTENANCE_COUNTS = [
12
13
  'extended',
@@ -17,6 +18,7 @@ const MAINTENANCE_COUNTS = [
17
18
  'staleSources',
18
19
  'noShows',
19
20
  'waitlistOffers',
21
+ 'approvalsExpired',
20
22
  ];
21
23
  /** A label value: an operation, protocol or outcome code. Anything else is counted as `other`. */
22
24
  const LABEL = /^[a-z0-9_.]{1,64}$/;
@@ -43,6 +45,9 @@ class Counter {
43
45
  current.value += amount;
44
46
  this.values.set(id, current);
45
47
  }
48
+ points() {
49
+ return [...this.values.values()].map(({ labels, value }) => ({ labels, value }));
50
+ }
46
51
  render(type = 'counter') {
47
52
  const lines = [`# HELP ${this.name} ${this.help}`, `# TYPE ${this.name} ${type}`];
48
53
  for (const { labels, value } of this.values.values()) {
@@ -75,6 +80,9 @@ class Histogram {
75
80
  current.count += 1;
76
81
  this.series.set(id, current);
77
82
  }
83
+ points() {
84
+ return [...this.series.values()].map(({ labels, buckets, sum, count }) => ({ labels, cumulative: [...buckets], sum, count }));
85
+ }
78
86
  render() {
79
87
  const lines = [`# HELP ${this.name} ${this.help}`, `# TYPE ${this.name} histogram`];
80
88
  for (const { labels, buckets, sum, count } of this.series.values()) {
@@ -99,6 +107,7 @@ export function createSlotlockMetrics(info) {
99
107
  const refused = new Counter('slotlock_refusals_total', 'Requests refused before they ran, by reason.');
100
108
  const passes = new Counter('slotlock_maintenance_passes_total', 'Maintenance passes, by whether one was capped.');
101
109
  const upkeep = new Counter('slotlock_maintenance_items_total', 'What maintenance did, by kind: series extended, holds pruned, no-shows released, waitlist offers made, and so on.');
110
+ const clients = new Counter('slotlock_requests_by_client_total', 'Authenticated requests by the integrator their Slotlock-Client field names (known ones, other or none).');
102
111
  const deliveries = new Counter('slotlock_webhook_deliveries_total', 'Webhook changes delivered, and deliveries that failed and will be retried.');
103
112
  return {
104
113
  event(event) {
@@ -134,6 +143,9 @@ export function createSlotlockMetrics(info) {
134
143
  refusedScrape() {
135
144
  refused.add({ reason: 'metrics_auth_refused' });
136
145
  },
146
+ client(name) {
147
+ clients.add({ client: label(name) });
148
+ },
137
149
  webhooks(result) {
138
150
  if (result.delivered > 0)
139
151
  deliveries.add({ result: 'delivered' }, result.delivered);
@@ -159,8 +171,18 @@ export function createSlotlockMetrics(info) {
159
171
  ...passes.render(),
160
172
  ...upkeep.render(),
161
173
  ...deliveries.render(),
174
+ ...clients.render(),
162
175
  ];
163
176
  return `${lines.join('\n')}\n`;
164
177
  },
178
+ collect() {
179
+ const counter = (metric) => ({ name: metric.name, help: metric.help, points: metric.points() });
180
+ return {
181
+ startedAtMs: started * 1000,
182
+ counters: [calls, confirmations, subscriptions, refused, passes, upkeep, deliveries, clients].map(counter),
183
+ histograms: [{ name: duration.name, help: duration.help, bounds: BUCKETS, points: duration.points() }],
184
+ gauges: [{ name: 'slotlock_subscriptions_open', help: 'MCP subscriptions open now.', points: [{ labels: {}, value: open }] }],
185
+ };
186
+ },
165
187
  };
166
188
  }