@contractspec/lib.metering 1.57.0 → 1.59.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 (65) hide show
  1. package/dist/aggregation/index.d.ts +119 -122
  2. package/dist/aggregation/index.d.ts.map +1 -1
  3. package/dist/aggregation/index.js +257 -265
  4. package/dist/analytics/posthog-metering-reader.d.ts +32 -36
  5. package/dist/analytics/posthog-metering-reader.d.ts.map +1 -1
  6. package/dist/analytics/posthog-metering-reader.js +239 -179
  7. package/dist/analytics/posthog-metering.d.ts +30 -34
  8. package/dist/analytics/posthog-metering.d.ts.map +1 -1
  9. package/dist/analytics/posthog-metering.js +45 -45
  10. package/dist/browser/aggregation/index.js +265 -0
  11. package/dist/browser/analytics/posthog-metering-reader.js +266 -0
  12. package/dist/browser/analytics/posthog-metering.js +45 -0
  13. package/dist/browser/contracts/index.js +617 -0
  14. package/dist/browser/docs/index.js +62 -0
  15. package/dist/browser/docs/metering.docblock.js +62 -0
  16. package/dist/browser/entities/index.js +350 -0
  17. package/dist/browser/events.js +228 -0
  18. package/dist/browser/index.js +1879 -0
  19. package/dist/browser/metering.capability.js +28 -0
  20. package/dist/browser/metering.feature.js +52 -0
  21. package/dist/contracts/index.d.ts +1076 -1082
  22. package/dist/contracts/index.d.ts.map +1 -1
  23. package/dist/contracts/index.js +616 -1030
  24. package/dist/docs/index.d.ts +2 -1
  25. package/dist/docs/index.d.ts.map +1 -0
  26. package/dist/docs/index.js +63 -1
  27. package/dist/docs/metering.docblock.d.ts +2 -1
  28. package/dist/docs/metering.docblock.d.ts.map +1 -0
  29. package/dist/docs/metering.docblock.js +17 -22
  30. package/dist/entities/index.d.ts +186 -191
  31. package/dist/entities/index.d.ts.map +1 -1
  32. package/dist/entities/index.js +340 -407
  33. package/dist/events.d.ts +411 -417
  34. package/dist/events.d.ts.map +1 -1
  35. package/dist/events.js +226 -414
  36. package/dist/index.d.ts +9 -8
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +1880 -10
  39. package/dist/metering.capability.d.ts +2 -7
  40. package/dist/metering.capability.d.ts.map +1 -1
  41. package/dist/metering.capability.js +29 -33
  42. package/dist/metering.feature.d.ts +1 -6
  43. package/dist/metering.feature.d.ts.map +1 -1
  44. package/dist/metering.feature.js +51 -132
  45. package/dist/node/aggregation/index.js +265 -0
  46. package/dist/node/analytics/posthog-metering-reader.js +266 -0
  47. package/dist/node/analytics/posthog-metering.js +45 -0
  48. package/dist/node/contracts/index.js +617 -0
  49. package/dist/node/docs/index.js +62 -0
  50. package/dist/node/docs/metering.docblock.js +62 -0
  51. package/dist/node/entities/index.js +350 -0
  52. package/dist/node/events.js +228 -0
  53. package/dist/node/index.js +1879 -0
  54. package/dist/node/metering.capability.js +28 -0
  55. package/dist/node/metering.feature.js +52 -0
  56. package/package.json +133 -34
  57. package/dist/aggregation/index.js.map +0 -1
  58. package/dist/analytics/posthog-metering-reader.js.map +0 -1
  59. package/dist/analytics/posthog-metering.js.map +0 -1
  60. package/dist/contracts/index.js.map +0 -1
  61. package/dist/docs/metering.docblock.js.map +0 -1
  62. package/dist/entities/index.js.map +0 -1
  63. package/dist/events.js.map +0 -1
  64. package/dist/metering.capability.js.map +0 -1
  65. package/dist/metering.feature.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","names":[],"sources":["../src/events.ts"],"mappings":";;;;;;;cAsIa,kBAAA,EAAkB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAU7B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,kBAAA,EAAkB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAU7B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;cAKW,kBAAA,EAAkB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAU7B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAVF;;;AAAA,cAea,uBAAA,EAAuB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUlC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;cAKW,oBAAA,EAAoB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAU/B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,qBAAA,EAAqB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUhC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,sBAAA,EAAsB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUjC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,yBAAA,EAAyB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUpC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,cAAA;;;YASZ,yBAAA,CAAA,SAAA"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAmIA;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAU7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;GAU7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAU7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;GAUlC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAU/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUjC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUpC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS1B,CAAC"}
