adapty 0.8.5 → 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 (114) hide show
  1. package/README.md +6 -1
  2. package/dist/cli/base/adapty/adapty-command.d.ts +21 -0
  3. package/dist/cli/base/adapty/adapty-command.js +47 -0
  4. package/dist/cli/base/adapty/build.d.ts +11 -0
  5. package/dist/cli/base/adapty/build.js +13 -0
  6. package/dist/cli/base/adapty/index.d.ts +5 -0
  7. package/dist/cli/base/adapty/index.js +3 -0
  8. package/dist/cli/base/adapty/openSession.d.ts +22 -0
  9. package/dist/cli/base/adapty/openSession.js +25 -0
  10. package/dist/cli/base/base-command.d.ts +30 -0
  11. package/dist/cli/base/base-command.js +64 -0
  12. package/dist/cli/commands/apps/create.d.ts +19 -0
  13. package/dist/cli/commands/apps/create.js +68 -0
  14. package/dist/cli/commands/apps/get.d.ts +10 -0
  15. package/dist/cli/commands/apps/get.js +14 -0
  16. package/dist/cli/commands/apps/list.d.ts +11 -0
  17. package/dist/cli/commands/apps/list.js +14 -0
  18. package/dist/cli/commands/apps/update.d.ts +15 -0
  19. package/dist/cli/commands/apps/update.js +30 -0
  20. package/dist/cli/commands/auth/login.d.ts +11 -0
  21. package/dist/cli/commands/auth/login.js +68 -0
  22. package/dist/cli/commands/auth/logout.d.ts +12 -0
  23. package/dist/cli/commands/auth/logout.js +28 -0
  24. package/dist/cli/commands/auth/revoke.d.ts +13 -0
  25. package/dist/cli/commands/auth/revoke.js +32 -0
  26. package/dist/cli/commands/auth/status/index.d.ts +7 -0
  27. package/dist/cli/commands/auth/status/index.js +22 -0
  28. package/dist/cli/commands/auth/status/lib/render.d.ts +3 -0
  29. package/dist/cli/commands/auth/status/lib/render.js +14 -0
  30. package/dist/cli/commands/auth/status/lib/result.d.ts +15 -0
  31. package/dist/cli/commands/auth/status/lib/result.js +1 -0
  32. package/dist/cli/commands/auth/whoami.d.ts +10 -0
  33. package/dist/cli/commands/auth/whoami.js +16 -0
  34. package/dist/cli/errors.d.ts +39 -0
  35. package/dist/cli/errors.js +92 -0
  36. package/dist/cli/flags.d.ts +16 -0
  37. package/dist/cli/flags.js +27 -0
  38. package/dist/cli/views/list.d.ts +6 -0
  39. package/dist/cli/views/list.js +10 -0
  40. package/dist/cli/views/record.d.ts +9 -0
  41. package/dist/cli/views/record.js +14 -0
  42. package/dist/commands/apps/create.d.ts +1 -14
  43. package/dist/commands/apps/create.js +2 -57
  44. package/dist/commands/apps/get.d.ts +1 -11
  45. package/dist/commands/apps/get.js +2 -22
  46. package/dist/commands/apps/list.d.ts +1 -13
  47. package/dist/commands/apps/list.js +2 -19
  48. package/dist/commands/apps/update.d.ts +1 -16
  49. package/dist/commands/apps/update.js +2 -41
  50. package/dist/commands/asa/whoami.js +6 -2
  51. package/dist/commands/auth/login.d.ts +1 -8
  52. package/dist/commands/auth/login.js +2 -122
  53. package/dist/commands/auth/logout.d.ts +1 -9
  54. package/dist/commands/auth/logout.js +2 -18
  55. package/dist/commands/auth/revoke.d.ts +1 -9
  56. package/dist/commands/auth/revoke.js +2 -21
  57. package/dist/commands/auth/status.d.ts +1 -7
  58. package/dist/commands/auth/status.js +2 -26
  59. package/dist/commands/auth/whoami.d.ts +1 -7
  60. package/dist/commands/auth/whoami.js +2 -15
  61. package/dist/lib/api-schemas.d.ts +7 -3
  62. package/dist/lib/asa-schemas.d.ts +1 -1
  63. package/dist/sdk/adapty/access-levels.d.ts +15 -0
  64. package/dist/sdk/adapty/access-levels.js +4 -0
  65. package/dist/sdk/adapty/apps/create.d.ts +26 -0
  66. package/dist/sdk/adapty/apps/create.js +36 -0
  67. package/dist/sdk/adapty/apps/index.d.ts +13 -0
  68. package/dist/sdk/adapty/apps/index.js +9 -0
  69. package/dist/sdk/adapty/apps/model.d.ts +24 -0
  70. package/dist/sdk/adapty/apps/model.js +10 -0
  71. package/dist/sdk/adapty/apps/resource.d.ts +19 -0
  72. package/dist/sdk/adapty/apps/resource.js +23 -0
  73. package/dist/sdk/adapty/apps/update.d.ts +16 -0
  74. package/dist/sdk/adapty/apps/update.js +25 -0
  75. package/dist/sdk/adapty/auth/device-code.d.ts +8 -0
  76. package/dist/sdk/adapty/auth/device-code.js +19 -0
  77. package/dist/sdk/adapty/auth/index.d.ts +7 -0
  78. package/dist/sdk/adapty/auth/index.js +5 -0
  79. package/dist/sdk/adapty/auth/model.d.ts +15 -0
  80. package/dist/sdk/adapty/auth/model.js +6 -0
  81. package/dist/sdk/adapty/auth/poll-token.d.ts +8 -0
  82. package/dist/sdk/adapty/auth/poll-token.js +58 -0
  83. package/dist/sdk/adapty/auth/resource.d.ts +17 -0
  84. package/dist/sdk/adapty/auth/resource.js +21 -0
  85. package/dist/sdk/adapty/errors.d.ts +10 -0
  86. package/dist/sdk/adapty/errors.js +38 -0
  87. package/dist/sdk/adapty/index.d.ts +36 -0
  88. package/dist/sdk/adapty/index.js +27 -0
  89. package/dist/sdk/adapty/pagination.d.ts +23 -0
  90. package/dist/sdk/adapty/pagination.js +1 -0
  91. package/dist/sdk/core/auth/device-flow.d.ts +46 -0
  92. package/dist/sdk/core/auth/device-flow.js +62 -0
  93. package/dist/sdk/core/clock.d.ts +7 -0
  94. package/dist/sdk/core/clock.js +21 -0
  95. package/dist/sdk/core/errors.d.ts +81 -0
  96. package/dist/sdk/core/errors.js +84 -0
  97. package/dist/sdk/core/http/client.d.ts +46 -0
  98. package/dist/sdk/core/http/client.js +127 -0
  99. package/dist/sdk/core/http/index.d.ts +11 -0
  100. package/dist/sdk/core/http/index.js +7 -0
  101. package/dist/sdk/core/http/policies.d.ts +14 -0
  102. package/dist/sdk/core/http/policies.js +29 -0
  103. package/dist/sdk/core/http/retry.d.ts +27 -0
  104. package/dist/sdk/core/http/retry.js +22 -0
  105. package/dist/sdk/core/http/url.d.ts +3 -0
  106. package/dist/sdk/core/http/url.js +19 -0
  107. package/dist/sdk/core/session.d.ts +20 -0
  108. package/dist/sdk/core/session.js +69 -0
  109. package/dist/sdk/core/testing.d.ts +25 -0
  110. package/dist/sdk/core/testing.js +46 -0
  111. package/dist/sdk/core/validation.d.ts +10 -0
  112. package/dist/sdk/core/validation.js +14 -0
  113. package/oclif.manifest.json +813 -813
  114. package/package.json +10 -2
