@treeseed/sdk 0.8.3 → 0.8.5

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 (47) hide show
  1. package/dist/capacity.d.ts +33 -0
  2. package/dist/fixture-support.d.ts +1 -1
  3. package/dist/fixture-support.js +5 -5
  4. package/dist/managed-dependencies.js +132 -10
  5. package/dist/operations/services/bootstrap-runner.js +7 -1
  6. package/dist/operations/services/config-runtime.js +13 -4
  7. package/dist/operations/services/github-actions-verification.d.ts +3 -0
  8. package/dist/operations/services/github-actions-verification.js +3 -0
  9. package/dist/operations/services/github-api.d.ts +4 -1
  10. package/dist/operations/services/github-api.js +26 -8
  11. package/dist/operations/services/github-automation.d.ts +14 -5
  12. package/dist/operations/services/github-automation.js +45 -11
  13. package/dist/operations/services/hub-provider-launch.js +9 -8
  14. package/dist/operations/services/project-platform.d.ts +93 -210
  15. package/dist/operations/services/project-platform.js +74 -34
  16. package/dist/operations/services/railway-deploy.d.ts +25 -2
  17. package/dist/operations/services/railway-deploy.js +312 -20
  18. package/dist/operations/services/repository-save-orchestrator.d.ts +8 -0
  19. package/dist/operations/services/repository-save-orchestrator.js +40 -3
  20. package/dist/operations/services/runtime-paths.d.ts +1 -0
  21. package/dist/operations/services/runtime-paths.js +3 -1
  22. package/dist/operations/services/runtime-tools.d.ts +1 -0
  23. package/dist/operations/services/runtime-tools.js +2 -0
  24. package/dist/operations/services/template-registry.js +3 -0
  25. package/dist/platform/contracts.d.ts +9 -0
  26. package/dist/platform/deploy-config.js +28 -0
  27. package/dist/platform/env.yaml +1 -745
  28. package/dist/platform/environment.js +69 -9
  29. package/dist/reconcile/builtin-adapters.js +7 -2
  30. package/dist/scripts/install-managed-dependencies.js +12 -0
  31. package/dist/scripts/tenant-workflow-action.js +11 -9
  32. package/dist/scripts/test-scaffold.js +3 -1
  33. package/dist/scripts/workflow-commands.test.js +10 -6
  34. package/dist/scripts/workspace-command-e2e.js +1 -1
  35. package/dist/treeseed/template-catalog/templates/starter-basic/template/package.json +1 -0
  36. package/dist/treeseed/template-catalog/templates/starter-basic/template/src/api/server.js +1 -1
  37. package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +7 -6
  38. package/dist/treeseed/template-catalog/templates/starter-basic/template.config.json +6 -0
  39. package/dist/workflow/operations.d.ts +41 -8
  40. package/dist/workflow/operations.js +119 -24
  41. package/dist/workflow/runs.js +31 -0
  42. package/package.json +1 -1
  43. package/templates/github/deploy-processing.workflow.yml +120 -0
  44. package/templates/github/deploy-web.workflow.yml +116 -0
  45. package/templates/github/hosted-project.workflow.yml +4 -4
  46. package/templates/github/deploy.managed.workflow.yml +0 -208
  47. package/templates/github/deploy.workflow.yml +0 -746
