appflare 0.1.12 → 0.1.13
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.
|
@@ -52,13 +52,10 @@ async function publishMutationEvents(
|
|
|
52
52
|
options,
|
|
53
53
|
subscription.authToken,
|
|
54
54
|
);
|
|
55
|
-
if (!authSession) {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
55
|
|
|
59
56
|
const subscriberCtx = await createExecutionContext(c as never, options);
|
|
60
|
-
subscriberCtx.user = authSession
|
|
61
|
-
subscriberCtx.session = authSession
|
|
57
|
+
subscriberCtx.user = authSession?.user as never;
|
|
58
|
+
subscriberCtx.session = authSession?.session as never;
|
|
62
59
|
|
|
63
60
|
try {
|
|
64
61
|
const parsedArgs = operation.schema.parse(subscription.args);
|
|
@@ -35,9 +35,7 @@ function registerRealtimeRoutes(
|
|
|
35
35
|
options,
|
|
36
36
|
authToken,
|
|
37
37
|
);
|
|
38
|
-
|
|
39
|
-
return c.json({ message: "Invalid auth token" }, 401);
|
|
40
|
-
}
|
|
38
|
+
|
|
41
39
|
|
|
42
40
|
let args: Record<string, unknown>;
|
|
43
41
|
try {
|
|
@@ -68,7 +66,7 @@ function registerRealtimeRoutes(
|
|
|
68
66
|
queryName,
|
|
69
67
|
args,
|
|
70
68
|
authToken,
|
|
71
|
-
userId: extractUserId(authSession
|
|
69
|
+
userId: extractUserId(authSession?.user),
|
|
72
70
|
createdAt: Date.now(),
|
|
73
71
|
}),
|
|
74
72
|
}),
|
|
@@ -107,9 +105,7 @@ function registerRealtimeRoutes(
|
|
|
107
105
|
options,
|
|
108
106
|
authToken,
|
|
109
107
|
);
|
|
110
|
-
|
|
111
|
-
return c.json({ message: "Invalid auth token" }, 401);
|
|
112
|
-
}
|
|
108
|
+
|
|
113
109
|
|
|
114
110
|
const stub = getRealtimeStub(c.env, options);
|
|
115
111
|
if (!stub) {
|
|
@@ -146,7 +142,7 @@ function registerRealtimeRoutes(
|
|
|
146
142
|
const token = c.req.query("token") ?? "";
|
|
147
143
|
const authToken = c.req.query("authToken") ?? "";
|
|
148
144
|
|
|
149
|
-
if (!token
|
|
145
|
+
if (!token) {
|
|
150
146
|
return c.json({ message: "token and authToken are required" }, 400);
|
|
151
147
|
}
|
|
152
148
|
|
|
@@ -156,9 +152,6 @@ function registerRealtimeRoutes(
|
|
|
156
152
|
options,
|
|
157
153
|
authToken,
|
|
158
154
|
);
|
|
159
|
-
if (!authSession) {
|
|
160
|
-
return c.json({ message: "Invalid auth token" }, 401);
|
|
161
|
-
}
|
|
162
155
|
|
|
163
156
|
const stub = getRealtimeStub(c.env, options);
|
|
164
157
|
if (!stub) {
|
|
@@ -46,6 +46,14 @@ export function generateTypesQueryRuntimeSection(): string {
|
|
|
46
46
|
? (args?.where as Record<string, unknown>)
|
|
47
47
|
: undefined;
|
|
48
48
|
const whereFilter = buildWhereFilter(table, where, tableName);
|
|
49
|
+
const passthroughArgs =
|
|
50
|
+
where !== undefined && !whereFilter
|
|
51
|
+
? (() => {
|
|
52
|
+
const nextArgs = { ...(args ?? {}) };
|
|
53
|
+
delete nextArgs.where;
|
|
54
|
+
return nextArgs;
|
|
55
|
+
})()
|
|
56
|
+
: args;
|
|
49
57
|
const withValue = args?.with;
|
|
50
58
|
const transformedWithResult =
|
|
51
59
|
withValue === undefined
|
|
@@ -57,11 +65,11 @@ export function generateTypesQueryRuntimeSection(): string {
|
|
|
57
65
|
const transformedWith = transformedWithResult.with;
|
|
58
66
|
const aggregatePlan = transformedWithResult.aggregatePlan;
|
|
59
67
|
if (!whereFilter && transformedWith === withValue && !aggregatePlan) {
|
|
60
|
-
return queryTable.findMany(
|
|
68
|
+
return queryTable.findMany(passthroughArgs);
|
|
61
69
|
}
|
|
62
70
|
|
|
63
71
|
const queryPromise = queryTable.findMany({
|
|
64
|
-
...(
|
|
72
|
+
...(passthroughArgs ?? {}),
|
|
65
73
|
...(whereFilter ? { where: () => whereFilter } : {}),
|
|
66
74
|
...(transformedWith !== undefined ? { with: transformedWith } : {}),
|
|
67
75
|
});
|
|
@@ -79,6 +87,14 @@ export function generateTypesQueryRuntimeSection(): string {
|
|
|
79
87
|
? (args?.where as Record<string, unknown>)
|
|
80
88
|
: undefined;
|
|
81
89
|
const whereFilter = buildWhereFilter(table, where, tableName);
|
|
90
|
+
const passthroughArgs =
|
|
91
|
+
where !== undefined && !whereFilter
|
|
92
|
+
? (() => {
|
|
93
|
+
const nextArgs = { ...(args ?? {}) };
|
|
94
|
+
delete nextArgs.where;
|
|
95
|
+
return nextArgs;
|
|
96
|
+
})()
|
|
97
|
+
: args;
|
|
82
98
|
const withValue = args?.with;
|
|
83
99
|
const transformedWithResult =
|
|
84
100
|
withValue === undefined
|
|
@@ -90,11 +106,11 @@ export function generateTypesQueryRuntimeSection(): string {
|
|
|
90
106
|
const transformedWith = transformedWithResult.with;
|
|
91
107
|
const aggregatePlan = transformedWithResult.aggregatePlan;
|
|
92
108
|
if (!whereFilter && transformedWith === withValue && !aggregatePlan) {
|
|
93
|
-
return queryTable.findFirst(
|
|
109
|
+
return queryTable.findFirst(passthroughArgs);
|
|
94
110
|
}
|
|
95
111
|
|
|
96
112
|
const queryPromise = queryTable.findFirst({
|
|
97
|
-
...(
|
|
113
|
+
...(passthroughArgs ?? {}),
|
|
98
114
|
...(whereFilter ? { where: () => whereFilter } : {}),
|
|
99
115
|
...(transformedWith !== undefined ? { with: transformedWith } : {}),
|
|
100
116
|
});
|