@lightdash/cli 2.228.1 → 2.229.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 (177) hide show
  1. package/dist/.tsbuildinfo.build +1 -0
  2. package/package.json +4 -4
  3. package/dist/.tsbuildinfo +0 -1
  4. package/dist/config.test.d.ts +0 -2
  5. package/dist/config.test.d.ts.map +0 -1
  6. package/dist/config.test.js +0 -72
  7. package/dist/dbt/context.test.d.ts +0 -2
  8. package/dist/dbt/context.test.d.ts.map +0 -1
  9. package/dist/dbt/context.test.js +0 -152
  10. package/dist/dbt/manifest.test.d.ts +0 -2
  11. package/dist/dbt/manifest.test.d.ts.map +0 -1
  12. package/dist/dbt/manifest.test.js +0 -170
  13. package/dist/dbt/models.test.d.ts +0 -2
  14. package/dist/dbt/models.test.d.ts.map +0 -1
  15. package/dist/dbt/models.test.js +0 -139
  16. package/dist/dbt/profiles.test.d.ts +0 -2
  17. package/dist/dbt/profiles.test.d.ts.map +0 -1
  18. package/dist/dbt/profiles.test.js +0 -50
  19. package/dist/dbt/targets/athena.test.d.ts +0 -2
  20. package/dist/dbt/targets/athena.test.d.ts.map +0 -1
  21. package/dist/dbt/targets/athena.test.js +0 -78
  22. package/dist/dbt/targets/duckdb.test.d.ts +0 -2
  23. package/dist/dbt/targets/duckdb.test.d.ts.map +0 -1
  24. package/dist/dbt/targets/duckdb.test.js +0 -149
  25. package/dist/dbt/targets/redshift.test.d.ts +0 -2
  26. package/dist/dbt/targets/redshift.test.d.ts.map +0 -1
  27. package/dist/dbt/targets/redshift.test.js +0 -198
  28. package/dist/dbt/templating.test.d.ts +0 -2
  29. package/dist/dbt/templating.test.d.ts.map +0 -1
  30. package/dist/dbt/templating.test.js +0 -51
  31. package/dist/dbt/validation.test.d.ts +0 -2
  32. package/dist/dbt/validation.test.d.ts.map +0 -1
  33. package/dist/dbt/validation.test.js +0 -67
  34. package/dist/handlers/apps/appCodeFiles.test.d.ts +0 -2
  35. package/dist/handlers/apps/appCodeFiles.test.d.ts.map +0 -1
  36. package/dist/handlers/apps/appCodeFiles.test.js +0 -391
  37. package/dist/handlers/apps/appsDownload.test.d.ts +0 -2
  38. package/dist/handlers/apps/appsDownload.test.d.ts.map +0 -1
  39. package/dist/handlers/apps/appsDownload.test.js +0 -639
  40. package/dist/handlers/apps/build.test.d.ts +0 -2
  41. package/dist/handlers/apps/build.test.d.ts.map +0 -1
  42. package/dist/handlers/apps/build.test.js +0 -252
  43. package/dist/handlers/apps/createApp.test.d.ts +0 -2
  44. package/dist/handlers/apps/createApp.test.d.ts.map +0 -1
  45. package/dist/handlers/apps/createApp.test.js +0 -340
  46. package/dist/handlers/apps/pathContainment.test.d.ts +0 -2
  47. package/dist/handlers/apps/pathContainment.test.d.ts.map +0 -1
  48. package/dist/handlers/apps/pathContainment.test.js +0 -66
  49. package/dist/handlers/apps/preview.test.d.ts +0 -2
  50. package/dist/handlers/apps/preview.test.d.ts.map +0 -1
  51. package/dist/handlers/apps/preview.test.js +0 -353
  52. package/dist/handlers/apps/previewProxy.test.d.ts +0 -2
  53. package/dist/handlers/apps/previewProxy.test.d.ts.map +0 -1
  54. package/dist/handlers/apps/previewProxy.test.js +0 -178
  55. package/dist/handlers/apps/scaffolding.test.d.ts +0 -2
  56. package/dist/handlers/apps/scaffolding.test.d.ts.map +0 -1
  57. package/dist/handlers/apps/scaffolding.test.js +0 -151
  58. package/dist/handlers/apps/uploadRetry.test.d.ts +0 -2
  59. package/dist/handlers/apps/uploadRetry.test.d.ts.map +0 -1
  60. package/dist/handlers/apps/uploadRetry.test.js +0 -103
  61. package/dist/handlers/apps/validate.test.d.ts +0 -2
  62. package/dist/handlers/apps/validate.test.d.ts.map +0 -1
  63. package/dist/handlers/apps/validate.test.js +0 -526
  64. package/dist/handlers/compile.test.d.ts +0 -2
  65. package/dist/handlers/compile.test.d.ts.map +0 -1
  66. package/dist/handlers/compile.test.js +0 -151
  67. package/dist/handlers/compileProject.test.d.ts +0 -2
  68. package/dist/handlers/compileProject.test.d.ts.map +0 -1
  69. package/dist/handlers/compileProject.test.js +0 -637
  70. package/dist/handlers/compileWarehouseColumnValidation.test.d.ts +0 -2
  71. package/dist/handlers/compileWarehouseColumnValidation.test.d.ts.map +0 -1
  72. package/dist/handlers/compileWarehouseColumnValidation.test.js +0 -493
  73. package/dist/handlers/connectSnowflake.test.d.ts +0 -2
  74. package/dist/handlers/connectSnowflake.test.d.ts.map +0 -1
  75. package/dist/handlers/connectSnowflake.test.js +0 -320
  76. package/dist/handlers/contentAsCode/fileNames.test.d.ts +0 -2
  77. package/dist/handlers/contentAsCode/fileNames.test.d.ts.map +0 -1
  78. package/dist/handlers/contentAsCode/fileNames.test.js +0 -79
  79. package/dist/handlers/contentAsCode/registry.test.d.ts +0 -2
  80. package/dist/handlers/contentAsCode/registry.test.d.ts.map +0 -1
  81. package/dist/handlers/contentAsCode/registry.test.js +0 -18
  82. package/dist/handlers/contentAsCode/resource.test.d.ts +0 -2
  83. package/dist/handlers/contentAsCode/resource.test.d.ts.map +0 -1
  84. package/dist/handlers/contentAsCode/resource.test.js +0 -121
  85. package/dist/handlers/dbt/getDbtVersion.test.d.ts +0 -2
  86. package/dist/handlers/dbt/getDbtVersion.test.d.ts.map +0 -1
  87. package/dist/handlers/dbt/getDbtVersion.test.js +0 -106
  88. package/dist/handlers/deploy.test.d.ts +0 -2
  89. package/dist/handlers/deploy.test.d.ts.map +0 -1
  90. package/dist/handlers/deploy.test.js +0 -244
  91. package/dist/handlers/download.test.d.ts +0 -2
  92. package/dist/handlers/download.test.d.ts.map +0 -1
  93. package/dist/handlers/download.test.js +0 -1739
  94. package/dist/handlers/exportChartImage.test.d.ts +0 -2
  95. package/dist/handlers/exportChartImage.test.d.ts.map +0 -1
  96. package/dist/handlers/exportChartImage.test.js +0 -55
  97. package/dist/handlers/homepagesAsCode.test.d.ts +0 -2
  98. package/dist/handlers/homepagesAsCode.test.d.ts.map +0 -1
  99. package/dist/handlers/homepagesAsCode.test.js +0 -72
  100. package/dist/handlers/lint.test.d.ts +0 -2
  101. package/dist/handlers/lint.test.d.ts.map +0 -1
  102. package/dist/handlers/lint.test.js +0 -221
  103. package/dist/handlers/login.test.d.ts +0 -2
  104. package/dist/handlers/login.test.d.ts.map +0 -1
  105. package/dist/handlers/login.test.js +0 -24
  106. package/dist/handlers/metadataFile.test.d.ts +0 -2
  107. package/dist/handlers/metadataFile.test.d.ts.map +0 -1
  108. package/dist/handlers/metadataFile.test.js +0 -46
  109. package/dist/handlers/organizationContent/customRoles.test.d.ts +0 -2
  110. package/dist/handlers/organizationContent/customRoles.test.d.ts.map +0 -1
  111. package/dist/handlers/organizationContent/customRoles.test.js +0 -179
  112. package/dist/handlers/organizationContent/groups.test.d.ts +0 -2
  113. package/dist/handlers/organizationContent/groups.test.d.ts.map +0 -1
  114. package/dist/handlers/organizationContent/groups.test.js +0 -135
  115. package/dist/handlers/organizationContent/index.test.d.ts +0 -2
  116. package/dist/handlers/organizationContent/index.test.d.ts.map +0 -1
  117. package/dist/handlers/organizationContent/index.test.js +0 -212
  118. package/dist/handlers/organizationContent/themes.test.d.ts +0 -2
  119. package/dist/handlers/organizationContent/themes.test.d.ts.map +0 -1
  120. package/dist/handlers/organizationContent/themes.test.js +0 -180
  121. package/dist/handlers/organizationContent/users.test.d.ts +0 -2
  122. package/dist/handlers/organizationContent/users.test.d.ts.map +0 -1
  123. package/dist/handlers/organizationContent/users.test.js +0 -155
  124. package/dist/handlers/preAggregateAudit.test.d.ts +0 -2
  125. package/dist/handlers/preAggregateAudit.test.d.ts.map +0 -1
  126. package/dist/handlers/preAggregateAudit.test.js +0 -102
  127. package/dist/handlers/renameHandler.test.d.ts +0 -2
  128. package/dist/handlers/renameHandler.test.d.ts.map +0 -1
  129. package/dist/handlers/renameHandler.test.js +0 -189
  130. package/dist/handlers/resolveProjectFlag.test.d.ts +0 -2
  131. package/dist/handlers/resolveProjectFlag.test.d.ts.map +0 -1
  132. package/dist/handlers/resolveProjectFlag.test.js +0 -48
  133. package/dist/handlers/selectProject.test.d.ts +0 -2
  134. package/dist/handlers/selectProject.test.d.ts.map +0 -1
  135. package/dist/handlers/selectProject.test.js +0 -224
  136. package/dist/handlers/setProject.test.d.ts +0 -2
  137. package/dist/handlers/setProject.test.d.ts.map +0 -1
  138. package/dist/handlers/setProject.test.js +0 -63
  139. package/dist/handlers/slugUpdate.test.d.ts +0 -2
  140. package/dist/handlers/slugUpdate.test.d.ts.map +0 -1
  141. package/dist/handlers/slugUpdate.test.js +0 -265
  142. package/dist/handlers/timestampConversion.test.d.ts +0 -2
  143. package/dist/handlers/timestampConversion.test.d.ts.map +0 -1
  144. package/dist/handlers/timestampConversion.test.js +0 -87
  145. package/dist/handlers/upgradeCheck.test.d.ts +0 -2
  146. package/dist/handlers/upgradeCheck.test.d.ts.map +0 -1
  147. package/dist/handlers/upgradeCheck.test.js +0 -227
  148. package/dist/handlers/validate.test.d.ts +0 -2
  149. package/dist/handlers/validate.test.d.ts.map +0 -1
  150. package/dist/handlers/validate.test.js +0 -318
  151. package/dist/handlers/validateSpaceFilter.test.d.ts +0 -2
  152. package/dist/handlers/validateSpaceFilter.test.d.ts.map +0 -1
  153. package/dist/handlers/validateSpaceFilter.test.js +0 -79
  154. package/dist/handlers/warehouseConnection.test.d.ts +0 -2
  155. package/dist/handlers/warehouseConnection.test.d.ts.map +0 -1
  156. package/dist/handlers/warehouseConnection.test.js +0 -75
  157. package/dist/lightdash-config/lightdash-config.test.d.ts +0 -2
  158. package/dist/lightdash-config/lightdash-config.test.d.ts.map +0 -1
  159. package/dist/lightdash-config/lightdash-config.test.js +0 -69
  160. package/dist/prompts/fuzzySearchPrompt.test.d.ts +0 -2
  161. package/dist/prompts/fuzzySearchPrompt.test.d.ts.map +0 -1
  162. package/dist/prompts/fuzzySearchPrompt.test.js +0 -53
  163. package/dist/refsArgument.test.d.ts +0 -2
  164. package/dist/refsArgument.test.d.ts.map +0 -1
  165. package/dist/refsArgument.test.js +0 -42
  166. package/dist/releaseSafety/index.test.d.ts +0 -2
  167. package/dist/releaseSafety/index.test.d.ts.map +0 -1
  168. package/dist/releaseSafety/index.test.js +0 -154
  169. package/dist/releaseSafety/version.test.d.ts +0 -2
  170. package/dist/releaseSafety/version.test.d.ts.map +0 -1
  171. package/dist/releaseSafety/version.test.js +0 -22
  172. package/dist/skills.test.d.ts +0 -2
  173. package/dist/skills.test.d.ts.map +0 -1
  174. package/dist/skills.test.js +0 -112
  175. package/dist/terminal/contentAsCodeOutput.test.d.ts +0 -2
  176. package/dist/terminal/contentAsCodeOutput.test.d.ts.map +0 -1
  177. package/dist/terminal/contentAsCodeOutput.test.js +0 -231
