adapty 0.8.6 → 0.8.8

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 (89) hide show
  1. package/README.md +31 -2
  2. package/dist/cli/base/adapty/adapty-command.d.ts +1 -4
  3. package/dist/cli/base/adapty/build.d.ts +2 -8
  4. package/dist/cli/base/adapty/index.d.ts +2 -3
  5. package/dist/cli/base/adapty/index.js +1 -1
  6. package/dist/cli/base/adapty/openSession.d.ts +2 -19
  7. package/dist/cli/base/adapty/openSession.js +6 -16
  8. package/dist/cli/base/attribution/attribution-command.d.ts +16 -0
  9. package/dist/cli/base/attribution/attribution-command.js +42 -0
  10. package/dist/cli/base/attribution/build.d.ts +5 -0
  11. package/dist/cli/base/attribution/build.js +12 -0
  12. package/dist/cli/base/attribution/flags.d.ts +16 -0
  13. package/dist/cli/base/attribution/flags.js +28 -0
  14. package/dist/cli/base/attribution/index.d.ts +4 -0
  15. package/dist/cli/base/attribution/index.js +4 -0
  16. package/dist/cli/base/attribution/openSession.d.ts +9 -0
  17. package/dist/cli/base/attribution/openSession.js +19 -0
  18. package/dist/cli/base/base-command.d.ts +7 -0
  19. package/dist/cli/base/session.d.ts +30 -0
  20. package/dist/cli/base/session.js +20 -0
  21. package/dist/cli/commands/attribution/dimensions.d.ts +7 -0
  22. package/dist/cli/commands/attribution/dimensions.js +18 -0
  23. package/dist/cli/commands/attribution/metrics.d.ts +7 -0
  24. package/dist/cli/commands/attribution/metrics.js +35 -0
  25. package/dist/cli/commands/attribution/report/index.d.ts +18 -0
  26. package/dist/cli/commands/attribution/report/index.js +93 -0
  27. package/dist/cli/commands/attribution/report/lib/render.d.ts +3 -0
  28. package/dist/cli/commands/attribution/report/lib/render.js +24 -0
  29. package/dist/cli/commands/attribution/values.d.ts +14 -0
  30. package/dist/cli/commands/attribution/values.js +44 -0
  31. package/dist/cli/errors.d.ts +12 -0
  32. package/dist/cli/errors.js +16 -0
  33. package/dist/cli/flags.d.ts +4 -0
  34. package/dist/cli/flags.js +14 -4
  35. package/dist/commands/access-levels/create.js +2 -2
  36. package/dist/commands/access-levels/get.js +3 -2
  37. package/dist/commands/access-levels/list.js +3 -2
  38. package/dist/commands/access-levels/update.js +3 -2
  39. package/dist/commands/asa/keywords/recommend.d.ts +20 -0
  40. package/dist/commands/asa/keywords/recommend.js +102 -0
  41. package/dist/commands/attribution/dimensions.d.ts +1 -0
  42. package/dist/commands/attribution/dimensions.js +2 -0
  43. package/dist/commands/attribution/metrics.d.ts +1 -0
  44. package/dist/commands/attribution/metrics.js +2 -0
  45. package/dist/commands/attribution/report.d.ts +1 -0
  46. package/dist/commands/attribution/report.js +2 -0
  47. package/dist/commands/attribution/values.d.ts +1 -0
  48. package/dist/commands/attribution/values.js +2 -0
  49. package/dist/commands/flows/config/get.js +3 -2
  50. package/dist/commands/flows/config/update.js +3 -2
  51. package/dist/commands/flows/config/validate.js +3 -2
  52. package/dist/commands/flows/create.js +2 -2
  53. package/dist/commands/flows/get.js +3 -2
  54. package/dist/commands/flows/list.js +3 -2
  55. package/dist/commands/flows/media/upload.js +2 -2
  56. package/dist/commands/flows/publish.js +3 -2
  57. package/dist/commands/flows/update.js +3 -2
  58. package/dist/commands/paywalls/create.js +2 -2
  59. package/dist/commands/paywalls/get.js +3 -2
  60. package/dist/commands/paywalls/list.js +3 -2
  61. package/dist/commands/paywalls/placements.js +3 -2
  62. package/dist/commands/paywalls/update.js +3 -2
  63. package/dist/commands/placements/create.js +2 -2
  64. package/dist/commands/placements/get.js +3 -2
  65. package/dist/commands/placements/list.js +3 -2
  66. package/dist/commands/placements/update.js +3 -2
  67. package/dist/commands/products/create.js +2 -2
  68. package/dist/commands/products/get.js +3 -2
  69. package/dist/commands/products/list.js +3 -2
  70. package/dist/commands/products/update.js +3 -2
  71. package/dist/commands/segments/get.js +3 -2
  72. package/dist/commands/segments/list.js +3 -2
  73. package/dist/lib/asa-schemas.d.ts +40 -0
  74. package/dist/lib/flags.d.ts +0 -3
  75. package/dist/lib/flags.js +0 -13
  76. package/dist/sdk/attribution/catalog.d.ts +51 -0
  77. package/dist/sdk/attribution/catalog.js +6 -0
  78. package/dist/sdk/attribution/errors.d.ts +10 -0
  79. package/dist/sdk/attribution/errors.js +43 -0
  80. package/dist/sdk/attribution/index.d.ts +30 -0
  81. package/dist/sdk/attribution/index.js +33 -0
  82. package/dist/sdk/attribution/report.d.ts +75 -0
  83. package/dist/sdk/attribution/report.js +81 -0
  84. package/dist/sdk/attribution/resource.d.ts +30 -0
  85. package/dist/sdk/attribution/resource.js +51 -0
  86. package/dist/sdk/attribution/values.d.ts +39 -0
  87. package/dist/sdk/attribution/values.js +21 -0
  88. package/oclif.manifest.json +1024 -692
  89. package/package.json +4 -1
