@objectstack/plugin-auth 3.3.0 → 4.0.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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +29 -0
- package/dist/index.d.mts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +22 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/objectql-adapter.test.ts +1 -1
- package/src/objectql-adapter.ts +22 -22
- package/tsconfig.json +12 -3
package/src/objectql-adapter.ts
CHANGED
|
@@ -106,7 +106,7 @@ export function createObjectQLAdapterFactory(dataEngine: IDataEngine) {
|
|
|
106
106
|
): Promise<T | null> => {
|
|
107
107
|
const filter = convertWhere(where);
|
|
108
108
|
|
|
109
|
-
const result = await dataEngine.findOne(model, { filter, select });
|
|
109
|
+
const result = await dataEngine.findOne(model, { where: filter, fields: select });
|
|
110
110
|
|
|
111
111
|
return result ? (result as T) : null;
|
|
112
112
|
},
|
|
@@ -119,15 +119,15 @@ export function createObjectQLAdapterFactory(dataEngine: IDataEngine) {
|
|
|
119
119
|
): Promise<T[]> => {
|
|
120
120
|
const filter = where ? convertWhere(where) : {};
|
|
121
121
|
|
|
122
|
-
const
|
|
122
|
+
const orderBy = sortBy
|
|
123
123
|
? [{ field: sortBy.field, order: sortBy.direction as 'asc' | 'desc' }]
|
|
124
124
|
: undefined;
|
|
125
125
|
|
|
126
126
|
const results = await dataEngine.find(model, {
|
|
127
|
-
filter,
|
|
127
|
+
where: filter,
|
|
128
128
|
limit: limit || 100,
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
offset,
|
|
130
|
+
orderBy,
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
return results as T[];
|
|
@@ -137,7 +137,7 @@ export function createObjectQLAdapterFactory(dataEngine: IDataEngine) {
|
|
|
137
137
|
{ model, where }: { model: string; where?: CleanedWhere[] },
|
|
138
138
|
): Promise<number> => {
|
|
139
139
|
const filter = where ? convertWhere(where) : {};
|
|
140
|
-
return await dataEngine.count(model, { filter });
|
|
140
|
+
return await dataEngine.count(model, { where: filter });
|
|
141
141
|
},
|
|
142
142
|
|
|
143
143
|
update: async <T>(
|
|
@@ -146,7 +146,7 @@ export function createObjectQLAdapterFactory(dataEngine: IDataEngine) {
|
|
|
146
146
|
const filter = convertWhere(where);
|
|
147
147
|
|
|
148
148
|
// ObjectQL requires an ID for updates – find the record first
|
|
149
|
-
const record = await dataEngine.findOne(model, { filter });
|
|
149
|
+
const record = await dataEngine.findOne(model, { where: filter });
|
|
150
150
|
if (!record) return null;
|
|
151
151
|
|
|
152
152
|
const result = await dataEngine.update(model, { ...(update as any), id: record.id });
|
|
@@ -159,7 +159,7 @@ export function createObjectQLAdapterFactory(dataEngine: IDataEngine) {
|
|
|
159
159
|
const filter = convertWhere(where);
|
|
160
160
|
|
|
161
161
|
// Sequential updates: ObjectQL requires an ID per update
|
|
162
|
-
const records = await dataEngine.find(model, { filter });
|
|
162
|
+
const records = await dataEngine.find(model, { where: filter });
|
|
163
163
|
for (const record of records) {
|
|
164
164
|
await dataEngine.update(model, { ...update, id: record.id });
|
|
165
165
|
}
|
|
@@ -171,10 +171,10 @@ export function createObjectQLAdapterFactory(dataEngine: IDataEngine) {
|
|
|
171
171
|
): Promise<void> => {
|
|
172
172
|
const filter = convertWhere(where);
|
|
173
173
|
|
|
174
|
-
const record = await dataEngine.findOne(model, { filter });
|
|
174
|
+
const record = await dataEngine.findOne(model, { where: filter });
|
|
175
175
|
if (!record) return;
|
|
176
176
|
|
|
177
|
-
await dataEngine.delete(model, {
|
|
177
|
+
await dataEngine.delete(model, { where: { id: record.id } });
|
|
178
178
|
},
|
|
179
179
|
|
|
180
180
|
deleteMany: async (
|
|
@@ -182,9 +182,9 @@ export function createObjectQLAdapterFactory(dataEngine: IDataEngine) {
|
|
|
182
182
|
): Promise<number> => {
|
|
183
183
|
const filter = convertWhere(where);
|
|
184
184
|
|
|
185
|
-
const records = await dataEngine.find(model, { filter });
|
|
185
|
+
const records = await dataEngine.find(model, { where: filter });
|
|
186
186
|
for (const record of records) {
|
|
187
|
-
await dataEngine.delete(model, {
|
|
187
|
+
await dataEngine.delete(model, { where: { id: record.id } });
|
|
188
188
|
}
|
|
189
189
|
return records.length;
|
|
190
190
|
},
|
|
@@ -221,28 +221,28 @@ export function createObjectQLAdapter(dataEngine: IDataEngine) {
|
|
|
221
221
|
findOne: async <T>({ model, where, select, join: _join }: { model: string; where: CleanedWhere[]; select?: string[]; join?: any }): Promise<T | null> => {
|
|
222
222
|
const objectName = resolveProtocolName(model);
|
|
223
223
|
const filter = convertWhere(where);
|
|
224
|
-
const result = await dataEngine.findOne(objectName, { filter, select });
|
|
224
|
+
const result = await dataEngine.findOne(objectName, { where: filter, fields: select });
|
|
225
225
|
return result ? result as T : null;
|
|
226
226
|
},
|
|
227
227
|
|
|
228
228
|
findMany: async <T>({ model, where, limit, offset, sortBy, join: _join }: { model: string; where?: CleanedWhere[]; limit: number; offset?: number; sortBy?: { field: string; direction: 'asc' | 'desc' }; join?: any }): Promise<T[]> => {
|
|
229
229
|
const objectName = resolveProtocolName(model);
|
|
230
230
|
const filter = where ? convertWhere(where) : {};
|
|
231
|
-
const
|
|
232
|
-
const results = await dataEngine.find(objectName, { filter, limit: limit || 100,
|
|
231
|
+
const orderBy = sortBy ? [{ field: sortBy.field, order: sortBy.direction as 'asc' | 'desc' }] : undefined;
|
|
232
|
+
const results = await dataEngine.find(objectName, { where: filter, limit: limit || 100, offset, orderBy });
|
|
233
233
|
return results as T[];
|
|
234
234
|
},
|
|
235
235
|
|
|
236
236
|
count: async ({ model, where }: { model: string; where?: CleanedWhere[] }): Promise<number> => {
|
|
237
237
|
const objectName = resolveProtocolName(model);
|
|
238
238
|
const filter = where ? convertWhere(where) : {};
|
|
239
|
-
return await dataEngine.count(objectName, { filter });
|
|
239
|
+
return await dataEngine.count(objectName, { where: filter });
|
|
240
240
|
},
|
|
241
241
|
|
|
242
242
|
update: async <T>({ model, where, update }: { model: string; where: CleanedWhere[]; update: Record<string, any> }): Promise<T | null> => {
|
|
243
243
|
const objectName = resolveProtocolName(model);
|
|
244
244
|
const filter = convertWhere(where);
|
|
245
|
-
const record = await dataEngine.findOne(objectName, { filter });
|
|
245
|
+
const record = await dataEngine.findOne(objectName, { where: filter });
|
|
246
246
|
if (!record) return null;
|
|
247
247
|
const result = await dataEngine.update(objectName, { ...update, id: record.id });
|
|
248
248
|
return result ? result as T : null;
|
|
@@ -251,7 +251,7 @@ export function createObjectQLAdapter(dataEngine: IDataEngine) {
|
|
|
251
251
|
updateMany: async ({ model, where, update }: { model: string; where: CleanedWhere[]; update: Record<string, any> }): Promise<number> => {
|
|
252
252
|
const objectName = resolveProtocolName(model);
|
|
253
253
|
const filter = convertWhere(where);
|
|
254
|
-
const records = await dataEngine.find(objectName, { filter });
|
|
254
|
+
const records = await dataEngine.find(objectName, { where: filter });
|
|
255
255
|
for (const record of records) {
|
|
256
256
|
await dataEngine.update(objectName, { ...update, id: record.id });
|
|
257
257
|
}
|
|
@@ -261,17 +261,17 @@ export function createObjectQLAdapter(dataEngine: IDataEngine) {
|
|
|
261
261
|
delete: async ({ model, where }: { model: string; where: CleanedWhere[] }): Promise<void> => {
|
|
262
262
|
const objectName = resolveProtocolName(model);
|
|
263
263
|
const filter = convertWhere(where);
|
|
264
|
-
const record = await dataEngine.findOne(objectName, { filter });
|
|
264
|
+
const record = await dataEngine.findOne(objectName, { where: filter });
|
|
265
265
|
if (!record) return;
|
|
266
|
-
await dataEngine.delete(objectName, {
|
|
266
|
+
await dataEngine.delete(objectName, { where: { id: record.id } });
|
|
267
267
|
},
|
|
268
268
|
|
|
269
269
|
deleteMany: async ({ model, where }: { model: string; where: CleanedWhere[] }): Promise<number> => {
|
|
270
270
|
const objectName = resolveProtocolName(model);
|
|
271
271
|
const filter = convertWhere(where);
|
|
272
|
-
const records = await dataEngine.find(objectName, { filter });
|
|
272
|
+
const records = await dataEngine.find(objectName, { where: filter });
|
|
273
273
|
for (const record of records) {
|
|
274
|
-
await dataEngine.delete(objectName, {
|
|
274
|
+
await dataEngine.delete(objectName, { where: { id: record.id } });
|
|
275
275
|
}
|
|
276
276
|
return records.length;
|
|
277
277
|
},
|
package/tsconfig.json
CHANGED
|
@@ -2,8 +2,17 @@
|
|
|
2
2
|
"extends": "../../../tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"outDir": "./dist",
|
|
5
|
-
"rootDir": "./src"
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"types": [
|
|
7
|
+
"node"
|
|
8
|
+
]
|
|
6
9
|
},
|
|
7
|
-
"include": [
|
|
8
|
-
|
|
10
|
+
"include": [
|
|
11
|
+
"src/**/*"
|
|
12
|
+
],
|
|
13
|
+
"exclude": [
|
|
14
|
+
"dist",
|
|
15
|
+
"node_modules",
|
|
16
|
+
"**/*.test.ts"
|
|
17
|
+
]
|
|
9
18
|
}
|