naystack 1.1.8 → 1.1.10-beta.0
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/socials/index.cjs.js +26 -3
- package/dist/socials/index.d.mts +11 -2
- package/dist/socials/index.d.ts +11 -2
- package/dist/socials/index.esm.js +23 -2
- package/package.json +1 -1
|
@@ -25,6 +25,7 @@ __export(socials_exports, {
|
|
|
25
25
|
getInstagramConversation: () => getInstagramConversation,
|
|
26
26
|
getInstagramConversationByUser: () => getInstagramConversationByUser,
|
|
27
27
|
getInstagramConversations: () => getInstagramConversations,
|
|
28
|
+
getInstagramConversationsByUser: () => getInstagramConversationsByUser,
|
|
28
29
|
getInstagramMedia: () => getInstagramMedia,
|
|
29
30
|
getInstagramMessage: () => getInstagramMessage,
|
|
30
31
|
getInstagramUser: () => getInstagramUser,
|
|
@@ -32,7 +33,8 @@ __export(socials_exports, {
|
|
|
32
33
|
getThreads: () => getThreads,
|
|
33
34
|
getThreadsReplies: () => getThreadsReplies,
|
|
34
35
|
sendInstagramMessage: () => sendInstagramMessage,
|
|
35
|
-
setupInstagramWebhook: () => setupInstagramWebhook
|
|
36
|
+
setupInstagramWebhook: () => setupInstagramWebhook,
|
|
37
|
+
setupThreadsWebhook: () => setupThreadsWebhook
|
|
36
38
|
});
|
|
37
39
|
module.exports = __toCommonJS(socials_exports);
|
|
38
40
|
|
|
@@ -79,7 +81,7 @@ var getInstagramConversations = async (token, limit = 25, cursor) => {
|
|
|
79
81
|
fetchMore: result?.paging?.cursors?.after ? () => getInstagramConversations(token, limit, result.paging.cursors?.after) : void 0
|
|
80
82
|
};
|
|
81
83
|
};
|
|
82
|
-
var
|
|
84
|
+
var getInstagramConversationsByUser = (token, userID) => {
|
|
83
85
|
return getInstagramData(
|
|
84
86
|
token,
|
|
85
87
|
"me/conversations",
|
|
@@ -89,6 +91,10 @@ var getInstagramConversationByUser = (token, userID) => {
|
|
|
89
91
|
}
|
|
90
92
|
);
|
|
91
93
|
};
|
|
94
|
+
var getInstagramConversationByUser = async (token, userID) => {
|
|
95
|
+
const res = await getInstagramConversationsByUser(token, userID);
|
|
96
|
+
return res?.data.find((item) => item.participants?.data.length === 2);
|
|
97
|
+
};
|
|
92
98
|
var getInstagramConversation = async (token, id, cursor) => {
|
|
93
99
|
const result = await getInstagramData(token, id + "", {
|
|
94
100
|
fields: "participants,messages,updated_time",
|
|
@@ -215,6 +221,21 @@ var createThread = async (token, threads) => {
|
|
|
215
221
|
}
|
|
216
222
|
return publishedIDs[0];
|
|
217
223
|
};
|
|
224
|
+
|
|
225
|
+
// src/socials/threads/webhook.ts
|
|
226
|
+
var setupThreadsWebhook = (options) => {
|
|
227
|
+
return {
|
|
228
|
+
GET: verifyWebhook(options.secret),
|
|
229
|
+
POST: async (req) => {
|
|
230
|
+
const payload = await req.json();
|
|
231
|
+
console.warn(payload.app_id, payload.target_id, payload.subscription_id);
|
|
232
|
+
for (const { value, field } of payload.values) {
|
|
233
|
+
await options.callback(field, value);
|
|
234
|
+
}
|
|
235
|
+
return new Response("OK");
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
};
|
|
218
239
|
// Annotate the CommonJS export names for ESM import in node:
|
|
219
240
|
0 && (module.exports = {
|
|
220
241
|
createThread,
|
|
@@ -222,6 +243,7 @@ var createThread = async (token, threads) => {
|
|
|
222
243
|
getInstagramConversation,
|
|
223
244
|
getInstagramConversationByUser,
|
|
224
245
|
getInstagramConversations,
|
|
246
|
+
getInstagramConversationsByUser,
|
|
225
247
|
getInstagramMedia,
|
|
226
248
|
getInstagramMessage,
|
|
227
249
|
getInstagramUser,
|
|
@@ -229,5 +251,6 @@ var createThread = async (token, threads) => {
|
|
|
229
251
|
getThreads,
|
|
230
252
|
getThreadsReplies,
|
|
231
253
|
sendInstagramMessage,
|
|
232
|
-
setupInstagramWebhook
|
|
254
|
+
setupInstagramWebhook,
|
|
255
|
+
setupThreadsWebhook
|
|
233
256
|
});
|
package/dist/socials/index.d.mts
CHANGED
|
@@ -76,9 +76,10 @@ declare const getInstagramConversations: (token: string, limit?: number, cursor?
|
|
|
76
76
|
}[] | undefined;
|
|
77
77
|
fetchMore: (() => Promise</*elided*/ any>) | undefined;
|
|
78
78
|
}>;
|
|
79
|
-
declare const
|
|
79
|
+
declare const getInstagramConversationsByUser: (token: string, userID: string) => Promise<({
|
|
80
80
|
data: InstagramConversation[];
|
|
81
81
|
} & InstagramError) | null>;
|
|
82
|
+
declare const getInstagramConversationByUser: (token: string, userID: string) => Promise<InstagramConversation | undefined>;
|
|
82
83
|
declare const getInstagramConversation: (token: string, id: string, cursor?: string) => Promise<{
|
|
83
84
|
messages: {
|
|
84
85
|
id: string;
|
|
@@ -118,4 +119,12 @@ declare const getThreadsReplies: <T = ThreadsPost>(token: string, id: string, fi
|
|
|
118
119
|
declare const createThreadsPost: (token: string, text: string, reply_to_id?: string) => Promise<string | void | null>;
|
|
119
120
|
declare const createThread: (token: string, threads: string[]) => Promise<string | undefined>;
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
declare const setupThreadsWebhook: (options: {
|
|
123
|
+
secret: string;
|
|
124
|
+
callback: (type: string, value: any) => Promise<void>;
|
|
125
|
+
}) => {
|
|
126
|
+
GET: (req: NextRequest) => next_server.NextResponse<unknown> | undefined;
|
|
127
|
+
POST: (req: NextRequest) => Promise<Response>;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export { createThread, createThreadsPost, getInstagramConversation, getInstagramConversationByUser, getInstagramConversations, getInstagramConversationsByUser, getInstagramMedia, getInstagramMessage, getInstagramUser, getThread, getThreads, getThreadsReplies, sendInstagramMessage, setupInstagramWebhook, setupThreadsWebhook };
|
package/dist/socials/index.d.ts
CHANGED
|
@@ -76,9 +76,10 @@ declare const getInstagramConversations: (token: string, limit?: number, cursor?
|
|
|
76
76
|
}[] | undefined;
|
|
77
77
|
fetchMore: (() => Promise</*elided*/ any>) | undefined;
|
|
78
78
|
}>;
|
|
79
|
-
declare const
|
|
79
|
+
declare const getInstagramConversationsByUser: (token: string, userID: string) => Promise<({
|
|
80
80
|
data: InstagramConversation[];
|
|
81
81
|
} & InstagramError) | null>;
|
|
82
|
+
declare const getInstagramConversationByUser: (token: string, userID: string) => Promise<InstagramConversation | undefined>;
|
|
82
83
|
declare const getInstagramConversation: (token: string, id: string, cursor?: string) => Promise<{
|
|
83
84
|
messages: {
|
|
84
85
|
id: string;
|
|
@@ -118,4 +119,12 @@ declare const getThreadsReplies: <T = ThreadsPost>(token: string, id: string, fi
|
|
|
118
119
|
declare const createThreadsPost: (token: string, text: string, reply_to_id?: string) => Promise<string | void | null>;
|
|
119
120
|
declare const createThread: (token: string, threads: string[]) => Promise<string | undefined>;
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
declare const setupThreadsWebhook: (options: {
|
|
123
|
+
secret: string;
|
|
124
|
+
callback: (type: string, value: any) => Promise<void>;
|
|
125
|
+
}) => {
|
|
126
|
+
GET: (req: NextRequest) => next_server.NextResponse<unknown> | undefined;
|
|
127
|
+
POST: (req: NextRequest) => Promise<Response>;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export { createThread, createThreadsPost, getInstagramConversation, getInstagramConversationByUser, getInstagramConversations, getInstagramConversationsByUser, getInstagramMedia, getInstagramMessage, getInstagramUser, getThread, getThreads, getThreadsReplies, sendInstagramMessage, setupInstagramWebhook, setupThreadsWebhook };
|
|
@@ -41,7 +41,7 @@ var getInstagramConversations = async (token, limit = 25, cursor) => {
|
|
|
41
41
|
fetchMore: result?.paging?.cursors?.after ? () => getInstagramConversations(token, limit, result.paging.cursors?.after) : void 0
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
-
var
|
|
44
|
+
var getInstagramConversationsByUser = (token, userID) => {
|
|
45
45
|
return getInstagramData(
|
|
46
46
|
token,
|
|
47
47
|
"me/conversations",
|
|
@@ -51,6 +51,10 @@ var getInstagramConversationByUser = (token, userID) => {
|
|
|
51
51
|
}
|
|
52
52
|
);
|
|
53
53
|
};
|
|
54
|
+
var getInstagramConversationByUser = async (token, userID) => {
|
|
55
|
+
const res = await getInstagramConversationsByUser(token, userID);
|
|
56
|
+
return res?.data.find((item) => item.participants?.data.length === 2);
|
|
57
|
+
};
|
|
54
58
|
var getInstagramConversation = async (token, id, cursor) => {
|
|
55
59
|
const result = await getInstagramData(token, id + "", {
|
|
56
60
|
fields: "participants,messages,updated_time",
|
|
@@ -177,12 +181,28 @@ var createThread = async (token, threads) => {
|
|
|
177
181
|
}
|
|
178
182
|
return publishedIDs[0];
|
|
179
183
|
};
|
|
184
|
+
|
|
185
|
+
// src/socials/threads/webhook.ts
|
|
186
|
+
var setupThreadsWebhook = (options) => {
|
|
187
|
+
return {
|
|
188
|
+
GET: verifyWebhook(options.secret),
|
|
189
|
+
POST: async (req) => {
|
|
190
|
+
const payload = await req.json();
|
|
191
|
+
console.warn(payload.app_id, payload.target_id, payload.subscription_id);
|
|
192
|
+
for (const { value, field } of payload.values) {
|
|
193
|
+
await options.callback(field, value);
|
|
194
|
+
}
|
|
195
|
+
return new Response("OK");
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
};
|
|
180
199
|
export {
|
|
181
200
|
createThread,
|
|
182
201
|
createThreadsPost,
|
|
183
202
|
getInstagramConversation,
|
|
184
203
|
getInstagramConversationByUser,
|
|
185
204
|
getInstagramConversations,
|
|
205
|
+
getInstagramConversationsByUser,
|
|
186
206
|
getInstagramMedia,
|
|
187
207
|
getInstagramMessage,
|
|
188
208
|
getInstagramUser,
|
|
@@ -190,5 +210,6 @@ export {
|
|
|
190
210
|
getThreads,
|
|
191
211
|
getThreadsReplies,
|
|
192
212
|
sendInstagramMessage,
|
|
193
|
-
setupInstagramWebhook
|
|
213
|
+
setupInstagramWebhook,
|
|
214
|
+
setupThreadsWebhook
|
|
194
215
|
};
|