lucid-extension-sdk 0.0.100 → 0.0.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/package.json +1 -1
  2. package/sdk/commandtypes.d.ts +20 -0
  3. package/sdk/commandtypes.js +2 -0
  4. package/sdk/core/data/fieldspecification.d.ts +104 -0
  5. package/sdk/core/data/fieldspecification.js +77 -0
  6. package/sdk/core/object.d.ts +4 -0
  7. package/sdk/core/object.js +18 -1
  8. package/sdk/data/dataupdatefiltertype.d.ts +9 -0
  9. package/sdk/data/dataupdatefiltertype.js +13 -0
  10. package/sdk/dataconnector/actions/action.d.ts +153 -0
  11. package/sdk/dataconnector/actions/action.js +137 -0
  12. package/sdk/dataconnector/actions/managewebhookresponsebody.d.ts +8 -0
  13. package/sdk/dataconnector/actions/managewebhookresponsebody.js +11 -0
  14. package/sdk/dataconnector/actions/patchresponsebody.d.ts +41 -0
  15. package/sdk/dataconnector/actions/patchresponsebody.js +71 -0
  16. package/sdk/dataconnector/actions/serializedactions.d.ts +9 -0
  17. package/sdk/dataconnector/actions/serializedactions.js +82 -0
  18. package/sdk/dataconnector/dataconnector.d.ts +62 -0
  19. package/sdk/dataconnector/dataconnector.js +115 -0
  20. package/sdk/dataconnector/dataconnectorclient.d.ts +38 -0
  21. package/sdk/dataconnector/dataconnectorclient.js +68 -0
  22. package/sdk/dataconnector/datasourceclient.d.ts +89 -0
  23. package/sdk/dataconnector/datasourceclient.js +106 -0
  24. package/sdk/dataconnector/debugserver.d.ts +42 -0
  25. package/sdk/dataconnector/debugserver.js +66 -0
  26. package/sdk/dataconnector/defaultfetchfunction.d.ts +13 -0
  27. package/sdk/dataconnector/defaultfetchfunction.js +6 -0
  28. package/sdk/dataconnector/signaturevalidator.d.ts +33 -0
  29. package/sdk/dataconnector/signaturevalidator.js +64 -0
  30. package/sdk/document/documentproxy.d.ts +16 -1
  31. package/sdk/document/documentproxy.js +26 -1
  32. package/sdk/index.d.ts +10 -0
  33. package/sdk/index.js +10 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.100",
