@ultracart/bq-skill 0.1.2
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/LICENSE +191 -0
- package/README.md +952 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +42 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/alarm.d.ts +3 -0
- package/dist/commands/alarm.d.ts.map +1 -0
- package/dist/commands/alarm.js +146 -0
- package/dist/commands/alarm.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +749 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/deck.d.ts +3 -0
- package/dist/commands/deck.d.ts.map +1 -0
- package/dist/commands/deck.js +567 -0
- package/dist/commands/deck.js.map +1 -0
- package/dist/commands/dry-run.d.ts +3 -0
- package/dist/commands/dry-run.d.ts.map +1 -0
- package/dist/commands/dry-run.js +105 -0
- package/dist/commands/dry-run.js.map +1 -0
- package/dist/commands/history.d.ts +3 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +127 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +302 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install-skill.d.ts +3 -0
- package/dist/commands/install-skill.d.ts.map +1 -0
- package/dist/commands/install-skill.js +132 -0
- package/dist/commands/install-skill.js.map +1 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +89 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/query.d.ts +3 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +152 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/render.d.ts +3 -0
- package/dist/commands/render.d.ts.map +1 -0
- package/dist/commands/render.js +107 -0
- package/dist/commands/render.js.map +1 -0
- package/dist/commands/run-all.d.ts +3 -0
- package/dist/commands/run-all.d.ts.map +1 -0
- package/dist/commands/run-all.js +285 -0
- package/dist/commands/run-all.js.map +1 -0
- package/dist/commands/run.d.ts +3 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +321 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/schema.d.ts +3 -0
- package/dist/commands/schema.d.ts.map +1 -0
- package/dist/commands/schema.js +271 -0
- package/dist/commands/schema.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +109 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/lib/alarm-notify.d.ts +16 -0
- package/dist/lib/alarm-notify.d.ts.map +1 -0
- package/dist/lib/alarm-notify.js +312 -0
- package/dist/lib/alarm-notify.js.map +1 -0
- package/dist/lib/alarm-state.d.ts +26 -0
- package/dist/lib/alarm-state.d.ts.map +1 -0
- package/dist/lib/alarm-state.js +118 -0
- package/dist/lib/alarm-state.js.map +1 -0
- package/dist/lib/alarm.d.ts +28 -0
- package/dist/lib/alarm.d.ts.map +1 -0
- package/dist/lib/alarm.js +215 -0
- package/dist/lib/alarm.js.map +1 -0
- package/dist/lib/analysis.d.ts +16 -0
- package/dist/lib/analysis.d.ts.map +1 -0
- package/dist/lib/analysis.js +134 -0
- package/dist/lib/analysis.js.map +1 -0
- package/dist/lib/bigquery.d.ts +55 -0
- package/dist/lib/bigquery.d.ts.map +1 -0
- package/dist/lib/bigquery.js +321 -0
- package/dist/lib/bigquery.js.map +1 -0
- package/dist/lib/config-writer.d.ts +3 -0
- package/dist/lib/config-writer.d.ts.map +1 -0
- package/dist/lib/config-writer.js +60 -0
- package/dist/lib/config-writer.js.map +1 -0
- package/dist/lib/config.d.ts +63 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +151 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/dashboard.d.ts +3 -0
- package/dist/lib/dashboard.d.ts.map +1 -0
- package/dist/lib/dashboard.js +468 -0
- package/dist/lib/dashboard.js.map +1 -0
- package/dist/lib/deck.d.ts +58 -0
- package/dist/lib/deck.d.ts.map +1 -0
- package/dist/lib/deck.js +232 -0
- package/dist/lib/deck.js.map +1 -0
- package/dist/lib/deliver-email.d.ts +14 -0
- package/dist/lib/deliver-email.d.ts.map +1 -0
- package/dist/lib/deliver-email.js +360 -0
- package/dist/lib/deliver-email.js.map +1 -0
- package/dist/lib/deliver-slack.d.ts +6 -0
- package/dist/lib/deliver-slack.d.ts.map +1 -0
- package/dist/lib/deliver-slack.js +73 -0
- package/dist/lib/deliver-slack.js.map +1 -0
- package/dist/lib/deliver.d.ts +10 -0
- package/dist/lib/deliver.d.ts.map +1 -0
- package/dist/lib/deliver.js +95 -0
- package/dist/lib/deliver.js.map +1 -0
- package/dist/lib/llm/anthropic.d.ts +7 -0
- package/dist/lib/llm/anthropic.d.ts.map +1 -0
- package/dist/lib/llm/anthropic.js +69 -0
- package/dist/lib/llm/anthropic.js.map +1 -0
- package/dist/lib/llm/bedrock.d.ts +7 -0
- package/dist/lib/llm/bedrock.d.ts.map +1 -0
- package/dist/lib/llm/bedrock.js +67 -0
- package/dist/lib/llm/bedrock.js.map +1 -0
- package/dist/lib/llm/gemini.d.ts +7 -0
- package/dist/lib/llm/gemini.d.ts.map +1 -0
- package/dist/lib/llm/gemini.js +67 -0
- package/dist/lib/llm/gemini.js.map +1 -0
- package/dist/lib/llm/index.d.ts +5 -0
- package/dist/lib/llm/index.d.ts.map +1 -0
- package/dist/lib/llm/index.js +61 -0
- package/dist/lib/llm/index.js.map +1 -0
- package/dist/lib/llm/models.d.ts +5 -0
- package/dist/lib/llm/models.d.ts.map +1 -0
- package/dist/lib/llm/models.js +33 -0
- package/dist/lib/llm/models.js.map +1 -0
- package/dist/lib/llm/openai.d.ts +8 -0
- package/dist/lib/llm/openai.d.ts.map +1 -0
- package/dist/lib/llm/openai.js +48 -0
- package/dist/lib/llm/openai.js.map +1 -0
- package/dist/lib/llm/provider.d.ts +28 -0
- package/dist/lib/llm/provider.d.ts.map +1 -0
- package/dist/lib/llm/provider.js +3 -0
- package/dist/lib/llm/provider.js.map +1 -0
- package/dist/lib/manifest.d.ts +95 -0
- package/dist/lib/manifest.d.ts.map +1 -0
- package/dist/lib/manifest.js +105 -0
- package/dist/lib/manifest.js.map +1 -0
- package/dist/lib/params.d.ts +27 -0
- package/dist/lib/params.d.ts.map +1 -0
- package/dist/lib/params.js +192 -0
- package/dist/lib/params.js.map +1 -0
- package/dist/lib/pdf.d.ts +8 -0
- package/dist/lib/pdf.d.ts.map +1 -0
- package/dist/lib/pdf.js +86 -0
- package/dist/lib/pdf.js.map +1 -0
- package/dist/lib/renderer.d.ts +17 -0
- package/dist/lib/renderer.d.ts.map +1 -0
- package/dist/lib/renderer.js +166 -0
- package/dist/lib/renderer.js.map +1 -0
- package/dist/lib/schema-filter.d.ts +3 -0
- package/dist/lib/schema-filter.d.ts.map +1 -0
- package/dist/lib/schema-filter.js +49 -0
- package/dist/lib/schema-filter.js.map +1 -0
- package/dist/lib/template.d.ts +4 -0
- package/dist/lib/template.d.ts.map +1 -0
- package/dist/lib/template.js +37 -0
- package/dist/lib/template.js.map +1 -0
- package/dist/lib/validator.d.ts +8 -0
- package/dist/lib/validator.d.ts.map +1 -0
- package/dist/lib/validator.js +88 -0
- package/dist/lib/validator.js.map +1 -0
- package/package.json +59 -0
- package/schemas/deck.schema.json +122 -0
- package/schemas/report-manifest.schema.json +309 -0
- package/schemas/tables/README.md +45 -0
- package/schemas/tables/ultracart_dw/uc_affiliate_clicks.json +186 -0
- package/schemas/tables/ultracart_dw/uc_affiliate_commission_groups.json +317 -0
- package/schemas/tables/ultracart_dw/uc_affiliate_ledgers.json +404 -0
- package/schemas/tables/ultracart_dw/uc_affiliate_network_pixel_postback_logs.json +166 -0
- package/schemas/tables/ultracart_dw/uc_affiliate_network_pixels.json +106 -0
- package/schemas/tables/ultracart_dw/uc_affiliate_payments.json +204 -0
- package/schemas/tables/ultracart_dw/uc_affiliate_postback_logs.json +90 -0
- package/schemas/tables/ultracart_dw/uc_affiliates.json +425 -0
- package/schemas/tables/ultracart_dw/uc_auto_orders.json +13848 -0
- package/schemas/tables/ultracart_dw/uc_cart_abandons.json +3971 -0
- package/schemas/tables/ultracart_dw/uc_conversation_pbx_calls.json +374 -0
- package/schemas/tables/ultracart_dw/uc_conversations.json +374 -0
- package/schemas/tables/ultracart_dw/uc_coupons.json +1893 -0
- package/schemas/tables/ultracart_dw/uc_customers.json +11886 -0
- package/schemas/tables/ultracart_dw/uc_fraud_rules.json +239 -0
- package/schemas/tables/ultracart_dw/uc_gift_certificates.json +135 -0
- package/schemas/tables/ultracart_dw/uc_item_inventory_history.json +79 -0
- package/schemas/tables/ultracart_dw/uc_items.json +4437 -0
- package/schemas/tables/ultracart_dw/uc_orders.json +6629 -0
- package/schemas/tables/ultracart_dw/uc_rotating_transaction_gateway_history.json +271 -0
- package/schemas/tables/ultracart_dw/uc_rotating_transaction_gateways.json +416 -0
- package/schemas/tables/ultracart_dw/uc_shipping_methods.json +1372 -0
- package/schemas/tables/ultracart_dw/uc_storefront_customers.json +261 -0
- package/schemas/tables/ultracart_dw/uc_storefront_experiments.json +386 -0
- package/schemas/tables/ultracart_dw/uc_storefront_pages.json +513 -0
- package/schemas/tables/ultracart_dw/uc_storefront_upsell_offer_events.json +338 -0
- package/schemas/tables/ultracart_dw/uc_storefront_upsell_offers.json +431 -0
- package/schemas/tables/ultracart_dw/uc_storefront_upsell_paths.json +163 -0
- package/schemas/tables/ultracart_dw/uc_storefronts.json +62 -0
- package/schemas/tables/ultracart_dw/uc_surveys.json +238 -0
- package/schemas/tables/ultracart_dw/uc_workflow_tasks.json +377 -0
- package/schemas/tables/ultracart_dw/uc_zoho_desk_tickets.json +1184 -0
- package/schemas/tables/ultracart_dw_high/uc_affiliate_clicks.json +186 -0
- package/schemas/tables/ultracart_dw_high/uc_affiliate_commission_groups.json +317 -0
- package/schemas/tables/ultracart_dw_high/uc_affiliate_ledgers.json +404 -0
- package/schemas/tables/ultracart_dw_high/uc_affiliate_network_pixel_postback_logs.json +166 -0
- package/schemas/tables/ultracart_dw_high/uc_affiliate_network_pixels.json +106 -0
- package/schemas/tables/ultracart_dw_high/uc_affiliate_payments.json +204 -0
- package/schemas/tables/ultracart_dw_high/uc_affiliate_postback_logs.json +90 -0
- package/schemas/tables/ultracart_dw_high/uc_affiliates.json +425 -0
- package/schemas/tables/ultracart_dw_high/uc_auto_orders.json +14332 -0
- package/schemas/tables/ultracart_dw_high/uc_cart_abandons.json +4245 -0
- package/schemas/tables/ultracart_dw_high/uc_conversation_pbx_calls.json +415 -0
- package/schemas/tables/ultracart_dw_high/uc_conversations.json +415 -0
- package/schemas/tables/ultracart_dw_high/uc_coupons.json +1893 -0
- package/schemas/tables/ultracart_dw_high/uc_customers.json +12250 -0
- package/schemas/tables/ultracart_dw_high/uc_fraud_rules.json +239 -0
- package/schemas/tables/ultracart_dw_high/uc_gift_certificates.json +135 -0
- package/schemas/tables/ultracart_dw_high/uc_item_inventory_history.json +79 -0
- package/schemas/tables/ultracart_dw_high/uc_items.json +4437 -0
- package/schemas/tables/ultracart_dw_high/uc_orders.json +6871 -0
- package/schemas/tables/ultracart_dw_high/uc_rotating_transaction_gateway_history.json +271 -0
- package/schemas/tables/ultracart_dw_high/uc_rotating_transaction_gateways.json +416 -0
- package/schemas/tables/ultracart_dw_high/uc_shipping_methods.json +1372 -0
- package/schemas/tables/ultracart_dw_high/uc_storefront_customers.json +261 -0
- package/schemas/tables/ultracart_dw_high/uc_storefront_experiments.json +386 -0
- package/schemas/tables/ultracart_dw_high/uc_storefront_pages.json +513 -0
- package/schemas/tables/ultracart_dw_high/uc_storefront_upsell_offer_events.json +338 -0
- package/schemas/tables/ultracart_dw_high/uc_storefront_upsell_offers.json +431 -0
- package/schemas/tables/ultracart_dw_high/uc_storefront_upsell_paths.json +163 -0
- package/schemas/tables/ultracart_dw_high/uc_storefronts.json +62 -0
- package/schemas/tables/ultracart_dw_high/uc_surveys.json +269 -0
- package/schemas/tables/ultracart_dw_high/uc_workflow_tasks.json +377 -0
- package/schemas/tables/ultracart_dw_high/uc_zoho_desk_tickets.json +1330 -0
- package/schemas/tables/ultracart_dw_low/uc_affiliate_clicks.json +186 -0
- package/schemas/tables/ultracart_dw_low/uc_affiliate_commission_groups.json +317 -0
- package/schemas/tables/ultracart_dw_low/uc_affiliate_ledgers.json +404 -0
- package/schemas/tables/ultracart_dw_low/uc_affiliate_network_pixel_postback_logs.json +166 -0
- package/schemas/tables/ultracart_dw_low/uc_affiliate_network_pixels.json +106 -0
- package/schemas/tables/ultracart_dw_low/uc_affiliate_payments.json +204 -0
- package/schemas/tables/ultracart_dw_low/uc_affiliate_postback_logs.json +90 -0
- package/schemas/tables/ultracart_dw_low/uc_affiliates.json +425 -0
- package/schemas/tables/ultracart_dw_low/uc_auto_orders.json +13868 -0
- package/schemas/tables/ultracart_dw_low/uc_cart_abandons.json +3971 -0
- package/schemas/tables/ultracart_dw_low/uc_conversation_pbx_calls.json +374 -0
- package/schemas/tables/ultracart_dw_low/uc_conversations.json +374 -0
- package/schemas/tables/ultracart_dw_low/uc_coupons.json +1893 -0
- package/schemas/tables/ultracart_dw_low/uc_customers.json +11900 -0
- package/schemas/tables/ultracart_dw_low/uc_fraud_rules.json +239 -0
- package/schemas/tables/ultracart_dw_low/uc_gift_certificates.json +135 -0
- package/schemas/tables/ultracart_dw_low/uc_item_inventory_history.json +79 -0
- package/schemas/tables/ultracart_dw_low/uc_items.json +4437 -0
- package/schemas/tables/ultracart_dw_low/uc_orders.json +6639 -0
- package/schemas/tables/ultracart_dw_low/uc_rotating_transaction_gateway_history.json +271 -0
- package/schemas/tables/ultracart_dw_low/uc_rotating_transaction_gateways.json +416 -0
- package/schemas/tables/ultracart_dw_low/uc_shipping_methods.json +1372 -0
- package/schemas/tables/ultracart_dw_low/uc_storefront_customers.json +261 -0
- package/schemas/tables/ultracart_dw_low/uc_storefront_experiments.json +386 -0
- package/schemas/tables/ultracart_dw_low/uc_storefront_pages.json +513 -0
- package/schemas/tables/ultracart_dw_low/uc_storefront_upsell_offer_events.json +338 -0
- package/schemas/tables/ultracart_dw_low/uc_storefront_upsell_offers.json +431 -0
- package/schemas/tables/ultracart_dw_low/uc_storefront_upsell_paths.json +163 -0
- package/schemas/tables/ultracart_dw_low/uc_storefronts.json +62 -0
- package/schemas/tables/ultracart_dw_low/uc_surveys.json +238 -0
- package/schemas/tables/ultracart_dw_low/uc_workflow_tasks.json +377 -0
- package/schemas/tables/ultracart_dw_low/uc_zoho_desk_tickets.json +1184 -0
- package/schemas/tables/ultracart_dw_medium/uc_affiliate_clicks.json +186 -0
- package/schemas/tables/ultracart_dw_medium/uc_affiliate_commission_groups.json +317 -0
- package/schemas/tables/ultracart_dw_medium/uc_affiliate_ledgers.json +404 -0
- package/schemas/tables/ultracart_dw_medium/uc_affiliate_network_pixel_postback_logs.json +166 -0
- package/schemas/tables/ultracart_dw_medium/uc_affiliate_network_pixels.json +106 -0
- package/schemas/tables/ultracart_dw_medium/uc_affiliate_payments.json +204 -0
- package/schemas/tables/ultracart_dw_medium/uc_affiliate_postback_logs.json +90 -0
- package/schemas/tables/ultracart_dw_medium/uc_affiliates.json +425 -0
- package/schemas/tables/ultracart_dw_medium/uc_auto_orders.json +14320 -0
- package/schemas/tables/ultracart_dw_medium/uc_cart_abandons.json +4245 -0
- package/schemas/tables/ultracart_dw_medium/uc_conversation_pbx_calls.json +415 -0
- package/schemas/tables/ultracart_dw_medium/uc_conversations.json +415 -0
- package/schemas/tables/ultracart_dw_medium/uc_coupons.json +1893 -0
- package/schemas/tables/ultracart_dw_medium/uc_customers.json +12250 -0
- package/schemas/tables/ultracart_dw_medium/uc_fraud_rules.json +239 -0
- package/schemas/tables/ultracart_dw_medium/uc_gift_certificates.json +135 -0
- package/schemas/tables/ultracart_dw_medium/uc_item_inventory_history.json +79 -0
- package/schemas/tables/ultracart_dw_medium/uc_items.json +4437 -0
- package/schemas/tables/ultracart_dw_medium/uc_orders.json +6865 -0
- package/schemas/tables/ultracart_dw_medium/uc_rotating_transaction_gateway_history.json +271 -0
- package/schemas/tables/ultracart_dw_medium/uc_rotating_transaction_gateways.json +416 -0
- package/schemas/tables/ultracart_dw_medium/uc_shipping_methods.json +1372 -0
- package/schemas/tables/ultracart_dw_medium/uc_storefront_customers.json +261 -0
- package/schemas/tables/ultracart_dw_medium/uc_storefront_experiments.json +386 -0
- package/schemas/tables/ultracart_dw_medium/uc_storefront_pages.json +513 -0
- package/schemas/tables/ultracart_dw_medium/uc_storefront_upsell_offer_events.json +338 -0
- package/schemas/tables/ultracart_dw_medium/uc_storefront_upsell_offers.json +431 -0
- package/schemas/tables/ultracart_dw_medium/uc_storefront_upsell_paths.json +163 -0
- package/schemas/tables/ultracart_dw_medium/uc_storefronts.json +62 -0
- package/schemas/tables/ultracart_dw_medium/uc_surveys.json +269 -0
- package/schemas/tables/ultracart_dw_medium/uc_workflow_tasks.json +377 -0
- package/schemas/tables/ultracart_dw_medium/uc_zoho_desk_tickets.json +1330 -0
- package/schemas/tables/ultracart_dw_streaming/uc_analytics_session_streaming.json +2444 -0
- package/schemas/tables/ultracart_dw_streaming/uc_screen_recording_streaming.json +509 -0
- package/schemas/ultracart-bq-config.schema.json +140 -0
- package/skill/skill.md +1228 -0
- package/templates/render.html +73 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.renderChart = renderChart;
|
|
40
|
+
exports.checkDependencies = checkDependencies;
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const puppeteer_1 = __importDefault(require("puppeteer"));
|
|
44
|
+
function getTemplatePath() {
|
|
45
|
+
return path.resolve(__dirname, '..', '..', 'templates', 'render.html');
|
|
46
|
+
}
|
|
47
|
+
async function renderChart(options) {
|
|
48
|
+
const errors = [];
|
|
49
|
+
const templateHtml = fs.readFileSync(getTemplatePath(), 'utf-8');
|
|
50
|
+
const chartFunction = fs.readFileSync(options.chartJsPath, 'utf-8');
|
|
51
|
+
const rawData = fs.readFileSync(options.dataJsonPath, 'utf-8');
|
|
52
|
+
// The data file may be { rows: [...] } or a plain array — normalize to array
|
|
53
|
+
let dataArray;
|
|
54
|
+
try {
|
|
55
|
+
const parsed = JSON.parse(rawData);
|
|
56
|
+
if (parsed && Array.isArray(parsed.rows)) {
|
|
57
|
+
dataArray = JSON.stringify(parsed.rows);
|
|
58
|
+
}
|
|
59
|
+
else if (Array.isArray(parsed)) {
|
|
60
|
+
dataArray = JSON.stringify(parsed);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
dataArray = rawData;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
dataArray = rawData;
|
|
68
|
+
}
|
|
69
|
+
// Remove the auto-executing script from the template — we'll run it manually after injecting data
|
|
70
|
+
const strippedHtml = templateHtml.replace(/\(function\s*\(\)\s*\{[\s\S]*?\}\)\(\);/, '// Chart initialization will be triggered by Puppeteer');
|
|
71
|
+
const browser = await puppeteer_1.default.launch({ headless: true });
|
|
72
|
+
const page = await browser.newPage();
|
|
73
|
+
await page.setViewport({
|
|
74
|
+
width: options.width + 40,
|
|
75
|
+
height: options.height + 40,
|
|
76
|
+
deviceScaleFactor: 2,
|
|
77
|
+
});
|
|
78
|
+
// Load the template (loads ECharts from CDN)
|
|
79
|
+
await page.setContent(strippedHtml, { waitUntil: 'networkidle0' });
|
|
80
|
+
// Inject data and render via addScriptTag — guarantees execution after DOM + ECharts are ready
|
|
81
|
+
await page.addScriptTag({
|
|
82
|
+
content: `
|
|
83
|
+
(async function() { try {
|
|
84
|
+
var data = ${dataArray};
|
|
85
|
+
var fnSource = ${JSON.stringify(chartFunction)};
|
|
86
|
+
var isDashboard = ${options.isDashboard};
|
|
87
|
+
var chartWidth = ${options.width};
|
|
88
|
+
var chartHeight = ${options.height};
|
|
89
|
+
|
|
90
|
+
var container = document.getElementById('myChart');
|
|
91
|
+
container.style.width = chartWidth + 'px';
|
|
92
|
+
container.style.height = chartHeight + 'px';
|
|
93
|
+
|
|
94
|
+
// Load USA map for geo charts (async)
|
|
95
|
+
try {
|
|
96
|
+
var mapResponse = await fetch('https://cdn.jsdelivr.net/npm/echarts@5.4.3/map/json/USA.json');
|
|
97
|
+
if (mapResponse.ok) {
|
|
98
|
+
var usaJson = await mapResponse.json();
|
|
99
|
+
echarts.registerMap('USA', usaJson, {
|
|
100
|
+
Alaska: { left: -131, top: 25, width: 15 },
|
|
101
|
+
Hawaii: { left: -110, top: 28, width: 5 },
|
|
102
|
+
'Puerto Rico': { left: -76, top: 26, width: 2 }
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
} catch (e) { /* map not needed for most charts */ }
|
|
106
|
+
|
|
107
|
+
var chart = echarts.init(container);
|
|
108
|
+
|
|
109
|
+
// Evaluate chart function — runs in Puppeteer sandbox, not Node.js process
|
|
110
|
+
var functionBody = fnSource
|
|
111
|
+
.replace(/function\\s+formatChartData\\s*\\(\\s*data\\s*(?:,\\s*isDashboard\\s*(?:=\\s*[^)]+)?\\s*)?\\)\\s*\\{/, '')
|
|
112
|
+
.replace(/\\}\\s*$/, '');
|
|
113
|
+
var formatChartData = new Function('data', 'isDashboard', functionBody);
|
|
114
|
+
|
|
115
|
+
var options = formatChartData(data, isDashboard);
|
|
116
|
+
|
|
117
|
+
if (options && typeof options === 'object') {
|
|
118
|
+
options.animation = false;
|
|
119
|
+
chart.setOption(options, true);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
window.__RENDER_COMPLETE__ = true;
|
|
123
|
+
} catch (e) {
|
|
124
|
+
window.__RENDER_ERROR__ = e.message || String(e);
|
|
125
|
+
window.__RENDER_COMPLETE__ = true;
|
|
126
|
+
} })();
|
|
127
|
+
`
|
|
128
|
+
});
|
|
129
|
+
// Wait for render to complete
|
|
130
|
+
await page.waitForFunction('(globalThis).__RENDER_COMPLETE__ === true', { timeout: 30000 });
|
|
131
|
+
// Check for render errors
|
|
132
|
+
const renderError = await page.evaluate(() => globalThis.__RENDER_ERROR__);
|
|
133
|
+
if (renderError) {
|
|
134
|
+
errors.push(renderError);
|
|
135
|
+
}
|
|
136
|
+
if (options.format === 'pdf') {
|
|
137
|
+
await page.pdf({
|
|
138
|
+
path: options.outputPath,
|
|
139
|
+
width: `${options.width + 40}px`,
|
|
140
|
+
height: `${options.height + 40}px`,
|
|
141
|
+
printBackground: true,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
const chartElement = await page.$('#myChart');
|
|
146
|
+
if (chartElement) {
|
|
147
|
+
await chartElement.screenshot({ path: options.outputPath });
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
await page.screenshot({ path: options.outputPath });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
await browser.close();
|
|
154
|
+
return { outputPath: options.outputPath, errors };
|
|
155
|
+
}
|
|
156
|
+
async function checkDependencies() {
|
|
157
|
+
try {
|
|
158
|
+
const browser = await puppeteer_1.default.launch({ headless: true });
|
|
159
|
+
await browser.close();
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../src/lib/renderer.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-filter.d.ts","sourceRoot":"","sources":["../../src/lib/schema-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAgB9D,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,GAAG,EAAE,EACb,oBAAoB,EAAE,MAAM,EAC5B,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,GAAG,EAAE,CAAC,CAiChB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterSchemaWithLLM = filterSchemaWithLLM;
|
|
4
|
+
const SCHEMA_FILTER_SYSTEM_PROMPT = `You are an expert at taking a natural language query from users for building reports or charts and filtering down BigQuery schema to fields highly likely to be used by another AI agent to write the query. Take the user's query and the schema in JSON format, then return only the applicable schema in minified single line JSON format inside a markdown code block (\`\`\`json).
|
|
5
|
+
|
|
6
|
+
# Follow these rules when processing column definitions
|
|
7
|
+
1. Always include columns with a name of "partition_date"
|
|
8
|
+
2. Always include columns with mandatory = true
|
|
9
|
+
3. CRITICALLY IMPORTANT: DO NOT modify or filter the "allowed_values" array in any way. The entire allowed_values list must be preserved exactly as it appears in the original schema.
|
|
10
|
+
4. If a column has 'mandatory': true, ALWAYS include the entire column definition in the output, regardless of other filtering criteria.
|
|
11
|
+
|
|
12
|
+
# Additional Output Instructions
|
|
13
|
+
- When a column is selected, include its description as a "description" field
|
|
14
|
+
- Preserve all other specified filtering rules
|
|
15
|
+
|
|
16
|
+
Do not include any other output, explanations, or unnecessary whitespace to minimize token count.`;
|
|
17
|
+
async function filterSchemaWithLLM(schema, naturalLanguageQuery, provider, model) {
|
|
18
|
+
const messages = [
|
|
19
|
+
{ role: 'system', content: SCHEMA_FILTER_SYSTEM_PROMPT },
|
|
20
|
+
{
|
|
21
|
+
role: 'user',
|
|
22
|
+
content: `Here is the BigQuery schema:\n\`\`\`json\n${JSON.stringify(schema)}\n\`\`\``,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
role: 'user',
|
|
26
|
+
content: `Please filter the schema based on this query: ${naturalLanguageQuery}`,
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
const text = await provider.complete(messages, {
|
|
30
|
+
model,
|
|
31
|
+
maxTokens: 8192,
|
|
32
|
+
temperature: 0,
|
|
33
|
+
});
|
|
34
|
+
// Extract the JSON from the markdown code block
|
|
35
|
+
const match = text.match(/```json\s*([\s\S]*?)```/);
|
|
36
|
+
if (match) {
|
|
37
|
+
return JSON.parse(match[1].trim());
|
|
38
|
+
}
|
|
39
|
+
// If no code block found, try parsing the whole response
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(text.trim());
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Fall back to full schema if parsing fails
|
|
45
|
+
console.error('Warning: LLM schema filtering returned unparseable response, using full schema.');
|
|
46
|
+
return schema;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=schema-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-filter.js","sourceRoot":"","sources":["../../src/lib/schema-filter.ts"],"names":[],"mappings":";;AAgBA,kDAsCC;AApDD,MAAM,2BAA2B,GAAG;;;;;;;;;;;;kGAY8D,CAAC;AAE5F,KAAK,UAAU,mBAAmB,CACvC,MAAa,EACb,oBAA4B,EAC5B,QAAqB,EACrB,KAAa;IAEb,MAAM,QAAQ,GAAiB;QAC7B,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,2BAA2B,EAAE;QACxD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,6CAA6C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU;SACvF;QACD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,iDAAiD,oBAAoB,EAAE;SACjF;KACF,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE;QAC7C,KAAK;QACL,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,CAAC;KACf,CAAC,CAAC;IAEH,gDAAgD;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACpD,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACrC,CAAC;IAED,yDAAyD;IACzD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,4CAA4C;QAC5C,OAAO,CAAC,KAAK,CAAC,iFAAiF,CAAC,CAAC;QACjG,OAAO,MAAM,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function substituteParams(sql: string, params: Record<string, string>): string;
|
|
2
|
+
export declare function processConditionals(sql: string, params: Record<string, string>): string;
|
|
3
|
+
export declare function renderTemplate(sqlTemplate: string, params: Record<string, string>): string;
|
|
4
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/lib/template.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAOpF;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CA0BvF;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAG1F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.substituteParams = substituteParams;
|
|
4
|
+
exports.processConditionals = processConditionals;
|
|
5
|
+
exports.renderTemplate = renderTemplate;
|
|
6
|
+
function substituteParams(sql, params) {
|
|
7
|
+
return sql.replace(/\{\{(\w+)\}\}/g, (match, name) => {
|
|
8
|
+
if (name in params) {
|
|
9
|
+
return params[name];
|
|
10
|
+
}
|
|
11
|
+
return match;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function processConditionals(sql, params) {
|
|
15
|
+
// Handle {% if param_name != 'value' %}...{% endif %}
|
|
16
|
+
let result = sql.replace(/\{%\s*if\s+(\w+)\s*!=\s*'([^']*)'\s*%\}([\s\S]*?)\{%\s*endif\s*%\}/g, (_match, name, value, body) => {
|
|
17
|
+
const paramValue = params[name];
|
|
18
|
+
if (paramValue !== undefined && paramValue !== value) {
|
|
19
|
+
return body;
|
|
20
|
+
}
|
|
21
|
+
return '';
|
|
22
|
+
});
|
|
23
|
+
// Handle {% if param_name %}...{% endif %}
|
|
24
|
+
result = result.replace(/\{%\s*if\s+(\w+)\s*%\}([\s\S]*?)\{%\s*endif\s*%\}/g, (_match, name, body) => {
|
|
25
|
+
const paramValue = params[name];
|
|
26
|
+
if (paramValue !== undefined && paramValue !== '' && paramValue !== 'false') {
|
|
27
|
+
return body;
|
|
28
|
+
}
|
|
29
|
+
return '';
|
|
30
|
+
});
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
function renderTemplate(sqlTemplate, params) {
|
|
34
|
+
const afterConditionals = processConditionals(sqlTemplate, params);
|
|
35
|
+
return substituteParams(afterConditionals, params);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/lib/template.ts"],"names":[],"mappings":";;AAAA,4CAOC;AAED,kDA0BC;AAED,wCAGC;AAxCD,SAAgB,gBAAgB,CAAC,GAAW,EAAE,MAA8B;IAC1E,OAAO,GAAG,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACnD,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;YACnB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,mBAAmB,CAAC,GAAW,EAAE,MAA8B;IAC7E,sDAAsD;IACtD,IAAI,MAAM,GAAG,GAAG,CAAC,OAAO,CACtB,qEAAqE,EACrE,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC5B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,CACF,CAAC;IAEF,2CAA2C;IAC3C,MAAM,GAAG,MAAM,CAAC,OAAO,CACrB,oDAAoD,EACpD,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACrB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,EAAE,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;YAC5E,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,cAAc,CAAC,WAAmB,EAAE,MAA8B;IAChF,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACnE,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface ValidationResult {
|
|
2
|
+
valid: boolean;
|
|
3
|
+
errors: string[];
|
|
4
|
+
}
|
|
5
|
+
export declare function validateConfig(config: unknown): ValidationResult;
|
|
6
|
+
export declare function validateManifest(manifest: unknown): ValidationResult;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AAKA,UAAU,gBAAgB;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AA8BD,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,gBAAgB,CAQhE;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB,CAQpE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.validateConfig = validateConfig;
|
|
40
|
+
exports.validateManifest = validateManifest;
|
|
41
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
42
|
+
const ajv_formats_1 = __importDefault(require("ajv-formats"));
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
function createAjv() {
|
|
46
|
+
const ajv = new ajv_1.default({ allErrors: true });
|
|
47
|
+
(0, ajv_formats_1.default)(ajv);
|
|
48
|
+
return ajv;
|
|
49
|
+
}
|
|
50
|
+
function getSchemaPath(schemaFile) {
|
|
51
|
+
// Resolve relative to the package root (two levels up from dist/lib/)
|
|
52
|
+
return path.resolve(__dirname, '..', '..', 'schemas', schemaFile);
|
|
53
|
+
}
|
|
54
|
+
function loadSchema(schemaFile) {
|
|
55
|
+
const schemaPath = getSchemaPath(schemaFile);
|
|
56
|
+
const schema = JSON.parse(fs.readFileSync(schemaPath, 'utf-8'));
|
|
57
|
+
// Remove $schema and $id — Ajv doesn't support 2020-12 meta-schema natively
|
|
58
|
+
delete schema.$schema;
|
|
59
|
+
delete schema.$id;
|
|
60
|
+
return schema;
|
|
61
|
+
}
|
|
62
|
+
function formatErrors(ajv) {
|
|
63
|
+
if (!ajv.errors)
|
|
64
|
+
return [];
|
|
65
|
+
return ajv.errors.map((e) => {
|
|
66
|
+
const path = e.instancePath || '/';
|
|
67
|
+
return `${path}: ${e.message}`;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function validateConfig(config) {
|
|
71
|
+
const ajv = createAjv();
|
|
72
|
+
const schema = loadSchema('ultracart-bq-config.schema.json');
|
|
73
|
+
const valid = ajv.validate(schema, config);
|
|
74
|
+
return {
|
|
75
|
+
valid: valid,
|
|
76
|
+
errors: valid ? [] : formatErrors(ajv),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function validateManifest(manifest) {
|
|
80
|
+
const ajv = createAjv();
|
|
81
|
+
const schema = loadSchema('report-manifest.schema.json');
|
|
82
|
+
const valid = ajv.validate(schema, manifest);
|
|
83
|
+
return {
|
|
84
|
+
valid: valid,
|
|
85
|
+
errors: valid ? [] : formatErrors(ajv),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,wCAQC;AAED,4CAQC;AAxDD,8CAAsB;AACtB,8DAAqC;AACrC,uCAAyB;AACzB,2CAA6B;AAO7B,SAAS,SAAS;IAChB,MAAM,GAAG,GAAG,IAAI,aAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,IAAA,qBAAU,EAAC,GAAG,CAAC,CAAC;IAChB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,aAAa,CAAC,UAAkB;IACvC,sEAAsE;IACtE,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,UAAU,CAAC,UAAkB;IACpC,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IAChE,4EAA4E;IAC5E,OAAO,MAAM,CAAC,OAAO,CAAC;IACtB,OAAO,MAAM,CAAC,GAAG,CAAC;IAClB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,GAAQ;IAC5B,IAAI,CAAC,GAAG,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAC3B,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC1B,MAAM,IAAI,GAAG,CAAC,CAAC,YAAY,IAAI,GAAG,CAAC;QACnC,OAAO,GAAG,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,cAAc,CAAC,MAAe;IAC5C,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,MAAM,MAAM,GAAG,UAAU,CAAC,iCAAiC,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,OAAO;QACL,KAAK,EAAE,KAAgB;QACvB,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC;KACvC,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,QAAiB;IAChD,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,MAAM,MAAM,GAAG,UAAU,CAAC,6BAA6B,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7C,OAAO;QACL,KAAK,EAAE,KAAgB;QACvB,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC;KACvC,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ultracart/bq-skill",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "UltraCart BigQuery reporting skill for Claude Code — CLI + skill prompt for creating and replaying e-commerce reports",
|
|
5
|
+
"main": "dist/cli.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"uc-bq": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"dev": "tsc --watch",
|
|
12
|
+
"start": "node dist/cli.js",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"ultracart",
|
|
17
|
+
"bigquery",
|
|
18
|
+
"claude-code",
|
|
19
|
+
"reporting",
|
|
20
|
+
"echarts",
|
|
21
|
+
"e-commerce"
|
|
22
|
+
],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/UltraCart/uc-bq-claude-skill"
|
|
26
|
+
},
|
|
27
|
+
"author": "UltraCart",
|
|
28
|
+
"license": "Apache-2.0",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@anthropic-ai/sdk": "^0.80.0",
|
|
31
|
+
"@aws-sdk/client-bedrock-runtime": "^3.0.0",
|
|
32
|
+
"@google-cloud/bigquery": "^8.0.0",
|
|
33
|
+
"@google/generative-ai": "^0.24.0",
|
|
34
|
+
"ajv": "^8.17.0",
|
|
35
|
+
"ajv-formats": "^3.0.0",
|
|
36
|
+
"commander": "^14.0.0",
|
|
37
|
+
"js-yaml": "^4.1.0",
|
|
38
|
+
"md-to-pdf": "^5.2.5",
|
|
39
|
+
"openai": "^6.0.0",
|
|
40
|
+
"puppeteer": "^24.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/js-yaml": "^4.0.9",
|
|
44
|
+
"@types/node": "^22.0.0",
|
|
45
|
+
"typescript": "^5.6.0"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=24.0.0"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist/",
|
|
52
|
+
"schemas/",
|
|
53
|
+
"templates/",
|
|
54
|
+
"skill/"
|
|
55
|
+
],
|
|
56
|
+
"volta": {
|
|
57
|
+
"node": "24.13.0"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://ultracart.com/schemas/deck.schema.json",
|
|
4
|
+
"title": "UltraCart Report Deck",
|
|
5
|
+
"description": "A deck definition that combines multiple reports into a single branded PDF with cover page and table of contents.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["name", "title", "reports"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"name": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Human-readable deck name",
|
|
13
|
+
"minLength": 1,
|
|
14
|
+
"maxLength": 100
|
|
15
|
+
},
|
|
16
|
+
"title": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Title displayed on the cover page",
|
|
19
|
+
"maxLength": 200
|
|
20
|
+
},
|
|
21
|
+
"cover": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"description": "Cover page branding options",
|
|
24
|
+
"properties": {
|
|
25
|
+
"company": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "Company name displayed on the cover page"
|
|
28
|
+
},
|
|
29
|
+
"logo_url": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "URL to a logo image to embed on the cover page"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"additionalProperties": false
|
|
35
|
+
},
|
|
36
|
+
"reports": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"description": "Ordered list of reports to include. Each entry is either a report directory name (string) or an object with name and optional per-report parameter overrides.",
|
|
39
|
+
"items": {
|
|
40
|
+
"oneOf": [
|
|
41
|
+
{ "type": "string" },
|
|
42
|
+
{
|
|
43
|
+
"type": "object",
|
|
44
|
+
"required": ["name"],
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"properties": {
|
|
47
|
+
"name": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "Report directory name"
|
|
50
|
+
},
|
|
51
|
+
"parameters": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"description": "Per-report parameter overrides (always win over deck-level parameters)",
|
|
54
|
+
"additionalProperties": { "type": "string" }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"minItems": 1
|
|
61
|
+
},
|
|
62
|
+
"parameter_mode": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"enum": ["smart", "override"],
|
|
65
|
+
"description": "How deck-level parameters push down to reports. 'smart' (default): only override static date defaults, leave relative date expressions (today, -90d, start_of_year, etc.) alone. 'override': deck parameters always win over report defaults.",
|
|
66
|
+
"default": "smart"
|
|
67
|
+
},
|
|
68
|
+
"parameters": {
|
|
69
|
+
"type": "object",
|
|
70
|
+
"description": "Shared parameter defaults that flow down to all reports in the deck (subject to parameter_mode)",
|
|
71
|
+
"additionalProperties": { "type": "string" }
|
|
72
|
+
},
|
|
73
|
+
"landscape": {
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"description": "Generate the deck PDF in landscape orientation"
|
|
76
|
+
},
|
|
77
|
+
"delivery": {
|
|
78
|
+
"type": "object",
|
|
79
|
+
"description": "Deck delivery configuration for Slack and/or email",
|
|
80
|
+
"properties": {
|
|
81
|
+
"slack": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"properties": {
|
|
84
|
+
"channels": {
|
|
85
|
+
"type": "array",
|
|
86
|
+
"items": {
|
|
87
|
+
"type": "string"
|
|
88
|
+
},
|
|
89
|
+
"minItems": 1,
|
|
90
|
+
"description": "Slack channel IDs (e.g., C0123456789)"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"required": ["channels"],
|
|
94
|
+
"additionalProperties": false
|
|
95
|
+
},
|
|
96
|
+
"email": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"properties": {
|
|
99
|
+
"to": {
|
|
100
|
+
"type": "array",
|
|
101
|
+
"items": { "type": "string", "format": "email" },
|
|
102
|
+
"minItems": 1,
|
|
103
|
+
"description": "Recipient email addresses"
|
|
104
|
+
},
|
|
105
|
+
"subject": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"description": "Email subject line"
|
|
108
|
+
},
|
|
109
|
+
"provider": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"enum": ["sendgrid", "ses", "postmark", "mailgun", "resend"],
|
|
112
|
+
"description": "Email delivery provider"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"required": ["to", "subject", "provider"],
|
|
116
|
+
"additionalProperties": false
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"additionalProperties": false
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|