oc-browser-relay 1.0.22 → 1.0.25

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.
@@ -23043,25 +23043,24 @@ function formatDateLocal(date) {
23043
23043
  const day = String(date.getDate()).padStart(2, "0");
23044
23044
  return `${year}-${month}-${day}`;
23045
23045
  }
23046
- function buildPreviousAvailableDailyDateRange(now = /* @__PURE__ */ new Date()) {
23047
- const target = new Date(now);
23048
- const daysBack = now.getHours() < 6 ? 2 : 1;
23049
- target.setDate(target.getDate() - daysBack);
23050
- const date = formatDateLocal(target);
23051
- return `${date}|${date}`;
23046
+ function shiftDate(d, days) {
23047
+ const r = new Date(d);
23048
+ r.setDate(r.getDate() + days);
23049
+ return r;
23052
23050
  }
23053
- function buildEffectiveDailyPeriod(now = /* @__PURE__ */ new Date()) {
23054
- const daysBack = now.getHours() < 6 ? 2 : 1;
23055
- const target = new Date(now);
23056
- target.setDate(target.getDate() - daysBack);
23057
- const date = formatDateLocal(target);
23058
- return {
23059
- effectiveMetricPeriodLabel: daysBack === 2 ? "\u524D\u5929" : "\u6628\u5929",
23060
- effectiveDateRange: `${date}|${date}`
23061
- };
23051
+ function diffDays(a, b) {
23052
+ return Math.round((b.getTime() - a.getTime()) / 864e5);
23062
23053
  }
23063
- function normalizeMetricPeriodLabel(value) {
23064
- return typeof value === "string" ? value.replace(/\s+/g, "") : "";
23054
+ function buildCompareRange(currentStart, currentEnd) {
23055
+ const days = diffDays(currentStart, currentEnd) + 1;
23056
+ const compareEnd = shiftDate(currentStart, -1);
23057
+ const compareStart = shiftDate(compareEnd, -(days - 1));
23058
+ return `${formatDateLocal(currentStart)}|${formatDateLocal(currentEnd)},${formatDateLocal(compareStart)}|${formatDateLocal(compareEnd)}`;
23059
+ }
23060
+ function buildDayRange(now = /* @__PURE__ */ new Date()) {
23061
+ const daysBack = now.getHours() < 6 ? 2 : 1;
23062
+ const d = shiftDate(now, -daysBack);
23063
+ return { dateRange: buildCompareRange(d, d), label: daysBack === 2 ? "\u524D\u5929" : "\u6628\u5929" };
23065
23064
  }
23066
23065
  function truncateByCharacters(value, maxLength) {
23067
23066
  return Array.from(value).slice(0, maxLength).join("");
@@ -23191,46 +23190,21 @@ var TemplateExecutor = class _TemplateExecutor {
23191
23190
  }
23192
23191
  }
23193
23192
  applySycmLiveMetricDerivedDefaults(template, rawInput, hydrated) {
23194
- const isSycmLiveMetricsTemplate = template.siteId === "sycm_taobao" && template.taskType === "browser_action" && (template.optionalFields ?? []).some((field) => field.name === "metricPeriodLabel");
23193
+ const isSycmLiveMetricsTemplate = template.siteId === "sycm_taobao" && template.taskType === "browser_action" && (template.optionalFields ?? []).some((field) => field.name === "requestDateType");
23195
23194
  if (!isSycmLiveMetricsTemplate) {
23196
23195
  return;
23197
23196
  }
23198
- const normalizedLabel = normalizeMetricPeriodLabel(hydrated.metricPeriodLabel);
23199
- const hasExplicitDateType = rawInput.requestDateType !== void 0;
23200
- const hasExplicitDateRange = rawInput.requestDateRange !== void 0;
23201
- const hasExplicitInvokeDirectly = rawInput.invokeDirectly !== void 0;
23202
- const isYesterdayLabel = normalizedLabel === "\u6628\u5929";
23203
- if (!hasExplicitDateType) {
23204
- switch (normalizedLabel) {
23205
- case "\u6628\u5929":
23206
- case "\u65E5":
23207
- hydrated.requestDateType = "day";
23208
- break;
23209
- case "\u5468":
23210
- hydrated.requestDateType = "week";
23211
- break;
23212
- case "\u6708":
23213
- hydrated.requestDateType = "month";
23214
- break;
23215
- case "\u5B9E\u65F6":
23216
- hydrated.requestDateType = "today";
23217
- break;
23218
- default:
23219
- break;
23220
- }
23221
- }
23222
- if (!hasExplicitDateRange) {
23223
- hydrated.requestDateRange = isYesterdayLabel ? buildPreviousAvailableDailyDateRange() : "";
23197
+ if (rawInput.requestDateType !== void 0) {
23198
+ return;
23224
23199
  }
23225
- if (isYesterdayLabel) {
23226
- const effectiveDailyPeriod = buildEffectiveDailyPeriod();
23227
- hydrated.effectiveMetricPeriodLabel = effectiveDailyPeriod.effectiveMetricPeriodLabel;
23228
- hydrated.effectiveDateRange = effectiveDailyPeriod.effectiveDateRange;
23229
- if ((/* @__PURE__ */ new Date()).getHours() < 6) {
23230
- hydrated.invokeDirectly = true;
23231
- } else if (!hasExplicitInvokeDirectly && hydrated.invokeDirectly === void 0) {
23232
- hydrated.invokeDirectly = false;
23233
- }
23200
+ if (!hydrated.requestDateRange) {
23201
+ const r = buildDayRange();
23202
+ hydrated.requestDateType = "compareRange";
23203
+ hydrated.requestDateRange = r.dateRange;
23204
+ hydrated.effectiveMetricPeriodLabel = r.label;
23205
+ hydrated.effectiveDateRange = r.dateRange.split(",")[0];
23206
+ } else if (!hydrated.requestDateType) {
23207
+ hydrated.requestDateType = "compareRange";
23234
23208
  }
23235
23209
  }
23236
23210
  mergeXiaohongshuTopicsIntoContent(template, data) {
@@ -221,6 +221,71 @@
221
221
  "responsePath": "data.taskId",
222
222
  "metaPath": "data"
223
223
  },
224
+ "create_adgroup_download_task": {
225
+ "method": "POST",
226
+ "url": "https://one.alimama.com/report/createDownLoadTask.json",
227
+ "query": {
228
+ "csrfId": "{{payload.csrfId}}",
229
+ "bizCode": "universalBP"
230
+ },
231
+ "headers": {
232
+ "Content-Type": "application/json"
233
+ },
234
+ "body": {
235
+ "excelName": "{{payload.excelName}}",
236
+ "pageSize": 20,
237
+ "offset": 0,
238
+ "havingList": [],
239
+ "endTime": "{{payload.endTime}}",
240
+ "from": "pcBaseReport",
241
+ "unifyType": "zhai",
242
+ "effectEqual": 15,
243
+ "startTime": "{{payload.startTime}}",
244
+ "splitType": "{{payload.splitType}}",
245
+ "bizCodeIn": [
246
+ "onebpSearch"
247
+ ],
248
+ "queryFieldIn": [
249
+ "adPv",
250
+ "click",
251
+ "charge",
252
+ "ctr",
253
+ "ecpc",
254
+ "alipayInshopAmt",
255
+ "alipayInshopNum",
256
+ "cvr",
257
+ "cartInshopNum",
258
+ "itemColInshopNum",
259
+ "shopColDirNum",
260
+ "colNum",
261
+ "itemColInshopCost"
262
+ ],
263
+ "vsType": "{{payload.vsType}}",
264
+ "vsTime": "{{payload.vsTime}}",
265
+ "searchValue": "{{payload.searchValue}}",
266
+ "searchKey": "strategyCampaignIdOrName",
267
+ "queryDomains": [
268
+ "adgroup",
269
+ "date",
270
+ "campaign"
271
+ ],
272
+ "adzonePkgIdIn": [
273
+ "114786650498",
274
+ "114790550288"
275
+ ],
276
+ "fieldType": "all",
277
+ "rptType": "adgroup",
278
+ "parentAdcName": "report_frame_adgroup",
279
+ "byPage": false,
280
+ "fromRealTime": false,
281
+ "source": "async_dowdload",
282
+ "csrfId": "{{payload.csrfId}}",
283
+ "bizCode": "universalBP",
284
+ "loginPointId": "{{payload.loginPointId}}"
285
+ },
286
+ "responsePath": "data.taskId",
287
+ "metaPath": "data"
288
+ },
224
289
  "get_download_url": {
225
290
  "method": "GET",
226
291
  "url": "https://bpcommon.alimama.com/commonapi/report/async/getDownloadUrl.json",
@@ -156,6 +156,7 @@
156
156
  "apiSources": {
157
157
  "live_metrics_overview": {
158
158
  "method": "GET",
159
+ "removeHeaders": ["Bx-ua"],
159
160
  "urlVariants": [
160
161
  {
161
162
  "whenPath": "payload.dateType",
@@ -182,6 +183,7 @@
182
183
  },
183
184
  "live_metrics_trend": {
184
185
  "method": "GET",
186
+ "removeHeaders": ["Bx-ua"],
185
187
  "urlVariants": [
186
188
  {
187
189
  "whenPath": "payload.dateType",
@@ -205,6 +207,41 @@
205
207
  "responsePath": "content.data.data",
206
208
  "metaPath": "content.data"
207
209
  },
210
+ "live_metrics_custom_overview": {
211
+ "method": "GET",
212
+ "removeHeaders": ["Bx-ua"],
213
+ "url": "https://sycm.taobao.com/portal/long/period/nodistinct/coreIndex/getShopMainIndexes/v3.json",
214
+ "query": {
215
+ "needCycleCrc": "true",
216
+ "dateType": "compareRange",
217
+ "dateRange": "{{payload.dateRange}}",
218
+ "device": "{{payload.device}}",
219
+ "_": "{{runtime.timestamp}}",
220
+ "token": "{{session.token}}"
221
+ },
222
+ "headers": {
223
+ "sycm-referer": "/portal/home.htm"
224
+ },
225
+ "responsePath": "content.data.data",
226
+ "metaPath": "content.data"
227
+ },
228
+ "live_metrics_custom_trend": {
229
+ "method": "GET",
230
+ "removeHeaders": ["Bx-ua"],
231
+ "url": "https://sycm.taobao.com/portal/long/period/nodistinct/coreIndex/new/trend/v3.json",
232
+ "query": {
233
+ "dateType": "compareRange",
234
+ "dateRange": "{{payload.dateRange}}",
235
+ "device": "{{payload.device}}",
236
+ "_": "{{runtime.timestamp}}",
237
+ "token": "{{session.token}}"
238
+ },
239
+ "headers": {
240
+ "sycm-referer": "/portal/home.htm"
241
+ },
242
+ "responsePath": "content.data.data",
243
+ "metaPath": "content.data"
244
+ },
208
245
  "growth_factor_overview": {
209
246
  "method": "GET",
210
247
  "url": "https://sycm.taobao.com/portal/board/grow/factor/overview.json",
@@ -73,20 +73,30 @@
73
73
  "label": "执行搜索",
74
74
  "kind": "submit",
75
75
  "locators": [
76
+ {
77
+ "kind": "xpath",
78
+ "value": "//*[@id='global']/div[1]/header/div[1]/div/div[4]",
79
+ "priority": 1
80
+ },
81
+ {
82
+ "kind": "css",
83
+ "value": "#global > div.header-container > header > div.input-box > div > div:nth-child(4)",
84
+ "priority": 2
85
+ },
76
86
  {
77
87
  "kind": "css",
78
88
  "value": ".input-box .input-button .search-icon",
79
- "priority": 1
89
+ "priority": 3
80
90
  },
81
91
  {
82
92
  "kind": "css",
83
93
  "value": ".input-box .search-icon",
84
- "priority": 2
94
+ "priority": 4
85
95
  },
86
96
  {
87
97
  "kind": "css",
88
98
  "value": ".input-box .input-button",
89
- "priority": 3
99
+ "priority": 5
90
100
  }
91
101
  ],
92
102
  "preconditions": [
@@ -200,20 +200,30 @@
200
200
  "label": "执行搜索",
201
201
  "kind": "submit",
202
202
  "locators": [
203
+ {
204
+ "kind": "xpath",
205
+ "value": "//*[@id='global']/div[1]/header/div[1]/div/div[4]",
206
+ "priority": 1
207
+ },
208
+ {
209
+ "kind": "css",
210
+ "value": "#global > div.header-container > header > div.input-box > div > div:nth-child(4)",
211
+ "priority": 2
212
+ },
203
213
  {
204
214
  "kind": "css",
205
215
  "value": ".input-box .input-button .search-icon",
206
- "priority": 1
216
+ "priority": 3
207
217
  },
208
218
  {
209
219
  "kind": "css",
210
220
  "value": ".input-box .search-icon",
211
- "priority": 2
221
+ "priority": 4
212
222
  },
213
223
  {
214
224
  "kind": "css",
215
225
  "value": ".input-box .input-button",
216
- "priority": 3
226
+ "priority": 5
217
227
  }
218
228
  ],
219
229
  "preconditions": [
@@ -0,0 +1,166 @@
1
+ {
2
+ "siteId": "alimama_report",
3
+ "taskType": "download_adgroup_report",
4
+ "platform": "taobao",
5
+ "name": "下载阿里妈妈单元报表",
6
+ "description": "打开阿里妈妈账户报表页,捕获鉴权信息,创建单元报表异步下载任务,轮询下载链接并将文件回传 relay 存储。",
7
+ "requiredFields": [
8
+ {
9
+ "name": "startTime",
10
+ "type": "string",
11
+ "description": "报表开始日期,格式 YYYY-MM-DD"
12
+ },
13
+ {
14
+ "name": "endTime",
15
+ "type": "string",
16
+ "description": "报表结束日期,格式 YYYY-MM-DD"
17
+ }
18
+ ],
19
+ "optionalFields": [
20
+ {
21
+ "name": "splitType",
22
+ "type": "string",
23
+ "description": "报表时间粒度,支持 sum/day/week/month/calendarmonth",
24
+ "default": "sum"
25
+ },
26
+ {
27
+ "name": "returnHostPatterns",
28
+ "type": "array",
29
+ "description": "任务结束后若存在匹配这些 host 或 URL 片段的标签页,则切回该标签页"
30
+ }
31
+ ],
32
+ "nodes": [
33
+ {
34
+ "nodeId": "s1",
35
+ "name": "open_alimama_report",
36
+ "goal": "打开阿里妈妈账户报表页并预抓鉴权接口",
37
+ "tool": "open_tab",
38
+ "args": {
39
+ "url": "https://one.alimama.com/index.html#!/report/account?rptType=account",
40
+ "captureNetwork": {
41
+ "capturePlanId": "auth_info"
42
+ }
43
+ }
44
+ },
45
+ {
46
+ "nodeId": "s2",
47
+ "name": "validate_alimama_report",
48
+ "goal": "校验当前页面已进入账户报表页",
49
+ "tool": "validate_page",
50
+ "args": {}
51
+ },
52
+ {
53
+ "nodeId": "s3",
54
+ "name": "collect_auth_info",
55
+ "goal": "从 checkAccess 响应中提取 csrfId 和 loginPointId",
56
+ "tool": "collect_structured_data",
57
+ "args": {
58
+ "extractor": "download_auth_info",
59
+ "sourceNodeId": "s1"
60
+ },
61
+ "storeAs": "authInfo"
62
+ },
63
+ {
64
+ "nodeId": "s4",
65
+ "name": "show_download_activity",
66
+ "goal": "在页面顶部展示独立提示,标记当前正在准备单元报表下载",
67
+ "tool": "present_page_activity",
68
+ "args": {
69
+ "mode": "start",
70
+ "message": "正在提交报表下载任务",
71
+ "style": "info",
72
+ "profile": "none"
73
+ }
74
+ },
75
+ {
76
+ "nodeId": "s5",
77
+ "name": "create_adgroup_download_task",
78
+ "goal": "创建单元报表异步下载任务",
79
+ "tool": "invoke_page_request",
80
+ "args": {
81
+ "sourceId": "create_adgroup_download_task",
82
+ "payload": {
83
+ "startTime": "{{data.startTime}}",
84
+ "endTime": "{{data.endTime}}",
85
+ "vsTime": "{{data.endTime}}",
86
+ "vsType": "week",
87
+ "searchValue": "",
88
+ "splitType": "{{data.splitType}}",
89
+ "excelName": "单元报表_{{data.startTime}}_{{data.endTime}}"
90
+ }
91
+ },
92
+ "fromContext": {
93
+ "payload.csrfId": "outputs.authInfo.data.csrfId",
94
+ "payload.loginPointId": "outputs.authInfo.data.loginPointId"
95
+ },
96
+ "storeAs": "downloadTask"
97
+ },
98
+ {
99
+ "nodeId": "s6",
100
+ "name": "update_download_activity",
101
+ "goal": "更新页面提示为等待报表生成完成",
102
+ "tool": "present_page_activity",
103
+ "args": {
104
+ "mode": "start",
105
+ "message": "正在等待报表生成完成",
106
+ "style": "info",
107
+ "profile": "none"
108
+ }
109
+ },
110
+ {
111
+ "nodeId": "s7",
112
+ "name": "poll_download_url",
113
+ "goal": "等待下载任务生成链接并轮询拿到下载地址",
114
+ "tool": "invoke_page_request",
115
+ "args": {
116
+ "sourceId": "get_download_url",
117
+ "payload": {},
118
+ "polling": {
119
+ "initialDelayMs": 30000,
120
+ "intervalMs": 5000,
121
+ "timeoutMs": 120000,
122
+ "maxAttempts": 25
123
+ }
124
+ },
125
+ "fromContext": {
126
+ "payload.taskId": "outputs.downloadTask.response.data",
127
+ "payload.csrfId": "outputs.authInfo.data.csrfId",
128
+ "payload.loginPointId": "outputs.authInfo.data.loginPointId"
129
+ },
130
+ "storeAs": "downloadLink"
131
+ },
132
+ {
133
+ "nodeId": "s8",
134
+ "name": "download_report_file",
135
+ "goal": "拉取下载链接并把文件内容回传给 relay 存储",
136
+ "tool": "download_page_file",
137
+ "args": {
138
+ "filename": "单元报表_{{data.startTime}}_{{data.endTime}}.zip"
139
+ },
140
+ "fromContext": {
141
+ "url": "outputs.downloadLink.response.data"
142
+ },
143
+ "storeAs": "downloadResult"
144
+ },
145
+ {
146
+ "nodeId": "s9",
147
+ "name": "hide_download_activity",
148
+ "goal": "在下载链路结束后关闭页面提示",
149
+ "tool": "present_page_activity",
150
+ "args": {
151
+ "mode": "stop"
152
+ }
153
+ },
154
+ {
155
+ "nodeId": "s10",
156
+ "name": "switch_to_existing_host_tab",
157
+ "goal": "任务结束后若存在匹配的既有标签页则切回去",
158
+ "when": "exists(payload.returnHostPatterns)",
159
+ "tool": "switch_tab",
160
+ "args": {
161
+ "urlIncludesAny": "{{data.returnHostPatterns}}",
162
+ "optional": true
163
+ }
164
+ }
165
+ ]
166
+ }
@@ -3,6 +3,7 @@
3
3
  "alimama-campaign-report-download.json",
4
4
  "alimama-crowd-report-download.json",
5
5
  "alimama-keyword-report-download.json",
6
+ "alimama-adgroup-report-download.json",
6
7
  "sycm-taobao-home-live-metrics.json",
7
8
  "sycm-taobao-api-group.json",
8
9
  "pinduoduo-mms-home-overview.json",