@query-doctor/core 0.10.6 → 0.10.7

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/dist/query.cjs CHANGED
@@ -21,7 +21,7 @@ const RecentQuery = zod.z.object({
21
21
  tags: zod.z.array(zod.z.custom()),
22
22
  nudges: zod.z.array(zod.z.custom()).optional().default([]),
23
23
  hash: zod.z.string(),
24
- seenAt: zod.z.number(),
24
+ firstSeen: zod.z.number().optional(),
25
25
  optimization: zod.z.custom().optional(),
26
26
  explainPlan: require_database.PostgresExplainStageSchema.optional()
27
27
  });
@@ -1 +1 @@
1
- {"version":3,"file":"query.cjs","names":["z","PostgresExplainStageSchema"],"sources":["../src/query.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type {\n DiscoveredColumnReference,\n SQLCommenterTag,\n TableReference,\n} from \"./sql/analyzer.js\";\nimport {\n PostgresExplainStageSchema,\n type PostgresExplainStage,\n} from \"./sql/database.js\";\nimport type { Nudge } from \"./sql/nudges.js\";\n\nexport type IndexRecommendation = {\n name?: string;\n schema: string;\n table: string;\n columns: Array<{\n schema: string;\n table: string;\n column: string;\n sort?: unknown;\n where?: unknown;\n }>;\n where?: string;\n definition: string;\n};\n\nexport type LiveQueryOptimization =\n | { state: \"waiting\" }\n | { state: \"optimizing\" }\n | { state: \"not_supported\"; reason: string }\n | {\n state: \"improvements_available\";\n cost: number;\n optimizedCost: number;\n costReductionPercentage: number;\n indexRecommendations: IndexRecommendation[];\n triedIndexNames?: Record<string, string>;\n indexesUsed: string[];\n explainPlan?: PostgresExplainStage;\n optimizedExplainPlan?: PostgresExplainStage;\n }\n | {\n state: \"no_improvement_found\";\n cost: number;\n indexesUsed: string[];\n explainPlan?: PostgresExplainStage;\n }\n | { state: \"timeout\"; cost?: number }\n | { state: \"error\"; error: string };\n\nexport type QueryHash = string;\n\nexport const RecentQuery = z.object({\n formattedQuery: z.string(),\n displayQuery: z.string().optional(),\n username: z.string(),\n query: z.string(),\n meanTime: z.number(),\n calls: z.string(),\n rows: z.string(),\n topLevel: z.boolean(),\n isSystemQuery: z.boolean(),\n isSelectQuery: z.boolean(),\n isIntrospection: z.boolean(),\n isTargetlessSelectQuery: z.boolean(),\n tableReferences: z.array(z.custom<TableReference>()),\n columnReferences: z.array(z.custom<DiscoveredColumnReference>()),\n tags: z.array(z.custom<SQLCommenterTag>()),\n nudges: z.array(z.custom<Nudge>()).optional().default([]),\n hash: z.string(),\n seenAt: z.number(),\n optimization: z.custom<LiveQueryOptimization>().optional(),\n explainPlan: PostgresExplainStageSchema.optional(),\n});\n\nexport type RecentQuery = z.infer<typeof RecentQuery>;\n\nexport const OptimizedQuery = RecentQuery.extend({\n optimization: z.custom<LiveQueryOptimization>(),\n});\n\nexport type OptimizedQuery = z.infer<typeof OptimizedQuery>;\n\nexport type OptimizationResult = {\n hash: QueryHash;\n optimization: LiveQueryOptimization;\n};\n"],"mappings":";;;;;AAqDA,MAAa,cAAcA,IAAAA,EAAE,OAAO;CAClC,gBAAgBA,IAAAA,EAAE,QAAQ;CAC1B,cAAcA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CACnC,UAAUA,IAAAA,EAAE,QAAQ;CACpB,OAAOA,IAAAA,EAAE,QAAQ;CACjB,UAAUA,IAAAA,EAAE,QAAQ;CACpB,OAAOA,IAAAA,EAAE,QAAQ;CACjB,MAAMA,IAAAA,EAAE,QAAQ;CAChB,UAAUA,IAAAA,EAAE,SAAS;CACrB,eAAeA,IAAAA,EAAE,SAAS;CAC1B,eAAeA,IAAAA,EAAE,SAAS;CAC1B,iBAAiBA,IAAAA,EAAE,SAAS;CAC5B,yBAAyBA,IAAAA,EAAE,SAAS;CACpC,iBAAiBA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAwB,CAAC;CACpD,kBAAkBA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAmC,CAAC;CAChE,MAAMA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAyB,CAAC;CAC1C,QAAQA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAe,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;CACzD,MAAMA,IAAAA,EAAE,QAAQ;CAChB,QAAQA,IAAAA,EAAE,QAAQ;CAClB,cAAcA,IAAAA,EAAE,QAA+B,CAAC,UAAU;CAC1D,aAAaC,iBAAAA,2BAA2B,UAAU;CACnD,CAAC;AAIF,MAAa,iBAAiB,YAAY,OAAO,EAC/C,cAAcD,IAAAA,EAAE,QAA+B,EAChD,CAAC"}
1
+ {"version":3,"file":"query.cjs","names":["z","PostgresExplainStageSchema"],"sources":["../src/query.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type {\n DiscoveredColumnReference,\n SQLCommenterTag,\n TableReference,\n} from \"./sql/analyzer.js\";\nimport {\n PostgresExplainStageSchema,\n type PostgresExplainStage,\n} from \"./sql/database.js\";\nimport type { Nudge } from \"./sql/nudges.js\";\n\nexport type IndexRecommendation = {\n name?: string;\n schema: string;\n table: string;\n columns: Array<{\n schema: string;\n table: string;\n column: string;\n sort?: unknown;\n where?: unknown;\n }>;\n where?: string;\n definition: string;\n};\n\nexport type LiveQueryOptimization =\n | { state: \"waiting\" }\n | { state: \"optimizing\" }\n | { state: \"not_supported\"; reason: string }\n | {\n state: \"improvements_available\";\n cost: number;\n optimizedCost: number;\n costReductionPercentage: number;\n indexRecommendations: IndexRecommendation[];\n triedIndexNames?: Record<string, string>;\n indexesUsed: string[];\n explainPlan?: PostgresExplainStage;\n optimizedExplainPlan?: PostgresExplainStage;\n }\n | {\n state: \"no_improvement_found\";\n cost: number;\n indexesUsed: string[];\n explainPlan?: PostgresExplainStage;\n }\n | { state: \"timeout\"; cost?: number }\n | { state: \"error\"; error: string };\n\nexport type QueryHash = string;\n\nexport const RecentQuery = z.object({\n formattedQuery: z.string(),\n displayQuery: z.string().optional(),\n username: z.string(),\n query: z.string(),\n meanTime: z.number(),\n calls: z.string(),\n rows: z.string(),\n topLevel: z.boolean(),\n isSystemQuery: z.boolean(),\n isSelectQuery: z.boolean(),\n isIntrospection: z.boolean(),\n isTargetlessSelectQuery: z.boolean(),\n tableReferences: z.array(z.custom<TableReference>()),\n columnReferences: z.array(z.custom<DiscoveredColumnReference>()),\n tags: z.array(z.custom<SQLCommenterTag>()),\n nudges: z.array(z.custom<Nudge>()).optional().default([]),\n hash: z.string(),\n firstSeen: z.number().optional(),\n optimization: z.custom<LiveQueryOptimization>().optional(),\n explainPlan: PostgresExplainStageSchema.optional(),\n});\n\nexport type RecentQuery = z.infer<typeof RecentQuery>;\n\nexport const OptimizedQuery = RecentQuery.extend({\n optimization: z.custom<LiveQueryOptimization>(),\n});\n\nexport type OptimizedQuery = z.infer<typeof OptimizedQuery>;\n\nexport type OptimizationResult = {\n hash: QueryHash;\n optimization: LiveQueryOptimization;\n};\n"],"mappings":";;;;;AAqDA,MAAa,cAAcA,IAAAA,EAAE,OAAO;CAClC,gBAAgBA,IAAAA,EAAE,QAAQ;CAC1B,cAAcA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CACnC,UAAUA,IAAAA,EAAE,QAAQ;CACpB,OAAOA,IAAAA,EAAE,QAAQ;CACjB,UAAUA,IAAAA,EAAE,QAAQ;CACpB,OAAOA,IAAAA,EAAE,QAAQ;CACjB,MAAMA,IAAAA,EAAE,QAAQ;CAChB,UAAUA,IAAAA,EAAE,SAAS;CACrB,eAAeA,IAAAA,EAAE,SAAS;CAC1B,eAAeA,IAAAA,EAAE,SAAS;CAC1B,iBAAiBA,IAAAA,EAAE,SAAS;CAC5B,yBAAyBA,IAAAA,EAAE,SAAS;CACpC,iBAAiBA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAwB,CAAC;CACpD,kBAAkBA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAmC,CAAC;CAChE,MAAMA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAyB,CAAC;CAC1C,QAAQA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAe,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;CACzD,MAAMA,IAAAA,EAAE,QAAQ;CAChB,WAAWA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAChC,cAAcA,IAAAA,EAAE,QAA+B,CAAC,UAAU;CAC1D,aAAaC,iBAAAA,2BAA2B,UAAU;CACnD,CAAC;AAIF,MAAa,iBAAiB,YAAY,OAAO,EAC/C,cAAcD,IAAAA,EAAE,QAA+B,EAChD,CAAC"}
package/dist/query.d.cts CHANGED
@@ -68,7 +68,7 @@ declare const RecentQuery: z.ZodObject<{
68
68
  tags: z.ZodArray<z.ZodCustom<SQLCommenterTag, SQLCommenterTag>>;
69
69
  nudges: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodCustom<Nudge, Nudge>>>>;
70
70
  hash: z.ZodString;
71
- seenAt: z.ZodNumber;
71
+ firstSeen: z.ZodOptional<z.ZodNumber>;
72
72
  optimization: z.ZodOptional<z.ZodCustom<LiveQueryOptimization, LiveQueryOptimization>>;
73
73
  explainPlan: z.ZodOptional<z.ZodType<PostgresExplainStage, unknown, z.core.$ZodTypeInternals<PostgresExplainStage, unknown>>>;
74
74
  }, z.core.$strip>;
