@markupai/api 0.3.0 → 1.1.0

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 (91) hide show
  1. package/README.md +18 -1
  2. package/dist/cjs/Client.js +2 -2
  3. package/dist/cjs/api/errors/TooManyRequestsError.d.ts +9 -0
  4. package/dist/cjs/api/errors/TooManyRequestsError.js +52 -0
  5. package/dist/cjs/api/errors/index.d.ts +1 -0
  6. package/dist/cjs/api/errors/index.js +1 -0
  7. package/dist/cjs/api/resources/styleChecks/client/Client.d.ts +3 -2
  8. package/dist/cjs/api/resources/styleChecks/client/Client.js +5 -2
  9. package/dist/cjs/api/resources/{styleSuggestions/client/requests/CreateStyleSuggestionV1StyleSuggestionsPostRequest.d.ts → styleChecks/client/requests/StyleCheckRequestBody.d.ts} +4 -4
  10. package/dist/cjs/api/resources/styleChecks/client/requests/index.d.ts +1 -1
  11. package/dist/cjs/api/resources/styleGuides/client/Client.js +3 -0
  12. package/dist/cjs/api/resources/styleGuides/client/requests/StyleGuideRequestBody.d.ts +3 -0
  13. package/dist/cjs/api/resources/styleRewrites/client/Client.d.ts +3 -2
  14. package/dist/cjs/api/resources/styleRewrites/client/Client.js +5 -2
  15. package/dist/cjs/api/resources/{styleChecks/client/requests/CreateStyleCheckV1StyleChecksPostRequest.d.ts → styleRewrites/client/requests/StyleRewriteRequestBody.d.ts} +4 -4
  16. package/dist/cjs/api/resources/styleRewrites/client/requests/index.d.ts +1 -1
  17. package/dist/cjs/api/resources/styleSuggestions/client/Client.d.ts +3 -2
  18. package/dist/cjs/api/resources/styleSuggestions/client/Client.js +5 -2
  19. package/dist/cjs/api/resources/{styleRewrites/client/requests/CreateStyleRewriteV1StyleRewritesPostRequest.d.ts → styleSuggestions/client/requests/StyleSuggestionRequestBody.d.ts} +4 -4
  20. package/dist/cjs/api/resources/styleSuggestions/client/requests/index.d.ts +1 -1
  21. package/dist/cjs/api/types/BaseStyleGuideType.d.ts +9 -0
  22. package/dist/cjs/api/types/BaseStyleGuideType.js +11 -0
  23. package/dist/cjs/api/types/StyleGuideResponse.d.ts +3 -1
  24. package/dist/cjs/api/types/StyleGuides.d.ts +1 -2
  25. package/dist/cjs/api/types/StyleGuides.js +0 -1
  26. package/dist/cjs/api/types/WorkflowInfo.d.ts +2 -0
  27. package/dist/cjs/api/types/index.d.ts +1 -0
  28. package/dist/cjs/api/types/index.js +1 -0
  29. package/dist/cjs/core/auth/index.d.ts +2 -2
  30. package/dist/cjs/core/fetcher/EndpointMetadata.d.ts +13 -0
  31. package/dist/cjs/core/fetcher/EndpointMetadata.js +2 -0
  32. package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +12 -0
  33. package/dist/cjs/core/fetcher/EndpointSupplier.js +22 -0
  34. package/dist/cjs/core/fetcher/Fetcher.d.ts +4 -2
  35. package/dist/cjs/core/fetcher/Fetcher.js +3 -2
  36. package/dist/cjs/core/fetcher/index.d.ts +2 -0
  37. package/dist/cjs/core/fetcher/index.js +3 -1
  38. package/dist/cjs/core/fetcher/requestWithRetries.js +44 -8
  39. package/dist/cjs/core/file/exports.d.ts +1 -1
  40. package/dist/cjs/core/headers.d.ts +2 -3
  41. package/dist/cjs/version.d.ts +1 -1
  42. package/dist/cjs/version.js +1 -1
  43. package/dist/esm/Client.mjs +2 -2
  44. package/dist/esm/api/errors/TooManyRequestsError.d.mts +9 -0
  45. package/dist/esm/api/errors/TooManyRequestsError.mjs +15 -0
  46. package/dist/esm/api/errors/index.d.mts +1 -0
  47. package/dist/esm/api/errors/index.mjs +1 -0
  48. package/dist/esm/api/resources/styleChecks/client/Client.d.mts +3 -2
  49. package/dist/esm/api/resources/styleChecks/client/Client.mjs +5 -2
  50. package/dist/esm/api/resources/{styleSuggestions/client/requests/CreateStyleSuggestionV1StyleSuggestionsPostRequest.d.mts → styleChecks/client/requests/StyleCheckRequestBody.d.mts} +4 -4
  51. package/dist/esm/api/resources/styleChecks/client/requests/index.d.mts +1 -1
  52. package/dist/esm/api/resources/styleGuides/client/Client.mjs +3 -0
  53. package/dist/esm/api/resources/styleGuides/client/requests/StyleGuideRequestBody.d.mts +3 -0
  54. package/dist/esm/api/resources/styleRewrites/client/Client.d.mts +3 -2
  55. package/dist/esm/api/resources/styleRewrites/client/Client.mjs +5 -2
  56. package/dist/esm/api/resources/styleRewrites/client/requests/{CreateStyleRewriteV1StyleRewritesPostRequest.d.mts → StyleRewriteRequestBody.d.mts} +4 -4
  57. package/dist/esm/api/resources/styleRewrites/client/requests/index.d.mts +1 -1
  58. package/dist/esm/api/resources/styleSuggestions/client/Client.d.mts +3 -2
  59. package/dist/esm/api/resources/styleSuggestions/client/Client.mjs +5 -2
  60. package/dist/esm/api/resources/{styleChecks/client/requests/CreateStyleCheckV1StyleChecksPostRequest.d.mts → styleSuggestions/client/requests/StyleSuggestionRequestBody.d.mts} +4 -4
  61. package/dist/esm/api/resources/styleSuggestions/client/requests/index.d.mts +1 -1
  62. package/dist/esm/api/types/BaseStyleGuideType.d.mts +9 -0
  63. package/dist/esm/api/types/BaseStyleGuideType.mjs +8 -0
  64. package/dist/esm/api/types/StyleGuideResponse.d.mts +3 -1
  65. package/dist/esm/api/types/StyleGuides.d.mts +1 -2
  66. package/dist/esm/api/types/StyleGuides.mjs +0 -1
  67. package/dist/esm/api/types/WorkflowInfo.d.mts +2 -0
  68. package/dist/esm/api/types/index.d.mts +1 -0
  69. package/dist/esm/api/types/index.mjs +1 -0
  70. package/dist/esm/core/auth/index.d.mts +2 -2
  71. package/dist/esm/core/fetcher/EndpointMetadata.d.mts +13 -0
  72. package/dist/esm/core/fetcher/EndpointMetadata.mjs +1 -0
  73. package/dist/esm/core/fetcher/EndpointSupplier.d.mts +12 -0
  74. package/dist/esm/core/fetcher/EndpointSupplier.mjs +19 -0
  75. package/dist/esm/core/fetcher/Fetcher.d.mts +4 -2
  76. package/dist/esm/core/fetcher/Fetcher.mjs +3 -2
  77. package/dist/esm/core/fetcher/index.d.mts +2 -0
  78. package/dist/esm/core/fetcher/index.mjs +1 -0
  79. package/dist/esm/core/fetcher/requestWithRetries.mjs +44 -8
  80. package/dist/esm/core/file/exports.d.mts +1 -1
  81. package/dist/esm/core/headers.d.mts +2 -3
  82. package/dist/esm/version.d.mts +1 -1
  83. package/dist/esm/version.mjs +1 -1
  84. package/package.json +8 -13
  85. package/reference.md +3 -3
  86. /package/dist/cjs/api/resources/styleChecks/client/requests/{CreateStyleCheckV1StyleChecksPostRequest.js → StyleCheckRequestBody.js} +0 -0
  87. /package/dist/cjs/api/resources/styleRewrites/client/requests/{CreateStyleRewriteV1StyleRewritesPostRequest.js → StyleRewriteRequestBody.js} +0 -0
  88. /package/dist/cjs/api/resources/styleSuggestions/client/requests/{CreateStyleSuggestionV1StyleSuggestionsPostRequest.js → StyleSuggestionRequestBody.js} +0 -0
  89. /package/dist/esm/api/resources/styleChecks/client/requests/{CreateStyleCheckV1StyleChecksPostRequest.mjs → StyleCheckRequestBody.mjs} +0 -0
  90. /package/dist/esm/api/resources/styleRewrites/client/requests/{CreateStyleRewriteV1StyleRewritesPostRequest.mjs → StyleRewriteRequestBody.mjs} +0 -0
  91. /package/dist/esm/api/resources/styleSuggestions/client/requests/{CreateStyleSuggestionV1StyleSuggestionsPostRequest.mjs → StyleSuggestionRequestBody.mjs} +0 -0
