@open-mercato/cli 0.10.1-develop.7758.1.fb3a60392f → 0.10.1-develop.7759.1.416727583e
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/.turbo/turbo-build.log +1 -1
- package/dist/agentic/guides/module-facts.json +162 -162
- package/dist/agentic/guides/module-facts.v2.json +162 -162
- package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
- package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
- package/dist/agentic/guides/modules/api_docs/index.md +1 -1
- package/dist/agentic/guides/modules/api_keys/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/index.md +1 -1
- package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
- package/dist/agentic/guides/modules/auth/index.md +1 -1
- package/dist/agentic/guides/modules/availability/index.md +1 -1
- package/dist/agentic/guides/modules/business_rules/index.md +1 -1
- package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
- package/dist/agentic/guides/modules/cart/index.md +1 -1
- package/dist/agentic/guides/modules/catalog/index.md +1 -1
- package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
- package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
- package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
- package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
- package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
- package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
- package/dist/agentic/guides/modules/configs/index.md +1 -1
- package/dist/agentic/guides/modules/content/index.md +1 -1
- package/dist/agentic/guides/modules/currencies/index.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
- package/dist/agentic/guides/modules/customers/index.md +1 -1
- package/dist/agentic/guides/modules/dashboards/index.md +1 -1
- package/dist/agentic/guides/modules/data_sync/index.md +1 -1
- package/dist/agentic/guides/modules/design_system/index.md +1 -1
- package/dist/agentic/guides/modules/devices/index.md +1 -1
- package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
- package/dist/agentic/guides/modules/directory/index.md +1 -1
- package/dist/agentic/guides/modules/documents/index.md +1 -1
- package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
- package/dist/agentic/guides/modules/entities/index.md +1 -1
- package/dist/agentic/guides/modules/eudr/index.md +1 -1
- package/dist/agentic/guides/modules/events/index.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
- package/dist/agentic/guides/modules/forms/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
- package/dist/agentic/guides/modules/generators/index.md +1 -1
- package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
- package/dist/agentic/guides/modules/integrations/index.md +1 -1
- package/dist/agentic/guides/modules/messages/index.md +1 -1
- package/dist/agentic/guides/modules/notifications/index.md +1 -1
- package/dist/agentic/guides/modules/onboarding/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
- package/dist/agentic/guides/modules/perspectives/index.md +1 -1
- package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
- package/dist/agentic/guides/modules/planner/index.md +1 -1
- package/dist/agentic/guides/modules/portal/index.md +1 -1
- package/dist/agentic/guides/modules/progress/index.md +1 -1
- package/dist/agentic/guides/modules/promotions/index.md +1 -1
- package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
- package/dist/agentic/guides/modules/query_index/index.md +1 -1
- package/dist/agentic/guides/modules/record_locks/index.md +1 -1
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/sales/index.md +1 -1
- package/dist/agentic/guides/modules/scheduler/index.md +1 -1
- package/dist/agentic/guides/modules/search/index.md +1 -1
- package/dist/agentic/guides/modules/security/index.md +1 -1
- package/dist/agentic/guides/modules/seeds/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/index.md +1 -1
- package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
- package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
- package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
- package/dist/agentic/guides/modules/telemetry/index.md +1 -1
- package/dist/agentic/guides/modules/tillio/index.md +1 -1
- package/dist/agentic/guides/modules/translations/index.md +1 -1
- package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
- package/dist/agentic/guides/modules/webhooks/index.md +1 -1
- package/dist/agentic/guides/modules/wms/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/reference-module-facts.json +1 -1
- package/dist/agentic/guides/upstream/manifest.json +1 -1
- package/dist/lib/module-search-args.js +97 -0
- package/dist/lib/module-search-args.js.map +7 -0
- package/dist/lib/module-search-index.js +677 -0
- package/dist/lib/module-search-index.js.map +7 -0
- package/dist/lib/module-search.js +668 -0
- package/dist/lib/module-search.js.map +7 -0
- package/dist/lib/modules-config.js +5 -0
- package/dist/lib/modules-config.js.map +2 -2
- package/dist/mercato.js +13 -3
- package/dist/mercato.js.map +2 -2
- package/package.json +8 -7
- package/src/__tests__/mercato.test.ts +57 -0
- package/src/lib/__fixtures__/module-search/README.md +97 -0
- package/src/lib/__fixtures__/module-search/built-in.json +235 -0
- package/src/lib/__fixtures__/module-search/catalog-parity.json +4076 -0
- package/src/lib/__fixtures__/module-search/modules-index.json +1980 -0
- package/src/lib/__tests__/module-search.test.ts +929 -0
- package/src/lib/module-search-args.ts +116 -0
- package/src/lib/module-search-index.ts +1033 -0
- package/src/lib/module-search.ts +952 -0
- package/src/lib/modules-config.ts +8 -0
- package/src/mercato.ts +17 -3
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export const MODULE_SEARCH_KINDS = ['module', 'provider', 'library', 'tool', 'built-in'] as const
|
|
2
|
+
export type ModuleSearchKind = (typeof MODULE_SEARCH_KINDS)[number]
|
|
3
|
+
|
|
4
|
+
export type ParsedModuleSearchArgs = {
|
|
5
|
+
query: string | null
|
|
6
|
+
category: string | null
|
|
7
|
+
kinds: ModuleSearchKind[] | null
|
|
8
|
+
allLines: boolean
|
|
9
|
+
limit: number
|
|
10
|
+
json: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ParsedModuleInfoArgs = {
|
|
14
|
+
ref: string | null
|
|
15
|
+
json: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const MODULE_SEARCH_DEFAULT_LIMIT = 10
|
|
19
|
+
export const MODULE_SEARCH_MAX_LIMIT = 20
|
|
20
|
+
const QUERY_MAX_LENGTH = 200
|
|
21
|
+
const CATEGORY_PATTERN = /^[a-z0-9][a-z0-9-]{0,40}$/
|
|
22
|
+
|
|
23
|
+
function readValue(args: string[], index: number, flag: string): string {
|
|
24
|
+
const next = args[index + 1]
|
|
25
|
+
if (next === undefined || next.startsWith('--')) {
|
|
26
|
+
throw new Error(`${flag} requires a value`)
|
|
27
|
+
}
|
|
28
|
+
return next
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function splitFlag(arg: string): { flag: string; inline: string | null } {
|
|
32
|
+
const eq = arg.indexOf('=')
|
|
33
|
+
return eq === -1 ? { flag: arg, inline: null } : { flag: arg.slice(0, eq), inline: arg.slice(eq + 1) }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function parseKinds(value: string): ModuleSearchKind[] {
|
|
37
|
+
const kinds = value
|
|
38
|
+
.split(',')
|
|
39
|
+
.map((item) => item.trim())
|
|
40
|
+
.filter((item) => item !== '')
|
|
41
|
+
if (kinds.length === 0) throw new Error('--kind requires a value')
|
|
42
|
+
return kinds.map((kind) => {
|
|
43
|
+
const match = MODULE_SEARCH_KINDS.find((candidate) => candidate === kind)
|
|
44
|
+
if (!match) throw new Error(`--kind must be one of: ${MODULE_SEARCH_KINDS.join(', ')}`)
|
|
45
|
+
return match
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function parseLimit(value: string): number {
|
|
50
|
+
if (!/^\d+$/.test(value)) throw new Error(`--limit must be a whole number between 1 and ${MODULE_SEARCH_MAX_LIMIT}`)
|
|
51
|
+
const limit = Number(value)
|
|
52
|
+
if (limit < 1 || limit > MODULE_SEARCH_MAX_LIMIT) {
|
|
53
|
+
throw new Error(`--limit must be a whole number between 1 and ${MODULE_SEARCH_MAX_LIMIT}`)
|
|
54
|
+
}
|
|
55
|
+
return limit
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function parseModuleSearchArgs(args: string[]): ParsedModuleSearchArgs {
|
|
59
|
+
const words: string[] = []
|
|
60
|
+
let category: string | null = null
|
|
61
|
+
let kinds: ModuleSearchKind[] | null = null
|
|
62
|
+
let allLines = false
|
|
63
|
+
let limit = MODULE_SEARCH_DEFAULT_LIMIT
|
|
64
|
+
let json = false
|
|
65
|
+
|
|
66
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
67
|
+
const arg = args[index]
|
|
68
|
+
if (!arg) continue
|
|
69
|
+
if (!arg.startsWith('--')) {
|
|
70
|
+
words.push(arg)
|
|
71
|
+
continue
|
|
72
|
+
}
|
|
73
|
+
const { flag, inline } = splitFlag(arg)
|
|
74
|
+
if (flag === '--json' || flag === '--all-lines') {
|
|
75
|
+
if (inline !== null) throw new Error(`${flag} does not accept a value`)
|
|
76
|
+
if (flag === '--json') json = true
|
|
77
|
+
else allLines = true
|
|
78
|
+
continue
|
|
79
|
+
}
|
|
80
|
+
if (flag === '--category' || flag === '--kind' || flag === '--limit') {
|
|
81
|
+
const value = inline ?? readValue(args, index, flag)
|
|
82
|
+
if (inline === null) index += 1
|
|
83
|
+
if (flag === '--category') {
|
|
84
|
+
if (!CATEGORY_PATTERN.test(value)) throw new Error('--category expects a catalog category id, for example payments-finance')
|
|
85
|
+
category = value
|
|
86
|
+
} else if (flag === '--kind') {
|
|
87
|
+
kinds = parseKinds(value)
|
|
88
|
+
} else {
|
|
89
|
+
limit = parseLimit(value)
|
|
90
|
+
}
|
|
91
|
+
continue
|
|
92
|
+
}
|
|
93
|
+
throw new Error(`Unsupported option: ${flag}`)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const query = words.join(' ').trim()
|
|
97
|
+
if (query.length > QUERY_MAX_LENGTH) throw new Error(`The query is longer than ${QUERY_MAX_LENGTH} characters`)
|
|
98
|
+
return { query: query === '' ? null : query, category, kinds, allLines, limit, json }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function parseModuleInfoArgs(args: string[]): ParsedModuleInfoArgs {
|
|
102
|
+
let ref: string | null = null
|
|
103
|
+
let json = false
|
|
104
|
+
for (const arg of args) {
|
|
105
|
+
if (!arg) continue
|
|
106
|
+
if (arg === '--json') {
|
|
107
|
+
json = true
|
|
108
|
+
continue
|
|
109
|
+
}
|
|
110
|
+
if (arg.startsWith('--')) throw new Error(`Unsupported option: ${splitFlag(arg).flag}`)
|
|
111
|
+
if (ref !== null) throw new Error('module info takes one package name or module id')
|
|
112
|
+
ref = arg.trim()
|
|
113
|
+
}
|
|
114
|
+
if (ref !== null && ref.length > 220) throw new Error('The package name or module id is too long')
|
|
115
|
+
return { ref: ref === '' ? null : ref, json }
|
|
116
|
+
}
|