@magemetrics/core 0.12.0-rc1 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -58,7 +58,7 @@ var addApiKeyHeader = (apiKey) => {
58
58
 
59
59
  // package.json
60
60
  var package_default = {
61
- version: "0.12.0-rc1"};
61
+ version: "0.12.1"};
62
62
 
63
63
  // src/core/MageMetricsEventEmitter.ts
64
64
  var MageMetricsEventEmitter = class {
@@ -482,7 +482,7 @@ function getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {
482
482
  };
483
483
  }
484
484
 
485
- // ../../node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/router/reg-exp-router/node.js
485
+ // ../../node_modules/.pnpm/hono@4.12.14/node_modules/hono/dist/router/reg-exp-router/node.js
486
486
  new Set(".\\+*[^]$()");
487
487
  var createRoute = (routeConfig) => {
488
488
  const route = {
@@ -856,6 +856,7 @@ var FEEDBACK_OPTIONS = [
856
856
  ];
857
857
  var FeedbackSchema = z.object({
858
858
  created_at: z.string(),
859
+ report_id: z.uuid(),
859
860
  flow_data_id: z.number(),
860
861
  helpfulness: z.enum(FEEDBACK_OPTIONS.map((option) => option.value)),
861
862
  id: z.number()
@@ -968,7 +969,11 @@ var MaterializationFieldsSchema = z.object({
968
969
  var ReportSchema = z.object({
969
970
  created_at: z.string(),
970
971
  flow_id: z.string(),
971
- id: z.number(),
972
+ id: z.number().openapi({
973
+ description: "Deprecated: use uuid.",
974
+ deprecated: true
975
+ }),
976
+ uuid: z.string(),
972
977
  is_sample: z.boolean(),
973
978
  schema: z.string(),
974
979
  sql: z.string(),
@@ -1029,7 +1034,11 @@ var ReportExplainabilitySchema = z.object({
1029
1034
  assumptions_score: z.number().nullish(),
1030
1035
  assumptions_score_reason: z.string().nullish(),
1031
1036
  id: z.number(),
1032
- flow_data_id: z.number(),
1037
+ report_id: z.uuid(),
1038
+ flow_data_id: z.number().openapi({
1039
+ description: "Deprecated: use report_id.",
1040
+ deprecated: true
1041
+ }),
1033
1042
  created_at: z.string()
1034
1043
  });
1035
1044
  var FrontendReportExplainabilitySchema = ReportExplainabilitySchema.omit({
@@ -1048,6 +1057,11 @@ var FrontendReportExplainabilitySchema = ReportExplainabilitySchema.omit({
1048
1057
  output_dataset: z.string().optional(),
1049
1058
  sql: z.string().optional()
1050
1059
  });
1060
+ var ReportNarrationSchema = z.object({
1061
+ step_name: z.string(),
1062
+ step_order: z.number(),
1063
+ narration: z.string()
1064
+ });
1051
1065
  var FilterOperatorSchema = z.enum([
1052
1066
  // Text operators
1053
1067
  "eq",
@@ -1216,7 +1230,18 @@ var DeleteUploadedFilePath = "/api/v1/uploaded-files/{uploadedFileId}";
1216
1230
  // ../shared/dist/src/endpoints/companion/flows.routes.js
1217
1231
  var FlowIdParam = z.object({ flowId: z.uuid() }).openapi("FlowId", { type: "string" });
1218
1232
  var FlowDataIdParam = z.object({ flowDataId: z.string().pipe(z.coerce.number()) }).openapi("FlowDataId", { type: "integer" });
1219
- var ReportId = z.string().pipe(z.coerce.number());
1233
+ var parseReportId = (val, ctx) => {
1234
+ const num = Number(val);
1235
+ if (Number.isInteger(num) && num > 0)
1236
+ return num;
1237
+ const uuidResult = z.uuid().safeParse(val);
1238
+ if (uuidResult.success)
1239
+ return val;
1240
+ ctx.addIssue("report_id must be a positive integer or a valid UUID");
1241
+ return z.NEVER;
1242
+ };
1243
+ var ReportId = z.string().transform((val, ctx) => parseReportId(val, ctx)).openapi({ type: "string", description: "Numeric legacy ID or UUID" });
1244
+ var ReportIdFromBody = z.union([z.string(), z.number()]).transform((val, ctx) => parseReportId(String(val), ctx));
1220
1245
  var ReportIdParam = z.object({ report_id: ReportId }).openapi("ReportId", { type: "integer" });
1221
1246
  var CreateFlowFileSchema = z.object({
1222
1247
  type: z.literal("file"),
@@ -1267,7 +1292,7 @@ createRoute({
1267
1292
  hide: true,
1268
1293
  path: "/api/v1/flows/{flowId}/data-reports/last/status",
1269
1294
  operationId: "retrieveLatestDataReportStatus",
1270
- tags: ["public"],
1295
+ tags: ["internal"],
1271
1296
  request: {
1272
1297
  headers: SupabaseHeaderSchema,
1273
1298
  params: FlowIdParam
@@ -1536,7 +1561,7 @@ createRoute({
1536
1561
  method: "get",
1537
1562
  path: "/api/v1/data-reports/{report_id}/feedback",
1538
1563
  operationId: "getDataReportFeedback",
1539
- tags: ["public"],
1564
+ tags: ["private"],
1540
1565
  request: {
1541
1566
  headers: SupabaseHeaderSchema,
1542
1567
  params: ReportIdParam
@@ -1574,7 +1599,7 @@ createRoute({
1574
1599
  method: "post",
1575
1600
  path: "/api/v1/data-reports/{report_id}/feedback",
1576
1601
  operationId: "upsertReportFeedback",
1577
- tags: ["public"],
1602
+ tags: ["private"],
1578
1603
  request: {
1579
1604
  headers: SupabaseHeaderSchema,
1580
1605
  params: ReportIdParam,
@@ -1610,7 +1635,7 @@ createRoute({
1610
1635
  method: "delete",
1611
1636
  path: "/api/v1/data-reports/{report_id}/feedback",
1612
1637
  operationId: "deleteReportFeedback",
1613
- tags: ["public"],
1638
+ tags: ["private"],
1614
1639
  request: {
1615
1640
  headers: SupabaseHeaderSchema,
1616
1641
  params: ReportIdParam
@@ -1677,6 +1702,45 @@ createRoute({
1677
1702
  }
1678
1703
  }
1679
1704
  });
1705
+ var ReportUuidParam = z.object({ report_id: z.uuid() }).openapi("ReportUuid");
1706
+ createRoute({
1707
+ method: "get",
1708
+ path: "/api/v1/data-reports/{report_id}/narrations",
1709
+ operationId: "getDataReportNarrations",
1710
+ tags: ["public"],
1711
+ request: {
1712
+ headers: SupabaseHeaderSchema,
1713
+ params: ReportUuidParam
1714
+ },
1715
+ responses: {
1716
+ 200: {
1717
+ description: "The narration steps for the report",
1718
+ content: {
1719
+ "application/json": {
1720
+ schema: z.array(ReportNarrationSchema)
1721
+ }
1722
+ }
1723
+ },
1724
+ 404: {
1725
+ content: {
1726
+ "application/json": {
1727
+ schema: z.object({ error: z.string() })
1728
+ }
1729
+ },
1730
+ description: "Unable to retrieve report with this id"
1731
+ },
1732
+ 500: {
1733
+ description: "Something wrong happened",
1734
+ content: {
1735
+ "application/json": {
1736
+ schema: z.object({
1737
+ error: z.string()
1738
+ })
1739
+ }
1740
+ }
1741
+ }
1742
+ }
1743
+ });
1680
1744
  var ColumnLineageNodeSchema = z.object({
1681
1745
  id: z.string(),
1682
1746
  type: z.enum([
@@ -1713,7 +1777,7 @@ createRoute({
1713
1777
  content: {
1714
1778
  "application/json": {
1715
1779
  schema: z.object({
1716
- report_id: z.number().int().describe("The report id"),
1780
+ report_id: z.union([z.number().int(), z.uuid()]).describe("The report identifier (UUID or legacy numeric ID)"),
1717
1781
  column_name: z.string().describe("The column name to get lineage for")
1718
1782
  })
1719
1783
  }
@@ -1799,7 +1863,7 @@ createRoute({
1799
1863
  method: "post",
1800
1864
  path: "/api/v1/flow_data/v1/materialized_views/refresh",
1801
1865
  operationId: "refreshMaterializedViews",
1802
- tags: ["public"],
1866
+ tags: ["private"],
1803
1867
  request: {
1804
1868
  headers: SupabaseHeaderSchema,
1805
1869
  body: {
@@ -1807,7 +1871,8 @@ createRoute({
1807
1871
  content: {
1808
1872
  "application/json": {
1809
1873
  schema: z.object({
1810
- flow_data_ids: z.array(z.number().int()).min(1).describe("List of flow_data IDs to refresh")
1874
+ report_ids: z.array(ReportIdFromBody).min(1).describe("Preferred over flow_data_ids. List of report IDs to refresh.").optional(),
1875
+ flow_data_ids: z.array(ReportIdFromBody).min(1).describe("Deprecated: use report_ids.").optional()
1811
1876
  })
1812
1877
  }
1813
1878
  }
@@ -1852,20 +1917,24 @@ createRoute({
1852
1917
  method: "get",
1853
1918
  path: "/api/v1/flow_data/materialization-status",
1854
1919
  operationId: "getMaterializationStatus",
1855
- tags: ["public"],
1920
+ tags: ["private"],
1856
1921
  request: {
1857
1922
  headers: SupabaseHeaderSchema,
1858
1923
  query: z.object({
1859
- ids: z.string().transform((s) => s.split(",").map(Number)).describe("Comma-separated list of flow_data IDs")
1924
+ ids: z.string().transform((s) => s.split(",")).pipe(z.array(ReportId)).describe("Comma-separated list of reports IDs")
1860
1925
  })
1861
1926
  },
1862
1927
  responses: {
1863
1928
  200: {
1864
- description: "Materialization status for the requested flow_data IDs",
1929
+ description: "Materialization status for the requested report IDs",
1865
1930
  content: {
1866
1931
  "application/json": {
1867
1932
  schema: z.array(z.object({
1868
- id: z.number(),
1933
+ uuid: z.string().describe("The report UUID"),
1934
+ id: z.number().openapi({
1935
+ description: "Deprecated: use uuid. Legacy numeric ID.",
1936
+ deprecated: true
1937
+ }),
1869
1938
  materialized_status: MaterializationStatusSchema.nullable(),
1870
1939
  last_materialized_at: z.string().nullable()
1871
1940
  }))
@@ -2596,6 +2665,20 @@ dayjs.extend(timezone);
2596
2665
  var daysjs_default = dayjs;
2597
2666
 
2598
2667
  // ../shared/dist/src/data/FormattedData.js
2668
+ var numberFormatCache = /* @__PURE__ */ new Map();
2669
+ var getNumberFormatter = (minimumFractionDigits, maximumFractionDigits, useGrouping) => {
2670
+ const key = `${minimumFractionDigits}:${maximumFractionDigits}:${useGrouping}`;
2671
+ let formatter = numberFormatCache.get(key);
2672
+ if (!formatter) {
2673
+ formatter = new Intl.NumberFormat(void 0, {
2674
+ minimumFractionDigits,
2675
+ maximumFractionDigits,
2676
+ useGrouping
2677
+ });
2678
+ numberFormatCache.set(key, formatter);
2679
+ }
2680
+ return formatter;
2681
+ };
2599
2682
  var formatWithAutoPrecision = (value, options = {}) => {
2600
2683
  const { minPrecision = 0, maxPrecision = 6, trimZeros = true, useGrouping = true } = options;
2601
2684
  if (typeof value !== "number" || isNaN(value)) {
@@ -2628,11 +2711,7 @@ var formatWithAutoPrecision = (value, options = {}) => {
2628
2711
  }
2629
2712
  }
2630
2713
  maximumFractionDigits = Math.max(maximumFractionDigits, minPrecision);
2631
- const formatter = new Intl.NumberFormat(void 0, {
2632
- minimumFractionDigits: trimZeros ? 0 : maximumFractionDigits,
2633
- maximumFractionDigits,
2634
- useGrouping
2635
- });
2714
+ const formatter = getNumberFormatter(trimZeros ? 0 : maximumFractionDigits, maximumFractionDigits, useGrouping);
2636
2715
  return formatter.format(value);
2637
2716
  };
2638
2717
  var MIN_VALID_YEAR = 1900;
@@ -2861,14 +2940,26 @@ var VisualizationConfigurationSchema = z.discriminatedUnion("type", [
2861
2940
  })
2862
2941
  ]);
2863
2942
  var BaseVisualizationSchema = z.object({
2864
- id: z.number(),
2865
- flow_data_id: z.number(),
2943
+ id: z.number().openapi({
2944
+ description: "Deprecated: use uuid.",
2945
+ deprecated: true
2946
+ }),
2947
+ uuid: z.string(),
2948
+ report_uuid: z.string(),
2949
+ flow_data_id: z.number().openapi({
2950
+ description: "Deprecated: use report_uuid.",
2951
+ deprecated: true
2952
+ }),
2866
2953
  created_at: z.string(),
2867
2954
  sql: z.string(),
2868
2955
  data_sample: z.array(z.record(z.string(), z.unknown())),
2869
2956
  is_sample: z.boolean(),
2870
2957
  data_summary: z.record(z.string(), z.unknown()),
2871
- flow_data: MaterializationFieldsSchema.optional()
2958
+ flow_data: MaterializationFieldsSchema.optional().openapi({
2959
+ description: "Deprecated: use materialization.",
2960
+ deprecated: true
2961
+ }),
2962
+ materialization: MaterializationFieldsSchema.optional()
2872
2963
  });
2873
2964
  var V1VisualizationSchema = z.object({
2874
2965
  ...BaseVisualizationSchema.shape,
@@ -3633,5 +3724,3 @@ var MageMetricsClient = class {
3633
3724
  };
3634
3725
 
3635
3726
  export { BrowserStorageAdapter, CHECK_KEY, DirectAuthProvider, ExternalAuthProvider, MageMetricsClient, MageMetricsEventEmitter, MemoryStorageAdapter, TOKEN_STORAGE_KEY, getPublicApiClient };
3636
- //# sourceMappingURL=index.js.map
3637
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@magemetrics/core",
3
3
  "type": "module",
4
- "version": "0.12.0-rc1",
4
+ "version": "0.12.1",
5
5
  "description": "MageMetrics client library",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -33,10 +33,10 @@
33
33
  "dist/"
34
34
  ],
35
35
  "dependencies": {
36
- "@noble/hashes": "^2.0.1",
37
- "@supabase/auth-js": "^2.97.0",
38
- "@xyflow/system": "^0.0.75",
39
- "ai": "6.0.137",
36
+ "@noble/hashes": "^2.2.0",
37
+ "@supabase/auth-js": "^2.103.0",
38
+ "@xyflow/system": "^0.0.76",
39
+ "ai": "6.0.159",
40
40
  "dayjs": "^1.11.20",
41
41
  "openapi-fetch": "^0.17.0",
42
42
  "type-fest": "^5.5.0",