@@ -0,0 +1,51 @@
1
+ import { ApiError } from '../core/errors.js';
2
+ import { assertValid } from '../core/validation.js';
3
+ import { toReportRequest, validateReport } from './report.js';
4
+ import { toValuesRequest, validateValues } from './values.js';
5
+ const isEnvelope = (body) => {
6
+ if (typeof body !== 'object' || body === null) {
7
+ return false;
8
+ }
9
+ const { data, success } = body;
10
+ return success === true && typeof data === 'object' && data !== null;
11
+ };
12
+ /**
13
+ * The transport hands back whatever a success body parsed to, and a proxy's HTML page parses to a
14
+ * string. Passed on, it would print under --json and exit 0, so a success without this service's
15
+ * envelope is an error: the counterpart of the legacy client's `malformed_response`.
16
+ */
17
+ const envelope = async (pending) => {
18
+ const body = await pending;
19
+ if (!isEnvelope(body)) {
20
+ throw new ApiError({
21
+ code: 'malformed_response',
22
+ details: body,
23
+ message: 'The attribution service answered with a success status but not with its response envelope, '
24
+ + 'so the answer was cut short or came from something in between. Nothing was read.',
25
+ // The transport keeps the status of an error only, and this service answers every success with 200
26
+ status: 200,
27
+ });
28
+ }
29
+ return body;
30
+ };
31
+ /**
32
+ * Every path of the attribution backend in one place. The catalog reads are GETs and keep the
33
+ * transport's retry. Report and values are POSTs that run analytics queries: sent once, never
34
+ * retried, so a busy or unavailable backend is not asked to run the same expensive query again —
35
+ * the ApiError carries the server's Retry-After for the caller to decide.
36
+ *
37
+ * The validating methods are async on purpose — a broken rule then arrives as a rejected promise,
38
+ * like a network failure, and one await covers both.
39
+ */
40
+ export const attribution = (http) => ({
41
+ dimensions: () => envelope(http.get('/dimensions')),
42
+ metrics: () => envelope(http.get('/metrics')),
43
+ report: async (input) => {
44
+ assertValid(validateReport(input));
45
+ return envelope(http.post('/report', toReportRequest(input), { idempotent: false }));
46
+ },
47
+ values: async (input) => {
48
+ assertValid(validateValues(input));
49
+ return envelope(http.post('/values', toValuesRequest(input), { idempotent: false }));
50
+ },
51
+ });
@@ -0,0 +1,39 @@
1
+ import type { RevenueBasis } from './report.js';
2
+ import type { Issue } from '../core/errors.js';
3
+ /** The values a dimension takes over a day range: what a report filter can be given. */
4
+ export type ValuesInput = {
5
+ appId: string;
6
+ dateFrom: string;
7
+ dateTo: string;
8
+ dimension: string;
9
+ revenueBasis?: RevenueBasis | undefined;
10
+ };
11
+ type ValuesRequest = {
12
+ app_id: string;
13
+ date_from: string;
14
+ date_to: string;
15
+ dimension: string;
16
+ revenue_basis?: RevenueBasis;
17
+ };
18
+ /** An item of a dimension whose catalog identity is `value`. */
19
+ export type ValuesItemByValue = {
20
+ /** null for rows the backend could not attribute to any value. */
21
+ value: null | string;
22
+ };
23
+ /** An item of a dimension whose catalog identity is `id`: an entity of one ad network. */
24
+ export type ValuesItemById = {
25
+ channel: null | string;
26
+ id: null | string;
27
+ name: null | string;
28
+ };
29
+ export type ValuesData = {
30
+ dimension: string;
31
+ items: (ValuesItemById | ValuesItemByValue)[];
32
+ };
33
+ export type ValuesMeta = {
34
+ query: Record<string, unknown>;
35
+ };
36
+ /** Whether the dimension exists is the catalog's knowledge, so the backend checks that. */
37
+ export declare const validateValues: (input: ValuesInput) => Issue[];
38
+ export declare const toValuesRequest: (input: ValuesInput) => ValuesRequest;
39
+ export {};
@@ -0,0 +1,21 @@
1
+ import { validateDateRange } from './report.js';
2
+ /** Whether the dimension exists is the catalog's knowledge, so the backend checks that. */
3
+ export const validateValues = (input) => {
4
+ const issues = validateDateRange(input);
5
+ if (input.dimension.trim() === '') {
6
+ issues.push({ message: 'must not be empty', path: 'dimension' });
7
+ }
8
+ return issues;
9
+ };
10
+ export const toValuesRequest = (input) => {
11
+ const body = {
12
+ app_id: input.appId,
13
+ date_from: input.dateFrom,
14
+ date_to: input.dateTo,
15
+ dimension: input.dimension,
16
+ };
17
+ if (input.revenueBasis !== undefined) {
18
+ body.revenue_basis = input.revenueBasis;
19
+ }
20
+ return body;
21
+ };