@tappify/cli 1.6.0-beta.2 → 1.6.0-beta.4
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 +12 -0
- package/dist/src/app.module.js +1 -0
- package/dist/src/app.module.js.map +1 -1
- package/dist/src/core/auth/auth.service.d.ts +1 -1
- package/dist/src/core/auth/auth.service.js +4 -1
- package/dist/src/core/auth/auth.service.js.map +1 -1
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/core/index.js +1 -0
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/core/manifest/scope-rules.d.ts +2 -0
- package/dist/src/core/manifest/scope-rules.js +59 -2
- package/dist/src/core/manifest/scope-rules.js.map +1 -1
- package/dist/src/core/prompt/clack-wizard-prompts.d.ts +2 -0
- package/dist/src/core/prompt/clack-wizard-prompts.js +112 -0
- package/dist/src/core/prompt/clack-wizard-prompts.js.map +1 -0
- package/dist/src/core/prompt/prompt.service.d.ts +2 -0
- package/dist/src/core/prompt/prompt.service.js +4 -0
- package/dist/src/core/prompt/prompt.service.js.map +1 -1
- package/dist/src/core/prompt/wizard-prompts.d.ts +48 -0
- package/dist/src/core/prompt/wizard-prompts.js +7 -0
- package/dist/src/core/prompt/wizard-prompts.js.map +1 -0
- package/dist/src/domains/extension/containers.js +8 -0
- package/dist/src/domains/extension/containers.js.map +1 -1
- package/dist/src/domains/extension/kinds.ads.d.ts +2 -0
- package/dist/src/domains/extension/kinds.ads.js +147 -0
- package/dist/src/domains/extension/kinds.ads.js.map +1 -0
- package/dist/src/domains/extension/kinds.js +2 -0
- package/dist/src/domains/extension/kinds.js.map +1 -1
- package/dist/src/domains/extension/kinds.server.js +113 -26
- package/dist/src/domains/extension/kinds.server.js.map +1 -1
- package/dist/src/domains/extension/kinds.types.d.ts +6 -2
- package/dist/src/domains/extension/kinds.types.js +25 -1
- package/dist/src/domains/extension/kinds.types.js.map +1 -1
- package/dist/src/domains/extension/labels.d.ts +4 -1
- package/dist/src/domains/extension/labels.js +14 -3
- package/dist/src/domains/extension/labels.js.map +1 -1
- package/dist/src/domains/extension/runners/add.runner.d.ts +16 -0
- package/dist/src/domains/extension/runners/add.runner.js +110 -8
- package/dist/src/domains/extension/runners/add.runner.js.map +1 -1
- package/dist/src/domains/extension/runners/dev.runner.d.ts +1 -0
- package/dist/src/domains/extension/runners/dev.runner.js +29 -7
- package/dist/src/domains/extension/runners/dev.runner.js.map +1 -1
- package/dist/src/domains/extension/runners/remove.runner.js +6 -3
- package/dist/src/domains/extension/runners/remove.runner.js.map +1 -1
- package/dist/src/domains/extension/services/add.service.js +3 -1
- package/dist/src/domains/extension/services/add.service.js.map +1 -1
- package/dist/src/domains/extension/services/checks/a11y-check.js +1 -0
- package/dist/src/domains/extension/services/checks/a11y-check.js.map +1 -1
- package/dist/src/domains/extension/services/checks/ads-check.d.ts +2 -0
- package/dist/src/domains/extension/services/checks/ads-check.js +76 -0
- package/dist/src/domains/extension/services/checks/ads-check.js.map +1 -0
- package/dist/src/domains/extension/services/checks/index.d.ts +2 -0
- package/dist/src/domains/extension/services/checks/index.js +2 -0
- package/dist/src/domains/extension/services/checks/index.js.map +1 -1
- package/dist/src/domains/extension/services/checks/manifest-checks.js +2 -1
- package/dist/src/domains/extension/services/checks/manifest-checks.js.map +1 -1
- package/dist/src/domains/extension/services/checks/server-url.d.ts +1 -0
- package/dist/src/domains/extension/services/checks/server-url.js +91 -0
- package/dist/src/domains/extension/services/checks/server-url.js.map +1 -0
- package/dist/src/domains/extension/services/checks/types.js +10 -0
- package/dist/src/domains/extension/services/checks/types.js.map +1 -1
- package/dist/src/domains/extension/services/checks/work-check.d.ts +2 -0
- package/dist/src/domains/extension/services/checks/work-check.js +53 -0
- package/dist/src/domains/extension/services/checks/work-check.js.map +1 -0
- package/dist/src/domains/extension/services/doctor.service.js +2 -0
- package/dist/src/domains/extension/services/doctor.service.js.map +1 -1
- package/dist/src/domains/index.d.ts +1 -0
- package/dist/src/domains/index.js +1 -0
- package/dist/src/domains/index.js.map +1 -1
- package/dist/src/domains/setup/api/setup-api.client.d.ts +38 -0
- package/dist/src/domains/setup/api/setup-api.client.js +134 -0
- package/dist/src/domains/setup/api/setup-api.client.js.map +1 -0
- package/dist/src/domains/setup/api/setup-projects.client.d.ts +20 -0
- package/dist/src/domains/setup/api/setup-projects.client.js +44 -0
- package/dist/src/domains/setup/api/setup-projects.client.js.map +1 -0
- package/dist/src/domains/setup/api/setup-request-log.d.ts +6 -0
- package/dist/src/domains/setup/api/setup-request-log.js +43 -0
- package/dist/src/domains/setup/api/setup-request-log.js.map +1 -0
- package/dist/src/domains/setup/auth/setup-auth.d.ts +29 -0
- package/dist/src/domains/setup/auth/setup-auth.js +159 -0
- package/dist/src/domains/setup/auth/setup-auth.js.map +1 -0
- package/dist/src/domains/setup/contracts/setup-api.d.ts +149 -0
- package/dist/src/domains/setup/contracts/setup-api.js +27 -0
- package/dist/src/domains/setup/contracts/setup-api.js.map +1 -0
- package/dist/src/domains/setup/detection/android/detect-android.d.ts +2 -0
- package/dist/src/domains/setup/detection/android/detect-android.js +103 -0
- package/dist/src/domains/setup/detection/android/detect-android.js.map +1 -0
- package/dist/src/domains/setup/detection/detection.contract.d.ts +26 -0
- package/dist/src/domains/setup/detection/detection.contract.js +3 -0
- package/dist/src/domains/setup/detection/detection.contract.js.map +1 -0
- package/dist/src/domains/setup/detection/expo/detect-expo.d.ts +2 -0
- package/dist/src/domains/setup/detection/expo/detect-expo.js +35 -0
- package/dist/src/domains/setup/detection/expo/detect-expo.js.map +1 -0
- package/dist/src/domains/setup/detection/git/git-facts.d.ts +2 -0
- package/dist/src/domains/setup/detection/git/git-facts.js +122 -0
- package/dist/src/domains/setup/detection/git/git-facts.js.map +1 -0
- package/dist/src/domains/setup/detection/git/remote-host.d.ts +3 -0
- package/dist/src/domains/setup/detection/git/remote-host.js +56 -0
- package/dist/src/domains/setup/detection/git/remote-host.js.map +1 -0
- package/dist/src/domains/setup/detection/index.d.ts +5 -0
- package/dist/src/domains/setup/detection/index.js +43 -0
- package/dist/src/domains/setup/detection/index.js.map +1 -0
- package/dist/src/domains/setup/detection/ios/detect-ios.d.ts +2 -0
- package/dist/src/domains/setup/detection/ios/detect-ios.js +118 -0
- package/dist/src/domains/setup/detection/ios/detect-ios.js.map +1 -0
- package/dist/src/domains/setup/detection/monorepo/candidate-folders.d.ts +3 -0
- package/dist/src/domains/setup/detection/monorepo/candidate-folders.js +120 -0
- package/dist/src/domains/setup/detection/monorepo/candidate-folders.js.map +1 -0
- package/dist/src/domains/setup/detection/monorepo/merge-apps.d.ts +2 -0
- package/dist/src/domains/setup/detection/monorepo/merge-apps.js +109 -0
- package/dist/src/domains/setup/detection/monorepo/merge-apps.js.map +1 -0
- package/dist/src/domains/setup/detection/monorepo/snapshot-scope.d.ts +2 -0
- package/dist/src/domains/setup/detection/monorepo/snapshot-scope.js +88 -0
- package/dist/src/domains/setup/detection/monorepo/snapshot-scope.js.map +1 -0
- package/dist/src/domains/setup/detection/react-native/detect-react-native.d.ts +13 -0
- package/dist/src/domains/setup/detection/react-native/detect-react-native.js +124 -0
- package/dist/src/domains/setup/detection/react-native/detect-react-native.js.map +1 -0
- package/dist/src/domains/setup/detection/shared/expo-config.d.ts +7 -0
- package/dist/src/domains/setup/detection/shared/expo-config.js +58 -0
- package/dist/src/domains/setup/detection/shared/expo-config.js.map +1 -0
- package/dist/src/domains/setup/detection/shared/gradle.d.ts +10 -0
- package/dist/src/domains/setup/detection/shared/gradle.js +110 -0
- package/dist/src/domains/setup/detection/shared/gradle.js.map +1 -0
- package/dist/src/domains/setup/detection/shared/identifier.d.ts +2 -0
- package/dist/src/domains/setup/detection/shared/identifier.js +42 -0
- package/dist/src/domains/setup/detection/shared/identifier.js.map +1 -0
- package/dist/src/domains/setup/detection/shared/pbxproj.d.ts +31 -0
- package/dist/src/domains/setup/detection/shared/pbxproj.js +332 -0
- package/dist/src/domains/setup/detection/shared/pbxproj.js.map +1 -0
- package/dist/src/domains/setup/detection/shared/repo-fs.d.ts +8 -0
- package/dist/src/domains/setup/detection/shared/repo-fs.js +119 -0
- package/dist/src/domains/setup/detection/shared/repo-fs.js.map +1 -0
- package/dist/src/domains/setup/detection/shared/run-git.d.ts +4 -0
- package/dist/src/domains/setup/detection/shared/run-git.js +29 -0
- package/dist/src/domains/setup/detection/shared/run-git.js.map +1 -0
- package/dist/src/domains/setup/detection/shared/xcconfig.d.ts +1 -0
- package/dist/src/domains/setup/detection/shared/xcconfig.js +42 -0
- package/dist/src/domains/setup/detection/shared/xcconfig.js.map +1 -0
- package/dist/src/domains/setup/detection/testing/fixture-repo.d.ts +19 -0
- package/dist/src/domains/setup/detection/testing/fixture-repo.js +61 -0
- package/dist/src/domains/setup/detection/testing/fixture-repo.js.map +1 -0
- package/dist/src/domains/setup/flow/question-renderer.d.ts +19 -0
- package/dist/src/domains/setup/flow/question-renderer.js +127 -0
- package/dist/src/domains/setup/flow/question-renderer.js.map +1 -0
- package/dist/src/domains/setup/flow/step-answers.d.ts +7 -0
- package/dist/src/domains/setup/flow/step-answers.js +26 -0
- package/dist/src/domains/setup/flow/step-answers.js.map +1 -0
- package/dist/src/domains/setup/flow/step-loop.d.ts +56 -0
- package/dist/src/domains/setup/flow/step-loop.js +556 -0
- package/dist/src/domains/setup/flow/step-loop.js.map +1 -0
- package/dist/src/domains/setup/index.d.ts +1 -0
- package/dist/src/domains/setup/index.js +18 -0
- package/dist/src/domains/setup/index.js.map +1 -0
- package/dist/src/domains/setup/local-change/local-change.applier.d.ts +47 -0
- package/dist/src/domains/setup/local-change/local-change.applier.js +377 -0
- package/dist/src/domains/setup/local-change/local-change.applier.js.map +1 -0
- package/dist/src/domains/setup/local-change/patch-plan.d.ts +15 -0
- package/dist/src/domains/setup/local-change/patch-plan.js +110 -0
- package/dist/src/domains/setup/local-change/patch-plan.js.map +1 -0
- package/dist/src/domains/setup/local-change/path-guard.d.ts +5 -0
- package/dist/src/domains/setup/local-change/path-guard.js +62 -0
- package/dist/src/domains/setup/local-change/path-guard.js.map +1 -0
- package/dist/src/domains/setup/local-change/recipe-lookup.d.ts +9 -0
- package/dist/src/domains/setup/local-change/recipe-lookup.js +5 -0
- package/dist/src/domains/setup/local-change/recipe-lookup.js.map +1 -0
- package/dist/src/domains/setup/local-change/unified-diff.d.ts +6 -0
- package/dist/src/domains/setup/local-change/unified-diff.js +24 -0
- package/dist/src/domains/setup/local-change/unified-diff.js.map +1 -0
- package/dist/src/domains/setup/output/setup-output.d.ts +24 -0
- package/dist/src/domains/setup/output/setup-output.js +107 -0
- package/dist/src/domains/setup/output/setup-output.js.map +1 -0
- package/dist/src/domains/setup/project/choose-app.d.ts +16 -0
- package/dist/src/domains/setup/project/choose-app.js +126 -0
- package/dist/src/domains/setup/project/choose-app.js.map +1 -0
- package/dist/src/domains/setup/project/setup-project.resolver.d.ts +40 -0
- package/dist/src/domains/setup/project/setup-project.resolver.js +289 -0
- package/dist/src/domains/setup/project/setup-project.resolver.js.map +1 -0
- package/dist/src/domains/setup/recipes/agent-tools/agent-instructions.recipe.d.ts +2 -0
- package/dist/src/domains/setup/recipes/agent-tools/agent-instructions.recipe.js +67 -0
- package/dist/src/domains/setup/recipes/agent-tools/agent-instructions.recipe.js.map +1 -0
- package/dist/src/domains/setup/recipes/agent-tools/mcp-server-config.recipe.d.ts +2 -0
- package/dist/src/domains/setup/recipes/agent-tools/mcp-server-config.recipe.js +157 -0
- package/dist/src/domains/setup/recipes/agent-tools/mcp-server-config.recipe.js.map +1 -0
- package/dist/src/domains/setup/recipes/git/git-remote-push.recipe.d.ts +2 -0
- package/dist/src/domains/setup/recipes/git/git-remote-push.recipe.js +96 -0
- package/dist/src/domains/setup/recipes/git/git-remote-push.recipe.js.map +1 -0
- package/dist/src/domains/setup/recipes/git/git-repository.d.ts +8 -0
- package/dist/src/domains/setup/recipes/git/git-repository.js +120 -0
- package/dist/src/domains/setup/recipes/git/git-repository.js.map +1 -0
- package/dist/src/domains/setup/recipes/index.d.ts +5 -0
- package/dist/src/domains/setup/recipes/index.js +36 -0
- package/dist/src/domains/setup/recipes/index.js.map +1 -0
- package/dist/src/domains/setup/recipes/ios/info-plist.d.ts +15 -0
- package/dist/src/domains/setup/recipes/ios/info-plist.js +308 -0
- package/dist/src/domains/setup/recipes/ios/info-plist.js.map +1 -0
- package/dist/src/domains/setup/recipes/ios/ios-start-call.recipe.d.ts +2 -0
- package/dist/src/domains/setup/recipes/ios/ios-start-call.recipe.js +200 -0
- package/dist/src/domains/setup/recipes/ios/ios-start-call.recipe.js.map +1 -0
- package/dist/src/domains/setup/recipes/ios/ios-swift-package.recipe.d.ts +2 -0
- package/dist/src/domains/setup/recipes/ios/ios-swift-package.recipe.js +273 -0
- package/dist/src/domains/setup/recipes/ios/ios-swift-package.recipe.js.map +1 -0
- package/dist/src/domains/setup/recipes/ios/ios-url-scheme.recipe.d.ts +2 -0
- package/dist/src/domains/setup/recipes/ios/ios-url-scheme.recipe.js +40 -0
- package/dist/src/domains/setup/recipes/ios/ios-url-scheme.recipe.js.map +1 -0
- package/dist/src/domains/setup/recipes/quick-check.d.ts +18 -0
- package/dist/src/domains/setup/recipes/quick-check.js +329 -0
- package/dist/src/domains/setup/recipes/quick-check.js.map +1 -0
- package/dist/src/domains/setup/recipes/react-native/expo-config-plugin.recipe.d.ts +2 -0
- package/dist/src/domains/setup/recipes/react-native/expo-config-plugin.recipe.js +65 -0
- package/dist/src/domains/setup/recipes/react-native/expo-config-plugin.recipe.js.map +1 -0
- package/dist/src/domains/setup/recipes/react-native/install-react-native-package.recipe.d.ts +2 -0
- package/dist/src/domains/setup/recipes/react-native/install-react-native-package.recipe.js +69 -0
- package/dist/src/domains/setup/recipes/react-native/install-react-native-package.recipe.js.map +1 -0
- package/dist/src/domains/setup/recipes/react-native/react-native-start-call.recipe.d.ts +2 -0
- package/dist/src/domains/setup/recipes/react-native/react-native-start-call.recipe.js +143 -0
- package/dist/src/domains/setup/recipes/react-native/react-native-start-call.recipe.js.map +1 -0
- package/dist/src/domains/setup/recipes/recipe.contract.d.ts +29 -0
- package/dist/src/domains/setup/recipes/recipe.contract.js +18 -0
- package/dist/src/domains/setup/recipes/recipe.contract.js.map +1 -0
- package/dist/src/domains/setup/recipes/shared/brace-scan.d.ts +9 -0
- package/dist/src/domains/setup/recipes/shared/brace-scan.js +188 -0
- package/dist/src/domains/setup/recipes/shared/brace-scan.js.map +1 -0
- package/dist/src/domains/setup/recipes/shared/json-text.d.ts +2 -0
- package/dist/src/domains/setup/recipes/shared/json-text.js +30 -0
- package/dist/src/domains/setup/recipes/shared/json-text.js.map +1 -0
- package/dist/src/domains/setup/recipes/shared/recipe-files.d.ts +17 -0
- package/dist/src/domains/setup/recipes/shared/recipe-files.js +79 -0
- package/dist/src/domains/setup/recipes/shared/recipe-files.js.map +1 -0
- package/dist/src/domains/setup/recipes/shared/recipe-params.d.ts +9 -0
- package/dist/src/domains/setup/recipes/shared/recipe-params.js +30 -0
- package/dist/src/domains/setup/recipes/shared/recipe-params.js.map +1 -0
- package/dist/src/domains/setup/recipes/shared/sdk-coordinates.d.ts +11 -0
- package/dist/src/domains/setup/recipes/shared/sdk-coordinates.js +12 -0
- package/dist/src/domains/setup/recipes/shared/sdk-coordinates.js.map +1 -0
- package/dist/src/domains/setup/recipes/testing/recipe-checklist.d.ts +9 -0
- package/dist/src/domains/setup/recipes/testing/recipe-checklist.js +139 -0
- package/dist/src/domains/setup/recipes/testing/recipe-checklist.js.map +1 -0
- package/dist/src/domains/setup/setup-flow.d.ts +46 -0
- package/dist/src/domains/setup/setup-flow.js +134 -0
- package/dist/src/domains/setup/setup-flow.js.map +1 -0
- package/dist/src/domains/setup/setup.module.d.ts +2 -0
- package/dist/src/domains/setup/setup.module.js +49 -0
- package/dist/src/domains/setup/setup.module.js.map +1 -0
- package/dist/src/domains/setup/setup.runner.d.ts +23 -0
- package/dist/src/domains/setup/setup.runner.js +120 -0
- package/dist/src/domains/setup/setup.runner.js.map +1 -0
- package/dist/src/domains/setup/snapshot/snapshot-exclusions.d.ts +9 -0
- package/dist/src/domains/setup/snapshot/snapshot-exclusions.js +107 -0
- package/dist/src/domains/setup/snapshot/snapshot-exclusions.js.map +1 -0
- package/dist/src/domains/setup/snapshot/snapshot-files.d.ts +16 -0
- package/dist/src/domains/setup/snapshot/snapshot-files.js +211 -0
- package/dist/src/domains/setup/snapshot/snapshot-files.js.map +1 -0
- package/dist/src/domains/setup/snapshot/snapshot-limits.d.ts +3 -0
- package/dist/src/domains/setup/snapshot/snapshot-limits.js +7 -0
- package/dist/src/domains/setup/snapshot/snapshot-limits.js.map +1 -0
- package/dist/src/domains/setup/snapshot/snapshot-packer.d.ts +30 -0
- package/dist/src/domains/setup/snapshot/snapshot-packer.js +147 -0
- package/dist/src/domains/setup/snapshot/snapshot-packer.js.map +1 -0
- package/dist/src/domains/setup/snapshot/snapshot-uploader.d.ts +39 -0
- package/dist/src/domains/setup/snapshot/snapshot-uploader.js +176 -0
- package/dist/src/domains/setup/snapshot/snapshot-uploader.js.map +1 -0
- package/dist/src/domains/setup/testing/fake-setup-api.d.ts +9 -0
- package/dist/src/domains/setup/testing/fake-setup-api.js +71 -0
- package/dist/src/domains/setup/testing/fake-setup-api.js.map +1 -0
- package/dist/src/domains/setup/testing/fake-wizard-prompts.d.ts +17 -0
- package/dist/src/domains/setup/testing/fake-wizard-prompts.js +120 -0
- package/dist/src/domains/setup/testing/fake-wizard-prompts.js.map +1 -0
- package/dist/src/domains/setup/testing/temp-repo.d.ts +14 -0
- package/dist/src/domains/setup/testing/temp-repo.js +62 -0
- package/dist/src/domains/setup/testing/temp-repo.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -2
- package/templates/contributions/ads/server/ads.ts +62 -0
- package/templates/contributions/ads/test/ads.test.ts +101 -0
- package/templates/contributions/work/server/provider-webhook.ts +82 -0
- package/templates/contributions/work/server/work.ts +99 -13
- package/templates/contributions/work/test/work.test.ts +218 -0
- package/templates/starter/api/tappify/ads/[id].ts +6 -0
- package/templates/starter/package.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tappify/cli",
|
|
3
|
-
"version": "1.6.0-beta.
|
|
3
|
+
"version": "1.6.0-beta.4",
|
|
4
4
|
"description": "Tappify CLI - Command line interface for managing deployments and more",
|
|
5
5
|
"author": "Tappify Team",
|
|
6
6
|
"private": false,
|
|
@@ -63,16 +63,19 @@
|
|
|
63
63
|
"check:release-assets": "node scripts/check-release-assets.cjs"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
+
"@clack/prompts": "^1.9.0",
|
|
66
67
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
67
68
|
"@nestjs/common": "^11.1.15",
|
|
68
69
|
"@nestjs/core": "^11.1.15",
|
|
69
70
|
"@nestjs/platform-express": "^11.1.15",
|
|
70
|
-
"@tappify/extension-sdk": "
|
|
71
|
+
"@tappify/extension-sdk": "2.1.0-beta.8",
|
|
71
72
|
"archiver": "^7.0.1",
|
|
72
73
|
"chalk": "^5.6.2",
|
|
73
74
|
"chokidar": "^4.0.3",
|
|
74
75
|
"conf": "^15.1.0",
|
|
76
|
+
"diff": "^9.0.0",
|
|
75
77
|
"form-data": "^4.0.5",
|
|
78
|
+
"ignore": "^7.0.16",
|
|
76
79
|
"nest-commander": "^3.20.1",
|
|
77
80
|
"node-pty": "^1.1.0",
|
|
78
81
|
"open": "^11.0.0",
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AdsItem,
|
|
3
|
+
AdsOperationMap,
|
|
4
|
+
TappifyRouteHandler,
|
|
5
|
+
} from '@tappify/extension-sdk/server';
|
|
6
|
+
|
|
7
|
+
type AdsHandlers = {
|
|
8
|
+
[O in keyof AdsOperationMap]: TappifyRouteHandler<
|
|
9
|
+
AdsOperationMap[O]['input'],
|
|
10
|
+
AdsOperationMap[O]['output']
|
|
11
|
+
>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const campaign: AdsItem = {
|
|
15
|
+
level: 'campaign',
|
|
16
|
+
id: 'campaign-1',
|
|
17
|
+
name: 'Example campaign',
|
|
18
|
+
status: 'active',
|
|
19
|
+
budget: { amount: '50.00', currency: 'USD', period: 'daily' },
|
|
20
|
+
storeAppId: '0000000000',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const ads: AdsHandlers = {
|
|
24
|
+
// The owner's sign-in arrives on request.credentials. Answer every ad
|
|
25
|
+
// account it can reach; the owner chooses which ones to bring in.
|
|
26
|
+
list_accounts: () => ({
|
|
27
|
+
accounts: [
|
|
28
|
+
{
|
|
29
|
+
id: 'account-1',
|
|
30
|
+
name: 'Example account',
|
|
31
|
+
currency: 'USD',
|
|
32
|
+
timeZone: 'America/New_York',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
}),
|
|
36
|
+
// Amounts are decimal strings and dates are days in the account's time
|
|
37
|
+
// zone, both ends of request.input.window included. Item ids are yours:
|
|
38
|
+
// put what you need to address a child into its id. Answer a row's item and
|
|
39
|
+
// an item's parent in the same page, and a cursor when there is more.
|
|
40
|
+
sync: request => ({
|
|
41
|
+
items: [campaign],
|
|
42
|
+
rows: [
|
|
43
|
+
{
|
|
44
|
+
level: 'campaign',
|
|
45
|
+
itemId: campaign.id,
|
|
46
|
+
date: request.input.window.start,
|
|
47
|
+
impressions: 0,
|
|
48
|
+
clicks: 0,
|
|
49
|
+
installs: 0,
|
|
50
|
+
spend: '0.00',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
}),
|
|
54
|
+
// Called only for changes the manifest declares, after a person approves,
|
|
55
|
+
// and never retried. Answer the item as the network now holds it.
|
|
56
|
+
apply_change: request => ({
|
|
57
|
+
item:
|
|
58
|
+
request.input.change.type === 'status'
|
|
59
|
+
? { ...campaign, status: request.input.change.status }
|
|
60
|
+
: campaign,
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { AdsAcquisition } from '@tappify/extension-sdk/manifest';
|
|
2
|
+
import type { TappifyRequest } from '@tappify/extension-sdk/server';
|
|
3
|
+
import { validateAdsSyncResponse } from '@tappify/extension-sdk/testing/server';
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { describe, expect, it } from 'vitest';
|
|
7
|
+
import { ads } from '../server/ads';
|
|
8
|
+
|
|
9
|
+
// Read on every run, so the test follows the levels and numbers you declare.
|
|
10
|
+
const manifest = JSON.parse(
|
|
11
|
+
readFileSync(
|
|
12
|
+
join(import.meta.dirname, '..', 'tappify.extension.json'),
|
|
13
|
+
'utf8',
|
|
14
|
+
),
|
|
15
|
+
) as { contributes: { ads: { acquisition: AdsAcquisition } } };
|
|
16
|
+
const acquisition = manifest.contributes.ads.acquisition;
|
|
17
|
+
|
|
18
|
+
const syncWindow = { start: '2026-01-01', end: '2026-01-02' };
|
|
19
|
+
|
|
20
|
+
function request<TInput>(
|
|
21
|
+
operation: string,
|
|
22
|
+
input: TInput,
|
|
23
|
+
): TappifyRequest<TInput> {
|
|
24
|
+
return {
|
|
25
|
+
install: {
|
|
26
|
+
id: 'install-1',
|
|
27
|
+
extensionId: '__id__',
|
|
28
|
+
projectId: null,
|
|
29
|
+
organizationId: 'org-1',
|
|
30
|
+
},
|
|
31
|
+
context: {
|
|
32
|
+
projectId: null,
|
|
33
|
+
platform: 'all',
|
|
34
|
+
from: '',
|
|
35
|
+
to: '',
|
|
36
|
+
filters: {
|
|
37
|
+
platform: 'all',
|
|
38
|
+
country: 'all',
|
|
39
|
+
range: { from: syncWindow.start, to: syncWindow.end },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
credentials: {},
|
|
43
|
+
documents: {},
|
|
44
|
+
event: undefined,
|
|
45
|
+
eventId: 'event-1',
|
|
46
|
+
request: new Request(`https://vendor.example.com/tappify/ads/${operation}`),
|
|
47
|
+
claims: {
|
|
48
|
+
iss: 'https://tappify.ai',
|
|
49
|
+
aud: 'ext:__id__',
|
|
50
|
+
exp: 9999999999,
|
|
51
|
+
iat: 1,
|
|
52
|
+
installId: 'install-1',
|
|
53
|
+
extensionId: '__id__',
|
|
54
|
+
projectId: null,
|
|
55
|
+
organizationId: 'org-1',
|
|
56
|
+
scopes: ['ads:sync', 'ads:manage'],
|
|
57
|
+
},
|
|
58
|
+
input,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
describe('ad network', () => {
|
|
63
|
+
it('lists at least one account with a currency and a time zone', async () => {
|
|
64
|
+
const { accounts } = await ads.list_accounts(request('list_accounts', {}));
|
|
65
|
+
|
|
66
|
+
expect(accounts.length).toBeGreaterThan(0);
|
|
67
|
+
for (const account of accounts) {
|
|
68
|
+
expect(account.currency).toMatch(/^[A-Z]{3}$/);
|
|
69
|
+
expect(account.timeZone).not.toBe('');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('answers a sync the contract accepts', async () => {
|
|
74
|
+
const answer = await ads.sync(
|
|
75
|
+
request('sync', { accountId: 'account-1', window: syncWindow }),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
expect(validateAdsSyncResponse(answer, acquisition, syncWindow)).toEqual(
|
|
79
|
+
[],
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('answers a change with the item as it now is', async () => {
|
|
84
|
+
const { item } = await ads.apply_change(
|
|
85
|
+
request('apply_change', {
|
|
86
|
+
idempotencyKey: 'change-1',
|
|
87
|
+
occurredAt: '2026-01-01T00:00:00Z',
|
|
88
|
+
accountId: 'account-1',
|
|
89
|
+
level: 'campaign',
|
|
90
|
+
itemId: 'campaign-1',
|
|
91
|
+
change: { type: 'status', status: 'paused' },
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
expect(item).toMatchObject({
|
|
96
|
+
level: 'campaign',
|
|
97
|
+
id: 'campaign-1',
|
|
98
|
+
status: 'paused',
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sendWorkEvent,
|
|
3
|
+
type SendWorkEventOptions,
|
|
4
|
+
type WorkEvent,
|
|
5
|
+
} from '@tappify/extension-sdk/server';
|
|
6
|
+
|
|
7
|
+
// Example PROVIDER payload only. Replace with the provider's validated wire
|
|
8
|
+
// schema; normalized work-event types always come from the SDK.
|
|
9
|
+
export type ExampleProviderEvent = {
|
|
10
|
+
id: string;
|
|
11
|
+
itemId: string;
|
|
12
|
+
occurredAt: string;
|
|
13
|
+
} & (
|
|
14
|
+
| {
|
|
15
|
+
type: 'comment';
|
|
16
|
+
commentId: string;
|
|
17
|
+
text: string;
|
|
18
|
+
authorId: string;
|
|
19
|
+
authorName: string;
|
|
20
|
+
}
|
|
21
|
+
| { type: 'status'; statusId: string; statusName: string; done: boolean }
|
|
22
|
+
| { type: 'deleted' }
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export function normalizeProviderEvent(event: ExampleProviderEvent): WorkEvent {
|
|
26
|
+
const common = {
|
|
27
|
+
externalItemId: event.itemId,
|
|
28
|
+
providerEventId: event.id,
|
|
29
|
+
occurredAt: event.occurredAt,
|
|
30
|
+
dedupeKey: `provider:${event.id}`,
|
|
31
|
+
};
|
|
32
|
+
switch (event.type) {
|
|
33
|
+
case 'comment':
|
|
34
|
+
return {
|
|
35
|
+
...common,
|
|
36
|
+
type: 'comment.created',
|
|
37
|
+
comment: {
|
|
38
|
+
externalCommentId: event.commentId,
|
|
39
|
+
body: event.text,
|
|
40
|
+
author: { id: event.authorId, displayName: event.authorName },
|
|
41
|
+
createdAt: event.occurredAt,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
case 'status':
|
|
45
|
+
return {
|
|
46
|
+
...common,
|
|
47
|
+
type: 'status.changed',
|
|
48
|
+
status: {
|
|
49
|
+
id: event.statusId,
|
|
50
|
+
label: event.statusName,
|
|
51
|
+
stage: event.done ? 'done' : 'open',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
case 'deleted':
|
|
55
|
+
return { ...common, type: 'item.deleted' };
|
|
56
|
+
default:
|
|
57
|
+
throw new Error('Unsupported provider event');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function verifyProviderWebhook(
|
|
62
|
+
request: Request,
|
|
63
|
+
): Promise<ExampleProviderEvent> {
|
|
64
|
+
// Verify the provider signature/timestamp over the EXACT raw body before
|
|
65
|
+
// parsing, then validate the provider payload and resolve its opaque routing
|
|
66
|
+
// record from configure. Never trust install IDs from an unverified payload.
|
|
67
|
+
// The provider signature scheme is separate from Tappify's callback HMAC.
|
|
68
|
+
void request;
|
|
69
|
+
throw new Error(
|
|
70
|
+
'Implement provider signature verification and payload validation',
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function providerWebhook(
|
|
75
|
+
request: Request,
|
|
76
|
+
callback: SendWorkEventOptions,
|
|
77
|
+
): Promise<void> {
|
|
78
|
+
// callbackUrl/secret come from the encrypted configure routing record, never
|
|
79
|
+
// request parameters. Do not retain host-vault access or refresh tokens.
|
|
80
|
+
const verified = await verifyProviderWebhook(request);
|
|
81
|
+
await sendWorkEvent(normalizeProviderEvent(verified), callback);
|
|
82
|
+
}
|
|
@@ -1,14 +1,100 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
url: 'https://example.com/issues/example-1',
|
|
12
|
-
title: String(request.input.title ?? 'Untitled'),
|
|
13
|
-
}),
|
|
1
|
+
import type {
|
|
2
|
+
TappifyRouteHandler,
|
|
3
|
+
WorkOperationMap,
|
|
4
|
+
} from '@tappify/extension-sdk/server';
|
|
5
|
+
|
|
6
|
+
type WorkHandlers = {
|
|
7
|
+
[O in keyof WorkOperationMap]: TappifyRouteHandler<
|
|
8
|
+
WorkOperationMap[O]['input'],
|
|
9
|
+
WorkOperationMap[O]['output']
|
|
10
|
+
>;
|
|
14
11
|
};
|
|
12
|
+
type Mutation =
|
|
13
|
+
| 'configure'
|
|
14
|
+
| 'create'
|
|
15
|
+
| 'attach'
|
|
16
|
+
| 'comment'
|
|
17
|
+
| 'set_status'
|
|
18
|
+
| 'disconnect';
|
|
19
|
+
|
|
20
|
+
export interface WorkIdempotencyStore {
|
|
21
|
+
// Implement atomic claims/results in YOUR durable database, keyed by install,
|
|
22
|
+
// operation and logical key. eventId changes on transport retries. Concurrent
|
|
23
|
+
// claims must join/replay and failures must be retryable. Use provider-native
|
|
24
|
+
// idempotency too, to cover crashes after provider writes. Hosted document
|
|
25
|
+
// storage is not a background work ledger.
|
|
26
|
+
runOnce<T>(
|
|
27
|
+
identity: {
|
|
28
|
+
installId: string;
|
|
29
|
+
operation: Mutation;
|
|
30
|
+
idempotencyKey: string;
|
|
31
|
+
},
|
|
32
|
+
execute: () => Promise<T>,
|
|
33
|
+
): Promise<T>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function createWorkHandlers(
|
|
37
|
+
handlers: WorkHandlers,
|
|
38
|
+
store: WorkIdempotencyStore,
|
|
39
|
+
): WorkHandlers {
|
|
40
|
+
const once =
|
|
41
|
+
<O extends Mutation>(
|
|
42
|
+
operation: O,
|
|
43
|
+
handler: TappifyRouteHandler<
|
|
44
|
+
WorkOperationMap[O]['input'],
|
|
45
|
+
WorkOperationMap[O]['output']
|
|
46
|
+
>,
|
|
47
|
+
): TappifyRouteHandler<
|
|
48
|
+
WorkOperationMap[O]['input'],
|
|
49
|
+
WorkOperationMap[O]['output']
|
|
50
|
+
> =>
|
|
51
|
+
request =>
|
|
52
|
+
store.runOnce(
|
|
53
|
+
{
|
|
54
|
+
installId: request.install.id,
|
|
55
|
+
operation,
|
|
56
|
+
idempotencyKey: request.input.idempotencyKey,
|
|
57
|
+
},
|
|
58
|
+
async () => handler(request),
|
|
59
|
+
);
|
|
60
|
+
return {
|
|
61
|
+
...handlers,
|
|
62
|
+
configure: once('configure', handlers.configure),
|
|
63
|
+
create: once('create', handlers.create),
|
|
64
|
+
attach: once('attach', handlers.attach),
|
|
65
|
+
comment: once('comment', handlers.comment),
|
|
66
|
+
set_status: once('set_status', handlers.set_status),
|
|
67
|
+
disconnect: once('disconnect', handlers.disconnect),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function implement(operation: keyof WorkOperationMap, input: unknown): never {
|
|
72
|
+
void input;
|
|
73
|
+
throw new Error(`Implement provider work operation: ${operation}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const handlers: WorkHandlers = {
|
|
77
|
+
// Store callbackUrl/secret encrypted per install. Acknowledge generation and
|
|
78
|
+
// configurationRevision only after registering/rotating provider webhooks.
|
|
79
|
+
configure: request => implement('configure', request.input),
|
|
80
|
+
list_containers: request => implement('list_containers', request.input),
|
|
81
|
+
// Return dynamic itemTypes, createFields and exact statuses with their stages.
|
|
82
|
+
describe_container: request => implement('describe_container', request.input),
|
|
83
|
+
// Translate input.source/fields; return SDK WorkItemLinkResult, including
|
|
84
|
+
// externalItemId, displayKey, url, title and provider status.
|
|
85
|
+
create: request => implement('create', request.input),
|
|
86
|
+
attach: request => implement('attach', request.input),
|
|
87
|
+
// Append only; persist provider comment IDs to suppress webhook echoes.
|
|
88
|
+
comment: request => implement('comment', request.input),
|
|
89
|
+
set_status: request => implement('set_status', request.input),
|
|
90
|
+
// Fetch a short-lived opaque hydrateRef with current request.credentials.
|
|
91
|
+
hydrate_event: request => implement('hydrate_event', request.input),
|
|
92
|
+
// Remove registered provider webhooks before deleting encrypted routing data.
|
|
93
|
+
disconnect: request => implement('disconnect', request.input),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const work = createWorkHandlers(handlers, {
|
|
97
|
+
runOnce: async () => {
|
|
98
|
+
throw new Error('Implement a durable per-install work idempotency ledger');
|
|
99
|
+
},
|
|
100
|
+
});
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import type {
|
|
3
|
+
TappifyRequest,
|
|
4
|
+
WorkCreateInput,
|
|
5
|
+
WorkItemLinkResult,
|
|
6
|
+
} from '@tappify/extension-sdk/server';
|
|
7
|
+
import {
|
|
8
|
+
createWorkHandlers,
|
|
9
|
+
work,
|
|
10
|
+
type WorkIdempotencyStore,
|
|
11
|
+
} from '../server/work';
|
|
12
|
+
import {
|
|
13
|
+
normalizeProviderEvent,
|
|
14
|
+
verifyProviderWebhook,
|
|
15
|
+
} from '../server/provider-webhook';
|
|
16
|
+
|
|
17
|
+
// TEST-ONLY memory ledger. Production needs atomic durable claims/results and
|
|
18
|
+
// provider-native idempotency to survive process crashes and multiple workers.
|
|
19
|
+
function testLedger(): WorkIdempotencyStore {
|
|
20
|
+
const results = new Map<string, Promise<unknown>>();
|
|
21
|
+
return {
|
|
22
|
+
async runOnce<T>(
|
|
23
|
+
identity: Parameters<WorkIdempotencyStore['runOnce']>[0],
|
|
24
|
+
execute: () => Promise<T>,
|
|
25
|
+
): Promise<T> {
|
|
26
|
+
const key = JSON.stringify(identity);
|
|
27
|
+
let result = results.get(key);
|
|
28
|
+
if (result === undefined) {
|
|
29
|
+
result = Promise.resolve().then(execute);
|
|
30
|
+
results.set(key, result);
|
|
31
|
+
void result.catch(() => results.delete(key));
|
|
32
|
+
}
|
|
33
|
+
return result as Promise<T>;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const item: WorkItemLinkResult = {
|
|
39
|
+
externalItemId: 'issue-1',
|
|
40
|
+
displayKey: 'ENG-1',
|
|
41
|
+
url: 'https://provider.example.com/ENG-1',
|
|
42
|
+
title: 'Review feedback',
|
|
43
|
+
status: { id: 'todo', label: 'Todo', stage: 'open' },
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function request(
|
|
47
|
+
installId: string,
|
|
48
|
+
eventId: string,
|
|
49
|
+
): TappifyRequest<WorkCreateInput> {
|
|
50
|
+
return {
|
|
51
|
+
install: {
|
|
52
|
+
id: installId,
|
|
53
|
+
extensionId: '__id__',
|
|
54
|
+
projectId: 'project-1',
|
|
55
|
+
organizationId: 'org-1',
|
|
56
|
+
},
|
|
57
|
+
context: {
|
|
58
|
+
projectId: 'project-1',
|
|
59
|
+
platform: 'all',
|
|
60
|
+
from: '',
|
|
61
|
+
to: '',
|
|
62
|
+
filters: {
|
|
63
|
+
platform: 'all',
|
|
64
|
+
country: 'all',
|
|
65
|
+
range: { from: '2026-01-01', to: '2026-01-02' },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
credentials: {},
|
|
69
|
+
documents: {},
|
|
70
|
+
event: undefined,
|
|
71
|
+
eventId,
|
|
72
|
+
request: new Request('https://vendor.example.com/tappify/work/create'),
|
|
73
|
+
claims: {
|
|
74
|
+
iss: 'https://tappify.ai',
|
|
75
|
+
aud: 'ext:__id__',
|
|
76
|
+
exp: 9999999999,
|
|
77
|
+
iat: 1,
|
|
78
|
+
installId,
|
|
79
|
+
extensionId: '__id__',
|
|
80
|
+
projectId: 'project-1',
|
|
81
|
+
organizationId: 'org-1',
|
|
82
|
+
scopes: ['review.threads:read', 'work:create'],
|
|
83
|
+
},
|
|
84
|
+
input: {
|
|
85
|
+
idempotencyKey: 'thread:thread-1:create',
|
|
86
|
+
occurredAt: '2026-01-01T00:00:00Z',
|
|
87
|
+
containerId: 'project-1',
|
|
88
|
+
itemTypeId: 'issue',
|
|
89
|
+
fields: {},
|
|
90
|
+
source: {
|
|
91
|
+
threadId: 'thread-1',
|
|
92
|
+
projectId: 'project-1',
|
|
93
|
+
appId: 'app-1',
|
|
94
|
+
buildVersion: '1.0',
|
|
95
|
+
buildNumber: '1',
|
|
96
|
+
screenId: 'screen-1',
|
|
97
|
+
pin: { x: 0.5, y: 0.5 },
|
|
98
|
+
firstComment: {
|
|
99
|
+
id: 'comment-1',
|
|
100
|
+
body: 'Review feedback',
|
|
101
|
+
authorDisplayName: 'Owner',
|
|
102
|
+
createdAt: '2026-01-01T00:00:00Z',
|
|
103
|
+
},
|
|
104
|
+
device: {},
|
|
105
|
+
deepLink: 'https://tappify.ai/review/thread-1',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
describe('work delivery', () => {
|
|
112
|
+
it('replays create by input.idempotencyKey across concurrent transport deliveries', async () => {
|
|
113
|
+
let creates = 0;
|
|
114
|
+
const handlers = createWorkHandlers(
|
|
115
|
+
{
|
|
116
|
+
...work,
|
|
117
|
+
create: async () => {
|
|
118
|
+
creates++;
|
|
119
|
+
return item;
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
testLedger(),
|
|
123
|
+
);
|
|
124
|
+
expect(
|
|
125
|
+
await Promise.all([
|
|
126
|
+
handlers.create(request('install-1', 'delivery-1')),
|
|
127
|
+
handlers.create(request('install-1', 'delivery-2')),
|
|
128
|
+
]),
|
|
129
|
+
).toEqual([item, item]);
|
|
130
|
+
expect(creates).toBe(1);
|
|
131
|
+
await handlers.create(request('install-2', 'delivery-3'));
|
|
132
|
+
expect(creates).toBe(2);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('allows a failed logical create to retry', async () => {
|
|
136
|
+
let attempts = 0;
|
|
137
|
+
const handlers = createWorkHandlers(
|
|
138
|
+
{
|
|
139
|
+
...work,
|
|
140
|
+
create: async () => {
|
|
141
|
+
if (++attempts === 1) throw new Error('Provider unavailable');
|
|
142
|
+
return item;
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
testLedger(),
|
|
146
|
+
);
|
|
147
|
+
await expect(
|
|
148
|
+
handlers.create(request('install-1', 'delivery-1')),
|
|
149
|
+
).rejects.toThrow('Provider unavailable');
|
|
150
|
+
await expect(
|
|
151
|
+
handlers.create(request('install-1', 'delivery-2')),
|
|
152
|
+
).resolves.toEqual(item);
|
|
153
|
+
expect(attempts).toBe(2);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('normalizes append-only comments with stable dedupe keys', () => {
|
|
157
|
+
const event = {
|
|
158
|
+
id: 'event-1',
|
|
159
|
+
itemId: 'issue-1',
|
|
160
|
+
occurredAt: '2026-01-01T00:00:00Z',
|
|
161
|
+
type: 'comment' as const,
|
|
162
|
+
commentId: 'external-comment-1',
|
|
163
|
+
text: 'Feedback',
|
|
164
|
+
authorId: 'author-1',
|
|
165
|
+
authorName: 'Provider author',
|
|
166
|
+
};
|
|
167
|
+
expect(normalizeProviderEvent(event)).toEqual({
|
|
168
|
+
type: 'comment.created',
|
|
169
|
+
externalItemId: 'issue-1',
|
|
170
|
+
providerEventId: 'event-1',
|
|
171
|
+
dedupeKey: 'provider:event-1',
|
|
172
|
+
occurredAt: '2026-01-01T00:00:00Z',
|
|
173
|
+
comment: {
|
|
174
|
+
externalCommentId: 'external-comment-1',
|
|
175
|
+
body: 'Feedback',
|
|
176
|
+
author: { id: 'author-1', displayName: 'Provider author' },
|
|
177
|
+
createdAt: '2026-01-01T00:00:00Z',
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
expect(normalizeProviderEvent({ ...event })).toEqual(
|
|
181
|
+
normalizeProviderEvent(event),
|
|
182
|
+
);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('normalizes provider status and deletion', () => {
|
|
186
|
+
const common = {
|
|
187
|
+
id: 'event-2',
|
|
188
|
+
itemId: 'issue-1',
|
|
189
|
+
occurredAt: '2026-01-01T00:00:00Z',
|
|
190
|
+
};
|
|
191
|
+
expect(
|
|
192
|
+
normalizeProviderEvent({
|
|
193
|
+
...common,
|
|
194
|
+
type: 'status',
|
|
195
|
+
statusId: 'done',
|
|
196
|
+
statusName: 'Done',
|
|
197
|
+
done: true,
|
|
198
|
+
}),
|
|
199
|
+
).toMatchObject({
|
|
200
|
+
type: 'status.changed',
|
|
201
|
+
status: { id: 'done', label: 'Done', stage: 'done' },
|
|
202
|
+
});
|
|
203
|
+
expect(
|
|
204
|
+
normalizeProviderEvent({ ...common, type: 'deleted' }),
|
|
205
|
+
).toMatchObject({ type: 'item.deleted', dedupeKey: 'provider:event-2' });
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('refuses webhook delivery until provider signature verification is implemented', async () => {
|
|
209
|
+
await expect(
|
|
210
|
+
verifyProviderWebhook(
|
|
211
|
+
new Request('https://vendor.example.com/provider-webhook', {
|
|
212
|
+
method: 'POST',
|
|
213
|
+
body: '{}',
|
|
214
|
+
}),
|
|
215
|
+
),
|
|
216
|
+
).rejects.toThrow('Implement provider signature verification');
|
|
217
|
+
});
|
|
218
|
+
});
|