apify-client 3.0.0-beta.1 → 3.0.0-beta.10

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 (94) hide show
  1. package/README.md +5 -3
  2. package/dist/apify_api_error.d.ts +59 -3
  3. package/dist/apify_api_error.js +71 -11
  4. package/dist/apify_client.d.ts +27 -27
  5. package/dist/apify_client.js +86 -91
  6. package/dist/base/api_client.d.ts +3 -3
  7. package/dist/base/api_client.js +6 -10
  8. package/dist/base/resource_client.d.ts +5 -4
  9. package/dist/base/resource_client.js +17 -21
  10. package/dist/base/resource_collection_client.d.ts +7 -6
  11. package/dist/base/resource_collection_client.js +11 -15
  12. package/dist/body_parser.js +6 -11
  13. package/dist/bundle.js +38 -48
  14. package/dist/bundle.js.map +1 -1
  15. package/dist/generated/api.d.ts +287 -214
  16. package/dist/generated/api.js +1 -2
  17. package/dist/generated/schemas.d.ts +6699 -0
  18. package/dist/generated/schemas.js +1521 -0
  19. package/dist/http_client.d.ts +2 -2
  20. package/dist/http_client.js +23 -28
  21. package/dist/index.d.ts +33 -32
  22. package/dist/index.js +32 -36
  23. package/dist/interceptors.d.ts +1 -1
  24. package/dist/interceptors.js +14 -19
  25. package/dist/lazy_schema.d.ts +8 -0
  26. package/dist/lazy_schema.js +11 -0
  27. package/dist/models.d.ts +33 -52
  28. package/dist/models.js +8 -11
  29. package/dist/resource_clients/actor.d.ts +13 -13
  30. package/dist/resource_clients/actor.js +70 -73
  31. package/dist/resource_clients/actor_collection.d.ts +10 -10
  32. package/dist/resource_clients/actor_collection.js +19 -20
  33. package/dist/resource_clients/actor_env_var.d.ts +3 -3
  34. package/dist/resource_clients/actor_env_var.js +7 -10
  35. package/dist/resource_clients/actor_env_var_collection.d.ts +11 -20
  36. package/dist/resource_clients/actor_env_var_collection.js +15 -19
  37. package/dist/resource_clients/actor_version.d.ts +16 -8
  38. package/dist/resource_clients/actor_version.js +15 -19
  39. package/dist/resource_clients/actor_version_collection.d.ts +13 -19
  40. package/dist/resource_clients/actor_version_collection.js +17 -19
  41. package/dist/resource_clients/build.d.ts +5 -5
  42. package/dist/resource_clients/build.js +14 -17
  43. package/dist/resource_clients/build_collection.d.ts +5 -5
  44. package/dist/resource_clients/build_collection.js +10 -13
  45. package/dist/resource_clients/dataset.d.ts +6 -6
  46. package/dist/resource_clients/dataset.js +73 -76
  47. package/dist/resource_clients/dataset_collection.d.ts +4 -4
  48. package/dist/resource_clients/dataset_collection.js +18 -21
  49. package/dist/resource_clients/key_value_store.d.ts +16 -8
  50. package/dist/resource_clients/key_value_store.js +61 -65
  51. package/dist/resource_clients/key_value_store_collection.d.ts +4 -4
  52. package/dist/resource_clients/key_value_store_collection.js +18 -21
  53. package/dist/resource_clients/log.d.ts +2 -2
  54. package/dist/resource_clients/log.js +15 -22
  55. package/dist/resource_clients/request_queue.d.ts +4 -11
  56. package/dist/resource_clients/request_queue.js +100 -106
  57. package/dist/resource_clients/request_queue_collection.d.ts +4 -4
  58. package/dist/resource_clients/request_queue_collection.js +16 -19
  59. package/dist/resource_clients/run.d.ts +8 -8
  60. package/dist/resource_clients/run.js +50 -53
  61. package/dist/resource_clients/run_collection.d.ts +4 -4
  62. package/dist/resource_clients/run_collection.js +15 -18
  63. package/dist/resource_clients/schedule.d.ts +8 -8
  64. package/dist/resource_clients/schedule.js +13 -15
  65. package/dist/resource_clients/schedule_collection.d.ts +4 -4
  66. package/dist/resource_clients/schedule_collection.js +13 -16
  67. package/dist/resource_clients/store_collection.d.ts +5 -5
  68. package/dist/resource_clients/store_collection.js +15 -18
  69. package/dist/resource_clients/task.d.ts +9 -9
  70. package/dist/resource_clients/task.js +47 -50
  71. package/dist/resource_clients/task_collection.d.ts +6 -6
  72. package/dist/resource_clients/task_collection.js +12 -15
  73. package/dist/resource_clients/user.d.ts +5 -5
  74. package/dist/resource_clients/user.js +11 -16
  75. package/dist/resource_clients/webhook.d.ts +6 -6
  76. package/dist/resource_clients/webhook.js +11 -14
  77. package/dist/resource_clients/webhook_collection.d.ts +4 -4
  78. package/dist/resource_clients/webhook_collection.js +13 -16
  79. package/dist/resource_clients/webhook_dispatch.d.ts +5 -5
  80. package/dist/resource_clients/webhook_dispatch.js +5 -9
  81. package/dist/resource_clients/webhook_dispatch_collection.d.ts +4 -4
  82. package/dist/resource_clients/webhook_dispatch_collection.js +10 -13
  83. package/dist/response_validation_error.d.ts +26 -0
  84. package/dist/response_validation_error.js +37 -0
  85. package/dist/schemas.d.ts +15 -0
  86. package/dist/schemas.js +15 -0
  87. package/dist/statistics.js +5 -9
  88. package/dist/timezones.js +1 -2
  89. package/dist/utils.d.ts +19 -24
  90. package/dist/utils.js +57 -93
  91. package/package.json +38 -40
  92. package/dist/argument_validation_error.d.ts +0 -17
  93. package/dist/argument_validation_error.js +0 -157
  94. package/dist/index.mjs +0 -42
