@camunda/ccma-api 0.0.2 → 0.0.4
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.d.ts +95 -0
- package/dist/index.js +151 -0
- package/dist/index.js.map +7 -0
- package/dist/services/accounts/accounts.data-export.service.d.ts +13 -0
- package/dist/services/accounts/accounts.data-export.service.js +41 -0
- package/dist/services/accounts/accounts.data-export.service.js.map +7 -0
- package/dist/services/accounts/accounts.valuemetrics.service.d.ts +8 -0
- package/dist/services/accounts/accounts.valuemetrics.service.js +1 -0
- package/dist/services/accounts/accounts.valuemetrics.service.js.map +7 -0
- package/dist/services/accounts/bot.service.d.ts +21 -0
- package/dist/services/accounts/bot.service.js +74 -0
- package/dist/services/accounts/bot.service.js.map +7 -0
- package/dist/services/accounts/challenge.service.d.ts +296 -0
- package/dist/services/accounts/challenge.service.js +475 -0
- package/dist/services/accounts/challenge.service.js.map +7 -0
- package/dist/services/accounts/connections.service.d.ts +27 -0
- package/dist/services/accounts/connections.service.js +41 -0
- package/dist/services/accounts/connections.service.js.map +7 -0
- package/dist/services/accounts/dashboards.service.d.ts +8 -0
- package/dist/services/accounts/dashboards.service.js +42 -0
- package/dist/services/accounts/dashboards.service.js.map +7 -0
- package/dist/services/accounts/early-access-features.service.d.ts +34 -0
- package/dist/services/accounts/early-access-features.service.js +67 -0
- package/dist/services/accounts/early-access-features.service.js.map +7 -0
- package/dist/services/accounts/genericCache.service.d.ts +13 -0
- package/dist/services/accounts/genericCache.service.js +80 -0
- package/dist/services/accounts/genericCache.service.js.map +7 -0
- package/dist/services/accounts/hdp.service.d.ts +52 -0
- package/dist/services/accounts/hdp.service.js +180 -0
- package/dist/services/accounts/hdp.service.js.map +7 -0
- package/dist/services/accounts/offboarding.service.d.ts +18 -0
- package/dist/services/accounts/offboarding.service.js +48 -0
- package/dist/services/accounts/offboarding.service.js.map +7 -0
- package/dist/services/accounts/organization-members.service.d.ts +68 -0
- package/dist/services/accounts/organization-members.service.js +216 -0
- package/dist/services/accounts/organization-members.service.js.map +7 -0
- package/dist/services/accounts/orgs.service.d.ts +282 -0
- package/dist/services/accounts/orgs.service.js +1012 -0
- package/dist/services/accounts/orgs.service.js.map +7 -0
- package/dist/services/accounts/salesplan.service.d.ts +7 -0
- package/dist/services/accounts/salesplan.service.js +40 -0
- package/dist/services/accounts/salesplan.service.js.map +7 -0
- package/dist/services/accounts/spam-detection.service.d.ts +8 -0
- package/dist/services/accounts/spam-detection.service.js +72 -0
- package/dist/services/accounts/spam-detection.service.js.map +7 -0
- package/dist/services/accounts/stats.service.d.ts +7 -0
- package/dist/services/accounts/stats.service.js +40 -0
- package/dist/services/accounts/stats.service.js.map +7 -0
- package/dist/services/accounts/usage-alerts.service.d.ts +34 -0
- package/dist/services/accounts/usage-alerts.service.js +112 -0
- package/dist/services/accounts/usage-alerts.service.js.map +7 -0
- package/dist/services/accounts/users.service.d.ts +101 -0
- package/dist/services/accounts/users.service.js +444 -0
- package/dist/services/accounts/users.service.js.map +7 -0
- package/dist/services/alerts/alerts.service.d.ts +59 -0
- package/dist/services/alerts/alerts.service.js +234 -0
- package/dist/services/alerts/alerts.service.js.map +7 -0
- package/dist/services/analytic-bridge/analytic-bridge.service.d.ts +23 -0
- package/dist/services/analytic-bridge/analytic-bridge.service.js +86 -0
- package/dist/services/analytic-bridge/analytic-bridge.service.js.map +7 -0
- package/dist/services/audit-logger/audit-logger.service.d.ts +27 -0
- package/dist/services/audit-logger/audit-logger.service.js +108 -0
- package/dist/services/audit-logger/audit-logger.service.js.map +7 -0
- package/dist/services/auth0/auth0.service.d.ts +15 -0
- package/dist/services/auth0/auth0.service.js +40 -0
- package/dist/services/auth0/auth0.service.js.map +7 -0
- package/dist/services/comm-bridge/comm-bridge.service.d.ts +33 -0
- package/dist/services/comm-bridge/comm-bridge.service.js +40 -0
- package/dist/services/comm-bridge/comm-bridge.service.js.map +7 -0
- package/dist/services/console/console.admin.service.d.ts +329 -0
- package/dist/services/console/console.admin.service.js +1527 -0
- package/dist/services/console/console.admin.service.js.map +7 -0
- package/dist/services/console/console.alerts.service.d.ts +69 -0
- package/dist/services/console/console.alerts.service.js +160 -0
- package/dist/services/console/console.alerts.service.js.map +7 -0
- package/dist/services/console/console.api-clients.service.d.ts +48 -0
- package/dist/services/console/console.api-clients.service.js +123 -0
- package/dist/services/console/console.api-clients.service.js.map +7 -0
- package/dist/services/console/console.backup-schedule.service.d.ts +21 -0
- package/dist/services/console/console.backup-schedule.service.js +67 -0
- package/dist/services/console/console.backup-schedule.service.js.map +7 -0
- package/dist/services/console/console.byok-scripts.service.d.ts +12 -0
- package/dist/services/console/console.byok-scripts.service.js +92 -0
- package/dist/services/console/console.byok-scripts.service.js.map +7 -0
- package/dist/services/console/console.byom-monitoring.service.d.ts +58 -0
- package/dist/services/console/console.byom-monitoring.service.js +177 -0
- package/dist/services/console/console.byom-monitoring.service.js.map +7 -0
- package/dist/services/console/console.cluster-clients.service.d.ts +55 -0
- package/dist/services/console/console.cluster-clients.service.js +123 -0
- package/dist/services/console/console.cluster-clients.service.js.map +7 -0
- package/dist/services/console/console.cluster-parameters.service.d.ts +64 -0
- package/dist/services/console/console.cluster-parameters.service.js +39 -0
- package/dist/services/console/console.cluster-parameters.service.js.map +7 -0
- package/dist/services/console/console.cluster.service.d.ts +114 -0
- package/dist/services/console/console.cluster.service.js +271 -0
- package/dist/services/console/console.cluster.service.js.map +7 -0
- package/dist/services/console/console.clusterBulkOperation.service.d.ts +20 -0
- package/dist/services/console/console.clusterBulkOperation.service.js +199 -0
- package/dist/services/console/console.clusterBulkOperation.service.js.map +7 -0
- package/dist/services/console/console.clusterplan.modification.service.d.ts +33 -0
- package/dist/services/console/console.clusterplan.modification.service.js +231 -0
- package/dist/services/console/console.clusterplan.modification.service.js.map +7 -0
- package/dist/services/console/console.clusterplan.service.d.ts +21 -0
- package/dist/services/console/console.clusterplan.service.js +64 -0
- package/dist/services/console/console.clusterplan.service.js.map +7 -0
- package/dist/services/console/console.connector-secrets.service.d.ts +30 -0
- package/dist/services/console/console.connector-secrets.service.js +125 -0
- package/dist/services/console/console.connector-secrets.service.js.map +7 -0
- package/dist/services/console/console.custommetrics.service.d.ts +10 -0
- package/dist/services/console/console.custommetrics.service.js +43 -0
- package/dist/services/console/console.custommetrics.service.js.map +7 -0
- package/dist/services/console/console.hotbackups.service.d.ts +34 -0
- package/dist/services/console/console.hotbackups.service.js +120 -0
- package/dist/services/console/console.hotbackups.service.js.map +7 -0
- package/dist/services/console/console.ip-whitelist.service.d.ts +15 -0
- package/dist/services/console/console.ip-whitelist.service.js +36 -0
- package/dist/services/console/console.ip-whitelist.service.js.map +7 -0
- package/dist/services/console/console.jobs.saas.service.d.ts +70 -0
- package/dist/services/console/console.jobs.saas.service.js +139 -0
- package/dist/services/console/console.jobs.saas.service.js.map +7 -0
- package/dist/services/console/console.m2m.service.d.ts +23 -0
- package/dist/services/console/console.m2m.service.js +94 -0
- package/dist/services/console/console.m2m.service.js.map +7 -0
- package/dist/services/console/console.secure-connectivity.service.d.ts +41 -0
- package/dist/services/console/console.secure-connectivity.service.js +129 -0
- package/dist/services/console/console.secure-connectivity.service.js.map +7 -0
- package/dist/services/console/console.valuemetrics.service.d.ts +17 -0
- package/dist/services/console/console.valuemetrics.service.js +110 -0
- package/dist/services/console/console.valuemetrics.service.js.map +7 -0
- package/dist/services/console/generation.service.d.ts +30 -0
- package/dist/services/console/generation.service.js +166 -0
- package/dist/services/console/generation.service.js.map +7 -0
- package/dist/services/github/github.service.d.ts +73 -0
- package/dist/services/github/github.service.js +272 -0
- package/dist/services/github/github.service.js.map +7 -0
- package/dist/services/hibob/hibob.service.d.ts +74 -0
- package/dist/services/hibob/hibob.service.js +125 -0
- package/dist/services/hibob/hibob.service.js.map +7 -0
- package/dist/services/hubspot/hubspot.service.d.ts +50 -0
- package/dist/services/hubspot/hubspot.service.js +119 -0
- package/dist/services/hubspot/hubspot.service.js.map +7 -0
- package/dist/services/litellm/litellm.service.d.ts +290 -0
- package/dist/services/litellm/litellm.service.js +392 -0
- package/dist/services/litellm/litellm.service.js.map +7 -0
- package/dist/services/login/login.service.d.ts +15 -0
- package/dist/services/login/login.service.js +66 -0
- package/dist/services/login/login.service.js.map +7 -0
- package/dist/services/mixpanel/mixpanel.service.d.ts +16 -0
- package/dist/services/mixpanel/mixpanel.service.js +86 -0
- package/dist/services/mixpanel/mixpanel.service.js.map +7 -0
- package/dist/services/notifications/notifications.service.d.ts +7 -0
- package/dist/services/notifications/notifications.service.js +38 -0
- package/dist/services/notifications/notifications.service.js.map +7 -0
- package/dist/services/slack/slack-blockkit.service.d.ts +28 -0
- package/dist/services/slack/slack-blockkit.service.js +45 -0
- package/dist/services/slack/slack-blockkit.service.js.map +7 -0
- package/dist/services/slack/slack.service.d.ts +31 -0
- package/dist/services/slack/slack.service.js +118 -0
- package/dist/services/slack/slack.service.js.map +7 -0
- package/dist/services/telemetry/telemetry.service.d.ts +16 -0
- package/dist/services/telemetry/telemetry.service.js +85 -0
- package/dist/services/telemetry/telemetry.service.js.map +7 -0
- package/dist/services/token-issuer/token-issuer.jwks.service.d.ts +13 -0
- package/dist/services/token-issuer/token-issuer.jwks.service.js +76 -0
- package/dist/services/token-issuer/token-issuer.jwks.service.js.map +7 -0
- package/dist/services/wordpress/wordpress.service.d.ts +15 -0
- package/dist/services/wordpress/wordpress.service.js +111 -0
- package/dist/services/wordpress/wordpress.service.js.map +7 -0
- package/dist/types/general.types.d.ts +61 -0
- package/dist/types/general.types.js +1 -0
- package/dist/types/general.types.js.map +7 -0
- package/dist/utils/api.d.ts +31 -0
- package/dist/utils/api.js +400 -0
- package/dist/utils/api.js.map +7 -0
- package/dist/utils/cache.d.ts +7 -0
- package/dist/utils/cache.js +25 -0
- package/dist/utils/cache.js.map +7 -0
- package/dist/utils/ccma-metrics.d.ts +18 -0
- package/dist/utils/ccma-metrics.js +37 -0
- package/dist/utils/ccma-metrics.js.map +7 -0
- package/dist/utils/environments.d.ts +11 -0
- package/dist/utils/environments.js +148 -0
- package/dist/utils/environments.js.map +7 -0
- package/dist/utils/errors.d.ts +5 -0
- package/dist/utils/errors.js +11 -0
- package/dist/utils/errors.js.map +7 -0
- package/dist/utils/frontendCache.d.ts +26 -0
- package/dist/utils/frontendCache.js +121 -0
- package/dist/utils/frontendCache.js.map +7 -0
- package/dist/utils/token-issuer.utils.d.ts +8 -0
- package/dist/utils/token-issuer.utils.js +19 -0
- package/dist/utils/token-issuer.utils.js.map +7 -0
- package/package.json +2 -6
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { request } from "../../utils/api.js";
|
|
2
|
+
import { HttpError } from "../../utils/errors.js";
|
|
3
|
+
class WordpressService {
|
|
4
|
+
static async getCards(params) {
|
|
5
|
+
const serviceContext = {
|
|
6
|
+
method: {
|
|
7
|
+
name: `WordpressService.getCards`,
|
|
8
|
+
url: `wp-json/camundahelp/v1/cards?card_id=${params.options.cardIds.join(
|
|
9
|
+
","
|
|
10
|
+
)}`,
|
|
11
|
+
normalizedUrl: `wp-json/camundahelp/v1/cards?card_id=:card_id`,
|
|
12
|
+
type: "get"
|
|
13
|
+
},
|
|
14
|
+
source: params.config.metrics?.source || "unset",
|
|
15
|
+
target: {
|
|
16
|
+
name: "wordpress",
|
|
17
|
+
type: "external"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const response = await request({
|
|
21
|
+
...params,
|
|
22
|
+
base: {
|
|
23
|
+
id: "wordpress-helpcenter"
|
|
24
|
+
},
|
|
25
|
+
url: serviceContext.method.url,
|
|
26
|
+
method: serviceContext.method.type,
|
|
27
|
+
metricsDetails: serviceContext,
|
|
28
|
+
type: "json"
|
|
29
|
+
});
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
throw new HttpError(
|
|
32
|
+
`${serviceContext.method.name}: ${response.status} ${response.statusText}`,
|
|
33
|
+
response.status,
|
|
34
|
+
response.statusText
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return response.body;
|
|
38
|
+
}
|
|
39
|
+
static async getHelpCenterConfig(params) {
|
|
40
|
+
const serviceContext = {
|
|
41
|
+
method: {
|
|
42
|
+
name: `WordpressService.getHelpCenterConfig`,
|
|
43
|
+
url: `wp-json/camundahelp/v1/helpcenter?env=${params.config.stage}`,
|
|
44
|
+
normalizedUrl: `wp-json/camundahelp/v1/helpcenter?env=:env`,
|
|
45
|
+
type: "get"
|
|
46
|
+
},
|
|
47
|
+
source: params.config.metrics?.source || "unset",
|
|
48
|
+
target: {
|
|
49
|
+
name: "wordpress",
|
|
50
|
+
type: "external"
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
params.config.stage = params.config.stage.replace("-test", "");
|
|
54
|
+
const response = await request({
|
|
55
|
+
...params,
|
|
56
|
+
base: {
|
|
57
|
+
id: "wordpress-helpcenter"
|
|
58
|
+
},
|
|
59
|
+
url: serviceContext.method.url,
|
|
60
|
+
method: serviceContext.method.type,
|
|
61
|
+
metricsDetails: serviceContext,
|
|
62
|
+
type: "json"
|
|
63
|
+
});
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
throw new HttpError(
|
|
66
|
+
`${serviceContext.method.name}: ${response.status} ${response.statusText}`,
|
|
67
|
+
response.status,
|
|
68
|
+
response.statusText
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return response.body;
|
|
72
|
+
}
|
|
73
|
+
static async getSurveyConfig(params) {
|
|
74
|
+
const serviceContext = {
|
|
75
|
+
method: {
|
|
76
|
+
name: `WordpressService.getSurveyConfig`,
|
|
77
|
+
url: `wp-json/camundahelp/v1/onboardingsurvey?env=${params.config.stage}`,
|
|
78
|
+
normalizedUrl: `wp-json/camundahelp/v1/onboardingsurvey?env=:env`,
|
|
79
|
+
type: "get"
|
|
80
|
+
},
|
|
81
|
+
source: params.config.metrics?.source || "unset",
|
|
82
|
+
target: {
|
|
83
|
+
name: "wordpress",
|
|
84
|
+
type: "external"
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
params.config.stage = params.config.stage.replace("-test", "");
|
|
88
|
+
const response = await request({
|
|
89
|
+
...params,
|
|
90
|
+
base: {
|
|
91
|
+
id: "wordpress-helpcenter"
|
|
92
|
+
},
|
|
93
|
+
url: serviceContext.method.url,
|
|
94
|
+
method: serviceContext.method.type,
|
|
95
|
+
metricsDetails: serviceContext,
|
|
96
|
+
type: "json"
|
|
97
|
+
});
|
|
98
|
+
if (!response.ok) {
|
|
99
|
+
throw new HttpError(
|
|
100
|
+
`${serviceContext.method.name}: ${response.status} ${response.statusText}`,
|
|
101
|
+
response.status,
|
|
102
|
+
response.statusText
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return response.body;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
WordpressService
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=wordpress.service.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/services/wordpress/wordpress.service.ts"],
|
|
4
|
+
"sourcesContent": ["/*\n * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH\n * under one or more contributor license agreements. Licensed under a commercial license.\n * You may not use this file except in compliance with the commercial license.\n */\n\nimport type {\n RequestBaseParams,\n RequestBaseServiceContext,\n} from '../../types/general.types.js'\nimport { request } from '../../utils/api.js'\nimport { HttpError } from '../../utils/errors.js'\n\nexport interface WordpressGetCardsRequest extends RequestBaseParams {\n options: {\n cardIds: string[]\n }\n}\n\nexport interface WordpressGetHelpCenterConfigRequest\n extends RequestBaseParams {}\n\nexport interface WordpressGetSurveyConfigRequest extends RequestBaseParams {}\n\nexport class WordpressService {\n public static async getCards(\n params: WordpressGetCardsRequest,\n ): Promise<any[]> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: `WordpressService.getCards`,\n url: `wp-json/camundahelp/v1/cards?card_id=${params.options.cardIds.join(\n ',',\n )}`,\n normalizedUrl: `wp-json/camundahelp/v1/cards?card_id=:card_id`,\n type: 'get',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'wordpress',\n type: 'external',\n },\n }\n\n const response = await request<any[]>({\n ...params,\n base: {\n id: 'wordpress-helpcenter',\n },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n type: 'json',\n })\n if (!response.ok) {\n throw new HttpError(\n `${serviceContext.method.name}: ${response.status} ${response.statusText}`,\n response.status,\n response.statusText,\n )\n }\n return response.body!\n }\n\n public static async getHelpCenterConfig(\n params: WordpressGetHelpCenterConfigRequest,\n ): Promise<any> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: `WordpressService.getHelpCenterConfig`,\n url: `wp-json/camundahelp/v1/helpcenter?env=${params.config.stage}`,\n normalizedUrl: `wp-json/camundahelp/v1/helpcenter?env=:env`,\n type: 'get',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'wordpress',\n type: 'external',\n },\n }\n params.config.stage = params.config.stage.replace('-test', '') as any\n const response = await request<any>({\n ...params,\n base: {\n id: 'wordpress-helpcenter',\n },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n type: 'json',\n })\n if (!response.ok) {\n throw new HttpError(\n `${serviceContext.method.name}: ${response.status} ${response.statusText}`,\n response.status,\n response.statusText,\n )\n }\n return response.body\n }\n\n public static async getSurveyConfig(\n params: WordpressGetSurveyConfigRequest,\n ): Promise<any> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: `WordpressService.getSurveyConfig`,\n url: `wp-json/camundahelp/v1/onboardingsurvey?env=${params.config.stage}`,\n normalizedUrl: `wp-json/camundahelp/v1/onboardingsurvey?env=:env`,\n type: 'get',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'wordpress',\n type: 'external',\n },\n }\n params.config.stage = params.config.stage.replace('-test', '') as any\n const response = await request<any>({\n ...params,\n base: {\n id: 'wordpress-helpcenter',\n },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n type: 'json',\n })\n if (!response.ok) {\n throw new HttpError(\n `${serviceContext.method.name}: ${response.status} ${response.statusText}`,\n response.status,\n response.statusText,\n )\n }\n return response.body\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type Stage = 'dev' | 'devAws' | 'int' | 'prod' | 'local' | 'localconsole' | 'localaccounts';
|
|
2
|
+
export interface RequestBaseParamsAuth {
|
|
3
|
+
getToken: () => Promise<string>;
|
|
4
|
+
}
|
|
5
|
+
export interface RequestBaseParamsLogger {
|
|
6
|
+
debug: (message: string, data?: any) => void;
|
|
7
|
+
info: (message: string, data?: any) => void;
|
|
8
|
+
error: (message: string, data?: any) => void;
|
|
9
|
+
}
|
|
10
|
+
export type RequestBaseCustomMetricsDetailsType = 'request' | 'success' | 'error' | 'rate-limit-retry';
|
|
11
|
+
export interface RequestBaseServiceContext {
|
|
12
|
+
source: string;
|
|
13
|
+
target: {
|
|
14
|
+
name: string;
|
|
15
|
+
type: 'internal' | 'external';
|
|
16
|
+
};
|
|
17
|
+
method: {
|
|
18
|
+
name: string;
|
|
19
|
+
url: string;
|
|
20
|
+
normalizedUrl: string;
|
|
21
|
+
type: RequestBaseMethodType;
|
|
22
|
+
};
|
|
23
|
+
eventType?: RequestBaseCustomMetricsDetailsType;
|
|
24
|
+
durationBucket?: string;
|
|
25
|
+
statusCode?: string;
|
|
26
|
+
error?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface RequestBaseCustomMetrics {
|
|
29
|
+
source: string;
|
|
30
|
+
types: RequestBaseCustomMetricsDetailsType[];
|
|
31
|
+
callback: (details: RequestBaseServiceContext) => void;
|
|
32
|
+
}
|
|
33
|
+
export interface RequestBaseParamsEnvOverride {
|
|
34
|
+
[key: string]: string;
|
|
35
|
+
}
|
|
36
|
+
export interface RequestBaseParamsConfig {
|
|
37
|
+
stage: Stage;
|
|
38
|
+
auth?: RequestBaseParamsAuth;
|
|
39
|
+
logger?: RequestBaseParamsLogger;
|
|
40
|
+
envOverride?: RequestBaseParamsEnvOverride;
|
|
41
|
+
metrics?: RequestBaseCustomMetrics;
|
|
42
|
+
timeout?: number;
|
|
43
|
+
proxyAgent?: any;
|
|
44
|
+
frontendCaching?: {
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
dbName: string;
|
|
47
|
+
storeName?: string;
|
|
48
|
+
ttl: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface RequestBaseParams {
|
|
52
|
+
config: RequestBaseParamsConfig;
|
|
53
|
+
cacheControl?: {
|
|
54
|
+
ignoreCache?: boolean;
|
|
55
|
+
};
|
|
56
|
+
onCachedResponse?: (data: any, info: {
|
|
57
|
+
fresh: boolean;
|
|
58
|
+
source: 'cache';
|
|
59
|
+
}) => void;
|
|
60
|
+
}
|
|
61
|
+
export type RequestBaseMethodType = 'get' | 'post' | 'put' | 'delete' | 'patch';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=general.types.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RequestBaseMethodType, RequestBaseParams, RequestBaseServiceContext } from '../types/general.types.js';
|
|
2
|
+
import { type ServiceName } from './environments.js';
|
|
3
|
+
export interface RequestPayload extends RequestBaseParams {
|
|
4
|
+
base?: {
|
|
5
|
+
id: ServiceName;
|
|
6
|
+
};
|
|
7
|
+
url: string;
|
|
8
|
+
method: RequestBaseMethodType;
|
|
9
|
+
headers?: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
type?: 'json' | 'text' | 'form' | 'none';
|
|
13
|
+
responseType?: 'json' | 'text' | 'none';
|
|
14
|
+
retry?: {
|
|
15
|
+
attempts: number;
|
|
16
|
+
remaining: number;
|
|
17
|
+
};
|
|
18
|
+
body?: any;
|
|
19
|
+
metricsDetails: RequestBaseServiceContext;
|
|
20
|
+
}
|
|
21
|
+
export interface Response<T> {
|
|
22
|
+
body?: T;
|
|
23
|
+
status: number;
|
|
24
|
+
statusText?: string;
|
|
25
|
+
ok: boolean;
|
|
26
|
+
meta: {
|
|
27
|
+
duration: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export declare function log(payload: RequestPayload, type: 'debug' | 'info' | 'error', message: string, additionalData?: any): void;
|
|
31
|
+
export declare function request<T>(payload: RequestPayload): Promise<Response<T>>;
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { getEnvParam } from "./environments.js";
|
|
2
|
+
import { frontendCache } from "./frontendCache.js";
|
|
3
|
+
function sendMetrics(payload, type, options) {
|
|
4
|
+
if (payload.config.metrics) {
|
|
5
|
+
if (payload.config.metrics.types.includes(type)) {
|
|
6
|
+
let durationBucket;
|
|
7
|
+
if (options?.duration) {
|
|
8
|
+
if (options.duration < 100) {
|
|
9
|
+
durationBucket = "0 | <100ms";
|
|
10
|
+
} else if (options.duration < 200) {
|
|
11
|
+
durationBucket = "1 | <200ms";
|
|
12
|
+
} else if (options.duration < 500) {
|
|
13
|
+
durationBucket = "2 | <500ms";
|
|
14
|
+
} else if (options.duration < 1e3) {
|
|
15
|
+
durationBucket = "3 | <1s";
|
|
16
|
+
} else {
|
|
17
|
+
durationBucket = "4 | >=1s";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
let error = "other";
|
|
21
|
+
if (options?.error) {
|
|
22
|
+
try {
|
|
23
|
+
const errorMessage = options.error;
|
|
24
|
+
if (errorMessage.startsWith("<!DOCTYPE html>")) {
|
|
25
|
+
error = "html-response";
|
|
26
|
+
} else if (errorMessage.includes("UND_ERR_CONNECT_TIMEOUT")) {
|
|
27
|
+
error = "connect-timeout";
|
|
28
|
+
}
|
|
29
|
+
} catch (_error) {
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
error = "unset";
|
|
33
|
+
}
|
|
34
|
+
const metrics = {
|
|
35
|
+
...payload.metricsDetails,
|
|
36
|
+
eventType: type,
|
|
37
|
+
durationBucket,
|
|
38
|
+
statusCode: options?.statusCode,
|
|
39
|
+
error
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
payload.config.metrics.callback(metrics);
|
|
43
|
+
} catch (metricsCallbackError) {
|
|
44
|
+
log(payload, "debug", `Failed to send metrics`, {
|
|
45
|
+
error: metricsCallbackError,
|
|
46
|
+
metrics
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function log(payload, type, message, additionalData) {
|
|
53
|
+
if (payload.config.logger) {
|
|
54
|
+
const messageParts = [];
|
|
55
|
+
messageParts.push(payload.metricsDetails?.method?.name);
|
|
56
|
+
messageParts.push(
|
|
57
|
+
`${payload.metricsDetails?.target?.name} (${payload.metricsDetails?.target?.type})`
|
|
58
|
+
);
|
|
59
|
+
messageParts.push(message);
|
|
60
|
+
let body;
|
|
61
|
+
if (payload.body) {
|
|
62
|
+
body = JSON.parse(JSON.stringify(payload.body));
|
|
63
|
+
for (const key of Object.keys(body)) {
|
|
64
|
+
if (key.toLowerCase().includes("password") || key.toLowerCase().includes("secret") || key.toLowerCase().includes("token")) {
|
|
65
|
+
body[key] = "********";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
let fullUrl = "unset";
|
|
70
|
+
if (payload.base) {
|
|
71
|
+
try {
|
|
72
|
+
const base = getEnvParam(payload.base.id, payload.config);
|
|
73
|
+
fullUrl = base ? `${base}/${payload.url}` : payload.url;
|
|
74
|
+
} catch (_error) {
|
|
75
|
+
fullUrl = `failed to get base url for ${payload.base.id}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
let url = `${payload.url}`.toLowerCase();
|
|
79
|
+
if (url.includes("secret") || url.includes("password")) {
|
|
80
|
+
url = url.split("?")[0];
|
|
81
|
+
}
|
|
82
|
+
const data = {
|
|
83
|
+
base: payload.base,
|
|
84
|
+
method: payload.method,
|
|
85
|
+
url,
|
|
86
|
+
fullUrl,
|
|
87
|
+
retry: payload.retry,
|
|
88
|
+
body,
|
|
89
|
+
context: payload.metricsDetails,
|
|
90
|
+
...additionalData
|
|
91
|
+
};
|
|
92
|
+
payload.config.logger[type](messageParts.join(" > "), { data });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function rateLimitWaitingTime(attempt) {
|
|
96
|
+
const noise = Math.random() * 100;
|
|
97
|
+
const waitingTime = 2 ** attempt * 1e3 + noise;
|
|
98
|
+
return Math.floor(waitingTime);
|
|
99
|
+
}
|
|
100
|
+
async function request(payload) {
|
|
101
|
+
log(payload, "debug", "starting request");
|
|
102
|
+
sendMetrics(payload, "request");
|
|
103
|
+
try {
|
|
104
|
+
if (payload.config.frontendCaching?.enabled) {
|
|
105
|
+
frontendCache.configure(payload.config.frontendCaching);
|
|
106
|
+
}
|
|
107
|
+
} catch (_cacheConfigError) {
|
|
108
|
+
}
|
|
109
|
+
let token;
|
|
110
|
+
if (payload.config.auth) {
|
|
111
|
+
token = await payload.config.auth.getToken();
|
|
112
|
+
}
|
|
113
|
+
const headers = payload.headers ?? {};
|
|
114
|
+
if (token) {
|
|
115
|
+
headers.Authorization = `Bearer ${token}`;
|
|
116
|
+
}
|
|
117
|
+
const type = payload.type ?? "json";
|
|
118
|
+
let body;
|
|
119
|
+
if (type) {
|
|
120
|
+
switch (type) {
|
|
121
|
+
case "json":
|
|
122
|
+
headers["Content-Type"] = "application/json";
|
|
123
|
+
body = payload.body ? JSON.stringify(payload.body) : void 0;
|
|
124
|
+
break;
|
|
125
|
+
case "text":
|
|
126
|
+
headers["Content-Type"] = "text/plain";
|
|
127
|
+
body = payload.body ? JSON.stringify(payload.body) : void 0;
|
|
128
|
+
break;
|
|
129
|
+
case "form":
|
|
130
|
+
if (payload.body) {
|
|
131
|
+
const formData = new URLSearchParams();
|
|
132
|
+
Object.keys(payload.body).forEach((key) => {
|
|
133
|
+
formData.append(key, payload.body[key]);
|
|
134
|
+
});
|
|
135
|
+
body = formData;
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
let base;
|
|
141
|
+
if (payload.base) {
|
|
142
|
+
try {
|
|
143
|
+
base = getEnvParam(payload.base.id, payload.config);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
log(payload, "error", `Failed to get base url for ${payload.base.id}`, {
|
|
146
|
+
error
|
|
147
|
+
});
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const url = base ? `${base}/${payload.url}` : payload.url;
|
|
152
|
+
let serveCachedAndReturnAfterNetwork = false;
|
|
153
|
+
if (payload.method === "get" && payload.config.frontendCaching?.enabled) {
|
|
154
|
+
try {
|
|
155
|
+
const cached = await frontendCache.get("get", url);
|
|
156
|
+
if (cached) {
|
|
157
|
+
const fresh = frontendCache.isFresh(cached);
|
|
158
|
+
if (payload.onCachedResponse) {
|
|
159
|
+
payload.onCachedResponse(cached.payload, { fresh, source: "cache" });
|
|
160
|
+
if (!fresh) {
|
|
161
|
+
log(payload, "debug", "cache stale, refreshing in background");
|
|
162
|
+
serveCachedAndReturnAfterNetwork = true;
|
|
163
|
+
} else {
|
|
164
|
+
log(payload, "debug", "cache fresh, returning early");
|
|
165
|
+
sendMetrics(payload, "success", { duration: 0, statusCode: "200" });
|
|
166
|
+
return {
|
|
167
|
+
// eslint-disable-next-line id-length
|
|
168
|
+
ok: true,
|
|
169
|
+
status: 200,
|
|
170
|
+
statusText: "cached",
|
|
171
|
+
body: cached.payload,
|
|
172
|
+
meta: { duration: 0 }
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
} else if (fresh) {
|
|
176
|
+
log(payload, "debug", "cache hit, returning cached response");
|
|
177
|
+
sendMetrics(payload, "success", { duration: 0, statusCode: "200" });
|
|
178
|
+
return {
|
|
179
|
+
// eslint-disable-next-line id-length
|
|
180
|
+
ok: true,
|
|
181
|
+
status: 200,
|
|
182
|
+
statusText: "cached",
|
|
183
|
+
body: cached.payload,
|
|
184
|
+
meta: { duration: 0 }
|
|
185
|
+
};
|
|
186
|
+
} else {
|
|
187
|
+
log(payload, "debug", "cache stale, proceeding with network request");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
} catch (_cacheGetError) {
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const start = performance.now();
|
|
194
|
+
const proxyAgent = payload.config.proxyAgent ?? {};
|
|
195
|
+
try {
|
|
196
|
+
const fetchResponse = await fetch(url, {
|
|
197
|
+
signal: payload.config.timeout ? AbortSignal.timeout(payload.config.timeout) : void 0,
|
|
198
|
+
method: payload.method.toUpperCase(),
|
|
199
|
+
headers,
|
|
200
|
+
body,
|
|
201
|
+
...proxyAgent
|
|
202
|
+
});
|
|
203
|
+
const end = performance.now();
|
|
204
|
+
const duration = end - start;
|
|
205
|
+
if ([429].includes(fetchResponse.status)) {
|
|
206
|
+
log(payload, "info", "rate limited");
|
|
207
|
+
sendMetrics(payload, "rate-limit-retry", {
|
|
208
|
+
duration,
|
|
209
|
+
statusCode: String(fetchResponse.status)
|
|
210
|
+
});
|
|
211
|
+
const remaining = payload.retry?.remaining ?? 8;
|
|
212
|
+
const attempts = payload.retry?.attempts ?? 1;
|
|
213
|
+
if (remaining > 0) {
|
|
214
|
+
let waitingTime = rateLimitWaitingTime(attempts);
|
|
215
|
+
if (fetchResponse.headers.has("x-ratelimit-reset")) {
|
|
216
|
+
const rateLimitHeader = fetchResponse.headers.get("x-ratelimit-reset");
|
|
217
|
+
log(
|
|
218
|
+
payload,
|
|
219
|
+
"debug",
|
|
220
|
+
`rate limited, found x-ratelimit-reset header: ${rateLimitHeader}`
|
|
221
|
+
);
|
|
222
|
+
const rateLimitHeaderNumber = Number(rateLimitHeader);
|
|
223
|
+
if (Number.isNaN(rateLimitHeaderNumber)) {
|
|
224
|
+
waitingTime = Date.parse(rateLimitHeader ?? "0") - Date.now();
|
|
225
|
+
} else {
|
|
226
|
+
waitingTime = rateLimitHeaderNumber - Date.now();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (waitingTime < 0 || waitingTime > 18e4) {
|
|
230
|
+
waitingTime = rateLimitWaitingTime(attempts);
|
|
231
|
+
}
|
|
232
|
+
log(
|
|
233
|
+
payload,
|
|
234
|
+
"debug",
|
|
235
|
+
`rate limited, attempt ${attempts}, remaining ${remaining}, waiting ${waitingTime}ms`
|
|
236
|
+
);
|
|
237
|
+
await new Promise((resolve) => {
|
|
238
|
+
setTimeout(resolve, waitingTime);
|
|
239
|
+
});
|
|
240
|
+
payload.retry = {
|
|
241
|
+
attempts: attempts + 1,
|
|
242
|
+
remaining: remaining - 1
|
|
243
|
+
};
|
|
244
|
+
return request(payload);
|
|
245
|
+
}
|
|
246
|
+
log(payload, "debug", `rate limited, no more retries`);
|
|
247
|
+
}
|
|
248
|
+
const response = {
|
|
249
|
+
// eslint-disable-next-line id-length
|
|
250
|
+
ok: fetchResponse.ok,
|
|
251
|
+
status: fetchResponse.status,
|
|
252
|
+
statusText: fetchResponse.statusText,
|
|
253
|
+
meta: {
|
|
254
|
+
duration
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const responseType = payload.responseType ?? type;
|
|
258
|
+
if (response.ok) {
|
|
259
|
+
log(payload, "debug", `request successful in ${Math.floor(duration)}ms`, {
|
|
260
|
+
baseUrl: base
|
|
261
|
+
});
|
|
262
|
+
sendMetrics(payload, "success", {
|
|
263
|
+
duration,
|
|
264
|
+
statusCode: String(fetchResponse.status)
|
|
265
|
+
});
|
|
266
|
+
switch (responseType) {
|
|
267
|
+
case "json":
|
|
268
|
+
try {
|
|
269
|
+
response.body = await fetchResponse.json();
|
|
270
|
+
} catch (_error) {
|
|
271
|
+
log(
|
|
272
|
+
payload,
|
|
273
|
+
"debug",
|
|
274
|
+
`Failed to parse json body. Returning empty object.`,
|
|
275
|
+
{
|
|
276
|
+
baseUrl: base
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
response.body = {};
|
|
280
|
+
try {
|
|
281
|
+
const responseBodyText = await fetchResponse.text();
|
|
282
|
+
log(payload, "debug", `Response body text`, {
|
|
283
|
+
baseUrl: base,
|
|
284
|
+
responseBodyText,
|
|
285
|
+
status: fetchResponse.status
|
|
286
|
+
});
|
|
287
|
+
} catch (textError) {
|
|
288
|
+
log(payload, "debug", `Failed to parse response body text.`, {
|
|
289
|
+
baseUrl: base,
|
|
290
|
+
status: fetchResponse.status,
|
|
291
|
+
error: textError
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
break;
|
|
296
|
+
case "text":
|
|
297
|
+
response.body = await fetchResponse.text();
|
|
298
|
+
break;
|
|
299
|
+
default:
|
|
300
|
+
response.body = await fetchResponse.text();
|
|
301
|
+
}
|
|
302
|
+
if (payload.method === "get" && payload.config.frontendCaching?.enabled && response.body !== void 0) {
|
|
303
|
+
try {
|
|
304
|
+
await frontendCache.set("get", url, response.body);
|
|
305
|
+
log(payload, "debug", "cache store successful");
|
|
306
|
+
} catch (_cacheSetError) {
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
} else {
|
|
310
|
+
let statusText = fetchResponse.statusText;
|
|
311
|
+
try {
|
|
312
|
+
statusText = await fetchResponse.text();
|
|
313
|
+
} catch (_error) {
|
|
314
|
+
}
|
|
315
|
+
response.statusText = statusText;
|
|
316
|
+
log(
|
|
317
|
+
payload,
|
|
318
|
+
"debug",
|
|
319
|
+
`request failed with status ${response.status}: ${statusText}`,
|
|
320
|
+
{
|
|
321
|
+
baseUrl: base
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
let type2 = "error";
|
|
325
|
+
const noErrorStatusCodes = [];
|
|
326
|
+
switch (payload.metricsDetails.target.name) {
|
|
327
|
+
case "auth0":
|
|
328
|
+
noErrorStatusCodes.push(...[400, 404, 409]);
|
|
329
|
+
break;
|
|
330
|
+
case "accounts":
|
|
331
|
+
case "console":
|
|
332
|
+
noErrorStatusCodes.push(...[404, 409]);
|
|
333
|
+
if (payload.metricsDetails.method.name === "createTemporaryCluster") {
|
|
334
|
+
noErrorStatusCodes.push(...[400, 403, 412]);
|
|
335
|
+
}
|
|
336
|
+
if ([
|
|
337
|
+
"ConsoleM2MService.verifyZeebeClient",
|
|
338
|
+
"ConsoleM2MService.verifyApiClient"
|
|
339
|
+
].includes(payload.metricsDetails.method.name)) {
|
|
340
|
+
noErrorStatusCodes.push(...[401]);
|
|
341
|
+
}
|
|
342
|
+
if (payload.metricsDetails.method.name === "OrgsService.createAndReturnSocialLoginUser") {
|
|
343
|
+
noErrorStatusCodes.push(
|
|
344
|
+
...[
|
|
345
|
+
// onboard user, user already has an org
|
|
346
|
+
400,
|
|
347
|
+
// existing extSSO-connection
|
|
348
|
+
412
|
|
349
|
+
]
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
if (noErrorStatusCodes.includes(response.status)) {
|
|
355
|
+
type2 = "success";
|
|
356
|
+
}
|
|
357
|
+
sendMetrics(payload, type2, {
|
|
358
|
+
duration,
|
|
359
|
+
statusCode: String(fetchResponse.status),
|
|
360
|
+
error: statusText
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
if (serveCachedAndReturnAfterNetwork && response.ok) {
|
|
364
|
+
log(payload, "debug", "stale cache updated, returning new data");
|
|
365
|
+
}
|
|
366
|
+
return response;
|
|
367
|
+
} catch (error) {
|
|
368
|
+
log(payload, "error", `request failed with no status`, {
|
|
369
|
+
baseUrl: base,
|
|
370
|
+
error
|
|
371
|
+
});
|
|
372
|
+
const duration = performance.now() - start;
|
|
373
|
+
let errorMessage;
|
|
374
|
+
if (error?.cause?.code) {
|
|
375
|
+
errorMessage = error?.cause?.code;
|
|
376
|
+
} else if (error?.message) {
|
|
377
|
+
errorMessage = error?.message;
|
|
378
|
+
}
|
|
379
|
+
sendMetrics(payload, "error", {
|
|
380
|
+
statusCode: "fetch-error",
|
|
381
|
+
duration,
|
|
382
|
+
error: errorMessage
|
|
383
|
+
});
|
|
384
|
+
const response = {
|
|
385
|
+
// eslint-disable-next-line id-length
|
|
386
|
+
ok: false,
|
|
387
|
+
status: 500,
|
|
388
|
+
statusText: "fetch error",
|
|
389
|
+
meta: {
|
|
390
|
+
duration
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
return response;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
export {
|
|
397
|
+
log,
|
|
398
|
+
request
|
|
399
|
+
};
|
|
400
|
+
//# sourceMappingURL=api.js.map
|