@lightdash/common 3.57.1 → 3.58.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 (142) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/ee/AiAgent/adminTypes.d.ts +2 -0
  3. package/dist/cjs/ee/AiAgent/adminTypes.d.ts.map +1 -1
  4. package/dist/cjs/ee/AiAgent/chartConfig/web/getWebAiChartConfig.d.ts +12 -12
  5. package/dist/cjs/ee/AiAgent/schemas/tools/index.d.ts +0 -1
  6. package/dist/cjs/ee/AiAgent/schemas/tools/index.d.ts.map +1 -1
  7. package/dist/cjs/ee/AiAgent/schemas/tools/index.js +0 -1
  8. package/dist/cjs/ee/AiAgent/schemas/tools/index.js.map +1 -1
  9. package/dist/cjs/ee/AiAgent/schemas/tools/toolDefinitions.d.ts +0 -3
  10. package/dist/cjs/ee/AiAgent/schemas/tools/toolDefinitions.d.ts.map +1 -1
  11. package/dist/cjs/ee/AiAgent/schemas/tools/toolDefinitions.js +2 -13
  12. package/dist/cjs/ee/AiAgent/schemas/tools/toolDefinitions.js.map +1 -1
  13. package/dist/cjs/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.d.ts +0 -8
  14. package/dist/cjs/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.d.ts.map +1 -1
  15. package/dist/cjs/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.js +0 -12
  16. package/dist/cjs/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.js.map +1 -1
  17. package/dist/cjs/ee/AiAgent/schemas/visualizations/index.d.ts +2 -4
  18. package/dist/cjs/ee/AiAgent/schemas/visualizations/index.d.ts.map +1 -1
  19. package/dist/cjs/ee/AiAgent/schemas/visualizations/index.js +0 -3
  20. package/dist/cjs/ee/AiAgent/schemas/visualizations/index.js.map +1 -1
  21. package/dist/cjs/ee/AiAgent/utils.d.ts +25 -25
  22. package/dist/cjs/featureFlags/previewFeatureFlags.d.ts.map +1 -1
  23. package/dist/cjs/featureFlags/previewFeatureFlags.js +0 -2
  24. package/dist/cjs/featureFlags/previewFeatureFlags.js.map +1 -1
  25. package/dist/cjs/index.d.ts +0 -2
  26. package/dist/cjs/index.d.ts.map +1 -1
  27. package/dist/cjs/index.js +0 -2
  28. package/dist/cjs/index.js.map +1 -1
  29. package/dist/cjs/types/api.d.ts +1 -2
  30. package/dist/cjs/types/api.d.ts.map +1 -1
  31. package/dist/cjs/types/api.js.map +1 -1
  32. package/dist/cjs/types/featureFlags.d.ts +0 -13
  33. package/dist/cjs/types/featureFlags.d.ts.map +1 -1
  34. package/dist/cjs/types/featureFlags.js +0 -13
  35. package/dist/cjs/types/featureFlags.js.map +1 -1
  36. package/dist/esm/.tsbuildinfo +1 -1
  37. package/dist/esm/ee/AiAgent/adminTypes.d.ts +2 -0
  38. package/dist/esm/ee/AiAgent/adminTypes.d.ts.map +1 -1
  39. package/dist/esm/ee/AiAgent/chartConfig/web/getWebAiChartConfig.d.ts +25 -25
  40. package/dist/esm/ee/AiAgent/schemas/tools/index.d.ts +0 -1
  41. package/dist/esm/ee/AiAgent/schemas/tools/index.d.ts.map +1 -1
  42. package/dist/esm/ee/AiAgent/schemas/tools/index.js +0 -1
  43. package/dist/esm/ee/AiAgent/schemas/tools/index.js.map +1 -1
  44. package/dist/esm/ee/AiAgent/schemas/tools/toolDefinitions.d.ts +0 -3
  45. package/dist/esm/ee/AiAgent/schemas/tools/toolDefinitions.d.ts.map +1 -1
  46. package/dist/esm/ee/AiAgent/schemas/tools/toolDefinitions.js +0 -11
  47. package/dist/esm/ee/AiAgent/schemas/tools/toolDefinitions.js.map +1 -1
  48. package/dist/esm/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.d.ts +0 -8
  49. package/dist/esm/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.d.ts.map +1 -1
  50. package/dist/esm/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.js +0 -12
  51. package/dist/esm/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.js.map +1 -1
  52. package/dist/esm/ee/AiAgent/schemas/visualizations/index.d.ts +2 -4
  53. package/dist/esm/ee/AiAgent/schemas/visualizations/index.d.ts.map +1 -1
  54. package/dist/esm/ee/AiAgent/schemas/visualizations/index.js +0 -3
  55. package/dist/esm/ee/AiAgent/schemas/visualizations/index.js.map +1 -1
  56. package/dist/esm/ee/AiAgent/utils.d.ts +28 -28
  57. package/dist/esm/featureFlags/previewFeatureFlags.d.ts.map +1 -1
  58. package/dist/esm/featureFlags/previewFeatureFlags.js +0 -2
  59. package/dist/esm/featureFlags/previewFeatureFlags.js.map +1 -1
  60. package/dist/esm/index.d.ts +0 -2
  61. package/dist/esm/index.d.ts.map +1 -1
  62. package/dist/esm/index.js +0 -2
  63. package/dist/esm/index.js.map +1 -1
  64. package/dist/esm/types/api.d.ts +1 -2
  65. package/dist/esm/types/api.d.ts.map +1 -1
  66. package/dist/esm/types/api.js.map +1 -1
  67. package/dist/esm/types/featureFlags.d.ts +0 -13
  68. package/dist/esm/types/featureFlags.d.ts.map +1 -1
  69. package/dist/esm/types/featureFlags.js +0 -13
  70. package/dist/esm/types/featureFlags.js.map +1 -1
  71. package/dist/types/.tsbuildinfo +1 -1
  72. package/dist/types/ee/AiAgent/adminTypes.d.ts +2 -0
  73. package/dist/types/ee/AiAgent/adminTypes.d.ts.map +1 -1
  74. package/dist/types/ee/AiAgent/chartConfig/web/getWebAiChartConfig.d.ts +25 -25
  75. package/dist/types/ee/AiAgent/schemas/tools/index.d.ts +0 -1
  76. package/dist/types/ee/AiAgent/schemas/tools/index.d.ts.map +1 -1
  77. package/dist/types/ee/AiAgent/schemas/tools/index.js +0 -1
  78. package/dist/types/ee/AiAgent/schemas/tools/index.js.map +1 -1
  79. package/dist/types/ee/AiAgent/schemas/tools/toolDefinitions.d.ts +0 -3
  80. package/dist/types/ee/AiAgent/schemas/tools/toolDefinitions.d.ts.map +1 -1
  81. package/dist/types/ee/AiAgent/schemas/tools/toolDefinitions.js +0 -11
  82. package/dist/types/ee/AiAgent/schemas/tools/toolDefinitions.js.map +1 -1
  83. package/dist/types/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.d.ts +0 -8
  84. package/dist/types/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.d.ts.map +1 -1
  85. package/dist/types/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.js +0 -12
  86. package/dist/types/ee/AiAgent/schemas/tools/toolGetProjectInfoArgs.js.map +1 -1
  87. package/dist/types/ee/AiAgent/schemas/visualizations/index.d.ts +2 -4
  88. package/dist/types/ee/AiAgent/schemas/visualizations/index.d.ts.map +1 -1
  89. package/dist/types/ee/AiAgent/schemas/visualizations/index.js +0 -3
  90. package/dist/types/ee/AiAgent/schemas/visualizations/index.js.map +1 -1
  91. package/dist/types/ee/AiAgent/utils.d.ts +28 -28
  92. package/dist/types/featureFlags/previewFeatureFlags.d.ts.map +1 -1
  93. package/dist/types/featureFlags/previewFeatureFlags.js +0 -2
  94. package/dist/types/featureFlags/previewFeatureFlags.js.map +1 -1
  95. package/dist/types/index.d.ts +0 -2
  96. package/dist/types/index.d.ts.map +1 -1
  97. package/dist/types/index.js +0 -2
  98. package/dist/types/index.js.map +1 -1
  99. package/dist/types/types/api.d.ts +1 -2
  100. package/dist/types/types/api.d.ts.map +1 -1
  101. package/dist/types/types/api.js.map +1 -1
  102. package/dist/types/types/featureFlags.d.ts +0 -13
  103. package/dist/types/types/featureFlags.d.ts.map +1 -1
  104. package/dist/types/types/featureFlags.js +0 -13
  105. package/dist/types/types/featureFlags.js.map +1 -1
  106. package/package.json +1 -1
  107. package/dist/cjs/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.d.ts +0 -63
  108. package/dist/cjs/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.d.ts.map +0 -1
  109. package/dist/cjs/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.js +0 -54
  110. package/dist/cjs/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.js.map +0 -1
  111. package/dist/cjs/types/projectCiStatus.d.ts +0 -27
  112. package/dist/cjs/types/projectCiStatus.d.ts.map +0 -1
  113. package/dist/cjs/types/projectCiStatus.js +0 -3
  114. package/dist/cjs/types/projectCiStatus.js.map +0 -1
  115. package/dist/cjs/utils/previewDeployWorkflow.d.ts +0 -73
  116. package/dist/cjs/utils/previewDeployWorkflow.d.ts.map +0 -1
  117. package/dist/cjs/utils/previewDeployWorkflow.js +0 -192
  118. package/dist/cjs/utils/previewDeployWorkflow.js.map +0 -1
  119. package/dist/esm/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.d.ts +0 -63
  120. package/dist/esm/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.d.ts.map +0 -1
  121. package/dist/esm/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.js +0 -51
  122. package/dist/esm/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.js.map +0 -1
  123. package/dist/esm/types/projectCiStatus.d.ts +0 -27
  124. package/dist/esm/types/projectCiStatus.d.ts.map +0 -1
  125. package/dist/esm/types/projectCiStatus.js +0 -2
  126. package/dist/esm/types/projectCiStatus.js.map +0 -1
  127. package/dist/esm/utils/previewDeployWorkflow.d.ts +0 -73
  128. package/dist/esm/utils/previewDeployWorkflow.d.ts.map +0 -1
  129. package/dist/esm/utils/previewDeployWorkflow.js +0 -185
  130. package/dist/esm/utils/previewDeployWorkflow.js.map +0 -1
  131. package/dist/types/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.d.ts +0 -63
  132. package/dist/types/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.d.ts.map +0 -1
  133. package/dist/types/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.js +0 -51
  134. package/dist/types/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.js.map +0 -1
  135. package/dist/types/types/projectCiStatus.d.ts +0 -27
  136. package/dist/types/types/projectCiStatus.d.ts.map +0 -1
  137. package/dist/types/types/projectCiStatus.js +0 -2
  138. package/dist/types/types/projectCiStatus.js.map +0 -1
  139. package/dist/types/utils/previewDeployWorkflow.d.ts +0 -73
  140. package/dist/types/utils/previewDeployWorkflow.d.ts.map +0 -1
  141. package/dist/types/utils/previewDeployWorkflow.js +0 -185
  142. package/dist/types/utils/previewDeployWorkflow.js.map +0 -1
