lucid-extension-sdk 1.1.2 → 1.2.0

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.
Files changed (111) hide show
  1. package/commandtypes.d.ts +36 -8
  2. package/commandtypes.js +1 -1
  3. package/core/cardintegration/cardintegrationautosyncconfig.d.ts +20 -2
  4. package/core/cardintegration/cardintegrationparams.d.ts +4 -0
  5. package/core/cardintegration/lucidcardintegrationregistry.d.ts +4 -6
  6. package/core/cardintegration/lucidcardintegrationregistry.js +11 -219
  7. package/core/checks.d.ts +1 -0
  8. package/core/checks.js +14 -0
  9. package/core/lucidproduct.d.ts +1 -0
  10. package/core/lucidproduct.js +1 -0
  11. package/core/sharedcardintegration/sharedregistryutil.d.ts +58 -1
  12. package/core/sharedcardintegration/sharedregistryutil.js +237 -0
  13. package/core/spreadsheetintegration/lucidspreadsheetintegration.d.ts +13 -0
  14. package/core/spreadsheetintegration/lucidspreadsheetintegrationregistry.d.ts +5 -1
  15. package/core/spreadsheetintegration/lucidspreadsheetintegrationregistry.js +21 -15
  16. package/core/validators/validators.d.ts +1 -0
  17. package/core/validators/validators.js +1 -0
  18. package/data/collectiondefinition.d.ts +2 -0
  19. package/data/collectiondefinition.js +1 -0
  20. package/data/collectionerrortypes.d.ts +4 -0
  21. package/data/collectionerrortypes.js +4 -0
  22. package/data/dataupdatefiltertype.d.ts +1 -0
  23. package/data/displayoptiondefinition.d.ts +5 -0
  24. package/data/displayoptiondefinition.js +2 -0
  25. package/data/fieldconstraintdefinition.d.ts +13 -0
  26. package/data/fieldconstraintdefinition.js +3 -0
  27. package/data/patchcollectionproxy.d.ts +2 -0
  28. package/data/patchcollectionproxy.js +2 -0
  29. package/data/patcherrortype.d.ts +1 -0
  30. package/data/referencekeydefinition.d.ts +6 -5
  31. package/data/referencekeyproxy.d.ts +1 -0
  32. package/data/referencekeyproxy.js +1 -0
  33. package/data/schemadefinition.d.ts +2 -2
  34. package/dataconnector/actions/action.d.ts +24 -1
  35. package/dataconnector/actions/action.js +7 -1
  36. package/dataconnector/actions/dataconnectoractionkeys.d.ts +1 -0
  37. package/dataconnector/actions/patch.d.ts +10 -0
  38. package/dataconnector/actions/patch.js +9 -0
  39. package/dataconnector/actions/patchresponsebody.d.ts +2 -0
  40. package/dataconnector/actions/serializedactions.d.ts +1 -0
  41. package/dataconnector/actions/serializedactions.js +8 -5
  42. package/dataconnector/actions/serializedpatchtypes.d.ts +10 -0
  43. package/dataconnector/actions/serializedpatchtypes.js +5 -0
  44. package/dataconnector/cryptodependencies.d.ts +3 -0
  45. package/dataconnector/dataconnector.d.ts +1 -0
  46. package/dataconnector/dataconnector.js +1 -0
  47. package/dataconnector/datasourcemetadatatypes.d.ts +4 -0
  48. package/dataconnector/datasourcemetadatatypes.js +1 -0
  49. package/dataconnector/datasourceupdatetypes.d.ts +19 -0
  50. package/dataconnector/datasourceupdatetypes.js +19 -1
  51. package/dataconnector/itemrekeyerandrelabeler.d.ts +2 -0
  52. package/dataconnector/itemrekeyerandrelabeler.js +2 -0
  53. package/dataconnector/querycollection/buildpatches.d.ts +38 -0
  54. package/dataconnector/querycollection/buildpatches.js +66 -0
  55. package/dataconnector/querycollection/derivequerycollectionschema.d.ts +15 -0
  56. package/dataconnector/querycollection/derivequerycollectionschema.js +36 -0
  57. package/dataconnector/querycollection/diffprimarykeys.d.ts +21 -0
  58. package/dataconnector/querycollection/diffprimarykeys.js +31 -0
  59. package/dataconnector/querycollection/getquerycollections.d.ts +21 -0
  60. package/dataconnector/querycollection/getquerycollections.js +44 -0
  61. package/dataconnector/querycollection/index.d.ts +5 -0
  62. package/dataconnector/querycollection/index.js +15 -0
  63. package/dataconnector/querycollection/sendquerycollectionpatch.d.ts +15 -0
  64. package/dataconnector/querycollection/sendquerycollectionpatch.js +21 -0
  65. package/document/blockclasses/cardblockproxy.d.ts +8 -1
  66. package/document/blockclasses/cardblockproxy.js +43 -30
  67. package/document/blockclasses/customblockproxy.d.ts +1 -0
  68. package/document/blockclasses/erdblockproxy.d.ts +2 -0
  69. package/document/blockclasses/erdblockproxy.js +2 -0
  70. package/document/blockclasses/legendblockproxy.d.ts +6 -0
  71. package/document/blockclasses/legendblockproxy.js +5 -0
  72. package/document/blockclasses/swimlaneblockproxy.d.ts +2 -0
  73. package/document/blockclasses/swimlaneblockproxy.js +2 -0
  74. package/document/blockclasses/tableblockproxy.d.ts +4 -1
  75. package/document/blockclasses/tableblockproxy.js +4 -1
  76. package/document/blockdefinition.d.ts +2 -2
  77. package/document/blockproxy.d.ts +2 -2
  78. package/document/blockproxy.js +2 -2
  79. package/document/documentaccesspermission.d.ts +1 -0
  80. package/document/documentelement/cardconfigproxy.d.ts +1 -0
  81. package/document/documentelement/cardconfigproxy.js +1 -0
  82. package/document/documentelement/documentelementproxy.d.ts +1 -0
  83. package/document/documentelement/documentelementproxy.js +1 -0
  84. package/document/documentelement/ruleproxy.d.ts +3 -0
  85. package/document/documentelement/ruleproxy.js +3 -0
  86. package/document/elementproxy.d.ts +6 -6
  87. package/document/elementproxy.js +6 -6
  88. package/document/graphdefinition.d.ts +2 -0
  89. package/document/graphdefinition.js +1 -0
  90. package/document/itemproxy.d.ts +4 -0
  91. package/document/itemproxy.js +4 -0
  92. package/document/linedefinition.d.ts +1 -0
  93. package/document/lineproxy.d.ts +2 -0
  94. package/document/lineproxy.js +1 -0
  95. package/document/linetextareapositioning.d.ts +14 -0
  96. package/document/linetextareapositioning.js +11 -2
  97. package/document/mapproxy.d.ts +2 -0
  98. package/document/mapproxy.js +1 -0
  99. package/document/propertystoreproxy.d.ts +7 -0
  100. package/document/propertystoreproxy.js +7 -0
  101. package/document/ruledefinition.d.ts +12 -0
  102. package/document/text/textstyle.d.ts +2 -0
  103. package/index.d.ts +190 -121
  104. package/index.js +583 -135
  105. package/package.json +1 -1
  106. package/ui/menu.d.ts +8 -4
  107. package/ui/menu.js +5 -4
  108. package/ui/modal.d.ts +1 -1
  109. package/ui/panel.d.ts +2 -0
  110. package/ui/viewport.d.ts +3 -2
  111. package/ui/viewport.js +2 -1
