eas-cli 26.0.0 → 27.2.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 (82) hide show
  1. package/README.md +293 -148
  2. package/build/analytics/AnalyticsManager.d.ts +2 -0
  3. package/build/analytics/AnalyticsManager.js +2 -0
  4. package/build/build/build.d.ts +1 -2
  5. package/build/build/build.js +9 -4
  6. package/build/build/errors.d.ts +2 -0
  7. package/build/build/errors.js +4 -1
  8. package/build/build/evaluateConfigWithEnvVarsAsync.js +1 -3
  9. package/build/build/freeTierNearLimitAgentUpdatesTip.d.ts +98 -0
  10. package/build/build/freeTierNearLimitAgentUpdatesTip.js +205 -0
  11. package/build/build/runBuildAndSubmit.d.ts +2 -0
  12. package/build/build/runBuildAndSubmit.js +3 -0
  13. package/build/build/simulatorsLaunchHint.d.ts +7 -0
  14. package/build/build/simulatorsLaunchHint.js +40 -0
  15. package/build/build/utils/expoTokenRole.d.ts +4 -0
  16. package/build/build/utils/expoTokenRole.js +14 -0
  17. package/build/commandUtils/EasCommand.js +3 -3
  18. package/build/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.js +2 -1
  19. package/build/commandUtils/workflow/referencedFiles.d.ts +6 -0
  20. package/build/commandUtils/workflow/referencedFiles.js +63 -0
  21. package/build/commandUtils/workflow/types.d.ts +1 -1
  22. package/build/commandUtils/workflow/utils.js +34 -5
  23. package/build/commands/account/login.js +6 -0
  24. package/build/commands/account/view.d.ts +0 -7
  25. package/build/commands/account/view.js +4 -74
  26. package/build/commands/build/index.js +8 -1
  27. package/build/commands/observe/session.js +4 -3
  28. package/build/commands/observe/trace.d.ts +17 -0
  29. package/build/commands/observe/trace.js +58 -0
  30. package/build/commands/observe/traces.d.ts +33 -0
  31. package/build/commands/observe/traces.js +159 -0
  32. package/build/commands/simulator/control.js +41 -6
  33. package/build/commands/simulator/logs.d.ts +22 -0
  34. package/build/commands/simulator/logs.js +188 -0
  35. package/build/commands/workflow/cancel.js +9 -20
  36. package/build/commands/workflow/run.js +9 -0
  37. package/build/commands/workflow/runs.js +1 -1
  38. package/build/graphql/generated.d.ts +698 -5
  39. package/build/graphql/generated.js +25 -4
  40. package/build/graphql/mutations/UserPreferenceMutation.d.ts +5 -0
  41. package/build/graphql/mutations/UserPreferenceMutation.js +24 -0
  42. package/build/graphql/mutations/WorkflowRevisionMutation.d.ts +3 -2
  43. package/build/graphql/mutations/WorkflowRevisionMutation.js +12 -3
  44. package/build/graphql/queries/AccountQuery.d.ts +3 -1
  45. package/build/graphql/queries/AccountQuery.js +54 -0
  46. package/build/graphql/queries/ObserveQuery.d.ts +24 -1
  47. package/build/graphql/queries/ObserveQuery.js +114 -1
  48. package/build/graphql/queries/UserPreferenceQuery.d.ts +8 -0
  49. package/build/graphql/queries/UserPreferenceQuery.js +28 -0
  50. package/build/graphql/queries/WorkflowRunQuery.js +6 -0
  51. package/build/graphql/types/Observe.d.ts +1 -0
  52. package/build/graphql/types/Observe.js +53 -1
  53. package/build/graphql/types/WorkflowRun.js +1 -0
  54. package/build/help.js +13 -6
  55. package/build/log.d.ts +2 -0
  56. package/build/log.js +10 -0
  57. package/build/observe/fetchSessions.d.ts +12 -1
  58. package/build/observe/fetchSessions.js +39 -2
  59. package/build/observe/fetchSpans.d.ts +27 -0
  60. package/build/observe/fetchSpans.js +36 -0
  61. package/build/observe/formatSessions.d.ts +3 -1
  62. package/build/observe/formatSessions.js +40 -3
  63. package/build/observe/formatSpans.d.ts +110 -0
  64. package/build/observe/formatSpans.js +250 -0
  65. package/build/observe/spanFilters.d.ts +5 -0
  66. package/build/observe/spanFilters.js +32 -0
  67. package/build/project/projectStatus.js +1 -0
  68. package/build/simulator/artifacts.d.ts +9 -0
  69. package/build/simulator/artifacts.js +97 -0
  70. package/build/simulator/download.d.ts +2 -0
  71. package/build/simulator/download.js +57 -0
  72. package/build/simulator/events.js +2 -10
  73. package/build/simulator/preview.d.ts +26 -0
  74. package/build/simulator/preview.js +156 -0
  75. package/build/simulator/utils.d.ts +5 -0
  76. package/build/simulator/utils.js +42 -0
  77. package/build/user/accountPermissions.d.ts +11 -0
  78. package/build/user/accountPermissions.js +89 -0
  79. package/oclif.manifest.json +920 -422
  80. package/package.json +6 -6
  81. package/build/build/freeTierLimitGuidance.d.ts +0 -19
  82. package/build/build/freeTierLimitGuidance.js +0 -39
