@slates/provider-handler 1.0.0-rc.11 → 1.0.0-rc.17

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.cjs CHANGED
@@ -108,7 +108,8 @@ var mapAuthMethod = (slate, m) => ({
108
108
  enabled: !!m.onInputChanged
109
109
  },
110
110
  getProfile: { enabled: !!m.getProfile }
111
- }
111
+ },
112
+ docs: m.docs ?? []
112
113
  });
113
114
  var getAction = (slate, actionId) => {
114
115
  let action = slate.actions.find((m) => m.key === actionId);
@@ -138,6 +139,7 @@ var mapAction = (_slate, a) => {
138
139
  tags: a.tags,
139
140
  metadata: a.metadata,
140
141
  scopes: a.scopes,
142
+ docs: a.docs ?? [],
141
143
  inputSchema: toJsonSchema(a.inputSchema),
142
144
  outputSchema: toJsonSchema(a.outputSchema)
143
145
  };
@@ -321,6 +323,7 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
321
323
  auth: currentAuth
322
324
  };
323
325
  };
326
+ let getAuthConfig = () => config.get()?.value ?? {};
324
327
  let getEmptyContext = () => new import_provider2.SlateContext({}, {}, {}, slate.spec, logger);
325
328
  let withRequestTraces = (context, result) => {
326
329
  let requestTraces = context.getHttpTraces();
@@ -433,7 +436,10 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
433
436
  });
434
437
  manager.onRequest("slates/config.schema.get", async () => {
435
438
  getContextBasic();
436
- return { schema: toJsonSchema(slate.spec.configSchema) };
439
+ return {
440
+ schema: toJsonSchema(slate.spec.configSchema),
441
+ docs: slate.spec.config.docsReferences ?? []
442
+ };
437
443
  });
438
444
  manager.onRequest("slates/provider.identify", async () => {
439
445
  getContextBasic();
@@ -445,7 +451,8 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
445
451
  name: slate.spec.name,
446
452
  description: slate.spec.description,
447
453
  metadata: slate.spec.parameters.metadata
448
- }
454
+ },
455
+ docs: slate.spec.docs ?? []
449
456
  };
450
457
  });
451
458
  manager.onRequest("slates/auth.methods.list", async () => {
@@ -591,7 +598,8 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
591
598
  clientSecret: params.clientSecret,
592
599
  scopes: params.scopes,
593
600
  callbackParams: params.callbackParams || {},
594
- callbackState: params.callbackState || {}
601
+ callbackState: params.callbackState || {},
602
+ config: getAuthConfig()
595
603
  })
596
604
  )
597
605
  );
@@ -637,7 +645,8 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
637
645
  input: params.input,
638
646
  clientId: params.clientId,
639
647
  clientSecret: params.clientSecret,
640
- scopes: params.scopes
648
+ scopes: params.scopes,
649
+ config: getAuthConfig()
641
650
  })
642
651
  )
643
652
  );
@@ -675,14 +684,20 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
675
684
  profileKeyCount: getObjectKeyCount(result.profile)
676
685
  })
677
686
  },
678
- () => (0, import_provider2.runWithContext)(
679
- context,
680
- () => authMethod.getProfile({
687
+ () => (0, import_provider2.runWithContext)(context, () => {
688
+ if (authMethod.type === "auth.oauth") {
689
+ return authMethod.getProfile({
690
+ output: params.output,
691
+ input: params.input,
692
+ scopes: params.scopes,
693
+ config: getAuthConfig()
694
+ });
695
+ }
696
+ return authMethod.getProfile({
681
697
  output: params.output,
682
- input: params.input,
683
- scopes: params.scopes
684
- })
685
- )
698
+ input: params.input
699
+ });
700
+ })
686
701
  );
687
702
  return withRequestTraces(context, {
688
703
  profile: profileRes.profile
@@ -717,16 +732,25 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
717
732
  returnedInput: !!result.input
718
733
  })
719
734
  },
720
- () => (0, import_provider2.runWithContext)(
721
- context,
722
- () => authMethod.handleTokenRefresh({
735
+ () => (0, import_provider2.runWithContext)(context, () => {
736
+ if (authMethod.type === "auth.oauth") {
737
+ return authMethod.handleTokenRefresh({
738
+ output: params.output,
739
+ input: params.input,
740
+ clientId: params.clientId,
741
+ clientSecret: params.clientSecret,
742
+ scopes: params.scopes,
743
+ config: getAuthConfig()
744
+ });
745
+ }
746
+ return authMethod.handleTokenRefresh({
723
747
  output: params.output,
724
748
  input: params.input,
725
749
  clientId: params.clientId,
726
750
  clientSecret: params.clientSecret,
727
751
  scopes: params.scopes
728
- })
729
- )
752
+ });
753
+ })
730
754
  );
731
755
  return withRequestTraces(context, {
732
756
  output: refreshRes.output,
@@ -81,7 +81,8 @@ var mapAuthMethod = (slate, m) => ({
81
81
  enabled: !!m.onInputChanged
82
82
  },
83
83
  getProfile: { enabled: !!m.getProfile }
84
- }
84
+ },
85
+ docs: m.docs ?? []
85
86
  });
