naystack 1.1.11 → 1.1.12-beta.2
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/auth/email/index.cjs.js +203 -0
- package/dist/auth/email/index.d.mts +18 -0
- package/dist/auth/email/index.d.ts +18 -0
- package/dist/auth/email/index.esm.js +176 -0
- package/dist/auth/email/routes/delete.cjs.js +58 -0
- package/dist/auth/email/routes/delete.d.mts +8 -0
- package/dist/auth/email/routes/delete.d.ts +8 -0
- package/dist/auth/email/routes/delete.esm.js +31 -0
- package/dist/auth/email/routes/get.cjs.js +83 -0
- package/dist/auth/email/routes/get.d.mts +11 -0
- package/dist/auth/email/routes/get.d.ts +11 -0
- package/dist/auth/email/routes/get.esm.js +56 -0
- package/dist/auth/email/routes/post.cjs.js +149 -0
- package/dist/auth/email/routes/post.d.mts +8 -0
- package/dist/auth/email/routes/post.d.ts +8 -0
- package/dist/auth/email/routes/post.esm.js +124 -0
- package/dist/auth/email/routes/put.cjs.js +135 -0
- package/dist/auth/email/routes/put.d.mts +8 -0
- package/dist/auth/email/routes/put.d.ts +8 -0
- package/dist/auth/email/routes/put.esm.js +108 -0
- package/dist/auth/email/token.cjs.js +85 -0
- package/dist/auth/email/token.d.mts +13 -0
- package/dist/auth/email/token.d.ts +13 -0
- package/dist/auth/email/token.esm.js +56 -0
- package/dist/auth/email/types.cjs.js +18 -0
- package/dist/auth/email/types.d.mts +14 -0
- package/dist/auth/email/types.d.ts +14 -0
- package/dist/auth/email/types.esm.js +0 -0
- package/dist/auth/email/utils.cjs.js +83 -0
- package/dist/auth/email/utils.d.mts +16 -0
- package/dist/auth/email/utils.d.ts +16 -0
- package/dist/auth/email/utils.esm.js +55 -0
- package/dist/auth/index.d.mts +4 -45
- package/dist/auth/index.d.ts +4 -45
- package/dist/auth/types.cjs.js +18 -0
- package/dist/auth/types.d.mts +21 -0
- package/dist/auth/types.d.ts +21 -0
- package/dist/auth/types.esm.js +0 -0
- package/dist/auth/utils/errors.cjs.js +35 -0
- package/dist/auth/utils/errors.d.mts +6 -0
- package/dist/auth/utils/errors.d.ts +6 -0
- package/dist/auth/utils/errors.esm.js +10 -0
- package/dist/graphql/context.cjs.js +76 -0
- package/dist/graphql/context.d.mts +6 -0
- package/dist/graphql/context.d.ts +6 -0
- package/dist/graphql/context.esm.js +51 -0
- package/dist/graphql/index.cjs.js +4 -2
- package/dist/graphql/index.d.mts +8 -23
- package/dist/graphql/index.d.ts +8 -23
- package/dist/graphql/index.esm.js +4 -2
- package/dist/graphql/init.cjs.js +126 -0
- package/dist/graphql/init.d.mts +18 -0
- package/dist/graphql/init.d.ts +18 -0
- package/dist/graphql/init.esm.js +106 -0
- package/dist/graphql/types.cjs.js +18 -0
- package/dist/graphql/types.d.mts +8 -0
- package/dist/graphql/types.d.ts +8 -0
- package/dist/graphql/types.esm.js +0 -0
- package/dist/graphql/utils.cjs.js +134 -0
- package/dist/graphql/utils.d.mts +29 -0
- package/dist/graphql/utils.d.ts +29 -0
- package/dist/graphql/utils.esm.js +118 -0
- package/dist/socials/index.d.mts +9 -130
- package/dist/socials/index.d.ts +9 -130
- package/dist/socials/instagram/getters.cjs.js +119 -0
- package/dist/socials/instagram/getters.d.mts +39 -0
- package/dist/socials/instagram/getters.d.ts +39 -0
- package/dist/socials/instagram/getters.esm.js +86 -0
- package/dist/socials/instagram/setters.cjs.js +54 -0
- package/dist/socials/instagram/setters.d.mts +8 -0
- package/dist/socials/instagram/setters.d.ts +8 -0
- package/dist/socials/instagram/setters.esm.js +27 -0
- package/dist/socials/instagram/types.cjs.js +18 -0
- package/dist/socials/instagram/types.d.mts +57 -0
- package/dist/socials/instagram/types.d.ts +57 -0
- package/dist/socials/instagram/types.esm.js +0 -0
- package/dist/socials/instagram/utils.cjs.js +44 -0
- package/dist/socials/instagram/utils.d.mts +6 -0
- package/dist/socials/instagram/utils.d.ts +6 -0
- package/dist/socials/instagram/utils.esm.js +18 -0
- package/dist/socials/instagram/webhook.cjs.js +57 -0
- package/dist/socials/instagram/webhook.d.mts +12 -0
- package/dist/socials/instagram/webhook.d.ts +12 -0
- package/dist/socials/instagram/webhook.esm.js +30 -0
- package/dist/socials/meta-webhook.cjs.js +36 -0
- package/dist/socials/meta-webhook.d.mts +5 -0
- package/dist/socials/meta-webhook.d.ts +5 -0
- package/dist/socials/meta-webhook.esm.js +11 -0
- package/dist/socials/threads/getters.cjs.js +60 -0
- package/dist/socials/threads/getters.d.mts +7 -0
- package/dist/socials/threads/getters.d.ts +7 -0
- package/dist/socials/threads/getters.esm.js +31 -0
- package/dist/socials/threads/setters.cjs.js +87 -0
- package/dist/socials/threads/setters.d.mts +6 -0
- package/dist/socials/threads/setters.d.ts +6 -0
- package/dist/socials/threads/setters.esm.js +57 -0
- package/dist/socials/threads/types.cjs.js +18 -0
- package/dist/socials/threads/types.d.mts +7 -0
- package/dist/socials/threads/types.d.ts +7 -0
- package/dist/socials/threads/types.esm.js +0 -0
- package/dist/socials/threads/utils.cjs.js +39 -0
- package/dist/socials/threads/utils.d.mts +4 -0
- package/dist/socials/threads/utils.d.ts +4 -0
- package/dist/socials/threads/utils.esm.js +13 -0
- package/dist/socials/threads/webhook.cjs.js +54 -0
- package/dist/socials/threads/webhook.d.mts +12 -0
- package/dist/socials/threads/webhook.d.ts +12 -0
- package/dist/socials/threads/webhook.esm.js +27 -0
- package/package.json +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/graphql/utils.ts
|
|
13
|
+
import {
|
|
14
|
+
Arg,
|
|
15
|
+
Authorized,
|
|
16
|
+
Ctx,
|
|
17
|
+
FieldResolver,
|
|
18
|
+
Mutation,
|
|
19
|
+
Query,
|
|
20
|
+
Resolver,
|
|
21
|
+
Root
|
|
22
|
+
} from "type-graphql";
|
|
23
|
+
function query(fn, options) {
|
|
24
|
+
return { ...options, fn };
|
|
25
|
+
}
|
|
26
|
+
function field(fn, options) {
|
|
27
|
+
return { ...options, fn };
|
|
28
|
+
}
|
|
29
|
+
function QueryLibrary(queries) {
|
|
30
|
+
let GeneratedResolver = class {
|
|
31
|
+
};
|
|
32
|
+
GeneratedResolver = __decorateClass([
|
|
33
|
+
Resolver()
|
|
34
|
+
], GeneratedResolver);
|
|
35
|
+
for (const key in queries) {
|
|
36
|
+
const def = queries[key];
|
|
37
|
+
if (!def) continue;
|
|
38
|
+
Object.defineProperty(GeneratedResolver.prototype, key, {
|
|
39
|
+
// eslint-disable-next-line
|
|
40
|
+
value: async function(ctx, data) {
|
|
41
|
+
return def.fn(ctx, data);
|
|
42
|
+
},
|
|
43
|
+
writable: false
|
|
44
|
+
});
|
|
45
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
46
|
+
GeneratedResolver.prototype,
|
|
47
|
+
key
|
|
48
|
+
);
|
|
49
|
+
if (def.mutation) {
|
|
50
|
+
Mutation(() => def.output, def.outputOptions)(
|
|
51
|
+
GeneratedResolver.prototype,
|
|
52
|
+
key,
|
|
53
|
+
descriptor
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
Query(() => def.output, def.outputOptions)(
|
|
57
|
+
GeneratedResolver.prototype,
|
|
58
|
+
key,
|
|
59
|
+
descriptor
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
Ctx()(GeneratedResolver.prototype, key, 0);
|
|
63
|
+
if (def.input) {
|
|
64
|
+
Arg("input", () => def.input || String, def.inputOptions)(
|
|
65
|
+
GeneratedResolver.prototype,
|
|
66
|
+
key,
|
|
67
|
+
1
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return GeneratedResolver;
|
|
72
|
+
}
|
|
73
|
+
function FieldLibrary(type, queries) {
|
|
74
|
+
let GeneratedResolver = class {
|
|
75
|
+
};
|
|
76
|
+
GeneratedResolver = __decorateClass([
|
|
77
|
+
Resolver(() => type)
|
|
78
|
+
], GeneratedResolver);
|
|
79
|
+
for (const key in queries) {
|
|
80
|
+
const def = queries[key];
|
|
81
|
+
if (!def) continue;
|
|
82
|
+
Object.defineProperty(GeneratedResolver.prototype, key, {
|
|
83
|
+
// eslint-disable-next-line
|
|
84
|
+
value: async function(root, ctx, input) {
|
|
85
|
+
return def.fn(root, ctx, input);
|
|
86
|
+
},
|
|
87
|
+
writable: false
|
|
88
|
+
});
|
|
89
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
90
|
+
GeneratedResolver.prototype,
|
|
91
|
+
key
|
|
92
|
+
);
|
|
93
|
+
if (def.authorized) {
|
|
94
|
+
Authorized()(GeneratedResolver, key);
|
|
95
|
+
}
|
|
96
|
+
Root()(GeneratedResolver.prototype, key, 0);
|
|
97
|
+
FieldResolver(() => def.output, def.outputOptions)(
|
|
98
|
+
GeneratedResolver.prototype,
|
|
99
|
+
key,
|
|
100
|
+
descriptor
|
|
101
|
+
);
|
|
102
|
+
Ctx()(GeneratedResolver.prototype, key, 1);
|
|
103
|
+
if (def.input) {
|
|
104
|
+
Arg("input", () => def.input || String, def.inputOptions)(
|
|
105
|
+
GeneratedResolver.prototype,
|
|
106
|
+
key,
|
|
107
|
+
2
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return GeneratedResolver;
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
FieldLibrary,
|
|
115
|
+
QueryLibrary,
|
|
116
|
+
field,
|
|
117
|
+
query
|
|
118
|
+
};
|
package/dist/socials/index.d.mts
CHANGED
|
@@ -1,130 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
to: {
|
|
12
|
-
data: {
|
|
13
|
-
username: string;
|
|
14
|
-
id: string;
|
|
15
|
-
}[];
|
|
16
|
-
};
|
|
17
|
-
message: string;
|
|
18
|
-
};
|
|
19
|
-
type InstagramUser = {
|
|
20
|
-
username: string;
|
|
21
|
-
followers_count: number;
|
|
22
|
-
media_count: number;
|
|
23
|
-
};
|
|
24
|
-
type InstagramMedia = {
|
|
25
|
-
like_count?: number;
|
|
26
|
-
comments_count: number;
|
|
27
|
-
permalink: string;
|
|
28
|
-
};
|
|
29
|
-
type InstagramConversation = {
|
|
30
|
-
id: string;
|
|
31
|
-
updated_time: string;
|
|
32
|
-
messages?: {
|
|
33
|
-
data: {
|
|
34
|
-
id: string;
|
|
35
|
-
created_time: string;
|
|
36
|
-
}[];
|
|
37
|
-
paging: {
|
|
38
|
-
cursors?: {
|
|
39
|
-
after?: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
participants?: {
|
|
44
|
-
data: {
|
|
45
|
-
id: string;
|
|
46
|
-
username: string;
|
|
47
|
-
}[];
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
type InstagramError = {
|
|
51
|
-
error?: {
|
|
52
|
-
message: string;
|
|
53
|
-
type: string;
|
|
54
|
-
code: number;
|
|
55
|
-
error_subcode: number;
|
|
56
|
-
fbtrace_id: string;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
declare const getInstagramUser: <T = InstagramUser>(token: string, id?: string, fields?: string[]) => Promise<(T & InstagramError) | null>;
|
|
61
|
-
declare const getInstagramMedia: <T = InstagramMedia>(token: string, fields?: string[], limit?: number) => Promise<({
|
|
62
|
-
data: T[];
|
|
63
|
-
} & InstagramError) | null>;
|
|
64
|
-
declare const getInstagramConversations: (token: string, limit?: number, cursor?: string) => Promise<{
|
|
65
|
-
data: {
|
|
66
|
-
messages: {
|
|
67
|
-
id: string;
|
|
68
|
-
created_time: string;
|
|
69
|
-
}[] | undefined;
|
|
70
|
-
participants: {
|
|
71
|
-
id: string;
|
|
72
|
-
username: string;
|
|
73
|
-
}[] | undefined;
|
|
74
|
-
id: string;
|
|
75
|
-
updated_time: string;
|
|
76
|
-
}[] | undefined;
|
|
77
|
-
fetchMore: (() => Promise</*elided*/ any>) | undefined;
|
|
78
|
-
}>;
|
|
79
|
-
declare const getInstagramConversationsByUser: (token: string, userID: string) => Promise<({
|
|
80
|
-
data: InstagramConversation[];
|
|
81
|
-
} & InstagramError) | null>;
|
|
82
|
-
declare const getInstagramConversationByUser: (token: string, userID: string) => Promise<InstagramConversation | undefined>;
|
|
83
|
-
declare const getInstagramConversation: (token: string, id: string, cursor?: string) => Promise<{
|
|
84
|
-
messages: {
|
|
85
|
-
id: string;
|
|
86
|
-
created_time: string;
|
|
87
|
-
}[] | undefined;
|
|
88
|
-
participants: {
|
|
89
|
-
id: string;
|
|
90
|
-
username: string;
|
|
91
|
-
}[] | undefined;
|
|
92
|
-
fetchMore: (() => Promise</*elided*/ any>) | undefined;
|
|
93
|
-
}>;
|
|
94
|
-
declare const getInstagramMessage: <T = InstagramMessage>(token: string, id: string, fields?: string[]) => Promise<(T & InstagramError) | null>;
|
|
95
|
-
|
|
96
|
-
declare const sendInstagramMessage: (token: string, to: string, text: string) => Promise<({
|
|
97
|
-
recipient_id?: string;
|
|
98
|
-
message_id?: string;
|
|
99
|
-
} & InstagramError) | null>;
|
|
100
|
-
|
|
101
|
-
declare const setupInstagramWebhook: (options: {
|
|
102
|
-
secret: string;
|
|
103
|
-
callback: (type: string, value: any, id: string) => Promise<void>;
|
|
104
|
-
}) => {
|
|
105
|
-
GET: (req: NextRequest) => next_server.NextResponse<unknown> | undefined;
|
|
106
|
-
POST: (req: NextRequest) => Promise<Response>;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
type ThreadsPost = {
|
|
110
|
-
text: string;
|
|
111
|
-
permalink: string;
|
|
112
|
-
username: string;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
declare const getThread: <T = ThreadsPost>(token: string, id: string, fields?: string[]) => Promise<T | null>;
|
|
116
|
-
declare const getThreads: <T = ThreadsPost>(token: string, fields?: string[]) => Promise<T[] | undefined>;
|
|
117
|
-
declare const getThreadsReplies: <T = ThreadsPost>(token: string, id: string, fields?: string[]) => Promise<T[] | undefined>;
|
|
118
|
-
|
|
119
|
-
declare const createThreadsPost: (token: string, text: string, reply_to_id?: string) => Promise<string | null | undefined>;
|
|
120
|
-
declare const createThread: (token: string, threads: string[]) => Promise<string | undefined>;
|
|
121
|
-
|
|
122
|
-
declare const setupThreadsWebhook: (options: {
|
|
123
|
-
secret: string;
|
|
124
|
-
callback: (type: string, value: any) => Promise<boolean>;
|
|
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 };
|
|
1
|
+
export { getInstagramConversation, getInstagramConversationByUser, getInstagramConversations, getInstagramConversationsByUser, getInstagramMedia, getInstagramMessage, getInstagramUser } from './instagram/getters.mjs';
|
|
2
|
+
export { sendInstagramMessage } from './instagram/setters.mjs';
|
|
3
|
+
export { setupInstagramWebhook } from './instagram/webhook.mjs';
|
|
4
|
+
export { getThread, getThreads, getThreadsReplies } from './threads/getters.mjs';
|
|
5
|
+
export { createThread, createThreadsPost } from './threads/setters.mjs';
|
|
6
|
+
export { setupThreadsWebhook } from './threads/webhook.mjs';
|
|
7
|
+
import './instagram/types.mjs';
|
|
8
|
+
import 'next/server';
|
|
9
|
+
import './threads/types.mjs';
|
package/dist/socials/index.d.ts
CHANGED
|
@@ -1,130 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
to: {
|
|
12
|
-
data: {
|
|
13
|
-
username: string;
|
|
14
|
-
id: string;
|
|
15
|
-
}[];
|
|
16
|
-
};
|
|
17
|
-
message: string;
|
|
18
|
-
};
|
|
19
|
-
type InstagramUser = {
|
|
20
|
-
username: string;
|
|
21
|
-
followers_count: number;
|
|
22
|
-
media_count: number;
|
|
23
|
-
};
|
|
24
|
-
type InstagramMedia = {
|
|
25
|
-
like_count?: number;
|
|
26
|
-
comments_count: number;
|
|
27
|
-
permalink: string;
|
|
28
|
-
};
|
|
29
|
-
type InstagramConversation = {
|
|
30
|
-
id: string;
|
|
31
|
-
updated_time: string;
|
|
32
|
-
messages?: {
|
|
33
|
-
data: {
|
|
34
|
-
id: string;
|
|
35
|
-
created_time: string;
|
|
36
|
-
}[];
|
|
37
|
-
paging: {
|
|
38
|
-
cursors?: {
|
|
39
|
-
after?: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
participants?: {
|
|
44
|
-
data: {
|
|
45
|
-
id: string;
|
|
46
|
-
username: string;
|
|
47
|
-
}[];
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
type InstagramError = {
|
|
51
|
-
error?: {
|
|
52
|
-
message: string;
|
|
53
|
-
type: string;
|
|
54
|
-
code: number;
|
|
55
|
-
error_subcode: number;
|
|
56
|
-
fbtrace_id: string;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
declare const getInstagramUser: <T = InstagramUser>(token: string, id?: string, fields?: string[]) => Promise<(T & InstagramError) | null>;
|
|
61
|
-
declare const getInstagramMedia: <T = InstagramMedia>(token: string, fields?: string[], limit?: number) => Promise<({
|
|
62
|
-
data: T[];
|
|
63
|
-
} & InstagramError) | null>;
|
|
64
|
-
declare const getInstagramConversations: (token: string, limit?: number, cursor?: string) => Promise<{
|
|
65
|
-
data: {
|
|
66
|
-
messages: {
|
|
67
|
-
id: string;
|
|
68
|
-
created_time: string;
|
|
69
|
-
}[] | undefined;
|
|
70
|
-
participants: {
|
|
71
|
-
id: string;
|
|
72
|
-
username: string;
|
|
73
|
-
}[] | undefined;
|
|
74
|
-
id: string;
|
|
75
|
-
updated_time: string;
|
|
76
|
-
}[] | undefined;
|
|
77
|
-
fetchMore: (() => Promise</*elided*/ any>) | undefined;
|
|
78
|
-
}>;
|
|
79
|
-
declare const getInstagramConversationsByUser: (token: string, userID: string) => Promise<({
|
|
80
|
-
data: InstagramConversation[];
|
|
81
|
-
} & InstagramError) | null>;
|
|
82
|
-
declare const getInstagramConversationByUser: (token: string, userID: string) => Promise<InstagramConversation | undefined>;
|
|
83
|
-
declare const getInstagramConversation: (token: string, id: string, cursor?: string) => Promise<{
|
|
84
|
-
messages: {
|
|
85
|
-
id: string;
|
|
86
|
-
created_time: string;
|
|
87
|
-
}[] | undefined;
|
|
88
|
-
participants: {
|
|
89
|
-
id: string;
|
|
90
|
-
username: string;
|
|
91
|
-
}[] | undefined;
|
|
92
|
-
fetchMore: (() => Promise</*elided*/ any>) | undefined;
|
|
93
|
-
}>;
|
|
94
|
-
declare const getInstagramMessage: <T = InstagramMessage>(token: string, id: string, fields?: string[]) => Promise<(T & InstagramError) | null>;
|
|
95
|
-
|
|
96
|
-
declare const sendInstagramMessage: (token: string, to: string, text: string) => Promise<({
|
|
97
|
-
recipient_id?: string;
|
|
98
|
-
message_id?: string;
|
|
99
|
-
} & InstagramError) | null>;
|
|
100
|
-
|
|
101
|
-
declare const setupInstagramWebhook: (options: {
|
|
102
|
-
secret: string;
|
|
103
|
-
callback: (type: string, value: any, id: string) => Promise<void>;
|
|
104
|
-
}) => {
|
|
105
|
-
GET: (req: NextRequest) => next_server.NextResponse<unknown> | undefined;
|
|
106
|
-
POST: (req: NextRequest) => Promise<Response>;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
type ThreadsPost = {
|
|
110
|
-
text: string;
|
|
111
|
-
permalink: string;
|
|
112
|
-
username: string;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
declare const getThread: <T = ThreadsPost>(token: string, id: string, fields?: string[]) => Promise<T | null>;
|
|
116
|
-
declare const getThreads: <T = ThreadsPost>(token: string, fields?: string[]) => Promise<T[] | undefined>;
|
|
117
|
-
declare const getThreadsReplies: <T = ThreadsPost>(token: string, id: string, fields?: string[]) => Promise<T[] | undefined>;
|
|
118
|
-
|
|
119
|
-
declare const createThreadsPost: (token: string, text: string, reply_to_id?: string) => Promise<string | null | undefined>;
|
|
120
|
-
declare const createThread: (token: string, threads: string[]) => Promise<string | undefined>;
|
|
121
|
-
|
|
122
|
-
declare const setupThreadsWebhook: (options: {
|
|
123
|
-
secret: string;
|
|
124
|
-
callback: (type: string, value: any) => Promise<boolean>;
|
|
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 };
|
|
1
|
+
export { getInstagramConversation, getInstagramConversationByUser, getInstagramConversations, getInstagramConversationsByUser, getInstagramMedia, getInstagramMessage, getInstagramUser } from './instagram/getters.js';
|
|
2
|
+
export { sendInstagramMessage } from './instagram/setters.js';
|
|
3
|
+
export { setupInstagramWebhook } from './instagram/webhook.js';
|
|
4
|
+
export { getThread, getThreads, getThreadsReplies } from './threads/getters.js';
|
|
5
|
+
export { createThread, createThreadsPost } from './threads/setters.js';
|
|
6
|
+
export { setupThreadsWebhook } from './threads/webhook.js';
|
|
7
|
+
import './instagram/types.js';
|
|
8
|
+
import 'next/server';
|
|
9
|
+
import './threads/types.js';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/socials/instagram/getters.ts
|
|
21
|
+
var getters_exports = {};
|
|
22
|
+
__export(getters_exports, {
|
|
23
|
+
getInstagramConversation: () => getInstagramConversation,
|
|
24
|
+
getInstagramConversationByUser: () => getInstagramConversationByUser,
|
|
25
|
+
getInstagramConversations: () => getInstagramConversations,
|
|
26
|
+
getInstagramConversationsByUser: () => getInstagramConversationsByUser,
|
|
27
|
+
getInstagramMedia: () => getInstagramMedia,
|
|
28
|
+
getInstagramMessage: () => getInstagramMessage,
|
|
29
|
+
getInstagramUser: () => getInstagramUser
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(getters_exports);
|
|
32
|
+
|
|
33
|
+
// src/socials/instagram/utils.ts
|
|
34
|
+
function getInstagramURL(token, path, params) {
|
|
35
|
+
return `https://graph.instagram.com/v23.0/${path}?${Object.keys(params).map((key) => `${key}=${params[key]}`).join("&")}&access_token=${token}`;
|
|
36
|
+
}
|
|
37
|
+
function getInstagramData(token, path, params = {}, postData) {
|
|
38
|
+
return fetch(getInstagramURL(token, path, params), {
|
|
39
|
+
method: postData ? "POST" : "GET",
|
|
40
|
+
body: JSON.stringify(postData),
|
|
41
|
+
headers: {
|
|
42
|
+
Authorization: `Bearer ${token}`,
|
|
43
|
+
"Content-Type": "application/json"
|
|
44
|
+
}
|
|
45
|
+
}).then((res) => res.json());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/socials/instagram/getters.ts
|
|
49
|
+
var getInstagramUser = (token, id, fields) => {
|
|
50
|
+
return getInstagramData(token, id || "me", {
|
|
51
|
+
fields: fields ? fields.join(",") : "username,followers_count,media_count"
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
var getInstagramMedia = (token, fields, limit = 12) => {
|
|
55
|
+
return getInstagramData(token, "me/media", {
|
|
56
|
+
fields: fields ? fields.join(",") : "like_count,comments_count,permalink",
|
|
57
|
+
limit: limit?.toString()
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
var getInstagramConversations = async (token, limit = 25, cursor) => {
|
|
61
|
+
const result = await getInstagramData(token, "me/conversations", {
|
|
62
|
+
platform: "instagram",
|
|
63
|
+
fields: "participants,messages,updated_time",
|
|
64
|
+
limit: limit.toString(),
|
|
65
|
+
...cursor ? { after: cursor } : {}
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
data: result?.data.map((item) => ({
|
|
69
|
+
...item,
|
|
70
|
+
messages: item.messages?.data,
|
|
71
|
+
participants: item.participants?.data
|
|
72
|
+
})),
|
|
73
|
+
fetchMore: result?.paging?.cursors?.after ? () => getInstagramConversations(token, limit, result.paging.cursors?.after) : void 0
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
var getInstagramConversationsByUser = (token, userID) => {
|
|
77
|
+
return getInstagramData(
|
|
78
|
+
token,
|
|
79
|
+
"me/conversations",
|
|
80
|
+
{
|
|
81
|
+
fields: "participants,messages,updated_time",
|
|
82
|
+
user_id: userID
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
var getInstagramConversationByUser = async (token, userID) => {
|
|
87
|
+
const res = await getInstagramConversationsByUser(token, userID);
|
|
88
|
+
return res?.data?.find((item) => item.participants?.data.length === 2);
|
|
89
|
+
};
|
|
90
|
+
var getInstagramConversation = async (token, id, cursor) => {
|
|
91
|
+
const result = await getInstagramData(token, id + "", {
|
|
92
|
+
fields: "participants,messages,updated_time",
|
|
93
|
+
...cursor ? { after: cursor } : {}
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
messages: result?.messages?.data,
|
|
97
|
+
participants: result?.participants?.data,
|
|
98
|
+
fetchMore: result?.messages?.paging.cursors?.after ? () => getInstagramConversation(
|
|
99
|
+
token,
|
|
100
|
+
id,
|
|
101
|
+
result?.messages?.paging?.cursors?.after
|
|
102
|
+
) : void 0
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
var getInstagramMessage = (token, id, fields) => {
|
|
106
|
+
return getInstagramData(token, id, {
|
|
107
|
+
fields: fields ? fields.join(",") : "id,created_time,from,to,message"
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
+
0 && (module.exports = {
|
|
112
|
+
getInstagramConversation,
|
|
113
|
+
getInstagramConversationByUser,
|
|
114
|
+
getInstagramConversations,
|
|
115
|
+
getInstagramConversationsByUser,
|
|
116
|
+
getInstagramMedia,
|
|
117
|
+
getInstagramMessage,
|
|
118
|
+
getInstagramUser
|
|
119
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InstagramConversation, InstagramError, InstagramMedia, InstagramMessage, InstagramUser } from './types.mjs';
|
|
2
|
+
|
|
3
|
+
declare const getInstagramUser: <T = InstagramUser>(token: string, id?: string, fields?: string[]) => Promise<(T & InstagramError) | null>;
|
|
4
|
+
declare const getInstagramMedia: <T = InstagramMedia>(token: string, fields?: string[], limit?: number) => Promise<({
|
|
5
|
+
data: T[];
|
|
6
|
+
} & InstagramError) | null>;
|
|
7
|
+
declare const getInstagramConversations: (token: string, limit?: number, cursor?: string) => Promise<{
|
|
8
|
+
data: {
|
|
9
|
+
messages: {
|
|
10
|
+
id: string;
|
|
11
|
+
created_time: string;
|
|
12
|
+
}[] | undefined;
|
|
13
|
+
participants: {
|
|
14
|
+
id: string;
|
|
15
|
+
username: string;
|
|
16
|
+
}[] | undefined;
|
|
17
|
+
id: string;
|
|
18
|
+
updated_time: string;
|
|
19
|
+
}[] | undefined;
|
|
20
|
+
fetchMore: (() => Promise</*elided*/ any>) | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
declare const getInstagramConversationsByUser: (token: string, userID: string) => Promise<({
|
|
23
|
+
data: InstagramConversation[];
|
|
24
|
+
} & InstagramError) | null>;
|
|
25
|
+
declare const getInstagramConversationByUser: (token: string, userID: string) => Promise<InstagramConversation | undefined>;
|
|
26
|
+
declare const getInstagramConversation: (token: string, id: string, cursor?: string) => Promise<{
|
|
27
|
+
messages: {
|
|
28
|
+
id: string;
|
|
29
|
+
created_time: string;
|
|
30
|
+
}[] | undefined;
|
|
31
|
+
participants: {
|
|
32
|
+
id: string;
|
|
33
|
+
username: string;
|
|
34
|
+
}[] | undefined;
|
|
35
|
+
fetchMore: (() => Promise</*elided*/ any>) | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
declare const getInstagramMessage: <T = InstagramMessage>(token: string, id: string, fields?: string[]) => Promise<(T & InstagramError) | null>;
|
|
38
|
+
|
|
39
|
+
export { getInstagramConversation, getInstagramConversationByUser, getInstagramConversations, getInstagramConversationsByUser, getInstagramMedia, getInstagramMessage, getInstagramUser };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InstagramConversation, InstagramError, InstagramMedia, InstagramMessage, InstagramUser } from './types.js';
|
|
2
|
+
|
|
3
|
+
declare const getInstagramUser: <T = InstagramUser>(token: string, id?: string, fields?: string[]) => Promise<(T & InstagramError) | null>;
|
|
4
|
+
declare const getInstagramMedia: <T = InstagramMedia>(token: string, fields?: string[], limit?: number) => Promise<({
|
|
5
|
+
data: T[];
|
|
6
|
+
} & InstagramError) | null>;
|
|
7
|
+
declare const getInstagramConversations: (token: string, limit?: number, cursor?: string) => Promise<{
|
|
8
|
+
data: {
|
|
9
|
+
messages: {
|
|
10
|
+
id: string;
|
|
11
|
+
created_time: string;
|
|
12
|
+
}[] | undefined;
|
|
13
|
+
participants: {
|
|
14
|
+
id: string;
|
|
15
|
+
username: string;
|
|
16
|
+
}[] | undefined;
|
|
17
|
+
id: string;
|
|
18
|
+
updated_time: string;
|
|
19
|
+
}[] | undefined;
|
|
20
|
+
fetchMore: (() => Promise</*elided*/ any>) | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
declare const getInstagramConversationsByUser: (token: string, userID: string) => Promise<({
|
|
23
|
+
data: InstagramConversation[];
|
|
24
|
+
} & InstagramError) | null>;
|
|
25
|
+
declare const getInstagramConversationByUser: (token: string, userID: string) => Promise<InstagramConversation | undefined>;
|
|
26
|
+
declare const getInstagramConversation: (token: string, id: string, cursor?: string) => Promise<{
|
|
27
|
+
messages: {
|
|
28
|
+
id: string;
|
|
29
|
+
created_time: string;
|
|
30
|
+
}[] | undefined;
|
|
31
|
+
participants: {
|
|
32
|
+
id: string;
|
|
33
|
+
username: string;
|
|
34
|
+
}[] | undefined;
|
|
35
|
+
fetchMore: (() => Promise</*elided*/ any>) | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
declare const getInstagramMessage: <T = InstagramMessage>(token: string, id: string, fields?: string[]) => Promise<(T & InstagramError) | null>;
|
|
38
|
+
|
|
39
|
+
export { getInstagramConversation, getInstagramConversationByUser, getInstagramConversations, getInstagramConversationsByUser, getInstagramMedia, getInstagramMessage, getInstagramUser };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// src/socials/instagram/utils.ts
|
|
2
|
+
function getInstagramURL(token, path, params) {
|
|
3
|
+
return `https://graph.instagram.com/v23.0/${path}?${Object.keys(params).map((key) => `${key}=${params[key]}`).join("&")}&access_token=${token}`;
|
|
4
|
+
}
|
|
5
|
+
function getInstagramData(token, path, params = {}, postData) {
|
|
6
|
+
return fetch(getInstagramURL(token, path, params), {
|
|
7
|
+
method: postData ? "POST" : "GET",
|
|
8
|
+
body: JSON.stringify(postData),
|
|
9
|
+
headers: {
|
|
10
|
+
Authorization: `Bearer ${token}`,
|
|
11
|
+
"Content-Type": "application/json"
|
|
12
|
+
}
|
|
13
|
+
}).then((res) => res.json());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/socials/instagram/getters.ts
|
|
17
|
+
var getInstagramUser = (token, id, fields) => {
|
|
18
|
+
return getInstagramData(token, id || "me", {
|
|
19
|
+
fields: fields ? fields.join(",") : "username,followers_count,media_count"
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var getInstagramMedia = (token, fields, limit = 12) => {
|
|
23
|
+
return getInstagramData(token, "me/media", {
|
|
24
|
+
fields: fields ? fields.join(",") : "like_count,comments_count,permalink",
|
|
25
|
+
limit: limit?.toString()
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var getInstagramConversations = async (token, limit = 25, cursor) => {
|
|
29
|
+
const result = await getInstagramData(token, "me/conversations", {
|
|
30
|
+
platform: "instagram",
|
|
31
|
+
fields: "participants,messages,updated_time",
|
|
32
|
+
limit: limit.toString(),
|
|
33
|
+
...cursor ? { after: cursor } : {}
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
data: result?.data.map((item) => ({
|
|
37
|
+
...item,
|
|
38
|
+
messages: item.messages?.data,
|
|
39
|
+
participants: item.participants?.data
|
|
40
|
+
})),
|
|
41
|
+
fetchMore: result?.paging?.cursors?.after ? () => getInstagramConversations(token, limit, result.paging.cursors?.after) : void 0
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
var getInstagramConversationsByUser = (token, userID) => {
|
|
45
|
+
return getInstagramData(
|
|
46
|
+
token,
|
|
47
|
+
"me/conversations",
|
|
48
|
+
{
|
|
49
|
+
fields: "participants,messages,updated_time",
|
|
50
|
+
user_id: userID
|
|
51
|
+
}
|
|
52
|
+
);
|
|
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
|
+
};
|
|
58
|
+
var getInstagramConversation = async (token, id, cursor) => {
|
|
59
|
+
const result = await getInstagramData(token, id + "", {
|
|
60
|
+
fields: "participants,messages,updated_time",
|
|
61
|
+
...cursor ? { after: cursor } : {}
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
messages: result?.messages?.data,
|
|
65
|
+
participants: result?.participants?.data,
|
|
66
|
+
fetchMore: result?.messages?.paging.cursors?.after ? () => getInstagramConversation(
|
|
67
|
+
token,
|
|
68
|
+
id,
|
|
69
|
+
result?.messages?.paging?.cursors?.after
|
|
70
|
+
) : void 0
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
var getInstagramMessage = (token, id, fields) => {
|
|
74
|
+
return getInstagramData(token, id, {
|
|
75
|
+
fields: fields ? fields.join(",") : "id,created_time,from,to,message"
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
getInstagramConversation,
|
|
80
|
+
getInstagramConversationByUser,
|
|
81
|
+
getInstagramConversations,
|
|
82
|
+
getInstagramConversationsByUser,
|
|
83
|
+
getInstagramMedia,
|
|
84
|
+
getInstagramMessage,
|
|
85
|
+
getInstagramUser
|
|
86
|
+
};
|