@@ -74,6 +74,34 @@ function errorToEntry(event) {
74
74
  environment: event.environment ?? null,
75
75
  };
76
76
  }
77
+ function spanToEntry(span) {
78
+ return {
79
+ source: 'span',
80
+ id: span.id,
81
+ timestamp: span.startTimestamp,
82
+ sessionId: span.sessionId ?? '',
83
+ name: span.name,
84
+ appVersion: span.appVersion,
85
+ appBuildNumber: span.appBuildNumber,
86
+ appUpdateId: span.appUpdateId ?? null,
87
+ deviceModel: span.deviceModel,
88
+ deviceOs: span.deviceOs,
89
+ deviceOsVersion: span.deviceOsVersion,
90
+ countryCode: span.countryCode ?? null,
91
+ easClientId: span.easClientId,
92
+ environment: span.environment ?? null,
93
+ traceId: span.traceId,
94
+ spanId: span.spanId,
95
+ parentSpanId: span.parentSpanId ?? null,
96
+ durationMs: span.durationMs,
97
+ statusCode: span.statusCode,
98
+ httpMethod: span.http?.method ?? null,
99
+ httpStatusCode: span.http?.statusCode ?? null,
100
+ httpErrorType: span.http?.errorType ?? null,
101
+ urlHost: span.http?.urlHost ?? null,
102
+ urlFull: span.http?.urlFull ?? null,
103
+ };
104
+ }
77
105
  function sessionLogToEntry(log) {
78
106
  return log.__typename === 'AppObserveError' ? errorToEntry(log) : userEventToEntry(log);
79
107
  }
@@ -93,7 +121,7 @@ async function verifyObserveSessionAccessAsync(graphqlClient, appId) {
93
121
  });
94
122
  }
