Files
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

126 lines
4.0 KiB
Plaintext

// @flow strict
import inspect from '../../jsutils/inspect';
import keyMap from '../../jsutils/keyMap';
import { GraphQLError } from '../../error/GraphQLError';
import type { ASTVisitor } from '../../language/visitor';
import type { InputValueDefinitionNode } from '../../language/ast';
import { Kind } from '../../language/kinds';
import { print } from '../../language/printer';
import { specifiedDirectives } from '../../type/directives';
import { isType, isRequiredArgument } from '../../type/definition';
import type {
ValidationContext,
SDLValidationContext,
} from '../ValidationContext';
/**
* Provided required arguments
*
* A field or directive is only valid if all required (non-null without a
* default value) field arguments have been provided.
*/
export function ProvidedRequiredArgumentsRule(
context: ValidationContext,
): ASTVisitor {
return {
// eslint-disable-next-line new-cap
...ProvidedRequiredArgumentsOnDirectivesRule(context),
Field: {
// Validate on leave to allow for deeper errors to appear first.
leave(fieldNode) {
const fieldDef = context.getFieldDef();
if (!fieldDef) {
return false;
}
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
const argNodes = fieldNode.arguments ?? [];
const argNodeMap = keyMap(argNodes, (arg) => arg.name.value);
for (const argDef of fieldDef.args) {
const argNode = argNodeMap[argDef.name];
if (!argNode && isRequiredArgument(argDef)) {
const argTypeStr = inspect(argDef.type);
context.reportError(
new GraphQLError(
`Field "${fieldDef.name}" argument "${argDef.name}" of type "${argTypeStr}" is required, but it was not provided.`,
fieldNode,
),
);
}
}
},
},
};
}
/**
* @internal
*/
export function ProvidedRequiredArgumentsOnDirectivesRule(
context: ValidationContext | SDLValidationContext,
): ASTVisitor {
const requiredArgsMap = Object.create(null);
const schema = context.getSchema();
const definedDirectives = schema
? schema.getDirectives()
: specifiedDirectives;
for (const directive of definedDirectives) {
requiredArgsMap[directive.name] = keyMap(
directive.args.filter(isRequiredArgument),
(arg) => arg.name,
);
}
const astDefinitions = context.getDocument().definitions;
for (const def of astDefinitions) {
if (def.kind === Kind.DIRECTIVE_DEFINITION) {
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
const argNodes = def.arguments ?? [];
requiredArgsMap[def.name.value] = keyMap(
argNodes.filter(isRequiredArgumentNode),
(arg) => arg.name.value,
);
}
}
return {
Directive: {
// Validate on leave to allow for deeper errors to appear first.
leave(directiveNode) {
const directiveName = directiveNode.name.value;
const requiredArgs = requiredArgsMap[directiveName];
if (requiredArgs) {
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
const argNodes = directiveNode.arguments ?? [];
const argNodeMap = keyMap(argNodes, (arg) => arg.name.value);
for (const argName of Object.keys(requiredArgs)) {
if (!argNodeMap[argName]) {
const argType = requiredArgs[argName].type;
const argTypeStr = isType(argType)
? inspect(argType)
: print(argType);
context.reportError(
new GraphQLError(
`Directive "@${directiveName}" argument "${argName}" of type "${argTypeStr}" is required, but it was not provided.`,
directiveNode,
),
);
}
}
}
},
},
};
}
function isRequiredArgumentNode(arg: InputValueDefinitionNode): boolean {
return arg.type.kind === Kind.NON_NULL_TYPE && arg.defaultValue == null;
}