86
87
  var getAction = (slate, actionId) => {
87
88
  let action = slate.actions.find((m) => m.key === actionId);
@@ -111,6 +112,7 @@ var mapAction = (_slate, a) => {
111
112
  tags: a.tags,
112
113
  metadata: a.metadata,
113
114
  scopes: a.scopes,
115
+ docs: a.docs ?? [],
114
116
  inputSchema: toJsonSchema(a.inputSchema),
115
117
  outputSchema: toJsonSchema(a.outputSchema)
116
118
  };
@@ -294,6 +296,7 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
294
296
  auth: currentAuth
295
297
  };
296
298
  };
299
+ let getAuthConfig = () => config.get()?.value ?? {};
297
300
  let getEmptyContext = () => new SlateContext({}, {}, {}, slate.spec, logger);
298
301
  let withRequestTraces = (context, result) => {
299
302
  let requestTraces = context.getHttpTraces();
@@ -406,7 +409,10 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
406
409
  });
407
410
  manager.onRequest("slates/config.schema.get", async () => {
408
411
  getContextBasic();
409
- return { schema: toJsonSchema(slate.spec.configSchema) };
412
+ return {
413
+ schema: toJsonSchema(slate.spec.configSchema),
414
+ docs: slate.spec.config.docsReferences ?? []
415
+ };
410
416
  });
411
417
  manager.onRequest("slates/provider.identify", async () => {
412
418
  getContextBasic();
@@ -418,7 +424,8 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
418
424
  name: slate.spec.name,
419
425
  description: slate.spec.description,
420
426
  metadata: slate.spec.parameters.metadata
421
- }
427
+ },
428
+ docs: slate.spec.docs ?? []
422
429
  };
423
430
  });
424
431
  manager.onRequest("slates/auth.methods.list", async () => {
@@ -564,7 +571,8 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
564
571
  clientSecret: params.clientSecret,
565
572
  scopes: params.scopes,
566
573
  callbackParams: params.callbackParams || {},
567
- callbackState: params.callbackState || {}
574
+ callbackState: params.callbackState || {},
575
+ config: getAuthConfig()
568
576
  })
569
577
  )
570
578
  );
@@ -610,7 +618,8 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
610
618
  input: params.input,
611
619
  clientId: params.clientId,
612
620
  clientSecret: params.clientSecret,
613
- scopes: params.scopes
621
+ scopes: params.scopes,
622
+ config: getAuthConfig()
614
623
  })
615
624
  )
616
625
  );
@@ -648,14 +657,20 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
648
657
  profileKeyCount: getObjectKeyCount(result.profile)
649
658
  })
650
659
  },
651
- () => runWithContext(
652
- context,
653
- () => authMethod.getProfile({
660
+ () => runWithContext(context, () => {
661
+ if (authMethod.type === "auth.oauth") {
662
+ return authMethod.getProfile({
663
+ output: params.output,
664
+ input: params.input,
665
+ scopes: params.scopes,
666
+ config: getAuthConfig()
667
+ });
668
+ }
669
+ return authMethod.getProfile({
654
670
  output: params.output,
655
- input: params.input,
656
- scopes: params.scopes
657
- })
658
- )
671
+ input: params.input
672
+ });
673
+ })
659
674
  );
660
675
  return withRequestTraces(context, {
661
676
  profile: profileRes.profile
@@ -690,16 +705,25 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
690
705
  returnedInput: !!result.input
691
706
  })
692
707
  },
693
- () => runWithContext(
694
- context,
695
- () => authMethod.handleTokenRefresh({
708
+ () => runWithContext(context, () => {
709
+ if (authMethod.type === "auth.oauth") {
710
+ return authMethod.handleTokenRefresh({
711
+ output: params.output,
712
+ input: params.input,
713
+ clientId: params.clientId,
714
+ clientSecret: params.clientSecret,
715
+ scopes: params.scopes,
716
+ config: getAuthConfig()
717
+ });
718
+ }
719
+ return authMethod.handleTokenRefresh({
696
720
  output: params.output,
697
721
  input: params.input,
698
722
  clientId: params.clientId,
699
723
  clientSecret: params.clientSecret,
700
724
  scopes: params.scopes
701
- })
702
- )
725
+ });
726
+ })
703
727
  );
