@openmeter/sdk 1.0.0-beta.21 → 1.0.0-beta.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -150
- package/dist/cjs/index.cjs +18 -0
- package/dist/cjs/index.d.cts +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/src/client/apps.cjs +174 -0
- package/dist/cjs/src/client/apps.d.cts +286 -0
- package/dist/cjs/src/client/apps.js.map +1 -0
- package/dist/cjs/src/client/billing.cjs +309 -0
- package/dist/cjs/src/client/billing.d.cts +502 -0
- package/dist/cjs/src/client/billing.js.map +1 -0
- package/dist/cjs/src/client/common.cjs +47 -0
- package/dist/cjs/src/client/common.d.cts +30 -0
- package/dist/cjs/src/client/common.js.map +1 -0
- package/dist/cjs/src/client/customers.cjs +199 -0
- package/dist/cjs/src/client/customers.d.cts +179 -0
- package/dist/cjs/src/client/customers.js.map +1 -0
- package/dist/cjs/src/client/entitlements.cjs +244 -0
- package/dist/cjs/src/client/entitlements.d.cts +472 -0
- package/dist/cjs/src/client/entitlements.js.map +1 -0
- package/dist/cjs/src/client/events.cjs +66 -0
- package/dist/cjs/src/client/events.d.cts +31 -0
- package/dist/cjs/src/client/events.js.map +1 -0
- package/dist/cjs/src/client/features.cjs +78 -0
- package/dist/cjs/src/client/features.d.cts +78 -0
- package/dist/cjs/src/client/features.js.map +1 -0
- package/dist/cjs/src/client/index.cjs +108 -0
- package/dist/cjs/src/client/index.d.cts +45 -0
- package/dist/cjs/src/client/index.js.map +1 -0
- package/dist/cjs/src/client/meters.cjs +96 -0
- package/dist/cjs/src/client/meters.d.cts +99 -0
- package/dist/cjs/src/client/meters.js.map +1 -0
- package/dist/cjs/src/client/notifications.cjs +249 -0
- package/dist/cjs/src/client/notifications.d.cts +219 -0
- package/dist/cjs/src/client/notifications.js.map +1 -0
- package/dist/cjs/src/client/plans.cjs +127 -0
- package/dist/cjs/src/client/plans.d.cts +142 -0
- package/dist/cjs/src/client/plans.js.map +1 -0
- package/dist/cjs/src/client/portal.cjs +55 -0
- package/dist/cjs/src/client/portal.d.cts +48 -0
- package/dist/cjs/src/client/portal.js.map +1 -0
- package/dist/cjs/src/client/schemas.cjs +3 -0
- package/dist/cjs/src/client/schemas.d.cts +22438 -0
- package/dist/cjs/src/client/schemas.js.map +1 -0
- package/dist/cjs/src/client/subjects.cjs +76 -0
- package/dist/cjs/src/client/subjects.d.cts +70 -0
- package/dist/cjs/src/client/subjects.js.map +1 -0
- package/dist/cjs/src/client/subscriptions.cjs +116 -0
- package/dist/cjs/src/client/subscriptions.d.cts +147 -0
- package/dist/cjs/src/client/subscriptions.js.map +1 -0
- package/dist/cjs/src/client/utils.cjs +69 -0
- package/dist/cjs/src/client/utils.d.cts +12 -0
- package/dist/cjs/src/client/utils.js.map +1 -0
- package/dist/cjs/src/portal/index.cjs +60 -0
- package/dist/cjs/src/portal/index.d.cts +43 -0
- package/dist/cjs/src/portal/index.js.map +1 -0
- package/dist/cjs/src/react/context.cjs +35 -0
- package/dist/cjs/src/react/context.d.cts +9 -0
- package/dist/cjs/src/react/context.js.map +1 -0
- package/dist/cjs/tsconfig.341d9ef4.tsbuildinfo +1 -0
- package/dist/cjs/tsconfig.523d9ac8.tsbuildinfo +1 -0
- package/dist/index.d.ts +1 -14
- package/dist/index.js +2 -15
- package/dist/index.js.map +1 -0
- package/dist/src/client/apps.d.ts +286 -0
- package/dist/src/client/apps.js +168 -0
- package/dist/src/client/apps.js.map +1 -0
- package/dist/src/client/billing.d.ts +502 -0
- package/dist/src/client/billing.js +302 -0
- package/dist/src/client/billing.js.map +1 -0
- package/dist/src/client/common.d.ts +30 -0
- package/dist/src/client/common.js +42 -0
- package/dist/src/client/common.js.map +1 -0
- package/dist/src/client/customers.d.ts +179 -0
- package/dist/src/client/customers.js +193 -0
- package/dist/src/client/customers.js.map +1 -0
- package/dist/src/client/entitlements.d.ts +472 -0
- package/dist/src/client/entitlements.js +239 -0
- package/dist/src/client/entitlements.js.map +1 -0
- package/dist/src/client/events.d.ts +31 -0
- package/dist/src/client/events.js +58 -0
- package/dist/src/client/events.js.map +1 -0
- package/dist/src/client/features.d.ts +78 -0
- package/dist/src/client/features.js +74 -0
- package/dist/src/client/features.js.map +1 -0
- package/dist/src/client/index.d.ts +45 -0
- package/dist/src/client/index.js +68 -0
- package/dist/src/client/index.js.map +1 -0
- package/dist/src/client/meters.d.ts +99 -0
- package/dist/src/client/meters.js +92 -0
- package/dist/src/client/meters.js.map +1 -0
- package/dist/src/client/notifications.d.ts +219 -0
- package/dist/src/client/notifications.js +242 -0
- package/dist/src/client/notifications.js.map +1 -0
- package/dist/src/client/plans.d.ts +142 -0
- package/dist/src/client/plans.js +123 -0
- package/dist/src/client/plans.js.map +1 -0
- package/dist/src/client/portal.d.ts +48 -0
- package/dist/src/client/portal.js +51 -0
- package/dist/src/client/portal.js.map +1 -0
- package/dist/src/client/schemas.d.ts +22438 -0
- package/dist/src/client/schemas.js +2 -0
- package/dist/src/client/schemas.js.map +1 -0
- package/dist/src/client/subjects.d.ts +70 -0
- package/dist/src/client/subjects.js +72 -0
- package/dist/src/client/subjects.js.map +1 -0
- package/dist/src/client/subscriptions.d.ts +147 -0
- package/dist/src/client/subscriptions.js +112 -0
- package/dist/src/client/subscriptions.js.map +1 -0
- package/dist/src/client/utils.d.ts +12 -0
- package/dist/src/client/utils.js +63 -0
- package/dist/src/client/utils.js.map +1 -0
- package/dist/src/portal/index.d.ts +43 -0
- package/dist/src/portal/index.js +53 -0
- package/dist/src/portal/index.js.map +1 -0
- package/dist/src/react/context.d.ts +9 -0
- package/dist/src/react/context.js +16 -0
- package/dist/src/react/context.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +75 -35
- package/patches/openapi-typescript.patch +73 -0
- package/dist/clients/client.d.ts +0 -40
- package/dist/clients/client.js +0 -104
- package/dist/clients/event.d.ts +0 -79
- package/dist/clients/event.js +0 -53
- package/dist/clients/meter.d.ts +0 -96
- package/dist/clients/meter.js +0 -64
- package/dist/clients/portal.d.ts +0 -23
- package/dist/clients/portal.js +0 -37
- package/dist/next.d.ts +0 -15
- package/dist/next.js +0 -46
- package/dist/schemas/openapi.d.ts +0 -460
- package/dist/schemas/openapi.js +0 -5
- package/dist/test/agent.d.ts +0 -2
- package/dist/test/agent.js +0 -178
- package/dist/test/mocks.d.ts +0 -12
- package/dist/test/mocks.js +0 -32
- package/index.ts +0 -22
- package/next.ts +0 -76
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { transformResponse } from './utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Entitlements
|
|
4
|
+
* @description With Entitlements, you can define and enforce usage limits, implement quota-based pricing, and manage access to features in your application.
|
|
5
|
+
*/
|
|
6
|
+
export class Entitlements {
|
|
7
|
+
client;
|
|
8
|
+
grants;
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
this.grants = new Grants(client);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create an entitlement
|
|
15
|
+
*
|
|
16
|
+
* - Boolean entitlements define static feature access, e.g. "Can use SSO authentication".
|
|
17
|
+
* - Static entitlements let you pass along a configuration while granting access, e.g. "Using this feature with X Y settings" (passed in the config).
|
|
18
|
+
* - Metered entitlements have many use cases, from setting up usage-based access to implementing complex credit systems. Example: The customer can use 10000 AI tokens during the usage period of the entitlement.
|
|
19
|
+
*
|
|
20
|
+
* A given subject can only have one active (non-deleted) entitlement per featureKey. If you try to create a new entitlement for a featureKey that already has an active entitlement, the request will fail with a 409 error.
|
|
21
|
+
*
|
|
22
|
+
* Once an entitlement is created you cannot modify it, only delete it.
|
|
23
|
+
*
|
|
24
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
25
|
+
* @param entitlement - The entitlement to create
|
|
26
|
+
* @param signal - An optional abort signal
|
|
27
|
+
* @returns The created entitlement
|
|
28
|
+
*/
|
|
29
|
+
async create(subjectIdOrKey, entitlement, options) {
|
|
30
|
+
const resp = await this.client.POST('/api/v1/subjects/{subjectIdOrKey}/entitlements', {
|
|
31
|
+
body: entitlement,
|
|
32
|
+
params: {
|
|
33
|
+
path: {
|
|
34
|
+
subjectIdOrKey: subjectIdOrKey,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
...options,
|
|
38
|
+
});
|
|
39
|
+
return transformResponse(resp);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get an entitlement by ID
|
|
43
|
+
*
|
|
44
|
+
* @param id - The ID of the entitlement
|
|
45
|
+
* @param signal - An optional abort signal
|
|
46
|
+
* @returns The entitlement
|
|
47
|
+
*/
|
|
48
|
+
async get(id, options) {
|
|
49
|
+
const resp = await this.client.GET('/api/v1/entitlements/{entitlementId}', {
|
|
50
|
+
params: {
|
|
51
|
+
path: {
|
|
52
|
+
entitlementId: id,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
...options,
|
|
56
|
+
});
|
|
57
|
+
return transformResponse(resp);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* List entitlements
|
|
61
|
+
*
|
|
62
|
+
* @param query - The query parameters
|
|
63
|
+
* @param signal - An optional abort signal
|
|
64
|
+
* @returns The entitlements
|
|
65
|
+
*/
|
|
66
|
+
async list(query, options) {
|
|
67
|
+
const resp = await this.client.GET('/api/v1/entitlements', {
|
|
68
|
+
params: {
|
|
69
|
+
query,
|
|
70
|
+
},
|
|
71
|
+
...options,
|
|
72
|
+
});
|
|
73
|
+
return transformResponse(resp);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Delete an entitlement
|
|
77
|
+
*
|
|
78
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
79
|
+
* @param entitlementId - The ID of the entitlement
|
|
80
|
+
* @param signal - An optional abort signal
|
|
81
|
+
* @returns The deleted entitlement
|
|
82
|
+
*/
|
|
83
|
+
async delete(subjectIdOrKey, entitlementId, options) {
|
|
84
|
+
const resp = await this.client.DELETE('/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}', {
|
|
85
|
+
params: {
|
|
86
|
+
path: {
|
|
87
|
+
entitlementId,
|
|
88
|
+
subjectIdOrKey,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
...options,
|
|
92
|
+
});
|
|
93
|
+
return transformResponse(resp);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get the value of an entitlement to check access
|
|
97
|
+
* All entitlement types share the hasAccess property in their value response, but multiple other properties are returned based on the entitlement type.
|
|
98
|
+
*
|
|
99
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
100
|
+
* @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
|
|
101
|
+
* @param query - The query parameters
|
|
102
|
+
* @param signal - An optional abort signal
|
|
103
|
+
* @returns The entitlement value
|
|
104
|
+
*/
|
|
105
|
+
async value(subjectIdOrKey, entitlementIdOrFeatureKey, query, options) {
|
|
106
|
+
const resp = await this.client.GET('/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/value', {
|
|
107
|
+
params: {
|
|
108
|
+
path: {
|
|
109
|
+
entitlementIdOrFeatureKey,
|
|
110
|
+
subjectIdOrKey,
|
|
111
|
+
},
|
|
112
|
+
query,
|
|
113
|
+
},
|
|
114
|
+
...options,
|
|
115
|
+
});
|
|
116
|
+
return transformResponse(resp);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get the history of an entitlement
|
|
120
|
+
* Returns historical balance and usage data for the entitlement. The queried history can span accross multiple reset events.
|
|
121
|
+
*
|
|
122
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
123
|
+
* @param entitlementId - The ID of the entitlement
|
|
124
|
+
* @param query - The query parameters
|
|
125
|
+
* @param signal - An optional abort signal
|
|
126
|
+
* @returns The history of the entitlement
|
|
127
|
+
*/
|
|
128
|
+
async history(subjectIdOrKey, entitlementId, query, options) {
|
|
129
|
+
const resp = await this.client.GET('/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}/history', {
|
|
130
|
+
params: {
|
|
131
|
+
path: {
|
|
132
|
+
entitlementId,
|
|
133
|
+
subjectIdOrKey,
|
|
134
|
+
},
|
|
135
|
+
query,
|
|
136
|
+
},
|
|
137
|
+
...options,
|
|
138
|
+
});
|
|
139
|
+
return transformResponse(resp);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Override an entitlement
|
|
143
|
+
* This is useful for upgrades, downgrades, or other changes to entitlements that require a new entitlement to be created with zero downtime.
|
|
144
|
+
*
|
|
145
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
146
|
+
* @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
|
|
147
|
+
* @param override - The override to create
|
|
148
|
+
* @param signal - An optional abort signal
|
|
149
|
+
* @returns The overridden entitlement
|
|
150
|
+
*/
|
|
151
|
+
async override(subjectIdOrKey, entitlementIdOrFeatureKey, override, options) {
|
|
152
|
+
const resp = await this.client.PUT('/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/override', {
|
|
153
|
+
body: override,
|
|
154
|
+
params: {
|
|
155
|
+
path: {
|
|
156
|
+
entitlementIdOrFeatureKey,
|
|
157
|
+
subjectIdOrKey,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
...options,
|
|
161
|
+
});
|
|
162
|
+
return transformResponse(resp);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Reset entitlement usage
|
|
166
|
+
* - Reset marks the start of a new usage period for the entitlement and initiates grant rollover. At the start of a period usage is zerod out and grants are rolled over based on their rollover settings. It would typically be synced with the subjects billing period to enforce usage based on their subscription.
|
|
167
|
+
* - Usage is automatically reset for metered entitlements based on their usage period, but this endpoint allows to manually reset it at any time. When doing so the period anchor of the entitlement can be changed if needed.
|
|
168
|
+
*
|
|
169
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
170
|
+
* @param entitlementId - The ID of the entitlement
|
|
171
|
+
* @param body - The body of the request
|
|
172
|
+
* @param signal - An optional abort signal
|
|
173
|
+
* @returns The reset entitlement
|
|
174
|
+
*/
|
|
175
|
+
async reset(subjectIdOrKey, entitlementId, body, options) {
|
|
176
|
+
const resp = await this.client.POST('/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}/reset', {
|
|
177
|
+
body,
|
|
178
|
+
params: {
|
|
179
|
+
path: {
|
|
180
|
+
entitlementId,
|
|
181
|
+
subjectIdOrKey,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
...options,
|
|
185
|
+
});
|
|
186
|
+
return transformResponse(resp);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
export class Grants {
|
|
190
|
+
client;
|
|
191
|
+
constructor(client) {
|
|
192
|
+
this.client = client;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
/**
|
|
196
|
+
* Grant usage to a subject for an entitlement
|
|
197
|
+
*
|
|
198
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
199
|
+
* @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
|
|
200
|
+
* @param grant - The grant to create
|
|
201
|
+
* @param signal - An optional abort signal
|
|
202
|
+
* @returns The created grant
|
|
203
|
+
*/
|
|
204
|
+
async create(subjectIdOrKey, entitlementIdOrFeatureKey, grant, options) {
|
|
205
|
+
const resp = await this.client.POST('/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/grants', {
|
|
206
|
+
body: grant,
|
|
207
|
+
params: {
|
|
208
|
+
path: {
|
|
209
|
+
entitlementIdOrFeatureKey,
|
|
210
|
+
subjectIdOrKey,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
...options,
|
|
214
|
+
});
|
|
215
|
+
return transformResponse(resp);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* List grants for an entitlement
|
|
219
|
+
*
|
|
220
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
221
|
+
* @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
|
|
222
|
+
* @param signal - An optional abort signal
|
|
223
|
+
* @returns The grants
|
|
224
|
+
*/
|
|
225
|
+
async list(subjectIdOrKey, entitlementIdOrFeatureKey, query, options) {
|
|
226
|
+
const resp = await this.client.GET('/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/grants', {
|
|
227
|
+
params: {
|
|
228
|
+
path: {
|
|
229
|
+
entitlementIdOrFeatureKey,
|
|
230
|
+
subjectIdOrKey,
|
|
231
|
+
},
|
|
232
|
+
query,
|
|
233
|
+
},
|
|
234
|
+
...options,
|
|
235
|
+
});
|
|
236
|
+
return transformResponse(resp);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=entitlements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.js","sourceRoot":"","sources":["../../../src/client/entitlements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAY9C;;;GAGG;AACH,MAAM,OAAO,YAAY;IAGH;IAFb,MAAM,CAAQ;IAErB,YAAoB,MAA4C;QAA5C,WAAM,GAAN,MAAM,CAAsC;QAC9D,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,MAAM,CACjB,cAAuF,EACvF,WAAoC,EACpC,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACjC,gDAAgD,EAChD;YACE,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,cAAc,EAAE,cAAc;iBAC/B;aACF;YACD,GAAG,OAAO;SACX,CACF,CAAA;QAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,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AAkC,EAClC,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACjC,mFAAmF,EACnF;YACE,IAAI,EAAE,KAAK;YACX,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,yBAAyB;oBACzB,cAAc;iBACf;aACF;YACD,GAAG,OAAO;SACX,CACF,CAAA;QAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,IAAI,CACf,cAA2F,EAC3F,yBAAiH,EACjH,KAAkE,EAClE,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAChC,mFAAmF,EACnF;YACE,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,yBAAyB;oBACzB,cAAc;iBACf;gBACD,KAAK;aACN;YACD,GAAG,OAAO;SACX,CACF,CAAA;QAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RequestOptions } from './common.js';
|
|
2
|
+
import type { operations, paths, Event } from './schemas.js';
|
|
3
|
+
import type { Client } from 'openapi-fetch';
|
|
4
|
+
/**
|
|
5
|
+
* Events are used to track usage of your product or service.
|
|
6
|
+
* Events are processed asynchronously by the meters, so they may not be immediately available for querying.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Events {
|
|
9
|
+
private client;
|
|
10
|
+
constructor(client: Client<paths, `${string}/${string}`>);
|
|
11
|
+
/**
|
|
12
|
+
* Ingests an event or batch of events
|
|
13
|
+
* @param events - The events to ingest
|
|
14
|
+
* @param signal - An optional abort signal
|
|
15
|
+
* @returns The ingested events
|
|
16
|
+
*/
|
|
17
|
+
ingest(events: Event | Event[], options?: RequestOptions): Promise<undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* List ingested events
|
|
20
|
+
* @param query - The query parameters
|
|
21
|
+
* @param signal - An optional abort signal
|
|
22
|
+
* @returns The events
|
|
23
|
+
*/
|
|
24
|
+
list(query?: operations['listEvents']['parameters']['query'], options?: RequestOptions): Promise<{
|
|
25
|
+
event: import("./schemas.js").components["schemas"]["Event"];
|
|
26
|
+
validationError?: string;
|
|
27
|
+
ingestedAt: Date;
|
|
28
|
+
storedAt: Date;
|
|
29
|
+
}[]>;
|
|
30
|
+
}
|
|
31
|
+
export declare function setDefaultsForEvent(ev: Event): Event;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
import { transformResponse } from './utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Events are used to track usage of your product or service.
|
|
5
|
+
* Events are processed asynchronously by the meters, so they may not be immediately available for querying.
|
|
6
|
+
*/
|
|
7
|
+
export class Events {
|
|
8
|
+
client;
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Ingests an event or batch of events
|
|
14
|
+
* @param events - The events to ingest
|
|
15
|
+
* @param signal - An optional abort signal
|
|
16
|
+
* @returns The ingested events
|
|
17
|
+
*/
|
|
18
|
+
async ingest(events, options) {
|
|
19
|
+
const body = (Array.isArray(events) ? events : [events]).map(setDefaultsForEvent);
|
|
20
|
+
const resp = await this.client.POST('/api/v1/events', {
|
|
21
|
+
body,
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/cloudevents-batch+json',
|
|
24
|
+
},
|
|
25
|
+
...options,
|
|
26
|
+
});
|
|
27
|
+
return transformResponse(resp);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* List ingested events
|
|
31
|
+
* @param query - The query parameters
|
|
32
|
+
* @param signal - An optional abort signal
|
|
33
|
+
* @returns The events
|
|
34
|
+
*/
|
|
35
|
+
async list(query, options) {
|
|
36
|
+
const resp = await this.client.GET('/api/v1/events', {
|
|
37
|
+
params: {
|
|
38
|
+
query,
|
|
39
|
+
},
|
|
40
|
+
...options,
|
|
41
|
+
});
|
|
42
|
+
return transformResponse(resp);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function setDefaultsForEvent(ev) {
|
|
46
|
+
return {
|
|
47
|
+
data: ev.data,
|
|
48
|
+
datacontenttype: ev.datacontenttype,
|
|
49
|
+
dataschema: ev.dataschema,
|
|
50
|
+
id: ev.id ?? crypto.randomUUID(),
|
|
51
|
+
source: ev.source ?? '@openmeter/sdk',
|
|
52
|
+
specversion: ev.specversion ?? '1.0',
|
|
53
|
+
subject: ev.subject,
|
|
54
|
+
time: ev.time,
|
|
55
|
+
type: ev.type,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/client/events.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,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,MAAuB,EAAE,OAAwB;QACnE,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAC1D,mBAAmB,CACpB,CAAA;QAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE;YACpD,IAAI;YACJ,OAAO,EAAE;gBACP,cAAc,EAAE,oCAAoC;aACrD;YACD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CACf,KAAuD,EACvD,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE;YACnD,MAAM,EAAE;gBACN,KAAK;aACN;YACD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;CACF;AAED,MAAM,UAAU,mBAAmB,CAAC,EAAS;IAC3C,OAAO;QACL,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,eAAe,EAAE,EAAE,CAAC,eAAe;QACnC,UAAU,EAAE,EAAE,CAAC,UAAU;QACzB,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE;QAChC,MAAM,EAAE,EAAE,CAAC,MAAM,IAAI,gBAAgB;QACrC,WAAW,EAAE,EAAE,CAAC,WAAW,IAAI,KAAK;QACpC,OAAO,EAAE,EAAE,CAAC,OAAO;QACnB,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,IAAI,EAAE,EAAE,CAAC,IAAI;KACd,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { RequestOptions } from './common.js';
|
|
2
|
+
import type { FeatureCreateInputs, operations, paths } from './schemas.js';
|
|
3
|
+
import type { Client } from 'openapi-fetch';
|
|
4
|
+
/**
|
|
5
|
+
* Features
|
|
6
|
+
* @description Features are the building blocks of your application. They represent the capabilities or services that your application offers.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Features {
|
|
9
|
+
private client;
|
|
10
|
+
constructor(client: Client<paths, `${string}/${string}`>);
|
|
11
|
+
/**
|
|
12
|
+
* Create a feature
|
|
13
|
+
* @param feature - The feature to create
|
|
14
|
+
* @param signal - An optional abort signal
|
|
15
|
+
* @returns The created feature
|
|
16
|
+
*/
|
|
17
|
+
create(feature: FeatureCreateInputs, options?: RequestOptions): Promise<{
|
|
18
|
+
readonly createdAt: Date;
|
|
19
|
+
readonly updatedAt: Date;
|
|
20
|
+
readonly deletedAt?: Date;
|
|
21
|
+
readonly archivedAt?: Date;
|
|
22
|
+
key: string;
|
|
23
|
+
name: string;
|
|
24
|
+
metadata?: import("./schemas.js").components["schemas"]["Metadata"];
|
|
25
|
+
meterSlug?: string;
|
|
26
|
+
meterGroupByFilters?: {
|
|
27
|
+
[key: string]: string;
|
|
28
|
+
};
|
|
29
|
+
readonly id: string;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Get a feature by ID
|
|
33
|
+
* @param id - The ID of the feature
|
|
34
|
+
* @param signal - An optional abort signal
|
|
35
|
+
* @returns The feature
|
|
36
|
+
*/
|
|
37
|
+
get(id: operations['getFeature']['parameters']['path']['featureId'], options?: RequestOptions): Promise<{
|
|
38
|
+
readonly createdAt: Date;
|
|
39
|
+
readonly updatedAt: Date;
|
|
40
|
+
readonly deletedAt?: Date;
|
|
41
|
+
readonly archivedAt?: Date;
|
|
42
|
+
key: string;
|
|
43
|
+
name: string;
|
|
44
|
+
metadata?: import("./schemas.js").components["schemas"]["Metadata"];
|
|
45
|
+
meterSlug?: string;
|
|
46
|
+
meterGroupByFilters?: {
|
|
47
|
+
[key: string]: string;
|
|
48
|
+
};
|
|
49
|
+
readonly id: string;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* List features
|
|
53
|
+
* @param query - The query parameters
|
|
54
|
+
* @param signal - An optional abort signal
|
|
55
|
+
* @returns The features
|
|
56
|
+
*/
|
|
57
|
+
list(query?: Omit<operations['listFeatures']['parameters']['query'], 'page' | 'pageSize'>, options?: RequestOptions): Promise<{
|
|
58
|
+
readonly createdAt: Date;
|
|
59
|
+
readonly updatedAt: Date;
|
|
60
|
+
readonly deletedAt?: Date;
|
|
61
|
+
readonly archivedAt?: Date;
|
|
62
|
+
key: string;
|
|
63
|
+
name: string;
|
|
64
|
+
metadata?: import("./schemas.js").components["schemas"]["Metadata"];
|
|
65
|
+
meterSlug?: string;
|
|
66
|
+
meterGroupByFilters?: {
|
|
67
|
+
[key: string]: string;
|
|
68
|
+
};
|
|
69
|
+
readonly id: string;
|
|
70
|
+
}[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Delete a feature by ID
|
|
73
|
+
* @param id - The ID of the feature
|
|
74
|
+
* @param signal - An optional abort signal
|
|
75
|
+
* @returns The deleted feature
|
|
76
|
+
*/
|
|
77
|
+
delete(id: operations['deleteFeature']['parameters']['path']['featureId'], options?: RequestOptions): Promise<undefined>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { transformResponse } from './utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Features
|
|
4
|
+
* @description Features are the building blocks of your application. They represent the capabilities or services that your application offers.
|
|
5
|
+
*/
|
|
6
|
+
export class Features {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create a feature
|
|
13
|
+
* @param feature - The feature to create
|
|
14
|
+
* @param signal - An optional abort signal
|
|
15
|
+
* @returns The created feature
|
|
16
|
+
*/
|
|
17
|
+
async create(feature, options) {
|
|
18
|
+
const resp = await this.client.POST('/api/v1/features', {
|
|
19
|
+
body: feature,
|
|
20
|
+
...options,
|
|
21
|
+
});
|
|
22
|
+
return transformResponse(resp);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get a feature by ID
|
|
26
|
+
* @param id - The ID of the feature
|
|
27
|
+
* @param signal - An optional abort signal
|
|
28
|
+
* @returns The feature
|
|
29
|
+
*/
|
|
30
|
+
async get(id, options) {
|
|
31
|
+
const resp = await this.client.GET('/api/v1/features/{featureId}', {
|
|
32
|
+
params: {
|
|
33
|
+
path: {
|
|
34
|
+
featureId: id,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
...options,
|
|
38
|
+
});
|
|
39
|
+
return transformResponse(resp);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* List features
|
|
43
|
+
* @param query - The query parameters
|
|
44
|
+
* @param signal - An optional abort signal
|
|
45
|
+
* @returns The features
|
|
46
|
+
*/
|
|
47
|
+
async list(query, options) {
|
|
48
|
+
const resp = await this.client.GET('/api/v1/features', {
|
|
49
|
+
params: {
|
|
50
|
+
query,
|
|
51
|
+
},
|
|
52
|
+
...options,
|
|
53
|
+
});
|
|
54
|
+
return transformResponse(resp);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Delete a feature by ID
|
|
58
|
+
* @param id - The ID of the feature
|
|
59
|
+
* @param signal - An optional abort signal
|
|
60
|
+
* @returns The deleted feature
|
|
61
|
+
*/
|
|
62
|
+
async delete(id, options) {
|
|
63
|
+
const resp = await this.client.DELETE('/api/v1/features/{featureId}', {
|
|
64
|
+
params: {
|
|
65
|
+
path: {
|
|
66
|
+
featureId: id,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
...options,
|
|
70
|
+
});
|
|
71
|
+
return transformResponse(resp);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=features.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../../src/client/features.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAU9C;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACC;IAApB,YAAoB,MAA4C;QAA5C,WAAM,GAAN,MAAM,CAAsC;IAAG,CAAC;IAEpE;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,OAA4B,EAAE,OAAwB;QACxE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE;YACtD,IAAI,EAAE,OAAO;YACb,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAAG,CACd,EAA+D,EAC/D,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,8BAA8B,EAAE;YACjE,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,SAAS,EAAE,EAAE;iBACd;aACF;YACD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CACf,KAGC,EACD,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE;YACrD,MAAM,EAAE;gBACN,KAAK;aACN;YACD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAc,CAAA;IAC7C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CACjB,EAAkE,EAClE,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,8BAA8B,EAAE;YACpE,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,SAAS,EAAE,EAAE;iBACd;aACF;YACD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Client, type ClientOptions } from 'openapi-fetch';
|
|
2
|
+
import { Apps } from './apps.js';
|
|
3
|
+
import { Billing } from './billing.js';
|
|
4
|
+
import { Customers } from './customers.js';
|
|
5
|
+
import { Entitlements } from './entitlements.js';
|
|
6
|
+
import { Events } from './events.js';
|
|
7
|
+
import { Features } from './features.js';
|
|
8
|
+
import { Meters } from './meters.js';
|
|
9
|
+
import { Notifications } from './notifications.js';
|
|
10
|
+
import { Plans } from './plans.js';
|
|
11
|
+
import { Portal } from './portal.js';
|
|
12
|
+
import { Subjects } from './subjects.js';
|
|
13
|
+
import { Subscriptions } from './subscriptions.js';
|
|
14
|
+
import type { paths } from './schemas.js';
|
|
15
|
+
export * from './schemas.js';
|
|
16
|
+
export * from './common.js';
|
|
17
|
+
/**
|
|
18
|
+
* OpenMeter Config
|
|
19
|
+
*/
|
|
20
|
+
export type Config = Pick<ClientOptions, 'baseUrl' | 'headers' | 'fetch' | 'Request' | 'requestInitExt'> & ({
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
} | {
|
|
23
|
+
baseUrl: 'https://openmeter.cloud';
|
|
24
|
+
apiKey: string;
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* OpenMeter Client
|
|
28
|
+
*/
|
|
29
|
+
export declare class OpenMeter {
|
|
30
|
+
config: Config;
|
|
31
|
+
client: Client<paths, `${string}/${string}`>;
|
|
32
|
+
apps: Apps;
|
|
33
|
+
billing: Billing;
|
|
34
|
+
customers: Customers;
|
|
35
|
+
entitlements: Entitlements;
|
|
36
|
+
events: Events;
|
|
37
|
+
features: Features;
|
|
38
|
+
meters: Meters;
|
|
39
|
+
notifications: Notifications;
|
|
40
|
+
plans: Plans;
|
|
41
|
+
portal: Portal;
|
|
42
|
+
subjects: Subjects;
|
|
43
|
+
subscriptions: Subscriptions;
|
|
44
|
+
constructor(config: Config);
|
|
45
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import createClient, { createQuerySerializer, } from 'openapi-fetch';
|
|
2
|
+
import { Apps } from './apps.js';
|
|
3
|
+
import { Billing } from './billing.js';
|
|
4
|
+
import { Customers } from './customers.js';
|
|
5
|
+
import { Entitlements } from './entitlements.js';
|
|
6
|
+
import { Events } from './events.js';
|
|
7
|
+
import { Features } from './features.js';
|
|
8
|
+
import { Meters } from './meters.js';
|
|
9
|
+
import { Notifications } from './notifications.js';
|
|
10
|
+
import { Plans } from './plans.js';
|
|
11
|
+
import { Portal } from './portal.js';
|
|
12
|
+
import { Subjects } from './subjects.js';
|
|
13
|
+
import { Subscriptions } from './subscriptions.js';
|
|
14
|
+
import { encodeDates } from './utils.js';
|
|
15
|
+
export * from './schemas.js';
|
|
16
|
+
export * from './common.js';
|
|
17
|
+
/**
|
|
18
|
+
* OpenMeter Client
|
|
19
|
+
*/
|
|
20
|
+
export class OpenMeter {
|
|
21
|
+
config;
|
|
22
|
+
client;
|
|
23
|
+
apps;
|
|
24
|
+
billing;
|
|
25
|
+
customers;
|
|
26
|
+
entitlements;
|
|
27
|
+
events;
|
|
28
|
+
features;
|
|
29
|
+
meters;
|
|
30
|
+
notifications;
|
|
31
|
+
plans;
|
|
32
|
+
portal;
|
|
33
|
+
subjects;
|
|
34
|
+
subscriptions;
|
|
35
|
+
constructor(config) {
|
|
36
|
+
this.config = config;
|
|
37
|
+
this.client = createClient({
|
|
38
|
+
...config,
|
|
39
|
+
headers: {
|
|
40
|
+
...config.headers,
|
|
41
|
+
Authorization: config.apiKey ? `Bearer ${config.apiKey}` : undefined,
|
|
42
|
+
},
|
|
43
|
+
querySerializer: (q) => createQuerySerializer({
|
|
44
|
+
array: {
|
|
45
|
+
explode: true,
|
|
46
|
+
style: 'form',
|
|
47
|
+
},
|
|
48
|
+
object: {
|
|
49
|
+
explode: true,
|
|
50
|
+
style: 'deepObject',
|
|
51
|
+
},
|
|
52
|
+
})(encodeDates(q)),
|
|
53
|
+
});
|
|
54
|
+
this.apps = new Apps(this.client);
|
|
55
|
+
this.billing = new Billing(this.client);
|
|
56
|
+
this.customers = new Customers(this.client);
|
|
57
|
+
this.entitlements = new Entitlements(this.client);
|
|
58
|
+
this.events = new Events(this.client);
|
|
59
|
+
this.features = new Features(this.client);
|
|
60
|
+
this.meters = new Meters(this.client);
|
|
61
|
+
this.notifications = new Notifications(this.client);
|
|
62
|
+
this.plans = new Plans(this.client);
|
|
63
|
+
this.portal = new Portal(this.client);
|
|
64
|
+
this.subjects = new Subjects(this.client);
|
|
65
|
+
this.subscriptions = new Subscriptions(this.client);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EACnB,qBAAqB,GAGtB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGxC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAmB3B;;GAEG;AACH,MAAM,OAAO,SAAS;IAgBD;IAfZ,MAAM,CAAsC;IAE5C,IAAI,CAAM;IACV,OAAO,CAAS;IAChB,SAAS,CAAW;IACpB,YAAY,CAAc;IAC1B,MAAM,CAAQ;IACd,QAAQ,CAAU;IAClB,MAAM,CAAQ;IACd,aAAa,CAAe;IAC5B,KAAK,CAAO;IACZ,MAAM,CAAQ;IACd,QAAQ,CAAU;IAClB,aAAa,CAAe;IAEnC,YAAmB,MAAc;QAAd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