@blimu/backend 1.1.0 → 1.1.3

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} +294 -399
  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 -330
  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} +2 -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} +175 -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} +4 -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} +4 -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} +6 -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} +6 -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} +4 -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} +8 -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} +6 -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} +8 -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} +9 -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} +14 -31
  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 +13 -34
  99. package/dist/token-verifier.mjs.map +1 -1
  100. package/dist/tsconfig.tsbuildinfo +1 -1
  101. package/dist/{utils.js → utils.cjs} +10 -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 +37 -25
  108. package/dist/client.js +0 -70
  109. package/dist/client.js.map +0 -1
  110. package/dist/index.js +0 -1042
  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 -1264
  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
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -27,33 +28,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
28
  ));
28
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
30
 
30
- // src/main.ts
31
- var main_exports = {};
32
- __export(main_exports, {
33
- Blimu: () => Blimu,
34
- BlimuError: () => BlimuError,
35
- BulkResourcesService: () => BulkResourcesService,
36
- BulkRolesService: () => BulkRolesService,
37
- CoreClient: () => CoreClient,
38
- EntitlementsService: () => EntitlementsService,
39
- FetchError: () => import_fetch.FetchError,
40
- PlansService: () => PlansService,
41
- ResourceMembersService: () => ResourceMembersService,
42
- ResourcesService: () => ResourcesService,
43
- RolesService: () => RolesService,
44
- Schema: () => schema_exports,
45
- TokenVerifier: () => TokenVerifier,
46
- UsageService: () => UsageService,
47
- UsersService: () => UsersService,
48
- ZodSchema: () => schema_zod_exports,
49
- listAll: () => listAll,
50
- paginate: () => paginate,
51
- parseNDJSONStream: () => import_fetch2.parseNDJSONStream,
52
- parseSSEStream: () => import_fetch2.parseSSEStream,
53
- verifyToken: () => verifyToken
54
- });
55
- module.exports = __toCommonJS(main_exports);
56
-
57
31
  // src/index.ts
58
32
  var index_exports = {};
59
33
  __export(index_exports, {
@@ -61,63 +35,49 @@ __export(index_exports, {
61
35
  BlimuError: () => BlimuError,
62
36
  BulkResourcesService: () => BulkResourcesService,
63
37
  BulkRolesService: () => BulkRolesService,
64
- CoreClient: () => CoreClient,
65
38
  EntitlementsService: () => EntitlementsService,
66
- FetchError: () => import_fetch.FetchError,
39
+ FetchError: () => import_fetch10.FetchError,
67
40
  PlansService: () => PlansService,
68
41
  ResourceMembersService: () => ResourceMembersService,
69
42
  ResourcesService: () => ResourcesService,
70
43
  RolesService: () => RolesService,
71
44
  Schema: () => schema_exports,
45
+ TokenVerifier: () => TokenVerifier,
72
46
  UsageService: () => UsageService,
73
47
  UsersService: () => UsersService,
74
48
  ZodSchema: () => schema_zod_exports,
49
+ isNotUndefined: () => isNotUndefined,
75
50
  listAll: () => listAll,
76
51
  paginate: () => paginate,
77
- parseNDJSONStream: () => import_fetch2.parseNDJSONStream,
78
- parseSSEStream: () => import_fetch2.parseSSEStream
52
+ parseNDJSONStream: () => import_fetch12.parseNDJSONStream,
53
+ parseSSEStream: () => import_fetch12.parseSSEStream,
54
+ verifyToken: () => verifyToken
79
55
  });
56
+ module.exports = __toCommonJS(index_exports);
80
57
 
81
58
  // src/client.ts
82
- var import_fetch = require("@blimu/fetch");
83
- var CoreClient = class extends import_fetch.FetchClient {
84
- constructor(cfg = {}) {
85
- const authStrategies = [];
86
- const { auth: _existingAuth, apiKey, ...restCfg } = cfg;
87
- if (cfg?.apiKey) {
88
- const apiKeyValue = cfg.apiKey;
89
- authStrategies.push({
90
- type: "apiKey",
91
- key: () => apiKeyValue,
92
- location: "header",
93
- name: "X-API-KEY"
94
- });
95
- }
96
- const finalAuthStrategies = [
97
- ..._existingAuth?.strategies || [],
98
- ...authStrategies
99
- ];
100
- const fetchConfig = {
101
- ...restCfg,
102
- baseURL: cfg.baseURL ?? "https://api.blimu.dev",
103
- // Explicitly set auth after restCfg to ensure it's not overwritten
104
- // (restCfg might have an auth property that we want to replace)
105
- ...finalAuthStrategies.length > 0 ? {
106
- auth: {
107
- strategies: finalAuthStrategies
108
- }
109
- } : {}
110
- // Hooks are passed through directly from FetchClientConfig (no mapping needed)
111
- };
112
- super(fetchConfig);
113
- }
114
- async request(init) {
115
- return await super.request(init);
116
- }
117
- async *requestStream(init) {
118
- yield* super.requestStream(init);
59
+ var import_fetch10 = require("@blimu/fetch");
60
+ var import_fetch11 = require("@blimu/fetch");
61
+
62
+ // src/auth-strategies.ts
63
+ function buildAuthStrategies(cfg) {
64
+ const authStrategies = [...cfg?.authStrategies ?? []];
65
+ if (cfg.apiKey) {
66
+ authStrategies.push({
67
+ type: "apiKey",
68
+ key: cfg.apiKey,
69
+ location: "header",
70
+ name: "X-API-KEY"
71
+ });
119
72
  }
120
- };
73
+ return authStrategies;
74
+ }
75
+
76
+ // src/services/bulk_resources.ts
77
+ var import_fetch = require("@blimu/fetch");
78
+
79
+ // src/schema.ts
80
+ var schema_exports = {};
121
81
 
122
82
  // src/services/bulk_resources.ts
123
83
  var BulkResourcesService = class {
@@ -133,12 +93,13 @@ var BulkResourcesService = class {
133
93
  method: "POST",
134
94
  path: `/v1/resources/${encodeURIComponent(resourceType)}/bulk`,
135
95
  body,
136
- ...init || {}
96
+ ...init ?? {}
137
97
  });
138
98
  }
139
99
  };
140
100
 
141
101
  // src/services/bulk_roles.ts
102
+ var import_fetch2 = require("@blimu/fetch");
142
103
  var BulkRolesService = class {
143
104
  constructor(core) {
144
105
  this.core = core;
@@ -152,12 +113,13 @@ var BulkRolesService = class {
152
113
  method: "POST",
153
114
  path: `/v1/users/roles/bulk`,
154
115
  body,
155
- ...init || {}
116
+ ...init ?? {}
156
117
  });
157
118
  }
158
119
  };
