lucid-extension-sdk 0.0.84 → 0.0.85

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.84",
3
+ "version": "0.0.85",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -28,6 +28,7 @@ export declare const enum CommandName {
28
28
  AwaitImport = "ai",
29
29
  Bootstrap = "b",
30
30
  CancelDragBlockToCanvas = "cdc",
31
+ CanEditPackageSettings = "ceps",
31
32
  Confirm = "c",
32
33
  CreateBlock = "cb",
33
34
  CreateCollection = "cc",
@@ -51,6 +52,7 @@ export declare const enum CommandName {
51
52
  GetDataItemField = "gdif",
52
53
  GetElementType = "get",
53
54
  GetItemPageId = "gip",
55
+ GetPackageSettings = "gps",
54
56
  GetProduct = "gpr",
55
57
  GetProperty = "gp",
56
58
  GetReferenceKey = "grk",
@@ -95,6 +97,7 @@ export declare const enum CommandName {
95
97
  SetText = "st",
96
98
  ShowModal = "sm",
97
99
  ShowPanel = "spn",
100
+ ShowPackageSettingsModal = "spsm",
98
101
  SleepForTestCase = "sleep",
99
102
  StartDragBlockToCanvas = "sdc",
100
103
  StartPDFUploadRequest = "pdf",
@@ -143,6 +146,10 @@ export declare type CommandArgs = {
143
146
  query: BootstrapQuery;
144
147
  result: BootstrapResult;
145
148
  };
149
+ [CommandName.CanEditPackageSettings]: {
150
+ query: CanEditPackageSettingsQuery;
151
+ result: CanEditPackageSettingsResult;
152
+ };
146
153
  [CommandName.CancelDragBlockToCanvas]: {
147
154
  query: CancelDragBlockToCanvasQuery;
148
155
  result: CancelDragBlockToCanvasResult;
@@ -239,6 +246,10 @@ export declare type CommandArgs = {
239
246
  query: GetItemPageIdQuery;
240
247
  result: GetItemPageIdResult;
241
248
  };
249
+ [CommandName.GetPackageSettings]: {
250
+ query: GetPackageSettingsQuery;
251
+ result: GetPackageSettingsResult;
252
+ };
242
253
  [CommandName.GetProduct]: {
243
254
  query: GetProductQuery;
244
255
  result: GetProductResult;
@@ -411,6 +422,10 @@ export declare type CommandArgs = {
411
422
  query: ShowModalQuery;
412
423
  result: ShowModalResult;
413
424
  };
425
+ [CommandName.ShowPackageSettingsModal]: {
426
+ query: ShowPackageSettingsModalQuery;
427
+ result: ShowPackageSettingsModalResult;
428
+ };
414
429
  [CommandName.ShowPanel]: {
415
430
  query: ShowPanelQuery;
416
431
  result: ShowPanelResult;
@@ -569,6 +584,8 @@ export declare type BootstrapQuery = {
569
584
  'm'?: boolean;
570
585
  };
571
586
  export declare type BootstrapResult = Promise<void>;
587
+ export declare type CanEditPackageSettingsQuery = undefined;
588
+ export declare type CanEditPackageSettingsResult = Promise<boolean>;
572
589
  export declare type CancelDragBlockToCanvasQuery = void;
573
590
  export declare type CancelDragBlockToCanvasResult = undefined;
574
591
  export declare type ConfirmQuery = {
@@ -771,6 +788,8 @@ export declare type GetPropertyQuery = {
771
788
  'p': string;
772
789
  };
773
790
  export declare type GetPropertyResult = JsonSerializable;
791
+ export declare type GetPackageSettingsQuery = undefined;
792
+ export declare type GetPackageSettingsResult = Promise<Record<string, JsonSerializable>>;
774
793
  export declare type GetRelativeLinePositionQuery = {
775
794
  /** Block or line ID to check the connections on */
776
795
  'id': string;
@@ -1034,6 +1053,8 @@ export declare type ShowModalQuery = {
1034
1053
  'c': string;
1035
1054
  };
1036
1055
  export declare type ShowModalResult = undefined;
1056
+ export declare type ShowPackageSettingsModalQuery = undefined;
1057
+ export declare type ShowPackageSettingsModalResult = Promise<void>;
1037
1058
  export declare type ShowPanelQuery = {
1038
1059
  /** Name of the panel's action for receiving events, i.e. RegisterPanelQuery['n'] */
1039
1060
  'n': string;
@@ -12,6 +12,7 @@ exports.commandTitles = new Map([
12
12
  ["av" /* CommandName.AnimateViewport */, 'AnimateViewport'],
13
13
  ["ai" /* CommandName.AwaitImport */, 'AwaitImport'],
14
14
  ["b" /* CommandName.Bootstrap */, 'Bootstrap'],
15
+ ["ceps" /* CommandName.CanEditPackageSettings */, 'CanEditPackageSettings'],
15
16
  ["cdc" /* CommandName.CancelDragBlockToCanvas */, 'CancelDragBlockToCanvas'],
16
17
  ["c" /* CommandName.Confirm */, 'Confirm'],
17
18
  ["cb" /* CommandName.CreateBlock */, 'CreateBlock'],
@@ -34,6 +35,7 @@ exports.commandTitles = new Map([
34
35
  ["gdif" /* CommandName.GetDataItemField */, 'GetDataItemField'],
35
36
  ["get" /* CommandName.GetElementType */, 'GetElementType'],
36
37
  ["gip" /* CommandName.GetItemPageId */, 'GetItemPageId'],
38
+ ["gps" /* CommandName.GetPackageSettings */, 'GetPackageSettings'],
37
39
  ["gpr" /* CommandName.GetProduct */, 'GetProduct'],
38
40
  ["gp" /* CommandName.GetProperty */, 'GetProperty'],
39
41
  ["grk" /* CommandName.GetReferenceKey */, 'GetReferenceKey'],
@@ -75,6 +77,7 @@ exports.commandTitles = new Map([
75
77
  ["srk" /* CommandName.SetReferenceKey */, 'SetReferenceKey'],
76
78
  ["ssd" /* CommandName.SetShapeData */, 'SetShapeData'],
77
79
  ["sm" /* CommandName.ShowModal */, 'ShowModal'],
80
+ ["spsm" /* CommandName.ShowPackageSettingsModal */, 'ShowPackageSettingsModal'],
78
81
  ["spn" /* CommandName.ShowPanel */, 'ShowPanel'],
79
82
  ["sleep" /* CommandName.SleepForTestCase */, 'SleepForTestCase'],
80
83
  ["sdc" /* CommandName.StartDragBlockToCanvas */, 'StartDragBlockToCanvas'],
@@ -1,3 +1,6 @@
1
1
  export declare function objectEvery<T, O extends {
2
2
  [key: string]: any;
3
3
  }>(obj: O, f: (this: T | undefined, _0: O[typeof _1], _1: string & keyof O, _2: O) => any, opt_this?: T): boolean;
4
+ export declare function entries<T>(obj: {
5
+ [key: string]: T;
6
+ }): [string, T][];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.objectEvery = void 0;
3
+ exports.entries = exports.objectEvery = void 0;
4
4
  function objectEvery(obj, f, opt_this) {
5
5
  for (const key in obj) {
6
6
  if (!f.call(opt_this, obj[key], key, obj)) {
@@ -10,3 +10,8 @@ function objectEvery(obj, f, opt_this) {
10
10
  return true;
11
11
  }
12
12
  exports.objectEvery = objectEvery;
13
+ // TODO: Placeholder until we adopt ES8 and can use Object.entries(obj)
14
+ function entries(obj) {
15
+ return Object.keys(obj).map((key) => [key, obj[key]]);
16
+ }
17
+ exports.entries = entries;
@@ -65,6 +65,31 @@ export declare class EditorClient {
65
65
  * @throws A string with an error from the data sync server
66
66
  */
67
67
  performDataAction(flowName: string, dataConnectorName: string, syncDataSourceId?: undefined | string, flowData?: unknown, async?: boolean): Promise<DataActionResponse>;
68
+ /**
69
+ * If the extension package containing this editor extension has configurable settings,
70
+ * show a standard modal allowing the user to view or change those settings.
71
+ *
72
+ * If the user does not have permission to change settings on this installation of this
73
+ * extension, or if no settings exist, an error is thrown.
74
+ *
75
+ * @returns A promise that resolves when the user closes the settings modal.
76
+ */
77
+ showPackageSettingsModal(): Promise<void>;
78
+ /**
79
+ * If the extension package containing this editor extension has configurable settings,
80
+ * fetch the current values of those settings for this installation of this extension.
81
+ *
82
+ * Only settings that have been set by the installing user will have a value in the map,
83
+ * other settings will be missing.
84
+ *
85
+ * @returns A promise that resolves to a map of setting names to current setting values
86
+ */
87
+ getPackageSettings(): Promise<Map<string, JsonSerializable>>;
88
+ /**
89
+ * @returns True if the current user is allowed to edit package settings on this installation
90
+ * of this extension (if any settings exist), or false otherwise.
91
+ */
92
+ canEditPackageSettings(): Promise<boolean>;
68
93
  awaitDataImport(dataConnectorName: string, syncDataSourceId: undefined | string, syncCollectionId: string, primaryKeys: string[], timeout?: number): Promise<CollectionProxy>;
69
94
  /**
70
95
  * Make a network request
@@ -4,6 +4,7 @@ exports.EditorClient = void 0;
4
4
  const commandtypes_1 = require("./commandtypes");
5
5
  const base64_1 = require("./core/base64");
6
6
  const checks_1 = require("./core/checks");
7
+ const object_1 = require("./core/object");
7
8
  const unfurlcallbacks_1 = require("./core/unfurl/unfurlcallbacks");
8
9
  const unfurldetails_1 = require("./core/unfurl/unfurldetails");
9
10
  const unfurlrefresherrortype_1 = require("./core/unfurl/unfurlrefresherrortype");
@@ -119,6 +120,37 @@ class EditorClient {
119
120
  'json': result['j'],
120
121
  };
121
122
  }
123
+ /**
124
+ * If the extension package containing this editor extension has configurable settings,
125
+ * show a standard modal allowing the user to view or change those settings.
126
+ *
127
+ * If the user does not have permission to change settings on this installation of this
128
+ * extension, or if no settings exist, an error is thrown.
129
+ *
130
+ * @returns A promise that resolves when the user closes the settings modal.
131
+ */
132
+ async showPackageSettingsModal() {
133
+ return this.sendCommand("spsm" /* CommandName.ShowPackageSettingsModal */, undefined);
134
+ }
135
+ /**
136
+ * If the extension package containing this editor extension has configurable settings,
137
+ * fetch the current values of those settings for this installation of this extension.
138
+ *
139
+ * Only settings that have been set by the installing user will have a value in the map,
140
+ * other settings will be missing.
141
+ *
142
+ * @returns A promise that resolves to a map of setting names to current setting values
143
+ */
144
+ async getPackageSettings() {
145
+ return new Map((0, object_1.entries)(await this.sendCommand("gps" /* CommandName.GetPackageSettings */, undefined)));
146
+ }
147
+ /**
148
+ * @returns True if the current user is allowed to edit package settings on this installation
149
+ * of this extension (if any settings exist), or false otherwise.
150
+ */
151
+ async canEditPackageSettings() {
152
+ return this.sendCommand("ceps" /* CommandName.CanEditPackageSettings */, undefined);
153
+ }
122
154
  async awaitDataImport(dataConnectorName, syncDataSourceId, syncCollectionId, primaryKeys, timeout = 30000) {
123
155
  return new collectionproxy_1.CollectionProxy(await this.sendCommand("ai" /* CommandName.AwaitImport */, {
124
156
  'n': dataConnectorName,