adapty 0.8.4 → 0.8.6

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 (209) hide show
  1. package/README.md +7 -2
  2. package/bin/dev.js +2 -2
  3. package/bin/run.js +2 -2
  4. package/dist/cli/base/adapty/adapty-command.d.ts +21 -0
  5. package/dist/cli/base/adapty/adapty-command.js +47 -0
  6. package/dist/cli/base/adapty/build.d.ts +11 -0
  7. package/dist/cli/base/adapty/build.js +13 -0
  8. package/dist/cli/base/adapty/index.d.ts +5 -0
  9. package/dist/cli/base/adapty/index.js +3 -0
  10. package/dist/cli/base/adapty/openSession.d.ts +22 -0
  11. package/dist/cli/base/adapty/openSession.js +25 -0
  12. package/dist/cli/base/base-command.d.ts +30 -0
  13. package/dist/cli/base/base-command.js +64 -0
  14. package/dist/cli/commands/apps/create.d.ts +19 -0
  15. package/dist/cli/commands/apps/create.js +68 -0
  16. package/dist/cli/commands/apps/get.d.ts +10 -0
  17. package/dist/cli/commands/apps/get.js +14 -0
  18. package/dist/cli/commands/apps/list.d.ts +11 -0
  19. package/dist/cli/commands/apps/list.js +14 -0
  20. package/dist/cli/commands/apps/update.d.ts +15 -0
  21. package/dist/cli/commands/apps/update.js +30 -0
  22. package/dist/cli/commands/auth/login.d.ts +11 -0
  23. package/dist/cli/commands/auth/login.js +68 -0
  24. package/dist/cli/commands/auth/logout.d.ts +12 -0
  25. package/dist/cli/commands/auth/logout.js +28 -0
  26. package/dist/cli/commands/auth/revoke.d.ts +13 -0
  27. package/dist/cli/commands/auth/revoke.js +32 -0
  28. package/dist/cli/commands/auth/status/index.d.ts +7 -0
  29. package/dist/cli/commands/auth/status/index.js +22 -0
  30. package/dist/cli/commands/auth/status/lib/render.d.ts +3 -0
  31. package/dist/cli/commands/auth/status/lib/render.js +14 -0
  32. package/dist/cli/commands/auth/status/lib/result.d.ts +15 -0
  33. package/dist/cli/commands/auth/status/lib/result.js +1 -0
  34. package/dist/cli/commands/auth/whoami.d.ts +10 -0
  35. package/dist/cli/commands/auth/whoami.js +16 -0
  36. package/dist/cli/errors.d.ts +39 -0
  37. package/dist/cli/errors.js +92 -0
  38. package/dist/cli/flags.d.ts +16 -0
  39. package/dist/cli/flags.js +27 -0
  40. package/dist/cli/views/list.d.ts +6 -0
  41. package/dist/cli/views/list.js +10 -0
  42. package/dist/cli/views/record.d.ts +9 -0
  43. package/dist/cli/views/record.js +14 -0
  44. package/dist/commands/access-levels/create.js +1 -1
  45. package/dist/commands/access-levels/list.d.ts +1 -1
  46. package/dist/commands/apps/create.d.ts +1 -14
  47. package/dist/commands/apps/create.js +2 -54
  48. package/dist/commands/apps/get.d.ts +1 -11
  49. package/dist/commands/apps/get.js +2 -22
  50. package/dist/commands/apps/list.d.ts +1 -13
  51. package/dist/commands/apps/list.js +2 -19
  52. package/dist/commands/apps/update.d.ts +1 -16
  53. package/dist/commands/apps/update.js +2 -38
  54. package/dist/commands/asa/ad-groups/create.js +9 -7
  55. package/dist/commands/asa/ad-groups/get.js +3 -2
  56. package/dist/commands/asa/ad-groups/list.d.ts +1 -1
  57. package/dist/commands/asa/ad-groups/list.js +1 -1
  58. package/dist/commands/asa/ad-groups/update.js +22 -12
  59. package/dist/commands/asa/ads/create.js +7 -5
  60. package/dist/commands/asa/ads/get.js +3 -2
  61. package/dist/commands/asa/ads/list.d.ts +1 -1
  62. package/dist/commands/asa/ads/list.js +1 -1
  63. package/dist/commands/asa/ads/update.js +9 -5
  64. package/dist/commands/asa/apps/list.d.ts +1 -1
  65. package/dist/commands/asa/apps/list.js +1 -1
  66. package/dist/commands/asa/automations/create.js +9 -6
  67. package/dist/commands/asa/automations/get.js +3 -2
  68. package/dist/commands/asa/automations/list.d.ts +1 -1
  69. package/dist/commands/asa/automations/list.js +1 -1
  70. package/dist/commands/asa/automations/run.js +5 -3
  71. package/dist/commands/asa/automations/runs.d.ts +1 -1
  72. package/dist/commands/asa/automations/runs.js +4 -4
  73. package/dist/commands/asa/automations/update.js +17 -9
  74. package/dist/commands/asa/campaigns/bulk-create.js +31 -18
  75. package/dist/commands/asa/campaigns/bulk-list.js +7 -5
  76. package/dist/commands/asa/campaigns/bulk-status.js +3 -2
  77. package/dist/commands/asa/campaigns/create.js +10 -8
  78. package/dist/commands/asa/campaigns/get.js +3 -2
  79. package/dist/commands/asa/campaigns/list.d.ts +1 -1
  80. package/dist/commands/asa/campaigns/list.js +1 -1
  81. package/dist/commands/asa/campaigns/update.js +25 -15
  82. package/dist/commands/asa/competitors/summary.js +5 -5
  83. package/dist/commands/asa/connect.js +5 -3
  84. package/dist/commands/asa/creatives/list.d.ts +1 -1
  85. package/dist/commands/asa/creatives/list.js +1 -1
  86. package/dist/commands/asa/keywords/add.js +13 -10
  87. package/dist/commands/asa/keywords/list.d.ts +1 -1
  88. package/dist/commands/asa/keywords/list.js +1 -1
  89. package/dist/commands/asa/keywords/update.js +15 -10
  90. package/dist/commands/asa/metrics/index.d.ts +2 -2
  91. package/dist/commands/asa/metrics/index.js +22 -8
  92. package/dist/commands/asa/metrics/overview.js +3 -3
  93. package/dist/commands/asa/negative-keywords/add.js +10 -7
  94. package/dist/commands/asa/negative-keywords/list.d.ts +1 -1
  95. package/dist/commands/asa/negative-keywords/list.js +1 -1
  96. package/dist/commands/asa/orgs/list.d.ts +1 -1
  97. package/dist/commands/asa/orgs/list.js +1 -1
  98. package/dist/commands/asa/product-pages/list.d.ts +1 -1
  99. package/dist/commands/asa/product-pages/list.js +1 -1
  100. package/dist/commands/asa/product-pages/sync.js +1 -1
  101. package/dist/commands/asa/search-terms/list.d.ts +1 -1
  102. package/dist/commands/asa/search-terms/list.js +1 -1
  103. package/dist/commands/asa/whoami.js +13 -4
  104. package/dist/commands/auth/login.d.ts +1 -8
  105. package/dist/commands/auth/login.js +2 -120
  106. package/dist/commands/auth/logout.d.ts +1 -9
  107. package/dist/commands/auth/logout.js +2 -18
  108. package/dist/commands/auth/revoke.d.ts +1 -9
  109. package/dist/commands/auth/revoke.js +2 -21
  110. package/dist/commands/auth/status.d.ts +1 -7
  111. package/dist/commands/auth/status.js +2 -26
  112. package/dist/commands/auth/whoami.d.ts +1 -7
  113. package/dist/commands/auth/whoami.js +2 -15
  114. package/dist/commands/flows/config/get.js +2 -2
  115. package/dist/commands/flows/config/preview.d.ts +2 -2
  116. package/dist/commands/flows/config/preview.js +6 -4
  117. package/dist/commands/flows/config/update.js +5 -3
  118. package/dist/commands/flows/config/validate.js +5 -3
  119. package/dist/commands/flows/list.d.ts +1 -1
  120. package/dist/commands/flows/media/upload.js +1 -1
  121. package/dist/commands/flows/publish.js +5 -5
  122. package/dist/commands/paywalls/create.js +1 -1
  123. package/dist/commands/paywalls/list.d.ts +1 -1
  124. package/dist/commands/paywalls/placements.d.ts +2 -2
  125. package/dist/commands/paywalls/update.js +1 -1
  126. package/dist/commands/placements/create.js +17 -12
  127. package/dist/commands/placements/list.d.ts +1 -1
  128. package/dist/commands/placements/update.js +20 -15
  129. package/dist/commands/products/create.js +20 -13
  130. package/dist/commands/products/list.d.ts +1 -1
  131. package/dist/commands/products/update.js +1 -1
  132. package/dist/commands/segments/list.d.ts +1 -1
  133. package/dist/lib/api-client.d.ts +10 -6
  134. package/dist/lib/api-client.js +56 -35
  135. package/dist/lib/api-schemas.d.ts +63 -59
  136. package/dist/lib/app-url.js +2 -1
  137. package/dist/lib/asa-client.d.ts +13 -8
  138. package/dist/lib/asa-client.js +9 -4
  139. package/dist/lib/asa-flags.d.ts +19 -19
  140. package/dist/lib/asa-flags.js +38 -25
  141. package/dist/lib/asa-keyword-action.d.ts +10 -10
  142. package/dist/lib/asa-keyword-action.js +40 -25
  143. package/dist/lib/asa-schemas.d.ts +101 -81
  144. package/dist/lib/auth.js +2 -1
  145. package/dist/lib/client-from-config.d.ts +1 -1
  146. package/dist/lib/client-from-config.js +2 -1
  147. package/dist/lib/config.d.ts +2 -2
  148. package/dist/lib/confirm.d.ts +4 -4
  149. package/dist/lib/confirm.js +12 -7
  150. package/dist/lib/errors.d.ts +18 -18
  151. package/dist/lib/errors.js +12 -9
  152. package/dist/lib/flags.d.ts +3 -3
  153. package/dist/lib/flags.js +2 -1
  154. package/dist/lib/flow-help.js +11 -6
  155. package/dist/lib/output.js +23 -12
  156. package/dist/lib/preview.d.ts +5 -5
  157. package/dist/lib/preview.js +2 -1
  158. package/dist/sdk/adapty/access-levels.d.ts +15 -0
  159. package/dist/sdk/adapty/access-levels.js +4 -0
  160. package/dist/sdk/adapty/apps/create.d.ts +26 -0
  161. package/dist/sdk/adapty/apps/create.js +36 -0
  162. package/dist/sdk/adapty/apps/index.d.ts +13 -0
  163. package/dist/sdk/adapty/apps/index.js +9 -0
  164. package/dist/sdk/adapty/apps/model.d.ts +24 -0
  165. package/dist/sdk/adapty/apps/model.js +10 -0
  166. package/dist/sdk/adapty/apps/resource.d.ts +19 -0
  167. package/dist/sdk/adapty/apps/resource.js +23 -0
  168. package/dist/sdk/adapty/apps/update.d.ts +16 -0
  169. package/dist/sdk/adapty/apps/update.js +25 -0
  170. package/dist/sdk/adapty/auth/device-code.d.ts +8 -0
  171. package/dist/sdk/adapty/auth/device-code.js +19 -0
  172. package/dist/sdk/adapty/auth/index.d.ts +7 -0
  173. package/dist/sdk/adapty/auth/index.js +5 -0
  174. package/dist/sdk/adapty/auth/model.d.ts +15 -0
  175. package/dist/sdk/adapty/auth/model.js +6 -0
  176. package/dist/sdk/adapty/auth/poll-token.d.ts +8 -0
  177. package/dist/sdk/adapty/auth/poll-token.js +58 -0
  178. package/dist/sdk/adapty/auth/resource.d.ts +17 -0
  179. package/dist/sdk/adapty/auth/resource.js +21 -0
  180. package/dist/sdk/adapty/errors.d.ts +10 -0
  181. package/dist/sdk/adapty/errors.js +38 -0
  182. package/dist/sdk/adapty/index.d.ts +36 -0
  183. package/dist/sdk/adapty/index.js +27 -0
  184. package/dist/sdk/adapty/pagination.d.ts +23 -0
  185. package/dist/sdk/adapty/pagination.js +1 -0
  186. package/dist/sdk/core/auth/device-flow.d.ts +46 -0
  187. package/dist/sdk/core/auth/device-flow.js +62 -0
  188. package/dist/sdk/core/clock.d.ts +7 -0
  189. package/dist/sdk/core/clock.js +21 -0
  190. package/dist/sdk/core/errors.d.ts +81 -0
  191. package/dist/sdk/core/errors.js +84 -0
  192. package/dist/sdk/core/http/client.d.ts +46 -0
  193. package/dist/sdk/core/http/client.js +127 -0
  194. package/dist/sdk/core/http/index.d.ts +11 -0
  195. package/dist/sdk/core/http/index.js +7 -0
  196. package/dist/sdk/core/http/policies.d.ts +14 -0
  197. package/dist/sdk/core/http/policies.js +29 -0
  198. package/dist/sdk/core/http/retry.d.ts +27 -0
  199. package/dist/sdk/core/http/retry.js +22 -0
  200. package/dist/sdk/core/http/url.d.ts +3 -0
  201. package/dist/sdk/core/http/url.js +19 -0
  202. package/dist/sdk/core/session.d.ts +20 -0
  203. package/dist/sdk/core/session.js +69 -0
  204. package/dist/sdk/core/testing.d.ts +25 -0
  205. package/dist/sdk/core/testing.js +46 -0
  206. package/dist/sdk/core/validation.d.ts +10 -0
  207. package/dist/sdk/core/validation.js +14 -0
  208. package/oclif.manifest.json +766 -766
  209. package/package.json +19 -9
