@mastra/connect 0.6.0 → 0.7.0-alpha.0

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.
Files changed (32) hide show
  1. package/dist/index.cjs +812 -0
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +812 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/providers/google-analytics/index.d.ts +5 -0
  6. package/dist/providers/google-analytics/index.d.ts.map +1 -0
  7. package/dist/providers/google-analytics/tools/archive-conversion-event.d.ts +18 -0
  8. package/dist/providers/google-analytics/tools/archive-conversion-event.d.ts.map +1 -0
  9. package/dist/providers/google-analytics/tools/batch-run-reports.d.ts +137 -0
  10. package/dist/providers/google-analytics/tools/batch-run-reports.d.ts.map +1 -0
  11. package/dist/providers/google-analytics/tools/create-conversion-event.d.ts +44 -0
  12. package/dist/providers/google-analytics/tools/create-conversion-event.d.ts.map +1 -0
  13. package/dist/providers/google-analytics/tools/create-data-stream.d.ts +99 -0
  14. package/dist/providers/google-analytics/tools/create-data-stream.d.ts.map +1 -0
  15. package/dist/providers/google-analytics/tools/create-property.d.ts +46 -0
  16. package/dist/providers/google-analytics/tools/create-property.d.ts.map +1 -0
  17. package/dist/providers/google-analytics/tools/get-metadata.d.ts +44 -0
  18. package/dist/providers/google-analytics/tools/get-metadata.d.ts.map +1 -0
  19. package/dist/providers/google-analytics/tools/run-pivot-report.d.ts +51 -0
  20. package/dist/providers/google-analytics/tools/run-pivot-report.d.ts.map +1 -0
  21. package/dist/providers/google-analytics/tools/run-realtime-report.d.ts +150 -0
  22. package/dist/providers/google-analytics/tools/run-realtime-report.d.ts.map +1 -0
  23. package/dist/providers/google-analytics/tools/run-report.d.ts +140 -0
  24. package/dist/providers/google-analytics/tools/run-report.d.ts.map +1 -0
  25. package/dist/providers/google-analytics/tools/update-data-stream.d.ts +60 -0
  26. package/dist/providers/google-analytics/tools/update-data-stream.d.ts.map +1 -0
  27. package/dist/providers/google-analytics/tools/update-property.d.ts +34 -0
  28. package/dist/providers/google-analytics/tools/update-property.d.ts.map +1 -0
  29. package/dist/providers/google-analytics/tools.d.ts +3 -0
  30. package/dist/providers/google-analytics/tools.d.ts.map +1 -0
  31. package/dist/providers/index.d.ts.map +1 -1
  32. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -13367,6 +13367,817 @@ const githubProvider = {
13367
13367
  createTools: createGithubTools
13368
13368
  };
13369
13369
  //#endregion