@@ -91,7 +91,7 @@ declare const OptimizedQuery: z.ZodObject<{
91
91
  tags: z.ZodArray<z.ZodCustom<SQLCommenterTag, SQLCommenterTag>>;
92
92
  nudges: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodCustom<Nudge, Nudge>>>>;
93
93
  hash: z.ZodString;
94
- seenAt: z.ZodNumber;
94
+ firstSeen: z.ZodOptional<z.ZodNumber>;
95
95
  explainPlan: z.ZodOptional<z.ZodType<PostgresExplainStage, unknown, z.core.$ZodTypeInternals<PostgresExplainStage, unknown>>>;
96
96
  optimization: z.ZodCustom<LiveQueryOptimization, LiveQueryOptimization>;
97
97
  }, z.core.$strip>;
package/dist/query.d.mts CHANGED
@@ -68,7 +68,7 @@ declare const RecentQuery: z.ZodObject<{
68
68
  tags: z.ZodArray<z.ZodCustom<SQLCommenterTag, SQLCommenterTag>>;
69
69
  nudges: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodCustom<Nudge, Nudge>>>>;
70
70
  hash: z.ZodString;
71
- seenAt: z.ZodNumber;
71
+ firstSeen: z.ZodOptional<z.ZodNumber>;
72
72
  optimization: z.ZodOptional<z.ZodCustom<LiveQueryOptimization, LiveQueryOptimization>>;
73
73
  explainPlan: z.ZodOptional<z.ZodType<PostgresExplainStage, unknown, z.core.$ZodTypeInternals<PostgresExplainStage, unknown>>>;
74
74
  }, z.core.$strip>;
