@adaptic/backend 0.0.1056 → 0.0.1058
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/Account.cjs +14 -0
- package/AccountLinkingRequest.cjs +14 -0
- package/AccountRiskMetrics.cjs +11 -0
- package/AdaConversation.cjs +14 -0
- package/Alert.cjs +11 -0
- package/Allocation.cjs +11 -0
- package/AlpacaAccount.cjs +36 -0
- package/Authenticator.cjs +14 -0
- package/AutoFollowRule.cjs +14 -0
- package/BrokerageAccount.cjs +11 -0
- package/Customer.cjs +14 -0
- package/DeskDecision.cjs +11 -0
- package/FeatureFlagOverride.cjs +14 -0
- package/Follow.cjs +14 -0
- package/Fund.cjs +56 -0
- package/FundAssignment.cjs +14 -0
- package/Investor.cjs +14 -0
- package/LinkedProvider.cjs +14 -0
- package/LlmConfiguration.cjs +14 -0
- package/Mandate.cjs +14 -0
- package/MandateApproval.cjs +14 -0
- package/MandateVersion.cjs +14 -0
- package/NotificationDelivery.cjs +14 -0
- package/NotificationPreference.cjs +14 -0
- package/OrgMembership.cjs +14 -0
- package/PolicyOverlay.cjs +64 -0
- package/PushSubscription.cjs +14 -0
- package/RiskEscalationEvent.cjs +33 -0
- package/Session.cjs +14 -0
- package/Strategy.cjs +28 -0
- package/StrategyHealthSnapshot.cjs +11 -0
- package/StrategySubscription.cjs +11 -0
- package/TradingPolicy.cjs +6 -0
- package/User.cjs +11 -0
- package/UserTotp.cjs +14 -0
- package/WaitlistEntry.cjs +14 -0
- package/auth/authorization-map.cjs +306 -0
- package/auth/authorization-map.d.ts +143 -0
- package/auth/cortex-auth-checker.cjs +172 -0
- package/auth/cortex-auth-checker.d.ts +114 -0
- package/auth/credential-fields.cjs +51 -0
- package/auth/credential-fields.d.ts +19 -0
- package/auth/credential-redaction.cjs +134 -0
- package/auth/credential-redaction.d.ts +60 -0
- package/auth/graphql-auth-shadow.cjs +317 -0
- package/auth/graphql-auth-shadow.d.ts +194 -0
- package/auth/membership-write-authority.cjs +131 -0
- package/auth/membership-write-authority.d.ts +110 -0
- package/auth/mutation-authorization.cjs +376 -0
- package/auth/mutation-authorization.d.ts +261 -0
- package/auth/nested-write-inspector.cjs +189 -0
- package/auth/nested-write-inspector.d.ts +94 -0
- package/auth/nested-write-policy.cjs +189 -0
- package/auth/nested-write-policy.d.ts +99 -0
- package/auth/service-token.cjs +316 -0
- package/auth/service-token.d.ts +94 -0
- package/auth/tenancy-scope.cjs +736 -0
- package/auth/tenancy-scope.d.ts +347 -0
- package/auth/token-verifier.cjs +451 -0
- package/auth/token-verifier.d.ts +153 -0
- package/auth/totp.cjs +265 -0
- package/auth/totp.d.ts +111 -0
- package/auth/user-write-content.cjs +116 -0
- package/auth/user-write-content.d.ts +47 -0
- package/auth/ws-auth-context.cjs +75 -0
- package/auth/ws-auth-context.d.ts +69 -0
- package/config/jwtConfig.cjs +52 -0
- package/config/jwtConfig.d.ts +16 -0
- package/config/metrics.cjs +356 -0
- package/config/metrics.d.ts +128 -0
- package/config/persisted-queries.cjs +122 -0
- package/config/persisted-queries.d.ts +40 -0
- package/config/server-only-models.cjs +166 -0
- package/config/server-only-models.d.ts +89 -0
- package/config/tracing.d.ts +24 -0
- package/esm/Account.mjs +14 -0
- package/esm/AccountLinkingRequest.mjs +14 -0
- package/esm/AccountRiskMetrics.mjs +11 -0
- package/esm/AdaConversation.mjs +14 -0
- package/esm/Alert.mjs +11 -0
- package/esm/Allocation.mjs +11 -0
- package/esm/AlpacaAccount.mjs +36 -0
- package/esm/Authenticator.mjs +14 -0
- package/esm/AutoFollowRule.mjs +14 -0
- package/esm/BrokerageAccount.mjs +11 -0
- package/esm/Customer.mjs +14 -0
- package/esm/DeskDecision.mjs +11 -0
- package/esm/FeatureFlagOverride.mjs +14 -0
- package/esm/Follow.mjs +14 -0
- package/esm/Fund.mjs +56 -0
- package/esm/FundAssignment.mjs +14 -0
- package/esm/Investor.mjs +14 -0
- package/esm/LinkedProvider.mjs +14 -0
- package/esm/LlmConfiguration.mjs +14 -0
- package/esm/Mandate.mjs +14 -0
- package/esm/MandateApproval.mjs +14 -0
- package/esm/MandateVersion.mjs +14 -0
- package/esm/NotificationDelivery.mjs +14 -0
- package/esm/NotificationPreference.mjs +14 -0
- package/esm/OrgMembership.mjs +14 -0
- package/esm/PolicyOverlay.mjs +64 -0
- package/esm/PushSubscription.mjs +14 -0
- package/esm/RiskEscalationEvent.mjs +33 -0
- package/esm/Session.mjs +14 -0
- package/esm/Strategy.mjs +28 -0
- package/esm/StrategyHealthSnapshot.mjs +11 -0
- package/esm/StrategySubscription.mjs +11 -0
- package/esm/TradingPolicy.mjs +6 -0
- package/esm/User.mjs +11 -0
- package/esm/UserTotp.mjs +14 -0
- package/esm/WaitlistEntry.mjs +14 -0
- package/esm/generated/typeStrings/PolicyOverlay.d.ts +1 -1
- package/esm/generated/typeStrings/PolicyOverlay.mjs +18 -0
- package/esm/generated/typeStrings/TradingPolicy.d.ts +1 -1
- package/esm/generated/typeStrings/TradingPolicy.mjs +18 -0
- package/esm/generated/typeStrings/index.d.ts +2 -2
- package/esm/generated/typegraphql-prisma/enhance.mjs +18 -18
- package/esm/generated/typegraphql-prisma/enums/TradingPolicyScalarFieldEnum.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/enums/TradingPolicyScalarFieldEnum.mjs +1 -0
- package/esm/generated/typegraphql-prisma/models/TradingPolicy.d.ts +20 -0
- package/esm/generated/typegraphql-prisma/models/TradingPolicy.mjs +27 -0
- package/esm/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindFirstTradingPolicyArgs.d.ts +1 -1
- package/esm/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindFirstTradingPolicyOrThrowArgs.d.ts +1 -1
- package/esm/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindManyTradingPolicyArgs.d.ts +1 -1
- package/esm/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/GroupByTradingPolicyArgs.d.ts +1 -1
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCountOrderByAggregateInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCountOrderByAggregateInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateManyInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateManyInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutAlpacaAccountInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutAlpacaAccountInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutOverlaysInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutOverlaysInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithAggregationInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithAggregationInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithRelationInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithRelationInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyScalarWhereWithAggregatesInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyScalarWhereWithAggregatesInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateManyMutationInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateManyMutationInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutAlpacaAccountInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutAlpacaAccountInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutOverlaysInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutOverlaysInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereUniqueInput.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereUniqueInput.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnTradingPolicy.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnTradingPolicy.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyCountAggregate.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyCountAggregate.mjs +7 -0
- package/esm/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyGroupBy.d.ts +1 -0
- package/esm/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyGroupBy.mjs +7 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.mjs +2 -0
- package/esm/middleware/mutation-account-facts.d.ts +3 -0
- package/esm/middleware/mutation-account-facts.mjs +2 -0
- package/esm/middleware/trading-policy-audit.d.ts +16 -4
- package/esm/middleware/trading-policy-audit.mjs +40 -11
- package/esm/readers/index.d.ts +10 -0
- package/esm/readers/index.mjs +10 -0
- package/esm/readers/intraday-lane-prefs.d.ts +45 -0
- package/esm/readers/intraday-lane-prefs.mjs +71 -0
- package/esm/tests/trading-policy-lane-fields-roundtrip.harness.d.ts +14 -0
- package/esm/tests/trading-policy-lane-fields-roundtrip.harness.mjs +107 -0
- package/generated/typeStrings/PolicyOverlay.cjs +18 -0
- package/generated/typeStrings/PolicyOverlay.d.ts +1 -1
- package/generated/typeStrings/TradingPolicy.cjs +18 -0
- package/generated/typeStrings/TradingPolicy.d.ts +1 -1
- package/generated/typeStrings/index.d.ts +2 -2
- package/generated/typegraphql-prisma/enhance.cjs +21 -21
- package/generated/typegraphql-prisma/enums/TradingPolicyScalarFieldEnum.cjs +1 -0
- package/generated/typegraphql-prisma/enums/TradingPolicyScalarFieldEnum.d.ts +1 -0
- package/generated/typegraphql-prisma/index.cjs +6 -6
- package/generated/typegraphql-prisma/models/TradingPolicy.cjs +7 -0
- package/generated/typegraphql-prisma/models/TradingPolicy.d.ts +20 -0
- package/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindFirstTradingPolicyArgs.d.ts +1 -1
- package/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindFirstTradingPolicyOrThrowArgs.d.ts +1 -1
- package/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindManyTradingPolicyArgs.d.ts +1 -1
- package/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/GroupByTradingPolicyArgs.d.ts +1 -1
- package/generated/typegraphql-prisma/resolvers/crud/args.index.cjs +95 -95
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCountOrderByAggregateInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCountOrderByAggregateInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateManyInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateManyInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutAlpacaAccountInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutAlpacaAccountInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutOverlaysInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutOverlaysInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithAggregationInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithAggregationInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithRelationInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithRelationInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyScalarWhereWithAggregatesInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyScalarWhereWithAggregatesInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateManyMutationInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateManyMutationInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutAlpacaAccountInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutAlpacaAccountInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutOverlaysInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutOverlaysInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereUniqueInput.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereUniqueInput.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnTradingPolicy.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnTradingPolicy.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyCountAggregate.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyCountAggregate.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyGroupBy.cjs +6 -0
- package/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyGroupBy.d.ts +1 -0
- package/generated/typegraphql-prisma/resolvers/outputs/index.cjs +1 -1
- package/generated/typegraphql-prisma/resolvers/relations/args.index.cjs +32 -32
- package/index.cjs +2 -0
- package/index.d.ts +1 -0
- package/middleware/audit-log-write-redaction.cjs +143 -0
- package/middleware/audit-log-write-redaction.d.ts +82 -0
- package/middleware/audit-logger.cjs +378 -0
- package/middleware/audit-logger.d.ts +158 -0
- package/middleware/audit-payload-guard.cjs +107 -0
- package/middleware/audit-payload-guard.d.ts +85 -0
- package/middleware/auth.cjs +66 -0
- package/middleware/auth.d.ts +41 -0
- package/middleware/credential-field-guard.cjs +514 -0
- package/middleware/credential-field-guard.d.ts +173 -0
- package/middleware/generated-type-names.cjs +77 -0
- package/middleware/generated-type-names.d.ts +44 -0
- package/middleware/graphql-validation-plugin.cjs +310 -0
- package/middleware/graphql-validation-plugin.d.ts +98 -0
- package/middleware/guard-log-throttle.cjs +89 -0
- package/middleware/guard-log-throttle.d.ts +80 -0
- package/middleware/index.cjs +57 -0
- package/middleware/index.d.ts +14 -0
- package/middleware/input-validator.cjs +220 -0
- package/middleware/input-validator.d.ts +63 -0
- package/middleware/mandate-version-validation.cjs +131 -0
- package/middleware/mandate-version-validation.d.ts +41 -0
- package/middleware/mutation-account-facts.cjs +223 -0
- package/middleware/mutation-account-facts.d.ts +143 -0
- package/middleware/mutation-auth-guard.cjs +536 -0
- package/middleware/mutation-auth-guard.d.ts +100 -0
- package/middleware/mutation-membership-facts.cjs +276 -0
- package/middleware/mutation-membership-facts.d.ts +133 -0
- package/middleware/mutation-tenant-facts.cjs +132 -0
- package/middleware/mutation-tenant-facts.d.ts +81 -0
- package/middleware/query-complexity.cjs +182 -0
- package/middleware/query-complexity.d.ts +56 -0
- package/middleware/rate-limiter.cjs +223 -0
- package/middleware/rate-limiter.d.ts +93 -0
- package/middleware/rate-tier.cjs +111 -0
- package/middleware/rate-tier.d.ts +56 -0
- package/middleware/soft-delete.cjs +175 -0
- package/middleware/soft-delete.d.ts +146 -0
- package/middleware/tenancy-scoping.cjs +229 -0
- package/middleware/tenancy-scoping.d.ts +67 -0
- package/middleware/trading-policy-audit.cjs +353 -0
- package/middleware/trading-policy-audit.d.ts +184 -0
- package/middleware/types.cjs +17 -0
- package/middleware/types.d.ts +87 -0
- package/middleware/validation-examples.cjs +398 -0
- package/middleware/validation-examples.d.ts +76 -0
- package/package.json +10 -2
- package/readers/index.cjs +15 -0
- package/readers/index.d.ts +10 -0
- package/readers/intraday-lane-prefs.cjs +76 -0
- package/readers/intraday-lane-prefs.d.ts +45 -0
- package/esm/config/__tests__/server-only-surface.harness.d.ts +0 -12
- package/esm/config/__tests__/server-only-surface.harness.mjs +0 -41
- package/esm/middleware/__tests__/audit-log-write-redaction.harness.d.ts +0 -144
- package/esm/middleware/__tests__/audit-log-write-redaction.harness.mjs +0 -920
- package/esm/middleware/__tests__/credential-field-coverage.harness.d.ts +0 -55
- package/esm/middleware/__tests__/credential-field-coverage.harness.mjs +0 -440
- package/esm/middleware/__tests__/credential-field-guard.harness.d.ts +0 -34
- package/esm/middleware/__tests__/credential-field-guard.harness.mjs +0 -212
- package/esm/middleware/__tests__/mutation-auth-guard.harness.d.ts +0 -56
- package/esm/middleware/__tests__/mutation-auth-guard.harness.mjs +0 -570
- package/esm/middleware/__tests__/rate-limit-test-utils.d.ts +0 -60
- package/esm/middleware/__tests__/rate-limit-test-utils.mjs +0 -85
- package/esm/middleware/__tests__/ts-node-harness.d.ts +0 -10
- package/esm/middleware/__tests__/ts-node-harness.mjs +0 -71
- package/health.cjs +0 -274
- package/server.cjs +0 -607
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ApolloServerPlugin } from '@apollo/server';
|
|
2
|
+
/**
|
|
3
|
+
* Validation execution mode for the GraphQL mutation-input plugin.
|
|
4
|
+
*
|
|
5
|
+
* - `scoped` (default) — validates ONLY top-level scalar input fields of each
|
|
6
|
+
* mutation variable (unwrapping single-key Prisma atomic `{ set: <scalar> }`
|
|
7
|
+
* update wrappers). Nested objects — relation create/connect inputs and
|
|
8
|
+
* opaque Json audit columns such as `effectivePolicySnapshot` — are engine-
|
|
9
|
+
* or Prisma-validated payloads, not user input, and are never recursed into.
|
|
10
|
+
* Range rules apply only to fields whose schema domain is genuinely bounded.
|
|
11
|
+
* - `legacy` — the pre-2026-07 behavior: name-pattern heuristics applied
|
|
12
|
+
* recursively to every nested non-array object of every mutation variable.
|
|
13
|
+
* Retained solely as an operational rollback lever.
|
|
14
|
+
* - `off` — disables mutation-input validation entirely (kill switch).
|
|
15
|
+
*/
|
|
16
|
+
export type ValidationMode = 'scoped' | 'legacy' | 'off';
|
|
17
|
+
/**
|
|
18
|
+
* Environment variable controlling the plugin mode. Accepted values:
|
|
19
|
+
* `scoped` | `legacy` | `off`. Unset or unrecognized values resolve to
|
|
20
|
+
* `scoped`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const VALIDATION_MODE_ENV_VAR = "GRAPHQL_VALIDATION_MODE";
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the active validation mode from the environment.
|
|
25
|
+
*
|
|
26
|
+
* @returns The configured {@link ValidationMode}, defaulting to `scoped`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveValidationMode(): ValidationMode;
|
|
29
|
+
/**
|
|
30
|
+
* Exact schema field names whose domain is genuinely a bounded share-of-a-whole
|
|
31
|
+
* percentage in `[0, 100]`.
|
|
32
|
+
*
|
|
33
|
+
* This is intentionally an explicit allowlist rather than a `/.*Pct$/` name
|
|
34
|
+
* pattern: many `*Pct` / `*Percent` fields in the Prisma schema are NOT
|
|
35
|
+
* bounded percentages — `maxGrossExposurePct` / `maxNetExposurePct` are
|
|
36
|
+
* leverage-denominated (200 = 2x gross is a legitimate production value) and
|
|
37
|
+
* PnL/return/drawdown fields (`dailyPnlPct`, `netReturnPct`, `changePercent`,
|
|
38
|
+
* `peakToTroughPct`, …) are signed. A blanket 0-100 rule on the name pattern
|
|
39
|
+
* rejected 100% of AccountDecisionRecord writes embedding a leverage policy
|
|
40
|
+
* snapshot (TM-01, 2026-07-01).
|
|
41
|
+
*/
|
|
42
|
+
export declare const BOUNDED_PERCENTAGE_FIELDS: ReadonlySet<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Lower-cased field names that must be non-empty strings when present as
|
|
45
|
+
* top-level scalar inputs.
|
|
46
|
+
*/
|
|
47
|
+
export declare const REQUIRED_NON_EMPTY_STRING_FIELDS: ReadonlySet<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Lower-cased field names that must be strictly positive numbers when present
|
|
50
|
+
* as top-level scalar inputs. Note: `*Threshold` fields are deliberately NOT
|
|
51
|
+
* validated — thresholds are legitimately signed (e.g. reversal-blackout and
|
|
52
|
+
* drawdown-breach thresholds are negative).
|
|
53
|
+
*/
|
|
54
|
+
export declare const POSITIVE_NUMBER_FIELDS: ReadonlySet<string>;
|
|
55
|
+
/**
|
|
56
|
+
* Field validation rules mapped by field name patterns (legacy mode only).
|
|
57
|
+
*/
|
|
58
|
+
interface FieldValidationRule {
|
|
59
|
+
pattern: RegExp;
|
|
60
|
+
validator: (value: unknown, fieldName: string) => void;
|
|
61
|
+
description: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Legacy name-pattern validation rules. Preserved verbatim for the `legacy`
|
|
65
|
+
* rollback mode; the default `scoped` mode does NOT use these (the `.*Pct$`,
|
|
66
|
+
* `.*Percent$`, and `.*Threshold$` heuristics reject legitimate leverage-
|
|
67
|
+
* denominated and signed values).
|
|
68
|
+
*/
|
|
69
|
+
declare const VALIDATION_RULES: FieldValidationRule[];
|
|
70
|
+
/**
|
|
71
|
+
* Apollo Server plugin that validates GraphQL mutation inputs before they
|
|
72
|
+
* reach the resolver.
|
|
73
|
+
*
|
|
74
|
+
* The active {@link ValidationMode} is resolved from the
|
|
75
|
+
* `GRAPHQL_VALIDATION_MODE` environment variable at request time (defaulting
|
|
76
|
+
* to `scoped`) unless an explicit `modeOverride` is supplied.
|
|
77
|
+
*
|
|
78
|
+
* @param modeOverride - Optional fixed mode, primarily for tests; when
|
|
79
|
+
* omitted the mode is re-resolved from the environment on each request so
|
|
80
|
+
* the toggle can be flipped without code changes.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const server = new ApolloServer({
|
|
85
|
+
* schema,
|
|
86
|
+
* plugins: [
|
|
87
|
+
* ApolloServerPluginDrainHttpServer({ httpServer }),
|
|
88
|
+
* createValidationPlugin(),
|
|
89
|
+
* ],
|
|
90
|
+
* });
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function createValidationPlugin(modeOverride?: ValidationMode): ApolloServerPlugin;
|
|
94
|
+
/**
|
|
95
|
+
* Export legacy validation rules for testing and documentation.
|
|
96
|
+
*/
|
|
97
|
+
export { VALIDATION_RULES };
|
|
98
|
+
//# sourceMappingURL=graphql-validation-plugin.d.ts.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bounded once-per-window throttle for guard decision log lines.
|
|
4
|
+
*
|
|
5
|
+
* A guard that logs every refused or would-refuse access floods the log for a
|
|
6
|
+
* caller that repeats one query all day, so each distinct caller key is logged
|
|
7
|
+
* once per window. The key has to carry caller-supplied values (operation
|
|
8
|
+
* name, user agent, `X-Forwarded-For`) because those are what tell two callers
|
|
9
|
+
* behind one edge address apart. That makes the key space caller-controlled:
|
|
10
|
+
* a caller rotating any of those values mints a new key per request. An
|
|
11
|
+
* unbounded map then grows until something clears it, and clearing a shared
|
|
12
|
+
* map on size is worse than growth — one caller's rotation erases every other
|
|
13
|
+
* caller's throttle state, so the flood re-logs everyone.
|
|
14
|
+
*
|
|
15
|
+
* So keys are counted per SCOPE — the principal kind plus the address this
|
|
16
|
+
* process accepted the connection from, neither of which the caller can set in
|
|
17
|
+
* a header — and each scope gets a fixed budget of distinct keys per window.
|
|
18
|
+
* The first key past the budget yields one overflow notice for that scope;
|
|
19
|
+
* later ones are dropped until the window ends. A caller rotating headers can
|
|
20
|
+
* therefore spend its own scope's budget and nothing else: other scopes keep
|
|
21
|
+
* their state, and the log volume per window is bounded by
|
|
22
|
+
* `(maxScopes + 1) * (keysPerScope + 1)` whatever the caller sends. Scopes are
|
|
23
|
+
* capped as well, because the connection address becomes caller-influenced if
|
|
24
|
+
* `trust proxy` is ever widened; scopes past the cap share one overflow scope.
|
|
25
|
+
*
|
|
26
|
+
* State resets when a window elapses (a tumbling window), which is time-driven
|
|
27
|
+
* and the same for every caller. The guard's counters are not throttled, so a
|
|
28
|
+
* dropped line loses attribution for that window, never a count.
|
|
29
|
+
*
|
|
30
|
+
* @module middleware/guard-log-throttle
|
|
31
|
+
*/
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.GuardLogThrottle = exports.OVERFLOW_SCOPE = void 0;
|
|
34
|
+
/** Scope that every scope past `maxScopes` shares within a window. */
|
|
35
|
+
exports.OVERFLOW_SCOPE = '<scope-overflow>';
|
|
36
|
+
/** A bounded, windowed, per-scope once-per-key log throttle. */
|
|
37
|
+
class GuardLogThrottle {
|
|
38
|
+
constructor(options) {
|
|
39
|
+
this.options = options;
|
|
40
|
+
this.keysByScope = new Map();
|
|
41
|
+
this.overflowedScopes = new Set();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Decide whether a decision for `key`, from `scope`, is logged.
|
|
45
|
+
*
|
|
46
|
+
* @param scope - Principal kind plus connection address; never a header.
|
|
47
|
+
* @param key - The caller key within the scope.
|
|
48
|
+
* @param nowMs - Current time.
|
|
49
|
+
* @returns The verdict; the scope it names is the one that was charged.
|
|
50
|
+
*/
|
|
51
|
+
admit(scope, key, nowMs) {
|
|
52
|
+
this.rollWindow(nowMs);
|
|
53
|
+
const charged = this.keysByScope.has(scope) || this.keysByScope.size < this.options.maxScopes
|
|
54
|
+
? scope
|
|
55
|
+
: exports.OVERFLOW_SCOPE;
|
|
56
|
+
let keys = this.keysByScope.get(charged);
|
|
57
|
+
if (!keys) {
|
|
58
|
+
keys = new Set();
|
|
59
|
+
this.keysByScope.set(charged, keys);
|
|
60
|
+
}
|
|
61
|
+
if (keys.has(key))
|
|
62
|
+
return { action: 'drop' };
|
|
63
|
+
if (keys.size < this.options.keysPerScope) {
|
|
64
|
+
keys.add(key);
|
|
65
|
+
return { action: 'log', scope: charged };
|
|
66
|
+
}
|
|
67
|
+
if (this.overflowedScopes.has(charged))
|
|
68
|
+
return { action: 'drop' };
|
|
69
|
+
this.overflowedScopes.add(charged);
|
|
70
|
+
return { action: 'overflow', scope: charged };
|
|
71
|
+
}
|
|
72
|
+
/** Forget all state (tests). */
|
|
73
|
+
reset() {
|
|
74
|
+
this.windowStartMs = undefined;
|
|
75
|
+
this.keysByScope.clear();
|
|
76
|
+
this.overflowedScopes.clear();
|
|
77
|
+
}
|
|
78
|
+
/** Start a new window once the current one has elapsed (or the clock stepped back). */
|
|
79
|
+
rollWindow(nowMs) {
|
|
80
|
+
const start = this.windowStartMs;
|
|
81
|
+
if (start !== undefined && nowMs >= start && nowMs - start < this.options.windowMs)
|
|
82
|
+
return;
|
|
83
|
+
this.windowStartMs = nowMs;
|
|
84
|
+
this.keysByScope.clear();
|
|
85
|
+
this.overflowedScopes.clear();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.GuardLogThrottle = GuardLogThrottle;
|
|
89
|
+
//# sourceMappingURL=guard-log-throttle.js.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded once-per-window throttle for guard decision log lines.
|
|
3
|
+
*
|
|
4
|
+
* A guard that logs every refused or would-refuse access floods the log for a
|
|
5
|
+
* caller that repeats one query all day, so each distinct caller key is logged
|
|
6
|
+
* once per window. The key has to carry caller-supplied values (operation
|
|
7
|
+
* name, user agent, `X-Forwarded-For`) because those are what tell two callers
|
|
8
|
+
* behind one edge address apart. That makes the key space caller-controlled:
|
|
9
|
+
* a caller rotating any of those values mints a new key per request. An
|
|
10
|
+
* unbounded map then grows until something clears it, and clearing a shared
|
|
11
|
+
* map on size is worse than growth — one caller's rotation erases every other
|
|
12
|
+
* caller's throttle state, so the flood re-logs everyone.
|
|
13
|
+
*
|
|
14
|
+
* So keys are counted per SCOPE — the principal kind plus the address this
|
|
15
|
+
* process accepted the connection from, neither of which the caller can set in
|
|
16
|
+
* a header — and each scope gets a fixed budget of distinct keys per window.
|
|
17
|
+
* The first key past the budget yields one overflow notice for that scope;
|
|
18
|
+
* later ones are dropped until the window ends. A caller rotating headers can
|
|
19
|
+
* therefore spend its own scope's budget and nothing else: other scopes keep
|
|
20
|
+
* their state, and the log volume per window is bounded by
|
|
21
|
+
* `(maxScopes + 1) * (keysPerScope + 1)` whatever the caller sends. Scopes are
|
|
22
|
+
* capped as well, because the connection address becomes caller-influenced if
|
|
23
|
+
* `trust proxy` is ever widened; scopes past the cap share one overflow scope.
|
|
24
|
+
*
|
|
25
|
+
* State resets when a window elapses (a tumbling window), which is time-driven
|
|
26
|
+
* and the same for every caller. The guard's counters are not throttled, so a
|
|
27
|
+
* dropped line loses attribution for that window, never a count.
|
|
28
|
+
*
|
|
29
|
+
* @module middleware/guard-log-throttle
|
|
30
|
+
*/
|
|
31
|
+
/** Scope that every scope past `maxScopes` shares within a window. */
|
|
32
|
+
export declare const OVERFLOW_SCOPE = "<scope-overflow>";
|
|
33
|
+
/** Bounds for a {@link GuardLogThrottle}. */
|
|
34
|
+
export interface GuardLogThrottleOptions {
|
|
35
|
+
/** Window length; a key is logged at most once per window. */
|
|
36
|
+
windowMs: number;
|
|
37
|
+
/** Distinct keys one scope may log per window. */
|
|
38
|
+
keysPerScope: number;
|
|
39
|
+
/** Distinct scopes tracked per window before new ones share one scope. */
|
|
40
|
+
maxScopes: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* What the caller should do with one decision.
|
|
44
|
+
*
|
|
45
|
+
* - `log` — first time this key is seen in this scope this window.
|
|
46
|
+
* - `overflow` — the scope has spent its budget this window; log one notice
|
|
47
|
+
* saying so, in place of the line.
|
|
48
|
+
* - `drop` — already logged, or the scope's overflow notice is already out.
|
|
49
|
+
*/
|
|
50
|
+
export type GuardLogVerdict = {
|
|
51
|
+
action: 'log';
|
|
52
|
+
scope: string;
|
|
53
|
+
} | {
|
|
54
|
+
action: 'overflow';
|
|
55
|
+
scope: string;
|
|
56
|
+
} | {
|
|
57
|
+
action: 'drop';
|
|
58
|
+
};
|
|
59
|
+
/** A bounded, windowed, per-scope once-per-key log throttle. */
|
|
60
|
+
export declare class GuardLogThrottle {
|
|
61
|
+
private readonly options;
|
|
62
|
+
private windowStartMs;
|
|
63
|
+
private readonly keysByScope;
|
|
64
|
+
private readonly overflowedScopes;
|
|
65
|
+
constructor(options: GuardLogThrottleOptions);
|
|
66
|
+
/**
|
|
67
|
+
* Decide whether a decision for `key`, from `scope`, is logged.
|
|
68
|
+
*
|
|
69
|
+
* @param scope - Principal kind plus connection address; never a header.
|
|
70
|
+
* @param key - The caller key within the scope.
|
|
71
|
+
* @param nowMs - Current time.
|
|
72
|
+
* @returns The verdict; the scope it names is the one that was charged.
|
|
73
|
+
*/
|
|
74
|
+
admit(scope: string, key: string, nowMs: number): GuardLogVerdict;
|
|
75
|
+
/** Forget all state (tests). */
|
|
76
|
+
reset(): void;
|
|
77
|
+
/** Start a new window once the current one has elapsed (or the clock stepped back). */
|
|
78
|
+
private rollWindow;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=guard-log-throttle.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Middleware Index
|
|
4
|
+
*
|
|
5
|
+
* Provides GraphQL mutation input validation, audit logging,
|
|
6
|
+
* soft-delete handling, and authentication middleware.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CustomValidators = exports.hardDelete = exports.restoreRecord = exports.softDeleteRecord = exports.isSoftDeleteModel = exports.deletedOnlyFilter = exports.softDeleteFilter = exports.SOFT_DELETE_MODELS = exports.ROW_PAYLOAD_ARGS = exports.redactAuditLogWriteArgs = exports.withAuditLogWriteRedaction = exports.extractChangedFields = exports.extractRecordId = exports.extractUserId = exports.parseMutationOperation = exports.createAuditLogPlugin = exports.authMiddleware = exports.VALIDATION_RULES = exports.POSITIVE_NUMBER_FIELDS = exports.REQUIRED_NON_EMPTY_STRING_FIELDS = exports.BOUNDED_PERCENTAGE_FIELDS = exports.VALIDATION_MODE_ENV_VAR = exports.resolveValidationMode = exports.createValidationPlugin = exports.ValidationError = exports.validateFields = exports.validateConfidenceScore = exports.validateNonEmpty = exports.validateUrl = exports.validateEmail = exports.validatePositiveNumber = exports.validatePercentage = void 0;
|
|
10
|
+
// Export validation functions
|
|
11
|
+
var input_validator_1 = require("./input-validator.cjs");
|
|
12
|
+
Object.defineProperty(exports, "validatePercentage", { enumerable: true, get: function () { return input_validator_1.validatePercentage; } });
|
|
13
|
+
Object.defineProperty(exports, "validatePositiveNumber", { enumerable: true, get: function () { return input_validator_1.validatePositiveNumber; } });
|
|
14
|
+
Object.defineProperty(exports, "validateEmail", { enumerable: true, get: function () { return input_validator_1.validateEmail; } });
|
|
15
|
+
Object.defineProperty(exports, "validateUrl", { enumerable: true, get: function () { return input_validator_1.validateUrl; } });
|
|
16
|
+
Object.defineProperty(exports, "validateNonEmpty", { enumerable: true, get: function () { return input_validator_1.validateNonEmpty; } });
|
|
17
|
+
Object.defineProperty(exports, "validateConfidenceScore", { enumerable: true, get: function () { return input_validator_1.validateConfidenceScore; } });
|
|
18
|
+
Object.defineProperty(exports, "validateFields", { enumerable: true, get: function () { return input_validator_1.validateFields; } });
|
|
19
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return input_validator_1.ValidationError; } });
|
|
20
|
+
// Export GraphQL validation plugin
|
|
21
|
+
var graphql_validation_plugin_1 = require("./graphql-validation-plugin.cjs");
|
|
22
|
+
Object.defineProperty(exports, "createValidationPlugin", { enumerable: true, get: function () { return graphql_validation_plugin_1.createValidationPlugin; } });
|
|
23
|
+
Object.defineProperty(exports, "resolveValidationMode", { enumerable: true, get: function () { return graphql_validation_plugin_1.resolveValidationMode; } });
|
|
24
|
+
Object.defineProperty(exports, "VALIDATION_MODE_ENV_VAR", { enumerable: true, get: function () { return graphql_validation_plugin_1.VALIDATION_MODE_ENV_VAR; } });
|
|
25
|
+
Object.defineProperty(exports, "BOUNDED_PERCENTAGE_FIELDS", { enumerable: true, get: function () { return graphql_validation_plugin_1.BOUNDED_PERCENTAGE_FIELDS; } });
|
|
26
|
+
Object.defineProperty(exports, "REQUIRED_NON_EMPTY_STRING_FIELDS", { enumerable: true, get: function () { return graphql_validation_plugin_1.REQUIRED_NON_EMPTY_STRING_FIELDS; } });
|
|
27
|
+
Object.defineProperty(exports, "POSITIVE_NUMBER_FIELDS", { enumerable: true, get: function () { return graphql_validation_plugin_1.POSITIVE_NUMBER_FIELDS; } });
|
|
28
|
+
Object.defineProperty(exports, "VALIDATION_RULES", { enumerable: true, get: function () { return graphql_validation_plugin_1.VALIDATION_RULES; } });
|
|
29
|
+
// Export authentication middleware
|
|
30
|
+
var auth_1 = require("./auth.cjs");
|
|
31
|
+
Object.defineProperty(exports, "authMiddleware", { enumerable: true, get: function () { return auth_1.authMiddleware; } });
|
|
32
|
+
// Export audit logging plugin
|
|
33
|
+
var audit_logger_1 = require("./audit-logger.cjs");
|
|
34
|
+
Object.defineProperty(exports, "createAuditLogPlugin", { enumerable: true, get: function () { return audit_logger_1.createAuditLogPlugin; } });
|
|
35
|
+
Object.defineProperty(exports, "parseMutationOperation", { enumerable: true, get: function () { return audit_logger_1.parseMutationOperation; } });
|
|
36
|
+
Object.defineProperty(exports, "extractUserId", { enumerable: true, get: function () { return audit_logger_1.extractUserId; } });
|
|
37
|
+
Object.defineProperty(exports, "extractRecordId", { enumerable: true, get: function () { return audit_logger_1.extractRecordId; } });
|
|
38
|
+
Object.defineProperty(exports, "extractChangedFields", { enumerable: true, get: function () { return audit_logger_1.extractChangedFields; } });
|
|
39
|
+
// Export AuditLog write redaction (applied to the server's Prisma client by
|
|
40
|
+
// `withClientGuards` in src/prismaClient.ts)
|
|
41
|
+
var audit_log_write_redaction_1 = require("./audit-log-write-redaction.cjs");
|
|
42
|
+
Object.defineProperty(exports, "withAuditLogWriteRedaction", { enumerable: true, get: function () { return audit_log_write_redaction_1.withAuditLogWriteRedaction; } });
|
|
43
|
+
Object.defineProperty(exports, "redactAuditLogWriteArgs", { enumerable: true, get: function () { return audit_log_write_redaction_1.redactAuditLogWriteArgs; } });
|
|
44
|
+
Object.defineProperty(exports, "ROW_PAYLOAD_ARGS", { enumerable: true, get: function () { return audit_log_write_redaction_1.ROW_PAYLOAD_ARGS; } });
|
|
45
|
+
// Export soft-delete utilities
|
|
46
|
+
var soft_delete_1 = require("./soft-delete.cjs");
|
|
47
|
+
Object.defineProperty(exports, "SOFT_DELETE_MODELS", { enumerable: true, get: function () { return soft_delete_1.SOFT_DELETE_MODELS; } });
|
|
48
|
+
Object.defineProperty(exports, "softDeleteFilter", { enumerable: true, get: function () { return soft_delete_1.softDeleteFilter; } });
|
|
49
|
+
Object.defineProperty(exports, "deletedOnlyFilter", { enumerable: true, get: function () { return soft_delete_1.deletedOnlyFilter; } });
|
|
50
|
+
Object.defineProperty(exports, "isSoftDeleteModel", { enumerable: true, get: function () { return soft_delete_1.isSoftDeleteModel; } });
|
|
51
|
+
Object.defineProperty(exports, "softDeleteRecord", { enumerable: true, get: function () { return soft_delete_1.softDeleteRecord; } });
|
|
52
|
+
Object.defineProperty(exports, "restoreRecord", { enumerable: true, get: function () { return soft_delete_1.restoreRecord; } });
|
|
53
|
+
Object.defineProperty(exports, "hardDelete", { enumerable: true, get: function () { return soft_delete_1.hardDelete; } });
|
|
54
|
+
// Export example validators for reference
|
|
55
|
+
var validation_examples_1 = require("./validation-examples.cjs");
|
|
56
|
+
Object.defineProperty(exports, "CustomValidators", { enumerable: true, get: function () { return validation_examples_1.CustomValidators; } });
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware Index
|
|
3
|
+
*
|
|
4
|
+
* Provides GraphQL mutation input validation, audit logging,
|
|
5
|
+
* soft-delete handling, and authentication middleware.
|
|
6
|
+
*/
|
|
7
|
+
export { validatePercentage, validatePositiveNumber, validateEmail, validateUrl, validateNonEmpty, validateConfidenceScore, validateFields, ValidationError, ValidationErrorDetail, } from './input-validator';
|
|
8
|
+
export { createValidationPlugin, resolveValidationMode, ValidationMode, VALIDATION_MODE_ENV_VAR, BOUNDED_PERCENTAGE_FIELDS, REQUIRED_NON_EMPTY_STRING_FIELDS, POSITIVE_NUMBER_FIELDS, VALIDATION_RULES, } from './graphql-validation-plugin';
|
|
9
|
+
export { authMiddleware, AuthenticatedRequest } from './auth';
|
|
10
|
+
export { createAuditLogPlugin, parseMutationOperation, extractUserId, extractRecordId, extractChangedFields, } from './audit-logger';
|
|
11
|
+
export { withAuditLogWriteRedaction, redactAuditLogWriteArgs, ROW_PAYLOAD_ARGS, } from './audit-log-write-redaction';
|
|
12
|
+
export { SOFT_DELETE_MODELS, softDeleteFilter, deletedOnlyFilter, isSoftDeleteModel, softDeleteRecord, restoreRecord, hardDelete, } from './soft-delete';
|
|
13
|
+
export { CustomValidators } from './validation-examples';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidationError = void 0;
|
|
4
|
+
exports.validatePercentage = validatePercentage;
|
|
5
|
+
exports.validatePositiveNumber = validatePositiveNumber;
|
|
6
|
+
exports.validateEmail = validateEmail;
|
|
7
|
+
exports.validateUrl = validateUrl;
|
|
8
|
+
exports.validateNonEmpty = validateNonEmpty;
|
|
9
|
+
exports.validateConfidenceScore = validateConfidenceScore;
|
|
10
|
+
exports.validateFields = validateFields;
|
|
11
|
+
const graphql_1 = require("graphql");
|
|
12
|
+
/**
|
|
13
|
+
* Custom error class for validation failures
|
|
14
|
+
*/
|
|
15
|
+
class ValidationError extends graphql_1.GraphQLError {
|
|
16
|
+
constructor(message, fields) {
|
|
17
|
+
super(message, {
|
|
18
|
+
extensions: {
|
|
19
|
+
code: 'BAD_USER_INPUT',
|
|
20
|
+
validationErrors: fields,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
this.fields = fields;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.ValidationError = ValidationError;
|
|
27
|
+
/**
|
|
28
|
+
* Validates that a number is within the 0-100 percentage range
|
|
29
|
+
* @param value - The numeric value to validate
|
|
30
|
+
* @param fieldName - The name of the field for error reporting
|
|
31
|
+
* @throws ValidationError if the value is not between 0 and 100
|
|
32
|
+
*/
|
|
33
|
+
function validatePercentage(value, fieldName) {
|
|
34
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
35
|
+
throw new ValidationError('Invalid percentage value', [
|
|
36
|
+
{
|
|
37
|
+
field: fieldName,
|
|
38
|
+
value,
|
|
39
|
+
message: 'Must be a valid number',
|
|
40
|
+
constraint: 'isNumber',
|
|
41
|
+
},
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
if (value < 0 || value > 100) {
|
|
45
|
+
throw new ValidationError('Percentage out of range', [
|
|
46
|
+
{
|
|
47
|
+
field: fieldName,
|
|
48
|
+
value,
|
|
49
|
+
message: 'Must be between 0 and 100',
|
|
50
|
+
constraint: 'range',
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Validates that a number is positive (greater than 0)
|
|
57
|
+
* @param value - The numeric value to validate
|
|
58
|
+
* @param fieldName - The name of the field for error reporting
|
|
59
|
+
* @throws ValidationError if the value is not positive
|
|
60
|
+
*/
|
|
61
|
+
function validatePositiveNumber(value, fieldName) {
|
|
62
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
63
|
+
throw new ValidationError('Invalid numeric value', [
|
|
64
|
+
{
|
|
65
|
+
field: fieldName,
|
|
66
|
+
value,
|
|
67
|
+
message: 'Must be a valid number',
|
|
68
|
+
constraint: 'isNumber',
|
|
69
|
+
},
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
if (value <= 0) {
|
|
73
|
+
throw new ValidationError('Number must be positive', [
|
|
74
|
+
{
|
|
75
|
+
field: fieldName,
|
|
76
|
+
value,
|
|
77
|
+
message: 'Must be greater than 0',
|
|
78
|
+
constraint: 'positive',
|
|
79
|
+
},
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Validates that a string is a valid email format
|
|
85
|
+
* @param value - The string value to validate
|
|
86
|
+
* @throws ValidationError if the value is not a valid email
|
|
87
|
+
*/
|
|
88
|
+
function validateEmail(value) {
|
|
89
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
90
|
+
if (typeof value !== 'string') {
|
|
91
|
+
throw new ValidationError('Invalid email value', [
|
|
92
|
+
{
|
|
93
|
+
field: 'email',
|
|
94
|
+
value,
|
|
95
|
+
message: 'Must be a string',
|
|
96
|
+
constraint: 'isString',
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
if (!emailRegex.test(value)) {
|
|
101
|
+
throw new ValidationError('Invalid email format', [
|
|
102
|
+
{
|
|
103
|
+
field: 'email',
|
|
104
|
+
value,
|
|
105
|
+
message: 'Must be a valid email address',
|
|
106
|
+
constraint: 'email',
|
|
107
|
+
},
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Validates that a string is a valid URL format
|
|
113
|
+
* @param value - The string value to validate
|
|
114
|
+
* @throws ValidationError if the value is not a valid URL
|
|
115
|
+
*/
|
|
116
|
+
function validateUrl(value) {
|
|
117
|
+
if (typeof value !== 'string') {
|
|
118
|
+
throw new ValidationError('Invalid URL value', [
|
|
119
|
+
{
|
|
120
|
+
field: 'url',
|
|
121
|
+
value,
|
|
122
|
+
message: 'Must be a string',
|
|
123
|
+
constraint: 'isString',
|
|
124
|
+
},
|
|
125
|
+
]);
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
new URL(value);
|
|
129
|
+
}
|
|
130
|
+
catch (_a) {
|
|
131
|
+
throw new ValidationError('Invalid URL format', [
|
|
132
|
+
{
|
|
133
|
+
field: 'url',
|
|
134
|
+
value,
|
|
135
|
+
message: 'Must be a valid URL',
|
|
136
|
+
constraint: 'url',
|
|
137
|
+
},
|
|
138
|
+
]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Validates that a string is non-empty
|
|
143
|
+
* @param value - The string value to validate
|
|
144
|
+
* @param fieldName - The name of the field for error reporting
|
|
145
|
+
* @throws ValidationError if the value is empty or not a string
|
|
146
|
+
*/
|
|
147
|
+
function validateNonEmpty(value, fieldName) {
|
|
148
|
+
if (typeof value !== 'string') {
|
|
149
|
+
throw new ValidationError('Invalid string value', [
|
|
150
|
+
{
|
|
151
|
+
field: fieldName,
|
|
152
|
+
value,
|
|
153
|
+
message: 'Must be a string',
|
|
154
|
+
constraint: 'isString',
|
|
155
|
+
},
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
158
|
+
if (value.trim().length === 0) {
|
|
159
|
+
throw new ValidationError('String cannot be empty', [
|
|
160
|
+
{
|
|
161
|
+
field: fieldName,
|
|
162
|
+
value,
|
|
163
|
+
message: 'Must not be empty',
|
|
164
|
+
constraint: 'notEmpty',
|
|
165
|
+
},
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Validates that a confidence score is within the 0-1 range
|
|
171
|
+
* @param value - The numeric value to validate
|
|
172
|
+
* @throws ValidationError if the value is not between 0 and 1
|
|
173
|
+
*/
|
|
174
|
+
function validateConfidenceScore(value) {
|
|
175
|
+
if (typeof value !== 'number' || isNaN(value)) {
|
|
176
|
+
throw new ValidationError('Invalid confidence score', [
|
|
177
|
+
{
|
|
178
|
+
field: 'confidenceScore',
|
|
179
|
+
value,
|
|
180
|
+
message: 'Must be a valid number',
|
|
181
|
+
constraint: 'isNumber',
|
|
182
|
+
},
|
|
183
|
+
]);
|
|
184
|
+
}
|
|
185
|
+
if (value < 0 || value > 1) {
|
|
186
|
+
throw new ValidationError('Confidence score out of range', [
|
|
187
|
+
{
|
|
188
|
+
field: 'confidenceScore',
|
|
189
|
+
value,
|
|
190
|
+
message: 'Must be between 0 and 1',
|
|
191
|
+
constraint: 'range',
|
|
192
|
+
},
|
|
193
|
+
]);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Validates multiple fields and accumulates all validation errors
|
|
198
|
+
* @param validations - Array of validation functions to execute
|
|
199
|
+
* @throws ValidationError with all accumulated field errors
|
|
200
|
+
*/
|
|
201
|
+
function validateFields(validations) {
|
|
202
|
+
const errors = [];
|
|
203
|
+
for (const validation of validations) {
|
|
204
|
+
try {
|
|
205
|
+
validation();
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
if (error instanceof ValidationError) {
|
|
209
|
+
errors.push(...error.fields);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (errors.length > 0) {
|
|
217
|
+
throw new ValidationError('Validation failed for multiple fields', errors);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=input-validator.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
/**
|
|
3
|
+
* Validation error details for field-level error reporting
|
|
4
|
+
*/
|
|
5
|
+
export interface ValidationErrorDetail {
|
|
6
|
+
field: string;
|
|
7
|
+
value: unknown;
|
|
8
|
+
message: string;
|
|
9
|
+
constraint: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Custom error class for validation failures
|
|
13
|
+
*/
|
|
14
|
+
export declare class ValidationError extends GraphQLError {
|
|
15
|
+
readonly fields: ValidationErrorDetail[];
|
|
16
|
+
constructor(message: string, fields: ValidationErrorDetail[]);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validates that a number is within the 0-100 percentage range
|
|
20
|
+
* @param value - The numeric value to validate
|
|
21
|
+
* @param fieldName - The name of the field for error reporting
|
|
22
|
+
* @throws ValidationError if the value is not between 0 and 100
|
|
23
|
+
*/
|
|
24
|
+
export declare function validatePercentage(value: number, fieldName: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Validates that a number is positive (greater than 0)
|
|
27
|
+
* @param value - The numeric value to validate
|
|
28
|
+
* @param fieldName - The name of the field for error reporting
|
|
29
|
+
* @throws ValidationError if the value is not positive
|
|
30
|
+
*/
|
|
31
|
+
export declare function validatePositiveNumber(value: number, fieldName: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Validates that a string is a valid email format
|
|
34
|
+
* @param value - The string value to validate
|
|
35
|
+
* @throws ValidationError if the value is not a valid email
|
|
36
|
+
*/
|
|
37
|
+
export declare function validateEmail(value: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Validates that a string is a valid URL format
|
|
40
|
+
* @param value - The string value to validate
|
|
41
|
+
* @throws ValidationError if the value is not a valid URL
|
|
42
|
+
*/
|
|
43
|
+
export declare function validateUrl(value: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* Validates that a string is non-empty
|
|
46
|
+
* @param value - The string value to validate
|
|
47
|
+
* @param fieldName - The name of the field for error reporting
|
|
48
|
+
* @throws ValidationError if the value is empty or not a string
|
|
49
|
+
*/
|
|
50
|
+
export declare function validateNonEmpty(value: string, fieldName: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Validates that a confidence score is within the 0-1 range
|
|
53
|
+
* @param value - The numeric value to validate
|
|
54
|
+
* @throws ValidationError if the value is not between 0 and 1
|
|
55
|
+
*/
|
|
56
|
+
export declare function validateConfidenceScore(value: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* Validates multiple fields and accumulates all validation errors
|
|
59
|
+
* @param validations - Array of validation functions to execute
|
|
60
|
+
* @throws ValidationError with all accumulated field errors
|
|
61
|
+
*/
|
|
62
|
+
export declare function validateFields(validations: Array<() => void>): void;
|
|
63
|
+
//# sourceMappingURL=input-validator.d.ts.map
|