159
120
 
160
121
  // src/services/entitlements.ts
122
+ var import_fetch3 = require("@blimu/fetch");
161
123
  var EntitlementsService = class {
162
124
  constructor(core) {
163
125
  this.core = core;
@@ -171,7 +133,7 @@ var EntitlementsService = class {
171
133
  method: "POST",
172
134
  path: `/v1/entitlements/check`,
173
135
  body,
174
- ...init || {}
136
+ ...init ?? {}
175
137
  });
176
138
  }
177
139
  /**
@@ -183,7 +145,7 @@ var EntitlementsService = class {
183
145
  method: "GET",
184
146
  path: `/v1/entitlements/list-for-resource/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,
185
147
  query,
186
- ...init || {}
148
+ ...init ?? {}
187
149
  });
188
150
  }
189
151
  /**
@@ -195,12 +157,13 @@ var EntitlementsService = class {
195
157
  method: "GET",
196
158
  path: `/v1/entitlements/list-for-tenant/${encodeURIComponent(tenantResourceId)}`,
197
159
  query,
198
- ...init || {}
160
+ ...init ?? {}
199
161
  });
200
162
  }
201
163
  };
202
164
 
203
165
  // src/services/plans.ts
166
+ var import_fetch4 = require("@blimu/fetch");
204
167
  var PlansService = class {
205
168
  constructor(core) {
206
169
  this.core = core;
@@ -213,7 +176,7 @@ var PlansService = class {
213
176
  return this.core.request({
214
177
  method: "DELETE",
215
178
  path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/plan`,
216
- ...init || {}
179
+ ...init ?? {}
217
180
  });
218
181
  }
219
182
  /**
@@ -224,7 +187,7 @@ var PlansService = class {
224
187
  return this.core.request({
225
188
  method: "GET",
226
189
  path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/plan`,
227
- ...init || {}
190
+ ...init ?? {}
228
191
  });
229
192
  }
230
193
  /**
@@ -236,12 +199,13 @@ var PlansService = class {
236
199
  method: "POST",
237
200
  path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/plan`,
238
201
  body,
239
- ...init || {}
202
+ ...init ?? {}
240
203
  });
241
204
  }
242
205
  };
243
206
 
244
207
  // src/services/resource_members.ts
208
+ var import_fetch5 = require("@blimu/fetch");
245
209
  var ResourceMembersService = class {
246
210
  constructor(core) {
247
211
  this.core = core;
@@ -255,12 +219,13 @@ var ResourceMembersService = class {
255
219
  method: "GET",
256
220
  path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/members`,
257
221
  query,
258
- ...init || {}
222
+ ...init ?? {}
259
223
  });
260
224
  }
261
225
  };
262
226
 
263
227
  // src/services/resources.ts
228
+ var import_fetch6 = require("@blimu/fetch");
264
229
  var ResourcesService = class {
265
230
  constructor(core) {
266
231
  this.core = core;
@@ -274,7 +239,7 @@ var ResourcesService = class {
274
239
  method: "GET",
275
240
  path: `/v1/resources/${encodeURIComponent(resourceType)}`,
276
241
  query,
277
- ...init || {}
242
+ ...init ?? {}
278
243
  });
279
244
  }
280
245
  /**
@@ -286,7 +251,7 @@ var ResourcesService = class {
286
251
  method: "POST",
287
252
  path: `/v1/resources/${encodeURIComponent(resourceType)}`,
288
253
  body,
289
- ...init || {}
254
+ ...init ?? {}
290
255
  });
291
256
  }
292
257
  /**
@@ -297,7 +262,7 @@ var ResourcesService = class {
297
262
  return this.core.request({
298
263
  method: "DELETE",
299
264
  path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,
300
- ...init || {}
265
+ ...init ?? {}
301
266
  });
302
267
  }
303
268
  /**
@@ -308,7 +273,7 @@ var ResourcesService = class {
308
273
  return this.core.request({
309
274
  method: "GET",
310
275
  path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,
311
- ...init || {}
276
+ ...init ?? {}
312
277
  });
313
278
  }
314
279
  /**
@@ -320,12 +285,13 @@ var ResourcesService = class {
320
285
  method: "PUT",
321
286
  path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,
322
287
  body,
323
- ...init || {}
288
+ ...init ?? {}
324
289
  });
325
290
  }
326
291
  };
327
292
 
328
293
  // src/services/roles.ts
294
+ var import_fetch7 = require("@blimu/fetch");
329
295
  var RolesService = class {
330
296
  constructor(core) {
331
297
  this.core = core;
@@ -339,7 +305,7 @@ var RolesService = class {
339
305
  method: "GET",
340
306
  path: `/v1/users/${encodeURIComponent(userId)}/roles`,
341
307
  query,
342
- ...init || {}
308
+ ...init ?? {}
343
309
  });
344
310
  }
345
311
  /**
@@ -351,7 +317,7 @@ var RolesService = class {
351
317
  method: "POST",
352
318
  path: `/v1/users/${encodeURIComponent(userId)}/roles`,
353
319
  body,
354
- ...init || {}
320
+ ...init ?? {}
355
321
  });
356
322
  }
357
323
  /**
@@ -362,12 +328,13 @@ var RolesService = class {
362
328
  return this.core.request({
363
329
  method: "DELETE",
364
330
  path: `/v1/users/${encodeURIComponent(userId)}/roles/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,
365
- ...init || {}
331
+ ...init ?? {}
366
332
  });
367
333
  }
368
334
  };
369
335
 
370
336
  // src/services/usage.ts
337
+ var import_fetch8 = require("@blimu/fetch");
371
338
  var UsageService = class {
372
339
  constructor(core) {
373
340
  this.core = core;
@@ -381,7 +348,7 @@ var UsageService = class {
381
348
  method: "GET",
382
349
  path: `/v1/usage/balance/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/${encodeURIComponent(limitType)}`,
383
350
  query,
384
- ...init || {}
351
+ ...init ?? {}
385
352
  });
386
353
  }
387
354
  /**
@@ -393,7 +360,7 @@ var UsageService = class {
393
360
  method: "POST",
394
361
  path: `/v1/usage/check`,
395
362
  body,
396
- ...init || {}
363
+ ...init ?? {}
397
364
  });
398
365
  }
399
366
  /**
@@ -405,7 +372,7 @@ var UsageService = class {
405
372
  method: "POST",
406
373
  path: `/v1/usage/consume`,
407
374
  body,
408
- ...init || {}
375
+ ...init ?? {}
409
376
  });
410
377
  }
411
378
  /**
@@ -417,7 +384,7 @@ var UsageService = class {
417
384
  method: "POST",
418
385
  path: `/v1/usage/credit`,
419
386
  body,
420
- ...init || {}
387
+ ...init ?? {}
421
388
  });
422
389
  }
423
390
  /**
@@ -429,12 +396,13 @@ var UsageService = class {
429
396
  method: "GET",
430
397
  path: `/v1/usage/transactions/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/${encodeURIComponent(limitType)}`,
431
398
  query,
432
- ...init || {}
399
+ ...init ?? {}
433
400
  });
434
401
  }
435
402
  };
436
403
 
437
404
  // src/services/users.ts
405
+ var import_fetch9 = require("@blimu/fetch");
438
406
  var UsersService = class {
439
407
  constructor(core) {
440
408
  this.core = core;
@@ -448,7 +416,7 @@ var UsersService = class {
448
416
  method: "GET",
449
417
  path: `/v1/users`,
450
418
  query,
451
- ...init || {}
419
+ ...init ?? {}
452
420
  });
453
421
  }
454
422
  /**
@@ -460,7 +428,7 @@ var UsersService = class {
460
428
  method: "POST",
461
429
  path: `/v1/users`,
462
430
  body,
463
- ...init || {}
431
+ ...init ?? {}
464
432
  });
465
433
  }
466
434
  /**
@@ -471,7 +439,7 @@ var UsersService = class {
471
439
  return this.core.request({
472
440
  method: "DELETE",
473
441
  path: `/v1/users/${encodeURIComponent(userId)}`,
474
- ...init || {}
442
+ ...init ?? {}
475
443
  });
476
444
  }
477
445
  /**
@@ -482,7 +450,7 @@ var UsersService = class {
482
450
  return this.core.request({
483
451
  method: "GET",
484
452
  path: `/v1/users/${encodeURIComponent(userId)}`,
485
- ...init || {}
453
+ ...init ?? {}
486
454
  });
487
455
  }
488
456
  /**
@@ -494,7 +462,7 @@ var UsersService = class {
494
462
  method: "PUT",
495
463
  path: `/v1/users/${encodeURIComponent(userId)}`,
496
464
  body,
497
- ...init || {}
465
+ ...init ?? {}
498
466
  });
499
467
  }
500
468
  /**
@@ -505,16 +473,49 @@ var UsersService = class {
505
473
  return this.core.request({
506
474
  method: "GET",
507
475
  path: `/v1/users/${encodeURIComponent(userId)}/effective-user-resources-roles`,
508
- ...init || {}
476
+ ...init ?? {}
477
+ });
478
+ }
479
+ };
480
+
481
+ // src/client.ts
482
+ var Blimu = class {
483
+ bulkResources;
484
+ bulkRoles;
485
+ entitlements;
486
+ plans;
487
+ resourceMembers;
488
+ resources;
489
+ roles;
490
+ usage;
491
+ users;
492
+ constructor(options) {
493
+ const restCfg = { ...options ?? {} };
494
+ delete restCfg.apiKey;
495
+ const authStrategies = buildAuthStrategies(options ?? {});
496
+ const core = new import_fetch10.FetchClient({
497
+ ...restCfg,
498
+ baseURL: options?.baseURL ?? "https://api.blimu.dev",
499
+ ...authStrategies.length > 0 ? { authStrategies } : {}
509
500
  });
501
+ this.bulkResources = new BulkResourcesService(core);
502
+ this.bulkRoles = new BulkRolesService(core);
503
+ this.entitlements = new EntitlementsService(core);
504
+ this.plans = new PlansService(core);
505
+ this.resourceMembers = new ResourceMembersService(core);
506
+ this.resources = new ResourcesService(core);
507
+ this.roles = new RolesService(core);
508
+ this.usage = new UsageService(core);
509
+ this.users = new UsersService(core);
510
510
  }
511
511
  };
512
+ var BlimuError = import_fetch10.FetchError;
512
513
 
513
514
  // src/index.ts
514
- __reExport(index_exports, require("@blimu/fetch"));
515
+ __reExport(index_exports, require("@blimu/fetch"), module.exports);
515
516
 
516
517
  // src/utils.ts
517
- var import_fetch2 = require("@blimu/fetch");
518
+ var import_fetch12 = require("@blimu/fetch");
518
519
  async function* paginate(fetchPage, initialQuery = {}, pageSize = 100) {
519
520
  let offset = Number(initialQuery.offset ?? 0);
520
521
  const limit = Number(initialQuery.limit ?? pageSize);
@@ -531,13 +532,14 @@ async function* paginate(fetchPage, initialQuery = {}, pageSize = 100) {
531
532
  }
532
533
  async function listAll(fetchPage, query = {}, pageSize = 100) {
533
534
  const out = [];
534
- for await (const item of paginate(fetchPage, query, pageSize))
535
- out.push(item);
535
+ for await (const item of paginate(fetchPage, query, pageSize)) out.push(item);
536
536
  return out;
537
537
  }
538
-
539
- // src/schema.ts
540
- var schema_exports = {};
538
+ function isNotUndefined(arr) {
539
+ return arr.filter(
540
+ (item) => item !== void 0
541
+ );
542
+ }
541
543
 
542
544
  // src/schema.zod.ts
543
545
  var schema_zod_exports = {};
@@ -546,15 +548,12 @@ __export(schema_zod_exports, {
546
548
  CheckLimitResponseSchema: () => CheckLimitResponseSchema,
547
549
  EntitlementCheckBodySchema: () => EntitlementCheckBodySchema,
548
550
  EntitlementCheckResultSchema: () => EntitlementCheckResultSchema,
549
- EntitlementTypeSchema: () => EntitlementTypeSchema,
550
551
  EntitlementsListForResourceQuerySchema: () => EntitlementsListForResourceQuerySchema,
551
552
  EntitlementsListForTenantQuerySchema: () => EntitlementsListForTenantQuerySchema,
552
553
  EntitlementsListResultSchema: () => EntitlementsListResultSchema,
553
- LimitTypeSchema: () => LimitTypeSchema,
554
554
  PlanAssignBodySchema: () => PlanAssignBodySchema,
555
555
  PlanDeleteResponseSchema: () => PlanDeleteResponseSchema,
556
556
  PlanResponseSchema: () => PlanResponseSchema,
557
- PlanTypeSchema: () => PlanTypeSchema,
558
557
  ResourceBulkCreateBodySchema: () => ResourceBulkCreateBodySchema,
559
558
  ResourceBulkResultSchema: () => ResourceBulkResultSchema,
560
559
  ResourceCreateBodySchema: () => ResourceCreateBodySchema,
@@ -562,7 +561,6 @@ __export(schema_zod_exports, {
562
561
  ResourceMemberListSchema: () => ResourceMemberListSchema,
563
562
  ResourceMembersListQuerySchema: () => ResourceMembersListQuerySchema,
564
563
  ResourceSchema: () => ResourceSchema,
565
- ResourceTypeSchema: () => ResourceTypeSchema,
566
564
  ResourceUpdateBodySchema: () => ResourceUpdateBodySchema,
567
565
  ResourcesListQuerySchema: () => ResourcesListQuerySchema,
568
566
  RoleBulkCreateBodySchema: () => RoleBulkCreateBodySchema,
@@ -577,7 +575,6 @@ __export(schema_zod_exports, {
577
575
  UsageCreditBodySchema: () => UsageCreditBodySchema,
578
576
  UsageGetBalanceQuerySchema: () => UsageGetBalanceQuerySchema,
579
577
  UsageGetTransactionHistoryQuerySchema: () => UsageGetTransactionHistoryQuerySchema,
580
- UsageLimitTypeSchema: () => UsageLimitTypeSchema,
581
578
  UsageWalletResponseSchema: () => UsageWalletResponseSchema,
582
579
  UserCreateBodySchema: () => UserCreateBodySchema,
583
580
  UserListSchema: () => UserListSchema,
@@ -587,11 +584,6 @@ __export(schema_zod_exports, {
587
584
  UsersListQuerySchema: () => UsersListQuerySchema
588
585
  });
589
586
  var import_zod = require("zod");
590
- var EntitlementTypeSchema = import_zod.z.string();
591
- var LimitTypeSchema = import_zod.z.string();
592
- var PlanTypeSchema = import_zod.z.string();
593
- var ResourceTypeSchema = import_zod.z.string();
594
- var UsageLimitTypeSchema = import_zod.z.string();
595
587
  var BalanceResponseSchema = import_zod.z.object({ balance: import_zod.z.number() });
596
588
  var CheckLimitResponseSchema = import_zod.z.object({
597
589
  allowed: import_zod.z.boolean(),
@@ -601,7 +593,7 @@ var CheckLimitResponseSchema = import_zod.z.object({
601
593
  });
602
594
  var EntitlementCheckBodySchema = import_zod.z.object({
603
595
  amount: import_zod.z.number().int().optional(),
604
- entitlement: EntitlementTypeSchema,
596
+ entitlement: import_zod.z.string(),
605
597
  resourceId: import_zod.z.string(),
606
598
  userId: import_zod.z.string()
607
599
  });
@@ -618,109 +610,89 @@ var EntitlementCheckResultSchema = import_zod.z.object({
618
610
  }).nullable().optional(),
619
611
  plans: import_zod.z.object({
620
612
  allowed: import_zod.z.boolean(),
621
- allowedPlans: import_zod.z.array(import_zod.z.string()).optional(),
613
+ allowedPlans: import_zod.z.string().array().optional(),
622
614
  plan: import_zod.z.string().nullable().optional(),
623
615
  reason: import_zod.z.string().optional()
624
616
  }).nullable().optional(),
625
617
  roles: import_zod.z.object({
626
618
  allowed: import_zod.z.boolean(),
627
- allowedRoles: import_zod.z.array(import_zod.z.string()).optional(),
619
+ allowedRoles: import_zod.z.string().array().optional(),
628
620
  reason: import_zod.z.string().optional(),
629
- userRoles: import_zod.z.array(import_zod.z.string()).optional()
621
+ userRoles: import_zod.z.string().array().optional()
630
622
  }).nullable().optional()
631
623
  });
632
624
  var EntitlementsListResultSchema = import_zod.z.object({
633
- results: import_zod.z.array(
634
- import_zod.z.object({
635
- entitlements: import_zod.z.array(
636
- import_zod.z.object({
637
- allowed: import_zod.z.boolean(),
638
- allowedByPlan: import_zod.z.boolean(),
639
- allowedByRole: import_zod.z.boolean(),
640
- allowedPlans: import_zod.z.array(import_zod.z.string()).optional(),
641
- allowedRoles: import_zod.z.array(import_zod.z.string()),
642
- currentPlan: import_zod.z.string().optional(),
643
- currentRole: import_zod.z.string().optional(),
644
- entitlement: EntitlementTypeSchema
645
- })
646
- ),
647
- resourceId: import_zod.z.string(),
648
- resourceType: ResourceTypeSchema
649
- })
650
- )
625
+ results: import_zod.z.object({
626
+ entitlements: import_zod.z.object({
627
+ allowed: import_zod.z.boolean(),
628
+ allowedByPlan: import_zod.z.boolean(),
629
+ allowedByRole: import_zod.z.boolean(),
630
+ allowedPlans: import_zod.z.string().array().optional(),
631
+ allowedRoles: import_zod.z.string().array(),
632
+ currentPlan: import_zod.z.string().optional(),
633
+ currentRole: import_zod.z.string().optional(),
634
+ entitlement: import_zod.z.string()
635
+ }).array(),
636
+ resourceId: import_zod.z.string(),
637
+ resourceType: import_zod.z.string()
638
+ }).array()
651
639
  });
652
- var PlanAssignBodySchema = import_zod.z.object({ planKey: PlanTypeSchema });
640
+ var PlanAssignBodySchema = import_zod.z.object({ planKey: import_zod.z.string() });
653
641
  var PlanDeleteResponseSchema = import_zod.z.object({ success: import_zod.z.boolean() });
654
642
  var PlanResponseSchema = import_zod.z.object({
655
- createdAt: import_zod.z.string().datetime(),
643
+ createdAt: import_zod.z.iso.datetime(),
656
644
  environmentId: import_zod.z.string(),
657
- planKey: PlanTypeSchema,
645
+ planKey: import_zod.z.string(),
658
646
  resourceId: import_zod.z.string(),
659
- resourceType: ResourceTypeSchema,
660
- updatedAt: import_zod.z.string().datetime()
647
+ resourceType: import_zod.z.string(),
648
+ updatedAt: import_zod.z.iso.datetime()
661
649
  });
662
650
  var ResourceSchema = import_zod.z.object({
663
- createdAt: import_zod.z.string().datetime(),
651
+ createdAt: import_zod.z.iso.datetime(),
664
652
  id: import_zod.z.string(),
665
653
  name: import_zod.z.string().nullable(),
666
- parents: import_zod.z.array(
667
- import_zod.z.object({
668
- id: import_zod.z.string(),
669
- type: ResourceTypeSchema
670
- })
671
- ).optional(),
672
- type: ResourceTypeSchema
654
+ parents: import_zod.z.object({
655
+ id: import_zod.z.string(),
656
+ type: import_zod.z.string()
657
+ }).array().optional(),
658
+ type: import_zod.z.string()
673
659
  });
674
660
  var ResourceBulkCreateBodySchema = import_zod.z.object({
675
- resources: import_zod.z.array(
676
- import_zod.z.object({
677
- id: import_zod.z.string().optional(),
678
- name: import_zod.z.string().optional(),
679
- parents: import_zod.z.array(
680
- import_zod.z.object({
681
- id: import_zod.z.string(),
682
- type: ResourceTypeSchema
683
- })
684
- ).optional(),
685
- roles: import_zod.z.array(
686
- import_zod.z.object({
687
- role: import_zod.z.string(),
688
- userId: import_zod.z.string()
689
- })
690
- ).optional()
691
- })
692
- )
661
+ resources: import_zod.z.object({
662
+ id: import_zod.z.string().optional(),
663
+ name: import_zod.z.string().optional(),
664
+ parents: import_zod.z.object({
665
+ id: import_zod.z.string(),
666
+ type: import_zod.z.string()
667
+ }).array().optional(),
668
+ roles: import_zod.z.object({
669
+ role: import_zod.z.string(),
670
+ userId: import_zod.z.string()
671
+ }).array().optional()
672
+ }).array()
693
673
  });
694
674
  var ResourceBulkResultSchema = import_zod.z.object({
695
- created: import_zod.z.array(
696
- import_zod.z.object({
697
- environmentId: import_zod.z.string(),
698
- id: import_zod.z.string(),
699
- type: ResourceTypeSchema
700
- })
701
- ),
702
- errors: import_zod.z.array(
703
- import_zod.z.object({
704
- error: import_zod.z.string(),
705
- index: import_zod.z.number(),
706
- resource: import_zod.z.object({
707
- id: import_zod.z.string().optional(),
708
- name: import_zod.z.string().optional(),
709
- parents: import_zod.z.array(
710
- import_zod.z.object({
711
- id: import_zod.z.string(),
712
- type: ResourceTypeSchema
713
- })
714
- ).optional(),
715
- roles: import_zod.z.array(
716
- import_zod.z.object({
717
- role: import_zod.z.string(),
718
- userId: import_zod.z.string()
719
- })
720
- ).optional()
721
- })
675
+ created: import_zod.z.object({
676
+ environmentId: import_zod.z.string(),
677
+ id: import_zod.z.string(),
678
+ type: import_zod.z.string()
679
+ }).array(),
680
+ errors: import_zod.z.object({
681
+ error: import_zod.z.string(),
682
+ index: import_zod.z.number(),
683
+ resource: import_zod.z.object({
684
+ id: import_zod.z.string().optional(),
685
+ name: import_zod.z.string().optional(),
686
+ parents: import_zod.z.object({
687
+ id: import_zod.z.string(),
688
+ type: import_zod.z.string()
689
+ }).array().optional(),
690
+ roles: import_zod.z.object({
691
+ role: import_zod.z.string(),
692
+ userId: import_zod.z.string()
693
+ }).array().optional()
722
694
  })
723
- ),
695
+ }).array(),
724
696
  success: import_zod.z.boolean(),
725
697
  summary: import_zod.z.object({
726
698
  failed: import_zod.z.number(),
@@ -731,58 +703,33 @@ var ResourceBulkResultSchema = import_zod.z.object({
731
703
  var ResourceCreateBodySchema = import_zod.z.object({
732
704
  id: import_zod.z.string().optional(),
733
705
  name: import_zod.z.string().optional(),
734
- parents: import_zod.z.array(
735
- import_zod.z.object({
736
- id: import_zod.z.string(),
737
- type: ResourceTypeSchema
738
- })
739
- ).optional(),
740
- roles: import_zod.z.array(
741
- import_zod.z.object({
742
- role: import_zod.z.string(),
743
- userId: import_zod.z.string()
744
- })
745
- ).optional()
746
- });
747
- var ResourceListSchema = import_zod.z.object({
748
- items: import_zod.z.array(
749
- import_zod.z.object({
750
- createdAt: import_zod.z.string().datetime(),
751
- id: import_zod.z.string(),
752
- name: import_zod.z.string().nullable(),
753
- parents: import_zod.z.array(
754
- import_zod.z.object({
755
- id: import_zod.z.string(),
756
- type: ResourceTypeSchema
757
- })
758
- ).optional(),
759
- type: ResourceTypeSchema
760
- })
761
- ),
762
- limit: import_zod.z.number(),
763
- page: import_zod.z.number(),
764
- total: import_zod.z.number()
706
+ parents: import_zod.z.object({
707
+ id: import_zod.z.string(),
708
+ type: import_zod.z.string()
709
+ }).array().optional(),
710
+ roles: import_zod.z.object({
711
+ role: import_zod.z.string(),
712
+ userId: import_zod.z.string()
713
+ }).array().optional()
765
714
  });
766
715
  var ResourceMemberListSchema = import_zod.z.object({
767
- items: import_zod.z.array(
768
- import_zod.z.object({
769
- inherited: import_zod.z.boolean(),
770
- role: import_zod.z.string(),
771
- user: import_zod.z.object({
772
- avatarUrl: import_zod.z.string().nullable(),
773
- createdAt: import_zod.z.string().datetime(),
774
- email: import_zod.z.string().email(),
775
- emailVerified: import_zod.z.boolean(),
776
- firstName: import_zod.z.string().nullable(),
777
- id: import_zod.z.string(),
778
- lastLoginAt: import_zod.z.string().datetime().nullable(),
779
- lastName: import_zod.z.string().nullable(),
780
- lookupKey: import_zod.z.string().nullable(),
781
- updatedAt: import_zod.z.string().datetime()
782
- }),
783
- userId: import_zod.z.string()
784
- })
785
- ),
716
+ items: import_zod.z.object({
717
+ inherited: import_zod.z.boolean(),
718
+ role: import_zod.z.string(),
719
+ user: import_zod.z.object({
720
+ avatarUrl: import_zod.z.string().nullable(),
721
+ createdAt: import_zod.z.iso.datetime(),
722
+ email: import_zod.z.email(),
723
+ emailVerified: import_zod.z.boolean(),
724
+ firstName: import_zod.z.string().nullable(),
725
+ id: import_zod.z.string(),
726
+ lastLoginAt: import_zod.z.iso.datetime().nullable(),
727
+ lastName: import_zod.z.string().nullable(),
728
+ lookupKey: import_zod.z.string().nullable(),
729
+ updatedAt: import_zod.z.iso.datetime()
730
+ }),
731
+ userId: import_zod.z.string()
732
+ }).array(),
786
733
  limit: import_zod.z.number(),
787
734
  page: import_zod.z.number(),
788
735
  total: import_zod.z.number()
@@ -790,54 +737,46 @@ var ResourceMemberListSchema = import_zod.z.object({
790
737
  var ResourceUpdateBodySchema = import_zod.z.object({
791
738
  name: import_zod.z.string().optional(),
792
739
  /** Creates relationships with other resources. Parent resources must already exist. */
