@forge/cli-shared 5.6.0-next.9 → 6.0.0-next.16
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/CHANGELOG.md +51 -0
- package/out/app-logs/graphql-client.d.ts +2 -1
- package/out/app-logs/graphql-client.d.ts.map +1 -1
- package/out/app-logs/graphql-client.js +71 -0
- package/out/app-logs/view-logs.d.ts +12 -2
- package/out/app-logs/view-logs.d.ts.map +1 -1
- package/out/app-logs/view-logs.js +31 -3
- package/out/graphql/graphql-types.d.ts +264 -661
- package/out/graphql/graphql-types.d.ts.map +1 -1
- package/out/graphql/graphql-types.js +35 -21
- package/out/service/feature-flag-service.d.ts +2 -2
- package/out/service/feature-flag-service.d.ts.map +1 -1
- package/out/service/feature-flag-service.js +2 -2
- package/out/ui/command-line-ui.d.ts +3 -3
- package/out/ui/command-line-ui.d.ts.map +1 -1
- package/out/ui/text.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# @forge/cli-shared
|
|
2
2
|
|
|
3
|
+
## 6.0.0-next.16
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- f354267: Migrating forge logs commands to use v2 logs APIs to fetch logs. Updated the functionality of the `forge logs -n <limit>` or `forge logs --limit <limit>` CLI command. Instead of showing logs from the last <limit> invocations, it will show the last <limit> log lines.
|
|
8
|
+
|
|
9
|
+
## 5.6.0-next.15
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 9c5836c: cleanup ff
|
|
14
|
+
- Updated dependencies [d9e0900]
|
|
15
|
+
- @forge/manifest@7.9.0-next.13
|
|
16
|
+
|
|
17
|
+
## 5.6.0-next.14
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [5cd256c]
|
|
22
|
+
- @forge/manifest@7.9.0-next.12
|
|
23
|
+
|
|
24
|
+
## 5.6.0-next.13
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [08ff14e]
|
|
29
|
+
- @forge/manifest@7.9.0-next.11
|
|
30
|
+
|
|
31
|
+
## 5.6.0-next.12
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [d500498]
|
|
36
|
+
- @forge/manifest@7.9.0-next.10
|
|
37
|
+
|
|
38
|
+
## 5.6.0-next.11
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [47f24ba]
|
|
43
|
+
- Updated dependencies [75698c0]
|
|
44
|
+
- Updated dependencies [6cd61be]
|
|
45
|
+
- @forge/manifest@7.9.0-next.9
|
|
46
|
+
|
|
47
|
+
## 5.6.0-next.10
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [bdca785]
|
|
52
|
+
- @forge/manifest@7.9.0-next.8
|
|
53
|
+
|
|
3
54
|
## 5.6.0-next.9
|
|
4
55
|
|
|
5
56
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLClient } from '../graphql';
|
|
2
|
-
import { AppInvocationLogsDetails, AppLogsDetails, Invocation, InvocationLogLine, ViewAppLogsClient } from './view-logs';
|
|
2
|
+
import { AppInvocationLogsDetails, AppLogsDetails, AppLogsDetailsV2, Invocation, InvocationLogLine, ViewAppLogsClient } from './view-logs';
|
|
3
3
|
export declare class MissingAppLogsError extends Error {
|
|
4
4
|
}
|
|
5
5
|
export declare class MissingAppLogLinesError extends Error {
|
|
@@ -18,6 +18,7 @@ export declare class LogsGraphQLClient implements ViewAppLogsClient {
|
|
|
18
18
|
function?: string | undefined;
|
|
19
19
|
trigger?: string | undefined;
|
|
20
20
|
}>;
|
|
21
|
+
viewAppLogsV2(details: AppLogsDetailsV2, invocationMap: Map<string, Invocation>, totalRecieved: number): Promise<Invocation[]>;
|
|
21
22
|
viewAppLogs(details: AppLogsDetails): Promise<Invocation[]>;
|
|
22
23
|
private extractInvocationInfo;
|
|
23
24
|
private extractLogLines;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../src/app-logs/graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6E,aAAa,EAAE,MAAM,YAAY,CAAC;AAEtH,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAwBrB,qBAAa,mBAAoB,SAAQ,KAAK;CAAG;AACjD,qBAAa,uBAAwB,SAAQ,KAAK;CAAG;AACrD,qBAAa,sBAAuB,SAAQ,KAAK;CAAG;AACpD,qBAAa,oBAAqB,SAAQ,KAAK;CAAG;AAElD,qBAAa,iBAAkB,YAAW,iBAAiB;IAC7C,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAE5C,kBAAkB,CAAC,OAAO,EAAE,wBAAwB;;;;;;;IAapD,WAAW,CAAC,OAAO,EAAE,cAAc;IAwEhD,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,eAAe;YAcT,iBAAiB;CAqDhC"}
|
|
1
|
+
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../src/app-logs/graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6E,aAAa,EAAE,MAAM,YAAY,CAAC;AAEtH,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAwBrB,qBAAa,mBAAoB,SAAQ,KAAK;CAAG;AACjD,qBAAa,uBAAwB,SAAQ,KAAK;CAAG;AACrD,qBAAa,sBAAuB,SAAQ,KAAK;CAAG;AACpD,qBAAa,oBAAqB,SAAQ,KAAK;CAAG;AAElD,qBAAa,iBAAkB,YAAW,iBAAiB;IAC7C,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAE5C,kBAAkB,CAAC,OAAO,EAAE,wBAAwB;;;;;;;IAapD,aAAa,CACxB,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACtC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,EAAE,CAAC;IAkFX,WAAW,CAAC,OAAO,EAAE,cAAc;IAwEhD,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,eAAe;YAcT,iBAAiB;CAqDhC"}
|
|
@@ -34,6 +34,77 @@ class LogsGraphQLClient {
|
|
|
34
34
|
logs: result.lines.map(sanitizeLogLine)
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
async viewAppLogsV2(details, invocationMap, totalRecieved) {
|
|
38
|
+
const query = `
|
|
39
|
+
query forge_cli_getApplicationLogsV2(
|
|
40
|
+
$appId: String!,
|
|
41
|
+
$environmentId: String!,
|
|
42
|
+
$dateSearchInput: DateSearchInput,
|
|
43
|
+
$offset: Int!,
|
|
44
|
+
$limit: Int!,
|
|
45
|
+
$queryStartTime: String!
|
|
46
|
+
) {
|
|
47
|
+
appLogsWithMetaData(
|
|
48
|
+
appId: $appId
|
|
49
|
+
environmentId: $environmentId
|
|
50
|
+
limit: $limit
|
|
51
|
+
offset: $offset
|
|
52
|
+
queryStartTime: $queryStartTime
|
|
53
|
+
query: {
|
|
54
|
+
dates: $dateSearchInput
|
|
55
|
+
}
|
|
56
|
+
) {
|
|
57
|
+
appLogs {
|
|
58
|
+
appId
|
|
59
|
+
appVersion
|
|
60
|
+
message
|
|
61
|
+
environmentId
|
|
62
|
+
invocationId
|
|
63
|
+
functionKey
|
|
64
|
+
lvl
|
|
65
|
+
error
|
|
66
|
+
other
|
|
67
|
+
ts
|
|
68
|
+
}
|
|
69
|
+
hasNextPage
|
|
70
|
+
totalLogs
|
|
71
|
+
__typename
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
const result = await this.graphqlClient.query(query, details);
|
|
76
|
+
if (!result || !result.appLogsWithMetaData || !result.appLogsWithMetaData.appLogs) {
|
|
77
|
+
throw new MissingAppLogsError();
|
|
78
|
+
}
|
|
79
|
+
for (const logLine of result.appLogsWithMetaData.appLogs) {
|
|
80
|
+
let logsMetadata = invocationMap.get(logLine.invocationId);
|
|
81
|
+
if (!logsMetadata) {
|
|
82
|
+
logsMetadata = {
|
|
83
|
+
id: logLine.invocationId,
|
|
84
|
+
appVersion: logLine.appVersion,
|
|
85
|
+
function: logLine.functionKey || undefined,
|
|
86
|
+
trigger: undefined,
|
|
87
|
+
logs: []
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
logsMetadata.logs.push({
|
|
91
|
+
message: logLine.message || undefined,
|
|
92
|
+
other: logLine.other ? JSON.parse(logLine.other) : [],
|
|
93
|
+
level: logLine.lvl || undefined,
|
|
94
|
+
timestamp: logLine.ts
|
|
95
|
+
});
|
|
96
|
+
invocationMap.set(logLine.invocationId, logsMetadata);
|
|
97
|
+
}
|
|
98
|
+
const serverSideMaxLimit = result.appLogsWithMetaData.appLogs.length;
|
|
99
|
+
totalRecieved += serverSideMaxLimit;
|
|
100
|
+
if (result.appLogsWithMetaData.hasNextPage && details.maxLimit > totalRecieved) {
|
|
101
|
+
details.offset = details.offset + serverSideMaxLimit;
|
|
102
|
+
details.limit = details.limit - serverSideMaxLimit;
|
|
103
|
+
return this.viewAppLogsV2(details, invocationMap, totalRecieved);
|
|
104
|
+
}
|
|
105
|
+
const invocations = [...invocationMap.values()];
|
|
106
|
+
return invocations;
|
|
107
|
+
}
|
|
37
108
|
async viewAppLogs(details) {
|
|
38
109
|
const query = `
|
|
39
110
|
query forge_cli_getApplicationLogs($appId: ID!, $environmentId: [ID!]!, $limit: Int!, $contextAri: [ID!], $startTime: String) {
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { Ari } from '@forge/util/packages/ari';
|
|
3
3
|
import { URL } from 'url';
|
|
4
4
|
import { AppConfigProvider } from '../apps';
|
|
5
|
-
import { AppEnvironmentClient } from '../graphql';
|
|
5
|
+
import { AppEnvironmentClient, DateSearchInput } from '../graphql';
|
|
6
6
|
import { GlobalEdgeClient } from '../http-client';
|
|
7
|
+
import { FeatureFlagService } from '../service';
|
|
7
8
|
export interface Context {
|
|
8
9
|
site: URL;
|
|
9
10
|
product: string;
|
|
@@ -24,6 +25,12 @@ export declare type AppLogsDetails = {
|
|
|
24
25
|
startTime?: string | null;
|
|
25
26
|
contextAri?: [Ari];
|
|
26
27
|
};
|
|
28
|
+
export declare type AppLogsDetailsV2 = AppLogsDetails & {
|
|
29
|
+
offset: number;
|
|
30
|
+
dateSearchInput: DateSearchInput;
|
|
31
|
+
queryStartTime: string;
|
|
32
|
+
maxLimit: number;
|
|
33
|
+
};
|
|
27
34
|
export interface InvocationQueryDetails {
|
|
28
35
|
environmentKey: string;
|
|
29
36
|
invocationId: string;
|
|
@@ -47,6 +54,7 @@ export interface Invocation {
|
|
|
47
54
|
}
|
|
48
55
|
export interface ViewAppLogsClient {
|
|
49
56
|
viewAppLogs(details: AppLogsDetails): Promise<Invocation[]>;
|
|
57
|
+
viewAppLogsV2(details: AppLogsDetailsV2, invocationMap: Map<string, Invocation>, totalRecieved: number): Promise<Invocation[]>;
|
|
50
58
|
viewInvocationLogs(details: AppInvocationLogsDetails): Promise<Invocation>;
|
|
51
59
|
}
|
|
52
60
|
export declare class ViewAppLogsCommand {
|
|
@@ -54,8 +62,10 @@ export declare class ViewAppLogsCommand {
|
|
|
54
62
|
private readonly appEnvironmentClient;
|
|
55
63
|
private readonly globalEdgeClient;
|
|
56
64
|
private readonly logsClient;
|
|
57
|
-
|
|
65
|
+
private readonly featureFlagService;
|
|
66
|
+
constructor(getAppConfig: AppConfigProvider, appEnvironmentClient: AppEnvironmentClient, globalEdgeClient: GlobalEdgeClient, logsClient: ViewAppLogsClient, featureFlagService: FeatureFlagService);
|
|
58
67
|
getAll({ environmentKey, limit, context, startTime }: QueryDetails): Promise<Invocation[]>;
|
|
68
|
+
getLogs(details: AppLogsDetails): Promise<Invocation[]>;
|
|
59
69
|
getOne(details: InvocationQueryDetails): Promise<Invocation>;
|
|
60
70
|
}
|
|
61
71
|
//# sourceMappingURL=view-logs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-logs.d.ts","sourceRoot":"","sources":["../../src/app-logs/view-logs.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAmB,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"view-logs.d.ts","sourceRoot":"","sources":["../../src/app-logs/view-logs.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAmB,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,C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C,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACzB,kBAAkB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC5E;AAED,qBAAa,kBAAkB;IAK3B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBAJlB,YAAY,EAAE,iBAAiB,EAC/B,oBAAoB,EAAE,oBAAoB,EAC1C,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,iBAAiB,EAC7B,kBAAkB,EAAE,kBAAkB;IAG5C,MAAM,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,SAAgB,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IA0BjG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IA2BvD,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC;CAI1E"}
|
|
@@ -8,11 +8,13 @@ class ViewAppLogsCommand {
|
|
|
8
8
|
appEnvironmentClient;
|
|
9
9
|
globalEdgeClient;
|
|
10
10
|
logsClient;
|
|
11
|
-
|
|
11
|
+
featureFlagService;
|
|
12
|
+
constructor(getAppConfig, appEnvironmentClient, globalEdgeClient, logsClient, featureFlagService) {
|
|
12
13
|
this.getAppConfig = getAppConfig;
|
|
13
14
|
this.appEnvironmentClient = appEnvironmentClient;
|
|
14
15
|
this.globalEdgeClient = globalEdgeClient;
|
|
15
16
|
this.logsClient = logsClient;
|
|
17
|
+
this.featureFlagService = featureFlagService;
|
|
16
18
|
}
|
|
17
19
|
async getAll({ environmentKey, limit, context, startTime = null }) {
|
|
18
20
|
const { id: appId } = await this.getAppConfig();
|
|
@@ -21,13 +23,39 @@ class ViewAppLogsCommand {
|
|
|
21
23
|
context ? this.globalEdgeClient.getCloudId(context.site) : undefined
|
|
22
24
|
]);
|
|
23
25
|
const contextAri = cloudId ? (0, ari_2.buildContextAri)(cloudId, context.product) : undefined;
|
|
24
|
-
|
|
26
|
+
const details = {
|
|
25
27
|
appId: ari_1.EcosystemAppAri.parse(appId).appId,
|
|
26
28
|
environmentId,
|
|
27
29
|
limit,
|
|
28
30
|
startTime,
|
|
29
31
|
contextAri: contextAri ? [contextAri] : undefined
|
|
30
|
-
}
|
|
32
|
+
};
|
|
33
|
+
const isV2ApiEnabled = await this.featureFlagService.isLogsV2ApiEnabled();
|
|
34
|
+
if (isV2ApiEnabled) {
|
|
35
|
+
return this.getLogs(details);
|
|
36
|
+
}
|
|
37
|
+
return this.logsClient.viewAppLogs(details);
|
|
38
|
+
}
|
|
39
|
+
async getLogs(details) {
|
|
40
|
+
const latestStart = new Date().toISOString();
|
|
41
|
+
let earliestStart = new Date();
|
|
42
|
+
if (details.startTime) {
|
|
43
|
+
earliestStart = new Date(details.startTime);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
earliestStart.setHours(new Date().getHours() - 1);
|
|
47
|
+
}
|
|
48
|
+
const dateSearchInput = {
|
|
49
|
+
earliestStart: earliestStart.toISOString(),
|
|
50
|
+
latestStart
|
|
51
|
+
};
|
|
52
|
+
return this.logsClient.viewAppLogsV2({
|
|
53
|
+
...details,
|
|
54
|
+
offset: 0,
|
|
55
|
+
dateSearchInput,
|
|
56
|
+
queryStartTime: earliestStart.toISOString(),
|
|
57
|
+
maxLimit: details.limit
|
|
58
|
+
}, new Map(), 0);
|
|
31
59
|
}
|
|
32
60
|
async getOne(details) {
|
|
33
61
|
return this.logsClient.viewInvocationLogs({ invocationId: details.invocationId });
|