lucid-extension-sdk 0.0.309 → 0.0.311
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/checks.d.ts
CHANGED
|
@@ -119,8 +119,8 @@ export declare function isArray(val: unknown): val is unknown[];
|
|
|
119
119
|
export declare function isTypedArray<T>(typeGuard: (a: unknown) => a is T): (val: unknown) => val is T[];
|
|
120
120
|
export type Tuple<T, N extends number> = N extends N ? (number extends N ? T[] : TupleOfHelper<T, N, []>) : never;
|
|
121
121
|
type TupleOfHelper<T, N extends number, R extends unknown[]> = R['length'] extends N ? R : TupleOfHelper<T, N, [T, ...R]>;
|
|
122
|
-
export declare function isExactLength<T, N extends number>(arr: T[], exactLength: N): arr is Tuple<T, N>;
|
|
123
|
-
export declare function isAtLeastLength<T, N extends number>(arr: T[], minimumLength: N): arr is [...Tuple<T, N>, ...T[]];
|
|
122
|
+
export declare function isExactLength<T, N extends number>(arr: readonly T[], exactLength: N): arr is Tuple<T, N>;
|
|
123
|
+
export declare function isAtLeastLength<T, N extends number>(arr: readonly T[], minimumLength: N): arr is [...Tuple<T, N>, ...T[]];
|
|
124
124
|
/**
|
|
125
125
|
* Returns true if the specified value is a tuple where the first element, T, passes the tGuard function
|
|
126
126
|
* and the second element, U, passes the uGuard function
|
|
@@ -23,6 +23,8 @@ export declare class DataConnectorActionContext {
|
|
|
23
23
|
};
|
|
24
24
|
/** Update filter type for this document */
|
|
25
25
|
updateFilterType: DataUpdateFilterType;
|
|
26
|
+
/** User timezone to ensure we properly account for any offsets */
|
|
27
|
+
timezone: string | null | undefined;
|
|
26
28
|
constructor(
|
|
27
29
|
/** The package ID of the extension that triggered this action */
|
|
28
30
|
packageId: string,
|
|
@@ -39,7 +41,9 @@ export declare class DataConnectorActionContext {
|
|
|
39
41
|
[collectionId: CollectionId]: ItemPrimaryKey[];
|
|
40
42
|
},
|
|
41
43
|
/** Update filter type for this document */
|
|
42
|
-
updateFilterType: DataUpdateFilterType
|
|
44
|
+
updateFilterType: DataUpdateFilterType,
|
|
45
|
+
/** User timezone to ensure we properly account for any offsets */
|
|
46
|
+
timezone: string | null | undefined);
|
|
43
47
|
}
|
|
44
48
|
/** Base class for actions to be performed by data connectors */
|
|
45
49
|
export declare class DataConnectorAction {
|
|
@@ -20,7 +20,9 @@ class DataConnectorActionContext {
|
|
|
20
20
|
/** Set of items this document is tracking as a `Record<CollectionId, ItemPrimaryKey[]>` */
|
|
21
21
|
documentCollections,
|
|
22
22
|
/** Update filter type for this document */
|
|
23
|
-
updateFilterType
|
|
23
|
+
updateFilterType,
|
|
24
|
+
/** User timezone to ensure we properly account for any offsets */
|
|
25
|
+
timezone) {
|
|
24
26
|
this.packageId = packageId;
|
|
25
27
|
this.packageVersion = packageVersion;
|
|
26
28
|
this.userCredential = userCredential;
|
|
@@ -28,6 +30,7 @@ class DataConnectorActionContext {
|
|
|
28
30
|
this.installationId = installationId;
|
|
29
31
|
this.documentCollections = documentCollections;
|
|
30
32
|
this.updateFilterType = updateFilterType;
|
|
33
|
+
this.timezone = timezone;
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
exports.DataConnectorActionContext = DataConnectorActionContext;
|
|
@@ -20,6 +20,7 @@ const serializedActionsBaseValidator = (0, validators_1.objectValidator)({
|
|
|
20
20
|
documentUpdateToken: (0, validators_1.nullableOption)(checks_1.isString),
|
|
21
21
|
documentCollections: (0, validators_1.objectOfValidator)((0, validators_1.arrayValidator)(checks_1.isString)),
|
|
22
22
|
updateFilterType: (0, validators_1.enumValidator)(dataupdatefiltertype_1.DataUpdateFilterType),
|
|
23
|
+
timezone: (0, validators_1.nullableOption)(checks_1.isString),
|
|
23
24
|
});
|
|
24
25
|
const serializedPatchDataValidator = (0, validators_1.objectValidator)({
|
|
25
26
|
packageVersion: checks_1.isString,
|
|
@@ -29,6 +30,7 @@ const serializedPatchDataValidator = (0, validators_1.objectValidator)({
|
|
|
29
30
|
})),
|
|
30
31
|
userCredential: checks_1.isString,
|
|
31
32
|
documentUpdateToken: checks_1.isString,
|
|
33
|
+
timezone: (0, validators_1.nullableOption)(checks_1.isString),
|
|
32
34
|
});
|
|
33
35
|
const parseSerializedPatches = (patches, patchParser) => {
|
|
34
36
|
return patches
|
|
@@ -60,7 +62,7 @@ function deserializeActions(client, actions, patchParser) {
|
|
|
60
62
|
}
|
|
61
63
|
const parsedData = data
|
|
62
64
|
.map((item) => {
|
|
63
|
-
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], item['packageVersion'], item['userCredential'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType']);
|
|
65
|
+
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], item['packageVersion'], item['userCredential'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType'], parsedActions['timezone']);
|
|
64
66
|
const patches = parseSerializedPatches(item['patches'], patchParser);
|
|
65
67
|
if (patches.length < item['patches'].length) {
|
|
66
68
|
return undefined;
|
|
@@ -74,6 +76,7 @@ function deserializeActions(client, actions, patchParser) {
|
|
|
74
76
|
}
|
|
75
77
|
return parsedData;
|
|
76
78
|
}
|
|
79
|
+
//TODO: Add a check for timezone when its made non-optional
|
|
77
80
|
if (!parsedActions['packageVersion'] || !parsedActions['userCredential']) {
|
|
78
81
|
return;
|
|
79
82
|
}
|
|
@@ -81,7 +84,7 @@ function deserializeActions(client, actions, patchParser) {
|
|
|
81
84
|
if (!serializedPatchDataValidator(data)) {
|
|
82
85
|
return;
|
|
83
86
|
}
|
|
84
|
-
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], parsedActions['packageVersion'], parsedActions['userCredential'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType']);
|
|
87
|
+
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], parsedActions['packageVersion'], parsedActions['userCredential'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType'], parsedActions['timezone']);
|
|
85
88
|
const parsedPatches = parseSerializedPatches(data['patches'], patchParser);
|
|
86
89
|
if (parsedPatches.length < data['patches'].length) {
|
|
87
90
|
console.log(`Failing validation step`);
|
|
@@ -91,7 +94,7 @@ function deserializeActions(client, actions, patchParser) {
|
|
|
91
94
|
new action_1.DataConnectorPatchAction(context, parsedPatches, client.getDataSourceClient(data['documentUpdateToken']), dataconnectoractionkeys_1.DataConnectorActionKeys.UnbatchedPatch),
|
|
92
95
|
];
|
|
93
96
|
}
|
|
94
|
-
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], parsedActions['packageVersion'], parsedActions['userCredential'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType']);
|
|
97
|
+
const context = new action_1.DataConnectorActionContext(parsedActions['packageId'], parsedActions['packageVersion'], parsedActions['userCredential'], parsedActions['dataConnectorName'], parsedActions['dataConnectorName'], parsedActions['documentCollections'], parsedActions['updateFilterType'], parsedActions['timezone']);
|
|
95
98
|
if (name == 'ManageWebhook') {
|
|
96
99
|
if (!serializedManageWebhookDataValidator(data)) {
|
|
97
100
|
return;
|