@@ -91,7 +91,7 @@ declare const OptimizedQuery: z.ZodObject<{
91
91
  tags: z.ZodArray<z.ZodCustom<SQLCommenterTag, SQLCommenterTag>>;
92
92
  nudges: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodCustom<Nudge, Nudge>>>>;
93
93
  hash: z.ZodString;
94
- seenAt: z.ZodNumber;
94
+ firstSeen: z.ZodOptional<z.ZodNumber>;
95
95
  explainPlan: z.ZodOptional<z.ZodType<PostgresExplainStage, unknown, z.core.$ZodTypeInternals<PostgresExplainStage, unknown>>>;
96
96
  optimization: z.ZodCustom<LiveQueryOptimization, LiveQueryOptimization>;
97
97
  }, z.core.$strip>;
package/dist/query.mjs CHANGED
@@ -20,7 +20,7 @@ const RecentQuery = z.object({
20
20
  tags: z.array(z.custom()),
21
21
  nudges: z.array(z.custom()).optional().default([]),
22
22
  hash: z.string(),
23
- seenAt: z.number(),
23
+ firstSeen: z.number().optional(),
24
24
  optimization: z.custom().optional(),
25
25
  explainPlan: PostgresExplainStageSchema.optional()
26
26
  });
@@ -1 +1 @@
1
- {"version":3,"file":"query.mjs","names":[],"sources":["../src/query.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type {\n DiscoveredColumnReference,\n SQLCommenterTag,\n TableReference,\n} from \"./sql/analyzer.js\";\nimport {\n PostgresExplainStageSchema,\n type PostgresExplainStage,\n} from \"./sql/database.js\";\nimport type { Nudge } from \"./sql/nudges.js\";\n\nexport type IndexRecommendation = {\n name?: string;\n schema: string;\n table: string;\n columns: Array<{\n schema: string;\n table: string;\n column: string;\n sort?: unknown;\n where?: unknown;\n }>;\n where?: string;\n definition: string;\n};\n\nexport type LiveQueryOptimization =\n | { state: \"waiting\" }\n | { state: \"optimizing\" }\n | { state: \"not_supported\"; reason: string }\n | {\n state: \"improvements_available\";\n cost: number;\n optimizedCost: number;\n costReductionPercentage: number;\n indexRecommendations: IndexRecommendation[];\n triedIndexNames?: Record<string, string>;\n indexesUsed: string[];\n explainPlan?: PostgresExplainStage;\n optimizedExplainPlan?: PostgresExplainStage;\n }\n | {\n state: \"no_improvement_found\";\n cost: number;\n indexesUsed: string[];\n explainPlan?: PostgresExplainStage;\n }\n | { state: \"timeout\"; cost?: number }\n | { state: \"error\"; error: string };\n\nexport type QueryHash = string;\n\nexport const RecentQuery = z.object({\n formattedQuery: z.string(),\n displayQuery: z.string().optional(),\n username: z.string(),\n query: z.string(),\n meanTime: z.number(),\n calls: z.string(),\n rows: z.string(),\n topLevel: z.boolean(),\n isSystemQuery: z.boolean(),\n isSelectQuery: z.boolean(),\n isIntrospection: z.boolean(),\n isTargetlessSelectQuery: z.boolean(),\n tableReferences: z.array(z.custom<TableReference>()),\n columnReferences: z.array(z.custom<DiscoveredColumnReference>()),\n tags: z.array(z.custom<SQLCommenterTag>()),\n nudges: z.array(z.custom<Nudge>()).optional().default([]),\n hash: z.string(),\n seenAt: z.number(),\n optimization: z.custom<LiveQueryOptimization>().optional(),\n explainPlan: PostgresExplainStageSchema.optional(),\n});\n\nexport type RecentQuery = z.infer<typeof RecentQuery>;\n\nexport const OptimizedQuery = RecentQuery.extend({\n optimization: z.custom<LiveQueryOptimization>(),\n});\n\nexport type OptimizedQuery = z.infer<typeof OptimizedQuery>;\n\nexport type OptimizationResult = {\n hash: QueryHash;\n optimization: LiveQueryOptimization;\n};\n"],"mappings":";;;;AAqDA,MAAa,cAAc,EAAE,OAAO;CAClC,gBAAgB,EAAE,QAAQ;CAC1B,cAAc,EAAE,QAAQ,CAAC,UAAU;CACnC,UAAU,EAAE,QAAQ;CACpB,OAAO,EAAE,QAAQ;CACjB,UAAU,EAAE,QAAQ;CACpB,OAAO,EAAE,QAAQ;CACjB,MAAM,EAAE,QAAQ;CAChB,UAAU,EAAE,SAAS;CACrB,eAAe,EAAE,SAAS;CAC1B,eAAe,EAAE,SAAS;CAC1B,iBAAiB,EAAE,SAAS;CAC5B,yBAAyB,EAAE,SAAS;CACpC,iBAAiB,EAAE,MAAM,EAAE,QAAwB,CAAC;CACpD,kBAAkB,EAAE,MAAM,EAAE,QAAmC,CAAC;CAChE,MAAM,EAAE,MAAM,EAAE,QAAyB,CAAC;CAC1C,QAAQ,EAAE,MAAM,EAAE,QAAe,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;CACzD,MAAM,EAAE,QAAQ;CAChB,QAAQ,EAAE,QAAQ;CAClB,cAAc,EAAE,QAA+B,CAAC,UAAU;CAC1D,aAAa,2BAA2B,UAAU;CACnD,CAAC;AAIF,MAAa,iBAAiB,YAAY,OAAO,EAC/C,cAAc,EAAE,QAA+B,EAChD,CAAC"}
1
+ {"version":3,"file":"query.mjs","names":[],"sources":["../src/query.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type {\n DiscoveredColumnReference,\n SQLCommenterTag,\n TableReference,\n} from \"./sql/analyzer.js\";\nimport {\n PostgresExplainStageSchema,\n type PostgresExplainStage,\n} from \"./sql/database.js\";\nimport type { Nudge } from \"./sql/nudges.js\";\n\nexport type IndexRecommendation = {\n name?: string;\n schema: string;\n table: string;\n columns: Array<{\n schema: string;\n table: string;\n column: string;\n sort?: unknown;\n where?: unknown;\n }>;\n where?: string;\n definition: string;\n};\n\nexport type LiveQueryOptimization =\n | { state: \"waiting\" }\n | { state: \"optimizing\" }\n | { state: \"not_supported\"; reason: string }\n | {\n state: \"improvements_available\";\n cost: number;\n optimizedCost: number;\n costReductionPercentage: number;\n indexRecommendations: IndexRecommendation[];\n triedIndexNames?: Record<string, string>;\n indexesUsed: string[];\n explainPlan?: PostgresExplainStage;\n optimizedExplainPlan?: PostgresExplainStage;\n }\n | {\n state: \"no_improvement_found\";\n cost: number;\n indexesUsed: string[];\n explainPlan?: PostgresExplainStage;\n }\n | { state: \"timeout\"; cost?: number }\n | { state: \"error\"; error: string };\n\nexport type QueryHash = string;\n\nexport const RecentQuery = z.object({\n formattedQuery: z.string(),\n displayQuery: z.string().optional(),\n username: z.string(),\n query: z.string(),\n meanTime: z.number(),\n calls: z.string(),\n rows: z.string(),\n topLevel: z.boolean(),\n isSystemQuery: z.boolean(),\n isSelectQuery: z.boolean(),\n isIntrospection: z.boolean(),\n isTargetlessSelectQuery: z.boolean(),\n tableReferences: z.array(z.custom<TableReference>()),\n columnReferences: z.array(z.custom<DiscoveredColumnReference>()),\n tags: z.array(z.custom<SQLCommenterTag>()),\n nudges: z.array(z.custom<Nudge>()).optional().default([]),\n hash: z.string(),\n firstSeen: z.number().optional(),\n optimization: z.custom<LiveQueryOptimization>().optional(),\n explainPlan: PostgresExplainStageSchema.optional(),\n});\n\nexport type RecentQuery = z.infer<typeof RecentQuery>;\n\nexport const OptimizedQuery = RecentQuery.extend({\n optimization: z.custom<LiveQueryOptimization>(),\n});\n\nexport type OptimizedQuery = z.infer<typeof OptimizedQuery>;\n\nexport type OptimizationResult = {\n hash: QueryHash;\n optimization: LiveQueryOptimization;\n};\n"],"mappings":";;;;AAqDA,MAAa,cAAc,EAAE,OAAO;CAClC,gBAAgB,EAAE,QAAQ;CAC1B,cAAc,EAAE,QAAQ,CAAC,UAAU;CACnC,UAAU,EAAE,QAAQ;CACpB,OAAO,EAAE,QAAQ;CACjB,UAAU,EAAE,QAAQ;CACpB,OAAO,EAAE,QAAQ;CACjB,MAAM,EAAE,QAAQ;CAChB,UAAU,EAAE,SAAS;CACrB,eAAe,EAAE,SAAS;CAC1B,eAAe,EAAE,SAAS;CAC1B,iBAAiB,EAAE,SAAS;CAC5B,yBAAyB,EAAE,SAAS;CACpC,iBAAiB,EAAE,MAAM,EAAE,QAAwB,CAAC;CACpD,kBAAkB,EAAE,MAAM,EAAE,QAAmC,CAAC;CAChE,MAAM,EAAE,MAAM,EAAE,QAAyB,CAAC;CAC1C,QAAQ,EAAE,MAAM,EAAE,QAAe,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;CACzD,MAAM,EAAE,QAAQ;CAChB,WAAW,EAAE,QAAQ,CAAC,UAAU;CAChC,cAAc,EAAE,QAA+B,CAAC,UAAU;CAC1D,aAAa,2BAA2B,UAAU;CACnD,CAAC;AAIF,MAAa,iBAAiB,YAAY,OAAO,EAC/C,cAAc,EAAE,QAA+B,EAChD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@query-doctor/core",
3
- "version": "0.10.6",
3
+ "version": "0.10.7",
4
4
  "private": false,
5
5
  "description": "Core logic for Query Doctor",
6
6
  "license": "",