@openmeter/sdk 1.0.0-beta.21 → 1.0.0-beta.210

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/README.md +38 -150
  2. package/dist/cjs/index.cjs +18 -0
  3. package/dist/cjs/index.d.cts +1 -0
  4. package/dist/cjs/index.js.map +1 -0
  5. package/dist/cjs/src/client/apps.cjs +174 -0
  6. package/dist/cjs/src/client/apps.d.cts +285 -0
  7. package/dist/cjs/src/client/apps.js.map +1 -0
  8. package/dist/cjs/src/client/billing.cjs +309 -0
  9. package/dist/cjs/src/client/billing.d.cts +502 -0
  10. package/dist/cjs/src/client/billing.js.map +1 -0
  11. package/dist/cjs/src/client/common.cjs +47 -0
  12. package/dist/cjs/src/client/common.d.cts +30 -0
  13. package/dist/cjs/src/client/common.js.map +1 -0
  14. package/dist/cjs/src/client/customers.cjs +199 -0
  15. package/dist/cjs/src/client/customers.d.cts +176 -0
  16. package/dist/cjs/src/client/customers.js.map +1 -0
  17. package/dist/cjs/src/client/entitlements.cjs +244 -0
  18. package/dist/cjs/src/client/entitlements.d.cts +472 -0
  19. package/dist/cjs/src/client/entitlements.js.map +1 -0
  20. package/dist/cjs/src/client/events.cjs +66 -0
  21. package/dist/cjs/src/client/events.d.cts +31 -0
  22. package/dist/cjs/src/client/events.js.map +1 -0
  23. package/dist/cjs/src/client/features.cjs +78 -0
  24. package/dist/cjs/src/client/features.d.cts +78 -0
  25. package/dist/cjs/src/client/features.js.map +1 -0
  26. package/dist/cjs/src/client/index.cjs +108 -0
  27. package/dist/cjs/src/client/index.d.cts +45 -0
  28. package/dist/cjs/src/client/index.js.map +1 -0
  29. package/dist/cjs/src/client/meters.cjs +96 -0
  30. package/dist/cjs/src/client/meters.d.cts +99 -0
  31. package/dist/cjs/src/client/meters.js.map +1 -0
  32. package/dist/cjs/src/client/notifications.cjs +249 -0
  33. package/dist/cjs/src/client/notifications.d.cts +219 -0
  34. package/dist/cjs/src/client/notifications.js.map +1 -0
  35. package/dist/cjs/src/client/plans.cjs +127 -0
  36. package/dist/cjs/src/client/plans.d.cts +142 -0
  37. package/dist/cjs/src/client/plans.js.map +1 -0
  38. package/dist/cjs/src/client/portal.cjs +55 -0
  39. package/dist/cjs/src/client/portal.d.cts +48 -0
  40. package/dist/cjs/src/client/portal.js.map +1 -0
  41. package/dist/cjs/src/client/schemas.cjs +3 -0
  42. package/dist/cjs/src/client/schemas.d.cts +22268 -0
  43. package/dist/cjs/src/client/schemas.js.map +1 -0
  44. package/dist/cjs/src/client/subjects.cjs +76 -0
  45. package/dist/cjs/src/client/subjects.d.cts +70 -0
  46. package/dist/cjs/src/client/subjects.js.map +1 -0
  47. package/dist/cjs/src/client/subscriptions.cjs +116 -0
  48. package/dist/cjs/src/client/subscriptions.d.cts +147 -0
  49. package/dist/cjs/src/client/subscriptions.js.map +1 -0
  50. package/dist/cjs/src/client/utils.cjs +69 -0
  51. package/dist/cjs/src/client/utils.d.cts +12 -0
  52. package/dist/cjs/src/client/utils.js.map +1 -0
  53. package/dist/cjs/src/portal/index.cjs +60 -0
  54. package/dist/cjs/src/portal/index.d.cts +43 -0
  55. package/dist/cjs/src/portal/index.js.map +1 -0
  56. package/dist/cjs/src/react/context.cjs +35 -0
  57. package/dist/cjs/src/react/context.d.cts +9 -0
  58. package/dist/cjs/src/react/context.js.map +1 -0
  59. package/dist/cjs/tsconfig.1232d5e5.tsbuildinfo +1 -0
  60. package/dist/cjs/tsconfig.90ca0b5f.tsbuildinfo +1 -0
  61. package/dist/index.d.ts +1 -14
  62. package/dist/index.js +2 -15
  63. package/dist/index.js.map +1 -0
  64. package/dist/src/client/apps.d.ts +285 -0
  65. package/dist/src/client/apps.js +168 -0
  66. package/dist/src/client/apps.js.map +1 -0
  67. package/dist/src/client/billing.d.ts +502 -0
  68. package/dist/src/client/billing.js +302 -0
  69. package/dist/src/client/billing.js.map +1 -0
  70. package/dist/src/client/common.d.ts +30 -0
  71. package/dist/src/client/common.js +42 -0
  72. package/dist/src/client/common.js.map +1 -0
  73. package/dist/src/client/customers.d.ts +176 -0
  74. package/dist/src/client/customers.js +193 -0
  75. package/dist/src/client/customers.js.map +1 -0
  76. package/dist/src/client/entitlements.d.ts +472 -0
  77. package/dist/src/client/entitlements.js +239 -0
  78. package/dist/src/client/entitlements.js.map +1 -0
  79. package/dist/src/client/events.d.ts +31 -0
  80. package/dist/src/client/events.js +58 -0
  81. package/dist/src/client/events.js.map +1 -0
  82. package/dist/src/client/features.d.ts +78 -0
  83. package/dist/src/client/features.js +74 -0
  84. package/dist/src/client/features.js.map +1 -0
  85. package/dist/src/client/index.d.ts +45 -0
  86. package/dist/src/client/index.js +68 -0
  87. package/dist/src/client/index.js.map +1 -0
  88. package/dist/src/client/meters.d.ts +99 -0
  89. package/dist/src/client/meters.js +92 -0
  90. package/dist/src/client/meters.js.map +1 -0
  91. package/dist/src/client/notifications.d.ts +219 -0
  92. package/dist/src/client/notifications.js +242 -0
  93. package/dist/src/client/notifications.js.map +1 -0
  94. package/dist/src/client/plans.d.ts +142 -0
  95. package/dist/src/client/plans.js +123 -0
  96. package/dist/src/client/plans.js.map +1 -0
  97. package/dist/src/client/portal.d.ts +48 -0
  98. package/dist/src/client/portal.js +51 -0
  99. package/dist/src/client/portal.js.map +1 -0
  100. package/dist/src/client/schemas.d.ts +22268 -0
  101. package/dist/src/client/schemas.js +2 -0
  102. package/dist/src/client/schemas.js.map +1 -0
  103. package/dist/src/client/subjects.d.ts +70 -0
  104. package/dist/src/client/subjects.js +72 -0
  105. package/dist/src/client/subjects.js.map +1 -0
  106. package/dist/src/client/subscriptions.d.ts +147 -0
  107. package/dist/src/client/subscriptions.js +112 -0
  108. package/dist/src/client/subscriptions.js.map +1 -0
  109. package/dist/src/client/utils.d.ts +12 -0
  110. package/dist/src/client/utils.js +63 -0
  111. package/dist/src/client/utils.js.map +1 -0
  112. package/dist/src/portal/index.d.ts +43 -0
  113. package/dist/src/portal/index.js +53 -0
  114. package/dist/src/portal/index.js.map +1 -0
  115. package/dist/src/react/context.d.ts +9 -0
  116. package/dist/src/react/context.js +16 -0
  117. package/dist/src/react/context.js.map +1 -0
  118. package/dist/tsconfig.tsbuildinfo +1 -1
  119. package/package.json +75 -35
  120. package/patches/openapi-typescript.patch +73 -0
  121. package/dist/clients/client.d.ts +0 -40
  122. package/dist/clients/client.js +0 -104
  123. package/dist/clients/event.d.ts +0 -79
  124. package/dist/clients/event.js +0 -53
  125. package/dist/clients/meter.d.ts +0 -96
  126. package/dist/clients/meter.js +0 -64
  127. package/dist/clients/portal.d.ts +0 -23
  128. package/dist/clients/portal.js +0 -37
  129. package/dist/next.d.ts +0 -15
  130. package/dist/next.js +0 -46
  131. package/dist/schemas/openapi.d.ts +0 -460
  132. package/dist/schemas/openapi.js +0 -5
  133. package/dist/test/agent.d.ts +0 -2
  134. package/dist/test/agent.js +0 -178
  135. package/dist/test/mocks.d.ts +0 -12
  136. package/dist/test/mocks.js +0 -32
  137. package/index.ts +0 -22
  138. package/next.ts +0 -76