3
+ "version": "0.0.102",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -62,6 +62,7 @@ export declare const enum CommandName {
62
62
  HideModal = "hm",
63
63
  HidePanel = "hp",
64
64
  HookCreateItems = "hci",
65
+ HookDeleteItems = "hdi",
65
66
  HookSelection = "hs",
66
67
  HookTextEdit = "hte",
67
68
  ImportCards = "ic",
@@ -103,6 +104,7 @@ export declare const enum CommandName {
103
104
  StartPDFUploadRequest = "pdf",
104
105
  ThrowForTestCase = "throw",
105
106
  UnhookCreateItems = "uci",
107
+ UnhookDeleteItems = "udi",
106
108
  UnhookSelection = "us",
107
109
  UnhookTextEdit = "ute"
108
110
  }
@@ -286,6 +288,10 @@ export declare type CommandArgs = {
286
288
  query: HookCreateItemsQuery;
287
289
  result: HookCreateItemsResult;
288
290
  };
291
+ [CommandName.HookDeleteItems]: {
292
+ query: HookDeleteItemsQuery;
293
+ result: HookDeleteItemsResult;
294
+ };
289
295
  [CommandName.HookSelection]: {
290
296
  query: HookSelectionQuery;
291
297
  result: HookSelectionResult;
@@ -450,6 +456,10 @@ export declare type CommandArgs = {
450
456
  query: UnhookCreateItemsQuery;
451
457
  result: UnhookCreateItemsResult;
452
458
  };
459
+ [CommandName.UnhookDeleteItems]: {
460
+ query: UnhookDeleteItemsQuery;
461
+ result: UnhookDeleteItemsResult;
462
+ };
453
463
  [CommandName.UnhookSelection]: {
454
464
  query: UnhookSelectionQuery;
455
465
  result: UnhookSelectionResult;
@@ -824,6 +834,11 @@ export declare type HookCreateItemsQuery = {
824
834
  'n': string;
825
835
  };
826
836
  export declare type HookCreateItemsResult = undefined;
837
+ export declare type HookDeleteItemsQuery = {
838
+ /** Name of the action for receiving events. Will be called with an array of strings of all recently deleted item IDs. */
839
+ 'n': string;
840
+ };
841
+ export declare type HookDeleteItemsResult = undefined;
827
842
  export declare type HookSelectionQuery = {
828
843
  /** Name of the action for receiving events. Will be called with an array of strings of all selected item IDs. */
829
844
  'n': string;
@@ -1092,6 +1107,11 @@ export declare type UnhookCreateItemsQuery = {
1092
1107
  'n': string;
1093
1108
  };
1094
1109
  export declare type UnhookCreateItemsResult = undefined;
1110
+ export declare type UnhookDeleteItemsQuery = {
1111
+ /** Name of the action passed to HookDeleteItems */
1112
+ 'n': string;
1113
+ };
1114
+ export declare type UnhookDeleteItemsResult = undefined;
1095
1115
  export declare type UnhookSelectionQuery = {
1096
1116
  /** Name of the action for receiving these events */
1097
1117
  'n': string;
@@ -45,6 +45,7 @@ exports.commandTitles = new Map([
45
45
  ["hm" /* CommandName.HideModal */, 'HideModal'],
46
46
  ["hp" /* CommandName.HidePanel */, 'HidePanel'],
47
47
  ["hci" /* CommandName.HookCreateItems */, 'HookCreateItems'],
48
+ ["hdi" /* CommandName.HookDeleteItems */, 'HookDeleteItems'],
48
49
  ["hs" /* CommandName.HookSelection */, 'HookSelection'],
49
50
  ["hte" /* CommandName.HookTextEdit */, 'HookTextEdit'],
50
51
  ["ic" /* CommandName.ImportCards */, 'ImportCards'],
@@ -84,6 +85,7 @@ exports.commandTitles = new Map([
84
85
  ["pdf" /* CommandName.StartPDFUploadRequest */, 'StartPDFUploadRequest'],
85
86
  ["throw" /* CommandName.ThrowForTestCase */, 'ThrowForTestCase'],
86
87
  ["uci" /* CommandName.UnhookCreateItems */, 'UnhookCreateItems'],
88
+ ["udi" /* CommandName.UnhookDeleteItems */, 'UnhookDeleteItems'],
87
89
  ["us" /* CommandName.UnhookSelection */, 'UnhookSelection'],
88
90
  ["ute" /* CommandName.UnhookTextEdit */, 'UnhookTextEdit'],
89
91
  ]);
@@ -0,0 +1,104 @@
1
+ import { FieldConstraintDefinition } from '../../data/schemadefinition';
2
+ import { CollectionEnumFieldType } from './fieldtypedefinition/collectionenumfieldtype';
3
+ import { FieldTypeArray } from './fieldtypedefinition/fieldtypearray';
4
+ import { FieldTypeDefinition } from './fieldtypedefinition/fieldtypedefinition';
5
+ import { ScalarFieldTypeEnum } from './fieldtypedefinition/scalarfieldtype';
6
+ import { SemanticKind } from './fieldtypedefinition/semantickind';
7
+ import { SerializedColorObject, SerializedLucidCurrency, SerializedLucidDateObject, SerializedLucidDictionary } from './serializedfield/serializedfields';
8
+ declare type TsTypeOf<X> = X extends ScalarFieldTypeEnum.ANY ? unknown : X extends ScalarFieldTypeEnum.NUMBER ? number : X extends ScalarFieldTypeEnum.BOOLEAN ? boolean : X extends ScalarFieldTypeEnum.STRING ? string : X extends ScalarFieldTypeEnum.COLOR ? SerializedColorObject : X extends ScalarFieldTypeEnum.DATE ? SerializedLucidDateObject : X extends ScalarFieldTypeEnum.NULL ? null : X extends ScalarFieldTypeEnum.DICTIONARY ? SerializedLucidDictionary : X extends FieldTypeArray<infer Inner> ? TsTypeOf<Inner>[] : X extends ScalarFieldTypeEnum.CURRENCY ? SerializedLucidCurrency : X extends ScalarFieldTypeEnum.DATEONLY ? SerializedLucidDateObject & {
9
+ isDateOnly: true;
10
+ } : X extends CollectionEnumFieldType ? string : X extends readonly [infer Inner, ...infer Others] ? TsTypeOf<Inner> | TsTypeOf<Others> : never;
11
+ /**
12
+ * Specifies all the fields that this itegration will be sending to the data-sync service.
13
+ * Give you well typed methods to convert from `YourType[]` to `{[PrimaryKey:string]: YourType}`
14
+ * which is what most of the data sync service calls expect.
15
+ *
16
+ * There is fromItems which does the above will full type information, and fromItems sparse
17
+ * which allows all the fields not part of the primaryKey to be undefined. The former should
18
+ * be used with initial imports, and the latter can be used for updates.
19
+ */
20
+ export declare function declareSchema<Names extends string, Types extends Readonly<FieldTypeDefinition>, Constraint extends FieldConstraintDefinition, SemanticFieldTypes extends SemanticKind, Fields extends {
21
+ [Name in Names]: {
22
+ type: Types;
23
+ constraints?: readonly Constraint[];
24
+ mapping?: readonly SemanticFieldTypes[] | undefined;
25
+ };
26
+ }, PrimaryKey extends keyof Fields>({ primaryKey, fields }: {
27
+ primaryKey: PrimaryKey[];
28
+ fields: Fields;
29
+ }): {
30
+ example: Fields;
31
+ array: {
32
+ name: Exclude<keyof typeof fields, number>;
33
+ type: FieldTypeDefinition;
34
+ constraints: FieldConstraintDefinition[];
35
+ mapping: SemanticFieldTypes[];
36
+ }[];
37
+ primaryKey: FormattedPrimaryKey<Fields, PrimaryKey>;
38
+ fromItemsSparse: (items: PartialItemType<typeof fields, PrimaryKey>[]) => Map<string, PartialItemType<Fields, PrimaryKey>>;
39
+ fromItems: (items: ItemType<typeof fields>[]) => Map<string, ItemType<Fields>>;
40
+ };
41
+ /**
42
+ * Generates a mapper that, given a primary key definition is able to produce the primary key for that item.
43
+ **/
44
+ export declare class FormattedPrimaryKey<Fields extends FieldsStructure, PrimaryKey extends keyof Fields> {
45
+ readonly elements: PrimaryKey[];
46
+ constructor(...elements: PrimaryKey[]);
47
+ /**
48
+ * Generate the serialized form of the item's primary key.
49
+ *
50
+ * For single value primary keys, the encoded values are just the json representation of the primary
51
+ * key. For example, if the primary key is ['id'] the following table shows encodings:
52
+ *
53
+ * | type | value | encoded |
54
+ * |---------|-----------|------------------------------------|
55
+ * | number | `15` | `new Map([["15", ...], ...])` |
56
+ * | boolean | `false` | `new Map([["false", ...], ...])` |
57
+ * | string | `"hello"` | `new Map([['"hello"', ...], ...])` |
58
+ *
59
+ * Take note of the extra quotes in the string case.
60
+ *
61
+ * For primary keys with multiple values, first sort the array of primary keys then join the json encoded values
62
+ * from of the keys with commas. For example:
63
+ *
64
+ * ```
65
+ * primary key = ["lastName", "firstName"]
66
+ * sorted key = ["firstName", "lastName"]
67
+ * row = {"lastName": "Smith", "firstName": "John", "age": 42}
68
+ * row key = '"John","Smith"'
69
+ * items = new Map([['"John","Smith"', {"lastName": "Smith", "firstName": "John", "age": 42}]])
70
+ * ```
71
+ */
72
+ forItem(item: PartialItemType<Fields, PrimaryKey>): string;
73
+ }
74
+ /**
75
+ * Root type for something that looks like the field list we use to sync with the data-sync service.
76
+ * Used just to make writing other internal types easier.
77
+ */
78
+ declare type FieldsStructure = {
79
+ [Name in string]: {
80
+ type: Readonly<FieldTypeDefinition>;
81
+ mapping?: undefined | readonly SemanticKind[];
82
+ };
83
+ };
84
+ /**
85
+ * The type of a item in the FieldsStructure, that is if the FieldsStructure represents
86
+ *
87
+ * ```
88
+ * [{Name: "id", Type: ScalarFieldTypeEnum.STRING}]
89
+ * ```
90
+ *
91
+ * then ItemType for that would be:
92
+ *
93
+ * ```
94
+ * {'id': string}
95
+ * ```
96
+ */
97
+ export declare type ItemType<Fields extends FieldsStructure> = {
98
+ [Field in keyof Fields]: TsTypeOf<Fields[Field]['type']>;
99
+ };
100
+ /**
101
+ * Just like ItemType<Foo>, but the fields not part of the primary key can be undefined.
102
+ */
103
+ export declare type PartialItemType<Fields extends FieldsStructure, PrimaryKey extends keyof Fields> = Pick<ItemType<Fields>, PrimaryKey> & Partial<Omit<ItemType<Fields>, PrimaryKey>>;
104
+ export {};
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormattedPrimaryKey = exports.declareSchema = void 0;
4
+ const object_1 = require("../object");
5
+ function isArrayAndAssertReadonly(val) {
6
+ return Array.isArray(val);
7
+ }
8
+ /**
9
+ * Specifies all the fields that this itegration will be sending to the data-sync service.
10
+ * Give you well typed methods to convert from `YourType[]` to `{[PrimaryKey:string]: YourType}`
11
+ * which is what most of the data sync service calls expect.
12
+ *
13
+ * There is fromItems which does the above will full type information, and fromItems sparse
14
+ * which allows all the fields not part of the primaryKey to be undefined. The former should
15
+ * be used with initial imports, and the latter can be used for updates.
16
+ */
17
+ function declareSchema({ primaryKey, fields }) {
18
+ const primaryKeyObj = new FormattedPrimaryKey(...primaryKey);
19
+ return {
20
+ example: fields,
21
+ array: (0, object_1.entries)(fields).map(([name, { type, constraints, mapping }]) => {
22
+ return {
23
+ 'name': name,
24
+ 'type': isArrayAndAssertReadonly(type) ? type.slice() : type,
25
+ 'constraints': constraints,
26
+ 'mapping': mapping,
27
+ };
28
+ }),
29
+ primaryKey: primaryKeyObj,
30
+ fromItemsSparse: (items) => {
31
+ return new Map(items.map((item) => [primaryKeyObj.forItem(item), item]));
32
+ },
33
+ fromItems: (items) => {
34
+ return new Map(items.map((item) => [primaryKeyObj.forItem(item), item]));
35
+ },
36
+ };
37
+ }
38
+ exports.declareSchema = declareSchema;
39
+ /**
40
+ * Generates a mapper that, given a primary key definition is able to produce the primary key for that item.
41
+ **/
42
+ class FormattedPrimaryKey {
43
+ constructor(...elements) {
44
+ this.elements = [...elements].sort();
45
+ }
46
+ /**
47
+ * Generate the serialized form of the item's primary key.
48
+ *
49
+ * For single value primary keys, the encoded values are just the json representation of the primary
50
+ * key. For example, if the primary key is ['id'] the following table shows encodings:
51
+ *
52
+ * | type | value | encoded |
53
+ * |---------|-----------|------------------------------------|
54
+ * | number | `15` | `new Map([["15", ...], ...])` |
55
+ * | boolean | `false` | `new Map([["false", ...], ...])` |
56
+ * | string | `"hello"` | `new Map([['"hello"', ...], ...])` |
57
+ *
58
+ * Take note of the extra quotes in the string case.
59
+ *
60
+ * For primary keys with multiple values, first sort the array of primary keys then join the json encoded values
61
+ * from of the keys with commas. For example:
62
+ *
63
+ * ```
64
+ * primary key = ["lastName", "firstName"]
65
+ * sorted key = ["firstName", "lastName"]
66
+ * row = {"lastName": "Smith", "firstName": "John", "age": 42}
67
+ * row key = '"John","Smith"'
68
+ * items = new Map([['"John","Smith"', {"lastName": "Smith", "firstName": "John", "age": 42}]])
69
+ * ```
70
+ */
71
+ forItem(item) {
72
+ let pk = JSON.stringify(this.elements.map((field) => item[field]));
73
+ pk = pk.substring(1, pk.length - 1);
74
+ return pk;
75
+ }
76
+ }
77
+ exports.FormattedPrimaryKey = FormattedPrimaryKey;
@@ -1,6 +1,10 @@
1
1
  export declare function objectEvery<T, O extends {
2
2
  [key: string]: any;
3
3
  }>(obj: O, f: (this: T | undefined, _0: O[typeof _1], _1: string & keyof O, _2: O) => any, opt_this?: T): boolean;
4
+ export declare function flatten<T>(a: T[][]): T[];
4
5
  export declare function entries<T>(obj: {
5
6
  [key: string]: T;
6
7
  }): [string, T][];
8
+ export declare function fromEntries<K extends PropertyKey, T>(entries: Iterable<readonly [K, T]>): {
9
+ [key in K]: T;
10
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.entries = exports.objectEvery = void 0;
3
+ exports.fromEntries = exports.entries = exports.flatten = exports.objectEvery = void 0;
4
4
  function objectEvery(obj, f, opt_this) {
5
5
  for (const key in obj) {
6
6
  if (!f.call(opt_this, obj[key], key, obj)) {
@@ -10,8 +10,25 @@ function objectEvery(obj, f, opt_this) {
10
10
  return true;
11
11
  }
12
12
  exports.objectEvery = objectEvery;
13
+ function flatten(a) {
14
+ const result = [];
15
+ for (const item of a) {
16
+ result.push(...item);
17
+ }
18
+ return result;
19
+ }
20
+ exports.flatten = flatten;
13
21
  // TODO: Placeholder until we adopt ES8 and can use Object.entries(obj)
14
22
  function entries(obj) {
15
23
  return Object.keys(obj).map((key) => [key, obj[key]]);
16
24
  }
17
25
  exports.entries = entries;
26
+ // TODO: Placeholder until we adopt ES8 and can use Object.fromEntries(obj)
27
+ function fromEntries(entries) {
28
+ const result = {};
29
+ for (const [key, value] of entries) {
30
+ result[key] = value;
31
+ }
32
+ return result;
33
+ }
34
+ exports.fromEntries = fromEntries;
@@ -0,0 +1,9 @@
1
+ /** Allows Lucid documents to determine what updates they will receive when changes happen in the data source */
2
+ export declare enum DataUpdateFilterType {
3
+ /** All updates relevant to the data source will be sent to the document, new items created in the data source will be added to the document */
4
+ 'AllUpdates' = "AllUpdates",
5
+ /** All updates relevant to collections already present on the document will be sent to that document, new items added to those collections in the data source will be added to the document */
6
+ 'CurrentCollectionUpdates' = "CurrentCollectionUpdates",
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
+ 'CurrentItemUpdates' = "CurrentItemUpdates"
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataUpdateFilterType = void 0;
4
+ /** Allows Lucid documents to determine what updates they will receive when changes happen in the data source */
5
+ var DataUpdateFilterType;
6
+ (function (DataUpdateFilterType) {
7
+ /** All updates relevant to the data source will be sent to the document, new items created in the data source will be added to the document */
8
+ DataUpdateFilterType["AllUpdates"] = "AllUpdates";
9
+ /** All updates relevant to collections already present on the document will be sent to that document, new items added to those collections in the data source will be added to the document */
10
+ DataUpdateFilterType["CurrentCollectionUpdates"] = "CurrentCollectionUpdates";
11
+ /** 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. */
12
+ DataUpdateFilterType["CurrentItemUpdates"] = "CurrentItemUpdates";
13
+ })(DataUpdateFilterType = exports.DataUpdateFilterType || (exports.DataUpdateFilterType = {}));
@@ -0,0 +1,153 @@
1
+ import { DataUpdateFilterType } from '../../data/dataupdatefiltertype';
2
+ import { DataSourceClient } from '../datasourceclient';
3
+ import { PatchChange, PatchChangeCollection } from './patchresponsebody';
4
+ export declare type CollectionId = string;
5
+ export declare type ItemPrimaryKey = string;
6
+ /**
7
+ * This holds all the contextual information about a give data action.
8
+ */
9
+ export declare class DataConnectorActionContext {
10
+ /** The package ID of the extension that triggered this action */
11
+ readonly packageId: string;
12
+ /** The version of the extension that triggered this action */
13
+ packageVersion: string;
14
+ /** The authorized OAuth2 credential that Lucid has for the 3rd party this extension works with */
15
+ userCredential: string;
16
+ /** The data connector name from manifest.json that triggered this action */
17
+ dataConnectorName: string;
18
+ /** The installation id of the extension/user that triggered this action */
19
+ installationId: string | undefined;
20
+ /** Set of items this document is tracking as a `Record<CollectionId, ItemPrimaryKey[]>` */
21
+ documentCollections: {
22
+ [collectionId: CollectionId]: ItemPrimaryKey[];
23
+ };
24
+ /** Update filter type for this document */
25
+ updateFilterType: DataUpdateFilterType;
26
+ constructor(
27
+ /** The package ID of the extension that triggered this action */
28
+ packageId: string,
29
+ /** The version of the extension that triggered this action */
30
+ packageVersion: string,
31
+ /** The authorized OAuth2 credential that Lucid has for the 3rd party this extension works with */
32
+ userCredential: string,
33
+ /** The data connector name from manifest.json that triggered this action */
34
+ dataConnectorName: string,
35
+ /** The installation id of the extension/user that triggered this action */
36
+ installationId: string | undefined,
37
+ /** Set of items this document is tracking as a `Record<CollectionId, ItemPrimaryKey[]>` */
38
+ documentCollections: {
39
+ [collectionId: CollectionId]: ItemPrimaryKey[];
40
+ },
41
+ /** Update filter type for this document */
42
+ updateFilterType: DataUpdateFilterType);
43
+ }
44
+ /** Base class for actions to be performed by data connectors */
45
+ export declare class DataConnectorAction {
46
+ name: string;
47
+ context: DataConnectorActionContext;
48
+ constructor(name: string, context: DataConnectorActionContext);
49
+ }
50
+ /**
51
+ * A generic "asynchronous" action to be performed by the data connector. This is an action that reports back to Lucid
52
+ * by calling back in the DataSourceClient rather than returning a meaningful value.
53
+ **/
54
+ export declare class DataConnectorAsynchronousAction extends DataConnectorAction {
55
+ client: DataSourceClient;
56
+ data: unknown;
57
+ constructor(name: string, context: DataConnectorActionContext, client: DataSourceClient, data: unknown);
58
+ }
59
+ /**
60
+ * A generic "synchronous" action to be performed by the data connector.
61
+ **/
62
+ export declare class DataConnectorSynchronousAction extends DataConnectorAction {
63
+ data: unknown;
64
+ constructor(name: string, context: DataConnectorActionContext, data: unknown);
65
+ }
66
+ export declare type PatchItems = {
67
+ [primaryKey: ItemPrimaryKey]: {
68
+ [fieldName: string]: unknown;
69
+ };
70
+ };
71
+ /** A patch to be applied against the 3rd party datasource with changes coming from Lucid */
72
+ export declare class Patch {
73
+ /** The id of the patch */
74
+ id: string;
75
+ /** Mapping of item primary keys to new items introduced by Lucid */
76
+ itemsAdded: PatchItems;
77
+ /** Mapping of item primary keys to sparse changesets of pre-existing items changed by Lucid */
78
+ itemsChanged: PatchItems;
79
+ /** List of item primary keys deleted by Lucid */
80
+ itemsDeleted: string[];
81
+ /** The syncSourceId of the changed data source */
82
+ syncSourceId: string;
83
+ /** The syncCollectionId of the changed collection */
84
+ syncCollectionId: CollectionId;
85
+ constructor(
86
+ /** The id of the patch */
87
+ id: string,
88
+ /** Mapping of item primary keys to new items introduced by Lucid */
89
+ itemsAdded: PatchItems,
90
+ /** Mapping of item primary keys to sparse changesets of pre-existing items changed by Lucid */
91
+ itemsChanged: PatchItems,
92
+ /** List of item primary keys deleted by Lucid */
93
+ itemsDeleted: string[],
94
+ /** The syncSourceId of the changed data source */
95
+ syncSourceId: string,
96
+ /** The syncCollectionId of the changed collection */
97
+ syncCollectionId: CollectionId);
98
+ getChange(collections?: PatchChangeCollection[]): PatchChange;
99
+ }
100
+ /**
101
+ * A patch action is a kind of synchronous style action. It occurs when data is changed in the Lucid editor. All the
102
+ * changes are collected in the patches field.
103
+ **/
104
+ export declare class DataConnectorPatchAction extends DataConnectorAction {
105
+ patches: Patch[];
106
+ constructor(context: DataConnectorActionContext, /** changes applied by Lucid */ patches: Patch[]);
107
+ }
108
+ /**
109
+ * A description of an existing webhook that Lucid is keeping track of.
110
+ **/
111
+ export declare class Webhook {
112
+ /** Set of items this webhook is tracking as a `Record<CollectionId, ItemPrimaryKey[]>` */
113
+ documentCollections: {
114
+ [collectionId: CollectionId]: ItemPrimaryKey[];
115
+ };
116
+ /** Arbitrary extra data to allow the data connector to better identitify the webhook. */
117
+ webhookData: unknown;
118
+ constructor(
119
+ /** Set of items this webhook is tracking as a `Record<CollectionId, ItemPrimaryKey[]>` */
120
+ documentCollections: {
121
+ [collectionId: CollectionId]: ItemPrimaryKey[];
122
+ },
123
+ /** Arbitrary extra data to allow the data connector to better identitify the webhook. */
124
+ webhookData: unknown);
125
+ }
126
+ /**
127
+ * A "synchronous" style action indicating that Lucid would like to setup a webhook in the third party.
128
+ */
129
+ export declare class DataConnectorManageWebhookAction extends DataConnectorAction {
130
+ /**
131
+ * Token to be added to the newly created webhook so that when it fires it will have permissions to make changes
132
+ * to Lucid documents.
133
+ */
134
+ webhookToken: string;
135
+ /**
136
+ * A list of existing webhooks so you can be more granular about what you track. You may also find it useful to
137
+ * delete some of the existing webhooks. The response back to Lucid should include all existing webhooks (newly
138
+ * created or any of these that were not deleted).
139
+ **/
140
+ webhooks: Webhook[];
141
+ constructor(context: DataConnectorActionContext,
142
+ /**
143
+ * Token to be added to the newly created webhook so that when it fires it will have permissions to make changes
144
+ * to Lucid documents.
145
+ */
146
+ webhookToken: string,
147
+ /**
148
+ * A list of existing webhooks so you can be more granular about what you track. You may also find it useful to
149
+ * delete some of the existing webhooks. The response back to Lucid should include all existing webhooks (newly
150
+ * created or any of these that were not deleted).
151
+ **/
152
+ webhooks: Webhook[]);
153
+ }
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataConnectorManageWebhookAction = exports.Webhook = exports.DataConnectorPatchAction = exports.Patch = exports.DataConnectorSynchronousAction = exports.DataConnectorAsynchronousAction = exports.DataConnectorAction = exports.DataConnectorActionContext = void 0;
4
+ const patchresponsebody_1 = require("./patchresponsebody");
5
+ /**
6
+ * This holds all the contextual information about a give data action.
7
+ */
8
+ class DataConnectorActionContext {
9
+ constructor(
10
+ /** The package ID of the extension that triggered this action */
11
+ packageId,
12
+ /** The version of the extension that triggered this action */
13
+ packageVersion,
14
+ /** The authorized OAuth2 credential that Lucid has for the 3rd party this extension works with */
15
+ userCredential,
16
+ /** The data connector name from manifest.json that triggered this action */
17
+ dataConnectorName,
18
+ /** The installation id of the extension/user that triggered this action */
19
+ installationId,
20
+ /** Set of items this document is tracking as a `Record<CollectionId, ItemPrimaryKey[]>` */
21
+ documentCollections,
22
+ /** Update filter type for this document */
23
+ updateFilterType) {
24
+ this.packageId = packageId;
25
+ this.packageVersion = packageVersion;
26
+ this.userCredential = userCredential;
27
+ this.dataConnectorName = dataConnectorName;
28
+ this.installationId = installationId;
29
+ this.documentCollections = documentCollections;
30
+ this.updateFilterType = updateFilterType;
31
+ }
32
+ }
33
+ exports.DataConnectorActionContext = DataConnectorActionContext;
34
+ /** Base class for actions to be performed by data connectors */
35
+ class DataConnectorAction {
36
+ constructor(name, context) {
37
+ this.name = name;
38
+ this.context = context;
39
+ }
40
+ }
41
+ exports.DataConnectorAction = DataConnectorAction;
42
+ /**
43
+ * A generic "asynchronous" action to be performed by the data connector. This is an action that reports back to Lucid
44
+ * by calling back in the DataSourceClient rather than returning a meaningful value.
45
+ **/
46
+ class DataConnectorAsynchronousAction extends DataConnectorAction {
47
+ constructor(name, context, client, data) {
48
+ super(name, context);
49
+ this.client = client;
50
+ this.data = data;
51
+ }
52
+ }
53
+ exports.DataConnectorAsynchronousAction = DataConnectorAsynchronousAction;
54
+ /**
55
+ * A generic "synchronous" action to be performed by the data connector.
56
+ **/
57
+ class DataConnectorSynchronousAction extends DataConnectorAction {
58
+ constructor(name, context, data) {
59
+ super(name, context);
60
+ this.data = data;
61
+ }
62
+ }
63
+ exports.DataConnectorSynchronousAction = DataConnectorSynchronousAction;
64
+ /** A patch to be applied against the 3rd party datasource with changes coming from Lucid */
65
+ class Patch {
66
+ constructor(
67
+ /** The id of the patch */
68
+ id,
69
+ /** Mapping of item primary keys to new items introduced by Lucid */
70
+ itemsAdded,
71
+ /** Mapping of item primary keys to sparse changesets of pre-existing items changed by Lucid */
72
+ itemsChanged,
73
+ /** List of item primary keys deleted by Lucid */
74
+ itemsDeleted,
75
+ /** The syncSourceId of the changed data source */
76
+ syncSourceId,
77
+ /** The syncCollectionId of the changed collection */
78
+ syncCollectionId) {
79
+ this.id = id;
80
+ this.itemsAdded = itemsAdded;
81
+ this.itemsChanged = itemsChanged;
82
+ this.itemsDeleted = itemsDeleted;
83
+ this.syncSourceId = syncSourceId;
84
+ this.syncCollectionId = syncCollectionId;
85
+ }
86
+ getChange(collections = []) {
87
+ return new patchresponsebody_1.PatchChange(this.id, this.syncSourceId, collections);
88
+ }
89
+ }
90
+ exports.Patch = Patch;
91
+ /**
92
+ * A patch action is a kind of synchronous style action. It occurs when data is changed in the Lucid editor. All the
93
+ * changes are collected in the patches field.
94
+ **/
95
+ class DataConnectorPatchAction extends DataConnectorAction {
96
+ constructor(context, /** changes applied by Lucid */ patches) {
97
+ super('Patch', context);
98
+ this.patches = patches;
99
+ }
100
+ }
101
+ exports.DataConnectorPatchAction = DataConnectorPatchAction;
102
+ /**
103
+ * A description of an existing webhook that Lucid is keeping track of.
104
+ **/
105
+ class Webhook {
106
+ constructor(
107
+ /** Set of items this webhook is tracking as a `Record<CollectionId, ItemPrimaryKey[]>` */
108
+ documentCollections,
109
+ /** Arbitrary extra data to allow the data connector to better identitify the webhook. */
110
+ webhookData) {
111
+ this.documentCollections = documentCollections;
112
+ this.webhookData = webhookData;
113
+ }
114
+ }
115
+ exports.Webhook = Webhook;
116
+ /**
117
+ * A "synchronous" style action indicating that Lucid would like to setup a webhook in the third party.
118
+ */
119
+ class DataConnectorManageWebhookAction extends DataConnectorAction {
120
+ constructor(context,
121
+ /**
122
+ * Token to be added to the newly created webhook so that when it fires it will have permissions to make changes
123
+ * to Lucid documents.
124
+ */
125
+ webhookToken,
126
+ /**
127
+ * A list of existing webhooks so you can be more granular about what you track. You may also find it useful to
128
+ * delete some of the existing webhooks. The response back to Lucid should include all existing webhooks (newly
129
+ * created or any of these that were not deleted).
130
+ **/
131
+ webhooks) {
132
+ super('ManageWebhook', context);
133
+ this.webhookToken = webhookToken;
134
+ this.webhooks = webhooks;
135
+ }
136
+ }
137
+ exports.DataConnectorManageWebhookAction = DataConnectorManageWebhookAction;
@@ -0,0 +1,8 @@
1
+ import { Webhook } from './action';
2
+ /** Convert the ManageWebhookResponse to Lucid's wire format */
3
+ export declare function serializeManageWebhookResponse(webhookResponse: Webhook): SerializedManageWebhookResponseBody;
4
+ /** Wire format for ManageWebhookResponses */
5
+ export declare type SerializedManageWebhookResponseBody = {
6
+ 'documentCollections': Record<string, string[]>;
7
+ 'webhookData': unknown;
8
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeManageWebhookResponse = void 0;
4
+ /** Convert the ManageWebhookResponse to Lucid's wire format */
5
+ function serializeManageWebhookResponse(webhookResponse) {
6
+ return {
7
+ 'documentCollections': webhookResponse.documentCollections,
8
+ 'webhookData': webhookResponse.webhookData,
9
+ };
10
+ }
11
+ exports.serializeManageWebhookResponse = serializeManageWebhookResponse;