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