@@ -0,0 +1,99 @@
1
+ import type { RequestOptions } from './common.js';
2
+ import type { MeterCreate, operations, paths } from './schemas.js';
3
+ import type { Client } from 'openapi-fetch';
4
+ /**
5
+ * Meters
6
+ * @description Meters are used to track and manage usage of your application.
7
+ */
8
+ export declare class Meters {
9
+ private client;
10
+ constructor(client: Client<paths, `${string}/${string}`>);
11
+ /**
12
+ * Create a meter
13
+ * @param meter - The meter to create
14
+ * @param signal - An optional abort signal
15
+ * @returns The created meter
16
+ */
17
+ create(meter: MeterCreate, options?: RequestOptions): Promise<{
18
+ readonly id: string;
19
+ description?: string;
20
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
21
+ readonly createdAt: Date;
22
+ readonly updatedAt: Date;
23
+ readonly deletedAt?: Date;
24
+ name?: string;
25
+ slug: string;
26
+ aggregation: import("./schemas.js").components["schemas"]["MeterAggregation"];
27
+ eventType: string;
28
+ eventFrom?: Date;
29
+ valueProperty?: string;
30
+ groupBy?: {
31
+ [key: string]: string;
32
+ };
33
+ }>;
34
+ /**
35
+ * Get a meter by ID or slug
36
+ * @param idOrSlug - The ID or slug of the meter
37
+ * @param signal - An optional abort signal
38
+ * @returns The meter
39
+ */
40
+ get(idOrSlug: operations['getMeter']['parameters']['path']['meterIdOrSlug'], options?: RequestOptions): Promise<{
41
+ readonly id: string;
42
+ description?: string;
43
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
44
+ readonly createdAt: Date;
45
+ readonly updatedAt: Date;
46
+ readonly deletedAt?: Date;
47
+ name?: string;
48
+ slug: string;
49
+ aggregation: import("./schemas.js").components["schemas"]["MeterAggregation"];
50
+ eventType: string;
51
+ eventFrom?: Date;
52
+ valueProperty?: string;
53
+ groupBy?: {
54
+ [key: string]: string;
55
+ };
56
+ }>;
57
+ /**
58
+ * List meters
59
+ * @param signal - An optional abort signal
60
+ * @returns The meters
61
+ */
62
+ list(options?: RequestOptions): Promise<{
63
+ readonly id: string;
64
+ description?: string;
65
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
66
+ readonly createdAt: Date;
67
+ readonly updatedAt: Date;
68
+ readonly deletedAt?: Date;
69
+ name?: string;
70
+ slug: string;
71
+ aggregation: import("./schemas.js").components["schemas"]["MeterAggregation"];
72
+ eventType: string;
73
+ eventFrom?: Date;
74
+ valueProperty?: string;
75
+ groupBy?: {
76
+ [key: string]: string;
77
+ };
78
+ }[]>;
79
+ /**
80
+ * Query usage data for a meter by ID or slug
81
+ * @param idOrSlug - The ID or slug of the meter
82
+ * @param query - The query parameters
83
+ * @param signal - An optional abort signal
84
+ * @returns The meter data
85
+ */
86
+ query(idOrSlug: operations['queryMeter']['parameters']['path']['meterIdOrSlug'], query?: operations['queryMeter']['parameters']['query'], options?: RequestOptions): Promise<{
87
+ from?: Date;
88
+ to?: Date;
89
+ windowSize?: import("./schemas.js").components["schemas"]["WindowSize"];
90
+ data: import("./schemas.js").components["schemas"]["MeterQueryRow"][];
91
+ }>;
92
+ /**
93
+ * Delete a meter by ID or slug
94
+ * @param idOrSlug - The ID or slug of the meter
95
+ * @param signal - An optional abort signal
96
+ * @returns The deleted meter
97
+ */
98
+ delete(idOrSlug: operations['deleteMeter']['parameters']['path']['meterIdOrSlug'], options?: RequestOptions): Promise<undefined>;
99
+ }
@@ -0,0 +1,92 @@
1
+ import { transformResponse } from './utils.js';
2
+ /**
3
+ * Meters
4
+ * @description Meters are used to track and manage usage of your application.
5
+ */
6
+ export class Meters {
7
+ client;
8
+ constructor(client) {
9
+ this.client = client;
10
+ }
11
+ /**
12
+ * Create a meter
13
+ * @param meter - The meter to create
14
+ * @param signal - An optional abort signal
15
+ * @returns The created meter
16
+ */
17
+ async create(meter, options) {
18
+ const resp = await this.client.POST('/api/v1/meters', {
19
+ body: meter,
20
+ ...options,
21
+ });
22
+ return transformResponse(resp);
23
+ }
24
+ /**
25
+ * Get a meter by ID or slug
26
+ * @param idOrSlug - The ID or slug of the meter
27
+ * @param signal - An optional abort signal
28
+ * @returns The meter
29
+ */
30
+ async get(idOrSlug, options) {
31
+ const resp = await this.client.GET('/api/v1/meters/{meterIdOrSlug}', {
32
+ params: {
33
+ path: {
34
+ meterIdOrSlug: idOrSlug,
35
+ },
36
+ },
37
+ ...options,
38
+ });
39
+ return transformResponse(resp);
40
+ }
41
+ /**
42
+ * List meters
43
+ * @param signal - An optional abort signal
44
+ * @returns The meters
45
+ */
46
+ async list(options) {
47
+ const resp = await this.client.GET('/api/v1/meters', {
48
+ ...options,
49
+ });
50
+ return transformResponse(resp);
51
+ }
52
+ /**
53
+ * Query usage data for a meter by ID or slug
54
+ * @param idOrSlug - The ID or slug of the meter
55
+ * @param query - The query parameters
56
+ * @param signal - An optional abort signal
57
+ * @returns The meter data
58
+ */
59
+ async query(idOrSlug, query, options) {
60
+ const resp = await this.client.GET('/api/v1/meters/{meterIdOrSlug}/query', {
61
+ headers: {
62
+ Accept: 'application/json',
63
+ },
64
+ params: {
65
+ path: {
66
+ meterIdOrSlug: idOrSlug,
67
+ },
68
+ query,
69
+ },
70
+ ...options,
71
+ });
72
+ return transformResponse(resp);
73
+ }
74
+ /**
75
+ * Delete a meter by ID or slug
76
+ * @param idOrSlug - The ID or slug of the meter
77
+ * @param signal - An optional abort signal
78
+ * @returns The deleted meter
79
+ */
80
+ async delete(idOrSlug, options) {
81
+ const resp = await this.client.DELETE('/api/v1/meters/{meterIdOrSlug}', {
82
+ params: {
83
+ path: {
84
+ meterIdOrSlug: idOrSlug,
85
+ },
86
+ },
87
+ ...options,
88
+ });
89
+ return transformResponse(resp);
90
+ }
91
+ }
92
+ //# sourceMappingURL=meters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meters.js","sourceRoot":"","sources":["../../../src/client/meters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAK9C;;;GAGG;AACH,MAAM,OAAO,MAAM;IACG;IAApB,YAAoB,MAA4C;QAA5C,WAAM,GAAN,MAAM,CAAsC;IAAG,CAAC;IAEpE;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,KAAkB,EAAE,OAAwB;QAC9D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE;YACpD,IAAI,EAAE,KAAK;YACX,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAAG,CACd,QAAuE,EACvE,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gCAAgC,EAAE;YACnE,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,aAAa,EAAE,QAAQ;iBACxB;aACF;YACD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAAC,OAAwB;QACxC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE;YACnD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,KAAK,CAChB,QAAyE,EACzE,KAAuD,EACvD,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,sCAAsC,EAAE;YACzE,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;aAC3B;YACD,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,aAAa,EAAE,QAAQ;iBACxB;gBACD,KAAK;aACN;YACD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CACtB,IAAI,CAC0E,CAAA;IAClF,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CACjB,QAA0E,EAC1E,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,gCAAgC,EAAE;YACtE,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,aAAa,EAAE,QAAQ;iBACxB;aACF;YACD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;CACF"}
@@ -0,0 +1,219 @@
1
+ import type { RequestOptions } from './common.js';
2
+ import type { NotificationChannel, NotificationRuleCreateRequest, operations, paths } from './schemas.js';
3
+ import type { Client } from 'openapi-fetch';
4
+ /**
5
+ * Notifications
6
+ * @description Notifications provide automated triggers when specific entitlement balances and usage thresholds are reached, ensuring that your customers and sales teams are always informed. Notify customers and internal teams when specific conditions are met, like reaching 75%, 100%, and 150% of their monthly usage allowance.
7
+ */
8
+ export declare class Notifications {
9
+ private client;
10
+ channels: NotificationChannels;
11
+ rules: NotificationRules;
12
+ events: NotificationEvents;
13
+ constructor(client: Client<paths, `${string}/${string}`>);
14
+ }
15
+ /**
16
+ * Notification Channels
17
+ * @description Notification channels are the destinations for notifications.
18
+ */
19
+ export declare class NotificationChannels {
20
+ private client;
21
+ constructor(client: Client<paths, `${string}/${string}`>);
22
+ /**
23
+ * Create a notification channel
24
+ * @param notification - The notification to create
25
+ * @param signal - An optional abort signal
26
+ * @returns The created notification
27
+ */
28
+ create(notification: NotificationChannel, options?: RequestOptions): Promise<{
29
+ readonly createdAt: Date;
30
+ readonly updatedAt: Date;
31
+ readonly deletedAt?: Date;
32
+ readonly id: string;
33
+ type: "WEBHOOK";
34
+ name: string;
35
+ disabled?: boolean;
36
+ url: string;
37
+ customHeaders?: {
38
+ [key: string]: string;
39
+ };
40
+ signingSecret?: string;
41
+ }>;
42
+ /**
43
+ * Get a notification channel by ID
44
+ * @param id - The ID of the notification channel
45
+ * @param signal - An optional abort signal
46
+ * @returns The notification channel
47
+ */
48
+ get(id: operations['getNotificationChannel']['parameters']['path']['channelId'], options?: RequestOptions): Promise<{
49
+ readonly createdAt: Date;
50
+ readonly updatedAt: Date;
51
+ readonly deletedAt?: Date;
52
+ readonly id: string;
53
+ type: "WEBHOOK";
54
+ name: string;
55
+ disabled?: boolean;
56
+ url: string;
57
+ customHeaders?: {
58
+ [key: string]: string;
59
+ };
60
+ signingSecret?: string;
61
+ }>;
62
+ /**
63
+ * Update a notification channel
64
+ * @param id - The ID of the notification channel
65
+ * @param notification - The notification to update
66
+ * @param signal - An optional abort signal
67
+ * @returns The updated notification
68
+ */
69
+ update(id: operations['updateNotificationChannel']['parameters']['path']['channelId'], notification: NotificationChannel, options?: RequestOptions): Promise<{
70
+ readonly createdAt: Date;
71
+ readonly updatedAt: Date;
72
+ readonly deletedAt?: Date;
73
+ readonly id: string;
74
+ type: "WEBHOOK";
75
+ name: string;
76
+ disabled?: boolean;
77
+ url: string;
78
+ customHeaders?: {
79
+ [key: string]: string;
80
+ };
81
+ signingSecret?: string;
82
+ }>;
83
+ /**
84
+ * List notification channels
85
+ * @param query - The query parameters
86
+ * @param signal - An optional abort signal
87
+ * @returns The list of notification channels
88
+ */
89
+ list(query?: operations['listNotificationChannels']['parameters']['query'], options?: RequestOptions): Promise<{
90
+ totalCount: number;
91
+ page: number;
92
+ pageSize: number;
93
+ items: import("./schemas.js").components["schemas"]["NotificationChannel"][];
94
+ }>;
95
+ /**
96
+ * Delete a notification channel
97
+ * @param id - The ID of the notification channel
98
+ * @param signal - An optional abort signal
99
+ * @returns The deleted notification
100
+ */
101
+ delete(id: operations['deleteNotificationChannel']['parameters']['path']['channelId'], options?: RequestOptions): Promise<undefined>;
102
+ }
103
+ /**
104
+ * Notification Rules
105
+ * @description Notification rules are the conditions that trigger notifications.
106
+ */
107
+ export declare class NotificationRules {
108
+ private client;
109
+ constructor(client: Client<paths, `${string}/${string}`>);
110
+ /**
111
+ * Create a notification rule
112
+ * @param rule - The rule to create
113
+ * @param signal - An optional abort signal
114
+ * @returns The created rule
115
+ */
116
+ create(rule: NotificationRuleCreateRequest, options?: RequestOptions): Promise<{
117
+ readonly createdAt: Date;
118
+ readonly updatedAt: Date;
119
+ readonly deletedAt?: Date;
120
+ readonly id: string;
121
+ type: "entitlements.balance.threshold";
122
+ name: string;
123
+ disabled?: boolean;
124
+ channels: import("./schemas.js").components["schemas"]["NotificationChannelMeta"][];
125
+ thresholds: import("./schemas.js").components["schemas"]["NotificationRuleBalanceThresholdValue"][];
126
+ features?: import("./schemas.js").components["schemas"]["FeatureMeta"][];
127
+ }>;
128
+ /**
129
+ * Get a notification rule by ID
130
+ * @param id - The ID of the notification rule
131
+ * @param signal - An optional abort signal
132
+ * @returns The notification rule
133
+ */
134
+ get(id: operations['getNotificationRule']['parameters']['path']['ruleId'], options?: RequestOptions): Promise<{
135
+ readonly createdAt: Date;
136
+ readonly updatedAt: Date;
137
+ readonly deletedAt?: Date;
138
+ readonly id: string;
139
+ type: "entitlements.balance.threshold";
140
+ name: string;
141
+ disabled?: boolean;
142
+ channels: import("./schemas.js").components["schemas"]["NotificationChannelMeta"][];
143
+ thresholds: import("./schemas.js").components["schemas"]["NotificationRuleBalanceThresholdValue"][];
144
+ features?: import("./schemas.js").components["schemas"]["FeatureMeta"][];
145
+ }>;
146
+ /**
147
+ * Update a notification rule
148
+ * @param id - The ID of the notification rule
149
+ * @param rule - The rule to update
150
+ * @param signal - An optional abort signal
151
+ * @returns The updated rule
152
+ */
153
+ update(id: operations['updateNotificationRule']['parameters']['path']['ruleId'], rule: NotificationRuleCreateRequest, options?: RequestOptions): Promise<{
154
+ readonly createdAt: Date;
155
+ readonly updatedAt: Date;
156
+ readonly deletedAt?: Date;
157
+ readonly id: string;
158
+ type: "entitlements.balance.threshold";
159
+ name: string;
160
+ disabled?: boolean;
161
+ channels: import("./schemas.js").components["schemas"]["NotificationChannelMeta"][];
162
+ thresholds: import("./schemas.js").components["schemas"]["NotificationRuleBalanceThresholdValue"][];
163
+ features?: import("./schemas.js").components["schemas"]["FeatureMeta"][];
164
+ }>;
165
+ /**
166
+ * List notification rules
167
+ * @param query - The query parameters
168
+ * @param signal - An optional abort signal
169
+ * @returns The list of notification rules
170
+ */
171
+ list(query?: operations['listNotificationRules']['parameters']['query'], options?: RequestOptions): Promise<{
172
+ totalCount: number;
173
+ page: number;
174
+ pageSize: number;
175
+ items: import("./schemas.js").components["schemas"]["NotificationRule"][];
176
+ }>;
177
+ /**
178
+ * Delete a notification rule
179
+ * @param id - The ID of the notification rule
180
+ * @param signal - An optional abort signal
181
+ * @returns The deleted notification
182
+ */
183
+ delete(id: operations['deleteNotificationRule']['parameters']['path']['ruleId'], options?: RequestOptions): Promise<undefined>;
184
+ }
185
+ /**
186
+ * Notification Events
187
+ * @description Notification events are the events that trigger notifications.
188
+ */
189
+ export declare class NotificationEvents {
190
+ private client;
191
+ constructor(client: Client<paths, `${string}/${string}`>);
192
+ /**
193
+ * Get a notification event by ID
194
+ * @param id - The ID of the notification event
195
+ * @param signal - An optional abort signal
196
+ * @returns The notification event
197
+ */
198
+ get(id: operations['getNotificationEvent']['parameters']['path']['eventId'], options?: RequestOptions): Promise<{
199
+ readonly id: string;
200
+ readonly type: import("./schemas.js").components["schemas"]["NotificationEventType"];
201
+ readonly createdAt: Date;
202
+ readonly rule: import("./schemas.js").components["schemas"]["NotificationRule"];
203
+ readonly deliveryStatus: import("./schemas.js").components["schemas"]["NotificationEventDeliveryStatus"][];
204
+ readonly payload: import("./schemas.js").components["schemas"]["NotificationEventPayload"];
205
+ readonly annotations?: import("./schemas.js").components["schemas"]["Annotations"];
206
+ }>;
207
+ /**
208
+ * List notification events
209
+ * @param query - The query parameters
210
+ * @param signal - An optional abort signal
211
+ * @returns The list of notification events
212
+ */
213
+ list(query?: operations['listNotificationEvents']['parameters']['query'], options?: RequestOptions): Promise<{
214
+ totalCount: number;
215
+ page: number;
216
+ pageSize: number;
217
+ items: import("./schemas.js").components["schemas"]["NotificationEvent"][];
218
+ }>;
219
+ }
@@ -0,0 +1,242 @@
1
+ import { transformResponse } from './utils.js';
2
+ /**
3
+ * Notifications
4
+ * @description Notifications provide automated triggers when specific entitlement balances and usage thresholds are reached, ensuring that your customers and sales teams are always informed. Notify customers and internal teams when specific conditions are met, like reaching 75%, 100%, and 150% of their monthly usage allowance.
5
+ */
6
+ export class Notifications {
7
+ client;
8
+ channels;
9
+ rules;
10
+ events;
11
+ constructor(client) {
12
+ this.client = client;
13
+ this.channels = new NotificationChannels(this.client);
14
+ this.rules = new NotificationRules(this.client);
15
+ this.events = new NotificationEvents(this.client);
16
+ }
17
+ }
18
+ /**
19
+ * Notification Channels
20
+ * @description Notification channels are the destinations for notifications.
21
+ */
22
+ export class NotificationChannels {
23
+ client;
24
+ constructor(client) {
25
+ this.client = client;
26
+ }
27
+ /**
28
+ * Create a notification channel
29
+ * @param notification - The notification to create
30
+ * @param signal - An optional abort signal
31
+ * @returns The created notification
32
+ */
33
+ async create(notification, options) {
34
+ const resp = await this.client.POST('/api/v1/notification/channels', {
35
+ body: notification,
36
+ ...options,
37
+ });
38
+ return transformResponse(resp);
39
+ }
40
+ /**
41
+ * Get a notification channel by ID
42
+ * @param id - The ID of the notification channel
43
+ * @param signal - An optional abort signal
44
+ * @returns The notification channel
45
+ */
46
+ async get(id, options) {
47
+ const resp = await this.client.GET('/api/v1/notification/channels/{channelId}', {
48
+ params: {
49
+ path: {
50
+ channelId: id,
51
+ },
52
+ },
53
+ ...options,
54
+ });
55
+ return transformResponse(resp);
56
+ }
57
+ /**
58
+ * Update a notification channel
59
+ * @param id - The ID of the notification channel
60
+ * @param notification - The notification to update
61
+ * @param signal - An optional abort signal
62
+ * @returns The updated notification
63
+ */
64
+ async update(id, notification, options) {
65
+ const resp = await this.client.PUT('/api/v1/notification/channels/{channelId}', {
66
+ body: notification,
67
+ params: {
68
+ path: {
69
+ channelId: id,
70
+ },
71
+ },
72
+ ...options,
73
+ });
74
+ return transformResponse(resp);
75
+ }
76
+ /**
77
+ * List notification channels
78
+ * @param query - The query parameters
79
+ * @param signal - An optional abort signal
80
+ * @returns The list of notification channels
81
+ */
82
+ async list(query, options) {
83
+ const resp = await this.client.GET('/api/v1/notification/channels', {
84
+ params: {
85
+ query,
86
+ },
87
+ ...options,
88
+ });
89
+ return transformResponse(resp);
90
+ }
91
+ /**
92
+ * Delete a notification channel
93
+ * @param id - The ID of the notification channel
94
+ * @param signal - An optional abort signal
95
+ * @returns The deleted notification
96
+ */
97
+ async delete(id, options) {
98
+ const resp = await this.client.DELETE('/api/v1/notification/channels/{channelId}', {
99
+ params: {
100
+ path: {
101
+ channelId: id,
102
+ },
103
+ },
104
+ ...options,
105
+ });
106
+ return transformResponse(resp);
107
+ }
108
+ }
109
+ /**
110
+ * Notification Rules
111
+ * @description Notification rules are the conditions that trigger notifications.
112
+ */
113
+ export class NotificationRules {
114
+ client;
115
+ constructor(client) {
116
+ this.client = client;
117
+ }
118
+ /**
119
+ * Create a notification rule
120
+ * @param rule - The rule to create
121
+ * @param signal - An optional abort signal
122
+ * @returns The created rule
123
+ */
124
+ async create(rule, options) {
125
+ const resp = await this.client.POST('/api/v1/notification/rules', {
126
+ body: rule,
127
+ ...options,
128
+ });
129
+ return transformResponse(resp);
130
+ }
131
+ /**
132
+ * Get a notification rule by ID
133
+ * @param id - The ID of the notification rule
134
+ * @param signal - An optional abort signal
135
+ * @returns The notification rule
136
+ */
137
+ async get(id, options) {
138
+ const resp = await this.client.GET('/api/v1/notification/rules/{ruleId}', {
139
+ params: {
140
+ path: {
141
+ ruleId: id,
142
+ },
143
+ },
144
+ ...options,
145
+ });
146
+ return transformResponse(resp);
147
+ }
148
+ /**
149
+ * Update a notification rule
150
+ * @param id - The ID of the notification rule
151
+ * @param rule - The rule to update
152
+ * @param signal - An optional abort signal
153
+ * @returns The updated rule
154
+ */
155
+ async update(id, rule, options) {
156
+ const resp = await this.client.PUT('/api/v1/notification/rules/{ruleId}', {
157
+ body: rule,
158
+ params: {
159
+ path: {
160
+ ruleId: id,
161
+ },
162
+ },
163
+ ...options,
164
+ });
165
+ return transformResponse(resp);
166
+ }
167
+ /**
168
+ * List notification rules
169
+ * @param query - The query parameters
170
+ * @param signal - An optional abort signal
171
+ * @returns The list of notification rules
172
+ */
173
+ async list(query, options) {
174
+ const resp = await this.client.GET('/api/v1/notification/rules', {
175
+ params: {
176
+ query,
177
+ },
178
+ ...options,
179
+ });
180
+ return transformResponse(resp);
181
+ }
182
+ /**
183
+ * Delete a notification rule
184
+ * @param id - The ID of the notification rule
185
+ * @param signal - An optional abort signal
186
+ * @returns The deleted notification
187
+ */
188
+ async delete(id, options) {
189
+ const resp = await this.client.DELETE('/api/v1/notification/rules/{ruleId}', {
190
+ params: {
191
+ path: {
192
+ ruleId: id,
193
+ },
194
+ },
195
+ ...options,
196
+ });
197
+ return transformResponse(resp);
198
+ }
199
+ }
200
+ /**
201
+ * Notification Events
202
+ * @description Notification events are the events that trigger notifications.
203
+ */
204
+ export class NotificationEvents {
205
+ client;
206
+ constructor(client) {
207
+ this.client = client;
208
+ }
209
+ /**
210
+ * Get a notification event by ID
211
+ * @param id - The ID of the notification event
212
+ * @param signal - An optional abort signal
213
+ * @returns The notification event
214
+ */
215
+ async get(id, options) {
216
+ const resp = await this.client.GET('/api/v1/notification/events/{eventId}', {
217
+ params: {
218
+ path: {
219
+ eventId: id,
220
+ },
221
+ },
222
+ ...options,
223
+ });
224
+ return transformResponse(resp);
225
+ }
226
+ /**
227
+ * List notification events
228
+ * @param query - The query parameters
229
+ * @param signal - An optional abort signal
230
+ * @returns The list of notification events
231
+ */
232
+ async list(query, options) {
233
+ const resp = await this.client.GET('/api/v1/notification/events', {
234
+ params: {
235
+ query,
236
+ },
237
+ ...options,
238
+ });
239
+ return transformResponse(resp);
240
+ }
241
+ }
242
+ //# sourceMappingURL=notifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/client/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAU9C;;;GAGG;AACH,MAAM,OAAO,aAAa;IAKJ;IAJb,QAAQ,CAAsB;IAC9B,KAAK,CAAmB;IACxB,MAAM,CAAoB;IAEjC,YAAoB,MAA4C;QAA5C,WAAM,GAAN,MAAM,CAAsC;QAC9D,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACrD,IAAI,CAAC,KAAK,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACnD,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IACX;IAApB,YAAoB,MAA4C;QAA5C,WAAM,GAAN,MAAM,CAAsC;IAAG,CAAC;IAEpE;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CACjB,YAAiC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