@chatu-ai/builder-sdk-mock 0.1.0 → 0.2.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 (2) hide show
  1. package/dist/index.js +16 -0
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -65,6 +65,22 @@ export function createMockBuilderClient(script) {
65
65
  read: async (_id, path) => `// mock content of ${path}\n`,
66
66
  downloadUrl: () => 'https://mock.invalid/download.zip',
67
67
  },
68
+ credentials: {
69
+ list: async () => [
70
+ { id: 'cred-1', scope: 'user', provider: 'github', label: '我的 GitHub', hint: 'ab12', createdTime: new Date().toISOString(), readOnly: false },
71
+ { id: 'cred-org', scope: 'organization', provider: 'git-https', label: '公司 GitLab 机器人', hint: 'zz99', createdTime: new Date().toISOString(), readOnly: true },
72
+ ],
73
+ save: async (input) => ({ id: 'cred-new', scope: input.scope, provider: input.provider, label: input.label, hint: input.secret.slice(-4), createdTime: new Date().toISOString(), readOnly: false }),
74
+ remove: async () => { },
75
+ },
76
+ deploy: {
77
+ settings: async () => [{ target: 'git', credentialId: 'cred-1', config: { remoteUrl: 'https://github.com/demo/app.git', branch: 'main' }, updatedTime: new Date().toISOString() }],
78
+ saveSetting: async (_id, input) => ({ target: input.target, credentialId: input.credentialId ?? null, config: input.config ?? {}, updatedTime: new Date().toISOString() }),
79
+ pushGit: async (_id, input) => ({ ok: true, remoteUrl: input.remoteUrl, branch: input.branch ?? 'main', sha: 'deadbeefcafe', output: 'mock push ok', webUrl: input.remoteUrl.replace(/\.git$/, '') }),
80
+ },
81
+ export: {
82
+ zip: async () => ({ blob: new Blob(['PK'], { type: 'application/zip' }), fileName: 'mock-app.zip' }),
83
+ },
68
84
  };
69
85
  }
70
86
  /** 极简树维护:仅保证 path 出现/消失,目录按需创建 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatu-ai/builder-sdk-mock",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Mock BuilderClient for @chatu-ai/builder-sdk: scripted event replay with latency & disconnect injection",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,7 +41,7 @@
41
41
  "node": ">=18"
42
42
  },
43
43
  "dependencies": {
44
- "@chatu-ai/builder-sdk": "0.1.0"
44
+ "@chatu-ai/builder-sdk": "0.2.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "typescript": "^5.7.0",