lucid-extension-sdk 0.0.53 → 0.0.55

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -90,6 +90,7 @@ export declare const enum CommandName {
90
90
  ShowPanel = "spn",
91
91
  SleepForTestCase = "sleep",
92
92
  StartDragBlockToCanvas = "sdc",
93
+ StartPDFUploadRequest = "pdf",
93
94
  ThrowForTestCase = "throw",
94
95
  UnhookCreateItems = "uci",
95
96
  UnhookSelection = "us",
@@ -395,6 +396,10 @@ export declare type CommandArgs = {
395
396
  query: StartDragBlockToCanvasQuery;
396
397
  result: StartDragBlockToCanvasResult;
397
398
  };
399
+ [CommandName.StartPDFUploadRequest]: {
400
+ query: StartPDFUploadRequestQuery;
401
+ result: StartPDFUploadRequestResponse;
402
+ };
398
403
  [CommandName.ThrowForTestCase]: {
399
404
  query: ThrowForTestCaseQuery;
400
405
  result: ThrowForTestCaseResult;
@@ -993,6 +998,13 @@ export declare type StartDragBlockToCanvasQuery = {
993
998
  's'?: JsonSerializable | undefined;
994
999
  };
995
1000
  export declare type StartDragBlockToCanvasResult = Promise<string | undefined>;
1001
+ export declare type StartPDFUploadRequestQuery = string;
1002
+ /**
1003
+ * @ignore
1004
+ * A signed URL you can upload the pdf to. You can do this manually (via the client, your own service) or via the
1005
+ * oauth proxy.
1006
+ */
1007
+ export declare type StartPDFUploadRequestResponse = Promise<string>;
996
1008
  export declare type ThrowForTestCaseQuery = number;
997
1009
  export declare type ThrowForTestCaseResult = undefined | Promise<void>;
998
1010
  export declare type UnhookCreateItemsQuery = {
@@ -74,6 +74,7 @@ exports.commandTitles = new Map([
74
74
  ["spn" /* CommandName.ShowPanel */, 'ShowPanel'],
75
75
  ["sleep" /* CommandName.SleepForTestCase */, 'SleepForTestCase'],
76
76
  ["sdc" /* CommandName.StartDragBlockToCanvas */, 'StartDragBlockToCanvas'],
77
+ ["pdf" /* CommandName.StartPDFUploadRequest */, 'StartPDFUploadRequest'],
77
78
  ["throw" /* CommandName.ThrowForTestCase */, 'ThrowForTestCase'],
78
79
  ["uci" /* CommandName.UnhookCreateItems */, 'UnhookCreateItems'],
79
80
  ["us" /* CommandName.UnhookSelection */, 'UnhookSelection'],
@@ -18,8 +18,19 @@ export interface ExtensionCardFieldDefinition extends FieldDefinition {
18
18
  default?: SerializedFieldType;
19
19
  /** Additional information we can provide to users, e.g. as a hover tooltip */
20
20
  description?: string;
21
- /** If specified, the list of options available to choose from */
22
- options?: ExtensionCardFieldOption[];
21
+ /**
22
+ * If specified, the list of options available to choose from, or the name
23
+ * of a registered action that returns the list of options (either directly
24
+ * or as a Promise).
25
+ */
26
+ options?: ExtensionCardFieldOption[] | string;
27
+ /**
28
+ * If specified, an action that takes the search text and input so far, and
29
+ * returns the list of options that should be displayed. This is useful when
30
+ * there are too many possible options to reasonably use the "options"
31
+ * option for options.
32
+ */
33
+ search?: string;
23
34
  }
24
35
  /** @ignore */
25
36
  export declare type SerializedCardFieldOption = {
@@ -33,7 +44,8 @@ export declare type SerializedExtensionCardFieldDefinition = SerializedFieldDefi
33
44
  'l': string;
34
45
  'def'?: SerializedFieldType;
35
46
  'd'?: string;
36
- 'op'?: SerializedCardFieldOption[];
47
+ 'op'?: SerializedCardFieldOption[] | string;
48
+ 's'?: string;
37
49
  };
38
50
  /** @ignore */
39
51
  export declare function serializeCardFieldDefinition(field: ExtensionCardFieldDefinition): SerializedExtensionCardFieldDefinition;
@@ -64,10 +76,11 @@ export declare const isSerializedExtensionCardFieldDefinition: (subject: unknown
64
76
  l: typeof isString;
65
77
  d: (x: unknown) => x is string | undefined;
66
78
  def: (x: unknown) => x is SerializedFieldType;
67
- op: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
79
+ op: (x: unknown) => x is string | import("../guards").DestructureGuardedTypeObj<{
68
80
  l: typeof isString;
69
81
  v: typeof isSerializedFieldType;
70
82
  }>[] | undefined;
83
+ s: (x: unknown) => x is string | undefined;
71
84
  }>;
72
85
  /** @ignore */
73
86
  export declare function deserializeCardFieldDefinition(field: SerializedExtensionCardFieldDefinition): ExtensionCardFieldDefinition;
@@ -18,7 +18,7 @@ exports.serializeCardFieldOption = serializeCardFieldOption;
18
18
  /** @ignore */
19
19
  function serializeCardFieldDefinition(field) {
20
20
  var _a;
21
- return Object.assign(Object.assign({}, (0, schemadefinition_1.serializeFieldDefinition)(field)), { 'l': field.label, 'def': field.default, 'd': field.description, 'op': (_a = field.options) === null || _a === void 0 ? void 0 : _a.map(serializeCardFieldOption) });
21
+ return Object.assign(Object.assign({}, (0, schemadefinition_1.serializeFieldDefinition)(field)), { 'l': field.label, 'def': field.default, 'd': field.description, 'op': (0, checks_1.isString)(field.options) ? field.options : (_a = field.options) === null || _a === void 0 ? void 0 : _a.map(serializeCardFieldOption), 's': field.search });
22
22
  }
23
23
  exports.serializeCardFieldDefinition = serializeCardFieldDefinition;
24
24
  /** @ignore */
@@ -51,12 +51,13 @@ exports.isSerializedExtensionCardFieldDefinition = (0, validators_1.objectValida
51
51
  'l': checks_1.isString,
52
52
  'd': (0, validators_1.option)(checks_1.isString),
53
53
  'def': (0, validators_1.option)(serializedfields_1.isSerializedFieldType),
54
- 'op': (0, validators_1.option)((0, validators_1.arrayValidator)(exports.isSerializedFieldOption)),
54
+ 'op': (0, validators_1.option)((0, validators_1.either)(checks_1.isString, (0, validators_1.arrayValidator)(exports.isSerializedFieldOption))),
55
+ 's': (0, validators_1.option)(checks_1.isString),
55
56
  });
56
57
  /** @ignore */
57
58
  function deserializeCardFieldDefinition(field) {
58
59
  var _a;
59
- return Object.assign(Object.assign({}, (0, schemadefinition_1.parseFieldDefinition)(field)), { label: field['l'], description: field['d'], default: field['def'], options: (_a = field['op']) === null || _a === void 0 ? void 0 : _a.map(deserializeFieldOption) });
60
+ return Object.assign(Object.assign({}, (0, schemadefinition_1.parseFieldDefinition)(field)), { label: field['l'], description: field['d'], default: field['def'], options: (0, checks_1.isString)(field['op']) ? field['op'] : (_a = field['op']) === null || _a === void 0 ? void 0 : _a.map(deserializeFieldOption), search: field['s'] });
60
61
  }
61
62
  exports.deserializeCardFieldDefinition = deserializeCardFieldDefinition;
62
63
  /** @ignore */
@@ -1,3 +1,4 @@
1
+ import { StartPDFUploadRequestResponse } from '../../commandtypes';
1
2
  import { UnfurlIframe } from '../../core/unfurl/unfurliframe';
2
3
  import { BlockProxy } from '../blockproxy';
3
4
  /**
@@ -50,7 +51,7 @@ export declare class ExperimentalLinkUnfurlBlockProxy extends BlockProxy {
50
51
  * The PDF uploaded at that url will be assocaite with this block (and any copy of it) in the editor until it is refreshed.
51
52
  * @param options The options for the upload
52
53
  */
53
- experimentalStartPDFUpload(options: LinkUnfurlPDFOptions): Promise<LinkUnfurlPDFResult>;
54
+ experimentalStartPDFUpload(options: LinkUnfurlPDFOptions): Promise<StartPDFUploadRequestResponse>;
54
55
  }
55
56
  /**
56
57
  * @ignore
@@ -64,21 +65,3 @@ export interface LinkUnfurlPDFOptions {
64
65
  */
65
66
  expectedNumberOfPages: number;
66
67
  }
67
- /**
68
- * @ignore
69
- * The result of initiating the PDF upload process.
70
- */
71
- export interface LinkUnfurlPDFResult {
72
- /**
73
- * @ignore
74
- * A signed URL you can upload the pdf to. You can do this manually (via the client, your own service) or via the
75
- * oauth proxy.
76
- */
77
- uploadUrl: string;
78
- /**
79
- * @ignore
80
- * The internal identifier to the PDF upload which is associated with the block.
81
- * TODO: Determine if we show this to the extension, or keep internal
82
- */
83
- blobId: string;
84
- }
@@ -73,8 +73,9 @@ class ExperimentalLinkUnfurlBlockProxy extends blockproxy_1.BlockProxy {
73
73
  * The PDF uploaded at that url will be assocaite with this block (and any copy of it) in the editor until it is refreshed.
74
74
  * @param options The options for the upload
75
75
  */
76
- experimentalStartPDFUpload(options) {
77
- throw new Error('Not yet implemented');
76
+ async experimentalStartPDFUpload(options) {
77
+ const result = await this.client.sendCommand("pdf" /* CommandName.StartPDFUploadRequest */, this.id);
78
+ return result;
78
79
  }
79
80
  }
80
81
  exports.ExperimentalLinkUnfurlBlockProxy = ExperimentalLinkUnfurlBlockProxy;
@@ -1,10 +1,13 @@
1
- import { CardIntegration } from '../core/cardintegration/cardintegration';
1
+ import { CardIntegration, ExtensionCardFieldOption } from '../core/cardintegration/cardintegration';
2
+ import { SerializedFieldType } from '../core/data/serializedfield/serializedfields';
2
3
  import { EditorClient } from '../editorclient';
3
4
  export declare class TaskManagementCardIntegration {
4
5
  private readonly client;
5
6
  constructor(client: EditorClient);
6
7
  private static nextHookId;
7
8
  private static nextHookName;
9
+ registerFieldOptionsCallback(callback: (inputSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldOption[]>): string;
10
+ registerFieldSearchCallback(callback: (searchText: string, inputSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldOption[]>): string;
8
11
  /**
9
12
  * Register a new card integration.
10
13
  * @param card The definition of the new card integration
@@ -12,6 +12,22 @@ class TaskManagementCardIntegration {
12
12
  static nextHookName() {
13
13
  return '__taskmanagementcard__hook' + TaskManagementCardIntegration.nextHookId++;
14
14
  }
15
+ registerFieldOptionsCallback(callback) {
16
+ const name = TaskManagementCardIntegration.nextHookName();
17
+ this.client.registerAction(name, async ({ 'i': inputSoFar }) => {
18
+ const result = await callback(new Map(inputSoFar));
19
+ return result.map((option) => (0, cardintegration_1.serializeCardFieldOption)(option));
20
+ });
21
+ return name;
22
+ }
23
+ registerFieldSearchCallback(callback) {
24
+ const name = TaskManagementCardIntegration.nextHookName();
25
+ this.client.registerAction(name, async ({ 'i': inputSoFar, 's': searchText }) => {
26
+ const result = await callback(searchText, new Map(inputSoFar));
27
+ return result.map((option) => (0, cardintegration_1.serializeCardFieldOption)(option));
28
+ });
29
+ return name;
30
+ }
15
31
  /**
16
32
  * Register a new card integration.
17
33
  * @param card The definition of the new card integration