lucid-extension-sdk 0.0.305 → 0.0.306

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/commandtypes.d.ts CHANGED
@@ -25,6 +25,7 @@ import { PanelLocation } from './ui/panel';
25
25
  * Before you add a new command bring it up in #api-committee to get feedback.
26
26
  */
27
27
  export declare const enum CommandName {
28
+ AddAuthorizationFlowHandler = "aafh",
28
29
  AddCardIntegration = "aci",
29
30
  AddDiagramFromMermaid = "adfm",
30
31
  AddDiagramFromText = "adft",
@@ -166,6 +167,10 @@ export declare const commandTitles: Map<CommandName, string>;
166
167
  * IMPORTANT - Before you add a new command bring it up in #api-committee to get feedback
167
168
  */
168
169
  export type CommandArgs = {
170
+ [CommandName.AddAuthorizationFlowHandler]: {
171
+ query: AddAuthorizationFlowHandlerQuery;
172
+ result: AddAuthorizationFlowHandlerResult;
173
+ };
169
174
  [CommandName.AddCardIntegration]: {
170
175
  query: AddCardIntegrationQuery;
171
176
  result: AddCardIntegrationResult;
@@ -687,6 +692,22 @@ export type CommandArgs = {
687
692
  result: ZOrderResult;
688
693
  };
689
694
  };
695
+ export type AuthorizationFlowHandlerProvider = string;
696
+ export declare enum AuthorizationFlowHandlerStage {
697
+ OnFailure = "onFailure"
698
+ }
699
+ export type AddAuthorizationFlowHandlerQuery = {
700
+ /**
701
+ * Specifies the callback function to run when the handler is triggered.
702
+ * String, not a function itself; this is the name of the client's registered action hook
703
+ */
704
+ 'c': string;
705
+ /** The name of the auth provider (as specified in the package's manifest.json) that triggers this handler. */
706
+ 'p': AuthorizationFlowHandlerProvider;
707
+ /** The stage during the auth flow when this handler is triggered. */
708
+ 's': AuthorizationFlowHandlerStage;
709
+ };
710
+ export type AddAuthorizationFlowHandlerResult = undefined;
690
711
  export type AddCardIntegrationQuery = {
691
712
  /** Title/name */
692
713
  'n': string;
@@ -709,7 +730,9 @@ export type AddCardIntegrationQuery = {
709
730
  /** Field name -> callback name tuples for searching for legal field values in an enum */
710
731
  'fvsc'?: [string, string][] | undefined;
711
732
  };
712
- /** Show intro if user has not yet authorized this integration */
733
+ /** Show intro if user has not yet authorized this integration
734
+ * String, not function; this is the name of the client's registered action hook
735
+ */
713
736
  'i'?: string | undefined;
714
737
  /** Get default config action */
715
738
  'gdc': string;
package/commandtypes.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZOrderOperation = exports.isRawSendXHRResponse = exports.MermaidDiagramType = exports.GetLLMContextType = exports.GetItemsAtSearchType = exports.GetDocumentChunksType = exports.HashAlgorithmEnum = exports.commandTitles = void 0;
3
+ exports.ZOrderOperation = exports.isRawSendXHRResponse = exports.MermaidDiagramType = exports.GetLLMContextType = exports.GetItemsAtSearchType = exports.GetDocumentChunksType = exports.HashAlgorithmEnum = exports.AuthorizationFlowHandlerStage = exports.commandTitles = void 0;
4
4
  const checks_1 = require("./core/checks");
5
5
  /** @ignore */
6
6
  exports.commandTitles = new Map([
7
+ ["aafh" /* CommandName.AddAuthorizationFlowHandler */, 'AddAuthorizationFlowHandler'],
7
8
  ["aci" /* CommandName.AddCardIntegration */, 'AddCardIntegration'],
8
9
  ["adfm" /* CommandName.AddDiagramFromMermaid */, 'AddDiagramFromMermaid'],
9
10
  ["adft" /* CommandName.AddDiagramFromText */, 'AddDiagramFromText'],
@@ -129,6 +130,10 @@ exports.commandTitles = new Map([
129
130
  ["wsa" /* CommandName.WithSilentActions */, 'WithSilentActions'],
130
131
  ["z" /* CommandName.ZOrder */, 'ZOrder'],
131
132
  ]);
133
+ var AuthorizationFlowHandlerStage;
134
+ (function (AuthorizationFlowHandlerStage) {
135
+ AuthorizationFlowHandlerStage["OnFailure"] = "onFailure";
136
+ })(AuthorizationFlowHandlerStage || (exports.AuthorizationFlowHandlerStage = AuthorizationFlowHandlerStage = {}));
132
137
  var HashAlgorithmEnum;
133
138
  (function (HashAlgorithmEnum) {
134
139
  /** Use the SHA 256 hashing algorithm */
@@ -0,0 +1,16 @@
1
+ import { AuthorizationFlowHandlerProvider, AuthorizationFlowHandlerStage } from '../commandtypes';
2
+ import { EditorClient } from '../editorclient';
3
+ export declare class AuthorizationFlowHandlerRegistry {
4
+ private static nextHookId;
5
+ private static nextHookName;
6
+ /**
7
+ * Register a function to be run at a given stage of the authorization flow for a provider.
8
+ *
9
+ * @param client A reference to the editor client.
10
+ * @param callback The function to run when the handler is triggered.
11
+ * @param stage The stage during the auth flow when this handler is triggered.
12
+ * @param provider The name of the auth provider (as specified in the package's manifest.json)
13
+ * that triggers this handler.
14
+ */
15
+ static registerAuthorizationFlowHandler(client: EditorClient, callback: () => void, stage: AuthorizationFlowHandlerStage, provider: AuthorizationFlowHandlerProvider): void;
16
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorizationFlowHandlerRegistry = void 0;
4
+ class AuthorizationFlowHandlerRegistry {
5
+ static nextHookName() {
6
+ return '__authorizationflow__hook' + AuthorizationFlowHandlerRegistry.nextHookId++;
7
+ }
8
+ /**
9
+ * Register a function to be run at a given stage of the authorization flow for a provider.
10
+ *
11
+ * @param client A reference to the editor client.
12
+ * @param callback The function to run when the handler is triggered.
13
+ * @param stage The stage during the auth flow when this handler is triggered.
14
+ * @param provider The name of the auth provider (as specified in the package's manifest.json)
15
+ * that triggers this handler.
16
+ */
17
+ static registerAuthorizationFlowHandler(client, callback, stage, provider) {
18
+ const actionHookName = AuthorizationFlowHandlerRegistry.nextHookName();
19
+ client.registerAction(actionHookName, callback);
20
+ const serialized = {
21
+ 'c': actionHookName,
22
+ 's': stage,
23
+ 'p': provider,
24
+ };
25
+ client.sendCommand("aafh" /* CommandName.AddAuthorizationFlowHandler */, serialized);
26
+ }
27
+ }
28
+ exports.AuthorizationFlowHandlerRegistry = AuthorizationFlowHandlerRegistry;
29
+ AuthorizationFlowHandlerRegistry.nextHookId = 0;
@@ -63,8 +63,8 @@ export declare abstract class LucidCardIntegration {
63
63
  fieldValueSearchCallbacks?: Map<string, string>;
64
64
  };
65
65
  /**
66
- * If specified, and the user hasn't yet authorized the data connector for this extension,
67
- * this should show the user an intro dialog or take some other action.
66
+ * @deprecated Use AuthorizationFlowHandlerRegistry.registerAuthorizationFlowHandler.
67
+ * WARNING: Currently unused and does nothing.
68
68
  */
69
69
  showIntro?: () => void;
70
70
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.305",
3
+ "version": "0.0.306",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",