@foxtware/mineral 0.1.26 → 0.1.28
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 +22 -4
- package/AGENTS.md +17 -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/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/shopifyMetaobjectCreate.js +72 -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 +82 -0
- package/api/tagalys/tagalysSearchSuggestionsGet.js +76 -0
- package/package.json +2 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// https://tagalys.notion.site/Storefront-API-v2-20eacdd38c2080d58d3fd0cf6f24e435
|
|
2
|
+
|
|
3
|
+
const { resolveCreds } = require('../pipelineSteps');
|
|
4
|
+
const {
|
|
5
|
+
FetchClient,
|
|
6
|
+
fetchClientCommonSteps,
|
|
7
|
+
} = require('../utils');
|
|
8
|
+
|
|
9
|
+
// Recursively flattens nested params into Rails/PHP-style bracket query
|
|
10
|
+
// params, e.g. { filter: { color: ['red'] } } -> filter[color][]=red
|
|
11
|
+
// and { filter: { price: { selected_min: 100 } } } -> filter[price][selected_min]=100
|
|
12
|
+
// This also covers the search_suggestions `sections[section_id][*]` shape,
|
|
13
|
+
// e.g. { sections: { products: { count: 6 } } } -> sections[products][count]=6
|
|
14
|
+
const appendParams = (searchParams, key, value) => {
|
|
15
|
+
if (value === undefined || value === null) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
value.forEach((item) => appendParams(searchParams, `${ key }[]`, item));
|
|
20
|
+
} else if (typeof value === 'object') {
|
|
21
|
+
Object.entries(value).forEach(([subKey, subValue]) => {
|
|
22
|
+
appendParams(searchParams, `${ key }[${ subKey }]`, subValue);
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
searchParams.append(key, value);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Request context (country, language, segmentTag) is supported by the
|
|
30
|
+
// collections, search and recommendations endpoints per the docs. Callers
|
|
31
|
+
// pass these via `context` (like `apiVersion` in the shopify client),
|
|
32
|
+
// rather than merging them into `query` themselves, so the shared client
|
|
33
|
+
// applies them consistently across every endpoint that uses it.
|
|
34
|
+
const useRequestContextParams = async (state) => {
|
|
35
|
+
const { requestPayload, context } = state;
|
|
36
|
+
const { country, language, segmentTag } = context;
|
|
37
|
+
|
|
38
|
+
if (!country && !language && !segmentTag) {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
requestPayload: {
|
|
44
|
+
...requestPayload,
|
|
45
|
+
query: {
|
|
46
|
+
...requestPayload.query,
|
|
47
|
+
...(country ? { country } : {}),
|
|
48
|
+
...(language ? { language } : {}),
|
|
49
|
+
...(segmentTag ? { segment_tag: segmentTag } : {}),
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Base URL is region-specific per account (e.g. https://api-r1.tagalys.com),
|
|
56
|
+
// so per AGENTS.md it's resolved from creds rather than tagalys.constants.js.
|
|
57
|
+
const useUrlAndQuery = async (state) => {
|
|
58
|
+
const { requestPayload, context } = state;
|
|
59
|
+
const { creds } = context;
|
|
60
|
+
|
|
61
|
+
const {
|
|
62
|
+
BASE_URL,
|
|
63
|
+
STORE_HANDLE,
|
|
64
|
+
STOREFRONT_API_KEY,
|
|
65
|
+
} = creds;
|
|
66
|
+
|
|
67
|
+
const searchParams = new URLSearchParams();
|
|
68
|
+
searchParams.append('shop_id', `${ STORE_HANDLE }.myshopify.com`);
|
|
69
|
+
if (STOREFRONT_API_KEY) {
|
|
70
|
+
// NOTE: the published docs call this param `storefront_api_key`, but a
|
|
71
|
+
// live request with that name returned `api_key_invalid`. `api_key`
|
|
72
|
+
// is what actually authenticates -- trusting the working behaviour
|
|
73
|
+
// over the doc text here. Revisit if Tagalys ships the documented name.
|
|
74
|
+
searchParams.append('api_key', STOREFRONT_API_KEY);
|
|
75
|
+
}
|
|
76
|
+
Object.entries(requestPayload.query || {}).forEach(([key, value]) => {
|
|
77
|
+
appendParams(searchParams, key, value);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
requestPayload: {
|
|
82
|
+
...requestPayload,
|
|
83
|
+
url: `${ BASE_URL }${ requestPayload.url }?${ searchParams.toString() }`,
|
|
84
|
+
headers: {
|
|
85
|
+
Accept: 'application/json',
|
|
86
|
+
...requestPayload.headers,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// A configured redirect takes precedence over the rest of the response --
|
|
93
|
+
// surface it plainly rather than making callers dig for it. Only /v2/search
|
|
94
|
+
// and /v2/search_suggestions ever populate `redirect_url`, so this is a
|
|
95
|
+
// no-op for every other endpoint on the shared client.
|
|
96
|
+
const useRedirectResponse = async (state) => {
|
|
97
|
+
const { response } = state;
|
|
98
|
+
|
|
99
|
+
if (!response?.ok || !response?.data?.redirect_url) {
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
response: {
|
|
105
|
+
redirected: true,
|
|
106
|
+
redirectUrl: response.data.redirect_url,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const tagalysClient = new FetchClient({
|
|
112
|
+
pipeline: [
|
|
113
|
+
resolveCreds,
|
|
114
|
+
useRequestContextParams,
|
|
115
|
+
useUrlAndQuery,
|
|
116
|
+
'fetch',
|
|
117
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
118
|
+
useRedirectResponse,
|
|
119
|
+
],
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
tagalysClient,
|
|
124
|
+
appendParams,
|
|
125
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// https://tagalys.notion.site/Storefront-API-v2-20eacdd38c2080d58d3fd0cf6f24e435
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, actionSingleOrMultiple, everyIfArray, valueProvided, logDeep } = require('../utils');
|
|
5
|
+
const { tagalysClient } = require('../tagalys/tagalys.utils');
|
|
6
|
+
|
|
7
|
+
// Supported `type` values and their `payload` shape:
|
|
8
|
+
// product_viewed { productId }
|
|
9
|
+
// product_added_to_cart { productId, quantity }
|
|
10
|
+
// checkout_completed { orderId, lineItems: [{ productId, quantity }] }
|
|
11
|
+
// search_results_viewed { query, productIds, page, totalCount, queryHandling?, sortedBy?, filteredBy? }
|
|
12
|
+
// collection_viewed { collectionId, productIds?, page?, totalCount?, sortedBy?, filteredBy? }
|
|
13
|
+
// recommendations_viewed { id, recommendedProductIds, sourceProductIds? (required when `id` is contextual to a product) }
|
|
14
|
+
const eventPayloadValidator = (eventPayload) => {
|
|
15
|
+
return valueProvided(eventPayload?.type)
|
|
16
|
+
&& valueProvided(eventPayload?.payload)
|
|
17
|
+
&& valueProvided(eventPayload?.context?.deviceId)
|
|
18
|
+
&& valueProvided(eventPayload?.context?.visitId);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const argsWarden = new ArgsWarden([
|
|
22
|
+
['credsPayload', credsValidator],
|
|
23
|
+
['eventPayload', (eventPayload) => everyIfArray(eventPayloadValidator, eventPayload)],
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
const tagalysAnalyticsEventSendSingle = async (
|
|
27
|
+
credsPayload,
|
|
28
|
+
eventPayload,
|
|
29
|
+
) => {
|
|
30
|
+
const { type, payload, context } = eventPayload;
|
|
31
|
+
const {
|
|
32
|
+
deviceId,
|
|
33
|
+
visitId,
|
|
34
|
+
userId,
|
|
35
|
+
country,
|
|
36
|
+
language,
|
|
37
|
+
segmentTag,
|
|
38
|
+
apiClientName,
|
|
39
|
+
apiClientVersion,
|
|
40
|
+
} = context;
|
|
41
|
+
|
|
42
|
+
const response = await tagalysClient.fetch({
|
|
43
|
+
context: {
|
|
44
|
+
credsPayload,
|
|
45
|
+
},
|
|
46
|
+
requestPayload: {
|
|
47
|
+
url: '/v2/analytics/events',
|
|
48
|
+
method: 'post',
|
|
49
|
+
body: {
|
|
50
|
+
type,
|
|
51
|
+
payload,
|
|
52
|
+
context: {
|
|
53
|
+
device_id: deviceId,
|
|
54
|
+
visit_id: visitId,
|
|
55
|
+
...(userId ? { user_id: userId } : {}),
|
|
56
|
+
...(country ? { country } : {}),
|
|
57
|
+
...(language ? { language } : {}),
|
|
58
|
+
...(segmentTag ? { segment_tag: segmentTag } : {}),
|
|
59
|
+
...((apiClientName || apiClientVersion) ? {
|
|
60
|
+
api_client: {
|
|
61
|
+
...(apiClientName ? { name: apiClientName } : {}),
|
|
62
|
+
...(apiClientVersion ? { version: apiClientVersion } : {}),
|
|
63
|
+
},
|
|
64
|
+
} : {}),
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const { ok, error } = response;
|
|
71
|
+
if (!ok) {
|
|
72
|
+
logDeep({ error });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return response;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const tagalysAnalyticsEventSend = async (
|
|
79
|
+
credsPayload,
|
|
80
|
+
eventPayload,
|
|
81
|
+
{
|
|
82
|
+
queueRunOptions,
|
|
83
|
+
} = {},
|
|
84
|
+
) => {
|
|
85
|
+
|
|
86
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
87
|
+
credsPayload,
|
|
88
|
+
eventPayload,
|
|
89
|
+
});
|
|
90
|
+
if (rejectResponse) {
|
|
91
|
+
return rejectResponse;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return actionSingleOrMultiple(
|
|
95
|
+
eventPayload,
|
|
96
|
+
tagalysAnalyticsEventSendSingle,
|
|
97
|
+
(eventPayloadItem) => ({
|
|
98
|
+
args: [credsPayload, eventPayloadItem],
|
|
99
|
+
}),
|
|
100
|
+
{
|
|
101
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
102
|
+
},
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const funcApiConfig = {
|
|
107
|
+
argsWarden,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
module.exports = {
|
|
111
|
+
tagalysAnalyticsEventSend,
|
|
112
|
+
funcApiConfig,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/*
|
|
116
|
+
curl -X POST "http://localhost:8000/tagalysAnalyticsEventSend" \
|
|
117
|
+
-d '{
|
|
118
|
+
"credsPayload": { "credsPath": "tagalys.au" },
|
|
119
|
+
"eventPayload": {
|
|
120
|
+
"type": "product_viewed",
|
|
121
|
+
"payload": { "productId": "7286848028804" },
|
|
122
|
+
"context": { "deviceId": "d123", "visitId": "v123" }
|
|
123
|
+
}
|
|
124
|
+
}'
|
|
125
|
+
*/
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// https://tagalys.notion.site/Storefront-API-v2-20eacdd38c2080d58d3fd0cf6f24e435
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, actionSingleOrMultiple, logDeep } = require('../utils');
|
|
5
|
+
const { DEFAULT_INCLUDE } = require('../tagalys/tagalys.constants');
|
|
6
|
+
const { tagalysClient } = require('../tagalys/tagalys.utils');
|
|
7
|
+
|
|
8
|
+
const argsWarden = new ArgsWarden([
|
|
9
|
+
['credsPayload', credsValidator],
|
|
10
|
+
['collectionId'],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const tagalysCollectionGetSingle = async (
|
|
14
|
+
credsPayload,
|
|
15
|
+
collectionId,
|
|
16
|
+
{
|
|
17
|
+
include = DEFAULT_INCLUDE, // e.g. ['products', 'filters', 'sort_options', 'total_count']
|
|
18
|
+
filter, // e.g. { color: ['red'], price: { selected_min: 100, selected_max: 200 } }
|
|
19
|
+
scope, // e.g. { gender: ['female'] }
|
|
20
|
+
sort, // e.g. 'price-asc'
|
|
21
|
+
page,
|
|
22
|
+
perPage,
|
|
23
|
+
bannerPositions, // { source: 'dashboard' | 'custom' | 'none', fixed: [4, 6], repeating: { every: 16, at: [5] } }
|
|
24
|
+
country,
|
|
25
|
+
language,
|
|
26
|
+
segmentTag,
|
|
27
|
+
} = {},
|
|
28
|
+
) => {
|
|
29
|
+
const response = await tagalysClient.fetch({
|
|
30
|
+
context: {
|
|
31
|
+
credsPayload,
|
|
32
|
+
country,
|
|
33
|
+
language,
|
|
34
|
+
segmentTag,
|
|
35
|
+
},
|
|
36
|
+
requestPayload: {
|
|
37
|
+
url: `/v2/collections/${ collectionId }`,
|
|
38
|
+
method: 'get',
|
|
39
|
+
query: {
|
|
40
|
+
include,
|
|
41
|
+
...(filter ? { filter } : {}),
|
|
42
|
+
...(scope ? { scope } : {}),
|
|
43
|
+
...(sort ? { sort } : {}),
|
|
44
|
+
...(page ? { page } : {}),
|
|
45
|
+
...(perPage ? { per_page: perPage } : {}),
|
|
46
|
+
...(bannerPositions ? { banner_positions: bannerPositions } : {}),
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const { ok, error } = response;
|
|
52
|
+
if (!ok) {
|
|
53
|
+
logDeep({ error });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return response;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const tagalysCollectionGet = async (
|
|
60
|
+
credsPayload,
|
|
61
|
+
collectionId,
|
|
62
|
+
{
|
|
63
|
+
queueRunOptions,
|
|
64
|
+
...options
|
|
65
|
+
} = {},
|
|
66
|
+
) => {
|
|
67
|
+
|
|
68
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
69
|
+
credsPayload,
|
|
70
|
+
collectionId,
|
|
71
|
+
});
|
|
72
|
+
if (rejectResponse) {
|
|
73
|
+
return rejectResponse;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return actionSingleOrMultiple(
|
|
77
|
+
collectionId,
|
|
78
|
+
tagalysCollectionGetSingle,
|
|
79
|
+
(collectionIdItem) => ({
|
|
80
|
+
args: [credsPayload, collectionIdItem, options],
|
|
81
|
+
}),
|
|
82
|
+
{
|
|
83
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const funcApiConfig = {
|
|
89
|
+
argsWarden,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
tagalysCollectionGet,
|
|
94
|
+
funcApiConfig,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/*
|
|
98
|
+
curl -X POST "http://localhost:8000/tagalysCollectionGet" \
|
|
99
|
+
-d '{ "credsPayload": { "credsPath": "tagalys.au" }, "collectionId": "123456789" }'
|
|
100
|
+
*/
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// https://tagalys.notion.site/Storefront-API-v2-20eacdd38c2080d58d3fd0cf6f24e435
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, logDeep } = require('../utils');
|
|
5
|
+
const { tagalysClient } = require('../tagalys/tagalys.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
// Returns at most 10 queries. When the store is configured for country-based
|
|
12
|
+
// availability, `country` filters the response (see the docs).
|
|
13
|
+
const tagalysPopularSearchesGet = async (
|
|
14
|
+
credsPayload,
|
|
15
|
+
{
|
|
16
|
+
country,
|
|
17
|
+
} = {},
|
|
18
|
+
) => {
|
|
19
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
20
|
+
credsPayload,
|
|
21
|
+
});
|
|
22
|
+
if (rejectResponse) {
|
|
23
|
+
return rejectResponse;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const response = await tagalysClient.fetch({
|
|
27
|
+
context: {
|
|
28
|
+
credsPayload,
|
|
29
|
+
},
|
|
30
|
+
requestPayload: {
|
|
31
|
+
url: '/v2/popular_searches',
|
|
32
|
+
method: 'get',
|
|
33
|
+
query: {
|
|
34
|
+
...(country ? { country } : {}),
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const { ok, data, error } = response;
|
|
40
|
+
if (!ok) {
|
|
41
|
+
logDeep({ error });
|
|
42
|
+
return { ok: false, error };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return { ok: true, data };
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const funcApiConfig = {
|
|
49
|
+
argsWarden,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
module.exports = {
|
|
53
|
+
tagalysPopularSearchesGet,
|
|
54
|
+
funcApiConfig,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
curl -X POST "http://localhost:8000/tagalysPopularSearchesGet" \
|
|
59
|
+
-d '{ "credsPayload": { "credsPath": "tagalys.au" } }'
|
|
60
|
+
*/
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// https://tagalys.notion.site/Storefront-API-v2-20eacdd38c2080d58d3fd0cf6f24e435
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, actionSingleOrMultiple, ensureArray, logDeep } = require('../utils');
|
|
5
|
+
const { MAX_RECOMMENDATION_PRODUCT_IDS } = require('../tagalys/tagalys.constants');
|
|
6
|
+
const { tagalysClient } = require('../tagalys/tagalys.utils');
|
|
7
|
+
|
|
8
|
+
// System-defined ids: bought_also_bought, viewed_also_viewed, atc_also_atc,
|
|
9
|
+
// recently_viewed, personalized. Custom recommendations use a dashboard slug
|
|
10
|
+
// (e.g. 8d72jc02jd719ddc6hw0).
|
|
11
|
+
const argsWarden = new ArgsWarden([
|
|
12
|
+
['credsPayload', credsValidator],
|
|
13
|
+
['recommendationId'],
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const tagalysRecommendationGetSingle = async (
|
|
17
|
+
credsPayload,
|
|
18
|
+
recommendationId,
|
|
19
|
+
{
|
|
20
|
+
productIds, // up to 3, for product-contextual recommendations
|
|
21
|
+
count,
|
|
22
|
+
|
|
23
|
+
// personalized / recently_viewed: either deviceId or userId is required
|
|
24
|
+
deviceId,
|
|
25
|
+
userId,
|
|
26
|
+
|
|
27
|
+
fallbackRecommendationId, // personalized only
|
|
28
|
+
visitId, // recently_viewed only
|
|
29
|
+
|
|
30
|
+
country,
|
|
31
|
+
language,
|
|
32
|
+
segmentTag,
|
|
33
|
+
} = {},
|
|
34
|
+
) => {
|
|
35
|
+
const response = await tagalysClient.fetch({
|
|
36
|
+
context: {
|
|
37
|
+
credsPayload,
|
|
38
|
+
country,
|
|
39
|
+
language,
|
|
40
|
+
segmentTag,
|
|
41
|
+
},
|
|
42
|
+
requestPayload: {
|
|
43
|
+
url: `/v2/recommendations/${ recommendationId }`,
|
|
44
|
+
method: 'get',
|
|
45
|
+
query: {
|
|
46
|
+
...(productIds ? { product_ids: ensureArray(productIds).slice(0, MAX_RECOMMENDATION_PRODUCT_IDS) } : {}),
|
|
47
|
+
...(count ? { count } : {}),
|
|
48
|
+
...(deviceId ? { device_id: deviceId } : {}),
|
|
49
|
+
...(userId ? { user_id: userId } : {}),
|
|
50
|
+
...(fallbackRecommendationId ? { fallback_recommendation_id: fallbackRecommendationId } : {}),
|
|
51
|
+
...(visitId ? { visit_id: visitId } : {}),
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const { ok, error } = response;
|
|
57
|
+
if (!ok) {
|
|
58
|
+
logDeep({ error });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return response;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const tagalysRecommendationGet = async (
|
|
65
|
+
credsPayload,
|
|
66
|
+
recommendationId,
|
|
67
|
+
{
|
|
68
|
+
queueRunOptions,
|
|
69
|
+
...options
|
|
70
|
+
} = {},
|
|
71
|
+
) => {
|
|
72
|
+
|
|
73
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
74
|
+
credsPayload,
|
|
75
|
+
recommendationId,
|
|
76
|
+
});
|
|
77
|
+
if (rejectResponse) {
|
|
78
|
+
return rejectResponse;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return actionSingleOrMultiple(
|
|
82
|
+
recommendationId,
|
|
83
|
+
tagalysRecommendationGetSingle,
|
|
84
|
+
(recommendationIdItem) => ({
|
|
85
|
+
args: [credsPayload, recommendationIdItem, options],
|
|
86
|
+
}),
|
|
87
|
+
{
|
|
88
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
89
|
+
},
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const funcApiConfig = {
|
|
94
|
+
argsWarden,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
module.exports = {
|
|
98
|
+
tagalysRecommendationGet,
|
|
99
|
+
funcApiConfig,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
curl -X POST "http://localhost:8000/tagalysRecommendationGet" \
|
|
104
|
+
-d '{
|
|
105
|
+
"credsPayload": { "credsPath": "tagalys.au" },
|
|
106
|
+
"recommendationId": "bought_also_bought",
|
|
107
|
+
"options": { "productIds": ["1234567890"], "count": 10 }
|
|
108
|
+
}'
|
|
109
|
+
*/
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// https://tagalys.notion.site/Storefront-API-v2-20eacdd38c2080d58d3fd0cf6f24e435
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, logDeep } = require('../utils');
|
|
5
|
+
const { DEFAULT_INCLUDE } = require('../tagalys/tagalys.constants');
|
|
6
|
+
const { tagalysClient } = require('../tagalys/tagalys.utils');
|
|
7
|
+
|
|
8
|
+
const argsWarden = new ArgsWarden([
|
|
9
|
+
['credsPayload', credsValidator],
|
|
10
|
+
['query'],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const tagalysSearch = async (
|
|
14
|
+
credsPayload,
|
|
15
|
+
query,
|
|
16
|
+
{
|
|
17
|
+
include = DEFAULT_INCLUDE, // e.g. ['products', 'filters', 'sort_options', 'total_count']
|
|
18
|
+
filter, // e.g. { color: ['red'], price: { selected_min: 100, selected_max: 200 } }
|
|
19
|
+
scope, // e.g. { gender: ['female'] }
|
|
20
|
+
sort, // e.g. 'price-asc'
|
|
21
|
+
page,
|
|
22
|
+
perPage,
|
|
23
|
+
country,
|
|
24
|
+
language,
|
|
25
|
+
segmentTag,
|
|
26
|
+
} = {},
|
|
27
|
+
) => {
|
|
28
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
29
|
+
credsPayload,
|
|
30
|
+
query,
|
|
31
|
+
});
|
|
32
|
+
if (rejectResponse) {
|
|
33
|
+
return rejectResponse;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// A search can be both redirected and spelling-corrected in the same
|
|
37
|
+
// response -- redirected/redirectUrl and data (query_handling,
|
|
38
|
+
// original_query, etc.) both land on the response, see
|
|
39
|
+
// tagalys.utils.js#useRedirectResponse.
|
|
40
|
+
const response = await tagalysClient.fetch({
|
|
41
|
+
context: {
|
|
42
|
+
credsPayload,
|
|
43
|
+
country,
|
|
44
|
+
language,
|
|
45
|
+
segmentTag,
|
|
46
|
+
},
|
|
47
|
+
requestPayload: {
|
|
48
|
+
url: '/v2/search',
|
|
49
|
+
method: 'get',
|
|
50
|
+
query: {
|
|
51
|
+
query,
|
|
52
|
+
include,
|
|
53
|
+
...(filter ? { filter } : {}),
|
|
54
|
+
...(scope ? { scope } : {}),
|
|
55
|
+
...(sort ? { sort } : {}),
|
|
56
|
+
...(page ? { page } : {}),
|
|
57
|
+
...(perPage ? { per_page: perPage } : {}),
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const { ok, error } = response;
|
|
63
|
+
if (!ok) {
|
|
64
|
+
logDeep({ error });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return response;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const funcApiConfig = {
|
|
71
|
+
argsWarden,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
tagalysSearch,
|
|
76
|
+
funcApiConfig,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
curl -X POST "http://localhost:8000/tagalysSearch" \
|
|
81
|
+
-d '{ "credsPayload": { "credsPath": "tagalys.store" }, "query": "gold" }'
|
|
82
|
+
*/
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// https://tagalys.notion.site/Storefront-API-v2-20eacdd38c2080d58d3fd0cf6f24e435
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, logDeep, valueProvided } = require('../utils');
|
|
5
|
+
const { tagalysClient } = require('../tagalys/tagalys.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['query'],
|
|
10
|
+
['sections', (sections) => valueProvided(sections) && Object.keys(sections).length > 0],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
// `sections` is an object keyed by section_id, e.g.:
|
|
14
|
+
// {
|
|
15
|
+
// products: { count: 6, include: ['items', 'total_count'], scope: { gender: ['female'] } },
|
|
16
|
+
// collections: { count: 4 },
|
|
17
|
+
// searches: { count: 4 },
|
|
18
|
+
// }
|
|
19
|
+
// section_ids and their available options are configured per account by Tagalys.
|
|
20
|
+
const tagalysSearchSuggestionsGet = async (
|
|
21
|
+
credsPayload,
|
|
22
|
+
query,
|
|
23
|
+
sections,
|
|
24
|
+
) => {
|
|
25
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
26
|
+
credsPayload,
|
|
27
|
+
query,
|
|
28
|
+
sections,
|
|
29
|
+
});
|
|
30
|
+
if (rejectResponse) {
|
|
31
|
+
return rejectResponse;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// redirected/redirectUrl land on the response via tagalys.utils.js#useRedirectResponse
|
|
35
|
+
const response = await tagalysClient.fetch({
|
|
36
|
+
context: {
|
|
37
|
+
credsPayload,
|
|
38
|
+
},
|
|
39
|
+
requestPayload: {
|
|
40
|
+
url: '/v2/search_suggestions',
|
|
41
|
+
method: 'get',
|
|
42
|
+
query: {
|
|
43
|
+
query,
|
|
44
|
+
sections,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const { ok, error } = response;
|
|
50
|
+
if (!ok) {
|
|
51
|
+
logDeep({ error });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return response;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const funcApiConfig = {
|
|
58
|
+
argsWarden,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
tagalysSearchSuggestionsGet,
|
|
63
|
+
funcApiConfig,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
curl -X POST "http://localhost:8000/tagalysSearchSuggestionsGet" \
|
|
68
|
+
-d '{
|
|
69
|
+
"credsPayload": { "credsPath": "tagalys.au" },
|
|
70
|
+
"query": "shi",
|
|
71
|
+
"sections": {
|
|
72
|
+
"products": { "count": 6 },
|
|
73
|
+
"collections": { "count": 4 }
|
|
74
|
+
}
|
|
75
|
+
}'
|
|
76
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foxtware/mineral",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"bin": {
|
|
5
5
|
"mineral": "bin/mineral.js"
|
|
6
6
|
},
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"spin_off": "node _build_scripts/spinOff.js",
|
|
18
18
|
"serve": "PORT=8100 node server.js",
|
|
19
19
|
"start": "node server.js",
|
|
20
|
+
"zip": "sh ../shell_scripts/zip.sh",
|
|
20
21
|
"npm:publish": "node _build_scripts/publish.js"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|