@lssm/lib.metering 0.0.0-canary-20251217080011 → 1.41.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 (138) hide show
  1. package/dist/aggregation/index.js +1 -271
  2. package/dist/contracts/index.js +1 -1034
  3. package/dist/docs/index.js +1 -1
  4. package/dist/docs/metering.docblock.js +2 -22
  5. package/dist/entities/index.js +1 -418
  6. package/dist/events.js +1 -379
  7. package/dist/index.js +1 -8
  8. package/dist/metering.feature.js +1 -125
  9. package/package.json +13 -14
  10. package/dist/aggregation/index.d.ts +0 -155
  11. package/dist/contracts/dist/capabilities/openbanking.js +0 -88
  12. package/dist/contracts/dist/client/index.js +0 -5
  13. package/dist/contracts/dist/client/react/feature-render.js +0 -2
  14. package/dist/contracts/dist/client/react/form-render.js +0 -4
  15. package/dist/contracts/dist/client/react/index.js +0 -4
  16. package/dist/contracts/dist/contract-registry/index.js +0 -1
  17. package/dist/contracts/dist/contract-registry/schemas.js +0 -60
  18. package/dist/contracts/dist/docs/PUBLISHING.docblock.js +0 -16
  19. package/dist/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +0 -16
  20. package/dist/contracts/dist/docs/index.js +0 -29
  21. package/dist/contracts/dist/docs/presentations.js +0 -71
  22. package/dist/contracts/dist/docs/registry.js +0 -44
  23. package/dist/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +0 -16
  24. package/dist/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +0 -16
  25. package/dist/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +0 -16
  26. package/dist/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +0 -16
  27. package/dist/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +0 -16
  28. package/dist/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +0 -80
  29. package/dist/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +0 -57
  30. package/dist/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +0 -16
  31. package/dist/contracts/dist/docs/tech/llm/llm-integration.docblock.js +0 -357
  32. package/dist/contracts/dist/docs/tech/mcp-endpoints.docblock.js +0 -37
  33. package/dist/contracts/dist/docs/tech/presentation-runtime.docblock.js +0 -16
  34. package/dist/contracts/dist/docs/tech/schema/README.docblock.js +0 -20
  35. package/dist/contracts/dist/docs/tech/studio/learning-events.docblock.js +0 -48
  36. package/dist/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +0 -79
  37. package/dist/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +0 -84
  38. package/dist/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +0 -45
  39. package/dist/contracts/dist/docs/tech/studio/project-routing.docblock.js +0 -67
  40. package/dist/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +0 -40
  41. package/dist/contracts/dist/docs/tech/studio/team-invitations.docblock.js +0 -69
  42. package/dist/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +0 -47
  43. package/dist/contracts/dist/docs/tech/studio/workspaces.docblock.js +0 -62
  44. package/dist/contracts/dist/docs/tech/telemetry-ingest.docblock.js +0 -155
  45. package/dist/contracts/dist/docs/tech/templates/runtime.docblock.js +0 -20
  46. package/dist/contracts/dist/docs/tech/vscode-extension.docblock.js +0 -101
  47. package/dist/contracts/dist/docs/tech/workflows/overview.docblock.js +0 -20
  48. package/dist/contracts/dist/events.js +0 -10
  49. package/dist/contracts/dist/experiments/evaluator.js +0 -1
  50. package/dist/contracts/dist/index.js +0 -71
  51. package/dist/contracts/dist/install.js +0 -2
  52. package/dist/contracts/dist/integrations/contracts.js +0 -377
  53. package/dist/contracts/dist/integrations/index.js +0 -18
  54. package/dist/contracts/dist/integrations/openbanking/contracts/accounts.js +0 -228
  55. package/dist/contracts/dist/integrations/openbanking/contracts/balances.js +0 -159
  56. package/dist/contracts/dist/integrations/openbanking/contracts/index.js +0 -3
  57. package/dist/contracts/dist/integrations/openbanking/contracts/transactions.js +0 -210
  58. package/dist/contracts/dist/integrations/openbanking/models.js +0 -242
  59. package/dist/contracts/dist/integrations/openbanking/telemetry.js +0 -13
  60. package/dist/contracts/dist/integrations/providers/elevenlabs.js +0 -52
  61. package/dist/contracts/dist/integrations/providers/gcs-storage.js +0 -75
  62. package/dist/contracts/dist/integrations/providers/gmail.js +0 -87
  63. package/dist/contracts/dist/integrations/providers/google-calendar.js +0 -66
  64. package/dist/contracts/dist/integrations/providers/index.js +0 -11
  65. package/dist/contracts/dist/integrations/providers/mistral.js +0 -68
  66. package/dist/contracts/dist/integrations/providers/postmark.js +0 -68
  67. package/dist/contracts/dist/integrations/providers/powens.js +0 -116
  68. package/dist/contracts/dist/integrations/providers/qdrant.js +0 -73
  69. package/dist/contracts/dist/integrations/providers/registry.js +0 -10
  70. package/dist/contracts/dist/integrations/providers/stripe.js +0 -83
  71. package/dist/contracts/dist/integrations/providers/twilio-sms.js +0 -61
  72. package/dist/contracts/dist/jsonschema.js +0 -1
  73. package/dist/contracts/dist/knowledge/contracts.js +0 -306
  74. package/dist/contracts/dist/knowledge/index.js +0 -7
  75. package/dist/contracts/dist/knowledge/spaces/email-threads.js +0 -34
  76. package/dist/contracts/dist/knowledge/spaces/financial-docs.js +0 -34
  77. package/dist/contracts/dist/knowledge/spaces/financial-overview.js +0 -38
  78. package/dist/contracts/dist/knowledge/spaces/index.js +0 -6
  79. package/dist/contracts/dist/knowledge/spaces/product-canon.js +0 -34
  80. package/dist/contracts/dist/knowledge/spaces/support-faq.js +0 -37
  81. package/dist/contracts/dist/knowledge/spaces/uploaded-docs.js +0 -34
  82. package/dist/contracts/dist/llm/exporters.js +0 -19
  83. package/dist/contracts/dist/llm/index.js +0 -2
  84. package/dist/contracts/dist/llm/prompts.js +0 -1
  85. package/dist/contracts/dist/onboarding-base.js +0 -196
  86. package/dist/contracts/dist/openapi.js +0 -1
  87. package/dist/contracts/dist/ownership.js +0 -21
  88. package/dist/contracts/dist/presentations.js +0 -1
  89. package/dist/contracts/dist/presentations.v2.js +0 -11
  90. package/dist/contracts/dist/prompt.js +0 -1
  91. package/dist/contracts/dist/promptRegistry.js +0 -1
  92. package/dist/contracts/dist/regenerator/index.js +0 -1
  93. package/dist/contracts/dist/regenerator/service.js +0 -6
  94. package/dist/contracts/dist/registry.js +0 -2
  95. package/dist/contracts/dist/resources.js +0 -1
  96. package/dist/contracts/dist/schema/dist/EnumType.js +0 -2
  97. package/dist/contracts/dist/schema/dist/FieldType.js +0 -49
  98. package/dist/contracts/dist/schema/dist/ScalarTypeEnum.js +0 -236
  99. package/dist/contracts/dist/schema/dist/SchemaModel.js +0 -34
  100. package/dist/contracts/dist/schema/dist/entity/defineEntity.js +0 -1
  101. package/dist/contracts/dist/schema/dist/entity/index.js +0 -2
  102. package/dist/contracts/dist/schema/dist/entity/types.js +0 -1
  103. package/dist/contracts/dist/schema/dist/index.js +0 -6
  104. package/dist/contracts/dist/server/graphql-pothos.js +0 -6
  105. package/dist/contracts/dist/server/index.js +0 -8
  106. package/dist/contracts/dist/server/mcp/createMcpServer.js +0 -4
  107. package/dist/contracts/dist/server/mcp/registerPresentations.js +0 -2
  108. package/dist/contracts/dist/server/mcp/registerPrompts.js +0 -1
  109. package/dist/contracts/dist/server/mcp/registerResources.js +0 -2
  110. package/dist/contracts/dist/server/mcp/registerTools.js +0 -1
  111. package/dist/contracts/dist/server/provider-mcp.js +0 -1
  112. package/dist/contracts/dist/server/rest-elysia.js +0 -1
  113. package/dist/contracts/dist/server/rest-express.js +0 -1
  114. package/dist/contracts/dist/server/rest-generic.js +0 -1
  115. package/dist/contracts/dist/server/rest-next-app.js +0 -1
  116. package/dist/contracts/dist/server/rest-next-pages.js +0 -1
  117. package/dist/contracts/dist/spec.js +0 -34
  118. package/dist/contracts/dist/telemetry/index.js +0 -1
  119. package/dist/contracts/dist/telemetry/tracker.js +0 -1
  120. package/dist/contracts/dist/tests/index.js +0 -1
  121. package/dist/contracts/dist/tests/runner.js +0 -2
  122. package/dist/contracts/dist/workflow/index.js +0 -1
  123. package/dist/contracts/dist/workflow/runner.js +0 -1
  124. package/dist/contracts/index.d.ts +0 -1138
  125. package/dist/docs/index.d.ts +0 -1
  126. package/dist/docs/metering.docblock.d.ts +0 -1
  127. package/dist/entities/index.d.ts +0 -230
  128. package/dist/events.d.ts +0 -539
  129. package/dist/index.d.ts +0 -6
  130. package/dist/metering.feature.d.ts +0 -11
  131. package/dist/schema/dist/EnumType.js +0 -2
  132. package/dist/schema/dist/FieldType.js +0 -49
  133. package/dist/schema/dist/ScalarTypeEnum.js +0 -236
  134. package/dist/schema/dist/SchemaModel.js +0 -39
  135. package/dist/schema/dist/entity/defineEntity.js +0 -236
  136. package/dist/schema/dist/entity/index.js +0 -2
  137. package/dist/schema/dist/entity/types.js +0 -1
  138. package/dist/schema/dist/index.js +0 -6