package/commandtypes.d.ts CHANGED
@@ -20,7 +20,7 @@ import { PanelLocation } from './ui/panel';
20
20
  * Typically, an extension author will not need to access any of these commands directly, as they are all
21
21
  * exposed through appropriate classes and methods elsewhere in this SDK.
22
22
  *
23
- * To use these directly, use [EditorClient.sendCommand](#classes_editorclient-EditorClient_sendcommand).
23
+ * To use these directly, use {@link EditorClient.sendCommand}.
24
24
  *
25
25
  * FOR DEVELOPERS AT LUCID:
26
26
  * Follow this guide to add new commands: https://lucidatlassian.atlassian.net/wiki/x/3AA3Xww
@@ -174,7 +174,7 @@ export type CommandName = (typeof CommandName)[keyof typeof CommandName];
174
174
  export declare const commandTitles: Map<CommandName, string>;
175
175
  /**
176
176
  * This is a type declaration whose purpose is to allow TypeScript to enforce the correct parameter and
177
- * return types from [EditorClient.sendCommand](#classes_editorclient-EditorClient_sendcommand) based on
177
+ * return types from {@link EditorClient.sendCommand} based on
178
178
  * which command name you pass in as the first parameter.
179
179
  *
180
180
  * IMPORTANT - Before you add a new command bring it up in #api-committee to get feedback
@@ -858,13 +858,11 @@ export type AutoSyncSettings = {
858
858
  'gsf': string;
859
859
  'sqs'?: string | undefined;
860
860
  'syqs'?: string | undefined;
861
- /** getDefaultFilterFields action ID - field-only config */
862
- 'gdf'?: string | undefined;
863
861
  /** searchFields action ID - field-only config */
864
862
  'sf'?: string | undefined;
865
863
  /** syncFields action ID - field-only config */
866
864
  'syf'?: string | undefined;
867
- /** If specified, setup fields that allow user to create query template that auto applies to dynamic tables when created*/
865
+ /** If specified, setup fields that allow user to create query template that auto applies to dynamic tables when created */
868
866
  'dpf'?: {
869
867
  /** Get search fields action */
870
868
  'gsf': string;
@@ -872,8 +870,10 @@ export type AutoSyncSettings = {
872
870
  'gpv': string;
873
871
  } | undefined;
874
872
  'cftqs'?: string | undefined;
875
- /** Get default filter fields action */
873
+ /** Get default filter fields action. Used in both field-only and query-string configurations. */
876
874
  'gdff'?: string | undefined;
875
+ /** Get more filter fields action. Used in both field-only and query-string configurations. */
876
+ 'gmff'?: string | undefined;
877
877
  };
878
878
  export type SerializedFieldConfiguration = {
879
879
  /** Callback to get field definitions for all fields supported by the card integration */
@@ -1137,6 +1137,10 @@ export type AddSpreadsheetIntegrationQuery = {
1137
1137
  [K in keyof SerializedFieldConfiguration]?: SerializedFieldConfiguration[K] | undefined;
1138
1138
  } | undefined;
1139
1139
  'dm'?: DependencyMappingSettings | undefined;
1140
+ /** Auto-sync configuration (only honored when `c` / addCardsIntegration is true) */
1141
+ 'as'?: AutoSyncSettings | undefined;
1142
+ /** Get default config action */
1143
+ 'gdc'?: string | undefined;
1140
1144
  };
1141
1145
  /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
1142
1146
  export type AddSpreadsheetIntegrationResult = undefined;
@@ -1632,7 +1636,19 @@ export type GetOAuthClientIdResult = Promise<string | undefined>;
1632
1636
  export type GetPropertyQuery = {
1633
1637
  /** ID of the LucidElement to read a property from, or undefined to read from the LucidDocument */
1634
1638
  'id'?: string | undefined;
1635
- /** Name of the property to read */
1639
+ /**
1640
+ * Name of the property to read.
1641
+ *
1642
+ * For text area properties, this returns the plain text string by default. To get rich text
1643
+ * (text + inline markup such as bold, italic, links, and line spacing), prefix the text area
1644
+ * name with `Rich:`. For example, `properties.get('Rich:Text')` returns an object with the
1645
+ * structure `{t: string, m: Array}` where `t` is the text content and `m` is an array of
1646
+ * markup entries. Each markup entry has:
1647
+ * - `s` (number): start index
1648
+ * - `e` (number, optional): end index (omitted for block-level markup)
1649
+ * - `n` (string): markup name (e.g. `'b'` for bold, `'i'` for italic, `'lk'` for link, `'p'` for line spacing)
1650
+ * - `v` (any): markup value
1651
+ */
1636
1652
  'p': string;
1637
1653
  };
1638
1654
  export type GetPropertyResult = UnsafeJsonSerializableOrUndefined;
@@ -1982,7 +1998,19 @@ export type SetPropertyQuery = {
1982
1998
  'id'?: string | undefined;
1983
1999
  /** Name of the property to change */
1984
2000
  'p': string;
1985
- /** New value of the property */
2001
+ /**
2002
+ * New value of the property.
2003
+ *
2004
+ * For text area properties, you can pass a plain text string to set the text while preserving
2005
+ * the existing style. To set rich text with inline markup (bold, italic, links, line spacing, etc.),
2006
+ * prefix the text area name in `p` with `Rich:` (e.g. `p: 'Rich:Text'`) and pass an object as
2007
+ * the value with the structure `{t: string, m: Array}` where `t` is the text content and `m`
2008
+ * is an array of markup entries. Each markup entry has:
2009
+ * - `s` (number): start index
2010
+ * - `e` (number, optional): end index
2011
+ * - `n` (string): markup name (e.g. `'b'` for bold, `'i'` for italic, `'lk'` for link, `'p'` for line spacing)
2012
+ * - `v` (any): markup value
2013
+ */
1986
2014
  'v'?: UnsafeJsonSerializableOrUndefined;
1987
2015
  };
1988
2016
  export type SetPropertyResult = undefined;
package/commandtypes.js CHANGED
@@ -8,7 +8,7 @@ const checks_1 = require("./core/checks");
8
8
  * Typically, an extension author will not need to access any of these commands directly, as they are all
9
9
  * exposed through appropriate classes and methods elsewhere in this SDK.
10
10
  *
11
- * To use these directly, use [EditorClient.sendCommand](#classes_editorclient-EditorClient_sendcommand).
11
+ * To use these directly, use {@link EditorClient.sendCommand}.
12
12
  *
13
13
  * FOR DEVELOPERS AT LUCID:
14
14
  * Follow this guide to add new commands: https://lucidatlassian.atlassian.net/wiki/x/3AA3Xww
@@ -74,9 +74,17 @@ export interface QueryStringCardIntegrationAutoSyncConfig extends BaseCardIntegr
74
74
  * type a raw query string.
75
75
  *
76
76
  * @param searchSoFar The fields the user has populated so far (e.g. the selected data source id)
77
- * @returns The filter fields to render
77
+ * @returns The filter fields to always render
78
78
  */
79
79
  getDefaultFilterFields?: (searchSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldDefinition[]>;
80
+ /**
81
+ * Provides the additional filter fields a user can pin from the "More filters" picker.
82
+ * Implementations **MUST exclude** any field already returned by {@link getDefaultFilterFields}.
83
+ *
84
+ * @param searchSoFar The fields the user has populated so far (e.g. the selected data source id)
85
+ * @returns The additional filter fields, excluding default fields
86
+ */
87
+ getMoreFilterFields?: (searchSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldDefinition[]>;
80
88
  }
81
89
  /**
82
90
  * @experimental
@@ -88,10 +96,20 @@ export interface FieldOnlyCardIntegrationAutoSyncConfig extends BaseCardIntegrat
88
96
  * Returns the filter field definitions available for the user to configure. Called whenever the
89
97
  * current field selections change, allowing fields to be dynamically updated based on prior selections.
90
98
  *
99
+ * Keep this callback fast — it is called eagerly whenever the filter form is shown.
100
+ *
91
101
  * @param searchSoFar The filter field values selected so far
92
- * @returns the field definitions to display for filtering
102
+ * @returns the field definitions to display for filtering by default
93
103
  */
94
104
  getDefaultFilterFields: (searchSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldDefinition[]>;
105
+ /**
106
+ * Provides the additional filter fields a user can pin from the "More filters" picker.
107
+ * Implementations **MUST exclude** any field already returned by {@link getDefaultFilterFields}.
108
+ *
109
+ * @param searchSoFar The filter field values selected so far
110
+ * @returns The additional filter fields, excluding default fields
111
+ */
112
+ getMoreFilterFields?: (searchSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldDefinition[]>;
95
113
  /**
96
114
  * Perform a search using the selected filter field values. This should support pagination
97
115
  * (See {@link AutoSyncPaginationSize}).
@@ -56,6 +56,10 @@ export interface GetDefaultFilterFieldsParam {
56
56
  's': [string, SerializedFieldType][];
57
57
  }
58
58
  /** @ignore */
59
+ export interface GetMoreFilterFieldsParam {
60
+ 's': [string, SerializedFieldType][];
61
+ }
62
+ /** @ignore */
59
63
  export interface QuerySyncRemoveNonMatchingLabelParam {
60
64
  'g': string;
61
65
  }
@@ -12,17 +12,15 @@ export declare class LucidCardIntegrationRegistry {
12
12
  name?: string | undefined;
13
13
  dataSourceId?: string | undefined;
14
14
  }) => Promise<ExtensionCardFieldOption[]>): string;
15
- static registerUserSearchCallback(client: EditorClient, callback: (searchText: string, inputSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardUserData[]>): string;
15
+ static registerUserSearchCallback(client: EditorClient, callback: (searchText: string, inputSoFar: Map<string, SerializedFieldType>, fieldData?: {
16
+ name?: string | undefined;
17
+ dataSourceId?: string | undefined;
18
+ }) => Promise<ExtensionCardUserData[]>): string;
16
19
  static registerFieldTypeToCollectionItemsCallback(client: EditorClient, callback: (fieldName: string, value: SerializedFieldType, dataSourceProxy?: DataSourceProxy | undefined) => Promise<[string, SerializedFields][]>): string;
17
20
  static registerFieldLabelIconsCallback(client: EditorClient, callback: (dataSourceProxy: DataSourceProxy, dataItemProxy: DataItemProxy) => Promise<ExtensionCardFieldLabelIcons>): string;
18
21
  static registerTagCallback(client: EditorClient, callback: TagCallback): string;
19
22
  static registerBannerActionCallback(client: EditorClient, callback: (actionId: string) => void): string;
20
23
  private static registerDependencyMapping;
21
- private static serializeSearchResult;
22
- /**
23
- * Helper to serialize import results (single or array) to the expected format.
24
- */
25
- private static serializeImportResults;
26
24
  private static registerImportCardFromPastedLinkHandler;
27
25
  /**
28
26
  * Register a card integration.
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LucidCardIntegrationRegistry = void 0;
4
4
  const commandtypes_1 = require("../../commandtypes");
5
- const collectiondefinition_1 = require("../../data/collectiondefinition");
6
5
  const collectionproxy_1 = require("../../data/collectionproxy");
7
6
  const dataitemproxy_1 = require("../../data/dataitemproxy");
8
7
  const datasourceproxy_1 = require("../../data/datasourceproxy");
@@ -11,7 +10,6 @@ const checks_1 = require("../checks");
11
10
  const importcardfromdetails_1 = require("../importcardfromdetails/importcardfromdetails");
12
11
  const cardintegrationdefinitions_1 = require("../sharedcardintegration/cardintegrationdefinitions");
13
12
  const sharedregistryutil_1 = require("../sharedcardintegration/sharedregistryutil");
14
- const cardintegrationautosyncconfig_1 = require("./cardintegrationautosyncconfig");
15
13
  const cardintegrationconfig_1 = require("./cardintegrationconfig");
16
14
  const tabs_1 = require("./cardpaneltabs/tabs");
17
15
  const extensiondatapanellistitem_1 = require("./extensiondatapanel/extensiondatapanellistitem");
@@ -30,31 +28,13 @@ class LucidCardIntegrationRegistry {
30
28
  return name;
31
29
  }
32
30
  static registerFieldSearchCallback(client, callback) {
33
- const name = LucidCardIntegrationRegistry.nextHookName();
34
- client.registerAction(name, async ({ 'i': inputSoFar, 's': searchText, 'fd': serializedFieldData }) => {
35
- const fieldData = serializedFieldData
36
- ? { name: serializedFieldData['n'], dataSourceId: serializedFieldData['ds'] }
37
- : undefined;
38
- const result = await callback(searchText, new Map(inputSoFar), fieldData);
39
- return result.map((option) => (0, cardintegrationdefinitions_1.serializeCardFieldOption)(option));
40
- });
41
- return name;
31
+ return (0, sharedregistryutil_1.registerFieldSearchCallback)(client, callback, () => LucidCardIntegrationRegistry.nextHookName());
42
32
  }
43
33
  static registerUserSearchCallback(client, callback) {
44
- const name = LucidCardIntegrationRegistry.nextHookName();
45
- client.registerAction(name, async ({ 'i': inputSoFar, 's': searchText }) => {
46
- const result = await callback(searchText, new Map(inputSoFar));
47
- return result.map((userData) => (0, cardintegrationdefinitions_1.serializeCardUserData)(userData));
48
- });
49
- return name;
34
+ return (0, sharedregistryutil_1.registerUserSearchCallback)(client, callback, () => LucidCardIntegrationRegistry.nextHookName());
50
35
  }
51
36
  static registerFieldTypeToCollectionItemsCallback(client, callback) {
52
- const name = LucidCardIntegrationRegistry.nextHookName();
53
- client.registerAction(name, async ({ 'd': dataSourceId, 'v': value, 'f': fieldName }) => {
54
- const dataSourceProxy = dataSourceId ? new datasourceproxy_1.DataSourceProxy(dataSourceId, client) : undefined;
55
- return await callback(fieldName, value, dataSourceProxy);
56
- });
57
- return name;
37
+ return (0, sharedregistryutil_1.registerFieldTypeToCollectionItemsCallback)(client, callback, () => LucidCardIntegrationRegistry.nextHookName());
58
38
  }
59
39
  static registerFieldLabelIconsCallback(client, callback) {
60
40
  const name = LucidCardIntegrationRegistry.nextHookName();
@@ -99,50 +79,6 @@ class LucidCardIntegrationRegistry {
99
79
  static registerDependencyMapping(client, cardIntegration, serialized) {
100
80
  return (0, sharedregistryutil_1.registerDependencyMapping)(client, cardIntegration, serialized, () => LucidCardIntegrationRegistry.nextHookName());
101
81
  }
102
- static serializeSearchResult(searchResult) {
103
- var _a;
104
- return {
105
- 'srs': searchResult.searchResults.map((resultPerCollection) => ({
106
- 'd': (0, collectiondefinition_1.serializeCollectionDefinition)(resultPerCollection.data),
107
- 'f': (0, cardintegrationdefinitions_1.serializeCardFieldArrayDefinition)(resultPerCollection.fields),
108
- 'm': resultPerCollection.partialImportMetadata && {
109
- 'cid': resultPerCollection.partialImportMetadata.collectionId,
110
- 'sid': resultPerCollection.partialImportMetadata.syncDataSourceId,
111
- },
112
- })),
113
- 'ipsr': searchResult.itemsPerSearchResult,
114
- 'e': searchResult.error,
115
- 'bs': (_a = searchResult.banners) === null || _a === void 0 ? void 0 : _a.map((banner) => ({
116
- 'ty': banner.type,
117
- 'msg': banner.message,
118
- 'btyp': banner.bannerType,
119
- 'actbtn': banner.actionButton
120
- ? {
121
- 'lab': banner.actionButton.label,
122
- 'aid': banner.actionButton.actionId,
123
- 'href': banner.actionButton.href,
124
- }
125
- : undefined,
126
- })),
127
- };
128
- }
129
- /**
130
- * Helper to serialize import results (single or array) to the expected format.
131
- */
132
- static serializeImportResults(result) {
133
- if ((0, checks_1.isArray)(result)) {
134
- return result.map((importResult) => {
135
- return {
136
- 'c': importResult.collection.id,
137
- 'pks': importResult.primaryKeys,
138
- };
139
- });
140
- }
141
- return {
142
- 'c': result.collection.id,
143
- 'pks': result.primaryKeys,
144
- };
145
- }
146
82
  static registerImportCardFromPastedLinkHandler(client, cardIntegration, serialized) {
147
83
  if (!cardIntegration.importCardFromPastedLink) {
148
84
  return;
@@ -175,7 +111,7 @@ class LucidCardIntegrationRegistry {
175
111
  * Register a card integration.
176
112
  */
177
113
  static addCardIntegration(client, cardIntegration) {
178
- var _a, _b, _c, _d, _e, _f;
114
+ var _a, _b, _c, _d;
179
115
  const getFieldsActionName = LucidCardIntegrationRegistry.nextHookName();
180
116
  client.registerAction(getFieldsActionName, async (param) => {
181
117
  const dataSource = new datasourceproxy_1.DataSourceProxy(param['d'], client);
@@ -282,32 +218,21 @@ class LucidCardIntegrationRegistry {
282
218
  const result = await importModal.search(new Map(param), offset, limit);
283
219
  if (!(0, cardintegrationdefinitions_1.isSearchResult)(result)) {
284
220
  if ((0, checks_1.isArray)(result)) {
285
- return this.serializeSearchResult({
221
+ return (0, sharedregistryutil_1.serializeSearchResult)({
286
222
  searchResults: result,
287
223
  });
288
224
  }
289
225
  else {
290
- return this.serializeSearchResult({
226
+ return (0, sharedregistryutil_1.serializeSearchResult)({
291
227
  searchResults: [result],
292
228
  });
293
229
  }
294
230
  }
295
- return this.serializeSearchResult(result);
231
+ return (0, sharedregistryutil_1.serializeSearchResult)(result);
296
232
  });
297
233
  client.registerAction(serialized['im']['i'], async ({ 'pks': primaryKeys, 's': searchFields }) => {
298
234
  const result = await importModal.import(primaryKeys, new Map(searchFields));
299
- if ((0, checks_1.isArray)(result)) {
300
- return result.map((importResult) => {
301
- return {
302
- 'c': importResult.collection.id,
303
- 'pks': importResult.primaryKeys,
304
- };
305
- });
306
- }
307
- return {
308
- 'c': result.collection.id,
309
- 'pks': result.primaryKeys,
310
- };
235
+ return (0, sharedregistryutil_1.serializeImportResults)(result);
311
236
  });
312
237
  if (serialized['im']['os']) {
313
238
  client.registerAction(serialized['im']['os'], async () => {
@@ -336,146 +261,13 @@ class LucidCardIntegrationRegistry {
336
261
  });
337
262
  }
338
263
  if (cardIntegration.autoSync) {
339
- const autoSync = cardIntegration.autoSync;
340
- serialized['as'] = {
341
- 'gsf': LucidCardIntegrationRegistry.nextHookName(),
342
- };
343
- if (autoSync.phrases) {
344
- serialized['as']['p'] = {
345
- 'h': autoSync.phrases.header,
346
- 'l': autoSync.phrases.label,
347
- 'qph': autoSync.phrases.queryPlaceholder,
348
- 'rnml': LucidCardIntegrationRegistry.nextHookName(),
349
- 'nml': autoSync.phrases.noMatchedLabel,
350
- 'esl': autoSync.phrases.emptyStateLabel,
351
- };
352
- client.registerAction(serialized['as']['p']['rnml'], ({ 'g': inputSoFar }) => {
353
- var _a;
354
- if (!(0, cardintegrationautosyncconfig_1.isSupportedAutoSyncGeneratorType)(inputSoFar)) {
355
- return '';
356
- }
357
- return (_a = autoSync.phrases) === null || _a === void 0 ? void 0 : _a.removeNonMatchingLabel(inputSoFar);
358
- });
359
- if ((_a = autoSync.phrases) === null || _a === void 0 ? void 0 : _a.syncingGrowlMessage) {
360
- serialized['as']['p']['sgm'] = LucidCardIntegrationRegistry.nextHookName();
361
- client.registerAction(serialized['as']['p']['sgm'], ({ 'c': count }) => {
362
- var _a, _b;
363
- return (_b = (_a = autoSync.phrases) === null || _a === void 0 ? void 0 : _a.syncingGrowlMessage) === null || _b === void 0 ? void 0 : _b.call(_a, count);
364
- });
365
- }
366
- if ((_b = autoSync.phrases) === null || _b === void 0 ? void 0 : _b.removingGrowlMessage) {
367
- serialized['as']['p']['rgm'] = LucidCardIntegrationRegistry.nextHookName();
368
- client.registerAction(serialized['as']['p']['rgm'], ({ 'c': count }) => {
369
- var _a, _b;
370
- return (_b = (_a = autoSync.phrases) === null || _a === void 0 ? void 0 : _a.removingGrowlMessage) === null || _b === void 0 ? void 0 : _b.call(_a, count);
371
- });
372
- }
373
- }
374
- client.registerAction(serialized['as']['gsf'], async ({ 'i': inputSoFar }) => {
375
- const result = await autoSync.getSyncDataSourceIdField(new Map(inputSoFar));
376
- return (0, cardintegrationdefinitions_1.serializeCardFieldArrayDefinition)(result);
377
- });
378
- if ('searchFields' in autoSync) {
379
- const fieldOnlyAutoSync = autoSync;
380
- serialized['as']['gdf'] = LucidCardIntegrationRegistry.nextHookName();
381
- client.registerAction(serialized['as']['gdf'], async ({ 'i': inputSoFar }) => {
382
- const result = await fieldOnlyAutoSync.getDefaultFilterFields(new Map(inputSoFar));
383
- return (0, cardintegrationdefinitions_1.serializeCardFieldArrayDefinition)(result);
384
- });
385
- serialized['as']['sf'] = LucidCardIntegrationRegistry.nextHookName();
386
- client.registerAction(serialized['as']['sf'], async ({ 'f': fields, 'if': instanceFields, 'pn': pageNumber, 'npt': nextPageToken, }) => {
387
- const result = await fieldOnlyAutoSync.searchFields(new Map(fields), new Map(instanceFields), pageNumber, nextPageToken);
388
- if (result) {
389
- return this.serializeSearchResult(result);
390
- }
391
- else {
392
- return this.serializeSearchResult({
393
- searchResults: [],
394
- error: 'Unknown Error Occurred',
395
- });
396
- }
397
- });
398
- serialized['as']['syf'] = LucidCardIntegrationRegistry.nextHookName();
399
- client.registerAction(serialized['as']['syf'], async ({ 'f': fields, 'if': instanceFields }) => {
400
- var _a;
401
- const result = (_a = (await fieldOnlyAutoSync.syncFields(new Map(fields), new Map(instanceFields)))) !== null && _a !== void 0 ? _a : [];
402
- return LucidCardIntegrationRegistry.serializeImportResults(result);
403
- });
404
- }
405
- else {
406
- const queryStringAutoSync = autoSync;
407
- if (queryStringAutoSync.searchQueryString) {
408
- serialized['as']['sqs'] = LucidCardIntegrationRegistry.nextHookName();
409
- client.registerAction(serialized['as']['sqs'], async ({ 'qs': queryString, 'of': otherFields, 'pn': pageNumber, 'npt': nextPageToken, }) => {
410
- var _a;
411
- const result = await ((_a = queryStringAutoSync.searchQueryString) === null || _a === void 0 ? void 0 : _a.call(queryStringAutoSync, queryString, new Map(otherFields), pageNumber, nextPageToken));
412
- if (result) {
413
- return this.serializeSearchResult(result);
414
- }
415
- else {
416
- return this.serializeSearchResult({
417
- searchResults: [],
418
- error: 'Unknown Error Occurred',
419
- });
420
- }
421
- });
422
- }
423
- if (queryStringAutoSync.syncQueryString) {
424
- serialized['as']['syqs'] = LucidCardIntegrationRegistry.nextHookName();
425
- client.registerAction(serialized['as']['syqs'], async ({ 'qs': queryString, 'of': otherFields }) => {
426
- var _a, _b;
427
- const result = (_b = (await ((_a = queryStringAutoSync.syncQueryString) === null || _a === void 0 ? void 0 : _a.call(queryStringAutoSync, queryString, new Map(otherFields))))) !== null && _b !== void 0 ? _b : [];
428
- return LucidCardIntegrationRegistry.serializeImportResults(result);
429
- });
430
- }
431
- if (queryStringAutoSync.convertFiltersToQueryString) {
432
- serialized['as']['cftqs'] = LucidCardIntegrationRegistry.nextHookName();
433
- client.registerAction(serialized['as']['cftqs'], async ({ 'ff': filterFields }) => {
434
- var _a;
435
- const result = await ((_a = queryStringAutoSync.convertFiltersToQueryString) === null || _a === void 0 ? void 0 : _a.call(queryStringAutoSync, new Map(filterFields)));
436
- if ((0, cardintegrationautosyncconfig_1.isConvertFiltersToQueryStringResult)(result)) {
437
- return {
438
- 'qs': result.queryString,
439
- 'e': result.error,
440
- };
441
- }
442
- return result;
443
- });
444
- }
445
- if (queryStringAutoSync.getDefaultFilterFields) {
446
- serialized['as']['gdff'] = LucidCardIntegrationRegistry.nextHookName();
447
- client.registerAction(serialized['as']['gdff'], async ({ 's': searchSoFar }) => {
448
- var _a, _b;
449
- const result = (_b = (await ((_a = queryStringAutoSync.getDefaultFilterFields) === null || _a === void 0 ? void 0 : _a.call(queryStringAutoSync, new Map(searchSoFar))))) !== null && _b !== void 0 ? _b : [];
450
- return (0, cardintegrationdefinitions_1.serializeCardFieldArrayDefinition)(result);
451
- });
452
- }
453
- }
454
- if (autoSync.documentPresetSetupFields) {
455
- const documentPresetSetupFields = autoSync.documentPresetSetupFields;
456
- serialized['as']['dpf'] = {
457
- 'gsf': LucidCardIntegrationRegistry.nextHookName(),
458
- 'gpv': LucidCardIntegrationRegistry.nextHookName(),
459
- };
460
- client.registerAction(serialized['as']['dpf']['gsf'], async ({ 's': searchSoFar }) => {
461
- const result = await documentPresetSetupFields.getSearchFields(new Map(searchSoFar));
462
- return (0, cardintegrationdefinitions_1.serializeCardFieldArrayDefinition)(result);
463
- });
464
- client.registerAction(serialized['as']['dpf']['gpv'], async ({ 'f': fields }) => {
465
- const result = await documentPresetSetupFields.generatePresetValue(new Map(fields));
466
- return {
467
- 'dcn': result.dataConnectorName,
468
- 'iid': result.instanceId,
469
- 'q': result.query,
470
- };
471
- });
472
- }
264
+ serialized['as'] = (0, sharedregistryutil_1.registerAutoSync)(client, cardIntegration.autoSync, () => LucidCardIntegrationRegistry.nextHookName());
473
265
  }
474
266
  if (cardIntegration.fieldConfiguration.customFieldDisplaySettings) {
475
267
  serialized['fc']['cfds'] = {
476
268
  'd': cardIntegration.fieldConfiguration.customFieldDisplaySettings.defaultToMultilineText,
477
- 'uri': (_d = (_c = cardIntegration.fieldConfiguration) === null || _c === void 0 ? void 0 : _c.customFieldDisplaySettings) === null || _d === void 0 ? void 0 : _d.useRoundIcons,
478
- 'dadr': (_f = (_e = cardIntegration.fieldConfiguration) === null || _e === void 0 ? void 0 : _e.customFieldDisplaySettings) === null || _f === void 0 ? void 0 : _f.displayMappedDatesAsDateRange,
269
+ 'uri': (_b = (_a = cardIntegration.fieldConfiguration) === null || _a === void 0 ? void 0 : _a.customFieldDisplaySettings) === null || _b === void 0 ? void 0 : _b.useRoundIcons,
270
+ 'dadr': (_d = (_c = cardIntegration.fieldConfiguration) === null || _c === void 0 ? void 0 : _c.customFieldDisplaySettings) === null || _d === void 0 ? void 0 : _d.displayMappedDatesAsDateRange,
479
271
  };
480
272
  }
481
273
  if (cardIntegration.fieldConfiguration.nonCustomizableFields) {
package/core/checks.d.ts CHANGED
@@ -138,6 +138,7 @@ export declare function isTypedTuple<const Tuple extends readonly unknown[]>(gua
138
138
  * @return Whether variable is a map.
139
139
  */
140
140
  export declare function isMap(val: unknown): val is Map<unknown, unknown>;
141
+ export declare function isTypedMap<K, V>(kTest: (k: unknown) => k is K, vTest: (v: unknown) => v is V): (val: unknown) => val is Map<K, V>;
141
142
  export type Tuple<T, N extends number> = N extends N ? (number extends N ? T[] : TupleOfHelper<T, N, []>) : never;
142
143
  type TupleOfHelper<T, N extends number, R extends unknown[]> = R['length'] extends N ? R : TupleOfHelper<T, N, [T, ...R]>;
143
144
  export declare function isExactLength<T, N extends number>(arr: readonly T[], exactLength: N): arr is Tuple<T, N>;
package/core/checks.js CHANGED
@@ -21,6 +21,7 @@ exports.isTypedArray = isTypedArray;
21
21
  exports.isDefinedArray = isDefinedArray;
22
22
  exports.isTypedTuple = isTypedTuple;
23
23
  exports.isMap = isMap;
24
+ exports.isTypedMap = isTypedMap;
24
25
  exports.isExactLength = isExactLength;
25
26
  exports.isAtLeastLength = isAtLeastLength;
26
27
  exports.isPair = isPair;
@@ -215,6 +216,19 @@ function isTypedTuple(guards) {
215
216
  function isMap(val) {
216
217
  return val instanceof Map;
217
218
  }
219
+ function isTypedMap(kTest, vTest) {
220
+ return function (val) {
221
+ if (!isMap(val)) {
222
+ return false;
223
+ }
224
+ for (const [k, v] of val) {
225
+ if (!kTest(k) || !vTest(v)) {
226
+ return false;
227
+ }
228
+ }
229
+ return true;
230
+ };
231
+ }
218
232
  function isExactLength(arr, exactLength) {
219
233
  return arr.length === exactLength;
220
234
  }
@@ -4,6 +4,7 @@
4
4
  export declare const LucidProduct: {
5
5
  readonly Chart: "chart";
6
6
  readonly Spark: "spark";
7
+ /** @ignore */
7
8
  readonly TeamSpaces: "teamspaces";
8
9
  };
9
10
  export type LucidProduct = (typeof LucidProduct)[keyof typeof LucidProduct];
@@ -7,5 +7,6 @@ exports.LucidProduct = void 0;
7
7
  exports.LucidProduct = {
8
8
  Chart: 'chart',
9
9
  Spark: 'spark',
10
+ /** @ignore */
10
11
  TeamSpaces: 'teamspaces',
11
12
  };
@@ -1,4 +1,61 @@
1
- import { DependencyMappingSettings } from '../../commandtypes';
1
+ import { AutoSyncSettings, DependencyMappingSettings } from '../../commandtypes';
2
+ import { DataSourceProxy } from '../../data/datasourceproxy';
2
3
  import { EditorClient } from '../../editorclient';
4
+ import { type CardIntegrationAutoSyncConfig } from '../cardintegration/cardintegrationautosyncconfig';
5
+ import { SerializedFieldType, SerializedFields } from '../data/serializedfield/serializedfields';
6
+ import { ExtensionCardFieldOption, ExtensionCardUserData, ImportResult, SearchResult } from './cardintegrationdefinitions';
3
7
  import { CardIntegrationDependencyMappingConfig } from './dependencymappingconfig';
8
+ /**
9
+ * Serializes a `SearchResult` into the wire-format object the editor expects. Shared between the
10
+ * import-modal `search` path and the auto-sync `searchQueryString` / `searchFields` paths.
11
+ */
12
+ export declare function serializeSearchResult(searchResult: SearchResult): {
13
+ srs: {
14
+ d: import("../../data/collectiondefinition").SerializedCollectionDefinition;
15
+ f: import("./cardintegrationdefinitions").SerializedExtensionCardFieldDefinition[];
16
+ m: {
17
+ cid: string;
18
+ sid: string | undefined;
19
+ } | undefined;
20
+ }[];
21
+ ipsr: number | undefined;
22
+ e: string | undefined;
23
+ bs: {
24
+ ty: "error-banner";
25
+ msg: string;
26
+ btyp: import("./cardintegrationdefinitions").BannerType | undefined;
27
+ actbtn: {
28
+ lab: string;
29
+ aid: string | undefined;
30
+ href: string | undefined;
31
+ } | undefined;
32
+ }[] | undefined;
33
+ };
34
+ /**
35
+ * Serializes import results (single or array) to the wire-format the editor expects. Shared
36
+ * between the import-modal `import` path, the dependency-mapping path, and the auto-sync `sync*`
37
+ * paths.
38
+ */
39
+ export declare function serializeImportResults(result: ImportResult | ImportResult[]): {
40
+ c: string;
41
+ pks: string[];
42
+ }[] | {
43
+ c: string;
44
+ pks: string[];
45
+ };
46
+ /**
47
+ * Registers the editor-side actions for a `CardIntegrationAutoSyncConfig` on the given client and
48
+ * returns the corresponding `AutoSyncSettings` wire-format payload. Used by both
49
+ * `LucidCardIntegrationRegistry` and `LucidSpreadsheetIntegrationRegistry`.
50
+ */
51
+ export declare function registerAutoSync(client: EditorClient, autoSync: CardIntegrationAutoSyncConfig, getNextHookName: () => string): AutoSyncSettings;
4
52
  export declare function registerDependencyMapping(client: EditorClient, dependencyMapping: CardIntegrationDependencyMappingConfig, serialized: DependencyMappingSettings, getNextHookName: () => string): void;
53
+ export declare function registerFieldSearchCallback(client: EditorClient, callback: (searchText: string, inputSoFar: Map<string, SerializedFieldType>, fieldData?: {
54
+ name?: string | undefined;
55
+ dataSourceId?: string | undefined;
56
+ }) => Promise<ExtensionCardFieldOption[]>, getNextHookName: () => string): string;
57
+ export declare function registerUserSearchCallback(client: EditorClient, callback: (searchText: string, inputSoFar: Map<string, SerializedFieldType>, fieldData?: {
58
+ name?: string | undefined;
59
+ dataSourceId?: string | undefined;
60
+ }) => Promise<ExtensionCardUserData[]>, getNextHookName: () => string): string;
61
+ export declare function registerFieldTypeToCollectionItemsCallback(client: EditorClient, callback: (fieldName: string, value: SerializedFieldType, dataSourceProxy?: DataSourceProxy | undefined) => Promise<[string, SerializedFields][]>, getNextHookName: () => string): string;