lucid-extension-sdk 0.0.436 → 0.0.438

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
@@ -749,6 +749,7 @@ export type AutoSyncSettings = {
749
749
  'h': string;
750
750
  'gsf': string;
751
751
  'sqs'?: string | undefined;
752
+ 'syqs'?: string | undefined;
752
753
  };
753
754
  export type SerializedFieldConfiguration = {
754
755
  /** Callback to get field definitions for all fields supported by the card integration */
@@ -832,6 +833,11 @@ export type AddCardIntegrationQuery = {
832
833
  /** Callback to fetch icons that show next to the field labels in the card details panel */
833
834
  'flic'?: string | undefined;
834
835
  } | undefined;
836
+ /**
837
+ * @experimental
838
+ * Tag callback, to display tag information for any card
839
+ */
840
+ 'tc'?: string | undefined;
835
841
  /**
836
842
  * If specified, the text phrases to show in the dependency mapping UI.
837
843
  * If not specified, dependency mapping for this integration uses the default fallback phrases.
@@ -902,9 +908,9 @@ export type AddCardIntegrationQuery = {
902
908
  'cb': string;
903
909
  } | undefined;
904
910
  /**
905
- * whether the user has access to items
911
+ * Whether the user can edit an item in the data source.
906
912
  */
907
- 'hait'?: string | undefined;
913
+ 'cei'?: string | undefined;
908
914
  };
909
915
  export type AddCardIntegrationResult = undefined;
910
916
  /** @ignore */
@@ -1392,8 +1398,13 @@ export type GetDataItemFieldQuery = {
1392
1398
  'c': string;
1393
1399
  /** Primary key of the data item to read */
1394
1400
  'pk': string;
1395
- /** Name of field to read */
1401
+ /** Name of field (or field label, if 'l' is true) to read */
1396
1402
  'f': string;
1403
+ /**
1404
+ * "label" - If true, get the field by label, not name
1405
+ * (Labels are specified by `FieldLabelOverrides` in `SerializedSchema`)
1406
+ * */
1407
+ 'l'?: boolean | undefined;
1397
1408
  };
1398
1409
  export type GetDataItemFieldResult = SerializedFieldType;
1399
1410
  export type GetDeveloperModeStatusQuery = void;
@@ -1625,6 +1636,8 @@ export type ListDataItemsResult = string[];
1625
1636
  export type ListCollectionFieldsQuery = {
1626
1637
  /** Collection ID to query */
1627
1638
  'id': string;
1639
+ /** "labels" - If true, list field labels. Otherwise, list field names (default) */
1640
+ 'l'?: boolean | undefined;
1628
1641
  };
1629
1642
  export type ListCollectionFieldsResult = string[];
1630
1643
  export type ListDataSourcesQuery = undefined;
@@ -1,8 +1,18 @@
1
1
  import { SerializedFieldType } from '../data/serializedfield/serializedfields';
