@oomol-lab/open-connector 1.6.2 → 1.6.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/README.md +27 -0
- package/assets/open-connector/catalog/apps/assured_platform.json +218 -0
- package/assets/open-connector/catalog/apps/baixiao.json +1080 -0
- package/assets/open-connector/catalog/apps/benchmarkone.json +956 -0
- package/assets/open-connector/catalog/apps/bing_webmaster.json +3097 -0
- package/assets/open-connector/catalog/apps/buzzsprout.json +1979 -0
- package/assets/open-connector/catalog/apps/feishu.json +13 -19
- package/assets/open-connector/catalog/apps/feishu_app_bot.json +12 -19
- package/assets/open-connector/catalog/apps/jin10.json +1 -1
- package/assets/open-connector/catalog/apps/linkfox.json +836 -0
- package/assets/open-connector/catalog/apps/metatraderapi.json +1077 -0
- package/assets/open-connector/catalog/apps/mktindex.json +2411 -0
- package/assets/open-connector/catalog/apps/mojo_helpdesk.json +660 -0
- package/assets/open-connector/catalog/apps/mumble.json +446 -0
- package/assets/open-connector/catalog/apps/notion.json +112 -3
- package/assets/open-connector/catalog/apps/omise.json +438 -0
- package/assets/open-connector/catalog/apps/panjiva.json +2858 -0
- package/assets/open-connector/catalog/apps/papertrail.json +449 -0
- package/assets/open-connector/catalog/apps/peec.json +747 -0
- package/assets/open-connector/catalog/apps/polygon_io.json +5156 -584
- package/assets/open-connector/catalog/apps/quant_data.json +1928 -0
- package/assets/open-connector/catalog/apps/riddle_quiz_maker.json +621 -0
- package/assets/open-connector/catalog/apps/slack.json +327 -4
- package/assets/open-connector/catalog/apps/slackbot.json +280 -3
- package/assets/open-connector/catalog/apps/templatedocs.json +438 -0
- package/assets/open-connector/catalog/apps/terminus_app.json +510 -0
- package/assets/open-connector/catalog/apps/ticket_tailor.json +584 -0
- package/assets/open-connector/catalog/apps/tongdaxin.json +2186 -82
- package/assets/open-connector/catalog/apps/veremark.json +514 -0
- package/assets/open-connector/catalog/apps/walletap.json +549 -0
- package/assets/open-connector/catalog/apps/xiaohongshu_store.json +955 -39
- package/assets/open-connector/catalog/apps-index.json +1 -1
- package/package.json +5 -1
- package/src/connection-service.d.ts +2 -0
- package/src/connection-service.js +8 -1
- package/src/core/provider-id.d.ts +5 -0
- package/src/core/provider-id.js +12 -0
- package/src/oauth/oauth-credential-refresh-service.js +2 -0
- package/src/oauth/oauth-flow-service.js +2 -0
- package/src/providers/action-contracts.generated.d.ts +27 -7
- package/src/providers/assured_platform/executors.d.ts +4 -0
- package/src/providers/assured_platform/executors.js +18 -0
- package/src/providers/assured_platform/runtime.d.ts +7 -0
- package/src/providers/assured_platform/runtime.js +108 -0
- package/src/providers/baixiao/actions.d.ts +2 -0
- package/src/providers/baixiao/actions.js +377 -0
- package/src/providers/baixiao/executors.d.ts +4 -0
- package/src/providers/baixiao/executors.js +106 -0
- package/src/providers/benchmarkone/executors.d.ts +4 -0
- package/src/providers/benchmarkone/executors.js +26 -0
- package/src/providers/benchmarkone/runtime.d.ts +12 -0
- package/src/providers/benchmarkone/runtime.js +113 -0
- package/src/providers/bing_webmaster/actions.d.ts +2 -0
- package/src/providers/bing_webmaster/actions.js +113 -0
- package/src/providers/bing_webmaster/executors.d.ts +4 -0
- package/src/providers/bing_webmaster/executors.js +104 -0
- package/src/providers/bing_webmaster/management-actions.d.ts +2 -0
- package/src/providers/bing_webmaster/management-actions.js +241 -0
- package/src/providers/bing_webmaster/reporting-actions.d.ts +2 -0
- package/src/providers/bing_webmaster/reporting-actions.js +300 -0
- package/src/providers/bing_webmaster/schemas.d.ts +33 -0
- package/src/providers/bing_webmaster/schemas.js +313 -0
- package/src/providers/buzzsprout/executors.d.ts +4 -0
- package/src/providers/buzzsprout/executors.js +21 -0
- package/src/providers/buzzsprout/runtime.d.ts +12 -0
- package/src/providers/buzzsprout/runtime.js +237 -0
- package/src/providers/dropbox/executors.js +21 -3
- package/src/providers/feishu/shared/drive-actions.d.ts +1 -0
- package/src/providers/feishu/shared/drive-actions.js +13 -9
- package/src/providers/feishu/shared/drive-runtime.js +15 -3
- package/src/providers/feishu/shared/wiki-actions.js +4 -2
- package/src/providers/feishu_app_bot/scopes.js +1 -1
- package/src/providers/hithink_finance/runtime.js +39 -60
- package/src/providers/linkfox/actions.js +2 -0
- package/src/providers/linkfox/runtime.js +70 -1
- package/src/providers/linkfox/sif-actions.d.ts +10 -0
- package/src/providers/linkfox/sif-actions.js +193 -0
- package/src/providers/mcp-client.d.ts +1 -0
- package/src/providers/mcp-client.js +41 -27
- package/src/providers/metatraderapi/executors.d.ts +4 -0
- package/src/providers/metatraderapi/executors.js +18 -0
- package/src/providers/metatraderapi/runtime.d.ts +7 -0
- package/src/providers/metatraderapi/runtime.js +216 -0
- package/src/providers/mktindex/actions-mmi.d.ts +2 -0
- package/src/providers/mktindex/actions-mmi.js +510 -0
- package/src/providers/mktindex/actions.d.ts +2 -0
- package/src/providers/mktindex/actions.js +2 -0
- package/src/providers/mktindex/executors.d.ts +4 -0
- package/src/providers/mktindex/executors.js +27 -0
- package/src/providers/mktindex/request.d.ts +17 -0
- package/src/providers/mktindex/request.js +48 -0
- package/src/providers/mktindex/runtime.d.ts +9 -0
- package/src/providers/mktindex/runtime.js +492 -0
- package/src/providers/mojo_helpdesk/executors.d.ts +4 -0
- package/src/providers/mojo_helpdesk/executors.js +18 -0
- package/src/providers/mojo_helpdesk/runtime.d.ts +7 -0
- package/src/providers/mojo_helpdesk/runtime.js +173 -0
- package/src/providers/mumble/executors.d.ts +4 -0
- package/src/providers/mumble/executors.js +99 -0
- package/src/providers/notion/executors.d.ts +9 -0
- package/src/providers/notion/executors.js +161 -6
- package/src/providers/omise/executors.d.ts +4 -0
- package/src/providers/omise/executors.js +120 -0
- package/src/providers/panjiva/actions.d.ts +14 -0
- package/src/providers/panjiva/actions.js +389 -0
- package/src/providers/panjiva/executors.d.ts +4 -0
- package/src/providers/panjiva/executors.js +136 -0
- package/src/providers/papertrail/executors.d.ts +4 -0
- package/src/providers/papertrail/executors.js +15 -0
- package/src/providers/papertrail/runtime.d.ts +7 -0
- package/src/providers/papertrail/runtime.js +167 -0
- package/src/providers/peec/executors.d.ts +4 -0
- package/src/providers/peec/executors.js +15 -0
- package/src/providers/peec/runtime.d.ts +7 -0
- package/src/providers/peec/runtime.js +128 -0
- package/src/providers/polygon_io/actions.d.ts +2 -0
- package/src/providers/polygon_io/actions.js +282 -0
- package/src/providers/polygon_io/expanded-actions.d.ts +2 -0
- package/src/providers/polygon_io/expanded-actions.js +375 -0
- package/src/providers/polygon_io/expanded-runtime.d.ts +16 -0
- package/src/providers/polygon_io/expanded-runtime.js +277 -0
- package/src/providers/polygon_io/runtime.js +21 -2
- package/src/providers/quant_data/executors.d.ts +4 -0
- package/src/providers/quant_data/executors.js +15 -0
- package/src/providers/quant_data/runtime.d.ts +7 -0
- package/src/providers/quant_data/runtime.js +118 -0
- package/src/providers/registry.generated.js +20 -0
- package/src/providers/riddle_quiz_maker/executors.d.ts +4 -0
- package/src/providers/riddle_quiz_maker/executors.js +15 -0
- package/src/providers/riddle_quiz_maker/runtime.d.ts +7 -0
- package/src/providers/riddle_quiz_maker/runtime.js +145 -0
- package/src/providers/sellersprite_mcp/executors.js +2 -1
- package/src/providers/slack/actions.js +106 -3
- package/src/providers/slack/runtime.js +262 -38
- package/src/providers/slackbot/actions.js +1 -1
- package/src/providers/templatedocs/executors.d.ts +4 -0
- package/src/providers/templatedocs/executors.js +18 -0
- package/src/providers/templatedocs/runtime.d.ts +13 -0
- package/src/providers/templatedocs/runtime.js +151 -0
- package/src/providers/terminus_app/executors.d.ts +4 -0
- package/src/providers/terminus_app/executors.js +15 -0
- package/src/providers/terminus_app/runtime.d.ts +7 -0
- package/src/providers/terminus_app/runtime.js +172 -0
- package/src/providers/ticket_tailor/executors.d.ts +4 -0
- package/src/providers/ticket_tailor/executors.js +15 -0
- package/src/providers/ticket_tailor/runtime.d.ts +7 -0
- package/src/providers/ticket_tailor/runtime.js +152 -0
- package/src/providers/tongdaxin/actions.d.ts +1 -0
- package/src/providers/tongdaxin/actions.js +6 -3
- package/src/providers/tongdaxin/executors.js +55 -13
- package/src/providers/tongdaxin/named-action-output.d.ts +1 -0
- package/src/providers/tongdaxin/named-action-output.js +143 -0
- package/src/providers/tongdaxin/named-action-routing.d.ts +9 -0
- package/src/providers/tongdaxin/named-action-routing.js +417 -0
- package/src/providers/tongdaxin/named-actions.d.ts +2 -0
- package/src/providers/tongdaxin/named-actions.js +373 -0
- package/src/providers/twenty_crm/runtime.js +4 -2
- package/src/providers/veremark/executors.d.ts +4 -0
- package/src/providers/veremark/executors.js +129 -0
- package/src/providers/walletap/executors.d.ts +4 -0
- package/src/providers/walletap/executors.js +15 -0
- package/src/providers/walletap/runtime.d.ts +7 -0
- package/src/providers/walletap/runtime.js +147 -0
- package/src/providers/weixin_official_account/access-token.js +31 -7
- package/src/providers/weixin_store/access-token.js +33 -7
- package/src/providers/xiaohongshu_store/executors.js +152 -3
- package/src/server/api/openapi.js +3 -0
- package/src/server/connector-assets.d.ts +4 -0
- package/src/server/connector-assets.js +12 -0
- package/src/server/connector-build.d.ts +33 -0
- package/src/server/connector-build.js +73 -0
- package/src/server/connector-runtime.d.ts +1 -2
- package/src/server/connector-runtime.js +2 -8
- package/src/server/server-assets.d.ts +0 -28
- package/src/server/server-assets.js +0 -50
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
import { jsonSchema as s } from "../../core/json-schema.js";
|
|
2
|
+
import { defineProviderAction } from "../../core/provider-definition.js";
|
|
3
|
+
const service = "mktindex";
|
|
4
|
+
const platformSchema = s.nonEmptyString("The Moojing platform ID, such as all, tmall, jd, pdd, or meituan. Supported platforms vary by endpoint and subscription.");
|
|
5
|
+
const categoryIdSchema = s.nonEmptyString("The Moojing category ID. Use 0 only when the selected endpoint supports all categories.");
|
|
6
|
+
const brandIdSchema = s.nonEmptyString("The Moojing brand ID. Use all to include every brand when supported.");
|
|
7
|
+
const monthSchema = s.nonEmptyString("The data month in YYYY-MM format.", {
|
|
8
|
+
pattern: "^\\d{4}-(0[1-9]|1[0-2])$",
|
|
9
|
+
});
|
|
10
|
+
const underscoreMonthSchema = s.nonEmptyString("The data month in the YYYY_MM format required by this Moojing endpoint.", { pattern: "^\\d{4}_(0[1-9]|1[0-2])$" });
|
|
11
|
+
const languageSchema = s.stringEnum("The response language.", ["zh", "en"]);
|
|
12
|
+
const currencySchema = s.stringEnum("The currency used for monetary values.", [
|
|
13
|
+
"CNY",
|
|
14
|
+
"JPY",
|
|
15
|
+
"GBP",
|
|
16
|
+
"EUR",
|
|
17
|
+
"USD",
|
|
18
|
+
]);
|
|
19
|
+
const periodSchema = s.stringEnum("The aggregation period used for the trend.", ["month", "quarter", "year"]);
|
|
20
|
+
const pageSchema = s.positiveInteger("The one-based result page number.", { default: 1 });
|
|
21
|
+
const pageSizeSchema = s.positiveInteger("The number of rows requested per page.", {
|
|
22
|
+
maximum: 100,
|
|
23
|
+
default: 10,
|
|
24
|
+
});
|
|
25
|
+
const rawObjectSchema = s.looseObject("The raw object returned by Moojing.");
|
|
26
|
+
const categorySchema = s.object("A normalized Moojing category.", {
|
|
27
|
+
id: s.string("The category ID."),
|
|
28
|
+
name: s.nullable(s.string("The Chinese category name when available.")),
|
|
29
|
+
englishName: s.nullable(s.string("The English category name when available.")),
|
|
30
|
+
parentId: s.nullable(s.string("The parent category ID when available.")),
|
|
31
|
+
level: s.nullable(s.integer("The category tree level when available.")),
|
|
32
|
+
childIds: s.array("The IDs of direct child categories.", s.string("A child category ID.")),
|
|
33
|
+
hasBrand: s.nullable(s.boolean("Whether the category has brand data when reported.")),
|
|
34
|
+
raw: rawObjectSchema,
|
|
35
|
+
});
|
|
36
|
+
const marketSelectorFields = {
|
|
37
|
+
platform: platformSchema,
|
|
38
|
+
categoryId: categoryIdSchema,
|
|
39
|
+
brandId: brandIdSchema,
|
|
40
|
+
};
|
|
41
|
+
const paginatedMarketFields = {
|
|
42
|
+
...marketSelectorFields,
|
|
43
|
+
month: monthSchema,
|
|
44
|
+
page: pageSchema,
|
|
45
|
+
pageSize: pageSizeSchema,
|
|
46
|
+
currency: currencySchema,
|
|
47
|
+
};
|
|
48
|
+
const regionFields = {
|
|
49
|
+
...marketSelectorFields,
|
|
50
|
+
province: s.nonWhitespaceString("The province name used to limit the regional market."),
|
|
51
|
+
city: s.nonWhitespaceString("The city name, or all to include every city in the province."),
|
|
52
|
+
};
|
|
53
|
+
const comparisonRangeSchema = s.object("One inclusive comparison range.", {
|
|
54
|
+
startMonth: monthSchema,
|
|
55
|
+
endMonth: monthSchema,
|
|
56
|
+
});
|
|
57
|
+
const comparisonRangesSchema = s.array("Exactly two date ranges to compare.", comparisonRangeSchema, {
|
|
58
|
+
minItems: 2,
|
|
59
|
+
maxItems: 2,
|
|
60
|
+
});
|
|
61
|
+
function defineRawReadAction(input) {
|
|
62
|
+
return defineProviderAction(service, {
|
|
63
|
+
name: input.name,
|
|
64
|
+
description: input.description,
|
|
65
|
+
operationType: "read",
|
|
66
|
+
inputSchema: input.inputSchema,
|
|
67
|
+
outputSchema: s.object(input.outputDescription, {
|
|
68
|
+
data: s.looseObject(input.dataDescription),
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const listCategoriesAction = defineProviderAction(service, {
|
|
73
|
+
name: "list_categories",
|
|
74
|
+
description: "List Moojing categories for an e-commerce platform.",
|
|
75
|
+
operationType: "read",
|
|
76
|
+
requiredScopes: [],
|
|
77
|
+
inputSchema: s.object("The input payload for listing Moojing categories.", {
|
|
78
|
+
platform: platformSchema,
|
|
79
|
+
rootCategoryId: s.nonEmptyString("An optional category ID used to limit the response to that branch plus top-level categories."),
|
|
80
|
+
language: languageSchema,
|
|
81
|
+
lastUpdatedAt: s.nonEmptyString("An optional category update timestamp in YYYY-MM-DD HH:mm:ss format."),
|
|
82
|
+
}, { optional: ["rootCategoryId", "language", "lastUpdatedAt"] }),
|
|
83
|
+
outputSchema: s.object("The normalized Moojing category tree response.", {
|
|
84
|
+
rootCategoryIds: s.array("The top-level category IDs returned by Moojing.", s.string("A top-level category ID.")),
|
|
85
|
+
maxDepth: s.nullable(s.integer("The maximum category tree depth when reported.")),
|
|
86
|
+
categories: s.array("The categories returned by Moojing.", categorySchema),
|
|
87
|
+
}),
|
|
88
|
+
});
|
|
89
|
+
const getDataRangeAction = defineProviderAction(service, {
|
|
90
|
+
name: "get_data_range",
|
|
91
|
+
description: "Get the earliest and latest available Moojing data months for a market.",
|
|
92
|
+
operationType: "read",
|
|
93
|
+
requiredScopes: [],
|
|
94
|
+
inputSchema: s.object("The input payload for getting the available Moojing data range.", {
|
|
95
|
+
platform: platformSchema,
|
|
96
|
+
categoryId: categoryIdSchema,
|
|
97
|
+
brandId: brandIdSchema,
|
|
98
|
+
}, { optional: ["categoryId", "brandId"] }),
|
|
99
|
+
outputSchema: s.object("The available Moojing data range.", {
|
|
100
|
+
startMonth: s.nullable(s.string("The earliest available data month.")),
|
|
101
|
+
endMonth: s.nullable(s.string("The latest available data month.")),
|
|
102
|
+
raw: rawObjectSchema,
|
|
103
|
+
}),
|
|
104
|
+
});
|
|
105
|
+
const listSubscriptionsAction = defineProviderAction(service, {
|
|
106
|
+
name: "list_subscriptions",
|
|
107
|
+
description: "List markets subscribed to or followed by the connected Moojing account.",
|
|
108
|
+
operationType: "read",
|
|
109
|
+
requiredScopes: [],
|
|
110
|
+
inputSchema: s.object("The input payload for listing subscribed or followed Moojing markets.", {
|
|
111
|
+
mode: s.stringEnum("Whether to return subscribed or followed markets.", ["subscribed", "followed"]),
|
|
112
|
+
language: languageSchema,
|
|
113
|
+
}, { optional: ["language"] }),
|
|
114
|
+
outputSchema: s.object("The markets available to the connected Moojing account.", {
|
|
115
|
+
subscriptions: s.array("The subscribed or followed market records.", rawObjectSchema),
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
const getJdDataVersionsAction = defineProviderAction(service, {
|
|
119
|
+
name: "get_jd_data_versions",
|
|
120
|
+
description: "List data-model versions available for a JD-related Moojing platform.",
|
|
121
|
+
operationType: "read",
|
|
122
|
+
requiredScopes: [],
|
|
123
|
+
inputSchema: s.object("The input payload for listing JD data-model versions.", {
|
|
124
|
+
platform: s.stringEnum("The JD-related Moojing platform ID.", [
|
|
125
|
+
"jd",
|
|
126
|
+
"jd_exclude_self",
|
|
127
|
+
"jd_only_self",
|
|
128
|
+
"jd_hk",
|
|
129
|
+
]),
|
|
130
|
+
}),
|
|
131
|
+
outputSchema: s.object("The available JD data-model versions.", {
|
|
132
|
+
versions: s.array("The available version identifiers.", s.string("A data-model version.")),
|
|
133
|
+
}),
|
|
134
|
+
});
|
|
135
|
+
const searchBrandsAction = defineProviderAction(service, {
|
|
136
|
+
name: "search_brands",
|
|
137
|
+
description: "Search Moojing brands by keyword or stock code.",
|
|
138
|
+
operationType: "read",
|
|
139
|
+
requiredScopes: [],
|
|
140
|
+
inputSchema: s.object("The input payload for searching Moojing brands.", {
|
|
141
|
+
query: s.nonWhitespaceString("The brand keyword or stock code to search for."),
|
|
142
|
+
currency: currencySchema,
|
|
143
|
+
}, { optional: ["currency"] }),
|
|
144
|
+
outputSchema: s.object("The Moojing brand search response.", {
|
|
145
|
+
results: s.array("The brand search result groups returned by Moojing.", rawObjectSchema),
|
|
146
|
+
}),
|
|
147
|
+
});
|
|
148
|
+
const getMarketSummaryAction = defineProviderAction(service, {
|
|
149
|
+
name: "get_market_summary",
|
|
150
|
+
description: "Get monthly sales, volume, price, shop, item, and market-share metrics for a Moojing market.",
|
|
151
|
+
operationType: "read",
|
|
152
|
+
requiredScopes: [],
|
|
153
|
+
inputSchema: s.object("The input payload for getting a Moojing market summary.", {
|
|
154
|
+
...marketSelectorFields,
|
|
155
|
+
month: monthSchema,
|
|
156
|
+
language: languageSchema,
|
|
157
|
+
currency: currencySchema,
|
|
158
|
+
}, { optional: ["currency"] }),
|
|
159
|
+
outputSchema: s.object("The normalized Moojing market summary.", {
|
|
160
|
+
sales: s.nullable(s.number("The market sales amount.")),
|
|
161
|
+
sold: s.nullable(s.number("The market sales volume.")),
|
|
162
|
+
averagePrice: s.nullable(s.number("The average item price.")),
|
|
163
|
+
marketShare: s.nullable(s.number("The market share within the parent market.")),
|
|
164
|
+
shopCount: s.nullable(s.number("The number of shops.")),
|
|
165
|
+
itemCount: s.nullable(s.number("The number of items.")),
|
|
166
|
+
names: rawObjectSchema,
|
|
167
|
+
raw: rawObjectSchema,
|
|
168
|
+
}),
|
|
169
|
+
});
|
|
170
|
+
const getMarketTrendAction = defineProviderAction(service, {
|
|
171
|
+
name: "get_market_trend",
|
|
172
|
+
description: "Get sales, volume, price, item, shop, and market-share trends for a Moojing market.",
|
|
173
|
+
operationType: "read",
|
|
174
|
+
requiredScopes: [],
|
|
175
|
+
inputSchema: s.object("The input payload for getting Moojing market trends.", {
|
|
176
|
+
...marketSelectorFields,
|
|
177
|
+
period: periodSchema,
|
|
178
|
+
includeYearOverYear: s.boolean("Whether to request the additional year-over-year and period-over-period series."),
|
|
179
|
+
currency: currencySchema,
|
|
180
|
+
}, { optional: ["includeYearOverYear", "currency"] }),
|
|
181
|
+
outputSchema: s.object("The Moojing market trend response.", {
|
|
182
|
+
series: rawObjectSchema,
|
|
183
|
+
}),
|
|
184
|
+
});
|
|
185
|
+
const listMarketBreakdownAction = defineProviderAction(service, {
|
|
186
|
+
name: "list_market_breakdown",
|
|
187
|
+
description: "List category, brand, or province rows within a Moojing market for one month.",
|
|
188
|
+
operationType: "read",
|
|
189
|
+
requiredScopes: [],
|
|
190
|
+
inputSchema: s.object("The input payload for listing a Moojing market breakdown.", {
|
|
191
|
+
...paginatedMarketFields,
|
|
192
|
+
dimension: s.stringEnum("The dimension used to break down the market.", [
|
|
193
|
+
"category",
|
|
194
|
+
"brand",
|
|
195
|
+
"province",
|
|
196
|
+
]),
|
|
197
|
+
}, { optional: ["page", "pageSize", "currency"] }),
|
|
198
|
+
outputSchema: s.object("The paginated Moojing market breakdown.", {
|
|
199
|
+
count: s.integer("The total number of available rows."),
|
|
200
|
+
rows: s.array("The market breakdown rows returned by Moojing.", rawObjectSchema),
|
|
201
|
+
}),
|
|
202
|
+
});
|
|
203
|
+
const listHotShopsAction = defineProviderAction(service, {
|
|
204
|
+
name: "list_hot_shops",
|
|
205
|
+
description: "List top-selling shops within a Moojing market for one month.",
|
|
206
|
+
operationType: "read",
|
|
207
|
+
requiredScopes: [],
|
|
208
|
+
inputSchema: s.object("The input payload for listing top-selling Moojing shops.", paginatedMarketFields, {
|
|
209
|
+
optional: ["page", "pageSize", "currency"],
|
|
210
|
+
}),
|
|
211
|
+
outputSchema: s.object("The paginated top-selling Moojing shops.", {
|
|
212
|
+
count: s.integer("The total number of available shops."),
|
|
213
|
+
shops: s.array("The shop rows returned by Moojing.", rawObjectSchema),
|
|
214
|
+
}),
|
|
215
|
+
});
|
|
216
|
+
const listHotItemsAction = defineProviderAction(service, {
|
|
217
|
+
name: "list_hot_items",
|
|
218
|
+
description: "List top-selling items within a Moojing market for one month.",
|
|
219
|
+
operationType: "read",
|
|
220
|
+
requiredScopes: [],
|
|
221
|
+
inputSchema: s.object("The input payload for listing top-selling Moojing items.", paginatedMarketFields, {
|
|
222
|
+
optional: ["page", "pageSize", "currency"],
|
|
223
|
+
}),
|
|
224
|
+
outputSchema: s.object("The paginated top-selling Moojing items.", {
|
|
225
|
+
count: s.integer("The total number of available items."),
|
|
226
|
+
items: s.array("The item rows returned by Moojing.", rawObjectSchema),
|
|
227
|
+
}),
|
|
228
|
+
});
|
|
229
|
+
const compareMarketPeriodsAction = defineRawReadAction({
|
|
230
|
+
name: "compare_market_periods",
|
|
231
|
+
description: "Compare sales and volume for two date ranges in a Moojing market.",
|
|
232
|
+
inputSchema: s.object("The input payload for comparing two Moojing market periods.", { ...marketSelectorFields, ranges: comparisonRangesSchema, currency: currencySchema }, { optional: ["currency"] }),
|
|
233
|
+
outputDescription: "The two-period Moojing market comparison.",
|
|
234
|
+
dataDescription: "The comparison metrics keyed by the requested ranges.",
|
|
235
|
+
});
|
|
236
|
+
const getRegionMarketSummaryAction = defineRawReadAction({
|
|
237
|
+
name: "get_region_market_summary",
|
|
238
|
+
description: "Get monthly summary metrics for a province or city within a Moojing market.",
|
|
239
|
+
inputSchema: s.object("The input payload for a regional Moojing market summary.", { ...regionFields, month: monthSchema, language: languageSchema, currency: currencySchema }, { optional: ["currency"] }),
|
|
240
|
+
outputDescription: "The regional Moojing market summary.",
|
|
241
|
+
dataDescription: "The provider-defined regional summary metrics.",
|
|
242
|
+
});
|
|
243
|
+
const getRegionMarketTrendAction = defineRawReadAction({
|
|
244
|
+
name: "get_region_market_trend",
|
|
245
|
+
description: "Get trend series for a province or city within a Moojing market.",
|
|
246
|
+
inputSchema: s.object("The input payload for a regional Moojing market trend.", { ...regionFields, period: periodSchema, currency: currencySchema }, { optional: ["currency"] }),
|
|
247
|
+
outputDescription: "The regional Moojing market trend.",
|
|
248
|
+
dataDescription: "The provider-defined regional trend series.",
|
|
249
|
+
});
|
|
250
|
+
const listRegionMarketBreakdownAction = defineRawReadAction({
|
|
251
|
+
name: "list_region_market_breakdown",
|
|
252
|
+
description: "List category, brand, or city rows within a regional Moojing market.",
|
|
253
|
+
inputSchema: s.object("The input payload for a regional Moojing market breakdown.", {
|
|
254
|
+
...regionFields,
|
|
255
|
+
month: monthSchema,
|
|
256
|
+
dimension: s.stringEnum("The dimension used to break down the regional market.", [
|
|
257
|
+
"category",
|
|
258
|
+
"brand",
|
|
259
|
+
"city",
|
|
260
|
+
]),
|
|
261
|
+
page: pageSchema,
|
|
262
|
+
pageSize: pageSizeSchema,
|
|
263
|
+
currency: currencySchema,
|
|
264
|
+
}, { optional: ["page", "pageSize", "currency"] }),
|
|
265
|
+
outputDescription: "The regional Moojing market breakdown.",
|
|
266
|
+
dataDescription: "The provider-defined paginated regional rows.",
|
|
267
|
+
});
|
|
268
|
+
const listRegionHotShopsAction = defineRawReadAction({
|
|
269
|
+
name: "list_region_hot_shops",
|
|
270
|
+
description: "List top-selling shops within a regional Moojing market.",
|
|
271
|
+
inputSchema: s.object("The input payload for regional top-selling shops.", {
|
|
272
|
+
...regionFields,
|
|
273
|
+
month: monthSchema,
|
|
274
|
+
page: pageSchema,
|
|
275
|
+
pageSize: pageSizeSchema,
|
|
276
|
+
currency: currencySchema,
|
|
277
|
+
}, { optional: ["page", "pageSize", "currency"] }),
|
|
278
|
+
outputDescription: "The regional top-selling Moojing shops.",
|
|
279
|
+
dataDescription: "The provider-defined paginated regional shop rows.",
|
|
280
|
+
});
|
|
281
|
+
const listRegionHotItemsAction = defineRawReadAction({
|
|
282
|
+
name: "list_region_hot_items",
|
|
283
|
+
description: "List top-selling items within a regional Moojing market.",
|
|
284
|
+
inputSchema: s.object("The input payload for regional top-selling items.", {
|
|
285
|
+
...regionFields,
|
|
286
|
+
month: monthSchema,
|
|
287
|
+
page: pageSchema,
|
|
288
|
+
pageSize: pageSizeSchema,
|
|
289
|
+
currency: currencySchema,
|
|
290
|
+
}, { optional: ["page", "pageSize", "currency"] }),
|
|
291
|
+
outputDescription: "The regional top-selling Moojing items.",
|
|
292
|
+
dataDescription: "The provider-defined paginated regional item rows.",
|
|
293
|
+
});
|
|
294
|
+
const compareRegionMarketPeriodsAction = defineRawReadAction({
|
|
295
|
+
name: "compare_region_market_periods",
|
|
296
|
+
description: "Compare sales and volume for two date ranges in a regional Moojing market.",
|
|
297
|
+
inputSchema: s.object("The input payload for comparing regional Moojing market periods.", { ...regionFields, ranges: comparisonRangesSchema, currency: currencySchema }, { optional: ["currency"] }),
|
|
298
|
+
outputDescription: "The two-period regional Moojing market comparison.",
|
|
299
|
+
dataDescription: "The regional comparison metrics keyed by the requested ranges.",
|
|
300
|
+
});
|
|
301
|
+
const getCommentTrendAction = defineRawReadAction({
|
|
302
|
+
name: "get_comment_trend",
|
|
303
|
+
description: "Get review-count and sentiment-rate trends for a Moojing market.",
|
|
304
|
+
inputSchema: s.object("The input payload for getting Moojing comment trends.", {
|
|
305
|
+
...marketSelectorFields,
|
|
306
|
+
period: periodSchema,
|
|
307
|
+
}),
|
|
308
|
+
outputDescription: "The Moojing comment trend response.",
|
|
309
|
+
dataDescription: "The good, neutral, bad, and comment-count series available for the platform.",
|
|
310
|
+
});
|
|
311
|
+
const listBrandCategoriesAction = defineProviderAction(service, {
|
|
312
|
+
name: "list_brand_categories",
|
|
313
|
+
description: "List categories and sales associated with a Moojing brand on a platform.",
|
|
314
|
+
operationType: "read",
|
|
315
|
+
requiredScopes: [],
|
|
316
|
+
inputSchema: s.object("The input payload for listing categories associated with a brand.", { platform: platformSchema, brandId: brandIdSchema, currency: currencySchema }, { optional: ["currency"] }),
|
|
317
|
+
outputSchema: s.object("The categories associated with the Moojing brand.", {
|
|
318
|
+
categories: s.array("The provider-defined brand category rows.", rawObjectSchema),
|
|
319
|
+
}),
|
|
320
|
+
});
|
|
321
|
+
const priceDistributionInputSchema = s.object("The input payload for calculating a Moojing price distribution.", {
|
|
322
|
+
...marketSelectorFields,
|
|
323
|
+
month: monthSchema,
|
|
324
|
+
priceBreakpoints: s.array("Custom price breakpoints used to build ranges.", s.number("One custom price breakpoint.", { minimum: 0 }), { minItems: 1 }),
|
|
325
|
+
intervalSize: s.number("The fixed size of each generated price interval.", {
|
|
326
|
+
exclusiveMinimum: 0,
|
|
327
|
+
}),
|
|
328
|
+
minPrice: s.number("The minimum price included in generated intervals.", { minimum: 0 }),
|
|
329
|
+
maxPrice: s.number("The maximum price included in generated intervals.", {
|
|
330
|
+
exclusiveMinimum: 0,
|
|
331
|
+
}),
|
|
332
|
+
rangeCount: s.positiveInteger("The number of generated price intervals."),
|
|
333
|
+
currency: currencySchema,
|
|
334
|
+
}, {
|
|
335
|
+
optional: ["priceBreakpoints", "intervalSize", "minPrice", "maxPrice", "rangeCount", "currency"],
|
|
336
|
+
});
|
|
337
|
+
const getPriceDistributionAction = defineProviderAction(service, {
|
|
338
|
+
name: "get_price_distribution",
|
|
339
|
+
description: "Get item share, volume, and sales across price ranges in a Moojing market.",
|
|
340
|
+
operationType: "read",
|
|
341
|
+
requiredScopes: [],
|
|
342
|
+
inputSchema: priceDistributionInputSchema,
|
|
343
|
+
outputSchema: s.object("The normalized Moojing price distribution.", {
|
|
344
|
+
ranges: s.array("The returned price ranges.", s.object("One price range and its market metrics.", {
|
|
345
|
+
label: s.string("The provider-defined price range label."),
|
|
346
|
+
itemShare: s.nullable(s.number("The share of items in the range.")),
|
|
347
|
+
sold: s.nullable(s.number("The sales volume in the range.")),
|
|
348
|
+
sales: s.nullable(s.number("The sales amount in the range.")),
|
|
349
|
+
raw: s.array("The raw tuple returned for the range.", s.unknown("A raw tuple value.")),
|
|
350
|
+
})),
|
|
351
|
+
}),
|
|
352
|
+
});
|
|
353
|
+
const getPlatformSalesTrendsAction = defineRawReadAction({
|
|
354
|
+
name: "get_platform_sales_trends",
|
|
355
|
+
description: "Get total sales trend series for each Moojing e-commerce platform.",
|
|
356
|
+
inputSchema: s.object("The input payload for total platform sales trends.", { period: periodSchema, startMonth: monthSchema, currency: currencySchema }, { optional: ["currency"] }),
|
|
357
|
+
outputDescription: "The total sales trends grouped by platform.",
|
|
358
|
+
dataDescription: "The provider-defined map from platform IDs to sales series.",
|
|
359
|
+
});
|
|
360
|
+
const listSpusAction = defineRawReadAction({
|
|
361
|
+
name: "list_spus",
|
|
362
|
+
description: "List product models or SPUs for a Tmall category and brand in one month.",
|
|
363
|
+
inputSchema: s.object("The input payload for listing Moojing SPUs.", {
|
|
364
|
+
platform: s.literal("tmall", { description: "The Tmall platform supported by the official SPU endpoint." }),
|
|
365
|
+
categoryId: categoryIdSchema,
|
|
366
|
+
brandId: brandIdSchema,
|
|
367
|
+
month: monthSchema,
|
|
368
|
+
currency: currencySchema,
|
|
369
|
+
}, { optional: ["currency"] }),
|
|
370
|
+
outputDescription: "The Moojing SPU list.",
|
|
371
|
+
dataDescription: "The provider-defined SPU count and rows.",
|
|
372
|
+
});
|
|
373
|
+
const getSpuAction = defineRawReadAction({
|
|
374
|
+
name: "get_spu",
|
|
375
|
+
description: "Get one Tmall product model or SPU with its items and shops.",
|
|
376
|
+
inputSchema: s.object("The input payload for getting one Moojing SPU.", {
|
|
377
|
+
platform: s.literal("tmall", { description: "The Tmall platform supported by the official SPU endpoint." }),
|
|
378
|
+
spuId: s.nonWhitespaceString("The Moojing SPU identifier."),
|
|
379
|
+
month: monthSchema,
|
|
380
|
+
currency: currencySchema,
|
|
381
|
+
}, { optional: ["currency"] }),
|
|
382
|
+
outputDescription: "The Moojing SPU detail response.",
|
|
383
|
+
dataDescription: "The provider-defined SPU detail, item, shop, and breadcrumb fields.",
|
|
384
|
+
});
|
|
385
|
+
const listCategoryAttributesAction = defineRawReadAction({
|
|
386
|
+
name: "list_category_attributes",
|
|
387
|
+
description: "List attribute groups and values available for a Moojing category in one month.",
|
|
388
|
+
inputSchema: s.object("The input payload for listing category attributes.", {
|
|
389
|
+
platform: platformSchema,
|
|
390
|
+
categoryId: categoryIdSchema,
|
|
391
|
+
month: monthSchema,
|
|
392
|
+
}),
|
|
393
|
+
outputDescription: "The Moojing category attribute dictionary.",
|
|
394
|
+
dataDescription: "The provider-defined map from attribute group names to values.",
|
|
395
|
+
});
|
|
396
|
+
const attributePerformanceInputSchema = s.object("The input payload for listing Moojing attribute performance.", {
|
|
397
|
+
platform: platformSchema,
|
|
398
|
+
categoryId: categoryIdSchema,
|
|
399
|
+
month: monthSchema,
|
|
400
|
+
mode: s.stringEnum("Whether to rank combinations or values in one attribute group.", [
|
|
401
|
+
"combinations",
|
|
402
|
+
"single_attribute",
|
|
403
|
+
]),
|
|
404
|
+
attributeName: s.nonWhitespaceString("The attribute group used when mode is single_attribute."),
|
|
405
|
+
currency: currencySchema,
|
|
406
|
+
}, { optional: ["attributeName", "currency"] });
|
|
407
|
+
const listAttributePerformanceAction = defineRawReadAction({
|
|
408
|
+
name: "list_attribute_performance",
|
|
409
|
+
description: "List sales performance for attribute values or combinations in a Moojing category.",
|
|
410
|
+
inputSchema: attributePerformanceInputSchema,
|
|
411
|
+
outputDescription: "The Moojing attribute performance result.",
|
|
412
|
+
dataDescription: "The provider-defined attribute performance count and rows.",
|
|
413
|
+
});
|
|
414
|
+
const attributeSelectionsSchema = s.record("One or two attribute group-to-value selections.", s.nonWhitespaceString("The selected value for an attribute group."));
|
|
415
|
+
const getAttributeSummaryAction = defineRawReadAction({
|
|
416
|
+
name: "get_attribute_summary",
|
|
417
|
+
description: "Get sales metrics and top items for one or two selected Moojing attributes.",
|
|
418
|
+
inputSchema: s.object("The input payload for a Moojing attribute summary.", {
|
|
419
|
+
platform: platformSchema,
|
|
420
|
+
categoryId: categoryIdSchema,
|
|
421
|
+
brandId: brandIdSchema,
|
|
422
|
+
attributes: attributeSelectionsSchema,
|
|
423
|
+
month: monthSchema,
|
|
424
|
+
currency: currencySchema,
|
|
425
|
+
}, { optional: ["currency"] }),
|
|
426
|
+
outputDescription: "The Moojing attribute summary.",
|
|
427
|
+
dataDescription: "The provider-defined attribute metrics, breadcrumbs, and top items.",
|
|
428
|
+
});
|
|
429
|
+
const getShopSalesTrendAction = defineRawReadAction({
|
|
430
|
+
name: "get_shop_sales_trend",
|
|
431
|
+
description: "Get sales trends for one Moojing shop within a category and brand.",
|
|
432
|
+
inputSchema: s.object("The input payload for a Moojing shop sales trend.", {
|
|
433
|
+
platform: platformSchema,
|
|
434
|
+
shopId: s.nonWhitespaceString("The Moojing shop identifier."),
|
|
435
|
+
categoryId: categoryIdSchema,
|
|
436
|
+
brandId: brandIdSchema,
|
|
437
|
+
startMonth: underscoreMonthSchema,
|
|
438
|
+
currency: currencySchema,
|
|
439
|
+
}, { optional: ["currency"] }),
|
|
440
|
+
outputDescription: "The Moojing shop sales trend.",
|
|
441
|
+
dataDescription: "The provider-defined shop identity and trend data.",
|
|
442
|
+
});
|
|
443
|
+
const getItemSalesTrendAction = defineRawReadAction({
|
|
444
|
+
name: "get_item_sales_trend",
|
|
445
|
+
description: "Get price, sales, volume, and comment trends for one Moojing item.",
|
|
446
|
+
inputSchema: s.object("The input payload for a Moojing item sales trend.", {
|
|
447
|
+
platform: platformSchema,
|
|
448
|
+
itemId: s.nonWhitespaceString("The provider item identifier."),
|
|
449
|
+
startMonth: underscoreMonthSchema,
|
|
450
|
+
currency: currencySchema,
|
|
451
|
+
}, { optional: ["currency"] }),
|
|
452
|
+
outputDescription: "The Moojing item sales trend.",
|
|
453
|
+
dataDescription: "The provider-defined item trend data.",
|
|
454
|
+
});
|
|
455
|
+
const shopDetailsInputSchema = s.object("The input payload for getting Moojing shop details.", {
|
|
456
|
+
platform: platformSchema,
|
|
457
|
+
startMonth: monthSchema,
|
|
458
|
+
endMonth: monthSchema,
|
|
459
|
+
shopNames: s.stringArray("The shop names to query.", {
|
|
460
|
+
minItems: 1,
|
|
461
|
+
itemDescription: "One shop name.",
|
|
462
|
+
}),
|
|
463
|
+
shopIds: s.stringArray("The shop IDs to query.", {
|
|
464
|
+
minItems: 1,
|
|
465
|
+
itemDescription: "One shop ID.",
|
|
466
|
+
}),
|
|
467
|
+
currency: currencySchema,
|
|
468
|
+
}, { optional: ["endMonth", "shopNames", "shopIds", "currency"] });
|
|
469
|
+
const getShopDetailsAction = defineProviderAction(service, {
|
|
470
|
+
name: "get_shop_details",
|
|
471
|
+
description: "Get category, brand, location, and service details for one or more Moojing shops.",
|
|
472
|
+
operationType: "read",
|
|
473
|
+
requiredScopes: [],
|
|
474
|
+
inputSchema: shopDetailsInputSchema,
|
|
475
|
+
outputSchema: s.object("The Moojing shop detail response.", {
|
|
476
|
+
shops: s.array("The shop detail records returned by Moojing.", rawObjectSchema),
|
|
477
|
+
errors: s.array("Shop lookup errors reported by Moojing.", s.string("One shop lookup error.")),
|
|
478
|
+
}),
|
|
479
|
+
});
|
|
480
|
+
export const mktindexMmiActions = [
|
|
481
|
+
listCategoriesAction,
|
|
482
|
+
getDataRangeAction,
|
|
483
|
+
listSubscriptionsAction,
|
|
484
|
+
getJdDataVersionsAction,
|
|
485
|
+
searchBrandsAction,
|
|
486
|
+
getMarketSummaryAction,
|
|
487
|
+
getMarketTrendAction,
|
|
488
|
+
listMarketBreakdownAction,
|
|
489
|
+
listHotShopsAction,
|
|
490
|
+
listHotItemsAction,
|
|
491
|
+
compareMarketPeriodsAction,
|
|
492
|
+
getRegionMarketSummaryAction,
|
|
493
|
+
getRegionMarketTrendAction,
|
|
494
|
+
listRegionMarketBreakdownAction,
|
|
495
|
+
listRegionHotShopsAction,
|
|
496
|
+
listRegionHotItemsAction,
|
|
497
|
+
compareRegionMarketPeriodsAction,
|
|
498
|
+
getCommentTrendAction,
|
|
499
|
+
listBrandCategoriesAction,
|
|
500
|
+
getPriceDistributionAction,
|
|
501
|
+
getPlatformSalesTrendsAction,
|
|
502
|
+
listSpusAction,
|
|
503
|
+
getSpuAction,
|
|
504
|
+
listCategoryAttributesAction,
|
|
505
|
+
listAttributePerformanceAction,
|
|
506
|
+
getAttributeSummaryAction,
|
|
507
|
+
getShopSalesTrendAction,
|
|
508
|
+
getItemSalesTrendAction,
|
|
509
|
+
getShopDetailsAction,
|
|
510
|
+
];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CredentialValidators, ProviderExecutors, ProviderProxyExecutor } from "../../core/types.ts";
|
|
2
|
+
export declare const executors: ProviderExecutors;
|
|
3
|
+
export declare const proxy: ProviderProxyExecutor;
|
|
4
|
+
export declare const credentialValidators: CredentialValidators;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineApiKeyProviderExecutors, defineProviderProxy, mapProviderActionHandlers, providerInputError, } from "../provider-runtime.js";
|
|
2
|
+
import { mktindexActions } from "./actions.js";
|
|
3
|
+
import { mktindexApiBaseUrl } from "./request.js";
|
|
4
|
+
import { mktindexActionHandlers, validateMktindexCredential } from "./runtime.js";
|
|
5
|
+
const service = "mktindex";
|
|
6
|
+
const handlers = mapProviderActionHandlers(service, mktindexActions, (action) => {
|
|
7
|
+
const handler = mktindexActionHandlers[action.name];
|
|
8
|
+
if (!handler)
|
|
9
|
+
return async () => {
|
|
10
|
+
throw providerInputError(`Unknown mktindex action: ${action.name}`);
|
|
11
|
+
};
|
|
12
|
+
return (input, context) => handler(input, { apiKey: context.apiKey, fetcher: context.fetcher });
|
|
13
|
+
});
|
|
14
|
+
export const executors = defineApiKeyProviderExecutors(service, handlers, {
|
|
15
|
+
skipDnsValidation: true,
|
|
16
|
+
});
|
|
17
|
+
export const proxy = defineProviderProxy({
|
|
18
|
+
service,
|
|
19
|
+
baseUrl: mktindexApiBaseUrl,
|
|
20
|
+
auth: { type: "api_key_header", name: "MOOJING-APIKEY" },
|
|
21
|
+
skipDnsValidation: true,
|
|
22
|
+
});
|
|
23
|
+
export const credentialValidators = {
|
|
24
|
+
apiKey(input, { fetcher }) {
|
|
25
|
+
return validateMktindexCredential({ apiKey: input.apiKey }, fetcher);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const mktindexApiBaseUrl = "https://market.moojing.com/api";
|
|
2
|
+
type MktindexPhase = "validate" | "execute";
|
|
3
|
+
interface RequestInput {
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
path: string;
|
|
6
|
+
method?: "GET" | "POST" | "DELETE";
|
|
7
|
+
apiKey: string;
|
|
8
|
+
query?: Record<string, string | undefined>;
|
|
9
|
+
jsonBody?: unknown;
|
|
10
|
+
formBody?: Record<string, string>;
|
|
11
|
+
fetcher: typeof fetch;
|
|
12
|
+
phase: MktindexPhase;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}
|
|
15
|
+
export declare function requestMktindexResult(input: RequestInput): Promise<unknown>;
|
|
16
|
+
export declare function requestMktindexEnvelope(input: RequestInput): Promise<Record<string, unknown>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { optionalRecord, optionalString } from "../../core/cast.js";
|
|
2
|
+
import { readProviderTextBody, providerResponseError, providerUserAgent, ProviderRequestError, } from "../provider-runtime.js";
|
|
3
|
+
export const mktindexApiBaseUrl = "https://market.moojing.com/api";
|
|
4
|
+
export async function requestMktindexResult(input) {
|
|
5
|
+
return (await requestMktindexEnvelope(input)).result;
|
|
6
|
+
}
|
|
7
|
+
export async function requestMktindexEnvelope(input) {
|
|
8
|
+
const url = new URL(input.path.replace(/^\//u, ""), `${input.baseUrl ?? mktindexApiBaseUrl}/`);
|
|
9
|
+
for (const [k, v] of Object.entries(input.query ?? {}))
|
|
10
|
+
if (v !== undefined)
|
|
11
|
+
url.searchParams.set(k, v);
|
|
12
|
+
const headers = new Headers({
|
|
13
|
+
accept: "application/json",
|
|
14
|
+
"MOOJING-APIKEY": input.apiKey,
|
|
15
|
+
"user-agent": providerUserAgent,
|
|
16
|
+
});
|
|
17
|
+
let body;
|
|
18
|
+
if (input.jsonBody !== undefined) {
|
|
19
|
+
headers.set("content-type", "application/json");
|
|
20
|
+
body = JSON.stringify(input.jsonBody);
|
|
21
|
+
}
|
|
22
|
+
else if (input.formBody) {
|
|
23
|
+
headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
|
|
24
|
+
body = new URLSearchParams(input.formBody).toString();
|
|
25
|
+
}
|
|
26
|
+
const response = await input.fetcher(url, { method: input.method ?? "GET", headers, body, signal: input.signal });
|
|
27
|
+
const text = await readProviderTextBody(response, "Mktindex response");
|
|
28
|
+
let payload;
|
|
29
|
+
try {
|
|
30
|
+
payload = JSON.parse(text);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
throw providerResponseError(text ? "Moojing returned invalid JSON" : "Moojing returned an empty response");
|
|
34
|
+
}
|
|
35
|
+
const record = optionalRecord(payload);
|
|
36
|
+
if (!record)
|
|
37
|
+
throw providerResponseError("Moojing returned an invalid response");
|
|
38
|
+
if (!response.ok || record.status === "error") {
|
|
39
|
+
const code = typeof record.code === "number" ? record.code : undefined;
|
|
40
|
+
const message = optionalString(record.message) ??
|
|
41
|
+
optionalString(record.msg) ??
|
|
42
|
+
`Moojing request failed with status ${response.status}`;
|
|
43
|
+
throw new ProviderRequestError(code === -413 ? 429 : response.status || 502, message, record);
|
|
44
|
+
}
|
|
45
|
+
if (record.status !== "ok")
|
|
46
|
+
throw providerResponseError("Moojing returned an unknown response status");
|
|
47
|
+
return record;
|
|
48
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CredentialValidationResult } from "../../core/types.ts";
|
|
2
|
+
type MktindexActionContext = {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
fetcher: typeof fetch;
|
|
5
|
+
};
|
|
6
|
+
type MktindexActionHandler = (input: Record<string, unknown>, context: MktindexActionContext) => Promise<unknown>;
|
|
7
|
+
export declare const mktindexActionHandlers: Record<string, MktindexActionHandler>;
|
|
8
|
+
export declare function validateMktindexCredential(input: Record<string, string>, fetcher: typeof fetch): Promise<CredentialValidationResult>;
|
|
9
|
+
export {};
|