@blimu/backend 1.1.1 → 1.1.4

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 (145) hide show
  1. package/README.md +6 -13
  2. package/dist/__tests__/token-verifier.test.cjs +17662 -0
  3. package/dist/__tests__/token-verifier.test.cjs.map +1 -0
  4. package/dist/__tests__/token-verifier.test.d.mts +2 -0
  5. package/dist/__tests__/token-verifier.test.d.ts +2 -0
  6. package/dist/__tests__/token-verifier.test.mjs +17661 -0
  7. package/dist/__tests__/token-verifier.test.mjs.map +1 -0
  8. package/dist/auth-strategies.cjs +42 -0
  9. package/dist/auth-strategies.cjs.map +1 -0
  10. package/dist/auth-strategies.d.mts +16 -0
  11. package/dist/auth-strategies.d.ts +16 -0
  12. package/dist/auth-strategies.mjs +17 -0
  13. package/dist/auth-strategies.mjs.map +1 -0
  14. package/dist/client.cjs +483 -0
  15. package/dist/client.cjs.map +1 -0
  16. package/dist/client.d.mts +26 -18
  17. package/dist/client.d.ts +26 -18
  18. package/dist/client.mjs +447 -39
  19. package/dist/client.mjs.map +1 -1
  20. package/dist/{main.js → index.cjs} +290 -407
  21. package/dist/index.cjs.map +1 -0
  22. package/dist/index.d.mts +15 -33
  23. package/dist/index.d.ts +15 -33
  24. package/dist/index.mjs +440 -339
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/{schema-B1usIXCr.d.mts → schema-BbKn_i-U.d.mts} +82 -93
  27. package/dist/{schema-B1usIXCr.d.ts → schema-BbKn_i-U.d.ts} +82 -93
  28. package/dist/{schema.js → schema.cjs} +1 -1
  29. package/dist/schema.cjs.map +1 -0
  30. package/dist/schema.d.mts +1 -2
  31. package/dist/schema.d.ts +1 -2
  32. package/dist/{schema.zod-CRNAHxbc.d.mts → schema.zod-DtXVS-1g.d.mts} +38 -48
  33. package/dist/{schema.zod-CRNAHxbc.d.ts → schema.zod-DtXVS-1g.d.ts} +38 -48
  34. package/dist/{schema.zod.js → schema.zod.cjs} +174 -248
  35. package/dist/schema.zod.cjs.map +1 -0
  36. package/dist/schema.zod.d.mts +1 -1
  37. package/dist/schema.zod.d.ts +1 -1
  38. package/dist/schema.zod.mjs +173 -242
  39. package/dist/schema.zod.mjs.map +1 -1
  40. package/dist/services/{bulk_resources.js → bulk_resources.cjs} +3 -2
  41. package/dist/services/bulk_resources.cjs.map +1 -0
  42. package/dist/services/bulk_resources.d.mts +4 -6
  43. package/dist/services/bulk_resources.d.ts +4 -6
  44. package/dist/services/bulk_resources.mjs +2 -1
  45. package/dist/services/bulk_resources.mjs.map +1 -1
  46. package/dist/services/{bulk_roles.js → bulk_roles.cjs} +3 -2
  47. package/dist/services/bulk_roles.cjs.map +1 -0
  48. package/dist/services/bulk_roles.d.mts +3 -5
  49. package/dist/services/bulk_roles.d.ts +3 -5
  50. package/dist/services/bulk_roles.mjs +2 -1
  51. package/dist/services/bulk_roles.mjs.map +1 -1
  52. package/dist/services/{entitlements.js → entitlements.cjs} +5 -4
  53. package/dist/services/entitlements.cjs.map +1 -0
  54. package/dist/services/entitlements.d.mts +4 -6
  55. package/dist/services/entitlements.d.ts +4 -6
  56. package/dist/services/entitlements.mjs +4 -3
  57. package/dist/services/entitlements.mjs.map +1 -1
  58. package/dist/services/{plans.js → plans.cjs} +5 -4
  59. package/dist/services/plans.cjs.map +1 -0
  60. package/dist/services/plans.d.mts +6 -8
  61. package/dist/services/plans.d.ts +6 -8
  62. package/dist/services/plans.mjs +4 -3
  63. package/dist/services/plans.mjs.map +1 -1
  64. package/dist/services/{resource_members.js → resource_members.cjs} +3 -2
  65. package/dist/services/resource_members.cjs.map +1 -0
  66. package/dist/services/resource_members.d.mts +4 -6
  67. package/dist/services/resource_members.d.ts +4 -6
  68. package/dist/services/resource_members.mjs +2 -1
  69. package/dist/services/resource_members.mjs.map +1 -1
  70. package/dist/services/{resources.js → resources.cjs} +7 -6
  71. package/dist/services/resources.cjs.map +1 -0
  72. package/dist/services/resources.d.mts +8 -10
  73. package/dist/services/resources.d.ts +8 -10
  74. package/dist/services/resources.mjs +6 -5
  75. package/dist/services/resources.mjs.map +1 -1
  76. package/dist/services/{roles.js → roles.cjs} +5 -4
  77. package/dist/services/roles.cjs.map +1 -0
  78. package/dist/services/roles.d.mts +4 -6
  79. package/dist/services/roles.d.ts +4 -6
  80. package/dist/services/roles.mjs +4 -3
  81. package/dist/services/roles.mjs.map +1 -1
  82. package/dist/services/{usage.js → usage.cjs} +7 -6
  83. package/dist/services/usage.cjs.map +1 -0
  84. package/dist/services/usage.d.mts +5 -7
  85. package/dist/services/usage.d.ts +5 -7
  86. package/dist/services/usage.mjs +6 -5
  87. package/dist/services/usage.mjs.map +1 -1
  88. package/dist/services/{users.js → users.cjs} +8 -7
  89. package/dist/services/users.cjs.map +1 -0
  90. package/dist/services/users.d.mts +3 -5
  91. package/dist/services/users.d.ts +3 -5
  92. package/dist/services/users.mjs +7 -6
  93. package/dist/services/users.mjs.map +1 -1
  94. package/dist/{token-verifier.js → token-verifier.cjs} +10 -30
  95. package/dist/token-verifier.cjs.map +1 -0
  96. package/dist/token-verifier.d.mts +5 -5
  97. package/dist/token-verifier.d.ts +5 -5
  98. package/dist/token-verifier.mjs +10 -33
  99. package/dist/token-verifier.mjs.map +1 -1
  100. package/dist/tsconfig.tsbuildinfo +1 -1
  101. package/dist/{utils.js → utils.cjs} +9 -3
  102. package/dist/utils.cjs.map +1 -0
  103. package/dist/utils.d.mts +4 -3
  104. package/dist/utils.d.ts +4 -3
  105. package/dist/utils.mjs +7 -2
  106. package/dist/utils.mjs.map +1 -1
  107. package/package.json +36 -24
  108. package/dist/client.js +0 -71
  109. package/dist/client.js.map +0 -1
  110. package/dist/index.js +0 -1052
  111. package/dist/index.js.map +0 -1
  112. package/dist/main.d.mts +0 -19
  113. package/dist/main.d.ts +0 -19
  114. package/dist/main.js.map +0 -1
  115. package/dist/main.mjs +0 -1275
  116. package/dist/main.mjs.map +0 -1
  117. package/dist/schema.js.map +0 -1
  118. package/dist/schema.zod.js.map +0 -1
  119. package/dist/services/bulk_resources.js.map +0 -1
  120. package/dist/services/bulk_roles.js.map +0 -1
  121. package/dist/services/entitlements.js.map +0 -1
  122. package/dist/services/plans.js.map +0 -1
  123. package/dist/services/resource_members.js.map +0 -1
  124. package/dist/services/resources.js.map +0 -1
  125. package/dist/services/roles.js.map +0 -1
  126. package/dist/services/usage.js.map +0 -1
  127. package/dist/services/users.js.map +0 -1
  128. package/dist/token-verifier.js.map +0 -1
  129. package/dist/utils.js.map +0 -1
  130. package/src/client.ts +0 -74
  131. package/src/index.ts +0 -55
  132. package/src/main.ts +0 -3
  133. package/src/schema.ts +0 -430
  134. package/src/schema.zod.ts +0 -558
  135. package/src/services/bulk_resources.ts +0 -24
  136. package/src/services/bulk_roles.ts +0 -22
  137. package/src/services/entitlements.ts +0 -58
  138. package/src/services/plans.ts +0 -57
  139. package/src/services/resource_members.ts +0 -25
  140. package/src/services/resources.ts +0 -91
  141. package/src/services/roles.ts +0 -58
  142. package/src/services/usage.ts +0 -93
  143. package/src/services/users.ts +0 -100
  144. package/src/token-verifier.ts +0 -280
  145. package/src/utils.ts +0 -56
