Add `pipe queries`, which lists every Firestore query a project can issue: scope, collection, path pattern, filters with operators and value types, composites, orderBy, limit, cursors, realtime, aggregation, in-loop, plus a confidence and the reasons it is not exact. Receivers are matched by static type and cloud_firestore library URI, never by name. Queries are followed through chains, local variables (flow-insensitive with two cuts), fields, getters and one level of helper methods with arguments bound. An --adapter-config (YAML or JSON) maps declarative query APIs such as a server-side gateway onto the same schema. Inventory only: no rules, findings or baseline changes. Every emitted name is validated against a safe character set so no source text reaches the output.
72 lines
1.9 KiB
Dart
72 lines
1.9 KiB
Dart
import 'data/gateway.dart';
|
|
|
|
/// Call sites of the declarative gateway, resolved through adapters.json.
|
|
class ScheduledJobs {
|
|
ScheduledJobs(this.gateway);
|
|
|
|
final Gateway gateway;
|
|
|
|
Future<void> reconcile(List<String> statuses) async {
|
|
await gateway.queryCollectionGroup(
|
|
'settlements',
|
|
inFilter: WhereIn('status', statuses),
|
|
limit: 200,
|
|
);
|
|
}
|
|
|
|
Future<void> digest(String userId, DateTime from, DateTime to) async {
|
|
await gateway.queryCollection(
|
|
'notifications',
|
|
filters: [
|
|
WhereEquals('userId', userId),
|
|
const WhereEquals('isRead', false),
|
|
],
|
|
ranges: [WhereRange('createdAt', gte: from, lt: to)],
|
|
orderBy: const [OrderBy('createdAt', descending: true)],
|
|
);
|
|
}
|
|
|
|
Future<void> followers(
|
|
String authorId, String? cursor, bool onlyActive) async {
|
|
final filters = <WhereEquals>[];
|
|
if (onlyActive) {
|
|
filters.add(const WhereEquals('active', true));
|
|
}
|
|
await gateway.queryCollection(
|
|
'users',
|
|
filters: filters,
|
|
arrayContains: WhereArrayContains('following', authorId),
|
|
orderBy: const [OrderBy('__name__')],
|
|
startAfterId: cursor,
|
|
limit: 500,
|
|
);
|
|
}
|
|
|
|
Future<void> storeScoped(String storeId, int threshold) async {
|
|
await gateway.queryCollection(
|
|
'stores/$storeId/payouts',
|
|
ranges: [WhereCmp('amount', Cmp.greaterThan, threshold)],
|
|
);
|
|
}
|
|
|
|
Future<void> confirm(String token) async {
|
|
await gateway.runTransaction((txn) async {
|
|
return txn.queryCollection(
|
|
'confirmations',
|
|
filters: [WhereEquals('token', token)],
|
|
limit: 1,
|
|
);
|
|
});
|
|
}
|
|
|
|
Future<void> concrete(InMemoryGateway memory, List<String> ids) async {
|
|
for (final id in ids) {
|
|
await memory
|
|
.queryCollection('carts', filters: [WhereEquals('owner', id)]);
|
|
}
|
|
}
|
|
|
|
Future<void> notAQuery(String path) async {
|
|
await gateway.getDocument(path);
|
|
}
|
|
}
|