@blimu/backend 0.7.0 → 1.1.0
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 +129 -134
- package/dist/client.d.mts +24 -0
- package/dist/client.d.ts +15 -57
- package/dist/client.js +67 -157
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +48 -0
- package/dist/client.mjs.map +1 -0
- package/dist/index.d.mts +36 -0
- package/dist/index.d.ts +25 -26
- package/dist/index.js +1037 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1005 -0
- package/dist/index.mjs.map +1 -0
- package/dist/main.d.mts +19 -0
- package/dist/main.d.ts +19 -0
- package/dist/main.js +1273 -0
- package/dist/main.js.map +1 -0
- package/dist/main.mjs +1264 -0
- package/dist/main.mjs.map +1 -0
- package/dist/schema-B1usIXCr.d.mts +424 -0
- package/dist/schema-B1usIXCr.d.ts +424 -0
- package/dist/schema.d.mts +2 -0
- package/dist/schema.d.ts +2 -381
- package/dist/schema.js +17 -2
- package/dist/schema.js.map +1 -1
- package/dist/schema.mjs +1 -0
- package/dist/schema.mjs.map +1 -0
- package/dist/schema.zod-CRNAHxbc.d.mts +444 -0
- package/dist/schema.zod-CRNAHxbc.d.ts +444 -0
- package/dist/schema.zod.d.mts +2 -0
- package/dist/schema.zod.d.ts +2 -0
- package/dist/schema.zod.js +562 -0
- package/dist/schema.zod.js.map +1 -0
- package/dist/schema.zod.mjs +496 -0
- package/dist/schema.zod.mjs.map +1 -0
- package/dist/services/bulk_resources.d.mts +12 -0
- package/dist/services/bulk_resources.d.ts +9 -4
- package/dist/services/bulk_resources.js +45 -18
- package/dist/services/bulk_resources.js.map +1 -1
- package/dist/services/bulk_resources.mjs +22 -0
- package/dist/services/bulk_resources.mjs.map +1 -0
- package/dist/services/bulk_roles.d.mts +12 -0
- package/dist/services/bulk_roles.d.ts +9 -4
- package/dist/services/bulk_roles.js +45 -18
- package/dist/services/bulk_roles.js.map +1 -1
- package/dist/services/bulk_roles.mjs +22 -0
- package/dist/services/bulk_roles.mjs.map +1 -0
- package/dist/services/entitlements.d.mts +14 -0
- package/dist/services/entitlements.d.ts +11 -6
- package/dist/services/entitlements.js +69 -34
- package/dist/services/entitlements.js.map +1 -1
- package/dist/services/entitlements.mjs +46 -0
- package/dist/services/entitlements.mjs.map +1 -0
- package/dist/services/plans.d.mts +14 -0
- package/dist/services/plans.d.ts +11 -6
- package/dist/services/plans.js +67 -32
- package/dist/services/plans.js.map +1 -1
- package/dist/services/plans.mjs +44 -0
- package/dist/services/plans.mjs.map +1 -0
- package/dist/services/resource_members.d.mts +12 -0
- package/dist/services/resource_members.d.ts +9 -4
- package/dist/services/resource_members.js +45 -17
- package/dist/services/resource_members.js.map +1 -1
- package/dist/services/resource_members.mjs +22 -0
- package/dist/services/resource_members.mjs.map +1 -0
- package/dist/services/resources.d.mts +16 -0
- package/dist/services/resources.d.ts +13 -8
- package/dist/services/resources.js +91 -49
- package/dist/services/resources.js.map +1 -1
- package/dist/services/resources.mjs +68 -0
- package/dist/services/resources.mjs.map +1 -0
- package/dist/services/roles.d.mts +14 -0
- package/dist/services/roles.d.ts +11 -6
- package/dist/services/roles.js +68 -33
- package/dist/services/roles.js.map +1 -1
- package/dist/services/roles.mjs +45 -0
- package/dist/services/roles.mjs.map +1 -0
- package/dist/services/usage.d.mts +16 -0
- package/dist/services/usage.d.ts +13 -8
- package/dist/services/usage.js +93 -52
- package/dist/services/usage.js.map +1 -1
- package/dist/services/usage.mjs +70 -0
- package/dist/services/usage.mjs.map +1 -0
- package/dist/services/users.d.mts +17 -0
- package/dist/services/users.d.ts +13 -8
- package/dist/services/users.js +102 -56
- package/dist/services/users.js.map +1 -1
- package/dist/services/users.mjs +79 -0
- package/dist/services/users.mjs.map +1 -0
- package/dist/token-verifier.d.mts +35 -0
- package/dist/token-verifier.d.ts +8 -6
- package/dist/token-verifier.js +225 -172
- package/dist/token-verifier.js.map +1 -1
- package/dist/token-verifier.mjs +201 -0
- package/dist/token-verifier.mjs.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils.d.mts +20 -0
- package/dist/utils.d.ts +7 -3
- package/dist/utils.js +50 -20
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +29 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +37 -62
- package/src/client.ts +74 -0
- package/src/index.ts +55 -0
- package/src/main.ts +3 -0
- package/src/schema.ts +430 -0
- package/src/schema.zod.ts +558 -0
- package/src/services/bulk_resources.ts +24 -0
- package/src/services/bulk_roles.ts +22 -0
- package/src/services/entitlements.ts +58 -0
- package/src/services/plans.ts +57 -0
- package/src/services/resource_members.ts +25 -0
- package/src/services/resources.ts +91 -0
- package/src/services/roles.ts +58 -0
- package/src/services/usage.ts +93 -0
- package/src/services/users.ts +100 -0
- package/src/token-verifier.ts +280 -0
- package/src/utils.ts +56 -0
- package/bin/blimu +0 -0
- package/scripts/download-binary.js +0 -243
- package/scripts/postinstall.js +0 -24
package/dist/index.js
CHANGED
|
@@ -1,88 +1,1042 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
8
|
};
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Blimu: () => Blimu,
|
|
24
|
+
BlimuError: () => BlimuError,
|
|
25
|
+
BulkResourcesService: () => BulkResourcesService,
|
|
26
|
+
BulkRolesService: () => BulkRolesService,
|
|
27
|
+
CoreClient: () => CoreClient,
|
|
28
|
+
EntitlementsService: () => EntitlementsService,
|
|
29
|
+
FetchError: () => import_fetch.FetchError,
|
|
30
|
+
PlansService: () => PlansService,
|
|
31
|
+
ResourceMembersService: () => ResourceMembersService,
|
|
32
|
+
ResourcesService: () => ResourcesService,
|
|
33
|
+
RolesService: () => RolesService,
|
|
34
|
+
Schema: () => schema_exports,
|
|
35
|
+
UsageService: () => UsageService,
|
|
36
|
+
UsersService: () => UsersService,
|
|
37
|
+
ZodSchema: () => schema_zod_exports,
|
|
38
|
+
listAll: () => listAll,
|
|
39
|
+
paginate: () => paginate,
|
|
40
|
+
parseNDJSONStream: () => import_fetch2.parseNDJSONStream,
|
|
41
|
+
parseSSEStream: () => import_fetch2.parseSSEStream
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(index_exports);
|
|
44
|
+
|
|
45
|
+
// src/client.ts
|
|
46
|
+
var import_fetch = require("@blimu/fetch");
|
|
47
|
+
var CoreClient = class extends import_fetch.FetchClient {
|
|
48
|
+
constructor(cfg = {}) {
|
|
49
|
+
const authStrategies = [];
|
|
50
|
+
const { auth: _existingAuth, apiKey, ...restCfg } = cfg;
|
|
51
|
+
if (cfg?.apiKey) {
|
|
52
|
+
const apiKeyValue = cfg.apiKey;
|
|
53
|
+
authStrategies.push({
|
|
54
|
+
type: "apiKey",
|
|
55
|
+
key: () => apiKeyValue,
|
|
56
|
+
location: "header",
|
|
57
|
+
name: "X-API-KEY"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const finalAuthStrategies = [
|
|
61
|
+
..._existingAuth?.strategies || [],
|
|
62
|
+
...authStrategies
|
|
63
|
+
];
|
|
64
|
+
const fetchConfig = {
|
|
65
|
+
...restCfg,
|
|
66
|
+
baseURL: cfg.baseURL ?? "https://api.blimu.dev",
|
|
67
|
+
// Explicitly set auth after restCfg to ensure it's not overwritten
|
|
68
|
+
// (restCfg might have an auth property that we want to replace)
|
|
69
|
+
...finalAuthStrategies.length > 0 ? {
|
|
70
|
+
auth: {
|
|
71
|
+
strategies: finalAuthStrategies
|
|
72
|
+
}
|
|
73
|
+
} : {}
|
|
74
|
+
// Hooks are passed through directly from FetchClientConfig (no mapping needed)
|
|
36
75
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
76
|
+
super(fetchConfig);
|
|
77
|
+
}
|
|
78
|
+
async request(init) {
|
|
79
|
+
return await super.request(init);
|
|
80
|
+
}
|
|
81
|
+
async *requestStream(init) {
|
|
82
|
+
yield* super.requestStream(init);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/services/bulk_resources.ts
|
|
87
|
+
var BulkResourcesService = class {
|
|
88
|
+
constructor(core) {
|
|
89
|
+
this.core = core;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* POST /v1/resources/{resourceType}/bulk*
|
|
93
|
+
* @summary Bulk create resources*
|
|
94
|
+
* @description Creates multiple resources of the specified type in a single request. This operation supports partial success - some resources may be created while others fail. The response includes details about successful creations and any errors encountered. Resources can have parent relationships and initial role assignments.*/
|
|
95
|
+
create(resourceType, body, init) {
|
|
96
|
+
return this.core.request({
|
|
97
|
+
method: "POST",
|
|
98
|
+
path: `/v1/resources/${encodeURIComponent(resourceType)}/bulk`,
|
|
99
|
+
body,
|
|
100
|
+
...init || {}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/services/bulk_roles.ts
|
|
106
|
+
var BulkRolesService = class {
|
|
107
|
+
constructor(core) {
|
|
108
|
+
this.core = core;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* POST /v1/users/roles/bulk*
|
|
112
|
+
* @summary Bulk create roles*
|
|
113
|
+
* @description Assigns multiple roles to users on resources in a single request. This operation supports partial success - some role assignments may succeed while others fail. The response includes details about successful assignments and any errors encountered. All roles must be valid according to your resource definitions.*/
|
|
114
|
+
create(body, init) {
|
|
115
|
+
return this.core.request({
|
|
116
|
+
method: "POST",
|
|
117
|
+
path: `/v1/users/roles/bulk`,
|
|
118
|
+
body,
|
|
119
|
+
...init || {}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// src/services/entitlements.ts
|
|
125
|
+
var EntitlementsService = class {
|
|
126
|
+
constructor(core) {
|
|
127
|
+
this.core = core;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* POST /v1/entitlements/check*
|
|
131
|
+
* @summary Check if a user has a specific entitlement on a resource*
|
|
132
|
+
* @description Checks whether a user has permission to perform a specific action (entitlement) on a resource. This endpoint evaluates role-based access, plan gating, and usage limits. The response includes detailed information about why access was granted or denied, including which roles were checked, plan requirements, and usage limit status.*/
|
|
133
|
+
checkEntitlement(body, init) {
|
|
134
|
+
return this.core.request({
|
|
135
|
+
method: "POST",
|
|
136
|
+
path: `/v1/entitlements/check`,
|
|
137
|
+
body,
|
|
138
|
+
...init || {}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* GET /v1/entitlements/list-for-resource/{resourceType}/{resourceId}*
|
|
143
|
+
* @summary List entitlements for a specific resource*
|
|
144
|
+
* @description Returns entitlements for a specific resource and user. Only evaluates roles and plans (excludes limits). Provides detailed information about why entitlements are allowed or denied, including current roles, allowed roles, current plan, and allowed plans. Results are cached per resource for performance.*/
|
|
145
|
+
listForResource(resourceType, resourceId, query, init) {
|
|
146
|
+
return this.core.request({
|
|
147
|
+
method: "GET",
|
|
148
|
+
path: `/v1/entitlements/list-for-resource/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,
|
|
149
|
+
query,
|
|
150
|
+
...init || {}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* GET /v1/entitlements/list-for-tenant/{tenantResourceId}*
|
|
155
|
+
* @summary List entitlements for a tenant and all its sub-resources*
|
|
156
|
+
* @description Returns entitlements for a tenant resource and all its descendant resources. This endpoint scopes queries to a single tenant, preventing cross-tenant data access. Only evaluates roles and plans (excludes limits). Results are cached per resource for performance. The tenant resource type is automatically determined from the environment definition (resource marked as `is_tenant: true`).*/
|
|
157
|
+
listForTenant(tenantResourceId, query, init) {
|
|
158
|
+
return this.core.request({
|
|
159
|
+
method: "GET",
|
|
160
|
+
path: `/v1/entitlements/list-for-tenant/${encodeURIComponent(tenantResourceId)}`,
|
|
161
|
+
query,
|
|
162
|
+
...init || {}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// src/services/plans.ts
|
|
168
|
+
var PlansService = class {
|
|
169
|
+
constructor(core) {
|
|
170
|
+
this.core = core;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* DELETE /v1/resources/{resourceType}/{resourceId}/plan*
|
|
174
|
+
* @summary Remove plan assignment from a tenant resource*
|
|
175
|
+
* @description Removes the billing plan assignment from a tenant resource. After removal, the resource will have no plan and will be subject to default limits.*/
|
|
176
|
+
delete(resourceType, resourceId, init) {
|
|
177
|
+
return this.core.request({
|
|
178
|
+
method: "DELETE",
|
|
179
|
+
path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/plan`,
|
|
180
|
+
...init || {}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* GET /v1/resources/{resourceType}/{resourceId}/plan*
|
|
185
|
+
* @summary Get the plan assigned to a tenant resource*
|
|
186
|
+
* @description Retrieves the billing plan currently assigned to a tenant resource, if any.*/
|
|
187
|
+
read(resourceType, resourceId, init) {
|
|
188
|
+
return this.core.request({
|
|
189
|
+
method: "GET",
|
|
190
|
+
path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/plan`,
|
|
191
|
+
...init || {}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* POST /v1/resources/{resourceType}/{resourceId}/plan*
|
|
196
|
+
* @summary Assign a plan to a tenant resource*
|
|
197
|
+
* @description Assigns a billing plan to a tenant resource. Plans control feature access and usage limits based on your plan definitions. The resource must be marked as a tenant in your resource definitions.*/
|
|
198
|
+
assign(resourceType, resourceId, body, init) {
|
|
199
|
+
return this.core.request({
|
|
200
|
+
method: "POST",
|
|
201
|
+
path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/plan`,
|
|
202
|
+
body,
|
|
203
|
+
...init || {}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// src/services/resource_members.ts
|
|
209
|
+
var ResourceMembersService = class {
|
|
210
|
+
constructor(core) {
|
|
211
|
+
this.core = core;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* GET /v1/resources/{resourceType}/{resourceId}/members*
|
|
215
|
+
* @summary List members for a resource*
|
|
216
|
+
* @description Retrieves a paginated list of users who have roles (direct or inherited) on the specified resource. Supports search functionality to filter users by email or name.*/
|
|
217
|
+
list(resourceType, resourceId, query, init) {
|
|
218
|
+
return this.core.request({
|
|
219
|
+
method: "GET",
|
|
220
|
+
path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/members`,
|
|
221
|
+
query,
|
|
222
|
+
...init || {}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// src/services/resources.ts
|
|
228
|
+
var ResourcesService = class {
|
|
229
|
+
constructor(core) {
|
|
230
|
+
this.core = core;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* GET /v1/resources/{resourceType}*
|
|
234
|
+
* @summary List resources*
|
|
235
|
+
* @description Retrieves a paginated list of resources of the specified type. Supports search and filtering. Resources are returned with their parent relationships and metadata.*/
|
|
236
|
+
list(resourceType, query, init) {
|
|
237
|
+
return this.core.request({
|
|
238
|
+
method: "GET",
|
|
239
|
+
path: `/v1/resources/${encodeURIComponent(resourceType)}`,
|
|
240
|
+
query,
|
|
241
|
+
...init || {}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* POST /v1/resources/{resourceType}*
|
|
246
|
+
* @summary Create a resource*
|
|
247
|
+
* @description Creates a new resource of the specified type. Resources can have parent relationships to form hierarchies. You can optionally assign initial roles to users when creating the resource. Parent resources must already exist.*/
|
|
248
|
+
create(resourceType, body, init) {
|
|
249
|
+
return this.core.request({
|
|
250
|
+
method: "POST",
|
|
251
|
+
path: `/v1/resources/${encodeURIComponent(resourceType)}`,
|
|
252
|
+
body,
|
|
253
|
+
...init || {}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* DELETE /v1/resources/{resourceType}/{resourceId}*
|
|
258
|
+
* @summary Delete a resource*
|
|
259
|
+
* @description Deletes a resource by its type and ID. This operation is permanent and cannot be undone. Deleting a resource may affect child resources that depend on it.*/
|
|
260
|
+
delete(resourceType, resourceId, init) {
|
|
261
|
+
return this.core.request({
|
|
262
|
+
method: "DELETE",
|
|
263
|
+
path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,
|
|
264
|
+
...init || {}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* GET /v1/resources/{resourceType}/{resourceId}*
|
|
269
|
+
* @summary Read a resource*
|
|
270
|
+
* @description Retrieves a single resource by its type and ID. Returns the resource with its parent relationships and metadata.*/
|
|
271
|
+
read(resourceType, resourceId, init) {
|
|
272
|
+
return this.core.request({
|
|
273
|
+
method: "GET",
|
|
274
|
+
path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,
|
|
275
|
+
...init || {}
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* PUT /v1/resources/{resourceType}/{resourceId}*
|
|
280
|
+
* @summary Update a resource*
|
|
281
|
+
* @description Updates an existing resource. You can update the resource name and modify parent relationships. Parent resources must already exist.*/
|
|
282
|
+
update(resourceType, resourceId, body, init) {
|
|
283
|
+
return this.core.request({
|
|
284
|
+
method: "PUT",
|
|
285
|
+
path: `/v1/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,
|
|
286
|
+
body,
|
|
287
|
+
...init || {}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// src/services/roles.ts
|
|
293
|
+
var RolesService = class {
|
|
294
|
+
constructor(core) {
|
|
295
|
+
this.core = core;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* GET /v1/users/{userId}/roles*
|
|
299
|
+
* @summary List user roles*
|
|
300
|
+
* @description Retrieves a paginated list of roles assigned to a user. Supports filtering by resource type, resource ID, and role name. Returns both directly assigned roles and inherited roles.*/
|
|
301
|
+
list(userId, query, init) {
|
|
302
|
+
return this.core.request({
|
|
303
|
+
method: "GET",
|
|
304
|
+
path: `/v1/users/${encodeURIComponent(userId)}/roles`,
|
|
305
|
+
query,
|
|
306
|
+
...init || {}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* POST /v1/users/{userId}/roles*
|
|
311
|
+
* @summary Create a role (assign role to user on resource)*
|
|
312
|
+
* @description Assigns a role to a user on a specific resource. The role must be defined in your resource definitions for the specified resource type. Roles can be inherited from parent resources based on your resource configuration.*/
|
|
313
|
+
create(userId, body, init) {
|
|
314
|
+
return this.core.request({
|
|
315
|
+
method: "POST",
|
|
316
|
+
path: `/v1/users/${encodeURIComponent(userId)}/roles`,
|
|
317
|
+
body,
|
|
318
|
+
...init || {}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* DELETE /v1/users/{userId}/roles/{resourceType}/{resourceId}*
|
|
323
|
+
* @summary Delete a role*
|
|
324
|
+
* @description Removes a role assignment from a user on a specific resource. This only removes the direct role assignment and does not affect inherited roles from parent resources.*/
|
|
325
|
+
delete(userId, resourceType, resourceId, init) {
|
|
326
|
+
return this.core.request({
|
|
327
|
+
method: "DELETE",
|
|
328
|
+
path: `/v1/users/${encodeURIComponent(userId)}/roles/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,
|
|
329
|
+
...init || {}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// src/services/usage.ts
|
|
335
|
+
var UsageService = class {
|
|
336
|
+
constructor(core) {
|
|
337
|
+
this.core = core;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* GET /v1/usage/balance/{resourceType}/{resourceId}/{limitType}*
|
|
341
|
+
* @summary Get wallet balance*
|
|
342
|
+
* @description Retrieves the current balance of a usage wallet for a specific resource and limit type within a given time period. The balance reflects all credits and consumption transactions.*/
|
|
343
|
+
getBalance(resourceType, resourceId, limitType, query, init) {
|
|
344
|
+
return this.core.request({
|
|
345
|
+
method: "GET",
|
|
346
|
+
path: `/v1/usage/balance/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/${encodeURIComponent(limitType)}`,
|
|
347
|
+
query,
|
|
348
|
+
...init || {}
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* POST /v1/usage/check*
|
|
353
|
+
* @summary Check if consumption is allowed*
|
|
354
|
+
* @description Checks whether a specific amount of consumption is allowed for a resource and limit type within a given time period. Returns the current balance, requested amount, and remaining balance after the consumption.*/
|
|
355
|
+
checkLimit(body, init) {
|
|
356
|
+
return this.core.request({
|
|
357
|
+
method: "POST",
|
|
358
|
+
path: `/v1/usage/check`,
|
|
359
|
+
body,
|
|
360
|
+
...init || {}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* POST /v1/usage/consume*
|
|
365
|
+
* @summary Record consumption (inserts negative amount)*
|
|
366
|
+
* @description Records consumption from a usage wallet for a specific resource and limit type. This decreases the available balance. Consumption can be tagged for tracking purposes.*/
|
|
367
|
+
consume(body, init) {
|
|
368
|
+
return this.core.request({
|
|
369
|
+
method: "POST",
|
|
370
|
+
path: `/v1/usage/consume`,
|
|
371
|
+
body,
|
|
372
|
+
...init || {}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* POST /v1/usage/credit*
|
|
377
|
+
* @summary Add credits to wallet (inserts positive amount)*
|
|
378
|
+
* @description Adds credits to a usage wallet for a specific resource and limit type. This increases the available balance for usage-based limits. Credits can be tagged for tracking purposes.*/
|
|
379
|
+
credit(body, init) {
|
|
380
|
+
return this.core.request({
|
|
381
|
+
method: "POST",
|
|
382
|
+
path: `/v1/usage/credit`,
|
|
383
|
+
body,
|
|
384
|
+
...init || {}
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* GET /v1/usage/transactions/{resourceType}/{resourceId}/{limitType}*
|
|
389
|
+
* @summary Get transaction history*
|
|
390
|
+
* @description Retrieves the transaction history for a usage wallet, including all credits and consumption records. Supports filtering by time period and date range.*/
|
|
391
|
+
getTransactionHistory(resourceType, resourceId, limitType, query, init) {
|
|
392
|
+
return this.core.request({
|
|
393
|
+
method: "GET",
|
|
394
|
+
path: `/v1/usage/transactions/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/${encodeURIComponent(limitType)}`,
|
|
395
|
+
query,
|
|
396
|
+
...init || {}
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// src/services/users.ts
|
|
402
|
+
var UsersService = class {
|
|
403
|
+
constructor(core) {
|
|
404
|
+
this.core = core;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* GET /v1/users*
|
|
408
|
+
* @summary List users*
|
|
409
|
+
* @description Retrieves a paginated list of users in your environment. Supports search functionality to filter users by email, name, or lookup key.*/
|
|
410
|
+
list(query, init) {
|
|
411
|
+
return this.core.request({
|
|
412
|
+
method: "GET",
|
|
413
|
+
path: `/v1/users`,
|
|
414
|
+
query,
|
|
415
|
+
...init || {}
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* POST /v1/users*
|
|
420
|
+
* @summary Create a user*
|
|
421
|
+
* @description Creates a new user in your environment. The lookupKey is a unique identifier that you can use to reference the user in your system. It should be stable and not change over time.*/
|
|
422
|
+
create(body, init) {
|
|
423
|
+
return this.core.request({
|
|
424
|
+
method: "POST",
|
|
425
|
+
path: `/v1/users`,
|
|
426
|
+
body,
|
|
427
|
+
...init || {}
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* DELETE /v1/users/{userId}*
|
|
432
|
+
* @summary Delete a user*
|
|
433
|
+
* @description Deletes a user by their ID or lookup key. This operation is permanent and cannot be undone. Deleting a user will also remove all role assignments for that user.*/
|
|
434
|
+
delete(userId, init) {
|
|
435
|
+
return this.core.request({
|
|
436
|
+
method: "DELETE",
|
|
437
|
+
path: `/v1/users/${encodeURIComponent(userId)}`,
|
|
438
|
+
...init || {}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* GET /v1/users/{userId}*
|
|
443
|
+
* @summary Get a user by ID*
|
|
444
|
+
* @description Retrieves a single user by their ID or lookup key. Returns user information including email, name, and metadata.*/
|
|
445
|
+
read(userId, init) {
|
|
446
|
+
return this.core.request({
|
|
447
|
+
method: "GET",
|
|
448
|
+
path: `/v1/users/${encodeURIComponent(userId)}`,
|
|
449
|
+
...init || {}
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* PUT /v1/users/{userId}*
|
|
454
|
+
* @summary Update a user*
|
|
455
|
+
* @description Updates an existing user. You can modify email, name, and other user properties. The lookupKey can be updated but should remain stable.*/
|
|
456
|
+
update(userId, body, init) {
|
|
457
|
+
return this.core.request({
|
|
458
|
+
method: "PUT",
|
|
459
|
+
path: `/v1/users/${encodeURIComponent(userId)}`,
|
|
460
|
+
body,
|
|
461
|
+
...init || {}
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* GET /v1/users/{userId}/effective-user-resources-roles*
|
|
466
|
+
* @summary List effective user resources roles*
|
|
467
|
+
* @description Retrieves all resources and roles for a user, including inherited roles from parent resources. The response indicates whether each role is directly assigned or inherited through resource hierarchies.*/
|
|
468
|
+
listEffectiveUserResourcesRoles(userId, init) {
|
|
469
|
+
return this.core.request({
|
|
470
|
+
method: "GET",
|
|
471
|
+
path: `/v1/users/${encodeURIComponent(userId)}/effective-user-resources-roles`,
|
|
472
|
+
...init || {}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
// src/index.ts
|
|
478
|
+
__reExport(index_exports, require("@blimu/fetch"), module.exports);
|
|
479
|
+
|
|
480
|
+
// src/utils.ts
|
|
481
|
+
var import_fetch2 = require("@blimu/fetch");
|
|
482
|
+
async function* paginate(fetchPage, initialQuery = {}, pageSize = 100) {
|
|
483
|
+
let offset = Number(initialQuery.offset ?? 0);
|
|
484
|
+
const limit = Number(initialQuery.limit ?? pageSize);
|
|
485
|
+
const baseQuery = { ...initialQuery };
|
|
486
|
+
while (true) {
|
|
487
|
+
const page = await fetchPage({ ...baseQuery, limit, offset });
|
|
488
|
+
const items = page.data ?? [];
|
|
489
|
+
for (const item of items) {
|
|
490
|
+
yield item;
|
|
63
491
|
}
|
|
492
|
+
if (!page.hasMore || items.length < limit) break;
|
|
493
|
+
offset += limit;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
async function listAll(fetchPage, query = {}, pageSize = 100) {
|
|
497
|
+
const out = [];
|
|
498
|
+
for await (const item of paginate(fetchPage, query, pageSize))
|
|
499
|
+
out.push(item);
|
|
500
|
+
return out;
|
|
64
501
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
502
|
+
|
|
503
|
+
// src/schema.ts
|
|
504
|
+
var schema_exports = {};
|
|
505
|
+
|
|
506
|
+
// src/schema.zod.ts
|
|
507
|
+
var schema_zod_exports = {};
|
|
508
|
+
__export(schema_zod_exports, {
|
|
509
|
+
BalanceResponseSchema: () => BalanceResponseSchema,
|
|
510
|
+
CheckLimitResponseSchema: () => CheckLimitResponseSchema,
|
|
511
|
+
EntitlementCheckBodySchema: () => EntitlementCheckBodySchema,
|
|
512
|
+
EntitlementCheckResultSchema: () => EntitlementCheckResultSchema,
|
|
513
|
+
EntitlementTypeSchema: () => EntitlementTypeSchema,
|
|
514
|
+
EntitlementsListForResourceQuerySchema: () => EntitlementsListForResourceQuerySchema,
|
|
515
|
+
EntitlementsListForTenantQuerySchema: () => EntitlementsListForTenantQuerySchema,
|
|
516
|
+
EntitlementsListResultSchema: () => EntitlementsListResultSchema,
|
|
517
|
+
LimitTypeSchema: () => LimitTypeSchema,
|
|
518
|
+
PlanAssignBodySchema: () => PlanAssignBodySchema,
|
|
519
|
+
PlanDeleteResponseSchema: () => PlanDeleteResponseSchema,
|
|
520
|
+
PlanResponseSchema: () => PlanResponseSchema,
|
|
521
|
+
PlanTypeSchema: () => PlanTypeSchema,
|
|
522
|
+
ResourceBulkCreateBodySchema: () => ResourceBulkCreateBodySchema,
|
|
523
|
+
ResourceBulkResultSchema: () => ResourceBulkResultSchema,
|
|
524
|
+
ResourceCreateBodySchema: () => ResourceCreateBodySchema,
|
|
525
|
+
ResourceListSchema: () => ResourceListSchema,
|
|
526
|
+
ResourceMemberListSchema: () => ResourceMemberListSchema,
|
|
527
|
+
ResourceMembersListQuerySchema: () => ResourceMembersListQuerySchema,
|
|
528
|
+
ResourceSchema: () => ResourceSchema,
|
|
529
|
+
ResourceTypeSchema: () => ResourceTypeSchema,
|
|
530
|
+
ResourceUpdateBodySchema: () => ResourceUpdateBodySchema,
|
|
531
|
+
ResourcesListQuerySchema: () => ResourcesListQuerySchema,
|
|
532
|
+
RoleBulkCreateBodySchema: () => RoleBulkCreateBodySchema,
|
|
533
|
+
RoleBulkResultSchema: () => RoleBulkResultSchema,
|
|
534
|
+
RoleCreateBodySchema: () => RoleCreateBodySchema,
|
|
535
|
+
RoleListSchema: () => RoleListSchema,
|
|
536
|
+
RoleSchema: () => RoleSchema,
|
|
537
|
+
RolesListQuerySchema: () => RolesListQuerySchema,
|
|
538
|
+
TransactionHistoryResponseSchema: () => TransactionHistoryResponseSchema,
|
|
539
|
+
UsageCheckBodySchema: () => UsageCheckBodySchema,
|
|
540
|
+
UsageConsumeBodySchema: () => UsageConsumeBodySchema,
|
|
541
|
+
UsageCreditBodySchema: () => UsageCreditBodySchema,
|
|
542
|
+
UsageGetBalanceQuerySchema: () => UsageGetBalanceQuerySchema,
|
|
543
|
+
UsageGetTransactionHistoryQuerySchema: () => UsageGetTransactionHistoryQuerySchema,
|
|
544
|
+
UsageLimitTypeSchema: () => UsageLimitTypeSchema,
|
|
545
|
+
UsageWalletResponseSchema: () => UsageWalletResponseSchema,
|
|
546
|
+
UserCreateBodySchema: () => UserCreateBodySchema,
|
|
547
|
+
UserListSchema: () => UserListSchema,
|
|
548
|
+
UserResourceListSchema: () => UserResourceListSchema,
|
|
549
|
+
UserSchema: () => UserSchema,
|
|
550
|
+
UserUpdateBodySchema: () => UserUpdateBodySchema,
|
|
551
|
+
UsersListQuerySchema: () => UsersListQuerySchema
|
|
552
|
+
});
|
|
553
|
+
var import_zod = require("zod");
|
|
554
|
+
var EntitlementTypeSchema = import_zod.z.string();
|
|
555
|
+
var LimitTypeSchema = import_zod.z.string();
|
|
556
|
+
var PlanTypeSchema = import_zod.z.string();
|
|
557
|
+
var ResourceTypeSchema = import_zod.z.string();
|
|
558
|
+
var UsageLimitTypeSchema = import_zod.z.string();
|
|
559
|
+
var BalanceResponseSchema = import_zod.z.object({ balance: import_zod.z.number() });
|
|
560
|
+
var CheckLimitResponseSchema = import_zod.z.object({
|
|
561
|
+
allowed: import_zod.z.boolean(),
|
|
562
|
+
current: import_zod.z.number(),
|
|
563
|
+
remaining: import_zod.z.number().optional(),
|
|
564
|
+
requested: import_zod.z.number()
|
|
565
|
+
});
|
|
566
|
+
var EntitlementCheckBodySchema = import_zod.z.object({
|
|
567
|
+
amount: import_zod.z.number().int().optional(),
|
|
568
|
+
entitlement: EntitlementTypeSchema,
|
|
569
|
+
resourceId: import_zod.z.string(),
|
|
570
|
+
userId: import_zod.z.string()
|
|
571
|
+
});
|
|
572
|
+
var EntitlementCheckResultSchema = import_zod.z.object({
|
|
573
|
+
allowed: import_zod.z.boolean(),
|
|
574
|
+
limit: import_zod.z.object({
|
|
575
|
+
allowed: import_zod.z.boolean(),
|
|
576
|
+
current: import_zod.z.number().optional(),
|
|
577
|
+
limit: import_zod.z.number().optional(),
|
|
578
|
+
plan: import_zod.z.string().nullable().optional(),
|
|
579
|
+
reason: import_zod.z.string().optional(),
|
|
580
|
+
remaining: import_zod.z.number().optional(),
|
|
581
|
+
scope: import_zod.z.string().optional()
|
|
582
|
+
}).nullable().optional(),
|
|
583
|
+
plans: import_zod.z.object({
|
|
584
|
+
allowed: import_zod.z.boolean(),
|
|
585
|
+
allowedPlans: import_zod.z.array(import_zod.z.string()).optional(),
|
|
586
|
+
plan: import_zod.z.string().nullable().optional(),
|
|
587
|
+
reason: import_zod.z.string().optional()
|
|
588
|
+
}).nullable().optional(),
|
|
589
|
+
roles: import_zod.z.object({
|
|
590
|
+
allowed: import_zod.z.boolean(),
|
|
591
|
+
allowedRoles: import_zod.z.array(import_zod.z.string()).optional(),
|
|
592
|
+
reason: import_zod.z.string().optional(),
|
|
593
|
+
userRoles: import_zod.z.array(import_zod.z.string()).optional()
|
|
594
|
+
}).nullable().optional()
|
|
595
|
+
});
|
|
596
|
+
var EntitlementsListResultSchema = import_zod.z.object({
|
|
597
|
+
results: import_zod.z.array(
|
|
598
|
+
import_zod.z.object({
|
|
599
|
+
entitlements: import_zod.z.array(
|
|
600
|
+
import_zod.z.object({
|
|
601
|
+
allowed: import_zod.z.boolean(),
|
|
602
|
+
allowedByPlan: import_zod.z.boolean(),
|
|
603
|
+
allowedByRole: import_zod.z.boolean(),
|
|
604
|
+
allowedPlans: import_zod.z.array(import_zod.z.string()).optional(),
|
|
605
|
+
allowedRoles: import_zod.z.array(import_zod.z.string()),
|
|
606
|
+
currentPlan: import_zod.z.string().optional(),
|
|
607
|
+
currentRole: import_zod.z.string().optional(),
|
|
608
|
+
entitlement: EntitlementTypeSchema
|
|
609
|
+
})
|
|
610
|
+
),
|
|
611
|
+
resourceId: import_zod.z.string(),
|
|
612
|
+
resourceType: ResourceTypeSchema
|
|
613
|
+
})
|
|
614
|
+
)
|
|
615
|
+
});
|
|
616
|
+
var PlanAssignBodySchema = import_zod.z.object({ planKey: PlanTypeSchema });
|
|
617
|
+
var PlanDeleteResponseSchema = import_zod.z.object({ success: import_zod.z.boolean() });
|
|
618
|
+
var PlanResponseSchema = import_zod.z.object({
|
|
619
|
+
createdAt: import_zod.z.string().datetime(),
|
|
620
|
+
environmentId: import_zod.z.string(),
|
|
621
|
+
planKey: PlanTypeSchema,
|
|
622
|
+
resourceId: import_zod.z.string(),
|
|
623
|
+
resourceType: ResourceTypeSchema,
|
|
624
|
+
updatedAt: import_zod.z.string().datetime()
|
|
625
|
+
});
|
|
626
|
+
var ResourceSchema = import_zod.z.object({
|
|
627
|
+
createdAt: import_zod.z.string().datetime(),
|
|
628
|
+
id: import_zod.z.string(),
|
|
629
|
+
name: import_zod.z.string().nullable(),
|
|
630
|
+
parents: import_zod.z.array(
|
|
631
|
+
import_zod.z.object({
|
|
632
|
+
id: import_zod.z.string(),
|
|
633
|
+
type: ResourceTypeSchema
|
|
634
|
+
})
|
|
635
|
+
).optional(),
|
|
636
|
+
type: ResourceTypeSchema
|
|
637
|
+
});
|
|
638
|
+
var ResourceBulkCreateBodySchema = import_zod.z.object({
|
|
639
|
+
resources: import_zod.z.array(
|
|
640
|
+
import_zod.z.object({
|
|
641
|
+
id: import_zod.z.string().optional(),
|
|
642
|
+
name: import_zod.z.string().optional(),
|
|
643
|
+
parents: import_zod.z.array(
|
|
644
|
+
import_zod.z.object({
|
|
645
|
+
id: import_zod.z.string(),
|
|
646
|
+
type: ResourceTypeSchema
|
|
647
|
+
})
|
|
648
|
+
).optional(),
|
|
649
|
+
roles: import_zod.z.array(
|
|
650
|
+
import_zod.z.object({
|
|
651
|
+
role: import_zod.z.string(),
|
|
652
|
+
userId: import_zod.z.string()
|
|
653
|
+
})
|
|
654
|
+
).optional()
|
|
655
|
+
})
|
|
656
|
+
)
|
|
657
|
+
});
|
|
658
|
+
var ResourceBulkResultSchema = import_zod.z.object({
|
|
659
|
+
created: import_zod.z.array(
|
|
660
|
+
import_zod.z.object({
|
|
661
|
+
environmentId: import_zod.z.string(),
|
|
662
|
+
id: import_zod.z.string(),
|
|
663
|
+
type: ResourceTypeSchema
|
|
664
|
+
})
|
|
665
|
+
),
|
|
666
|
+
errors: import_zod.z.array(
|
|
667
|
+
import_zod.z.object({
|
|
668
|
+
error: import_zod.z.string(),
|
|
669
|
+
index: import_zod.z.number(),
|
|
670
|
+
resource: import_zod.z.object({
|
|
671
|
+
id: import_zod.z.string().optional(),
|
|
672
|
+
name: import_zod.z.string().optional(),
|
|
673
|
+
parents: import_zod.z.array(
|
|
674
|
+
import_zod.z.object({
|
|
675
|
+
id: import_zod.z.string(),
|
|
676
|
+
type: ResourceTypeSchema
|
|
677
|
+
})
|
|
678
|
+
).optional(),
|
|
679
|
+
roles: import_zod.z.array(
|
|
680
|
+
import_zod.z.object({
|
|
681
|
+
role: import_zod.z.string(),
|
|
682
|
+
userId: import_zod.z.string()
|
|
683
|
+
})
|
|
684
|
+
).optional()
|
|
685
|
+
})
|
|
686
|
+
})
|
|
687
|
+
),
|
|
688
|
+
success: import_zod.z.boolean(),
|
|
689
|
+
summary: import_zod.z.object({
|
|
690
|
+
failed: import_zod.z.number(),
|
|
691
|
+
successful: import_zod.z.number(),
|
|
692
|
+
total: import_zod.z.number()
|
|
693
|
+
})
|
|
694
|
+
});
|
|
695
|
+
var ResourceCreateBodySchema = import_zod.z.object({
|
|
696
|
+
id: import_zod.z.string().optional(),
|
|
697
|
+
name: import_zod.z.string().optional(),
|
|
698
|
+
parents: import_zod.z.array(
|
|
699
|
+
import_zod.z.object({
|
|
700
|
+
id: import_zod.z.string(),
|
|
701
|
+
type: ResourceTypeSchema
|
|
702
|
+
})
|
|
703
|
+
).optional(),
|
|
704
|
+
roles: import_zod.z.array(
|
|
705
|
+
import_zod.z.object({
|
|
706
|
+
role: import_zod.z.string(),
|
|
707
|
+
userId: import_zod.z.string()
|
|
708
|
+
})
|
|
709
|
+
).optional()
|
|
710
|
+
});
|
|
711
|
+
var ResourceListSchema = import_zod.z.object({
|
|
712
|
+
items: import_zod.z.array(
|
|
713
|
+
import_zod.z.object({
|
|
714
|
+
createdAt: import_zod.z.string().datetime(),
|
|
715
|
+
id: import_zod.z.string(),
|
|
716
|
+
name: import_zod.z.string().nullable(),
|
|
717
|
+
parents: import_zod.z.array(
|
|
718
|
+
import_zod.z.object({
|
|
719
|
+
id: import_zod.z.string(),
|
|
720
|
+
type: ResourceTypeSchema
|
|
721
|
+
})
|
|
722
|
+
).optional(),
|
|
723
|
+
type: ResourceTypeSchema
|
|
724
|
+
})
|
|
725
|
+
),
|
|
726
|
+
limit: import_zod.z.number(),
|
|
727
|
+
page: import_zod.z.number(),
|
|
728
|
+
total: import_zod.z.number()
|
|
729
|
+
});
|
|
730
|
+
var ResourceMemberListSchema = import_zod.z.object({
|
|
731
|
+
items: import_zod.z.array(
|
|
732
|
+
import_zod.z.object({
|
|
733
|
+
inherited: import_zod.z.boolean(),
|
|
734
|
+
role: import_zod.z.string(),
|
|
735
|
+
user: import_zod.z.object({
|
|
736
|
+
avatarUrl: import_zod.z.string().nullable(),
|
|
737
|
+
createdAt: import_zod.z.string().datetime(),
|
|
738
|
+
email: import_zod.z.string().email(),
|
|
739
|
+
emailVerified: import_zod.z.boolean(),
|
|
740
|
+
firstName: import_zod.z.string().nullable(),
|
|
741
|
+
id: import_zod.z.string(),
|
|
742
|
+
lastLoginAt: import_zod.z.string().datetime().nullable(),
|
|
743
|
+
lastName: import_zod.z.string().nullable(),
|
|
744
|
+
lookupKey: import_zod.z.string().nullable(),
|
|
745
|
+
updatedAt: import_zod.z.string().datetime()
|
|
746
|
+
}),
|
|
747
|
+
userId: import_zod.z.string()
|
|
748
|
+
})
|
|
749
|
+
),
|
|
750
|
+
limit: import_zod.z.number(),
|
|
751
|
+
page: import_zod.z.number(),
|
|
752
|
+
total: import_zod.z.number()
|
|
753
|
+
});
|
|
754
|
+
var ResourceUpdateBodySchema = import_zod.z.object({
|
|
755
|
+
name: import_zod.z.string().optional(),
|
|
756
|
+
/** Creates relationships with other resources. Parent resources must already exist. */
|
|
757
|
+
parents: import_zod.z.array(
|
|
758
|
+
import_zod.z.object({
|
|
759
|
+
id: import_zod.z.string(),
|
|
760
|
+
type: ResourceTypeSchema
|
|
761
|
+
})
|
|
762
|
+
).optional()
|
|
763
|
+
});
|
|
764
|
+
var RoleSchema = import_zod.z.object({
|
|
765
|
+
createdAt: import_zod.z.string(),
|
|
766
|
+
environmentId: import_zod.z.string(),
|
|
767
|
+
resourceId: import_zod.z.string(),
|
|
768
|
+
resourceType: ResourceTypeSchema,
|
|
769
|
+
role: import_zod.z.string(),
|
|
770
|
+
userId: import_zod.z.string()
|
|
771
|
+
});
|
|
772
|
+
var RoleBulkCreateBodySchema = import_zod.z.object({
|
|
773
|
+
roles: import_zod.z.array(
|
|
774
|
+
import_zod.z.object({
|
|
775
|
+
resourceId: import_zod.z.string(),
|
|
776
|
+
resourceType: ResourceTypeSchema,
|
|
777
|
+
role: import_zod.z.string(),
|
|
778
|
+
userId: import_zod.z.string()
|
|
779
|
+
})
|
|
780
|
+
)
|
|
781
|
+
});
|
|
782
|
+
var RoleBulkResultSchema = import_zod.z.object({
|
|
783
|
+
created: import_zod.z.array(
|
|
784
|
+
import_zod.z.object({
|
|
785
|
+
createdAt: import_zod.z.string(),
|
|
786
|
+
environmentId: import_zod.z.string(),
|
|
787
|
+
resourceId: import_zod.z.string(),
|
|
788
|
+
resourceType: ResourceTypeSchema,
|
|
789
|
+
role: import_zod.z.string(),
|
|
790
|
+
userId: import_zod.z.string()
|
|
791
|
+
})
|
|
792
|
+
),
|
|
793
|
+
errors: import_zod.z.array(
|
|
794
|
+
import_zod.z.object({
|
|
795
|
+
error: import_zod.z.string(),
|
|
796
|
+
index: import_zod.z.number(),
|
|
797
|
+
role: import_zod.z.object({
|
|
798
|
+
resourceId: import_zod.z.string(),
|
|
799
|
+
resourceType: ResourceTypeSchema,
|
|
800
|
+
role: import_zod.z.string(),
|
|
801
|
+
userId: import_zod.z.string()
|
|
802
|
+
})
|
|
803
|
+
})
|
|
804
|
+
),
|
|
805
|
+
success: import_zod.z.boolean(),
|
|
806
|
+
summary: import_zod.z.object({
|
|
807
|
+
failed: import_zod.z.number(),
|
|
808
|
+
successful: import_zod.z.number(),
|
|
809
|
+
total: import_zod.z.number()
|
|
810
|
+
})
|
|
811
|
+
});
|
|
812
|
+
var RoleCreateBodySchema = import_zod.z.object({
|
|
813
|
+
resourceId: import_zod.z.string(),
|
|
814
|
+
resourceType: ResourceTypeSchema,
|
|
815
|
+
role: import_zod.z.string()
|
|
816
|
+
});
|
|
817
|
+
var RoleListSchema = import_zod.z.object({
|
|
818
|
+
limit: import_zod.z.number(),
|
|
819
|
+
page: import_zod.z.number(),
|
|
820
|
+
roles: import_zod.z.array(
|
|
821
|
+
import_zod.z.object({
|
|
822
|
+
createdAt: import_zod.z.string(),
|
|
823
|
+
environmentId: import_zod.z.string(),
|
|
824
|
+
resourceId: import_zod.z.string(),
|
|
825
|
+
resourceType: ResourceTypeSchema,
|
|
826
|
+
role: import_zod.z.string(),
|
|
827
|
+
userId: import_zod.z.string()
|
|
828
|
+
})
|
|
829
|
+
),
|
|
830
|
+
total: import_zod.z.number()
|
|
831
|
+
});
|
|
832
|
+
var TransactionHistoryResponseSchema = import_zod.z.object({
|
|
833
|
+
items: import_zod.z.array(
|
|
834
|
+
import_zod.z.object({
|
|
835
|
+
amount: import_zod.z.number().int(),
|
|
836
|
+
createdAt: import_zod.z.string().datetime(),
|
|
837
|
+
environmentId: import_zod.z.string(),
|
|
838
|
+
id: import_zod.z.string(),
|
|
839
|
+
limitType: LimitTypeSchema,
|
|
840
|
+
resourceId: import_zod.z.string(),
|
|
841
|
+
resourceType: ResourceTypeSchema,
|
|
842
|
+
tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).nullable()
|
|
843
|
+
})
|
|
844
|
+
)
|
|
845
|
+
});
|
|
846
|
+
var UsageCheckBodySchema = import_zod.z.object({
|
|
847
|
+
amount: import_zod.z.number().int(),
|
|
848
|
+
limitType: UsageLimitTypeSchema,
|
|
849
|
+
period: import_zod.z.enum(["monthly", "yearly", "lifetime"]),
|
|
850
|
+
resourceId: import_zod.z.string(),
|
|
851
|
+
resourceType: ResourceTypeSchema
|
|
852
|
+
});
|
|
853
|
+
var UsageConsumeBodySchema = import_zod.z.object({
|
|
854
|
+
amount: import_zod.z.number().int(),
|
|
855
|
+
limitType: UsageLimitTypeSchema,
|
|
856
|
+
resourceId: import_zod.z.string(),
|
|
857
|
+
resourceType: ResourceTypeSchema,
|
|
858
|
+
tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
|
|
859
|
+
});
|
|
860
|
+
var UsageCreditBodySchema = import_zod.z.object({
|
|
861
|
+
amount: import_zod.z.number().int(),
|
|
862
|
+
limitType: UsageLimitTypeSchema,
|
|
863
|
+
resourceId: import_zod.z.string(),
|
|
864
|
+
resourceType: ResourceTypeSchema,
|
|
865
|
+
tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
|
|
866
|
+
});
|
|
867
|
+
var UsageWalletResponseSchema = import_zod.z.object({
|
|
868
|
+
amount: import_zod.z.number().int(),
|
|
869
|
+
createdAt: import_zod.z.string().datetime(),
|
|
870
|
+
environmentId: import_zod.z.string(),
|
|
871
|
+
id: import_zod.z.string(),
|
|
872
|
+
limitType: UsageLimitTypeSchema,
|
|
873
|
+
resourceId: import_zod.z.string(),
|
|
874
|
+
resourceType: ResourceTypeSchema,
|
|
875
|
+
tags: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).nullable()
|
|
876
|
+
});
|
|
877
|
+
var UserSchema = import_zod.z.object({
|
|
878
|
+
avatarUrl: import_zod.z.string().nullable(),
|
|
879
|
+
createdAt: import_zod.z.string().datetime(),
|
|
880
|
+
email: import_zod.z.string().email(),
|
|
881
|
+
emailVerified: import_zod.z.boolean(),
|
|
882
|
+
firstName: import_zod.z.string().nullable(),
|
|
883
|
+
id: import_zod.z.string(),
|
|
884
|
+
lastLoginAt: import_zod.z.string().datetime().nullable(),
|
|
885
|
+
lastName: import_zod.z.string().nullable(),
|
|
886
|
+
lookupKey: import_zod.z.string().nullable(),
|
|
887
|
+
updatedAt: import_zod.z.string().datetime()
|
|
888
|
+
});
|
|
889
|
+
var UserCreateBodySchema = import_zod.z.object({
|
|
890
|
+
avatarUrl: import_zod.z.string().url().optional(),
|
|
891
|
+
email: import_zod.z.string().email(),
|
|
892
|
+
firstName: import_zod.z.string().nullable().optional(),
|
|
893
|
+
lastName: import_zod.z.string().nullable().optional(),
|
|
894
|
+
lookupKey: import_zod.z.string(),
|
|
895
|
+
newUser: import_zod.z.boolean().nullable().optional(),
|
|
896
|
+
password: import_zod.z.string().nullable().optional()
|
|
897
|
+
});
|
|
898
|
+
var UserListSchema = import_zod.z.object({
|
|
899
|
+
items: import_zod.z.array(
|
|
900
|
+
import_zod.z.object({
|
|
901
|
+
avatarUrl: import_zod.z.string().nullable(),
|
|
902
|
+
createdAt: import_zod.z.string().datetime(),
|
|
903
|
+
email: import_zod.z.string().email(),
|
|
904
|
+
emailVerified: import_zod.z.boolean(),
|
|
905
|
+
firstName: import_zod.z.string().nullable(),
|
|
906
|
+
id: import_zod.z.string(),
|
|
907
|
+
lastLoginAt: import_zod.z.string().datetime().nullable(),
|
|
908
|
+
lastName: import_zod.z.string().nullable(),
|
|
909
|
+
lookupKey: import_zod.z.string().nullable(),
|
|
910
|
+
updatedAt: import_zod.z.string().datetime()
|
|
911
|
+
})
|
|
912
|
+
),
|
|
913
|
+
limit: import_zod.z.number(),
|
|
914
|
+
page: import_zod.z.number(),
|
|
915
|
+
total: import_zod.z.number()
|
|
916
|
+
});
|
|
917
|
+
var UserResourceListSchema = import_zod.z.array(
|
|
918
|
+
import_zod.z.object({
|
|
919
|
+
inherited: import_zod.z.boolean(),
|
|
920
|
+
resource: import_zod.z.object({
|
|
921
|
+
id: import_zod.z.string(),
|
|
922
|
+
name: import_zod.z.string(),
|
|
923
|
+
parents: import_zod.z.array(
|
|
924
|
+
import_zod.z.object({
|
|
925
|
+
id: import_zod.z.string(),
|
|
926
|
+
type: ResourceTypeSchema
|
|
927
|
+
})
|
|
928
|
+
),
|
|
929
|
+
type: ResourceTypeSchema
|
|
930
|
+
}).catchall(import_zod.z.unknown()),
|
|
931
|
+
role: import_zod.z.string()
|
|
932
|
+
})
|
|
933
|
+
);
|
|
934
|
+
var UserUpdateBodySchema = import_zod.z.object({
|
|
935
|
+
avatarUrl: import_zod.z.string().url().nullable().optional(),
|
|
936
|
+
email: import_zod.z.string().email().optional(),
|
|
937
|
+
firstName: import_zod.z.string().nullable().optional(),
|
|
938
|
+
lastName: import_zod.z.string().nullable().optional(),
|
|
939
|
+
lookupKey: import_zod.z.string().optional(),
|
|
940
|
+
password: import_zod.z.string().optional()
|
|
941
|
+
});
|
|
942
|
+
var EntitlementsListForResourceQuerySchema = import_zod.z.object({
|
|
943
|
+
/** The unique identifier of the user */
|
|
944
|
+
userId: import_zod.z.string()
|
|
945
|
+
});
|
|
946
|
+
var EntitlementsListForTenantQuerySchema = import_zod.z.object({
|
|
947
|
+
/** The unique identifier of the user */
|
|
948
|
+
userId: import_zod.z.string()
|
|
949
|
+
});
|
|
950
|
+
var ResourceMembersListQuerySchema = import_zod.z.object({
|
|
951
|
+
/** Number of items per page (minimum: 1, maximum: 100) */
|
|
952
|
+
limit: import_zod.z.number().optional(),
|
|
953
|
+
/** Page number for pagination */
|
|
954
|
+
page: import_zod.z.number().optional(),
|
|
955
|
+
/** Search query to filter members by email or name */
|
|
956
|
+
search: import_zod.z.string().optional()
|
|
957
|
+
});
|
|
958
|
+
var ResourcesListQuerySchema = import_zod.z.object({
|
|
959
|
+
/** Number of items per page (minimum: 1, maximum: 100) */
|
|
960
|
+
limit: import_zod.z.number().optional(),
|
|
961
|
+
/** Page number for pagination */
|
|
962
|
+
page: import_zod.z.number().optional(),
|
|
963
|
+
/** Search query to filter resources by name */
|
|
964
|
+
search: import_zod.z.string().optional()
|
|
965
|
+
});
|
|
966
|
+
var RolesListQuerySchema = import_zod.z.object({
|
|
967
|
+
/** Number of items per page (minimum: 1, maximum: 100) */
|
|
968
|
+
limit: import_zod.z.number().optional(),
|
|
969
|
+
/** Page number for pagination */
|
|
970
|
+
page: import_zod.z.number().optional(),
|
|
971
|
+
/** Filter roles by specific resource ID */
|
|
972
|
+
resourceId: import_zod.z.string().optional(),
|
|
973
|
+
/** Filter roles by resource type */
|
|
974
|
+
resourceType: ResourceTypeSchema.optional(),
|
|
975
|
+
/** Filter by role name */
|
|
976
|
+
role: import_zod.z.string().optional()
|
|
977
|
+
});
|
|
978
|
+
var UsageGetBalanceQuerySchema = import_zod.z.object({
|
|
979
|
+
/** Time period for the balance calculation */
|
|
980
|
+
period: import_zod.z.enum([
|
|
981
|
+
"monthly",
|
|
982
|
+
"yearly",
|
|
983
|
+
"lifetime"
|
|
984
|
+
])
|
|
985
|
+
});
|
|
986
|
+
var UsageGetTransactionHistoryQuerySchema = import_zod.z.object({
|
|
987
|
+
/** End date for filtering transactions (ISO 8601 format) */
|
|
988
|
+
endDate: import_zod.z.string().optional(),
|
|
989
|
+
/** Time period for filtering transactions */
|
|
990
|
+
period: import_zod.z.enum(["monthly", "yearly", "lifetime"]).optional(),
|
|
991
|
+
/** Start date for filtering transactions (ISO 8601 format) */
|
|
992
|
+
startDate: import_zod.z.string().optional()
|
|
993
|
+
});
|
|
994
|
+
var UsersListQuerySchema = import_zod.z.object({
|
|
995
|
+
/** Number of items per page (minimum: 1, maximum: 100) */
|
|
996
|
+
limit: import_zod.z.number().optional(),
|
|
997
|
+
/** Page number for pagination */
|
|
998
|
+
page: import_zod.z.number().optional(),
|
|
999
|
+
/** Search query to filter users by email, name, or lookup key */
|
|
1000
|
+
search: import_zod.z.string().optional()
|
|
1001
|
+
});
|
|
1002
|
+
|
|
1003
|
+
// src/index.ts
|
|
1004
|
+
var Blimu = class {
|
|
1005
|
+
constructor(options) {
|
|
1006
|
+
const core = new CoreClient(options);
|
|
1007
|
+
this.bulkResources = new BulkResourcesService(core);
|
|
1008
|
+
this.bulkRoles = new BulkRolesService(core);
|
|
1009
|
+
this.entitlements = new EntitlementsService(core);
|
|
1010
|
+
this.plans = new PlansService(core);
|
|
1011
|
+
this.resourceMembers = new ResourceMembersService(core);
|
|
1012
|
+
this.resources = new ResourcesService(core);
|
|
1013
|
+
this.roles = new RolesService(core);
|
|
1014
|
+
this.usage = new UsageService(core);
|
|
1015
|
+
this.users = new UsersService(core);
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
var BlimuError = import_fetch.FetchError;
|
|
1019
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1020
|
+
0 && (module.exports = {
|
|
1021
|
+
Blimu,
|
|
1022
|
+
BlimuError,
|
|
1023
|
+
BulkResourcesService,
|
|
1024
|
+
BulkRolesService,
|
|
1025
|
+
CoreClient,
|
|
1026
|
+
EntitlementsService,
|
|
1027
|
+
FetchError,
|
|
1028
|
+
PlansService,
|
|
1029
|
+
ResourceMembersService,
|
|
1030
|
+
ResourcesService,
|
|
1031
|
+
RolesService,
|
|
1032
|
+
Schema,
|
|
1033
|
+
UsageService,
|
|
1034
|
+
UsersService,
|
|
1035
|
+
ZodSchema,
|
|
1036
|
+
listAll,
|
|
1037
|
+
paginate,
|
|
1038
|
+
parseNDJSONStream,
|
|
1039
|
+
parseSSEStream,
|
|
1040
|
+
...require("@blimu/fetch")
|
|
1041
|
+
});
|
|
88
1042
|
//# sourceMappingURL=index.js.map
|