704
728
  return withRequestTraces(context, {
705
729
  output: refreshRes.output,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slates/provider-handler",
3
- "version": "1.0.0-rc.11",
3
+ "version": "1.0.0-rc.17",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -26,14 +26,14 @@
26
26
  "unpkg": "./dist/index.module.js",
27
27
  "scripts": {
28
28
  "test": "vitest run --passWithNoTests",
29
- "lint": "prettier src/**/*.ts --check",
30
29
  "build": "tsup --config ../../tsup.packages.config.ts",
31
- "typecheck": "tsc --noEmit"
30
+ "typecheck": "tsc --noEmit",
31
+ "biome:check": "biome check --write src"
32
32
  },
33
33
  "dependencies": {
34
34
  "@lowerdeck/error": "^1.1.0",
35
- "@slates/proto": "1.0.0-rc.9",
36
- "@slates/provider": "1.0.0-rc.12",
35
+ "@slates/proto": "1.0.0-rc.11",
36
+ "@slates/provider": "1.0.0-rc.15",
37
37
  "zod": "^4.2.1"
38
38
  },
39
39
  "devDependencies": {
package/src/index.ts CHANGED
@@ -225,6 +225,8 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
225
225
  };
226
226
  };
227
227
 
228
+ let getAuthConfig = (): Record<string, any> => config.get()?.value ?? {};
229
+
228
230
  let getEmptyContext = () => new SlateContext({}, {}, {}, slate.spec as any, logger);
229
231
  let withRequestTraces = <Result extends Record<string, any>>(
230
232
  context: SlateContext<any, any, any>,
@@ -361,7 +363,10 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
361
363
  manager.onRequest('slates/config.schema.get', async () => {
362
364
  getContextBasic();
363
365
 
364
- return { schema: toJsonSchema(slate.spec.configSchema) };
366
+ return {
367
+ schema: toJsonSchema(slate.spec.configSchema),
368
+ docs: slate.spec.config.docsReferences ?? []
369
+ };
365
370
  });
366
371
 
367
372
  manager.onRequest('slates/provider.identify', async () => {
@@ -375,7 +380,8 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
375
380
  name: slate.spec.name,
376
381
  description: slate.spec.description,
377
382
  metadata: slate.spec.parameters.metadata
378
- }
383
+ },
384
+ docs: slate.spec.docs ?? []
379
385
  };
380
386
  });
381
387
 
@@ -540,7 +546,8 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
540
546
  clientSecret: params.clientSecret,
541
547
  scopes: params.scopes,
542
548
  callbackParams: params.callbackParams || {},
543
- callbackState: params.callbackState || {}
549
+ callbackState: params.callbackState || {},
550
+ config: getAuthConfig()
544
551
  })
545
552
  )
546
553
  );
@@ -590,7 +597,8 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
590
597
  input: params.input,
591
598
  clientId: params.clientId,
592
599
  clientSecret: params.clientSecret,
593
- scopes: params.scopes
600
+ scopes: params.scopes,
601
+ config: getAuthConfig()
594
602
  })
595
603
  )
596
604
  );
@@ -633,15 +641,21 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
633
641
  })
634
642
  },
635
643
  () =>
636
- runWithContext(
637
- context,
638
- () =>
639
- authMethod.getProfile!({
644
+ runWithContext(context, () => {
645
+ if (authMethod.type === 'auth.oauth') {
646
+ return authMethod.getProfile!({
640
647
  output: params.output as any,
641
648
  input: params.input,
642
- scopes: params.scopes
643
- })!
644
- )
649
+ scopes: params.scopes,
650
+ config: getAuthConfig()
651
+ });
652
+ }
653
+
654
+ return authMethod.getProfile!({
655
+ output: params.output as any,
656
+ input: params.input
657
+ })!;
658
+ })
645
659
  );
646
660
 
647
661
  return withRequestTraces(context, {
@@ -681,15 +695,26 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
681
695
  })
682
696
  },
683
697
  () =>
684
- runWithContext(context, () =>
685
- authMethod.handleTokenRefresh!({
698
+ runWithContext(context, () => {
699
+ if (authMethod.type === 'auth.oauth') {
700
+ return authMethod.handleTokenRefresh!({
701
+ output: params.output as any,
702
+ input: params.input,
703
+ clientId: params.clientId,
704
+ clientSecret: params.clientSecret,
705
+ scopes: params.scopes,
706
+ config: getAuthConfig()
707
+ });
708
+ }
709
+
710
+ return authMethod.handleTokenRefresh!({
686
711
  output: params.output as any,
687
712
  input: params.input,
688
713
  clientId: params.clientId,
689
714
  clientSecret: params.clientSecret,
690
715
  scopes: params.scopes
691
- })
692
- )
716
+ });
717
+ })
693
718
  );
694
719
 
695
720
  return withRequestTraces(context, {
package/src/spec.ts CHANGED
@@ -50,7 +50,9 @@ export let mapAuthMethod = <ConfigType extends {}, AuthType extends {}>(
50
50
  enabled: !!m.onInputChanged
51
51
  },
52
52
  getProfile: { enabled: !!m.getProfile }
53
- }
53
+ },
54
+
55
+ docs: m.docs ?? []
54
56
  });
55
57
 
56
58
  export let getAction = <ConfigType extends {}, AuthType extends {}>(
@@ -99,6 +101,7 @@ export let mapAction = <ConfigType extends {}, AuthType extends {}>(
99
101
  tags: a.tags,
100
102
  metadata: a.metadata,
101
103
  scopes: a.scopes,
104
+ docs: a.docs ?? [],
102
105
 
103
106
  inputSchema: toJsonSchema(a.inputSchema),
104
107
  outputSchema: toJsonSchema(a.outputSchema)