lucid-extension-sdk 0.0.274 → 0.0.277
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/datasourceutils.d.ts +8 -18
- package/core/data/datasource/datasourceutils.js +19 -1
- package/core/data/datasource/serializedimporteddatasource.d.ts +41 -1
- package/core/data/datasource/serializedimporteddatasource.js +9 -1
- package/dataconnector/actions/serializedactions.js +10 -9
- package/dataconnector/debugserver.js +2 -2
- package/dataconnector/signaturevalidator.js +2 -1
- package/package.json +1 -1
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { DataUpdateFilterType } from '../../../data/dataupdatefiltertype';
|
|
2
1
|
import { SerializedFields } from '../serializedfield/serializedfields';
|
|
3
|
-
import {
|
|
4
|
-
import { SerializedImportedCollection } from './serializedimporteddatasource';
|
|
5
|
-
import { UpstreamUpdateType } from './upstreamupdatetype';
|
|
2
|
+
import { SerializedImportedCollection, SerializedImportedDataSource, SerializedPreviewData } from './serializedimporteddatasource';
|
|
6
3
|
/** @ignore */
|
|
7
4
|
export declare function alphabetize(n: number): string;
|
|
8
5
|
/** @ignore */
|
|
@@ -21,17 +18,10 @@ export declare function makeSerializedImportedCollection(name: string, rawFieldN
|
|
|
21
18
|
primaryKey: string[];
|
|
22
19
|
}): SerializedImportedCollection;
|
|
23
20
|
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
24
|
-
export declare function makeSerializedImportedDataSource(id: string, name: string, collections: SerializedImportedCollection[]):
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
spreadsheetId: string;
|
|
32
|
-
UpdateFilterType: DataUpdateFilterType;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
Collections: SerializedImportedCollection[];
|
|
37
|
-
};
|
|
21
|
+
export declare function makeSerializedImportedDataSource(id: string, name: string, collections: SerializedImportedCollection[]): SerializedImportedDataSource;
|
|
22
|
+
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
23
|
+
export declare function makeSerializedPreviewData(id: string, name: string, collections: {
|
|
24
|
+
'Data': SerializedImportedCollection;
|
|
25
|
+
'HeaderRow'?: number | undefined;
|
|
26
|
+
'PrimaryKey'?: number[] | undefined;
|
|
27
|
+
}[]): SerializedPreviewData;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeSerializedImportedDataSource = exports.makeSerializedImportedCollection = exports.MetadataPK = exports.makeNameReadablyUnique = exports.normalizeName = exports.alphabetize = void 0;
|
|
3
|
+
exports.makeSerializedPreviewData = exports.makeSerializedImportedDataSource = exports.makeSerializedImportedCollection = exports.MetadataPK = exports.makeNameReadablyUnique = exports.normalizeName = exports.alphabetize = void 0;
|
|
4
4
|
const dataupdatefiltertype_1 = require("../../../data/dataupdatefiltertype");
|
|
5
5
|
const checks_1 = require("../../checks");
|
|
6
6
|
const scalarfieldtype_1 = require("../fieldtypedefinition/scalarfieldtype");
|
|
@@ -235,3 +235,21 @@ function makeSerializedImportedDataSource(id, name, collections) {
|
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
237
|
exports.makeSerializedImportedDataSource = makeSerializedImportedDataSource;
|
|
238
|
+
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
239
|
+
function makeSerializedPreviewData(id, name, collections) {
|
|
240
|
+
return {
|
|
241
|
+
'Properties': {
|
|
242
|
+
'Name': name,
|
|
243
|
+
'UpstreamConfig': {
|
|
244
|
+
'SourceType': datasourcetype_1.DataSourceType.DataService,
|
|
245
|
+
'UpdateType': upstreamupdatetype_1.UpstreamUpdateType.EVENTPULL,
|
|
246
|
+
'SourceConfig': {
|
|
247
|
+
'spreadsheetId': id,
|
|
248
|
+
'UpdateFilterType': dataupdatefiltertype_1.DataUpdateFilterType.CurrentCollectionUpdates,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
'Collections': collections,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
exports.makeSerializedPreviewData = makeSerializedPreviewData;
|
|
@@ -53,7 +53,7 @@ export declare const isSerializedImportedDataSource: (subject: unknown) => subje
|
|
|
53
53
|
SourceType: (x: unknown) => x is import("./datasourcetype").DataSourceType;
|
|
54
54
|
UpdateType: (x: unknown) => x is import("./upstreamupdatetype").UpstreamUpdateType;
|
|
55
55
|
PatchType: (x: unknown) => x is import("./upstreampatchtype").UpstreamPatchType | null | undefined;
|
|
56
|
-
SourceConfig: typeof isObject;
|
|
56
|
+
SourceConfig: typeof isObject;
|
|
57
57
|
}> | null | undefined;
|
|
58
58
|
SourceForeignKeys: (x: unknown) => x is import("../../guards").DestructureGuardedTypeObj<{
|
|
59
59
|
Id: typeof isString;
|
|
@@ -74,3 +74,43 @@ export declare const isSerializedImportedDataSource: (subject: unknown) => subje
|
|
|
74
74
|
DataIsPartial: (x: unknown) => x is true | undefined;
|
|
75
75
|
}>[];
|
|
76
76
|
}>;
|
|
77
|
+
export interface SerializedPreviewData {
|
|
78
|
+
'Properties': SerializedDataSourceProperties;
|
|
79
|
+
'Collections': {
|
|
80
|
+
'Data': SerializedImportedCollection;
|
|
81
|
+
'HeaderRow'?: number | undefined;
|
|
82
|
+
'PrimaryKey'?: number[] | undefined;
|
|
83
|
+
}[];
|
|
84
|
+
}
|
|
85
|
+
export declare const isSerializedPreviewData: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
|
|
86
|
+
Properties: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
|
|
87
|
+
Name: typeof isString;
|
|
88
|
+
UpstreamConfig: (x: unknown) => x is import("../../guards").DestructureGuardedTypeObj<{
|
|
89
|
+
SourceType: (x: unknown) => x is import("./datasourcetype").DataSourceType;
|
|
90
|
+
UpdateType: (x: unknown) => x is import("./upstreamupdatetype").UpstreamUpdateType;
|
|
91
|
+
PatchType: (x: unknown) => x is import("./upstreampatchtype").UpstreamPatchType | null | undefined;
|
|
92
|
+
SourceConfig: typeof isObject;
|
|
93
|
+
}> | null | undefined;
|
|
94
|
+
SourceForeignKeys: (x: unknown) => x is import("../../guards").DestructureGuardedTypeObj<{
|
|
95
|
+
Id: typeof isString;
|
|
96
|
+
SourceFields: (p1: unknown) => p1 is string[];
|
|
97
|
+
RelationshipType: typeof isString;
|
|
98
|
+
}>[] | null | undefined;
|
|
99
|
+
}>;
|
|
100
|
+
Collections: (val: unknown) => val is import("../../guards").DestructureGuardedTypeObj<{
|
|
101
|
+
Data: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
|
|
102
|
+
Name: typeof isString;
|
|
103
|
+
Schema: typeof isSerializedSchema;
|
|
104
|
+
Items: (x: unknown) => x is Record<any, Record<any, import("../serializedfield/serializedfields").SerializedFieldType>>;
|
|
105
|
+
UpstreamConfig: typeof isObject;
|
|
106
|
+
Metadata: (val: unknown) => val is Record<string, import("../../guards").DestructureGuardedTypeObj<{
|
|
107
|
+
Name: typeof isString;
|
|
108
|
+
Schema: typeof isSerializedSchema;
|
|
109
|
+
Items: (x: unknown) => x is Record<any, Record<any, import("../serializedfield/serializedfields").SerializedFieldType>>;
|
|
110
|
+
}>>;
|
|
111
|
+
DataIsPartial: (x: unknown) => x is true | undefined;
|
|
112
|
+
}>;
|
|
113
|
+
HeaderRow: (x: unknown) => x is number | undefined;
|
|
114
|
+
PrimaryKey: (x: unknown) => x is number[] | undefined;
|
|
115
|
+
}>[];
|
|
116
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSerializedImportedDataSource = exports.isSerializedImportedCollection = exports.isSerializedImportedMetadataCollection = void 0;
|
|
3
|
+
exports.isSerializedPreviewData = exports.isSerializedImportedDataSource = exports.isSerializedImportedCollection = exports.isSerializedImportedMetadataCollection = void 0;
|
|
4
4
|
const checks_1 = require("../../checks");
|
|
5
5
|
const validators_1 = require("../../validators/validators");
|
|
6
6
|
const serializeddataitems_1 = require("../serializedfield/serializeddataitems");
|
|
@@ -26,3 +26,11 @@ exports.isSerializedImportedDataSource = (0, validators_1.strictObjectValidator)
|
|
|
26
26
|
'Properties': serializeddatasourceproperties_1.isSerializedDataSourceProperties,
|
|
27
27
|
'Collections': (0, checks_1.isTypedArray)(exports.isSerializedImportedCollection),
|
|
28
28
|
});
|
|
29
|
+
exports.isSerializedPreviewData = (0, validators_1.strictObjectValidator)({
|
|
30
|
+
'Properties': serializeddatasourceproperties_1.isSerializedDataSourceProperties,
|
|
31
|
+
'Collections': (0, checks_1.isTypedArray)((0, validators_1.strictObjectValidator)({
|
|
32
|
+
'Data': exports.isSerializedImportedCollection,
|
|
33
|
+
'HeaderRow': (0, validators_1.option)(checks_1.isNumber),
|
|
34
|
+
'PrimaryKey': (0, validators_1.option)((0, checks_1.isTypedArray)(checks_1.isNumber)),
|
|
35
|
+
})),
|
|
36
|
+
});
|
|
@@ -55,35 +55,36 @@ const serializedManageWebhookDataValidator = (0, validators_1.objectValidator)({
|
|
|
55
55
|
});
|
|
56
56
|
/** Function to convert the lucid action wire format into a clean list of actions */
|
|
57
57
|
function deserializeActions(client, actions) {
|
|
58
|
-
|
|
58
|
+
const parsedActions = typeof actions === 'string' ? JSON.parse(actions) : actions;
|
|
59
|
+
if (!serializedActionsBaseValidator(parsedActions)) {
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
61
|
-
const name =
|
|
62
|
-
const data =
|
|
62
|
+
const name = parsedActions['action']['name'];
|
|
63
|
+
const data = parsedActions['action']['data'];
|
|
63
64
|
if (name === dataconnectoractionkeys_1.DataConnectorActionKeys.Patch) {
|
|
64
65
|
if (!(0, validators_1.arrayValidator)(serializedPatchDataValidator)(data)) {
|
|
65
66
|
console.log(`Failing validation step`);
|
|
66
67
|
return;
|
|
67
68
|
}
|
|
68
69
|
return data.map((item) => {
|
|
69
|
-
const context = new action_1.DataConnectorActionContext(
|
|
70
|
+
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], item['packageVersion'], item['userCredential'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType']);
|
|
70
71
|
const patches = parseSerializedPatches(item['patches']);
|
|
71
72
|
return new action_1.DataConnectorPatchAction(context, patches, client.getDataSourceClient(item['documentUpdateToken']));
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
|
-
if (!
|
|
75
|
+
if (!parsedActions['packageVersion'] || !parsedActions['userCredential']) {
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
if (name === dataconnectoractionkeys_1.DataConnectorActionKeys.UnbatchedPatch) {
|
|
78
79
|
if (!serializedPatchDataValidator(data)) {
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
|
-
const context = new action_1.DataConnectorActionContext(
|
|
82
|
+
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], parsedActions['packageVersion'], parsedActions['userCredential'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType']);
|
|
82
83
|
return [
|
|
83
84
|
new action_1.DataConnectorPatchAction(context, parseSerializedPatches(data['patches']), client.getDataSourceClient(data['documentUpdateToken']), dataconnectoractionkeys_1.DataConnectorActionKeys.UnbatchedPatch),
|
|
84
85
|
];
|
|
85
86
|
}
|
|
86
|
-
const context = new action_1.DataConnectorActionContext(
|
|
87
|
+
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], parsedActions['packageVersion'], parsedActions['userCredential'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType']);
|
|
87
88
|
if (name == 'ManageWebhook') {
|
|
88
89
|
if (!serializedManageWebhookDataValidator(data)) {
|
|
89
90
|
return;
|
|
@@ -91,9 +92,9 @@ function deserializeActions(client, actions) {
|
|
|
91
92
|
const webhooks = data['webhooks'].map((webhook) => new action_1.Webhook(webhook['documentCollections'], webhook['webhookData']));
|
|
92
93
|
return [new action_1.DataConnectorManageWebhookAction(context, data['webhookToken'], webhooks)];
|
|
93
94
|
}
|
|
94
|
-
if (
|
|
95
|
+
if (parsedActions['documentUpdateToken']) {
|
|
95
96
|
return [
|
|
96
|
-
new action_1.DataConnectorAsynchronousAction(name, context, client.getDataSourceClient(
|
|
97
|
+
new action_1.DataConnectorAsynchronousAction(name, context, client.getDataSourceClient(parsedActions['documentUpdateToken']), data),
|
|
97
98
|
];
|
|
98
99
|
}
|
|
99
100
|
return [new action_1.DataConnectorSynchronousAction(name, context, data)];
|
|
@@ -13,7 +13,7 @@ function routeDebugServer(dataConnector, options) {
|
|
|
13
13
|
// CORS
|
|
14
14
|
app.use((req, res, next) => {
|
|
15
15
|
var _a, _b;
|
|
16
|
-
if ((_b = (_a = req.headers) === null || _a === void 0 ? void 0 : _a.origin) === null || _b === void 0 ? void 0 : _b.match(/.lucid(dev|staging|preprod|).app$/)) {
|
|
16
|
+
if ((_b = (_a = req.headers) === null || _a === void 0 ? void 0 : _a.origin) === null || _b === void 0 ? void 0 : _b.match(/.lucid(dev|staging|preprod|gov|govpreprod|).app$/)) {
|
|
17
17
|
res.header('Access-Control-Allow-Origin', req.headers.origin);
|
|
18
18
|
res.header('Vary', 'Origin');
|
|
19
19
|
res.header('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
|
@@ -32,7 +32,7 @@ function routeDebugServer(dataConnector, options) {
|
|
|
32
32
|
try {
|
|
33
33
|
const routeKind = req.query['kind'];
|
|
34
34
|
if (routeKind === 'action' || routeKind == undefined || routeKind === '') {
|
|
35
|
-
const { body, status } = await dataConnector.runAction(req.url, req.headers,
|
|
35
|
+
const { body, status } = await dataConnector.runAction(req.url, req.headers, req.body.toString());
|
|
36
36
|
res.status(status).json(body);
|
|
37
37
|
}
|
|
38
38
|
if (routeKind === 'route') {
|
|
@@ -24,7 +24,8 @@ class SignatureValidator {
|
|
|
24
24
|
const [, params = ''] = url.split('?');
|
|
25
25
|
const nonce = headers['x-lucid-rsa-nonce'];
|
|
26
26
|
const signature = this.dependencies.Buffer.from(headers['x-lucid-signature'], 'base64');
|
|
27
|
-
const
|
|
27
|
+
const stringBody = typeof body === 'string' ? body : JSON.stringify(body);
|
|
28
|
+
const data = this.dependencies.Buffer.from(stringBody + nonce + params);
|
|
28
29
|
const verified = this.dependencies.crypto.verify('SHA384', data, this.publicKey, signature);
|
|
29
30
|
return verified;
|
|
30
31
|
}
|