lucid-extension-sdk 0.0.44 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/sdk/commandtypes.d.ts +15 -1
- package/sdk/core/cardintegration/cardintegration.d.ts +63 -29
- package/sdk/core/cardintegration/cardintegration.js +19 -26
- package/sdk/data/collectionproxy.d.ts +3 -1
- package/sdk/data/collectionproxy.js +5 -1
- package/sdk/data/schemadefinition.d.ts +33 -0
- package/sdk/data/schemadefinition.js +51 -13
- package/sdk/document/taskmanagementcardintegration.js +28 -3
package/package.json
CHANGED
package/sdk/commandtypes.d.ts
CHANGED
|
@@ -415,12 +415,18 @@ export declare type CommandArgs = {
|
|
|
415
415
|
export declare type AddCardIntegrationQuery = {
|
|
416
416
|
/** Title/name */
|
|
417
417
|
'n': string;
|
|
418
|
+
/** Item label */
|
|
419
|
+
'il': string;
|
|
420
|
+
/** Items label */
|
|
421
|
+
'isl': string;
|
|
418
422
|
/** Icon url */
|
|
419
423
|
'u': string;
|
|
420
424
|
/** Callback to get field definitions for a given imported collection */
|
|
421
425
|
'gf': string;
|
|
422
426
|
/** Show intro if user has not yet authorized this integration */
|
|
423
427
|
'i'?: string;
|
|
428
|
+
/** Get default config action */
|
|
429
|
+
'gdc': string;
|
|
424
430
|
/** If specified, import modal settings */
|
|
425
431
|
'im'?: {
|
|
426
432
|
/** Get search fields action */
|
|
@@ -430,6 +436,13 @@ export declare type AddCardIntegrationQuery = {
|
|
|
430
436
|
/** Import action */
|
|
431
437
|
'i': string;
|
|
432
438
|
};
|
|
439
|
+
/** If specified, add-card settings */
|
|
440
|
+
'ac'?: {
|
|
441
|
+
/** Get input fields action */
|
|
442
|
+
'gif': string;
|
|
443
|
+
/** Create card action */
|
|
444
|
+
'cc': string;
|
|
445
|
+
};
|
|
433
446
|
};
|
|
434
447
|
export declare type AddCardIntegrationResult = undefined;
|
|
435
448
|
export declare type AddLineTextAreaQuery = {
|
|
@@ -822,7 +835,8 @@ export declare type PatchDataItemsQuery = {
|
|
|
822
835
|
/** Primary keys of items to delete */
|
|
823
836
|
'd': string[];
|
|
824
837
|
};
|
|
825
|
-
|
|
838
|
+
/** Primary keys inserted, if any */
|
|
839
|
+
export declare type PatchDataItemsResult = string[];
|
|
826
840
|
export declare type RegisterPanelQuery = {
|
|
827
841
|
/** Name of the panel's action for receiving events; generated automatically by Panel base class */
|
|
828
842
|
'n': string;
|
|
@@ -1,36 +1,23 @@
|
|
|
1
1
|
import { CollectionDefinition } from '../../data/collectiondefinition';
|
|
2
2
|
import { CollectionProxy } from '../../data/collectionproxy';
|
|
3
|
+
import { FieldDefinition } from '../../data/schemadefinition';
|
|
3
4
|
import { isString } from '../checks';
|
|
4
|
-
import {
|
|
5
|
+
import { isSerializedFieldTypeDefinition } from '../data/fieldtypedefinition/fieldtypedefinition';
|
|
6
|
+
import { FieldConstraintType, SerializedFieldDefinition } from '../data/serializedfield/serializedfielddefinition';
|
|
5
7
|
import { isSerializedFieldType, SerializedFieldType } from '../data/serializedfield/serializedfields';
|
|
6
|
-
/**
|
|
7
|
-
* When this field is displayed on a card shape, how should it be displayed?
|
|
8
|
-
*/
|
|
9
|
-
export declare enum CardFieldDisplayType {
|
|
10
|
-
Text = 1,
|
|
11
|
-
TextBadge = 2,
|
|
12
|
-
ImageBadge = 3
|
|
13
|
-
}
|
|
14
8
|
/** For fields with Option or ApiOption type, the label and value for each available option */
|
|
15
9
|
export interface ExtensionCardFieldOption {
|
|
16
10
|
label: string;
|
|
17
11
|
value: SerializedFieldType;
|
|
18
12
|
}
|
|
19
|
-
export interface ExtensionCardFieldDefinition {
|
|
20
|
-
/**
|
|
21
|
-
fieldName: string;
|
|
22
|
-
/** The text to display on the menu item */
|
|
13
|
+
export interface ExtensionCardFieldDefinition extends FieldDefinition {
|
|
14
|
+
/** The label to display in the UI */
|
|
23
15
|
label: string;
|
|
24
|
-
/**
|
|
16
|
+
/** If defined, the default value for this field */
|
|
17
|
+
default?: SerializedFieldType;
|
|
18
|
+
/** Additional information we can provide to users, e.g. as a hover tooltip */
|
|
25
19
|
description?: string;
|
|
26
|
-
/**
|
|
27
|
-
displayType?: CardFieldDisplayType;
|
|
28
|
-
/**
|
|
29
|
-
* Override what kind of input to allow the user to edit the value.
|
|
30
|
-
* e.g. ScalarFieldTypeEnum.STRING for a text input
|
|
31
|
-
**/
|
|
32
|
-
inputType?: FieldTypeDefinition;
|
|
33
|
-
/** If dataType is Option, the list of options available to choose from */
|
|
20
|
+
/** If specified, the list of options available to choose from */
|
|
34
21
|
options?: ExtensionCardFieldOption[];
|
|
35
22
|
}
|
|
36
23
|
/** @ignore */
|
|
@@ -41,12 +28,10 @@ export declare type SerializedCardFieldOption = {
|
|
|
41
28
|
/** @ignore */
|
|
42
29
|
export declare function serializeCardFieldOption(option: ExtensionCardFieldOption): SerializedCardFieldOption;
|
|
43
30
|
/** @ignore */
|
|
44
|
-
export declare type SerializedExtensionCardFieldDefinition = {
|
|
45
|
-
'
|
|
46
|
-
'
|
|
31
|
+
export declare type SerializedExtensionCardFieldDefinition = SerializedFieldDefinition & {
|
|
32
|
+
'l': string;
|
|
33
|
+
'def'?: SerializedFieldType;
|
|
47
34
|
'd'?: string;
|
|
48
|
-
'diT'?: CardFieldDisplayType;
|
|
49
|
-
'daT'?: SerializedFieldTypeDefinition;
|
|
50
35
|
'op'?: SerializedCardFieldOption[];
|
|
51
36
|
};
|
|
52
37
|
/** @ignore */
|
|
@@ -63,6 +48,26 @@ export declare const isSerializedFieldOptions: (p1: unknown) => p1 is import("..
|
|
|
63
48
|
l: typeof isString;
|
|
64
49
|
v: typeof isSerializedFieldType;
|
|
65
50
|
}>[];
|
|
51
|
+
export declare const isSerializedFieldConstraint: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
|
|
52
|
+
Type: (x: unknown) => x is FieldConstraintType;
|
|
53
|
+
Details: (x: unknown) => x is number | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
/** @ignore */
|
|
56
|
+
export declare const isSerializedExtensionCardFieldDefinition: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
|
|
57
|
+
Name: typeof isString;
|
|
58
|
+
Type: typeof isSerializedFieldTypeDefinition;
|
|
59
|
+
Constraints: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
|
|
60
|
+
Type: (x: unknown) => x is FieldConstraintType;
|
|
61
|
+
Details: (x: unknown) => x is number | undefined;
|
|
62
|
+
}>[] | undefined;
|
|
63
|
+
l: typeof isString;
|
|
64
|
+
d: (x: unknown) => x is string | undefined;
|
|
65
|
+
def: (x: unknown) => x is SerializedFieldType;
|
|
66
|
+
op: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
|
|
67
|
+
l: typeof isString;
|
|
68
|
+
v: typeof isSerializedFieldType;
|
|
69
|
+
}>[] | undefined;
|
|
70
|
+
}>;
|
|
66
71
|
/** @ignore */
|
|
67
72
|
export declare function deserializeCardFieldDefinition(field: SerializedExtensionCardFieldDefinition): ExtensionCardFieldDefinition;
|
|
68
73
|
/** @ignore */
|
|
@@ -92,6 +97,14 @@ export interface CardIntegration {
|
|
|
92
97
|
* Should be unique within any given extension.
|
|
93
98
|
*/
|
|
94
99
|
label: string;
|
|
100
|
+
/**
|
|
101
|
+
* Label used to identify one card worth of data, e.g. "Jira task"
|
|
102
|
+
*/
|
|
103
|
+
itemLabel: string;
|
|
104
|
+
/**
|
|
105
|
+
* Label used to identify multiple cards worth of data, e.g. "Jira tasks"
|
|
106
|
+
*/
|
|
107
|
+
itemsLabel: string;
|
|
95
108
|
/**
|
|
96
109
|
* URL for an icon to display in toolbars, etc. Should be at least 24x24.
|
|
97
110
|
*/
|
|
@@ -109,6 +122,10 @@ export interface CardIntegration {
|
|
|
109
122
|
* this should show the user an intro dialog or take some other action.
|
|
110
123
|
*/
|
|
111
124
|
showIntro?: () => void;
|
|
125
|
+
/**
|
|
126
|
+
* Provide the default configuration for a new import
|
|
127
|
+
*/
|
|
128
|
+
getDefaultConfig: (collection: CollectionProxy) => Promise<CardIntegrationConfig>;
|
|
112
129
|
/**
|
|
113
130
|
* If specified, allow the user to import cards using the standard card-import modal.
|
|
114
131
|
*/
|
|
@@ -133,10 +150,27 @@ export interface CardIntegration {
|
|
|
133
150
|
* The config provided here is only used on the first import from a given source; on subsequent imports,
|
|
134
151
|
* the existing config will remain unchanged to preserve any customizations by the user.
|
|
135
152
|
*/
|
|
136
|
-
import: (primaryKeys: string[]) => Promise<{
|
|
153
|
+
import: (primaryKeys: string[], searchFields: Map<string, SerializedFieldType>) => Promise<{
|
|
137
154
|
collection: CollectionProxy;
|
|
138
155
|
primaryKeys: string[];
|
|
139
|
-
|
|
156
|
+
}>;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* If specified, allow the user to create new cards and convert other shapes to cards
|
|
160
|
+
*/
|
|
161
|
+
addCard?: {
|
|
162
|
+
/**
|
|
163
|
+
* Given the values entered by the user so far into input fields, return the list of all input fields
|
|
164
|
+
* to display in the create-card form.
|
|
165
|
+
*/
|
|
166
|
+
getInputFields: (inputSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldDefinition[]>;
|
|
167
|
+
/**
|
|
168
|
+
* Given the values entered by the user into input fields, create a new data record to represent the
|
|
169
|
+
* created card, and return information about that record.
|
|
170
|
+
*/
|
|
171
|
+
createCardData: (input: Map<string, SerializedFieldType>) => Promise<{
|
|
172
|
+
collection: CollectionProxy;
|
|
173
|
+
primaryKey: string;
|
|
140
174
|
}>;
|
|
141
175
|
};
|
|
142
176
|
}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializeCardIntegrationConfig = exports.serializeCardIntegrationConfig = exports.deserializeCardFieldArrayDefinition = exports.deserializeCardFieldDefinition = exports.isSerializedFieldOptions = exports.isSerializedFieldOption = exports.deserializeFieldOption = exports.serializeCardFieldArrayDefinition = exports.serializeCardFieldDefinition = exports.serializeCardFieldOption =
|
|
3
|
+
exports.deserializeCardIntegrationConfig = exports.serializeCardIntegrationConfig = exports.deserializeCardFieldArrayDefinition = exports.deserializeCardFieldDefinition = exports.isSerializedExtensionCardFieldDefinition = exports.isSerializedFieldConstraint = exports.isSerializedFieldOptions = exports.isSerializedFieldOption = exports.deserializeFieldOption = exports.serializeCardFieldArrayDefinition = exports.serializeCardFieldDefinition = exports.serializeCardFieldOption = void 0;
|
|
4
|
+
const schemadefinition_1 = require("../../data/schemadefinition");
|
|
4
5
|
const checks_1 = require("../checks");
|
|
5
6
|
const fieldtypedefinition_1 = require("../data/fieldtypedefinition/fieldtypedefinition");
|
|
7
|
+
const serializedfielddefinition_1 = require("../data/serializedfield/serializedfielddefinition");
|
|
6
8
|
const serializedfields_1 = require("../data/serializedfield/serializedfields");
|
|
7
9
|
const validators_1 = require("../validators/validators");
|
|
8
|
-
/**
|
|
9
|
-
* When this field is displayed on a card shape, how should it be displayed?
|
|
10
|
-
*/
|
|
11
|
-
var CardFieldDisplayType;
|
|
12
|
-
(function (CardFieldDisplayType) {
|
|
13
|
-
CardFieldDisplayType[CardFieldDisplayType["Text"] = 1] = "Text";
|
|
14
|
-
CardFieldDisplayType[CardFieldDisplayType["TextBadge"] = 2] = "TextBadge";
|
|
15
|
-
CardFieldDisplayType[CardFieldDisplayType["ImageBadge"] = 3] = "ImageBadge";
|
|
16
|
-
})(CardFieldDisplayType = exports.CardFieldDisplayType || (exports.CardFieldDisplayType = {}));
|
|
17
10
|
/** @ignore */
|
|
18
11
|
function serializeCardFieldOption(option) {
|
|
19
12
|
return {
|
|
@@ -25,14 +18,7 @@ exports.serializeCardFieldOption = serializeCardFieldOption;
|
|
|
25
18
|
/** @ignore */
|
|
26
19
|
function serializeCardFieldDefinition(field) {
|
|
27
20
|
var _a;
|
|
28
|
-
return {
|
|
29
|
-
'n': field.fieldName,
|
|
30
|
-
't': field.label,
|
|
31
|
-
'd': field.description,
|
|
32
|
-
'diT': field.displayType,
|
|
33
|
-
'daT': field.inputType === undefined ? undefined : (0, fieldtypedefinition_1.serializeFieldTypeDefinition)(field.inputType),
|
|
34
|
-
'op': (_a = field.options) === null || _a === void 0 ? void 0 : _a.map(serializeCardFieldOption),
|
|
35
|
-
};
|
|
21
|
+
return Object.assign(Object.assign({}, (0, schemadefinition_1.serializeFieldDefinition)(field)), { 'l': field.label, 'def': field.default, 'd': field.description, 'op': (_a = field.options) === null || _a === void 0 ? void 0 : _a.map(serializeCardFieldOption) });
|
|
36
22
|
}
|
|
37
23
|
exports.serializeCardFieldDefinition = serializeCardFieldDefinition;
|
|
38
24
|
/** @ignore */
|
|
@@ -53,17 +39,24 @@ exports.isSerializedFieldOption = (0, validators_1.objectValidator)({
|
|
|
53
39
|
'v': serializedfields_1.isSerializedFieldType,
|
|
54
40
|
});
|
|
55
41
|
exports.isSerializedFieldOptions = (0, validators_1.arrayValidator)(exports.isSerializedFieldOption);
|
|
42
|
+
exports.isSerializedFieldConstraint = (0, validators_1.objectValidator)({
|
|
43
|
+
'Type': (0, validators_1.enumValidator)(serializedfielddefinition_1.FieldConstraintType),
|
|
44
|
+
'Details': (0, validators_1.option)(checks_1.isNumber),
|
|
45
|
+
});
|
|
46
|
+
/** @ignore */
|
|
47
|
+
exports.isSerializedExtensionCardFieldDefinition = (0, validators_1.objectValidator)({
|
|
48
|
+
'Name': checks_1.isString,
|
|
49
|
+
'Type': fieldtypedefinition_1.isSerializedFieldTypeDefinition,
|
|
50
|
+
'Constraints': (0, validators_1.option)((0, validators_1.arrayValidator)(exports.isSerializedFieldConstraint)),
|
|
51
|
+
'l': checks_1.isString,
|
|
52
|
+
'd': (0, validators_1.option)(checks_1.isString),
|
|
53
|
+
'def': (0, validators_1.option)(serializedfields_1.isSerializedFieldType),
|
|
54
|
+
'op': (0, validators_1.option)((0, validators_1.arrayValidator)(exports.isSerializedFieldOption)),
|
|
55
|
+
});
|
|
56
56
|
/** @ignore */
|
|
57
57
|
function deserializeCardFieldDefinition(field) {
|
|
58
58
|
var _a;
|
|
59
|
-
return {
|
|
60
|
-
fieldName: field['n'],
|
|
61
|
-
label: field['t'],
|
|
62
|
-
description: field['d'],
|
|
63
|
-
displayType: field['diT'],
|
|
64
|
-
inputType: field['daT'] === undefined ? undefined : (0, fieldtypedefinition_1.deserializeFieldTypeDefinition)(field['daT']),
|
|
65
|
-
options: (_a = field['op']) === null || _a === void 0 ? void 0 : _a.map(deserializeFieldOption),
|
|
66
|
-
};
|
|
59
|
+
return Object.assign(Object.assign({}, (0, schemadefinition_1.parseFieldDefinition)(field)), { label: field['l'], description: field['d'], default: field['def'], options: (_a = field['op']) === null || _a === void 0 ? void 0 : _a.map(deserializeFieldOption) });
|
|
67
60
|
}
|
|
68
61
|
exports.deserializeCardFieldDefinition = deserializeCardFieldDefinition;
|
|
69
62
|
/** @ignore */
|
|
@@ -3,6 +3,7 @@ import { MapProxy } from '../document/mapproxy';
|
|
|
3
3
|
import { PropertyStoreProxy } from '../document/propertystoreproxy';
|
|
4
4
|
import { EditorClient } from '../editorclient';
|
|
5
5
|
import { DataItemProxy } from './dataitemproxy';
|
|
6
|
+
import { SchemaDefinition } from './schemadefinition';
|
|
6
7
|
/**
|
|
7
8
|
* A collection is a set of data items, each with the same set of fields (though some data items may not have all
|
|
8
9
|
* fields defined).
|
|
@@ -38,9 +39,10 @@ export declare class CollectionProxy extends PropertyStoreProxy {
|
|
|
38
39
|
added?: Record<string, SerializedFieldType>[];
|
|
39
40
|
changed?: Map<string, Record<string, SerializedFieldType>>;
|
|
40
41
|
deleted?: string[];
|
|
41
|
-
}):
|
|
42
|
+
}): import("../commandtypes").PatchDataItemsResult;
|
|
42
43
|
/**
|
|
43
44
|
* @returns an array of field names that are accessible on the items in this collection
|
|
44
45
|
*/
|
|
45
46
|
getFields(): string[];
|
|
47
|
+
getSchema(): SchemaDefinition;
|
|
46
48
|
}
|
|
@@ -4,6 +4,7 @@ exports.CollectionProxy = void 0;
|
|
|
4
4
|
const mapproxy_1 = require("../document/mapproxy");
|
|
5
5
|
const propertystoreproxy_1 = require("../document/propertystoreproxy");
|
|
6
6
|
const dataitemproxy_1 = require("./dataitemproxy");
|
|
7
|
+
const schemadefinition_1 = require("./schemadefinition");
|
|
7
8
|
/**
|
|
8
9
|
* A collection is a set of data items, each with the same set of fields (though some data items may not have all
|
|
9
10
|
* fields defined).
|
|
@@ -50,7 +51,7 @@ class CollectionProxy extends propertystoreproxy_1.PropertyStoreProxy {
|
|
|
50
51
|
changed[primaryKey] = record;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
|
-
this.client.sendCommand("pdi" /* PatchDataItems */, {
|
|
54
|
+
return this.client.sendCommand("pdi" /* PatchDataItems */, {
|
|
54
55
|
'id': this.id,
|
|
55
56
|
'a': (_a = patch.added) !== null && _a !== void 0 ? _a : [],
|
|
56
57
|
'c': changed,
|
|
@@ -63,5 +64,8 @@ class CollectionProxy extends propertystoreproxy_1.PropertyStoreProxy {
|
|
|
63
64
|
getFields() {
|
|
64
65
|
return this.client.sendCommand("lcf" /* ListCollectionFields */, { 'id': this.id });
|
|
65
66
|
}
|
|
67
|
+
getSchema() {
|
|
68
|
+
return (0, schemadefinition_1.parseSchemaDefinition)(this.properties.get('Schema'));
|
|
69
|
+
}
|
|
66
70
|
}
|
|
67
71
|
exports.CollectionProxy = CollectionProxy;
|
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
import { FieldTypeDefinition } from '../core/data/fieldtypedefinition/fieldtypedefinition';
|
|
2
|
+
import { FieldConstraintType, SerializedFieldConstraint, SerializedFieldDefinition } from '../core/data/serializedfield/serializedfielddefinition';
|
|
2
3
|
import { SerializedSchema } from '../core/data/serializedfield/serializedschema';
|
|
4
|
+
export interface RequiredFieldConstraintDefinition {
|
|
5
|
+
type: FieldConstraintType.REQUIRED;
|
|
6
|
+
value?: undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface LockedFieldConstraintDefinition {
|
|
9
|
+
type: FieldConstraintType.LOCKED;
|
|
10
|
+
value?: undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface MinValueFieldConstraintDefinition {
|
|
13
|
+
type: FieldConstraintType.MIN_VALUE;
|
|
14
|
+
value: number;
|
|
15
|
+
}
|
|
16
|
+
export interface MaxValueFieldConstraintDefinition {
|
|
17
|
+
type: FieldConstraintType.MAX_VALUE;
|
|
18
|
+
value: number;
|
|
19
|
+
}
|
|
20
|
+
export interface SingleLineFieldConstraintDefinition {
|
|
21
|
+
type: FieldConstraintType.SINGLE_LINE_ONLY;
|
|
22
|
+
value?: undefined;
|
|
23
|
+
}
|
|
24
|
+
export interface NoWhitespaceFieldConstraintDefinition {
|
|
25
|
+
type: FieldConstraintType.NO_WHITESPACE;
|
|
26
|
+
value?: undefined;
|
|
27
|
+
}
|
|
28
|
+
export declare type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition;
|
|
3
29
|
/**
|
|
4
30
|
* The definition for a field to be included in a [SchemaDefinition](#interfaces_data_schemadefinition-SchemaDefinition)
|
|
5
31
|
*/
|
|
6
32
|
export interface FieldDefinition {
|
|
7
33
|
name: string;
|
|
8
34
|
type: FieldTypeDefinition;
|
|
35
|
+
constraints?: FieldConstraintDefinition[];
|
|
9
36
|
}
|
|
10
37
|
/**
|
|
11
38
|
* Definition of a schema for creating a [Collection](#classes_data_collectionproxy-CollectionProxy)
|
|
@@ -24,6 +51,12 @@ export interface SchemaDefinition {
|
|
|
24
51
|
fieldLabels?: Record<string, string>;
|
|
25
52
|
}
|
|
26
53
|
/** @ignore */
|
|
54
|
+
export declare function serializeFieldConstraintDefinition(constraint: FieldConstraintDefinition): SerializedFieldConstraint;
|
|
55
|
+
/** @ignore */
|
|
56
|
+
export declare function serializeFieldDefinition(field: FieldDefinition): SerializedFieldDefinition;
|
|
57
|
+
/** @ignore */
|
|
27
58
|
export declare function serializeSchemaDefinition(def: SchemaDefinition): SerializedSchema;
|
|
28
59
|
/** @ignore */
|
|
60
|
+
export declare function parseFieldDefinition(field: SerializedFieldDefinition): FieldDefinition;
|
|
61
|
+
/** @ignore */
|
|
29
62
|
export declare function parseSchemaDefinition(def: SerializedSchema): SchemaDefinition;
|
|
@@ -1,30 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseSchemaDefinition = exports.serializeSchemaDefinition = void 0;
|
|
3
|
+
exports.parseSchemaDefinition = exports.parseFieldDefinition = exports.serializeSchemaDefinition = exports.serializeFieldDefinition = exports.serializeFieldConstraintDefinition = void 0;
|
|
4
|
+
const checks_1 = require("../core/checks");
|
|
4
5
|
const fieldtypedefinition_1 = require("../core/data/fieldtypedefinition/fieldtypedefinition");
|
|
6
|
+
const serializedfielddefinition_1 = require("../core/data/serializedfield/serializedfielddefinition");
|
|
7
|
+
/** @ignore */
|
|
8
|
+
function serializeFieldConstraintDefinition(constraint) {
|
|
9
|
+
return {
|
|
10
|
+
'Type': constraint.type,
|
|
11
|
+
'Details': constraint.value,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.serializeFieldConstraintDefinition = serializeFieldConstraintDefinition;
|
|
15
|
+
/** @ignore */
|
|
16
|
+
function serializeFieldDefinition(field) {
|
|
17
|
+
const serialized = {
|
|
18
|
+
'Name': field.name,
|
|
19
|
+
'Type': (0, fieldtypedefinition_1.serializeFieldTypeDefinition)(field.type),
|
|
20
|
+
};
|
|
21
|
+
if (field.constraints) {
|
|
22
|
+
serialized['Constraints'] = field.constraints.map(serializeFieldConstraintDefinition);
|
|
23
|
+
}
|
|
24
|
+
return serialized;
|
|
25
|
+
}
|
|
26
|
+
exports.serializeFieldDefinition = serializeFieldDefinition;
|
|
5
27
|
/** @ignore */
|
|
6
28
|
function serializeSchemaDefinition(def) {
|
|
7
29
|
return {
|
|
8
|
-
'Fields': def.fields.map(
|
|
9
|
-
return {
|
|
10
|
-
'Name': field.name,
|
|
11
|
-
'Type': (0, fieldtypedefinition_1.serializeFieldTypeDefinition)(field.type),
|
|
12
|
-
};
|
|
13
|
-
}),
|
|
30
|
+
'Fields': def.fields.map(serializeFieldDefinition),
|
|
14
31
|
'PrimaryKey': def.primaryKey,
|
|
15
32
|
'FieldLabelOverrides': def.fieldLabels,
|
|
16
33
|
};
|
|
17
34
|
}
|
|
18
35
|
exports.serializeSchemaDefinition = serializeSchemaDefinition;
|
|
19
36
|
/** @ignore */
|
|
20
|
-
function
|
|
37
|
+
function parseFieldDefinition(field) {
|
|
38
|
+
var _a;
|
|
21
39
|
return {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
name: field['Name'],
|
|
41
|
+
type: (0, fieldtypedefinition_1.deserializeFieldTypeDefinition)(field['Type']),
|
|
42
|
+
constraints: (_a = field['Constraints']) === null || _a === void 0 ? void 0 : _a.map((constraint) => {
|
|
43
|
+
switch (constraint['Type']) {
|
|
44
|
+
case serializedfielddefinition_1.FieldConstraintType.MIN_VALUE:
|
|
45
|
+
case serializedfielddefinition_1.FieldConstraintType.MAX_VALUE:
|
|
46
|
+
if (!(0, checks_1.isNumber)(constraint['Details'])) {
|
|
47
|
+
throw new Error('Invalid constraint format');
|
|
48
|
+
}
|
|
49
|
+
return { type: constraint['Type'], value: constraint['Details'] };
|
|
50
|
+
case serializedfielddefinition_1.FieldConstraintType.REQUIRED:
|
|
51
|
+
case serializedfielddefinition_1.FieldConstraintType.LOCKED:
|
|
52
|
+
case serializedfielddefinition_1.FieldConstraintType.SINGLE_LINE_ONLY:
|
|
53
|
+
case serializedfielddefinition_1.FieldConstraintType.NO_WHITESPACE:
|
|
54
|
+
return { type: constraint['Type'] };
|
|
55
|
+
default:
|
|
56
|
+
throw new Error('Invalid constraint format');
|
|
57
|
+
}
|
|
27
58
|
}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.parseFieldDefinition = parseFieldDefinition;
|
|
62
|
+
/** @ignore */
|
|
63
|
+
function parseSchemaDefinition(def) {
|
|
64
|
+
return {
|
|
65
|
+
fields: def['Fields'].map(parseFieldDefinition),
|
|
28
66
|
primaryKey: def['PrimaryKey'],
|
|
29
67
|
fieldLabels: def['FieldLabelOverrides'],
|
|
30
68
|
};
|
|
@@ -23,6 +23,11 @@ class TaskManagementCardIntegration {
|
|
|
23
23
|
const serializedFields = (0, cardintegration_1.serializeCardFieldArrayDefinition)(fields);
|
|
24
24
|
return serializedFields;
|
|
25
25
|
});
|
|
26
|
+
const getDefaultConfigActionName = TaskManagementCardIntegration.nextHookName();
|
|
27
|
+
this.client.registerAction(getDefaultConfigActionName, async (param) => {
|
|
28
|
+
const collection = new collectionproxy_1.CollectionProxy(param['c'], this.client);
|
|
29
|
+
return (0, cardintegration_1.serializeCardIntegrationConfig)(await card.getDefaultConfig(collection));
|
|
30
|
+
});
|
|
26
31
|
let showIntroActionName = undefined;
|
|
27
32
|
if (card.showIntro) {
|
|
28
33
|
showIntroActionName = TaskManagementCardIntegration.nextHookName();
|
|
@@ -30,8 +35,11 @@ class TaskManagementCardIntegration {
|
|
|
30
35
|
}
|
|
31
36
|
const serialized = {
|
|
32
37
|
'n': card.label,
|
|
38
|
+
'il': card.itemLabel,
|
|
39
|
+
'isl': card.itemsLabel,
|
|
33
40
|
'u': card.iconUrl,
|
|
34
41
|
'gf': getFieldsActionName,
|
|
42
|
+
'gdc': getDefaultConfigActionName,
|
|
35
43
|
'i': showIntroActionName,
|
|
36
44
|
};
|
|
37
45
|
if (card.importModal) {
|
|
@@ -52,12 +60,29 @@ class TaskManagementCardIntegration {
|
|
|
52
60
|
'f': (0, cardintegration_1.serializeCardFieldArrayDefinition)(result.fields),
|
|
53
61
|
};
|
|
54
62
|
});
|
|
55
|
-
this.client.registerAction(serialized['im']['i'], async ({ 'pks': primaryKeys }) => {
|
|
56
|
-
const result = await importModal.import(primaryKeys);
|
|
63
|
+
this.client.registerAction(serialized['im']['i'], async ({ 'pks': primaryKeys, 's': searchFields }) => {
|
|
64
|
+
const result = await importModal.import(primaryKeys, new Map(searchFields));
|
|
57
65
|
return {
|
|
58
66
|
'c': result.collection.id,
|
|
59
67
|
'pks': result.primaryKeys,
|
|
60
|
-
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (card.addCard) {
|
|
72
|
+
const addCard = card.addCard;
|
|
73
|
+
serialized['ac'] = {
|
|
74
|
+
'gif': TaskManagementCardIntegration.nextHookName(),
|
|
75
|
+
'cc': TaskManagementCardIntegration.nextHookName(),
|
|
76
|
+
};
|
|
77
|
+
this.client.registerAction(serialized['ac']['gif'], async ({ 'i': inputSoFar }) => {
|
|
78
|
+
const result = await addCard.getInputFields(new Map(inputSoFar));
|
|
79
|
+
return (0, cardintegration_1.serializeCardFieldArrayDefinition)(result);
|
|
80
|
+
});
|
|
81
|
+
this.client.registerAction(serialized['ac']['cc'], async ({ 'i': input }) => {
|
|
82
|
+
const result = await addCard.createCardData(new Map(input));
|
|
83
|
+
return {
|
|
84
|
+
'c': result.collection.id,
|
|
85
|
+
'pk': result.primaryKey,
|
|
61
86
|
};
|
|
62
87
|
});
|
|
63
88
|
}
|