@@ -1,208 +0,0 @@
1
- name: Treeseed Managed Hosted Project
2
-
3
- on:
4
- workflow_dispatch:
5
- inputs:
6
- project_id:
7
- description: Treeseed project id recorded in the Market control plane
8
- required: false
9
- type: string
10
- environment:
11
- description: Target environment
12
- required: true
13
- default: staging
14
- type: choice
15
- options:
16
- - staging
17
- - prod
18
- action_kind:
19
- description: Requested managed operation
20
- required: true
21
- default: deploy_code
22
- type: choice
23
- options:
24
- - provision
25
- - deploy_code
26
- - publish_content
27
- - monitor
28
- push:
29
- branches:
30
- - staging
31
- - main
32
- release:
33
- types: [published]
34
-
35
- concurrency:
36
- group: treeseed-managed-${{ github.workflow }}-${{ github.ref }}
37
- cancel-in-progress: false
38
-
39
- jobs:
40
- classify:
41
- runs-on: ubuntu-latest
42
- outputs:
43
- scope: ${{ steps.classify.outputs.scope }}
44
- workflow_action: ${{ steps.classify.outputs.workflow_action }}
45
- code_changed: ${{ steps.classify.outputs.code_changed }}
46
- content_changed: ${{ steps.classify.outputs.content_changed }}
47
- release_tag: ${{ steps.classify.outputs.release_tag }}
48
- steps:
49
- - name: Classify change
50
- id: classify
51
- shell: bash
52
- run: |
53
- set -euo pipefail
54
- if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
55
- scope="${{ inputs.environment }}"
56
- workflow_action="${{ inputs.action_kind }}"
57
- code_changed=$([[ "${workflow_action}" == "deploy_code" ]] && echo "true" || echo "false")
58
- content_changed=$([[ "${workflow_action}" == "publish_content" ]] && echo "true" || echo "false")
59
- release_tag="false"
60
- elif [[ "${{ github.event_name }}" == "release" ]]; then
61
- scope="prod"
62
- workflow_action="deploy_code"
63
- code_changed="true"
64
- content_changed="false"
65
- release_tag="true"
66
- elif [[ "${{ github.ref_name }}" == "main" ]]; then
67
- scope="prod"
68
- workflow_action="deploy_code"
69
- code_changed="true"
70
- content_changed="false"
71
- release_tag="false"
72
- else
73
- scope="staging"
74
- workflow_action="deploy_code"
75
- code_changed="true"
76
- content_changed="false"
77
- release_tag="false"
78
- fi
79
- echo "scope=${scope}" >> "${GITHUB_OUTPUT}"
80
- echo "workflow_action=${workflow_action}" >> "${GITHUB_OUTPUT}"
81
- echo "code_changed=${code_changed}" >> "${GITHUB_OUTPUT}"
82
- echo "content_changed=${content_changed}" >> "${GITHUB_OUTPUT}"
83
- echo "release_tag=${release_tag}" >> "${GITHUB_OUTPUT}"
84
-
85
- verify:
86
- runs-on: ubuntu-latest
87
- needs: classify
88
- permissions:
89
- contents: read
90
- __WORKING_DIRECTORY_BLOCK__
91
- steps:
92
- - name: Checkout
93
- uses: actions/checkout@v4
94
-
95
- - name: Setup Node
96
- uses: actions/setup-node@v4
97
- with:
98
- node-version: 22
99
- cache: npm
100
- cache-dependency-path: __CACHE_DEPENDENCY_PATH__
101
-
102
- - name: Install dependencies
103
- shell: bash
104
- run: npm ci --ignore-scripts
105
-
106
- - name: Build workspace package artifacts
107
- shell: bash
108
- run: |
109
- set -euo pipefail
110
- for dir in packages/sdk packages/core packages/cli; do
111
- if test -f "${dir}/package.json"; then
112
- npm --prefix "${dir}" run build:dist
113
- fi
114
- done
115
-
116
- - name: Verify workspace
117
- shell: bash
118
- run: |
119
- set -euo pipefail
120
- npm run verify:local
121
-
122
- request-managed-operation:
123
- runs-on: ubuntu-latest
124
- needs:
125
- - classify
126
- - verify
127
- if: |
128
- needs.classify.outputs.workflow_action == 'provision' ||
129
- needs.classify.outputs.workflow_action == 'deploy_code' ||
130
- needs.classify.outputs.workflow_action == 'publish_content' ||
131
- needs.classify.outputs.workflow_action == 'monitor' ||
132
- needs.classify.outputs.code_changed == 'true' ||
133
- needs.classify.outputs.content_changed == 'true' ||
134
- needs.classify.outputs.release_tag == 'true'
135
- permissions:
136
- contents: read
137
- id-token: write
138
- environment: ${{ needs.classify.outputs.scope == 'prod' && 'production' || 'staging' }}
139
- env:
140
- TREESEED_MARKET_API_BASE_URL: ${{ vars.TREESEED_MARKET_API_BASE_URL || vars.TREESEED_CENTRAL_MARKET_API_BASE_URL || 'https://api.treeseed.ai' }}
141
- TREESEED_PROJECT_ID: ${{ inputs.project_id || vars.TREESEED_PROJECT_ID }}
142
- TREESEED_WORKFLOW_ACTION: ${{ needs.classify.outputs.workflow_action }}
143
- TREESEED_WORKFLOW_ENVIRONMENT: ${{ needs.classify.outputs.scope }}
144
- steps:
145
- - name: Request TreeSeed managed operation
146
- shell: bash
147
- run: |
148
- set -euo pipefail
149
- if [[ -z "${TREESEED_PROJECT_ID}" ]]; then
150
- echo "TREESEED_PROJECT_ID is required for managed TreeSeed operations."
151
- exit 1
152
- fi
153
- audience="treeseed:${TREESEED_PROJECT_ID}"
154
- oidc_json="$(curl -fsSL -H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=${audience}")"
155
- oidc_token="$(node -e "const fs=require('node:fs'); const data=JSON.parse(fs.readFileSync(0,'utf8')); process.stdout.write(data.value || '')" <<< "${oidc_json}")"
156
- if [[ -z "${oidc_token}" ]]; then
157
- echo "GitHub did not return an OIDC token."
158
- exit 1
159
- fi
160
- request_json="$(OIDC_TOKEN="${oidc_token}" node --input-type=module <<'NODE'
161
- const payload = {
162
- oidcToken: process.env.OIDC_TOKEN,
163
- actionKind: process.env.TREESEED_WORKFLOW_ACTION,
164
- environment: process.env.TREESEED_WORKFLOW_ENVIRONMENT,
165
- repository: process.env.GITHUB_REPOSITORY,
166
- ref: process.env.GITHUB_REF,
167
- refName: process.env.GITHUB_REF_NAME,
168
- sha: process.env.GITHUB_SHA,
169
- workflow: process.env.GITHUB_WORKFLOW,
170
- workflowRef: process.env.GITHUB_WORKFLOW_REF,
171
- runId: process.env.GITHUB_RUN_ID,
172
- runAttempt: process.env.GITHUB_RUN_ATTEMPT,
173
- };
174
- process.stdout.write(JSON.stringify(payload));
175
- NODE
176
- )"
177
- response="$(curl -fsSL -X POST "${TREESEED_MARKET_API_BASE_URL%/}/v1/projects/${TREESEED_PROJECT_ID}/ci/oidc/exchange" \
178
- -H "content-type: application/json" \
179
- --data "${request_json}")"
180
- node -e "const r=JSON.parse(process.argv[1]); if (!r.ok) { throw new Error(r.error || 'TreeSeed operation request failed'); } console.log('Requested TreeSeed job ' + r.payload.job.id + ' (' + r.payload.job.status + ')');" "${response}"
181
- echo "${response}" > treeseed-operation.json
182
-
183
- - name: Wait for TreeSeed managed operation
184
- shell: bash
185
- run: |
186
- set -euo pipefail
187
- job_id="$(node -e "const r=require('./treeseed-operation.json'); process.stdout.write(r.payload.job.id)")"
188
- operation_token="$(node -e "const r=require('./treeseed-operation.json'); process.stdout.write(r.payload.operationToken || '')")"
189
- if [[ -z "${operation_token}" ]]; then
190
- echo "TreeSeed did not return an operation status token."
191
- exit 1
192
- fi
193
- for attempt in $(seq 1 180); do
194
- status_json="$(curl -fsSL "${TREESEED_MARKET_API_BASE_URL%/}/v1/projects/${TREESEED_PROJECT_ID}/ci/jobs/${job_id}" \
195
- -H "authorization: Bearer ${operation_token}")"
196
- status="$(node -e "const r=JSON.parse(process.argv[1]); process.stdout.write(r.payload.job.status)" "${status_json}")"
197
- echo "TreeSeed job ${job_id}: ${status}"
198
- if [[ "${status}" == "succeeded" ]]; then
199
- exit 0
200
- fi
201
- if [[ "${status}" == "failed" || "${status}" == "cancelled" ]]; then
202
- node -e "const r=JSON.parse(process.argv[1]); console.error(JSON.stringify(r.payload.job.error || {}, null, 2));" "${status_json}"
203
- exit 1
204
- fi
205
- sleep 10
206
- done
207
- echo "Timed out waiting for TreeSeed job ${job_id}."
208
- exit 1