@@ -0,0 +1,22 @@
1
+ import { openSession } from '../../../base/adapty/index.js';
2
+ import { BaseCommand } from '../../../base/base-command.js';
3
+ import { renderStatus } from './lib/render.js';
4
+ export default class AuthStatus extends BaseCommand {
5
+ static description = 'Show the local authentication state (no network)';
6
+ static examples = ['<%= config.bin %> auth status'];
7
+ async run() {
8
+ await this.parse(AuthStatus);
9
+ const session = await openSession(this.config);
10
+ const result = session.token === undefined
11
+ ? { authenticated: false, config_path: session.store.path, source: 'none' }
12
+ : {
13
+ authenticated: true,
14
+ config_path: session.store.path,
15
+ email: session.user?.email,
16
+ source: session.source === 'env' ? 'env' : 'file',
17
+ token_prefix: session.token.slice(0, 8),
18
+ };
19
+ this.render(result, renderStatus);
20
+ return result;
21
+ }
22
+ }
@@ -0,0 +1,3 @@
1
+ import type { Result } from './result.js';
2
+ /** Private to `auth status`: the moment a second command needs this, it belongs in cli/views. */
3
+ export declare const renderStatus: (status: Result) => string;
@@ -0,0 +1,14 @@
1
+ /** Private to `auth status`: the moment a second command needs this, it belongs in cli/views. */
2
+ export const renderStatus = (status) => {
3
+ if (!status.authenticated) {
4
+ return 'Not authenticated. Run `adapty auth login`.';
5
+ }
6
+ const lines = [];
7
+ if (status.email !== undefined) {
8
+ lines.push(`Email: ${status.email}`);
9
+ }
10
+ // A prefix, never the token: this output ends up in logs, screenshots and CI transcripts
11
+ lines.push(`Token: ${status.token_prefix}****`);
12
+ lines.push(status.source === 'env' ? 'Source: ADAPTY_TOKEN (environment)' : `Config: ${status.config_path}`);
13
+ return lines.join('\n');
14
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * What `auth status` returns, and what its view renders. It sits in lib/ so that neither imports
3
+ * the other, and because a sibling of index.ts would be picked up as the command `auth:status:*`.
4
+ */
5
+ export type Result = {
6
+ authenticated: false;
7
+ config_path: string;
8
+ source: 'none';
9
+ } | {
10
+ authenticated: true;
11
+ config_path: string;
12
+ email: string | undefined;
13
+ source: 'env' | 'file';
14
+ token_prefix: string;
15
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { AdaptyCommand } from '../../base/adapty/index.js';
2
+ /**
3
+ * The pair to `auth status`: that one answers "what is stored", this one "does it still work". The
4
+ * answer is passed through untyped, so a new server field shows up in the output on its own.
5
+ */
6
+ export default class AuthWhoami extends AdaptyCommand {
7
+ static description: string;
8
+ static examples: string[];
9
+ run(): Promise<Record<string, unknown>>;
10
+ }
@@ -0,0 +1,16 @@
1
+ import { AdaptyCommand } from '../../base/adapty/index.js';
2
+ import { renderRecord } from '../../views/record.js';
3
+ /**
4
+ * The pair to `auth status`: that one answers "what is stored", this one "does it still work". The
5
+ * answer is passed through untyped, so a new server field shows up in the output on its own.
6
+ */
7
+ export default class AuthWhoami extends AdaptyCommand {
8
+ static description = 'Show the current user from the server (verifies the token)';
9
+ static examples = ['<%= config.bin %> auth whoami'];
10
+ async run() {
11
+ await this.parse(AuthWhoami);
12
+ const me = await this.adapty.auth.me();
13
+ this.render(me, renderRecord);
14
+ return me;
15
+ }
16
+ }
@@ -0,0 +1,39 @@
1
+ import { Errors } from '@oclif/core';
2
+ /**
3
+ * Exit codes are the adapter's business: sdk errors carry none.
4
+ * 2 usage — the input is wrong (oclif's own parse errors exit 2 as well)
5
+ * 3 auth — no token, an expired one, or a refused authorization
6
+ * 4 api — the server rejected a well-formed request
7
+ * 5 network — the server was never reached
8
+ * 130 cancelled — Ctrl+C, by the shell convention 128 + SIGINT
9
+ */
10
+ export declare const exitCode: {
11
+ readonly api: 4;
12
+ readonly auth: 3;
13
+ readonly cancelled: 130;
14
+ readonly network: 5;
15
+ readonly usage: 2;
16
+ };
17
+ /** HTTP status is separate from the process exit code. Snake_case fields preserve the old JSON contract. */
18
+ export type ErrorJson = {
19
+ code?: string | undefined;
20
+ error_code?: string | undefined;
21
+ errors?: unknown;
22
+ message: string;
23
+ status?: number | undefined;
24
+ status_code?: number | undefined;
25
+ };
26
+ /**
27
+ * oclif takes the exit code from two places: `handle()` reads `oclif.exit`, Command.catch under
28
+ * --json reads `exitCode` and never rethrows. Set one and the other mode exits 1.
29
+ */
30
+ export declare class CliError extends Errors.CLIError {
31
+ readonly exitCode: number;
32
+ readonly json: ErrorJson;
33
+ constructor(message: string, exit: number, code?: string, data?: Partial<ErrorJson>);
34
+ }
35
+ /**
36
+ * The one place where an sdk error gets a human text and an exit code. No default in the switch:
37
+ * a new kind fails to compile until it is mapped here.
38
+ */
39
+ export declare const toCliError: (error: unknown) => Error;
@@ -0,0 +1,92 @@
1
+ import { Errors } from '@oclif/core';
2
+ import { isSdkError } from '../sdk/core/errors.js';
3
+ /**
4
+ * Exit codes are the adapter's business: sdk errors carry none.
5
+ * 2 usage — the input is wrong (oclif's own parse errors exit 2 as well)
6
+ * 3 auth — no token, an expired one, or a refused authorization
7
+ * 4 api — the server rejected a well-formed request
8
+ * 5 network — the server was never reached
9
+ * 130 cancelled — Ctrl+C, by the shell convention 128 + SIGINT
10
+ */
11
+ export const exitCode = {
12
+ api: 4,
13
+ auth: 3,
14
+ cancelled: 130,
15
+ network: 5,
16
+ usage: 2,
17
+ };
18
+ /**
19
+ * oclif takes the exit code from two places: `handle()` reads `oclif.exit`, Command.catch under
20
+ * --json reads `exitCode` and never rethrows. Set one and the other mode exits 1.
21
+ */
22
+ export class CliError extends Errors.CLIError {
23
+ exitCode;
24
+ json;
25
+ constructor(message, exit, code, data = {}) {
26
+ super(message, { exit });
27
+ this.exitCode = exit;
28
+ this.code = code;
29
+ this.json = { message, code, ...data };
30
+ }
31
+ }
32
+ const cliError = (message, exit, code, data) => new CliError(message, exit, code, data);
33
+ /** Issue.path is a camelCase sdk field; the user typed a kebab-case flag. */
34
+ const flagName = (path) => `--${path.replace(/[A-Z]/g, char => `-${char.toLowerCase()}`)}`;
35
+ const describeIssue = (issue) => (issue.path === undefined ? issue.message : `${flagName(issue.path)}: ${issue.message}`);
36
+ /**
37
+ * The one place where an sdk error gets a human text and an exit code. No default in the switch:
38
+ * a new kind fails to compile until it is mapped here.
39
+ */
40
+ export const toCliError = (error) => {
41
+ if (!isSdkError(error)) {
42
+ return error instanceof Error ? error : new Error(String(error));
43
+ }
44
+ switch (error.kind) {
45
+ case 'api': {
46
+ // `http_<status>` is our own placeholder, not a code the user can look up
47
+ const code = error.code === undefined || error.code.startsWith('http_') ? undefined : error.code;
48
+ const jsonCode = error.code ?? `http_${error.status}`;
49
+ const fields = typeof error.details === 'object' && error.details !== null && 'errors' in error.details
50
+ ? error.details.errors
51
+ : undefined;
52
+ return cliError(error.message, exitCode.api, code, {
53
+ code: jsonCode,
54
+ error_code: jsonCode,
55
+ errors: fields,
56
+ status: error.status,
57
+ status_code: error.status,
58
+ });
59
+ }
60
+ case 'auth_required': {
61
+ return cliError(error.reason === 'missing'
62
+ ? 'Not authenticated. Run `adapty auth login`.'
63
+ : 'Token expired or invalid. Run `adapty auth login`.', exitCode.auth, undefined, { code: error.kind, status: error.reason === 'rejected' ? 401 : undefined });
64
+ }
65
+ case 'cancelled': {
66
+ return cliError('Cancelled.', exitCode.cancelled);
67
+ }
68
+ case 'device_flow_denied': {
69
+ return cliError('Authorization was denied. Run `adapty auth login` to try again.', exitCode.auth);
70
+ }
71
+ case 'device_flow_expired': {
72
+ return cliError('The code expired before authorization. Run `adapty auth login` to get a new one.', exitCode.auth);
73
+ }
74
+ case 'network': {
75
+ return cliError(`Could not reach ${error.url}. Check the connection and try again.`, exitCode.network, undefined, {
76
+ code: 'network_error',
77
+ error_code: 'network_error',
78
+ errors: { connection: [error.cause instanceof Error ? error.cause.message : error.message] },
79
+ status: 0,
80
+ status_code: 0,
81
+ });
82
+ }
83
+ case 'storage': {
84
+ return cliError(`${error.message}\nDelete the file and run \`adapty auth login\` again.`, exitCode.auth);
85
+ }
86
+ case 'validation': {
87
+ // A header plus one indented line per issue: a rule reports them all at once
88
+ const lines = error.issues.map(issue => describeIssue(issue));
89
+ return cliError(['Invalid input:', ...lines].join('\n '), exitCode.usage);
90
+ }
91
+ }
92
+ };
@@ -0,0 +1,16 @@
1
+ import type { PageParams } from '../sdk/adapty/index.js';
2
+ export declare const isUuid: (value: string) => boolean;
3
+ /** Spread into a command: `static args = { ...appIdArg }`. Texts kept as published. */
4
+ export declare const appIdArg: {
5
+ app_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ /** The published defaults, so a migrated `list` asks for the same page as an untouched one. */
8
+ export declare const paginationFlags: {
9
+ page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'page-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
11
+ };
12
+ /** The one place where flag names meet sdk field names. */
13
+ export declare const pageParams: (flags: {
14
+ "page": number;
15
+ "page-size": number;
16
+ }) => PageParams;
@@ -0,0 +1,27 @@
1
+ import { Args, Errors, Flags } from '@oclif/core';
2
+ import { exitCode } from './errors.js';
3
+ const UUID_PATTERN = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
4
+ export const isUuid = (value) => UUID_PATTERN.test(value);
5
+ /**
6
+ * Checking the shape of a value is the parser's job, so a run() never starts with one. oclif turns
7
+ * a *flag* parser's failure into exit 2 itself but passes an *arg* parser's error through, hence
8
+ * the explicit code. The hint is per resource: `adapty apps list` only helps for an app id.
9
+ */
10
+ const uuidParser = (hint) => (input) => (isUuid(input)
11
+ ? Promise.resolve(input)
12
+ : Promise.reject(new Errors.CLIError(hint, { exit: exitCode.usage })));
13
+ /** Spread into a command: `static args = { ...appIdArg }`. Texts kept as published. */
14
+ export const appIdArg = {
15
+ app_id: Args.string({
16
+ description: 'App ID (UUID)',
17
+ parse: uuidParser('Invalid app ID format. Run `adapty apps list` to find your app ID.'),
18
+ required: true,
19
+ }),
20
+ };
21
+ /** The published defaults, so a migrated `list` asks for the same page as an untouched one. */
22
+ export const paginationFlags = {
23
+ 'page': Flags.integer({ default: 1, description: 'Page number', min: 1 }),
24
+ 'page-size': Flags.integer({ default: 20, description: 'Items per page (max 100)', max: 100, min: 1 }),
25
+ };
26
+ /** The one place where flag names meet sdk field names. */
27
+ export const pageParams = (flags) => ({ page: flags.page, pageSize: flags['page-size'] });
@@ -0,0 +1,6 @@
1
+ import type { Paginated } from '../../sdk/adapty/index.js';
2
+ /**
3
+ * A page as the published CLI prints it: every item a labelled block, `---` between them, then a
4
+ * blank line and the pagination footer. Wraps src/lib the same way views/record.ts does.
5
+ */
6
+ export declare const renderPage: <T extends object>(page: Paginated<T>) => string;
@@ -0,0 +1,10 @@
1
+ import { printList } from '../../lib/output.js';
2
+ /**
3
+ * A page as the published CLI prints it: every item a labelled block, `---` between them, then a
4
+ * blank line and the pagination footer. Wraps src/lib the same way views/record.ts does.
5
+ */
6
+ export const renderPage = (page) => {
7
+ const lines = [];
8
+ printList(page.data, line => lines.push(line), page.meta.pagination);
9
+ return lines.join('\n');
10
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A server record as the published CLI prints it: snake_case keys as labels, nested objects
3
+ * indented, empty values dropped.
4
+ *
5
+ * The formatter still lives in src/lib and writes through a callback; this wraps it into the shape
6
+ * of a view (value in, string out), so commands do not depend on where it lives. The cast is that
7
+ * formatter's parameter type — it walks whatever it is given at runtime.
8
+ */
9
+ export declare const renderRecord: (record: object) => string;
@@ -0,0 +1,14 @@
1
+ import { printResponse } from '../../lib/output.js';
2
+ /**
3
+ * A server record as the published CLI prints it: snake_case keys as labels, nested objects
4
+ * indented, empty values dropped.
5
+ *
6
+ * The formatter still lives in src/lib and writes through a callback; this wraps it into the shape
7
+ * of a view (value in, string out), so commands do not depend on where it lives. The cast is that
8
+ * formatter's parameter type — it walks whatever it is given at runtime.
9
+ */
10
+ export const renderRecord = (record) => {
11
+ const lines = [];
12
+ printResponse(record, line => lines.push(line));
13
+ return lines.join('\n');
14
+ };
@@ -1,14 +1 @@
1
- import { Command } from '@oclif/core';
2
- import type { AppSummaryDTO } from '../../lib/api-schemas.js';
3
- export default class AppsCreate extends Command {
4
- static description: string;
5
- static enableJsonFlag: boolean;
6
- static examples: string[];
7
- static flags: {
8
- 'apple-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
- 'google-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
- platform: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
11
- title: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
- };
13
- run(): Promise<AppSummaryDTO>;
14
- }
1
+ export { default } from '../../cli/commands/apps/create.js';
@@ -1,57 +1,2 @@
1
- import { Command, Flags } from '@oclif/core';
2
- import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
- import { printResponse } from '../../lib/output.js';
4
- export default class AppsCreate extends Command {
5
- static description = 'Create a new Adapty app';
6
- static enableJsonFlag = true;
7
- static examples = [
8
- '<%= config.bin %> apps create --title "My App" --platform ios --apple-bundle-id com.example.app',
9
- '<%= config.bin %> apps create --title "My App" --platform ios --platform android --apple-bundle-id com.example.app --google-bundle-id com.example.app',
10
- ];
11
- static flags = {
12
- 'apple-bundle-id': Flags.string({ description: 'Apple bundle ID (required with --platform ios)' }),
13
- 'google-bundle-id': Flags.string({ description: 'Google bundle ID (required with --platform android)' }),
14
- 'platform': Flags.string({
15
- description: 'Platform (ios, android). Repeat for multiple.',
16
- multiple: true,
17
- options: ['ios', 'android'],
18
- required: true,
19
- }),
20
- 'title': Flags.string({ description: 'App title', required: true }),
21
- };
22
- async run() {
23
- const { flags } = await this.parse(AppsCreate);
24
- if (flags.platform.includes('ios') && !flags['apple-bundle-id']) {
25
- this.error('--apple-bundle-id is required when --platform ios is specified', { exit: 2 });
26
- }
27
- if (flags.platform.includes('android') && !flags['google-bundle-id']) {
28
- this.error('--google-bundle-id is required when --platform android is specified', { exit: 2 });
29
- }
30
- const client = await createAuthenticatedClient(this.config);
31
- const body = {
32
- platforms: flags.platform,
33
- title: flags.title,
34
- };
35
- if (flags['apple-bundle-id']) {
36
- body.apple_bundle_id = flags['apple-bundle-id'];
37
- }
38
- if (flags['google-bundle-id']) {
39
- body.google_bundle_id = flags['google-bundle-id'];
40
- }
41
- const result = await client.post('/apps', body);
42
- this.log('App created!');
43
- printResponse(result, this.log.bind(this));
44
- try {
45
- const accessLevels = await client.get(`/apps/${result.id}/access-levels`);
46
- const [defaultAccessLevel] = accessLevels.items ?? [];
47
- if (defaultAccessLevel) {
48
- this.log('\nDefault access level:');
49
- printResponse(defaultAccessLevel, this.log.bind(this));
50
- }
51
- }
52
- catch {
53
- this.warn('Could not fetch access levels for new app');
54
- }
55
- return result;
56
- }
57
- }
1
+ // Implementation lives in the new cli layer; oclif discovers commands only under src/commands.
2
+ export { default } from '../../cli/commands/apps/create.js';
@@ -1,11 +1 @@
1
- import { Command } from '@oclif/core';
2
- import type { AppDetailDTO } from '../../lib/api-schemas.js';
3
- export default class AppsGet extends Command {
4
- static args: {
5
- app_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
- };
7
- static description: string;
8
- static enableJsonFlag: boolean;
9
- static examples: string[];
10
- run(): Promise<AppDetailDTO>;
11
- }
1
+ export { default } from '../../cli/commands/apps/get.js';
@@ -1,22 +1,2 @@
1
- import { Args, Command } from '@oclif/core';
2
- import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
- import { isValidUuid } from '../../lib/flags.js';
4
- import { printResponse } from '../../lib/output.js';
5
- export default class AppsGet extends Command {
6
- static args = {
7
- app_id: Args.string({ description: 'App ID (UUID)', required: true }),
8
- };
9
- static description = 'Get app details';
10
- static enableJsonFlag = true;
11
- static examples = ['<%= config.bin %> apps get 550e8400-e29b-41d4-a716-446655440000'];
12
- async run() {
13
- const { args } = await this.parse(AppsGet);
14
- if (!isValidUuid(args.app_id)) {
15
- this.error('Invalid app ID format. Run `adapty apps list` to find your app ID.', { exit: 2 });
16
- }
17
- const client = await createAuthenticatedClient(this.config);
18
- const result = await client.get(`/apps/${args.app_id}`);
19
- printResponse(result, this.log.bind(this));
20
- return result;
21
- }
22
- }
1
+ // Implementation lives in the new cli layer; oclif discovers commands only under src/commands.
2
+ export { default } from '../../cli/commands/apps/get.js';
@@ -1,13 +1 @@
1
- import { Command } from '@oclif/core';
2
- import type { AppSummaryDTO } from '../../lib/api-schemas.js';
3
- import type { PaginatedResponse } from '../../lib/flags.js';
4
- export default class AppsList extends Command {
5
- static description: string;
6
- static enableJsonFlag: boolean;
7
- static examples: string[];
8
- static flags: {
9
- page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
10
- 'page-size': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
11
- };
12
- run(): Promise<PaginatedResponse<AppSummaryDTO>>;
13
- }
1
+ export { default } from '../../cli/commands/apps/list.js';
@@ -1,19 +1,2 @@
1
- import { Command } from '@oclif/core';
2
- import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
- import { paginationFlags, paginationParams } from '../../lib/flags.js';
4
- import { printList } from '../../lib/output.js';
5
- export default class AppsList extends Command {
6
- static description = 'List Adapty apps';
7
- static enableJsonFlag = true;
8
- static examples = ['<%= config.bin %> apps list', '<%= config.bin %> apps list --page 2 --page-size 10'];
9
- static flags = {
10
- ...paginationFlags,
11
- };
12
- async run() {
13
- const { flags } = await this.parse(AppsList);
14
- const client = await createAuthenticatedClient(this.config);
15
- const result = await client.get('/apps', paginationParams(flags));
16
- printList(result.data, this.log.bind(this), result.meta.pagination);
17
- return result;
18
- }
19
- }
1
+ // Implementation lives in the new cli layer; oclif discovers commands only under src/commands.
2
+ export { default } from '../../cli/commands/apps/list.js';
@@ -1,16 +1 @@
1
- import { Command } from '@oclif/core';
2
- import type { AppDetailDTO } from '../../lib/api-schemas.js';
3
- export default class AppsUpdate extends Command {
4
- static args: {
5
- app_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
- };
7
- static description: string;
8
- static enableJsonFlag: boolean;
9
- static examples: string[];
10
- static flags: {
11
- 'apple-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- 'google-bundle-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
- title: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
- };
15
- run(): Promise<AppDetailDTO>;
16
- }
1
+ export { default } from '../../cli/commands/apps/update.js';
@@ -1,41 +1,2 @@
1
- import { Args, Command, Flags } from '@oclif/core';
2
- import { createAuthenticatedClient } from '../../lib/client-from-config.js';
3
- import { isValidUuid } from '../../lib/flags.js';
4
- import { printResponse } from '../../lib/output.js';
5
- export default class AppsUpdate extends Command {
6
- static args = {
7
- app_id: Args.string({ description: 'App ID (UUID)', required: true }),
8
- };
9
- static description = 'Update an app';
10
- static enableJsonFlag = true;
11
- static examples = ['<%= config.bin %> apps update 550e8400-... --title "My App"'];
12
- static flags = {
13
- 'apple-bundle-id': Flags.string({ description: 'Apple bundle ID' }),
14
- 'google-bundle-id': Flags.string({ description: 'Google bundle ID' }),
15
- 'title': Flags.string({ description: 'App title' }),
16
- };
17
- async run() {
18
- const { args, flags } = await this.parse(AppsUpdate);
19
- if (!isValidUuid(args.app_id)) {
20
- this.error('Invalid app ID format. Run `adapty apps list` to find your app ID.', { exit: 2 });
21
- }
22
- if (!flags.title && !flags['apple-bundle-id'] && !flags['google-bundle-id']) {
23
- this.error('At least one of --title, --apple-bundle-id, or --google-bundle-id is required', { exit: 2 });
24
- }
25
- const client = await createAuthenticatedClient(this.config);
26
- const body = {};
27
- if (flags.title) {
28
- body.title = flags.title;
29
- }
30
- if (flags['apple-bundle-id']) {
31
- body.apple_bundle_id = flags['apple-bundle-id'];
32
- }
33
- if (flags['google-bundle-id']) {
34
- body.google_bundle_id = flags['google-bundle-id'];
35
- }
36
- const result = await client.put(`/apps/${args.app_id}`, body);
37
- this.log('App updated!');
38
- printResponse(result, this.log.bind(this));
39
- return result;
40
- }
41
- }
1
+ // Implementation lives in the new cli layer; oclif discovers commands only under src/commands.
2
+ export { default } from '../../cli/commands/apps/update.js';
@@ -19,8 +19,12 @@ grouped page may project to before it is refused.`;
19
19
  this.log('\nApple Ads is not connected. Run `adapty asa connect` to link an account.');
20
20
  }
21
21
  if (result.access_source === 'none') {
22
- this.log('\nNo active Ads Manager subscription for this company: connecting an account works, but every');
23
- 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.');
24
28
  }
25
29
  return result;
26
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';