neonctl 1.27.6 → 1.29.1

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 (184) hide show
  1. package/.bump +1 -0
  2. package/.editorconfig +7 -0
  3. package/.eslintrc.cjs +15 -0
  4. package/.github/workflows/commitlint.yml +46 -0
  5. package/.github/workflows/pr.yml +25 -0
  6. package/.github/workflows/release.yml +30 -0
  7. package/.husky/commit-msg +4 -0
  8. package/.husky/pre-commit +4 -0
  9. package/.nvmrc +1 -0
  10. package/.prettierignore +3 -0
  11. package/.prettierrc.json +3 -0
  12. package/.releaserc.json +47 -0
  13. package/LICENSE +202 -0
  14. package/commitlint.config.cjs +7 -0
  15. package/generateOptionsFromSpec.ts +68 -0
  16. package/jest/setup.js +5 -0
  17. package/jest.config.ts +199 -0
  18. package/mocks/bin/psql.cjs +9 -0
  19. package/mocks/main/projects/GET.js +27 -0
  20. package/mocks/main/projects/POST.js +22 -0
  21. package/mocks/main/projects/shared/GET.js +16 -0
  22. package/mocks/main/projects/test/DELETE.json +7 -0
  23. package/mocks/main/projects/test/GET.json +13 -0
  24. package/mocks/main/projects/test/PATCH.js +18 -0
  25. package/mocks/main/projects/test/branches/GET.json +25 -0
  26. package/mocks/main/projects/test/branches/POST.js +83 -0
  27. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/DELETE.json +7 -0
  28. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/GET.json +9 -0
  29. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/PATCH.js +14 -0
  30. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/databases/GET.json +6 -0
  31. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/databases/POST.js +13 -0
  32. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/databases/test_db/DELETE.json +6 -0
  33. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/endpoints/GET.json +26 -0
  34. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/endpoints/POST.json +6 -0
  35. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/GET.json +3 -0
  36. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/POST.js +14 -0
  37. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/test_role/DELETE.json +6 -0
  38. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/test_role/reveal_password/GET.json +3 -0
  39. package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/set_as_primary/POST.json +9 -0
  40. package/mocks/main/projects/test/branches/br-numbered-branch-123456/GET.json +10 -0
  41. package/mocks/main/projects/test/branches/br-sunny-branch-123456/DELETE.json +7 -0
  42. package/mocks/main/projects/test/branches/br-sunny-branch-123456/GET.json +10 -0
  43. package/mocks/main/projects/test/branches/br-sunny-branch-123456/PATCH.js +14 -0
  44. package/mocks/main/projects/test/branches/br-sunny-branch-123456/databases/GET.json +6 -0
  45. package/mocks/main/projects/test/branches/br-sunny-branch-123456/databases/POST.js +13 -0
  46. package/mocks/main/projects/test/branches/br-sunny-branch-123456/databases/test_db/DELETE.json +6 -0
  47. package/mocks/main/projects/test/branches/br-sunny-branch-123456/endpoints/GET.json +26 -0
  48. package/mocks/main/projects/test/branches/br-sunny-branch-123456/endpoints/POST.json +6 -0
  49. package/mocks/main/projects/test/branches/br-sunny-branch-123456/restore/POST.js +16 -0
  50. package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/GET.json +3 -0
  51. package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/POST.js +14 -0
  52. package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/test_role/DELETE.json +6 -0
  53. package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/test_role/reveal_password/GET.json +3 -0
  54. package/mocks/main/projects/test/branches/br-sunny-branch-123456/set_as_primary/POST.json +9 -0
  55. package/mocks/main/projects/test/endpoints/GET.json +9 -0
  56. package/mocks/main/projects/test/endpoints/POST.js +32 -0
  57. package/mocks/main/projects/test/endpoints/test_endpoint_id/DELETE.json +7 -0
  58. package/mocks/main/projects/test/endpoints/test_endpoint_id/GET.json +9 -0
  59. package/mocks/main/projects/test/endpoints/test_endpoint_id/PATCH.js +17 -0
  60. package/mocks/main/projects/test/operations/GET.json +22 -0
  61. package/mocks/main/users/me/GET.json +5 -0
  62. package/mocks/restore/projects/test/branches/GET.json +21 -0
  63. package/mocks/restore/projects/test/branches/br-another-branch-123456/GET.json +6 -0
  64. package/mocks/restore/projects/test/branches/br-another-branch-123456/restore/POST.js +13 -0
  65. package/mocks/restore/projects/test/branches/br-any-branch-123456/GET.json +6 -0
  66. package/mocks/restore/projects/test/branches/br-parent-tots-123456/GET.json +7 -0
  67. package/mocks/restore/projects/test/branches/br-parent-tots-123456/restore/POST.js +14 -0
  68. package/mocks/restore/projects/test/branches/br-self-tolsn-123456/GET.json +6 -0
  69. package/mocks/restore/projects/test/branches/br-self-tolsn-123456/restore/POST.js +15 -0
  70. package/mocks/single_project/projects/GET.json +10 -0
  71. package/mocks/single_project/projects/test-project-123456/GET.json +14 -0
  72. package/mocks/single_project/projects/test-project-123456/branches/GET.json +11 -0
  73. package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/databases/GET.json +3 -0
  74. package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/endpoints/GET.json +10 -0
  75. package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/roles/GET.json +3 -0
  76. package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/roles/test_role/reveal_password/GET.json +3 -0
  77. package/package.json +7 -6
  78. package/pkg.js +45 -3
  79. package/rollup.config.js +20 -0
  80. package/snapshots/commands/branches.test.snap +221 -0
  81. package/snapshots/commands/connection_string.test.snap +70 -0
  82. package/snapshots/commands/databases.test.snap +20 -0
  83. package/snapshots/commands/ip_allow.test.snap +55 -0
  84. package/snapshots/commands/operations.test.snap +17 -0
  85. package/snapshots/commands/projects.test.snap +141 -0
  86. package/snapshots/commands/roles.test.snap +19 -0
  87. package/snapshots/commands/set_context.test.snap +30 -0
  88. package/snapshots/writer.test.snap +60 -0
  89. package/snapshotsResolver.cjs +32 -0
  90. package/src/analytics.ts +95 -0
  91. package/src/api.ts +44 -0
  92. package/src/auth.ts +137 -0
  93. package/{cli.js → src/cli.ts} +1 -0
  94. package/src/commands/auth.test.ts +62 -0
  95. package/src/commands/auth.ts +148 -0
  96. package/src/commands/branches.test.ts +354 -0
  97. package/src/commands/branches.ts +451 -0
  98. package/src/commands/connection_string.test.ts +250 -0
  99. package/src/commands/connection_string.ts +210 -0
  100. package/src/commands/databases.test.ts +55 -0
  101. package/src/commands/databases.ts +129 -0
  102. package/src/commands/help.test.ts +13 -0
  103. package/{commands/index.js → src/commands/index.ts} +11 -10
  104. package/src/commands/ip_allow.test.ts +86 -0
  105. package/src/commands/ip_allow.ts +202 -0
  106. package/src/commands/operations.test.ts +13 -0
  107. package/src/commands/operations.ts +41 -0
  108. package/src/commands/projects.test.ts +147 -0
  109. package/src/commands/projects.ts +275 -0
  110. package/src/commands/roles.test.ts +46 -0
  111. package/src/commands/roles.ts +100 -0
  112. package/src/commands/set_context.test.ts +64 -0
  113. package/src/commands/set_context.ts +27 -0
  114. package/src/commands/user.ts +21 -0
  115. package/src/config.ts +22 -0
  116. package/src/context.ts +61 -0
  117. package/src/env.ts +7 -0
  118. package/src/errors.ts +24 -0
  119. package/src/help.ts +185 -0
  120. package/src/index.ts +180 -0
  121. package/src/log.ts +16 -0
  122. package/src/parameters.gen.ts +332 -0
  123. package/src/pkg.ts +9 -0
  124. package/src/test_utils/mock_server.ts +27 -0
  125. package/src/test_utils/oauth_server.ts +10 -0
  126. package/src/test_utils/test_cli_command.ts +117 -0
  127. package/src/types.ts +25 -0
  128. package/src/utils/enrichers.ts +73 -0
  129. package/src/utils/formats.test.ts +41 -0
  130. package/src/utils/formats.ts +11 -0
  131. package/src/utils/middlewares.ts +23 -0
  132. package/src/utils/point_in_time.ts +86 -0
  133. package/src/utils/psql.ts +29 -0
  134. package/src/utils/string.ts +8 -0
  135. package/src/utils/ui.ts +64 -0
  136. package/src/writer.test.ts +98 -0
  137. package/src/writer.ts +131 -0
  138. package/tsconfig.json +17 -0
  139. package/analytics.js +0 -78
  140. package/api.js +0 -35
  141. package/auth.js +0 -101
  142. package/commands/auth.js +0 -102
  143. package/commands/auth.test.js +0 -42
  144. package/commands/branches.js +0 -311
  145. package/commands/branches.test.js +0 -321
  146. package/commands/connection_string.js +0 -137
  147. package/commands/connection_string.test.js +0 -204
  148. package/commands/databases.js +0 -79
  149. package/commands/databases.test.js +0 -51
  150. package/commands/help.test.js +0 -11
  151. package/commands/ip_allow.js +0 -135
  152. package/commands/ip_allow.test.js +0 -78
  153. package/commands/operations.js +0 -28
  154. package/commands/operations.test.js +0 -11
  155. package/commands/projects.js +0 -156
  156. package/commands/projects.test.js +0 -116
  157. package/commands/roles.js +0 -57
  158. package/commands/roles.test.js +0 -42
  159. package/commands/set_context.js +0 -22
  160. package/commands/set_context.test.js +0 -53
  161. package/commands/user.js +0 -15
  162. package/config.js +0 -11
  163. package/context.js +0 -48
  164. package/env.js +0 -6
  165. package/errors.js +0 -16
  166. package/help.js +0 -146
  167. package/index.js +0 -168
  168. package/log.js +0 -15
  169. package/parameters.gen.js +0 -302
  170. package/test_utils/mock_server.js +0 -16
  171. package/test_utils/oauth_server.js +0 -9
  172. package/test_utils/test_cli_command.js +0 -80
  173. package/types.js +0 -1
  174. package/utils/enrichers.js +0 -49
  175. package/utils/formats.js +0 -5
  176. package/utils/formats.test.js +0 -32
  177. package/utils/middlewares.js +0 -20
  178. package/utils/point_in_time.js +0 -44
  179. package/utils/psql.js +0 -24
  180. package/utils/string.js +0 -5
  181. package/utils/ui.js +0 -59
  182. package/writer.js +0 -87
  183. package/writer.test.js +0 -86
  184. /package/{callback.html → src/callback.html} +0 -0