@@ -13,6 +13,7 @@ exports.fetcher = void 0;
13
13
  exports.fetcherImpl = fetcherImpl;
14
14
  const json_js_1 = require("../json.js");
15
15
  const createRequestUrl_js_1 = require("./createRequestUrl.js");
16
+ const EndpointSupplier_js_1 = require("./EndpointSupplier.js");
16
17
  const getErrorResponseBody_js_1 = require("./getErrorResponseBody.js");
17
18
  const getFetchFn_js_1 = require("./getFetchFn.js");
18
19
  const getRequestBody_js_1 = require("./getRequestBody.js");
@@ -20,9 +21,9 @@ const getResponseBody_js_1 = require("./getResponseBody.js");
20
21
  const makeRequest_js_1 = require("./makeRequest.js");
21
22
  const RawResponse_js_1 = require("./RawResponse.js");
22
23
  const requestWithRetries_js_1 = require("./requestWithRetries.js");
23
- const Supplier_js_1 = require("./Supplier.js");
24
24
  function getHeaders(args) {
25
25
  return __awaiter(this, void 0, void 0, function* () {
26
+ var _a;
26
27
  const newHeaders = {};
27
28
  if (args.body !== undefined && args.contentType != null) {
28
29
  newHeaders["Content-Type"] = args.contentType;
@@ -31,7 +32,7 @@ function getHeaders(args) {
31
32
  return newHeaders;
32
33
  }
33
34
  for (const [key, value] of Object.entries(args.headers)) {
34
- const result = yield Supplier_js_1.Supplier.get(value);
35
+ const result = yield EndpointSupplier_js_1.EndpointSupplier.get(value, { endpointMetadata: (_a = args.endpointMetadata) !== null && _a !== void 0 ? _a : {} });
35
36
  if (typeof result === "string") {
36
37
  newHeaders[key] = result;
37
38
  continue;
@@ -1,5 +1,7 @@
1
1
  export type { APIResponse } from "./APIResponse.js";
2
2
  export type { BinaryResponse } from "./BinaryResponse.js";
3
+ export type { EndpointMetadata } from "./EndpointMetadata.js";
4
+ export { EndpointSupplier } from "./EndpointSupplier.js";
3
5
  export type { Fetcher, FetchFunction } from "./Fetcher.js";
4
6
  export { fetcher } from "./Fetcher.js";
5
7
  export { getHeader } from "./getHeader.js";
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Supplier = exports.unknownRawResponse = exports.toRawResponse = exports.abortRawResponse = exports.HttpResponsePromise = exports.getHeader = exports.fetcher = void 0;
3
+ exports.Supplier = exports.unknownRawResponse = exports.toRawResponse = exports.abortRawResponse = exports.HttpResponsePromise = exports.getHeader = exports.fetcher = exports.EndpointSupplier = void 0;
4
+ var EndpointSupplier_js_1 = require("./EndpointSupplier.js");
5
+ Object.defineProperty(exports, "EndpointSupplier", { enumerable: true, get: function () { return EndpointSupplier_js_1.EndpointSupplier; } });
4
6
  var Fetcher_js_1 = require("./Fetcher.js");
5
7
  Object.defineProperty(exports, "fetcher", { enumerable: true, get: function () { return Fetcher_js_1.fetcher; } });
6
8
  var getHeader_js_1 = require("./getHeader.js");
@@ -14,21 +14,57 @@ const INITIAL_RETRY_DELAY = 1000; // in milliseconds
14
14
  const MAX_RETRY_DELAY = 60000; // in milliseconds
15
15
  const DEFAULT_MAX_RETRIES = 2;
16
16
  const JITTER_FACTOR = 0.2; // 20% random jitter
17
- function addJitter(delay) {
18
- // Generate a random value between -JITTER_FACTOR and +JITTER_FACTOR
19
- const jitterMultiplier = 1 + (Math.random() * 2 - 1) * JITTER_FACTOR;
17
+ function addPositiveJitter(delay) {
18
+ // Generate a random value between 0 and +JITTER_FACTOR
19
+ const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
20
20
  return delay * jitterMultiplier;
21
21
  }
22
+ function addSymmetricJitter(delay) {
23
+ // Generate a random value in a JITTER_FACTOR-sized percentage range around delay
24
+ const jitterMultiplier = 1 + (Math.random() - 0.5) * JITTER_FACTOR;
25
+ return delay * jitterMultiplier;
26
+ }
27
+ function getRetryDelayFromHeaders(response, retryAttempt) {
28
+ // Check for Retry-After header first (RFC 7231), with no jitter
29
+ const retryAfter = response.headers.get("Retry-After");
30
+ if (retryAfter) {
31
+ // Parse as number of seconds...
32
+ const retryAfterSeconds = parseInt(retryAfter, 10);
33
+ if (!isNaN(retryAfterSeconds) && retryAfterSeconds > 0) {
34
+ return Math.min(retryAfterSeconds * 1000, MAX_RETRY_DELAY);
35
+ }
36
+ // ...or as an HTTP date; both are valid
37
+ const retryAfterDate = new Date(retryAfter);
38
+ if (!isNaN(retryAfterDate.getTime())) {
39
+ const delay = retryAfterDate.getTime() - Date.now();
40
+ if (delay > 0) {
41
+ return Math.min(Math.max(delay, 0), MAX_RETRY_DELAY);
42
+ }
43
+ }
44
+ }
45
+ // Then check for industry-standard X-RateLimit-Reset header, with positive jitter
46
+ const rateLimitReset = response.headers.get("X-RateLimit-Reset");
47
+ if (rateLimitReset) {
48
+ const resetTime = parseInt(rateLimitReset, 10);
49
+ if (!isNaN(resetTime)) {
50
+ // Assume Unix timestamp in epoch seconds
51
+ const delay = resetTime * 1000 - Date.now();
52
+ if (delay > 0) {
53
+ return addPositiveJitter(Math.min(delay, MAX_RETRY_DELAY));
54
+ }
55
+ }
56
+ }
57
+ // Fall back to exponential backoff, with symmetric jitter
58
+ return addSymmetricJitter(Math.min(INITIAL_RETRY_DELAY * Math.pow(2, retryAttempt), MAX_RETRY_DELAY));
59
+ }
22
60
  function requestWithRetries(requestFn_1) {
23
61
  return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
24
62
  let response = yield requestFn();
25
63
  for (let i = 0; i < maxRetries; ++i) {
26
64
  if ([408, 429].includes(response.status) || response.status >= 500) {
27
- // Calculate base delay using exponential backoff (in milliseconds)
28
- const baseDelay = Math.min(INITIAL_RETRY_DELAY * Math.pow(2, i), MAX_RETRY_DELAY);
29
- // Add jitter to the delay
30
- const delayWithJitter = addJitter(baseDelay);
31
- yield new Promise((resolve) => setTimeout(resolve, delayWithJitter));
65
+ // Get delay with appropriate jitter applied
66
+ const delay = getRetryDelayFromHeaders(response, i);
67
+ yield new Promise((resolve) => setTimeout(resolve, delay));
32
68
  response = yield requestFn();
33
69
  }
34
70
  else {
@@ -1 +1 @@
1
- export { Uploadable } from "./types.js";
1
+ export type { Uploadable } from "./types.js";
@@ -1,3 +1,2 @@
1
- import * as core from "./index.js";
2
- export declare function mergeHeaders(...headersArray: (Record<string, string | core.Supplier<string | null | undefined> | null | undefined> | null | undefined)[]): Record<string, string | core.Supplier<string | null | undefined>>;
3
- export declare function mergeOnlyDefinedHeaders(...headersArray: (Record<string, string | core.Supplier<string | null | undefined> | null | undefined> | null | undefined)[]): Record<string, string | core.Supplier<string | null | undefined>>;
1
+ export declare function mergeHeaders<THeaderValue>(...headersArray: (Record<string, THeaderValue> | null | undefined)[]): Record<string, string | THeaderValue>;
2
+ export declare function mergeOnlyDefinedHeaders<THeaderValue>(...headersArray: (Record<string, THeaderValue> | null | undefined)[]): Record<string, THeaderValue>;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.3.0";
1
+ export declare const SDK_VERSION = "1.1.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.3.0";
4
+ exports.SDK_VERSION = "1.1.0";
@@ -12,8 +12,8 @@ export class MarkupAIClient {
12
12
  this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
13
13
  "X-Fern-Language": "JavaScript",
14
14
  "X-Fern-SDK-Name": "@markupai/api",
15
- "X-Fern-SDK-Version": "0.3.0",
16
- "User-Agent": "@markupai/api/0.3.0",
15
+ "X-Fern-SDK-Version": "1.1.0",
16
+ "User-Agent": "@markupai/api/1.1.0",
17
17
  "X-Fern-Runtime": core.RUNTIME.type,
18
18
  "X-Fern-Runtime-Version": core.RUNTIME.version,
19
19
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as errors from "../../errors/index.mjs";
5
+ import * as MarkupAI from "../index.mjs";
6
+ import * as core from "../../core/index.mjs";
7
+ export declare class TooManyRequestsError extends errors.MarkupAIError {
8
+ constructor(body: MarkupAI.ErrorResponse, rawResponse?: core.RawResponse);
9
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as errors from "../../errors/index.mjs";
5
+ export class TooManyRequestsError extends errors.MarkupAIError {
6
+ constructor(body, rawResponse) {
7
+ super({
8
+ message: "TooManyRequestsError",
9
+ statusCode: 429,
10
+ body: body,
11
+ rawResponse: rawResponse,
12
+ });
13
+ Object.setPrototypeOf(this, TooManyRequestsError.prototype);
14
+ }
15
+ }
@@ -4,3 +4,4 @@ export * from "./UnprocessableEntityError.mjs";
4
4
  export * from "./InternalServerError.mjs";
5
5
  export * from "./ContentTooLargeError.mjs";
6
6
  export * from "./NotFoundError.mjs";
7
+ export * from "./TooManyRequestsError.mjs";
@@ -4,3 +4,4 @@ export * from "./UnprocessableEntityError.mjs";
4
4
  export * from "./InternalServerError.mjs";
5
5
  export * from "./ContentTooLargeError.mjs";
6
6
  export * from "./NotFoundError.mjs";
7
+ export * from "./TooManyRequestsError.mjs";
@@ -36,13 +36,14 @@ export declare class StyleChecks {
36
36
  /**
37
37
  * Analyze text for grammar, style, and clarity issues.
38
38
  *
39
- * @param {MarkupAI.CreateStyleCheckV1StyleChecksPostRequest} request
39
+ * @param {MarkupAI.StyleCheckRequestBody} request
40
40
  * @param {StyleChecks.RequestOptions} requestOptions - Request-specific configuration.
41
41
  *
42
42
  * @throws {@link MarkupAI.UnauthorizedError}
43
43
  * @throws {@link MarkupAI.ForbiddenError}
44
44
  * @throws {@link MarkupAI.ContentTooLargeError}
45
45
  * @throws {@link MarkupAI.UnprocessableEntityError}
46
+ * @throws {@link MarkupAI.TooManyRequestsError}
46
47
  * @throws {@link MarkupAI.InternalServerError}
47
48
  *
48
49
  * @example
@@ -53,7 +54,7 @@ export declare class StyleChecks {
53
54
  * style_guide: "style_guide"
54
55
  * })
55
56
  */
56
- createStyleCheck(request: MarkupAI.CreateStyleCheckV1StyleChecksPostRequest, requestOptions?: StyleChecks.RequestOptions): core.HttpResponsePromise<MarkupAI.WorkflowResponse>;
57
+ createStyleCheck(request: MarkupAI.StyleCheckRequestBody, requestOptions?: StyleChecks.RequestOptions): core.HttpResponsePromise<MarkupAI.WorkflowResponse>;
57
58
  private __createStyleCheck;
58
59
  /**
59
60
  * Retrieve style check results.
@@ -25,13 +25,14 @@ export class StyleChecks {
25
25
  /**
26
26
  * Analyze text for grammar, style, and clarity issues.
27
27
  *
28
- * @param {MarkupAI.CreateStyleCheckV1StyleChecksPostRequest} request
28
+ * @param {MarkupAI.StyleCheckRequestBody} request
29
29
  * @param {StyleChecks.RequestOptions} requestOptions - Request-specific configuration.
30
30
  *
31
31
  * @throws {@link MarkupAI.UnauthorizedError}
32
32
  * @throws {@link MarkupAI.ForbiddenError}
33
33
  * @throws {@link MarkupAI.ContentTooLargeError}
34
34
  * @throws {@link MarkupAI.UnprocessableEntityError}
35
+ * @throws {@link MarkupAI.TooManyRequestsError}
35
36
  * @throws {@link MarkupAI.InternalServerError}
36
37
  *
37
38
  * @example
@@ -49,7 +50,6 @@ export class StyleChecks {
49
50
  return __awaiter(this, void 0, void 0, function* () {
50
51
  var _a, _b, _c, _d;
51
52
  const _request = yield core.newFormData();
52
- yield _request.appendFile("file_upload", request.file_upload);
53
53
  _request.append("dialect", request.dialect);
54
54
  if (request.tone != null) {
55
55
  _request.append("tone", request.tone);
@@ -58,6 +58,7 @@ export class StyleChecks {
58
58
  if (request.webhook_url != null) {
59
59
  _request.append("webhook_url", request.webhook_url);
60
60
  }
61
+ yield _request.appendFile("file_upload", request.file_upload);
61
62
  const _maybeEncodedRequest = yield _request.getRequest();
62
63
  let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({ Authorization: yield this._getAuthorizationHeader() }, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
63
64
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
@@ -85,6 +86,8 @@ export class StyleChecks {
85
86
  throw new MarkupAI.ContentTooLargeError(_response.error.body, _response.rawResponse);
86
87
  case 422:
87
88
  throw new MarkupAI.UnprocessableEntityError(_response.error.body, _response.rawResponse);
89
+ case 429:
90
+ throw new MarkupAI.TooManyRequestsError(_response.error.body, _response.rawResponse);
88
91
  case 500:
89
92
  throw new MarkupAI.InternalServerError(_response.error.body, _response.rawResponse);
90
93
  default:
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- import * as core from "../../../../../core/index.mjs";
5
4
  import * as MarkupAI from "../../../../index.mjs";
5
+ import * as core from "../../../../../core/index.mjs";
6
6
  /**
7
7
  * @example
8
8
  * {
@@ -11,9 +11,7 @@ import * as MarkupAI from "../../../../index.mjs";
11
11
  * style_guide: "style_guide"
12
12
  * }
13
13
  */
14
- export interface CreateStyleSuggestionV1StyleSuggestionsPostRequest {
15
- /** The document to analyze. Text files (.txt), PDFs (.pdf), and Markdown files (.md) are accepted. The max file size is 1.5 MB */
16
- file_upload: core.file.Uploadable.FileLike;
14
+ export interface StyleCheckRequestBody {
17
15
  /** The language variant you'd like us to use for analysis. Choose from American English, British English, or other supported dialects. */
18
16
  dialect: MarkupAI.Dialects;
19
17
  /** The tone variation you're aiming for. Options include formal, academic, casual, and other tone variations to match your content goals. */
@@ -22,4 +20,6 @@ export interface CreateStyleSuggestionV1StyleSuggestionsPostRequest {
22
20
  style_guide: string;
23
21
  /** A URL that results will be POSTed to once the process completes. */
24
22
  webhook_url?: string;
23
+ /** The document to analyze. Text (.txt), Markdown (.md), HTML (.html .htm), DITA (.dita, .xml), and PDF (.pdf) files are accepted. The max file size is 1.5 MB. */
24
+ file_upload: core.file.Uploadable.FileLike;
25
25
  }
@@ -1 +1 @@
1
- export { type CreateStyleCheckV1StyleChecksPostRequest } from "./CreateStyleCheckV1StyleChecksPostRequest.mjs";
1
+ export { type StyleCheckRequestBody } from "./StyleCheckRequestBody.mjs";
@@ -117,6 +117,9 @@ export class StyleGuides {
117
117
  const _request = yield core.newFormData();
118
118
  yield _request.appendFile("file_upload", request.file_upload);
119
119
  _request.append("name", request.name);
120
+ if (request.base_style_guide != null) {
121
+ _request.append("base_style_guide", request.base_style_guide);
122
+ }
120
123
  const _maybeEncodedRequest = yield _request.getRequest();
121
124
  let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({ Authorization: yield this._getAuthorizationHeader() }, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
122
125
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
@@ -2,6 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as core from "../../../../../core/index.mjs";
5
+ import * as MarkupAI from "../../../../index.mjs";
5
6
  /**
6
7
  * @example
7
8
  * {
@@ -14,4 +15,6 @@ export interface StyleGuideRequestBody {
14
15
  file_upload: core.file.Uploadable.FileLike;
15
16
  /** A friendly name for your style guide to help you identify it later. */
16
17
  name: string;
18
+ /** The base style guide to extend (AP, Chicago, or Microsoft). If not provided, the style guide will be created from scratch. */
19
+ base_style_guide?: MarkupAI.BaseStyleGuideType;
17
20
  }
@@ -36,13 +36,14 @@ export declare class StyleRewrites {
36
36
  /**
37
37
  * Rewrite text with style corrections applied.
38
38
  *
39
- * @param {MarkupAI.CreateStyleRewriteV1StyleRewritesPostRequest} request
39
+ * @param {MarkupAI.StyleRewriteRequestBody} request
40
40
  * @param {StyleRewrites.RequestOptions} requestOptions - Request-specific configuration.
41
41
  *
42
42
  * @throws {@link MarkupAI.UnauthorizedError}
43
43
  * @throws {@link MarkupAI.ForbiddenError}
44
44
  * @throws {@link MarkupAI.ContentTooLargeError}
45
45
  * @throws {@link MarkupAI.UnprocessableEntityError}
46
+ * @throws {@link MarkupAI.TooManyRequestsError}
46
47
  * @throws {@link MarkupAI.InternalServerError}
47
48
  *
48
49
  * @example
@@ -53,7 +54,7 @@ export declare class StyleRewrites {
53
54
  * style_guide: "style_guide"
54
55
  * })
55
56
  */
56
- createStyleRewrite(request: MarkupAI.CreateStyleRewriteV1StyleRewritesPostRequest, requestOptions?: StyleRewrites.RequestOptions): core.HttpResponsePromise<MarkupAI.WorkflowResponse>;
57
+ createStyleRewrite(request: MarkupAI.StyleRewriteRequestBody, requestOptions?: StyleRewrites.RequestOptions): core.HttpResponsePromise<MarkupAI.WorkflowResponse>;
57
58
  private __createStyleRewrite;
58
59
  /**
59
60
  * Retrieve rewrite results.
@@ -25,13 +25,14 @@ export class StyleRewrites {
25
25
  /**
26
26
  * Rewrite text with style corrections applied.
27
27
  *
28
- * @param {MarkupAI.CreateStyleRewriteV1StyleRewritesPostRequest} request
28
+ * @param {MarkupAI.StyleRewriteRequestBody} request
29
29
  * @param {StyleRewrites.RequestOptions} requestOptions - Request-specific configuration.
30
30
  *
31
31
  * @throws {@link MarkupAI.UnauthorizedError}
32
32
  * @throws {@link MarkupAI.ForbiddenError}
33
33
  * @throws {@link MarkupAI.ContentTooLargeError}
34
34
  * @throws {@link MarkupAI.UnprocessableEntityError}
35
+ * @throws {@link MarkupAI.TooManyRequestsError}
35
36
  * @throws {@link MarkupAI.InternalServerError}
36
37
  *
37
38
  * @example
@@ -49,7 +50,6 @@ export class StyleRewrites {
49
50
  return __awaiter(this, void 0, void 0, function* () {
50
51
  var _a, _b, _c, _d;
51
52
  const _request = yield core.newFormData();
52
- yield _request.appendFile("file_upload", request.file_upload);
53
53
  _request.append("dialect", request.dialect);
54
54
  if (request.tone != null) {
55
55
  _request.append("tone", request.tone);
@@ -58,6 +58,7 @@ export class StyleRewrites {
58
58
  if (request.webhook_url != null) {
59
59
  _request.append("webhook_url", request.webhook_url);
60
60
  }
61
+ yield _request.appendFile("file_upload", request.file_upload);
61
62
  const _maybeEncodedRequest = yield _request.getRequest();
62
63
  let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({ Authorization: yield this._getAuthorizationHeader() }, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
63
64
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
@@ -85,6 +86,8 @@ export class StyleRewrites {
85
86
  throw new MarkupAI.ContentTooLargeError(_response.error.body, _response.rawResponse);
86
87
  case 422:
87
88
  throw new MarkupAI.UnprocessableEntityError(_response.error.body, _response.rawResponse);
89
+ case 429:
90
+ throw new MarkupAI.TooManyRequestsError(_response.error.body, _response.rawResponse);
88
91
  case 500:
89
92
  throw new MarkupAI.InternalServerError(_response.error.body, _response.rawResponse);
90
93
  default:
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- import * as core from "../../../../../core/index.mjs";
5
4
  import * as MarkupAI from "../../../../index.mjs";
5
+ import * as core from "../../../../../core/index.mjs";
6
6
  /**
7
7
  * @example
8
8
  * {
@@ -11,9 +11,7 @@ import * as MarkupAI from "../../../../index.mjs";
11
11
  * style_guide: "style_guide"
12
12
  * }
13
13
  */
14
- export interface CreateStyleRewriteV1StyleRewritesPostRequest {
15
- /** The document to analyze. Text files (.txt), PDFs (.pdf), and Markdown files (.md) are accepted. The max file size is 1.5 MB */
16
- file_upload: core.file.Uploadable.FileLike;
14
+ export interface StyleRewriteRequestBody {
17
15
  /** The language variant you'd like us to use for analysis. Choose from American English, British English, or other supported dialects. */
18
16
  dialect: MarkupAI.Dialects;
19
17
  /** The tone variation you're aiming for. Options include formal, academic, casual, and other tone variations to match your content goals. */
@@ -22,4 +20,6 @@ export interface CreateStyleRewriteV1StyleRewritesPostRequest {
22
20
  style_guide: string;
23
21
  /** A URL that results will be POSTed to once the process completes. */
24
22
  webhook_url?: string;
23
+ /** The document to rewrite. Text (.txt), Markdown (.md), HTML (.html .htm), and DITA (.dita, .xml) files are accepted. The max file size is 1.5 MB. */
24
+ file_upload: core.file.Uploadable.FileLike;
25
25
  }
@@ -1 +1 @@
1
- export { type CreateStyleRewriteV1StyleRewritesPostRequest } from "./CreateStyleRewriteV1StyleRewritesPostRequest.mjs";
1
+ export { type StyleRewriteRequestBody } from "./StyleRewriteRequestBody.mjs";
@@ -36,13 +36,14 @@ export declare class StyleSuggestions {
36
36
  /**
37
37
  * Get suggested corrections for text.
38
38
  *
39
- * @param {MarkupAI.CreateStyleSuggestionV1StyleSuggestionsPostRequest} request
39
+ * @param {MarkupAI.StyleSuggestionRequestBody} request
40
40
  * @param {StyleSuggestions.RequestOptions} requestOptions - Request-specific configuration.
41
41
  *
42
42
  * @throws {@link MarkupAI.UnauthorizedError}
43
43
  * @throws {@link MarkupAI.ForbiddenError}
44
44
  * @throws {@link MarkupAI.ContentTooLargeError}
45
45
  * @throws {@link MarkupAI.UnprocessableEntityError}
46
+ * @throws {@link MarkupAI.TooManyRequestsError}
46
47
  * @throws {@link MarkupAI.InternalServerError}
47
48
  *
48
49
  * @example
@@ -53,7 +54,7 @@ export declare class StyleSuggestions {
53
54
  * style_guide: "style_guide"
54
55
  * })
55
56
  */
56
- createStyleSuggestion(request: MarkupAI.CreateStyleSuggestionV1StyleSuggestionsPostRequest, requestOptions?: StyleSuggestions.RequestOptions): core.HttpResponsePromise<MarkupAI.WorkflowResponse>;
57
+ createStyleSuggestion(request: MarkupAI.StyleSuggestionRequestBody, requestOptions?: StyleSuggestions.RequestOptions): core.HttpResponsePromise<MarkupAI.WorkflowResponse>;
57
58
  private __createStyleSuggestion;
58
59
  /**
59
60
  * Retrieve suggestion results.
@@ -25,13 +25,14 @@ export class StyleSuggestions {
25
25
  /**
26
26
  * Get suggested corrections for text.
27
27
  *
28
- * @param {MarkupAI.CreateStyleSuggestionV1StyleSuggestionsPostRequest} request
28
+ * @param {MarkupAI.StyleSuggestionRequestBody} request
29
29
  * @param {StyleSuggestions.RequestOptions} requestOptions - Request-specific configuration.
30
30
  *
31
31
  * @throws {@link MarkupAI.UnauthorizedError}
32
32
  * @throws {@link MarkupAI.ForbiddenError}
33
33
  * @throws {@link MarkupAI.ContentTooLargeError}
34
34
  * @throws {@link MarkupAI.UnprocessableEntityError}
35
+ * @throws {@link MarkupAI.TooManyRequestsError}
35
36
  * @throws {@link MarkupAI.InternalServerError}
36
37
  *
37
38
  * @example
@@ -49,7 +50,6 @@ export class StyleSuggestions {
49
50
  return __awaiter(this, void 0, void 0, function* () {
50
51
  var _a, _b, _c, _d;
51
52
  const _request = yield core.newFormData();
52
- yield _request.appendFile("file_upload", request.file_upload);
53
53
  _request.append("dialect", request.dialect);
54
54
  if (request.tone != null) {
55
55
  _request.append("tone", request.tone);
@@ -58,6 +58,7 @@ export class StyleSuggestions {
58
58
  if (request.webhook_url != null) {
59
59
  _request.append("webhook_url", request.webhook_url);
60
60
  }
61
+ yield _request.appendFile("file_upload", request.file_upload);
61
62
  const _maybeEncodedRequest = yield _request.getRequest();
62
63
  let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({ Authorization: yield this._getAuthorizationHeader() }, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
63
64
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
@@ -85,6 +86,8 @@ export class StyleSuggestions {
85
86
  throw new MarkupAI.ContentTooLargeError(_response.error.body, _response.rawResponse);
86
87
  case 422:
87
88
  throw new MarkupAI.UnprocessableEntityError(_response.error.body, _response.rawResponse);
89
+ case 429:
90
+ throw new MarkupAI.TooManyRequestsError(_response.error.body, _response.rawResponse);
88
91
  case 500:
89
92
  throw new MarkupAI.InternalServerError(_response.error.body, _response.rawResponse);
90
93
  default:
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- import * as core from "../../../../../core/index.mjs";
5
4
  import * as MarkupAI from "../../../../index.mjs";
5
+ import * as core from "../../../../../core/index.mjs";
6
6
  /**
7
7
  * @example
8
8
  * {
@@ -11,9 +11,7 @@ import * as MarkupAI from "../../../../index.mjs";
11
11
  * style_guide: "style_guide"
12
12
  * }
13
13
  */
14
- export interface CreateStyleCheckV1StyleChecksPostRequest {
15
- /** The document to analyze. Text files (.txt), PDFs (.pdf), and Markdown files (.md) are accepted. The max file size is 1.5 MB */
16
- file_upload: core.file.Uploadable.FileLike;
14
+ export interface StyleSuggestionRequestBody {
17
15
  /** The language variant you'd like us to use for analysis. Choose from American English, British English, or other supported dialects. */
18
16
  dialect: MarkupAI.Dialects;
19
17
  /** The tone variation you're aiming for. Options include formal, academic, casual, and other tone variations to match your content goals. */
@@ -22,4 +20,6 @@ export interface CreateStyleCheckV1StyleChecksPostRequest {
22
20
  style_guide: string;
23
21
  /** A URL that results will be POSTed to once the process completes. */
24
22
  webhook_url?: string;
23
+ /** The document to analyze. Text (.txt), Markdown (.md), HTML (.html .htm), DITA (.dita, .xml), and PDF (.pdf) files are accepted. The max file size is 1.5 MB. */
24
+ file_upload: core.file.Uploadable.FileLike;
25
25
  }
@@ -1 +1 @@
1
- export { type CreateStyleSuggestionV1StyleSuggestionsPostRequest } from "./CreateStyleSuggestionV1StyleSuggestionsPostRequest.mjs";
1
+ export { type StyleSuggestionRequestBody } from "./StyleSuggestionRequestBody.mjs";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export type BaseStyleGuideType = "ap" | "chicago" | "microsoft";
5
+ export declare const BaseStyleGuideType: {
6
+ readonly Ap: "ap";
7
+ readonly Chicago: "chicago";
8
+ readonly Microsoft: "microsoft";
9
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export const BaseStyleGuideType = {
5
+ Ap: "ap",
6
+ Chicago: "chicago",
7
+ Microsoft: "microsoft",
8
+ };
@@ -16,6 +16,8 @@ export interface StyleGuideResponse {
16
16
  updated_at?: string;
17
17
  /** The ID of the user who last updated the style guide. If null, the style guide has never been updated. */
18
18
  updated_by?: string;
19
- /** Summarizes the rules and guidelines which will be applied by this style guide. */
19
+ /** User-friendly summary of the style guide's contents and characteristics */
20
20
  summary?: string;
21
+ /** The base style guide type that this style guide extends (AP, Chicago, or Microsoft). */
22
+ base_style_guide_type?: MarkupAI.BaseStyleGuideType;
21
23
  }
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export type StyleGuides = "ap" | "chicago" | "microsoft" | "demo" | "style_brand_importer";
4
+ export type StyleGuides = "ap" | "chicago" | "microsoft" | "style_brand_importer";
5
5
  export declare const StyleGuides: {
6
6
  readonly Ap: "ap";
7
7
  readonly Chicago: "chicago";
8
8
  readonly Microsoft: "microsoft";
9
- readonly Demo: "demo";
10
9
  readonly StyleBrandImporter: "style_brand_importer";
11
10
  };
@@ -5,6 +5,5 @@ export const StyleGuides = {
5
5
  Ap: "ap",
6
6
  Chicago: "chicago",
7
7
  Microsoft: "microsoft",
8
- Demo: "demo",
9
8
  StyleBrandImporter: "style_brand_importer",
10
9
  };
@@ -7,6 +7,8 @@ export interface WorkflowInfo {
7
7
  id: string;
8
8
  /** API version */
9
9
  api_version?: string;
10
+ /** The original name of the file passed into the workflow */
11
+ filename?: string;
10
12
  /** UTC timestamp when the result was generated */
11
13
  generated_at?: string;
12
14
  status?: MarkupAI.WorkflowStatus;
@@ -1,4 +1,5 @@
1
1
  export * from "./AnalysisScore.mjs";
2
+ export * from "./BaseStyleGuideType.mjs";
2
3
  export * from "./ClarityCategory.mjs";
3
4
  export * from "./ClarityScore.mjs";
4
5
  export * from "./ConfigOptions.mjs";
@@ -1,4 +1,5 @@
1
1
  export * from "./AnalysisScore.mjs";
2
+ export * from "./BaseStyleGuideType.mjs";
2
3
  export * from "./ClarityCategory.mjs";
3
4
  export * from "./ClarityScore.mjs";
4
5
  export * from "./ConfigOptions.mjs";
@@ -1,4 +1,4 @@
1
- export { AuthProvider } from "./AuthProvider.mjs";
2
- export { type AuthRequest } from "./AuthRequest.mjs";
1
+ export type { AuthProvider } from "./AuthProvider.mjs";
2
+ export type { AuthRequest } from "./AuthRequest.mjs";
3
3
  export { BasicAuth } from "./BasicAuth.mjs";
4
4
  export { BearerToken } from "./BearerToken.mjs";
@@ -0,0 +1,13 @@
1
+ export type SecuritySchemeKey = string;
2
+ /**
3
+ * A collection of security schemes, where the key is the name of the security scheme and the value is the list of scopes required for that scheme.
4
+ * All schemes in the collection must be satisfied for authentication to be successful.
5
+ */
6
+ export type SecuritySchemeCollection = Record<SecuritySchemeKey, AuthScope[]>;
7
+ export type AuthScope = string;
8
+ export type EndpointMetadata = {
9
+ /**
10
+ * An array of security scheme collections. Each collection represents an alternative way to authenticate.
11
+ */
12
+ security?: SecuritySchemeCollection[];
13
+ };
@@ -0,0 +1 @@
1
+ export {};