13370
+ //#region src/providers/google-analytics/tools/archive-conversion-event.ts
13371
+ const archiveConversionEventInputSchema = z.object({
13372
+ property_id: z.string().describe("GA4 property numeric ID. Example: \"12345\""),
13373
+ conversion_event_id: z.string().describe("Conversion event numeric ID. Example: \"67890\"")
13374
+ });
13375
+ const archiveConversionEventOutputSchema = z.object({
13376
+ success: z.boolean(),
13377
+ name: z.string().describe("Resource name of the archived conversion event.")
13378
+ });
13379
+ function archiveConversionEventTool(proxy) {
13380
+ return createTool({
13381
+ id: "google_analytics_archive_conversion_event",
13382
+ description: "Archive a GA4 conversion event.",
13383
+ inputSchema: archiveConversionEventInputSchema,
13384
+ outputSchema: archiveConversionEventOutputSchema,
13385
+ execute: async (input, { requestContext }) => {
13386
+ const platformProxy = proxy.withRequestContext(requestContext);
13387
+ const name = `properties/${input.property_id}/conversionEvents/${input.conversion_event_id}`;
13388
+ await platformProxy.delete({
13389
+ endpoint: `/v1beta/properties/${encodeURIComponent(input.property_id)}/conversionEvents/${encodeURIComponent(input.conversion_event_id)}`,
13390
+ baseUrlOverride: "https://analyticsadmin.googleapis.com",
13391
+ retries: 3
13392
+ });
13393
+ return {
13394
+ success: true,
13395
+ name
13396
+ };
13397
+ }
13398
+ });
13399
+ }
13400
+ //#endregion
13401
+ //#region src/providers/google-analytics/tools/batch-run-reports.ts
13402
+ const DateRangeSchema$1 = z.object({
13403
+ startDate: z.string(),
13404
+ endDate: z.string()
13405
+ });
13406
+ const DimensionSchema$9 = z.object({ name: z.string() });
13407
+ const MetricSchema$3 = z.object({ name: z.string() });
13408
+ const ReportRequestSchema = z.object({
13409
+ dimensions: z.array(DimensionSchema$9).optional(),
13410
+ metrics: z.array(MetricSchema$3).optional(),
13411
+ dateRanges: z.array(DateRangeSchema$1).optional(),
13412
+ offset: z.string().optional(),
13413
+ limit: z.string().optional(),
13414
+ keepEmptyRows: z.boolean().optional(),
13415
+ returnPropertyQuota: z.boolean().optional()
13416
+ }).passthrough();
13417
+ const batchRunReportsInputSchema = z.object({
13418
+ property: z.string().describe("Google Analytics property ID. Example: \"properties/123456789\""),
13419
+ requests: z.array(ReportRequestSchema).min(1).max(5)
13420
+ });
13421
+ const DimensionValueSchema$2 = z.object({ value: z.string().optional() });
13422
+ const MetricValueSchema$2 = z.object({ value: z.string().optional() });
13423
+ const RowSchema$2 = z.object({
13424
+ dimensionValues: z.array(DimensionValueSchema$2).optional(),
13425
+ metricValues: z.array(MetricValueSchema$2).optional()
13426
+ });
13427
+ const DimensionHeaderSchema$2 = z.object({ name: z.string().optional() });
13428
+ const MetricHeaderSchema$2 = z.object({
13429
+ name: z.string().optional(),
13430
+ type: z.string().optional()
13431
+ });
13432
+ const RunReportResponseSchema = z.object({
13433
+ dimensionHeaders: z.array(DimensionHeaderSchema$2).optional(),
13434
+ metricHeaders: z.array(MetricHeaderSchema$2).optional(),
13435
+ rows: z.array(RowSchema$2).optional(),
13436
+ totals: z.array(RowSchema$2).optional(),
13437
+ maximums: z.array(RowSchema$2).optional(),
13438
+ minimums: z.array(RowSchema$2).optional(),
13439
+ rowCount: z.number().optional(),
13440
+ metadata: z.record(z.string(), z.unknown()).optional(),
13441
+ propertyQuota: z.record(z.string(), z.unknown()).optional(),
13442
+ kind: z.string().optional()
13443
+ });
13444
+ const batchRunReportsOutputSchema = z.object({
13445
+ reports: z.array(RunReportResponseSchema),
13446
+ kind: z.string().optional()
13447
+ });
13448
+ function batchRunReportsTool(proxy) {
13449
+ return createTool({
13450
+ id: "google_analytics_batch_run_reports",
13451
+ description: "Run multiple GA4 reports in one request.",
13452
+ inputSchema: batchRunReportsInputSchema,
13453
+ outputSchema: batchRunReportsOutputSchema,
13454
+ execute: async (input, { requestContext }) => {
13455
+ const platformProxy = proxy.withRequestContext(requestContext);
13456
+ const propertyId = input.property.replace(/^properties\//, "");
13457
+ const response = await platformProxy.post({
13458
+ endpoint: `/v1beta/properties/${encodeURIComponent(propertyId)}:batchRunReports`,
13459
+ baseUrlOverride: "https://analyticsdata.googleapis.com",
13460
+ data: { requests: input.requests },
13461
+ retries: 3
13462
+ });
13463
+ const providerResponse = z.object({
13464
+ reports: z.array(z.unknown()).optional(),
13465
+ kind: z.string().optional()
13466
+ }).parse(response.data);
13467
+ return {
13468
+ reports: providerResponse.reports?.map((report) => RunReportResponseSchema.parse(report)) ?? [],
13469
+ kind: providerResponse.kind
13470
+ };
13471
+ }
13472
+ });
13473
+ }
13474
+ //#endregion
13475
+ //#region src/providers/google-analytics/tools/create-conversion-event.ts
13476
+ const DefaultConversionValueInputSchema = z.object({
13477
+ value: z.number(),
13478
+ currencyCode: z.string()
13479
+ });
13480
+ const createConversionEventInputSchema = z.object({
13481
+ propertyId: z.string().describe("GA4 property ID. Example: \"123456789\""),
13482
+ eventName: z.string().describe("The event name for this conversion event. Example: \"click\""),
13483
+ countingMethod: z.string().optional().describe("Optional. The method by which conversions will be counted. Example: \"ONCE_PER_EVENT\""),
13484
+ defaultConversionValue: DefaultConversionValueInputSchema.optional().describe("Optional. Defines a default value/currency for a conversion event.")
13485
+ });
13486
+ const ProviderDefaultConversionValueSchema = z.object({
13487
+ value: z.number(),
13488
+ currencyCode: z.string()
13489
+ });
13490
+ const ProviderConversionEventSchema = z.object({
13491
+ name: z.string(),
13492
+ eventName: z.string(),
13493
+ createTime: z.string().optional(),
13494
+ deletable: z.boolean().optional(),
13495
+ custom: z.boolean().optional(),
13496
+ countingMethod: z.string().optional(),
13497
+ defaultConversionValue: ProviderDefaultConversionValueSchema.optional()
13498
+ });
13499
+ const createConversionEventOutputSchema = z.object({
13500
+ name: z.string(),
13501
+ eventName: z.string(),
13502
+ createTime: z.string().optional(),
13503
+ deletable: z.boolean().optional(),
13504
+ custom: z.boolean().optional(),
13505
+ countingMethod: z.string().optional(),
13506
+ defaultConversionValue: z.object({
13507
+ value: z.number(),
13508
+ currencyCode: z.string()
13509
+ }).optional()
13510
+ });
13511
+ function createConversionEventTool(proxy) {
13512
+ return createTool({
13513
+ id: "google_analytics_create_conversion_event",
13514
+ description: "Create a conversion event for a GA4 property.",
13515
+ inputSchema: createConversionEventInputSchema,
13516
+ outputSchema: createConversionEventOutputSchema,
13517
+ execute: async (input, { requestContext }) => {
13518
+ const response = await proxy.withRequestContext(requestContext).post({
13519
+ endpoint: `/v1beta/properties/${encodeURIComponent(input.propertyId)}/conversionEvents`,
13520
+ data: {
13521
+ eventName: input.eventName,
13522
+ ...input.countingMethod !== void 0 && { countingMethod: input.countingMethod },
13523
+ ...input.defaultConversionValue !== void 0 && { defaultConversionValue: input.defaultConversionValue }
13524
+ },
13525
+ retries: 3,
13526
+ baseUrlOverride: "https://analyticsadmin.googleapis.com"
13527
+ });
13528
+ const providerEvent = ProviderConversionEventSchema.parse(response.data);
13529
+ return {
13530
+ name: providerEvent.name,
13531
+ eventName: providerEvent.eventName,
13532
+ ...providerEvent.createTime !== void 0 && { createTime: providerEvent.createTime },
13533
+ ...providerEvent.deletable !== void 0 && { deletable: providerEvent.deletable },
13534
+ ...providerEvent.custom !== void 0 && { custom: providerEvent.custom },
13535
+ ...providerEvent.countingMethod !== void 0 && { countingMethod: providerEvent.countingMethod },
13536
+ ...providerEvent.defaultConversionValue !== void 0 && { defaultConversionValue: providerEvent.defaultConversionValue }
13537
+ };
13538
+ }
13539
+ });
13540
+ }
13541
+ //#endregion
13542
+ //#region src/providers/google-analytics/tools/create-data-stream.ts
13543
+ const DataStreamTypeSchema = z.enum([
13544
+ "DATA_STREAM_TYPE_UNSPECIFIED",
13545
+ "WEB_DATA_STREAM",
13546
+ "ANDROID_APP_DATA_STREAM",
13547
+ "IOS_APP_DATA_STREAM"
13548
+ ]).or(z.string());
13549
+ const WebStreamDataInputSchema = z.object({ default_uri: z.string().describe("Domain name of the web app being measured. Example: \"https://www.example.com\"") });
13550
+ const AndroidAppStreamDataInputSchema = z.object({ package_name: z.string().describe("The package name for the app being measured. Example: \"com.example.myandroidapp\"") });
13551
+ const IosAppStreamDataInputSchema = z.object({ bundle_id: z.string().describe("The Apple App Store Bundle ID for the app. Example: \"com.example.myiosapp\"") });
13552
+ const CommonInputSchema = {
13553
+ property_id: z.string().describe("GA4 property numeric ID. Example: \"1234\""),
13554
+ display_name: z.string().describe("Human-readable display name for the Data Stream.")
13555
+ };
13556
+ const createDataStreamInputSchema = z.discriminatedUnion("type", [
13557
+ z.object({
13558
+ ...CommonInputSchema,
13559
+ type: z.literal("WEB_DATA_STREAM"),
13560
+ web_stream_data: WebStreamDataInputSchema.describe("Data specific to web streams. Required when type is WEB_DATA_STREAM.")
13561
+ }),
13562
+ z.object({
13563
+ ...CommonInputSchema,
13564
+ type: z.literal("ANDROID_APP_DATA_STREAM"),
13565
+ android_app_stream_data: AndroidAppStreamDataInputSchema.describe("Data specific to Android app streams. Required when type is ANDROID_APP_DATA_STREAM.")
13566
+ }),
13567
+ z.object({
13568
+ ...CommonInputSchema,
13569
+ type: z.literal("IOS_APP_DATA_STREAM"),
13570
+ ios_app_stream_data: IosAppStreamDataInputSchema.describe("Data specific to iOS app streams. Required when type is IOS_APP_DATA_STREAM.")
13571
+ }),
13572
+ z.object({
13573
+ ...CommonInputSchema,
13574
+ type: z.literal("DATA_STREAM_TYPE_UNSPECIFIED")
13575
+ })
13576
+ ]);
13577
+ const WebStreamDataSchema$1 = z.object({
13578
+ measurementId: z.string().optional(),
13579
+ firebaseAppId: z.string().optional(),
13580
+ defaultUri: z.string().optional()
13581
+ });
13582
+ const AndroidAppStreamDataSchema$1 = z.object({
13583
+ firebaseAppId: z.string().optional(),
13584
+ packageName: z.string().optional()
13585
+ });
13586
+ const IosAppStreamDataSchema$1 = z.object({
13587
+ firebaseAppId: z.string().optional(),
13588
+ bundleId: z.string().optional()
13589
+ });
13590
+ const DataStreamSchema$1 = z.object({
13591
+ name: z.string().optional(),
13592
+ type: DataStreamTypeSchema.optional(),
13593
+ displayName: z.string().optional(),
13594
+ createTime: z.string().optional(),
13595
+ updateTime: z.string().optional(),
13596
+ webStreamData: WebStreamDataSchema$1.optional(),
13597
+ androidAppStreamData: AndroidAppStreamDataSchema$1.optional(),
13598
+ iosAppStreamData: IosAppStreamDataSchema$1.optional()
13599
+ });
13600
+ const createDataStreamOutputSchema = z.object({
13601
+ name: z.string().optional(),
13602
+ type: DataStreamTypeSchema.optional(),
13603
+ displayName: z.string().optional(),
13604
+ createTime: z.string().optional(),
13605
+ updateTime: z.string().optional(),
13606
+ webStreamData: WebStreamDataSchema$1.optional(),
13607
+ androidAppStreamData: AndroidAppStreamDataSchema$1.optional(),
13608
+ iosAppStreamData: IosAppStreamDataSchema$1.optional()
13609
+ });
13610
+ function createDataStreamTool(proxy) {
13611
+ return createTool({
13612
+ id: "google_analytics_create_data_stream",
13613
+ description: "Create a data stream for a GA4 property.",
13614
+ inputSchema: createDataStreamInputSchema,
13615
+ outputSchema: createDataStreamOutputSchema,
13616
+ execute: async (input, { requestContext }) => {
13617
+ const platformProxy = proxy.withRequestContext(requestContext);
13618
+ const body = {
13619
+ type: input.type,
13620
+ displayName: input.display_name
13621
+ };
13622
+ if (input.type === "WEB_DATA_STREAM") body.webStreamData = { defaultUri: input.web_stream_data.default_uri };
13623
+ else if (input.type === "ANDROID_APP_DATA_STREAM") body.androidAppStreamData = { packageName: input.android_app_stream_data.package_name };
13624
+ else if (input.type === "IOS_APP_DATA_STREAM") body.iosAppStreamData = { bundleId: input.ios_app_stream_data.bundle_id };
13625
+ const response = await platformProxy.post({
13626
+ endpoint: `/v1beta/properties/${encodeURIComponent(input.property_id)}/dataStreams`,
13627
+ data: body,
13628
+ baseUrlOverride: "https://analyticsadmin.googleapis.com",
13629
+ retries: 3
13630
+ });
13631
+ const dataStream = DataStreamSchema$1.parse(response.data);
13632
+ return {
13633
+ ...dataStream.name !== void 0 && { name: dataStream.name },
13634
+ ...dataStream.type !== void 0 && { type: dataStream.type },
13635
+ ...dataStream.displayName !== void 0 && { displayName: dataStream.displayName },
13636
+ ...dataStream.createTime !== void 0 && { createTime: dataStream.createTime },
13637
+ ...dataStream.updateTime !== void 0 && { updateTime: dataStream.updateTime },
13638
+ ...dataStream.webStreamData !== void 0 && { webStreamData: dataStream.webStreamData },
13639
+ ...dataStream.androidAppStreamData !== void 0 && { androidAppStreamData: dataStream.androidAppStreamData },
13640
+ ...dataStream.iosAppStreamData !== void 0 && { iosAppStreamData: dataStream.iosAppStreamData }
13641
+ };
13642
+ }
13643
+ });
13644
+ }
13645
+ //#endregion
13646
+ //#region src/providers/google-analytics/tools/create-property.ts
13647
+ const createPropertyInputSchema$1 = z.object({
13648
+ parent: z.string().describe("The resource name of the account under which to create the property. Example: \"accounts/12345\""),
13649
+ displayName: z.string().describe("Human-readable display name for the property. Max 100 UTF-16 code units."),
13650
+ timeZone: z.string().describe("Reporting time zone for the property. Example: \"America/Los_Angeles\""),
13651
+ currencyCode: z.string().optional().describe("Currency type used in reports. Example: \"USD\""),
13652
+ industryCategory: z.string().optional().describe("Industry category for benchmarking. Example: \"TECHNOLOGY\""),
13653
+ serviceLevel: z.string().optional().describe("Service level. Example: \"STANDARD\" or \"GOOGLE_ANALYTICS_360\""),
13654
+ propertyType: z.string().optional().describe("Property type. Example: \"ORDINARY_PROPERTY\"")
13655
+ });
13656
+ const ProviderPropertySchema$1 = z.object({
13657
+ name: z.string(),
13658
+ parent: z.string(),
13659
+ displayName: z.string(),
13660
+ createTime: z.string().optional(),
13661
+ updateTime: z.string().optional(),
13662
+ timeZone: z.string().optional(),
13663
+ currencyCode: z.string().optional(),
13664
+ industryCategory: z.string().optional(),
13665
+ serviceLevel: z.string().optional(),
13666
+ propertyType: z.string().optional(),
13667
+ account: z.string().optional(),
13668
+ deleteTime: z.string().optional(),
13669
+ expireTime: z.string().optional()
13670
+ });
13671
+ const createPropertyOutputSchema$1 = z.object({
13672
+ name: z.string().describe("Resource name of the created property. Example: \"properties/12345\""),
13673
+ parent: z.string().describe("Parent account name. Example: \"accounts/12345\""),
13674
+ displayName: z.string(),
13675
+ createTime: z.string().optional(),
13676
+ updateTime: z.string().optional(),
13677
+ timeZone: z.string().optional(),
13678
+ currencyCode: z.string().optional(),
13679
+ industryCategory: z.string().optional(),
13680
+ serviceLevel: z.string().optional(),
13681
+ propertyType: z.string().optional(),
13682
+ account: z.string().optional()
13683
+ });
13684
+ function createPropertyTool$1(proxy) {
13685
+ return createTool({
13686
+ id: "google_analytics_create_property",
13687
+ description: "Create a GA4 property under an account.",
13688
+ inputSchema: createPropertyInputSchema$1,
13689
+ outputSchema: createPropertyOutputSchema$1,
13690
+ execute: async (input, { requestContext }) => {
13691
+ const platformProxy = proxy.withRequestContext(requestContext);
13692
+ const requestBody = {
13693
+ parent: input.parent,
13694
+ displayName: input.displayName
13695
+ };
13696
+ if (input.timeZone !== void 0) requestBody.timeZone = input.timeZone;
13697
+ if (input.currencyCode !== void 0) requestBody.currencyCode = input.currencyCode;
13698
+ if (input.industryCategory !== void 0) requestBody.industryCategory = input.industryCategory;
13699
+ if (input.serviceLevel !== void 0) requestBody.serviceLevel = input.serviceLevel;
13700
+ if (input.propertyType !== void 0) requestBody.propertyType = input.propertyType;
13701
+ const response = await platformProxy.post({
13702
+ baseUrlOverride: "https://analyticsadmin.googleapis.com",
13703
+ endpoint: "/v1beta/properties",
13704
+ data: requestBody,
13705
+ retries: 3
13706
+ });
13707
+ if (!response.data) throw new platformProxy.ActionError({
13708
+ type: "provider_error",
13709
+ message: "Empty response from Google Analytics Admin API when creating property."
13710
+ });
13711
+ const providerProperty = ProviderPropertySchema$1.parse(response.data);
13712
+ return {
13713
+ name: providerProperty.name,
13714
+ parent: providerProperty.parent,
13715
+ displayName: providerProperty.displayName,
13716
+ ...providerProperty.createTime !== void 0 && { createTime: providerProperty.createTime },
13717
+ ...providerProperty.updateTime !== void 0 && { updateTime: providerProperty.updateTime },
13718
+ ...providerProperty.timeZone !== void 0 && { timeZone: providerProperty.timeZone },
13719
+ ...providerProperty.currencyCode !== void 0 && { currencyCode: providerProperty.currencyCode },
13720
+ ...providerProperty.industryCategory !== void 0 && { industryCategory: providerProperty.industryCategory },
13721
+ ...providerProperty.serviceLevel !== void 0 && { serviceLevel: providerProperty.serviceLevel },
13722
+ ...providerProperty.propertyType !== void 0 && { propertyType: providerProperty.propertyType },
13723
+ ...providerProperty.account !== void 0 && { account: providerProperty.account }
13724
+ };
13725
+ }
13726
+ });
13727
+ }
13728
+ //#endregion
13729
+ //#region src/providers/google-analytics/tools/get-metadata.ts
13730
+ const getMetadataInputSchema = z.object({ propertyId: z.string().describe("GA4 property ID. Use \"0\" for universal metadata. Example: \"123456789\"") });
13731
+ const DimensionSchema$8 = z.object({
13732
+ apiName: z.string(),
13733
+ uiName: z.string(),
13734
+ description: z.string(),
13735
+ category: z.string(),
13736
+ deprecatedApiNames: z.array(z.string()).optional()
13737
+ });
13738
+ const MetricSchema$2 = z.object({
13739
+ apiName: z.string(),
13740
+ uiName: z.string(),
13741
+ description: z.string(),
13742
+ type: z.string(),
13743
+ category: z.string(),
13744
+ deprecatedApiNames: z.array(z.string()).optional()
13745
+ });
13746
+ const getMetadataOutputSchema = z.object({
13747
+ name: z.string(),
13748
+ dimensions: z.array(DimensionSchema$8),
13749
+ metrics: z.array(MetricSchema$2)
13750
+ });
13751
+ function getMetadataTool(proxy) {
13752
+ return createTool({
13753
+ id: "google_analytics_get_metadata",
13754
+ description: "Retrieve GA4 dimensions and metrics metadata.",
13755
+ inputSchema: getMetadataInputSchema,
13756
+ outputSchema: getMetadataOutputSchema,
13757
+ execute: async (input, { requestContext }) => {
13758
+ const platformProxy = proxy.withRequestContext(requestContext);
13759
+ const config = {
13760
+ endpoint: `/v1beta/properties/${encodeURIComponent(input.propertyId)}/metadata`,
13761
+ retries: 3,
13762
+ baseUrlOverride: "https://analyticsdata.googleapis.com"
13763
+ };
13764
+ const response = await platformProxy.get(config);
13765
+ if (!response.data) throw new platformProxy.ActionError({
13766
+ type: "not_found",
13767
+ message: "Metadata not found for the specified property."
13768
+ });
13769
+ return getMetadataOutputSchema.parse(response.data);
13770
+ }
13771
+ });
13772
+ }
13773
+ //#endregion
13774
+ //#region src/providers/google-analytics/tools/run-pivot-report.ts
13775
+ const runPivotReportInputSchema = z.object({
13776
+ property: z.string().describe("Google Analytics property numeric ID. Example: 535258304"),
13777
+ dimensions: z.array(z.record(z.string(), z.unknown())).optional(),
13778
+ metrics: z.array(z.record(z.string(), z.unknown())).optional(),
13779
+ dateRanges: z.array(z.record(z.string(), z.unknown())).optional(),
13780
+ pivots: z.array(z.record(z.string(), z.unknown())).optional(),
13781
+ dimensionFilter: z.record(z.string(), z.unknown()).optional(),
13782
+ metricFilter: z.record(z.string(), z.unknown()).optional(),
13783
+ currencyCode: z.string().optional(),
13784
+ cohortSpec: z.record(z.string(), z.unknown()).optional(),
13785
+ keepEmptyRows: z.boolean().optional(),
13786
+ returnPropertyQuota: z.boolean().optional(),
13787
+ comparisons: z.array(z.record(z.string(), z.unknown())).optional()
13788
+ });
13789
+ const runPivotReportOutputSchema = z.object({
13790
+ pivotHeaders: z.array(z.record(z.string(), z.unknown())).optional(),
13791
+ dimensionHeaders: z.array(z.record(z.string(), z.unknown())).optional(),
13792
+ metricHeaders: z.array(z.record(z.string(), z.unknown())).optional(),
13793
+ rows: z.array(z.record(z.string(), z.unknown())).optional(),
13794
+ aggregates: z.array(z.record(z.string(), z.unknown())).optional(),
13795
+ metadata: z.record(z.string(), z.unknown()).optional(),
13796
+ propertyQuota: z.record(z.string(), z.unknown()).optional(),
13797
+ kind: z.string().optional()
13798
+ }).passthrough();
13799
+ function runPivotReportTool(proxy) {
13800
+ return createTool({
13801
+ id: "google_analytics_run_pivot_report",
13802
+ description: "Run a GA4 pivot report.",
13803
+ inputSchema: runPivotReportInputSchema,
13804
+ outputSchema: runPivotReportOutputSchema,
13805
+ execute: async (input, { requestContext }) => {
13806
+ const platformProxy = proxy.withRequestContext(requestContext);
13807
+ const { property, ...requestBody } = input;
13808
+ const response = await platformProxy.post({
13809
+ endpoint: `/v1beta/properties/${encodeURIComponent(property)}:runPivotReport`,
13810
+ data: requestBody,
13811
+ baseUrlOverride: "https://analyticsdata.googleapis.com",
13812
+ retries: 3
13813
+ });
13814
+ return runPivotReportOutputSchema.parse(response.data);
13815
+ }
13816
+ });
13817
+ }
13818
+ //#endregion
13819
+ //#region src/providers/google-analytics/tools/run-realtime-report.ts
13820
+ const DimensionSchema$7 = z.object({ name: z.string().optional() });
13821
+ const MetricSchema$1 = z.object({
13822
+ name: z.string().optional(),
13823
+ expression: z.string().optional(),
13824
+ invisible: z.boolean().optional()
13825
+ });
13826
+ const FilterExpressionSchema = z.object({}).passthrough();
13827
+ const OrderBySchema$1 = z.object({}).passthrough();
13828
+ const MinuteRangeSchema = z.object({
13829
+ name: z.string().optional(),
13830
+ startMinutesAgo: z.number().optional(),
13831
+ endMinutesAgo: z.number().optional()
13832
+ });
13833
+ const runRealtimeReportInputSchema = z.object({
13834
+ property: z.string().describe("A Google Analytics property identifier. Example: \"properties/1234\""),
13835
+ dimensions: z.array(DimensionSchema$7).optional(),
13836
+ metrics: z.array(MetricSchema$1).optional(),
13837
+ dimensionFilter: FilterExpressionSchema.optional(),
13838
+ metricFilter: FilterExpressionSchema.optional(),
13839
+ limit: z.string().optional().describe("The number of rows to return. If unspecified, 10,000 rows are returned."),
13840
+ metricAggregations: z.array(z.string()).optional(),
13841
+ orderBys: z.array(OrderBySchema$1).optional(),
13842
+ returnPropertyQuota: z.boolean().optional(),
13843
+ minuteRanges: z.array(MinuteRangeSchema).optional()
13844
+ });
13845
+ const DimensionHeaderSchema$1 = z.object({ name: z.string().optional() });
13846
+ const MetricHeaderSchema$1 = z.object({
13847
+ name: z.string().optional(),
13848
+ type: z.string().optional()
13849
+ });
13850
+ const DimensionValueSchema$1 = z.object({
13851
+ value: z.string().optional(),
13852
+ oneValue: z.string().optional()
13853
+ });
13854
+ const MetricValueSchema$1 = z.object({ value: z.string().optional() });
13855
+ const RowSchema$1 = z.object({
13856
+ dimensionValues: z.array(DimensionValueSchema$1).optional(),
13857
+ metricValues: z.array(MetricValueSchema$1).optional()
13858
+ });
13859
+ const PropertyQuotaSchema = z.object({}).passthrough();
13860
+ const runRealtimeReportOutputSchema = z.object({
13861
+ dimensionHeaders: z.array(DimensionHeaderSchema$1).optional(),
13862
+ metricHeaders: z.array(MetricHeaderSchema$1).optional(),
13863
+ rows: z.array(RowSchema$1).optional(),
13864
+ totals: z.array(RowSchema$1).optional(),
13865
+ maximums: z.array(RowSchema$1).optional(),
13866
+ minimums: z.array(RowSchema$1).optional(),
13867
+ rowCount: z.number().optional(),
13868
+ propertyQuota: PropertyQuotaSchema.optional(),
13869
+ kind: z.string().optional()
13870
+ });
13871
+ function runRealtimeReportTool(proxy) {
13872
+ return createTool({
13873
+ id: "google_analytics_run_realtime_report",
13874
+ description: "Run a realtime GA4 report.",
13875
+ inputSchema: runRealtimeReportInputSchema,
13876
+ outputSchema: runRealtimeReportOutputSchema,
13877
+ execute: async (input, { requestContext }) => {
13878
+ const platformProxy = proxy.withRequestContext(requestContext);
13879
+ const propertyParts = input.property.split("/");
13880
+ if (propertyParts.length !== 2 || propertyParts[0] !== "properties" || !propertyParts[1]) throw new platformProxy.ActionError({
13881
+ type: "invalid_property",
13882
+ message: "Property must be in the format \"properties/{propertyId}\". Example: \"properties/1234\""
13883
+ });
13884
+ const propertyId = encodeURIComponent(propertyParts[1]);
13885
+ const requestBody = {
13886
+ ...input.dimensions !== void 0 && { dimensions: input.dimensions },
13887
+ ...input.metrics !== void 0 && { metrics: input.metrics },
13888
+ ...input.dimensionFilter !== void 0 && { dimensionFilter: input.dimensionFilter },
13889
+ ...input.metricFilter !== void 0 && { metricFilter: input.metricFilter },
13890
+ ...input.limit !== void 0 && { limit: input.limit },
13891
+ ...input.metricAggregations !== void 0 && { metricAggregations: input.metricAggregations },
13892
+ ...input.orderBys !== void 0 && { orderBys: input.orderBys },
13893
+ ...input.returnPropertyQuota !== void 0 && { returnPropertyQuota: input.returnPropertyQuota },
13894
+ ...input.minuteRanges !== void 0 && { minuteRanges: input.minuteRanges }
13895
+ };
13896
+ const response = await platformProxy.post({
13897
+ endpoint: `/v1beta/properties/${propertyId}:runRealtimeReport`,
13898
+ baseUrlOverride: "https://analyticsdata.googleapis.com",
13899
+ data: requestBody,
13900
+ retries: 3
13901
+ });
13902
+ return runRealtimeReportOutputSchema.parse(response.data);
13903
+ }
13904
+ });
13905
+ }
13906
+ //#endregion
13907
+ //#region src/providers/google-analytics/tools/run-report.ts
13908
+ const DimensionSchema$6 = z.object({ name: z.string() });
13909
+ const MetricSchema = z.object({ name: z.string() });
13910
+ const DateRangeSchema = z.object({
13911
+ startDate: z.string(),
13912
+ endDate: z.string()
13913
+ });
13914
+ const OrderBySchema = z.object({
13915
+ dimension: z.object({ dimensionName: z.string() }).optional(),
13916
+ metric: z.object({ metricName: z.string() }).optional(),
13917
+ desc: z.boolean().optional()
13918
+ });
13919
+ const runReportInputSchema = z.object({
13920
+ property: z.string().describe("GA4 property ID. Example: \"properties/123456789\" or \"123456789\""),
13921
+ dimensions: z.array(DimensionSchema$6).optional(),
13922
+ metrics: z.array(MetricSchema).optional(),
13923
+ dateRanges: z.array(DateRangeSchema).optional(),
13924
+ dimensionFilter: z.object({}).passthrough().optional(),
13925
+ metricFilter: z.object({}).passthrough().optional(),
13926
+ ordering: z.array(OrderBySchema).optional(),
13927
+ limit: z.number().optional()
13928
+ });
13929
+ const DimensionHeaderSchema = z.object({ name: z.string().optional() });
13930
+ const MetricHeaderSchema = z.object({
13931
+ name: z.string().optional(),
13932
+ type: z.string().optional()
13933
+ });
13934
+ const DimensionValueSchema = z.object({ value: z.string().optional() });
13935
+ const MetricValueSchema = z.object({ value: z.string().optional() });
13936
+ const RowSchema = z.object({
13937
+ dimensionValues: z.array(DimensionValueSchema).optional(),
13938
+ metricValues: z.array(MetricValueSchema).optional()
13939
+ });
13940
+ const runReportOutputSchema = z.object({
13941
+ dimensionHeaders: z.array(DimensionHeaderSchema).optional(),
13942
+ metricHeaders: z.array(MetricHeaderSchema).optional(),
13943
+ rows: z.array(RowSchema).optional(),
13944
+ rowCount: z.number().optional(),
13945
+ totals: z.array(RowSchema).optional(),
13946
+ maximums: z.array(RowSchema).optional(),
13947
+ minimums: z.array(RowSchema).optional()
13948
+ });
13949
+ function runReportTool(proxy) {
13950
+ return createTool({
13951
+ id: "google_analytics_run_report",
13952
+ description: "Run a GA4 report for a property",
13953
+ inputSchema: runReportInputSchema,
13954
+ outputSchema: runReportOutputSchema,
13955
+ execute: async (input, { requestContext }) => {
13956
+ const platformProxy = proxy.withRequestContext(requestContext);
13957
+ const propertyNumericId = input.property.replace(/^properties\//, "");
13958
+ const response = await platformProxy.post({
13959
+ endpoint: `/v1beta/properties/${encodeURIComponent(propertyNumericId)}:runReport`,
13960
+ baseUrlOverride: "https://analyticsdata.googleapis.com",
13961
+ data: {
13962
+ ...input.dimensions !== void 0 && { dimensions: input.dimensions },
13963
+ ...input.metrics !== void 0 && { metrics: input.metrics },
13964
+ ...input.dateRanges !== void 0 && { dateRanges: input.dateRanges },
13965
+ ...input.dimensionFilter !== void 0 && { dimensionFilter: input.dimensionFilter },
13966
+ ...input.metricFilter !== void 0 && { metricFilter: input.metricFilter },
13967
+ ...input.ordering !== void 0 && { orderBys: input.ordering },
13968
+ ...input.limit !== void 0 && { limit: input.limit }
13969
+ },
13970
+ retries: 3
13971
+ });
13972
+ const providerResponse = z.object({
13973
+ dimensionHeaders: z.array(z.object({ name: z.string().optional() })).optional(),
13974
+ metricHeaders: z.array(z.object({
13975
+ name: z.string().optional(),
13976
+ type: z.string().optional()
13977
+ })).optional(),
13978
+ rows: z.array(z.object({
13979
+ dimensionValues: z.array(z.object({ value: z.string().optional() })).optional(),
13980
+ metricValues: z.array(z.object({ value: z.string().optional() })).optional()
13981
+ })).optional(),
13982
+ rowCount: z.number().optional(),
13983
+ totals: z.array(z.object({
13984
+ dimensionValues: z.array(z.object({ value: z.string().optional() })).optional(),
13985
+ metricValues: z.array(z.object({ value: z.string().optional() })).optional()
13986
+ })).optional(),
13987
+ maximums: z.array(z.object({
13988
+ dimensionValues: z.array(z.object({ value: z.string().optional() })).optional(),
13989
+ metricValues: z.array(z.object({ value: z.string().optional() })).optional()
13990
+ })).optional(),
13991
+ minimums: z.array(z.object({
13992
+ dimensionValues: z.array(z.object({ value: z.string().optional() })).optional(),
13993
+ metricValues: z.array(z.object({ value: z.string().optional() })).optional()
13994
+ })).optional()
13995
+ }).parse(response.data);
13996
+ return {
13997
+ dimensionHeaders: providerResponse.dimensionHeaders,
13998
+ metricHeaders: providerResponse.metricHeaders,
13999
+ rows: providerResponse.rows,
14000
+ rowCount: providerResponse.rowCount,
14001
+ totals: providerResponse.totals,
14002
+ maximums: providerResponse.maximums,
14003
+ minimums: providerResponse.minimums
14004
+ };
14005
+ }
14006
+ });
14007
+ }
14008
+ //#endregion
14009
+ //#region src/providers/google-analytics/tools/update-data-stream.ts
14010
+ const updateDataStreamInputSchema = z.object({
14011
+ propertyId: z.string().describe("GA4 property ID."),
14012
+ dataStreamId: z.string().describe("Data stream ID to update."),
14013
+ displayName: z.string().optional().describe("Human-readable display name for the Data Stream."),
14014
+ webStreamData: z.object({ defaultUri: z.string().optional().describe("Domain name of the web app being measured.") }).optional().describe("Data specific to web streams."),
14015
+ updateMask: z.string().optional().describe("The list of fields to be updated. If omitted, it will be computed from provided fields.")
14016
+ });
14017
+ const WebStreamDataSchema = z.object({
14018
+ defaultUri: z.string().optional(),
14019
+ measurementId: z.string().optional(),
14020
+ firebaseAppId: z.string().optional()
14021
+ });
14022
+ const AndroidAppStreamDataSchema = z.object({
14023
+ packageName: z.string().optional(),
14024
+ firebaseAppId: z.string().optional()
14025
+ });
14026
+ const IosAppStreamDataSchema = z.object({
14027
+ bundleId: z.string().optional(),
14028
+ firebaseAppId: z.string().optional()
14029
+ });
14030
+ const DataStreamSchema = z.object({
14031
+ name: z.string(),
14032
+ type: z.string().optional(),
14033
+ displayName: z.string().optional(),
14034
+ createTime: z.string().optional(),
14035
+ updateTime: z.string().optional(),
14036
+ webStreamData: WebStreamDataSchema.optional(),
14037
+ androidAppStreamData: AndroidAppStreamDataSchema.optional(),
14038
+ iosAppStreamData: IosAppStreamDataSchema.optional()
14039
+ });
14040
+ const updateDataStreamOutputSchema = DataStreamSchema;
14041
+ function updateDataStreamTool(proxy) {
14042
+ return createTool({
14043
+ id: "google_analytics_update_data_stream",
14044
+ description: "Update a GA4 data stream.",
14045
+ inputSchema: updateDataStreamInputSchema,
14046
+ outputSchema: updateDataStreamOutputSchema,
14047
+ execute: async (input, { requestContext }) => {
14048
+ const platformProxy = proxy.withRequestContext(requestContext);
14049
+ const updateMaskParts = [];
14050
+ if (input.displayName !== void 0) updateMaskParts.push("displayName");
14051
+ if (input.webStreamData?.defaultUri !== void 0) updateMaskParts.push("webStreamData.defaultUri");
14052
+ const updateMask = input.updateMask || updateMaskParts.join(",");
14053
+ if (!updateMask) throw new platformProxy.ActionError({
14054
+ type: "invalid_input",
14055
+ message: "No fields to update. Provide at least one of displayName or webStreamData.defaultUri, or specify updateMask explicitly."
14056
+ });
14057
+ const requestBody = {};
14058
+ if (input.displayName !== void 0) requestBody.displayName = input.displayName;
14059
+ if (input.webStreamData?.defaultUri !== void 0) requestBody.webStreamData = { defaultUri: input.webStreamData.defaultUri };
14060
+ const response = await platformProxy.patch({
14061
+ endpoint: `/v1beta/properties/${encodeURIComponent(input.propertyId)}/dataStreams/${encodeURIComponent(input.dataStreamId)}`,
14062
+ params: { updateMask },
14063
+ data: requestBody,
14064
+ retries: 3,
14065
+ baseUrlOverride: "https://analyticsadmin.googleapis.com"
14066
+ });
14067
+ return DataStreamSchema.parse(response.data);
14068
+ }
14069
+ });
14070
+ }
14071
+ //#endregion
14072
+ //#region src/providers/google-analytics/tools/update-property.ts
14073
+ const updatePropertyInputSchema = z.object({
14074
+ name: z.string().describe("Property resource name. Example: \"properties/123456789\""),
14075
+ displayName: z.string().optional().describe("Human-readable display name for the property."),
14076
+ timeZone: z.string().optional().describe("The reporting time zone for the property. Example: \"America/Los_Angeles\"."),
14077
+ currencyCode: z.string().optional().describe("The currency type used in reports. Example: \"USD\"."),
14078
+ industryCategory: z.string().optional().describe("Industry category. Example: \"TECHNOLOGY\".")
14079
+ });
14080
+ const ProviderPropertySchema = z.object({
14081
+ name: z.string(),
14082
+ createTime: z.string().optional(),
14083
+ updateTime: z.string().optional(),
14084
+ parent: z.string().optional(),
14085
+ displayName: z.string().optional(),
14086
+ industryCategory: z.string().optional(),
14087
+ timeZone: z.string().optional(),
14088
+ currencyCode: z.string().optional(),
14089
+ serviceLevel: z.string().optional(),
14090
+ account: z.string().optional(),
14091
+ propertyType: z.string().optional()
14092
+ });
14093
+ const updatePropertyOutputSchema = z.object({
14094
+ name: z.string(),
14095
+ displayName: z.string().optional(),
14096
+ industryCategory: z.string().optional(),
14097
+ timeZone: z.string().optional(),
14098
+ currencyCode: z.string().optional(),
14099
+ serviceLevel: z.string().optional(),
14100
+ account: z.string().optional()
14101
+ });
14102
+ function updatePropertyTool(proxy) {
14103
+ return createTool({
14104
+ id: "google_analytics_update_property",
14105
+ description: "Update a GA4 property.",
14106
+ inputSchema: updatePropertyInputSchema,
14107
+ outputSchema: updatePropertyOutputSchema,
14108
+ execute: async (input, { requestContext }) => {
14109
+ const platformProxy = proxy.withRequestContext(requestContext);
14110
+ const propertyId = input.name.replace(/^properties\//, "");
14111
+ if (!propertyId || propertyId.includes("/")) throw new platformProxy.ActionError({
14112
+ type: "invalid_input",
14113
+ message: "name must be a valid property resource name in the format \"properties/{propertyId}\"."
14114
+ });
14115
+ const updateMaskFields = [];
14116
+ if (input.displayName !== void 0) updateMaskFields.push("displayName");
14117
+ if (input.timeZone !== void 0) updateMaskFields.push("timeZone");
14118
+ if (input.currencyCode !== void 0) updateMaskFields.push("currencyCode");
14119
+ if (input.industryCategory !== void 0) updateMaskFields.push("industryCategory");
14120
+ if (updateMaskFields.length === 0) throw new platformProxy.ActionError({
14121
+ type: "invalid_input",
14122
+ message: "At least one field to update must be provided."
14123
+ });
14124
+ const response = await platformProxy.patch({
14125
+ endpoint: `/v1beta/properties/${encodeURIComponent(propertyId)}`,
14126
+ params: { updateMask: updateMaskFields.join(",") },
14127
+ data: {
14128
+ ...input.displayName !== void 0 && { displayName: input.displayName },
14129
+ ...input.timeZone !== void 0 && { timeZone: input.timeZone },
14130
+ ...input.currencyCode !== void 0 && { currencyCode: input.currencyCode },
14131
+ ...input.industryCategory !== void 0 && { industryCategory: input.industryCategory }
14132
+ },
14133
+ retries: 3,
14134
+ baseUrlOverride: "https://analyticsadmin.googleapis.com"
14135
+ });
14136
+ const providerProperty = ProviderPropertySchema.parse(response.data);
14137
+ return {
14138
+ name: providerProperty.name,
14139
+ ...providerProperty.displayName !== void 0 && { displayName: providerProperty.displayName },
14140
+ ...providerProperty.industryCategory !== void 0 && { industryCategory: providerProperty.industryCategory },
14141
+ ...providerProperty.timeZone !== void 0 && { timeZone: providerProperty.timeZone },
14142
+ ...providerProperty.currencyCode !== void 0 && { currencyCode: providerProperty.currencyCode },
14143
+ ...providerProperty.serviceLevel !== void 0 && { serviceLevel: providerProperty.serviceLevel },
14144
+ ...providerProperty.account !== void 0 && { account: providerProperty.account }
14145
+ };
14146
+ }
14147
+ });
14148
+ }
14149
+ //#endregion
14150
+ //#region src/providers/google-analytics/tools.ts
14151
+ function createGoogleAnalyticsTools(options) {
14152
+ const platformProxy = createPlatformProxy({
14153
+ connectionId: options?.connectionId,
14154
+ client: options?.client
14155
+ });
14156
+ return applyToolFilter({
14157
+ google_analytics_archive_conversion_event: archiveConversionEventTool(platformProxy),
14158
+ google_analytics_batch_run_reports: batchRunReportsTool(platformProxy),
14159
+ google_analytics_create_conversion_event: createConversionEventTool(platformProxy),
14160
+ google_analytics_create_data_stream: createDataStreamTool(platformProxy),
14161
+ google_analytics_create_property: createPropertyTool$1(platformProxy),
14162
+ google_analytics_get_metadata: getMetadataTool(platformProxy),
14163
+ google_analytics_run_pivot_report: runPivotReportTool(platformProxy),
14164
+ google_analytics_run_realtime_report: runRealtimeReportTool(platformProxy),
14165
+ google_analytics_run_report: runReportTool(platformProxy),
14166
+ google_analytics_update_data_stream: updateDataStreamTool(platformProxy),
14167
+ google_analytics_update_property: updatePropertyTool(platformProxy)
14168
+ }, {
14169
+ allowTools: options?.allowTools,
14170
+ disallowTools: options?.disallowTools
14171
+ });
14172
+ }
14173
+ //#endregion
14174
+ //#region src/providers/google-analytics/index.ts
14175
+ const googleAnalyticsProvider = {
14176
+ integrationId: "google-analytics",
14177
+ envVar: "MASTRA_GOOGLE_ANALYTICS_CONNECTION_ID",
14178
+ createTools: createGoogleAnalyticsTools
14179
+ };
14180
+ //#endregion
13370
14181
  //#region src/providers/google-calendar/tools/add-attendee.ts
13371
14182
  const addAttendeeInputSchema = z.object({
13372
14183
  calendarId: z.string().describe("Calendar identifier. Use \"primary\" for the primary calendar. Example: \"primary\""),
@@ -73286,6 +74097,7 @@ const TOOLS = [
73286
74097
  discordProvider,
73287
74098
  firefliesProvider,
73288
74099
  githubProvider,
74100
+ googleAnalyticsProvider,
73289
74101
  googleCalendarProvider,
73290
74102
  googleDocsProvider,
73291
74103
  googleDriveProvider,