openany-cli-dev 0.1.5 → 0.1.7
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 +50 -1
- package/package.json +3 -2
- package/skills/openany-provider/SKILL.md +3 -3
- package/skills/openany-provider/SKILL.zh-CN.md +3 -3
- package/skills/openany-provider/references/application.md +48 -30
- package/skills/openany-provider/references/application.zh-CN.md +47 -31
- package/skills/openany-provider/templates/seller-registration.json +3 -2
- package/src/catalog.js +6 -2
- package/src/cli.js +10 -2
- package/src/config.js +27 -0
- package/src/http.js +4 -0
- package/src/provider-client.js +7 -4
- package/src/provider-profile.js +2 -0
- package/src/provider.js +3 -1
- package/src/seller-profile.js +62 -0
- package/src/seller-registration-validation.js +29 -0
package/README.md
CHANGED
|
@@ -63,12 +63,23 @@ openany-dev run --id API_ID --query '{"limit":"10"}' -j
|
|
|
63
63
|
|
|
64
64
|
Use the API ID and parameters from the live catalog. `status` checks local configuration and reports `configured/missing` without testing network access or key validity. Configure a key before proceeding with authenticated discovery or inspection. Use `discover --public` when the user explicitly requests public catalog browsing only.
|
|
65
65
|
|
|
66
|
-
`run --headers` accepts `Accept` and `
|
|
66
|
+
`run --headers` accepts `Accept`, `Accept-Language`, and `x-openany-partner-id` even when they are absent from the published inputs. Header names are case-insensitive. Published constraints still apply when these headers are declared; other unknown headers and reserved headers remain rejected.
|
|
67
67
|
|
|
68
68
|
```bash
|
|
69
69
|
openany-dev run --id API_ID --headers '{"Accept":"application/json;version=20230203","Accept-Language":"zh-CN"}' -j
|
|
70
|
+
openany-dev run --id API_ID --headers '{"x-openany-partner-id":"PARTNER_ID"}' -j
|
|
70
71
|
```
|
|
71
72
|
|
|
73
|
+
Save a default partner ID once to automatically include `x-openany-partner-id` on API and model gateway requests:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
openany config set partner-id PARTNER_ID
|
|
77
|
+
openany config get partner-id
|
|
78
|
+
openany config unset partner-id
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
These local commands do not require an API key or access the network. The ID is stored in the existing restricted credentials file and survives later CLI invocations. Explicit `run --headers` values override the saved ID case-insensitively for that call; published API input constraints still apply. Backend requests do not receive the saved header. `config unset partner-id` removes the default, and `logout` clears it along with other local account configuration. Model calls use the saved default; `models run --headers` remains unsupported.
|
|
82
|
+
|
|
72
83
|
Balance checks use `GET /api/v1/agent-api-account` with a Bearer API key. This works with both wallet and email account keys. `run` reads the API contract, validates parameters, checks the balance, and calls the gateway. `calls list/get` retrieves model, data, and tool API usage records for the current key and requires a backend version that includes this fix. Status filters accept only `--status success` or `--status failed`. Passing `--review-required` produces a local error.
|
|
73
84
|
|
|
74
85
|
## Retrieving asynchronous API results
|
|
@@ -244,6 +255,14 @@ slug and maps `seller`/`seller_types` to the backend's
|
|
|
244
255
|
`provider`/`provider_types` fields before calling
|
|
245
256
|
`POST /api/v1/provider/account/registrations`. Use your real details and
|
|
246
257
|
explicit consents; never include credentials.
|
|
258
|
+
Include `seller.bio` (up to 280 characters after trimming) and
|
|
259
|
+
`seller.introductionHtml` (required supported HTML, up to 32768 UTF-8 bytes,
|
|
260
|
+
with at least 150 decoded visible text characters) in the application.
|
|
261
|
+
`resource.description` requires at least 50 Unicode characters and at most
|
|
262
|
+
2000 UTF-16 units. Both minimums remove all U+200B, trim Unicode whitespace
|
|
263
|
+
and U+FEFF, then count Unicode code points; HTML tags and attributes do not
|
|
264
|
+
count as visible text. HTML is submitted intact; the service validates and
|
|
265
|
+
filters supported markup.
|
|
247
266
|
The backend applies the website's validation and application approval workflow.
|
|
248
267
|
The returned `reg_...` ID identifies a registration, not an `--application` UUID.
|
|
249
268
|
Check its review status on the website; after administrator approval, run
|
|
@@ -253,6 +272,36 @@ If submission times out, check the website before any further submission.
|
|
|
253
272
|
Registration creation is non-idempotent: the CLI blocks replay of an uncertain
|
|
254
273
|
operation even with `--resume`. Do not use a new operation to bypass this check.
|
|
255
274
|
|
|
275
|
+
After approval, read or edit a selected seller's basic information:
|
|
276
|
+
|
|
277
|
+
```sh
|
|
278
|
+
openany-dev seller profile get --application APPLICATION_ID -j
|
|
279
|
+
openany-dev seller profile update --application APPLICATION_ID --file profile.json --operation seller-profile-1 -j
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
The update file is a flat JSON object containing only fields to change:
|
|
283
|
+
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"name": "Example Research",
|
|
287
|
+
"bio": "Public company research tools for teams.",
|
|
288
|
+
"introductionHtml": "<p>We provide public company research tools for teams. Our APIs help teams find company profiles, review public business information, and integrate research into their workflows.</p>",
|
|
289
|
+
"website": "https://example.com",
|
|
290
|
+
"contactEmail": "seller@example.com",
|
|
291
|
+
"telegram": "@example",
|
|
292
|
+
"whatsApp": "+1234567890"
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
`name` maps to the API's `providerName`. Omitted fields retain their current
|
|
297
|
+
values. `description` is also editable when an older profile needs to meet the
|
|
298
|
+
service's profile rules: at least 50 characters of description and 150 characters
|
|
299
|
+
of introduction text. The CLI reads the selected profile and its connection
|
|
300
|
+
revision before updating. It does not edit the slug, ownership, connection
|
|
301
|
+
credentials, or publication settings. An empty string clears an optional field.
|
|
302
|
+
Use `profile get` to verify the result. An uncertain update must be checked before
|
|
303
|
+
starting an independent operation; it is never blindly replayed with `--resume`.
|
|
304
|
+
|
|
256
305
|
To create a connection with a native macOS or Windows dialog, run:
|
|
257
306
|
|
|
258
307
|
```sh
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openany-cli-dev",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "OpenAny command-line client for internal dev testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"@solana/web3.js": "1.98.4",
|
|
20
20
|
"ajv": "8.17.1",
|
|
21
21
|
"bs58": "6.0.0",
|
|
22
|
-
"ethers": "6.17.0"
|
|
22
|
+
"ethers": "6.17.0",
|
|
23
|
+
"parse5": "8.1.1"
|
|
23
24
|
},
|
|
24
25
|
"license": "UNLICENSED",
|
|
25
26
|
"publishConfig": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: openany-seller
|
|
3
|
-
description: Use when a user wants to
|
|
3
|
+
description: Use when a user wants to apply as an OpenAny seller, edit seller profile or contact information, list resources, APIs or models, import configurations, publish verified resources, or check review and publication results.
|
|
4
4
|
metadata:
|
|
5
5
|
contract-version: seller-resource-reviews-v1
|
|
6
6
|
---
|
|
@@ -12,8 +12,8 @@ Use `openany-dev` for production at https://dev.openany.si and `openany-dev` for
|
|
|
12
12
|
## Basic workflow
|
|
13
13
|
|
|
14
14
|
1. **Complete login first.** Follow [Login](references/login.md) to confirm the CLI and session. If the user is known to be signed out, including when `local.configured: false`, skip repeat status checks. If the email address is missing, ask only “Which email address should I use to sign in to OpenAny?” Once the code has been sent, ask only for that code if the user needs to supply it. Wait for successful login before requesting resource materials or attempting an import, verification, or publication. Reuse an existing valid session.
|
|
15
|
-
2. **
|
|
16
|
-
3. **
|
|
15
|
+
2. **Select the seller for the task.** For profile edits or resource listings, use `seller applications list -j` as needed to confirm accessible sellers and admission status. Reuse known results; ask the user to choose only when multiple candidates remain. Use the selected UUID as `--application`. Query `seller status --application APPLICATION_ID -j` only for a missing capability; resolve insufficient permissions before proceeding.
|
|
16
|
+
3. **Follow the task workflow.** For applications or seller profile edits, read [Seller application and profile](references/application.md); applications require a 50-character description and 150 characters of visible introduction text; the profile section covers names, bios, introductions, websites and contacts. For connections, imports, verification or publication, read [Resource publishing](references/publishing.md) and follow the matching resource, API or model workflow. Confirm or create any required connection before collecting source materials. Confirm the material source; use the source form and matching template when materials are missing. Inspect a local file only after the user chooses it and provides its path. Ask only for missing or invalid fields and any unspecified stopping point. Testing and publication each require authorization within their respective scope.
|
|
17
17
|
4. **Determine the result from the receipt.** Query again only when the result is pending, incomplete, or uncertain. Report IDs, status, and the next step. Stop at the point the user requested.
|
|
18
18
|
|
|
19
19
|
For supported listing types and fee disclosures, see [Listing guidance](references/listing.md).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: openany-seller
|
|
3
|
-
description:
|
|
3
|
+
description: 当用户希望申请成为 OpenAny 卖家、修改卖家资料或联系方式、上架资源、API 或模型,或导入配置、发布已验证资源、查询审核与发布结果时使用。
|
|
4
4
|
metadata:
|
|
5
5
|
contract-version: seller-resource-reviews-v1
|
|
6
6
|
---
|
|
@@ -12,8 +12,8 @@ metadata:
|
|
|
12
12
|
## 基础执行流程
|
|
13
13
|
|
|
14
14
|
1. **先完成登录。**按[登录](references/login.zh-CN.md)确认 CLI 和会话。已知未登录(包括 `local.configured: false`)时跳过重复状态检查。缺邮箱时,本轮只问「这次用哪个邮箱登录 OpenAny?」;发送验证码后,如需用户提供,本轮只问本次验证码。等待登录成功后再继续,期间不索取资源资料,也不尝试导入、验证或发布。已有有效会话直接复用。
|
|
15
|
-
2.
|
|
16
|
-
3.
|
|
15
|
+
2. **选定本次操作的卖家。**修改资料或上架资源时,按需用 `seller applications list -j` 确认可访问卖家及准入状态,复用已有结果;多个候选才请用户选择。将选定 UUID 用作 `--application`。仅在缺少所需能力时查询 `seller status --application APPLICATION_ID -j`;权限不足先处理再继续。
|
|
16
|
+
3. **按任务读取对应流程。**申请或修改资料读[卖家申请与资料](references/application.zh-CN.md),申请须提供至少 50 字符的卖家介绍和至少 150 个可见文本字符的详细介绍;资料编辑涵盖名称、简介、详细介绍、网站及联系方式。连接、导入、验证或发布读[资源上架](references/publishing.zh-CN.md),按资源、API 或模型走对应流程。需要连接时先确认或创建,再收集源资料。先确认来源,缺资料时使用来源表单并显示对应模板;只有用户选定本地文件并提供路径后才检查该文件。只补缺失或无效字段及未明确的停止点。测试与发布各自须在授权范围内。
|
|
17
17
|
4. **用回执判断结果。**仅在结果未终结、缺字段或不确定时查询。报告 ID、状态和下一步,到达用户要求的停止点即结束。
|
|
18
18
|
|
|
19
19
|
了解可上架类型和费用说明,参见[上架说明](references/listing.zh-CN.md)。
|
|
@@ -1,49 +1,67 @@
|
|
|
1
|
-
# Seller application
|
|
1
|
+
# Seller application and profile
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use the login, native forms, and input handling in the [main entry](../SKILL.md). New sellers use the application section; existing sellers use the profile-editing section below.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Apply as a seller
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Collect only missing or invalid values and outstanding consents through the agent's native form. Reuse supplied answers and the signed-in account's email. Wait for actual answers, then prepare JSON internally rather than asking the user to write it. This application describes the seller's business; individual resources are configured after approval.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
| Website field | Application field | Requirement |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| Seller name | `seller.name` | Required text, at most 100 characters. |
|
|
12
|
+
| Contact email | `seller.email` | Reuse the signed-in account's email as read-only information. Resolve a missing session through login. |
|
|
13
|
+
| Store URL | `seller.slug` | User-selected, 1–63 lowercase letters or digits with single hyphens between words. Cannot change after submission. |
|
|
14
|
+
| Bio | `seller.bio` | Required by the website form; plain text, at most 280 characters after trimming. |
|
|
15
|
+
| Seller introduction | `seller.introductionHtml` | Required supported HTML, at most 32768 UTF-8 bytes, with at least 150 decoded visible text characters; tags and attributes do not count. |
|
|
16
|
+
| Seller type | `seller_types` | Explicitly choose Models (`model`), APIs (`api`), or both. |
|
|
17
|
+
| Seller description | `resource.description` | Required, at least 50 Unicode characters and at most 2,000 UTF-16 units: the seller's business, expertise and customers. The field path is retained for compatibility. |
|
|
18
|
+
| Main category | `resource.primary_category` | Use the website's current category choices and IDs. |
|
|
19
|
+
| Website or documentation | `connection.documentation_url` | Public HTTPS URL, at most 2048 characters, without credentials, IP addresses or fragments. |
|
|
20
|
+
| Contains personal data | `resource.contains_personal_data` | Boolean declaration; unchecked means false. |
|
|
21
|
+
| Rights to sell | `consents.authorized` | Explicit user confirmation. |
|
|
22
|
+
| Non-billable, non-destructive checks | `consents.automated_checks` | Separate explicit confirmation; paid tests require separate authorization. |
|
|
10
23
|
|
|
11
|
-
|
|
24
|
+
For the description and visible-text minimums, remove every U+200B, trim Unicode whitespace and U+FEFF from both ends, then count Unicode code points. Keep HTML intact for submission; the service validates supported markup and attributes.
|
|
12
25
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
| Contact email | `seller.email` | Required. Reuse the signed-in account's email and display it as read-only information without asking again. If no session exists, resolve email login first. |
|
|
17
|
-
| Supplier route | `seller.slug` | Required, 1–63 lowercase letters or digits, with single hyphens between words (`[a-z0-9]+(-[a-z0-9]+)*`). Explain that it cannot be changed after submission. Let the user choose; do not invent it. |
|
|
18
|
-
| Public seller bio | `seller.bio` | Optional plain text, at most 280 characters after trimming. It is saved when approval creates the seller profile. |
|
|
19
|
-
| What types of resources do you sell? | `seller_types` | Required: Models (`model`), APIs (`api`), or both. |
|
|
20
|
-
| Describe the resources you want to sell | `resource.description` | Required text, at most 2,000 characters. Describe the resources, their purpose, and target customers in this single field. |
|
|
21
|
-
| Primary category | `resource.primary_category` | Required. Use the website's current category choices and IDs; do not invent categories. |
|
|
22
|
-
| Website or documentation URL | `connection.documentation_url` | Required public HTTPS URL, at most 2,048 characters. Must not contain credentials, IP addresses, or URL fragments. |
|
|
23
|
-
| These resources contain personal data | `resource.contains_personal_data` | Boolean declaration matching the website's optional checkbox (unchecked means false). Do not require true or request personal data records. |
|
|
24
|
-
| I am authorized to provide and sell these resources | `consents.authorized` | Requires the user's explicit confirmation. |
|
|
25
|
-
| I allow free, non-destructive checks; paid tests require separate authorization | `consents.automated_checks` | Requires the user's explicit confirmation, separately from sales authorization. Do not infer either consent from the application request. |
|
|
26
|
+
Map the user's type choice to `["model"]`, `["api"]`, or `["model", "api"]`. Show it in the submission summary and check any returned `providerTypes` against it. Reuse explicit choices and consents; neither consent is preselected. If a value is missing or invalid, ask only for that value. Connection credentials, individual endpoints, prices and publication settings belong to later setup.
|
|
27
|
+
|
|
28
|
+
After validation, construct the [registration JSON](../templates/seller-registration.json): derive `resource.name` from the seller name, set `resource.type` to `model` for Models only and `service` otherwise, and use `resource.secondary_categories: []`, `connection.authentication: {"type":"none"}`, and `endpoints: []`. These are application defaults, not future service authentication settings. Resolve unavailable categories or contract mismatches before submitting.
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
Reuse the known seller list, or run `openany-dev seller applications list -j`, to check for duplicates. Once the user has requested submission and both consents are confirmed, run:
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
```bash
|
|
33
|
+
openany-dev seller applications create --file registration.json --operation TASK-registration-1 -j
|
|
34
|
+
```
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
The CLI maps `seller`/`seller_types` to the service's registration contract. Report the returned `id` (`reg_...`) and `reviewStatus`, then stop at application submission. Approval and resource publication are separate steps. After approval, select the resulting seller UUID from applications list for `--application`.
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
If creation times out, check the website account's application list before another submission. The same operation returns its completed receipt; an uncertain creation is not replayed, including with `--resume`. A new operation name is for an independent request, not a retry of an unknown outcome.
|
|
34
39
|
|
|
35
|
-
##
|
|
40
|
+
## Edit seller information
|
|
36
41
|
|
|
37
|
-
Reuse the
|
|
42
|
+
Reuse the selected seller UUID and read its current profile:
|
|
38
43
|
|
|
39
44
|
```bash
|
|
40
|
-
openany-dev seller
|
|
45
|
+
openany-dev seller profile get --application APPLICATION_ID -j
|
|
41
46
|
```
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
Collect only requested changes through the native form, using current values as context. Build a flat `profile.json` with the changed fields below. The CLI preserves omitted fields; `name` maps to the read result's `providerName`. Text is trimmed, while HTML formatting is preserved for service-side filtering.
|
|
49
|
+
|
|
50
|
+
| Update field | Requirement |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `name` | Nonblank, 1–100 characters after trimming. |
|
|
53
|
+
| `bio` | At most 280 characters after trimming; `""` clears it. |
|
|
54
|
+
| `introductionHtml` | HTML, at most 32768 UTF-8 bytes; the saved introduction needs at least 150 characters of visible text. |
|
|
55
|
+
| `description` | The saved seller description needs at least 50 characters. |
|
|
56
|
+
| `website` | HTTP or HTTPS URL, at most 2048 characters, without credentials; `""` clears it. |
|
|
57
|
+
| `contactEmail` | Valid, nonblank email address. |
|
|
58
|
+
| `telegram`, `whatsApp` | Text contact values; `""` clears either field. |
|
|
44
59
|
|
|
45
|
-
The
|
|
60
|
+
The description and introduction minimums apply to the resulting saved profile, including retained values. If older text is too short, ask for the missing content before saving. The 2,000-UTF-16-unit application description limit is not a profile-update rule. The CLI reads the current profile and connection revision internally; the update file contains basic information only.
|
|
46
61
|
|
|
47
|
-
|
|
62
|
+
```bash
|
|
63
|
+
openany-dev seller profile update --application APPLICATION_ID --file profile.json --operation TASK-profile-1 -j
|
|
64
|
+
openany-dev seller profile get --application APPLICATION_ID -j
|
|
65
|
+
```
|
|
48
66
|
|
|
49
|
-
|
|
67
|
+
Verify the changed values in the final read and report the result. A failed preparation read can reuse the same operation. For an uncertain write, read the profile and reconcile the outcome before another edit; `--resume` does not repeat that write.
|
|
@@ -1,51 +1,67 @@
|
|
|
1
|
+
# 卖家申请与资料
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
沿用[主入口](../SKILL.zh-CN.md)的登录、原生表单和输入处理流程。新卖家走申请流程,已有卖家走下文的资料修改流程。
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
## 申请成为卖家
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
用 Agent 原生表单补齐缺失或无效字段及尚未确认的同意项,复用已有答案和当前登录账号的邮箱。等待用户实际作答后,在内部构造 JSON,不要求用户编写。这里介绍卖家的业务,具体资源在审核通过后配置。
|
|
7
8
|
|
|
9
|
+
| 网站字段 | 申请字段 | 要求 |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| 卖家名称 | `seller.name` | 必填文本,最多 100 个字符。 |
|
|
12
|
+
| 联系邮箱 | `seller.email` | 复用当前登录账号的邮箱,以只读信息展示;没有会话时先登录。 |
|
|
13
|
+
| 店铺地址 | `seller.slug` | 由用户选择,1–63 位小写字母或数字,单词间使用单个连接符;提交后不可修改。 |
|
|
14
|
+
| 简介 | `seller.bio` | 网站表单必填;纯文本,去除首尾空白后最多 280 个字符。 |
|
|
15
|
+
| 详细介绍 | `seller.introductionHtml` | 必填受支持的 HTML,最多 32768 个 UTF-8 字节,解码后的可见文本至少 150 个字符;标签和属性不计入。 |
|
|
16
|
+
| 卖家类型 | `seller_types` | 明确选择 Models(`model`)、APIs(`api`)或两者。 |
|
|
17
|
+
| 卖家介绍 | `resource.description` | 必填,至少 50 个 Unicode 字符、最多 2,000 个 UTF-16 单元:介绍业务、专业能力和服务客户;字段路径为兼容旧协议保留。 |
|
|
18
|
+
| 主营分类 | `resource.primary_category` | 使用网站当前分类选项及 ID。 |
|
|
19
|
+
| 网站或文档 | `connection.documentation_url` | 公共 HTTPS 地址,最多 2048 个字符,无凭据、IP 地址或片段。 |
|
|
20
|
+
| 包含个人数据 | `resource.contains_personal_data` | 布尔声明,未勾选表示 false。 |
|
|
21
|
+
| 有权销售 | `consents.authorized` | 用户明确确认。 |
|
|
22
|
+
| 非收费、非破坏性检查 | `consents.automated_checks` | 用户单独明确确认;付费测试另行授权。 |
|
|
8
23
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
异步表单发出后等待用户作答,期间不在对话里重复提问。工具返回 accepted、预选项、沉默或超时都不代表回答。按工具限制合并独立的缺失字段,减少来回;已给出的字段和明确同意不重复询问。
|
|
24
|
+
介绍及可见文本的最小长度均先删除全部 U+200B,再去除首尾 Unicode 空白与 U+FEFF,最后按 Unicode 码点计数。HTML 原样提交,由服务端校验支持的标签及属性。
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
将用户的类型选择映射为 `["model"]`、`["api"]` 或 `["model", "api"]`,在提交摘要中展示,并核对回执中的 `providerTypes`。复用明确选择和同意;两个同意项均不预选。字段缺失或无效时只补问对应项。连接凭据、具体端点、价格和发布设置在后续配置。
|
|
14
27
|
|
|
15
|
-
|
|
16
|
-
| --- | --- | --- |
|
|
17
|
-
| 供应商名称 | `seller.name` | 必填文本,最多 100 个字符。 |
|
|
18
|
-
| 联系邮箱 | `seller.email` | 必填;复用已登录账号的邮箱,以只读信息展示,不额外提问。如果缺少会话,先通过邮箱登录解决。 |
|
|
19
|
-
| 供应商路由 | `seller.slug` | 必填,1–63 位小写字母或数字,单词之间使用单个连接符(`[a-z0-9]+(-[a-z0-9]+)*`)。说明提交后不可修改;由用户选择,不要擅自编造。 |
|
|
20
|
-
| 商家一句话简介 | `seller.bio` | 选填纯文本,去除首尾空白后最多 280 字;审批创建卖家资料时保存。 |
|
|
21
|
-
| 销售哪些类型的资源? | `seller_types` | 必填:Models(`model`)、APIs(`api`),或两者。 |
|
|
22
|
-
| 介绍你要销售的资源 | `resource.description` | 必填文本,最多 2,000 个字符:在同一个字段中说明资源、用途和目标客户。 |
|
|
23
|
-
| 主营分类 | `resource.primary_category` | 必填;使用网站当前的分类选项及 ID,不要编造分类。 |
|
|
24
|
-
| 网站或文档链接 | `connection.documentation_url` | 必填的公共 HTTPS 地址,最多 2,048 个字符;不得包含凭据、IP 地址或 URL 片段。 |
|
|
25
|
-
| 这些资源包含个人数据 | `resource.contains_personal_data` | 布尔声明,对应网站的可选复选框(未勾选表示 false);不得要求必须为 true,也不要索取个人数据记录。 |
|
|
26
|
-
| 我有权提供并销售这些资源 | `consents.authorized` | 必须由用户明确确认。 |
|
|
27
|
-
| 我允许不收费、无破坏性的检查;付费测试需另行授权 | `consents.automated_checks` | 必须由用户明确确认,并与销售权利的确认分开;不得因用户提出申请就推断其已同意任一事项。 |
|
|
28
|
+
校验通过后构造[申请 JSON](../templates/seller-registration.json):从卖家名称生成 `resource.name`;仅 Models 时 `resource.type` 为 `model`,否则为 `service`;设置 `resource.secondary_categories: []`、`connection.authentication: {"type":"none"}` 和 `endpoints: []`。这些是申请默认值,不代表未来服务的认证方式。分类不可用或接口约定不一致时先核实再提交。
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
复用已知卖家列表,缺少时运行 `openany-dev seller applications list -j` 检查重复申请。用户已要求提交且两个同意项均已确认后运行:
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
```bash
|
|
33
|
+
openany-dev seller applications create --file registration.json --operation TASK-registration-1 -j
|
|
34
|
+
```
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
CLI 将 `seller`、`seller_types` 映射到服务端申请协议。报告返回的 `id`(`reg_...`)和 `reviewStatus`,到申请提交即停止。审批和资源发布是后续步骤;获批后从 applications list 选择卖家 UUID,用作 `--application`。
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
创建超时后先在网站账号的申请列表核实,再决定下一步。同一 operation 可返回已完成回执;结果不确定的创建不会重放,包括使用 `--resume`。新 operation 用于独立请求,不用于重试未知结果。
|
|
36
39
|
|
|
37
|
-
##
|
|
40
|
+
## 修改卖家信息
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
复用选定的卖家 UUID,先读取当前资料:
|
|
40
43
|
|
|
41
44
|
```bash
|
|
42
|
-
openany-dev seller
|
|
45
|
+
openany-dev seller profile get --application APPLICATION_ID -j
|
|
43
46
|
```
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
以当前值为上下文,用原生表单仅收集用户要求的修改,生成只含变更字段的平铺 `profile.json`。CLI 保留未传字段;`name` 对应读取结果中的 `providerName`。文本去除首尾空白,HTML 保留格式并由服务端过滤。
|
|
49
|
+
|
|
50
|
+
| 修改字段 | 要求 |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `name` | 去除首尾空白后非空,1–100 个字符。 |
|
|
53
|
+
| `bio` | 去除首尾空白后最多 280 个字符;`""` 表示清空。 |
|
|
54
|
+
| `introductionHtml` | HTML 最多 32768 个 UTF-8 字节;保存后的介绍至少包含 150 个可见文本字符。 |
|
|
55
|
+
| `description` | 保存后的卖家介绍至少 50 个字符。 |
|
|
56
|
+
| `website` | HTTP 或 HTTPS 地址,最多 2048 个字符,无凭据;`""` 表示清空。 |
|
|
57
|
+
| `contactEmail` | 有效且非空的邮箱地址。 |
|
|
58
|
+
| `telegram`、`whatsApp` | 文本联系方式;`""` 可清空对应字段。 |
|
|
46
59
|
|
|
47
|
-
|
|
60
|
+
描述和详细介绍的最低长度适用于最终保存的资料,包括保留的原值。旧资料不足时先请用户补齐;申请阶段的 2,000 个 UTF-16 单元描述上限不适用于资料修改。CLI 内部读取当前资料和连接版本,更新文件只填写基础信息。
|
|
48
61
|
|
|
49
|
-
|
|
62
|
+
```bash
|
|
63
|
+
openany-dev seller profile update --application APPLICATION_ID --file profile.json --operation TASK-profile-1 -j
|
|
64
|
+
openany-dev seller profile get --application APPLICATION_ID -j
|
|
65
|
+
```
|
|
50
66
|
|
|
51
|
-
|
|
67
|
+
最后读取并核对变更值,再报告结果。准备阶段读取失败可复用同一 operation;实际写入结果不确定时先读取资料核实,再决定下一次编辑,`--resume` 不会重复该写入。
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
"name": "Example Research",
|
|
4
4
|
"email": "seller@example.com",
|
|
5
5
|
"slug": "example-research",
|
|
6
|
-
"bio": "Public company research tools for teams."
|
|
6
|
+
"bio": "Public company research tools for teams.",
|
|
7
|
+
"introductionHtml": "<h2>About Example Research</h2><p>We build public company research APIs for analysts and business teams. Search company profiles by domain, review public business information, and integrate structured research results into your existing workflows.</p>"
|
|
7
8
|
},
|
|
8
9
|
"seller_types": ["api"],
|
|
9
10
|
"resource": {
|
|
10
11
|
"name": "Example Research",
|
|
11
|
-
"description": "
|
|
12
|
+
"description": "Example Research builds public company research APIs for analysts and business teams, specializing in company profiles and public business data.",
|
|
12
13
|
"type": "service",
|
|
13
14
|
"primary_category": "search-research",
|
|
14
15
|
"secondary_categories": [],
|
package/src/catalog.js
CHANGED
|
@@ -144,7 +144,7 @@ export function prepareApiRequest(
|
|
|
144
144
|
for (const [location, values] of Object.entries(groups))
|
|
145
145
|
for (const name of Object.keys(values))
|
|
146
146
|
if (
|
|
147
|
-
!(location === "header" && /^(accept|accept-language)$/i.test(name)) &&
|
|
147
|
+
!(location === "header" && /^(accept|accept-language|x-openany-partner-id)$/i.test(name)) &&
|
|
148
148
|
!definition.inputs.some(
|
|
149
149
|
(f) =>
|
|
150
150
|
f.location === location &&
|
|
@@ -276,10 +276,14 @@ export async function runApi(options, ctx) {
|
|
|
276
276
|
const definition = unwrap(
|
|
277
277
|
await ctx.http.backend(`/api/v1/agent-apis/${encodeURIComponent(id)}`),
|
|
278
278
|
);
|
|
279
|
+
let headers = ctx.jsonOption("headers", {});
|
|
280
|
+
if (ctx.http.partnerId && isObject(headers) &&
|
|
281
|
+
!Object.keys(headers).some(name => name.toLowerCase() === "x-openany-partner-id"))
|
|
282
|
+
headers = { ...headers, "x-openany-partner-id": ctx.http.partnerId };
|
|
279
283
|
const prepared = prepareApiRequest(definition, {
|
|
280
284
|
path: ctx.jsonOption("path", {}),
|
|
281
285
|
query: ctx.jsonOption("query", {}),
|
|
282
|
-
headers
|
|
286
|
+
headers,
|
|
283
287
|
body: await ctx.input(),
|
|
284
288
|
});
|
|
285
289
|
const account = unwrap(
|
package/src/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import packageInfo from "../package.json" with { type: "json" };
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { readFile, writeFile, lstat, mkdtemp } from "node:fs/promises";
|
|
6
|
-
import { ConfigStore, configurationStatus } from "./config.js";
|
|
6
|
+
import { ConfigStore, configurationStatus, runConfig } from "./config.js";
|
|
7
7
|
import { CLIError, errorRecord, redact, requireValue } from "./errors.js";
|
|
8
8
|
import { HttpClient, unwrap } from "./http.js";
|
|
9
9
|
import { listQuery, runApi, formatMicroUsd } from "./catalog.js";
|
|
@@ -17,6 +17,9 @@ Model execution uses the OpenAny gateway with the path and query from curlExampl
|
|
|
17
17
|
setup --api_key api_key --gui [-j] (native API key dialog)
|
|
18
18
|
setup --wallet_connect wallet --gui [-j] (native wallet dialog)
|
|
19
19
|
logout [-j] (back up and remove all local account configuration)
|
|
20
|
+
config set partner-id VALUE [-j] (save the default gateway partner ID)
|
|
21
|
+
config get partner-id [-j]
|
|
22
|
+
config unset partner-id [-j]
|
|
20
23
|
status_check wallet|email|api_key|payment [-j]
|
|
21
24
|
Legacy syntax (still supported):
|
|
22
25
|
setup [--scenario call|wallet|email] (interactive terminal setup)
|
|
@@ -51,6 +54,8 @@ Model execution uses the OpenAny gateway with the path and query from curlExampl
|
|
|
51
54
|
Requires OPENANY_DEV_SELLER_KEY and absolute OPENANY_TASK_ROOT; does not settle the task.
|
|
52
55
|
seller status [--application ID]
|
|
53
56
|
seller applications list|create --file REGISTRATION_JSON --operation NAME
|
|
57
|
+
seller profile get --application ID
|
|
58
|
+
seller profile update --application ID --file PROFILE_JSON --operation NAME
|
|
54
59
|
seller connections list|get|create --application ID [--id ID]
|
|
55
60
|
create --file JSON --operation NAME [--stdin] (or OPENANY_CONNECTION_API_KEY)
|
|
56
61
|
create --gui --operation NAME [-j] (native connection dialog; macOS/Windows)
|
|
@@ -406,6 +411,7 @@ export async function runCommand(args, ctx) {
|
|
|
406
411
|
return runSetup(ctx);
|
|
407
412
|
}
|
|
408
413
|
if (command === "status") return configurationStatus(store, options);
|
|
414
|
+
if (command === "config") return runConfig(args, ctx);
|
|
409
415
|
if (
|
|
410
416
|
command === "keys" &&
|
|
411
417
|
!["remote", "create", "rotate", "revoke"].includes(args[1])
|
|
@@ -550,7 +556,9 @@ export async function main(
|
|
|
550
556
|
env = await store.getEnvironment();
|
|
551
557
|
const apiKey = await store.getApiKey();
|
|
552
558
|
if (apiKey) secrets.push(apiKey);
|
|
553
|
-
const
|
|
559
|
+
const partnerId = args[0] === "config" || args[0] === "logout"
|
|
560
|
+
? null : await store.getPartnerId();
|
|
561
|
+
const http = new HttpClient({ fetch, apiKey, partnerId });
|
|
554
562
|
const ctx = {
|
|
555
563
|
args,
|
|
556
564
|
options,
|
package/src/config.js
CHANGED
|
@@ -151,6 +151,11 @@ export class ConfigStore {
|
|
|
151
151
|
const state = await this.read();
|
|
152
152
|
return state.keys.find((k) => k.label === state.activeKey)?.key || null;
|
|
153
153
|
}
|
|
154
|
+
async getPartnerId() {
|
|
155
|
+
const state = await this.read();
|
|
156
|
+
const value = state.settings?.partnerId;
|
|
157
|
+
return value === undefined ? null : validatePartnerId(value, "CONFIG_INVALID");
|
|
158
|
+
}
|
|
154
159
|
async getEnvironment() {
|
|
155
160
|
const { settings = {} } = await this.read();
|
|
156
161
|
if (!settings || typeof settings !== "object" || Array.isArray(settings))
|
|
@@ -170,6 +175,28 @@ export class ConfigStore {
|
|
|
170
175
|
}
|
|
171
176
|
}
|
|
172
177
|
|
|
178
|
+
function validatePartnerId(value, code = "INVALID_INPUT") {
|
|
179
|
+
if (typeof value !== "string" || !value.trim() || !/^[\x20-\x7e]+$/.test(value))
|
|
180
|
+
throw new CLIError(code, "Partner ID must be a non-empty printable ASCII header value");
|
|
181
|
+
return value.trim();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export async function runConfig(args, { store, options }) {
|
|
185
|
+
const [, action, name, value] = args;
|
|
186
|
+
if (name !== "partner-id" || !["set", "get", "unset"].includes(action) ||
|
|
187
|
+
args.length !== (action === "set" ? 4 : 3) ||
|
|
188
|
+
Object.keys(options).some(key => !["json", "output"].includes(key)))
|
|
189
|
+
throw new CLIError("INVALID_INPUT", "Use config set partner-id VALUE, config get partner-id, or config unset partner-id");
|
|
190
|
+
if (action === "get") return { partnerId: await store.getPartnerId() };
|
|
191
|
+
const partnerId = action === "set" ? validatePartnerId(value) : null;
|
|
192
|
+
return store.update(state => {
|
|
193
|
+
state.settings = { ...state.settings };
|
|
194
|
+
if (partnerId === null) delete state.settings.partnerId;
|
|
195
|
+
else state.settings.partnerId = partnerId;
|
|
196
|
+
return { partnerId, saved: true };
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
173
200
|
export async function configurationStatus(store, options = {}) {
|
|
174
201
|
const env = await store.getEnvironment();
|
|
175
202
|
const state = await store.read();
|
package/src/http.js
CHANGED
|
@@ -58,10 +58,12 @@ export class HttpClient {
|
|
|
58
58
|
constructor({
|
|
59
59
|
fetch: fetcher = globalThis.fetch,
|
|
60
60
|
apiKey,
|
|
61
|
+
partnerId,
|
|
61
62
|
timeoutMs = 120000,
|
|
62
63
|
} = {}) {
|
|
63
64
|
this.fetch = fetcher;
|
|
64
65
|
this.apiKey = apiKey;
|
|
66
|
+
this.partnerId = partnerId;
|
|
65
67
|
this.timeoutMs = timeoutMs;
|
|
66
68
|
}
|
|
67
69
|
backend(path, options = {}) {
|
|
@@ -127,6 +129,8 @@ export class HttpClient {
|
|
|
127
129
|
for (const item of Array.isArray(value) ? value : [value])
|
|
128
130
|
url.searchParams.append(key, String(item));
|
|
129
131
|
const headers = new Headers(extra);
|
|
132
|
+
if (origin === GATEWAY_ORIGIN && this.partnerId && !headers.has("x-openany-partner-id"))
|
|
133
|
+
headers.set("x-openany-partner-id", this.partnerId);
|
|
130
134
|
for (const name of [
|
|
131
135
|
"authorization",
|
|
132
136
|
"cookie",
|
package/src/provider-client.js
CHANGED
|
@@ -77,7 +77,7 @@ export class ProviderClient {
|
|
|
77
77
|
method,
|
|
78
78
|
json,
|
|
79
79
|
operation,
|
|
80
|
-
{ global = false, verification = false, recover = false, registration = false, validate, selectResult = value => value } = {},
|
|
80
|
+
{ global = false, verification = false, recover = false, registration = false, validate, prepare, selectResult = value => value } = {},
|
|
81
81
|
) {
|
|
82
82
|
requireValue(operation, "--operation");
|
|
83
83
|
await this.credential();
|
|
@@ -114,10 +114,13 @@ export class ProviderClient {
|
|
|
114
114
|
{ operation, resourceId: state.resourceId },
|
|
115
115
|
);
|
|
116
116
|
await updateOperation(this.ctx.store, operation, { state: "sending" });
|
|
117
|
+
let writeStarted = false;
|
|
117
118
|
try {
|
|
119
|
+
const requestJson = prepare ? await prepare(json) : json;
|
|
120
|
+
writeStarted = true;
|
|
118
121
|
const result = selectResult(await this.requestPath(
|
|
119
122
|
path,
|
|
120
|
-
{ method, json, ...(!registration ? { headers: { "Idempotency-Key": state.key } } : {}) },
|
|
123
|
+
{ method, json: requestJson, ...(!registration ? { headers: { "Idempotency-Key": state.key } } : {}) },
|
|
121
124
|
));
|
|
122
125
|
if (app !== this.application)
|
|
123
126
|
throw new CLIError(
|
|
@@ -130,7 +133,7 @@ export class ProviderClient {
|
|
|
130
133
|
});
|
|
131
134
|
return result;
|
|
132
135
|
} catch (error) {
|
|
133
|
-
if (uncertain(error) && method === "PUT") {
|
|
136
|
+
if (writeStarted && uncertain(error) && method === "PUT") {
|
|
134
137
|
try {
|
|
135
138
|
error.details = {
|
|
136
139
|
...error.details,
|
|
@@ -144,7 +147,7 @@ export class ProviderClient {
|
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
await updateOperation(this.ctx.store, operation, {
|
|
147
|
-
state: uncertain(error) ? "unknown" : "failed",
|
|
150
|
+
state: writeStarted && uncertain(error) ? "unknown" : "failed",
|
|
148
151
|
errorCode: error.code || "INTERNAL_ERROR",
|
|
149
152
|
});
|
|
150
153
|
throw error;
|
package/src/provider-profile.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CLIError } from "./errors.js";
|
|
2
|
+
import { validateSellerRegistration } from "./seller-registration-validation.js";
|
|
2
3
|
import { assertNoSecrets, receipt } from "./provider-state.js";
|
|
3
4
|
export async function runProfile(action, client, ctx) {
|
|
4
5
|
if (action === "list") return client.request("", {}, true);
|
|
@@ -41,6 +42,7 @@ export async function runProfile(action, client, ctx) {
|
|
|
41
42
|
throw new CLIError("INVALID_INPUT", "Enter seller.bio as text with at most 280 characters", { field: "seller.bio" });
|
|
42
43
|
provider.bio = provider.bio.trim();
|
|
43
44
|
}
|
|
45
|
+
validateSellerRegistration(input);
|
|
44
46
|
const registration = { ...rest, provider, provider_types: seller_types };
|
|
45
47
|
return receipt(await client.write("", "POST", registration, ctx.options.operation, {
|
|
46
48
|
registration: true,
|
package/src/provider.js
CHANGED
|
@@ -2,6 +2,7 @@ import { sellerInput } from "./seller-fields.js";
|
|
|
2
2
|
import { ProviderClient } from "./provider-client.js";
|
|
3
3
|
import { CLIError } from "./errors.js";
|
|
4
4
|
import { runProfile } from "./provider-profile.js";
|
|
5
|
+
import { runSellerProfile } from "./seller-profile.js";
|
|
5
6
|
import { runConnections } from "./provider-connections.js";
|
|
6
7
|
import { runResource } from "./provider-models.js";
|
|
7
8
|
import { runReviews } from "./provider-reviews.js";
|
|
@@ -50,6 +51,7 @@ export async function runProvider(args, ctx) {
|
|
|
50
51
|
throw error;
|
|
51
52
|
}
|
|
52
53
|
if (group === "status") return runProfile("status", client, ctx);
|
|
54
|
+
if (group === "profile") return runSellerProfile(action, client, ctx);
|
|
53
55
|
if (group === "applications") return runProfile(action, client, ctx);
|
|
54
56
|
if (group === "connections") return runConnections(action, client, ctx);
|
|
55
57
|
if (group === "models" || group === "apis")
|
|
@@ -80,6 +82,6 @@ export async function runProvider(args, ctx) {
|
|
|
80
82
|
}
|
|
81
83
|
throw new CLIError(
|
|
82
84
|
"UNKNOWN_COMMAND",
|
|
83
|
-
"Seller commands: status|applications|connections|models|apis|reviews|imports|schema",
|
|
85
|
+
"Seller commands: status|applications|profile|connections|models|apis|reviews|imports|schema",
|
|
84
86
|
);
|
|
85
87
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CLIError } from './errors.js';
|
|
2
|
+
import { assertNoSecrets, receipt, uuid } from './provider-state.js';
|
|
3
|
+
|
|
4
|
+
const editable = ['name', 'bio', 'introductionHtml', 'website', 'contactEmail', 'telegram', 'whatsApp', 'description'];
|
|
5
|
+
const preserved = ['applicationType', 'requestedTrustLevel', 'providerName', 'website', 'legalName', 'description', 'introductionHtml', 'bio', 'contactEmail', 'telegram', 'whatsApp', 'modelsUrl', 'dataPolicy', 'authorizationDetails'];
|
|
6
|
+
|
|
7
|
+
export function validateIntroduction(value, field) {
|
|
8
|
+
if (typeof value !== 'string' || Buffer.byteLength(value, 'utf8') > 32768)
|
|
9
|
+
throw new CLIError('INVALID_INPUT', 'Introduction must be HTML text up to 32768 bytes', { field });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function profilePatch(input) {
|
|
13
|
+
if (!input || typeof input !== 'object' || Array.isArray(input) || !Object.keys(input).length)
|
|
14
|
+
throw new CLIError('INVALID_INPUT', 'Supply a nonempty seller profile JSON object');
|
|
15
|
+
assertNoSecrets(input);
|
|
16
|
+
const patch = {};
|
|
17
|
+
for (const [key, value] of Object.entries(input)) {
|
|
18
|
+
if (!editable.includes(key)) throw new CLIError('FORBIDDEN_FIELD', 'Only seller basic information can be edited', { field: key });
|
|
19
|
+
if (typeof value !== 'string') throw new CLIError('INVALID_INPUT', 'Profile fields must be text', { field: key });
|
|
20
|
+
if (key === 'introductionHtml') validateIntroduction(value, key);
|
|
21
|
+
const text = key === 'introductionHtml' ? value : value.trim();
|
|
22
|
+
if (key === 'name' && (!text || [...text].length > 100))
|
|
23
|
+
throw new CLIError('INVALID_INPUT', 'Enter a seller name of 1–100 characters', { field: key });
|
|
24
|
+
if (key === 'bio' && [...text].length > 280)
|
|
25
|
+
throw new CLIError('INVALID_INPUT', 'Enter a bio of at most 280 characters', { field: key });
|
|
26
|
+
if (key === 'contactEmail' && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(text))
|
|
27
|
+
throw new CLIError('INVALID_INPUT', 'Enter a valid contact email', { field: key });
|
|
28
|
+
if (key === 'website' && text) {
|
|
29
|
+
let url;
|
|
30
|
+
try { url = new URL(text); } catch { /* Report the validation error below. */ }
|
|
31
|
+
if (!url || !['https:', 'http:'].includes(url.protocol) || url.username || url.password || text.length > 2048)
|
|
32
|
+
throw new CLIError('INVALID_INPUT', 'Enter an HTTP(S) website URL without credentials', { field: key });
|
|
33
|
+
}
|
|
34
|
+
patch[key === 'name' ? 'providerName' : key] = text;
|
|
35
|
+
}
|
|
36
|
+
return patch;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function runSellerProfile(action, client, ctx) {
|
|
40
|
+
if (action === 'get') {
|
|
41
|
+
const current = await client.request('');
|
|
42
|
+
if (!current || typeof current.id !== 'string' || current.id.toLowerCase() !== client.application.toLowerCase())
|
|
43
|
+
throw new CLIError('INVALID_RESPONSE', 'Seller profile does not match the selected application');
|
|
44
|
+
return Object.fromEntries(['id', 'providerSlug', 'status', ...preserved].filter(key => Object.hasOwn(current, key)).map(key => [key, current[key]]));
|
|
45
|
+
}
|
|
46
|
+
if (action !== 'update') throw new CLIError('UNKNOWN_COMMAND', 'Seller profile supports get|update');
|
|
47
|
+
const patch = profilePatch(await ctx.input());
|
|
48
|
+
return receipt(await client.write('', 'PUT', patch, ctx.options.operation, {
|
|
49
|
+
// Reserve the user's patch before reading mutable server state. Completed and
|
|
50
|
+
// uncertain operations retain their identity even if the connection changes.
|
|
51
|
+
prepare: async () => {
|
|
52
|
+
const current = await client.request('');
|
|
53
|
+
if (!current || typeof current.id !== 'string' || current.id.toLowerCase() !== client.application.toLowerCase())
|
|
54
|
+
throw new CLIError('INVALID_RESPONSE', 'Seller profile does not match the selected application');
|
|
55
|
+
const connection = await client.request('/connections/' + uuid(current.upstreamKeyId, 'connection'));
|
|
56
|
+
if (!Number.isSafeInteger(connection?.revision) || connection.revision < 1)
|
|
57
|
+
throw new CLIError('INVALID_RESPONSE', 'The seller connection revision is unavailable');
|
|
58
|
+
const payload = Object.fromEntries(preserved.filter(key => Object.hasOwn(current, key)).map(key => [key, current[key]]));
|
|
59
|
+
return { ...payload, ...patch, expectedApplicationId: client.application, expectedUpstreamRevision: connection.revision };
|
|
60
|
+
},
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { parseFragment } from 'parse5';
|
|
2
|
+
import { CLIError } from './errors.js';
|
|
3
|
+
import { validateIntroduction } from './seller-profile.js';
|
|
4
|
+
|
|
5
|
+
// Match the service's Unicode text minimums, including NEL and BOM whitespace.
|
|
6
|
+
const characterCount = value => [...value.replace(/\u200b/g, '').replace(/^[\p{White_Space}\ufeff]+|[\p{White_Space}\ufeff]+$/gu, '')].length;
|
|
7
|
+
const supportedTags = new Set('p div span br hr h2 h3 h4 h5 h6 strong b em i u s ul ol li blockquote pre code a table caption thead tbody tfoot tr th td'.split(' '));
|
|
8
|
+
|
|
9
|
+
export function validateSellerRegistration(input) {
|
|
10
|
+
const description = input.resource?.description;
|
|
11
|
+
if (typeof description !== 'string' || characterCount(description) < 50 || description.length > 2000)
|
|
12
|
+
throw new CLIError('INVALID_INPUT', 'Seller description must contain at least 50 Unicode characters and at most 2000 UTF-16 units', { field: 'resource.description' });
|
|
13
|
+
|
|
14
|
+
const field = 'seller.introductionHtml';
|
|
15
|
+
const html = input.seller.introductionHtml;
|
|
16
|
+
validateIntroduction(html, field);
|
|
17
|
+
const invalidHtml = () => { throw new CLIError('INVALID_INPUT', 'Seller introduction must use supported text HTML', { field }); };
|
|
18
|
+
if (html.includes('\0')) invalidHtml();
|
|
19
|
+
function visibleText(node, depth = 0) {
|
|
20
|
+
if (depth > 40) invalidHtml();
|
|
21
|
+
if (node.nodeName === '#text') return node.value;
|
|
22
|
+
if (!supportedTags.has(node.tagName) || node.namespaceURI !== 'http://www.w3.org/1999/xhtml') invalidHtml();
|
|
23
|
+
return node.childNodes.map(child => visibleText(child, depth + 1)).join('');
|
|
24
|
+
}
|
|
25
|
+
// Attributes never count as text. The service validates layout and link attributes.
|
|
26
|
+
const text = parseFragment(html).childNodes.map(node => visibleText(node)).join('');
|
|
27
|
+
if (characterCount(text) < 150)
|
|
28
|
+
throw new CLIError('INVALID_INPUT', 'Seller introduction must contain at least 150 visible Unicode text characters', { field });
|
|
29
|
+
}
|