@@ -1,192 +0,0 @@
1
- "use strict";
2
- /**
3
- * Detection and generation of Lightdash "preview project" GitHub Actions.
4
- *
5
- * Lightdash ships a canonical CI workflow (the `lightdash/cli-actions`
6
- * `start-preview.yml` / `close-preview.yml` pair) that spins up a temporary
7
- * preview project for every pull request and tears it down on close. The AI
8
- * writeback sandbox agent detects whether a repo already has this set up and,
9
- * if not, offers to open a PR adding it.
10
- *
11
- * Everything here is pure so it can be unit-tested without a sandbox or
12
- * database: detection takes the workflow files as `{ path, content }` and the
13
- * generators take only the project identity.
14
- */
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.generatePreviewDeployWorkflowFiles = exports.getPreviewDeploySecrets = exports.detectPreviewDeployWorkflow = exports.isWorkflowFile = exports.PREVIEW_DEPLOY_WORKFLOW_MARKERS = void 0;
17
- /**
18
- * Substrings that, when found in a `.github/workflows` file, indicate the repo
19
- * already deploys Lightdash preview projects. `lightdash deploy` is
20
- * deliberately excluded — that is a production deploy, not a preview.
21
- */
22
- exports.PREVIEW_DEPLOY_WORKFLOW_MARKERS = [
23
- 'lightdash start-preview',
24
- 'start-preview',
25
- 'lightdash stop-preview',
26
- 'stop-preview',
27
- 'lightdash preview',
28
- 'lightdash-deploy-action',
29
- ];
30
- const WORKFLOWS_DIR = '.github/workflows/';
31
- /** True for `.github/workflows/*.yml|*.yaml` paths (tolerates a `./` prefix). */
32
- const isWorkflowFile = (path) => {
33
- const normalized = path.replace(/^\.\//, '');
34
- return (normalized.startsWith(WORKFLOWS_DIR) &&
35
- (normalized.endsWith('.yml') || normalized.endsWith('.yaml')));
36
- };
37
- exports.isWorkflowFile = isWorkflowFile;
38
- const detectPreviewDeployWorkflow = (files) => {
39
- const match = files.find((file) => (0, exports.isWorkflowFile)(file.path) &&
40
- exports.PREVIEW_DEPLOY_WORKFLOW_MARKERS.some((marker) => file.content.includes(marker)));
41
- return {
42
- hasPreviewDeployWorkflow: match !== undefined,
43
- workflowPath: match?.path ?? null,
44
- };
45
- };
46
- exports.detectPreviewDeployWorkflow = detectPreviewDeployWorkflow;
47
- const getPreviewDeploySecrets = ({ projectUuid, siteUrl, }) => {
48
- const baseUrl = siteUrl.replace(/\/+$/, '');
49
- return [
50
- {
51
- name: 'LIGHTDASH_URL',
52
- value: siteUrl,
53
- description: 'The base URL of your Lightdash instance.',
54
- },
55
- {
56
- name: 'LIGHTDASH_PROJECT',
57
- value: projectUuid,
58
- description: 'The UUID of the Lightdash project to base preview projects on.',
59
- },
60
- {
61
- name: 'LIGHTDASH_API_KEY',
62
- value: null,
63
- description: `A Lightdash personal access token — create one at ${baseUrl}/generalSettings/personalAccessTokens. Lightdash cannot create this for you.`,
64
- },
65
- {
66
- name: 'DBT_PROFILES',
67
- value: null,
68
- description: 'A dbt profiles.yml with your warehouse connection. Lightdash never stores your warehouse password, so you must add this yourself.',
69
- },
70
- ];
71
- };
72
- exports.getPreviewDeploySecrets = getPreviewDeploySecrets;
73
- const PREVIEW_WORKFLOW_PATH = `${WORKFLOWS_DIR}start-preview.yml`;
74
- const CLOSE_WORKFLOW_PATH = `${WORKFLOWS_DIR}close-preview.yml`;
75
- // Third-party actions are pinned to a full commit SHA (with a version comment)
76
- // rather than a floating tag — these workflows run with the repo's warehouse +
77
- // Lightdash secrets in scope, so a retagged/compromised action is a real
78
- // supply-chain risk. SHAs match the pins Lightdash uses in its own CI.
79
- const CHECKOUT_ACTION = 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2';
80
- const SETUP_NODE_ACTION = 'actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6';
81
- const GITHUB_SCRIPT_ACTION = 'actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8';
82
- /**
83
- * Generate the canonical Lightdash preview-on-PR workflow pair.
84
- *
85
- * @param projectSubPath dbt project directory within the repo (repo root when
86
- * null) — passed to the CLI as `--project-dir`.
87
- * @param cliVersion the `@lightdash/cli` version to pin. Pass the Lightdash
88
- * instance's own version (`VERSION`): every Lightdash package releases in
89
- * lockstep, so the instance version is the CLI version that matches it — this
90
- * keeps the pin reproducible, compatible, and self-updating with the instance
91
- * instead of frozen at a literal that rots.
92
- */
93
- const generatePreviewDeployWorkflowFiles = ({ projectSubPath, cliVersion, }) => {
94
- const projectDir = projectSubPath && projectSubPath !== '' ? projectSubPath : '.';
95
- const startPreview = `name: lightdash-start-preview
96
- on:
97
- pull_request:
98
- types: [opened, synchronize, reopened]
99
- # contents:read for checkout; pull-requests:write to post the preview link
100
- # comment. Both must be listed — an omitted scope defaults to none.
101
- permissions:
102
- contents: read
103
- pull-requests: write
104
- concurrency:
105
- group: lightdash-preview-\${{ github.ref }}
106
- cancel-in-progress: true
107
- jobs:
108
- start-preview:
109
- runs-on: ubuntu-latest
110
- timeout-minutes: 15
111
- env:
112
- PROJECT_DIR: ${projectDir}
113
- steps:
114
- - uses: ${CHECKOUT_ACTION}
115
- - uses: ${SETUP_NODE_ACTION}
116
- with:
117
- node-version: '24.x'
118
- - name: Install Lightdash CLI
119
- run: npm install -g @lightdash/cli@${cliVersion}
120
- - name: Write dbt profiles
121
- run: echo "$DBT_PROFILES" > profiles.yml
122
- env:
123
- DBT_PROFILES: \${{ secrets.DBT_PROFILES }}
124
- - name: Create preview project
125
- id: preview
126
- run: lightdash start-preview --project-dir "$PROJECT_DIR" --profiles-dir . --name "\${GITHUB_HEAD_REF}"
127
- env:
128
- LIGHTDASH_URL: \${{ secrets.LIGHTDASH_URL }}
129
- LIGHTDASH_PROJECT: \${{ secrets.LIGHTDASH_PROJECT }}
130
- LIGHTDASH_API_KEY: \${{ secrets.LIGHTDASH_API_KEY }}
131
- - name: Comment preview link on PR
132
- if: steps.preview.outputs.url != ''
133
- uses: ${GITHUB_SCRIPT_ACTION}
134
- env:
135
- PREVIEW_URL: \${{ steps.preview.outputs.url }}
136
- with:
137
- script: |
138
- const marker = '<!-- lightdash-preview -->';
139
- const body = marker + '\\n:zap: Your Lightdash preview project is ready: ' + process.env.PREVIEW_URL;
140
- const { data: comments } = await github.rest.issues.listComments({
141
- owner: context.repo.owner,
142
- repo: context.repo.repo,
143
- issue_number: context.issue.number,
144
- });
145
- const existing = comments.find((c) => c.body && c.body.includes(marker));
146
- if (existing) {
147
- await github.rest.issues.updateComment({
148
- owner: context.repo.owner,
149
- repo: context.repo.repo,
150
- comment_id: existing.id,
151
- body,
152
- });
153
- } else {
154
- await github.rest.issues.createComment({
155
- owner: context.repo.owner,
156
- repo: context.repo.repo,
157
- issue_number: context.issue.number,
158
- body,
159
- });
160
- }
161
- `;
162
- const closePreview = `name: lightdash-close-preview
163
- on:
164
- pull_request:
165
- types: [closed]
166
- permissions:
167
- contents: read
168
- jobs:
169
- close-preview:
170
- runs-on: ubuntu-latest
171
- timeout-minutes: 15
172
- steps:
173
- - uses: ${CHECKOUT_ACTION}
174
- - uses: ${SETUP_NODE_ACTION}
175
- with:
176
- node-version: '24.x'
177
- - name: Install Lightdash CLI
178
- run: npm install -g @lightdash/cli@${cliVersion}
179
- - name: Delete preview project
180
- run: lightdash stop-preview --name "\${GITHUB_HEAD_REF}"
181
- env:
182
- LIGHTDASH_URL: \${{ secrets.LIGHTDASH_URL }}
183
- LIGHTDASH_PROJECT: \${{ secrets.LIGHTDASH_PROJECT }}
184
- LIGHTDASH_API_KEY: \${{ secrets.LIGHTDASH_API_KEY }}
185
- `;
186
- return [
187
- { path: PREVIEW_WORKFLOW_PATH, content: startPreview },
188
- { path: CLOSE_WORKFLOW_PATH, content: closePreview },
189
- ];
190
- };
191
- exports.generatePreviewDeployWorkflowFiles = generatePreviewDeployWorkflowFiles;
192
- //# sourceMappingURL=previewDeployWorkflow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"previewDeployWorkflow.js","sourceRoot":"","sources":["../../../src/utils/previewDeployWorkflow.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAcH;;;;GAIG;AACU,QAAA,+BAA+B,GAAG;IAC3C,yBAAyB;IACzB,eAAe;IACf,wBAAwB;IACxB,cAAc;IACd,mBAAmB;IACnB,yBAAyB;CACnB,CAAC;AAEX,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAE3C,iFAAiF;AAC1E,MAAM,cAAc,GAAG,CAAC,IAAY,EAAW,EAAE;IACpD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC7C,OAAO,CACH,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC;QACpC,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAChE,CAAC;AACN,CAAC,CAAC;AANW,QAAA,cAAc,GAAd,cAAc,CAMzB;AAEK,MAAM,2BAA2B,GAAG,CACvC,KAAqB,EACC,EAAE;IACxB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CACpB,CAAC,IAAI,EAAE,EAAE,CACL,IAAA,QAAA,cAAc,EAAC,IAAI,CAAC,IAAI,CAAC;QACzB,QAAA,+BAA+B,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAC5C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAChC,CACR,CAAC;IACF,OAAO;QACH,wBAAwB,EAAE,KAAK,KAAK,SAAS;QAC7C,YAAY,EAAE,KAAK,EAAE,IAAI,IAAI,IAAI;KACpC,CAAC;AACN,CAAC,CAAC;AAdW,QAAA,2BAA2B,GAA3B,2BAA2B,CActC;AAyBK,MAAM,uBAAuB,GAAG,CAAC,EACpC,WAAW,EACX,OAAO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AAY,GAAG;;;;;;;;;;;gBAWT,eAAe;gBACf,iBAAiB;;;;6CAIY,UAAU;;;;;;;CAOtD,CAAC;IAEE,OAAO;QACH,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,YAAY,EAAE;QACtD,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE;KACvD,CAAC;AACN,CAAC,CAAC;AA3GW,QAAA,kCAAkC,GAAlC,kCAAkC,CA2G7C"}
@@ -1,63 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const TOOL_SETUP_PREVIEW_DEPLOY_DESCRIPTION: string;
3
- export declare const toolSetupPreviewDeployArgsSchema: z.ZodObject<{}, z.core.$strip>;
4
- export declare const toolSetupPreviewDeployStructuredContentSchema: z.ZodObject<{
5
- projectName: z.ZodString;
6
- repository: z.ZodString;
7
- secrets: z.ZodArray<z.ZodObject<{
8
- name: z.ZodString;
9
- value: z.ZodNullable<z.ZodString>;
10
- description: z.ZodString;
11
- }, z.core.$strip>>;
12
- }, z.core.$strip>;
13
- export declare const toolSetupPreviewDeployOutputSchema: z.ZodObject<{
14
- result: z.ZodString;
15
- metadata: z.ZodDiscriminatedUnion<[z.ZodObject<{
16
- status: z.ZodLiteral<"success">;
17
- prUrl: z.ZodNullable<z.ZodString>;
18
- }, z.core.$strip>, z.ZodObject<{
19
- status: z.ZodLiteral<"error">;
20
- }, z.core.$strip>], "status">;
21
- structuredContent: z.ZodUnion<readonly [z.ZodObject<{
22
- projectName: z.ZodString;
23
- repository: z.ZodString;
24
- secrets: z.ZodArray<z.ZodObject<{
25
- name: z.ZodString;
26
- value: z.ZodNullable<z.ZodString>;
27
- description: z.ZodString;
28
- }, z.core.$strip>>;
29
- }, z.core.$strip>, z.ZodObject<{
30
- refusal: z.ZodOptional<z.ZodNullable<z.ZodObject<{
31
- code: z.ZodLiteral<"ai_access_refused">;
32
- reason: z.ZodString;
33
- message: z.ZodString;
34
- action: z.ZodNullable<z.ZodString>;
35
- settingsUrl: z.ZodNullable<z.ZodString>;
36
- connectUrl: z.ZodNullable<z.ZodString>;
37
- capability: z.ZodOptional<z.ZodNullable<z.ZodString>>;
38
- policyLayer: z.ZodOptional<z.ZodString>;
39
- operation: z.ZodOptional<z.ZodString>;
40
- policyVersion: z.ZodOptional<z.ZodNumber>;
41
- projectUuid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
- }, z.core.$strip>>>;
43
- error: z.ZodString;
44
- }, z.core.$strip>]>;
45
- }, z.core.$strip>;
46
- export type ToolSetupPreviewDeployArgs = z.infer<typeof toolSetupPreviewDeployArgsSchema>;
47
- export type ToolSetupPreviewDeployStructuredContent = z.infer<typeof toolSetupPreviewDeployStructuredContentSchema>;
48
- export type ToolSetupPreviewDeployOutput = z.infer<typeof toolSetupPreviewDeployOutputSchema>;
49
- export declare const isToolSetupPreviewDeployResult: <T extends {
50
- toolType: string;
51
- toolName: string;
52
- metadata: unknown;
53
- }>(result: T) => result is T & {
54
- toolType: 'built-in';
55
- toolName: "setupPreviewDeploy";
56
- metadata: {
57
- status: "success";
58
- prUrl: string | null;
59
- } | {
60
- status: "error";
61
- };
62
- };
63
- //# sourceMappingURL=toolSetupPreviewDeployArgs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toolSetupPreviewDeployArgs.d.ts","sourceRoot":"","sources":["../../../../../../src/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,qCAAqC,QAKvC,CAAC;AAEZ,eAAO,MAAM,gCAAgC,gCAAe,CAAC;AAY7D,eAAO,MAAM,6CAA6C;;;;;;;;iBA2BxD,CAAC;AAIH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAO7C,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,gCAAgC,CAC1C,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG,CAAC,CAAC,KAAK,CACzD,OAAO,6CAA6C,CACvD,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,kCAAkC,CAC5C,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;CAG1C,CAAC"}
@@ -1,51 +0,0 @@
1
- import { z } from 'zod';
2
- import { toolErrorStructuredContentSchema } from '../outputMetadata';
3
- import { makeBuiltInToolResultGuard } from './builtInToolResultGuard';
4
- export const TOOL_SETUP_PREVIEW_DEPLOY_DESCRIPTION = [
5
- "Open a pull request that adds the Lightdash preview-deploy GitHub Actions workflow to this project's repository: each pull request then gets a temporary preview project, torn down when it closes.",
6
- 'Call it when the user asks to set up preview deploys ("deploy a preview project for each PR") or accepts your offer after getProjectInfo reports no preview-deploy workflow; no earlier writeback is needed.',
7
- 'It automates GitHub Actions only; on other CI, tell the user preview deploys are set up by hand.',
8
- 'It takes no arguments (the repository and dbt sub-folder are resolved server-side) and can take a few minutes.',
9
- ].join(' ');
10
- export const toolSetupPreviewDeployArgsSchema = z.object({});
11
- const toolSetupPreviewDeployMetadataSchema = z.discriminatedUnion('status', [
12
- z.object({
13
- status: z.literal('success'),
14
- prUrl: z.string().nullable(),
15
- }),
16
- z.object({
17
- status: z.literal('error'),
18
- }),
19
- ]);
20
- export const toolSetupPreviewDeployStructuredContentSchema = z.object({
21
- projectName: z
22
- .string()
23
- .describe('Lightdash project the preview deploys are based on.'),
24
- repository: z
25
- .string()
26
- .describe('GitHub repository (owner/name) the pull request was opened against.'),
27
- secrets: z
28
- .array(z.object({
29
- name: z.string().describe('GitHub Actions secret name.'),
30
- value: z
31
- .string()
32
- .nullable()
33
- .describe('Pre-filled value to present to the user verbatim; null when the user must provide it themselves.'),
34
- description: z
35
- .string()
36
- .describe('What the secret is used for.'),
37
- }))
38
- .describe('GitHub Actions secrets the user must add to the repository before the workflow can run.'),
39
- });
40
- // Hand-rolled rather than `structuredToolOutputSchema`: that helper takes an
41
- // object metadata schema and this tool's metadata is a discriminated union.
42
- export const toolSetupPreviewDeployOutputSchema = z.object({
43
- result: z.string(),
44
- metadata: toolSetupPreviewDeployMetadataSchema,
45
- structuredContent: z.union([
46
- toolSetupPreviewDeployStructuredContentSchema,
47
- toolErrorStructuredContentSchema,
48
- ]),
49
- });
50
- export const isToolSetupPreviewDeployResult = makeBuiltInToolResultGuard('setupPreviewDeploy', toolSetupPreviewDeployOutputSchema.shape.metadata);
51
- //# sourceMappingURL=toolSetupPreviewDeployArgs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toolSetupPreviewDeployArgs.js","sourceRoot":"","sources":["../../../../../../src/ee/AiAgent/schemas/tools/toolSetupPreviewDeployArgs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,CAAC,MAAM,qCAAqC,GAAG;IACjD,qMAAqM;IACrM,8MAA8M;IAC9M,kGAAkG;IAClG,gHAAgH;CACnH,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE7D,MAAM,oCAAoC,GAAG,CAAC,CAAC,kBAAkB,CAAC,QAAQ,EAAE;IACxE,CAAC,CAAC,MAAM,CAAC;QACL,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;QAC5B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC/B,CAAC;IACF,CAAC,CAAC,MAAM,CAAC;QACL,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;KAC7B,CAAC;CACL,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,6CAA6C,GAAG,CAAC,CAAC,MAAM,CAAC;IAClE,WAAW,EAAE,CAAC;SACT,MAAM,EAAE;SACR,QAAQ,CAAC,qDAAqD,CAAC;IACpE,UAAU,EAAE,CAAC;SACR,MAAM,EAAE;SACR,QAAQ,CACL,qEAAqE,CACxE;IACL,OAAO,EAAE,CAAC;SACL,KAAK,CACF,CAAC,CAAC,MAAM,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;QACxD,KAAK,EAAE,CAAC;aACH,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACL,kGAAkG,CACrG;QACL,WAAW,EAAE,CAAC;aACT,MAAM,EAAE;aACR,QAAQ,CAAC,8BAA8B,CAAC;KAChD,CAAC,CACL;SACA,QAAQ,CACL,yFAAyF,CAC5F;CACR,CAAC,CAAC;AAEH,6EAA6E;AAC7E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,QAAQ,EAAE,oCAAoC;IAC9C,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC;QACvB,6CAA6C;QAC7C,gCAAgC;KACnC,CAAC;CACL,CAAC,CAAC;AAcH,MAAM,CAAC,MAAM,8BAA8B,GAAG,0BAA0B,CACpE,oBAAoB,EACpB,kCAAkC,CAAC,KAAK,CAAC,QAAQ,CACpD,CAAC"}
@@ -1,27 +0,0 @@
1
- /**
2
- * Per-project record of whether a project's git repo has Lightdash CI/CD set
3
- * up. Populated as a secondary task of the AI writeback sandbox agent: while it
4
- * has the repo cloned it scans `.github/workflows/` for a Lightdash
5
- * preview-deploy workflow and persists the result so we don't re-scan a project
6
- * that already has it set up.
7
- */
8
- export type ProjectCiStatus = {
9
- projectUuid: string;
10
- hasPreviewDeployWorkflow: boolean;
11
- /** Path of the detected workflow file, or null when none was found. */
12
- workflowPath: string | null;
13
- /** Repo HEAD commit the scan ran against, for debugging staleness. */
14
- detectedCommitSha: string | null;
15
- checkedAt: Date;
16
- };
17
- /**
18
- * CI status for a project, or null when the project has never been scanned
19
- * (e.g. no AI writeback has run yet). A null result means "unknown", which is
20
- * distinct from a record with `hasPreviewDeployWorkflow: false` ("scanned, no
21
- * preview workflow").
22
- */
23
- export type ApiProjectCiStatusResponse = {
24
- status: 'ok';
25
- results: ProjectCiStatus | null;
26
- };
27
- //# sourceMappingURL=projectCiStatus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"projectCiStatus.d.ts","sourceRoot":"","sources":["../../../src/types/projectCiStatus.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,wBAAwB,EAAE,OAAO,CAAC;IAClC,uEAAuE;IACvE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,sEAAsE;IACtE,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,IAAI,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACrC,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CACnC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=projectCiStatus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"projectCiStatus.js","sourceRoot":"","sources":["../../../src/types/projectCiStatus.ts"],"names":[],"mappings":""}
@@ -1,73 +0,0 @@
1
- /**
2
- * Detection and generation of Lightdash "preview project" GitHub Actions.
3
- *
4
- * Lightdash ships a canonical CI workflow (the `lightdash/cli-actions`
5
- * `start-preview.yml` / `close-preview.yml` pair) that spins up a temporary
6
- * preview project for every pull request and tears it down on close. The AI
7
- * writeback sandbox agent detects whether a repo already has this set up and,
8
- * if not, offers to open a PR adding it.
9
- *
10
- * Everything here is pure so it can be unit-tested without a sandbox or
11
- * database: detection takes the workflow files as `{ path, content }` and the
12
- * generators take only the project identity.
13
- */
14
- /** A single file read out of a repo, used for detection. */
15
- export type WorkflowFile = {
16
- path: string;
17
- content: string;
18
- };
19
- export type PreviewDeployDetection = {
20
- hasPreviewDeployWorkflow: boolean;
21
- /** Path of the first matching workflow file, or null when none matched. */
22
- workflowPath: string | null;
23
- };
24
- /**
25
- * Substrings that, when found in a `.github/workflows` file, indicate the repo
26
- * already deploys Lightdash preview projects. `lightdash deploy` is
27
- * deliberately excluded — that is a production deploy, not a preview.
28
- */
29
- export declare const PREVIEW_DEPLOY_WORKFLOW_MARKERS: readonly ['lightdash start-preview', 'start-preview', 'lightdash stop-preview', 'stop-preview', 'lightdash preview', 'lightdash-deploy-action'];
30
- /** True for `.github/workflows/*.yml|*.yaml` paths (tolerates a `./` prefix). */
31
- export declare const isWorkflowFile: (path: string) => boolean;
32
- export declare const detectPreviewDeployWorkflow: (files: WorkflowFile[]) => PreviewDeployDetection;
33
- /**
34
- * A GitHub Actions secret the preview workflow needs. `value` is non-null when
35
- * Lightdash can pre-fill it (project UUID, instance URL); null means the user
36
- * must supply it themselves — the sandbox never holds real warehouse secrets.
37
- */
38
- export type PreviewDeploySecret = {
39
- name: string;
40
- value: string | null;
41
- description: string;
42
- };
43
- /**
44
- * Result of opening the preview-deploy setup pull request. `secrets` are the
45
- * GitHub Actions secrets the user must add for the workflow to run, with the
46
- * values Lightdash can pre-fill already populated.
47
- */
48
- export type PreviewDeploySetupResult = {
49
- prUrl: string;
50
- projectName: string;
51
- repository: string;
52
- secrets: PreviewDeploySecret[];
53
- };
54
- export declare const getPreviewDeploySecrets: ({ projectUuid, siteUrl, }: {
55
- projectUuid: string;
56
- siteUrl: string;
57
- }) => PreviewDeploySecret[];
58
- /**
59
- * Generate the canonical Lightdash preview-on-PR workflow pair.
60
- *
61
- * @param projectSubPath dbt project directory within the repo (repo root when
62
- * null) — passed to the CLI as `--project-dir`.
63
- * @param cliVersion the `@lightdash/cli` version to pin. Pass the Lightdash
64
- * instance's own version (`VERSION`): every Lightdash package releases in
65
- * lockstep, so the instance version is the CLI version that matches it — this
66
- * keeps the pin reproducible, compatible, and self-updating with the instance
67
- * instead of frozen at a literal that rots.
68
- */
69
- export declare const generatePreviewDeployWorkflowFiles: ({ projectSubPath, cliVersion, }: {
70
- projectSubPath: string | null;
71
- cliVersion: string;
72
- }) => WorkflowFile[];
73
- //# sourceMappingURL=previewDeployWorkflow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"previewDeployWorkflow.d.ts","sourceRoot":"","sources":["../../../src/utils/previewDeployWorkflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,4DAA4D;AAC5D,MAAM,MAAM,YAAY,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACjC,wBAAwB,EAAE,OAAO,CAAC;IAClC,2EAA2E;IAC3E,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,YACxC,yBAAyB,EACzB,eAAe,EACf,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,yBAAyB,CACnB,CAAC;AAIX,iFAAiF;AACjF,eAAO,MAAM,cAAc,SAAU,MAAM,KAAG,OAM7C,CAAC;AAEF,eAAO,MAAM,2BAA2B,UAC7B,YAAY,EAAE,KACtB,sBAYF,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,mBAAmB,EAAE,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,uBAAuB,8BAGjC;IACC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACnB,KAAG,mBAAmB,EA0BtB,CAAC;AAgBF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,oCAG5C;IACC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;CACtB,KAAG,YAAY,EAqGf,CAAC"}
@@ -1,185 +0,0 @@
1
- /**
2
- * Detection and generation of Lightdash "preview project" GitHub Actions.
3
- *
4
- * Lightdash ships a canonical CI workflow (the `lightdash/cli-actions`
5
- * `start-preview.yml` / `close-preview.yml` pair) that spins up a temporary
6
- * preview project for every pull request and tears it down on close. The AI
7
- * writeback sandbox agent detects whether a repo already has this set up and,
8
- * if not, offers to open a PR adding it.
9
- *
10
- * Everything here is pure so it can be unit-tested without a sandbox or
11
- * database: detection takes the workflow files as `{ path, content }` and the
12
- * generators take only the project identity.
13
- */
14
- /**
15
- * Substrings that, when found in a `.github/workflows` file, indicate the repo
16
- * already deploys Lightdash preview projects. `lightdash deploy` is
17
- * deliberately excluded — that is a production deploy, not a preview.
18
- */
19
- export const PREVIEW_DEPLOY_WORKFLOW_MARKERS = [
20
- 'lightdash start-preview',
21
- 'start-preview',
22
- 'lightdash stop-preview',
23
- 'stop-preview',
24
- 'lightdash preview',
25
- 'lightdash-deploy-action',
26
- ];
27
- const WORKFLOWS_DIR = '.github/workflows/';
28
- /** True for `.github/workflows/*.yml|*.yaml` paths (tolerates a `./` prefix). */
29
- export const isWorkflowFile = (path) => {
30
- const normalized = path.replace(/^\.\//, '');
31
- return (normalized.startsWith(WORKFLOWS_DIR) &&
32
- (normalized.endsWith('.yml') || normalized.endsWith('.yaml')));
33
- };
34
- export const detectPreviewDeployWorkflow = (files) => {
35
- const match = files.find((file) => isWorkflowFile(file.path) &&
36
- PREVIEW_DEPLOY_WORKFLOW_MARKERS.some((marker) => file.content.includes(marker)));
37
- return {
38
- hasPreviewDeployWorkflow: match !== undefined,
39
- workflowPath: match?.path ?? null,
40
- };
41
- };
42
- export const getPreviewDeploySecrets = ({ projectUuid, siteUrl, }) => {
43
- const baseUrl = siteUrl.replace(/\/+$/, '');
44
- return [
45
- {
46
- name: 'LIGHTDASH_URL',
47
- value: siteUrl,
48
- description: 'The base URL of your Lightdash instance.',
49
- },
50
- {
51
- name: 'LIGHTDASH_PROJECT',
52
- value: projectUuid,
53
- description: 'The UUID of the Lightdash project to base preview projects on.',
54
- },
55
- {
56
- name: 'LIGHTDASH_API_KEY',
57
- value: null,
58
- description: `A Lightdash personal access token — create one at ${baseUrl}/generalSettings/personalAccessTokens. Lightdash cannot create this for you.`,
59
- },
60
- {
61
- name: 'DBT_PROFILES',
62
- value: null,
63
- description: 'A dbt profiles.yml with your warehouse connection. Lightdash never stores your warehouse password, so you must add this yourself.',
64
- },
65
- ];
66
- };
67
- const PREVIEW_WORKFLOW_PATH = `${WORKFLOWS_DIR}start-preview.yml`;
68
- const CLOSE_WORKFLOW_PATH = `${WORKFLOWS_DIR}close-preview.yml`;
69
- // Third-party actions are pinned to a full commit SHA (with a version comment)
70
- // rather than a floating tag — these workflows run with the repo's warehouse +
71
- // Lightdash secrets in scope, so a retagged/compromised action is a real
72
- // supply-chain risk. SHAs match the pins Lightdash uses in its own CI.
73
- const CHECKOUT_ACTION = 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2';
74
- const SETUP_NODE_ACTION = 'actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6';
75
- const GITHUB_SCRIPT_ACTION = 'actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8';
76
- /**
77
- * Generate the canonical Lightdash preview-on-PR workflow pair.
78
- *
79
- * @param projectSubPath dbt project directory within the repo (repo root when
80
- * null) — passed to the CLI as `--project-dir`.
81
- * @param cliVersion the `@lightdash/cli` version to pin. Pass the Lightdash
82
- * instance's own version (`VERSION`): every Lightdash package releases in
83
- * lockstep, so the instance version is the CLI version that matches it — this
84
- * keeps the pin reproducible, compatible, and self-updating with the instance
85
- * instead of frozen at a literal that rots.
86
- */
87
- export const generatePreviewDeployWorkflowFiles = ({ projectSubPath, cliVersion, }) => {
88
- const projectDir = projectSubPath && projectSubPath !== '' ? projectSubPath : '.';
89
- const startPreview = `name: lightdash-start-preview
90
- on:
91
- pull_request:
92
- types: [opened, synchronize, reopened]
93
- # contents:read for checkout; pull-requests:write to post the preview link
94
- # comment. Both must be listed — an omitted scope defaults to none.
95
- permissions:
96
- contents: read
97
- pull-requests: write
98
- concurrency:
99
- group: lightdash-preview-\${{ github.ref }}
100
- cancel-in-progress: true
101
- jobs:
102
- start-preview:
103
- runs-on: ubuntu-latest
104
- timeout-minutes: 15
105
- env:
106
- PROJECT_DIR: ${projectDir}
107
- steps:
108
- - uses: ${CHECKOUT_ACTION}
109
- - uses: ${SETUP_NODE_ACTION}
110
- with:
111
- node-version: '24.x'
112
- - name: Install Lightdash CLI
113
- run: npm install -g @lightdash/cli@${cliVersion}
114
- - name: Write dbt profiles
115
- run: echo "$DBT_PROFILES" > profiles.yml
116
- env:
117
- DBT_PROFILES: \${{ secrets.DBT_PROFILES }}
118
- - name: Create preview project
119
- id: preview
120
- run: lightdash start-preview --project-dir "$PROJECT_DIR" --profiles-dir . --name "\${GITHUB_HEAD_REF}"
121
- env:
122
- LIGHTDASH_URL: \${{ secrets.LIGHTDASH_URL }}
123
- LIGHTDASH_PROJECT: \${{ secrets.LIGHTDASH_PROJECT }}
124
- LIGHTDASH_API_KEY: \${{ secrets.LIGHTDASH_API_KEY }}
125
- - name: Comment preview link on PR
126
- if: steps.preview.outputs.url != ''
127
- uses: ${GITHUB_SCRIPT_ACTION}
128
- env:
129
- PREVIEW_URL: \${{ steps.preview.outputs.url }}
130
- with:
131
- script: |
132
- const marker = '<!-- lightdash-preview -->';
133
- const body = marker + '\\n:zap: Your Lightdash preview project is ready: ' + process.env.PREVIEW_URL;
134
- const { data: comments } = await github.rest.issues.listComments({
135
- owner: context.repo.owner,
136
- repo: context.repo.repo,
137
- issue_number: context.issue.number,
138
- });
139
- const existing = comments.find((c) => c.body && c.body.includes(marker));
140
- if (existing) {
141
- await github.rest.issues.updateComment({
142
- owner: context.repo.owner,
143
- repo: context.repo.repo,
144
- comment_id: existing.id,
145
- body,
146
- });
147
- } else {
148
- await github.rest.issues.createComment({
149
- owner: context.repo.owner,
150
- repo: context.repo.repo,
151
- issue_number: context.issue.number,
152
- body,
153
- });
154
- }
155
- `;
156
- const closePreview = `name: lightdash-close-preview
157
- on:
158
- pull_request:
159
- types: [closed]
160
- permissions:
161
- contents: read
162
- jobs:
163
- close-preview:
164
- runs-on: ubuntu-latest
165
- timeout-minutes: 15
166
- steps:
167
- - uses: ${CHECKOUT_ACTION}
168
- - uses: ${SETUP_NODE_ACTION}
169
- with:
170
- node-version: '24.x'
171
- - name: Install Lightdash CLI
172
- run: npm install -g @lightdash/cli@${cliVersion}
173
- - name: Delete preview project
174
- run: lightdash stop-preview --name "\${GITHUB_HEAD_REF}"
175
- env:
176
- LIGHTDASH_URL: \${{ secrets.LIGHTDASH_URL }}
177
- LIGHTDASH_PROJECT: \${{ secrets.LIGHTDASH_PROJECT }}
178
- LIGHTDASH_API_KEY: \${{ secrets.LIGHTDASH_API_KEY }}
179
- `;
180
- return [
181
- { path: PREVIEW_WORKFLOW_PATH, content: startPreview },
182
- { path: CLOSE_WORKFLOW_PATH, content: closePreview },
183
- ];
184
- };
185
- //# sourceMappingURL=previewDeployWorkflow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"previewDeployWorkflow.js","sourceRoot":"","sources":["../../../src/utils/previewDeployWorkflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAcH;;;;GAIG;AACH,MAAM,CAAC,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