@openmeter/sdk 1.0.0-beta.13 → 1.0.0-beta.131

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 (86) hide show
  1. package/README.md +224 -46
  2. package/dist/cjs/clients/client.cjs +120 -0
  3. package/dist/cjs/clients/client.d.cts +37 -0
  4. package/dist/cjs/clients/client.js.map +1 -0
  5. package/dist/cjs/clients/entitlement.cjs +39 -0
  6. package/dist/cjs/clients/entitlement.d.cts +32 -0
  7. package/dist/cjs/clients/entitlement.js.map +1 -0
  8. package/dist/cjs/clients/event.cjs +71 -0
  9. package/dist/cjs/clients/event.d.cts +79 -0
  10. package/dist/cjs/clients/event.js.map +1 -0
  11. package/dist/cjs/clients/feature.cjs +80 -0
  12. package/dist/cjs/clients/feature.d.cts +46 -0
  13. package/dist/cjs/clients/feature.js.map +1 -0
  14. package/dist/cjs/clients/grant.cjs +41 -0
  15. package/dist/cjs/clients/grant.d.cts +24 -0
  16. package/dist/cjs/clients/grant.js.map +1 -0
  17. package/dist/cjs/clients/meter.cjs +83 -0
  18. package/dist/cjs/clients/meter.d.cts +79 -0
  19. package/dist/cjs/clients/meter.js.map +1 -0
  20. package/dist/cjs/clients/pagination.cjs +3 -0
  21. package/dist/cjs/clients/pagination.d.cts +6 -0
  22. package/dist/cjs/clients/pagination.js.map +1 -0
  23. package/dist/cjs/clients/portal.cjs +41 -0
  24. package/dist/cjs/clients/portal.d.cts +22 -0
  25. package/dist/cjs/clients/portal.js.map +1 -0
  26. package/dist/cjs/clients/subject.cjs +242 -0
  27. package/dist/cjs/clients/subject.d.cts +125 -0
  28. package/dist/cjs/clients/subject.js.map +1 -0
  29. package/dist/cjs/index.cjs +33 -0
  30. package/dist/cjs/index.d.cts +21 -0
  31. package/dist/cjs/index.js.map +1 -0
  32. package/dist/cjs/schemas/openapi.cjs +7 -0
  33. package/dist/cjs/schemas/openapi.d.cts +3032 -0
  34. package/dist/cjs/schemas/openapi.js.map +1 -0
  35. package/dist/cjs/test/agent.cjs +485 -0
  36. package/dist/cjs/test/agent.d.cts +2 -0
  37. package/dist/cjs/test/agent.js.map +1 -0
  38. package/dist/cjs/test/mocks.cjs +153 -0
  39. package/dist/cjs/test/mocks.d.cts +25 -0
  40. package/dist/cjs/test/mocks.js.map +1 -0
  41. package/dist/cjs/tsconfig.229eb452.tsbuildinfo +1 -0
  42. package/dist/cjs/tsconfig.b2052a4e.tsbuildinfo +1 -0
  43. package/dist/clients/client.d.ts +1 -4
  44. package/dist/clients/client.js +12 -1
  45. package/dist/clients/client.js.map +1 -0
  46. package/dist/clients/entitlement.d.ts +32 -0
  47. package/dist/clients/entitlement.js +35 -0
  48. package/dist/clients/entitlement.js.map +1 -0
  49. package/dist/clients/event.d.ts +5 -5
  50. package/dist/clients/event.js +29 -18
  51. package/dist/clients/event.js.map +1 -0
  52. package/dist/clients/feature.d.ts +46 -0
  53. package/dist/clients/feature.js +76 -0
  54. package/dist/clients/feature.js.map +1 -0
  55. package/dist/clients/grant.d.ts +24 -0
  56. package/dist/clients/grant.js +37 -0
  57. package/dist/clients/grant.js.map +1 -0
  58. package/dist/clients/meter.d.ts +13 -30
  59. package/dist/clients/meter.js +15 -0
  60. package/dist/clients/meter.js.map +1 -0
  61. package/dist/clients/pagination.d.ts +6 -0
  62. package/dist/clients/pagination.js +2 -0
  63. package/dist/clients/pagination.js.map +1 -0
  64. package/dist/clients/portal.d.ts +22 -0
  65. package/dist/clients/portal.js +37 -0
  66. package/dist/clients/portal.js.map +1 -0
  67. package/dist/clients/subject.d.ts +125 -0
  68. package/dist/clients/subject.js +238 -0
  69. package/dist/clients/subject.js.map +1 -0
  70. package/dist/index.d.ts +11 -2
  71. package/dist/index.js +16 -1
  72. package/dist/index.js.map +1 -0
  73. package/dist/schemas/openapi.d.ts +2790 -164
  74. package/dist/schemas/openapi.js +1 -0
  75. package/dist/schemas/openapi.js.map +1 -0
  76. package/dist/test/agent.js +327 -29
  77. package/dist/test/agent.js.map +1 -0
  78. package/dist/test/mocks.d.ts +13 -0
  79. package/dist/test/mocks.js +118 -0
  80. package/dist/test/mocks.js.map +1 -0
  81. package/dist/tsconfig.tsbuildinfo +1 -1
  82. package/package.json +40 -30
  83. package/dist/next.d.ts +0 -15
  84. package/dist/next.js +0 -46
  85. package/index.ts +0 -19
  86. package/next.ts +0 -76
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../../clients/event.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAE3B,2CAAyE;AAuEzE,MAAa,YAAa,SAAQ,sBAAU;IAC1C,YAAY,MAAuB;QACjC,KAAK,CAAC,MAAM,CAAC,CAAA;IACf,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,MAAM,CACjB,UAA2B,EAC3B,OAAwB;QAExB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QACzC,MAAM,WAAW,GAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CACzE,CAAC,EAAE,EAAE,EAAE;YACL,wBAAwB;YACxB,IAAI,EAAE,CAAC,eAAe,IAAI,EAAE,CAAC,eAAe,KAAK,kBAAkB,EAAE,CAAC;gBACpE,MAAM,IAAI,SAAS,CACjB,gCAAgC,EAAE,CAAC,eAAe,EAAE,CACrD,CAAA;YACH,CAAC;YAED,kEAAkE;YAClE,MAAM,UAAU,GAAe;gBAC7B,WAAW,EAAE,EAAE,CAAC,WAAW,IAAI,KAAK;gBACpC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,gBAAM,CAAC,UAAU,EAAE;gBAChC,MAAM,EAAE,EAAE,CAAC,MAAM,IAAI,gBAAgB;gBACrC,IAAI,EAAE,EAAE,CAAC,IAAI;gBACb,OAAO,EAAE,EAAE,CAAC,OAAO;gBACnB,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE;gBAC5B,eAAe,EAAE,EAAE,CAAC,eAAe;gBACnC,UAAU,EAAE,EAAE,CAAC,UAAU;gBACzB,IAAI,EAAE,EAAE,CAAC,IAAI;aACd,CAAA;YAED,OAAO,UAAU,CAAA;QACnB,CAAC,CACF,CAAA;QAED,MAAM,WAAW,GAAG,OAAO;YACzB,CAAC,CAAC,oCAAoC;YACtC,CAAC,CAAC,8BAA8B,CAAA;QAClC,MAAM,IAAI,GAAG,OAAO;YAClB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;YAC7B,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;QAElC,iBAAiB;QACjB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC;YACxB,IAAI,EAAE,gBAAgB;YACtB,MAAM,EAAE,MAAM;YACd,IAAI;YACJ,OAAO,EAAE;gBACP,cAAc,EAAE,WAAW;aAC5B;YACD,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CACf,MAA0B,EAC1B,OAAwB;QAExB,MAAM,YAAY,GAAG,MAAM;YACzB,CAAC,CAAC,sBAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC;YACtC,CAAC,CAAC,SAAS,CAAA;QACb,OAAO,IAAI,CAAC,OAAO,CAAkB;YACnC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB;YACtB,YAAY;YACZ,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF;AA5ED,oCA4EC"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FeatureClient = void 0;
4
+ const client_js_1 = require("./client.cjs");
5
+ class FeatureClient extends client_js_1.BaseClient {
6
+ constructor(config) {
7
+ super(config);
8
+ }
9
+ /**
10
+ * Features are the building blocks of your entitlements, part of your product offering.
11
+ * @description
12
+ * Features are either metered or static. A feature is metered if meterSlug is provided at creation. For metered features you can pass additional filters that will be applied when calculating feature usage, based on the meter's groupBy fields. Only meters with SUM and COUNT aggregation are supported for features.
13
+ *
14
+ * Features cannot be updated later, only archived.
15
+ *
16
+ * @example
17
+ * const feature = await openmeter.features.create({
18
+ * key: 'ai_tokens',
19
+ * name: 'AI Tokens',
20
+ * // optional
21
+ * meterSlug: 'tokens_total',
22
+ * })
23
+ */
24
+ async create(input, options) {
25
+ return await this.request({
26
+ path: '/api/v1/features',
27
+ method: 'POST',
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ },
31
+ body: JSON.stringify(input),
32
+ options,
33
+ });
34
+ }
35
+ /**
36
+ * Get Feature
37
+ *
38
+ * @example
39
+ * const feature = await openmeter.features.get('ai_tokens')
40
+ */
41
+ async get(id, options) {
42
+ return await this.request({
43
+ path: `/api/v1/features/${id}`,
44
+ method: 'GET',
45
+ options,
46
+ });
47
+ }
48
+ /**
49
+ * List features
50
+ * @example
51
+ * const feature = await openmeter.features.list()
52
+ */
53
+ async list(params, options) {
54
+ const searchParams = params
55
+ ? client_js_1.BaseClient.toURLSearchParams(params)
56
+ : undefined;
57
+ return await this.request({
58
+ path: '/api/v1/features',
59
+ method: 'GET',
60
+ searchParams,
61
+ options,
62
+ });
63
+ }
64
+ /**
65
+ * Archive a feature
66
+ * @description
67
+ * Once a feature is archived it cannot be unarchived. If a feature is archived, new entitlements cannot be created for it, but archiving the feature does not affect existing entitlements.
68
+ * @example
69
+ * await openmeter.delete('ai_tokens')
70
+ */
71
+ async delete(id, options) {
72
+ return await this.request({
73
+ path: `/api/v1/features/${id}`,
74
+ method: 'DELETE',
75
+ options,
76
+ });
77
+ }
78
+ }
79
+ exports.FeatureClient = FeatureClient;
80
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1,46 @@
1
+ import { components, operations } from '../schemas/openapi.cjs';
2
+ import { RequestOptions, BaseClient, OpenMeterConfig } from './client.cjs';
3
+ import { Paginated } from './pagination.cjs';
4
+ export type Feature = components['schemas']['Feature'];
5
+ export type FeatureCreateInputs = components['schemas']['FeatureCreateInputs'];
6
+ export type ListFeatureQueryParams = operations['listFeatures']['parameters']['query'];
7
+ export declare class FeatureClient extends BaseClient {
8
+ constructor(config: OpenMeterConfig);
9
+ /**
10
+ * Features are the building blocks of your entitlements, part of your product offering.
11
+ * @description
12
+ * Features are either metered or static. A feature is metered if meterSlug is provided at creation. For metered features you can pass additional filters that will be applied when calculating feature usage, based on the meter's groupBy fields. Only meters with SUM and COUNT aggregation are supported for features.
13
+ *
14
+ * Features cannot be updated later, only archived.
15
+ *
16
+ * @example
17
+ * const feature = await openmeter.features.create({
18
+ * key: 'ai_tokens',
19
+ * name: 'AI Tokens',
20
+ * // optional
21
+ * meterSlug: 'tokens_total',
22
+ * })
23
+ */
24
+ create(input: FeatureCreateInputs, options?: RequestOptions): Promise<Feature>;
25
+ /**
26
+ * Get Feature
27
+ *
28
+ * @example
29
+ * const feature = await openmeter.features.get('ai_tokens')
30
+ */
31
+ get(id: string, options?: RequestOptions): Promise<Feature>;
32
+ /**
33
+ * List features
34
+ * @example
35
+ * const feature = await openmeter.features.list()
36
+ */
37
+ list(params?: ListFeatureQueryParams, options?: RequestOptions): Promise<Feature[] | Paginated<Feature>>;
38
+ /**
39
+ * Archive a feature
40
+ * @description
41
+ * Once a feature is archived it cannot be unarchived. If a feature is archived, new entitlements cannot be created for it, but archiving the feature does not affect existing entitlements.
42
+ * @example
43
+ * await openmeter.delete('ai_tokens')
44
+ */
45
+ delete(id: string, options?: RequestOptions): Promise<void>;
46
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature.js","sourceRoot":"","sources":["../../../clients/feature.ts"],"names":[],"mappings":";;;AACA,2CAAyE;AAQzE,MAAa,aAAc,SAAQ,sBAAU;IAC3C,YAAY,MAAuB;QACjC,KAAK,CAAC,MAAM,CAAC,CAAA;IACf,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACI,KAAK,CAAC,MAAM,CACjB,KAA0B,EAC1B,OAAwB;QAExB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC;YACxB,IAAI,EAAE,kBAAkB;YACxB,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC3B,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAAG,CAAC,EAAU,EAAE,OAAwB;QACnD,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC;YACxB,IAAI,EAAE,oBAAoB,EAAE,EAAE;YAC9B,MAAM,EAAE,KAAK;YACb,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CACf,MAA+B,EAC/B,OAAwB;QAExB,MAAM,YAAY,GAAG,MAAM;YACzB,CAAC,CAAC,sBAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC;YACtC,CAAC,CAAC,SAAS,CAAA;QACb,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC;YACxB,IAAI,EAAE,kBAAkB;YACxB,MAAM,EAAE,KAAK;YACb,YAAY;YACZ,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,OAAwB;QACtD,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC;YACxB,IAAI,EAAE,oBAAoB,EAAE,EAAE;YAC9B,MAAM,EAAE,QAAQ;YAChB,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF;AAnFD,sCAmFC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GrantClient = void 0;
4
+ const client_js_1 = require("./client.cjs");
5
+ class GrantClient extends client_js_1.BaseClient {
6
+ constructor(config) {
7
+ super(config);
8
+ }
9
+ /**
10
+ * List grants
11
+ * @example
12
+ * const grant = await openmeter.grants.list()
13
+ */
14
+ async list(params, options) {
15
+ const searchParams = params
16
+ ? client_js_1.BaseClient.toURLSearchParams(params)
17
+ : undefined;
18
+ return await this.request({
19
+ path: '/api/v1/grants',
20
+ method: 'GET',
21
+ searchParams,
22
+ options,
23
+ });
24
+ }
25
+ /**
26
+ * Void a grant
27
+ * @description
28
+ * Voiding a grant means it is no longer valid, it doesn't take part in further balance calculations. Voiding a grant does not retroactively take effect, meaning any usage that has already been attributed to the grant will remain, but future usage cannot be burnt down from the grant.
29
+ * @example
30
+ * const grant = await openmeter.grants.list()
31
+ */
32
+ async delete(id, options) {
33
+ return await this.request({
34
+ method: 'DELETE',
35
+ path: `/api/v1/grants/${id}`,
36
+ options,
37
+ });
38
+ }
39
+ }
40
+ exports.GrantClient = GrantClient;
41
+ //# sourceMappingURL=grant.js.map
@@ -0,0 +1,24 @@
1
+ import { components, operations } from '../schemas/openapi.cjs';
2
+ import { RequestOptions, BaseClient, OpenMeterConfig } from './client.cjs';
3
+ import { Paginated } from './pagination.cjs';
4
+ export type EntitlementGrant = components['schemas']['EntitlementGrant'];
5
+ export type EntitlementGrantCreateInput = components['schemas']['EntitlementGrantCreateInput'];
6
+ export type ListGrantQueryParams = operations['listGrants']['parameters']['query'];
7
+ export type ListEntitlementGrantQueryParams = operations['listEntitlementGrants']['parameters']['query'];
8
+ export declare class GrantClient extends BaseClient {
9
+ constructor(config: OpenMeterConfig);
10
+ /**
11
+ * List grants
12
+ * @example
13
+ * const grant = await openmeter.grants.list()
14
+ */
15
+ list(params?: ListGrantQueryParams, options?: RequestOptions): Promise<EntitlementGrant[] | Paginated<EntitlementGrant>>;
16
+ /**
17
+ * Void a grant
18
+ * @description
19
+ * Voiding a grant means it is no longer valid, it doesn't take part in further balance calculations. Voiding a grant does not retroactively take effect, meaning any usage that has already been attributed to the grant will remain, but future usage cannot be burnt down from the grant.
20
+ * @example
21
+ * const grant = await openmeter.grants.list()
22
+ */
23
+ delete(id: string, options?: RequestOptions): Promise<EntitlementGrant[]>;
24
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grant.js","sourceRoot":"","sources":["../../../clients/grant.ts"],"names":[],"mappings":";;;AACA,2CAAyE;AAWzE,MAAa,WAAY,SAAQ,sBAAU;IACzC,YAAY,MAAuB;QACjC,KAAK,CAAC,MAAM,CAAC,CAAA;IACf,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CACf,MAA6B,EAC7B,OAAwB;QAExB,MAAM,YAAY,GAAG,MAAM;YACzB,CAAC,CAAC,sBAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC;YACtC,CAAC,CAAC,SAAS,CAAA;QACb,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC;YACxB,IAAI,EAAE,gBAAgB;YACtB,MAAM,EAAE,KAAK;YACb,YAAY;YACZ,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CACjB,EAAU,EACV,OAAwB;QAExB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC;YACxB,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,kBAAkB,EAAE,EAAE;YAC5B,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF;AA1CD,kCA0CC"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MetersClient = exports.MeterAggregation = exports.WindowSize = void 0;
4
+ const client_js_1 = require("./client.cjs");
5
+ var WindowSize;
6
+ (function (WindowSize) {
7
+ WindowSize["MINUTE"] = "MINUTE";
8
+ WindowSize["HOUR"] = "HOUR";
9
+ WindowSize["DAY"] = "DAY";
10
+ })(WindowSize || (exports.WindowSize = WindowSize = {}));
11
+ var MeterAggregation;
12
+ (function (MeterAggregation) {
13
+ MeterAggregation["SUM"] = "SUM";
14
+ MeterAggregation["COUNT"] = "COUNT";
15
+ MeterAggregation["AVG"] = "AVG";
16
+ MeterAggregation["MIN"] = "MIN";
17
+ MeterAggregation["MAX"] = "MAX";
18
+ })(MeterAggregation || (exports.MeterAggregation = MeterAggregation = {}));
19
+ class MetersClient extends client_js_1.BaseClient {
20
+ constructor(config) {
21
+ super(config);
22
+ }
23
+ /**
24
+ * Create a meter
25
+ */
26
+ async create(meter, options) {
27
+ return this.request({
28
+ method: 'POST',
29
+ path: `/api/v1/meters`,
30
+ headers: {
31
+ 'Content-Type': 'application/json',
32
+ },
33
+ body: JSON.stringify(meter),
34
+ options,
35
+ });
36
+ }
37
+ /**
38
+ * Get one meter by slug
39
+ */
40
+ async get(slug, options) {
41
+ return this.request({
42
+ method: 'GET',
43
+ path: `/api/v1/meters/${slug}`,
44
+ options,
45
+ });
46
+ }
47
+ /**
48
+ * List meters
49
+ */
50
+ async list(options) {
51
+ return this.request({
52
+ method: 'GET',
53
+ path: `/api/v1/meters`,
54
+ options,
55
+ });
56
+ }
57
+ /**
58
+ * Query a meter
59
+ */
60
+ async query(slug, params, options) {
61
+ const searchParams = params
62
+ ? client_js_1.BaseClient.toURLSearchParams(params)
63
+ : undefined;
64
+ return this.request({
65
+ method: 'GET',
66
+ path: `/api/v1/meters/${slug}/query`,
67
+ searchParams,
68
+ options,
69
+ });
70
+ }
71
+ /**
72
+ * List subjects of a meter
73
+ */
74
+ async subjects(slug, options) {
75
+ return this.request({
76
+ method: 'GET',
77
+ path: `/api/v1/meters/${slug}/subjects`,
78
+ options,
79
+ });
80
+ }
81
+ }
82
+ exports.MetersClient = MetersClient;
83
+ //# sourceMappingURL=meter.js.map
@@ -0,0 +1,79 @@
1
+ import { paths, components } from '../schemas/openapi.cjs';
2
+ import { BaseClient, OpenMeterConfig, RequestOptions } from './client.cjs';
3
+ export declare enum WindowSize {
4
+ MINUTE = "MINUTE",
5
+ HOUR = "HOUR",
6
+ DAY = "DAY"
7
+ }
8
+ export declare enum MeterAggregation {
9
+ SUM = "SUM",
10
+ COUNT = "COUNT",
11
+ AVG = "AVG",
12
+ MIN = "MIN",
13
+ MAX = "MAX"
14
+ }
15
+ export type MeterQueryParams = {
16
+ /**
17
+ * @description Subject(s) to filter by.
18
+ * @example ["customer-1", "customer-2"]
19
+ */
20
+ subject?: string[];
21
+ /**
22
+ * @description Start date.
23
+ * Must be aligned with the window size.
24
+ * Inclusive.
25
+ */
26
+ from?: Date;
27
+ /**
28
+ * @description End date.
29
+ * Must be aligned with the window size.
30
+ * Inclusive.
31
+ */
32
+ to?: Date;
33
+ /**
34
+ * @description Window Size
35
+ * If not specified, a single usage aggregate will be returned for the entirety of
36
+ * the specified period for each subject and group.
37
+ */
38
+ windowSize?: WindowSizeType;
39
+ /**
40
+ * @description The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones).
41
+ * If not specified, the UTC timezone will be used.
42
+ */
43
+ windowTimeZone?: string;
44
+ /**
45
+ * @description Group By
46
+ * If not specified a single aggregate will be returned for each subject and time window.
47
+ */
48
+ groupBy?: string[];
49
+ /**
50
+ * @description Filter by group by
51
+ */
52
+ filterGroupBy?: Record<string, string>;
53
+ };
54
+ export type MeterQueryResponse = paths['/api/v1/meters/{meterIdOrSlug}/query']['get']['responses']['200']['content']['application/json'];
55
+ export type Meter = components['schemas']['Meter'];
56
+ export type WindowSizeType = components['schemas']['WindowSize'];
57
+ export declare class MetersClient extends BaseClient {
58
+ constructor(config: OpenMeterConfig);
59
+ /**
60
+ * Create a meter
61
+ */
62
+ create(meter: Meter, options?: RequestOptions): Promise<Meter>;
63
+ /**
64
+ * Get one meter by slug
65
+ */
66
+ get(slug: string, options?: RequestOptions): Promise<Meter>;
67
+ /**
68
+ * List meters
69
+ */
70
+ list(options?: RequestOptions): Promise<Meter[]>;
71
+ /**
72
+ * Query a meter
73
+ */
74
+ query(slug: string, params?: MeterQueryParams, options?: RequestOptions): Promise<MeterQueryResponse>;
75
+ /**
76
+ * List subjects of a meter
77
+ */
78
+ subjects(slug: string, options?: RequestOptions): Promise<string[]>;
79
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meter.js","sourceRoot":"","sources":["../../../clients/meter.ts"],"names":[],"mappings":";;;AACA,2CAAyE;AAEzE,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,2BAAa,CAAA;IACb,yBAAW,CAAA;AACb,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB;AAED,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,+BAAW,CAAA;IACX,mCAAe,CAAA;IACf,+BAAW,CAAA;IACX,+BAAW,CAAA;IACX,+BAAW,CAAA;AACb,CAAC,EANW,gBAAgB,gCAAhB,gBAAgB,QAM3B;AAgDD,MAAa,YAAa,SAAQ,sBAAU;IAC1C,YAAY,MAAuB;QACjC,KAAK,CAAC,MAAM,CAAC,CAAA;IACf,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,KAAY,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAQ;YACzB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC3B,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,OAAwB;QACrD,OAAO,IAAI,CAAC,OAAO,CAAQ;YACzB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,kBAAkB,IAAI,EAAE;YAC9B,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAAC,OAAwB;QACxC,OAAO,IAAI,CAAC,OAAO,CAAU;YAC3B,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB;YACtB,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,KAAK,CAChB,IAAY,EACZ,MAAyB,EACzB,OAAwB;QAExB,MAAM,YAAY,GAAG,MAAM;YACzB,CAAC,CAAC,sBAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC;YACtC,CAAC,CAAC,SAAS,CAAA;QACb,OAAO,IAAI,CAAC,OAAO,CAAqB;YACtC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,kBAAkB,IAAI,QAAQ;YACpC,YAAY;YACZ,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,QAAQ,CACnB,IAAY,EACZ,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAW;YAC5B,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,kBAAkB,IAAI,WAAW;YACvC,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF;AA1ED,oCA0EC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=pagination.js.map
@@ -0,0 +1,6 @@
1
+ export interface Paginated<T> {
2
+ items: T[];
3
+ totalCount: number;
4
+ page: number;
5
+ pageSize: number;
6
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../../clients/pagination.ts"],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PortalClient = void 0;
4
+ const client_js_1 = require("./client.cjs");
5
+ class PortalClient extends client_js_1.BaseClient {
6
+ constructor(config) {
7
+ super(config);
8
+ }
9
+ /**
10
+ * Create portal token
11
+ * Useful for creating a token sharable with your customer to query their own usage
12
+ */
13
+ async createToken(token, options) {
14
+ return await this.request({
15
+ path: '/api/v1/portal/tokens',
16
+ method: 'POST',
17
+ headers: {
18
+ 'Content-Type': 'application/json',
19
+ },
20
+ body: JSON.stringify(token),
21
+ options,
22
+ });
23
+ }
24
+ /**
25
+ * Invalidate portal token
26
+ * @note OpenMeter Cloud only feature
27
+ */
28
+ async invalidateTokens(invalidate = {}, options) {
29
+ return await this.request({
30
+ path: '/api/v1/portal/tokens/invalidate',
31
+ method: 'POST',
32
+ headers: {
33
+ 'Content-Type': 'application/json',
34
+ },
35
+ body: JSON.stringify(invalidate),
36
+ options,
37
+ });
38
+ }
39
+ }
40
+ exports.PortalClient = PortalClient;
41
+ //# sourceMappingURL=portal.js.map
@@ -0,0 +1,22 @@
1
+ import { components } from '../schemas/openapi.cjs';
2
+ import { RequestOptions, BaseClient, OpenMeterConfig } from './client.cjs';
3
+ export type PortalToken = components['schemas']['PortalToken'];
4
+ export declare class PortalClient extends BaseClient {
5
+ constructor(config: OpenMeterConfig);
6
+ /**
7
+ * Create portal token
8
+ * Useful for creating a token sharable with your customer to query their own usage
9
+ */
10
+ createToken(token: {
11
+ subject: string;
12
+ expiresAt?: Date;
13
+ allowedMeterSlugs?: string[];
14
+ }, options?: RequestOptions): Promise<PortalToken>;
15
+ /**
16
+ * Invalidate portal token
17
+ * @note OpenMeter Cloud only feature
18
+ */
19
+ invalidateTokens(invalidate?: {
20
+ subject?: string;
21
+ }, options?: RequestOptions): Promise<void>;
22
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal.js","sourceRoot":"","sources":["../../../clients/portal.ts"],"names":[],"mappings":";;;AACA,2CAAyE;AAIzE,MAAa,YAAa,SAAQ,sBAAU;IAC1C,YAAY,MAAuB;QACjC,KAAK,CAAC,MAAM,CAAC,CAAA;IACf,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW,CACtB,KAIC,EACD,OAAwB;QAExB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC;YACxB,IAAI,EAAE,uBAAuB;YAC7B,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC3B,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,gBAAgB,CAC3B,aAAmC,EAAE,EACrC,OAAwB;QAExB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC;YACxB,IAAI,EAAE,kCAAkC;YACxC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;YAChC,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF;AA9CD,oCA8CC"}