Files
smart-city-digital-twin-mar…/smart-app-city/frontend/node_modules/graphql/validation/rules/UniqueDirectivesPerLocationRule.js.flow
Eric FELIXINE e30ae8ed09 feat(smart-app): implement complete mobile app MVP
- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
2026-06-01 18:00:35 -04:00

91 lines
2.6 KiB
Plaintext

// @flow strict
import { GraphQLError } from '../../error/GraphQLError';
import { Kind } from '../../language/kinds';
import type { ASTVisitor } from '../../language/visitor';
import {
isTypeDefinitionNode,
isTypeExtensionNode,
} from '../../language/predicates';
import { specifiedDirectives } from '../../type/directives';
import type {
SDLValidationContext,
ValidationContext,
} from '../ValidationContext';
/**
* Unique directive names per location
*
* A GraphQL document is only valid if all non-repeatable directives at
* a given location are uniquely named.
*/
export function UniqueDirectivesPerLocationRule(
context: ValidationContext | SDLValidationContext,
): ASTVisitor {
const uniqueDirectiveMap = Object.create(null);
const schema = context.getSchema();
const definedDirectives = schema
? schema.getDirectives()
: specifiedDirectives;
for (const directive of definedDirectives) {
uniqueDirectiveMap[directive.name] = !directive.isRepeatable;
}
const astDefinitions = context.getDocument().definitions;
for (const def of astDefinitions) {
if (def.kind === Kind.DIRECTIVE_DEFINITION) {
uniqueDirectiveMap[def.name.value] = !def.repeatable;
}
}
const schemaDirectives = Object.create(null);
const typeDirectivesMap = Object.create(null);
return {
// Many different AST nodes may contain directives. Rather than listing
// them all, just listen for entering any node, and check to see if it
// defines any directives.
enter(node) {
if (node.directives == null) {
return;
}
let seenDirectives;
if (
node.kind === Kind.SCHEMA_DEFINITION ||
node.kind === Kind.SCHEMA_EXTENSION
) {
seenDirectives = schemaDirectives;
} else if (isTypeDefinitionNode(node) || isTypeExtensionNode(node)) {
const typeName = node.name.value;
seenDirectives = typeDirectivesMap[typeName];
if (seenDirectives === undefined) {
typeDirectivesMap[typeName] = seenDirectives = Object.create(null);
}
} else {
seenDirectives = Object.create(null);
}
for (const directive of node.directives) {
const directiveName = directive.name.value;
if (uniqueDirectiveMap[directiveName]) {
if (seenDirectives[directiveName]) {
context.reportError(
new GraphQLError(
`The directive "@${directiveName}" can only be used once at this location.`,
[seenDirectives[directiveName], directive],
),
);
} else {
seenDirectives[directiveName] = directive;
}
}
}
},
};
}