@@ -1,157 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArgumentValidationError = void 0;
4
- /** Formats a zod issue path like `groups[0]` or `countryCode`. */
5
- function formatIssuePath(path) {
6
- let out = '';
7
- for (const key of path) {
8
- if (typeof key === 'number')
9
- out += `[${key}]`;
10
- else
11
- out += out ? `.${String(key)}` : String(key);
12
- }
13
- return out;
14
- }
15
- /** Reads the value at `path` from the validated input, to include in the error. */
16
- function valueAtPath(root, path) {
17
- let current = root;
18
- for (const key of path) {
19
- if (current === null || typeof current !== 'object')
20
- return undefined;
21
- current = current[key];
22
- }
23
- return current;
24
- }
25
- /**
26
- * How much of a received string the message renders. A rejected argument can be arbitrarily large - a
27
- * whole JSON payload passed where an object was expected - and its full text would swamp the message.
28
- */
29
- const MAX_RECEIVED_STRING_LENGTH = 80;
30
- /** Renders a primitive received value for an error; skips objects/Dates (noisy). */
31
- function describeReceived(value) {
32
- switch (typeof value) {
33
- case 'string':
34
- // An empty string would render as bare backticks - make it visible.
35
- if (value === '')
36
- return "''";
37
- return value.length > MAX_RECEIVED_STRING_LENGTH
38
- ? `${value.slice(0, MAX_RECEIVED_STRING_LENGTH)}...`
39
- : value;
40
- case 'number':
41
- case 'boolean':
42
- return String(value);
43
- case 'bigint':
44
- // Keep the `n` suffix, so a rejected bigint is not mistaken for a number.
45
- return `${value}n`;
46
- default:
47
- return undefined;
48
- }
49
- }
50
- /**
51
- * Renders the issue's own sentence, except where zod's contradicts itself: a value of the expected type
52
- * that fails that type's implicit constraint is still reported as the wrong *type*, giving "expected
53
- * number, received number" for `Infinity` / `NaN` and "expected date, received Date" for an invalid
54
- * `Date`. Name the constraint that actually failed instead.
55
- */
56
- function describeIssue(issue, value) {
57
- if (issue.code === 'invalid_type') {
58
- if (issue.expected === 'number' && typeof value === 'number') {
59
- return 'Invalid input: expected a finite number';
60
- }
61
- // A tag check, not `instanceof`, so a `Date` from another realm is named too.
62
- if (issue.expected === 'date' && Object.prototype.toString.call(value) === '[object Date]') {
63
- return 'Invalid input: expected a valid date';
64
- }
65
- }
66
- return issue.message;
67
- }
68
- /**
69
- * How many issue lines the message renders, before a closing "... and N more" line. Validating a
70
- * large array - a dataset push, a request batch - can fail on every element, and rendering all of
71
- * them would make the message megabytes long. The full set stays on `issues` either way.
72
- */
73
- const MAX_RENDERED_LINES = 10;
74
- /**
75
- * How deep into the value the lines for `issue` would sit, as a path length. Computed without
76
- * rendering anything, so a union can weigh its arms before any string is built.
77
- */
78
- function deepestIssueDepth(issue, baseDepth) {
79
- const depth = baseDepth + issue.path.length;
80
- if (issue.code === 'invalid_union') {
81
- let deepest = -1;
82
- for (const arm of issue.errors) {
83
- for (const nested of arm)
84
- deepest = Math.max(deepest, deepestIssueDepth(nested, depth));
85
- }
86
- return deepest;
87
- }
88
- return depth;
89
- }
90
- /** Collects one line per issue into `lines`; a union expands into a line per deepest-failing arm. */
91
- function collectIssueLines(issue, root, basePath, lines, counter) {
92
- const path = [...basePath, ...issue.path];
93
- // A union's own message is a bare "Invalid input" - the useful part is in `errors`,
94
- // whose paths are relative to the union, hence passing `path` down as the base.
95
- if (issue.code === 'invalid_union') {
96
- // Only the arms that reached deepest are reported. An arm that failed nearer the root rejected a
97
- // shape the value never had - for `[{ ok: 1 }, 2]` against `object | string | array`, the object
98
- // and string arms fail on the whole array, and only the array arm can point at `[1]`. When every
99
- // arm fails at the same depth, as for an argument of an outright wrong type, they are all kept.
100
- const armDepths = issue.errors.map((arm) => arm.reduce((deepest, nested) => Math.max(deepest, deepestIssueDepth(nested, path.length)), -1));
101
- const deepest = Math.max(...armDepths);
102
- for (const [index, arm] of issue.errors.entries()) {
103
- if (armDepths[index] !== deepest)
104
- continue;
105
- for (const nested of arm)
106
- collectIssueLines(nested, root, path, lines, counter);
107
- }
108
- return;
109
- }
110
- counter.total += 1;
111
- if (lines.length >= MAX_RENDERED_LINES)
112
- return;
113
- const location = path.length ? ` at \`${formatIssuePath(path)}\`` : '';
114
- const value = valueAtPath(root, path);
115
- const received = describeReceived(value);
116
- const got = received === undefined ? '' : `, got \`${received}\``;
117
- lines.push(`${describeIssue(issue, value)}${location}${got}`);
118
- }
119
- /**
120
- * Formats a `ZodError` as a plain, human-readable message that names the
121
- * offending field *and* the value it received (e.g. ``must match pattern
122
- * /^[A-Z]{2}$/ at `countryCode`, got `CZE` ``) - closer to the old `ow` errors
123
- * than zod's default, which omits the received value.
124
- */
125
- function formatZodError(error, root, label) {
126
- const lines = [];
127
- const counter = { total: 0 };
128
- for (const issue of error.issues)
129
- collectIssueLines(issue, root, [], lines, counter);
130
- // The label names the validated interface, the way ow's errors ended with "in object `X`".
131
- const rendered = label ? lines.map((line) => `${line} in \`${label}\``) : [...lines];
132
- const hidden = counter.total - lines.length;
133
- if (hidden > 0)
134
- rendered.push(`... and ${hidden} more problem${hidden === 1 ? '' : 's'}`);
135
- return rendered.join('\n');
136
- }
137
- /**
138
- * Thrown when an argument fails schema validation.
139
- *
140
- * Its `message` is a human-readable sentence naming the offending field and the
141
- * value it received (rather than a raw JSON dump). The structured
142
- * {@link https://zod.dev | zod} issues are available on `issues`, and the
143
- * original `ZodError` on `cause`, for programmatic inspection.
144
- *
145
- * `apify-client` sits below `@crawlee/core` and the Apify SDK in the dependency
146
- * graph, so it defines its own error type rather than importing one from them.
147
- */
148
- class ArgumentValidationError extends Error {
149
- /** Structured issues from the underlying schema check. */
150
- issues;
151
- constructor(error, value, label) {
152
- super(formatZodError(error, value, label), { cause: error });
153
- this.name = 'ArgumentValidationError';
154
- this.issues = error.issues;
155
- }
156
- }
157
- exports.ArgumentValidationError = ArgumentValidationError;
package/dist/index.mjs DELETED
@@ -1,42 +0,0 @@
1
- import mod from "./index.js";
2
-
3
- export default mod;
4
- export const ActorClient = mod.ActorClient;
5
- export const ActorCollectionClient = mod.ActorCollectionClient;
6
- export const ActorEnvVarClient = mod.ActorEnvVarClient;
7
- export const ActorEnvVarCollectionClient = mod.ActorEnvVarCollectionClient;
8
- export const ActorListSortBy = mod.ActorListSortBy;
9
- export const ActorSourceType = mod.ActorSourceType;
10
- export const ActorVersionClient = mod.ActorVersionClient;
11
- export const ActorVersionCollectionClient = mod.ActorVersionCollectionClient;
12
- export const ApifyApiError = mod.ApifyApiError;
13
- export const ApifyClient = mod.ApifyClient;
14
- export const ArgumentValidationError = mod.ArgumentValidationError;
15
- export const BuildClient = mod.BuildClient;
16
- export const BuildCollectionClient = mod.BuildCollectionClient;
17
- export const DatasetClient = mod.DatasetClient;
18
- export const DatasetCollectionClient = mod.DatasetCollectionClient;
19
- export const DownloadItemsFormat = mod.DownloadItemsFormat;
20
- export const InvalidResponseBodyError = mod.InvalidResponseBodyError;
21
- export const KeyValueStoreClient = mod.KeyValueStoreClient;
22
- export const KeyValueStoreCollectionClient = mod.KeyValueStoreCollectionClient;
23
- export const LogClient = mod.LogClient;
24
- export const LoggerActorRedirect = mod.LoggerActorRedirect;
25
- export const PlatformFeature = mod.PlatformFeature;
26
- export const RequestQueueClient = mod.RequestQueueClient;
27
- export const RequestQueueCollectionClient = mod.RequestQueueCollectionClient;
28
- export const RunClient = mod.RunClient;
29
- export const RunCollectionClient = mod.RunCollectionClient;
30
- export const ScheduleActions = mod.ScheduleActions;
31
- export const ScheduleClient = mod.ScheduleClient;
32
- export const ScheduleCollectionClient = mod.ScheduleCollectionClient;
33
- export const StoreCollectionClient = mod.StoreCollectionClient;
34
- export const StreamedLog = mod.StreamedLog;
35
- export const TaskClient = mod.TaskClient;
36
- export const TaskCollectionClient = mod.TaskCollectionClient;
37
- export const UserClient = mod.UserClient;
38
- export const WebhookClient = mod.WebhookClient;
39
- export const WebhookCollectionClient = mod.WebhookCollectionClient;
40
- export const WebhookDispatchClient = mod.WebhookDispatchClient;
41
- export const WebhookDispatchCollectionClient = mod.WebhookDispatchCollectionClient;
42
- export const WebhookDispatchStatus = mod.WebhookDispatchStatus;