@alipay/alipay-aipay 1.2.2 → 1.4.9

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 (98) hide show
  1. package/README.md +5 -0
  2. package/dist/commands/install.d.ts.map +1 -1
  3. package/dist/commands/install.js +13 -12
  4. package/dist/commands/install.js.map +1 -1
  5. package/dist/commands/uninstall.d.ts.map +1 -1
  6. package/dist/commands/uninstall.js +17 -9
  7. package/dist/commands/uninstall.js.map +1 -1
  8. package/dist/commands/update.d.ts.map +1 -1
  9. package/dist/commands/update.js +5 -5
  10. package/dist/commands/update.js.map +1 -1
  11. package/dist/index.js +4 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/utils/config.d.ts +5 -3
  14. package/dist/utils/config.d.ts.map +1 -1
  15. package/dist/utils/config.js +34 -12
  16. package/dist/utils/config.js.map +1 -1
  17. package/dist/utils/file.d.ts +8 -0
  18. package/dist/utils/file.d.ts.map +1 -1
  19. package/dist/utils/file.js +161 -9
  20. package/dist/utils/file.js.map +1 -1
  21. package/dist/utils/jq.d.ts.map +1 -1
  22. package/dist/utils/jq.js +8 -0
  23. package/dist/utils/jq.js.map +1 -1
  24. package/package.json +6 -5
  25. package/skill/SKILL.md +15 -169
  26. package/skill/VERSION +1 -1
  27. package/skill/references/integration/flow.md +321 -292
  28. package/skill/references/integration/modules/alipay-sdk-reminder.md +5 -3
  29. package/skill/references/integration/modules/checklist.md +41 -27
  30. package/skill/references/integration/modules/code-examples/csharp/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +199 -0
  31. package/skill/references/integration/modules/code-examples/csharp/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +8 -4
  32. package/skill/references/integration/modules/code-examples/csharp/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +6 -2
  33. package/skill/references/integration/modules/code-examples/csharp/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.cs +3 -1
  34. package/skill/references/integration/modules/code-examples/java/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +184 -0
  35. package/skill/references/integration/modules/code-examples/java/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +4 -1
  36. package/skill/references/integration/modules/code-examples/java/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +5 -2
  37. package/skill/references/integration/modules/code-examples/java/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemoController.java +3 -1
  38. package/skill/references/integration/modules/code-examples/nodejs/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +135 -0
  39. package/skill/references/integration/modules/code-examples/nodejs/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +16 -10
  40. package/skill/references/integration/modules/code-examples/nodejs/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +10 -4
  41. package/skill/references/integration/modules/code-examples/nodejs/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.js +2 -1
  42. package/skill/references/integration/modules/code-examples/php/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +157 -0
  43. package/skill/references/integration/modules/code-examples/php/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +4 -1
  44. package/skill/references/integration/modules/code-examples/php/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +5 -2
  45. package/skill/references/integration/modules/code-examples/php/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.php +2 -1
  46. package/skill/references/integration/modules/code-examples/python/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +128 -0
  47. package/skill/references/integration/modules/code-examples/python/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +4 -1
  48. package/skill/references/integration/modules/code-examples/python/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +5 -1
  49. package/skill/references/integration/modules/code-examples/python/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.py +4 -2
  50. package/skill/references/integration/modules/interface-contract/aipay-interface-contract.md +53 -0
  51. package/skill/references/integration/modules/interface-contract/apppay-interface-contract.md +45 -0
  52. package/skill/references/integration/modules/interface-contract/common-trade-contract.md +42 -0
  53. package/skill/references/integration/modules/interface-contract/notify-url-contract.md +68 -0
  54. package/skill/references/integration/modules/interface-contract/webpay-interface-contract.md +44 -0
  55. package/skill/references/integration/modules/interface-guide.md +37 -72
  56. package/skill/references/integration/modules/product-decision.md +10 -27
  57. package/skill/references/integration/modules/sandbox/a2m-sandbox-test.md +62 -94
  58. package/skill/references/integration/modules/sandbox/alipay-sandbox-tool.md +43 -40
  59. package/skill/references/integration/modules/sandbox/sandbox-setup-guide.md +93 -114
  60. package/skill/references/integration/modules/scripts/local_402_sandbox_pay.py +357 -147
  61. package/skill/references/integration/modules/scripts/sandbox_config.sh +299 -0
  62. package/skill/references/integration/modules/troubleshooting-flow.md +28 -0
  63. package/skill/references/normal/alipay-cli-env.md +15 -5
  64. package/skill/references/normal/full-process-routing.md +80 -0
  65. package/skill/references/normal/json/customer-messages.json +937 -0
  66. package/skill/references/normal/json/policy-rules.json +179 -0
  67. package/skill/references/normal/rejection-guide.md +11 -6
  68. package/skill/references/normal/scripts/alipay_cli_env.mjs +29 -0
  69. package/skill/references/normal/scripts/alipay_cli_env.sh +21 -0
  70. package/skill/references/normal/scripts/common.sh +87 -0
  71. package/skill/references/normal/scripts/detect_dev_tool.sh +5 -1
  72. package/skill/references/normal/scripts/integration_message_runner.mjs +801 -0
  73. package/skill/references/normal/scripts/onboarding_message_runner.mjs +436 -0
  74. package/skill/references/normal/scripts/open_official_url.sh +82 -0
  75. package/skill/references/normal/scripts/platform_compat.mjs +39 -0
  76. package/skill/references/normal/scripts/project_route_inspector.sh +132 -0
  77. package/skill/references/normal/scripts/python_script_runner.mjs +56 -0
  78. package/skill/references/normal/scripts/render_customer_message.mjs +1263 -0
  79. package/skill/references/normal/scripts/self_update.mjs +160 -0
  80. package/skill/references/normal/scripts/telemetry.mjs +1278 -0
  81. package/skill/references/normal/self-update.md +18 -51
  82. package/skill/references/onboarding/flow.md +381 -283
  83. package/skill/references/onboarding/modules/app-release.md +132 -179
  84. package/skill/references/onboarding/modules/authorization.md +53 -64
  85. package/skill/references/onboarding/modules/error-handling.md +31 -34
  86. package/skill/references/onboarding/modules/product-sign.md +62 -66
  87. package/skill/references/onboarding/modules/scripts/app.sh +397 -158
  88. package/skill/references/onboarding/modules/scripts/ar_sign_apply.sh +38 -22
  89. package/skill/references/onboarding/modules/scripts/auth.sh +479 -167
  90. package/skill/references/onboarding/modules/scripts/download_key_tool.sh +157 -0
  91. package/skill/references/onboarding/modules/scripts/error_handler.sh +100 -130
  92. package/skill/references/onboarding/modules/scripts/network_retry.sh +96 -0
  93. package/skill/references/onboarding/modules/scripts/query_sign_status.sh +17 -70
  94. package/skill/references/onboarding/modules/scripts/service.sh +153 -89
  95. package/skill/references/onboarding/modules/scripts/sign_status_parser.sh +58 -0
  96. package/skill/references/onboarding/modules/scripts/upload_screenshots.sh +16 -14
  97. package/skill/references/onboarding/modules/service-registration.md +67 -72
  98. package/skill/references/runtime-entry.md +62 -0
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from 'node:child_process';
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import process from 'node:process';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const scriptDir = path.dirname(fileURLToPath(import.meta.url));
10
+ const defaultSkillDir = path.resolve(scriptDir, '../../..');
11
+ const npmQueryTimeoutMs = 5 * 1000;
12
+ const installTimeoutMs = 60 * 1000;
13
+
14
+ function spawnPackageManager(command, args, options) {
15
+ const windows = process.platform === 'win32';
16
+ if (!windows) return spawnSync(command, args, { ...options, windowsHide: true });
17
+
18
+ const allowedCommands = new Set(['npm', 'npx']);
19
+ const safeToken = /^[A-Za-z0-9@./=+_-]+$/u;
20
+ if (!allowedCommands.has(command) || args.some((arg) => !safeToken.test(arg))) {
21
+ throw new Error('unsafe Windows package-manager command');
22
+ }
23
+ const commandLine = [`${command}.cmd`, ...args].join(' ');
24
+ return spawnSync(process.env.ComSpec || 'cmd.exe', ['/d', '/s', '/c', commandLine], {
25
+ ...options,
26
+ windowsHide: true
27
+ });
28
+ }
29
+
30
+ function parseArgs(argv) {
31
+ if (argv[2] !== 'check') throw new Error('用法: self_update.mjs check [--skill-dir <absolutePath>]');
32
+ let skillDir = defaultSkillDir;
33
+ for (let index = 3; index < argv.length; index += 1) {
34
+ if (argv[index] === '--skill-dir' && argv[index + 1]) {
35
+ skillDir = argv[index + 1];
36
+ index += 1;
37
+ continue;
38
+ }
39
+ throw new Error(`未知参数 ${argv[index]}`);
40
+ }
41
+ if (!path.isAbsolute(skillDir)) throw new Error('--skill-dir 必须是绝对路径');
42
+ return fs.realpathSync(skillDir);
43
+ }
44
+
45
+ function parseVersion(value) {
46
+ const raw = value.trim().replace(/^v/u, '');
47
+ const match = raw.match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/u);
48
+ if (!match) return null;
49
+ return { raw, major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]), prerelease: match[4]?.split('.') || [] };
50
+ }
51
+
52
+ function compareIdentifiers(left, right) {
53
+ const leftNumeric = /^\d+$/u.test(left);
54
+ const rightNumeric = /^\d+$/u.test(right);
55
+ if (leftNumeric && rightNumeric) return Number(left) - Number(right);
56
+ if (leftNumeric !== rightNumeric) return leftNumeric ? -1 : 1;
57
+ return left.localeCompare(right);
58
+ }
59
+
60
+ function compareVersions(left, right) {
61
+ for (const key of ['major', 'minor', 'patch']) {
62
+ if (left[key] !== right[key]) return left[key] - right[key];
63
+ }
64
+ if (left.prerelease.length === 0 || right.prerelease.length === 0) {
65
+ return left.prerelease.length === right.prerelease.length ? 0 : left.prerelease.length === 0 ? 1 : -1;
66
+ }
67
+ for (let index = 0; index < Math.max(left.prerelease.length, right.prerelease.length); index += 1) {
68
+ if (left.prerelease[index] === undefined) return -1;
69
+ if (right.prerelease[index] === undefined) return 1;
70
+ const compared = compareIdentifiers(left.prerelease[index], right.prerelease[index]);
71
+ if (compared !== 0) return compared;
72
+ }
73
+ return 0;
74
+ }
75
+
76
+ function readLocalVersion(skillDir) {
77
+ try {
78
+ const versionFile = path.join(skillDir, 'VERSION');
79
+ const skillFile = path.join(skillDir, 'SKILL.md');
80
+ const runtimeEntry = path.join(skillDir, 'references', 'runtime-entry.md');
81
+ const [versionStat, skillStat, runtimeEntryStat] = [versionFile, skillFile, runtimeEntry].map((file) => fs.lstatSync(file));
82
+ if (
83
+ !versionStat.isFile() || versionStat.isSymbolicLink()
84
+ || !skillStat.isFile() || skillStat.isSymbolicLink()
85
+ || !runtimeEntryStat.isFile() || runtimeEntryStat.isSymbolicLink()
86
+ ) return null;
87
+ return parseVersion(fs.readFileSync(versionFile, 'utf8'));
88
+ } catch {
89
+ return null;
90
+ }
91
+ }
92
+
93
+ function npmLatest() {
94
+ try {
95
+ const result = spawnPackageManager('npm', ['view', '@alipay/alipay-aipay', 'version', '--json'], {
96
+ encoding: 'utf8',
97
+ timeout: npmQueryTimeoutMs
98
+ });
99
+ if (result.status !== 0 || result.error) return { ok: false };
100
+ const decoded = JSON.parse(result.stdout);
101
+ const version = typeof decoded === 'string' ? parseVersion(decoded) : null;
102
+ return version ? { ok: true, version } : { ok: false };
103
+ } catch {
104
+ return { ok: false };
105
+ }
106
+ }
107
+
108
+ function installLatest(skillDir) {
109
+ try {
110
+ const result = spawnPackageManager('npx', ['-y', '@alipay/alipay-aipay@latest', 'install', '--target', 'all', '--skip-tools'], {
111
+ encoding: 'utf8',
112
+ timeout: installTimeoutMs,
113
+ env: {
114
+ ...process.env,
115
+ ALIPAY_AIPAY_EXTRA_SKILL_DIRS: path.dirname(skillDir),
116
+ ALIPAY_AIPAY_CURRENT_SKILL_DIR: skillDir
117
+ }
118
+ });
119
+ return result.status === 0 && !result.error;
120
+ } catch {
121
+ return false;
122
+ }
123
+ }
124
+
125
+ function reportOutcome(outcome) {
126
+ const version = outcome.version ? `=${outcome.version.raw}` : '';
127
+ process.stderr.write(`SELF_UPDATE:${outcome.kind}${version}\n`);
128
+ }
129
+
130
+ function main() {
131
+ const skillDir = parseArgs(process.argv);
132
+ const local = readLocalVersion(skillDir);
133
+
134
+ if (!local) {
135
+ const installed = installLatest(skillDir);
136
+ const updated = readLocalVersion(skillDir);
137
+ if (updated) return { kind: 'UPDATED', version: updated };
138
+ return { kind: installed ? 'VERIFY_FAILED' : 'INSTALL_FAILED' };
139
+ }
140
+
141
+ const checked = npmLatest();
142
+ if (!checked.ok) {
143
+ const current = readLocalVersion(skillDir);
144
+ if (current && compareVersions(current, local) > 0) return { kind: 'UPDATED', version: current };
145
+ return { kind: 'CHECK_FAILED' };
146
+ }
147
+ const latest = checked.version;
148
+ if (compareVersions(local, latest) >= 0) return { kind: 'CURRENT', version: local };
149
+
150
+ const installed = installLatest(skillDir);
151
+ const updated = readLocalVersion(skillDir);
152
+ if (updated && compareVersions(updated, latest) >= 0) return { kind: 'UPDATED', version: updated };
153
+ return { kind: installed ? 'VERIFY_FAILED' : 'INSTALL_FAILED' };
154
+ }
155
+
156
+ try {
157
+ reportOutcome(main());
158
+ } catch {
159
+ reportOutcome({ kind: 'CHECK_FAILED' });
160
+ }