95
123
  async function fetchObserveSessionEventsAsync(graphqlClient, appId, options) {
96
- const { metrics, logs, metricsPageInfo, logsPageInfo } = await ObserveQuery_1.ObserveQuery.sessionEventsAsync(graphqlClient, {
124
+ const { metrics, logs, spans, metricsPageInfo, logsPageInfo, spansPageInfo } = await ObserveQuery_1.ObserveQuery.sessionEventsAsync(graphqlClient, {
97
125
  appId,
98
126
  id: options.sessionId,
99
127
  first: options.limit,
@@ -105,8 +133,16 @@ async function fetchObserveSessionEventsAsync(graphqlClient, appId, options) {
105
133
  field: generated_1.AppObserveLogsOrderByField.Timestamp,
106
134
  direction: generated_1.AppObserveOrderDirection.Asc,
107
135
  },
136
+ spansOrderBy: {
137
+ field: generated_1.AppObserveSpanListOrderByField.StartTimestamp,
138
+ direction: generated_1.AppObserveOrderDirection.Asc,
139
+ },
108
140
  });
109
- const entries = [...metrics.map(metricEventToEntry), ...logs.map(sessionLogToEntry)].sort((a, b) => (a.timestamp < b.timestamp ? -1 : a.timestamp > b.timestamp ? 1 : 0));
141
+ const entries = [
142
+ ...metrics.map(metricEventToEntry),
143
+ ...logs.map(sessionLogToEntry),
144
+ ...spans.map(spanToEntry),
145
+ ].sort((a, b) => (a.timestamp < b.timestamp ? -1 : a.timestamp > b.timestamp ? 1 : 0));
110
146
  let metadata = null;
111
147
  if (entries.length > 0) {
112
148
  const newest = entries[entries.length - 1];
@@ -127,6 +163,7 @@ async function fetchObserveSessionEventsAsync(graphqlClient, appId, options) {
127
163
  metadata,
128
164
  hasMoreMetricEvents: metricsPageInfo.hasNextPage,
129
165
  hasMoreLogEvents: logsPageInfo.hasNextPage,
166
+ hasMoreSpans: spansPageInfo.hasNextPage,
130
167
  };
131
168
  }
132
169
  /**
@@ -0,0 +1,27 @@
1
+ import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
2
+ import { AppObservePlatform, AppObserveSpan, AppObserveSpanKind, AppObserveSpanListOrderBy, AppObserveSpanStatusCode, PageInfo } from '../graphql/generated';
3
+ export interface FetchSpansOptions {
4
+ limit: number;
5
+ after?: string;
6
+ startTime: string;
7
+ endTime: string;
8
+ platforms?: AppObservePlatform[];
9
+ appVersion?: string;
10
+ buildNumber?: string;
11
+ updateId?: string;
12
+ environment?: string;
13
+ sessionId?: string;
14
+ names?: string[];
15
+ kinds?: AppObserveSpanKind[];
16
+ statusCodes?: AppObserveSpanStatusCode[];
17
+ hosts?: string[];
18
+ httpStatusCodes?: number[];
19
+ minDurationMs?: number;
20
+ rootOnly?: boolean;
21
+ }
22
+ export declare const NEWEST_SPANS_FIRST: AppObserveSpanListOrderBy;
23
+ export interface FetchSpansResult {
24
+ spans: AppObserveSpan[];
25
+ pageInfo: PageInfo;
26
+ }
27
+ export declare function fetchObserveSpansAsync(graphqlClient: ExpoGraphqlClient, appId: string, options: FetchSpansOptions): Promise<FetchSpansResult>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NEWEST_SPANS_FIRST = void 0;
4
+ exports.fetchObserveSpansAsync = fetchObserveSpansAsync;
5
+ const generated_1 = require("../graphql/generated");
6
+ const ObserveQuery_1 = require("../graphql/queries/ObserveQuery");
7
+ exports.NEWEST_SPANS_FIRST = {
8
+ field: generated_1.AppObserveSpanListOrderByField.StartTimestamp,
9
+ direction: generated_1.AppObserveOrderDirection.Desc,
10
+ };
11
+ async function fetchObserveSpansAsync(graphqlClient, appId, options) {
12
+ const filter = {
13
+ startTime: options.startTime,
14
+ endTime: options.endTime,
15
+ ...(options.platforms?.length && { platforms: options.platforms }),
16
+ ...(options.appVersion && { appVersion: options.appVersion }),
17
+ ...(options.buildNumber && { appBuildNumber: options.buildNumber }),
18
+ ...(options.updateId && { appUpdateId: options.updateId }),
19
+ ...(options.environment && { environment: options.environment }),
20
+ ...(options.sessionId && { sessionId: options.sessionId }),
21
+ ...(options.names?.length && { names: options.names }),
22
+ ...(options.kinds?.length && { kinds: options.kinds }),
23
+ ...(options.statusCodes?.length && { statusCodes: options.statusCodes }),
24
+ ...(options.hosts?.length && { hosts: options.hosts }),
25
+ ...(options.httpStatusCodes?.length && { httpStatusCodes: options.httpStatusCodes }),
26
+ ...(options.minDurationMs != null && { minDurationMs: options.minDurationMs }),
27
+ ...(options.rootOnly && { rootOnly: true }),
28
+ };
29
+ return await ObserveQuery_1.ObserveQuery.spanListAsync(graphqlClient, {
30
+ appId,
31
+ filter,
32
+ first: options.limit,
33
+ orderBy: exports.NEWEST_SPANS_FIRST,
34
+ ...(options.after && { after: options.after }),
35
+ });
36
+ }
@@ -4,6 +4,7 @@ export interface BuildSessionEventsOptions {
4
4
  metadata?: SessionMetadata | null;
5
5
  hasMoreMetricEvents?: boolean;
6
6
  hasMoreLogEvents?: boolean;
7
+ hasMoreSpans?: boolean;
7
8
  }
8
9
  export declare function buildObserveSessionEventsTable(entries: SessionEventEntry[], options?: BuildSessionEventsOptions): string;
9
10
  export interface ObserveSessionEventsJson {
@@ -12,8 +13,9 @@ export interface ObserveSessionEventsJson {
12
13
  entries: SessionEventEntry[];
13
14
  hasMoreMetricEvents: boolean;
14
15
  hasMoreLogEvents: boolean;
16
+ hasMoreSpans: boolean;
15
17
  }
16
- export declare function buildObserveSessionEventsJson(entries: SessionEventEntry[], sessionId: string, metadata: SessionMetadata | null, hasMoreMetricEvents: boolean, hasMoreLogEvents: boolean): ObserveSessionEventsJson;
18
+ export declare function buildObserveSessionEventsJson(entries: SessionEventEntry[], sessionId: string, metadata: SessionMetadata | null, hasMoreMetricEvents: boolean, hasMoreLogEvents: boolean, hasMoreSpans: boolean): ObserveSessionEventsJson;
17
19
  /**
18
20
  * Compact session ID for display in candidate lists — long UUIDs are
19
21
  * truncated to `<first-8>…<last-4>` so a row stays scannable.
@@ -7,16 +7,38 @@ exports.formatMetricCandidateTitle = formatMetricCandidateTitle;
7
7
  exports.formatLogCandidateTitle = formatLogCandidateTitle;
8
8
  const tslib_1 = require("tslib");
9
9
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
10
+ const formatSpans_1 = require("./formatSpans");
10
11
  const formatUtils_1 = require("./formatUtils");
11
12
  const metricNames_1 = require("./metricNames");
12
13
  const renderTextTable_1 = tslib_1.__importDefault(require("../utils/renderTextTable"));
14
+ const terminalText_1 = require("../utils/terminalText");
13
15
  function formatEntryName(entry) {
14
16
  if (entry.source === 'metric') {
15
17
  const name = (0, metricNames_1.getMetricDisplayName)(entry.name);
16
18
  return entry.routeName ? `${name} · ${entry.routeName}` : name;
17
19
  }
20
+ if (entry.source === 'span') {
21
+ if (!entry.urlHost) {
22
+ return (0, terminalText_1.sanitizeTerminalText)(entry.name);
23
+ }
24
+ const path = entry.urlFull ? (0, formatSpans_1.formatSpanUrlPath)(entry.urlFull) : '';
25
+ return (0, terminalText_1.sanitizeTerminalText)(`${entry.name} ${entry.urlHost}${path}`);
26
+ }
18
27
  return entry.name;
19
28
  }
29
+ function formatSpanEntryValue(entry) {
30
+ return typeof entry.durationMs === 'number' ? (0, formatSpans_1.formatSpanDuration)(entry.durationMs) : '-';
31
+ }
32
+ function formatSpanEntryProperties(entry) {
33
+ const parts = [`status=${entry.statusCode ?? '-'}`];
34
+ if (entry.httpStatusCode != null) {
35
+ parts.push(`http=${entry.httpStatusCode}`);
36
+ }
37
+ else if (entry.httpErrorType) {
38
+ parts.push(`error=${entry.httpErrorType}`);
39
+ }
40
+ return parts.join(' ');
41
+ }
20
42
  function formatMetricEntryValue(entry) {
21
43
  if (typeof entry.value === 'number') {
22
44
  return `${entry.value.toFixed(2)}s`;
@@ -62,13 +84,24 @@ function buildObserveSessionEventsTable(entries, options) {
62
84
  const rows = [];
63
85
  for (const entry of entries) {
64
86
  const offset = formatOffsetSeconds(startIso, entry.timestamp);
65
- const type = entry.source === 'metric' ? 'metric' : 'log';
87
+ const type = entry.source;
66
88
  const name = formatEntryName(entry);
67
89
  const severity = formatEntrySeverity(entry);
68
90
  if (entry.source === 'metric') {
69
91
  rows.push([offset, type, name, formatMetricEntryValue(entry), '-', severity]);
70
92
  continue;
71
93
  }
94
+ if (entry.source === 'span') {
95
+ rows.push([
96
+ offset,
97
+ type,
98
+ name,
99
+ formatSpanEntryValue(entry),
100
+ formatSpanEntryProperties(entry),
101
+ severity,
102
+ ]);
103
+ continue;
104
+ }
72
105
  const propLines = primitivePropertyLines(entry);
73
106
  if (propLines.length === 0) {
74
107
  rows.push([offset, type, name, '-', '-', severity]);
@@ -80,7 +113,7 @@ function buildObserveSessionEventsTable(entries, options) {
80
113
  }
81
114
  }
82
115
  lines.push((0, renderTextTable_1.default)(headers, rows));
83
- if (options?.hasMoreMetricEvents || options?.hasMoreLogEvents) {
116
+ if (options?.hasMoreMetricEvents || options?.hasMoreLogEvents || options?.hasMoreSpans) {
84
117
  const sources = [];
85
118
  if (options.hasMoreMetricEvents) {
86
119
  sources.push('metric events');
@@ -88,17 +121,21 @@ function buildObserveSessionEventsTable(entries, options) {
88
121
  if (options.hasMoreLogEvents) {
89
122
  sources.push('log events');
90
123
  }
124
+ if (options.hasMoreSpans) {
125
+ sources.push('spans');
126
+ }
91
127
  lines.push('', chalk_1.default.yellow(`More ${sources.join(' and ')} are available for this session; only the first 100 of each are shown.`));
92
128
  }
93
129
  return lines.join('\n');
94
130
  }
95
- function buildObserveSessionEventsJson(entries, sessionId, metadata, hasMoreMetricEvents, hasMoreLogEvents) {
131
+ function buildObserveSessionEventsJson(entries, sessionId, metadata, hasMoreMetricEvents, hasMoreLogEvents, hasMoreSpans) {
96
132
  return {
97
133
  sessionId,
98
134
  metadata,
99
135
  entries,
100
136
  hasMoreMetricEvents,
101
137
  hasMoreLogEvents,
138
+ hasMoreSpans,
102
139
  };
103
140
  }
104
141
  /**
@@ -0,0 +1,110 @@
1
+ import { AppObserveSpan, AppObserveSpanName, AppObserveTrace, PageInfo } from '../graphql/generated';
2
+ export declare function formatSpanDuration(durationMs: number): string;
3
+ /**
4
+ * The HTTP response status code, or the client-side error type when the
5
+ * request got no response, or "-" for a span that is not an HTTP request.
6
+ */
7
+ export declare function formatSpanHttpStatus(span: AppObserveSpan): string;
8
+ /** The path and query of a full URL; the URL itself when it does not parse. */
9
+ export declare function formatSpanUrlPath(urlFull: string): string;
10
+ /**
11
+ * One-line title for a span: the HTTP method, host, and path for a request
12
+ * span (`GET api.example.com/users`), else the span name.
13
+ */
14
+ export declare function formatSpanTitle(span: AppObserveSpan): string;
15
+ export interface ObserveSpanHttpJson {
16
+ method: string | null;
17
+ statusCode: number | null;
18
+ urlHost: string | null;
19
+ urlFull: string | null;
20
+ protocolVersion: string | null;
21
+ requestSize: number | null;
22
+ responseSize: number | null;
23
+ errorType: string | null;
24
+ }
25
+ export interface ObserveSpanJson {
26
+ id: string;
27
+ traceId: string;
28
+ spanId: string;
29
+ parentSpanId: string | null;
30
+ name: string;
31
+ kind: string;
32
+ startTimestamp: string;
33
+ endTimestamp: string;
34
+ durationMs: number;
35
+ statusCode: string;
36
+ statusMessage: string | null;
37
+ sessionId: string | null;
38
+ http: ObserveSpanHttpJson | null;
39
+ attributes: Array<{
40
+ key: string;
41
+ value: string;
42
+ type: string;
43
+ }>;
44
+ events: Array<{
45
+ name: string;
46
+ timestamp: string;
47
+ attributes: unknown;
48
+ }>;
49
+ droppedAttributesCount: number;
50
+ droppedEventsCount: number;
51
+ droppedLinksCount: number;
52
+ ingestedAt: string | null;
53
+ appVersion: string;
54
+ appBuildNumber: string;
55
+ appUpdateId: string | null;
56
+ appEasBuildId: string | null;
57
+ expoSdkVersion: string | null;
58
+ reactNativeVersion: string | null;
59
+ deviceModel: string;
60
+ deviceOs: string;
61
+ deviceOsVersion: string;
62
+ environment: string | null;
63
+ easClientId: string;
64
+ countryCode: string | null;
65
+ }
66
+ export declare function buildObserveSpanJson(span: AppObserveSpan): ObserveSpanJson;
67
+ export interface BuildSpanNamesTableOptions {
68
+ daysBack?: number;
69
+ startTime?: string;
70
+ endTime?: string;
71
+ isTruncated?: boolean;
72
+ }
73
+ export declare function buildObserveSpanNamesTable(names: AppObserveSpanName[], options?: BuildSpanNamesTableOptions): string;
74
+ export declare function buildObserveSpanNamesJson(names: AppObserveSpanName[], isTruncated: boolean): {
75
+ names: Array<{
76
+ name: string;
77
+ kind: string;
78
+ count: number;
79
+ }>;
80
+ isTruncated: boolean;
81
+ };
82
+ export interface BuildSpansTableOptions {
83
+ daysBack?: number;
84
+ startTime?: string;
85
+ endTime?: string;
86
+ sessionId?: string;
87
+ }
88
+ export declare function buildObserveSpansTable(spans: AppObserveSpan[], pageInfo: PageInfo, options?: BuildSpansTableOptions): string;
89
+ export declare function buildObserveSpansJson(spans: AppObserveSpan[], pageInfo: PageInfo): {
90
+ spans: ObserveSpanJson[];
91
+ pageInfo: {
92
+ hasNextPage: boolean;
93
+ endCursor: string | null;
94
+ };
95
+ };
96
+ export interface TraceTreeRow {
97
+ span: AppObserveSpan;
98
+ depth: number;
99
+ }
100
+ /**
101
+ * Orders a trace's spans depth-first, children under their parent, siblings
102
+ * oldest first. A span whose parent is not in the trace is shown as a root.
103
+ */
104
+ export declare function orderTraceSpans(spans: AppObserveSpan[]): TraceTreeRow[];
105
+ export declare function buildObserveTraceTable(trace: AppObserveTrace): string;
106
+ export declare function buildObserveTraceJson(trace: AppObserveTrace): {
107
+ id: string;
108
+ isTruncated: boolean;
109
+ spans: ObserveSpanJson[];
110
+ };
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatSpanDuration = formatSpanDuration;
4
+ exports.formatSpanHttpStatus = formatSpanHttpStatus;
5
+ exports.formatSpanUrlPath = formatSpanUrlPath;
6
+ exports.formatSpanTitle = formatSpanTitle;
7
+ exports.buildObserveSpanJson = buildObserveSpanJson;
8
+ exports.buildObserveSpanNamesTable = buildObserveSpanNamesTable;
9
+ exports.buildObserveSpanNamesJson = buildObserveSpanNamesJson;
10
+ exports.buildObserveSpansTable = buildObserveSpansTable;
11
+ exports.buildObserveSpansJson = buildObserveSpansJson;
12
+ exports.orderTraceSpans = orderTraceSpans;
13
+ exports.buildObserveTraceTable = buildObserveTraceTable;
14
+ exports.buildObserveTraceJson = buildObserveTraceJson;
15
+ const tslib_1 = require("tslib");
16
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
17
+ const renderTextTable_1 = tslib_1.__importDefault(require("../utils/renderTextTable"));
18
+ const terminalText_1 = require("../utils/terminalText");
19
+ const formatUtils_1 = require("./formatUtils");
20
+ function formatSpanDuration(durationMs) {
21
+ const wholeMs = Math.round(durationMs);
22
+ if (wholeMs >= 1000) {
23
+ return `${(durationMs / 1000).toFixed(2)}s`;
24
+ }
25
+ return `${wholeMs}ms`;
26
+ }
27
+ /**
28
+ * The HTTP response status code, or the client-side error type when the
29
+ * request got no response, or "-" for a span that is not an HTTP request.
30
+ */
31
+ function formatSpanHttpStatus(span) {
32
+ if (span.http?.statusCode != null) {
33
+ return String(span.http.statusCode);
34
+ }
35
+ return span.http?.errorType ?? '-';
36
+ }
37
+ /** The path and query of a full URL; the URL itself when it does not parse. */
38
+ function formatSpanUrlPath(urlFull) {
39
+ try {
40
+ const url = new URL(urlFull);
41
+ return `${url.pathname}${url.search}`;
42
+ }
43
+ catch {
44
+ return urlFull;
45
+ }
46
+ }
47
+ /**
48
+ * One-line title for a span: the HTTP method, host, and path for a request
49
+ * span (`GET api.example.com/users`), else the span name.
50
+ */
51
+ function formatSpanTitle(span) {
52
+ const host = span.http?.urlHost;
53
+ if (!host) {
54
+ return span.name;
55
+ }
56
+ const path = span.http?.urlFull ? formatSpanUrlPath(span.http.urlFull) : '';
57
+ return `${span.name} ${host}${path}`;
58
+ }
59
+ function buildObserveSpanJson(span) {
60
+ return {
61
+ id: span.id,
62
+ traceId: span.traceId,
63
+ spanId: span.spanId,
64
+ parentSpanId: span.parentSpanId ?? null,
65
+ name: span.name,
66
+ kind: span.kind,
67
+ startTimestamp: span.startTimestamp,
68
+ endTimestamp: span.endTimestamp,
69
+ durationMs: span.durationMs,
70
+ statusCode: span.statusCode,
71
+ statusMessage: span.statusMessage ?? null,
72
+ sessionId: span.sessionId ?? null,
73
+ http: span.http
74
+ ? {
75
+ method: span.http.method ?? null,
76
+ statusCode: span.http.statusCode ?? null,
77
+ urlHost: span.http.urlHost ?? null,
78
+ urlFull: span.http.urlFull ?? null,
79
+ protocolVersion: span.http.protocolVersion ?? null,
80
+ requestSize: span.http.requestSize ?? null,
81
+ responseSize: span.http.responseSize ?? null,
82
+ errorType: span.http.errorType ?? null,
83
+ }
84
+ : null,
85
+ attributes: span.attributes.map(a => ({ key: a.key, value: a.value, type: a.type })),
86
+ events: span.events.map(e => ({
87
+ name: e.name,
88
+ timestamp: e.timestamp,
89
+ attributes: e.attributes,
90
+ })),
91
+ droppedAttributesCount: span.droppedAttributesCount,
92
+ droppedEventsCount: span.droppedEventsCount,
93
+ droppedLinksCount: span.droppedLinksCount,
94
+ ingestedAt: span.ingestedAt ?? null,
95
+ appVersion: span.appVersion,
96
+ appBuildNumber: span.appBuildNumber,
97
+ appUpdateId: span.appUpdateId ?? null,
98
+ appEasBuildId: span.appEasBuildId ?? null,
99
+ expoSdkVersion: span.expoSdkVersion ?? null,
100
+ reactNativeVersion: span.reactNativeVersion ?? null,
101
+ deviceModel: span.deviceModel,
102
+ deviceOs: span.deviceOs,
103
+ deviceOsVersion: span.deviceOsVersion,
104
+ environment: span.environment ?? null,
105
+ easClientId: span.easClientId,
106
+ countryCode: span.countryCode ?? null,
107
+ };
108
+ }
109
+ function buildObserveSpanNamesTable(names, options) {
110
+ if (names.length === 0) {
111
+ return chalk_1.default.yellow('No spans found.');
112
+ }
113
+ const headers = ['Span Name', 'Kind', 'Count'];
114
+ const rows = names.map(n => [
115
+ (0, terminalText_1.sanitizeTerminalText)(n.name),
116
+ n.kind,
117
+ n.count.toLocaleString(),
118
+ ]);
119
+ const lines = [];
120
+ if (options) {
121
+ const timeDesc = (0, formatUtils_1.buildTimeRangeDescription)(options);
122
+ lines.push(chalk_1.default.bold(`Span names ${timeDesc}`.trim()), '');
123
+ }
124
+ lines.push((0, renderTextTable_1.default)(headers, rows));
125
+ if (options?.isTruncated) {
126
+ lines.push('', chalk_1.default.yellow('Result is truncated; not all span names are shown.'));
127
+ }
128
+ lines.push('', 'Pass --all-spans or a span filter such as --name, --host, or --status to list individual spans.');
129
+ return lines.join('\n');
130
+ }
131
+ function buildObserveSpanNamesJson(names, isTruncated) {
132
+ return {
133
+ names: names.map(n => ({ name: n.name, kind: n.kind, count: n.count })),
134
+ isTruncated,
135
+ };
136
+ }
137
+ function buildObserveSpansTable(spans, pageInfo, options) {
138
+ if (spans.length === 0) {
139
+ return chalk_1.default.yellow('No spans found.');
140
+ }
141
+ const headers = [
142
+ 'Timestamp',
143
+ 'Name',
144
+ 'Duration',
145
+ 'Status',
146
+ 'HTTP',
147
+ 'Host',
148
+ 'App Version',
149
+ 'Platform',
150
+ 'Trace ID',
151
+ ];
152
+ const rows = spans.map(span => [
153
+ (0, formatUtils_1.formatLogTimestamp)(span.startTimestamp),
154
+ (0, terminalText_1.sanitizeTerminalText)(span.name),
155
+ formatSpanDuration(span.durationMs),
156
+ span.statusCode,
157
+ formatSpanHttpStatus(span),
158
+ (0, terminalText_1.sanitizeTerminalText)(span.http?.urlHost ?? '-'),
159
+ `${span.appVersion} (${span.appBuildNumber})`,
160
+ `${span.deviceOs} ${span.deviceOsVersion}`,
161
+ span.traceId,
162
+ ]);
163
+ const lines = [];
164
+ if (options) {
165
+ const subject = options.sessionId ? `Spans in session ${options.sessionId}` : 'Spans';
166
+ const timeDesc = options.sessionId ? '' : (0, formatUtils_1.buildTimeRangeDescription)(options);
167
+ lines.push(chalk_1.default.bold(`${subject} ${timeDesc}`.trim()), '');
168
+ }
169
+ lines.push((0, renderTextTable_1.default)(headers, rows));
170
+ lines.push('', 'Show a whole trace: eas observe:trace <Trace ID>');
171
+ if (pageInfo.hasNextPage && pageInfo.endCursor) {
172
+ lines.push('', `Next page: --after ${pageInfo.endCursor}`);
173
+ }
174
+ return lines.join('\n');
175
+ }
176
+ function buildObserveSpansJson(spans, pageInfo) {
177
+ return {
178
+ spans: spans.map(buildObserveSpanJson),
179
+ pageInfo: {
180
+ hasNextPage: pageInfo.hasNextPage,
181
+ endCursor: pageInfo.endCursor ?? null,
182
+ },
183
+ };
184
+ }
185
+ function compareByStart(a, b) {
186
+ if (a.startTimestamp !== b.startTimestamp) {
187
+ return a.startTimestamp < b.startTimestamp ? -1 : 1;
188
+ }
189
+ return a.spanId < b.spanId ? -1 : a.spanId > b.spanId ? 1 : 0;
190
+ }
191
+ /**
192
+ * Orders a trace's spans depth-first, children under their parent, siblings
193
+ * oldest first. A span whose parent is not in the trace is shown as a root.
194
+ */
195
+ function orderTraceSpans(spans) {
196
+ const spanIds = new Set(spans.map(span => span.spanId));
197
+ const childrenByParent = new Map();
198
+ for (const span of spans) {
199
+ const parentKey = span.parentSpanId && spanIds.has(span.parentSpanId) ? span.parentSpanId : null;
200
+ const siblings = childrenByParent.get(parentKey) ?? [];
201
+ siblings.push(span);
202
+ childrenByParent.set(parentKey, siblings);
203
+ }
204
+ const rows = [];
205
+ const visit = (parentKey, depth) => {
206
+ const children = childrenByParent.get(parentKey) ?? [];
207
+ for (const span of [...children].sort(compareByStart)) {
208
+ rows.push({ span, depth });
209
+ visit(span.spanId, depth + 1);
210
+ }
211
+ };
212
+ visit(null, 0);
213
+ return rows;
214
+ }
215
+ function buildObserveTraceTable(trace) {
216
+ const rows = orderTraceSpans(trace.spans);
217
+ const lines = [chalk_1.default.bold(`Trace ${trace.id}`), ''];
218
+ if (rows.length === 0) {
219
+ lines.push(chalk_1.default.yellow('No spans found for this trace.'));
220
+ return lines.join('\n');
221
+ }
222
+ const sessionId = trace.spans.find(span => span.sessionId)?.sessionId;
223
+ const first = rows[0].span;
224
+ lines.push(`Started: ${(0, formatUtils_1.formatLogTimestamp)(first.startTimestamp)}`, `Spans: ${rows.length}${trace.isTruncated ? ' (truncated)' : ''}`, `App version: ${first.appVersion} (${first.appBuildNumber})`, `Device: ${(0, terminalText_1.sanitizeTerminalText)(first.deviceModel)} · ${first.deviceOs} ${first.deviceOsVersion}`, `Session: ${sessionId ?? '-'}`, '');
225
+ const traceStartMs = Math.min(...trace.spans.map(span => new Date(span.startTimestamp).getTime()));
226
+ const headers = ['Offset', 'Duration', 'Name', 'Status', 'HTTP', 'URL'];
227
+ const tableRows = rows.map(({ span, depth }) => [
228
+ formatSpanDuration(new Date(span.startTimestamp).getTime() - traceStartMs),
229
+ formatSpanDuration(span.durationMs),
230
+ `${' '.repeat(depth)}${(0, terminalText_1.sanitizeTerminalText)(span.name)}`,
231
+ span.statusCode,
232
+ formatSpanHttpStatus(span),
233
+ (0, terminalText_1.sanitizeTerminalText)(span.http?.urlFull ?? '-'),
234
+ ]);
235
+ lines.push((0, renderTextTable_1.default)(headers, tableRows));
236
+ if (trace.isTruncated) {
237
+ lines.push('', chalk_1.default.yellow('This trace has more spans than are shown.'));
238
+ }
239
+ if (sessionId) {
240
+ lines.push('', `Show the session timeline: eas observe:session ${sessionId}`);
241
+ }
242
+ return lines.join('\n');
243
+ }
244
+ function buildObserveTraceJson(trace) {
245
+ return {
246
+ id: trace.id,
247
+ isTruncated: trace.isTruncated,
248
+ spans: orderTraceSpans(trace.spans).map(({ span }) => buildObserveSpanJson(span)),
249
+ };
250
+ }
@@ -0,0 +1,5 @@
1
+ import { AppObserveSpanKind, AppObserveSpanStatusCode } from '../graphql/generated';
2
+ export declare const allowedSpanKindFlagValues: string[];
3
+ export declare const allowedSpanStatusFlagValues: string[];
4
+ export declare function spanKindsFromFlag(values: string[] | undefined): AppObserveSpanKind[] | undefined;
5
+ export declare function spanStatusCodesFromFlag(values: string[] | undefined): AppObserveSpanStatusCode[] | undefined;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.allowedSpanStatusFlagValues = exports.allowedSpanKindFlagValues = void 0;
4
+ exports.spanKindsFromFlag = spanKindsFromFlag;
5
+ exports.spanStatusCodesFromFlag = spanStatusCodesFromFlag;
6
+ const generated_1 = require("../graphql/generated");
7
+ exports.allowedSpanKindFlagValues = Object.values(generated_1.AppObserveSpanKind).map(kind => kind.toLowerCase());
8
+ exports.allowedSpanStatusFlagValues = Object.values(generated_1.AppObserveSpanStatusCode).map(code => code.toLowerCase());
9
+ function spanKindsFromFlag(values) {
10
+ if (!values?.length) {
11
+ return undefined;
12
+ }
13
+ return values.map(value => {
14
+ const kind = Object.values(generated_1.AppObserveSpanKind).find(k => k.toLowerCase() === value);
15
+ if (!kind) {
16
+ throw new Error(`Unknown span kind flag value: "${value}"`);
17
+ }
18
+ return kind;
19
+ });
20
+ }
21
+ function spanStatusCodesFromFlag(values) {
22
+ if (!values?.length) {
23
+ return undefined;
24
+ }
25
+ return values.map(value => {
26
+ const code = Object.values(generated_1.AppObserveSpanStatusCode).find(c => c.toLowerCase() === value);
27
+ if (!code) {
28
+ throw new Error(`Unknown span status flag value: "${value}"`);
29
+ }
30
+ return code;
31
+ });
32
+ }
@@ -306,6 +306,7 @@ function colorWorkflowStatus(status) {
306
306
  case generated_1.WorkflowRunStatus.ActionRequired:
307
307
  return chalk_1.default.yellow('action required');
308
308
  case generated_1.WorkflowRunStatus.New:
309
+ case generated_1.WorkflowRunStatus.Waiting:
309
310
  case generated_1.WorkflowRunStatus.InProgress:
310
311
  return chalk_1.default.blue(status.toLowerCase().replace(/_/g, ' '));
311
312
  default:
@@ -0,0 +1,9 @@
1
+ import { DeviceRunSessionByIdQuery } from '../graphql/generated';
2
+ export type SimulatorSession = DeviceRunSessionByIdQuery['deviceRunSessions']['byId'];
3
+ export declare function hasSimulatorArtifacts(session: SimulatorSession): boolean;
4
+ export declare function downloadSimulatorArtifactAsync(session: SimulatorSession, type: string, { artifact: index, output, nonInteractive, json, }: {
5
+ artifact?: number;
6
+ output?: string;
7
+ nonInteractive: boolean;
8
+ json: boolean;
9
+ }): Promise<void>;