lucid-extension-sdk 1.1.3 → 1.2.1
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 +30 -4
- package/commandtypes.js +1 -1
- package/core/cardintegration/cardfielddisplaysettings.d.ts +2 -2
- package/core/cardintegration/cardfielddisplaysettings.js +1 -1
- package/core/cardintegration/lucidcardintegrationregistry.d.ts +4 -1
- package/core/cardintegration/lucidcardintegrationregistry.js +3 -21
- package/core/lucidproduct.d.ts +1 -0
- package/core/lucidproduct.js +1 -0
- package/core/sharedcardintegration/cardintegrationdefinitions.d.ts +9 -0
- package/core/sharedcardintegration/cardintegrationdefinitions.js +3 -2
- package/core/sharedcardintegration/sharedregistryutil.d.ts +12 -1
- package/core/sharedcardintegration/sharedregistryutil.js +34 -0
- package/core/spreadsheetintegration/lucidspreadsheetintegration.d.ts +8 -0
- package/core/spreadsheetintegration/lucidspreadsheetintegrationregistry.d.ts +5 -1
- package/core/spreadsheetintegration/lucidspreadsheetintegrationregistry.js +18 -15
- package/core/validators/validators.d.ts +1 -0
- package/core/validators/validators.js +1 -0
- package/data/collectiondefinition.d.ts +2 -0
- package/data/collectiondefinition.js +1 -0
- package/data/collectionerrortypes.d.ts +4 -0
- package/data/collectionerrortypes.js +4 -0
- package/data/dataupdatefiltertype.d.ts +1 -0
- package/data/displayoptiondefinition.d.ts +5 -0
- package/data/displayoptiondefinition.js +2 -0
- package/data/fieldconstraintdefinition.d.ts +13 -0
- package/data/fieldconstraintdefinition.js +3 -0
- package/data/patchcollectionproxy.d.ts +2 -0
- package/data/patchcollectionproxy.js +2 -0
- package/data/patcherrortype.d.ts +1 -0
- package/data/referencekeydefinition.d.ts +6 -5
- package/data/referencekeyproxy.d.ts +1 -0
- package/data/referencekeyproxy.js +1 -0
- package/data/schemadefinition.d.ts +2 -2
- package/dataconnector/actions/action.d.ts +4 -0
- package/dataconnector/actions/dataconnectoractionkeys.d.ts +1 -0
- package/dataconnector/actions/patch.d.ts +10 -0
- package/dataconnector/actions/patch.js +9 -0
- package/dataconnector/actions/patchresponsebody.d.ts +2 -0
- package/dataconnector/actions/serializedactions.d.ts +1 -0
- package/dataconnector/actions/serializedactions.js +1 -0
- package/dataconnector/actions/serializedpatchtypes.d.ts +10 -0
- package/dataconnector/actions/serializedpatchtypes.js +5 -0
- package/dataconnector/cryptodependencies.d.ts +3 -0
- package/dataconnector/dataconnector.d.ts +1 -0
- package/dataconnector/dataconnector.js +1 -0
- package/dataconnector/datasourcemetadatatypes.d.ts +4 -0
- package/dataconnector/datasourcemetadatatypes.js +1 -0
- package/dataconnector/datasourceupdatetypes.d.ts +5 -0
- package/dataconnector/itemrekeyerandrelabeler.d.ts +2 -0
- package/dataconnector/itemrekeyerandrelabeler.js +2 -0
- package/document/blockclasses/cardblockproxy.d.ts +11 -1
- package/document/blockclasses/cardblockproxy.js +46 -30
- package/document/blockclasses/customblockproxy.d.ts +1 -0
- package/document/blockclasses/erdblockproxy.d.ts +2 -0
- package/document/blockclasses/erdblockproxy.js +2 -0
- package/document/blockclasses/legendblockproxy.d.ts +6 -0
- package/document/blockclasses/legendblockproxy.js +5 -0
- package/document/blockclasses/swimlaneblockproxy.d.ts +2 -0
- package/document/blockclasses/swimlaneblockproxy.js +2 -0
- package/document/blockclasses/tableblockproxy.d.ts +4 -1
- package/document/blockclasses/tableblockproxy.js +4 -1
- package/document/blockdefinition.d.ts +2 -2
- package/document/blockproxy.d.ts +2 -2
- package/document/blockproxy.js +2 -2
- package/document/documentaccesspermission.d.ts +1 -0
- package/document/documentelement/cardconfigproxy.d.ts +1 -0
- package/document/documentelement/cardconfigproxy.js +1 -0
- package/document/documentelement/documentelementproxy.d.ts +1 -0
- package/document/documentelement/documentelementproxy.js +1 -0
- package/document/documentelement/ruleproxy.d.ts +3 -0
- package/document/documentelement/ruleproxy.js +3 -0
- package/document/elementproxy.d.ts +6 -6
- package/document/elementproxy.js +6 -6
- package/document/graphdefinition.d.ts +2 -0
- package/document/graphdefinition.js +1 -0
- package/document/itemproxy.d.ts +4 -0
- package/document/itemproxy.js +4 -0
- package/document/linedefinition.d.ts +1 -0
- package/document/lineproxy.d.ts +2 -0
- package/document/lineproxy.js +1 -0
- package/document/linetextareapositioning.d.ts +1 -0
- package/document/mapproxy.d.ts +2 -0
- package/document/mapproxy.js +1 -0
- package/document/propertystoreproxy.d.ts +7 -0
- package/document/propertystoreproxy.js +7 -0
- package/document/ruledefinition.d.ts +12 -0
- package/document/text/textstyle.d.ts +2 -0
- package/package.json +1 -1
- package/ui/menu.d.ts +8 -4
- package/ui/menu.js +5 -4
- package/ui/modal.d.ts +1 -1
- package/ui/panel.d.ts +2 -0
- package/ui/viewport.d.ts +3 -2
- 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
|
|
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
|
|
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
|
|
@@ -1139,6 +1139,8 @@ export type AddSpreadsheetIntegrationQuery = {
|
|
|
1139
1139
|
'dm'?: DependencyMappingSettings | undefined;
|
|
1140
1140
|
/** Auto-sync configuration (only honored when `c` / addCardsIntegration is true) */
|
|
1141
1141
|
'as'?: AutoSyncSettings | undefined;
|
|
1142
|
+
/** Get default config action */
|
|
1143
|
+
'gdc'?: string | undefined;
|
|
1142
1144
|
};
|
|
1143
1145
|
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
1144
1146
|
export type AddSpreadsheetIntegrationResult = undefined;
|
|
@@ -1634,7 +1636,19 @@ export type GetOAuthClientIdResult = Promise<string | undefined>;
|
|
|
1634
1636
|
export type GetPropertyQuery = {
|
|
1635
1637
|
/** ID of the LucidElement to read a property from, or undefined to read from the LucidDocument */
|
|
1636
1638
|
'id'?: string | undefined;
|
|
1637
|
-
/**
|
|
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
|
+
*/
|
|
1638
1652
|
'p': string;
|
|
1639
1653
|
};
|
|
1640
1654
|
export type GetPropertyResult = UnsafeJsonSerializableOrUndefined;
|
|
@@ -1984,7 +1998,19 @@ export type SetPropertyQuery = {
|
|
|
1984
1998
|
'id'?: string | undefined;
|
|
1985
1999
|
/** Name of the property to change */
|
|
1986
2000
|
'p': string;
|
|
1987
|
-
/**
|
|
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
|
+
*/
|
|
1988
2014
|
'v'?: UnsafeJsonSerializableOrUndefined;
|
|
1989
2015
|
};
|
|
1990
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
|
|
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
|
|
@@ -65,7 +65,7 @@ export declare const FieldDisplayType: {
|
|
|
65
65
|
readonly CustomTextField: "CustomTextField";
|
|
66
66
|
/**
|
|
67
67
|
* @experimental
|
|
68
|
-
* Renders the field value as a small
|
|
68
|
+
* Renders the field value as a small 16x16 square icon aligned inline with
|
|
69
69
|
* one of the card's text rows. Use `inlineRowIndex` on the stencil config to pick which row.
|
|
70
70
|
*/
|
|
71
71
|
readonly InlineIcon: "InlineIcon";
|
|
@@ -131,7 +131,7 @@ export declare const isFieldDisplayType: (x: unknown) => x is {} extends {
|
|
|
131
131
|
readonly CustomTextField: "CustomTextField";
|
|
132
132
|
/**
|
|
133
133
|
* @experimental
|
|
134
|
-
* Renders the field value as a small
|
|
134
|
+
* Renders the field value as a small 16x16 square icon aligned inline with
|
|
135
135
|
* one of the card's text rows. Use `inlineRowIndex` on the stencil config to pick which row.
|
|
136
136
|
*/
|
|
137
137
|
readonly InlineIcon: "InlineIcon";
|
|
@@ -73,7 +73,7 @@ exports.FieldDisplayType = {
|
|
|
73
73
|
CustomTextField: 'CustomTextField',
|
|
74
74
|
/**
|
|
75
75
|
* @experimental
|
|
76
|
-
* Renders the field value as a small
|
|
76
|
+
* Renders the field value as a small 16x16 square icon aligned inline with
|
|
77
77
|
* one of the card's text rows. Use `inlineRowIndex` on the stencil config to pick which row.
|
|
78
78
|
*/
|
|
79
79
|
InlineIcon: 'InlineIcon',
|
|
@@ -12,7 +12,10 @@ 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
|
|
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;
|
|
@@ -28,31 +28,13 @@ class LucidCardIntegrationRegistry {
|
|
|
28
28
|
return name;
|
|
29
29
|
}
|
|
30
30
|
static registerFieldSearchCallback(client, callback) {
|
|
31
|
-
|
|
32
|
-
client.registerAction(name, async ({ 'i': inputSoFar, 's': searchText, 'fd': serializedFieldData }) => {
|
|
33
|
-
const fieldData = serializedFieldData
|
|
34
|
-
? { name: serializedFieldData['n'], dataSourceId: serializedFieldData['ds'] }
|
|
35
|
-
: undefined;
|
|
36
|
-
const result = await callback(searchText, new Map(inputSoFar), fieldData);
|
|
37
|
-
return result.map((option) => (0, cardintegrationdefinitions_1.serializeCardFieldOption)(option));
|
|
38
|
-
});
|
|
39
|
-
return name;
|
|
31
|
+
return (0, sharedregistryutil_1.registerFieldSearchCallback)(client, callback, () => LucidCardIntegrationRegistry.nextHookName());
|
|
40
32
|
}
|
|
41
33
|
static registerUserSearchCallback(client, callback) {
|
|
42
|
-
|
|
43
|
-
client.registerAction(name, async ({ 'i': inputSoFar, 's': searchText }) => {
|
|
44
|
-
const result = await callback(searchText, new Map(inputSoFar));
|
|
45
|
-
return result.map((userData) => (0, cardintegrationdefinitions_1.serializeCardUserData)(userData));
|
|
46
|
-
});
|
|
47
|
-
return name;
|
|
34
|
+
return (0, sharedregistryutil_1.registerUserSearchCallback)(client, callback, () => LucidCardIntegrationRegistry.nextHookName());
|
|
48
35
|
}
|
|
49
36
|
static registerFieldTypeToCollectionItemsCallback(client, callback) {
|
|
50
|
-
|
|
51
|
-
client.registerAction(name, async ({ 'd': dataSourceId, 'v': value, 'f': fieldName }) => {
|
|
52
|
-
const dataSourceProxy = dataSourceId ? new datasourceproxy_1.DataSourceProxy(dataSourceId, client) : undefined;
|
|
53
|
-
return await callback(fieldName, value, dataSourceProxy);
|
|
54
|
-
});
|
|
55
|
-
return name;
|
|
37
|
+
return (0, sharedregistryutil_1.registerFieldTypeToCollectionItemsCallback)(client, callback, () => LucidCardIntegrationRegistry.nextHookName());
|
|
56
38
|
}
|
|
57
39
|
static registerFieldLabelIconsCallback(client, callback) {
|
|
58
40
|
const name = LucidCardIntegrationRegistry.nextHookName();
|
package/core/lucidproduct.d.ts
CHANGED
package/core/lucidproduct.js
CHANGED
|
@@ -62,6 +62,11 @@ export interface ExtensionCardFieldDefinition extends FieldDefinition {
|
|
|
62
62
|
* This is useful if changing this field invalidates the values of other fields.
|
|
63
63
|
*/
|
|
64
64
|
unsetFieldsWhenChanged?: string[] | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* When true, every field named in {@link unsetFieldsWhenChanged} renders as disabled while this
|
|
67
|
+
* field's value is empty.
|
|
68
|
+
*/
|
|
69
|
+
disableChildrenWhenEmpty?: boolean | undefined;
|
|
65
70
|
/**
|
|
66
71
|
* If specified, an action that takes the search text and input so far, and
|
|
67
72
|
* returns the list of options that should be displayed. This is useful when
|
|
@@ -143,6 +148,7 @@ export type SerializedExtensionCardFieldDefinition = SerializedFieldDefinition &
|
|
|
143
148
|
'op'?: SerializedCardFieldOption[] | string | undefined;
|
|
144
149
|
's'?: string | undefined;
|
|
145
150
|
'u'?: string[] | undefined;
|
|
151
|
+
'dcwe'?: boolean | undefined;
|
|
146
152
|
't'?: string | undefined;
|
|
147
153
|
};
|
|
148
154
|
/** @ignore */
|
|
@@ -194,6 +200,7 @@ export declare const isSerializedExtensionCardFieldDefinition: (subject: unknown
|
|
|
194
200
|
}>[]) | undefined;
|
|
195
201
|
s: (x: unknown) => x is string | undefined;
|
|
196
202
|
u: (x: unknown) => x is string[] | undefined;
|
|
203
|
+
dcwe: (x: unknown) => x is boolean | undefined;
|
|
197
204
|
t: (x: unknown) => x is string | undefined;
|
|
198
205
|
}>;
|
|
199
206
|
/** @ignore */
|
|
@@ -242,6 +249,7 @@ export declare const isSerializedExtensionCardFieldsGroup: (subject: unknown) =>
|
|
|
242
249
|
}>[]) | undefined;
|
|
243
250
|
s: (x: unknown) => x is string | undefined;
|
|
244
251
|
u: (x: unknown) => x is string[] | undefined;
|
|
252
|
+
dcwe: (x: unknown) => x is boolean | undefined;
|
|
245
253
|
t: (x: unknown) => x is string | undefined;
|
|
246
254
|
}>[];
|
|
247
255
|
}>;
|
|
@@ -278,6 +286,7 @@ export declare const isSerializedExtensionCardFieldsGroupArray: (val: unknown) =
|
|
|
278
286
|
}>[]) | undefined;
|
|
279
287
|
s: (x: unknown) => x is string | undefined;
|
|
280
288
|
u: (x: unknown) => x is string[] | undefined;
|
|
289
|
+
dcwe: (x: unknown) => x is boolean | undefined;
|
|
281
290
|
t: (x: unknown) => x is string | undefined;
|
|
282
291
|
}>[];
|
|
283
292
|
}>[];
|
|
@@ -62,7 +62,7 @@ function serializeCardFieldOption(option) {
|
|
|
62
62
|
/** @ignore */
|
|
63
63
|
function serializeCardFieldDefinition(field) {
|
|
64
64
|
var _a;
|
|
65
|
-
return Object.assign(Object.assign({}, (0, schemadefinition_1.serializeFieldDefinition)(field)), { 'l': field.label, 'def': field.default, 'd': field.description, 'op': (0, checks_1.isString)(field.options) ? field.options : (_a = field.options) === null || _a === void 0 ? void 0 : _a.map(serializeCardFieldOption), 's': field.search, 'u': field.unsetFieldsWhenChanged, 't': field.truncatedLabel });
|
|
65
|
+
return Object.assign(Object.assign({}, (0, schemadefinition_1.serializeFieldDefinition)(field)), { 'l': field.label, 'def': field.default, 'd': field.description, 'op': (0, checks_1.isString)(field.options) ? field.options : (_a = field.options) === null || _a === void 0 ? void 0 : _a.map(serializeCardFieldOption), 's': field.search, 'u': field.unsetFieldsWhenChanged, 'dcwe': field.disableChildrenWhenEmpty, 't': field.truncatedLabel });
|
|
66
66
|
}
|
|
67
67
|
/** @ignore */
|
|
68
68
|
function serializeCardFieldArrayDefinition(fields) {
|
|
@@ -90,12 +90,13 @@ exports.isSerializedExtensionCardFieldDefinition = (0, validators_1.objectValida
|
|
|
90
90
|
'op': (0, validators_1.option)((0, validators_1.either)(checks_1.isString, (0, validators_1.arrayValidator)(exports.isSerializedFieldOption))),
|
|
91
91
|
's': (0, validators_1.option)(checks_1.isString),
|
|
92
92
|
'u': (0, validators_1.option)((0, checks_1.isTypedArray)(checks_1.isString)),
|
|
93
|
+
'dcwe': (0, validators_1.option)(checks_1.isBoolean),
|
|
93
94
|
't': (0, validators_1.option)(checks_1.isString),
|
|
94
95
|
});
|
|
95
96
|
/** @ignore */
|
|
96
97
|
function deserializeCardFieldDefinition(field) {
|
|
97
98
|
var _a;
|
|
98
|
-
return Object.assign(Object.assign({}, (0, schemadefinition_1.parseFieldDefinition)(field)), { label: field['l'], description: field['d'], default: field['def'], options: (0, checks_1.isString)(field['op']) ? field['op'] : (_a = field['op']) === null || _a === void 0 ? void 0 : _a.map(deserializeFieldOption), search: field['s'], unsetFieldsWhenChanged: field['u'], truncatedLabel: field['t'] });
|
|
99
|
+
return Object.assign(Object.assign({}, (0, schemadefinition_1.parseFieldDefinition)(field)), { label: field['l'], description: field['d'], default: field['def'], options: (0, checks_1.isString)(field['op']) ? field['op'] : (_a = field['op']) === null || _a === void 0 ? void 0 : _a.map(deserializeFieldOption), search: field['s'], unsetFieldsWhenChanged: field['u'], disableChildrenWhenEmpty: field['dcwe'], truncatedLabel: field['t'] });
|
|
99
100
|
}
|
|
100
101
|
/** @ignore */
|
|
101
102
|
function deserializeCardFieldArrayDefinition(fields) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AutoSyncSettings, DependencyMappingSettings } from '../../commandtypes';
|
|
2
|
+
import { DataSourceProxy } from '../../data/datasourceproxy';
|
|
2
3
|
import { EditorClient } from '../../editorclient';
|
|
3
4
|
import { type CardIntegrationAutoSyncConfig } from '../cardintegration/cardintegrationautosyncconfig';
|
|
4
|
-
import {
|
|
5
|
+
import { SerializedFieldType, SerializedFields } from '../data/serializedfield/serializedfields';
|
|
6
|
+
import { ExtensionCardFieldOption, ExtensionCardUserData, ImportResult, SearchResult } from './cardintegrationdefinitions';
|
|
5
7
|
import { CardIntegrationDependencyMappingConfig } from './dependencymappingconfig';
|
|
6
8
|
/**
|
|
7
9
|
* Serializes a `SearchResult` into the wire-format object the editor expects. Shared between the
|
|
@@ -48,3 +50,12 @@ export declare function serializeImportResults(result: ImportResult | ImportResu
|
|
|
48
50
|
*/
|
|
49
51
|
export declare function registerAutoSync(client: EditorClient, autoSync: CardIntegrationAutoSyncConfig, getNextHookName: () => string): AutoSyncSettings;
|
|
50
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;
|
|
@@ -4,9 +4,13 @@ exports.serializeSearchResult = serializeSearchResult;
|
|
|
4
4
|
exports.serializeImportResults = serializeImportResults;
|
|
5
5
|
exports.registerAutoSync = registerAutoSync;
|
|
6
6
|
exports.registerDependencyMapping = registerDependencyMapping;
|
|
7
|
+
exports.registerFieldSearchCallback = registerFieldSearchCallback;
|
|
8
|
+
exports.registerUserSearchCallback = registerUserSearchCallback;
|
|
9
|
+
exports.registerFieldTypeToCollectionItemsCallback = registerFieldTypeToCollectionItemsCallback;
|
|
7
10
|
const collectiondefinition_1 = require("../../data/collectiondefinition");
|
|
8
11
|
const collectionproxy_1 = require("../../data/collectionproxy");
|
|
9
12
|
const dataitemproxy_1 = require("../../data/dataitemproxy");
|
|
13
|
+
const datasourceproxy_1 = require("../../data/datasourceproxy");
|
|
10
14
|
const cardintegrationautosyncconfig_1 = require("../cardintegration/cardintegrationautosyncconfig");
|
|
11
15
|
const checks_1 = require("../checks");
|
|
12
16
|
const cardintegrationdefinitions_1 = require("./cardintegrationdefinitions");
|
|
@@ -297,3 +301,33 @@ function registerDependencyMapping(client, dependencyMapping, serialized, getNex
|
|
|
297
301
|
});
|
|
298
302
|
}
|
|
299
303
|
}
|
|
304
|
+
function registerFieldSearchCallback(client, callback, getNextHookName) {
|
|
305
|
+
const name = getNextHookName();
|
|
306
|
+
client.registerAction(name, async ({ 'i': inputSoFar, 's': searchText, 'fd': serializedFieldData }) => {
|
|
307
|
+
const fieldData = serializedFieldData
|
|
308
|
+
? { name: serializedFieldData['n'], dataSourceId: serializedFieldData['ds'] }
|
|
309
|
+
: undefined;
|
|
310
|
+
const result = await callback(searchText, new Map(inputSoFar), fieldData);
|
|
311
|
+
return result.map((option) => (0, cardintegrationdefinitions_1.serializeCardFieldOption)(option));
|
|
312
|
+
});
|
|
313
|
+
return name;
|
|
314
|
+
}
|
|
315
|
+
function registerUserSearchCallback(client, callback, getNextHookName) {
|
|
316
|
+
const name = getNextHookName();
|
|
317
|
+
client.registerAction(name, async ({ 'i': inputSoFar, 's': searchText, 'fd': serializedFieldData }) => {
|
|
318
|
+
const fieldData = serializedFieldData
|
|
319
|
+
? { name: serializedFieldData['n'], dataSourceId: serializedFieldData['ds'] }
|
|
320
|
+
: undefined;
|
|
321
|
+
const result = await callback(searchText, new Map(inputSoFar), fieldData);
|
|
322
|
+
return result.map((userData) => (0, cardintegrationdefinitions_1.serializeCardUserData)(userData));
|
|
323
|
+
});
|
|
324
|
+
return name;
|
|
325
|
+
}
|
|
326
|
+
function registerFieldTypeToCollectionItemsCallback(client, callback, getNextHookName) {
|
|
327
|
+
const name = getNextHookName();
|
|
328
|
+
client.registerAction(name, async ({ 'd': dataSourceId, 'v': value, 'f': fieldName }) => {
|
|
329
|
+
const dataSourceProxy = dataSourceId ? new datasourceproxy_1.DataSourceProxy(dataSourceId, client) : undefined;
|
|
330
|
+
return await callback(fieldName, value, dataSourceProxy);
|
|
331
|
+
});
|
|
332
|
+
return name;
|
|
333
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CollectionProxy } from '../../data/collectionproxy';
|
|
2
|
+
import type { DataSourceProxy } from '../../data/datasourceproxy';
|
|
2
3
|
import type { CardIntegrationAutoSyncConfig } from '../cardintegration/cardintegrationautosyncconfig';
|
|
4
|
+
import type { CardIntegrationConfig } from '../cardintegration/cardintegrationconfig';
|
|
3
5
|
import { type SerializedUpstreamConfig } from '../data/datasource/serializedupstreamconfig';
|
|
4
6
|
import type { SerializedFieldType } from '../data/serializedfield/serializedfields';
|
|
5
7
|
import { type SerializedSchema } from '../data/serializedfield/serializedschema';
|
|
@@ -120,6 +122,12 @@ export declare abstract class LucidSpreadsheetIntegration {
|
|
|
120
122
|
};
|
|
121
123
|
fieldConfiguration?: Partial<ExtensionFieldConfiguration>;
|
|
122
124
|
dependencyMapping?: CardIntegrationDependencyMappingConfig;
|
|
125
|
+
/**
|
|
126
|
+
* If specified, called when initializing the default card config for a newly imported spreadsheet.
|
|
127
|
+
* Use this to customize which fields appear in the detail edit panel.
|
|
128
|
+
* If not specified, all schema fields are included by default.
|
|
129
|
+
*/
|
|
130
|
+
getDefaultConfig?: (dataSource: DataSourceProxy) => Promise<CardIntegrationConfig>;
|
|
123
131
|
/**
|
|
124
132
|
* If specified, allows the user to use auto-sync to keep generators populated from this spreadsheet integration.
|
|
125
133
|
*/
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { DataSourceProxy } from '../../data/datasourceproxy';
|
|
2
2
|
import { EditorClient } from '../../editorclient';
|
|
3
3
|
import { SerializedFieldType, SerializedFields } from '../data/serializedfield/serializedfields';
|
|
4
|
-
import { ExtensionCardUserData } from '../sharedcardintegration/cardintegrationdefinitions';
|
|
4
|
+
import { ExtensionCardFieldOption, ExtensionCardUserData } from '../sharedcardintegration/cardintegrationdefinitions';
|
|
5
5
|
import { LucidSpreadsheetIntegration } from './lucidspreadsheetintegration';
|
|
6
6
|
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
7
7
|
export declare class LucidSpreadsheetIntegrationRegistry {
|
|
8
8
|
private static nextHookId;
|
|
9
9
|
private static nextHookName;
|
|
10
|
+
static registerFieldSearchCallback(client: EditorClient, callback: (searchText: string, inputSoFar: Map<string, SerializedFieldType>, fieldData?: {
|
|
11
|
+
name?: string | undefined;
|
|
12
|
+
dataSourceId?: string | undefined;
|
|
13
|
+
}) => Promise<ExtensionCardFieldOption[]>): string;
|
|
10
14
|
static registerUserSearchCallback(client: EditorClient, callback: (searchText: string, inputSoFar: Map<string, SerializedFieldType>, fieldData?: {
|
|
11
15
|
name?: string | undefined;
|
|
12
16
|
dataSourceId?: string | undefined;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LucidSpreadsheetIntegrationRegistry = void 0;
|
|
4
4
|
const commandtypes_1 = require("../../commandtypes");
|
|
5
5
|
const datasourceproxy_1 = require("../../data/datasourceproxy");
|
|
6
|
+
const cardintegrationconfig_1 = require("../cardintegration/cardintegrationconfig");
|
|
6
7
|
const checks_1 = require("../checks");
|
|
7
8
|
const cardintegrationdefinitions_1 = require("../sharedcardintegration/cardintegrationdefinitions");
|
|
8
9
|
const sharedregistryutil_1 = require("../sharedcardintegration/sharedregistryutil");
|
|
@@ -12,24 +13,14 @@ class LucidSpreadsheetIntegrationRegistry {
|
|
|
12
13
|
static nextHookName() {
|
|
13
14
|
return '__lucidspreadsheet__hook' + LucidSpreadsheetIntegrationRegistry.nextHookId++;
|
|
14
15
|
}
|
|
16
|
+
static registerFieldSearchCallback(client, callback) {
|
|
17
|
+
return (0, sharedregistryutil_1.registerFieldSearchCallback)(client, callback, () => LucidSpreadsheetIntegrationRegistry.nextHookName());
|
|
18
|
+
}
|
|
15
19
|
static registerUserSearchCallback(client, callback) {
|
|
16
|
-
|
|
17
|
-
client.registerAction(name, async ({ 'i': inputSoFar, 's': searchText, 'fd': serializedFieldData }) => {
|
|
18
|
-
const fieldData = serializedFieldData
|
|
19
|
-
? { name: serializedFieldData['n'], dataSourceId: serializedFieldData['ds'] }
|
|
20
|
-
: undefined;
|
|
21
|
-
const result = await callback(searchText, new Map(inputSoFar), fieldData);
|
|
22
|
-
return result.map((userData) => (0, cardintegrationdefinitions_1.serializeCardUserData)(userData));
|
|
23
|
-
});
|
|
24
|
-
return name;
|
|
20
|
+
return (0, sharedregistryutil_1.registerUserSearchCallback)(client, callback, () => LucidSpreadsheetIntegrationRegistry.nextHookName());
|
|
25
21
|
}
|
|
26
22
|
static registerFieldTypeToCollectionItemsCallback(client, callback) {
|
|
27
|
-
|
|
28
|
-
client.registerAction(name, async ({ 'd': dataSourceId, 'v': value, 'f': fieldName }) => {
|
|
29
|
-
const dataSourceProxy = dataSourceId ? new datasourceproxy_1.DataSourceProxy(dataSourceId, client) : undefined;
|
|
30
|
-
return await callback(fieldName, value, dataSourceProxy);
|
|
31
|
-
});
|
|
32
|
-
return name;
|
|
23
|
+
return (0, sharedregistryutil_1.registerFieldTypeToCollectionItemsCallback)(client, callback, () => LucidSpreadsheetIntegrationRegistry.nextHookName());
|
|
33
24
|
}
|
|
34
25
|
/**
|
|
35
26
|
* Register a spreadsheet integration.
|
|
@@ -92,6 +83,15 @@ class LucidSpreadsheetIntegrationRegistry {
|
|
|
92
83
|
return fields;
|
|
93
84
|
});
|
|
94
85
|
}
|
|
86
|
+
let getDefaultConfigActionName = undefined;
|
|
87
|
+
if (spreadsheetIntegration.getDefaultConfig) {
|
|
88
|
+
getDefaultConfigActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
|
|
89
|
+
const getDefaultConfig = spreadsheetIntegration.getDefaultConfig;
|
|
90
|
+
client.registerAction(getDefaultConfigActionName, async (param) => {
|
|
91
|
+
const dataSource = new datasourceproxy_1.DataSourceProxy(param['d'], client);
|
|
92
|
+
return (0, cardintegrationconfig_1.serializeCardIntegrationConfig)(await getDefaultConfig(dataSource));
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
95
|
const serialized = {
|
|
96
96
|
'il': spreadsheetIntegration.itemLabel,
|
|
97
97
|
'isl': spreadsheetIntegration.itemsLabel,
|
|
@@ -116,6 +116,9 @@ class LucidSpreadsheetIntegrationRegistry {
|
|
|
116
116
|
},
|
|
117
117
|
},
|
|
118
118
|
};
|
|
119
|
+
if (getDefaultConfigActionName) {
|
|
120
|
+
serialized['gdc'] = getDefaultConfigActionName;
|
|
121
|
+
}
|
|
119
122
|
if (spreadsheetIntegration.iconConfiguration) {
|
|
120
123
|
serialized['icu'] = {
|
|
121
124
|
'pi': spreadsheetIntegration.iconConfiguration.primaryIconUrl,
|
|
@@ -198,6 +198,7 @@ export declare const isStringOrNegativeOne: (x: unknown) => x is string | -1;
|
|
|
198
198
|
export declare const isRestrictions: (subject: unknown) => subject is DestructureGuardedTypeObj<{
|
|
199
199
|
b: (x: unknown) => x is boolean | null | undefined;
|
|
200
200
|
p: (x: unknown) => x is boolean | null | undefined;
|
|
201
|
+
s: (x: unknown) => x is boolean | null | undefined;
|
|
201
202
|
c: (x: unknown) => x is boolean | null | undefined;
|
|
202
203
|
f: (x: unknown) => x is boolean | null | undefined;
|
|
203
204
|
o: (x: unknown) => x is boolean | null | undefined;
|
|
@@ -444,6 +444,7 @@ exports.isStringOrNegativeOne = either(checks_1.isString, (v) => v === -1);
|
|
|
444
444
|
exports.isRestrictions = strictObjectValidator({
|
|
445
445
|
'b': nullableOption(checks_1.isBoolean),
|
|
446
446
|
'p': nullableOption(checks_1.isBoolean),
|
|
447
|
+
's': nullableOption(checks_1.isBoolean),
|
|
447
448
|
'c': nullableOption(checks_1.isBoolean),
|
|
448
449
|
'f': nullableOption(checks_1.isBoolean),
|
|
449
450
|
'o': nullableOption(checks_1.isBoolean),
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type SerializedFields } from '../core/data/serializedfield/serializedfields';
|
|
2
2
|
import { isSerializedSchema, type SerializedSchema } from '../core/data/serializedfield/serializedschema';
|
|
3
3
|
import { type SchemaDefinition } from './schemadefinition';
|
|
4
|
+
/** A complete description of a collection: its schema and the ordered set of items that conform to it. */
|
|
4
5
|
export interface CollectionDefinition {
|
|
5
6
|
schema: SchemaDefinition;
|
|
6
7
|
items: Map<string, SerializedFields>;
|
|
7
8
|
}
|
|
9
|
+
/** @ignore */
|
|
8
10
|
export declare const isSerializedCollectionDefinition: (subject: unknown) => subject is import("..").DestructureGuardedTypeObj<{
|
|
9
11
|
Schema: typeof isSerializedSchema;
|
|
10
12
|
Items: (val: unknown) => val is [string, Record<string | number, import("../core/data/serializedfield/serializedfields").SerializedFieldType>][];
|
|
@@ -8,6 +8,7 @@ const serializedfields_1 = require("../core/data/serializedfield/serializedfield
|
|
|
8
8
|
const serializedschema_1 = require("../core/data/serializedfield/serializedschema");
|
|
9
9
|
const validators_1 = require("../core/validators/validators");
|
|
10
10
|
const schemadefinition_1 = require("./schemadefinition");
|
|
11
|
+
/** @ignore */
|
|
11
12
|
exports.isSerializedCollectionDefinition = (0, validators_1.objectValidator)({
|
|
12
13
|
'Schema': serializedschema_1.isSerializedSchema,
|
|
13
14
|
'Items': (0, checks_1.isTypedArray)((0, checks_1.isPair)(checks_1.isString, serializedfields_1.isSerializedFields)),
|
|
@@ -1 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reserved key for entries in a collection's error map that report the status of the upstream schema sync.
|
|
3
|
+
* Use the `schemaOutOfSyncStatus` and `schemaOKStatus` helpers to construct the corresponding values.
|
|
4
|
+
*/
|
|
1
5
|
export declare const CollectionUpstreamSchemaStatus = "__CollectionUpstreamSchemaStatus__";
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CollectionUpstreamSchemaStatus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Reserved key for entries in a collection's error map that report the status of the upstream schema sync.
|
|
6
|
+
* Use the `schemaOutOfSyncStatus` and `schemaOKStatus` helpers to construct the corresponding values.
|
|
7
|
+
*/
|
|
4
8
|
exports.CollectionUpstreamSchemaStatus = '__CollectionUpstreamSchemaStatus__';
|
|
@@ -7,4 +7,5 @@ export declare const DataUpdateFilterType: {
|
|
|
7
7
|
/** All updates to items already present on the document will be sent to the document. New items created in the data source will not be created on the document. */
|
|
8
8
|
readonly CurrentItemUpdates: "CurrentItemUpdates";
|
|
9
9
|
};
|
|
10
|
+
/** One of the values in {@link DataUpdateFilterType}. */
|
|
10
11
|
export type DataUpdateFilterType = (typeof DataUpdateFilterType)[keyof typeof DataUpdateFilterType];
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { DisplayOptionType, type SerializedDisplayOption } from '../core/data/serializedfield/serializeddisplayoption';
|
|
2
|
+
/** Display option that renders a field as a multi-user select picker, allowing multiple users to be assigned. */
|
|
2
3
|
export interface DisplayMultiUserEditDisplayOptionDefinition {
|
|
3
4
|
type: typeof DisplayOptionType.DisplayMultiUserSelect;
|
|
4
5
|
value?: undefined;
|
|
5
6
|
}
|
|
7
|
+
/** Display option that shows helper text beneath a field to guide users on expected input. */
|
|
6
8
|
export interface HelperTextDisplayOptionDefinition {
|
|
7
9
|
type: typeof DisplayOptionType.HelperText;
|
|
8
10
|
value?: string | undefined;
|
|
9
11
|
}
|
|
12
|
+
/** Union of all supported display option types that control how a field is rendered in the UI. */
|
|
10
13
|
export type DisplayOptionDefinition = DisplayMultiUserEditDisplayOptionDefinition | HelperTextDisplayOptionDefinition;
|
|
14
|
+
/** Construct a {@link DisplayOptionDefinition} for the given type, validating that the value (if any) matches what the type expects. */
|
|
11
15
|
export declare function createDisplayOptionDefinition(type: DisplayOptionType, value?: number | string): DisplayOptionDefinition;
|
|
16
|
+
/** @ignore */
|
|
12
17
|
export declare const isDisplayOptionDefinition: (x: unknown) => x is DisplayOptionDefinition;
|
|
13
18
|
/** @ignore */
|
|
14
19
|
export declare function serializeDisplayOptionDefinition(option: DisplayOptionDefinition): SerializedDisplayOption;
|
|
@@ -7,6 +7,7 @@ const assertnever_1 = require("../core/assertnever");
|
|
|
7
7
|
const checks_1 = require("../core/checks");
|
|
8
8
|
const serializeddisplayoption_1 = require("../core/data/serializedfield/serializeddisplayoption");
|
|
9
9
|
const validators_1 = require("../core/validators/validators");
|
|
10
|
+
/** Construct a {@link DisplayOptionDefinition} for the given type, validating that the value (if any) matches what the type expects. */
|
|
10
11
|
function createDisplayOptionDefinition(type, value) {
|
|
11
12
|
switch (type) {
|
|
12
13
|
case serializeddisplayoption_1.DisplayOptionType.DisplayMultiUserSelect:
|
|
@@ -36,6 +37,7 @@ const isHelperTextDisplayOptionDefinition = (0, validators_1.objectValidator)({
|
|
|
36
37
|
const isDisplayMultiUserSelectDisplayOptionDefinition = (0, validators_1.objectValidator)({
|
|
37
38
|
type: isDisplayMultiUserSelectType,
|
|
38
39
|
});
|
|
40
|
+
/** @ignore */
|
|
39
41
|
exports.isDisplayOptionDefinition = (0, validators_1.either)(isHelperTextDisplayOptionDefinition, isDisplayMultiUserSelectDisplayOptionDefinition);
|
|
40
42
|
/** @ignore */
|
|
41
43
|
function serializeDisplayOptionDefinition(option) {
|
|
@@ -1,45 +1,54 @@
|
|
|
1
1
|
import { isNumber, isUndefined } from '../core/checks';
|
|
2
2
|
import { FieldConstraintType, type SerializedFieldConstraint } from '../core/data/serializedfield/serializedfielddefinition';
|
|
3
|
+
/** Constraint that marks a field as required, preventing empty values. */
|
|
3
4
|
export interface RequiredFieldConstraintDefinition {
|
|
4
5
|
type: typeof FieldConstraintType.REQUIRED;
|
|
5
6
|
value?: undefined;
|
|
6
7
|
reason?: string | undefined;
|
|
7
8
|
}
|
|
9
|
+
/** Constraint that locks a field, preventing users from editing its value. */
|
|
8
10
|
export interface LockedFieldConstraintDefinition {
|
|
9
11
|
type: typeof FieldConstraintType.LOCKED;
|
|
10
12
|
value?: undefined;
|
|
11
13
|
reason?: string | undefined;
|
|
12
14
|
}
|
|
15
|
+
/** Constraint that enforces a minimum numeric value for a field. */
|
|
13
16
|
export interface MinValueFieldConstraintDefinition {
|
|
14
17
|
type: typeof FieldConstraintType.MIN_VALUE;
|
|
15
18
|
value: number;
|
|
16
19
|
reason?: string | undefined;
|
|
17
20
|
}
|
|
21
|
+
/** Constraint that enforces a maximum numeric value for a field. */
|
|
18
22
|
export interface MaxValueFieldConstraintDefinition {
|
|
19
23
|
type: typeof FieldConstraintType.MAX_VALUE;
|
|
20
24
|
value: number;
|
|
21
25
|
reason?: string | undefined;
|
|
22
26
|
}
|
|
27
|
+
/** Constraint that restricts a text field to a single line, disallowing newline characters. */
|
|
23
28
|
export interface SingleLineFieldConstraintDefinition {
|
|
24
29
|
type: typeof FieldConstraintType.SINGLE_LINE_ONLY;
|
|
25
30
|
value?: undefined;
|
|
26
31
|
reason?: string | undefined;
|
|
27
32
|
}
|
|
33
|
+
/** Constraint that disallows whitespace characters in a field value. */
|
|
28
34
|
export interface NoWhitespaceFieldConstraintDefinition {
|
|
29
35
|
type: typeof FieldConstraintType.NO_WHITESPACE;
|
|
30
36
|
value?: undefined;
|
|
31
37
|
reason?: string | undefined;
|
|
32
38
|
}
|
|
39
|
+
/** Constraint that requires a field value to be unique across all items in the collection when edited. */
|
|
33
40
|
export interface UniqueEditFieldConstraintDefinition {
|
|
34
41
|
type: typeof FieldConstraintType.UNIQUE_EDIT;
|
|
35
42
|
value?: undefined;
|
|
36
43
|
reason?: string | undefined;
|
|
37
44
|
}
|
|
45
|
+
/** Constraint that enforces a maximum character length for a text field. */
|
|
38
46
|
export interface MaxLengthConstraintDefinition {
|
|
39
47
|
type: typeof FieldConstraintType.MAX_LENGTH;
|
|
40
48
|
value: number;
|
|
41
49
|
reason?: string | undefined;
|
|
42
50
|
}
|
|
51
|
+
/** Constraint that limits the number of decimal places allowed in a numeric field value. */
|
|
43
52
|
export interface MaxDecimalPlacesConstraintDefinition {
|
|
44
53
|
type: typeof FieldConstraintType.MAX_DECIMAL_PLACES;
|
|
45
54
|
value: number;
|
|
@@ -51,9 +60,13 @@ export interface MaxDecimalLengthConstraintDefinition {
|
|
|
51
60
|
value: number;
|
|
52
61
|
reason?: string | undefined;
|
|
53
62
|
}
|
|
63
|
+
/** Union of all supported field constraint types that can be applied to a collection schema field. */
|
|
54
64
|
export type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition | UniqueEditFieldConstraintDefinition | MaxLengthConstraintDefinition | MaxDecimalPlacesConstraintDefinition | MaxDecimalLengthConstraintDefinition;
|
|
65
|
+
/** Construct a {@link FieldConstraintDefinition} for the given type, validating that the value (if any) matches what the type expects. */
|
|
55
66
|
export declare function createFieldConstraintDefinition(type: FieldConstraintType, value?: number, reason?: string): FieldConstraintDefinition;
|
|
67
|
+
/** @ignore */
|
|
56
68
|
export declare function numericFieldConstraintValidator(val: unknown): val is typeof FieldConstraintType.MIN_VALUE | typeof FieldConstraintType.MAX_VALUE | typeof FieldConstraintType.MAX_LENGTH | typeof FieldConstraintType.MAX_DECIMAL_PLACES | typeof FieldConstraintType.MAX_DECIMAL_LENGTH;
|
|
69
|
+
/** @ignore */
|
|
57
70
|
export declare const isFieldConstraintDefinition: (x: unknown) => x is import("..").DestructureGuardedTypeObj<{
|
|
58
71
|
type: (x: unknown) => x is {} extends {
|
|
59
72
|
readonly REQUIRED: "required";
|
|
@@ -8,6 +8,7 @@ const assertnever_1 = require("../core/assertnever");
|
|
|
8
8
|
const checks_1 = require("../core/checks");
|
|
9
9
|
const serializedfielddefinition_1 = require("../core/data/serializedfield/serializedfielddefinition");
|
|
10
10
|
const validators_1 = require("../core/validators/validators");
|
|
11
|
+
/** Construct a {@link FieldConstraintDefinition} for the given type, validating that the value (if any) matches what the type expects. */
|
|
11
12
|
function createFieldConstraintDefinition(type, value, reason) {
|
|
12
13
|
switch (type) {
|
|
13
14
|
case serializedfielddefinition_1.FieldConstraintType.REQUIRED:
|
|
@@ -33,6 +34,7 @@ function createFieldConstraintDefinition(type, value, reason) {
|
|
|
33
34
|
(0, assertnever_1.assertNever)(type);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
37
|
+
/** @ignore */
|
|
36
38
|
function numericFieldConstraintValidator(val) {
|
|
37
39
|
return (val === serializedfielddefinition_1.FieldConstraintType.MIN_VALUE ||
|
|
38
40
|
val === serializedfielddefinition_1.FieldConstraintType.MAX_VALUE ||
|
|
@@ -40,6 +42,7 @@ function numericFieldConstraintValidator(val) {
|
|
|
40
42
|
val === serializedfielddefinition_1.FieldConstraintType.MAX_DECIMAL_PLACES ||
|
|
41
43
|
val === serializedfielddefinition_1.FieldConstraintType.MAX_DECIMAL_LENGTH);
|
|
42
44
|
}
|
|
45
|
+
/** @ignore */
|
|
43
46
|
exports.isFieldConstraintDefinition = (0, validators_1.both)((0, validators_1.objectValidator)({
|
|
44
47
|
'type': serializedfielddefinition_1.isFieldConstraintType,
|
|
45
48
|
}), (0, validators_1.either)((0, validators_1.objectValidator)({ 'type': numericFieldConstraintValidator, 'value': checks_1.isNumber }), (0, validators_1.objectValidator)({
|