793
- parents: import_zod.z.array(
794
- import_zod.z.object({
795
- id: import_zod.z.string(),
796
- type: ResourceTypeSchema
797
- })
798
- ).optional()
740
+ parents: import_zod.z.object({
741
+ id: import_zod.z.string(),
742
+ type: import_zod.z.string()
743
+ }).array().optional()
799
744
  });
800
745
  var RoleSchema = import_zod.z.object({
801
746
  createdAt: import_zod.z.string(),
802
747
  environmentId: import_zod.z.string(),
803
748
  resourceId: import_zod.z.string(),
804
- resourceType: ResourceTypeSchema,
749
+ resourceType: import_zod.z.string(),
805
750
  role: import_zod.z.string(),
806
751
  userId: import_zod.z.string()
807
752
  });
808
753
  var RoleBulkCreateBodySchema = import_zod.z.object({
809
- roles: import_zod.z.array(
810
- import_zod.z.object({
811
- resourceId: import_zod.z.string(),
812
- resourceType: ResourceTypeSchema,
813
- role: import_zod.z.string(),
814
- userId: import_zod.z.string()
815
- })
816
- )
754
+ roles: import_zod.z.object({
755
+ resourceId: import_zod.z.string(),
756
+ resourceType: import_zod.z.string(),
757
+ role: import_zod.z.string(),
758
+ userId: import_zod.z.string()
759
+ }).array()
817
760
  });