2
- import { ExtensionCardFieldDefinition, SearchResult } from '../sharedcardintegration/cardintegrationdefinitions';
2
+ import { ExtensionCardFieldDefinition, ImportResult, SearchResult } from '../sharedcardintegration/cardintegrationdefinitions';
3
+ /**
4
+ * The amount of results that will be displayed per page when using pagination. To enable pagination, define the
5
+ * {@link SearchResult.itemsPerSearchResult} field in your search results and return workitems equal to this variable's
6
+ * value.
7
+ */
8
+ export declare const AutoSyncPaginationSize = 50;
9
+ /**
10
+ * This config defines variables and methods required to implement query sync for various container objects in Lucid
11
+ * (e.g. timelines).
12
+ */
3
13
  export interface CardIntegrationAutoSyncConfig {
4
14
  /**
5
- * The header to display for the integration. For example, the Jira integration displays "JQL query sync"
15
+ * The header to display for the integration in the autosync modal.
6
16
  */
7
17
  header: string;
8
18
  /**
@@ -14,10 +24,15 @@ export interface CardIntegrationAutoSyncConfig {
14
24
  */
15
25
  getSyncDataSourceIdField: (searchSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldDefinition[]>;
16
26
  /**
17
- * Perform a search on the query string. This should support pagination.
27
+ * Perform a search on the query string. This should support pagination (See {@link AutoSyncPaginationSize}).
18
28
  *
19
29
  * The syncDataSourceIdNonce is provided in otherFields
20
- * @returns either an error AutoSyncError or an array of issues / tasks / cards represented as an AutoSyncRow
30
+ * @param pageNumber If undefined, will return all results from the search
31
+ * @returns the search results after searching using the given query string.
21
32
  */
22
- searchQueryString?: (queryString: string, otherFields: Map<string, SerializedFieldType>, pageNumber: number, nextPageToken: string | undefined) => Promise<SearchResult>;
33
+ searchQueryString?: (queryString: string, otherFields: Map<string, SerializedFieldType>, pageNumber: number | undefined, nextPageToken: string | undefined) => Promise<SearchResult>;
34
+ /**
35
+ * @returns the ImportResult for the query string.
36
+ */
37
+ syncQueryString?: (queryString: string, otherFields: Map<string, SerializedFieldType>) => Promise<ImportResult | ImportResult[]>;
23
38
  }
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutoSyncPaginationSize = void 0;
4
+ /**
5
+ * The amount of results that will be displayed per page when using pagination. To enable pagination, define the
6
+ * {@link SearchResult.itemsPerSearchResult} field in your search results and return workitems equal to this variable's
7
+ * value.
8
+ */
9
+ exports.AutoSyncPaginationSize = 50;
@@ -26,9 +26,13 @@ export interface SearchParam {
26
26
  export interface QuerySearchParam {
27
27
  'qs': string;
28
28
  'of': [string, SerializedFieldType][];
29
- 'pn': number;
29
+ 'pn': number | undefined;
30
30
  'npt': string | undefined;
31
31
  }
32
+ export interface QuerySyncParam {
33
+ 'qs': string;
34
+ 'of': [string, SerializedFieldType][];
35
+ }
32
36
  /** @ignore */
33
37
  export interface ImportParam {
34
38
  'pks': string[];
@@ -87,7 +91,7 @@ export interface DependencyMappingSelectedIssueHeadingParam {
87
91
  'k': string;
88
92
  }
89
93
  /** @ignore */
90
- export interface FieldLabelIconsCallbackParam {
94
+ export interface DataItemCallbackParam {
91
95
  'd': string;
92
96
  'c': string;
93
97
  'p': string;
@@ -97,7 +101,7 @@ export interface ImportFromSerializedFieldsCallbackParam {
97
101
  'sf': SerializedFields[];
98
102
  }
99
103
  /** @ignore */
100
- export interface HasAccessToItemsParam {
104
+ export interface CanEditItemsParam {
101
105
  'ek': string;
102
106
  'dk'?: string;
103
107
  }
@@ -9,10 +9,10 @@ import { ImportCardFromPastedLinkCallback } from '../importcardfrompastedlink/im
9
9
  import { DependenciesForItems, ExtensionCardFieldDefinition, ExtensionFieldConfiguration, ImportResult } from '../sharedcardintegration/cardintegrationdefinitions';
10
10
  import { CardIntegrationAutoSyncConfig } from './cardintegrationautosyncconfig';
11
11
  import { CardIntegrationConfig } from './cardintegrationconfig';
12
- import { CardUserAccessResult } from './carduseraccessresult';
13
12
  import { DependencyMappingPhrasesType } from './dependencymappingphrases';
14
13
  import { LucidCardIntegrationCustomImportModal } from './lucidcardintegrationcustomimportmodal';
15
14
  import { LucidCardIntegrationStandardImportModal } from './lucidcardintegrationstandardimportmodal';
15
+ import { UserItemEditPermissions } from './useritemeditpermissions';
16
16
  export interface FieldDescriptor {
17
17
  name: string;
18
18
  label?: string | undefined;
@@ -81,6 +81,12 @@ export declare abstract class LucidCardIntegration {
81
81
  */
82
82
  fieldLabelIconsCallback?: string;
83
83
  };
84
+ /**
85
+ * @experimental Optional. Callback function to derive a tag for any given card.
86
+ * A tag is a combination of a text label (preferably short, less than two words) and an icon,
87
+ * which can provide extra user-facing information in the card details panel.
88
+ */
89
+ tagCallback?: string;
84
90
  /** If we are only able to search by name and not email in the card integration (ex: for JDC) */
85
91
  searchUserByName?: boolean;
86
92
  /** This is used to search for users in the card integration. It returns an additional email field of the user if available.*/
@@ -150,7 +156,7 @@ export declare abstract class LucidCardIntegration {
150
156
  */
151
157
  importFromSerializedFields?: (data: SerializedFields[]) => Promise<ImportCardFromDetails>;
152
158
  /**
153
- * @experimental When defined, allows the extension to make cards that the user doesn't have access to view-only.
159
+ * @experimental When defined, allows the extension to make cards that the user can't edit view-only.
154
160
  */
155
- hasAccessToItems?: (editedKey: string, dependencyKey: string | undefined) => Promise<CardUserAccessResult>;
161
+ canEditItems?: (editedKey: string, dependencyKey: string | undefined) => Promise<UserItemEditPermissions>;
156
162
  }
@@ -2,7 +2,7 @@ import { DataItemProxy } from '../../data/dataitemproxy';
2
2
  import { DataSourceProxy } from '../../data/datasourceproxy';
3
3
  import { EditorClient } from '../../editorclient';
4
4
  import { SerializedFieldType } from '../data/serializedfield/serializedfields';
5
- import { ExtensionCardFieldLabelIcons, ExtensionCardFieldOption, ExtensionCardUserData } from '../sharedcardintegration/cardintegrationdefinitions';
5
+ import { ExtensionCardFieldLabelIcons, ExtensionCardFieldOption, ExtensionCardUserData, TagCallback } from '../sharedcardintegration/cardintegrationdefinitions';
6
6
  import { LucidCardIntegration } from './lucidcardintegration';
7
7
  export declare class LucidCardIntegrationRegistry {
8
8
  private static nextHookId;
@@ -14,8 +14,13 @@ export declare class LucidCardIntegrationRegistry {
14
14
  }) => Promise<ExtensionCardFieldOption[]>): string;
15
15
  static registerUserSearchCallback(client: EditorClient, callback: (searchText: string, inputSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardUserData[]>): string;
16
16
  static registerFieldLabelIconsCallback(client: EditorClient, callback: (dataSourceProxy: DataSourceProxy, dataItemProxy: DataItemProxy) => Promise<ExtensionCardFieldLabelIcons>): string;
17
+ static registerTagCallback(client: EditorClient, callback: TagCallback): string;
17
18
  private static registerDependencyMapping;
18
19
  private static serializeSearchResult;
20
+ /**
21
+ * Helper to serialize import results (single or array) to the expected format.
22
+ */
23
+ private static serializeImportResults;
19
24
  private static registerImportCardFromPastedLinkHandler;
20
25
  /**
21
26
  * Register a card integration.
@@ -10,8 +10,8 @@ const checks_1 = require("../checks");
10
10
  const importcardfromdetails_1 = require("../importcardfromdetails/importcardfromdetails");
11
11
  const cardintegrationdefinitions_1 = require("../sharedcardintegration/cardintegrationdefinitions");
12
12
  const cardintegrationconfig_1 = require("./cardintegrationconfig");
13
- const carduseraccessresult_1 = require("./carduseraccessresult");
14
13
  const lucidcardintegrationcustomimportmodal_1 = require("./lucidcardintegrationcustomimportmodal");
14
+ const useritemeditpermissions_1 = require("./useritemeditpermissions");
15
15
  class LucidCardIntegrationRegistry {
16
16
  static nextHookName() {
17
17
  return '__lucidcard__hook' + LucidCardIntegrationRegistry.nextHookId++;
@@ -60,6 +60,21 @@ class LucidCardIntegrationRegistry {
60
60
  });
61
61
  return name;
62
62
  }
63
+ static registerTagCallback(client, callback) {
64
+ const name = LucidCardIntegrationRegistry.nextHookName();
65
+ client.registerAction(name, async ({ 'd': dataSourceId, 'c': collectionId, 'p': primaryKey, }) => {
66
+ const dataSourceProxy = new datasourceproxy_1.DataSourceProxy(dataSourceId, client);
67
+ const collectionProxy = new collectionproxy_1.CollectionProxy(collectionId, client);
68
+ const dataItemProxy = new dataitemproxy_1.DataItemProxy(primaryKey, collectionProxy, client);
69
+ const result = await callback(dataSourceProxy, collectionProxy, dataItemProxy);
70
+ if (result === undefined) {
71
+ return undefined;
72
+ }
73
+ const serializedResult = (0, cardintegrationdefinitions_1.serializeTagCallbackResult)(result);
74
+ return serializedResult;
75
+ });
76
+ return name;
77
+ }
63
78
  static registerDependencyMapping(client, cardIntegration, serialized) {
64
79
  if (cardIntegration.showDependencyMapping) {
65
80
  serialized['sdm'] = true;
@@ -176,6 +191,23 @@ class LucidCardIntegrationRegistry {
176
191
  'e': searchResult.error,
177
192
  };
178
193
  }
194
+ /**
195
+ * Helper to serialize import results (single or array) to the expected format.
196
+ */
197
+ static serializeImportResults(result) {
198
+ if ((0, checks_1.isArray)(result)) {
199
+ return result.map((importResult) => {
200
+ return {
201
+ 'c': importResult.collection.id,
202
+ 'pks': importResult.primaryKeys,
203
+ };
204
+ });
205
+ }
206
+ return {
207
+ 'c': result.collection.id,
208
+ 'pks': result.primaryKeys,
209
+ };
210
+ }
179
211
  static registerImportCardFromPastedLinkHandler(client, cardIntegration, serialized) {
180
212
  if (!cardIntegration.importCardFromPastedLink) {
181
213
  return;
@@ -258,6 +290,9 @@ class LucidCardIntegrationRegistry {
258
290
  'flic': cardIntegration.iconConfiguration.fieldLabelIconsCallback,
259
291
  };
260
292
  }
293
+ if (cardIntegration.tagCallback) {
294
+ serialized['tc'] = cardIntegration.tagCallback;
295
+ }
261
296
  if (cardIntegration.importModal) {
262
297
  const importModal = cardIntegration.importModal;
263
298
  if (importModal instanceof lucidcardintegrationcustomimportmodal_1.LucidCardIntegrationCustomImportModal) {
@@ -369,6 +404,14 @@ class LucidCardIntegrationRegistry {
369
404
  }
370
405
  });
371
406
  }
407
+ if (autoSync.syncQueryString) {
408
+ serialized['as']['syqs'] = LucidCardIntegrationRegistry.nextHookName();
409
+ client.registerAction(serialized['as']['syqs'], async ({ 'qs': queryString, 'of': otherFields }) => {
410
+ var _a, _b;
411
+ const result = (_b = (await ((_a = autoSync.syncQueryString) === null || _a === void 0 ? void 0 : _a.call(autoSync, queryString, new Map(otherFields))))) !== null && _b !== void 0 ? _b : [];
412
+ return LucidCardIntegrationRegistry.serializeImportResults(result);
413
+ });
414
+ }
372
415
  }
373
416
  if (cardIntegration.fieldConfiguration.customFieldDisplaySettings) {
374
417
  serialized['fc']['cfds'] = {
@@ -387,12 +430,12 @@ class LucidCardIntegrationRegistry {
387
430
  return (0, importcardfromdetails_1.serializeImportCardFromDetails)(result);
388
431
  });
389
432
  }
390
- if (cardIntegration.hasAccessToItems) {
391
- const hasAccessToItemsActionName = LucidCardIntegrationRegistry.nextHookName();
392
- serialized['hait'] = hasAccessToItemsActionName;
393
- client.registerAction(hasAccessToItemsActionName, async ({ 'ek': editedKey, 'dk': dependencyKey }) => {
394
- const result = await cardIntegration.hasAccessToItems(editedKey, dependencyKey);
395
- return (0, carduseraccessresult_1.serializeCardUserAccessResult)(result);
433
+ if (cardIntegration.canEditItems) {
434
+ const canEditItemsActionName = LucidCardIntegrationRegistry.nextHookName();
435
+ serialized['cei'] = canEditItemsActionName;
436
+ client.registerAction(canEditItemsActionName, async ({ 'ek': editedKey, 'dk': dependencyKey }) => {
437
+ const result = await cardIntegration.canEditItems(editedKey, dependencyKey);
438
+ return (0, useritemeditpermissions_1.serializeUserItemEditPermissions)(result);
396
439
  });
397
440
  }
398
441
  client.sendCommand("aci" /* CommandName.AddCardIntegration */, serialized);
@@ -0,0 +1,26 @@
1
+ import { SerializedFieldConstraint } from '../data/serializedfield/serializedfielddefinition';
2
+ /**
3
+ * Defines whether the current user can edit an item.
4
+ */
5
+ export interface UserItemEditPermissions {
6
+ hasPermission: boolean;
7
+ constraints: {
8
+ fieldName: string;
9
+ constraints?: SerializedFieldConstraint[];
10
+ }[];
11
+ }
12
+ export declare class UserCanEditItem implements UserItemEditPermissions {
13
+ readonly hasPermission = true;
14
+ constraints: never[];
15
+ }
16
+ export declare class UserCannotEditItem implements UserItemEditPermissions {
17
+ readonly hasPermission = false;
18
+ constraints: never[];
19
+ }
20
+ export declare function serializeUserItemEditPermissions(result: UserItemEditPermissions): {
21
+ hp: boolean;
22
+ c: {
23
+ fn: string;
24
+ cs: SerializedFieldConstraint[] | undefined;
25
+ }[];
26
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeUserItemEditPermissions = exports.UserCannotEditItem = exports.UserCanEditItem = void 0;
4
+ class UserCanEditItem {
5
+ constructor() {
6
+ this.hasPermission = true;
7
+ this.constraints = [];
8
+ }
9
+ }
10
+ exports.UserCanEditItem = UserCanEditItem;
11
+ class UserCannotEditItem {
12
+ constructor() {
13
+ this.hasPermission = false;
14
+ this.constraints = [];
15
+ }
16
+ }
17
+ exports.UserCannotEditItem = UserCannotEditItem;
18
+ function serializeUserItemEditPermissions(result) {
19
+ return {
20
+ 'hp': result.hasPermission,
21
+ 'c': result.constraints.map((c) => ({
22
+ 'fn': c.fieldName,
23
+ 'cs': c.constraints,
24
+ })),
25
+ };
26
+ }
27
+ exports.serializeUserItemEditPermissions = serializeUserItemEditPermissions;
@@ -13,7 +13,8 @@ export declare enum FieldConstraintType {
13
13
  SINGLE_LINE_ONLY = "singleLineOnly",
14
14
  NO_WHITESPACE = "noWhitespace",
15
15
  UNIQUE_EDIT = "uniqueEditType",
16
- MAX_LENGTH = "maxLength"
16
+ MAX_LENGTH = "maxLength",
17
+ MAX_DECIMAL_LENGTH = "maxDecimalLength"
17
18
  }
18
19
  export declare const isFieldConstraintType: (x: unknown) => x is FieldConstraintType;
19
20
  export type SerializedFieldConstraint = {
@@ -18,6 +18,7 @@ var FieldConstraintType;
18
18
  FieldConstraintType["NO_WHITESPACE"] = "noWhitespace";
19
19
  FieldConstraintType["UNIQUE_EDIT"] = "uniqueEditType";
20
20
  FieldConstraintType["MAX_LENGTH"] = "maxLength";
21
+ FieldConstraintType["MAX_DECIMAL_LENGTH"] = "maxDecimalLength";
21
22
  })(FieldConstraintType || (exports.FieldConstraintType = FieldConstraintType = {}));
22
23
  exports.isFieldConstraintType = (0, validators_1.enumValidator)(FieldConstraintType);
23
24
  exports.isSerializedFieldConstraint = (0, validators_1.objectValidator)({
@@ -154,8 +154,10 @@ export interface SearchResultPerCollection {
154
154
  * If you change this interface, check if your changes need to be synced with
155
155
  * editorextensioncardintegrationregistry.ts.
156
156
  *
157
- * By specifying the itemsPerSearchResult, you can enable pagination for results in the import modal. The offset and limit
158
- * parameters in the search function will tell you which page of results to return.
157
+ * By specifying the itemsPerSearchResult, you can enable pagination for results in the import modal OR the
158
+ * query sync modal. The offset and limit parameters in the search function will tell you which page of results
159
+ * to return, whereas the {@link AutoSyncPaginationSize} variable and pageNumber parameter should be used to
160
+ * calculate which search reults to return for query sync.
159
161
  *
160
162
  */
161
163
  export interface SearchResult {
@@ -277,3 +279,33 @@ export type ExtensionFieldConfiguration = {
277
279
  * Use the `createLucidIconData()` helper to format the icon data in this map.
278
280
  */
279
281
  export type ExtensionCardFieldLabelIcons = Map<string, SerializedLucidIconData>;
282
+ /**
283
+ * @experimental Callback function to derive a tag for any given card's data item.
284
+ * A tag is a combination of a text label (preferably short, less than two words) and an icon,
285
+ * which can provide extra user-facing information in the card details panel.
286
+ */
287
+ export type TagCallback = (dataSourceProxy: DataSourceProxy, collectionProxy: CollectionProxy, dataItemProxy: DataItemProxy) => Promise<TagCallbackResult | undefined>;
288
+ /** @ignore */
289
+ export type TagCallbackResult = {
290
+ label: string;
291
+ icon?: SerializedLucidIconData | undefined;
292
+ };
293
+ /** @ignore */
294
+ export interface SerializedTagCallbackResult {
295
+ 'l': string;
296
+ 'i'?: SerializedLucidIconData | undefined;
297
+ }
298
+ /** @ignore */
299
+ export declare const isSerializedTagCallbackResult: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
300
+ l: typeof isString;
301
+ i: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
302
+ dict: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
303
+ icon: typeof isString;
304
+ ariaLabel: typeof isString;
305
+ tooltipLabel: (x: unknown) => x is string | undefined;
306
+ roundedIcon: (x: unknown) => x is boolean | undefined;
307
+ }>;
308
+ }> | undefined;
309
+ }>;
310
+ /** @ignore */
311
+ export declare function serializeTagCallbackResult(tag: TagCallbackResult): SerializedTagCallbackResult;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deserializePlaceholderImportMetadata = exports.serializePlaceholderImportMetadata = exports.isSerializedPlaceholderImportMetadata = exports.isSearchResult = exports.deserializeCardFieldArrayDefinition = exports.deserializeCardFieldDefinition = exports.isSerializedExtensionCardFieldDefinition = exports.isSerializedFieldOptions = exports.isSerializedFieldOption = exports.deserializeFieldOption = exports.serializeCardFieldArrayDefinition = exports.serializeCardFieldDefinition = exports.serializeCardFieldOption = exports.isSerializedCardUserDataArray = exports.isSerializedCardUserData = exports.deserializeCardUserData = exports.serializeCardUserData = void 0;
3
+ exports.serializeTagCallbackResult = exports.isSerializedTagCallbackResult = exports.deserializePlaceholderImportMetadata = exports.serializePlaceholderImportMetadata = exports.isSerializedPlaceholderImportMetadata = exports.isSearchResult = exports.deserializeCardFieldArrayDefinition = exports.deserializeCardFieldDefinition = exports.isSerializedExtensionCardFieldDefinition = exports.isSerializedFieldOptions = exports.isSerializedFieldOption = exports.deserializeFieldOption = exports.serializeCardFieldArrayDefinition = exports.serializeCardFieldDefinition = exports.serializeCardFieldOption = exports.isSerializedCardUserDataArray = exports.isSerializedCardUserData = exports.deserializeCardUserData = exports.serializeCardUserData = void 0;
4
4
  const collectiondefinition_1 = require("../../data/collectiondefinition");
5
5
  const schemadefinition_1 = require("../../data/schemadefinition");
6
6
  const checks_1 = require("../checks");
@@ -104,3 +104,16 @@ function deserializePlaceholderImportMetadata(serializedPlaceholderImportMetadat
104
104
  };
105
105
  }
106
106
  exports.deserializePlaceholderImportMetadata = deserializePlaceholderImportMetadata;
107
+ /** @ignore */
108
+ exports.isSerializedTagCallbackResult = (0, validators_1.objectValidator)({
109
+ 'l': checks_1.isString,
110
+ 'i': (0, validators_1.option)(serializedfields_1.isSerializedLucidIconData),
111
+ });
112
+ /** @ignore */
113
+ function serializeTagCallbackResult(tag) {
114
+ return {
115
+ 'l': tag.label,
116
+ 'i': tag === null || tag === void 0 ? void 0 : tag.icon,
117
+ };
118
+ }
119
+ exports.serializeTagCallbackResult = serializeTagCallbackResult;
@@ -18,6 +18,10 @@ export declare class DataItemProxy {
18
18
  * The fields on this data item, organized by their name.
19
19
  */
20
20
  readonly fields: MapProxy<string, import("..").SerializedFieldType>;
21
+ /**
22
+ * The fields on this data item, organized by their label.
23
+ */
24
+ readonly fieldsByLabel: MapProxy<string, import("..").SerializedFieldType>;
21
25
  /**
22
26
  * @returns True if a data item exists in this collection at this primary key
23
27
  */
@@ -23,6 +23,15 @@ class DataItemProxy {
23
23
  'pk': this.primaryKey,
24
24
  'f': name,
25
25
  }));
26
+ /**
27
+ * The fields on this data item, organized by their label.
28
+ */
29
+ this.fieldsByLabel = new mapproxy_1.MapProxy(() => this.client.sendCommand("lcf" /* CommandName.ListCollectionFields */, { 'id': this.collection.id, 'l': true }), (name) => this.client.sendCommand("gdif" /* CommandName.GetDataItemField */, {
30
+ 'c': this.collection.id,
31
+ 'pk': this.primaryKey,
32
+ 'f': name,
33
+ 'l': true,
34
+ }));
26
35
  }
27
36
  /**
28
37
  * @returns True if a data item exists in this collection at this primary key
@@ -40,15 +40,20 @@ export interface MaxLengthConstraintDefinition {
40
40
  value: number;
41
41
  reason?: string | undefined;
42
42
  }
43
- export type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition | UniqueEditFieldConstraintDefinition | MaxLengthConstraintDefinition;
43
+ export interface MaxDecimalPlacesConstraintDefinition {
44
+ type: FieldConstraintType.MAX_DECIMAL_LENGTH;
45
+ value: number;
46
+ reason?: string | undefined;
47
+ }
48
+ export type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition | UniqueEditFieldConstraintDefinition | MaxLengthConstraintDefinition | MaxDecimalPlacesConstraintDefinition;
44
49
  export declare function createFieldConstraintDefinition(type: FieldConstraintType, value?: number, reason?: string): FieldConstraintDefinition;
45
- export declare function minMaxFieldConstraintValidator(val: unknown): val is FieldConstraintType.MIN_VALUE | FieldConstraintType.MAX_VALUE | FieldConstraintType.MAX_LENGTH;
50
+ export declare function numericFieldConstraintValidator(val: unknown): val is FieldConstraintType.MIN_VALUE | FieldConstraintType.MAX_VALUE | FieldConstraintType.MAX_LENGTH | FieldConstraintType.MAX_DECIMAL_LENGTH;
46
51
  export declare const isFieldConstraintDefinition: (x: unknown) => x is {
47
52
  type?: FieldConstraintType | undefined;
48
53
  } & {
49
54
  type: FieldConstraintType;
50
55
  } & (import("..").DestructureGuardedTypeObj<{
51
- type: typeof minMaxFieldConstraintValidator;
56
+ type: typeof numericFieldConstraintValidator;
52
57
  value: typeof isNumber;
53
58
  }> | import("..").DestructureGuardedTypeObj<{
54
59
  type: (x: unknown) => x is FieldConstraintType.REQUIRED | FieldConstraintType.LOCKED | FieldConstraintType.SINGLE_LINE_ONLY | FieldConstraintType.NO_WHITESPACE | FieldConstraintType.UNIQUE_EDIT;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeFieldConstraintDefinition = exports.isFieldConstraintDefinition = exports.minMaxFieldConstraintValidator = exports.createFieldConstraintDefinition = void 0;
3
+ exports.serializeFieldConstraintDefinition = exports.isFieldConstraintDefinition = exports.numericFieldConstraintValidator = exports.createFieldConstraintDefinition = void 0;
4
4
  const assertnever_1 = require("../core/assertnever");
5
5
  const checks_1 = require("../core/checks");
6
6
  const serializedfielddefinition_1 = require("../core/data/serializedfield/serializedfielddefinition");
@@ -13,6 +13,7 @@ function createFieldConstraintDefinition(type, value, reason) {
13
13
  case serializedfielddefinition_1.FieldConstraintType.MIN_VALUE:
14
14
  case serializedfielddefinition_1.FieldConstraintType.MAX_VALUE:
15
15
  case serializedfielddefinition_1.FieldConstraintType.MAX_LENGTH:
16
+ case serializedfielddefinition_1.FieldConstraintType.MAX_DECIMAL_LENGTH:
16
17
  if (value === undefined) {
17
18
  throw new Error('Invalid constraint value');
18
19
  }
@@ -29,15 +30,19 @@ function createFieldConstraintDefinition(type, value, reason) {
29
30
  }
30
31
  }
31
32
  exports.createFieldConstraintDefinition = createFieldConstraintDefinition;
32
- function minMaxFieldConstraintValidator(val) {
33
+ function numericFieldConstraintValidator(val) {
33
34
  return (val === serializedfielddefinition_1.FieldConstraintType.MIN_VALUE ||
34
35
  val === serializedfielddefinition_1.FieldConstraintType.MAX_VALUE ||
35
- val === serializedfielddefinition_1.FieldConstraintType.MAX_LENGTH);
36
+ val === serializedfielddefinition_1.FieldConstraintType.MAX_LENGTH ||
37
+ val === serializedfielddefinition_1.FieldConstraintType.MAX_DECIMAL_LENGTH);
36
38
  }
37
- exports.minMaxFieldConstraintValidator = minMaxFieldConstraintValidator;
39
+ exports.numericFieldConstraintValidator = numericFieldConstraintValidator;
38
40
  exports.isFieldConstraintDefinition = (0, validators_1.both)((0, validators_1.objectValidator)({
39
41
  'type': serializedfielddefinition_1.isFieldConstraintType,
40
- }), (0, validators_1.either)((0, validators_1.objectValidator)({ 'type': minMaxFieldConstraintValidator, 'value': checks_1.isNumber }), (0, validators_1.objectValidator)({ 'type': (0, validators_1.exclude)(serializedfielddefinition_1.isFieldConstraintType, minMaxFieldConstraintValidator), 'value': checks_1.isUndefined })));
42
+ }), (0, validators_1.either)((0, validators_1.objectValidator)({ 'type': numericFieldConstraintValidator, 'value': checks_1.isNumber }), (0, validators_1.objectValidator)({
43
+ 'type': (0, validators_1.exclude)(serializedfielddefinition_1.isFieldConstraintType, numericFieldConstraintValidator),
44
+ 'value': checks_1.isUndefined,
45
+ })));
41
46
  /** @ignore */
42
47
  function serializeFieldConstraintDefinition(constraint) {
43
48
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.436",
3
+ "version": "0.0.438",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,18 +0,0 @@
1
- import { SerializedFieldConstraint } from '../data/serializedfield/serializedfielddefinition';
2
- /**
3
- * Defines whether the current user has access to an item.
4
- */
5
- export interface CardUserAccessResult {
6
- hasPermission: boolean;
7
- constraints: {
8
- fieldName: string;
9
- constraints?: SerializedFieldConstraint[];
10
- }[];
11
- }
12
- export declare function serializeCardUserAccessResult(result: CardUserAccessResult): {
13
- hp: boolean;
14
- c: {
15
- fn: string;
16
- cs: SerializedFieldConstraint[] | undefined;
17
- }[];
18
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeCardUserAccessResult = void 0;
4
- function serializeCardUserAccessResult(result) {
5
- return {
6
- 'hp': result.hasPermission,
7
- 'c': result.constraints.map((c) => ({
8
- 'fn': c.fieldName,
9
- 'cs': c.constraints,
10
- })),
11
- };
12
- }
13
- exports.serializeCardUserAccessResult = serializeCardUserAccessResult;