package/jest.config.ts ADDED
@@ -0,0 +1,199 @@
1
+ /*
2
+ * For a detailed explanation regarding each configuration property and type check, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ export default {
7
+ // All imported modules in your tests should be mocked automatically
8
+ // automock: false,
9
+
10
+ // Stop running tests after `n` failures
11
+ // bail: 0,
12
+
13
+ // The directory where Jest should store its cached dependency information
14
+ // cacheDirectory: "/tmp/jest_rs",
15
+
16
+ // Automatically clear mock calls, instances, contexts and results before every test
17
+ clearMocks: true,
18
+
19
+ // Indicates whether the coverage information should be collected while executing the test
20
+ collectCoverage: true,
21
+
22
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
23
+ // collectCoverageFrom: undefined,
24
+
25
+ // The directory where Jest should output its coverage files
26
+ coverageDirectory: 'coverage',
27
+
28
+ // An array of regexp pattern strings used to skip coverage collection
29
+ // coveragePathIgnorePatterns: [
30
+ // "/node_modules/"
31
+ // ],
32
+
33
+ // Indicates which provider should be used to instrument code for coverage
34
+ coverageProvider: 'v8',
35
+
36
+ // A list of reporter names that Jest uses when writing coverage reports
37
+ // coverageReporters: [
38
+ // "json",
39
+ // "text",
40
+ // "lcov",
41
+ // "clover"
42
+ // ],
43
+
44
+ // An object that configures minimum threshold enforcement for coverage results
45
+ // coverageThreshold: undefined,
46
+
47
+ // A path to a custom dependency extractor
48
+ // dependencyExtractor: undefined,
49
+
50
+ // Make calling deprecated APIs throw helpful error messages
51
+ // errorOnDeprecated: false,
52
+
53
+ // The default configuration for fake timers
54
+ // fakeTimers: {
55
+ // "enableGlobally": false
56
+ // },
57
+
58
+ // Force coverage collection from ignored files using an array of glob patterns
59
+ // forceCoverageMatch: [],
60
+
61
+ // A path to a module which exports an async function that is triggered once before all test suites
62
+ globalSetup: '<rootDir>/jest/setup.js',
63
+
64
+ // A path to a module which exports an async function that is triggered once after all test suites
65
+ // globalTeardown: undefined,
66
+
67
+ // A set of global variables that need to be available in all test environments
68
+ // globals: {},
69
+
70
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
71
+ // maxWorkers: "50%",
72
+
73
+ // An array of directory names to be searched recursively up from the requiring module's location
74
+ // moduleDirectories: [
75
+ // "node_modules"
76
+ // ],
77
+
78
+ // An array of file extensions your modules use
79
+ // moduleFileExtensions: [
80
+ // "js",
81
+ // "mjs",
82
+ // "cjs",
83
+ // "jsx",
84
+ // "ts",
85
+ // "tsx",
86
+ // "json",
87
+ // "node"
88
+ // ],
89
+ // extensionsToTreatAsEsm: ['.ts'],
90
+
91
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
92
+ // moduleNameMapper: {
93
+ // '^(\\.{1,2}/.*)\\.js$': '$1',
94
+ // },
95
+
96
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
97
+ // modulePathIgnorePatterns: [],
98
+
99
+ // Activates notifications for test results
100
+ // notify: false,
101
+
102
+ // An enum that specifies notification mode. Requires { notify: true }
103
+ // notifyMode: "failure-change",
104
+
105
+ // A preset that is used as a base for Jest's configuration
106
+ // preset: 'ts-jest',
107
+
108
+ // Run tests from one or more projects
109
+ // projects: undefined,
110
+
111
+ // Use this configuration option to add custom reporters to Jest
112
+ // reporters: undefined,
113
+
114
+ // Automatically reset mock state before every test
115
+ // resetMocks: false,
116
+
117
+ // Reset the module registry before running each individual test
118
+ // resetModules: false,
119
+
120
+ // A path to a custom resolver
121
+ // resolver: undefined,
122
+
123
+ // Automatically restore mock state and implementation before every test
124
+ // restoreMocks: false,
125
+
126
+ // The root directory that Jest should scan for tests and modules within
127
+ // rootDir: undefined,
128
+
129
+ // A list of paths to directories that Jest should use to search for files in
130
+ // roots: ['<rootDir>/dist'],
131
+
132
+ // Allows you to use a custom runner instead of Jest's default test runner
133
+ // runner: "jest-runner",
134
+
135
+ // The paths to modules that run some code to configure or set up the testing environment before each test
136
+ // setupFiles: [],
137
+
138
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
139
+ // setupFilesAfterEnv: [],
140
+
141
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
142
+ // slowTestThreshold: 5,
143
+
144
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
145
+ // snapshotSerializers: [],
146
+ snapshotResolver: '<rootDir>/snapshotsResolver.cjs',
147
+
148
+ // The test environment that will be used for testing
149
+ // testEnvironment: "jest-environment-node",
150
+
151
+ // Options that will be passed to the testEnvironment
152
+ // testEnvironmentOptions: {},
153
+
154
+ // Adds a location field to test results
155
+ // testLocationInResults: false,
156
+
157
+ // The glob patterns Jest uses to detect test files
158
+ testMatch: ['<rootDir>/dist/**/*.test.js'],
159
+
160
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
161
+ // testPathIgnorePatterns: [
162
+ // "/node_modules/"
163
+ // ],
164
+
165
+ // The regexp pattern or array of patterns that Jest uses to detect test files
166
+ // testRegex: [],
167
+
168
+ // This option allows the use of a custom results processor
169
+ // testResultsProcessor: undefined,
170
+
171
+ // This option allows use of a custom test runner
172
+ // testRunner: "jest-circus/runner",
173
+
174
+ // A map from regular expressions to paths to transformers
175
+ // transform: {
176
+ // '^.+\\.ts$': [
177
+ // 'ts-jest',
178
+ // {
179
+ // useESM: true,
180
+ // },
181
+ // ],
182
+ // },
183
+ transform: {},
184
+
185
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
186
+ // transformIgnorePatterns: [],
187
+
188
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
189
+ // unmockedModulePathPatterns: undefined,
190
+
191
+ // Indicates whether each individual test should be reported during the run
192
+ // verbose: undefined,
193
+
194
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
195
+ // watchPathIgnorePatterns: [],
196
+
197
+ // Whether to use watchman for file crawling
198
+ // watchman: true,
199
+ };
@@ -0,0 +1,9 @@
1
+ #! /usr/bin/env node
2
+
3
+ // A psql mock that just prints its arguments (as an array in an object) to stdout.
4
+ // Node.js script should have an extension (otherwise ERR_UNKNOWN_FILE_EXTENSION is thrown), so we use a symlink psql -> psql.cjs
5
+ if (require.main === module) {
6
+ process.stdout.write(
7
+ JSON.stringify({ 'psql-cli-args': process.argv.slice(2) }),
8
+ );
9
+ }
@@ -0,0 +1,27 @@
1
+ export default function (req, res) {
2
+ expect(req.query).toMatchObject({
3
+ limit: '100',
4
+ });
5
+ res.json({
6
+ projects: [
7
+ {
8
+ id: 1,
9
+ name: 'Project_1',
10
+ created_at: '2019-01-01T00:00:00.000Z',
11
+ updated_at: '2019-01-01T00:00:00.000Z',
12
+ },
13
+ {
14
+ id: 2,
15
+ name: 'Project_2',
16
+ created_at: '2019-01-01T00:00:00.000Z',
17
+ updated_at: '2019-01-01T00:00:00.000Z',
18
+ },
19
+ {
20
+ id: 3,
21
+ name: 'Project_3',
22
+ created_at: '2019-01-01T00:00:00.000Z',
23
+ updated_at: '2019-01-01T00:00:00.000Z',
24
+ },
25
+ ],
26
+ });
27
+ }
@@ -0,0 +1,22 @@
1
+ export default function (req, res) {
2
+ expect(req.body).toMatchObject({
3
+ project: {
4
+ name: 'test_project',
5
+ },
6
+ });
7
+ res.send({
8
+ project: {
9
+ id: 'new-project-123456',
10
+ name: 'test_project',
11
+ created_at: '2021-01-01T00:00:00.000Z',
12
+ },
13
+ connection_uris: [
14
+ { connection_uri: 'postgres://localhost:5432/test_project' },
15
+ ],
16
+ branch: {
17
+ id: 'br-test-branch-123456',
18
+ name: 'test_branch',
19
+ created_at: '2021-01-01T00:00:00.000Z',
20
+ },
21
+ });
22
+ }
@@ -0,0 +1,16 @@
1
+ export default function (req, res) {
2
+ expect(req.query).toMatchObject({
3
+ limit: '100',
4
+ });
5
+ res.json({
6
+ projects: [
7
+ {
8
+ id: 'adj-noun-12401747',
9
+ region_id: 'aws-us-east-2',
10
+ name: 'Shared Project',
11
+ created_at: '2024-04-03T04:45:46Z',
12
+ updated_at: '2024-04-11T16:13:43Z',
13
+ },
14
+ ],
15
+ });
16
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "project": {
3
+ "id": "test",
4
+ "name": "test",
5
+ "create_at": "2018-01-01T00:00:00.000Z"
6
+ }
7
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "project": {
3
+ "id": "test",
4
+ "name": "test_project",
5
+ "created_at": "2019-01-01T00:00:00Z",
6
+ "settings": {
7
+ "allowed_ips": {
8
+ "ips": ["192.168.1.1"],
9
+ "primary_branch_only": false
10
+ }
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,18 @@
1
+ const defaultSettings = {
2
+ allowed_ips: {
3
+ ips: ['192.168.1.1'],
4
+ primary_branch_only: false,
5
+ },
6
+ };
7
+
8
+ export default function (req, res) {
9
+ const project = req.body.project ?? {};
10
+ res.send({
11
+ project: {
12
+ id: 'test',
13
+ name: project.name ?? 'test_project',
14
+ created_at: '2019-01-01T00:00:00Z',
15
+ settings: { ...defaultSettings, ...project.settings },
16
+ },
17
+ });
18
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "branches": [
3
+ {
4
+ "id": "br-main-branch-123456",
5
+ "name": "main",
6
+ "primary": true,
7
+ "created_at": "2021-01-01T00:00:00.000Z",
8
+ "updated_at": "2021-01-01T00:00:00.000Z"
9
+ },
10
+ {
11
+ "id": "br-sunny-branch-123456",
12
+ "name": "test_branch",
13
+ "parent_id": "br-parent-branch-123456",
14
+ "created_at": "2021-01-01T00:00:00.000Z",
15
+ "updated_at": "2021-01-01T00:00:00.000Z"
16
+ },
17
+ {
18
+ "id": "br-numbered-branch-123456",
19
+ "name": "123",
20
+ "parent_id": "br-parent-branch-123456",
21
+ "created_at": "2021-01-01T00:00:00.000Z",
22
+ "updated_at": "2021-01-01T00:00:00.000Z"
23
+ }
24
+ ]
25
+ }
@@ -0,0 +1,83 @@
1
+ export default function (req, res) {
2
+ if (req.body.branch?.name === 'test_branch_with_parent_name') {
3
+ expect(req.body).toMatchObject({
4
+ branch: {
5
+ name: 'test_branch_with_parent_name',
6
+ parent_id: 'br-main-branch-123456',
7
+ },
8
+ });
9
+ res.send({
10
+ branch: {
11
+ id: 'br-new-branch-123456',
12
+ name: 'test_branch_with_parent_name',
13
+ parent_id: 'br-main-branch-123456',
14
+ created_at: '2021-01-01T00:00:00.000Z',
15
+ },
16
+ });
17
+ } else if (req.body.branch?.name === 'test_branch_with_parent_lsn') {
18
+ expect(req.body).toMatchObject({
19
+ branch: {
20
+ name: 'test_branch_with_parent_lsn',
21
+ parent_lsn: expect.any(String),
22
+ },
23
+ });
24
+ res.send({
25
+ branch: {
26
+ id: 'br-new-branch-123456',
27
+ name: 'test_branch_with_parent_lsn',
28
+ parent_id: 'br-main-branch-123456',
29
+ created_at: '2021-01-01T00:00:00.000Z',
30
+ },
31
+ });
32
+ } else if (req.body.branch?.name === 'test_branch_with_parent_timestamp') {
33
+ expect(req.body).toMatchObject({
34
+ branch: {
35
+ name: 'test_branch_with_parent_timestamp',
36
+ parent_timestamp: expect.any(String),
37
+ },
38
+ });
39
+ res.send({
40
+ branch: {
41
+ id: 'br-new-branch-123456',
42
+ name: 'test_branch_with_parent_timestamp',
43
+ parent_id: 'br-main-branch-123456',
44
+ created_at: '2021-01-01T00:00:00.000Z',
45
+ },
46
+ });
47
+ } else if (req.body.branch?.name === 'test_branch_with_suspend_timeout') {
48
+ res.send({
49
+ branch: {
50
+ id: 'br-new-branch-123456',
51
+ name: 'test_branch_with_suspend_timeout',
52
+ parent_id: 'br-main-branch-123456',
53
+ created_at: '2021-01-01T00:00:00.000Z',
54
+ suspend_timeout: req.body.endpoints[0].suspend_timeout_seconds,
55
+ },
56
+ });
57
+ } else {
58
+ expect(req.body).toMatchObject({
59
+ branch: {
60
+ name: 'test_branch',
61
+ },
62
+ });
63
+ const result = {
64
+ branch: {
65
+ id: 'br-new-branch-123456',
66
+ name: 'test_branch',
67
+ created_at: '2021-01-01T00:00:00.000Z',
68
+ },
69
+ };
70
+ if (req.body.endpoints?.length > 0) {
71
+ result.endpoints = req.body.endpoints.map((endpoint) => ({
72
+ id: `ep-${endpoint.name}-123456`,
73
+ type: endpoint.type,
74
+ created_at: '2021-01-01T00:00:00.000Z',
75
+ host: `${endpoint.name}.example.com`,
76
+ }));
77
+ result.connection_uris = req.body.endpoints.map((endpoint) => ({
78
+ connection_uri: `postgres://ep-${endpoint.name}-123456.example.com:5432/test_project`,
79
+ }));
80
+ }
81
+ res.send(result);
82
+ }
83
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "branch": {
3
+ "id": "br-cloudy-branch-12345678",
4
+ "name": "cloudy-branch",
5
+ "created_at": "2021-01-01T00:00:00.000Z"
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "branch": {
3
+ "name": "test-branch-cloudy",
4
+ "id": "br-cloudy-branch-12345678",
5
+ "primary": true,
6
+ "created_at": "2019-01-01T00:00:00Z",
7
+ "updated_at": "2019-01-01T00:00:00Z"
8
+ }
9
+ }
@@ -0,0 +1,14 @@
1
+ export default function (req, res) {
2
+ expect(req.body).toMatchObject({
3
+ branch: {
4
+ name: 'new_test_branch',
5
+ },
6
+ });
7
+ res.send({
8
+ branch: {
9
+ id: req.body.branch.id,
10
+ name: 'new_test_branch',
11
+ created_at: '2021-01-01T00:00:00.000Z',
12
+ },
13
+ });
14
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "databases": [
3
+ { "name": "db1", "owner_name": "user1" },
4
+ { "name": "db2", "owner_name": "user2" }
5
+ ]
6
+ }
@@ -0,0 +1,13 @@
1
+ export default function (req, res) {
2
+ expect(req.body).toMatchObject({
3
+ database: {
4
+ name: 'test_db',
5
+ owner_name: 'test_owner',
6
+ },
7
+ });
8
+ res.send({
9
+ database: {
10
+ name: 'test_database',
11
+ },
12
+ });
13
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "database": {
3
+ "name": "test_db",
4
+ "owner_name": "test_owner"
5
+ }
6
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "endpoints": [
3
+ {
4
+ "host": "ep-lame-king-930914.us-east-2.aws.neon.tech",
5
+ "id": "ep-lame-king-930914",
6
+ "project_id": "test",
7
+ "branch_id": "br-cloudy-branch-12345678",
8
+ "type": "read_write",
9
+ "created_at": "2023-06-22T14:26:33Z",
10
+ "updated_at": "2023-06-30T04:07:32Z",
11
+ "proxy_host": "us-east-2.aws.neon.tech",
12
+ "provisioner": "k8s-pod"
13
+ },
14
+ {
15
+ "host": "ep-lame-king-933333.us-east-2.aws.neon.tech",
16
+ "id": "ep-lame-king-933333",
17
+ "project_id": "test",
18
+ "branch_id": "br-cloudy-branch-12345678",
19
+ "type": "read_only",
20
+ "created_at": "2023-06-22T14:26:33Z",
21
+ "updated_at": "2023-06-30T04:07:32Z",
22
+ "proxy_host": "us-east-2.aws.neon.tech",
23
+ "provisioner": "k8s-pod"
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "endpoint": {
3
+ "id": "ep-worthless-fish-123456",
4
+ "host": "localhost"
5
+ }
6
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "roles": [{ "name": "test_role", "created_at": "2016-01-01T00:00:00Z" }]
3
+ }
@@ -0,0 +1,14 @@
1
+ export default function (req, res) {
2
+ expect(req.body).toMatchObject({
3
+ role: {
4
+ name: 'test_role',
5
+ },
6
+ });
7
+
8
+ res.send({
9
+ role: {
10
+ name: 'test_role',
11
+ created_at: '2019-01-01T00:00:00.000Z',
12
+ },
13
+ });
14
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "role": {
3
+ "name": "test_role",
4
+ "created_at": "2016-11-16T15:39:18.000Z"
5
+ }
6
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "branch": {
3
+ "name": "test-branch-cloudy",
4
+ "id": "br-cloudy-branch-12345678",
5
+ "primary": true,
6
+ "created_at": "2019-01-01T00:00:00Z",
7
+ "updated_at": "2019-01-01T00:00:00Z"
8
+ }
9
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "branch": {
3
+ "name": "123",
4
+ "id": "br-numbered-branch-123456",
5
+ "primary": false,
6
+ "parent_id": "br-parent-branch-123456",
7
+ "created_at": "2019-01-01T00:00:00Z",
8
+ "updated_at": "2019-01-01T00:00:00Z"
9
+ }
10
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "branch": {
3
+ "id": "br-sunny-branch-123456",
4
+ "name": "sunny-branch",
5
+ "created_at": "2021-01-01T00:00:00.000Z"
6
+ }
7
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "branch": {
3
+ "name": "test-branch-sunny",
4
+ "id": "br-sunny-branch-123456",
5
+ "primary": true,
6
+ "parent_id": "br-parent-branch-123456",
7
+ "created_at": "2019-01-01T00:00:00Z",
8
+ "updated_at": "2019-01-01T00:00:00Z"
9
+ }
10
+ }
@@ -0,0 +1,14 @@
1
+ export default function (req, res) {
2
+ expect(req.body).toMatchObject({
3
+ branch: {
4
+ name: 'new_test_branch',
5
+ },
6
+ });
7
+ res.send({
8
+ branch: {
9
+ id: req.body.branch.id,
10
+ name: 'new_test_branch',
11
+ created_at: '2021-01-01T00:00:00.000Z',
12
+ },
13
+ });
14
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "databases": [
3
+ { "name": "db1", "owner_name": "user1" },
4
+ { "name": "db2", "owner_name": "user2" }
5
+ ]
6
+ }
@@ -0,0 +1,13 @@
1
+ export default function (req, res) {
2
+ expect(req.body).toMatchObject({
3
+ database: {
4
+ name: 'test_db',
5
+ owner_name: 'test_owner',
6
+ },
7
+ });
8
+ res.send({
9
+ database: {
10
+ name: 'test_database',
11
+ },
12
+ });
13
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "database": {
3
+ "name": "test_db",
4
+ "owner_name": "test_owner"
5
+ }
6
+ }