@blimu/client 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -101,6 +101,10 @@ import { PaymentService, Schema } from '@blimu/client';
101
101
  - **refresh**: POST /v1/auth/refresh - Refresh session token
102
102
  - **getSession**: GET /v1/auth/session - Get current session
103
103
 
104
+ ### EntitlementsService
105
+
106
+ - **listForTenant**: GET /v1/client/entitlements/list-for-tenant/{tenantResourceId} - List entitlements for a tenant and all its sub-resources
107
+
104
108
  ## TypeScript Support
105
109
 
106
110
  This SDK is written in TypeScript and provides full type safety:
@@ -116,7 +120,7 @@ const client = new BlimuClient({
116
120
  const result: unknown = await client.auth.logout(/* ... */);
117
121
 
118
122
  // Schema types are available
119
- const data: Schema.RefreshResponse = {
123
+ const data: Schema.EntitlementType = {
120
124
  // Fully typed object
121
125
  };
122
126
  ```
@@ -143,7 +147,10 @@ const client = new BlimuClient({
143
147
 
144
148
  The SDK includes the following TypeScript interfaces:
145
149
 
150
+ - **EntitlementType**: Entitlement identifier
151
+ - **EntitlementsListResult**
146
152
  - **RefreshResponse**
153
+ - **ResourceType**: Resource type identifier
147
154
  - **SessionResponse**
148
155
 
149
156
  All types are available under the `Schema` namespace:
@@ -23,6 +23,7 @@ var CoreClient = class {
23
23
  this.cfg.accessToken = token;
24
24
  }
25
25
  async request(init) {
26
+ var _a, _b, _c;
26
27
  let normalizedPath = init.path || "";
27
28
  if (normalizedPath.length > 1 && normalizedPath.endsWith("/")) {
28
29
  normalizedPath = normalizedPath.slice(0, -1);
@@ -54,14 +55,27 @@ var CoreClient = class {
54
55
  ...init,
55
56
  headers: requestHeaders
56
57
  };
58
+ if (this.cfg.credentials !== void 0) {
59
+ fetchInit.credentials = this.cfg.credentials;
60
+ }
57
61
  if (this.cfg.onRequest)
58
62
  await this.cfg.onRequest({ url: url.toString(), init: fetchInit, attempt });
59
63
  let controller;
60
64
  let timeoutId;
65
+ const existingSignal = fetchInit.signal;
61
66
  if (this.cfg.timeoutMs && typeof AbortController !== "undefined") {
62
67
  controller = new AbortController();
68
+ if (existingSignal) {
69
+ if (existingSignal.aborted) {
70
+ controller.abort();
71
+ } else {
72
+ existingSignal.addEventListener("abort", () => {
73
+ controller == null ? void 0 : controller.abort();
74
+ });
75
+ }
76
+ }
63
77
  fetchInit.signal = controller.signal;
64
- timeoutId = setTimeout(() => controller?.abort(), this.cfg.timeoutMs);
78
+ timeoutId = setTimeout(() => controller == null ? void 0 : controller.abort(), this.cfg.timeoutMs);
65
79
  }
66
80
  try {
67
81
  const res = await (this.cfg.fetch || fetch)(url.toString(), fetchInit);
@@ -82,7 +96,12 @@ var CoreClient = class {
82
96
  parsed = await res.arrayBuffer();
83
97
  }
84
98
  if (!res.ok) {
85
- throw new FetchError(`HTTP ${res.status}`, res.status, parsed, res.headers);
99
+ throw new FetchError(
100
+ (parsed == null ? void 0 : parsed.message) || `HTTP ${res.status}`,
101
+ res.status,
102
+ parsed,
103
+ res.headers
104
+ );
86
105
  }
87
106
  return parsed;
88
107
  } catch (err) {
@@ -92,15 +111,15 @@ var CoreClient = class {
92
111
  if (timeoutId) clearTimeout(timeoutId);
93
112
  }
94
113
  };
95
- const retries = this.cfg.retry?.retries ?? 0;
96
- const baseBackoff = this.cfg.retry?.backoffMs ?? 300;
97
- const retryOn = this.cfg.retry?.retryOn ?? [429, 500, 502, 503, 504];
114
+ const retries = ((_a = this.cfg.retry) == null ? void 0 : _a.retries) ?? 0;
115
+ const baseBackoff = ((_b = this.cfg.retry) == null ? void 0 : _b.backoffMs) ?? 300;
116
+ const retryOn = ((_c = this.cfg.retry) == null ? void 0 : _c.retryOn) ?? [429, 500, 502, 503, 504];
98
117
  let lastError;
99
118
  for (let attempt = 0; attempt <= retries; attempt++) {
100
119
  try {
101
120
  return await doFetch(attempt);
102
121
  } catch (err) {
103
- const status = err?.status;
122
+ const status = err == null ? void 0 : err.status;
104
123
  const shouldRetry = status ? retryOn.includes(status) : true;
105
124
  if (attempt < retries && shouldRetry) {
106
125
  const delay = baseBackoff * Math.pow(2, attempt);
@@ -108,8 +127,10 @@ var CoreClient = class {
108
127
  lastError = err;
109
128
  continue;
110
129
  }
130
+ if (err instanceof DOMException) throw err;
111
131
  if (err instanceof FetchError) throw err;
112
- throw new FetchError(err?.message || "Network error", status ?? 0);
132
+ if (typeof err === "string") throw new FetchError(err, status ?? 0);
133
+ throw new FetchError((err == null ? void 0 : err.message) || "Network error", status ?? 0);
113
134
  }
114
135
  }
115
136
  throw lastError;
@@ -0,0 +1,30 @@
1
+ // src/services/entitlements.ts
2
+ var EntitlementsService = class {
3
+ constructor(core) {
4
+ this.core = core;
5
+ }
6
+ /**
7
+ * GET /v1/client/entitlements/list-for-tenant/{tenantResourceId}
8
+ * @summary List entitlements for a tenant and all its sub-resources
9
+ *
10
+ * @description Returns entitlements for a tenant resource and all its descendant resources for the authenticated user. This endpoint scopes queries to a single tenant, preventing cross-tenant data access. Only evaluates roles and plans (excludes limits). Results are cached per resource for performance. The tenant resource type is automatically determined from the environment definition (resource marked as `is_tenant: true`).
11
+ */
12
+ listForTenant(tenantResourceId, init) {
13
+ return this.core.request({
14
+ method: "GET",
15
+ path: `/v1/client/entitlements/list-for-tenant/${encodeURIComponent(tenantResourceId)}`,
16
+ ...init || {}
17
+ });
18
+ }
19
+ /**
20
+ * @summary Get query keys for listForTenant
21
+ * @returns ['v1/client/entitlements/list-for-tenant', tenantResourceId]
22
+ */
23
+ listForTenant__queryKeys(tenantResourceId) {
24
+ return ["v1/client/entitlements/list-for-tenant", tenantResourceId];
25
+ }
26
+ };
27
+
28
+ export {
29
+ EntitlementsService
30
+ };
@@ -14,17 +14,32 @@ var AuthService = class {
14
14
  ...init || {}
15
15
  });
16
16
  }
17
+ /**
18
+ * @summary Get query keys for logout
19
+ * @returns ['v1/auth/logout']
20
+ */
21
+ logout__queryKeys() {
22
+ return ["v1/auth/logout"];
23
+ }
17
24
  /**
18
25
  * POST /v1/auth/refresh
19
26
  * @summary Refresh session token
20
27
  */
21
- refresh(init) {
28
+ refresh(query, init) {
22
29
  return this.core.request({
23
30
  method: "POST",
24
31
  path: `/v1/auth/refresh`,
32
+ query,
25
33
  ...init || {}
26
34
  });
27
35
  }
36
+ /**
37
+ * @summary Get query keys for refresh
38
+ * @returns ['v1/auth/refresh', query]
39
+ */
40
+ refresh__queryKeys(query) {
41
+ return ["v1/auth/refresh", query];
42
+ }
28
43
  /**
29
44
  * GET /v1/auth/session
30
45
  * @summary Get current session
@@ -36,6 +51,13 @@ var AuthService = class {
36
51
  ...init || {}
37
52
  });
38
53
  }
54
+ /**
55
+ * @summary Get query keys for getSession
56
+ * @returns ['v1/auth/session']
57
+ */
58
+ getSession__queryKeys() {
59
+ return ["v1/auth/session"];
60
+ }
39
61
  };
40
62
 
41
63
  export {
package/dist/client.d.mts CHANGED
@@ -46,6 +46,7 @@ type ClientOption = {
46
46
  headerName?: string;
47
47
  bearer?: string;
48
48
  fetch?: typeof fetch;
49
+ credentials?: RequestCredentials;
49
50
  };
50
51
  declare class FetchError<T = unknown> extends Error {
51
52
  readonly status: number;
package/dist/client.d.ts CHANGED
@@ -46,6 +46,7 @@ type ClientOption = {
46
46
  headerName?: string;
47
47
  bearer?: string;
48
48
  fetch?: typeof fetch;
49
+ credentials?: RequestCredentials;
49
50
  };
50
51
  declare class FetchError<T = unknown> extends Error {
51
52
  readonly status: number;
package/dist/client.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -47,6 +48,7 @@ var CoreClient = class {
47
48
  this.cfg.accessToken = token;
48
49
  }
49
50
  async request(init) {
51
+ var _a, _b, _c;
50
52
  let normalizedPath = init.path || "";
51
53
  if (normalizedPath.length > 1 && normalizedPath.endsWith("/")) {
52
54
  normalizedPath = normalizedPath.slice(0, -1);
@@ -78,14 +80,27 @@ var CoreClient = class {
78
80
  ...init,
79
81
  headers: requestHeaders
80
82
  };
83
+ if (this.cfg.credentials !== void 0) {
84
+ fetchInit.credentials = this.cfg.credentials;
85
+ }
81
86
  if (this.cfg.onRequest)
82
87
  await this.cfg.onRequest({ url: url.toString(), init: fetchInit, attempt });
83
88
  let controller;
84
89
  let timeoutId;
90
+ const existingSignal = fetchInit.signal;
85
91
  if (this.cfg.timeoutMs && typeof AbortController !== "undefined") {
86
92
  controller = new AbortController();
93
+ if (existingSignal) {
94
+ if (existingSignal.aborted) {
95
+ controller.abort();
96
+ } else {
97
+ existingSignal.addEventListener("abort", () => {
98
+ controller == null ? void 0 : controller.abort();
99
+ });
100
+ }
101
+ }
87
102
  fetchInit.signal = controller.signal;
88
- timeoutId = setTimeout(() => controller?.abort(), this.cfg.timeoutMs);
103
+ timeoutId = setTimeout(() => controller == null ? void 0 : controller.abort(), this.cfg.timeoutMs);
89
104
  }
90
105
  try {
91
106
  const res = await (this.cfg.fetch || fetch)(url.toString(), fetchInit);
@@ -106,7 +121,12 @@ var CoreClient = class {
106
121
  parsed = await res.arrayBuffer();
107
122
  }
108
123
  if (!res.ok) {
109
- throw new FetchError(`HTTP ${res.status}`, res.status, parsed, res.headers);
124
+ throw new FetchError(
125
+ (parsed == null ? void 0 : parsed.message) || `HTTP ${res.status}`,
126
+ res.status,
127
+ parsed,
128
+ res.headers
129
+ );
110
130
  }
111
131
  return parsed;
112
132
  } catch (err) {
@@ -116,15 +136,15 @@ var CoreClient = class {
116
136
  if (timeoutId) clearTimeout(timeoutId);
117
137
  }
118
138
  };
119
- const retries = this.cfg.retry?.retries ?? 0;
120
- const baseBackoff = this.cfg.retry?.backoffMs ?? 300;
121
- const retryOn = this.cfg.retry?.retryOn ?? [429, 500, 502, 503, 504];
139
+ const retries = ((_a = this.cfg.retry) == null ? void 0 : _a.retries) ?? 0;
140
+ const baseBackoff = ((_b = this.cfg.retry) == null ? void 0 : _b.backoffMs) ?? 300;
141
+ const retryOn = ((_c = this.cfg.retry) == null ? void 0 : _c.retryOn) ?? [429, 500, 502, 503, 504];
122
142
  let lastError;
123
143
  for (let attempt = 0; attempt <= retries; attempt++) {
124
144
  try {
125
145
  return await doFetch(attempt);
126
146
  } catch (err) {
127
- const status = err?.status;
147
+ const status = err == null ? void 0 : err.status;
128
148
  const shouldRetry = status ? retryOn.includes(status) : true;
129
149
  if (attempt < retries && shouldRetry) {
130
150
  const delay = baseBackoff * Math.pow(2, attempt);
@@ -132,8 +152,10 @@ var CoreClient = class {
132
152
  lastError = err;
133
153
  continue;
134
154
  }
155
+ if (err instanceof DOMException) throw err;
135
156
  if (err instanceof FetchError) throw err;
136
- throw new FetchError(err?.message || "Network error", status ?? 0);
157
+ if (typeof err === "string") throw new FetchError(err, status ?? 0);
158
+ throw new FetchError((err == null ? void 0 : err.message) || "Network error", status ?? 0);
137
159
  }
138
160
  }
139
161
  throw lastError;
package/dist/client.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CoreClient,
3
3
  FetchError
4
- } from "./chunk-GA44NLBR.mjs";
4
+ } from "./chunk-ATZGLDGF.mjs";
5
5
  export {
6
6
  CoreClient,
7
7
  FetchError
package/dist/index.d.mts CHANGED
@@ -1,13 +1,15 @@
1
1
  import { ClientOption, FetchError } from './client.mjs';
2
2
  import { AuthService } from './services/auth.mjs';
3
+ import { EntitlementsService } from './services/entitlements.mjs';
3
4
  export { PaginableQuery, listAll, paginate } from './utils.mjs';
4
- export { s as Schema } from './schema-C3_USjmu.mjs';
5
+ export { s as Schema } from './schema-jwKwV_Bm.mjs';
5
6
 
6
7
  declare class Blimu {
7
8
  readonly auth: AuthService;
9
+ readonly entitlements: EntitlementsService;
8
10
  constructor(options?: ClientOption);
9
11
  }
10
12
 
11
13
  declare const BlimuError: typeof FetchError;
12
14
 
13
- export { AuthService, Blimu, BlimuError, ClientOption, FetchError };
15
+ export { AuthService, Blimu, BlimuError, ClientOption, EntitlementsService, FetchError };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,15 @@
1
1
  import { ClientOption, FetchError } from './client.js';
2
2
  import { AuthService } from './services/auth.js';
3
+ import { EntitlementsService } from './services/entitlements.js';
3
4
  export { PaginableQuery, listAll, paginate } from './utils.js';
4
- export { s as Schema } from './schema-C3_USjmu.js';
5
+ export { s as Schema } from './schema-jwKwV_Bm.js';
5
6
 
6
7
  declare class Blimu {
7
8
  readonly auth: AuthService;
9
+ readonly entitlements: EntitlementsService;
8
10
  constructor(options?: ClientOption);
9
11
  }
10
12
 
11
13
  declare const BlimuError: typeof FetchError;
12
14
 
13
- export { AuthService, Blimu, BlimuError, ClientOption, FetchError };
15
+ export { AuthService, Blimu, BlimuError, ClientOption, EntitlementsService, FetchError };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -22,6 +23,7 @@ __export(index_exports, {
22
23
  AuthService: () => AuthService,
23
24
  Blimu: () => Blimu,
24
25
  BlimuError: () => BlimuError,
26
+ EntitlementsService: () => EntitlementsService,
25
27
  FetchError: () => FetchError,
26
28
  Schema: () => schema_exports,
27
29
  listAll: () => listAll,
@@ -54,6 +56,7 @@ var CoreClient = class {
54
56
  this.cfg.accessToken = token;
55
57
  }
56
58
  async request(init) {
59
+ var _a, _b, _c;
57
60
  let normalizedPath = init.path || "";
58
61
  if (normalizedPath.length > 1 && normalizedPath.endsWith("/")) {
59
62
  normalizedPath = normalizedPath.slice(0, -1);
@@ -85,14 +88,27 @@ var CoreClient = class {
85
88
  ...init,
86
89
  headers: requestHeaders
87
90
  };
91
+ if (this.cfg.credentials !== void 0) {
92
+ fetchInit.credentials = this.cfg.credentials;
93
+ }
88
94
  if (this.cfg.onRequest)
89
95
  await this.cfg.onRequest({ url: url.toString(), init: fetchInit, attempt });
90
96
  let controller;
91
97
  let timeoutId;
98
+ const existingSignal = fetchInit.signal;
92
99
  if (this.cfg.timeoutMs && typeof AbortController !== "undefined") {
93
100
  controller = new AbortController();
101
+ if (existingSignal) {
102
+ if (existingSignal.aborted) {
103
+ controller.abort();
104
+ } else {
105
+ existingSignal.addEventListener("abort", () => {
106
+ controller == null ? void 0 : controller.abort();
107
+ });
108
+ }
109
+ }
94
110
  fetchInit.signal = controller.signal;
95
- timeoutId = setTimeout(() => controller?.abort(), this.cfg.timeoutMs);
111
+ timeoutId = setTimeout(() => controller == null ? void 0 : controller.abort(), this.cfg.timeoutMs);
96
112
  }
97
113
  try {
98
114
  const res = await (this.cfg.fetch || fetch)(url.toString(), fetchInit);
@@ -113,7 +129,12 @@ var CoreClient = class {
113
129
  parsed = await res.arrayBuffer();
114
130
  }
115
131
  if (!res.ok) {
116
- throw new FetchError(`HTTP ${res.status}`, res.status, parsed, res.headers);
132
+ throw new FetchError(
133
+ (parsed == null ? void 0 : parsed.message) || `HTTP ${res.status}`,
134
+ res.status,
135
+ parsed,
136
+ res.headers
137
+ );
117
138
  }
118
139
  return parsed;
119
140
  } catch (err) {
@@ -123,15 +144,15 @@ var CoreClient = class {
123
144
  if (timeoutId) clearTimeout(timeoutId);
124
145
  }
125
146
  };
126
- const retries = this.cfg.retry?.retries ?? 0;
127
- const baseBackoff = this.cfg.retry?.backoffMs ?? 300;
128
- const retryOn = this.cfg.retry?.retryOn ?? [429, 500, 502, 503, 504];
147
+ const retries = ((_a = this.cfg.retry) == null ? void 0 : _a.retries) ?? 0;
148
+ const baseBackoff = ((_b = this.cfg.retry) == null ? void 0 : _b.backoffMs) ?? 300;
149
+ const retryOn = ((_c = this.cfg.retry) == null ? void 0 : _c.retryOn) ?? [429, 500, 502, 503, 504];
129
150
  let lastError;
130
151
  for (let attempt = 0; attempt <= retries; attempt++) {
131
152
  try {
132
153
  return await doFetch(attempt);
133
154
  } catch (err) {
134
- const status = err?.status;
155
+ const status = err == null ? void 0 : err.status;
135
156
  const shouldRetry = status ? retryOn.includes(status) : true;
136
157
  if (attempt < retries && shouldRetry) {
137
158
  const delay = baseBackoff * Math.pow(2, attempt);
@@ -139,14 +160,19 @@ var CoreClient = class {
139
160
  lastError = err;
140
161
  continue;
141
162
  }
163
+ if (err instanceof DOMException) throw err;
142
164
  if (err instanceof FetchError) throw err;
143
- throw new FetchError(err?.message || "Network error", status ?? 0);
165
+ if (typeof err === "string") throw new FetchError(err, status ?? 0);
166
+ throw new FetchError((err == null ? void 0 : err.message) || "Network error", status ?? 0);
144
167
  }
145
168
  }
146
169
  throw lastError;
147
170
  }
148
171
  };
149
172
 
173
+ // src/schema.ts
174
+ var schema_exports = {};
175
+
150
176
  // src/services/auth.ts
151
177
  var AuthService = class {
152
178
  constructor(core) {
@@ -163,17 +189,32 @@ var AuthService = class {
163
189
  ...init || {}
164
190
  });
165
191
  }
192
+ /**
193
+ * @summary Get query keys for logout
194
+ * @returns ['v1/auth/logout']
195
+ */
196
+ logout__queryKeys() {
197
+ return ["v1/auth/logout"];
198
+ }
166
199
  /**
167
200
  * POST /v1/auth/refresh
168
201
  * @summary Refresh session token
169
202
  */
170
- refresh(init) {
203
+ refresh(query, init) {
171
204
  return this.core.request({
172
205
  method: "POST",
173
206
  path: `/v1/auth/refresh`,
207
+ query,
174
208
  ...init || {}
175
209
  });
176
210
  }
211
+ /**
212
+ * @summary Get query keys for refresh
213
+ * @returns ['v1/auth/refresh', query]
214
+ */
215
+ refresh__queryKeys(query) {
216
+ return ["v1/auth/refresh", query];
217
+ }
177
218
  /**
178
219
  * GET /v1/auth/session
179
220
  * @summary Get current session
@@ -185,6 +226,40 @@ var AuthService = class {
185
226
  ...init || {}
186
227
  });
187
228
  }
229
+ /**
230
+ * @summary Get query keys for getSession
231
+ * @returns ['v1/auth/session']
232
+ */
233
+ getSession__queryKeys() {
234
+ return ["v1/auth/session"];
235
+ }
236
+ };
237
+
238
+ // src/services/entitlements.ts
239
+ var EntitlementsService = class {
240
+ constructor(core) {
241
+ this.core = core;
242
+ }
243
+ /**
244
+ * GET /v1/client/entitlements/list-for-tenant/{tenantResourceId}
245
+ * @summary List entitlements for a tenant and all its sub-resources
246
+ *
247
+ * @description Returns entitlements for a tenant resource and all its descendant resources for the authenticated user. This endpoint scopes queries to a single tenant, preventing cross-tenant data access. Only evaluates roles and plans (excludes limits). Results are cached per resource for performance. The tenant resource type is automatically determined from the environment definition (resource marked as `is_tenant: true`).
248
+ */
249
+ listForTenant(tenantResourceId, init) {
250
+ return this.core.request({
251
+ method: "GET",
252
+ path: `/v1/client/entitlements/list-for-tenant/${encodeURIComponent(tenantResourceId)}`,
253
+ ...init || {}
254
+ });
255
+ }
256
+ /**
257
+ * @summary Get query keys for listForTenant
258
+ * @returns ['v1/client/entitlements/list-for-tenant', tenantResourceId]
259
+ */
260
+ listForTenant__queryKeys(tenantResourceId) {
261
+ return ["v1/client/entitlements/list-for-tenant", tenantResourceId];
262
+ }
188
263
  };
189
264
 
190
265
  // src/utils.ts
@@ -208,14 +283,14 @@ async function listAll(fetchPage, query = {}, pageSize = 100) {
208
283
  return out;
209
284
  }
210
285
 
211
- // src/schema.ts
212
- var schema_exports = {};
213
-
214
286
  // src/index.ts
215
287
  var Blimu = class {
288
+ auth;
289
+ entitlements;
216
290
  constructor(options) {
217
291
  const core = new CoreClient(options);
218
292
  this.auth = new AuthService(core);
293
+ this.entitlements = new EntitlementsService(core);
219
294
  }
220
295
  };
221
296
  var BlimuError = FetchError;
@@ -224,6 +299,7 @@ var BlimuError = FetchError;
224
299
  AuthService,
225
300
  Blimu,
226
301
  BlimuError,
302
+ EntitlementsService,
227
303
  FetchError,
228
304
  Schema,
229
305
  listAll,
package/dist/index.mjs CHANGED
@@ -1,23 +1,29 @@
1
- import {
2
- CoreClient,
3
- FetchError
4
- } from "./chunk-GA44NLBR.mjs";
5
- import {
6
- schema_exports
7
- } from "./chunk-7SBLH5KM.mjs";
8
1
  import {
9
2
  listAll,
10
3
  paginate
11
4
  } from "./chunk-LZ27JJ4R.mjs";
12
5
  import {
13
6
  AuthService
14
- } from "./chunk-UTMQXMDQ.mjs";
7
+ } from "./chunk-YGEJFE6U.mjs";
8
+ import {
9
+ EntitlementsService
10
+ } from "./chunk-ENXZU3RF.mjs";
11
+ import {
12
+ CoreClient,
13
+ FetchError
14
+ } from "./chunk-ATZGLDGF.mjs";
15
+ import {
16
+ schema_exports
17
+ } from "./chunk-7SBLH5KM.mjs";
15
18
 
16
19
  // src/index.ts
17
20
  var Blimu = class {
21
+ auth;
22
+ entitlements;
18
23
  constructor(options) {
19
24
  const core = new CoreClient(options);
20
25
  this.auth = new AuthService(core);
26
+ this.entitlements = new EntitlementsService(core);
21
27
  }
22
28
  };
23
29
  var BlimuError = FetchError;
@@ -25,6 +31,7 @@ export {
25
31
  AuthService,
26
32
  Blimu,
27
33
  BlimuError,
34
+ EntitlementsService,
28
35
  FetchError,
29
36
  schema_exports as Schema,
30
37
  listAll,
@@ -0,0 +1,57 @@
1
+ type Enum<T> = T[keyof T];
2
+ /**
3
+ * Entitlement identifier
4
+ */
5
+ type EntitlementType = string;
6
+ interface EntitlementsListResult {
7
+ results: Array<{
8
+ entitlements: Array<{
9
+ allowed: boolean;
10
+ allowedByPlan: boolean;
11
+ allowedByRole: boolean;
12
+ allowedPlans?: Array<string>;
13
+ allowedRoles: Array<string>;
14
+ currentPlan?: string;
15
+ currentRole?: string;
16
+ entitlement: EntitlementType;
17
+ }>;
18
+ resourceId: string;
19
+ resourceType: ResourceType;
20
+ }>;
21
+ }
22
+ interface RefreshResponse {
23
+ sessionToken: string;
24
+ }
25
+ /**
26
+ * Resource type identifier
27
+ */
28
+ type ResourceType = string;
29
+ interface SessionResponse {
30
+ isAuthenticated: boolean;
31
+ user: {
32
+ email: string;
33
+ emailVerified: boolean;
34
+ firstName: string | null;
35
+ id: string;
36
+ lastName: string | null;
37
+ } | null;
38
+ }
39
+ /**
40
+ * Query params for Auth.Refresh
41
+ */
42
+ interface AuthRefreshQuery {
43
+ __lh_jwt?: string;
44
+ }
45
+
46
+ type schema_AuthRefreshQuery = AuthRefreshQuery;
47
+ type schema_EntitlementType = EntitlementType;
48
+ type schema_EntitlementsListResult = EntitlementsListResult;
49
+ type schema_Enum<T> = Enum<T>;
50
+ type schema_RefreshResponse = RefreshResponse;
51
+ type schema_ResourceType = ResourceType;
52
+ type schema_SessionResponse = SessionResponse;
53
+ declare namespace schema {
54
+ export type { schema_AuthRefreshQuery as AuthRefreshQuery, schema_EntitlementType as EntitlementType, schema_EntitlementsListResult as EntitlementsListResult, schema_Enum as Enum, schema_RefreshResponse as RefreshResponse, schema_ResourceType as ResourceType, schema_SessionResponse as SessionResponse };
55
+ }
56
+
57
+ export { type AuthRefreshQuery as A, type EntitlementsListResult as E, type RefreshResponse as R, type SessionResponse as S, type Enum as a, type EntitlementType as b, type ResourceType as c, schema as s };
@@ -0,0 +1,57 @@
1
+ type Enum<T> = T[keyof T];
2
+ /**
3
+ * Entitlement identifier
4
+ */
5
+ type EntitlementType = string;
6
+ interface EntitlementsListResult {
7
+ results: Array<{
8
+ entitlements: Array<{
9
+ allowed: boolean;
10
+ allowedByPlan: boolean;
11
+ allowedByRole: boolean;
12
+ allowedPlans?: Array<string>;
13
+ allowedRoles: Array<string>;
14
+ currentPlan?: string;
15
+ currentRole?: string;
16
+ entitlement: EntitlementType;
17
+ }>;
18
+ resourceId: string;
19
+ resourceType: ResourceType;
20
+ }>;
21
+ }
22
+ interface RefreshResponse {
23
+ sessionToken: string;
24
+ }
25
+ /**
26
+ * Resource type identifier
27
+ */
28
+ type ResourceType = string;
29
+ interface SessionResponse {
30
+ isAuthenticated: boolean;
31
+ user: {
32
+ email: string;
33
+ emailVerified: boolean;
34
+ firstName: string | null;
35
+ id: string;
36
+ lastName: string | null;
37
+ } | null;
38
+ }
39
+ /**
40
+ * Query params for Auth.Refresh
41
+ */
42
+ interface AuthRefreshQuery {
43
+ __lh_jwt?: string;
44
+ }
45
+
46
+ type schema_AuthRefreshQuery = AuthRefreshQuery;
47
+ type schema_EntitlementType = EntitlementType;
48
+ type schema_EntitlementsListResult = EntitlementsListResult;
49
+ type schema_Enum<T> = Enum<T>;
50
+ type schema_RefreshResponse = RefreshResponse;
51
+ type schema_ResourceType = ResourceType;
52
+ type schema_SessionResponse = SessionResponse;
53
+ declare namespace schema {
54
+ export type { schema_AuthRefreshQuery as AuthRefreshQuery, schema_EntitlementType as EntitlementType, schema_EntitlementsListResult as EntitlementsListResult, schema_Enum as Enum, schema_RefreshResponse as RefreshResponse, schema_ResourceType as ResourceType, schema_SessionResponse as SessionResponse };
55
+ }
56
+
57
+ export { type AuthRefreshQuery as A, type EntitlementsListResult as E, type RefreshResponse as R, type SessionResponse as S, type Enum as a, type EntitlementType as b, type ResourceType as c, schema as s };
package/dist/schema.d.mts CHANGED
@@ -1 +1 @@
1
- export { E as Enum, R as RefreshResponse, S as SessionResponse } from './schema-C3_USjmu.mjs';
1
+ export { A as AuthRefreshQuery, b as EntitlementType, E as EntitlementsListResult, a as Enum, R as RefreshResponse, c as ResourceType, S as SessionResponse } from './schema-jwKwV_Bm.mjs';
package/dist/schema.d.ts CHANGED
@@ -1 +1 @@
1
- export { E as Enum, R as RefreshResponse, S as SessionResponse } from './schema-C3_USjmu.js';
1
+ export { A as AuthRefreshQuery, b as EntitlementType, E as EntitlementsListResult, a as Enum, R as RefreshResponse, c as ResourceType, S as SessionResponse } from './schema-jwKwV_Bm.js';
package/dist/schema.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,12 +1,39 @@
1
1
  import { CoreClient } from '../client.mjs';
2
- import { R as RefreshResponse, S as SessionResponse } from '../schema-C3_USjmu.mjs';
2
+ import { A as AuthRefreshQuery, R as RefreshResponse, S as SessionResponse } from '../schema-jwKwV_Bm.mjs';
3
3
 
4
4
  declare class AuthService {
5
5
  private core;
6
6
  constructor(core: CoreClient);
7
+ /**
8
+ * POST /v1/auth/logout
9
+ * @summary Logout and invalidate session
10
+ */
7
11
  logout(init?: Omit<RequestInit, 'method' | 'body'>): Promise<unknown>;
8
- refresh(init?: Omit<RequestInit, 'method' | 'body'>): Promise<RefreshResponse>;
12
+ /**
13
+ * @summary Get query keys for logout
14
+ * @returns ['v1/auth/logout']
15
+ */
16
+ logout__queryKeys(): readonly ["v1/auth/logout"];
17
+ /**
18
+ * POST /v1/auth/refresh
19
+ * @summary Refresh session token
20
+ */
21
+ refresh(query?: AuthRefreshQuery, init?: Omit<RequestInit, 'method' | 'body'>): Promise<RefreshResponse>;
22
+ /**
23
+ * @summary Get query keys for refresh
24
+ * @returns ['v1/auth/refresh', query]
25
+ */
26
+ refresh__queryKeys(query?: AuthRefreshQuery): readonly ["v1/auth/refresh", AuthRefreshQuery | undefined];
27
+ /**
28
+ * GET /v1/auth/session
29
+ * @summary Get current session
30
+ */
9
31
  getSession(init?: Omit<RequestInit, 'method' | 'body'>): Promise<SessionResponse>;
32
+ /**
33
+ * @summary Get query keys for getSession
34
+ * @returns ['v1/auth/session']
35
+ */
36
+ getSession__queryKeys(): readonly ["v1/auth/session"];
10
37
  }
11
38
 
12
39
  export { AuthService };
@@ -1,12 +1,39 @@
1
1
  import { CoreClient } from '../client.js';
2
- import { R as RefreshResponse, S as SessionResponse } from '../schema-C3_USjmu.js';
2
+ import { A as AuthRefreshQuery, R as RefreshResponse, S as SessionResponse } from '../schema-jwKwV_Bm.js';
3
3
 
4
4
  declare class AuthService {
5
5
  private core;
6
6
  constructor(core: CoreClient);
7
+ /**
8
+ * POST /v1/auth/logout
9
+ * @summary Logout and invalidate session
10
+ */
7
11
  logout(init?: Omit<RequestInit, 'method' | 'body'>): Promise<unknown>;
8
- refresh(init?: Omit<RequestInit, 'method' | 'body'>): Promise<RefreshResponse>;
12
+ /**
13
+ * @summary Get query keys for logout
14
+ * @returns ['v1/auth/logout']
15
+ */
16
+ logout__queryKeys(): readonly ["v1/auth/logout"];
17
+ /**
18
+ * POST /v1/auth/refresh
19
+ * @summary Refresh session token
20
+ */
21
+ refresh(query?: AuthRefreshQuery, init?: Omit<RequestInit, 'method' | 'body'>): Promise<RefreshResponse>;
22
+ /**
23
+ * @summary Get query keys for refresh
24
+ * @returns ['v1/auth/refresh', query]
25
+ */
26
+ refresh__queryKeys(query?: AuthRefreshQuery): readonly ["v1/auth/refresh", AuthRefreshQuery | undefined];
27
+ /**
28
+ * GET /v1/auth/session
29
+ * @summary Get current session
30
+ */
9
31
  getSession(init?: Omit<RequestInit, 'method' | 'body'>): Promise<SessionResponse>;
32
+ /**
33
+ * @summary Get query keys for getSession
34
+ * @returns ['v1/auth/session']
35
+ */
36
+ getSession__queryKeys(): readonly ["v1/auth/session"];
10
37
  }
11
38
 
12
39
  export { AuthService };
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -37,17 +38,32 @@ var AuthService = class {
37
38
  ...init || {}
38
39
  });
39
40
  }
41
+ /**
42
+ * @summary Get query keys for logout
43
+ * @returns ['v1/auth/logout']
44
+ */
45
+ logout__queryKeys() {
46
+ return ["v1/auth/logout"];
47
+ }
40
48
  /**
41
49
  * POST /v1/auth/refresh
42
50
  * @summary Refresh session token
43
51
  */
44
- refresh(init) {
52
+ refresh(query, init) {
45
53
  return this.core.request({
46
54
  method: "POST",
47
55
  path: `/v1/auth/refresh`,
56
+ query,
48
57
  ...init || {}
49
58
  });
50
59
  }
60
+ /**
61
+ * @summary Get query keys for refresh
62
+ * @returns ['v1/auth/refresh', query]
63
+ */
64
+ refresh__queryKeys(query) {
65
+ return ["v1/auth/refresh", query];
66
+ }
51
67
  /**
52
68
  * GET /v1/auth/session
53
69
  * @summary Get current session
@@ -59,6 +75,13 @@ var AuthService = class {
59
75
  ...init || {}
60
76
  });
61
77
  }
78
+ /**
79
+ * @summary Get query keys for getSession
80
+ * @returns ['v1/auth/session']
81
+ */
82
+ getSession__queryKeys() {
83
+ return ["v1/auth/session"];
84
+ }
62
85
  };
63
86
  // Annotate the CommonJS export names for ESM import in node:
64
87
  0 && (module.exports = {
@@ -1,6 +1,8 @@
1
1
  import {
2
2
  AuthService
3
- } from "../chunk-UTMQXMDQ.mjs";
3
+ } from "../chunk-YGEJFE6U.mjs";
4
+ import "../chunk-ATZGLDGF.mjs";
5
+ import "../chunk-7SBLH5KM.mjs";
4
6
  export {
5
7
  AuthService
6
8
  };
@@ -0,0 +1,21 @@
1
+ import { CoreClient } from '../client.mjs';
2
+ import { E as EntitlementsListResult } from '../schema-jwKwV_Bm.mjs';
3
+
4
+ declare class EntitlementsService {
5
+ private core;
6
+ constructor(core: CoreClient);
7
+ /**
8
+ * GET /v1/client/entitlements/list-for-tenant/{tenantResourceId}
9
+ * @summary List entitlements for a tenant and all its sub-resources
10
+ *
11
+ * @description Returns entitlements for a tenant resource and all its descendant resources for the authenticated user. This endpoint scopes queries to a single tenant, preventing cross-tenant data access. Only evaluates roles and plans (excludes limits). Results are cached per resource for performance. The tenant resource type is automatically determined from the environment definition (resource marked as `is_tenant: true`).
12
+ */
13
+ listForTenant(tenantResourceId: string, init?: Omit<RequestInit, 'method' | 'body'>): Promise<EntitlementsListResult>;
14
+ /**
15
+ * @summary Get query keys for listForTenant
16
+ * @returns ['v1/client/entitlements/list-for-tenant', tenantResourceId]
17
+ */
18
+ listForTenant__queryKeys(tenantResourceId: string): readonly ["v1/client/entitlements/list-for-tenant", string];
19
+ }
20
+
21
+ export { EntitlementsService };
@@ -0,0 +1,21 @@
1
+ import { CoreClient } from '../client.js';
2
+ import { E as EntitlementsListResult } from '../schema-jwKwV_Bm.js';
3
+
4
+ declare class EntitlementsService {
5
+ private core;
6
+ constructor(core: CoreClient);
7
+ /**
8
+ * GET /v1/client/entitlements/list-for-tenant/{tenantResourceId}
9
+ * @summary List entitlements for a tenant and all its sub-resources
10
+ *
11
+ * @description Returns entitlements for a tenant resource and all its descendant resources for the authenticated user. This endpoint scopes queries to a single tenant, preventing cross-tenant data access. Only evaluates roles and plans (excludes limits). Results are cached per resource for performance. The tenant resource type is automatically determined from the environment definition (resource marked as `is_tenant: true`).
12
+ */
13
+ listForTenant(tenantResourceId: string, init?: Omit<RequestInit, 'method' | 'body'>): Promise<EntitlementsListResult>;
14
+ /**
15
+ * @summary Get query keys for listForTenant
16
+ * @returns ['v1/client/entitlements/list-for-tenant', tenantResourceId]
17
+ */
18
+ listForTenant__queryKeys(tenantResourceId: string): readonly ["v1/client/entitlements/list-for-tenant", string];
19
+ }
20
+
21
+ export { EntitlementsService };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/services/entitlements.ts
21
+ var entitlements_exports = {};
22
+ __export(entitlements_exports, {
23
+ EntitlementsService: () => EntitlementsService
24
+ });
25
+ module.exports = __toCommonJS(entitlements_exports);
26
+ var EntitlementsService = class {
27
+ constructor(core) {
28
+ this.core = core;
29
+ }
30
+ /**
31
+ * GET /v1/client/entitlements/list-for-tenant/{tenantResourceId}
32
+ * @summary List entitlements for a tenant and all its sub-resources
33
+ *
34
+ * @description Returns entitlements for a tenant resource and all its descendant resources for the authenticated user. This endpoint scopes queries to a single tenant, preventing cross-tenant data access. Only evaluates roles and plans (excludes limits). Results are cached per resource for performance. The tenant resource type is automatically determined from the environment definition (resource marked as `is_tenant: true`).
35
+ */
36
+ listForTenant(tenantResourceId, init) {
37
+ return this.core.request({
38
+ method: "GET",
39
+ path: `/v1/client/entitlements/list-for-tenant/${encodeURIComponent(tenantResourceId)}`,
40
+ ...init || {}
41
+ });
42
+ }
43
+ /**
44
+ * @summary Get query keys for listForTenant
45
+ * @returns ['v1/client/entitlements/list-for-tenant', tenantResourceId]
46
+ */
47
+ listForTenant__queryKeys(tenantResourceId) {
48
+ return ["v1/client/entitlements/list-for-tenant", tenantResourceId];
49
+ }
50
+ };
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ EntitlementsService
54
+ });
@@ -0,0 +1,8 @@
1
+ import {
2
+ EntitlementsService
3
+ } from "../chunk-ENXZU3RF.mjs";
4
+ import "../chunk-ATZGLDGF.mjs";
5
+ import "../chunk-7SBLH5KM.mjs";
6
+ export {
7
+ EntitlementsService
8
+ };
package/dist/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@blimu/client",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "TypeScript SDK for Blimu API (auto-generated)",
5
- "repository": "https://github.com/blimu/blimu-ts",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/blimu-dev/blimu-ts"
8
+ },
6
9
  "author": "viniciusdacal",
7
10
  "license": "MIT",
8
11
  "publishConfig": {
@@ -61,7 +64,8 @@
61
64
  }
62
65
  },
63
66
  "scripts": {
64
- "build": "tsup src/index.ts src/services/*.ts src/schema.ts src/client.ts src/utils.ts --format cjs,esm --dts",
67
+ "build": "npm run clean && tsup src/index.ts src/services/*.ts src/schema.ts src/client.ts src/utils.ts --format cjs,esm --dts",
68
+ "clean": "rm -rf dist",
65
69
  "typecheck": "tsc -p tsconfig.json --noEmit",
66
70
  "lint": "eslint .",
67
71
  "format": "eslint --fix . && prettier --write .",
@@ -1,23 +0,0 @@
1
- type Enum<T> = T[keyof T];
2
- interface RefreshResponse {
3
- sessionToken: string;
4
- }
5
- interface SessionResponse {
6
- isAuthenticated: boolean;
7
- user: {
8
- email: string;
9
- emailVerified: boolean;
10
- firstName: string | null;
11
- id: string;
12
- lastName: string | null;
13
- } | null;
14
- }
15
-
16
- type schema_Enum<T> = Enum<T>;
17
- type schema_RefreshResponse = RefreshResponse;
18
- type schema_SessionResponse = SessionResponse;
19
- declare namespace schema {
20
- export type { schema_Enum as Enum, schema_RefreshResponse as RefreshResponse, schema_SessionResponse as SessionResponse };
21
- }
22
-
23
- export { type Enum as E, type RefreshResponse as R, type SessionResponse as S, schema as s };
@@ -1,23 +0,0 @@
1
- type Enum<T> = T[keyof T];
2
- interface RefreshResponse {
3
- sessionToken: string;
4
- }
5
- interface SessionResponse {
6
- isAuthenticated: boolean;
7
- user: {
8
- email: string;
9
- emailVerified: boolean;
10
- firstName: string | null;
11
- id: string;
12
- lastName: string | null;
13
- } | null;
14
- }
15
-
16
- type schema_Enum<T> = Enum<T>;
17
- type schema_RefreshResponse = RefreshResponse;
18
- type schema_SessionResponse = SessionResponse;
19
- declare namespace schema {
20
- export type { schema_Enum as Enum, schema_RefreshResponse as RefreshResponse, schema_SessionResponse as SessionResponse };
21
- }
22
-
23
- export { type Enum as E, type RefreshResponse as R, type SessionResponse as S, schema as s };