lucid-extension-sdk 0.0.263 → 0.0.264
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 +17 -6
- package/core/cardintegration/lucidcardintegration.d.ts +6 -78
- package/core/cardintegration/lucidcardintegrationcustomimportmodal.d.ts +13 -0
- package/core/cardintegration/lucidcardintegrationcustomimportmodal.js +24 -0
- package/core/cardintegration/lucidcardintegrationregistry.js +39 -46
- package/core/cardintegration/lucidcardintegrationstandardimportmodal.d.ts +58 -0
- package/core/cardintegration/lucidcardintegrationstandardimportmodal.js +2 -0
- package/package.json +1 -1
package/commandtypes.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare const enum CommandName {
|
|
|
42
42
|
CanEditPackageSettings = "ceps",
|
|
43
43
|
Confirm = "c",
|
|
44
44
|
CreateBlock = "cb",
|
|
45
|
+
CreateCards = "ca",
|
|
45
46
|
CreateCollection = "cc",
|
|
46
47
|
CreateDataSource = "cds",
|
|
47
48
|
CreateDocumentElement = "cde",
|
|
@@ -232,6 +233,10 @@ export type CommandArgs = {
|
|
|
232
233
|
query: CreateBlockQuery;
|
|
233
234
|
result: CreateBlockResult;
|
|
234
235
|
};
|
|
236
|
+
[CommandName.CreateCards]: {
|
|
237
|
+
query: CreateCardsQuery;
|
|
238
|
+
result: CreateCardsResult;
|
|
239
|
+
};
|
|
235
240
|
[CommandName.CreateCollection]: {
|
|
236
241
|
query: CreateCollectionQuery;
|
|
237
242
|
result: CreateCollectionResult;
|
|
@@ -714,13 +719,10 @@ export type AddCardIntegrationQuery = {
|
|
|
714
719
|
/** OnSetup action */
|
|
715
720
|
'os'?: string | undefined;
|
|
716
721
|
} | undefined;
|
|
717
|
-
/** If specified, custom import modal
|
|
722
|
+
/** If specified, custom import modal*/
|
|
718
723
|
'cim'?: {
|
|
719
|
-
'
|
|
720
|
-
|
|
721
|
-
'h': number;
|
|
722
|
-
'i': string;
|
|
723
|
-
};
|
|
724
|
+
'sh': string;
|
|
725
|
+
} | undefined;
|
|
724
726
|
/** If specified, add-card settings */
|
|
725
727
|
'ac'?: {
|
|
726
728
|
/** Get input fields action */
|
|
@@ -901,6 +903,15 @@ export type CreateBlockQuery = {
|
|
|
901
903
|
's'?: JsonSerializable | undefined;
|
|
902
904
|
};
|
|
903
905
|
export type CreateBlockResult = string;
|
|
906
|
+
export type CreateCardsQuery = {
|
|
907
|
+
/** Identifier for the cards integration. */
|
|
908
|
+
'cid': string;
|
|
909
|
+
/** Identifier for the collection. */
|
|
910
|
+
'coid': string;
|
|
911
|
+
/** Primary keys of the items to import. */
|
|
912
|
+
'pks': string[];
|
|
913
|
+
};
|
|
914
|
+
export type CreateCardsResult = Promise<string[]>;
|
|
904
915
|
export type CreateGroupQuery = {
|
|
905
916
|
/**
|
|
906
917
|
* By default, we add the group to the current page & currently active group. If specified, the
|
|
@@ -1,30 +1,13 @@
|
|
|
1
|
-
import { CollectionDefinition } from '../../data/collectiondefinition';
|
|
2
1
|
import { CollectionProxy } from '../../data/collectionproxy';
|
|
3
2
|
import { DataSourceProxy } from '../../data/datasourceproxy';
|
|
4
3
|
import { TextStyle } from '../../document/text/textstyle';
|
|
5
4
|
import { EditorClient } from '../../editorclient';
|
|
6
5
|
import { SerializedFieldType } from '../data/serializedfield/serializedfields';
|
|
7
|
-
import { JsonSerializable } from '../jsonserializable';
|
|
8
6
|
import { CardIntegrationConfig } from './cardintegrationconfig';
|
|
9
7
|
import { ExtensionCardFieldDefinition } from './cardintegrationdefinitions';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export interface SearchResult {
|
|
14
|
-
partialImportMetadata?: {
|
|
15
|
-
collectionId: string;
|
|
16
|
-
syncDataSourceId?: string;
|
|
17
|
-
};
|
|
18
|
-
data: CollectionDefinition;
|
|
19
|
-
fields: ExtensionCardFieldDefinition[];
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Result of importing data from the import modal
|
|
23
|
-
*/
|
|
24
|
-
export interface ImportResult {
|
|
25
|
-
collection: CollectionProxy;
|
|
26
|
-
primaryKeys: string[];
|
|
27
|
-
}
|
|
8
|
+
import { LucidCardIntegrationCustomImportModal } from './lucidcardintegrationcustomimportmodal';
|
|
9
|
+
import { LucidCardIntegrationStandardImportModal } from './lucidcardintegrationstandardimportmodal';
|
|
10
|
+
export { ImportResult, SearchResult } from './lucidcardintegrationstandardimportmodal';
|
|
28
11
|
export declare abstract class LucidCardIntegration {
|
|
29
12
|
protected readonly client: EditorClient;
|
|
30
13
|
constructor(client: EditorClient);
|
|
@@ -89,65 +72,10 @@ export declare abstract class LucidCardIntegration {
|
|
|
89
72
|
*/
|
|
90
73
|
abstract getDefaultConfig: (dataSource: DataSourceProxy) => Promise<CardIntegrationConfig>;
|
|
91
74
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* getSearchFields:
|
|
95
|
-
* Given the values entered by the user so far into search fields, return the list of all search fields
|
|
96
|
-
* to display in the search form.
|
|
97
|
-
*
|
|
98
|
-
* search:
|
|
99
|
-
* Given values entered by the user into the search fields so far, return a collection of data to
|
|
100
|
-
* display in the results table. If partialImportMetadata is also returned, it will be used to create the tasks cards before
|
|
101
|
-
* the import is completed—which allows users to interact with the cards while the
|
|
102
|
-
* data is fetched asynchronously. The collectionId needs to match the id that will be
|
|
103
|
-
* returned from the completed import. The syncDataSourceId needs to match the
|
|
104
|
-
* syncDataSourceId that is passed into performDataAction.
|
|
105
|
-
* The last requirement for the partial import to work is that the primary keys in the data also
|
|
106
|
-
* returned in this search need to match the primary keys that will be returned
|
|
107
|
-
* on import.
|
|
108
|
-
*
|
|
109
|
-
* import:
|
|
110
|
-
* The user checked the boxes beside the given list of items in the collection returned from search().
|
|
111
|
-
* Import them, and return the collection and primary keys in that final collection that were imported.
|
|
112
|
-
*
|
|
113
|
-
* onSetup:
|
|
114
|
-
* If specified, it's going to be called everytime the modal is setting up, right after the modal is displayed
|
|
115
|
-
* and before the initial form fields are shown to the user.
|
|
116
|
-
*
|
|
117
|
-
* The config provided here is only used on the first import from a given source; on subsequent imports,
|
|
118
|
-
* the existing config will remain unchanged to preserve any customizations by the user.
|
|
75
|
+
* This allows the user to import cards by selecting items from within a modal. You can either create a custom
|
|
76
|
+
* import modal or the standard import modal can be used.
|
|
119
77
|
*/
|
|
120
|
-
importModal?:
|
|
121
|
-
getSearchFields: (searchSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldDefinition[]>;
|
|
122
|
-
search: (fields: Map<string, SerializedFieldType>) => Promise<SearchResult>;
|
|
123
|
-
import: (primaryKeys: string[], searchFields: Map<string, SerializedFieldType>) => Promise<ImportResult>;
|
|
124
|
-
onSetup?: () => Promise<void>;
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* If specified, allow the user to import cards using a custom card-import modal.
|
|
128
|
-
*
|
|
129
|
-
* srcUrl:
|
|
130
|
-
* The url to be displayed in an iframe. This can either be a public url, or a local
|
|
131
|
-
* file located in the public folder of your packages root directory.
|
|
132
|
-
*
|
|
133
|
-
* width:
|
|
134
|
-
* The width of the iframe. The maximum width is 1344px.
|
|
135
|
-
*
|
|
136
|
-
* height:
|
|
137
|
-
* The height of the iframe. The maximum height is 1000px.
|
|
138
|
-
*
|
|
139
|
-
* import:
|
|
140
|
-
* Imports the items selected from you custom iframe. You can pass in whatever data is needed to import the items
|
|
141
|
-
* through you data-connector. The data must be of type JsonSerializable. Return the collection created and the
|
|
142
|
-
* primary keys of the items that were imported.
|
|
143
|
-
*
|
|
144
|
-
*/
|
|
145
|
-
customImportModal?: {
|
|
146
|
-
srcUrl: string;
|
|
147
|
-
width: number;
|
|
148
|
-
height: number;
|
|
149
|
-
import: (data: JsonSerializable) => Promise<ImportResult>;
|
|
150
|
-
};
|
|
78
|
+
importModal?: LucidCardIntegrationStandardImportModal | LucidCardIntegrationCustomImportModal;
|
|
151
79
|
/**
|
|
152
80
|
* If specified, allow the user to create new cards and convert other shapes to cards
|
|
153
81
|
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EditorClient } from '../../editorclient';
|
|
2
|
+
import { Modal, ModalConfig } from '../../ui/modal';
|
|
3
|
+
/**
|
|
4
|
+
* Extending this class lets you create a custom import modal for a Lucid card integration.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class LucidCardIntegrationCustomImportModal extends Modal {
|
|
7
|
+
private readonly cardIntegrationLabel;
|
|
8
|
+
constructor(client: EditorClient, config: ModalConfig, cardIntegrationLabel: string);
|
|
9
|
+
/**
|
|
10
|
+
* Once the data has been imported, call this function to create Lucid cards on the canvas.
|
|
11
|
+
*/
|
|
12
|
+
protected createCards(collectionId: string, primaryKeys: string[]): import("../../commandtypes").CreateCardsResult;
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LucidCardIntegrationCustomImportModal = void 0;
|
|
4
|
+
const modal_1 = require("../../ui/modal");
|
|
5
|
+
/**
|
|
6
|
+
* Extending this class lets you create a custom import modal for a Lucid card integration.
|
|
7
|
+
*/
|
|
8
|
+
class LucidCardIntegrationCustomImportModal extends modal_1.Modal {
|
|
9
|
+
constructor(client, config, cardIntegrationLabel) {
|
|
10
|
+
super(client, config);
|
|
11
|
+
this.cardIntegrationLabel = cardIntegrationLabel;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Once the data has been imported, call this function to create Lucid cards on the canvas.
|
|
15
|
+
*/
|
|
16
|
+
createCards(collectionId, primaryKeys) {
|
|
17
|
+
return this.client.sendCommand("ca" /* CommandName.CreateCards */, {
|
|
18
|
+
'cid': this.cardIntegrationLabel,
|
|
19
|
+
'coid': collectionId,
|
|
20
|
+
'pks': primaryKeys,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.LucidCardIntegrationCustomImportModal = LucidCardIntegrationCustomImportModal;
|
|
@@ -5,6 +5,7 @@ const collectiondefinition_1 = require("../../data/collectiondefinition");
|
|
|
5
5
|
const datasourceproxy_1 = require("../../data/datasourceproxy");
|
|
6
6
|
const cardintegrationconfig_1 = require("./cardintegrationconfig");
|
|
7
7
|
const cardintegrationdefinitions_1 = require("./cardintegrationdefinitions");
|
|
8
|
+
const lucidcardintegrationcustomimportmodal_1 = require("./lucidcardintegrationcustomimportmodal");
|
|
8
9
|
class LucidCardIntegrationRegistry {
|
|
9
10
|
static nextHookName() {
|
|
10
11
|
return '__lucidcard__hook' + LucidCardIntegrationRegistry.nextHookId++;
|
|
@@ -73,57 +74,49 @@ class LucidCardIntegrationRegistry {
|
|
|
73
74
|
};
|
|
74
75
|
if (cardIntegration.importModal) {
|
|
75
76
|
const importModal = cardIntegration.importModal;
|
|
76
|
-
|
|
77
|
-
'
|
|
78
|
-
|
|
79
|
-
'i': LucidCardIntegrationRegistry.nextHookName(),
|
|
80
|
-
'os': importModal.onSetup ? LucidCardIntegrationRegistry.nextHookName() : undefined,
|
|
81
|
-
};
|
|
82
|
-
client.registerAction(serialized['im']['gsf'], async ({ 's': searchSoFar }) => {
|
|
83
|
-
const result = await importModal.getSearchFields(new Map(searchSoFar));
|
|
84
|
-
return (0, cardintegrationdefinitions_1.serializeCardFieldArrayDefinition)(result);
|
|
85
|
-
});
|
|
86
|
-
client.registerAction(serialized['im']['s'], async ({ 's': param }) => {
|
|
87
|
-
const result = await importModal.search(new Map(param));
|
|
88
|
-
return {
|
|
89
|
-
'd': (0, collectiondefinition_1.serializeCollectionDefinition)(result.data),
|
|
90
|
-
'f': (0, cardintegrationdefinitions_1.serializeCardFieldArrayDefinition)(result.fields),
|
|
91
|
-
'm': result.partialImportMetadata && {
|
|
92
|
-
'cid': result.partialImportMetadata.collectionId,
|
|
93
|
-
'sid': result.partialImportMetadata.syncDataSourceId,
|
|
94
|
-
},
|
|
77
|
+
if (importModal instanceof lucidcardintegrationcustomimportmodal_1.LucidCardIntegrationCustomImportModal) {
|
|
78
|
+
serialized['cim'] = {
|
|
79
|
+
'sh': LucidCardIntegrationRegistry.nextHookName(),
|
|
95
80
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
'
|
|
101
|
-
'
|
|
81
|
+
client.registerAction(serialized['cim']['sh'], () => importModal.show());
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
serialized['im'] = {
|
|
85
|
+
'gsf': LucidCardIntegrationRegistry.nextHookName(),
|
|
86
|
+
's': LucidCardIntegrationRegistry.nextHookName(),
|
|
87
|
+
'i': LucidCardIntegrationRegistry.nextHookName(),
|
|
88
|
+
'os': importModal.onSetup ? LucidCardIntegrationRegistry.nextHookName() : undefined,
|
|
102
89
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var _a;
|
|
107
|
-
await ((_a = importModal.onSetup) === null || _a === void 0 ? void 0 : _a.call(importModal));
|
|
90
|
+
client.registerAction(serialized['im']['gsf'], async ({ 's': searchSoFar }) => {
|
|
91
|
+
const result = await importModal.getSearchFields(new Map(searchSoFar));
|
|
92
|
+
return (0, cardintegrationdefinitions_1.serializeCardFieldArrayDefinition)(result);
|
|
108
93
|
});
|
|
94
|
+
client.registerAction(serialized['im']['s'], async ({ 's': param }) => {
|
|
95
|
+
const result = await importModal.search(new Map(param));
|
|
96
|
+
return {
|
|
97
|
+
'd': (0, collectiondefinition_1.serializeCollectionDefinition)(result.data),
|
|
98
|
+
'f': (0, cardintegrationdefinitions_1.serializeCardFieldArrayDefinition)(result.fields),
|
|
99
|
+
'm': result.partialImportMetadata && {
|
|
100
|
+
'cid': result.partialImportMetadata.collectionId,
|
|
101
|
+
'sid': result.partialImportMetadata.syncDataSourceId,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
client.registerAction(serialized['im']['i'], async ({ 'pks': primaryKeys, 's': searchFields }) => {
|
|
106
|
+
const result = await importModal.import(primaryKeys, new Map(searchFields));
|
|
107
|
+
return {
|
|
108
|
+
'c': result.collection.id,
|
|
109
|
+
'pks': result.primaryKeys,
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
if (serialized['im']['os']) {
|
|
113
|
+
client.registerAction(serialized['im']['os'], async () => {
|
|
114
|
+
var _a;
|
|
115
|
+
await ((_a = importModal.onSetup) === null || _a === void 0 ? void 0 : _a.call(importModal));
|
|
116
|
+
});
|
|
117
|
+
}
|
|
109
118
|
}
|
|
110
119
|
}
|
|
111
|
-
if (cardIntegration.customImportModal) {
|
|
112
|
-
const customImportModal = cardIntegration.customImportModal;
|
|
113
|
-
serialized['cim'] = {
|
|
114
|
-
'su': customImportModal.srcUrl,
|
|
115
|
-
'w': customImportModal.width,
|
|
116
|
-
'h': customImportModal.height,
|
|
117
|
-
'i': LucidCardIntegrationRegistry.nextHookName(),
|
|
118
|
-
};
|
|
119
|
-
client.registerAction(serialized['cim']['i'], async ({ 'd': data }) => {
|
|
120
|
-
const result = await customImportModal.import(data);
|
|
121
|
-
return {
|
|
122
|
-
'c': result.collection.id,
|
|
123
|
-
'pks': result.primaryKeys,
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
120
|
if (cardIntegration.addCard) {
|
|
128
121
|
const addCard = cardIntegration.addCard;
|
|
129
122
|
serialized['ac'] = {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CollectionDefinition } from '../../data/collectiondefinition';
|
|
2
|
+
import { CollectionProxy } from '../../data/collectionproxy';
|
|
3
|
+
import { SerializedFieldType } from '../data/serializedfield/serializedfields';
|
|
4
|
+
import { ExtensionCardFieldDefinition } from './cardintegrationdefinitions';
|
|
5
|
+
/**
|
|
6
|
+
* You can use the standard import modal can be used by providing the following data:
|
|
7
|
+
*
|
|
8
|
+
* getSearchFields:
|
|
9
|
+
* Given the values entered by the user so far into search fields, return the list of all search fields
|
|
10
|
+
* to display in the search form.
|
|
11
|
+
*
|
|
12
|
+
* search:
|
|
13
|
+
* Given values entered by the user into the search fields so far, return a collection of data to
|
|
14
|
+
* display in the results table. If partialImportMetadata is also returned, it will be used to create the tasks cards before
|
|
15
|
+
* the import is completed—which allows users to interact with the cards while the
|
|
16
|
+
* data is fetched asynchronously. The collectionId needs to match the id that will be
|
|
17
|
+
* returned from the completed import. The syncDataSourceId needs to match the
|
|
18
|
+
* syncDataSourceId that is passed into performDataAction.
|
|
19
|
+
* The last requirement for the partial import to work is that the primary keys in the data also
|
|
20
|
+
* returned in this search need to match the primary keys that will be returned
|
|
21
|
+
* on import.
|
|
22
|
+
*
|
|
23
|
+
* import:
|
|
24
|
+
* The user checked the boxes beside the given list of items in the collection returned from search().
|
|
25
|
+
* Import them, and return the collection and primary keys in that final collection that were imported.
|
|
26
|
+
*
|
|
27
|
+
* onSetup:
|
|
28
|
+
* If specified, it's going to be called everytime the modal is setting up, right after the modal is displayed
|
|
29
|
+
* and before the initial form fields are shown to the user.
|
|
30
|
+
*
|
|
31
|
+
* The config provided here is only used on the first import from a given source; on subsequent imports,
|
|
32
|
+
* the existing config will remain unchanged to preserve any customizations by the user.
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
export interface LucidCardIntegrationStandardImportModal {
|
|
36
|
+
getSearchFields: (searchSoFar: Map<string, SerializedFieldType>) => Promise<ExtensionCardFieldDefinition[]>;
|
|
37
|
+
search: (fields: Map<string, SerializedFieldType>) => Promise<SearchResult>;
|
|
38
|
+
import: (primaryKeys: string[], searchFields: Map<string, SerializedFieldType>) => Promise<ImportResult>;
|
|
39
|
+
onSetup?: () => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Result of searching for data in the import modal
|
|
43
|
+
*/
|
|
44
|
+
export interface SearchResult {
|
|
45
|
+
partialImportMetadata?: {
|
|
46
|
+
collectionId: string;
|
|
47
|
+
syncDataSourceId?: string;
|
|
48
|
+
};
|
|
49
|
+
data: CollectionDefinition;
|
|
50
|
+
fields: ExtensionCardFieldDefinition[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Result of importing data from the import modal
|
|
54
|
+
*/
|
|
55
|
+
export interface ImportResult {
|
|
56
|
+
collection: CollectionProxy;
|
|
57
|
+
primaryKeys: string[];
|
|
58
|
+
}
|