@@ -1,151 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fs_1 = require("fs");
4
- const os_1 = require("os");
5
- const yaml_1 = require("yaml");
6
- const scaffolding_1 = require("./scaffolding");
7
- describe('firstExistingDir', () => {
8
- it('returns the first path that exists when a later candidate exists', () => {
9
- const realDir = (0, fs_1.mkdtempSync)(`${(0, os_1.tmpdir)()}/ld-test-`);
10
- const result = (0, scaffolding_1.firstExistingDir)(['/nonexistent/path/xyz', realDir]);
11
- expect(result).toBe(realDir);
12
- });
13
- it('returns the first candidate when it exists', () => {
14
- const realDir = (0, fs_1.mkdtempSync)(`${(0, os_1.tmpdir)()}/ld-test-`);
15
- const result = (0, scaffolding_1.firstExistingDir)([realDir, '/nonexistent/path/xyz']);
16
- expect(result).toBe(realDir);
17
- });
18
- it('returns null when all candidates are missing', () => {
19
- const result = (0, scaffolding_1.firstExistingDir)([
20
- '/nonexistent/path/aaa',
21
- '/nonexistent/path/bbb',
22
- ]);
23
- expect(result).toBeNull();
24
- });
25
- });
26
- describe('rewriteWorkspaceDeps', () => {
27
- it('replaces workspace protocol pins with a concrete version', () => {
28
- const pkg = JSON.stringify({
29
- dependencies: {
30
- '@lightdash/query-sdk': 'workspace:*',
31
- react: '19.2.5',
32
- },
33
- });
34
- const out = JSON.parse((0, scaffolding_1.rewriteWorkspaceDeps)(pkg, '0.3275.0'));
35
- expect(out.dependencies['@lightdash/query-sdk']).toBe('0.3275.0');
36
- expect(out.dependencies.react).toBe('19.2.5');
37
- });
38
- it('handles workspace:^ and workspace:~ variants', () => {
39
- const pkg = JSON.stringify({
40
- dependencies: {
41
- '@lightdash/query-sdk': 'workspace:^',
42
- 'some-lib': 'workspace:~1.2.3',
43
- other: '2.0.0',
44
- },
45
- });
46
- const out = JSON.parse((0, scaffolding_1.rewriteWorkspaceDeps)(pkg, '1.0.0'));
47
- expect(out.dependencies['@lightdash/query-sdk']).toBe('1.0.0');
48
- expect(out.dependencies['some-lib']).toBe('1.0.0');
49
- expect(out.dependencies.other).toBe('2.0.0');
50
- });
51
- });
52
- describe('buildStaticAuthoringFiles', () => {
53
- const files = (0, scaffolding_1.buildStaticAuthoringFiles)({
54
- appName: 'Revenue',
55
- sdkVersion: '0.3275.0',
56
- });
57
- const byPath = (p) => files.find((f) => f.path === p);
58
- const text = (p) => Buffer.from(byPath(p).contentBase64, 'base64').toString('utf-8');
59
- it.each([
60
- 'lightdash-data-app',
61
- 'developing-data-apps-locally',
62
- 'frontend-design',
63
- 'reusable-visualization',
64
- 'sdk-features',
65
- ])('ships the %s skill', (skill) => {
66
- expect(byPath(`.claude/skills/${skill}/SKILL.md`)).toBeDefined();
67
- });
68
- it('pins the SDK to a concrete version in package.json', () => {
69
- expect(text('package.json')).toContain('"@lightdash/query-sdk": "0.3275.0"');
70
- expect(text('package.json')).not.toContain('workspace:');
71
- });
72
- it('renders the README with the app name and ships a .gitignore', () => {
73
- expect(text('README.md')).toContain('Revenue');
74
- expect(text('.gitignore')).toContain('node_modules');
75
- });
76
- it('uses npm for the standard local workflow', () => {
77
- expect(text('README.md')).toContain('run `npm install` first');
78
- expect(text('AGENTS.md')).toContain('run `npm install` first');
79
- expect(text('.claude/skills/developing-data-apps-locally/SKILL.md')).toContain('run `npm install` before');
80
- expect(text('.npmrc')).toContain('ignore-scripts=true');
81
- expect(text('.npmrc')).not.toContain('shamefully-hoist');
82
- });
83
- it('ships a release-age policy for pnpm with the SDK exemption', () => {
84
- expect((0, yaml_1.parse)(text('pnpm-workspace.yaml'))).toMatchObject({
85
- minimumReleaseAge: 4320,
86
- minimumReleaseAgeExclude: ['@lightdash/query-sdk'],
87
- ignoreScripts: true,
88
- });
89
- });
90
- it('documents Cloud-parity validation builds', () => {
91
- for (const path of [
92
- 'README.md',
93
- 'AGENTS.md',
94
- '.claude/skills/developing-data-apps-locally/SKILL.md',
95
- ]) {
96
- expect(text(path)).toContain('validate --build');
97
- expect(text(path)).toContain('Cloud-parity');
98
- }
99
- });
100
- it('never writes app source (no src/ files)', () => {
101
- expect(files.every((f) => !f.path.startsWith('src/'))).toBe(true);
102
- });
103
- });
104
- describe('buildStaticAuthoringFiles — chart-type flavor', () => {
105
- const files = (0, scaffolding_1.buildStaticAuthoringFiles)({
106
- appName: 'Radial gauge',
107
- sdkVersion: '0.3275.0',
108
- flavor: 'chart-type',
109
- });
110
- const byPath = (p) => files.find((f) => f.path === p);
111
- const text = (p) => Buffer.from(byPath(p).contentBase64, 'base64').toString('utf-8');
112
- it('ships the chart-type workflow skill, not the app skills', () => {
113
- expect(byPath('.claude/skills/developing-chart-types-locally/SKILL.md')).toBeDefined();
114
- expect(byPath('.claude/skills/lightdash-data-app/SKILL.md')).toBeUndefined();
115
- });
116
- it('ships a starter viz fixture for local preview', () => {
117
- const fixture = JSON.parse(text('viz-fixture.json'));
118
- expect(fixture.fieldMapping.category).toBeDefined();
119
- expect(fixture.fieldMapping.value).toBeDefined();
120
- expect(Array.isArray(fixture.rows)).toBe(true);
121
- });
122
- it('documents the fixture preview flow in AGENTS.md', () => {
123
- expect(text('AGENTS.md')).toContain('vizFixture');
124
- });
125
- });
126
- describe('loadVendoredBuildScaffold', () => {
127
- const files = (0, scaffolding_1.loadVendoredBuildScaffold)('0.3275.0');
128
- const byPath = (p) => files.find((file) => file.path === p);
129
- it('loads the trusted build files without app source', () => {
130
- expect(byPath('vite.config.js')).toBeDefined();
131
- expect(byPath('index.html')).toBeDefined();
132
- expect(files.every((file) => !file.path.startsWith('src/'))).toBe(true);
133
- });
134
- it('pins the SDK used by the local build', () => {
135
- const packageJson = Buffer.from(byPath('package.json').contentBase64, 'base64').toString('utf-8');
136
- expect(packageJson).toContain('"@lightdash/query-sdk": "0.3275.0"');
137
- expect(packageJson).not.toContain('workspace:');
138
- });
139
- });
140
- describe('loadVendoredStarterSource', () => {
141
- const files = (0, scaffolding_1.loadVendoredStarterSource)();
142
- it('loads the starter app source with bundle-relative paths', () => {
143
- expect(files.map((file) => file.path)).toEqual(expect.arrayContaining([
144
- 'src/App.jsx',
145
- 'src/main.jsx',
146
- 'src/index.css',
147
- ]));
148
- expect(files.every((file) => file.path.startsWith('src/'))).toBe(true);
149
- expect(files.some((file) => file.path.startsWith('src/components/ui/'))).toBe(false);
150
- });
151
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=uploadRetry.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uploadRetry.test.d.ts","sourceRoot":"","sources":["../../../src/handlers/apps/uploadRetry.test.ts"],"names":[],"mappings":""}
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const common_1 = require("@lightdash/common");
4
- const uploadRetry_1 = require("./uploadRetry");
5
- const buildLimitError = () => new common_1.LightdashError({
6
- message: 'Too many app builds in progress for this project (5/5). Wait for some to finish and try again.',
7
- name: 'TooManyRequestsError',
8
- statusCode: 429,
9
- data: {},
10
- });
11
- describe('withBuildLimitRetry', () => {
12
- it('retries 429s with backoff until the upload is accepted and refills the budget', async () => {
13
- const sleeps = [];
14
- const sleep = vi.fn(async (ms) => {
15
- sleeps.push(ms);
16
- });
17
- const onWait = vi.fn();
18
- const post = vi
19
- .fn()
20
- .mockRejectedValueOnce(buildLimitError())
21
- .mockRejectedValueOnce(buildLimitError())
22
- .mockResolvedValue('accepted');
23
- const waitState = (0, uploadRetry_1.createBuildLimitWaitState)(600_000);
24
- waitState.spend(500_000); // partially spent by earlier apps
25
- const result = await (0, uploadRetry_1.withBuildLimitRetry)(post, waitState, {
26
- onWait,
27
- initialDelayMs: 5_000,
28
- maxDelayMs: 30_000,
29
- sleep,
30
- });
31
- expect(result).toBe('accepted');
32
- expect(post).toHaveBeenCalledTimes(3);
33
- expect(sleeps).toEqual([5_000, 10_000]);
34
- expect(onWait).toHaveBeenNthCalledWith(1, 1, 5_000);
35
- expect(onWait).toHaveBeenNthCalledWith(2, 2, 10_000);
36
- // Progress refills the shared budget for the remaining apps
37
- expect(waitState.remainingMs()).toBe(600_000);
38
- });
39
- it('caps the backoff delay at maxDelayMs', async () => {
40
- const sleeps = [];
41
- const post = vi
42
- .fn()
43
- .mockRejectedValueOnce(buildLimitError())
44
- .mockRejectedValueOnce(buildLimitError())
45
- .mockRejectedValueOnce(buildLimitError())
46
- .mockRejectedValueOnce(buildLimitError())
47
- .mockResolvedValue('accepted');
48
- await (0, uploadRetry_1.withBuildLimitRetry)(post, (0, uploadRetry_1.createBuildLimitWaitState)(600_000), {
49
- onWait: vi.fn(),
50
- initialDelayMs: 5_000,
51
- maxDelayMs: 15_000,
52
- sleep: async (ms) => {
53
- sleeps.push(ms);
54
- },
55
- });
56
- expect(sleeps).toEqual([5_000, 10_000, 15_000, 15_000]);
57
- });
58
- it('rethrows non-429 errors without sleeping', async () => {
59
- const sleep = vi.fn();
60
- const notFound = new common_1.LightdashError({
61
- message: 'not found',
62
- name: 'NotFoundError',
63
- statusCode: 404,
64
- data: {},
65
- });
66
- const post = vi.fn().mockRejectedValue(notFound);
67
- await expect((0, uploadRetry_1.withBuildLimitRetry)(post, (0, uploadRetry_1.createBuildLimitWaitState)(), {
68
- onWait: vi.fn(),
69
- sleep,
70
- })).rejects.toThrow('not found');
71
- expect(post).toHaveBeenCalledTimes(1);
72
- expect(sleep).not.toHaveBeenCalled();
73
- });
74
- it('rethrows the 429 once the wait budget is exhausted', async () => {
75
- const sleeps = [];
76
- const post = vi.fn().mockRejectedValue(buildLimitError());
77
- const waitState = (0, uploadRetry_1.createBuildLimitWaitState)(12_000);
78
- await expect((0, uploadRetry_1.withBuildLimitRetry)(post, waitState, {
79
- onWait: vi.fn(),
80
- initialDelayMs: 5_000,
81
- maxDelayMs: 30_000,
82
- sleep: async (ms) => {
83
- sleeps.push(ms);
84
- },
85
- })).rejects.toThrow('Too many app builds in progress');
86
- // 5s, then 10s capped to the 7s remaining, then the budget is spent
87
- expect(sleeps).toEqual([5_000, 7_000]);
88
- expect(waitState.remainingMs()).toBe(0);
89
- expect(post).toHaveBeenCalledTimes(3);
90
- });
91
- it('fails fast on 429 when a previous app already exhausted the budget', async () => {
92
- const sleep = vi.fn();
93
- const post = vi.fn().mockRejectedValue(buildLimitError());
94
- const waitState = (0, uploadRetry_1.createBuildLimitWaitState)(600_000);
95
- waitState.spend(600_000);
96
- await expect((0, uploadRetry_1.withBuildLimitRetry)(post, waitState, {
97
- onWait: vi.fn(),
98
- sleep,
99
- })).rejects.toThrow('Too many app builds in progress');
100
- expect(post).toHaveBeenCalledTimes(1);
101
- expect(sleep).not.toHaveBeenCalled();
102
- });
103
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=validate.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate.test.d.ts","sourceRoot":"","sources":["../../../src/handlers/apps/validate.test.ts"],"names":[],"mappings":""}