lucid-extension-sdk 0.0.331 → 0.0.334
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/core/data/datasource/serializedimporteddatasource.d.ts +4 -4
- package/core/data/datasource/updatecreationpermission.d.ts +21 -0
- package/core/data/datasource/updatecreationpermission.js +38 -0
- package/dataconnector/actions/action.d.ts +4 -0
- package/dataconnector/actions/action.js +3 -0
- package/dataconnector/actions/patch.d.ts +2 -1
- package/dataconnector/actions/patch.js +2 -2
- package/dataconnector/actions/patchresponsebody.d.ts +4 -1
- package/dataconnector/actions/patchresponsebody.js +3 -1
- package/dataconnector/actions/serializedactions.js +6 -3
- package/dataconnector/datasourceclient.js +2 -1
- package/dataconnector/datasourceupdatetypes.d.ts +3 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { isObject, isString } from '../../checks';
|
|
|
2
2
|
import { SerializedDataItems } from '../serializedfield/serializeddataitems';
|
|
3
3
|
import { SerializedSchema, isSerializedSchema } from '../serializedfield/serializedschema';
|
|
4
4
|
import { SerializedDataSourceProperties } from './serializeddatasourceproperties';
|
|
5
|
+
import { UpdateCreationPermission } from './updatecreationpermission';
|
|
5
6
|
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
6
7
|
export interface SerializedImportedMetadataCollection {
|
|
7
8
|
'Name': string;
|
|
@@ -44,6 +45,7 @@ export declare const isSerializedImportedCollection: (subject: unknown) => subje
|
|
|
44
45
|
export interface SerializedImportedDataSource {
|
|
45
46
|
'Properties': SerializedDataSourceProperties;
|
|
46
47
|
'Collections': SerializedImportedCollection[];
|
|
48
|
+
'CreationPermission'?: UpdateCreationPermission | undefined;
|
|
47
49
|
}
|
|
48
50
|
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
49
51
|
export declare const isSerializedImportedDataSource: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
|
|
@@ -53,11 +55,10 @@ export declare const isSerializedImportedDataSource: (subject: unknown) => subje
|
|
|
53
55
|
SourceType: (x: unknown) => x is import("./datasourcetype").DataSourceType;
|
|
54
56
|
UpdateType: (x: unknown) => x is import("./upstreamupdatetype").UpstreamUpdateType;
|
|
55
57
|
PatchType: (x: unknown) => x is import("./upstreampatchtype").UpstreamPatchType | null | undefined;
|
|
56
|
-
IsSyncingPaused: (x: unknown) => x is true | undefined;
|
|
58
|
+
IsSyncingPaused: (x: unknown) => x is true | undefined; /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
57
59
|
SourceConfig: typeof isObject;
|
|
58
60
|
}> | null | undefined;
|
|
59
61
|
SourceForeignKeys: (x: unknown) => x is import("../../guards").DestructureGuardedTypeObj<{
|
|
60
|
-
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
61
62
|
Id: typeof isString;
|
|
62
63
|
SourceFields: (p1: unknown) => p1 is string[];
|
|
63
64
|
RelationshipType: (x: unknown) => x is string | undefined;
|
|
@@ -93,11 +94,10 @@ export declare const isSerializedPreviewData: (subject: unknown) => subject is i
|
|
|
93
94
|
SourceType: (x: unknown) => x is import("./datasourcetype").DataSourceType;
|
|
94
95
|
UpdateType: (x: unknown) => x is import("./upstreamupdatetype").UpstreamUpdateType;
|
|
95
96
|
PatchType: (x: unknown) => x is import("./upstreampatchtype").UpstreamPatchType | null | undefined;
|
|
96
|
-
IsSyncingPaused: (x: unknown) => x is true | undefined;
|
|
97
|
+
IsSyncingPaused: (x: unknown) => x is true | undefined; /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
97
98
|
SourceConfig: typeof isObject;
|
|
98
99
|
}> | null | undefined;
|
|
99
100
|
SourceForeignKeys: (x: unknown) => x is import("../../guards").DestructureGuardedTypeObj<{
|
|
100
|
-
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
101
101
|
Id: typeof isString;
|
|
102
102
|
SourceFields: (p1: unknown) => p1 is string[];
|
|
103
103
|
RelationshipType: (x: unknown) => x is string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UpdateCreationPermission is used by data source updates from third party data integrations to indicate
|
|
3
|
+
* how much data that particular request is allowed to create. If the data source update would require creating
|
|
4
|
+
* something at a higher level of permission, the request will fail.
|
|
5
|
+
*
|
|
6
|
+
* The levels are 'DataSource', 'Collection', 'Item', and 'None'. 'DataSource' is the most permissive, allowing the
|
|
7
|
+
* update to create new data sources and anything contained in them (i.e. collections and items). 'Collection' allows
|
|
8
|
+
* the update to create new collections and items only in existing data sources. 'Item' allows the update to modify the contents
|
|
9
|
+
* of existing on-document collections, but not to create the collections or data sources needed to hold them.
|
|
10
|
+
*
|
|
11
|
+
* The original purpose of this parameter was to make it so that in-flight patches to edit on-document data could not
|
|
12
|
+
* accidentally re-create a collection that the user had manually deleted while the patch was in-flight.
|
|
13
|
+
*/
|
|
14
|
+
declare const creationPermissionOrdering: readonly ['DataSource', 'Collection', 'Item', 'None'];
|
|
15
|
+
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
16
|
+
export type UpdateCreationPermission = (typeof creationPermissionOrdering)[number];
|
|
17
|
+
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
18
|
+
export declare const isUpdateCreationPermission: (x: unknown) => x is "DataSource" | "Collection" | "Item" | "None";
|
|
19
|
+
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
20
|
+
export declare function isAsPermissiveAs(permission: UpdateCreationPermission, targetPermission: UpdateCreationPermission): boolean;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* UpdateCreationPermission is used by data source updates from third party data integrations to indicate
|
|
4
|
+
* how much data that particular request is allowed to create. If the data source update would require creating
|
|
5
|
+
* something at a higher level of permission, the request will fail.
|
|
6
|
+
*
|
|
7
|
+
* The levels are 'DataSource', 'Collection', 'Item', and 'None'. 'DataSource' is the most permissive, allowing the
|
|
8
|
+
* update to create new data sources and anything contained in them (i.e. collections and items). 'Collection' allows
|
|
9
|
+
* the update to create new collections and items only in existing data sources. 'Item' allows the update to modify the contents
|
|
10
|
+
* of existing on-document collections, but not to create the collections or data sources needed to hold them.
|
|
11
|
+
*
|
|
12
|
+
* The original purpose of this parameter was to make it so that in-flight patches to edit on-document data could not
|
|
13
|
+
* accidentally re-create a collection that the user had manually deleted while the patch was in-flight.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.isAsPermissiveAs = exports.isUpdateCreationPermission = void 0;
|
|
17
|
+
const creationPermissionOrdering = [
|
|
18
|
+
'DataSource',
|
|
19
|
+
'Collection',
|
|
20
|
+
'Item',
|
|
21
|
+
'None',
|
|
22
|
+
];
|
|
23
|
+
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
24
|
+
const isUpdateCreationPermission = (x) => creationPermissionOrdering.find((p) => p === x) !== undefined;
|
|
25
|
+
exports.isUpdateCreationPermission = isUpdateCreationPermission;
|
|
26
|
+
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
27
|
+
function isAsPermissiveAs(permission, targetPermission) {
|
|
28
|
+
for (const p of creationPermissionOrdering) {
|
|
29
|
+
if (p === permission) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
else if (p === targetPermission) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
exports.isAsPermissiveAs = isAsPermissiveAs;
|
|
@@ -13,6 +13,8 @@ export declare class DataConnectorActionContext {
|
|
|
13
13
|
packageVersion: string;
|
|
14
14
|
/** The authorized OAuth2 credential that Lucid has for the 3rd party this extension works with */
|
|
15
15
|
userCredential: string;
|
|
16
|
+
/** @ignore Boolean indicating whether to use a proxy server when making a request to third party */
|
|
17
|
+
useOutboundProxy: boolean | undefined;
|
|
16
18
|
/** The data connector name from manifest.json that triggered this action */
|
|
17
19
|
dataConnectorName: string;
|
|
18
20
|
/** The installation id of the extension/user that triggered this action */
|
|
@@ -32,6 +34,8 @@ export declare class DataConnectorActionContext {
|
|
|
32
34
|
packageVersion: string,
|
|
33
35
|
/** The authorized OAuth2 credential that Lucid has for the 3rd party this extension works with */
|
|
34
36
|
userCredential: string,
|
|
37
|
+
/** @ignore Boolean indicating whether to use a proxy server when making a request to third party */
|
|
38
|
+
useOutboundProxy: boolean | undefined,
|
|
35
39
|
/** The data connector name from manifest.json that triggered this action */
|
|
36
40
|
dataConnectorName: string,
|
|
37
41
|
/** The installation id of the extension/user that triggered this action */
|
|
@@ -13,6 +13,8 @@ class DataConnectorActionContext {
|
|
|
13
13
|
packageVersion,
|
|
14
14
|
/** The authorized OAuth2 credential that Lucid has for the 3rd party this extension works with */
|
|
15
15
|
userCredential,
|
|
16
|
+
/** @ignore Boolean indicating whether to use a proxy server when making a request to third party */
|
|
17
|
+
useOutboundProxy,
|
|
16
18
|
/** The data connector name from manifest.json that triggered this action */
|
|
17
19
|
dataConnectorName,
|
|
18
20
|
/** The installation id of the extension/user that triggered this action */
|
|
@@ -26,6 +28,7 @@ class DataConnectorActionContext {
|
|
|
26
28
|
this.packageId = packageId;
|
|
27
29
|
this.packageVersion = packageVersion;
|
|
28
30
|
this.userCredential = userCredential;
|
|
31
|
+
this.useOutboundProxy = useOutboundProxy;
|
|
29
32
|
this.dataConnectorName = dataConnectorName;
|
|
30
33
|
this.installationId = installationId;
|
|
31
34
|
this.documentCollections = documentCollections;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UpdateCreationPermission } from '../../core/data/datasource/updatecreationpermission';
|
|
1
2
|
import { FieldTypeDefinition } from '../../core/data/fieldtypedefinition/fieldtypedefinition';
|
|
2
3
|
import { CollectionId, PatchItems } from './action';
|
|
3
4
|
import { PatchChange, PatchChangeCollection } from './patchresponsebody';
|
|
@@ -18,7 +19,7 @@ export declare abstract class Patch {
|
|
|
18
19
|
syncSourceId: string,
|
|
19
20
|
/** The syncCollectionId of the changed collection */
|
|
20
21
|
syncCollectionId: CollectionId);
|
|
21
|
-
getChange(collections?: PatchChangeCollection[]): PatchChange;
|
|
22
|
+
getChange(collections?: PatchChangeCollection[], creationPermission?: UpdateCreationPermission | undefined): PatchChange;
|
|
22
23
|
abstract toJSON(): object;
|
|
23
24
|
abstract clone(): this;
|
|
24
25
|
}
|
|
@@ -24,8 +24,8 @@ class Patch {
|
|
|
24
24
|
this.syncSourceId = syncSourceId;
|
|
25
25
|
this.syncCollectionId = syncCollectionId;
|
|
26
26
|
}
|
|
27
|
-
getChange(collections = []) {
|
|
28
|
-
return new patchresponsebody_1.PatchChange(this.id, this.syncSourceId, collections);
|
|
27
|
+
getChange(collections = [], creationPermission = undefined) {
|
|
28
|
+
return new patchresponsebody_1.PatchChange(this.id, this.syncSourceId, collections, creationPermission);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
exports.Patch = Patch;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UpdateCreationPermission } from '../../core/data/datasource/updatecreationpermission';
|
|
1
2
|
import { SchemaDefinition } from '../../data/schemadefinition';
|
|
2
3
|
import { ItemsPatch, SerializedItemsPatch, SerializedSchemaForApi } from '../datasourceupdatetypes';
|
|
3
4
|
export type PatchChangeCollection = {
|
|
@@ -12,8 +13,9 @@ export declare class PatchChange {
|
|
|
12
13
|
patchId: string;
|
|
13
14
|
syncId: string;
|
|
14
15
|
collections: PatchChangeCollection[];
|
|
16
|
+
creationPermission?: "DataSource" | "Collection" | "Item" | "None" | undefined;
|
|
15
17
|
private errors;
|
|
16
|
-
constructor(patchId: string, syncId: string, collections: PatchChangeCollection[]);
|
|
18
|
+
constructor(patchId: string, syncId: string, collections: PatchChangeCollection[], creationPermission?: "DataSource" | "Collection" | "Item" | "None" | undefined);
|
|
17
19
|
setError(primaryKey: string, fieldName: string, error: string): void;
|
|
18
20
|
setTooltipError(primaryKey: string, error: string): void;
|
|
19
21
|
getErrors(): Record<string, Record<string, string>>;
|
|
@@ -31,6 +33,7 @@ export type SerializedPatchChange = {
|
|
|
31
33
|
'itemsPatch': SerializedItemsPatch;
|
|
32
34
|
'schema'?: SerializedSchemaForApi;
|
|
33
35
|
}[];
|
|
36
|
+
'creationPermission'?: UpdateCreationPermission | undefined;
|
|
34
37
|
};
|
|
35
38
|
/** Wire format for "Patch" Action responses */
|
|
36
39
|
export type SerializedPatchResponseBody = {
|
|
@@ -7,10 +7,11 @@ const datasourceupdatetypes_1 = require("../datasourceupdatetypes");
|
|
|
7
7
|
* Reports a completed change back to Lucid
|
|
8
8
|
*/
|
|
9
9
|
class PatchChange {
|
|
10
|
-
constructor(patchId, syncId, collections) {
|
|
10
|
+
constructor(patchId, syncId, collections, creationPermission) {
|
|
11
11
|
this.patchId = patchId;
|
|
12
12
|
this.syncId = syncId;
|
|
13
13
|
this.collections = collections;
|
|
14
|
+
this.creationPermission = creationPermission;
|
|
14
15
|
this.errors = {};
|
|
15
16
|
}
|
|
16
17
|
setError(primaryKey, fieldName, error) {
|
|
@@ -36,6 +37,7 @@ function serializePatchResponse(patchChange) {
|
|
|
36
37
|
'collections': patchChange.collections.map((c) => {
|
|
37
38
|
return Object.assign({ 'collectionId': c.collectionId, 'itemsPatch': (0, datasourceupdatetypes_1.serializeItemsPatch)(c.itemsPatch) }, (c.schema != null ? { 'schema': (0, datasourceupdatetypes_1.serializeSchemaForApi)(c.schema) } : undefined));
|
|
38
39
|
}),
|
|
40
|
+
'creationPermission': patchChange.creationPermission,
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
exports.serializePatchResponse = serializePatchResponse;
|
|
@@ -17,6 +17,7 @@ const serializedActionsBaseValidator = (0, validators_1.objectValidator)({
|
|
|
17
17
|
dataConnectorName: checks_1.isString,
|
|
18
18
|
installationId: (0, validators_1.nullableOption)(checks_1.isString),
|
|
19
19
|
userCredential: (0, validators_1.nullableOption)(checks_1.isString),
|
|
20
|
+
useOutboundProxy: (0, validators_1.option)(checks_1.isBoolean),
|
|
20
21
|
documentUpdateToken: (0, validators_1.nullableOption)(checks_1.isString),
|
|
21
22
|
documentCollections: (0, validators_1.objectOfValidator)((0, validators_1.arrayValidator)(checks_1.isString)),
|
|
22
23
|
updateFilterType: (0, validators_1.enumValidator)(dataupdatefiltertype_1.DataUpdateFilterType),
|
|
@@ -29,6 +30,7 @@ const serializedPatchDataValidator = (0, validators_1.objectValidator)({
|
|
|
29
30
|
id: checks_1.isString,
|
|
30
31
|
})),
|
|
31
32
|
userCredential: checks_1.isString,
|
|
33
|
+
useOutboundProxy: (0, validators_1.option)(checks_1.isBoolean),
|
|
32
34
|
documentUpdateToken: checks_1.isString,
|
|
33
35
|
timezone: (0, validators_1.nullableOption)(checks_1.isString),
|
|
34
36
|
});
|
|
@@ -62,7 +64,8 @@ function deserializeActions(client, actions, patchParser) {
|
|
|
62
64
|
}
|
|
63
65
|
const parsedData = data
|
|
64
66
|
.map((item) => {
|
|
65
|
-
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], item['packageVersion'], item['userCredential'],
|
|
67
|
+
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], item['packageVersion'], item['userCredential'], item['useOutboundProxy'], // Use from action data and ignores the useOutboundProxy boolean in parsedActions
|
|
68
|
+
parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType'], parsedActions['timezone']);
|
|
66
69
|
const patches = parseSerializedPatches(item['patches'], patchParser);
|
|
67
70
|
if (patches.length < item['patches'].length) {
|
|
68
71
|
return undefined;
|
|
@@ -84,7 +87,7 @@ function deserializeActions(client, actions, patchParser) {
|
|
|
84
87
|
if (!serializedPatchDataValidator(data)) {
|
|
85
88
|
return;
|
|
86
89
|
}
|
|
87
|
-
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], parsedActions['packageVersion'], parsedActions['userCredential'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType'], parsedActions['timezone']);
|
|
90
|
+
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], parsedActions['packageVersion'], parsedActions['userCredential'], parsedActions['useOutboundProxy'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType'], parsedActions['timezone']);
|
|
88
91
|
const parsedPatches = parseSerializedPatches(data['patches'], patchParser);
|
|
89
92
|
if (parsedPatches.length < data['patches'].length) {
|
|
90
93
|
console.log(`Failing validation step`);
|
|
@@ -94,7 +97,7 @@ function deserializeActions(client, actions, patchParser) {
|
|
|
94
97
|
new action_1.DataConnectorPatchAction(context, parsedPatches, client.getDataSourceClient(data['documentUpdateToken']), dataconnectoractionkeys_1.DataConnectorActionKeys.UnbatchedPatch),
|
|
95
98
|
];
|
|
96
99
|
}
|
|
97
|
-
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], parsedActions['packageVersion'], parsedActions['userCredential'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType'], parsedActions['timezone']);
|
|
100
|
+
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], parsedActions['packageVersion'], parsedActions['userCredential'], parsedActions['useOutboundProxy'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType'], parsedActions['timezone']);
|
|
98
101
|
if (name == 'ManageWebhook') {
|
|
99
102
|
if (!serializedManageWebhookDataValidator(data)) {
|
|
100
103
|
return;
|
|
@@ -25,7 +25,7 @@ class DataSourceClient {
|
|
|
25
25
|
const dataSyncUrl = urls.dataSync;
|
|
26
26
|
this.metadataUrl = (0, checks_1.isString)(dataSyncUrl) ? `${dataSyncUrl}dataSource/metadata` : undefined;
|
|
27
27
|
}
|
|
28
|
-
formatBody({ dataSourceName, collections, updateFilterType, dataSourceConfiguration, sourceForeignKeys, }) {
|
|
28
|
+
formatBody({ dataSourceName, collections, updateFilterType, dataSourceConfiguration, sourceForeignKeys, creationPermission, }) {
|
|
29
29
|
const updateData = {};
|
|
30
30
|
for (const collectionId in collections) {
|
|
31
31
|
updateData[collectionId] = (0, datasourceupdatetypes_1.serializeCollectionPatch)(collections[collectionId]);
|
|
@@ -43,6 +43,7 @@ class DataSourceClient {
|
|
|
43
43
|
'name': dataSourceName,
|
|
44
44
|
'upstreamConfig': (0, upstreamconfig_1.serializeUpstreamConfig)(upstreamConfig),
|
|
45
45
|
'sourceForeignKeys': foreignKeys,
|
|
46
|
+
'creationPermission': creationPermission,
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
/** Create or update a datasource. If you create a new collection it must be fully specified in terms of schema and
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SemanticCollection } from '../core/data/datasource/semanticcollection';
|
|
2
2
|
import { SourceForeignKey } from '../core/data/datasource/sourceforeignkeys';
|
|
3
|
+
import { UpdateCreationPermission } from '../core/data/datasource/updatecreationpermission';
|
|
3
4
|
import { UpstreamPatchType } from '../core/data/datasource/upstreampatchtype';
|
|
4
5
|
import { SerializedFieldTypeDefinition } from '../core/data/fieldtypedefinition/fieldtypedefinition';
|
|
5
6
|
import { LucidFields } from '../core/data/fieldtypedefinition/lucidfields';
|
|
@@ -28,6 +29,8 @@ export type DataSourceRequest = {
|
|
|
28
29
|
};
|
|
29
30
|
/** Configuration for relationships between collections in the data source */
|
|
30
31
|
sourceForeignKeys?: SourceForeignKey[];
|
|
32
|
+
/** The level of permission the request has to create data */
|
|
33
|
+
creationPermission?: UpdateCreationPermission;
|
|
31
34
|
};
|
|
32
35
|
type SerializedFieldConstraintForApi = {
|
|
33
36
|
'type': FieldConstraintType;
|