package/src/schema.zod.ts DELETED
@@ -1,558 +0,0 @@
1
- // Generated zod schemas from OpenAPI components.schemas
2
- // Use these schemas for runtime validation in forms, API requests, etc.
3
-
4
- import { z } from 'zod';
5
-
6
- /**
7
- * Schema for EntitlementType
8
- * Entitlement identifier
9
- */
10
- export const EntitlementTypeSchema = z.string();
11
- /**
12
- * Schema for LimitType
13
- * Limit type identifier
14
- */
15
- export const LimitTypeSchema = z.string();
16
- /**
17
- * Schema for PlanType
18
- * Plan type identifier
19
- */
20
- export const PlanTypeSchema = z.string();
21
- /**
22
- * Schema for ResourceType
23
- * Resource type identifier
24
- */
25
- export const ResourceTypeSchema = z.string();
26
- /**
27
- * Schema for UsageLimitType
28
- * Usage-based limit type identifier
29
- */
30
- export const UsageLimitTypeSchema = z.string();
31
-
32
- /**
33
- * Zod schema for BalanceResponse*/
34
- export const BalanceResponseSchema = z.object({ balance: z.number() }); /**
35
- * Zod schema for CheckLimitResponse*/
36
- export const CheckLimitResponseSchema = z.object({
37
- allowed: z.boolean(),
38
- current: z.number(),
39
- remaining: z.number().optional(),
40
- requested: z.number(),
41
- }); /**
42
- * Zod schema for EntitlementCheckBody*/
43
- export const EntitlementCheckBodySchema = z.object({
44
- amount: z.number().int().optional(),
45
- entitlement: EntitlementTypeSchema,
46
- resourceId: z.string(),
47
- userId: z.string(),
48
- }); /**
49
- * Zod schema for EntitlementCheckResult*/
50
- export const EntitlementCheckResultSchema = z.object({
51
- allowed: z.boolean(),
52
- limit: z
53
- .object({
54
- allowed: z.boolean(),
55
- current: z.number().optional(),
56
- limit: z.number().optional(),
57
- plan: z.string().nullable().optional(),
58
- reason: z.string().optional(),
59
- remaining: z.number().optional(),
60
- scope: z.string().optional(),
61
- })
62
- .nullable()
63
- .optional(),
64
- plans: z
65
- .object({
66
- allowed: z.boolean(),
67
- allowedPlans: z.array(z.string()).optional(),
68
- plan: z.string().nullable().optional(),
69
- reason: z.string().optional(),
70
- })
71
- .nullable()
72
- .optional(),
73
- roles: z
74
- .object({
75
- allowed: z.boolean(),
76
- allowedRoles: z.array(z.string()).optional(),
77
- reason: z.string().optional(),
78
- userRoles: z.array(z.string()).optional(),
79
- })
80
- .nullable()
81
- .optional(),
82
- }); /**
83
- * Zod schema for EntitlementsListResult*/
84
- export const EntitlementsListResultSchema = z.object({
85
- results: z.array(
86
- z.object({
87
- entitlements: z.array(
88
- z.object({
89
- allowed: z.boolean(),
90
- allowedByPlan: z.boolean(),
91
- allowedByRole: z.boolean(),
92
- allowedPlans: z.array(z.string()).optional(),
93
- allowedRoles: z.array(z.string()),
94
- currentPlan: z.string().optional(),
95
- currentRole: z.string().optional(),
96
- entitlement: EntitlementTypeSchema,
97
- })
98
- ),
99
- resourceId: z.string(),
100
- resourceType: ResourceTypeSchema,
101
- })
102
- ),
103
- }); /**
104
- * Zod schema for PlanAssignBody*/
105
- export const PlanAssignBodySchema = z.object({ planKey: PlanTypeSchema }); /**
106
- * Zod schema for PlanDeleteResponse*/
107
- export const PlanDeleteResponseSchema = z.object({ success: z.boolean() }); /**
108
- * Zod schema for PlanResponse*/
109
- export const PlanResponseSchema = z.object({
110
- createdAt: z.string().datetime(),
111
- environmentId: z.string(),
112
- planKey: PlanTypeSchema,
113
- resourceId: z.string(),
114
- resourceType: ResourceTypeSchema,
115
- updatedAt: z.string().datetime(),
116
- }); /**
117
- * Zod schema for Resource*/
118
- export const ResourceSchema = z.object({
119
- createdAt: z.string().datetime(),
120
- id: z.string(),
121
- name: z.string().nullable(),
122
- parents: z
123
- .array(
124
- z.object({
125
- id: z.string(),
126
- type: ResourceTypeSchema,
127
- })
128
- )
129
- .optional(),
130
- type: ResourceTypeSchema,
131
- }); /**
132
- * Zod schema for ResourceBulkCreateBody*/
133
- export const ResourceBulkCreateBodySchema = z.object({
134
- resources: z.array(
135
- z.object({
136
- id: z.string().optional(),
137
- name: z.string().optional(),
138
- parents: z
139
- .array(
140
- z.object({
141
- id: z.string(),
142
- type: ResourceTypeSchema,
143
- })
144
- )
145
- .optional(),
146
- roles: z
147
- .array(
148
- z.object({
149
- role: z.string(),
150
- userId: z.string(),
151
- })
152
- )
153
- .optional(),
154
- })
155
- ),
156
- }); /**
157
- * Zod schema for ResourceBulkResult*/
158
- export const ResourceBulkResultSchema = z.object({
159
- created: z.array(
160
- z.object({
161
- environmentId: z.string(),
162
- id: z.string(),
163
- type: ResourceTypeSchema,
164
- })
165
- ),
166
- errors: z.array(
167
- z.object({
168
- error: z.string(),
169
- index: z.number(),
170
- resource: z.object({
171
- id: z.string().optional(),
172
- name: z.string().optional(),
173
- parents: z
174
- .array(
175
- z.object({
176
- id: z.string(),
177
- type: ResourceTypeSchema,
178
- })
179
- )
180
- .optional(),
181
- roles: z
182
- .array(
183
- z.object({
184
- role: z.string(),
185
- userId: z.string(),
186
- })
187
- )
188
- .optional(),
189
- }),
190
- })
191
- ),
192
- success: z.boolean(),
193
- summary: z.object({
194
- failed: z.number(),
195
- successful: z.number(),
196
- total: z.number(),
197
- }),
198
- }); /**
199
- * Zod schema for ResourceCreateBody*/
200
- export const ResourceCreateBodySchema = z.object({
201
- id: z.string().optional(),
202
- name: z.string().optional(),
203
- parents: z
204
- .array(
205
- z.object({
206
- id: z.string(),
207
- type: ResourceTypeSchema,
208
- })
209
- )
210
- .optional(),
211
- roles: z
212
- .array(
213
- z.object({
214
- role: z.string(),
215
- userId: z.string(),
216
- })
217
- )
218
- .optional(),
219
- }); /**
220
- * Zod schema for ResourceList*/
221
- export const ResourceListSchema = z.object({
222
- items: z.array(
223
- z.object({
224
- createdAt: z.string().datetime(),
225
- id: z.string(),
226
- name: z.string().nullable(),
227
- parents: z
228
- .array(
229
- z.object({
230
- id: z.string(),
231
- type: ResourceTypeSchema,
232
- })
233
- )
234
- .optional(),
235
- type: ResourceTypeSchema,
236
- })
237
- ),
238
- limit: z.number(),
239
- page: z.number(),
240
- total: z.number(),
241
- }); /**
242
- * Zod schema for ResourceMemberList*/
243
- export const ResourceMemberListSchema = z.object({
244
- items: z.array(
245
- z.object({
246
- inherited: z.boolean(),
247
- role: z.string(),
248
- user: z.object({
249
- avatarUrl: z.string().nullable(),
250
- createdAt: z.string().datetime(),
251
- email: z.string().email(),
252
- emailVerified: z.boolean(),
253
- firstName: z.string().nullable(),
254
- id: z.string(),
255
- lastLoginAt: z.string().datetime().nullable(),
256
- lastName: z.string().nullable(),
257
- lookupKey: z.string().nullable(),
258
- updatedAt: z.string().datetime(),
259
- }),
260
- userId: z.string(),
261
- })
262
- ),
263
- limit: z.number(),
264
- page: z.number(),
265
- total: z.number(),
266
- }); /**
267
- * Zod schema for ResourceUpdateBody*/
268
- export const ResourceUpdateBodySchema = z.object({
269
- name: z.string().optional(),
270
- /** Creates relationships with other resources. Parent resources must already exist. */ parents:
271
- z
272
- .array(
273
- z.object({
274
- id: z.string(),
275
- type: ResourceTypeSchema,
276
- })
277
- )
278
- .optional(),
279
- }); /**
280
- * Zod schema for Role*/
281
- export const RoleSchema = z.object({
282
- createdAt: z.string(),
283
- environmentId: z.string(),
284
- resourceId: z.string(),
285
- resourceType: ResourceTypeSchema,
286
- role: z.string(),
287
- userId: z.string(),
288
- }); /**
289
- * Zod schema for RoleBulkCreateBody*/
290
- export const RoleBulkCreateBodySchema = z.object({
291
- roles: z.array(
292
- z.object({
293
- resourceId: z.string(),
294
- resourceType: ResourceTypeSchema,
295
- role: z.string(),
296
- userId: z.string(),
297
- })
298
- ),
299
- }); /**
300
- * Zod schema for RoleBulkResult*/
301
- export const RoleBulkResultSchema = z.object({
302
- created: z.array(
303
- z.object({
304
- createdAt: z.string(),
305
- environmentId: z.string(),
306
- resourceId: z.string(),
307
- resourceType: ResourceTypeSchema,
308
- role: z.string(),
309
- userId: z.string(),
310
- })
311
- ),
312
- errors: z.array(
313
- z.object({
314
- error: z.string(),
315
- index: z.number(),
316
- role: z.object({
317
- resourceId: z.string(),
318
- resourceType: ResourceTypeSchema,
319
- role: z.string(),
320
- userId: z.string(),
321
- }),
322
- })
323
- ),
324
- success: z.boolean(),
325
- summary: z.object({
326
- failed: z.number(),
327
- successful: z.number(),
328
- total: z.number(),
329
- }),
330
- }); /**
331
- * Zod schema for RoleCreateBody*/
332
- export const RoleCreateBodySchema = z.object({
333
- resourceId: z.string(),
334
- resourceType: ResourceTypeSchema,
335
- role: z.string(),
336
- }); /**
337
- * Zod schema for RoleList*/
338
- export const RoleListSchema = z.object({
339
- limit: z.number(),
340
- page: z.number(),
341
- roles: z.array(
342
- z.object({
343
- createdAt: z.string(),
344
- environmentId: z.string(),
345
- resourceId: z.string(),
346
- resourceType: ResourceTypeSchema,
347
- role: z.string(),
348
- userId: z.string(),
349
- })
350
- ),
351
- total: z.number(),
352
- }); /**
353
- * Zod schema for TransactionHistoryResponse*/
354
- export const TransactionHistoryResponseSchema = z.object({
355
- items: z.array(
356
- z.object({
357
- amount: z.number().int(),
358
- createdAt: z.string().datetime(),
359
- environmentId: z.string(),
360
- id: z.string(),
361
- limitType: LimitTypeSchema,
362
- resourceId: z.string(),
363
- resourceType: ResourceTypeSchema,
364
- tags: z.record(z.string(), z.unknown()).nullable(),
365
- })
366
- ),
367
- }); /**
368
- * Zod schema for UsageCheckBody*/
369
- export const UsageCheckBodySchema = z.object({
370
- amount: z.number().int(),
371
- limitType: UsageLimitTypeSchema,
372
- period: z.enum(['monthly', 'yearly', 'lifetime']),
373
- resourceId: z.string(),
374
- resourceType: ResourceTypeSchema,
375
- }); /**
376
- * Zod schema for UsageConsumeBody*/
377
- export const UsageConsumeBodySchema = z.object({
378
- amount: z.number().int(),
379
- limitType: UsageLimitTypeSchema,
380
- resourceId: z.string(),
381
- resourceType: ResourceTypeSchema,
382
- tags: z.record(z.string(), z.unknown()).optional(),
383
- }); /**
384
- * Zod schema for UsageCreditBody*/
385
- export const UsageCreditBodySchema = z.object({
386
- amount: z.number().int(),
387
- limitType: UsageLimitTypeSchema,
388
- resourceId: z.string(),
389
- resourceType: ResourceTypeSchema,
390
- tags: z.record(z.string(), z.unknown()).optional(),
391
- }); /**
392
- * Zod schema for UsageWalletResponse*/
393
- export const UsageWalletResponseSchema = z.object({
394
- amount: z.number().int(),
395
- createdAt: z.string().datetime(),
396
- environmentId: z.string(),
397
- id: z.string(),
398
- limitType: UsageLimitTypeSchema,
399
- resourceId: z.string(),
400
- resourceType: ResourceTypeSchema,
401
- tags: z.record(z.string(), z.unknown()).nullable(),
402
- }); /**
403
- * Zod schema for User*/
404
- export const UserSchema = z.object({
405
- avatarUrl: z.string().nullable(),
406
- createdAt: z.string().datetime(),
407
- email: z.string().email(),
408
- emailVerified: z.boolean(),
409
- firstName: z.string().nullable(),
410
- id: z.string(),
411
- lastLoginAt: z.string().datetime().nullable(),
412
- lastName: z.string().nullable(),
413
- lookupKey: z.string().nullable(),
414
- updatedAt: z.string().datetime(),
415
- }); /**
416
- * Zod schema for UserCreateBody*/
417
- export const UserCreateBodySchema = z.object({
418
- avatarUrl: z.string().url().optional(),
419
- email: z.string().email(),
420
- firstName: z.string().nullable().optional(),
421
- lastName: z.string().nullable().optional(),
422
- lookupKey: z.string(),
423
- newUser: z.boolean().nullable().optional(),
424
- password: z.string().nullable().optional(),
425
- }); /**
426
- * Zod schema for UserList*/
427
- export const UserListSchema = z.object({
428
- items: z.array(
429
- z.object({
430
- avatarUrl: z.string().nullable(),
431
- createdAt: z.string().datetime(),
432
- email: z.string().email(),
433
- emailVerified: z.boolean(),
434
- firstName: z.string().nullable(),
435
- id: z.string(),
436
- lastLoginAt: z.string().datetime().nullable(),
437
- lastName: z.string().nullable(),
438
- lookupKey: z.string().nullable(),
439
- updatedAt: z.string().datetime(),
440
- })
441
- ),
442
- limit: z.number(),
443
- page: z.number(),
444
- total: z.number(),
445
- }); /**
446
- * Zod schema for UserResourceList*/
447
- export const UserResourceListSchema = z.array(
448
- z.object({
449
- inherited: z.boolean(),
450
- resource: z
451
- .object({
452
- id: z.string(),
453
- name: z.string(),
454
- parents: z.array(
455
- z.object({
456
- id: z.string(),
457
- type: ResourceTypeSchema,
458
- })
459
- ),
460
- type: ResourceTypeSchema,
461
- })
462
- .catchall(z.unknown()),
463
- role: z.string(),
464
- })
465
- ); /**
466
- * Zod schema for UserUpdateBody*/
467
- export const UserUpdateBodySchema = z.object({
468
- avatarUrl: z.string().url().nullable().optional(),
469
- email: z.string().email().optional(),
470
- firstName: z.string().nullable().optional(),
471
- lastName: z.string().nullable().optional(),
472
- lookupKey: z.string().optional(),
473
- password: z.string().optional(),
474
- });
475
- // Operation query parameter schemas
476
-
477
- /**
478
- * Schema for query params of Entitlements.ListForResource* Returns entitlements for a specific resource and user. Only evaluates roles and plans (excludes limits). Provides detailed information about why entitlements are allowed or denied, including current roles, allowed roles, current plan, and allowed plans. Results are cached per resource for performance.*/
479
- export const EntitlementsListForResourceQuerySchema = z.object({
480
- /** The unique identifier of the user */ userId: z.string(),
481
- });
482
-
483
- /**
484
- * Schema for query params of Entitlements.ListForTenant* Returns entitlements for a tenant resource and all its descendant resources. This endpoint scopes queries to a single tenant, preventing cross-tenant data access. Only evaluates roles and plans (excludes limits). Results are cached per resource for performance. The tenant resource type is automatically determined from the environment definition (resource marked as `is_tenant: true`).*/
485
- export const EntitlementsListForTenantQuerySchema = z.object({
486
- /** The unique identifier of the user */ userId: z.string(),
487
- });
488
-
489
- /**
490
- * Schema for query params of Resource Members.List* Retrieves a paginated list of users who have roles (direct or inherited) on the specified resource. Supports search functionality to filter users by email or name.*/
491
- export const ResourceMembersListQuerySchema = z.object({
492
- /** Number of items per page (minimum: 1, maximum: 100) */ limit: z
493
- .number()
494
- .optional(),
495
- /** Page number for pagination */ page: z.number().optional(),
496
- /** Search query to filter members by email or name */ search: z
497
- .string()
498
- .optional(),
499
- });
500
-
501
- /**
502
- * Schema for query params of Resources.List* Retrieves a paginated list of resources of the specified type. Supports search and filtering. Resources are returned with their parent relationships and metadata.*/
503
- export const ResourcesListQuerySchema = z.object({
504
- /** Number of items per page (minimum: 1, maximum: 100) */ limit: z
505
- .number()
506
- .optional(),
507
- /** Page number for pagination */ page: z.number().optional(),
508
- /** Search query to filter resources by name */ search: z.string().optional(),
509
- });
510
-
511
- /**
512
- * Schema for query params of Roles.List* Retrieves a paginated list of roles assigned to a user. Supports filtering by resource type, resource ID, and role name. Returns both directly assigned roles and inherited roles.*/
513
- export const RolesListQuerySchema = z.object({
514
- /** Number of items per page (minimum: 1, maximum: 100) */ limit: z
515
- .number()
516
- .optional(),
517
- /** Page number for pagination */ page: z.number().optional(),
518
- /** Filter roles by specific resource ID */ resourceId: z.string().optional(),
519
- /** Filter roles by resource type */ resourceType:
520
- ResourceTypeSchema.optional(),
521
- /** Filter by role name */ role: z.string().optional(),
522
- });
523
-
524
- /**
525
- * Schema for query params of Usage.GetBalance* Retrieves the current balance of a usage wallet for a specific resource and limit type within a given time period. The balance reflects all credits and consumption transactions.*/
526
- export const UsageGetBalanceQuerySchema = z.object({
527
- /** Time period for the balance calculation */ period: z.enum([
528
- 'monthly',
529
- 'yearly',
530
- 'lifetime',
531
- ]),
532
- });
533
-
534
- /**
535
- * Schema for query params of Usage.GetTransactionHistory* Retrieves the transaction history for a usage wallet, including all credits and consumption records. Supports filtering by time period and date range.*/
536
- export const UsageGetTransactionHistoryQuerySchema = z.object({
537
- /** End date for filtering transactions (ISO 8601 format) */ endDate: z
538
- .string()
539
- .optional(),
540
- /** Time period for filtering transactions */ period: z
541
- .enum(['monthly', 'yearly', 'lifetime'])
542
- .optional(),
543
- /** Start date for filtering transactions (ISO 8601 format) */ startDate: z
544
- .string()
545
- .optional(),
546
- });
547
-
548
- /**
549
- * Schema for query params of Users.List* Retrieves a paginated list of users in your environment. Supports search functionality to filter users by email, name, or lookup key.*/
550
- export const UsersListQuerySchema = z.object({
551
- /** Number of items per page (minimum: 1, maximum: 100) */ limit: z
552
- .number()
553
- .optional(),
554
- /** Page number for pagination */ page: z.number().optional(),
555
- /** Search query to filter users by email, name, or lookup key */ search: z
556
- .string()
557
- .optional(),
558
- });
@@ -1,24 +0,0 @@
1
- import { CoreClient } from '../client';
2
- import * as Schema from '../schema';
3
- import type { ResourceType } from '@blimu/types';
4
-
5
- export class BulkResourcesService {
6
- constructor(private core: CoreClient) {}
7
-
8
- /**
9
- * POST /v1/resources/{resourceType}/bulk*
10
- * @summary Bulk create resources*
11
- * @description Creates multiple resources of the specified type in a single request. This operation supports partial success - some resources may be created while others fail. The response includes details about successful creations and any errors encountered. Resources can have parent relationships and initial role assignments.*/
12
- create(
13
- resourceType: ResourceType,
14
- body: Schema.ResourceBulkCreateBody,
15
- init?: Omit<RequestInit, 'method' | 'body'>
16
- ): Promise<Schema.ResourceBulkResult> {
17
- return this.core.request({
18
- method: 'POST',
19
- path: `/v1/resources/${encodeURIComponent(resourceType)}/bulk`,
20
- body: body as any,
21
- ...(init || {}),
22
- });
23
- }
24
- }
@@ -1,22 +0,0 @@
1
- import { CoreClient } from '../client';
2
- import * as Schema from '../schema';
3
-
4
- export class BulkRolesService {
5
- constructor(private core: CoreClient) {}
6
-
7
- /**
8
- * POST /v1/users/roles/bulk*
9
- * @summary Bulk create roles*
10
- * @description Assigns multiple roles to users on resources in a single request. This operation supports partial success - some role assignments may succeed while others fail. The response includes details about successful assignments and any errors encountered. All roles must be valid according to your resource definitions.*/
11
- create(
12
- body: Schema.RoleBulkCreateBody,
13
- init?: Omit<RequestInit, 'method' | 'body'>
14
- ): Promise<Schema.RoleBulkResult> {
15
- return this.core.request({
16
- method: 'POST',
17
- path: `/v1/users/roles/bulk`,
18
- body: body as any,
19
- ...(init || {}),
20
- });
21
- }
22
- }
@@ -1,58 +0,0 @@
1
- import { CoreClient } from '../client';
2
- import * as Schema from '../schema';
3
- import type { ResourceType } from '@blimu/types';
4
-
5
- export class EntitlementsService {
6
- constructor(private core: CoreClient) {}
7
-
8
- /**
9
- * POST /v1/entitlements/check*
10
- * @summary Check if a user has a specific entitlement on a resource*
11
- * @description Checks whether a user has permission to perform a specific action (entitlement) on a resource. This endpoint evaluates role-based access, plan gating, and usage limits. The response includes detailed information about why access was granted or denied, including which roles were checked, plan requirements, and usage limit status.*/
12
- checkEntitlement(
13
- body: Schema.EntitlementCheckBody,
14
- init?: Omit<RequestInit, 'method' | 'body'>
15
- ): Promise<Schema.EntitlementCheckResult> {
16
- return this.core.request({
17
- method: 'POST',
18
- path: `/v1/entitlements/check`,
19
- body: body as any,
20
- ...(init || {}),
21
- });
22
- }
23
-
24
- /**
25
- * GET /v1/entitlements/list-for-resource/{resourceType}/{resourceId}*
26
- * @summary List entitlements for a specific resource*
27
- * @description Returns entitlements for a specific resource and user. Only evaluates roles and plans (excludes limits). Provides detailed information about why entitlements are allowed or denied, including current roles, allowed roles, current plan, and allowed plans. Results are cached per resource for performance.*/
28
- listForResource(
29
- resourceType: ResourceType,
30
- resourceId: string,
31
- query?: Schema.EntitlementsListForResourceQuery,
32
- init?: Omit<RequestInit, 'method' | 'body'>
33
- ): Promise<Schema.EntitlementsListResult> {
34
- return this.core.request({
35
- method: 'GET',
36
- path: `/v1/entitlements/list-for-resource/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,
37
- query,
38
- ...(init || {}),
39
- });
40
- }
41
-
42
- /**
43
- * GET /v1/entitlements/list-for-tenant/{tenantResourceId}*
44
- * @summary List entitlements for a tenant and all its sub-resources*
45
- * @description Returns entitlements for a tenant resource and all its descendant resources. This endpoint scopes queries to a single tenant, preventing cross-tenant data access. Only evaluates roles and plans (excludes limits). Results are cached per resource for performance. The tenant resource type is automatically determined from the environment definition (resource marked as `is_tenant: true`).*/
46
- listForTenant(
47
- tenantResourceId: string,
48
- query?: Schema.EntitlementsListForTenantQuery,
49
- init?: Omit<RequestInit, 'method' | 'body'>
50
- ): Promise<Schema.EntitlementsListResult> {
51
- return this.core.request({
52
- method: 'GET',
53
- path: `/v1/entitlements/list-for-tenant/${encodeURIComponent(tenantResourceId)}`,
54
- query,
55
- ...(init || {}),
56
- });
57
- }
58
- }