@@ -2,20 +2,29 @@ import { Command } from '@oclif/core';
2
2
  import { createAsaClient } from '../../lib/asa-client.js';
3
3
  import { printResponse } from '../../lib/output.js';
4
4
  export default class AsaWhoami extends Command {
5
- static description = 'Show which company the token unlocks and whether Apple Ads is connected';
5
+ static description = `Show which company the token unlocks, whether Apple Ads is connected, and the request budgets it gets
6
+
7
+ Limits are raised per company, so read them here rather than assuming the defaults: metrics_limit_per_minute
8
+ and metrics_burst_limit govern asa metrics, keywords_read_limit_per_minute the keyword lists,
9
+ metrics_inflight_limit how many analytics calls may overlap, and max_breakdown_rows_per_page the size a
10
+ grouped page may project to before it is refused.`;
6
11
  static enableJsonFlag = true;
7
12
  static examples = ['<%= config.bin %> asa whoami'];
8
13
  async run() {
9
14
  await this.parse(AsaWhoami);
10
- const client = await createAsaClient(this.config);
15
+ const client = await createAsaClient(this);
11
16
  const result = await client.get('/me');
12
17
  printResponse(result, this.log.bind(this));
13
18
  if (result.apple_credentials_status !== 'active') {
14
19
  this.log('\nApple Ads is not connected. Run `adapty asa connect` to link an account.');
15
20
  }
16
21
  if (result.access_source === 'none') {
17
- this.log('\nNo active Ads Manager subscription for this company: connecting an account works, but every');
18
- this.log('data command answers 402 until the subscription is in place.');
22
+ this.log('\nNo Ads Manager access for this company: connecting an account works, but every data command');
23
+ this.log('answers 402 until the Ads Manager trial is started or a subscription is in place.');
24
+ }
25
+ if (result.access_source === 'trial') {
26
+ this.log('\nAccess comes from the Ads Manager trial: every command works, and they stop working when');
27
+ this.log('the trial ends without a subscription.');
19
28
  }
20
29
  return result;
21
30
  }
@@ -1,8 +1 @@
1
- import { Command } from '@oclif/core';
2
- export default class AuthLogin extends Command {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- /** Keeps the browser on the configured dashboard host, when ADAPTY_APP_URL asks for one. */
7
- private verificationUrl;
8
- }
1
+ export { default } from '../../cli/commands/auth/login.js';
@@ -1,120 +1,2 @@
1
- import { Command } from '@oclif/core';
2
- import open from 'open';
3
- import { ApiClient } from '../../lib/api-client.js';
4
- import { onAppHost } from '../../lib/app-url.js';
5
- import { buildUserAgent } from '../../lib/client-from-config.js';
6
- import { readConfig, writeConfig } from '../../lib/config.js';
7
- import { ApiError } from '../../lib/errors.js';
8
- function sleep(ms) {
9
- return new Promise((resolve) => {
10
- setTimeout(resolve, ms);
11
- });
12
- }
13
- export default class AuthLogin extends Command {
14
- static description = 'Authenticate with Adapty via browser';
15
- static examples = ['<%= config.bin %> auth login'];
16
- async run() {
17
- const config = await readConfig(this.config.configDir);
18
- if (config.access_token && config.user) {
19
- this.log(`Already authenticated as ${config.user.email}. Re-authenticating...`);
20
- }
21
- const client = new ApiClient({
22
- userAgent: buildUserAgent(this.config),
23
- });
24
- let device;
25
- try {
26
- device = await client.post('/auth/device', { client_id: 'adapty-cli' });
27
- }
28
- catch (error) {
29
- this.error(error instanceof Error ? error.message : 'Failed to initiate auth flow', { exit: 1 });
30
- }
31
- const verificationUrl = this.verificationUrl(device.verification_uri_complete);
32
- this.log(`\nYour code: ${device.user_code}\n`);
33
- this.log(`If browser doesn't open, visit: ${verificationUrl}\n`);
34
- if (process.stdin.isTTY === true) {
35
- try {
36
- await open(verificationUrl);
37
- }
38
- catch {
39
- // browser open failed silently — URL already printed
40
- }
41
- }
42
- this.log('Waiting for authorization...');
43
- let interval = Math.max((device.interval_seconds || 5) * 1000, 5000);
44
- const deadline = Date.now() + device.expires_in * 1000;
45
- let consecutiveErrors = 0;
46
- // Handle Ctrl+C
47
- const onSignal = () => {
48
- this.log('\nLogin cancelled.');
49
- process.exit(0);
50
- };
51
- process.on('SIGINT', onSignal);
52
- try {
53
- while (Date.now() < deadline) {
54
- await sleep(interval);
55
- let result;
56
- try {
57
- result = await client.post('/auth/token', {
58
- client_id: 'adapty-cli',
59
- device_code: device.device_code,
60
- grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
61
- });
62
- }
63
- catch (error) {
64
- if (error instanceof ApiError) {
65
- switch (error.errorCode) {
66
- case 'authorization_pending': {
67
- continue;
68
- }
69
- case 'slow_down': {
70
- interval += 5000;
71
- continue;
72
- }
73
- case 'access_denied': {
74
- this.error('Authorization denied.', { exit: 1 });
75
- break;
76
- }
77
- case 'expired_token': {
78
- this.error('Code expired. Run `adapty auth login` again.', { exit: 1 });
79
- break;
80
- }
81
- default:
82
- // unexpected API error — fall through to network error handling
83
- }
84
- }
85
- consecutiveErrors++;
86
- if (consecutiveErrors >= 10) {
87
- this.error('Too many consecutive network errors. Check your connection and try again.', { exit: 1 });
88
- }
89
- if (consecutiveErrors >= 3) {
90
- process.stderr.write(`Warning: ${consecutiveErrors} consecutive network errors (${error instanceof Error ? error.message : 'unknown'})\n`);
91
- }
92
- continue;
93
- }
94
- consecutiveErrors = 0;
95
- if ('access_token' in result) {
96
- await writeConfig({
97
- access_token: result.access_token,
98
- user: result.user,
99
- }, this.config.configDir);
100
- this.log(`\nAuthenticated as ${result.user.email}`);
101
- this.log(`Token saved to ${this.config.configDir}/config.json`);
102
- return;
103
- }
104
- }
105
- this.error('Code expired. Run `adapty auth login` again.', { exit: 1 });
106
- }
107
- finally {
108
- process.removeListener('SIGINT', onSignal);
109
- }
110
- }
111
- /** Keeps the browser on the configured dashboard host, when ADAPTY_APP_URL asks for one. */
112
- verificationUrl(issuedUrl) {
113
- try {
114
- return onAppHost(issuedUrl);
115
- }
116
- catch (error) {
117
- this.error(error instanceof Error ? error.message : String(error), { exit: 2 });
118
- }
119
- }
120
- }
1
+ // Implementation lives in the new cli layer; oclif discovers commands only under src/commands.
2
+ export { default } from '../../cli/commands/auth/login.js';
@@ -1,9 +1 @@
1
- import { Command } from '@oclif/core';
2
- export default class AuthLogout extends Command {
3
- static description: string;
4
- static enableJsonFlag: boolean;
5
- static examples: string[];
6
- run(): Promise<{
7
- status: string;
8
- }>;
9
- }
1
+ export { default } from '../../cli/commands/auth/logout.js';
@@ -1,18 +1,2 @@
1
- import { Command } from '@oclif/core';
2
- import { readConfig, writeConfig } from '../../lib/config.js';
3
- export default class AuthLogout extends Command {
4
- static description = 'Remove stored authentication token';
5
- static enableJsonFlag = true;
6
- static examples = ['<%= config.bin %> auth logout'];
7
- async run() {
8
- await this.parse(AuthLogout);
9
- const config = await readConfig(this.config.configDir);
10
- if (!config.access_token) {
11
- this.log('Not currently authenticated.');
12
- return { status: 'not_authenticated' };
13
- }
14
- await writeConfig({}, this.config.configDir);
15
- this.log('Logged out. Note: token remains valid server-side until expiry.');
16
- return { status: 'logged_out' };
17
- }
18
- }
1
+ // Implementation lives in the new cli layer; oclif discovers commands only under src/commands.
2
+ export { default } from '../../cli/commands/auth/logout.js';
@@ -1,9 +1 @@
1
- import { Command } from '@oclif/core';
2
- export default class AuthRevoke extends Command {
3
- static description: string;
4
- static enableJsonFlag: boolean;
5
- static examples: string[];
6
- run(): Promise<{
7
- status: string;
8
- }>;
9
- }
1
+ export { default } from '../../cli/commands/auth/revoke.js';
@@ -1,21 +1,2 @@
1
- import { Command } from '@oclif/core';
2
- import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
- import { readConfig, writeConfig } from '../../lib/config.js';
4
- export default class AuthRevoke extends Command {
5
- static description = 'Revoke the current authentication token';
6
- static enableJsonFlag = true;
7
- static examples = ['<%= config.bin %> auth revoke'];
8
- async run() {
9
- await this.parse(AuthRevoke);
10
- const config = await readConfig(this.config.configDir);
11
- if (!config.access_token) {
12
- this.log('Not currently authenticated.');
13
- return { status: 'not_authenticated' };
14
- }
15
- const client = await createAuthenticatedClient(this.config);
16
- await client.post('/auth/tokens/revoke', { token: config.access_token });
17
- await writeConfig({}, this.config.configDir);
18
- this.log('Token revoked and logged out.');
19
- return { status: 'revoked' };
20
- }
21
- }
1
+ // Implementation lives in the new cli layer; oclif discovers commands only under src/commands.
2
+ export { default } from '../../cli/commands/auth/revoke.js';
@@ -1,7 +1 @@
1
- import { Command } from '@oclif/core';
2
- export default class AuthStatus extends Command {
3
- static description: string;
4
- static enableJsonFlag: boolean;
5
- static examples: string[];
6
- run(): Promise<Record<string, unknown>>;
7
- }
1
+ export { default } from '../../cli/commands/auth/status/index.js';
@@ -1,26 +1,2 @@
1
- import { Command } from '@oclif/core';
2
- import { readConfig } from '../../lib/config.js';
3
- export default class AuthStatus extends Command {
4
- static description = 'Show current authentication state (local only)';
5
- static enableJsonFlag = true;
6
- static examples = ['<%= config.bin %> auth status'];
7
- async run() {
8
- await this.parse(AuthStatus);
9
- const config = await readConfig(this.config.configDir);
10
- if (!config.access_token || !config.user) {
11
- this.log('Not authenticated. Run `adapty auth login`.');
12
- return { authenticated: false };
13
- }
14
- const masked = config.access_token.slice(0, 8) + '****';
15
- const configPath = `${this.config.configDir}/config.json`;
16
- this.log(`Email: ${config.user.email}`);
17
- this.log(`Token: ${masked}`);
18
- this.log(`Config: ${configPath}`);
19
- return {
20
- authenticated: true,
21
- config_path: configPath,
22
- email: config.user.email,
23
- token_prefix: config.access_token.slice(0, 8),
24
- };
25
- }
26
- }
1
+ // Implementation lives in the new cli layer; oclif discovers commands only under src/commands.
2
+ export { default } from '../../cli/commands/auth/status/index.js';
@@ -1,7 +1 @@
1
- import { Command } from '@oclif/core';
2
- export default class AuthWhoami extends Command {
3
- static description: string;
4
- static enableJsonFlag: boolean;
5
- static examples: string[];
6
- run(): Promise<Record<string, unknown>>;
7
- }
1
+ export { default } from '../../cli/commands/auth/whoami.js';
@@ -1,15 +1,2 @@
1
- import { Command } from '@oclif/core';
2
- import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
- import { printResponse } from '../../lib/output.js';
4
- export default class AuthWhoami extends Command {
5
- static description = 'Show current user info from server (verifies token)';
6
- static enableJsonFlag = true;
7
- static examples = ['<%= config.bin %> auth whoami'];
8
- async run() {
9
- await this.parse(AuthWhoami);
10
- const client = await createAuthenticatedClient(this.config);
11
- const me = await client.get('/me');
12
- printResponse(me, this.log.bind(this));
13
- return me;
14
- }
15
- }
1
+ // Implementation lives in the new cli layer; oclif discovers commands only under src/commands.
2
+ export { default } from '../../cli/commands/auth/whoami.js';
@@ -6,8 +6,8 @@ export default class FlowsConfigGet extends Command {
6
6
  static args = {
7
7
  flow_id: Args.string({ description: 'Flow ID (UUID)', required: true }),
8
8
  };
9
- static description = 'Read the flow builder config (404 until the config has been written at least once). ' +
10
- 'On a failed publish, `publication_status`, `transform_error` and `publication_error` show why.';
9
+ static description = 'Read the flow builder config (404 until the config has been written at least once). '
10
+ + 'On a failed publish, `publication_status`, `transform_error` and `publication_error` show why.';
11
11
  static enableJsonFlag = true;
12
12
  static examples = ['<%= config.bin %> flows config get --app UUID 550e8400-e29b-41d4-a716-446655440000'];
13
13
  static flags = {
@@ -1,7 +1,7 @@
1
1
  import { Command } from '@oclif/core';
2
- export interface PreviewResult {
2
+ export type PreviewResult = {
3
3
  render_url: string;
4
- }
4
+ };
5
5
  export default class FlowsConfigPreview extends Command {
6
6
  static args: {
7
7
  config_file: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
@@ -1,6 +1,6 @@
1
- import { Args, Command, Flags } from '@oclif/core';
2
1
  import { readFile } from 'node:fs/promises';
3
2
  import { resolve } from 'node:path';
3
+ import { Args, Command, Flags } from '@oclif/core';
4
4
  import open from 'open';
5
5
  import { APP_URL_ENV_VAR } from '../../../lib/app-url.js';
6
6
  import { buildRenderUrl, DEFAULT_DEVICE_ID, DEFAULT_ORIENTATION, normalizePreviewConfig, ORIENTATIONS, } from '../../../lib/preview.js';
@@ -26,7 +26,7 @@ export default class FlowsConfigPreview extends Command {
26
26
  description: 'Device orientation to render in',
27
27
  options: [...ORIENTATIONS],
28
28
  }),
29
- screen: Flags.string({ description: "Screen ID to render (default: the flow's first screen)" }),
29
+ screen: Flags.string({ description: 'Screen ID to render (default: the flow\'s first screen)' }),
30
30
  };
31
31
  async run() {
32
32
  const { args, flags } = await this.parse(FlowsConfigPreview);
@@ -47,17 +47,19 @@ export default class FlowsConfigPreview extends Command {
47
47
  }
48
48
  let renderUrl;
49
49
  try {
50
+ // eslint-disable-next-line @stylistic/max-len -- FIXME if you see this
50
51
  renderUrl = buildRenderUrl({ device: flags.device, orientation: flags.orientation, screen: flags.screen }, payload);
51
52
  }
52
53
  catch (error) {
53
54
  this.error(describeError(error), { exit: 2 });
54
55
  }
55
56
  const result = { render_url: renderUrl };
56
- if (this.jsonEnabled())
57
+ if (this.jsonEnabled()) {
57
58
  return result;
59
+ }
58
60
  // Piped output stays a bare URL so it composes — the whole config rides in the fragment, which
59
61
  // is why a TTY gets the browser opened instead of a screenful of base64.
60
- if (process.stdout.isTTY !== true) {
62
+ if (!process.stdout.isTTY) {
61
63
  this.log(renderUrl);
62
64
  return result;
63
65
  }
@@ -1,5 +1,5 @@
1
- import { Args, Command, Flags } from '@oclif/core';
2
1
  import { readFile } from 'node:fs/promises';
2
+ import { Args, Command, Flags } from '@oclif/core';
3
3
  import { createAuthenticatedClient } from '../../../lib/client-from-config.js';
4
4
  import { appFlag, isValidUuid } from '../../../lib/flags.js';
5
5
  import { printResponse } from '../../../lib/output.js';
@@ -16,7 +16,7 @@ export default class FlowsConfigUpdate extends Command {
16
16
  ];
17
17
  static flags = {
18
18
  ...appFlag,
19
- config: Flags.string({
19
+ 'config': Flags.string({
20
20
  description: 'Builder config as a JSON string',
21
21
  exactlyOne: ['config', 'config-file'],
22
22
  }),
@@ -50,6 +50,7 @@ export default class FlowsConfigUpdate extends Command {
50
50
  printResponse(result, this.log.bind(this));
51
51
  return result;
52
52
  }
53
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- FIXME if you see this
53
54
  parseJson(raw, label) {
54
55
  try {
55
56
  return JSON.parse(raw);
@@ -77,8 +78,9 @@ export default class FlowsConfigUpdate extends Command {
77
78
  }
78
79
  async readStdin() {
79
80
  const chunks = [];
80
- for await (const chunk of process.stdin)
81
+ for await (const chunk of process.stdin) {
81
82
  chunks.push(chunk);
83
+ }
82
84
  return Buffer.concat(chunks).toString('utf8');
83
85
  }
84
86
  }
@@ -1,5 +1,5 @@
1
- import { Args, Command, Flags } from '@oclif/core';
2
1
  import { readFile } from 'node:fs/promises';
2
+ import { Args, Command, Flags } from '@oclif/core';
3
3
  import { createAuthenticatedClient } from '../../../lib/client-from-config.js';
4
4
  import { appFlag, isValidUuid } from '../../../lib/flags.js';
5
5
  import { printResponse } from '../../../lib/output.js';
@@ -16,7 +16,7 @@ export default class FlowsConfigValidate extends Command {
16
16
  ];
17
17
  static flags = {
18
18
  ...appFlag,
19
- config: Flags.string({
19
+ 'config': Flags.string({
20
20
  description: 'Builder config as a JSON string',
21
21
  exactlyOne: ['config', 'config-file'],
22
22
  }),
@@ -43,6 +43,7 @@ export default class FlowsConfigValidate extends Command {
43
43
  }
44
44
  return result;
45
45
  }
46
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- FIXME if you see this
46
47
  parseJson(raw, label) {
47
48
  try {
48
49
  return JSON.parse(raw);
@@ -70,8 +71,9 @@ export default class FlowsConfigValidate extends Command {
70
71
  }
71
72
  async readStdin() {
72
73
  const chunks = [];
73
- for await (const chunk of process.stdin)
74
+ for await (const chunk of process.stdin) {
74
75
  chunks.push(chunk);
76
+ }
75
77
  return Buffer.concat(chunks).toString('utf8');
76
78
  }
77
79
  }
@@ -1,6 +1,6 @@
1
1
  import { Command } from '@oclif/core';
2
2
  import type { FlowDTO } from '../../lib/api-schemas.js';
3
- import { type PaginatedResponse } from '../../lib/flags.js';
3
+ import type { PaginatedResponse } from '../../lib/flags.js';
4
4
  export default class FlowsList extends Command {
5
5
  static description: string;
6
6
  static enableJsonFlag: boolean;
@@ -1,6 +1,6 @@
1
- import { Args, Command } from '@oclif/core';
2
1
  import { readFile } from 'node:fs/promises';
3
2
  import { basename, extname } from 'node:path';
3
+ import { Args, Command } from '@oclif/core';
4
4
  import { createAuthenticatedClient } from '../../../lib/client-from-config.js';
5
5
  import { appFlag } from '../../../lib/flags.js';
6
6
  import { printResponse } from '../../../lib/output.js';
@@ -9,8 +9,8 @@ export default class FlowsPublish extends Command {
9
9
  static args = {
10
10
  flow_id: Args.string({ description: 'Flow ID (UUID)', required: true }),
11
11
  };
12
- static description = 'Publish a flow (async — publication completes in the background). ' +
13
- 'Publishing is async: returns status `publishing`. Poll `adapty flows get <flow_id>` for `published`/`publication_failed`; on failure, `adapty flows config get <flow_id>` shows why.';
12
+ static description = 'Publish a flow (async — publication completes in the background). '
13
+ + 'Publishing is async: returns status `publishing`. Poll `adapty flows get <flow_id>` for `published`/`publication_failed`; on failure, `adapty flows config get <flow_id>` shows why.';
14
14
  static enableJsonFlag = true;
15
15
  static examples = ['<%= config.bin %> flows publish --app UUID 550e8400-e29b-41d4-a716-446655440000'];
16
16
  static flags = {
@@ -35,9 +35,9 @@ export default class FlowsPublish extends Command {
35
35
  }
36
36
  catch (error) {
37
37
  if (error instanceof ApiError && (error.statusCode === 400 || error.errorCode === 'validation_error')) {
38
- this.error(`Flow publish failed: ${error.message}\n` +
39
- 'Publishing needs a flow with a valid config. Fix it, then run `adapty flows publish` again:\n' +
40
- flowFixLinks(args.flow_id), { exit: 1 });
38
+ this.error(`Flow publish failed: ${error.message}\n`
39
+ + 'Publishing needs a flow with a valid config. Fix it, then run `adapty flows publish` again:\n'
40
+ + flowFixLinks(args.flow_id), { exit: 1 });
41
41
  }
42
42
  throw error;
43
43
  }
@@ -15,7 +15,7 @@ export default class PaywallsCreate extends Command {
15
15
  multiple: true,
16
16
  required: true,
17
17
  }),
18
- title: Flags.string({ description: 'Paywall title', required: true }),
18
+ 'title': Flags.string({ description: 'Paywall title', required: true }),
19
19
  };
20
20
  async run() {
21
21
  const { flags } = await this.parse(PaywallsCreate);
@@ -1,6 +1,6 @@
1
1
  import { Command } from '@oclif/core';
2
2
  import type { PaywallDTO } from '../../lib/api-schemas.js';
3
- import { type PaginatedResponse } from '../../lib/flags.js';
3
+ import type { PaginatedResponse } from '../../lib/flags.js';
4
4
  export default class PaywallsList extends Command {
5
5
  static description: string;
6
6
  static enableJsonFlag: boolean;
@@ -1,8 +1,8 @@
1
1
  import { Command } from '@oclif/core';
2
2
  import type { PlacementSummaryDTO } from '../../lib/api-schemas.js';
3
- interface PlacementsByPaywallResponse {
3
+ type PlacementsByPaywallResponse = {
4
4
  data: PlacementSummaryDTO[];
5
- }
5
+ };
6
6
  export default class PaywallsPlacements extends Command {
7
7
  static args: {
8
8
  paywall_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
@@ -18,7 +18,7 @@ export default class PaywallsUpdate extends Command {
18
18
  multiple: true,
19
19
  required: true,
20
20
  }),
21
- title: Flags.string({ description: 'Paywall title', required: true }),
21
+ 'title': Flags.string({ description: 'Paywall title', required: true }),
22
22
  };
23
23
  async run() {
24
24
  const { args, flags } = await this.parse(PaywallsUpdate);
@@ -14,11 +14,11 @@ export default class PlacementsCreate extends Command {
14
14
  ];
15
15
  static flags = {
16
16
  ...appFlag,
17
- audiences: Flags.string({
18
- description: 'JSON array of audience entries. Every entry needs an explicit content_type. ' +
19
- 'Paywall: {content_type:"paywall", segment_ids, paywall_id, priority}. ' +
20
- 'Flow: {content_type:"flow", segment_ids, flow_id, priority}. ' +
21
- 'A flow must be published first (flows publish) — attaching a draft flow returns 400.',
17
+ 'audiences': Flags.string({
18
+ description: 'JSON array of audience entries. Every entry needs an explicit content_type. '
19
+ + 'Paywall: {content_type:"paywall", segment_ids, paywall_id, priority}. '
20
+ + 'Flow: {content_type:"flow", segment_ids, flow_id, priority}. '
21
+ + 'A flow must be published first (flows publish) — attaching a draft flow returns 400.',
22
22
  exactlyOne: ['paywall-id', 'audiences'],
23
23
  }),
24
24
  'developer-id': Flags.string({ description: 'Developer ID for the placement', required: true }),
@@ -26,7 +26,7 @@ export default class PlacementsCreate extends Command {
26
26
  description: 'Paywall ID (UUID). DEPRECATED: use --audiences.',
27
27
  exactlyOne: ['paywall-id', 'audiences'],
28
28
  }),
29
- title: Flags.string({ description: 'Placement title', required: true }),
29
+ 'title': Flags.string({ description: 'Placement title', required: true }),
30
30
  };
31
31
  async run() {
32
32
  const { flags } = await this.parse(PlacementsCreate);
@@ -37,13 +37,15 @@ export default class PlacementsCreate extends Command {
37
37
  title: flags.title,
38
38
  };
39
39
  if (flags['paywall-id']) {
40
- process.stderr.write('⚠️ --paywall-id is deprecated. Use --audiences instead.\n' +
41
- ' `paywall_id` will be removed from the API in a future release.\n');
40
+ process.stderr.write('⚠️ --paywall-id is deprecated. Use --audiences instead.\n'
41
+ + ' `paywall_id` will be removed from the API in a future release.\n');
42
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- FIXME if you see this
42
43
  body.paywall_id = flags['paywall-id'];
43
44
  }
44
45
  else {
45
46
  let parsed;
46
47
  try {
48
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- FIXME if you see this
47
49
  parsed = JSON.parse(flags.audiences);
48
50
  }
49
51
  catch (error) {
@@ -52,12 +54,14 @@ export default class PlacementsCreate extends Command {
52
54
  if (!Array.isArray(parsed)) {
53
55
  this.error('--audiences must be a JSON array of audience entries.', { exit: 2 });
54
56
  }
55
- for (const [index, entry] of parsed.entries()) {
57
+ const entries = parsed;
58
+ for (const [index, entry] of entries.entries()) {
56
59
  const problem = audienceEntryProblem(entry);
57
- if (problem)
60
+ if (problem) {
58
61
  this.error(`--audiences[${index}]: ${problem}`, { exit: 2 });
62
+ }
59
63
  }
60
- body.audiences = parsed;
64
+ body.audiences = entries;
61
65
  }
62
66
  const client = await createAuthenticatedClient(this.config);
63
67
  let result;
@@ -66,8 +70,9 @@ export default class PlacementsCreate extends Command {
66
70
  }
67
71
  catch (error) {
68
72
  const message = draftFlowError(error, flags.app, body.audiences);
69
- if (message)
73
+ if (message) {
70
74
  this.error(message, { exit: 2 });
75
+ }
71
76
  throw error;
72
77
  }
73
78
  this.log('Placement created!');
@@ -1,6 +1,6 @@
1
1
  import { Command } from '@oclif/core';
2
2
  import type { PlacementSummaryDTO } from '../../lib/api-schemas.js';
3
- import { type PaginatedResponse } from '../../lib/flags.js';
3
+ import type { PaginatedResponse } from '../../lib/flags.js';
4
4
  export default class PlacementsList extends Command {
5
5
  static description: string;
6
6
  static enableJsonFlag: boolean;