@anton.andrusenko/shopify-mcp-admin 2.1.1 → 2.1.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/README.md +18 -8
- package/dist/chunk-DCQTHXKI.js +124 -0
- package/dist/chunk-EGGOXEIC.js +249 -0
- package/dist/chunk-QXLLD2A7.js +130 -0
- package/dist/chunk-UXI33LQD.js +208 -0
- package/dist/dashboard/assets/geist-mono-cyrillic-400-normal-BPBWmzPh.woff +0 -0
- package/dist/dashboard/assets/geist-mono-cyrillic-400-normal-Ce5q_31Z.woff2 +0 -0
- package/dist/dashboard/assets/geist-mono-latin-400-normal-CoULgQGM.woff +0 -0
- package/dist/dashboard/assets/geist-mono-latin-400-normal-LC9RFr9I.woff2 +0 -0
- package/dist/dashboard/assets/geist-mono-latin-ext-400-normal-Cgks_Qgx.woff2 +0 -0
- package/dist/dashboard/assets/geist-mono-latin-ext-400-normal-CxNRRMGd.woff +0 -0
- package/dist/dashboard/assets/geist-sans-latin-400-normal-BOaIZNA2.woff +0 -0
- package/dist/dashboard/assets/geist-sans-latin-400-normal-gapTbOY8.woff2 +0 -0
- package/dist/dashboard/assets/index-BSh6M640.js +107 -0
- package/dist/dashboard/assets/index-BSh6M640.js.map +1 -0
- package/dist/dashboard/assets/index-DLoVESj2.css +1 -0
- package/dist/dashboard/index.html +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18446 -0
- package/dist/mcp-auth-2WVQELV5.js +16 -0
- package/dist/schema-SOWYIQIV.js +38 -0
- package/dist/security-XP6MXK5B.js +98 -0
- package/dist/setup-wizard-PVLOC3DU.js +697 -0
- package/dist/store-FM7HCQVW.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {
|
|
2
|
+
log
|
|
3
|
+
} from "./chunk-QXLLD2A7.js";
|
|
4
|
+
|
|
5
|
+
// src/db/client.ts
|
|
6
|
+
import { PrismaClient } from "@prisma/client";
|
|
7
|
+
import { PrismaClient as PrismaClient2 } from "@prisma/client";
|
|
8
|
+
var prismaInstance = null;
|
|
9
|
+
function getPrismaClient() {
|
|
10
|
+
if (!prismaInstance) {
|
|
11
|
+
log.debug("Creating new Prisma client instance");
|
|
12
|
+
prismaInstance = new PrismaClient({
|
|
13
|
+
log: process.env.DEBUG === "true" ? ["query", "info", "warn", "error"] : ["error"]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return prismaInstance;
|
|
17
|
+
}
|
|
18
|
+
async function disconnectPrisma() {
|
|
19
|
+
if (prismaInstance) {
|
|
20
|
+
log.debug("Disconnecting Prisma client");
|
|
21
|
+
await prismaInstance.$disconnect();
|
|
22
|
+
prismaInstance = null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
var prisma = getPrismaClient();
|
|
26
|
+
|
|
27
|
+
// src/session/store.ts
|
|
28
|
+
var SessionStore = class {
|
|
29
|
+
cleanupInterval = null;
|
|
30
|
+
prisma = getPrismaClient();
|
|
31
|
+
SESSION_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
32
|
+
// 24 hours
|
|
33
|
+
/**
|
|
34
|
+
* Retrieve session data by session ID
|
|
35
|
+
* @param sessionId - Unique session identifier
|
|
36
|
+
* @returns SessionData if valid and not expired, null otherwise
|
|
37
|
+
*/
|
|
38
|
+
async get(sessionId) {
|
|
39
|
+
try {
|
|
40
|
+
const session = await this.prisma.tenantSession.findUnique({
|
|
41
|
+
where: { id: sessionId },
|
|
42
|
+
select: {
|
|
43
|
+
tenantId: true,
|
|
44
|
+
expiresAt: true
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (!session) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const expiresAt = session.expiresAt.getTime();
|
|
51
|
+
if (expiresAt < Date.now()) {
|
|
52
|
+
await this.prisma.tenantSession.delete({
|
|
53
|
+
where: { id: sessionId }
|
|
54
|
+
}).catch(() => {
|
|
55
|
+
});
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
tenantId: session.tenantId,
|
|
60
|
+
expiresAt
|
|
61
|
+
};
|
|
62
|
+
} catch (error) {
|
|
63
|
+
log.error("Failed to retrieve session", error instanceof Error ? error : void 0);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Store session data with automatic 24-hour expiration
|
|
69
|
+
* @param sessionId - Unique session identifier
|
|
70
|
+
* @param data - Session data (tenantId)
|
|
71
|
+
*/
|
|
72
|
+
async set(sessionId, data) {
|
|
73
|
+
const expiresAt = new Date(Date.now() + this.SESSION_TTL_MS);
|
|
74
|
+
try {
|
|
75
|
+
await this.prisma.tenantSession.upsert({
|
|
76
|
+
where: { id: sessionId },
|
|
77
|
+
update: {
|
|
78
|
+
expiresAt
|
|
79
|
+
},
|
|
80
|
+
create: {
|
|
81
|
+
id: sessionId,
|
|
82
|
+
tenantId: data.tenantId,
|
|
83
|
+
expiresAt
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
log.error("Failed to store session", error instanceof Error ? error : void 0);
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Delete a specific session
|
|
93
|
+
* @param sessionId - Session identifier to delete
|
|
94
|
+
*/
|
|
95
|
+
async delete(sessionId) {
|
|
96
|
+
try {
|
|
97
|
+
await this.prisma.tenantSession.delete({
|
|
98
|
+
where: { id: sessionId }
|
|
99
|
+
});
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (error && typeof error === "object" && "code" in error && error.code !== "P2025") {
|
|
102
|
+
log.error("Failed to delete session", error instanceof Error ? error : void 0);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Delete all sessions for a specific tenant
|
|
108
|
+
* Used when a tenant changes their password for security
|
|
109
|
+
* @param tenantId - Tenant identifier
|
|
110
|
+
*/
|
|
111
|
+
async deleteByTenantId(tenantId) {
|
|
112
|
+
try {
|
|
113
|
+
await this.prisma.tenantSession.deleteMany({
|
|
114
|
+
where: { tenantId }
|
|
115
|
+
});
|
|
116
|
+
log.debug(`Deleted all sessions for tenant ${tenantId}`);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
log.error("Failed to delete tenant sessions", error instanceof Error ? error : void 0);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Remove all expired sessions from the store
|
|
124
|
+
*/
|
|
125
|
+
async cleanup() {
|
|
126
|
+
try {
|
|
127
|
+
const result = await this.prisma.tenantSession.deleteMany({
|
|
128
|
+
where: {
|
|
129
|
+
expiresAt: {
|
|
130
|
+
lt: /* @__PURE__ */ new Date()
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
if (result.count > 0) {
|
|
135
|
+
log.debug(`Cleaned up ${result.count} expired sessions`);
|
|
136
|
+
}
|
|
137
|
+
} catch (error) {
|
|
138
|
+
log.error("Session cleanup failed", error instanceof Error ? error : void 0);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Start automatic cleanup task (runs every 10 minutes)
|
|
143
|
+
* @returns Timer handle for cleanup task
|
|
144
|
+
*/
|
|
145
|
+
startCleanup() {
|
|
146
|
+
if (this.cleanupInterval) {
|
|
147
|
+
return this.cleanupInterval;
|
|
148
|
+
}
|
|
149
|
+
this.cleanupInterval = setInterval(
|
|
150
|
+
() => {
|
|
151
|
+
this.cleanup().catch((error) => {
|
|
152
|
+
log.error("Background session cleanup error", error instanceof Error ? error : void 0);
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
10 * 60 * 1e3
|
|
156
|
+
);
|
|
157
|
+
this.cleanupInterval.unref();
|
|
158
|
+
log.info("Session cleanup background task started (runs every 10 minutes)");
|
|
159
|
+
return this.cleanupInterval;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Stop the automatic cleanup task
|
|
163
|
+
*/
|
|
164
|
+
stopCleanup() {
|
|
165
|
+
if (this.cleanupInterval) {
|
|
166
|
+
clearInterval(this.cleanupInterval);
|
|
167
|
+
this.cleanupInterval = null;
|
|
168
|
+
log.info("Session cleanup background task stopped");
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get the number of active sessions (for testing/monitoring)
|
|
173
|
+
*/
|
|
174
|
+
async size() {
|
|
175
|
+
try {
|
|
176
|
+
return await this.prisma.tenantSession.count({
|
|
177
|
+
where: {
|
|
178
|
+
expiresAt: {
|
|
179
|
+
gte: /* @__PURE__ */ new Date()
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
} catch (error) {
|
|
184
|
+
log.error("Failed to count sessions", error instanceof Error ? error : void 0);
|
|
185
|
+
return 0;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Clear all sessions (for testing)
|
|
190
|
+
*/
|
|
191
|
+
async clear() {
|
|
192
|
+
try {
|
|
193
|
+
await this.prisma.tenantSession.deleteMany();
|
|
194
|
+
} catch (error) {
|
|
195
|
+
log.error("Failed to clear sessions", error instanceof Error ? error : void 0);
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
var sessionStore = new SessionStore();
|
|
201
|
+
|
|
202
|
+
export {
|
|
203
|
+
getPrismaClient,
|
|
204
|
+
disconnectPrisma,
|
|
205
|
+
prisma,
|
|
206
|
+
SessionStore,
|
|
207
|
+
sessionStore
|
|
208
|
+
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|