@foxtware/mineral 0.1.27 → 0.1.29
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/.creds.yml.sample +29 -0
- package/AGENTS.md +24 -0
- package/_build_scripts/createNewFunction.js +26 -3
- package/api/dropbox/docs.md +7 -0
- package/api/dropbox/dropbox.constants.js +10 -0
- package/api/dropbox/dropbox.utils.js +67 -0
- package/api/dropbox/dropboxAccountGet.js +64 -0
- package/api/dropbox/dropboxFileCopy.js +67 -0
- package/api/dropbox/dropboxFileDelete.js +89 -0
- package/api/dropbox/dropboxFileDownload.js +139 -0
- package/api/dropbox/dropboxFileMetadataGet.js +100 -0
- package/api/dropbox/dropboxFileMove.js +67 -0
- package/api/dropbox/dropboxFileUpload.js +129 -0
- package/api/dropbox/dropboxFolderCreate.js +68 -0
- package/api/dropbox/dropboxFolderList.js +66 -0
- package/api/dropbox/dropboxGet.js +158 -0
- package/api/dropbox/dropboxSearch.js +161 -0
- package/api/dropbox/dropboxSharedLinkCreate.js +68 -0
- package/api/dropbox/dropboxSpaceUsageGet.js +55 -0
- package/api/dropbox/dropboxTemporaryLinkGet.js +75 -0
- package/api/fastsimon/.gitkeep +0 -0
- package/api/fastsimon/docs.md +14 -0
- package/api/fastsimon/fastsimon.constants.js +18 -0
- package/api/fastsimon/fastsimon.utils.js +246 -0
- package/api/fastsimon/fastsimonSearch.js +84 -0
- package/api/figma/docs.md +3 -3
- package/api/figma/figma.constants.js +1 -1
- package/api/figma/figma.utils.js +13 -2
- package/api/figma/figmaActivityLogsGet.js +44 -0
- package/api/figma/figmaAiUsageDailyGet.js +44 -0
- package/api/figma/figmaComponentGet.js +48 -0
- package/api/figma/figmaComponentSetGet.js +48 -0
- package/api/figma/figmaDevResourcesCreate.js +47 -0
- package/api/figma/figmaDevResourcesUpdate.js +47 -0
- package/api/figma/figmaDeveloperLogsCreate.js +47 -0
- package/api/figma/figmaDiscoveryGet.js +44 -0
- package/api/figma/figmaFileCommentCreate.js +50 -0
- package/api/figma/figmaFileCommentDelete.js +51 -0
- package/api/figma/figmaFileCommentReactionCreate.js +53 -0
- package/api/figma/figmaFileCommentReactionDelete.js +51 -0
- package/api/figma/figmaFileCommentReactionsGet.js +51 -0
- package/api/figma/figmaFileCommentsGet.js +48 -0
- package/api/figma/figmaFileComponentSetsGet.js +48 -0
- package/api/figma/figmaFileComponentsGet.js +48 -0
- package/api/figma/figmaFileDevResourceDelete.js +51 -0
- package/api/figma/figmaFileDevResourcesGet.js +48 -0
- package/api/figma/figmaFileGet.js +48 -0
- package/api/figma/figmaFileImageFillsGet.js +48 -0
- package/api/figma/figmaFileImagesGet.js +48 -0
- package/api/figma/figmaFileMetaGet.js +48 -0
- package/api/figma/figmaFileNodesGet.js +48 -0
- package/api/figma/figmaFileStylesGet.js +48 -0
- package/api/figma/figmaFileVersionsGet.js +48 -0
- package/api/figma/figmaFolderFilesGet.js +48 -0
- package/api/figma/figmaFolderFoldersGet.js +48 -0
- package/api/figma/figmaFolderMetaGet.js +48 -0
- package/api/figma/figmaGet.js +15 -63
- package/api/figma/figmaMeGet.js +53 -0
- package/api/figma/figmaOembedGet.js +44 -0
- package/api/figma/figmaPaymentsGet.js +44 -0
- package/api/figma/figmaProjectFilesGet.js +48 -0
- package/api/figma/figmaProjectMetaGet.js +48 -0
- package/api/figma/figmaStyleGet.js +48 -0
- package/api/figma/figmaTeamComponentSetsGet.js +48 -0
- package/api/figma/figmaTeamComponentsGet.js +48 -0
- package/api/figma/figmaTeamFoldersGet.js +48 -0
- package/api/figma/figmaTeamProjectsGet.js +48 -0
- package/api/figma/figmaTeamStylesGet.js +48 -0
- package/api/figma/figmaTeamWebhooksGet.js +47 -0
- package/api/figma/figmaVariablesLocalGet.js +48 -0
- package/api/figma/figmaVariablesPublishedGet.js +48 -0
- package/api/figma/figmaVariablesUpdate.js +50 -0
- package/api/figma/figmaWebhookCreate.js +47 -0
- package/api/figma/figmaWebhookDelete.js +48 -0
- package/api/figma/figmaWebhookGet.js +46 -0
- package/api/figma/figmaWebhookRequestsGet.js +47 -0
- package/api/figma/figmaWebhookUpdate.js +50 -0
- package/api/figma/figmaWebhooksGet.js +47 -0
- package/api/google/docs.md +1 -0
- package/api/google/google.constants.js +1 -0
- package/api/google/google.utils.js +21 -0
- package/api/google/googleanalyticsMetadataGet.js +62 -0
- package/api/google/googleanalyticsRealtimeReportRun.js +103 -0
- package/api/google/googleanalyticsReportRun.js +114 -0
- package/api/gorgias/gorgiasTicketCreate.js +1 -1
- package/api/gorgias/gorgiasTicketMessageCreate.js +1 -1
- package/api/gorgias/gorgiasTicketUpdate.js +1 -1
- package/api/linear/linearAttachmentCreate.js +1 -1
- package/api/linear/linearCommentCreate.js +1 -1
- package/api/linear/linearCommentUpdate.js +1 -1
- package/api/linear/linearIssueLabelCreate.js +1 -1
- package/api/linear/linearIssueUpdate.js +1 -1
- package/api/linear/linearProjectCreate.js +1 -1
- package/api/linear/linearProjectUpdate.js +1 -1
- package/api/linear/linearWebhookCreate.js +1 -1
- package/api/salesforce/salesforce.constants.js +13 -0
- package/api/salesforce/salesforce.utils.js +61 -0
- package/api/salesforce/salesforceAuthGet.js +115 -0
- package/api/salesforce/salesforceComposite.js +79 -0
- package/api/salesforce/salesforceCompositeBatch.js +73 -0
- package/api/salesforce/salesforceLimitsGet.js +55 -0
- package/api/salesforce/salesforceQuery.js +69 -0
- package/api/salesforce/salesforceQueryAll.js +62 -0
- package/api/salesforce/salesforceQueryMore.js +75 -0
- package/api/salesforce/salesforceRecentItemsGet.js +63 -0
- package/api/salesforce/salesforceResourcesGet.js +55 -0
- package/api/salesforce/salesforceSearch.js +62 -0
- package/api/salesforce/salesforceSobjectBasicInfoGet.js +81 -0
- package/api/salesforce/salesforceSobjectBlobGet.js +67 -0
- package/api/salesforce/salesforceSobjectCollectionCreate.js +78 -0
- package/api/salesforce/salesforceSobjectCollectionDelete.js +70 -0
- package/api/salesforce/salesforceSobjectCollectionGet.js +75 -0
- package/api/salesforce/salesforceSobjectCollectionUpdate.js +74 -0
- package/api/salesforce/salesforceSobjectCreate.js +66 -0
- package/api/salesforce/salesforceSobjectDelete.js +86 -0
- package/api/salesforce/salesforceSobjectDeleteByExternalId.js +91 -0
- package/api/salesforce/salesforceSobjectDeletedGet.js +71 -0
- package/api/salesforce/salesforceSobjectDescribe.js +81 -0
- package/api/salesforce/salesforceSobjectDescribeLayouts.js +64 -0
- package/api/salesforce/salesforceSobjectGet.js +93 -0
- package/api/salesforce/salesforceSobjectGetByExternalId.js +98 -0
- package/api/salesforce/salesforceSobjectTreeCreate.js +79 -0
- package/api/salesforce/salesforceSobjectUpdate.js +94 -0
- package/api/salesforce/salesforceSobjectUpdatedGet.js +71 -0
- package/api/salesforce/salesforceSobjectUpsert.js +74 -0
- package/api/salesforce/salesforceSobjectsDescribeGlobal.js +55 -0
- package/api/salesforce/salesforceVersionsGet.js +62 -0
- package/api/shopify/shopify.utils.js +53 -4
- package/api/shopify/shopifyMetaobjectCreate.js +79 -0
- package/api/shopify/shopifyMetaobjectDelete.js +90 -0
- package/api/shopify/shopifyMetaobjectGet.js +80 -0
- package/api/shopify/shopifyMetaobjectUpdate.js +108 -0
- package/api/shopify/shopifyStorefrontSearch.js +158 -0
- package/api/spotify/docs.md +8 -0
- package/api/spotify/spotify.constants.js +12 -0
- package/api/spotify/spotify.utils.js +106 -0
- package/api/spotify/spotifyAlbumGet.js +76 -0
- package/api/spotify/spotifyAlbumTracksGet.js +49 -0
- package/api/spotify/spotifyArtistAlbumsGet.js +55 -0
- package/api/spotify/spotifyArtistGet.js +71 -0
- package/api/spotify/spotifyArtistTopTracksGet.js +56 -0
- package/api/spotify/spotifyGet.js +171 -0
- package/api/spotify/spotifyMeGet.js +48 -0
- package/api/spotify/spotifyPlayerCurrentlyPlayingGet.js +62 -0
- package/api/spotify/spotifyPlayerDevicesGet.js +51 -0
- package/api/spotify/spotifyPlayerGet.js +63 -0
- package/api/spotify/spotifyPlayerNext.js +55 -0
- package/api/spotify/spotifyPlayerPause.js +55 -0
- package/api/spotify/spotifyPlayerPlay.js +70 -0
- package/api/spotify/spotifyPlayerPrevious.js +55 -0
- package/api/spotify/spotifyPlaylistCreate.js +63 -0
- package/api/spotify/spotifyPlaylistGet.js +91 -0
- package/api/spotify/spotifyPlaylistItemsAdd.js +61 -0
- package/api/spotify/spotifyPlaylistItemsGet.js +58 -0
- package/api/spotify/spotifyPlaylistItemsRemove.js +67 -0
- package/api/spotify/spotifyPlaylistUpdate.js +64 -0
- package/api/spotify/spotifyPlaylistsGet.js +47 -0
- package/api/spotify/spotifySavedTracksGet.js +46 -0
- package/api/spotify/spotifySavedTracksRemove.js +59 -0
- package/api/spotify/spotifySavedTracksSave.js +59 -0
- package/api/spotify/spotifySearch.js +174 -0
- package/api/spotify/spotifyTrackGet.js +76 -0
- package/api/tableau/tableau.constants.js +8 -0
- package/api/tableau/tableau.utils.js +93 -0
- package/api/tableau/tableauGet.js +174 -0
- package/api/tableau/tableauUserAdd.js +16 -94
- package/api/tableau/tableauUsersGet.js +46 -134
- package/api/tagalys/docs.md +2 -2
- package/api/tagalys/tagalys.constants.js +17 -0
- package/api/tagalys/tagalys.utils.js +125 -0
- package/api/tagalys/tagalysAnalyticsEventSend.js +125 -0
- package/api/tagalys/tagalysCollectionGet.js +100 -0
- package/api/tagalys/tagalysPopularSearchesGet.js +60 -0
- package/api/tagalys/tagalysRecommendationGet.js +109 -0
- package/api/tagalys/tagalysSearch.js +15 -89
- package/api/tagalys/tagalysSearchSuggestionsGet.js +76 -0
- package/package.json +2 -1
- package/server.js +3 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// https://developers.figma.com/docs/rest-api/webhooks-endpoints/
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { figmaClient } = require('../figma/figma.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['webhookPayload', Boolean],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const figmaWebhookCreate = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
webhookPayload,
|
|
15
|
+
{
|
|
16
|
+
params,
|
|
17
|
+
fetchClient = figmaClient,
|
|
18
|
+
} = {},
|
|
19
|
+
) => {
|
|
20
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
21
|
+
credsPayload,
|
|
22
|
+
webhookPayload
|
|
23
|
+
});
|
|
24
|
+
if (rejectResponse) {
|
|
25
|
+
return rejectResponse;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return fetchClient.fetch({
|
|
29
|
+
requestPayload: {
|
|
30
|
+
method: 'post',
|
|
31
|
+
url: `/v2/webhooks`,
|
|
32
|
+
body: webhookPayload,
|
|
33
|
+
},
|
|
34
|
+
context: {
|
|
35
|
+
credsPayload,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const funcApiConfig = {
|
|
41
|
+
argsWarden,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
figmaWebhookCreate,
|
|
46
|
+
funcApiConfig,
|
|
47
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// https://developers.figma.com/docs/rest-api/webhooks-endpoints/
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { figmaClient } = require('../figma/figma.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['webhookId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const figmaWebhookDelete = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
webhookId,
|
|
15
|
+
{
|
|
16
|
+
params,
|
|
17
|
+
fetchClient = figmaClient,
|
|
18
|
+
} = {},
|
|
19
|
+
) => {
|
|
20
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
21
|
+
credsPayload,
|
|
22
|
+
webhookId,
|
|
23
|
+
});
|
|
24
|
+
if (rejectResponse) {
|
|
25
|
+
return rejectResponse;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return fetchClient.fetch({
|
|
29
|
+
requestPayload: {
|
|
30
|
+
method: 'delete',
|
|
31
|
+
url: `/v2/webhooks/${ webhookId }`,
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
},
|
|
35
|
+
context: {
|
|
36
|
+
credsPayload,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const funcApiConfig = {
|
|
42
|
+
argsWarden,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
figmaWebhookDelete,
|
|
47
|
+
funcApiConfig,
|
|
48
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// https://developers.figma.com/docs/rest-api/webhooks-endpoints/
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { figmaClient } = require('../figma/figma.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['webhookId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const figmaWebhookGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
webhookId,
|
|
15
|
+
{
|
|
16
|
+
params,
|
|
17
|
+
fetchClient = figmaClient,
|
|
18
|
+
} = {},
|
|
19
|
+
) => {
|
|
20
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
21
|
+
credsPayload,
|
|
22
|
+
webhookId
|
|
23
|
+
});
|
|
24
|
+
if (rejectResponse) {
|
|
25
|
+
return rejectResponse;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return fetchClient.fetch({
|
|
29
|
+
requestPayload: {
|
|
30
|
+
method: 'get',
|
|
31
|
+
url: `/v2/webhooks/${ webhookId }`,
|
|
32
|
+
},
|
|
33
|
+
context: {
|
|
34
|
+
credsPayload,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const funcApiConfig = {
|
|
40
|
+
argsWarden,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
figmaWebhookGet,
|
|
45
|
+
funcApiConfig,
|
|
46
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// https://developers.figma.com/docs/rest-api/webhooks-endpoints/
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { figmaClient } = require('../figma/figma.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['webhookId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const figmaWebhookRequestsGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
webhookId,
|
|
15
|
+
{
|
|
16
|
+
params,
|
|
17
|
+
fetchClient = figmaClient,
|
|
18
|
+
} = {},
|
|
19
|
+
) => {
|
|
20
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
21
|
+
credsPayload,
|
|
22
|
+
webhookId
|
|
23
|
+
});
|
|
24
|
+
if (rejectResponse) {
|
|
25
|
+
return rejectResponse;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return fetchClient.fetch({
|
|
29
|
+
requestPayload: {
|
|
30
|
+
method: 'get',
|
|
31
|
+
url: `/v2/webhooks/${ webhookId }/requests`,
|
|
32
|
+
params,
|
|
33
|
+
},
|
|
34
|
+
context: {
|
|
35
|
+
credsPayload,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const funcApiConfig = {
|
|
41
|
+
argsWarden,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
figmaWebhookRequestsGet,
|
|
46
|
+
funcApiConfig,
|
|
47
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// https://developers.figma.com/docs/rest-api/webhooks-endpoints/
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { figmaClient } = require('../figma/figma.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['webhookId'],
|
|
10
|
+
['webhookPayload', Boolean],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const figmaWebhookUpdate = async (
|
|
14
|
+
credsPayload,
|
|
15
|
+
webhookId,
|
|
16
|
+
webhookPayload,
|
|
17
|
+
{
|
|
18
|
+
params,
|
|
19
|
+
fetchClient = figmaClient,
|
|
20
|
+
} = {},
|
|
21
|
+
) => {
|
|
22
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
23
|
+
credsPayload,
|
|
24
|
+
webhookId,
|
|
25
|
+
webhookPayload
|
|
26
|
+
});
|
|
27
|
+
if (rejectResponse) {
|
|
28
|
+
return rejectResponse;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return fetchClient.fetch({
|
|
32
|
+
requestPayload: {
|
|
33
|
+
method: 'put',
|
|
34
|
+
url: `/v2/webhooks/${ webhookId }`,
|
|
35
|
+
body: webhookPayload,
|
|
36
|
+
},
|
|
37
|
+
context: {
|
|
38
|
+
credsPayload,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const funcApiConfig = {
|
|
44
|
+
argsWarden,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
figmaWebhookUpdate,
|
|
49
|
+
funcApiConfig,
|
|
50
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// https://developers.figma.com/docs/rest-api/webhooks-endpoints/
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { figmaClient } = require('../figma/figma.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const figmaWebhooksGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
|
|
14
|
+
{
|
|
15
|
+
params,
|
|
16
|
+
fetchClient = figmaClient,
|
|
17
|
+
} = {},
|
|
18
|
+
) => {
|
|
19
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
20
|
+
credsPayload,
|
|
21
|
+
|
|
22
|
+
});
|
|
23
|
+
if (rejectResponse) {
|
|
24
|
+
return rejectResponse;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return fetchClient.fetch({
|
|
28
|
+
requestPayload: {
|
|
29
|
+
method: 'get',
|
|
30
|
+
url: `/v2/webhooks`,
|
|
31
|
+
params,
|
|
32
|
+
|
|
33
|
+
},
|
|
34
|
+
context: {
|
|
35
|
+
credsPayload,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const funcApiConfig = {
|
|
41
|
+
argsWarden,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
figmaWebhooksGet,
|
|
46
|
+
funcApiConfig,
|
|
47
|
+
};
|
package/api/google/docs.md
CHANGED
|
@@ -5,3 +5,4 @@ Service account auth via `SERVICE_ACCOUNT_JSON` on the `google` creds path. Uses
|
|
|
5
5
|
- [Sheets API](https://developers.google.com/workspace/sheets/api/reference/rest)
|
|
6
6
|
- [Drive API](https://developers.google.com/workspace/drive/api/reference/rest/v3)
|
|
7
7
|
- [Calendar API](https://developers.google.com/workspace/calendar/api/v3/reference)
|
|
8
|
+
- [Analytics Data API](https://developers.google.com/analytics/devguides/reporting/data/v1/rest)
|
|
@@ -2,6 +2,7 @@ const GOOGLE_SCOPES = {
|
|
|
2
2
|
sheets: ['https://www.googleapis.com/auth/spreadsheets'],
|
|
3
3
|
drive: ['https://www.googleapis.com/auth/drive'],
|
|
4
4
|
calendar: ['https://www.googleapis.com/auth/calendar'],
|
|
5
|
+
analytics: ['https://www.googleapis.com/auth/analytics'],
|
|
5
6
|
};
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
@@ -108,6 +108,26 @@ const getGoogleCalendar = async (
|
|
|
108
108
|
};
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
const getGoogleAnalyticsData = async (
|
|
112
|
+
credsPayload,
|
|
113
|
+
{
|
|
114
|
+
subject,
|
|
115
|
+
} = {},
|
|
116
|
+
) => {
|
|
117
|
+
const { auth, error } = await getGoogleAuth(credsPayload, {
|
|
118
|
+
scopes: GOOGLE_SCOPES.analytics,
|
|
119
|
+
subject,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (error) {
|
|
123
|
+
return { error };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
client: google.analyticsdata({ version: 'v1beta', auth }),
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
111
131
|
const googleApiCall = async (promiseFn) => {
|
|
112
132
|
try {
|
|
113
133
|
const response = await promiseFn();
|
|
@@ -132,6 +152,7 @@ module.exports = {
|
|
|
132
152
|
getGoogleSheets,
|
|
133
153
|
getGoogleDrive,
|
|
134
154
|
getGoogleCalendar,
|
|
155
|
+
getGoogleAnalyticsData,
|
|
135
156
|
googleApiCall,
|
|
136
157
|
invalidCredsResponse,
|
|
137
158
|
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/getMetadata
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, objHasAny } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { getGoogleAnalyticsData, googleApiCall } = require('../google/google.utils');
|
|
6
|
+
|
|
7
|
+
const propertyIdentifierValidator = (propertyIdentifier) => {
|
|
8
|
+
return objHasAny(propertyIdentifier, ['propertyId', 'property']);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const argsWarden = new ArgsWarden([
|
|
12
|
+
['credsPayload', credsValidator],
|
|
13
|
+
['propertyIdentifier', propertyIdentifierValidator],
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const googleanalyticsMetadataGet = async (
|
|
17
|
+
credsPayload,
|
|
18
|
+
propertyIdentifier,
|
|
19
|
+
{
|
|
20
|
+
subject,
|
|
21
|
+
} = {},
|
|
22
|
+
) => {
|
|
23
|
+
|
|
24
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
25
|
+
credsPayload,
|
|
26
|
+
propertyIdentifier,
|
|
27
|
+
});
|
|
28
|
+
if (rejectResponse) {
|
|
29
|
+
return rejectResponse;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const { propertyId, property } = propertyIdentifier;
|
|
33
|
+
const propertyName = property ?? `properties/${ propertyId }`;
|
|
34
|
+
|
|
35
|
+
const { client, error } = await getGoogleAnalyticsData(credsPayload, { subject });
|
|
36
|
+
|
|
37
|
+
if (error) {
|
|
38
|
+
return error;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return googleApiCall(() => client.properties.getMetadata({
|
|
42
|
+
name: `${ propertyName }/metadata`,
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const funcApiConfig = {
|
|
47
|
+
argsWarden,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
module.exports = {
|
|
51
|
+
googleanalyticsMetadataGet,
|
|
52
|
+
funcApiConfig,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/*
|
|
56
|
+
curl -X POST "http://localhost:8000/googleanalyticsMetadataGet" \
|
|
57
|
+
-H "Content-Type: application/json" \
|
|
58
|
+
-d '{
|
|
59
|
+
"credsPayload": { "credsPath": "google" },
|
|
60
|
+
"propertyIdentifier": { "propertyId": "402247571" }
|
|
61
|
+
}'
|
|
62
|
+
*/
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runRealtimeReport
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, objHasAny } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { getGoogleAnalyticsData, googleApiCall } = require('../google/google.utils');
|
|
6
|
+
|
|
7
|
+
const propertyIdentifierValidator = (propertyIdentifier) => {
|
|
8
|
+
return objHasAny(propertyIdentifier, ['propertyId', 'property']);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const argsWarden = new ArgsWarden([
|
|
12
|
+
['credsPayload', credsValidator],
|
|
13
|
+
['propertyIdentifier', propertyIdentifierValidator],
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const formatDimensions = (dimensions) => {
|
|
17
|
+
if (!dimensions) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return dimensions.map((dim) => (typeof dim === 'string' ? { name: dim } : dim));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const formatMetrics = (metrics) => {
|
|
24
|
+
if (!metrics) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return metrics.map((metric) => (typeof metric === 'string' ? { name: metric } : metric));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const googleanalyticsRealtimeReportRun = async (
|
|
31
|
+
credsPayload,
|
|
32
|
+
propertyIdentifier,
|
|
33
|
+
{
|
|
34
|
+
subject,
|
|
35
|
+
dimensions,
|
|
36
|
+
metrics,
|
|
37
|
+
dimensionFilter,
|
|
38
|
+
metricFilter,
|
|
39
|
+
limit,
|
|
40
|
+
metricAggregations,
|
|
41
|
+
orderBys,
|
|
42
|
+
returnPropertyQuota,
|
|
43
|
+
minuteRanges,
|
|
44
|
+
} = {},
|
|
45
|
+
) => {
|
|
46
|
+
|
|
47
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
48
|
+
credsPayload,
|
|
49
|
+
propertyIdentifier,
|
|
50
|
+
});
|
|
51
|
+
if (rejectResponse) {
|
|
52
|
+
return rejectResponse;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const { propertyId, property } = propertyIdentifier;
|
|
56
|
+
const propertyName = property ?? `properties/${ propertyId }`;
|
|
57
|
+
|
|
58
|
+
const { client, error } = await getGoogleAnalyticsData(credsPayload, { subject });
|
|
59
|
+
|
|
60
|
+
if (error) {
|
|
61
|
+
return error;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const formattedDimensions = formatDimensions(dimensions);
|
|
65
|
+
const formattedMetrics = formatMetrics(metrics);
|
|
66
|
+
|
|
67
|
+
return googleApiCall(() => client.properties.runRealtimeReport({
|
|
68
|
+
property: propertyName,
|
|
69
|
+
requestBody: {
|
|
70
|
+
...formattedDimensions && { dimensions: formattedDimensions },
|
|
71
|
+
...formattedMetrics && { metrics: formattedMetrics },
|
|
72
|
+
...dimensionFilter && { dimensionFilter },
|
|
73
|
+
...metricFilter && { metricFilter },
|
|
74
|
+
...limit !== undefined && { limit },
|
|
75
|
+
...metricAggregations && { metricAggregations },
|
|
76
|
+
...orderBys && { orderBys },
|
|
77
|
+
...returnPropertyQuota !== undefined && { returnPropertyQuota },
|
|
78
|
+
...minuteRanges && { minuteRanges },
|
|
79
|
+
},
|
|
80
|
+
}));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const funcApiConfig = {
|
|
84
|
+
argsWarden,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
googleanalyticsRealtimeReportRun,
|
|
89
|
+
funcApiConfig,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/*
|
|
93
|
+
curl -X POST "http://localhost:8000/googleanalyticsRealtimeReportRun" \
|
|
94
|
+
-H "Content-Type: application/json" \
|
|
95
|
+
-d '{
|
|
96
|
+
"credsPayload": { "credsPath": "google" },
|
|
97
|
+
"propertyIdentifier": { "propertyId": "402247571" },
|
|
98
|
+
"options": {
|
|
99
|
+
"dimensions": ["country"],
|
|
100
|
+
"metrics": ["activeUsers"]
|
|
101
|
+
}
|
|
102
|
+
}'
|
|
103
|
+
*/
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, objHasAny } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { getGoogleAnalyticsData, googleApiCall } = require('../google/google.utils');
|
|
6
|
+
|
|
7
|
+
const propertyIdentifierValidator = (propertyIdentifier) => {
|
|
8
|
+
return objHasAny(propertyIdentifier, ['propertyId', 'property']);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const argsWarden = new ArgsWarden([
|
|
12
|
+
['credsPayload', credsValidator],
|
|
13
|
+
['propertyIdentifier', propertyIdentifierValidator],
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const formatDimensions = (dimensions) => {
|
|
17
|
+
if (!dimensions) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return dimensions.map((dim) => (typeof dim === 'string' ? { name: dim } : dim));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const formatMetrics = (metrics) => {
|
|
24
|
+
if (!metrics) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return metrics.map((metric) => (typeof metric === 'string' ? { name: metric } : metric));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const googleanalyticsReportRun = async (
|
|
31
|
+
credsPayload,
|
|
32
|
+
propertyIdentifier,
|
|
33
|
+
{
|
|
34
|
+
subject,
|
|
35
|
+
dateRanges,
|
|
36
|
+
dimensions,
|
|
37
|
+
metrics,
|
|
38
|
+
dimensionFilter,
|
|
39
|
+
metricFilter,
|
|
40
|
+
offset,
|
|
41
|
+
limit,
|
|
42
|
+
metricAggregations,
|
|
43
|
+
orderBys,
|
|
44
|
+
currencyCode,
|
|
45
|
+
cohortSpec,
|
|
46
|
+
keepEmptyRows,
|
|
47
|
+
returnPropertyQuota,
|
|
48
|
+
comparisons,
|
|
49
|
+
} = {},
|
|
50
|
+
) => {
|
|
51
|
+
|
|
52
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
53
|
+
credsPayload,
|
|
54
|
+
propertyIdentifier,
|
|
55
|
+
});
|
|
56
|
+
if (rejectResponse) {
|
|
57
|
+
return rejectResponse;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const { propertyId, property } = propertyIdentifier;
|
|
61
|
+
const propertyName = property ?? `properties/${ propertyId }`;
|
|
62
|
+
|
|
63
|
+
const { client, error } = await getGoogleAnalyticsData(credsPayload, { subject });
|
|
64
|
+
|
|
65
|
+
if (error) {
|
|
66
|
+
return error;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const formattedDimensions = formatDimensions(dimensions);
|
|
70
|
+
const formattedMetrics = formatMetrics(metrics);
|
|
71
|
+
|
|
72
|
+
return googleApiCall(() => client.properties.runReport({
|
|
73
|
+
property: propertyName,
|
|
74
|
+
requestBody: {
|
|
75
|
+
...dateRanges && { dateRanges },
|
|
76
|
+
...formattedDimensions && { dimensions: formattedDimensions },
|
|
77
|
+
...formattedMetrics && { metrics: formattedMetrics },
|
|
78
|
+
...dimensionFilter && { dimensionFilter },
|
|
79
|
+
...metricFilter && { metricFilter },
|
|
80
|
+
...offset !== undefined && { offset },
|
|
81
|
+
...limit !== undefined && { limit },
|
|
82
|
+
...metricAggregations && { metricAggregations },
|
|
83
|
+
...orderBys && { orderBys },
|
|
84
|
+
...currencyCode && { currencyCode },
|
|
85
|
+
...cohortSpec && { cohortSpec },
|
|
86
|
+
...keepEmptyRows !== undefined && { keepEmptyRows },
|
|
87
|
+
...returnPropertyQuota !== undefined && { returnPropertyQuota },
|
|
88
|
+
...comparisons && { comparisons },
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const funcApiConfig = {
|
|
94
|
+
argsWarden,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
module.exports = {
|
|
98
|
+
googleanalyticsReportRun,
|
|
99
|
+
funcApiConfig,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
curl -X POST "http://localhost:8000/googleanalyticsReportRun" \
|
|
104
|
+
-H "Content-Type: application/json" \
|
|
105
|
+
-d '{
|
|
106
|
+
"credsPayload": { "credsPath": "google" },
|
|
107
|
+
"propertyIdentifier": { "propertyId": "402247571" },
|
|
108
|
+
"options": {
|
|
109
|
+
"dateRanges": [{ "startDate": "30daysAgo", "endDate": "today" }],
|
|
110
|
+
"dimensions": ["date"],
|
|
111
|
+
"metrics": ["activeUsers", "sessions"]
|
|
112
|
+
}
|
|
113
|
+
}'
|
|
114
|
+
*/
|