lucid-extension-sdk 0.0.57 → 0.0.59

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.57",
3
+ "version": "0.0.59",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -420,14 +420,21 @@ export declare type CommandArgs = {
420
420
  export declare type AddCardIntegrationQuery = {
421
421
  /** Title/name */
422
422
  'n': string;
423
+ /** Data connector name */
424
+ 'dcn': string;
423
425
  /** Item label */
424
426
  'il': string;
425
427
  /** Items label */
426
428
  'isl': string;
427
429
  /** Icon url */
428
430
  'u': string;
429
- /** Callback to get field definitions for a given imported collection */
430
- 'gf': string;
431
+ /** Field configuration */
432
+ 'fc': {
433
+ /** Callback to get field definitions for all fields supported by the card integration */
434
+ 'gf': string;
435
+ /** Callback to handle a change in the fields the user want to be displayed */
436
+ 'osfc'?: string;
437
+ };
431
438
  /** Show intro if user has not yet authorized this integration */
432
439
  'i'?: string;
433
440
  /** Get default config action */
@@ -1,5 +1,6 @@
1
1
  import { CollectionDefinition } from '../../data/collectiondefinition';
2
2
  import { CollectionProxy } from '../../data/collectionproxy';
3
+ import { DataSourceProxy } from '../../data/datasourceproxy';
3
4
  import { FieldDefinition } from '../../data/schemadefinition';
4
5
  import { isString } from '../checks';
5
6
  import { isSerializedFieldTypeDefinition } from '../data/fieldtypedefinition/fieldtypedefinition';
@@ -105,13 +106,23 @@ export interface CardIntegration {
105
106
  */
106
107
  iconUrl: string;
107
108
  /**
108
- * Callback to provide a list of field definitions for the given collection, if that collection
109
- * was imported as part of this card integration.
110
- *
111
- * Any fields on the schema of the collection that you don't provide a ExtensionCardFieldDefinition
112
- * for will have a default definition generated based on the type specified in the schema.
109
+ * The name of the data connector associated with the card integration.
113
110
  */
114
- getAllFields: (collection: CollectionProxy) => Promise<ExtensionCardFieldDefinition[]>;
111
+ dataConnectorName: string;
112
+ fieldConfiguration: {
113
+ /**
114
+ * Callback to provide a list of all supported field definitions for the card integration.
115
+ *
116
+ * Any fields on the schema of the collection that you don't provide a ExtensionCardFieldDefinition
117
+ * for will have a default definition generated based on the type specified in the schema.
118
+ */
119
+ getAllFields: (collection: CollectionProxy) => Promise<ExtensionCardFieldDefinition[]>;
120
+ /**
121
+ * Callback that handled changes in the fields the user wants to be displayed in the card integration.
122
+ * If this callback is not provided then the user will not be shown the modal to configure fields.
123
+ */
124
+ onSelectedFieldsChange?: (dataSource: DataSourceProxy, selectedFields: string[]) => void;
125
+ };
115
126
  /**
116
127
  * If specified, and the user hasn't yet authorized the data connector for this extension,
117
128
  * this should show the user an intro dialog or take some other action.
@@ -1,23 +1,48 @@
1
1
  import { LucidCardFieldDisplaySettings, SerializedLucidCardFieldDisplaySettings } from './cardfielddisplaysettings';
2
2
  export interface CardIntegrationConfig {
3
- /**
4
- * The data fields to be displayed on cards, as data-linked text fields
5
- */
6
- fieldNames: string[];
7
- /**
8
- * The data fields to be displayed on cards as data graphics
9
- */
10
- fieldDisplaySettings?: Map<string, LucidCardFieldDisplaySettings>;
11
- /**
12
- * The field name to use as the displayed ID of the card, if any
13
- */
14
- idFieldName?: string;
3
+ cardConfig: {
4
+ /**
5
+ * The data fields to be displayed on cards, as data-linked text fields
6
+ */
7
+ fieldNames: string[];
8
+ /**
9
+ * The data fields to be displayed on cards as data graphics
10
+ */
11
+ fieldDisplaySettings?: Map<string, LucidCardFieldDisplaySettings>;
12
+ /**
13
+ * The field name to use as the displayed ID of the card, if any
14
+ */
15
+ idFieldName?: string;
16
+ };
17
+ cardDetailsPanelConfig: {
18
+ /**
19
+ * The data fields to be displayed in the details panel of a card
20
+ */
21
+ fields: {
22
+ /**
23
+ * The field name
24
+ */
25
+ name: string;
26
+ /**
27
+ * If true then the visibility of this field in the details panel cannot be modified by a user.
28
+ */
29
+ locked?: boolean;
30
+ }[];
31
+ };
15
32
  }
16
33
  /** @ignore */
17
34
  export declare type SerializedCardIntegrationConfig = {
18
- 'f': string[];
19
- 'fd'?: [string, SerializedLucidCardFieldDisplaySettings][];
20
- 'id'?: string;
35
+ 'cc': {
36
+ 'f': string[];
37
+ 'fd'?: [string, SerializedLucidCardFieldDisplaySettings][];
38
+ 'id'?: string;
39
+ };
40
+ 'cdpc': {
41
+ 'f': {
42
+ 'n': string;
43
+ 'l'?: boolean;
44
+ }[];
45
+ };
21
46
  };
22
47
  /** @ignore */
23
48
  export declare function serializeCardIntegrationConfig(config: CardIntegrationConfig): SerializedCardIntegrationConfig;
@@ -5,25 +5,48 @@ const cardfielddisplaysettings_1 = require("./cardfielddisplaysettings");
5
5
  /** @ignore */
6
6
  function serializeCardIntegrationConfig(config) {
7
7
  return {
8
- 'f': config.fieldNames,
9
- 'fd': config.fieldDisplaySettings
10
- ? [...config.fieldDisplaySettings].map(([key, settings]) => [
11
- key,
12
- (0, cardfielddisplaysettings_1.serializeLucidCardFieldDisplaySettings)(settings),
13
- ])
14
- : undefined,
15
- 'id': config.idFieldName,
8
+ 'cc': {
9
+ 'f': config.cardConfig.fieldNames,
10
+ 'fd': config.cardConfig.fieldDisplaySettings
11
+ ? [...config.cardConfig.fieldDisplaySettings].map(([key, settings]) => [
12
+ key,
13
+ (0, cardfielddisplaysettings_1.serializeLucidCardFieldDisplaySettings)(settings),
14
+ ])
15
+ : undefined,
16
+ 'id': config.cardConfig.idFieldName,
17
+ },
18
+ 'cdpc': {
19
+ 'f': config.cardDetailsPanelConfig.fields.map((field) => {
20
+ return {
21
+ 'n': field.name,
22
+ 'l': field.locked,
23
+ };
24
+ }),
25
+ },
16
26
  };
17
27
  }
18
28
  exports.serializeCardIntegrationConfig = serializeCardIntegrationConfig;
19
29
  /** @ignore */
20
30
  function deserializeCardIntegrationConfig(raw) {
21
31
  return {
22
- fieldNames: raw['f'],
23
- fieldDisplaySettings: raw['fd']
24
- ? new Map(raw['fd'].map(([key, settings]) => [key, (0, cardfielddisplaysettings_1.deserializeLucidCardFieldDisplaySettings)(settings)]))
25
- : undefined,
26
- idFieldName: raw['id'],
32
+ cardConfig: {
33
+ fieldNames: raw['cc']['f'],
34
+ fieldDisplaySettings: raw['cc']['fd']
35
+ ? new Map(raw['cc']['fd'].map(([key, settings]) => [
36
+ key,
37
+ (0, cardfielddisplaysettings_1.deserializeLucidCardFieldDisplaySettings)(settings),
38
+ ]))
39
+ : undefined,
40
+ idFieldName: raw['cc']['id'],
41
+ },
42
+ cardDetailsPanelConfig: {
43
+ fields: raw['cdpc']['f'].map((field) => {
44
+ return {
45
+ name: field['n'],
46
+ locked: field['l'],
47
+ };
48
+ }),
49
+ },
27
50
  };
28
51
  }
29
52
  exports.deserializeCardIntegrationConfig = deserializeCardIntegrationConfig;
@@ -1,4 +1,5 @@
1
1
  import { isString } from '../checks';
2
+ import { IframeAttributes } from '../iframe/iframeutils';
2
3
  /**
3
4
  * An enumeration of of the supported unfurl Iframe aspect ratio.
4
5
  * The iframe will be maximized to fit the screen responsively
@@ -64,3 +65,4 @@ export declare function serializeUnfurlIframe(concrete: UnfurlIframe): Serialize
64
65
  export declare function getIFrameHeight(unfurlIframeAspectRatio: UnfurlIframeAspectRatio): number;
65
66
  /** @ignore */
66
67
  export declare function getIFrameWidth(unfurlIframeAspectRatio: UnfurlIframeAspectRatio): number;
68
+ export declare function generateIframeAttributes(unfurlIframe: UnfurlIframe): IframeAttributes;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIFrameWidth = exports.getIFrameHeight = exports.serializeUnfurlIframe = exports.deserializeUnfurlIframe = exports.isValidUnfurlIframe = exports.UnfurlIframeAspectRatio = void 0;
3
+ exports.generateIframeAttributes = exports.getIFrameWidth = exports.getIFrameHeight = exports.serializeUnfurlIframe = exports.deserializeUnfurlIframe = exports.isValidUnfurlIframe = exports.UnfurlIframeAspectRatio = void 0;
4
4
  const checks_1 = require("../checks");
5
+ const iframeutils_1 = require("../iframe/iframeutils");
5
6
  const validators_1 = require("../validators/validators");
6
7
  /**
7
8
  * An enumeration of of the supported unfurl Iframe aspect ratio.
@@ -91,3 +92,13 @@ function getIFrameWidth(unfurlIframeAspectRatio) {
91
92
  }
92
93
  }
93
94
  exports.getIFrameWidth = getIFrameWidth;
95
+ function generateIframeAttributes(unfurlIframe) {
96
+ const iframeAttributes = {
97
+ src: unfurlIframe.iframeUrl,
98
+ height: unfurlIframe.aspectRatio ? getIFrameHeight(unfurlIframe.aspectRatio) : iframeutils_1.DEFAULT_IFRAME_HEIGHT,
99
+ width: unfurlIframe.aspectRatio ? getIFrameWidth(unfurlIframe.aspectRatio) : iframeutils_1.DEFAULT_IFRAME_WIDTH,
100
+ title: unfurlIframe.iframeTitle,
101
+ };
102
+ return iframeAttributes;
103
+ }
104
+ exports.generateIframeAttributes = generateIframeAttributes;
@@ -11,7 +11,7 @@ import { SchemaDefinition } from './schemadefinition';
11
11
  export declare class DataSourceProxy extends PropertyStoreProxy {
12
12
  readonly id: string;
13
13
  /**
14
- * @param id ID of the collection on the current document
14
+ * @param id ID of the dataSource on the current document
15
15
  * @param client
16
16
  */
17
17
  constructor(id: string, client: EditorClient);
@@ -12,7 +12,7 @@ const collectionproxy_1 = require("./collectionproxy");
12
12
  */
13
13
  class DataSourceProxy extends propertystoreproxy_1.PropertyStoreProxy {
14
14
  /**
15
- * @param id ID of the collection on the current document
15
+ * @param id ID of the dataSource on the current document
16
16
  * @param client
17
17
  */
18
18
  constructor(id, client) {
@@ -41,12 +41,7 @@ class ExperimentalLinkUnfurlBlockProxy extends blockproxy_1.BlockProxy {
41
41
  * @ignore
42
42
  */
43
43
  setIframe(unfurlIframe) {
44
- const iframeAttributes = {
45
- src: unfurlIframe.iframeUrl,
46
- height: unfurlIframe.aspectRatio ? (0, unfurliframe_1.getIFrameHeight)(unfurlIframe.aspectRatio) : iframeutils_1.DEFAULT_IFRAME_HEIGHT,
47
- width: unfurlIframe.aspectRatio ? (0, unfurliframe_1.getIFrameWidth)(unfurlIframe.aspectRatio) : iframeutils_1.DEFAULT_IFRAME_WIDTH,
48
- title: unfurlIframe.iframeTitle,
49
- };
44
+ const iframeAttributes = (0, unfurliframe_1.generateIframeAttributes)(unfurlIframe);
50
45
  this.properties.set('LinkUnfurlIframeHtml', (0, iframeutils_1.generateIFrameHTML)(iframeAttributes));
51
46
  this.properties.set('LinkUnfurlIframeHeight', iframeAttributes.height);
52
47
  this.properties.set('LinkUnfurlIframeWidth', iframeAttributes.width);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TaskManagementCardIntegration = void 0;
4
+ const lucid_extension_sdk_1 = require("../../lucid-extension-sdk");
4
5
  const cardintegration_1 = require("../core/cardintegration/cardintegration");
5
6
  const cardintegrationconfig_1 = require("../core/cardintegration/cardintegrationconfig");
6
7
  const collectiondefinition_1 = require("../data/collectiondefinition");
@@ -36,10 +37,19 @@ class TaskManagementCardIntegration {
36
37
  const getFieldsActionName = TaskManagementCardIntegration.nextHookName();
37
38
  this.client.registerAction(getFieldsActionName, async (param) => {
38
39
  const collection = new collectionproxy_1.CollectionProxy(param['c'], this.client);
39
- const fields = await card.getAllFields(collection);
40
+ const fields = await card.fieldConfiguration.getAllFields(collection);
40
41
  const serializedFields = (0, cardintegration_1.serializeCardFieldArrayDefinition)(fields);
41
42
  return serializedFields;
42
43
  });
44
+ let onSelectedFieldsChangeActionName = undefined;
45
+ const onSelectedFieldsChange = card.fieldConfiguration.onSelectedFieldsChange;
46
+ if (onSelectedFieldsChange) {
47
+ onSelectedFieldsChangeActionName = TaskManagementCardIntegration.nextHookName();
48
+ this.client.registerAction(onSelectedFieldsChangeActionName, (param) => {
49
+ const dataSource = new lucid_extension_sdk_1.DataSourceProxy(param['ds'], this.client);
50
+ onSelectedFieldsChange(dataSource, param['sf']);
51
+ });
52
+ }
43
53
  const getDefaultConfigActionName = TaskManagementCardIntegration.nextHookName();
44
54
  this.client.registerAction(getDefaultConfigActionName, async (param) => {
45
55
  const collection = new collectionproxy_1.CollectionProxy(param['c'], this.client);
@@ -52,10 +62,14 @@ class TaskManagementCardIntegration {
52
62
  }
53
63
  const serialized = {
54
64
  'n': card.label,
65
+ 'dcn': card.dataConnectorName,
55
66
  'il': card.itemLabel,
56
67
  'isl': card.itemsLabel,
57
68
  'u': card.iconUrl,
58
- 'gf': getFieldsActionName,
69
+ 'fc': {
70
+ 'gf': getFieldsActionName,
71
+ 'osfc': onSelectedFieldsChangeActionName,
72
+ },
59
73
  'gdc': getDefaultConfigActionName,
60
74
  'i': showIntroActionName,
61
75
  };