818
761
  var RoleBulkResultSchema = import_zod.z.object({
819
- created: import_zod.z.array(
820
- import_zod.z.object({
821
- createdAt: import_zod.z.string(),
822
- environmentId: import_zod.z.string(),
762
+ created: import_zod.z.object({
763
+ createdAt: import_zod.z.string(),
764
+ environmentId: import_zod.z.string(),
765
+ resourceId: import_zod.z.string(),
766
+ resourceType: import_zod.z.string(),
767
+ role: import_zod.z.string(),
768
+ userId: import_zod.z.string()
769
+ }).array(),
770
+ errors: import_zod.z.object({
771
+ error: import_zod.z.string(),
772
+ index: import_zod.z.number(),
773
+ role: import_zod.z.object({
823
774
  resourceId: import_zod.z.string(),
824
- resourceType: ResourceTypeSchema,
775
+ resourceType: import_zod.z.string(),
825
776
  role: import_zod.z.string(),
826
777
  userId: import_zod.z.string()
827
778
  })
828
- ),
829
- errors: import_zod.z.array(
830
- import_zod.z.object({
831
- error: import_zod.z.string(),
832
- index: import_zod.z.number(),
833
- role: import_zod.z.object({
834
- resourceId: import_zod.z.string(),
835
- resourceType: ResourceTypeSchema,
836
- role: import_zod.z.string(),
837
- userId: import_zod.z.string()
838
- })
839
- })
840
- ),
779
+ }).array(),
841
780
  success: import_zod.z.boolean(),
842
781
  summary: import_zod.z.object({
843
782
  failed: import_zod.z.number(),
@@ -847,84 +786,80 @@ var RoleBulkResultSchema = import_zod.z.object({
847
786
  });
848
787
  var RoleCreateBodySchema = import_zod.z.object({
849
788
  resourceId: import_zod.z.string(),
850
- resourceType: ResourceTypeSchema,
789
+ resourceType: import_zod.z.string(),
851
790
  role: import_zod.z.string()
852
791
  });
853
792
  var RoleListSchema = import_zod.z.object({
854
793
  limit: import_zod.z.number(),
855
794
  page: import_zod.z.number(),
856
- roles: import_zod.z.array(
857
- import_zod.z.object({
858
- createdAt: import_zod.z.string(),
859
- environmentId: import_zod.z.string(),
860
- resourceId: import_zod.z.string(),
861
- resourceType: ResourceTypeSchema,
862
- role: import_zod.z.string(),
863
- userId: import_zod.z.string()
864
- })
865
- ),
795
+ roles: import_zod.z.object({
796
+ createdAt: import_zod.z.string(),
797
+ environmentId: import_zod.z.string(),
798
+ resourceId: import_zod.z.string(),
799
+ resourceType: import_zod.z.string(),
800
+ role: import_zod.z.string(),
801
+ userId: import_zod.z.string()
802
+ }).array(),
866
803
  total: import_zod.z.number()
867
804
  });
868
805
  var TransactionHistoryResponseSchema = import_zod.z.object({
869
- items: import_zod.z.array(
870
- import_zod.z.object({
871
- amount: import_zod.z.number().int(),
872
- createdAt: import_zod.z.string().datetime(),
873
- environmentId: import_zod.z.string(),
874
- id: import_zod.z.string(),
875
- limitType: LimitTypeSchema,
876
- resourceId: import_zod.z.string(),
877
- resourceType: ResourceTypeSchema,
878
- tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).nullable()
879
- })
880
- )
806
+ items: import_zod.z.object({
807
+ amount: import_zod.z.number().int(),
808
+ createdAt: import_zod.z.iso.datetime(),
809
+ environmentId: import_zod.z.string(),
810
+ id: import_zod.z.string(),
811
+ limitType: import_zod.z.string(),
812
+ resourceId: import_zod.z.string(),
813
+ resourceType: import_zod.z.string(),
814
+ tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).nullable()
815
+ }).array()
881
816
  });
882
817
  var UsageCheckBodySchema = import_zod.z.object({
883
818
  amount: import_zod.z.number().int(),
884
- limitType: UsageLimitTypeSchema,
819
+ limitType: import_zod.z.string(),
885
820
  period: import_zod.z.enum(["monthly", "yearly", "lifetime"]),
886
821
  resourceId: import_zod.z.string(),
887
- resourceType: ResourceTypeSchema
822
+ resourceType: import_zod.z.string()
888
823
  });
889
824
  var UsageConsumeBodySchema = import_zod.z.object({
890
825
  amount: import_zod.z.number().int(),
891
- limitType: UsageLimitTypeSchema,
826
+ limitType: import_zod.z.string(),
892
827
  resourceId: import_zod.z.string(),
893
- resourceType: ResourceTypeSchema,
828
+ resourceType: import_zod.z.string(),
894
829
  tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
895
830
  });
896
831
  var UsageCreditBodySchema = import_zod.z.object({
897
832
  amount: import_zod.z.number().int(),
898
- limitType: UsageLimitTypeSchema,
833
+ limitType: import_zod.z.string(),
899
834
  resourceId: import_zod.z.string(),
900
- resourceType: ResourceTypeSchema,
835
+ resourceType: import_zod.z.string(),
901
836
  tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
902
837
  });
903
838
  var UsageWalletResponseSchema = import_zod.z.object({
904
839
  amount: import_zod.z.number().int(),
905
- createdAt: import_zod.z.string().datetime(),
840
+ createdAt: import_zod.z.iso.datetime(),
906
841
  environmentId: import_zod.z.string(),
907
842
  id: import_zod.z.string(),
908
- limitType: UsageLimitTypeSchema,
843
+ limitType: import_zod.z.string(),
909
844
  resourceId: import_zod.z.string(),
910
- resourceType: ResourceTypeSchema,
845
+ resourceType: import_zod.z.string(),
911
846
  tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).nullable()
912
847
  });
913
848
  var UserSchema = import_zod.z.object({
914
849
  avatarUrl: import_zod.z.string().nullable(),
915
- createdAt: import_zod.z.string().datetime(),
916
- email: import_zod.z.string().email(),
850
+ createdAt: import_zod.z.iso.datetime(),
851
+ email: import_zod.z.email(),
917
852
  emailVerified: import_zod.z.boolean(),
918
853
  firstName: import_zod.z.string().nullable(),
919
854
  id: import_zod.z.string(),
920
- lastLoginAt: import_zod.z.string().datetime().nullable(),
855
+ lastLoginAt: import_zod.z.iso.datetime().nullable(),
921
856
  lastName: import_zod.z.string().nullable(),
922
857
  lookupKey: import_zod.z.string().nullable(),
923
- updatedAt: import_zod.z.string().datetime()
858
+ updatedAt: import_zod.z.iso.datetime()
924
859
  });
925
860
  var UserCreateBodySchema = import_zod.z.object({
926
- avatarUrl: import_zod.z.string().url().optional(),
927
- email: import_zod.z.string().email(),
861
+ avatarUrl: import_zod.z.url().optional(),
862
+ email: import_zod.z.email(),
928
863
  firstName: import_zod.z.string().nullable().optional(),
929
864
  lastName: import_zod.z.string().nullable().optional(),
930
865
  lookupKey: import_zod.z.string(),
@@ -932,20 +867,18 @@ var UserCreateBodySchema = import_zod.z.object({
932
867
  password: import_zod.z.string().nullable().optional()
933
868
  });
934
869
  var UserListSchema = import_zod.z.object({
935
- items: import_zod.z.array(
936
- import_zod.z.object({
937
- avatarUrl: import_zod.z.string().nullable(),
938
- createdAt: import_zod.z.string().datetime(),
939
- email: import_zod.z.string().email(),
940
- emailVerified: import_zod.z.boolean(),
941
- firstName: import_zod.z.string().nullable(),
942
- id: import_zod.z.string(),
943
- lastLoginAt: import_zod.z.string().datetime().nullable(),
944
- lastName: import_zod.z.string().nullable(),
945
- lookupKey: import_zod.z.string().nullable(),
946
- updatedAt: import_zod.z.string().datetime()
947
- })
948
- ),
870
+ items: import_zod.z.object({
871
+ avatarUrl: import_zod.z.string().nullable(),
872
+ createdAt: import_zod.z.iso.datetime(),
873
+ email: import_zod.z.email(),
874
+ emailVerified: import_zod.z.boolean(),
875
+ firstName: import_zod.z.string().nullable(),
876
+ id: import_zod.z.string(),
877
+ lastLoginAt: import_zod.z.iso.datetime().nullable(),
878
+ lastName: import_zod.z.string().nullable(),
879
+ lookupKey: import_zod.z.string().nullable(),
880
+ updatedAt: import_zod.z.iso.datetime()
881
+ }).array(),
949
882
  limit: import_zod.z.number(),
950
883
  page: import_zod.z.number(),
951
884
  total: import_zod.z.number()
@@ -956,25 +889,29 @@ var UserResourceListSchema = import_zod.z.array(
956
889
  resource: import_zod.z.object({
957
890
  id: import_zod.z.string(),
958
891
  name: import_zod.z.string(),
959
- parents: import_zod.z.array(
960
- import_zod.z.object({
961
- id: import_zod.z.string(),
962
- type: ResourceTypeSchema
963
- })
964
- ),
965
- type: ResourceTypeSchema
892
+ parents: import_zod.z.object({
893
+ id: import_zod.z.string(),
894
+ type: import_zod.z.string()
895
+ }).array(),
896
+ type: import_zod.z.string()
966
897
  }).catchall(import_zod.z.unknown()),
967
898
  role: import_zod.z.string()
968
899
  })
969
900
  );
970
901
  var UserUpdateBodySchema = import_zod.z.object({
971
- avatarUrl: import_zod.z.string().url().nullable().optional(),
972
- email: import_zod.z.string().email().optional(),
902
+ avatarUrl: import_zod.z.url().nullable().optional(),
903
+ email: import_zod.z.email().optional(),
973
904
  firstName: import_zod.z.string().nullable().optional(),
974
905
  lastName: import_zod.z.string().nullable().optional(),
975
906
  lookupKey: import_zod.z.string().optional(),
976
907
  password: import_zod.z.string().optional()
977
908
  });
909
+ var ResourceListSchema = import_zod.z.object({
910
+ items: ResourceSchema.array(),
911
+ limit: import_zod.z.number(),
912
+ page: import_zod.z.number(),
913
+ total: import_zod.z.number()
914
+ });
978
915
  var EntitlementsListForResourceQuerySchema = import_zod.z.object({
979
916
  /** The unique identifier of the user */
980
917
  userId: import_zod.z.string()
@@ -1007,17 +944,13 @@ var RolesListQuerySchema = import_zod.z.object({
1007
944
  /** Filter roles by specific resource ID */
1008
945
  resourceId: import_zod.z.string().optional(),
1009
946
  /** Filter roles by resource type */
1010
- resourceType: ResourceTypeSchema.optional(),
947
+ resourceType: import_zod.z.string().optional(),
1011
948
  /** Filter by role name */
1012
949
  role: import_zod.z.string().optional()
1013
950
  });
1014
951
  var UsageGetBalanceQuerySchema = import_zod.z.object({
1015
952
  /** Time period for the balance calculation */
1016
- period: import_zod.z.enum([
1017
- "monthly",
1018
- "yearly",
1019
- "lifetime"
1020
- ])
953
+ period: import_zod.z.enum(["monthly", "yearly", "lifetime"])
1021
954
  });
1022
955
  var UsageGetTransactionHistoryQuerySchema = import_zod.z.object({
1023
956
  /** End date for filtering transactions (ISO 8601 format) */
@@ -1036,35 +969,16 @@ var UsersListQuerySchema = import_zod.z.object({
1036
969
  search: import_zod.z.string().optional()
1037
970
  });
1038
971
 
1039
- // src/index.ts
1040
- var Blimu = class {
1041
- constructor(options) {
1042
- const core = new CoreClient(options);
1043
- this.bulkResources = new BulkResourcesService(core);
1044
- this.bulkRoles = new BulkRolesService(core);
1045
- this.entitlements = new EntitlementsService(core);
1046
- this.plans = new PlansService(core);
1047
- this.resourceMembers = new ResourceMembersService(core);
1048
- this.resources = new ResourcesService(core);
1049
- this.roles = new RolesService(core);
1050
- this.usage = new UsageService(core);
1051
- this.users = new UsersService(core);
1052
- }
1053
- };
1054
- var BlimuError = import_fetch.FetchError;
1055
-
1056
- // src/main.ts
1057
- __reExport(main_exports, index_exports, module.exports);
1058
-
1059
972
  // src/token-verifier.ts
1060
973
  var crypto = __toESM(require("crypto"));
1061
974
  var jwt = __toESM(require("jsonwebtoken"));
1062
975
  var TokenVerifier = class {
976
+ cache = /* @__PURE__ */ new Map();
977
+ cacheTTL;
978
+ runtimeApiUrl;
1063
979
  constructor(options) {
1064
- this.cache = /* @__PURE__ */ new Map();
1065
980
  this.cacheTTL = options?.cacheTTL ?? 60 * 60 * 1e3;
1066
- const blimuAuthApiUrl = typeof process !== "undefined" && process.env.BLIMU_AUTH_API_URL ? process.env.BLIMU_AUTH_API_URL : void 0;
1067
- this.runtimeApiUrl = blimuAuthApiUrl ?? "https://api.blimu.dev";
981
+ this.runtimeApiUrl = options?.runtimeApiUrl ?? "https://api.blimu.dev";
1068
982
  }
1069
983
  /**
1070
984
  * Fetch JWK Set from runtime-api
@@ -1083,20 +997,14 @@ var TokenVerifier = class {
1083
997
  ...headers
1084
998
  }
1085
999
  });
1086
- console.log(
1087
- `[TokenVerifier] \u{1F4E1} Response status: ${response.status} ${response.statusText}`
1088
- );
1000
+ console.log(`[TokenVerifier] \u{1F4E1} Response status: ${response.status} ${response.statusText}`);
1089
1001
  if (!response.ok) {
1090
1002
  const errorText = await response.text();
1091
- console.error(
1092
- `[TokenVerifier] \u274C Failed to fetch JWKs: ${response.status} ${errorText}`
1093
- );
1094
- throw new import_fetch.FetchError("Failed to fetch JWKs", response.status, errorText);
1003
+ console.error(`[TokenVerifier] \u274C Failed to fetch JWKs: ${response.status} ${errorText}`);
1004
+ throw new import_fetch10.FetchError("Failed to fetch JWKs", response.status, errorText);
1095
1005
  }
1096
1006
  const jwkSet = await response.json();
1097
- console.log(
1098
- `[TokenVerifier] \u2705 Successfully fetched JWK Set with ${jwkSet.keys.length} keys`
1099
- );
1007
+ console.log(`[TokenVerifier] \u2705 Successfully fetched JWK Set with ${jwkSet.keys.length} keys`);
1100
1008
  return jwkSet;
1101
1009
  }
1102
1010
  /**
@@ -1122,9 +1030,7 @@ var TokenVerifier = class {
1122
1030
  console.log(`[TokenVerifier] \u2705 Using cached key for kid: ${kid}`);
1123
1031
  return cached.key;
1124
1032
  }
1125
- console.log(
1126
- `[TokenVerifier] \u{1F50D} Cache miss or expired. Fetching new key for kid: ${kid}`
1127
- );
1033
+ console.log(`[TokenVerifier] \u{1F50D} Cache miss or expired. Fetching new key for kid: ${kid}`);
1128
1034
  const jwkSet = await this.fetchJWKSet(endpoint, headers);
1129
1035
  const jwk = jwkSet.keys.find((k) => k.kid === kid);
1130
1036
  if (!jwk) {
@@ -1186,15 +1092,8 @@ var TokenVerifier = class {
1186
1092
  }
1187
1093
  let publicKey;
1188
1094
  try {
1189
- publicKey = await this.getPublicKey(
1190
- header.kid,
1191
- cacheKey,
1192
- endpoint,
1193
- headers
1194
- );
1195
- console.log(
1196
- `[TokenVerifier] \u2705 Successfully retrieved public key for kid: ${header.kid}`
1197
- );
1095
+ publicKey = await this.getPublicKey(header.kid, cacheKey, endpoint, headers);
1096
+ console.log(`[TokenVerifier] \u2705 Successfully retrieved public key for kid: ${header.kid}`);
1198
1097
  } catch (error) {
1199
1098
  console.error(
1200
1099
  `[TokenVerifier] \u274C Failed to get public key (first attempt): ${error instanceof Error ? error.message : String(error)}`
@@ -1202,12 +1101,7 @@ var TokenVerifier = class {
1202
1101
  this.clearCache(cacheKey);
1203
1102
  console.log(`[TokenVerifier] \u{1F504} Retrying after cache clear...`);
1204
1103
  try {
1205
- publicKey = await this.getPublicKey(
1206
- header.kid,
1207
- cacheKey,
1208
- endpoint,
1209
- headers
1210
- );
1104
+ publicKey = await this.getPublicKey(header.kid, cacheKey, endpoint, headers);
1211
1105
  console.log(
1212
1106
  `[TokenVerifier] \u2705 Successfully retrieved public key for kid: ${header.kid} (retry)`
1213
1107
  );
@@ -1252,7 +1146,6 @@ async function verifyToken(options) {
1252
1146
  BlimuError,
1253
1147
  BulkResourcesService,
1254
1148
  BulkRolesService,
1255
- CoreClient,
1256
1149
  EntitlementsService,
1257
1150
  FetchError,
1258
1151
  PlansService,
@@ -1264,10 +1157,12 @@ async function verifyToken(options) {
1264
1157
  UsageService,
1265
1158
  UsersService,
1266
1159
  ZodSchema,
1160
+ isNotUndefined,
1267
1161
  listAll,
1268
1162
  paginate,
1269
1163
  parseNDJSONStream,
1270
1164
  parseSSEStream,
1271
- verifyToken
1165
+ verifyToken,
1166
+ ...require("@blimu/fetch")
1272
1167
  });
1273
- //# sourceMappingURL=main.js.map
1168
+ //# sourceMappingURL=index.cjs.map