package/dist/events.js CHANGED
@@ -1,417 +1,229 @@
1
+ // @bun
2
+ // src/events.ts
1
3
  import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
2
4
  import { defineEvent } from "@contractspec/lib.contracts";
3
-
4
- //#region src/events.ts
5
- const MetricDefinedPayload = defineSchemaModel({
6
- name: "MetricDefinedEventPayload",
7
- description: "Payload when a metric is defined",
8
- fields: {
9
- metricId: {
10
- type: ScalarTypeEnum.String_unsecure(),
11
- isOptional: false
12
- },
13
- key: {
14
- type: ScalarTypeEnum.String_unsecure(),
15
- isOptional: false
16
- },
17
- name: {
18
- type: ScalarTypeEnum.String_unsecure(),
19
- isOptional: false
20
- },
21
- unit: {
22
- type: ScalarTypeEnum.String_unsecure(),
23
- isOptional: false
24
- },
25
- aggregationType: {
26
- type: ScalarTypeEnum.String_unsecure(),
27
- isOptional: false
28
- },
29
- orgId: {
30
- type: ScalarTypeEnum.String_unsecure(),
31
- isOptional: true
32
- },
33
- createdBy: {
34
- type: ScalarTypeEnum.String_unsecure(),
35
- isOptional: true
36
- },
37
- createdAt: {
38
- type: ScalarTypeEnum.DateTime(),
39
- isOptional: false
40
- }
41
- }
42
- });
43
- const MetricUpdatedPayload = defineSchemaModel({
44
- name: "MetricUpdatedEventPayload",
45
- description: "Payload when a metric is updated",
46
- fields: {
47
- metricId: {
48
- type: ScalarTypeEnum.String_unsecure(),
49
- isOptional: false
50
- },
51
- key: {
52
- type: ScalarTypeEnum.String_unsecure(),
53
- isOptional: false
54
- },
55
- changes: {
56
- type: ScalarTypeEnum.JSON(),
57
- isOptional: false
58
- },
59
- updatedBy: {
60
- type: ScalarTypeEnum.String_unsecure(),
61
- isOptional: true
62
- },
63
- updatedAt: {
64
- type: ScalarTypeEnum.DateTime(),
65
- isOptional: false
66
- }
67
- }
68
- });
69
- const UsageRecordedPayload = defineSchemaModel({
70
- name: "UsageRecordedEventPayload",
71
- description: "Payload when usage is recorded",
72
- fields: {
73
- recordId: {
74
- type: ScalarTypeEnum.String_unsecure(),
75
- isOptional: false
76
- },
77
- metricKey: {
78
- type: ScalarTypeEnum.String_unsecure(),
79
- isOptional: false
80
- },
81
- subjectType: {
82
- type: ScalarTypeEnum.String_unsecure(),
83
- isOptional: false
84
- },
85
- subjectId: {
86
- type: ScalarTypeEnum.String_unsecure(),
87
- isOptional: false
88
- },
89
- quantity: {
90
- type: ScalarTypeEnum.Float_unsecure(),
91
- isOptional: false
92
- },
93
- source: {
94
- type: ScalarTypeEnum.String_unsecure(),
95
- isOptional: true
96
- },
97
- timestamp: {
98
- type: ScalarTypeEnum.DateTime(),
99
- isOptional: false
100
- }
101
- }
102
- });
103
- const UsageBatchRecordedPayload = defineSchemaModel({
104
- name: "UsageBatchRecordedEventPayload",
105
- description: "Payload when a batch of usage is recorded",
106
- fields: {
107
- recordCount: {
108
- type: ScalarTypeEnum.Int_unsecure(),
109
- isOptional: false
110
- },
111
- metricKeys: {
112
- type: ScalarTypeEnum.JSON(),
113
- isOptional: false
114
- },
115
- totalQuantity: {
116
- type: ScalarTypeEnum.Float_unsecure(),
117
- isOptional: false
118
- },
119
- timestamp: {
120
- type: ScalarTypeEnum.DateTime(),
121
- isOptional: false
122
- }
123
- }
124
- });
125
- const UsageAggregatedPayload = defineSchemaModel({
126
- name: "UsageAggregatedEventPayload",
127
- description: "Payload when usage is aggregated",
128
- fields: {
129
- summaryId: {
130
- type: ScalarTypeEnum.String_unsecure(),
131
- isOptional: false
132
- },
133
- metricKey: {
134
- type: ScalarTypeEnum.String_unsecure(),
135
- isOptional: false
136
- },
137
- subjectType: {
138
- type: ScalarTypeEnum.String_unsecure(),
139
- isOptional: false
140
- },
141
- subjectId: {
142
- type: ScalarTypeEnum.String_unsecure(),
143
- isOptional: false
144
- },
145
- periodType: {
146
- type: ScalarTypeEnum.String_unsecure(),
147
- isOptional: false
148
- },
149
- periodStart: {
150
- type: ScalarTypeEnum.DateTime(),
151
- isOptional: false
152
- },
153
- periodEnd: {
154
- type: ScalarTypeEnum.DateTime(),
155
- isOptional: false
156
- },
157
- totalQuantity: {
158
- type: ScalarTypeEnum.Float_unsecure(),
159
- isOptional: false
160
- },
161
- recordCount: {
162
- type: ScalarTypeEnum.Int_unsecure(),
163
- isOptional: false
164
- },
165
- aggregatedAt: {
166
- type: ScalarTypeEnum.DateTime(),
167
- isOptional: false
168
- }
169
- }
170
- });
171
- const ThresholdCreatedPayload = defineSchemaModel({
172
- name: "ThresholdCreatedEventPayload",
173
- description: "Payload when a threshold is created",
174
- fields: {
175
- thresholdId: {
176
- type: ScalarTypeEnum.String_unsecure(),
177
- isOptional: false
178
- },
179
- metricKey: {
180
- type: ScalarTypeEnum.String_unsecure(),
181
- isOptional: false
182
- },
183
- subjectType: {
184
- type: ScalarTypeEnum.String_unsecure(),
185
- isOptional: true
186
- },
187
- subjectId: {
188
- type: ScalarTypeEnum.String_unsecure(),
189
- isOptional: true
190
- },
191
- threshold: {
192
- type: ScalarTypeEnum.Float_unsecure(),
193
- isOptional: false
194
- },
195
- action: {
196
- type: ScalarTypeEnum.String_unsecure(),
197
- isOptional: false
198
- },
199
- createdAt: {
200
- type: ScalarTypeEnum.DateTime(),
201
- isOptional: false
202
- }
203
- }
204
- });
205
- const ThresholdExceededPayload = defineSchemaModel({
206
- name: "ThresholdExceededEventPayload",
207
- description: "Payload when a threshold is exceeded",
208
- fields: {
209
- alertId: {
210
- type: ScalarTypeEnum.String_unsecure(),
211
- isOptional: false
212
- },
213
- thresholdId: {
214
- type: ScalarTypeEnum.String_unsecure(),
215
- isOptional: false
216
- },
217
- metricKey: {
218
- type: ScalarTypeEnum.String_unsecure(),
219
- isOptional: false
220
- },
221
- subjectType: {
222
- type: ScalarTypeEnum.String_unsecure(),
223
- isOptional: true
224
- },
225
- subjectId: {
226
- type: ScalarTypeEnum.String_unsecure(),
227
- isOptional: true
228
- },
229
- threshold: {
230
- type: ScalarTypeEnum.Float_unsecure(),
231
- isOptional: false
232
- },
233
- actualValue: {
234
- type: ScalarTypeEnum.Float_unsecure(),
235
- isOptional: false
236
- },
237
- percentageUsed: {
238
- type: ScalarTypeEnum.Float_unsecure(),
239
- isOptional: false
240
- },
241
- action: {
242
- type: ScalarTypeEnum.String_unsecure(),
243
- isOptional: false
244
- },
245
- triggeredAt: {
246
- type: ScalarTypeEnum.DateTime(),
247
- isOptional: false
248
- }
249
- }
250
- });
251
- const ThresholdApproachingPayload = defineSchemaModel({
252
- name: "ThresholdApproachingEventPayload",
253
- description: "Payload when usage is approaching a threshold",
254
- fields: {
255
- thresholdId: {
256
- type: ScalarTypeEnum.String_unsecure(),
257
- isOptional: false
258
- },
259
- metricKey: {
260
- type: ScalarTypeEnum.String_unsecure(),
261
- isOptional: false
262
- },
263
- subjectType: {
264
- type: ScalarTypeEnum.String_unsecure(),
265
- isOptional: true
266
- },
267
- subjectId: {
268
- type: ScalarTypeEnum.String_unsecure(),
269
- isOptional: true
270
- },
271
- threshold: {
272
- type: ScalarTypeEnum.Float_unsecure(),
273
- isOptional: false
274
- },
275
- currentValue: {
276
- type: ScalarTypeEnum.Float_unsecure(),
277
- isOptional: false
278
- },
279
- percentageUsed: {
280
- type: ScalarTypeEnum.Float_unsecure(),
281
- isOptional: false
282
- },
283
- triggeredAt: {
284
- type: ScalarTypeEnum.DateTime(),
285
- isOptional: false
286
- }
287
- }
288
- });
289
- /**
290
- * Emitted when a metric is defined.
291
- */
292
- const MetricDefinedEvent = defineEvent({
293
- meta: {
294
- key: "metric.defined",
295
- version: "1.0.0",
296
- description: "A metric has been defined.",
297
- stability: "stable",
298
- owners: ["@platform.metering"],
299
- tags: ["metering", "metric"]
300
- },
301
- payload: MetricDefinedPayload
302
- });
303
- /**
304
- * Emitted when a metric is updated.
305
- */
306
- const MetricUpdatedEvent = defineEvent({
307
- meta: {
308
- key: "metric.updated",
309
- version: "1.0.0",
310
- description: "A metric has been updated.",
311
- stability: "stable",
312
- owners: ["@platform.metering"],
313
- tags: ["metering", "metric"]
314
- },
315
- payload: MetricUpdatedPayload
316
- });
317
- /**
318
- * Emitted when usage is recorded.
319
- */
320
- const UsageRecordedEvent = defineEvent({
321
- meta: {
322
- key: "usage.recorded",
323
- version: "1.0.0",
324
- description: "Usage has been recorded.",
325
- stability: "stable",
326
- owners: ["@platform.metering"],
327
- tags: ["metering", "usage"]
328
- },
329
- payload: UsageRecordedPayload
330
- });
331
- /**
332
- * Emitted when a batch of usage is recorded.
333
- */
334
- const UsageBatchRecordedEvent = defineEvent({
335
- meta: {
336
- key: "usage.batch_recorded",
337
- version: "1.0.0",
338
- description: "A batch of usage has been recorded.",
339
- stability: "stable",
340
- owners: ["@platform.metering"],
341
- tags: ["metering", "usage"]
342
- },
343
- payload: UsageBatchRecordedPayload
344
- });
345
- /**
346
- * Emitted when usage is aggregated.
347
- */
348
- const UsageAggregatedEvent = defineEvent({
349
- meta: {
350
- key: "usage.aggregated",
351
- version: "1.0.0",
352
- description: "Usage has been aggregated into a summary.",
353
- stability: "stable",
354
- owners: ["@platform.metering"],
355
- tags: ["metering", "usage"]
356
- },
357
- payload: UsageAggregatedPayload
358
- });
359
- /**
360
- * Emitted when a threshold is created.
361
- */
362
- const ThresholdCreatedEvent = defineEvent({
363
- meta: {
364
- key: "threshold.created",
365
- version: "1.0.0",
366
- description: "A usage threshold has been created.",
367
- stability: "stable",
368
- owners: ["@platform.metering"],
369
- tags: ["metering", "threshold"]
370
- },
371
- payload: ThresholdCreatedPayload
372
- });
373
- /**
374
- * Emitted when a threshold is exceeded.
375
- */
376
- const ThresholdExceededEvent = defineEvent({
377
- meta: {
378
- key: "threshold.exceeded",
379
- version: "1.0.0",
380
- description: "Usage has exceeded a threshold.",
381
- stability: "stable",
382
- owners: ["@platform.metering"],
383
- tags: ["metering", "threshold"]
384
- },
385
- payload: ThresholdExceededPayload
386
- });
387
- /**
388
- * Emitted when usage is approaching a threshold.
389
- */
390
- const ThresholdApproachingEvent = defineEvent({
391
- meta: {
392
- key: "threshold.approaching",
393
- version: "1.0.0",
394
- description: "Usage is approaching a threshold.",
395
- stability: "stable",
396
- owners: ["@platform.metering"],
397
- tags: ["metering", "threshold"]
398
- },
399
- payload: ThresholdApproachingPayload
400
- });
401
- /**
402
- * All metering events.
403
- */
404
- const MeteringEvents = {
405
- MetricDefinedEvent,
406
- MetricUpdatedEvent,
407
- UsageRecordedEvent,
408
- UsageBatchRecordedEvent,
409
- UsageAggregatedEvent,
410
- ThresholdCreatedEvent,
411
- ThresholdExceededEvent,
412
- ThresholdApproachingEvent
5
+ var MetricDefinedPayload = defineSchemaModel({
6
+ name: "MetricDefinedEventPayload",
7
+ description: "Payload when a metric is defined",
8
+ fields: {
9
+ metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
10
+ key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
11
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
12
+ unit: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
13
+ aggregationType: {
14
+ type: ScalarTypeEnum.String_unsecure(),
15
+ isOptional: false
16
+ },
17
+ orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
18
+ createdBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
19
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
20
+ }
21
+ });
22
+ var MetricUpdatedPayload = defineSchemaModel({
23
+ name: "MetricUpdatedEventPayload",
24
+ description: "Payload when a metric is updated",
25
+ fields: {
26
+ metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
27
+ key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
28
+ changes: { type: ScalarTypeEnum.JSON(), isOptional: false },
29
+ updatedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
30
+ updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
31
+ }
32
+ });
33
+ var UsageRecordedPayload = defineSchemaModel({
34
+ name: "UsageRecordedEventPayload",
35
+ description: "Payload when usage is recorded",
36
+ fields: {
37
+ recordId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
38
+ metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
39
+ subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
40
+ subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
41
+ quantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
42
+ source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
43
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
44
+ }
45
+ });
46
+ var UsageBatchRecordedPayload = defineSchemaModel({
47
+ name: "UsageBatchRecordedEventPayload",
48
+ description: "Payload when a batch of usage is recorded",
49
+ fields: {
50
+ recordCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
51
+ metricKeys: { type: ScalarTypeEnum.JSON(), isOptional: false },
52
+ totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
53
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false }
54
+ }
55
+ });
56
+ var UsageAggregatedPayload = defineSchemaModel({
57
+ name: "UsageAggregatedEventPayload",
58
+ description: "Payload when usage is aggregated",
59
+ fields: {
60
+ summaryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
61
+ metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
62
+ subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
63
+ subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
64
+ periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
65
+ periodStart: { type: ScalarTypeEnum.DateTime(), isOptional: false },
66
+ periodEnd: { type: ScalarTypeEnum.DateTime(), isOptional: false },
67
+ totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
68
+ recordCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
69
+ aggregatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
70
+ }
71
+ });
72
+ var ThresholdCreatedPayload = defineSchemaModel({
73
+ name: "ThresholdCreatedEventPayload",
74
+ description: "Payload when a threshold is created",
75
+ fields: {
76
+ thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
77
+ metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
78
+ subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
79
+ subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
80
+ threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
81
+ action: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
82
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
83
+ }
84
+ });
85
+ var ThresholdExceededPayload = defineSchemaModel({
86
+ name: "ThresholdExceededEventPayload",
87
+ description: "Payload when a threshold is exceeded",
88
+ fields: {
89
+ alertId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
90
+ thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
91
+ metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
92
+ subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
93
+ subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
94
+ threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
95
+ actualValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
96
+ percentageUsed: {
97
+ type: ScalarTypeEnum.Float_unsecure(),
98
+ isOptional: false
99
+ },
100
+ action: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
101
+ triggeredAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
102
+ }
103
+ });
104
+ var ThresholdApproachingPayload = defineSchemaModel({
105
+ name: "ThresholdApproachingEventPayload",
106
+ description: "Payload when usage is approaching a threshold",
107
+ fields: {
108
+ thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
109
+ metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
110
+ subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
111
+ subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
112
+ threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
113
+ currentValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
114
+ percentageUsed: {
115
+ type: ScalarTypeEnum.Float_unsecure(),
116
+ isOptional: false
117
+ },
118
+ triggeredAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
119
+ }
120
+ });
121
+ var MetricDefinedEvent = defineEvent({
122
+ meta: {
123
+ key: "metric.defined",
124
+ version: "1.0.0",
125
+ description: "A metric has been defined.",
126
+ stability: "stable",
127
+ owners: ["@platform.metering"],
128
+ tags: ["metering", "metric"]
129
+ },
130
+ payload: MetricDefinedPayload
131
+ });
132
+ var MetricUpdatedEvent = defineEvent({
133
+ meta: {
134
+ key: "metric.updated",
135
+ version: "1.0.0",
136
+ description: "A metric has been updated.",
137
+ stability: "stable",
138
+ owners: ["@platform.metering"],
139
+ tags: ["metering", "metric"]
140
+ },
141
+ payload: MetricUpdatedPayload
142
+ });
143
+ var UsageRecordedEvent = defineEvent({
144
+ meta: {
145
+ key: "usage.recorded",
146
+ version: "1.0.0",
147
+ description: "Usage has been recorded.",
148
+ stability: "stable",
149
+ owners: ["@platform.metering"],
150
+ tags: ["metering", "usage"]
151
+ },
152
+ payload: UsageRecordedPayload
153
+ });
154
+ var UsageBatchRecordedEvent = defineEvent({
155
+ meta: {
156
+ key: "usage.batch_recorded",
157
+ version: "1.0.0",
158
+ description: "A batch of usage has been recorded.",
159
+ stability: "stable",
160
+ owners: ["@platform.metering"],
161
+ tags: ["metering", "usage"]
162
+ },
163
+ payload: UsageBatchRecordedPayload
164
+ });
165
+ var UsageAggregatedEvent = defineEvent({
166
+ meta: {
167
+ key: "usage.aggregated",
168
+ version: "1.0.0",
169
+ description: "Usage has been aggregated into a summary.",
170
+ stability: "stable",
171
+ owners: ["@platform.metering"],
172
+ tags: ["metering", "usage"]
173
+ },
174
+ payload: UsageAggregatedPayload
175
+ });
176
+ var ThresholdCreatedEvent = defineEvent({
177
+ meta: {
178
+ key: "threshold.created",
179
+ version: "1.0.0",
180
+ description: "A usage threshold has been created.",
181
+ stability: "stable",
182
+ owners: ["@platform.metering"],
183
+ tags: ["metering", "threshold"]
184
+ },
185
+ payload: ThresholdCreatedPayload
186
+ });
187
+ var ThresholdExceededEvent = defineEvent({
188
+ meta: {
189
+ key: "threshold.exceeded",
190
+ version: "1.0.0",
191
+ description: "Usage has exceeded a threshold.",
192
+ stability: "stable",
193
+ owners: ["@platform.metering"],
194
+ tags: ["metering", "threshold"]
195
+ },
196
+ payload: ThresholdExceededPayload
197
+ });
198
+ var ThresholdApproachingEvent = defineEvent({
199
+ meta: {
200
+ key: "threshold.approaching",
201
+ version: "1.0.0",
202
+ description: "Usage is approaching a threshold.",
203
+ stability: "stable",
204
+ owners: ["@platform.metering"],
205
+ tags: ["metering", "threshold"]
206
+ },
207
+ payload: ThresholdApproachingPayload
208
+ });
209
+ var MeteringEvents = {
210
+ MetricDefinedEvent,
211
+ MetricUpdatedEvent,
212
+ UsageRecordedEvent,
213
+ UsageBatchRecordedEvent,
214
+ UsageAggregatedEvent,
215
+ ThresholdCreatedEvent,
216
+ ThresholdExceededEvent,
217
+ ThresholdApproachingEvent
218
+ };
219
+ export {
220
+ UsageRecordedEvent,
221
+ UsageBatchRecordedEvent,
222
+ UsageAggregatedEvent,
223
+ ThresholdExceededEvent,
224
+ ThresholdCreatedEvent,
225
+ ThresholdApproachingEvent,
226
+ MetricUpdatedEvent,
227
+ MetricDefinedEvent,
228
+ MeteringEvents
413
229
  };
414
-
415
- //#endregion
416
- export { MeteringEvents, MetricDefinedEvent, MetricUpdatedEvent, ThresholdApproachingEvent, ThresholdCreatedEvent, ThresholdExceededEvent, UsageAggregatedEvent, UsageBatchRecordedEvent, UsageRecordedEvent };
417
- //# sourceMappingURL=events.js.map