@contractspec/lib.metering 0.0.0-canary-20260113162409
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/LICENSE +21 -0
- package/README.md +198 -0
- package/dist/aggregation/index.d.ts +156 -0
- package/dist/aggregation/index.d.ts.map +1 -0
- package/dist/aggregation/index.js +274 -0
- package/dist/aggregation/index.js.map +1 -0
- package/dist/contracts/index.d.ts +1139 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +1032 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/docs/metering.docblock.d.ts +1 -0
- package/dist/docs/metering.docblock.js +67 -0
- package/dist/docs/metering.docblock.js.map +1 -0
- package/dist/entities/index.d.ts +231 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +418 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/events.d.ts +540 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +417 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8 -0
- package/dist/metering.capability.d.ts +8 -0
- package/dist/metering.capability.d.ts.map +1 -0
- package/dist/metering.capability.js +33 -0
- package/dist/metering.capability.js.map +1 -0
- package/dist/metering.feature.d.ts +12 -0
- package/dist/metering.feature.d.ts.map +1 -0
- package/dist/metering.feature.js +134 -0
- package/dist/metering.feature.js.map +1 -0
- package/package.json +75 -0
package/dist/events.js
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
2
|
+
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
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
//#endregion
|
|
416
|
+
export { MeteringEvents, MetricDefinedEvent, MetricUpdatedEvent, ThresholdApproachingEvent, ThresholdCreatedEvent, ThresholdExceededEvent, UsageAggregatedEvent, UsageBatchRecordedEvent, UsageRecordedEvent };
|
|
417
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","names":[],"sources":["../src/events.ts"],"sourcesContent":["import { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\nimport { defineEvent } from '@contractspec/lib.contracts';\n\n// ============ Event Payloads ============\n\nconst MetricDefinedPayload = defineSchemaModel({\n name: 'MetricDefinedEventPayload',\n description: 'Payload when a metric is defined',\n fields: {\n metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n unit: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n aggregationType: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n createdBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst MetricUpdatedPayload = defineSchemaModel({\n name: 'MetricUpdatedEventPayload',\n description: 'Payload when a metric is updated',\n fields: {\n metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n changes: { type: ScalarTypeEnum.JSON(), isOptional: false },\n updatedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst UsageRecordedPayload = defineSchemaModel({\n name: 'UsageRecordedEventPayload',\n description: 'Payload when usage is recorded',\n fields: {\n recordId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n quantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst UsageBatchRecordedPayload = defineSchemaModel({\n name: 'UsageBatchRecordedEventPayload',\n description: 'Payload when a batch of usage is recorded',\n fields: {\n recordCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n metricKeys: { type: ScalarTypeEnum.JSON(), isOptional: false },\n totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst UsageAggregatedPayload = defineSchemaModel({\n name: 'UsageAggregatedEventPayload',\n description: 'Payload when usage is aggregated',\n fields: {\n summaryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodStart: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n periodEnd: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n recordCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n aggregatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst ThresholdCreatedPayload = defineSchemaModel({\n name: 'ThresholdCreatedEventPayload',\n description: 'Payload when a threshold is created',\n fields: {\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst ThresholdExceededPayload = defineSchemaModel({\n name: 'ThresholdExceededEventPayload',\n description: 'Payload when a threshold is exceeded',\n fields: {\n alertId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n actualValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n percentageUsed: {\n type: ScalarTypeEnum.Float_unsecure(),\n isOptional: false,\n },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n triggeredAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst ThresholdApproachingPayload = defineSchemaModel({\n name: 'ThresholdApproachingEventPayload',\n description: 'Payload when usage is approaching a threshold',\n fields: {\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n currentValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n percentageUsed: {\n type: ScalarTypeEnum.Float_unsecure(),\n isOptional: false,\n },\n triggeredAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\n// ============ Events ============\n\n/**\n * Emitted when a metric is defined.\n */\nexport const MetricDefinedEvent = defineEvent({\n meta: {\n key: 'metric.defined',\n version: '1.0.0',\n description: 'A metric has been defined.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'metric'],\n },\n payload: MetricDefinedPayload,\n});\n\n/**\n * Emitted when a metric is updated.\n */\nexport const MetricUpdatedEvent = defineEvent({\n meta: {\n key: 'metric.updated',\n version: '1.0.0',\n description: 'A metric has been updated.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'metric'],\n },\n payload: MetricUpdatedPayload,\n});\n\n/**\n * Emitted when usage is recorded.\n */\nexport const UsageRecordedEvent = defineEvent({\n meta: {\n key: 'usage.recorded',\n version: '1.0.0',\n description: 'Usage has been recorded.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage'],\n },\n payload: UsageRecordedPayload,\n});\n\n/**\n * Emitted when a batch of usage is recorded.\n */\nexport const UsageBatchRecordedEvent = defineEvent({\n meta: {\n key: 'usage.batch_recorded',\n version: '1.0.0',\n description: 'A batch of usage has been recorded.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage'],\n },\n payload: UsageBatchRecordedPayload,\n});\n\n/**\n * Emitted when usage is aggregated.\n */\nexport const UsageAggregatedEvent = defineEvent({\n meta: {\n key: 'usage.aggregated',\n version: '1.0.0',\n description: 'Usage has been aggregated into a summary.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage'],\n },\n payload: UsageAggregatedPayload,\n});\n\n/**\n * Emitted when a threshold is created.\n */\nexport const ThresholdCreatedEvent = defineEvent({\n meta: {\n key: 'threshold.created',\n version: '1.0.0',\n description: 'A usage threshold has been created.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'threshold'],\n },\n payload: ThresholdCreatedPayload,\n});\n\n/**\n * Emitted when a threshold is exceeded.\n */\nexport const ThresholdExceededEvent = defineEvent({\n meta: {\n key: 'threshold.exceeded',\n version: '1.0.0',\n description: 'Usage has exceeded a threshold.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'threshold'],\n },\n payload: ThresholdExceededPayload,\n});\n\n/**\n * Emitted when usage is approaching a threshold.\n */\nexport const ThresholdApproachingEvent = defineEvent({\n meta: {\n key: 'threshold.approaching',\n version: '1.0.0',\n description: 'Usage is approaching a threshold.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'threshold'],\n },\n payload: ThresholdApproachingPayload,\n});\n\n/**\n * All metering events.\n */\nexport const MeteringEvents = {\n MetricDefinedEvent,\n MetricUpdatedEvent,\n UsageRecordedEvent,\n UsageBatchRecordedEvent,\n UsageAggregatedEvent,\n ThresholdCreatedEvent,\n ThresholdExceededEvent,\n ThresholdApproachingEvent,\n};\n"],"mappings":";;;;AAKA,MAAM,uBAAuB,kBAAkB;CAC7C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACvE,KAAK;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAClE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,iBAAiB;GACf,MAAM,eAAe,iBAAiB;GACtC,YAAY;GACb;EACD,OAAO;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACnE,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACvE,WAAW;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EAClE;CACF,CAAC;AAEF,MAAM,uBAAuB,kBAAkB;CAC7C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACvE,KAAK;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAClE,SAAS;GAAE,MAAM,eAAe,MAAM;GAAE,YAAY;GAAO;EAC3D,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACvE,WAAW;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EAClE;CACF,CAAC;AAEF,MAAM,uBAAuB,kBAAkB;CAC7C,MAAM;CACN,aAAa;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AAS;CACV,CAAC;;;;AAKF,MAAa,uBAAuB,YAAY;CAC9C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,QAAQ;EAC5B;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,wBAAwB,YAAY;CAC/C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,YAAY;EAChC;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,yBAAyB,YAAY;CAChD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,YAAY;EAChC;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,4BAA4B,YAAY;CACnD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,YAAY;EAChC;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AggregateParams, AggregationError, AggregationOptions, AggregationResult, AggregationType, InMemoryUsageStorage, MetricDefinition, PeriodType, UsageAggregator, UsageRecord, UsageStorage, UsageSummary, formatPeriodKey, getPeriodEnd, getPeriodStart } from "./aggregation/index.js";
|
|
2
|
+
import { CreateThresholdContract, DefineMetricContract, DeleteMetricContract, DeleteThresholdContract, GetMetricContract, GetUsageContract, GetUsageSummaryContract, ListMetricsContract, ListThresholdsContract, MetricDefinitionModel, RecordBatchUsageContract, RecordUsageContract, UpdateMetricContract, UpdateThresholdContract, UsageRecordModel, UsageSummaryModel, UsageThresholdModel } from "./contracts/index.js";
|
|
3
|
+
import { AggregationTypeEnum, MetricDefinitionEntity, PeriodTypeEnum, ResetPeriodEnum, ThresholdActionEnum, UsageAlertEntity, UsageRecordEntity, UsageSummaryEntity, UsageThresholdEntity, meteringEntities, meteringSchemaContribution } from "./entities/index.js";
|
|
4
|
+
import { MeteringEvents, MetricDefinedEvent, MetricUpdatedEvent, ThresholdApproachingEvent, ThresholdCreatedEvent, ThresholdExceededEvent, UsageAggregatedEvent, UsageBatchRecordedEvent, UsageRecordedEvent } from "./events.js";
|
|
5
|
+
import { MeteringFeature } from "./metering.feature.js";
|
|
6
|
+
export { AggregateParams, AggregationError, AggregationOptions, AggregationResult, AggregationType, AggregationTypeEnum, CreateThresholdContract, DefineMetricContract, DeleteMetricContract, DeleteThresholdContract, GetMetricContract, GetUsageContract, GetUsageSummaryContract, InMemoryUsageStorage, ListMetricsContract, ListThresholdsContract, MeteringEvents, MeteringFeature, MetricDefinedEvent, MetricDefinition, MetricDefinitionEntity, MetricDefinitionModel, MetricUpdatedEvent, PeriodType, PeriodTypeEnum, RecordBatchUsageContract, RecordUsageContract, ResetPeriodEnum, ThresholdActionEnum, ThresholdApproachingEvent, ThresholdCreatedEvent, ThresholdExceededEvent, UpdateMetricContract, UpdateThresholdContract, UsageAggregatedEvent, UsageAggregator, UsageAlertEntity, UsageBatchRecordedEvent, UsageRecord, UsageRecordEntity, UsageRecordModel, UsageRecordedEvent, UsageStorage, UsageSummary, UsageSummaryEntity, UsageSummaryModel, UsageThresholdEntity, UsageThresholdModel, formatPeriodKey, getPeriodEnd, getPeriodStart, meteringEntities, meteringSchemaContribution };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MeteringEvents, MetricDefinedEvent, MetricUpdatedEvent, ThresholdApproachingEvent, ThresholdCreatedEvent, ThresholdExceededEvent, UsageAggregatedEvent, UsageBatchRecordedEvent, UsageRecordedEvent } from "./events.js";
|
|
2
|
+
import { AggregationTypeEnum, MetricDefinitionEntity, PeriodTypeEnum, ResetPeriodEnum, ThresholdActionEnum, UsageAlertEntity, UsageRecordEntity, UsageSummaryEntity, UsageThresholdEntity, meteringEntities, meteringSchemaContribution } from "./entities/index.js";
|
|
3
|
+
import { CreateThresholdContract, DefineMetricContract, DeleteMetricContract, DeleteThresholdContract, GetMetricContract, GetUsageContract, GetUsageSummaryContract, ListMetricsContract, ListThresholdsContract, MetricDefinitionModel, RecordBatchUsageContract, RecordUsageContract, UpdateMetricContract, UpdateThresholdContract, UsageRecordModel, UsageSummaryModel, UsageThresholdModel } from "./contracts/index.js";
|
|
4
|
+
import { InMemoryUsageStorage, UsageAggregator, formatPeriodKey, getPeriodEnd, getPeriodStart } from "./aggregation/index.js";
|
|
5
|
+
import { MeteringFeature } from "./metering.feature.js";
|
|
6
|
+
import "./docs/index.js";
|
|
7
|
+
|
|
8
|
+
export { AggregationTypeEnum, CreateThresholdContract, DefineMetricContract, DeleteMetricContract, DeleteThresholdContract, GetMetricContract, GetUsageContract, GetUsageSummaryContract, InMemoryUsageStorage, ListMetricsContract, ListThresholdsContract, MeteringEvents, MeteringFeature, MetricDefinedEvent, MetricDefinitionEntity, MetricDefinitionModel, MetricUpdatedEvent, PeriodTypeEnum, RecordBatchUsageContract, RecordUsageContract, ResetPeriodEnum, ThresholdActionEnum, ThresholdApproachingEvent, ThresholdCreatedEvent, ThresholdExceededEvent, UpdateMetricContract, UpdateThresholdContract, UsageAggregatedEvent, UsageAggregator, UsageAlertEntity, UsageBatchRecordedEvent, UsageRecordEntity, UsageRecordModel, UsageRecordedEvent, UsageSummaryEntity, UsageSummaryModel, UsageThresholdEntity, UsageThresholdModel, formatPeriodKey, getPeriodEnd, getPeriodStart, meteringEntities, meteringSchemaContribution };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as _contractspec_lib_contracts15 from "@contractspec/lib.contracts";
|
|
2
|
+
|
|
3
|
+
//#region src/metering.capability.d.ts
|
|
4
|
+
declare const MeteringCapability: _contractspec_lib_contracts15.CapabilitySpec;
|
|
5
|
+
declare const ThresholdsCapability: _contractspec_lib_contracts15.CapabilitySpec;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { MeteringCapability, ThresholdsCapability };
|
|
8
|
+
//# sourceMappingURL=metering.capability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metering.capability.d.ts","names":[],"sources":["../src/metering.capability.ts"],"sourcesContent":[],"mappings":";;;cAEa,oBAUX,6BAAA,CAV6B;cAYlB,sBAUX,6BAAA,CAV+B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { StabilityEnum, defineCapability } from "@contractspec/lib.contracts";
|
|
2
|
+
|
|
3
|
+
//#region src/metering.capability.ts
|
|
4
|
+
const MeteringCapability = defineCapability({ meta: {
|
|
5
|
+
key: "metering",
|
|
6
|
+
version: "1.0.0",
|
|
7
|
+
kind: "api",
|
|
8
|
+
stability: StabilityEnum.Experimental,
|
|
9
|
+
description: "Usage metering and tracking",
|
|
10
|
+
owners: ["@platform.finance"],
|
|
11
|
+
tags: [
|
|
12
|
+
"metering",
|
|
13
|
+
"usage",
|
|
14
|
+
"billing"
|
|
15
|
+
]
|
|
16
|
+
} });
|
|
17
|
+
const ThresholdsCapability = defineCapability({ meta: {
|
|
18
|
+
key: "thresholds",
|
|
19
|
+
version: "1.0.0",
|
|
20
|
+
kind: "api",
|
|
21
|
+
stability: StabilityEnum.Experimental,
|
|
22
|
+
description: "Usage threshold alerts and limits",
|
|
23
|
+
owners: ["@platform.finance"],
|
|
24
|
+
tags: [
|
|
25
|
+
"thresholds",
|
|
26
|
+
"limits",
|
|
27
|
+
"metering"
|
|
28
|
+
]
|
|
29
|
+
} });
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { MeteringCapability, ThresholdsCapability };
|
|
33
|
+
//# sourceMappingURL=metering.capability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metering.capability.js","names":[],"sources":["../src/metering.capability.ts"],"sourcesContent":["import { defineCapability, StabilityEnum } from '@contractspec/lib.contracts';\n\nexport const MeteringCapability = defineCapability({\n meta: {\n key: 'metering',\n version: '1.0.0',\n kind: 'api',\n stability: StabilityEnum.Experimental,\n description: 'Usage metering and tracking',\n owners: ['@platform.finance'],\n tags: ['metering', 'usage', 'billing'],\n },\n});\n\nexport const ThresholdsCapability = defineCapability({\n meta: {\n key: 'thresholds',\n version: '1.0.0',\n kind: 'api',\n stability: StabilityEnum.Experimental,\n description: 'Usage threshold alerts and limits',\n owners: ['@platform.finance'],\n tags: ['thresholds', 'limits', 'metering'],\n },\n});\n"],"mappings":";;;AAEA,MAAa,qBAAqB,iBAAiB,EACjD,MAAM;CACJ,KAAK;CACL,SAAS;CACT,MAAM;CACN,WAAW,cAAc;CACzB,aAAa;CACb,QAAQ,CAAC,oBAAoB;CAC7B,MAAM;EAAC;EAAY;EAAS;EAAU;CACvC,EACF,CAAC;AAEF,MAAa,uBAAuB,iBAAiB,EACnD,MAAM;CACJ,KAAK;CACL,SAAS;CACT,MAAM;CACN,WAAW,cAAc;CACzB,aAAa;CACb,QAAQ,CAAC,oBAAoB;CAC7B,MAAM;EAAC;EAAc;EAAU;EAAW;CAC3C,EACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as _contractspec_lib_contracts17 from "@contractspec/lib.contracts";
|
|
2
|
+
|
|
3
|
+
//#region src/metering.feature.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Metering feature module that bundles usage tracking,
|
|
7
|
+
* metrics definitions, and billing capabilities.
|
|
8
|
+
*/
|
|
9
|
+
declare const MeteringFeature: _contractspec_lib_contracts17.FeatureModuleSpec;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { MeteringFeature };
|
|
12
|
+
//# sourceMappingURL=metering.feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metering.feature.d.ts","names":[],"sources":["../src/metering.feature.ts"],"sourcesContent":[],"mappings":";;;;;;;AAWA;cAAa,iBAgEX,6BAAA,CAhE0B"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { defineFeature } from "@contractspec/lib.contracts";
|
|
2
|
+
|
|
3
|
+
//#region src/metering.feature.ts
|
|
4
|
+
/**
|
|
5
|
+
* Metering Feature Module Specification
|
|
6
|
+
*
|
|
7
|
+
* Defines the feature module for usage metering and threshold management.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Metering feature module that bundles usage tracking,
|
|
11
|
+
* metrics definitions, and billing capabilities.
|
|
12
|
+
*/
|
|
13
|
+
const MeteringFeature = defineFeature({
|
|
14
|
+
meta: {
|
|
15
|
+
key: "metering",
|
|
16
|
+
version: "1.0.0",
|
|
17
|
+
title: "Usage Metering",
|
|
18
|
+
description: "Usage metering, metric definitions, and threshold alerting",
|
|
19
|
+
domain: "platform",
|
|
20
|
+
owners: ["@platform.metering"],
|
|
21
|
+
tags: [
|
|
22
|
+
"metering",
|
|
23
|
+
"usage",
|
|
24
|
+
"billing",
|
|
25
|
+
"thresholds"
|
|
26
|
+
],
|
|
27
|
+
stability: "stable"
|
|
28
|
+
},
|
|
29
|
+
operations: [
|
|
30
|
+
{
|
|
31
|
+
key: "metric.define",
|
|
32
|
+
version: "1.0.0"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
key: "metric.update",
|
|
36
|
+
version: "1.0.0"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
key: "metric.delete",
|
|
40
|
+
version: "1.0.0"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: "metric.get",
|
|
44
|
+
version: "1.0.0"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
key: "metric.list",
|
|
48
|
+
version: "1.0.0"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: "usage.record",
|
|
52
|
+
version: "1.0.0"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: "usage.recordBatch",
|
|
56
|
+
version: "1.0.0"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: "usage.get",
|
|
60
|
+
version: "1.0.0"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: "usage.getSummary",
|
|
64
|
+
version: "1.0.0"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: "threshold.create",
|
|
68
|
+
version: "1.0.0"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
key: "threshold.update",
|
|
72
|
+
version: "1.0.0"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
key: "threshold.delete",
|
|
76
|
+
version: "1.0.0"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
key: "threshold.list",
|
|
80
|
+
version: "1.0.0"
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
events: [
|
|
84
|
+
{
|
|
85
|
+
key: "metric.defined",
|
|
86
|
+
version: "1.0.0"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
key: "metric.updated",
|
|
90
|
+
version: "1.0.0"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
key: "usage.recorded",
|
|
94
|
+
version: "1.0.0"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
key: "usage.batch_recorded",
|
|
98
|
+
version: "1.0.0"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
key: "usage.aggregated",
|
|
102
|
+
version: "1.0.0"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
key: "threshold.created",
|
|
106
|
+
version: "1.0.0"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
key: "threshold.exceeded",
|
|
110
|
+
version: "1.0.0"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
key: "threshold.approaching",
|
|
114
|
+
version: "1.0.0"
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
presentations: [],
|
|
118
|
+
opToPresentation: [],
|
|
119
|
+
presentationsTargets: [],
|
|
120
|
+
capabilities: {
|
|
121
|
+
provides: [{
|
|
122
|
+
key: "metering",
|
|
123
|
+
version: "1.0.0"
|
|
124
|
+
}, {
|
|
125
|
+
key: "thresholds",
|
|
126
|
+
version: "1.0.0"
|
|
127
|
+
}],
|
|
128
|
+
requires: []
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
export { MeteringFeature };
|
|
134
|
+
//# sourceMappingURL=metering.feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metering.feature.js","names":[],"sources":["../src/metering.feature.ts"],"sourcesContent":["/**\n * Metering Feature Module Specification\n *\n * Defines the feature module for usage metering and threshold management.\n */\nimport { defineFeature } from '@contractspec/lib.contracts';\n\n/**\n * Metering feature module that bundles usage tracking,\n * metrics definitions, and billing capabilities.\n */\nexport const MeteringFeature = defineFeature({\n meta: {\n key: 'metering',\n version: '1.0.0',\n title: 'Usage Metering',\n description: 'Usage metering, metric definitions, and threshold alerting',\n domain: 'platform',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage', 'billing', 'thresholds'],\n stability: 'stable',\n },\n\n // All contract operations included in this feature\n operations: [\n // Metric operations\n { key: 'metric.define', version: '1.0.0' },\n { key: 'metric.update', version: '1.0.0' },\n { key: 'metric.delete', version: '1.0.0' },\n { key: 'metric.get', version: '1.0.0' },\n { key: 'metric.list', version: '1.0.0' },\n\n // Usage operations\n { key: 'usage.record', version: '1.0.0' },\n { key: 'usage.recordBatch', version: '1.0.0' },\n { key: 'usage.get', version: '1.0.0' },\n { key: 'usage.getSummary', version: '1.0.0' },\n\n // Threshold operations\n { key: 'threshold.create', version: '1.0.0' },\n { key: 'threshold.update', version: '1.0.0' },\n { key: 'threshold.delete', version: '1.0.0' },\n { key: 'threshold.list', version: '1.0.0' },\n ],\n\n // Events emitted by this feature\n events: [\n // Metric events\n { key: 'metric.defined', version: '1.0.0' },\n { key: 'metric.updated', version: '1.0.0' },\n\n // Usage events\n { key: 'usage.recorded', version: '1.0.0' },\n { key: 'usage.batch_recorded', version: '1.0.0' },\n { key: 'usage.aggregated', version: '1.0.0' },\n\n // Threshold events\n { key: 'threshold.created', version: '1.0.0' },\n { key: 'threshold.exceeded', version: '1.0.0' },\n { key: 'threshold.approaching', version: '1.0.0' },\n ],\n\n // No presentations for this library feature\n presentations: [],\n opToPresentation: [],\n presentationsTargets: [],\n\n // Capability definitions\n capabilities: {\n provides: [\n { key: 'metering', version: '1.0.0' },\n { key: 'thresholds', version: '1.0.0' },\n ],\n requires: [],\n },\n});\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,kBAAkB,cAAc;CAC3C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aAAa;EACb,QAAQ;EACR,QAAQ,CAAC,qBAAqB;EAC9B,MAAM;GAAC;GAAY;GAAS;GAAW;GAAa;EACpD,WAAW;EACZ;CAGD,YAAY;EAEV;GAAE,KAAK;GAAiB,SAAS;GAAS;EAC1C;GAAE,KAAK;GAAiB,SAAS;GAAS;EAC1C;GAAE,KAAK;GAAiB,SAAS;GAAS;EAC1C;GAAE,KAAK;GAAc,SAAS;GAAS;EACvC;GAAE,KAAK;GAAe,SAAS;GAAS;EAGxC;GAAE,KAAK;GAAgB,SAAS;GAAS;EACzC;GAAE,KAAK;GAAqB,SAAS;GAAS;EAC9C;GAAE,KAAK;GAAa,SAAS;GAAS;EACtC;GAAE,KAAK;GAAoB,SAAS;GAAS;EAG7C;GAAE,KAAK;GAAoB,SAAS;GAAS;EAC7C;GAAE,KAAK;GAAoB,SAAS;GAAS;EAC7C;GAAE,KAAK;GAAoB,SAAS;GAAS;EAC7C;GAAE,KAAK;GAAkB,SAAS;GAAS;EAC5C;CAGD,QAAQ;EAEN;GAAE,KAAK;GAAkB,SAAS;GAAS;EAC3C;GAAE,KAAK;GAAkB,SAAS;GAAS;EAG3C;GAAE,KAAK;GAAkB,SAA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