ai-ops-cli 0.1.11 → 0.1.14
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/data/presets.yaml +2 -0
- package/data/rules/graphql-client-app.yaml +29 -0
- package/data/rules/graphql-client-web.yaml +30 -0
- package/data/rules/graphql-core.yaml +31 -0
- package/data/rules/graphql-server.yaml +33 -0
- package/data/rules/libs-backend-ts.yaml +0 -2
- package/data/rules/libs-frontend-web.yaml +0 -5
- package/dist/bin/index.js +222 -85
- package/dist/bin/index.js.map +1 -1
- package/package.json +1 -1
- package/data/rules/graphql.yaml +0 -34
package/data/presets.yaml
CHANGED
|
@@ -11,6 +11,7 @@ frontend-web:
|
|
|
11
11
|
- react-typescript
|
|
12
12
|
- shadcn-ui
|
|
13
13
|
- nextjs
|
|
14
|
+
- graphql
|
|
14
15
|
- libs-frontend-web
|
|
15
16
|
|
|
16
17
|
frontend-app:
|
|
@@ -23,6 +24,7 @@ frontend-app:
|
|
|
23
24
|
- naming-convention
|
|
24
25
|
- engineering-standards
|
|
25
26
|
- flutter
|
|
27
|
+
- graphql
|
|
26
28
|
- libs-frontend-app
|
|
27
29
|
|
|
28
30
|
backend-ts:
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
id: graphql-client-app
|
|
2
|
+
category: api
|
|
3
|
+
tags:
|
|
4
|
+
- graphql
|
|
5
|
+
- frontend
|
|
6
|
+
- flutter
|
|
7
|
+
priority: 46
|
|
8
|
+
content:
|
|
9
|
+
constraints:
|
|
10
|
+
- 'DO NOT call GraphQL endpoints directly from widgets. Route operations through provider/repository layers to avoid rebuild-driven duplicate requests and side effects.'
|
|
11
|
+
- 'DO NOT parse GraphQL response maps in UI code. Convert payloads to typed freezed/json_serializable models in the data layer to prevent runtime cast/null errors.'
|
|
12
|
+
- 'DO NOT treat HTTP 200 as success when GraphQL errors[] exists. Map GraphQL errors to typed domain failures.'
|
|
13
|
+
- 'DO NOT create ad-hoc Dio instances for GraphQL calls. Reuse the shared DI-injected client with auth interceptors.'
|
|
14
|
+
guidelines:
|
|
15
|
+
- 'Use Riverpod providers as the boundary between presentation and GraphQL data access.'
|
|
16
|
+
- 'Generate GraphQL DTO/union models with the same build_runner pipeline used for other app models.'
|
|
17
|
+
- 'Map __typename-based unions to freezed union types to force exhaustive handling.'
|
|
18
|
+
- 'Keep optimistic update and cache invalidation logic in repositories/providers, not in widgets.'
|
|
19
|
+
- 'Log operationName with redacted variables for debugging failed GraphQL operations.'
|
|
20
|
+
decision_table:
|
|
21
|
+
- when: 'A widget needs GraphQL data'
|
|
22
|
+
then: 'Read a Riverpod provider that delegates to repository/use-case'
|
|
23
|
+
avoid: 'Calling Dio/GraphQL requests directly inside build() or event handlers'
|
|
24
|
+
- when: 'A mutation returns data plus business errors'
|
|
25
|
+
then: 'Preserve successful fields and map typed errors into UI state'
|
|
26
|
+
avoid: 'Treating the full response as fatal failure'
|
|
27
|
+
- when: 'New GraphQL documents are added'
|
|
28
|
+
then: 'Run build_runner to regenerate typed models before commit'
|
|
29
|
+
avoid: 'Manual map access against dynamic JSON payloads'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
id: graphql-client-web
|
|
2
|
+
category: api
|
|
3
|
+
tags:
|
|
4
|
+
- graphql
|
|
5
|
+
- frontend
|
|
6
|
+
- nextjs
|
|
7
|
+
- apollo
|
|
8
|
+
priority: 47
|
|
9
|
+
content:
|
|
10
|
+
constraints:
|
|
11
|
+
- 'DO NOT call /graphql with ad-hoc fetch wrappers in Next.js App Router features. Use the shared Apollo client stack to preserve auth links and normalized cache behavior.'
|
|
12
|
+
- 'DO NOT handwrite GraphQL operation/result types or cast payloads with as assertions. Use generated TypedDocumentNode artifacts.'
|
|
13
|
+
- 'DO NOT treat HTTP 200 as success when GraphQL errors[] exists. Handle partial-success responses explicitly.'
|
|
14
|
+
- 'DO NOT create per-feature ApolloClient instances. Reuse one configured provider to preserve auth/cache/link behavior.'
|
|
15
|
+
guidelines:
|
|
16
|
+
- 'Use @apollo/client with @apollo/experimental-nextjs-app-support and mount ApolloNextAppProvider once at the app root.'
|
|
17
|
+
- 'Use GraphQL Codegen client-preset and import generated graphql(...) documents from feature modules.'
|
|
18
|
+
- 'Set fetchPolicy explicitly per operation (cache-first, network-only, no-cache) based on freshness requirements.'
|
|
19
|
+
- 'Co-locate .graphql documents and fragments with feature code, and keep fragment names feature-prefixed.'
|
|
20
|
+
- 'Normalize GraphQL errors/extensions into a shared UI error model before rendering.'
|
|
21
|
+
decision_table:
|
|
22
|
+
- when: 'GraphQL data fetching is needed in App Router'
|
|
23
|
+
then: 'Use the shared ApolloNextAppProvider + generated documents'
|
|
24
|
+
avoid: 'Ad-hoc raw fetch cache wiring in components'
|
|
25
|
+
- when: 'A mutation can return both data and business errors'
|
|
26
|
+
then: 'Render partial-success data and surface typed errors from the same response'
|
|
27
|
+
avoid: 'Throwing away data whenever errors[] is present'
|
|
28
|
+
- when: 'A new query document is added'
|
|
29
|
+
then: 'Regenerate codegen artifacts before committing'
|
|
30
|
+
avoid: 'Shipping stale generated types/documents'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
id: graphql-core
|
|
2
|
+
category: api
|
|
3
|
+
tags:
|
|
4
|
+
- graphql
|
|
5
|
+
- api
|
|
6
|
+
- schema-contract
|
|
7
|
+
priority: 48
|
|
8
|
+
content:
|
|
9
|
+
constraints:
|
|
10
|
+
- 'DO NOT rely on implicit nullability. Mark every field intentionally (prefer non-null by default).'
|
|
11
|
+
- 'DO NOT return unbounded lists. Every collection must provide pagination arguments and a stable cursor.'
|
|
12
|
+
- 'DO NOT expose internal implementation details in enum values. Use semantic SCREAMING_SNAKE_CASE names that remain stable across refactors.'
|
|
13
|
+
- 'DO NOT rename/remove published fields or types in the same release. Deprecate first, then remove in the next major.'
|
|
14
|
+
guidelines:
|
|
15
|
+
- 'Follow naming conventions: PascalCase for types/enums, camelCase for fields/arguments, SCREAMING_SNAKE_CASE for enum values.'
|
|
16
|
+
- 'Prefer cursor pagination (first/after) for user-facing lists; use offset only for bounded admin tables.'
|
|
17
|
+
- 'Define typed FilterInput/OrderByInput for filtering and sorting instead of JSON-like free-form arguments.'
|
|
18
|
+
- 'Document scalar contracts (DateTime, UUID, JSON) with accepted formats and timezone policy.'
|
|
19
|
+
decision_table:
|
|
20
|
+
- when: 'A field returns a collection'
|
|
21
|
+
then: 'Use cursor pagination with a stable cursor and deterministic ordering'
|
|
22
|
+
avoid: 'Returning unbounded [Node!]! lists'
|
|
23
|
+
- when: 'A field or type must be renamed/removed'
|
|
24
|
+
then: 'Mark it as @deprecated with a migration reason, keep compatibility for at least one release, remove in next major'
|
|
25
|
+
avoid: 'Immediate rename/removal that breaks existing client operations'
|
|
26
|
+
- when: 'A schema change is high-risk (widely used field, auth/payment domain)'
|
|
27
|
+
then: 'Add pre-release usage checks (operation usage, top callers), publish rollback criteria, and keep a revert path that restores the previous contract'
|
|
28
|
+
avoid: 'Shipping a contract change without usage visibility or rollback plan'
|
|
29
|
+
- when: 'Filtering or sorting is complex'
|
|
30
|
+
then: 'Define typed FilterInput/OrderByInput types'
|
|
31
|
+
avoid: 'Accepting raw JSON blobs or ad-hoc string filters'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
id: graphql-server
|
|
2
|
+
category: api
|
|
3
|
+
tags:
|
|
4
|
+
- graphql
|
|
5
|
+
- api
|
|
6
|
+
- backend
|
|
7
|
+
priority: 44
|
|
8
|
+
content:
|
|
9
|
+
constraints:
|
|
10
|
+
- 'DO NOT perform mutations in Query resolvers. Reads belong to Query, writes belong to Mutation.'
|
|
11
|
+
- 'DO NOT throw top-level GraphQL errors for expected business failures. Return typed domain errors in payloads.'
|
|
12
|
+
- 'DO NOT issue per-parent DB queries from field resolvers. Use request-scoped batching (DataLoader or equivalent).'
|
|
13
|
+
- 'DO NOT accept multiple scalar mutation arguments. Standardize on one input object (mutation X($input: XInput!)).'
|
|
14
|
+
- 'DO NOT expose unauthenticated subscription/live update endpoints in production.'
|
|
15
|
+
guidelines:
|
|
16
|
+
- 'Keep resolvers thin and delegate business logic to service/use-case layers.'
|
|
17
|
+
- 'Use payload types that carry both success data and typed userErrors for partial success handling.'
|
|
18
|
+
- 'Apply query depth/complexity limits and operation timeout guards to prevent expensive nested queries.'
|
|
19
|
+
- 'Record operationName and requestId in structured logs for mutation/subscription debugging.'
|
|
20
|
+
- 'Document idempotency expectations for side-effecting mutations (payment, provisioning, outbound integrations).'
|
|
21
|
+
decision_table:
|
|
22
|
+
- when: 'A mutation can fail due to business validation'
|
|
23
|
+
then: 'Return payload data + typed userErrors and keep top-level errors for unexpected faults only'
|
|
24
|
+
avoid: 'Throwing generic Error for expected business branches'
|
|
25
|
+
- when: 'A field resolver loads related entities'
|
|
26
|
+
then: 'Batch and cache per-request with DataLoader (or equivalent)'
|
|
27
|
+
avoid: 'Repository call per parent row (N+1)'
|
|
28
|
+
- when: 'A new subscription is introduced'
|
|
29
|
+
then: 'Require auth/tenant checks and choose production-safe PubSub transport'
|
|
30
|
+
avoid: 'Unauthenticated or in-memory-only subscription setup in production'
|
|
31
|
+
- when: 'A mutation triggers irreversible side effects (billing, provisioning, partner API)'
|
|
32
|
+
then: 'Verify pre-conditions first, require idempotency keys, and define compensating/rollback actions before execution'
|
|
33
|
+
avoid: 'Calling external side effects before validation or without replay/rollback strategy'
|
|
@@ -15,8 +15,6 @@ content:
|
|
|
15
15
|
- 'DO NOT use winston/morgan/console.log for app logs. Use pino via nestjs-pino.'
|
|
16
16
|
guidelines:
|
|
17
17
|
- 'Use class-validator + class-transformer DTO validation with ValidationPipe({ whitelist: true }).'
|
|
18
|
-
- 'Use @nestjs/graphql + @nestjs/apollo code-first for GraphQL APIs.'
|
|
19
|
-
- 'Use GraphQL Codegen for operation/result type generation.'
|
|
20
18
|
- 'Use jose for JWT sign/verify and JWKS workflows.'
|
|
21
19
|
- 'Use pino + nestjs-pino as the default structured logger.'
|
|
22
20
|
- 'Use rxjs operators for NestJS interceptors, guards, and event streams.'
|
|
@@ -15,8 +15,6 @@ content:
|
|
|
15
15
|
- 'DO NOT install parallel UI kits (MUI, Ant, Chakra) alongside shadcn/ui.'
|
|
16
16
|
- 'DO NOT use Redux/Recoil/MobX for local UI state. Use zustand for client UI state.'
|
|
17
17
|
guidelines:
|
|
18
|
-
- 'Use @apollo/client with @apollo/experimental-nextjs-app-support for GraphQL in App Router.'
|
|
19
|
-
- 'Use GraphQL Codegen client-preset to generate TypedDocumentNode types at build time.'
|
|
20
18
|
- 'Keep styling on Tailwind + design tokens (CSS variables) and cva variants.'
|
|
21
19
|
- 'Use next-intl for i18n and next-themes for theme switching.'
|
|
22
20
|
- 'Render Recharts inside client components only.'
|
|
@@ -24,9 +22,6 @@ content:
|
|
|
24
22
|
- 'Sanitize user HTML with isomorphic-dompurify before dangerouslySetInnerHTML.'
|
|
25
23
|
- 'Use Vitest + Testing Library; prefer userEvent over fireEvent.'
|
|
26
24
|
decision_table:
|
|
27
|
-
- when: 'GraphQL data fetching is needed in App Router'
|
|
28
|
-
then: 'Use ApolloNextAppProvider with @apollo/client'
|
|
29
|
-
avoid: 'Ad-hoc raw fetch cache wiring'
|
|
30
25
|
- when: 'Date handling is needed'
|
|
31
26
|
then: 'Use date-fns named imports'
|
|
32
27
|
avoid: 'moment/dayjs'
|