@@ -1,1034 +1 @@
1
- import { ScalarTypeEnum } from "../schema/dist/ScalarTypeEnum.js";
2
- import { defineSchemaModel } from "../schema/dist/SchemaModel.js";
3
- import "../schema/dist/index.js";
4
- import { defineCommand, defineQuery } from "./dist/spec.js";
5
- import "./dist/index.js";
6
-
7
- //#region src/contracts/index.ts
8
- const OWNERS = ["platform.metering"];
9
- const MetricDefinitionModel = defineSchemaModel({
10
- name: "MetricDefinition",
11
- description: "Represents a metric definition",
12
- fields: {
13
- id: {
14
- type: ScalarTypeEnum.String_unsecure(),
15
- isOptional: false
16
- },
17
- key: {
18
- type: ScalarTypeEnum.String_unsecure(),
19
- isOptional: false
20
- },
21
- name: {
22
- type: ScalarTypeEnum.String_unsecure(),
23
- isOptional: false
24
- },
25
- description: {
26
- type: ScalarTypeEnum.String_unsecure(),
27
- isOptional: true
28
- },
29
- unit: {
30
- type: ScalarTypeEnum.String_unsecure(),
31
- isOptional: false
32
- },
33
- aggregationType: {
34
- type: ScalarTypeEnum.String_unsecure(),
35
- isOptional: false
36
- },
37
- resetPeriod: {
38
- type: ScalarTypeEnum.String_unsecure(),
39
- isOptional: false
40
- },
41
- category: {
42
- type: ScalarTypeEnum.String_unsecure(),
43
- isOptional: true
44
- },
45
- isActive: {
46
- type: ScalarTypeEnum.Boolean(),
47
- isOptional: false
48
- },
49
- orgId: {
50
- type: ScalarTypeEnum.String_unsecure(),
51
- isOptional: true
52
- },
53
- createdAt: {
54
- type: ScalarTypeEnum.DateTime(),
55
- isOptional: false
56
- },
57
- updatedAt: {
58
- type: ScalarTypeEnum.DateTime(),
59
- isOptional: false
60
- }
61
- }
62
- });
63
- const UsageRecordModel = defineSchemaModel({
64
- name: "UsageRecord",
65
- description: "Represents a usage record",
66
- fields: {
67
- id: {
68
- type: ScalarTypeEnum.String_unsecure(),
69
- isOptional: false
70
- },
71
- metricKey: {
72
- type: ScalarTypeEnum.String_unsecure(),
73
- isOptional: false
74
- },
75
- subjectType: {
76
- type: ScalarTypeEnum.String_unsecure(),
77
- isOptional: false
78
- },
79
- subjectId: {
80
- type: ScalarTypeEnum.String_unsecure(),
81
- isOptional: false
82
- },
83
- quantity: {
84
- type: ScalarTypeEnum.Float_unsecure(),
85
- isOptional: false
86
- },
87
- source: {
88
- type: ScalarTypeEnum.String_unsecure(),
89
- isOptional: true
90
- },
91
- resourceId: {
92
- type: ScalarTypeEnum.String_unsecure(),
93
- isOptional: true
94
- },
95
- resourceType: {
96
- type: ScalarTypeEnum.String_unsecure(),
97
- isOptional: true
98
- },
99
- metadata: {
100
- type: ScalarTypeEnum.JSON(),
101
- isOptional: true
102
- },
103
- timestamp: {
104
- type: ScalarTypeEnum.DateTime(),
105
- isOptional: false
106
- },
107
- createdAt: {
108
- type: ScalarTypeEnum.DateTime(),
109
- isOptional: false
110
- }
111
- }
112
- });
113
- const UsageSummaryModel = defineSchemaModel({
114
- name: "UsageSummary",
115
- description: "Represents aggregated usage",
116
- fields: {
117
- id: {
118
- type: ScalarTypeEnum.String_unsecure(),
119
- isOptional: false
120
- },
121
- metricKey: {
122
- type: ScalarTypeEnum.String_unsecure(),
123
- isOptional: false
124
- },
125
- subjectType: {
126
- type: ScalarTypeEnum.String_unsecure(),
127
- isOptional: false
128
- },
129
- subjectId: {
130
- type: ScalarTypeEnum.String_unsecure(),
131
- isOptional: false
132
- },
133
- periodType: {
134
- type: ScalarTypeEnum.String_unsecure(),
135
- isOptional: false
136
- },
137
- periodStart: {
138
- type: ScalarTypeEnum.DateTime(),
139
- isOptional: false
140
- },
141
- periodEnd: {
142
- type: ScalarTypeEnum.DateTime(),
143
- isOptional: false
144
- },
145
- totalQuantity: {
146
- type: ScalarTypeEnum.Float_unsecure(),
147
- isOptional: false
148
- },
149
- recordCount: {
150
- type: ScalarTypeEnum.Int_unsecure(),
151
- isOptional: false
152
- },
153
- minQuantity: {
154
- type: ScalarTypeEnum.Float_unsecure(),
155
- isOptional: true
156
- },
157
- maxQuantity: {
158
- type: ScalarTypeEnum.Float_unsecure(),
159
- isOptional: true
160
- },
161
- avgQuantity: {
162
- type: ScalarTypeEnum.Float_unsecure(),
163
- isOptional: true
164
- }
165
- }
166
- });
167
- const UsageThresholdModel = defineSchemaModel({
168
- name: "UsageThreshold",
169
- description: "Represents a usage threshold",
170
- fields: {
171
- id: {
172
- type: ScalarTypeEnum.String_unsecure(),
173
- isOptional: false
174
- },
175
- metricKey: {
176
- type: ScalarTypeEnum.String_unsecure(),
177
- isOptional: false
178
- },
179
- subjectType: {
180
- type: ScalarTypeEnum.String_unsecure(),
181
- isOptional: true
182
- },
183
- subjectId: {
184
- type: ScalarTypeEnum.String_unsecure(),
185
- isOptional: true
186
- },
187
- name: {
188
- type: ScalarTypeEnum.String_unsecure(),
189
- isOptional: false
190
- },
191
- threshold: {
192
- type: ScalarTypeEnum.Float_unsecure(),
193
- isOptional: false
194
- },
195
- warnThreshold: {
196
- type: ScalarTypeEnum.Float_unsecure(),
197
- isOptional: true
198
- },
199
- periodType: {
200
- type: ScalarTypeEnum.String_unsecure(),
201
- isOptional: false
202
- },
203
- action: {
204
- type: ScalarTypeEnum.String_unsecure(),
205
- isOptional: false
206
- },
207
- currentValue: {
208
- type: ScalarTypeEnum.Float_unsecure(),
209
- isOptional: false
210
- },
211
- isActive: {
212
- type: ScalarTypeEnum.Boolean(),
213
- isOptional: false
214
- },
215
- createdAt: {
216
- type: ScalarTypeEnum.DateTime(),
217
- isOptional: false
218
- }
219
- }
220
- });
221
- const DefineMetricInput = defineSchemaModel({
222
- name: "DefineMetricInput",
223
- description: "Input for defining a metric",
224
- fields: {
225
- key: {
226
- type: ScalarTypeEnum.String_unsecure(),
227
- isOptional: false
228
- },
229
- name: {
230
- type: ScalarTypeEnum.String_unsecure(),
231
- isOptional: false
232
- },
233
- description: {
234
- type: ScalarTypeEnum.String_unsecure(),
235
- isOptional: true
236
- },
237
- unit: {
238
- type: ScalarTypeEnum.String_unsecure(),
239
- isOptional: false
240
- },
241
- aggregationType: {
242
- type: ScalarTypeEnum.String_unsecure(),
243
- isOptional: true
244
- },
245
- resetPeriod: {
246
- type: ScalarTypeEnum.String_unsecure(),
247
- isOptional: true
248
- },
249
- category: {
250
- type: ScalarTypeEnum.String_unsecure(),
251
- isOptional: true
252
- },
253
- orgId: {
254
- type: ScalarTypeEnum.String_unsecure(),
255
- isOptional: true
256
- },
257
- metadata: {
258
- type: ScalarTypeEnum.JSON(),
259
- isOptional: true
260
- }
261
- }
262
- });
263
- const UpdateMetricInput = defineSchemaModel({
264
- name: "UpdateMetricInput",
265
- description: "Input for updating a metric",
266
- fields: {
267
- metricId: {
268
- type: ScalarTypeEnum.String_unsecure(),
269
- isOptional: false
270
- },
271
- name: {
272
- type: ScalarTypeEnum.String_unsecure(),
273
- isOptional: true
274
- },
275
- description: {
276
- type: ScalarTypeEnum.String_unsecure(),
277
- isOptional: true
278
- },
279
- category: {
280
- type: ScalarTypeEnum.String_unsecure(),
281
- isOptional: true
282
- },
283
- isActive: {
284
- type: ScalarTypeEnum.Boolean(),
285
- isOptional: true
286
- },
287
- metadata: {
288
- type: ScalarTypeEnum.JSON(),
289
- isOptional: true
290
- }
291
- }
292
- });
293
- const DeleteMetricInput = defineSchemaModel({
294
- name: "DeleteMetricInput",
295
- description: "Input for deleting a metric",
296
- fields: { metricId: {
297
- type: ScalarTypeEnum.String_unsecure(),
298
- isOptional: false
299
- } }
300
- });
301
- const GetMetricInput = defineSchemaModel({
302
- name: "GetMetricInput",
303
- description: "Input for getting a metric",
304
- fields: {
305
- key: {
306
- type: ScalarTypeEnum.String_unsecure(),
307
- isOptional: false
308
- },
309
- orgId: {
310
- type: ScalarTypeEnum.String_unsecure(),
311
- isOptional: true
312
- }
313
- }
314
- });
315
- const ListMetricsInput = defineSchemaModel({
316
- name: "ListMetricsInput",
317
- description: "Input for listing metrics",
318
- fields: {
319
- orgId: {
320
- type: ScalarTypeEnum.String_unsecure(),
321
- isOptional: true
322
- },
323
- category: {
324
- type: ScalarTypeEnum.String_unsecure(),
325
- isOptional: true
326
- },
327
- isActive: {
328
- type: ScalarTypeEnum.Boolean(),
329
- isOptional: true
330
- },
331
- limit: {
332
- type: ScalarTypeEnum.Int_unsecure(),
333
- isOptional: true
334
- },
335
- offset: {
336
- type: ScalarTypeEnum.Int_unsecure(),
337
- isOptional: true
338
- }
339
- }
340
- });
341
- const ListMetricsOutput = defineSchemaModel({
342
- name: "ListMetricsOutput",
343
- description: "Output for listing metrics",
344
- fields: {
345
- metrics: {
346
- type: MetricDefinitionModel,
347
- isArray: true,
348
- isOptional: false
349
- },
350
- total: {
351
- type: ScalarTypeEnum.Int_unsecure(),
352
- isOptional: false
353
- }
354
- }
355
- });
356
- const RecordUsageInput = defineSchemaModel({
357
- name: "RecordUsageInput",
358
- description: "Input for recording usage",
359
- fields: {
360
- metricKey: {
361
- type: ScalarTypeEnum.String_unsecure(),
362
- isOptional: false
363
- },
364
- subjectType: {
365
- type: ScalarTypeEnum.String_unsecure(),
366
- isOptional: false
367
- },
368
- subjectId: {
369
- type: ScalarTypeEnum.String_unsecure(),
370
- isOptional: false
371
- },
372
- quantity: {
373
- type: ScalarTypeEnum.Float_unsecure(),
374
- isOptional: false
375
- },
376
- timestamp: {
377
- type: ScalarTypeEnum.DateTime(),
378
- isOptional: true
379
- },
380
- source: {
381
- type: ScalarTypeEnum.String_unsecure(),
382
- isOptional: true
383
- },
384
- resourceId: {
385
- type: ScalarTypeEnum.String_unsecure(),
386
- isOptional: true
387
- },
388
- resourceType: {
389
- type: ScalarTypeEnum.String_unsecure(),
390
- isOptional: true
391
- },
392
- metadata: {
393
- type: ScalarTypeEnum.JSON(),
394
- isOptional: true
395
- },
396
- idempotencyKey: {
397
- type: ScalarTypeEnum.String_unsecure(),
398
- isOptional: true
399
- }
400
- }
401
- });
402
- const RecordBatchUsageInput = defineSchemaModel({
403
- name: "RecordBatchUsageInput",
404
- description: "Input for recording batch usage",
405
- fields: { records: {
406
- type: RecordUsageInput,
407
- isArray: true,
408
- isOptional: false
409
- } }
410
- });
411
- const RecordBatchUsageOutput = defineSchemaModel({
412
- name: "RecordBatchUsageOutput",
413
- description: "Output for recording batch usage",
414
- fields: {
415
- recordedCount: {
416
- type: ScalarTypeEnum.Int_unsecure(),
417
- isOptional: false
418
- },
419
- skippedCount: {
420
- type: ScalarTypeEnum.Int_unsecure(),
421
- isOptional: false
422
- },
423
- recordIds: {
424
- type: ScalarTypeEnum.JSON(),
425
- isOptional: false
426
- }
427
- }
428
- });
429
- const GetUsageInput = defineSchemaModel({
430
- name: "GetUsageInput",
431
- description: "Input for getting usage",
432
- fields: {
433
- metricKey: {
434
- type: ScalarTypeEnum.String_unsecure(),
435
- isOptional: false
436
- },
437
- subjectType: {
438
- type: ScalarTypeEnum.String_unsecure(),
439
- isOptional: false
440
- },
441
- subjectId: {
442
- type: ScalarTypeEnum.String_unsecure(),
443
- isOptional: false
444
- },
445
- startDate: {
446
- type: ScalarTypeEnum.DateTime(),
447
- isOptional: false
448
- },
449
- endDate: {
450
- type: ScalarTypeEnum.DateTime(),
451
- isOptional: false
452
- },
453
- limit: {
454
- type: ScalarTypeEnum.Int_unsecure(),
455
- isOptional: true
456
- },
457
- offset: {
458
- type: ScalarTypeEnum.Int_unsecure(),
459
- isOptional: true
460
- }
461
- }
462
- });
463
- const GetUsageOutput = defineSchemaModel({
464
- name: "GetUsageOutput",
465
- description: "Output for getting usage",
466
- fields: {
467
- records: {
468
- type: UsageRecordModel,
469
- isArray: true,
470
- isOptional: false
471
- },
472
- total: {
473
- type: ScalarTypeEnum.Int_unsecure(),
474
- isOptional: false
475
- },
476
- totalQuantity: {
477
- type: ScalarTypeEnum.Float_unsecure(),
478
- isOptional: false
479
- }
480
- }
481
- });
482
- const GetUsageSummaryInput = defineSchemaModel({
483
- name: "GetUsageSummaryInput",
484
- description: "Input for getting usage summary",
485
- fields: {
486
- metricKey: {
487
- type: ScalarTypeEnum.String_unsecure(),
488
- isOptional: false
489
- },
490
- subjectType: {
491
- type: ScalarTypeEnum.String_unsecure(),
492
- isOptional: false
493
- },
494
- subjectId: {
495
- type: ScalarTypeEnum.String_unsecure(),
496
- isOptional: false
497
- },
498
- periodType: {
499
- type: ScalarTypeEnum.String_unsecure(),
500
- isOptional: false
501
- },
502
- startDate: {
503
- type: ScalarTypeEnum.DateTime(),
504
- isOptional: false
505
- },
506
- endDate: {
507
- type: ScalarTypeEnum.DateTime(),
508
- isOptional: true
509
- }
510
- }
511
- });
512
- const GetUsageSummaryOutput = defineSchemaModel({
513
- name: "GetUsageSummaryOutput",
514
- description: "Output for getting usage summary",
515
- fields: {
516
- summaries: {
517
- type: UsageSummaryModel,
518
- isArray: true,
519
- isOptional: false
520
- },
521
- total: {
522
- type: ScalarTypeEnum.Int_unsecure(),
523
- isOptional: false
524
- }
525
- }
526
- });
527
- const CreateThresholdInput = defineSchemaModel({
528
- name: "CreateThresholdInput",
529
- description: "Input for creating a threshold",
530
- fields: {
531
- metricKey: {
532
- type: ScalarTypeEnum.String_unsecure(),
533
- isOptional: false
534
- },
535
- subjectType: {
536
- type: ScalarTypeEnum.String_unsecure(),
537
- isOptional: true
538
- },
539
- subjectId: {
540
- type: ScalarTypeEnum.String_unsecure(),
541
- isOptional: true
542
- },
543
- name: {
544
- type: ScalarTypeEnum.String_unsecure(),
545
- isOptional: false
546
- },
547
- threshold: {
548
- type: ScalarTypeEnum.Float_unsecure(),
549
- isOptional: false
550
- },
551
- warnThreshold: {
552
- type: ScalarTypeEnum.Float_unsecure(),
553
- isOptional: true
554
- },
555
- periodType: {
556
- type: ScalarTypeEnum.String_unsecure(),
557
- isOptional: true
558
- },
559
- action: {
560
- type: ScalarTypeEnum.String_unsecure(),
561
- isOptional: true
562
- },
563
- notifyEmails: {
564
- type: ScalarTypeEnum.JSON(),
565
- isOptional: true
566
- },
567
- notifyWebhook: {
568
- type: ScalarTypeEnum.String_unsecure(),
569
- isOptional: true
570
- }
571
- }
572
- });
573
- const UpdateThresholdInput = defineSchemaModel({
574
- name: "UpdateThresholdInput",
575
- description: "Input for updating a threshold",
576
- fields: {
577
- thresholdId: {
578
- type: ScalarTypeEnum.String_unsecure(),
579
- isOptional: false
580
- },
581
- name: {
582
- type: ScalarTypeEnum.String_unsecure(),
583
- isOptional: true
584
- },
585
- threshold: {
586
- type: ScalarTypeEnum.Float_unsecure(),
587
- isOptional: true
588
- },
589
- warnThreshold: {
590
- type: ScalarTypeEnum.Float_unsecure(),
591
- isOptional: true
592
- },
593
- action: {
594
- type: ScalarTypeEnum.String_unsecure(),
595
- isOptional: true
596
- },
597
- notifyEmails: {
598
- type: ScalarTypeEnum.JSON(),
599
- isOptional: true
600
- },
601
- notifyWebhook: {
602
- type: ScalarTypeEnum.String_unsecure(),
603
- isOptional: true
604
- },
605
- isActive: {
606
- type: ScalarTypeEnum.Boolean(),
607
- isOptional: true
608
- }
609
- }
610
- });
611
- const DeleteThresholdInput = defineSchemaModel({
612
- name: "DeleteThresholdInput",
613
- description: "Input for deleting a threshold",
614
- fields: { thresholdId: {
615
- type: ScalarTypeEnum.String_unsecure(),
616
- isOptional: false
617
- } }
618
- });
619
- const ListThresholdsInput = defineSchemaModel({
620
- name: "ListThresholdsInput",
621
- description: "Input for listing thresholds",
622
- fields: {
623
- metricKey: {
624
- type: ScalarTypeEnum.String_unsecure(),
625
- isOptional: true
626
- },
627
- subjectType: {
628
- type: ScalarTypeEnum.String_unsecure(),
629
- isOptional: true
630
- },
631
- subjectId: {
632
- type: ScalarTypeEnum.String_unsecure(),
633
- isOptional: true
634
- },
635
- isActive: {
636
- type: ScalarTypeEnum.Boolean(),
637
- isOptional: true
638
- }
639
- }
640
- });
641
- const ListThresholdsOutput = defineSchemaModel({
642
- name: "ListThresholdsOutput",
643
- description: "Output for listing thresholds",
644
- fields: {
645
- thresholds: {
646
- type: UsageThresholdModel,
647
- isArray: true,
648
- isOptional: false
649
- },
650
- total: {
651
- type: ScalarTypeEnum.Int_unsecure(),
652
- isOptional: false
653
- }
654
- }
655
- });
656
- const SuccessOutput = defineSchemaModel({
657
- name: "SuccessOutput",
658
- description: "Generic success output",
659
- fields: { success: {
660
- type: ScalarTypeEnum.Boolean(),
661
- isOptional: false
662
- } }
663
- });
664
- /**
665
- * Define a metric.
666
- */
667
- const DefineMetricContract = defineCommand({
668
- meta: {
669
- name: "metric.define",
670
- version: 1,
671
- stability: "stable",
672
- owners: [...OWNERS],
673
- tags: [
674
- "metering",
675
- "metric",
676
- "define"
677
- ],
678
- description: "Define a new usage metric.",
679
- goal: "Create a new metric for tracking usage.",
680
- context: "Called when setting up metering."
681
- },
682
- io: {
683
- input: DefineMetricInput,
684
- output: MetricDefinitionModel,
685
- errors: { METRIC_KEY_EXISTS: {
686
- description: "Metric key already exists",
687
- http: 409,
688
- gqlCode: "METRIC_KEY_EXISTS",
689
- when: "A metric with this key already exists"
690
- } }
691
- },
692
- policy: { auth: "admin" }
693
- });
694
- /**
695
- * Update a metric.
696
- */
697
- const UpdateMetricContract = defineCommand({
698
- meta: {
699
- name: "metric.update",
700
- version: 1,
701
- stability: "stable",
702
- owners: [...OWNERS],
703
- tags: [
704
- "metering",
705
- "metric",
706
- "update"
707
- ],
708
- description: "Update a metric definition.",
709
- goal: "Modify metric configuration.",
710
- context: "Called when updating metric settings."
711
- },
712
- io: {
713
- input: UpdateMetricInput,
714
- output: MetricDefinitionModel,
715
- errors: { METRIC_NOT_FOUND: {
716
- description: "Metric does not exist",
717
- http: 404,
718
- gqlCode: "METRIC_NOT_FOUND",
719
- when: "Metric ID is invalid"
720
- } }
721
- },
722
- policy: { auth: "admin" }
723
- });
724
- /**
725
- * Delete a metric.
726
- */
727
- const DeleteMetricContract = defineCommand({
728
- meta: {
729
- name: "metric.delete",
730
- version: 1,
731
- stability: "stable",
732
- owners: [...OWNERS],
733
- tags: [
734
- "metering",
735
- "metric",
736
- "delete"
737
- ],
738
- description: "Delete a metric definition.",
739
- goal: "Remove a metric and its data.",
740
- context: "Called when removing a metric."
741
- },
742
- io: {
743
- input: DeleteMetricInput,
744
- output: SuccessOutput,
745
- errors: { METRIC_NOT_FOUND: {
746
- description: "Metric does not exist",
747
- http: 404,
748
- gqlCode: "METRIC_NOT_FOUND",
749
- when: "Metric ID is invalid"
750
- } }
751
- },
752
- policy: { auth: "admin" }
753
- });
754
- /**
755
- * Get a metric by key.
756
- */
757
- const GetMetricContract = defineQuery({
758
- meta: {
759
- name: "metric.get",
760
- version: 1,
761
- stability: "stable",
762
- owners: [...OWNERS],
763
- tags: [
764
- "metering",
765
- "metric",
766
- "get"
767
- ],
768
- description: "Get a metric by key.",
769
- goal: "Retrieve metric definition.",
770
- context: "Called to inspect metric details."
771
- },
772
- io: {
773
- input: GetMetricInput,
774
- output: MetricDefinitionModel,
775
- errors: { METRIC_NOT_FOUND: {
776
- description: "Metric does not exist",
777
- http: 404,
778
- gqlCode: "METRIC_NOT_FOUND",
779
- when: "Metric key is invalid"
780
- } }
781
- },
782
- policy: { auth: "user" }
783
- });
784
- /**
785
- * List metrics.
786
- */
787
- const ListMetricsContract = defineQuery({
788
- meta: {
789
- name: "metric.list",
790
- version: 1,
791
- stability: "stable",
792
- owners: [...OWNERS],
793
- tags: [
794
- "metering",
795
- "metric",
796
- "list"
797
- ],
798
- description: "List all metrics.",
799
- goal: "View configured metrics.",
800
- context: "Called to browse metrics."
801
- },
802
- io: {
803
- input: ListMetricsInput,
804
- output: ListMetricsOutput
805
- },
806
- policy: { auth: "user" }
807
- });
808
- /**
809
- * Record usage.
810
- */
811
- const RecordUsageContract = defineCommand({
812
- meta: {
813
- name: "usage.record",
814
- version: 1,
815
- stability: "stable",
816
- owners: [...OWNERS],
817
- tags: [
818
- "metering",
819
- "usage",
820
- "record"
821
- ],
822
- description: "Record a usage event.",
823
- goal: "Track usage for billing and monitoring.",
824
- context: "Called when usage occurs."
825
- },
826
- io: {
827
- input: RecordUsageInput,
828
- output: UsageRecordModel,
829
- errors: {
830
- METRIC_NOT_FOUND: {
831
- description: "Metric does not exist",
832
- http: 404,
833
- gqlCode: "METRIC_NOT_FOUND",
834
- when: "Metric key is invalid"
835
- },
836
- DUPLICATE_RECORD: {
837
- description: "Record already exists",
838
- http: 409,
839
- gqlCode: "DUPLICATE_RECORD",
840
- when: "Idempotency key already used"
841
- }
842
- }
843
- },
844
- policy: { auth: "admin" }
845
- });
846
- /**
847
- * Record batch usage.
848
- */
849
- const RecordBatchUsageContract = defineCommand({
850
- meta: {
851
- name: "usage.recordBatch",
852
- version: 1,
853
- stability: "stable",
854
- owners: [...OWNERS],
855
- tags: [
856
- "metering",
857
- "usage",
858
- "batch"
859
- ],
860
- description: "Record multiple usage events.",
861
- goal: "Efficiently track bulk usage.",
862
- context: "Called for batch processing."
863
- },
864
- io: {
865
- input: RecordBatchUsageInput,
866
- output: RecordBatchUsageOutput
867
- },
868
- policy: { auth: "admin" }
869
- });
870
- /**
871
- * Get usage records.
872
- */
873
- const GetUsageContract = defineQuery({
874
- meta: {
875
- name: "usage.get",
876
- version: 1,
877
- stability: "stable",
878
- owners: [...OWNERS],
879
- tags: [
880
- "metering",
881
- "usage",
882
- "get"
883
- ],
884
- description: "Get usage records for a subject.",
885
- goal: "View detailed usage history.",
886
- context: "Called to analyze usage."
887
- },
888
- io: {
889
- input: GetUsageInput,
890
- output: GetUsageOutput
891
- },
892
- policy: { auth: "user" }
893
- });
894
- /**
895
- * Get usage summary.
896
- */
897
- const GetUsageSummaryContract = defineQuery({
898
- meta: {
899
- name: "usage.getSummary",
900
- version: 1,
901
- stability: "stable",
902
- owners: [...OWNERS],
903
- tags: [
904
- "metering",
905
- "usage",
906
- "summary"
907
- ],
908
- description: "Get aggregated usage summary.",
909
- goal: "View usage totals for billing.",
910
- context: "Called for billing and reporting."
911
- },
912
- io: {
913
- input: GetUsageSummaryInput,
914
- output: GetUsageSummaryOutput
915
- },
916
- policy: { auth: "user" }
917
- });
918
- /**
919
- * Create a threshold.
920
- */
921
- const CreateThresholdContract = defineCommand({
922
- meta: {
923
- name: "threshold.create",
924
- version: 1,
925
- stability: "stable",
926
- owners: [...OWNERS],
927
- tags: [
928
- "metering",
929
- "threshold",
930
- "create"
931
- ],
932
- description: "Create a usage threshold.",
933
- goal: "Set up usage limits and alerts.",
934
- context: "Called when configuring limits."
935
- },
936
- io: {
937
- input: CreateThresholdInput,
938
- output: UsageThresholdModel,
939
- errors: { METRIC_NOT_FOUND: {
940
- description: "Metric does not exist",
941
- http: 404,
942
- gqlCode: "METRIC_NOT_FOUND",
943
- when: "Metric key is invalid"
944
- } }
945
- },
946
- policy: { auth: "admin" }
947
- });
948
- /**
949
- * Update a threshold.
950
- */
951
- const UpdateThresholdContract = defineCommand({
952
- meta: {
953
- name: "threshold.update",
954
- version: 1,
955
- stability: "stable",
956
- owners: [...OWNERS],
957
- tags: [
958
- "metering",
959
- "threshold",
960
- "update"
961
- ],
962
- description: "Update a threshold.",
963
- goal: "Modify threshold configuration.",
964
- context: "Called when adjusting limits."
965
- },
966
- io: {
967
- input: UpdateThresholdInput,
968
- output: UsageThresholdModel,
969
- errors: { THRESHOLD_NOT_FOUND: {
970
- description: "Threshold does not exist",
971
- http: 404,
972
- gqlCode: "THRESHOLD_NOT_FOUND",
973
- when: "Threshold ID is invalid"
974
- } }
975
- },
976
- policy: { auth: "admin" }
977
- });
978
- /**
979
- * Delete a threshold.
980
- */
981
- const DeleteThresholdContract = defineCommand({
982
- meta: {
983
- name: "threshold.delete",
984
- version: 1,
985
- stability: "stable",
986
- owners: [...OWNERS],
987
- tags: [
988
- "metering",
989
- "threshold",
990
- "delete"
991
- ],
992
- description: "Delete a threshold.",
993
- goal: "Remove a usage threshold.",
994
- context: "Called when removing limits."
995
- },
996
- io: {
997
- input: DeleteThresholdInput,
998
- output: SuccessOutput,
999
- errors: { THRESHOLD_NOT_FOUND: {
1000
- description: "Threshold does not exist",
1001
- http: 404,
1002
- gqlCode: "THRESHOLD_NOT_FOUND",
1003
- when: "Threshold ID is invalid"
1004
- } }
1005
- },
1006
- policy: { auth: "admin" }
1007
- });
1008
- /**
1009
- * List thresholds.
1010
- */
1011
- const ListThresholdsContract = defineQuery({
1012
- meta: {
1013
- name: "threshold.list",
1014
- version: 1,
1015
- stability: "stable",
1016
- owners: [...OWNERS],
1017
- tags: [
1018
- "metering",
1019
- "threshold",
1020
- "list"
1021
- ],
1022
- description: "List usage thresholds.",
1023
- goal: "View configured limits.",
1024
- context: "Called to browse thresholds."
1025
- },
1026
- io: {
1027
- input: ListThresholdsInput,
1028
- output: ListThresholdsOutput
1029
- },
1030
- policy: { auth: "user" }
1031
- });
1032
-
1033
- //#endregion
1034
- export { CreateThresholdContract, DefineMetricContract, DeleteMetricContract, DeleteThresholdContract, GetMetricContract, GetUsageContract, GetUsageSummaryContract, ListMetricsContract, ListThresholdsContract, MetricDefinitionModel, RecordBatchUsageContract, RecordUsageContract, UpdateMetricContract, UpdateThresholdContract, UsageRecordModel, UsageSummaryModel, UsageThresholdModel };
1
+ import{ScalarTypeEnum as e,defineSchemaModel as t}from"@lssm/lib.schema";import{defineCommand as n,defineQuery as r}from"@lssm/lib.contracts";const i=[`platform.metering`],a=t({name:`MetricDefinition`,description:`Represents a metric definition`,fields:{id:{type:e.String_unsecure(),isOptional:!1},key:{type:e.String_unsecure(),isOptional:!1},name:{type:e.String_unsecure(),isOptional:!1},description:{type:e.String_unsecure(),isOptional:!0},unit:{type:e.String_unsecure(),isOptional:!1},aggregationType:{type:e.String_unsecure(),isOptional:!1},resetPeriod:{type:e.String_unsecure(),isOptional:!1},category:{type:e.String_unsecure(),isOptional:!0},isActive:{type:e.Boolean(),isOptional:!1},orgId:{type:e.String_unsecure(),isOptional:!0},createdAt:{type:e.DateTime(),isOptional:!1},updatedAt:{type:e.DateTime(),isOptional:!1}}}),o=t({name:`UsageRecord`,description:`Represents a usage record`,fields:{id:{type:e.String_unsecure(),isOptional:!1},metricKey:{type:e.String_unsecure(),isOptional:!1},subjectType:{type:e.String_unsecure(),isOptional:!1},subjectId:{type:e.String_unsecure(),isOptional:!1},quantity:{type:e.Float_unsecure(),isOptional:!1},source:{type:e.String_unsecure(),isOptional:!0},resourceId:{type:e.String_unsecure(),isOptional:!0},resourceType:{type:e.String_unsecure(),isOptional:!0},metadata:{type:e.JSON(),isOptional:!0},timestamp:{type:e.DateTime(),isOptional:!1},createdAt:{type:e.DateTime(),isOptional:!1}}}),s=t({name:`UsageSummary`,description:`Represents aggregated usage`,fields:{id:{type:e.String_unsecure(),isOptional:!1},metricKey:{type:e.String_unsecure(),isOptional:!1},subjectType:{type:e.String_unsecure(),isOptional:!1},subjectId:{type:e.String_unsecure(),isOptional:!1},periodType:{type:e.String_unsecure(),isOptional:!1},periodStart:{type:e.DateTime(),isOptional:!1},periodEnd:{type:e.DateTime(),isOptional:!1},totalQuantity:{type:e.Float_unsecure(),isOptional:!1},recordCount:{type:e.Int_unsecure(),isOptional:!1},minQuantity:{type:e.Float_unsecure(),isOptional:!0},maxQuantity:{type:e.Float_unsecure(),isOptional:!0},avgQuantity:{type:e.Float_unsecure(),isOptional:!0}}}),c=t({name:`UsageThreshold`,description:`Represents a usage threshold`,fields:{id:{type:e.String_unsecure(),isOptional:!1},metricKey:{type:e.String_unsecure(),isOptional:!1},subjectType:{type:e.String_unsecure(),isOptional:!0},subjectId:{type:e.String_unsecure(),isOptional:!0},name:{type:e.String_unsecure(),isOptional:!1},threshold:{type:e.Float_unsecure(),isOptional:!1},warnThreshold:{type:e.Float_unsecure(),isOptional:!0},periodType:{type:e.String_unsecure(),isOptional:!1},action:{type:e.String_unsecure(),isOptional:!1},currentValue:{type:e.Float_unsecure(),isOptional:!1},isActive:{type:e.Boolean(),isOptional:!1},createdAt:{type:e.DateTime(),isOptional:!1}}}),l=t({name:`DefineMetricInput`,description:`Input for defining a metric`,fields:{key:{type:e.String_unsecure(),isOptional:!1},name:{type:e.String_unsecure(),isOptional:!1},description:{type:e.String_unsecure(),isOptional:!0},unit:{type:e.String_unsecure(),isOptional:!1},aggregationType:{type:e.String_unsecure(),isOptional:!0},resetPeriod:{type:e.String_unsecure(),isOptional:!0},category:{type:e.String_unsecure(),isOptional:!0},orgId:{type:e.String_unsecure(),isOptional:!0},metadata:{type:e.JSON(),isOptional:!0}}}),u=t({name:`UpdateMetricInput`,description:`Input for updating a metric`,fields:{metricId:{type:e.String_unsecure(),isOptional:!1},name:{type:e.String_unsecure(),isOptional:!0},description:{type:e.String_unsecure(),isOptional:!0},category:{type:e.String_unsecure(),isOptional:!0},isActive:{type:e.Boolean(),isOptional:!0},metadata:{type:e.JSON(),isOptional:!0}}}),d=t({name:`DeleteMetricInput`,description:`Input for deleting a metric`,fields:{metricId:{type:e.String_unsecure(),isOptional:!1}}}),f=t({name:`GetMetricInput`,description:`Input for getting a metric`,fields:{key:{type:e.String_unsecure(),isOptional:!1},orgId:{type:e.String_unsecure(),isOptional:!0}}}),p=t({name:`ListMetricsInput`,description:`Input for listing metrics`,fields:{orgId:{type:e.String_unsecure(),isOptional:!0},category:{type:e.String_unsecure(),isOptional:!0},isActive:{type:e.Boolean(),isOptional:!0},limit:{type:e.Int_unsecure(),isOptional:!0},offset:{type:e.Int_unsecure(),isOptional:!0}}}),m=t({name:`ListMetricsOutput`,description:`Output for listing metrics`,fields:{metrics:{type:a,isArray:!0,isOptional:!1},total:{type:e.Int_unsecure(),isOptional:!1}}}),h=t({name:`RecordUsageInput`,description:`Input for recording usage`,fields:{metricKey:{type:e.String_unsecure(),isOptional:!1},subjectType:{type:e.String_unsecure(),isOptional:!1},subjectId:{type:e.String_unsecure(),isOptional:!1},quantity:{type:e.Float_unsecure(),isOptional:!1},timestamp:{type:e.DateTime(),isOptional:!0},source:{type:e.String_unsecure(),isOptional:!0},resourceId:{type:e.String_unsecure(),isOptional:!0},resourceType:{type:e.String_unsecure(),isOptional:!0},metadata:{type:e.JSON(),isOptional:!0},idempotencyKey:{type:e.String_unsecure(),isOptional:!0}}}),g=t({name:`RecordBatchUsageInput`,description:`Input for recording batch usage`,fields:{records:{type:h,isArray:!0,isOptional:!1}}}),_=t({name:`RecordBatchUsageOutput`,description:`Output for recording batch usage`,fields:{recordedCount:{type:e.Int_unsecure(),isOptional:!1},skippedCount:{type:e.Int_unsecure(),isOptional:!1},recordIds:{type:e.JSON(),isOptional:!1}}}),v=t({name:`GetUsageInput`,description:`Input for getting usage`,fields:{metricKey:{type:e.String_unsecure(),isOptional:!1},subjectType:{type:e.String_unsecure(),isOptional:!1},subjectId:{type:e.String_unsecure(),isOptional:!1},startDate:{type:e.DateTime(),isOptional:!1},endDate:{type:e.DateTime(),isOptional:!1},limit:{type:e.Int_unsecure(),isOptional:!0},offset:{type:e.Int_unsecure(),isOptional:!0}}}),y=t({name:`GetUsageOutput`,description:`Output for getting usage`,fields:{records:{type:o,isArray:!0,isOptional:!1},total:{type:e.Int_unsecure(),isOptional:!1},totalQuantity:{type:e.Float_unsecure(),isOptional:!1}}}),b=t({name:`GetUsageSummaryInput`,description:`Input for getting usage summary`,fields:{metricKey:{type:e.String_unsecure(),isOptional:!1},subjectType:{type:e.String_unsecure(),isOptional:!1},subjectId:{type:e.String_unsecure(),isOptional:!1},periodType:{type:e.String_unsecure(),isOptional:!1},startDate:{type:e.DateTime(),isOptional:!1},endDate:{type:e.DateTime(),isOptional:!0}}}),x=t({name:`GetUsageSummaryOutput`,description:`Output for getting usage summary`,fields:{summaries:{type:s,isArray:!0,isOptional:!1},total:{type:e.Int_unsecure(),isOptional:!1}}}),S=t({name:`CreateThresholdInput`,description:`Input for creating a threshold`,fields:{metricKey:{type:e.String_unsecure(),isOptional:!1},subjectType:{type:e.String_unsecure(),isOptional:!0},subjectId:{type:e.String_unsecure(),isOptional:!0},name:{type:e.String_unsecure(),isOptional:!1},threshold:{type:e.Float_unsecure(),isOptional:!1},warnThreshold:{type:e.Float_unsecure(),isOptional:!0},periodType:{type:e.String_unsecure(),isOptional:!0},action:{type:e.String_unsecure(),isOptional:!0},notifyEmails:{type:e.JSON(),isOptional:!0},notifyWebhook:{type:e.String_unsecure(),isOptional:!0}}}),C=t({name:`UpdateThresholdInput`,description:`Input for updating a threshold`,fields:{thresholdId:{type:e.String_unsecure(),isOptional:!1},name:{type:e.String_unsecure(),isOptional:!0},threshold:{type:e.Float_unsecure(),isOptional:!0},warnThreshold:{type:e.Float_unsecure(),isOptional:!0},action:{type:e.String_unsecure(),isOptional:!0},notifyEmails:{type:e.JSON(),isOptional:!0},notifyWebhook:{type:e.String_unsecure(),isOptional:!0},isActive:{type:e.Boolean(),isOptional:!0}}}),w=t({name:`DeleteThresholdInput`,description:`Input for deleting a threshold`,fields:{thresholdId:{type:e.String_unsecure(),isOptional:!1}}}),T=t({name:`ListThresholdsInput`,description:`Input for listing thresholds`,fields:{metricKey:{type:e.String_unsecure(),isOptional:!0},subjectType:{type:e.String_unsecure(),isOptional:!0},subjectId:{type:e.String_unsecure(),isOptional:!0},isActive:{type:e.Boolean(),isOptional:!0}}}),E=t({name:`ListThresholdsOutput`,description:`Output for listing thresholds`,fields:{thresholds:{type:c,isArray:!0,isOptional:!1},total:{type:e.Int_unsecure(),isOptional:!1}}}),D=t({name:`SuccessOutput`,description:`Generic success output`,fields:{success:{type:e.Boolean(),isOptional:!1}}}),O=n({meta:{name:`metric.define`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`metric`,`define`],description:`Define a new usage metric.`,goal:`Create a new metric for tracking usage.`,context:`Called when setting up metering.`},io:{input:l,output:a,errors:{METRIC_KEY_EXISTS:{description:`Metric key already exists`,http:409,gqlCode:`METRIC_KEY_EXISTS`,when:`A metric with this key already exists`}}},policy:{auth:`admin`}}),k=n({meta:{name:`metric.update`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`metric`,`update`],description:`Update a metric definition.`,goal:`Modify metric configuration.`,context:`Called when updating metric settings.`},io:{input:u,output:a,errors:{METRIC_NOT_FOUND:{description:`Metric does not exist`,http:404,gqlCode:`METRIC_NOT_FOUND`,when:`Metric ID is invalid`}}},policy:{auth:`admin`}}),A=n({meta:{name:`metric.delete`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`metric`,`delete`],description:`Delete a metric definition.`,goal:`Remove a metric and its data.`,context:`Called when removing a metric.`},io:{input:d,output:D,errors:{METRIC_NOT_FOUND:{description:`Metric does not exist`,http:404,gqlCode:`METRIC_NOT_FOUND`,when:`Metric ID is invalid`}}},policy:{auth:`admin`}}),j=r({meta:{name:`metric.get`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`metric`,`get`],description:`Get a metric by key.`,goal:`Retrieve metric definition.`,context:`Called to inspect metric details.`},io:{input:f,output:a,errors:{METRIC_NOT_FOUND:{description:`Metric does not exist`,http:404,gqlCode:`METRIC_NOT_FOUND`,when:`Metric key is invalid`}}},policy:{auth:`user`}}),M=r({meta:{name:`metric.list`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`metric`,`list`],description:`List all metrics.`,goal:`View configured metrics.`,context:`Called to browse metrics.`},io:{input:p,output:m},policy:{auth:`user`}}),N=n({meta:{name:`usage.record`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`usage`,`record`],description:`Record a usage event.`,goal:`Track usage for billing and monitoring.`,context:`Called when usage occurs.`},io:{input:h,output:o,errors:{METRIC_NOT_FOUND:{description:`Metric does not exist`,http:404,gqlCode:`METRIC_NOT_FOUND`,when:`Metric key is invalid`},DUPLICATE_RECORD:{description:`Record already exists`,http:409,gqlCode:`DUPLICATE_RECORD`,when:`Idempotency key already used`}}},policy:{auth:`admin`}}),P=n({meta:{name:`usage.recordBatch`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`usage`,`batch`],description:`Record multiple usage events.`,goal:`Efficiently track bulk usage.`,context:`Called for batch processing.`},io:{input:g,output:_},policy:{auth:`admin`}}),F=r({meta:{name:`usage.get`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`usage`,`get`],description:`Get usage records for a subject.`,goal:`View detailed usage history.`,context:`Called to analyze usage.`},io:{input:v,output:y},policy:{auth:`user`}}),I=r({meta:{name:`usage.getSummary`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`usage`,`summary`],description:`Get aggregated usage summary.`,goal:`View usage totals for billing.`,context:`Called for billing and reporting.`},io:{input:b,output:x},policy:{auth:`user`}}),L=n({meta:{name:`threshold.create`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`threshold`,`create`],description:`Create a usage threshold.`,goal:`Set up usage limits and alerts.`,context:`Called when configuring limits.`},io:{input:S,output:c,errors:{METRIC_NOT_FOUND:{description:`Metric does not exist`,http:404,gqlCode:`METRIC_NOT_FOUND`,when:`Metric key is invalid`}}},policy:{auth:`admin`}}),R=n({meta:{name:`threshold.update`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`threshold`,`update`],description:`Update a threshold.`,goal:`Modify threshold configuration.`,context:`Called when adjusting limits.`},io:{input:C,output:c,errors:{THRESHOLD_NOT_FOUND:{description:`Threshold does not exist`,http:404,gqlCode:`THRESHOLD_NOT_FOUND`,when:`Threshold ID is invalid`}}},policy:{auth:`admin`}}),z=n({meta:{name:`threshold.delete`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`threshold`,`delete`],description:`Delete a threshold.`,goal:`Remove a usage threshold.`,context:`Called when removing limits.`},io:{input:w,output:D,errors:{THRESHOLD_NOT_FOUND:{description:`Threshold does not exist`,http:404,gqlCode:`THRESHOLD_NOT_FOUND`,when:`Threshold ID is invalid`}}},policy:{auth:`admin`}}),B=r({meta:{name:`threshold.list`,version:1,stability:`stable`,owners:[...i],tags:[`metering`,`threshold`,`list`],description:`List usage thresholds.`,goal:`View configured limits.`,context:`Called to browse thresholds.`},io:{input:T,output:E},policy:{auth:`user`}});export{L as CreateThresholdContract,O as DefineMetricContract,A as DeleteMetricContract,z as DeleteThresholdContract,j as GetMetricContract,F as GetUsageContract,I as GetUsageSummaryContract,M as ListMetricsContract,B as ListThresholdsContract,a as MetricDefinitionModel,P as RecordBatchUsageContract,N as RecordUsageContract,k as UpdateMetricContract,R as UpdateThresholdContract,o as UsageRecordModel,s as UsageSummaryModel,c as UsageThresholdModel};