@knocklabs/node 0.6.7 → 0.6.8
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/dist/package.json
CHANGED
|
@@ -69,6 +69,9 @@ class FetchClient {
|
|
|
69
69
|
}
|
|
70
70
|
buildUrl(path, params) {
|
|
71
71
|
const url = new URL(this.config.baseURL + path);
|
|
72
|
+
function containsObject(array) {
|
|
73
|
+
return array.some((item) => typeof item === "object" && item !== null);
|
|
74
|
+
}
|
|
72
75
|
function appendParams(key, value, parentKey) {
|
|
73
76
|
const fullKey = parentKey ? `${parentKey}[${key}]` : key;
|
|
74
77
|
if (typeof value === "object" &&
|
|
@@ -80,6 +83,22 @@ class FetchClient {
|
|
|
80
83
|
appendParams(nestedKey, nestedValue, fullKey);
|
|
81
84
|
});
|
|
82
85
|
}
|
|
86
|
+
else if (Array.isArray(value) && containsObject(value)) {
|
|
87
|
+
// Send array values as individual values with identifier
|
|
88
|
+
// e.g. key[0]=user1&key[1]=userid2&key[3][field1Key]=field1Value&key[3][field2Key]=field2Value
|
|
89
|
+
value.forEach((item, index) => {
|
|
90
|
+
const indexKey = index.toString();
|
|
91
|
+
if (typeof item === "string") {
|
|
92
|
+
url.searchParams.append(`${fullKey}[${indexKey}]`, item);
|
|
93
|
+
}
|
|
94
|
+
else if (typeof item === "object" && item !== null) {
|
|
95
|
+
Object.entries(item).forEach(([key, val]) => {
|
|
96
|
+
const strVal = val;
|
|
97
|
+
url.searchParams.append(`${fullKey}[${indexKey}][${key}]`, strVal);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
83
102
|
else if (Array.isArray(value)) {
|
|
84
103
|
// Send array values as individual values instead of a comma separated list
|
|
85
104
|
// e.g. key[]=1&key[]=2&key[]=3 instead of key=1,2,3
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChannelData, CommonMetadata, SetChannelDataProperties, PaginatedEntriesResponse, ChannelType, PaginatedItemsResponse } from "../../common/interfaces";
|
|
2
2
|
import { Knock } from "../../knock";
|
|
3
|
-
import { AddObjectSubscriptionProperties, BulkAddSubscriptionsOption, BulkSetObjectOption, DeleteObjectSubscriptionProperties, ListObjectOptions, ListObjectSubscriptionsOptions, Object, ObjectSubscription, SetObjectProperties } from "./interfaces";
|
|
3
|
+
import { AddObjectSubscriptionProperties, BulkAddSubscriptionsOption, BulkSetObjectOption, DeleteObjectSubscriptionProperties, GetObjectSubscriptionsOptions, ListObjectOptions, ListObjectSubscriptionsOptions, Object, ObjectSubscription, SetObjectProperties } from "./interfaces";
|
|
4
4
|
import { BulkOperation } from "../bulk_operations/interfaces";
|
|
5
5
|
import { ListMessagesOptions, Message } from "../messages/interfaces";
|
|
6
6
|
import { ListSchedulesProps, Schedule } from "../workflows/interfaces";
|
|
@@ -29,7 +29,7 @@ export declare class Objects {
|
|
|
29
29
|
setCategoriesPreferences(collection: string, objectId: string, categoryPreferences: WorkflowPreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
30
30
|
setCategoryPreferences(collection: string, objectId: string, categoryKey: string, setting: WorkflowPreferenceSetting, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
31
31
|
listSubscriptions(collection: string, objectId: string, options?: ListObjectSubscriptionsOptions): Promise<PaginatedEntriesResponse<ObjectSubscription>>;
|
|
32
|
-
getSubscriptions(collection: string, objectId: string, options?:
|
|
32
|
+
getSubscriptions(collection: string, objectId: string, options?: GetObjectSubscriptionsOptions): Promise<PaginatedEntriesResponse<ObjectSubscription>>;
|
|
33
33
|
addSubscriptions(collection: string, objectId: string, properties?: AddObjectSubscriptionProperties): Promise<ObjectSubscription[]>;
|
|
34
34
|
deleteSubscriptions(collection: string, objectId: string, properties?: DeleteObjectSubscriptionProperties): Promise<ObjectSubscription[]>;
|
|
35
35
|
getSchedules(collection: string, objectId: string, filteringOptions?: ListSchedulesProps): Promise<PaginatedEntriesResponse<Schedule>>;
|
|
@@ -31,6 +31,10 @@ export interface ListObjectOptions extends PaginationOptions {
|
|
|
31
31
|
name?: string;
|
|
32
32
|
}
|
|
33
33
|
export interface ListObjectSubscriptionsOptions extends PaginationOptions {
|
|
34
|
+
recipients?: Recipient[];
|
|
35
|
+
}
|
|
36
|
+
export interface GetObjectSubscriptionsOptions extends PaginationOptions {
|
|
37
|
+
objects?: ObjectRef[];
|
|
34
38
|
}
|
|
35
39
|
export interface ObjectSubscription<T = CommonMetadata> {
|
|
36
40
|
recipient: User | Object;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PaginationOptions } from "../../common/interfaces";
|
|
2
|
+
import { ObjectRef } from "../objects/interfaces";
|
|
2
3
|
export interface IdentifyProperties {
|
|
3
4
|
name?: string;
|
|
4
5
|
email?: string;
|
|
@@ -31,4 +32,5 @@ export interface ListUserOptions extends PaginationOptions {
|
|
|
31
32
|
user_id?: string;
|
|
32
33
|
}
|
|
33
34
|
export interface ListSubscriptionsOptions extends PaginationOptions {
|
|
35
|
+
objects?: ObjectRef[];
|
|
34
36
|
}
|