@crowdstrike/foundry-js 0.7.2 → 0.8.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/dist/index.js CHANGED
@@ -2172,22 +2172,23 @@ class RemoteResponseApiBridge {
2172
2172
  };
2173
2173
  return this.bridge.postMessage(message);
2174
2174
  }
2175
- async getScriptIds(urlParams = {}) {
2175
+ async postEntitiesAppCommandV1(postBody, urlParams = {}) {
2176
2176
  const message = {
2177
2177
  type: 'api',
2178
2178
  api: 'remoteResponse',
2179
- method: 'getQueriesScriptsV1',
2179
+ method: 'postEntitiesAppCommandV1',
2180
2180
  payload: {
2181
+ body: postBody,
2181
2182
  params: urlParams,
2182
2183
  },
2183
2184
  };
2184
2185
  return this.bridge.postMessage(message);
2185
2186
  }
2186
- async postEntitiesAppCommandV1(postBody, urlParams = {}) {
2187
+ async postEntitiesAppRefreshSessionsV1(postBody, urlParams = {}) {
2187
2188
  const message = {
2188
2189
  type: 'api',
2189
2190
  api: 'remoteResponse',
2190
- method: 'postEntitiesAppCommandV1',
2191
+ method: 'postEntitiesAppRefreshSessionsV1',
2191
2192
  payload: {
2192
2193
  body: postBody,
2193
2194
  params: urlParams,
@@ -2195,11 +2196,11 @@ class RemoteResponseApiBridge {
2195
2196
  };
2196
2197
  return this.bridge.postMessage(message);
2197
2198
  }
2198
- async postEntitiesAppRefreshSessionsV1(postBody, urlParams = {}) {
2199
+ async postEntitiesAppSessionsV1(postBody, urlParams = {}) {
2199
2200
  const message = {
2200
2201
  type: 'api',
2201
2202
  api: 'remoteResponse',
2202
- method: 'postEntitiesAppRefreshSessionsV1',
2203
+ method: 'postEntitiesAppSessionsV1',
2203
2204
  payload: {
2204
2205
  body: postBody,
2205
2206
  params: urlParams,
@@ -2207,23 +2208,39 @@ class RemoteResponseApiBridge {
2207
2208
  };
2208
2209
  return this.bridge.postMessage(message);
2209
2210
  }
2210
- async postEntitiesAppSessionsV1(postBody, urlParams = {}) {
2211
+ }
2212
+
2213
+ /**
2214
+ *
2215
+ * This file is autogenerated.
2216
+ *
2217
+ * DO NOT EDIT DIRECTLY
2218
+ *
2219
+ **/
2220
+ class UserManagementApiBridge {
2221
+ bridge;
2222
+ constructor(bridge) {
2223
+ this.bridge = bridge;
2224
+ }
2225
+ getBridge() {
2226
+ return this.bridge;
2227
+ }
2228
+ async getQueriesUsersV1(urlParams = {}) {
2211
2229
  const message = {
2212
2230
  type: 'api',
2213
- api: 'remoteResponse',
2214
- method: 'postEntitiesAppSessionsV1',
2231
+ api: 'userManagement',
2232
+ method: 'getQueriesUsersV1',
2215
2233
  payload: {
2216
- body: postBody,
2217
2234
  params: urlParams,
2218
2235
  },
2219
2236
  };
2220
2237
  return this.bridge.postMessage(message);
2221
2238
  }
2222
- async getScriptEntities(postBody, urlParams = {}) {
2239
+ async postEntitiesUsersGetV1(postBody, urlParams = {}) {
2223
2240
  const message = {
2224
2241
  type: 'api',
2225
- api: 'remoteResponse',
2226
- method: 'postEntitiesScriptsGetV2',
2242
+ api: 'userManagement',
2243
+ method: 'postEntitiesUsersGetV1',
2227
2244
  payload: {
2228
2245
  body: postBody,
2229
2246
  params: urlParams,
@@ -2330,6 +2347,10 @@ class FalconPublicApis {
2330
2347
  assertConnection(this);
2331
2348
  return new RemoteResponseApiBridge(this.bridge);
2332
2349
  }
2350
+ get userManagement() {
2351
+ assertConnection(this);
2352
+ return new UserManagementApiBridge(this.bridge);
2353
+ }
2333
2354
  get workflows() {
2334
2355
  assertConnection(this);
2335
2356
  return new WorkflowsApiBridge(this.bridge);
@@ -2374,6 +2395,9 @@ __decorate([
2374
2395
  __decorate([
2375
2396
  Memoize()
2376
2397
  ], FalconPublicApis.prototype, "remoteResponse", null);
2398
+ __decorate([
2399
+ Memoize()
2400
+ ], FalconPublicApis.prototype, "userManagement", null);
2377
2401
  __decorate([
2378
2402
  Memoize()
2379
2403
  ], FalconPublicApis.prototype, "workflows", null);
@@ -2421,16 +2445,23 @@ class CloudFunction {
2421
2445
  this.falcon = falcon;
2422
2446
  this.definition = definition;
2423
2447
  }
2424
- async execute({ path, method, queryParams, body, headers, }) {
2448
+ async execute({ path, method, body, params }) {
2449
+ const functionDefinition = 'id' in this.definition
2450
+ ? {
2451
+ function_id: this.definition.id,
2452
+ function_version: this.definition.version,
2453
+ }
2454
+ : {
2455
+ function_name: this.definition.name,
2456
+ function_version: this.definition.version,
2457
+ };
2425
2458
  const result = await this.falcon.faasGateway.postEntitiesExecutionV1({
2426
- function_id: this.definition.id,
2427
- function_version: this.definition.version,
2459
+ ...functionDefinition,
2428
2460
  payload: {
2429
2461
  path,
2430
2462
  method,
2431
2463
  body,
2432
- headers,
2433
- query_params: queryParams,
2464
+ params,
2434
2465
  },
2435
2466
  });
2436
2467
  return new Promise((resolve, reject) => {
@@ -2476,94 +2507,101 @@ class CloudFunction {
2476
2507
  path(pathEntry) {
2477
2508
  const urlPath = new URL(pathEntry, 'http://localhost');
2478
2509
  const path = urlPath.pathname;
2479
- const searchParams = [...urlPath.searchParams.entries()].map(([key, value]) => ({
2510
+ const searchParams = [...urlPath.searchParams.entries()].reduce((acc, [key, value]) => ({
2511
+ ...acc,
2480
2512
  [key]: [value],
2481
- }));
2513
+ }), {});
2482
2514
  return {
2483
2515
  path,
2484
2516
  queryParams: searchParams,
2485
- get: async (queryParams = {}) => {
2517
+ get: async (params = {}) => {
2486
2518
  return this.get({
2487
2519
  path,
2488
- queryParams: queryParams ?? searchParams ?? {},
2520
+ params: {
2521
+ query: params?.query ?? searchParams ?? {},
2522
+ header: params?.header ?? {},
2523
+ },
2489
2524
  });
2490
2525
  },
2491
- post: async (body, queryParams = {}, headers = {}) => {
2526
+ post: async (body, params = {}) => {
2492
2527
  return this.post({
2493
2528
  path,
2494
- queryParams: queryParams ?? searchParams ?? {},
2529
+ params: {
2530
+ query: params?.query ?? searchParams ?? {},
2531
+ header: params?.header ?? {},
2532
+ },
2495
2533
  body,
2496
- headers,
2497
2534
  });
2498
2535
  },
2499
- patch: async (body, queryParams = {}, headers = {}) => {
2536
+ patch: async (body, params = {}) => {
2500
2537
  return this.patch({
2501
2538
  path,
2502
- queryParams: queryParams ?? searchParams ?? {},
2539
+ params: {
2540
+ query: params?.query ?? searchParams ?? {},
2541
+ header: params?.header ?? {},
2542
+ },
2503
2543
  body,
2504
- headers,
2505
2544
  });
2506
2545
  },
2507
- put: async (body, queryParams = {}, headers = {}) => {
2546
+ put: async (body, params = {}) => {
2508
2547
  return this.put({
2509
2548
  path,
2510
- queryParams: queryParams ?? searchParams ?? {},
2549
+ params: {
2550
+ query: params?.query ?? searchParams ?? {},
2551
+ header: params?.header ?? {},
2552
+ },
2511
2553
  body,
2512
- headers,
2513
2554
  });
2514
2555
  },
2515
- delete: async (body, queryParams = {}, headers = {}) => {
2556
+ delete: async (body, params = {}) => {
2516
2557
  return this.delete({
2517
2558
  path,
2518
- queryParams: queryParams ?? searchParams ?? {},
2559
+ params: {
2560
+ query: params?.query ?? searchParams ?? {},
2561
+ header: params?.header ?? {},
2562
+ },
2519
2563
  body,
2520
- headers,
2521
2564
  });
2522
2565
  },
2523
2566
  };
2524
2567
  }
2525
- async get({ path, queryParams, headers }) {
2568
+ async get({ path, params }) {
2526
2569
  return this.execute({
2527
2570
  path,
2528
2571
  method: CloudFunction.GET,
2529
- queryParams,
2530
- headers,
2572
+ params,
2531
2573
  });
2532
2574
  }
2533
- async post({ path, queryParams, body, headers }) {
2575
+ async post({ path, params, body }) {
2534
2576
  return this.execute({
2535
2577
  path,
2536
2578
  method: CloudFunction.POST,
2537
2579
  body,
2538
- queryParams,
2539
- headers,
2580
+ params,
2540
2581
  });
2541
2582
  }
2542
- async patch({ path, queryParams, body, headers }) {
2583
+ async patch({ path, params, body }) {
2543
2584
  return this.execute({
2544
2585
  path,
2545
2586
  method: CloudFunction.PATCH,
2546
2587
  body,
2547
- queryParams,
2548
- headers,
2588
+ params,
2549
2589
  });
2550
2590
  }
2551
- async put({ path, queryParams, body, headers }) {
2591
+ async put({ path, params, body }) {
2552
2592
  return this.execute({
2553
2593
  path,
2554
2594
  method: CloudFunction.PUT,
2555
2595
  body,
2556
- queryParams,
2557
- headers,
2596
+ params,
2558
2597
  });
2559
2598
  }
2560
- async delete({ path, queryParams, body, headers }) {
2599
+ async delete({ path, params, body }) {
2561
2600
  return this.execute({
2562
2601
  path,
2563
2602
  method: CloudFunction.DELETE,
2564
2603
  body,
2565
- queryParams,
2566
- headers,
2604
+ params,
2567
2605
  });
2568
2606
  }
2569
2607
  destroy() {
@@ -2612,14 +2650,15 @@ class Collection {
2612
2650
  },
2613
2651
  });
2614
2652
  }
2615
- async search({ startKey, endKey, limit }) {
2653
+ async search({ filter, offset, sort, limit, }) {
2616
2654
  return this.falcon.bridge.postMessage({
2617
2655
  type: 'collection',
2618
2656
  payload: {
2619
2657
  type: 'search',
2620
- startKey,
2621
- endKey,
2658
+ filter,
2622
2659
  limit,
2660
+ offset,
2661
+ sort,
2623
2662
  collection: this.definition.collection,
2624
2663
  },
2625
2664
  });
@@ -2652,6 +2691,15 @@ class Logscale {
2652
2691
  },
2653
2692
  });
2654
2693
  }
2694
+ async savedQuery(data) {
2695
+ return this.falcon.bridge.postMessage({
2696
+ type: 'loggingapi',
2697
+ payload: {
2698
+ type: 'saved-query-execute',
2699
+ data,
2700
+ },
2701
+ });
2702
+ }
2655
2703
  }
2656
2704
 
2657
2705
  const ALLOWED_TARGETS = ['_self', '_blank'];
@@ -2773,6 +2821,9 @@ class FalconApi extends FalconPublicApis {
2773
2821
  this.resizeTracker = new ResizeTracker(this.bridge);
2774
2822
  this.isConnected = true;
2775
2823
  }
2824
+ get appId() {
2825
+ return this.data?.app.id;
2826
+ }
2776
2827
  sendBroadcast(payload) {
2777
2828
  this.bridge.sendUnidirectionalMessage({ type: 'broadcast', payload });
2778
2829
  }
@@ -2802,15 +2853,21 @@ class FalconApi extends FalconPublicApis {
2802
2853
  document.documentElement.classList.add(activeTheme);
2803
2854
  document.documentElement.classList.remove(inactiveTheme);
2804
2855
  }
2805
- cloudFunction({ id, version }) {
2856
+ cloudFunction(definition) {
2806
2857
  assertConnection(this);
2807
- const cf = new CloudFunction(this, { id, version });
2858
+ const cf = new CloudFunction(this, definition);
2808
2859
  this.cloudFunctions.push(cf);
2809
2860
  return cf;
2810
2861
  }
2811
2862
  apiIntegration({ definitionId, operationId, }) {
2812
2863
  assertConnection(this);
2813
- const cf = new ApiIntegration(this, { operationId, definitionId });
2864
+ if (!this.data) {
2865
+ throw Error('Data from console is missing');
2866
+ }
2867
+ const cf = new ApiIntegration(this, {
2868
+ operationId,
2869
+ definitionId: definitionId ?? this.data?.app.id,
2870
+ });
2814
2871
  this.apiIntegrations.push(cf);
2815
2872
  return cf;
2816
2873
  }