@sfmc-bds/cli 0.5.3 → 0.7.0

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.
Files changed (39) hide show
  1. package/dist/logs.d.ts +21 -0
  2. package/dist/logs.d.ts.map +1 -1
  3. package/dist/logs.js +67 -1
  4. package/dist/logs.js.map +2 -2
  5. package/dist/management/deployment.js +1 -1
  6. package/dist/management/deployment.js.map +2 -2
  7. package/dist/management/domain.d.ts +46 -2
  8. package/dist/management/domain.d.ts.map +1 -1
  9. package/dist/management/domain.js +112 -26
  10. package/dist/management/domain.js.map +2 -2
  11. package/dist/management/maintenance.d.ts +14 -1
  12. package/dist/management/maintenance.d.ts.map +1 -1
  13. package/dist/management/maintenance.js +46 -38
  14. package/dist/management/maintenance.js.map +2 -2
  15. package/dist/management/pack-import.d.ts +29 -0
  16. package/dist/management/pack-import.d.ts.map +1 -0
  17. package/dist/management/pack-import.js +108 -0
  18. package/dist/management/pack-import.js.map +7 -0
  19. package/dist/management/platform-worker.js +5 -6
  20. package/dist/management/platform-worker.js.map +2 -2
  21. package/dist/management/server.d.ts.map +1 -1
  22. package/dist/management/server.js +113 -33
  23. package/dist/management/server.js.map +2 -2
  24. package/dist/management/tasks.js +1 -1
  25. package/dist/management/tasks.js.map +2 -2
  26. package/dist/registry.d.ts +11 -5
  27. package/dist/registry.d.ts.map +1 -1
  28. package/dist/registry.js +35 -11
  29. package/dist/registry.js.map +2 -2
  30. package/dist/services.d.ts +2 -1
  31. package/dist/services.d.ts.map +1 -1
  32. package/dist/services.js +16 -3
  33. package/dist/services.js.map +2 -2
  34. package/dist/world-packs.d.ts +47 -0
  35. package/dist/world-packs.d.ts.map +1 -1
  36. package/dist/world-packs.js +38 -11
  37. package/dist/world-packs.js.map +2 -2
  38. package/package.json +6 -6
  39. package/scripts/module-install/lib/registry-index.mjs +50 -13
@@ -3,15 +3,40 @@
3
3
  * 解析 Tanya7z/sfmc-modules index.json
4
4
  *
5
5
  * 契约(与 sfmc/src/registry.ts#parseRegistryIndex 保持一致):
6
- * { modules: { <id>: { npm?, version?, sdk?, repo?, tag? } } }
6
+ * { modules: { <id>: { npm?, version?, sdk?, repo?, tag?, name?, description?, category?, license?, official?, requires? } } }
7
7
  * 条目至少具备 npm 或 repo+tag。`_` 前缀键视为元数据并忽略。
8
+ * requires 只有在全部是非空字符串时才保留;空数组表示没有额外依赖。缺字段表示索引没有声明依赖。
8
9
  */
9
10
 
10
11
  /**
11
- * @typedef {{ npm?: string, version?: string, sdk?: string, repo?: string, tag?: string }} RegistryEntry
12
+ * @typedef {{ npm?: string, version?: string, sdk?: string, repo?: string, tag?: string, name?: string, description?: string, category?: string, license?: string, official?: boolean, requires?: string[] }} RegistryEntry
12
13
  * @typedef {Record<string, RegistryEntry>} RegistryIndex
13
14
  */
14
15
 
16
+ /**
17
+ * @param {unknown} value
18
+ * @returns {string | undefined}
19
+ */
20
+ function optionalText(value) {
21
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
22
+ }
23
+
24
+ /**
25
+ * 索引 requires。格式不对时返回 undefined,让安装方拒绝,而不是当成没有依赖。
26
+ * @param {unknown} value
27
+ * @returns {string[] | undefined}
28
+ */
29
+ function optionalRequires(value) {
30
+ if (!Array.isArray(value)) return undefined;
31
+ /** @type {string[]} */
32
+ const items = [];
33
+ for (const item of value) {
34
+ if (typeof item !== "string" || !item.trim()) return undefined;
35
+ items.push(item.trim());
36
+ }
37
+ return items;
38
+ }
39
+
15
40
  /**
16
41
  * @param {unknown} json
17
42
  * @returns {RegistryIndex}
@@ -30,20 +55,32 @@ export function parseRegistryIndex(json) {
30
55
  if (k.startsWith("_")) continue;
31
56
  if (typeof v !== "object" || v === null || Array.isArray(v)) continue;
32
57
  const entry = /** @type {Record<string, unknown>} */ (v);
33
- const hasNpm = typeof entry.npm === "string" && entry.npm.length > 0;
34
- const hasGh = typeof entry.repo === "string" && typeof entry.tag === "string";
58
+ const npm = optionalText(entry.npm);
59
+ const repo = optionalText(entry.repo);
60
+ const tag = optionalText(entry.tag);
61
+ const hasNpm = Boolean(npm);
62
+ const hasGh = Boolean(repo && tag);
35
63
  if (!hasNpm && !hasGh) continue;
36
64
  /** @type {RegistryEntry} */
37
65
  const out = {};
38
- if (hasNpm) {
39
- out.npm = /** @type {string} */ (entry.npm);
40
- if (typeof entry.version === "string") out.version = entry.version;
41
- if (typeof entry.sdk === "string") out.sdk = entry.sdk;
42
- }
43
- if (hasGh) {
44
- out.repo = /** @type {string} */ (entry.repo);
45
- out.tag = /** @type {string} */ (entry.tag);
46
- }
66
+ if (npm) out.npm = npm;
67
+ const version = optionalText(entry.version);
68
+ const sdk = optionalText(entry.sdk);
69
+ const name = optionalText(entry.name);
70
+ const description = optionalText(entry.description);
71
+ const category = optionalText(entry.category);
72
+ const license = optionalText(entry.license);
73
+ const requires = optionalRequires(entry.requires);
74
+ if (version) out.version = version;
75
+ if (sdk) out.sdk = sdk;
76
+ if (repo) out.repo = repo;
77
+ if (repo && tag) out.tag = tag;
78
+ if (name) out.name = name;
79
+ if (description) out.description = description;
80
+ if (category) out.category = category;
81
+ if (license) out.license = license;
82
+ if (typeof entry.official === "boolean") out.official = entry.official;
83
+ if (requires !== undefined) out.requires = requires;
47
84
  filtered[k] = out;
48
85
  }
49
86
  return filtered;