@lssm/example.analytics-dashboard 0.0.0-canary-20251220002821 → 0.0.0-canary-20251220015515

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.
@@ -13,6 +13,7 @@ const OwnersEnum = {
13
13
  ProductArtisanos: "product.artisanos",
14
14
  PlatformSigil: "platform.sigil",
15
15
  PlatformMarketplace: "platform.marketplace",
16
+ PlatformMessaging: "platform.messaging",
16
17
  PlatformContent: "platform.content",
17
18
  PlatformFeatureFlags: "platform.featureflags",
18
19
  PlatformFinance: "platform.finance"
@@ -1 +1 @@
1
- {"version":3,"file":"ownership.js","names":[],"sources":["../../../../../../libs/contracts/dist/ownership.js"],"sourcesContent":["//#region src/ownership.ts\nconst StabilityEnum = {\n\tIdea: \"idea\",\n\tInCreation: \"in_creation\",\n\tExperimental: \"experimental\",\n\tBeta: \"beta\",\n\tStable: \"stable\",\n\tDeprecated: \"deprecated\"\n};\nconst OwnersEnum = {\n\tProductColiving: \"product.coliving\",\n\tProductStrit: \"product.strit\",\n\tProductArtisanos: \"product.artisanos\",\n\tPlatformSigil: \"platform.sigil\",\n\tPlatformMarketplace: \"platform.marketplace\",\n\tPlatformContent: \"platform.content\",\n\tPlatformFeatureFlags: \"platform.featureflags\",\n\tPlatformFinance: \"platform.finance\"\n};\nconst Owners = OwnersEnum;\nconst TagsEnum = {\n\tSpots: \"spots\",\n\tCollectivity: \"collectivity\",\n\tMarketplace: \"marketplace\",\n\tSellers: \"sellers\",\n\tAuth: \"auth\",\n\tLogin: \"login\",\n\tSignup: \"signup\",\n\tGuide: \"guide\",\n\tDocs: \"docs\",\n\tI18n: \"i18n\",\n\tIncident: \"incident\",\n\tAutomation: \"automation\",\n\tHygiene: \"hygiene\"\n};\nconst Tags = TagsEnum;\n\n//#endregion\nexport { Owners, OwnersEnum, StabilityEnum, Tags, TagsEnum };"],"mappings":";AACA,MAAM,gBAAgB;CACrB,MAAM;CACN,YAAY;CACZ,cAAc;CACd,MAAM;CACN,QAAQ;CACR,YAAY;CACZ;AACD,MAAM,aAAa;CAClB,iBAAiB;CACjB,cAAc;CACd,kBAAkB;CAClB,eAAe;CACf,qBAAqB;CACrB,iBAAiB;CACjB,sBAAsB;CACtB,iBAAiB;CACjB"}
1
+ {"version":3,"file":"ownership.js","names":[],"sources":["../../../../../../libs/contracts/dist/ownership.js"],"sourcesContent":["//#region src/ownership.ts\nconst StabilityEnum = {\n\tIdea: \"idea\",\n\tInCreation: \"in_creation\",\n\tExperimental: \"experimental\",\n\tBeta: \"beta\",\n\tStable: \"stable\",\n\tDeprecated: \"deprecated\"\n};\nconst OwnersEnum = {\n\tProductColiving: \"product.coliving\",\n\tProductStrit: \"product.strit\",\n\tProductArtisanos: \"product.artisanos\",\n\tPlatformSigil: \"platform.sigil\",\n\tPlatformMarketplace: \"platform.marketplace\",\n\tPlatformMessaging: \"platform.messaging\",\n\tPlatformContent: \"platform.content\",\n\tPlatformFeatureFlags: \"platform.featureflags\",\n\tPlatformFinance: \"platform.finance\"\n};\nconst Owners = OwnersEnum;\nconst TagsEnum = {\n\tSpots: \"spots\",\n\tCollectivity: \"collectivity\",\n\tMarketplace: \"marketplace\",\n\tSellers: \"sellers\",\n\tAuth: \"auth\",\n\tLogin: \"login\",\n\tSignup: \"signup\",\n\tGuide: \"guide\",\n\tDocs: \"docs\",\n\tI18n: \"i18n\",\n\tIncident: \"incident\",\n\tAutomation: \"automation\",\n\tHygiene: \"hygiene\"\n};\nconst Tags = TagsEnum;\n\n//#endregion\nexport { Owners, OwnersEnum, StabilityEnum, Tags, TagsEnum };"],"mappings":";AACA,MAAM,gBAAgB;CACrB,MAAM;CACN,YAAY;CACZ,cAAc;CACd,MAAM;CACN,QAAQ;CACR,YAAY;CACZ;AACD,MAAM,aAAa;CAClB,iBAAiB;CACjB,cAAc;CACd,kBAAkB;CAClB,eAAe;CACf,qBAAqB;CACrB,mBAAmB;CACnB,iBAAiB;CACjB,sBAAsB;CACtB,iBAAiB;CACjB"}
@@ -1,120 +1,120 @@
1
1
  import * as _lssm_lib_contracts9 from "@lssm/lib.contracts";
2
- import * as _lssm_lib_schema248 from "@lssm/lib.schema";
2
+ import * as _lssm_lib_schema247 from "@lssm/lib.schema";
3
3
 
4
4
  //#region src/query/query.contracts.d.ts
5
5
  /**
6
6
  * Create a data query.
7
7
  */
8
- declare const CreateQueryContract: _lssm_lib_contracts9.ContractSpec<_lssm_lib_schema248.SchemaModel<{
8
+ declare const CreateQueryContract: _lssm_lib_contracts9.ContractSpec<_lssm_lib_schema247.SchemaModel<{
9
9
  name: {
10
- type: _lssm_lib_schema248.FieldType<string, string>;
10
+ type: _lssm_lib_schema247.FieldType<string, string>;
11
11
  isOptional: false;
12
12
  };
13
13
  description: {
14
- type: _lssm_lib_schema248.FieldType<string, string>;
14
+ type: _lssm_lib_schema247.FieldType<string, string>;
15
15
  isOptional: true;
16
16
  };
17
17
  type: {
18
- type: _lssm_lib_schema248.EnumType<[string, string, string, string]>;
18
+ type: _lssm_lib_schema247.EnumType<[string, string, string, string]>;
19
19
  isOptional: false;
20
20
  };
21
21
  definition: {
22
- type: _lssm_lib_schema248.FieldType<unknown, unknown>;
22
+ type: _lssm_lib_schema247.FieldType<unknown, unknown>;
23
23
  isOptional: false;
24
24
  };
25
25
  sql: {
26
- type: _lssm_lib_schema248.FieldType<string, string>;
26
+ type: _lssm_lib_schema247.FieldType<string, string>;
27
27
  isOptional: true;
28
28
  };
29
29
  metricIds: {
30
- type: _lssm_lib_schema248.FieldType<string, string>;
30
+ type: _lssm_lib_schema247.FieldType<string, string>;
31
31
  isArray: true;
32
32
  isOptional: true;
33
33
  };
34
34
  cacheTtlSeconds: {
35
- type: _lssm_lib_schema248.FieldType<number, number>;
35
+ type: _lssm_lib_schema247.FieldType<number, number>;
36
36
  isOptional: true;
37
37
  };
38
38
  isShared: {
39
- type: _lssm_lib_schema248.FieldType<boolean, boolean>;
39
+ type: _lssm_lib_schema247.FieldType<boolean, boolean>;
40
40
  isOptional: true;
41
41
  };
42
- }>, _lssm_lib_schema248.SchemaModel<{
42
+ }>, _lssm_lib_schema247.SchemaModel<{
43
43
  id: {
44
- type: _lssm_lib_schema248.FieldType<string, string>;
44
+ type: _lssm_lib_schema247.FieldType<string, string>;
45
45
  isOptional: false;
46
46
  };
47
47
  name: {
48
- type: _lssm_lib_schema248.FieldType<string, string>;
48
+ type: _lssm_lib_schema247.FieldType<string, string>;
49
49
  isOptional: false;
50
50
  };
51
51
  description: {
52
- type: _lssm_lib_schema248.FieldType<string, string>;
52
+ type: _lssm_lib_schema247.FieldType<string, string>;
53
53
  isOptional: true;
54
54
  };
55
55
  type: {
56
- type: _lssm_lib_schema248.EnumType<[string, string, string, string]>;
56
+ type: _lssm_lib_schema247.EnumType<[string, string, string, string]>;
57
57
  isOptional: false;
58
58
  };
59
59
  definition: {
60
- type: _lssm_lib_schema248.FieldType<unknown, unknown>;
60
+ type: _lssm_lib_schema247.FieldType<unknown, unknown>;
61
61
  isOptional: false;
62
62
  };
63
63
  sql: {
64
- type: _lssm_lib_schema248.FieldType<string, string>;
64
+ type: _lssm_lib_schema247.FieldType<string, string>;
65
65
  isOptional: true;
66
66
  };
67
67
  cacheTtlSeconds: {
68
- type: _lssm_lib_schema248.FieldType<number, number>;
68
+ type: _lssm_lib_schema247.FieldType<number, number>;
69
69
  isOptional: false;
70
70
  };
71
71
  isShared: {
72
- type: _lssm_lib_schema248.FieldType<boolean, boolean>;
72
+ type: _lssm_lib_schema247.FieldType<boolean, boolean>;
73
73
  isOptional: false;
74
74
  };
75
75
  createdAt: {
76
- type: _lssm_lib_schema248.FieldType<Date, string>;
76
+ type: _lssm_lib_schema247.FieldType<Date, string>;
77
77
  isOptional: false;
78
78
  };
79
79
  }>, {
80
80
  name: string;
81
81
  version: number;
82
82
  when: string;
83
- payload: _lssm_lib_schema248.SchemaModel<{
83
+ payload: _lssm_lib_schema247.SchemaModel<{
84
84
  id: {
85
- type: _lssm_lib_schema248.FieldType<string, string>;
85
+ type: _lssm_lib_schema247.FieldType<string, string>;
86
86
  isOptional: false;
87
87
  };
88
88
  name: {
89
- type: _lssm_lib_schema248.FieldType<string, string>;
89
+ type: _lssm_lib_schema247.FieldType<string, string>;
90
90
  isOptional: false;
91
91
  };
92
92
  description: {
93
- type: _lssm_lib_schema248.FieldType<string, string>;
93
+ type: _lssm_lib_schema247.FieldType<string, string>;
94
94
  isOptional: true;
95
95
  };
96
96
  type: {
97
- type: _lssm_lib_schema248.EnumType<[string, string, string, string]>;
97
+ type: _lssm_lib_schema247.EnumType<[string, string, string, string]>;
98
98
  isOptional: false;
99
99
  };
100
100
  definition: {
101
- type: _lssm_lib_schema248.FieldType<unknown, unknown>;
101
+ type: _lssm_lib_schema247.FieldType<unknown, unknown>;
102
102
  isOptional: false;
103
103
  };
104
104
  sql: {
105
- type: _lssm_lib_schema248.FieldType<string, string>;
105
+ type: _lssm_lib_schema247.FieldType<string, string>;
106
106
  isOptional: true;
107
107
  };
108
108
  cacheTtlSeconds: {
109
- type: _lssm_lib_schema248.FieldType<number, number>;
109
+ type: _lssm_lib_schema247.FieldType<number, number>;
110
110
  isOptional: false;
111
111
  };
112
112
  isShared: {
113
- type: _lssm_lib_schema248.FieldType<boolean, boolean>;
113
+ type: _lssm_lib_schema247.FieldType<boolean, boolean>;
114
114
  isOptional: false;
115
115
  };
116
116
  createdAt: {
117
- type: _lssm_lib_schema248.FieldType<Date, string>;
117
+ type: _lssm_lib_schema247.FieldType<Date, string>;
118
118
  isOptional: false;
119
119
  };
120
120
  }>;
@@ -122,54 +122,54 @@ declare const CreateQueryContract: _lssm_lib_contracts9.ContractSpec<_lssm_lib_s
122
122
  /**
123
123
  * Execute a data query.
124
124
  */
125
- declare const ExecuteQueryContract: _lssm_lib_contracts9.ContractSpec<_lssm_lib_schema248.SchemaModel<{
125
+ declare const ExecuteQueryContract: _lssm_lib_contracts9.ContractSpec<_lssm_lib_schema247.SchemaModel<{
126
126
  queryId: {
127
- type: _lssm_lib_schema248.FieldType<string, string>;
127
+ type: _lssm_lib_schema247.FieldType<string, string>;
128
128
  isOptional: false;
129
129
  };
130
130
  parameters: {
131
- type: _lssm_lib_schema248.FieldType<unknown, unknown>;
131
+ type: _lssm_lib_schema247.FieldType<unknown, unknown>;
132
132
  isOptional: true;
133
133
  };
134
134
  dateRange: {
135
- type: _lssm_lib_schema248.FieldType<unknown, unknown>;
135
+ type: _lssm_lib_schema247.FieldType<unknown, unknown>;
136
136
  isOptional: true;
137
137
  };
138
138
  filters: {
139
- type: _lssm_lib_schema248.FieldType<unknown, unknown>;
139
+ type: _lssm_lib_schema247.FieldType<unknown, unknown>;
140
140
  isOptional: true;
141
141
  };
142
142
  forceRefresh: {
143
- type: _lssm_lib_schema248.FieldType<boolean, boolean>;
143
+ type: _lssm_lib_schema247.FieldType<boolean, boolean>;
144
144
  isOptional: true;
145
145
  };
146
- }>, _lssm_lib_schema248.SchemaModel<{
146
+ }>, _lssm_lib_schema247.SchemaModel<{
147
147
  queryId: {
148
- type: _lssm_lib_schema248.FieldType<string, string>;
148
+ type: _lssm_lib_schema247.FieldType<string, string>;
149
149
  isOptional: false;
150
150
  };
151
151
  data: {
152
- type: _lssm_lib_schema248.FieldType<unknown, unknown>;
152
+ type: _lssm_lib_schema247.FieldType<unknown, unknown>;
153
153
  isOptional: false;
154
154
  };
155
155
  columns: {
156
- type: _lssm_lib_schema248.FieldType<unknown, unknown>;
156
+ type: _lssm_lib_schema247.FieldType<unknown, unknown>;
157
157
  isOptional: false;
158
158
  };
159
159
  rowCount: {
160
- type: _lssm_lib_schema248.FieldType<number, number>;
160
+ type: _lssm_lib_schema247.FieldType<number, number>;
161
161
  isOptional: false;
162
162
  };
163
163
  executionTimeMs: {
164
- type: _lssm_lib_schema248.FieldType<number, number>;
164
+ type: _lssm_lib_schema247.FieldType<number, number>;
165
165
  isOptional: false;
166
166
  };
167
167
  cachedAt: {
168
- type: _lssm_lib_schema248.FieldType<Date, string>;
168
+ type: _lssm_lib_schema247.FieldType<Date, string>;
169
169
  isOptional: true;
170
170
  };
171
171
  error: {
172
- type: _lssm_lib_schema248.FieldType<string, string>;
172
+ type: _lssm_lib_schema247.FieldType<string, string>;
173
173
  isOptional: true;
174
174
  };
175
175
  }>, undefined>;
@@ -1,10 +1,10 @@
1
- import * as _lssm_lib_schema247 from "@lssm/lib.schema";
1
+ import * as _lssm_lib_schema290 from "@lssm/lib.schema";
2
2
 
3
3
  //#region src/query/query.enum.d.ts
4
4
  /**
5
5
  * Query type enum.
6
6
  */
7
- declare const QueryTypeEnum: _lssm_lib_schema247.EnumType<[string, string, string, string]>;
7
+ declare const QueryTypeEnum: _lssm_lib_schema290.EnumType<[string, string, string, string]>;
8
8
  //#endregion
9
9
  export { QueryTypeEnum };
10
10
  //# sourceMappingURL=query.enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/query-engine/index.ts"],"sourcesContent":[],"mappings":";;AAQA;AAQA;;;AAIY,UAZK,eAAA,CAYL;EACA,IAAA,EAAA,KAAA,GAAA,QAAA,GAAA,aAAA,GAAA,QAAA;EAAiB,GAAA,CAAA,EAAA,MAAA;EAIZ,SAAA,CAAA,EAAA,MAAA,EAAiB;EAOjB,WAAA,CAAA,EApBD,qBAoBoB;EAOnB,MAAA,CAAA,EA1BN,qBA0BsB;AAgBjC;AAKiB,UA5CA,qBAAA,CA8CH;EAGG,MAAA,EAAA,MAAA;EAEN,QAAA,EAjDC,iBAiDD,EAAA;EACF,UAAA,EAjDK,mBAiDL,EAAA;EAGG,OAAA,CAAA,EAnDA,gBAmDA,EAAA;EACG,OAAA,CAAA,EAnDH,iBAmDG,EAAA;EAAM,KAAA,CAAA,EAAA,MAAA;AAGrB;AACQ,UAnDS,iBAAA,CAmDT;EACG,IAAA,EAAA,MAAA;EAIE,KAAA,EAAA,MAAA;EAAI,WAAA,EAAA,OAAA,GAAA,KAAA,GAAA,KAAA,GAAA,KAAA,GAAA,KAAA,GAAA,gBAAA;EAIA,MAAA,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;EACO,KAAA,EAAA,OAAA;;AACI,UAvDd,iBAAA,CAuDc;EAAO,KAAA,EAAA,MAAA;EAGzB,SAAA,EAAA,KAAA,GAAA,MAAmB;;AAGN,UAxDT,qBAAA,CAwDS;EAYd,OAAA,EAAA,MAAA;EAEP,UAAA,EApES,MAoET,CAAA,MAAA,EAAA,OAAA,CAAA;;AAjBsC,UAhD1B,eAAA,CAgD0B;EAAW,SAAA,CAAA,EAAA;IAkCzC,KAAA,EAhFF,IAgFE;IAGS,GAAA,EAlFb,IAkFa;IAKN,WAAA,CAAA,EAAA,MAAA;EACJ,CAAA;EACC,OAAA,CAAA,EAtFD,gBAsFC,EAAA;EAAR,UAAA,CAAA,EArFU,MAqFV,CAAA,MAAA,EAAA,OAAA,CAAA;;AAVoC,UAxExB,WAAA,CAwEwB;EAAY,IAAA,EAvE7C,MAuE6C,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA;EA6OrC,OAAA,EAnTL,gBAmTsB,EAAA;;;;aA/SpB;;;UAII,gBAAA;;;;;;UASA,YAAA;sBAED,yBACJ,kBACP,QAAQ;4BACe;;;;;UAQX,WAAA;oBACG,QAAQ;2BACD,kCAAkC;+BAC9B;;cAGlB,kBAAA,YAA8B;;oBAGjB,QAAQ;2BAYtB,kCAEP;+BAKgC;;cAYxB,gBAAA,YAA4B;;sBAGnB;sBAKN,yBACJ,kBACP,QAAQ;4BAgEe;;;;;;;;;;iBAmKZ,iBAAA,SAA0B,cAAc"}
@@ -48,12 +48,15 @@ var BasicQueryEngine = class {
48
48
  let result;
49
49
  switch (definition.type) {
50
50
  case "AGGREGATION":
51
+ if (!definition.aggregation) throw new Error("Aggregation definition is missing");
51
52
  result = await this.executeAggregation(definition.aggregation, params);
52
53
  break;
53
54
  case "METRIC":
55
+ if (!definition.metricIds) throw new Error("Metric IDs are missing");
54
56
  result = await this.executeMetric(definition.metricIds, params);
55
57
  break;
56
58
  case "SQL":
59
+ if (!definition.sql) throw new Error("SQL query is missing");
57
60
  result = await this.executeSql(definition.sql, params);
58
61
  break;
59
62
  default: result = {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["result: QueryResult","errors: string[]","columns: ColumnDefinition[]","data: Record<string, unknown>[]","row: Record<string, unknown>"],"sources":["../../src/query-engine/index.ts"],"sourcesContent":["/**\n * Analytics Query Engine\n *\n * Provides query execution and caching for analytics dashboards.\n */\n\n// ============ Types ============\n\nexport interface QueryDefinition {\n type: 'SQL' | 'METRIC' | 'AGGREGATION' | 'CUSTOM';\n sql?: string;\n metricIds?: string[];\n aggregation?: AggregationDefinition;\n custom?: CustomQueryDefinition;\n}\n\nexport interface AggregationDefinition {\n source: string;\n measures: MeasureDefinition[];\n dimensions: DimensionDefinition[];\n filters?: FilterDefinition[];\n orderBy?: OrderByDefinition[];\n limit?: number;\n}\n\nexport interface MeasureDefinition {\n name: string;\n field: string;\n aggregation: 'COUNT' | 'SUM' | 'AVG' | 'MIN' | 'MAX' | 'COUNT_DISTINCT';\n format?: string;\n}\n\nexport interface DimensionDefinition {\n name: string;\n field: string;\n type?: 'TIME' | 'STRING' | 'NUMBER';\n granularity?: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';\n}\n\nexport interface FilterDefinition {\n field: string;\n operator:\n | 'eq'\n | 'neq'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'in'\n | 'nin'\n | 'contains'\n | 'between';\n value: unknown;\n}\n\nexport interface OrderByDefinition {\n field: string;\n direction: 'ASC' | 'DESC';\n}\n\nexport interface CustomQueryDefinition {\n handler: string;\n parameters: Record<string, unknown>;\n}\n\nexport interface QueryParameters {\n dateRange?: {\n start: Date;\n end: Date;\n granularity?: string;\n };\n filters?: FilterDefinition[];\n parameters?: Record<string, unknown>;\n}\n\nexport interface QueryResult {\n data: Record<string, unknown>[];\n columns: ColumnDefinition[];\n rowCount: number;\n executionTimeMs: number;\n cached: boolean;\n cachedAt?: Date;\n error?: string;\n}\n\nexport interface ColumnDefinition {\n name: string;\n type: 'STRING' | 'NUMBER' | 'DATE' | 'BOOLEAN';\n label?: string;\n format?: string;\n}\n\n// ============ Query Engine Interface ============\n\nexport interface IQueryEngine {\n execute(\n definition: QueryDefinition,\n params: QueryParameters\n ): Promise<QueryResult>;\n validateQuery(definition: QueryDefinition): {\n valid: boolean;\n errors: string[];\n };\n}\n\n// ============ Query Cache ============\n\nexport interface IQueryCache {\n get(key: string): Promise<QueryResult | null>;\n set(key: string, result: QueryResult, ttlSeconds: number): Promise<void>;\n invalidate(pattern: string): Promise<void>;\n}\n\nexport class InMemoryQueryCache implements IQueryCache {\n private cache = new Map<string, { result: QueryResult; expiresAt: Date }>();\n\n async get(key: string): Promise<QueryResult | null> {\n const entry = this.cache.get(key);\n if (!entry) return null;\n if (entry.expiresAt < new Date()) {\n this.cache.delete(key);\n return null;\n }\n return { ...entry.result, cached: true, cachedAt: entry.expiresAt };\n }\n\n async set(\n key: string,\n result: QueryResult,\n ttlSeconds: number\n ): Promise<void> {\n const expiresAt = new Date(Date.now() + ttlSeconds * 1000);\n this.cache.set(key, { result, expiresAt });\n }\n\n async invalidate(pattern: string): Promise<void> {\n const regex = new RegExp(pattern);\n for (const key of this.cache.keys()) {\n if (regex.test(key)) {\n this.cache.delete(key);\n }\n }\n }\n}\n\n// ============ Basic Query Engine ============\n\nexport class BasicQueryEngine implements IQueryEngine {\n private cache: IQueryCache;\n\n constructor(cache?: IQueryCache) {\n this.cache = cache ?? new InMemoryQueryCache();\n }\n\n async execute(\n definition: QueryDefinition,\n params: QueryParameters\n ): Promise<QueryResult> {\n const startTime = Date.now();\n\n // Validate query\n const validation = this.validateQuery(definition);\n if (!validation.valid) {\n return {\n data: [],\n columns: [],\n rowCount: 0,\n executionTimeMs: Date.now() - startTime,\n cached: false,\n error: validation.errors.join(', '),\n };\n }\n\n // Check cache\n const cacheKey = this.buildCacheKey(definition, params);\n const cachedResult = await this.cache.get(cacheKey);\n if (cachedResult) {\n return cachedResult;\n }\n\n // Execute query based on type\n let result: QueryResult;\n switch (definition.type) {\n case 'AGGREGATION':\n result = await this.executeAggregation(definition.aggregation!, params);\n break;\n case 'METRIC':\n result = await this.executeMetric(definition.metricIds!, params);\n break;\n case 'SQL':\n result = await this.executeSql(definition.sql!, params);\n break;\n default:\n result = {\n data: [],\n columns: [],\n rowCount: 0,\n executionTimeMs: Date.now() - startTime,\n cached: false,\n error: `Unknown query type: ${definition.type}`,\n };\n }\n\n result.executionTimeMs = Date.now() - startTime;\n result.cached = false;\n\n // Cache result\n await this.cache.set(cacheKey, result, 300);\n\n return result;\n }\n\n validateQuery(definition: QueryDefinition): {\n valid: boolean;\n errors: string[];\n } {\n const errors: string[] = [];\n\n if (!definition.type) {\n errors.push('Query type is required');\n }\n\n switch (definition.type) {\n case 'SQL':\n if (!definition.sql) {\n errors.push('SQL query is required for SQL type');\n }\n break;\n case 'METRIC':\n if (!definition.metricIds || definition.metricIds.length === 0) {\n errors.push('Metric IDs are required for METRIC type');\n }\n break;\n case 'AGGREGATION':\n if (!definition.aggregation) {\n errors.push(\n 'Aggregation definition is required for AGGREGATION type'\n );\n } else {\n if (!definition.aggregation.source) {\n errors.push('Aggregation source is required');\n }\n if (\n !definition.aggregation.measures ||\n definition.aggregation.measures.length === 0\n ) {\n errors.push('At least one measure is required');\n }\n }\n break;\n }\n\n return { valid: errors.length === 0, errors };\n }\n\n private buildCacheKey(\n definition: QueryDefinition,\n params: QueryParameters\n ): string {\n return JSON.stringify({ definition, params });\n }\n\n private async executeAggregation(\n aggregation: AggregationDefinition,\n params: QueryParameters\n ): Promise<QueryResult> {\n // In production, this would execute against a data warehouse\n // For demo, return mock data\n const columns: ColumnDefinition[] = [\n ...aggregation.dimensions.map((d) => ({\n name: d.name,\n type: (d.type === 'NUMBER'\n ? 'NUMBER'\n : d.type === 'TIME'\n ? 'DATE'\n : 'STRING') as ColumnDefinition['type'],\n label: d.name,\n })),\n ...aggregation.measures.map((m) => ({\n name: m.name,\n type: 'NUMBER' as const,\n label: m.name,\n format: m.format,\n })),\n ];\n\n // Mock data generation\n const data = this.generateMockData(aggregation, params);\n\n return {\n data,\n columns,\n rowCount: data.length,\n executionTimeMs: 0,\n cached: false,\n };\n }\n\n private async executeMetric(\n metricIds: string[],\n _params: QueryParameters\n ): Promise<QueryResult> {\n // In production, this would fetch from metering service\n const data = metricIds.map((id) => ({\n metricId: id,\n value: Math.random() * 1000,\n change: (Math.random() - 0.5) * 20,\n }));\n\n return {\n data,\n columns: [\n { name: 'metricId', type: 'STRING' },\n { name: 'value', type: 'NUMBER' },\n { name: 'change', type: 'NUMBER' },\n ],\n rowCount: data.length,\n executionTimeMs: 0,\n cached: false,\n };\n }\n\n private async executeSql(\n _sql: string,\n _params: QueryParameters\n ): Promise<QueryResult> {\n // In production, this would execute SQL against a database\n return {\n data: [],\n columns: [],\n rowCount: 0,\n executionTimeMs: 0,\n cached: false,\n error: 'SQL execution not implemented in demo',\n };\n }\n\n private generateMockData(\n aggregation: AggregationDefinition,\n params: QueryParameters\n ): Record<string, unknown>[] {\n const data: Record<string, unknown>[] = [];\n const rowCount = 10;\n\n // Generate time series data if there's a time dimension\n const timeDimension = aggregation.dimensions.find((d) => d.type === 'TIME');\n\n for (let i = 0; i < rowCount; i++) {\n const row: Record<string, unknown> = {};\n\n for (const dim of aggregation.dimensions) {\n if (dim.type === 'TIME') {\n const date = new Date(params.dateRange?.start ?? new Date());\n date.setDate(date.getDate() + i);\n row[dim.name] = date.toISOString().split('T')[0];\n } else {\n row[dim.name] = `${dim.name}_${i % 5}`;\n }\n }\n\n for (const measure of aggregation.measures) {\n const baseValue = timeDimension ? 100 + i * 10 : Math.random() * 1000;\n const noise = (Math.random() - 0.5) * 20;\n row[measure.name] = Math.round((baseValue + noise) * 100) / 100;\n }\n\n data.push(row);\n }\n\n return data;\n }\n}\n\n// ============ Factory ============\n\nexport function createQueryEngine(cache?: IQueryCache): IQueryEngine {\n return new BasicQueryEngine(cache);\n}\n"],"mappings":";AAiHA,IAAa,qBAAb,MAAuD;C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,KAAK,KAAK,QAAQ,GAAG;IACjE,MAAM,SAAS,KAAK,QAAQ,GAAG,MAAO;AACtC,QAAI,QAAQ,QAAQ,KAAK,OAAO,YAAY,SAAS,IAAI,GAAG;;AAG9D,QAAK,KAAK,IAAI;;AAGhB,SAAO;;;AAMX,SAAgB,kBAAkB,OAAmC;AACnE,QAAO,IAAI,iBAAiB,MAAM"}
1
+ {"version":3,"file":"index.js","names":["result: QueryResult","errors: string[]","columns: ColumnDefinition[]","data: Record<string, unknown>[]","row: Record<string, unknown>"],"sources":["../../src/query-engine/index.ts"],"sourcesContent":["/**\n * Analytics Query Engine\n *\n * Provides query execution and caching for analytics dashboards.\n */\n\n// ============ Types ============\n\nexport interface QueryDefinition {\n type: 'SQL' | 'METRIC' | 'AGGREGATION' | 'CUSTOM';\n sql?: string;\n metricIds?: string[];\n aggregation?: AggregationDefinition;\n custom?: CustomQueryDefinition;\n}\n\nexport interface AggregationDefinition {\n source: string;\n measures: MeasureDefinition[];\n dimensions: DimensionDefinition[];\n filters?: FilterDefinition[];\n orderBy?: OrderByDefinition[];\n limit?: number;\n}\n\nexport interface MeasureDefinition {\n name: string;\n field: string;\n aggregation: 'COUNT' | 'SUM' | 'AVG' | 'MIN' | 'MAX' | 'COUNT_DISTINCT';\n format?: string;\n}\n\nexport interface DimensionDefinition {\n name: string;\n field: string;\n type?: 'TIME' | 'STRING' | 'NUMBER';\n granularity?: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';\n}\n\nexport interface FilterDefinition {\n field: string;\n operator:\n | 'eq'\n | 'neq'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'in'\n | 'nin'\n | 'contains'\n | 'between';\n value: unknown;\n}\n\nexport interface OrderByDefinition {\n field: string;\n direction: 'ASC' | 'DESC';\n}\n\nexport interface CustomQueryDefinition {\n handler: string;\n parameters: Record<string, unknown>;\n}\n\nexport interface QueryParameters {\n dateRange?: {\n start: Date;\n end: Date;\n granularity?: string;\n };\n filters?: FilterDefinition[];\n parameters?: Record<string, unknown>;\n}\n\nexport interface QueryResult {\n data: Record<string, unknown>[];\n columns: ColumnDefinition[];\n rowCount: number;\n executionTimeMs: number;\n cached: boolean;\n cachedAt?: Date;\n error?: string;\n}\n\nexport interface ColumnDefinition {\n name: string;\n type: 'STRING' | 'NUMBER' | 'DATE' | 'BOOLEAN';\n label?: string;\n format?: string;\n}\n\n// ============ Query Engine Interface ============\n\nexport interface IQueryEngine {\n execute(\n definition: QueryDefinition,\n params: QueryParameters\n ): Promise<QueryResult>;\n validateQuery(definition: QueryDefinition): {\n valid: boolean;\n errors: string[];\n };\n}\n\n// ============ Query Cache ============\n\nexport interface IQueryCache {\n get(key: string): Promise<QueryResult | null>;\n set(key: string, result: QueryResult, ttlSeconds: number): Promise<void>;\n invalidate(pattern: string): Promise<void>;\n}\n\nexport class InMemoryQueryCache implements IQueryCache {\n private cache = new Map<string, { result: QueryResult; expiresAt: Date }>();\n\n async get(key: string): Promise<QueryResult | null> {\n const entry = this.cache.get(key);\n if (!entry) return null;\n if (entry.expiresAt < new Date()) {\n this.cache.delete(key);\n return null;\n }\n return { ...entry.result, cached: true, cachedAt: entry.expiresAt };\n }\n\n async set(\n key: string,\n result: QueryResult,\n ttlSeconds: number\n ): Promise<void> {\n const expiresAt = new Date(Date.now() + ttlSeconds * 1000);\n this.cache.set(key, { result, expiresAt });\n }\n\n async invalidate(pattern: string): Promise<void> {\n const regex = new RegExp(pattern);\n for (const key of this.cache.keys()) {\n if (regex.test(key)) {\n this.cache.delete(key);\n }\n }\n }\n}\n\n// ============ Basic Query Engine ============\n\nexport class BasicQueryEngine implements IQueryEngine {\n private cache: IQueryCache;\n\n constructor(cache?: IQueryCache) {\n this.cache = cache ?? new InMemoryQueryCache();\n }\n\n async execute(\n definition: QueryDefinition,\n params: QueryParameters\n ): Promise<QueryResult> {\n const startTime = Date.now();\n\n // Validate query\n const validation = this.validateQuery(definition);\n if (!validation.valid) {\n return {\n data: [],\n columns: [],\n rowCount: 0,\n executionTimeMs: Date.now() - startTime,\n cached: false,\n error: validation.errors.join(', '),\n };\n }\n\n // Check cache\n const cacheKey = this.buildCacheKey(definition, params);\n const cachedResult = await this.cache.get(cacheKey);\n if (cachedResult) {\n return cachedResult;\n }\n\n // Execute query based on type\n let result: QueryResult;\n switch (definition.type) {\n case 'AGGREGATION':\n if (!definition.aggregation) {\n throw new Error('Aggregation definition is missing');\n }\n result = await this.executeAggregation(definition.aggregation, params);\n break;\n case 'METRIC':\n if (!definition.metricIds) {\n throw new Error('Metric IDs are missing');\n }\n result = await this.executeMetric(definition.metricIds, params);\n break;\n case 'SQL':\n if (!definition.sql) {\n throw new Error('SQL query is missing');\n }\n result = await this.executeSql(definition.sql, params);\n break;\n default:\n result = {\n data: [],\n columns: [],\n rowCount: 0,\n executionTimeMs: Date.now() - startTime,\n cached: false,\n error: `Unknown query type: ${definition.type}`,\n };\n }\n\n result.executionTimeMs = Date.now() - startTime;\n result.cached = false;\n\n // Cache result\n await this.cache.set(cacheKey, result, 300);\n\n return result;\n }\n\n validateQuery(definition: QueryDefinition): {\n valid: boolean;\n errors: string[];\n } {\n const errors: string[] = [];\n\n if (!definition.type) {\n errors.push('Query type is required');\n }\n\n switch (definition.type) {\n case 'SQL':\n if (!definition.sql) {\n errors.push('SQL query is required for SQL type');\n }\n break;\n case 'METRIC':\n if (!definition.metricIds || definition.metricIds.length === 0) {\n errors.push('Metric IDs are required for METRIC type');\n }\n break;\n case 'AGGREGATION':\n if (!definition.aggregation) {\n errors.push(\n 'Aggregation definition is required for AGGREGATION type'\n );\n } else {\n if (!definition.aggregation.source) {\n errors.push('Aggregation source is required');\n }\n if (\n !definition.aggregation.measures ||\n definition.aggregation.measures.length === 0\n ) {\n errors.push('At least one measure is required');\n }\n }\n break;\n }\n\n return { valid: errors.length === 0, errors };\n }\n\n private buildCacheKey(\n definition: QueryDefinition,\n params: QueryParameters\n ): string {\n return JSON.stringify({ definition, params });\n }\n\n private async executeAggregation(\n aggregation: AggregationDefinition,\n params: QueryParameters\n ): Promise<QueryResult> {\n // In production, this would execute against a data warehouse\n // For demo, return mock data\n const columns: ColumnDefinition[] = [\n ...aggregation.dimensions.map((d) => ({\n name: d.name,\n type: (d.type === 'NUMBER'\n ? 'NUMBER'\n : d.type === 'TIME'\n ? 'DATE'\n : 'STRING') as ColumnDefinition['type'],\n label: d.name,\n })),\n ...aggregation.measures.map((m) => ({\n name: m.name,\n type: 'NUMBER' as const,\n label: m.name,\n format: m.format,\n })),\n ];\n\n // Mock data generation\n const data = this.generateMockData(aggregation, params);\n\n return {\n data,\n columns,\n rowCount: data.length,\n executionTimeMs: 0,\n cached: false,\n };\n }\n\n private async executeMetric(\n metricIds: string[],\n _params: QueryParameters\n ): Promise<QueryResult> {\n // In production, this would fetch from metering service\n const data = metricIds.map((id) => ({\n metricId: id,\n value: Math.random() * 1000,\n change: (Math.random() - 0.5) * 20,\n }));\n\n return {\n data,\n columns: [\n { name: 'metricId', type: 'STRING' },\n { name: 'value', type: 'NUMBER' },\n { name: 'change', type: 'NUMBER' },\n ],\n rowCount: data.length,\n executionTimeMs: 0,\n cached: false,\n };\n }\n\n private async executeSql(\n _sql: string,\n _params: QueryParameters\n ): Promise<QueryResult> {\n // In production, this would execute SQL against a database\n return {\n data: [],\n columns: [],\n rowCount: 0,\n executionTimeMs: 0,\n cached: false,\n error: 'SQL execution not implemented in demo',\n };\n }\n\n private generateMockData(\n aggregation: AggregationDefinition,\n params: QueryParameters\n ): Record<string, unknown>[] {\n const data: Record<string, unknown>[] = [];\n const rowCount = 10;\n\n // Generate time series data if there's a time dimension\n const timeDimension = aggregation.dimensions.find((d) => d.type === 'TIME');\n\n for (let i = 0; i < rowCount; i++) {\n const row: Record<string, unknown> = {};\n\n for (const dim of aggregation.dimensions) {\n if (dim.type === 'TIME') {\n const date = new Date(params.dateRange?.start ?? new Date());\n date.setDate(date.getDate() + i);\n row[dim.name] = date.toISOString().split('T')[0];\n } else {\n row[dim.name] = `${dim.name}_${i % 5}`;\n }\n }\n\n for (const measure of aggregation.measures) {\n const baseValue = timeDimension ? 100 + i * 10 : Math.random() * 1000;\n const noise = (Math.random() - 0.5) * 20;\n row[measure.name] = Math.round((baseValue + noise) * 100) / 100;\n }\n\n data.push(row);\n }\n\n return data;\n }\n}\n\n// ============ Factory ============\n\nexport function createQueryEngine(cache?: IQueryCache): IQueryEngine {\n return new BasicQueryEngine(cache);\n}\n"],"mappings":";AAiHA,IAAa,qBAAb,MAAuD;CACrD,AAAQ,wBAAQ,IAAI,KAAuD;CAE3E,MAAM,IAAI,KAA0C;EAClD,MAAM,QAAQ,KAAK,MAAM,IAAI,IAAI;AACjC,MAAI,CAAC,MAAO,QAAO;AACnB,MAAI,MAAM,4BAAY,IAAI,MAAM,EAAE;AAChC,QAAK,MAAM,OAAO,IAAI;AACtB,UAAO;;AAET,SAAO;GAAE,GAAG,MAAM;GAAQ,QAAQ;GAAM,UAAU,MAAM;GAAW;;CAGrE,MAAM,IACJ,KACA,QACA,YACe;EACf,MAAM,YAAY,IAAI,KAAK,KAAK,KAAK,GAAG,aAAa,IAAK;AAC1D,OAAK,MAAM,IAAI,KAAK;GAAE;GAAQ;GAAW,CAAC;;CAG5C,MAAM,WAAW,SAAgC;EAC/C,MAAM,QAAQ,IAAI,OAAO,QAAQ;AACjC,OAAK,MAAM,OAAO,KAAK,MAAM,MAAM,CACjC,KAAI,MAAM,KAAK,IAAI,CACjB,MAAK,MAAM,OAAO,IAAI;;;AAQ9B,IAAa,mBAAb,MAAsD;CACpD,AAAQ;CAER,YAAY,OAAqB;AAC/B,OAAK,QAAQ,SAAS,IAAI,oBAAoB;;CAGhD,MAAM,QACJ,YACA,QACsB;EACtB,MAAM,YAAY,KAAK,KAAK;EAG5B,MAAM,aAAa,KAAK,cAAc,WAAW;AACjD,MAAI,CAAC,WAAW,MACd,QAAO;GACL,MAAM,EAAE;GACR,SAAS,EAAE;GACX,UAAU;GACV,iBAAiB,KAAK,KAAK,GAAG;GAC9B,Q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AAM,MAAM,EAAE,SAAS,OAAO;AAE3E,OAAK,IAAI,IAAI,GAAG,IAAI,UAAU,KAAK;GACjC,MAAMC,MAA+B,EAAE;AAEvC,QAAK,MAAM,OAAO,YAAY,WAC5B,KAAI,IAAI,SAAS,QAAQ;IACvB,MAAM,OAAO,IAAI,KAAK,OAAO,WAAW,yBAAS,IAAI,MAAM,CAAC;AAC5D,SAAK,QAAQ,KAAK,SAAS,GAAG,EAAE;AAChC,QAAI,IAAI,QAAQ,KAAK,aAAa,CAAC,MAAM,IAAI,CAAC;SAE9C,KAAI,IAAI,QAAQ,GAAG,IAAI,KAAK,GAAG,IAAI;AAIvC,QAAK,MAAM,WAAW,YAAY,UAAU;IAC1C,MAAM,YAAY,gBAAgB,MAAM,IAAI,KAAK,KAAK,QAAQ,GAAG;IACjE,MAAM,SAAS,KAAK,QAAQ,GAAG,MAAO;AACtC,QAAI,QAAQ,QAAQ,KAAK,OAAO,YAAY,SAAS,IAAI,GAAG;;AAG9D,QAAK,KAAK,IAAI;;AAGhB,SAAO;;;AAMX,SAAgB,kBAAkB,OAAmC;AACnE,QAAO,IAAI,iBAAiB,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/example.analytics-dashboard",
3
- "version": "0.0.0-canary-20251220002821",
3
+ "version": "0.0.0-canary-20251220015515",
4
4
  "description": "Analytics Dashboard example with widgets and query engine for ContractSpec",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -18,18 +18,18 @@
18
18
  "lint:check": "eslint src"
19
19
  },
20
20
  "dependencies": {
21
- "@lssm/lib.schema": "0.0.0-canary-20251220002821",
22
- "@lssm/lib.contracts": "0.0.0-canary-20251220002821",
23
- "@lssm/lib.bus": "0.0.0-canary-20251220002821",
24
- "@lssm/lib.identity-rbac": "0.0.0-canary-20251220002821",
25
- "@lssm/lib.metering": "0.0.0-canary-20251220002821",
26
- "@lssm/lib.jobs": "0.0.0-canary-20251220002821",
27
- "@lssm/module.audit-trail": "0.0.0-canary-20251220002821",
21
+ "@lssm/lib.schema": "0.0.0-canary-20251220015515",
22
+ "@lssm/lib.contracts": "0.0.0-canary-20251220015515",
23
+ "@lssm/lib.bus": "0.0.0-canary-20251220015515",
24
+ "@lssm/lib.identity-rbac": "0.0.0-canary-20251220015515",
25
+ "@lssm/lib.metering": "0.0.0-canary-20251220015515",
26
+ "@lssm/lib.jobs": "0.0.0-canary-20251220015515",
27
+ "@lssm/module.audit-trail": "0.0.0-canary-20251220015515",
28
28
  "zod": "^4.1.13"
29
29
  },
30
30
  "devDependencies": {
31
- "@lssm/tool.typescript": "0.0.0-canary-20251220002821",
32
- "@lssm/tool.tsdown": "0.0.0-canary-20251220002821",
31
+ "@lssm/tool.typescript": "0.0.0-canary-20251220015515",
32
+ "@lssm/tool.tsdown": "0.0.0-canary-20251220015515",
33
33
  "typescript": "^5.9.3"
34
34
  },
35
35
  "exports": {