From 74d47d3ea896686388d5673abdeac164e91feffc Mon Sep 17 00:00:00 2001 From: Sam Sloate Date: Mon, 8 Jul 2024 09:41:50 -0400 Subject: [PATCH 1/4] Add ResponseTooLarge Error * add response too large error * bump version to pre-release --- api.ts | 26 ++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/api.ts b/api.ts index c862eaaac7..635446f91c 100644 --- a/api.ts +++ b/api.ts @@ -247,6 +247,32 @@ export class MissingScopesError extends Error { } } +/** + * An error that will be thrown by {@link Fetcher.fetch} when the response body from the external system + * exceeds packs platform limits + * + * This error can be caught and retried by requesting less data from the external system through + * a smaller page size or omitting large fields. + * + * @hidden + */ +export class ResponseSizeTooLargeError extends Error { + /** + * The name of the error, for identification purposes. + */ + override name: string = 'ResponseSizeTooLargeError'; + + /** @hidden */ + constructor(message?: string) { + super(message || 'Response size too large'); + } + + /** Returns if the error is an instance of ResponseSizeTooLargeError. Note that `instanceof` may not work. */ + static isResponseSizeTooLargeError(err: any): err is ResponseSizeTooLargeError { + return 'name' in err && err.name === ResponseSizeTooLargeError.name; + } +} + /** * A map of named property options methods for a particular sync table. The names need to match * the values stored in the object schema. For the name, we use the property's name so that diff --git a/package.json b/package.json index e5bfc8a60a..ab7a826626 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@codahq/packs-sdk", - "version": "1.7.9", + "version": "1.7.9-prerelease.1", "license": "MIT", "workspaces": [ "dev/eslint" From cfeab758b1a3d3ceac6fce117e31fd2d005d1960 Mon Sep 17 00:00:00 2001 From: Sam Sloate Date: Mon, 8 Jul 2024 09:44:12 -0400 Subject: [PATCH 2/4] run make build --- dist/api.d.ts | 19 +++++++++++++++++++ dist/api.js | 26 +++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/dist/api.d.ts b/dist/api.d.ts index 405b534c9a..a708b51c5b 100644 --- a/dist/api.d.ts +++ b/dist/api.d.ts @@ -183,6 +183,25 @@ export declare class MissingScopesError extends Error { /** Returns if the error is an instance of MissingScopesError. Note that `instanceof` may not work. */ static isMissingScopesError(err: any): err is MissingScopesError; } +/** + * An error that will be thrown by {@link Fetcher.fetch} when the response body from the external system + * exceeds packs platform limits + * + * This error can be caught and retried by requesting less data from the external system through + * a smaller page size or omitting large fields. + * + * @hidden + */ +export declare class ResponseSizeTooLargeError extends Error { + /** + * The name of the error, for identification purposes. + */ + name: string; + /** @hidden */ + constructor(message?: string); + /** Returns if the error is an instance of ResponseSizeTooLargeError. Note that `instanceof` may not work. */ + static isResponseSizeTooLargeError(err: any): err is ResponseSizeTooLargeError; +} /** * A map of named property options methods for a particular sync table. The names need to match * the values stored in the object schema. For the name, we use the property's name so that diff --git a/dist/api.js b/dist/api.js index 1016e8b59b..c268135046 100644 --- a/dist/api.js +++ b/dist/api.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.maybeRewriteConnectionForFormula = exports.maybeRewriteConnectionForNamedPropertyOptions = exports.makeEmptyFormula = exports.makeTranslateObjectFormula = exports.makeDynamicSyncTable = exports.makeSyncTableLegacy = exports.makeSyncTable = exports.makeObjectFormula = exports.makeSimpleAutocompleteMetadataFormula = exports.autocompleteSearchObjects = exports.simpleAutocomplete = exports.makePropertyOptionsFormula = exports.makeMetadataFormula = exports.normalizePropertyOptionsResults = exports.makeFormula = exports.makeStringFormula = exports.makeNumericFormula = exports.UpdateOutcome = exports.isSyncPackFormula = exports.isStringPackFormula = exports.isObjectPackFormula = exports.check = exports.makeUserVisibleError = exports.makeFileArrayParameter = exports.makeFileParameter = exports.makeImageArrayParameter = exports.makeImageParameter = exports.makeHtmlArrayParameter = exports.makeHtmlParameter = exports.makeDateArrayParameter = exports.makeDateParameter = exports.makeBooleanArrayParameter = exports.makeBooleanParameter = exports.makeNumericArrayParameter = exports.makeNumericParameter = exports.makeStringArrayParameter = exports.makeStringParameter = exports.makeParameter = exports.wrapGetSchema = exports.wrapMetadataFunction = exports.isDynamicSyncTable = exports.isUserVisibleError = exports.MissingScopesError = exports.StatusCodeError = exports.UserVisibleError = void 0; +exports.maybeRewriteConnectionForFormula = exports.maybeRewriteConnectionForNamedPropertyOptions = exports.makeEmptyFormula = exports.makeTranslateObjectFormula = exports.makeDynamicSyncTable = exports.makeSyncTableLegacy = exports.makeSyncTable = exports.makeObjectFormula = exports.makeSimpleAutocompleteMetadataFormula = exports.autocompleteSearchObjects = exports.simpleAutocomplete = exports.makePropertyOptionsFormula = exports.makeMetadataFormula = exports.normalizePropertyOptionsResults = exports.makeFormula = exports.makeStringFormula = exports.makeNumericFormula = exports.UpdateOutcome = exports.isSyncPackFormula = exports.isStringPackFormula = exports.isObjectPackFormula = exports.check = exports.makeUserVisibleError = exports.makeFileArrayParameter = exports.makeFileParameter = exports.makeImageArrayParameter = exports.makeImageParameter = exports.makeHtmlArrayParameter = exports.makeHtmlParameter = exports.makeDateArrayParameter = exports.makeDateParameter = exports.makeBooleanArrayParameter = exports.makeBooleanParameter = exports.makeNumericArrayParameter = exports.makeNumericParameter = exports.makeStringArrayParameter = exports.makeStringParameter = exports.makeParameter = exports.wrapGetSchema = exports.wrapMetadataFunction = exports.isDynamicSyncTable = exports.isUserVisibleError = exports.ResponseSizeTooLargeError = exports.MissingScopesError = exports.StatusCodeError = exports.UserVisibleError = void 0; const api_types_1 = require("./api_types"); const api_types_2 = require("./api_types"); const api_types_3 = require("./api_types"); @@ -168,6 +168,30 @@ class MissingScopesError extends Error { } } exports.MissingScopesError = MissingScopesError; +/** + * An error that will be thrown by {@link Fetcher.fetch} when the response body from the external system + * exceeds packs platform limits + * + * This error can be caught and retried by requesting less data from the external system through + * a smaller page size or omitting large fields. + * + * @hidden + */ +class ResponseSizeTooLargeError extends Error { + /** @hidden */ + constructor(message) { + super(message || 'Response size too large'); + /** + * The name of the error, for identification purposes. + */ + this.name = 'ResponseSizeTooLargeError'; + } + /** Returns if the error is an instance of ResponseSizeTooLargeError. Note that `instanceof` may not work. */ + static isResponseSizeTooLargeError(err) { + return 'name' in err && err.name === ResponseSizeTooLargeError.name; + } +} +exports.ResponseSizeTooLargeError = ResponseSizeTooLargeError; /** * Helper to determine if an error is considered user-visible and can be shown in the UI. * See {@link UserVisibleError}. From f0c014d8bfdcea5b72c2bcef9c9c0ed487699985 Mon Sep 17 00:00:00 2001 From: Sam Sloate Date: Mon, 8 Jul 2024 10:01:36 -0400 Subject: [PATCH 3/4] add to coda error types --- runtime/common/marshaling/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/common/marshaling/index.ts b/runtime/common/marshaling/index.ts index f42131c4fe..59c9fabe81 100644 --- a/runtime/common/marshaling/index.ts +++ b/runtime/common/marshaling/index.ts @@ -1,6 +1,7 @@ import {CodaMarshalerType} from './constants'; import {MarshalingInjectedKeys} from './constants'; import {MissingScopesError} from '../../../api'; +import {ResponseSizeTooLargeError} from '../../../api'; import {StatusCodeError} from '../../../api'; import {deserialize} from './serializer'; import {format} from 'util'; @@ -66,6 +67,7 @@ const recognizableCodaErrorClasses: ErrorConstructor[] = [ // StatusCodeError doesn't have the new StatusCodeError(message) constructor but it's okay. StatusCodeError as any, MissingScopesError as any, + ResponseSizeTooLargeError as any, ]; // pathPrefix can be temporarily modified, but needs to be restored to its original value From f7a15df4ecb112feea8e87a17b53d504f199245d Mon Sep 17 00:00:00 2001 From: Sam Sloate Date: Mon, 8 Jul 2024 10:32:12 -0400 Subject: [PATCH 4/4] run make build --- api.ts | 2 +- bundles/thunk_bundle.js | 19 ++++++++++++++++++- dist/api.d.ts | 2 +- dist/bundles/thunk_bundle.js | 19 ++++++++++++++++++- dist/runtime/common/marshaling/index.js | 4 +++- 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/api.ts b/api.ts index 635446f91c..2287bd4c9d 100644 --- a/api.ts +++ b/api.ts @@ -263,7 +263,7 @@ export class ResponseSizeTooLargeError extends Error { override name: string = 'ResponseSizeTooLargeError'; /** @hidden */ - constructor(message?: string) { + constructor(message?: string | undefined) { super(message || 'Response size too large'); } diff --git a/bundles/thunk_bundle.js b/bundles/thunk_bundle.js index 93e8277a1d..4d6c248b49 100644 --- a/bundles/thunk_bundle.js +++ b/bundles/thunk_bundle.js @@ -5911,6 +5911,22 @@ module.exports = (() => { }; __name(_MissingScopesError, "MissingScopesError"); var MissingScopesError = _MissingScopesError; + var _ResponseSizeTooLargeError = class _ResponseSizeTooLargeError extends Error { + /** @hidden */ + constructor(message) { + super(message || "Response size too large"); + /** + * The name of the error, for identification purposes. + */ + this.name = "ResponseSizeTooLargeError"; + } + /** Returns if the error is an instance of ResponseSizeTooLargeError. Note that `instanceof` may not work. */ + static isResponseSizeTooLargeError(err) { + return "name" in err && err.name === _ResponseSizeTooLargeError.name; + } + }; + __name(_ResponseSizeTooLargeError, "ResponseSizeTooLargeError"); + var ResponseSizeTooLargeError = _ResponseSizeTooLargeError; function isDynamicSyncTable(syncTable) { return "isDynamic" in syncTable; } @@ -6164,7 +6180,8 @@ module.exports = (() => { var recognizableCodaErrorClasses2 = [ // StatusCodeError doesn't have the new StatusCodeError(message) constructor but it's okay. StatusCodeError, - MissingScopesError + MissingScopesError, + ResponseSizeTooLargeError ]; function fixUncopyableTypes(val, pathPrefix, postTransforms, depth = 0) { if (depth >= MaxTraverseDepth) { diff --git a/dist/api.d.ts b/dist/api.d.ts index a708b51c5b..a0bcaf2262 100644 --- a/dist/api.d.ts +++ b/dist/api.d.ts @@ -198,7 +198,7 @@ export declare class ResponseSizeTooLargeError extends Error { */ name: string; /** @hidden */ - constructor(message?: string); + constructor(message?: string | undefined); /** Returns if the error is an instance of ResponseSizeTooLargeError. Note that `instanceof` may not work. */ static isResponseSizeTooLargeError(err: any): err is ResponseSizeTooLargeError; } diff --git a/dist/bundles/thunk_bundle.js b/dist/bundles/thunk_bundle.js index 93e8277a1d..4d6c248b49 100644 --- a/dist/bundles/thunk_bundle.js +++ b/dist/bundles/thunk_bundle.js @@ -5911,6 +5911,22 @@ module.exports = (() => { }; __name(_MissingScopesError, "MissingScopesError"); var MissingScopesError = _MissingScopesError; + var _ResponseSizeTooLargeError = class _ResponseSizeTooLargeError extends Error { + /** @hidden */ + constructor(message) { + super(message || "Response size too large"); + /** + * The name of the error, for identification purposes. + */ + this.name = "ResponseSizeTooLargeError"; + } + /** Returns if the error is an instance of ResponseSizeTooLargeError. Note that `instanceof` may not work. */ + static isResponseSizeTooLargeError(err) { + return "name" in err && err.name === _ResponseSizeTooLargeError.name; + } + }; + __name(_ResponseSizeTooLargeError, "ResponseSizeTooLargeError"); + var ResponseSizeTooLargeError = _ResponseSizeTooLargeError; function isDynamicSyncTable(syncTable) { return "isDynamic" in syncTable; } @@ -6164,7 +6180,8 @@ module.exports = (() => { var recognizableCodaErrorClasses2 = [ // StatusCodeError doesn't have the new StatusCodeError(message) constructor but it's okay. StatusCodeError, - MissingScopesError + MissingScopesError, + ResponseSizeTooLargeError ]; function fixUncopyableTypes(val, pathPrefix, postTransforms, depth = 0) { if (depth >= MaxTraverseDepth) { diff --git a/dist/runtime/common/marshaling/index.js b/dist/runtime/common/marshaling/index.js index 54f3f5a12a..3e2db627f9 100644 --- a/dist/runtime/common/marshaling/index.js +++ b/dist/runtime/common/marshaling/index.js @@ -5,6 +5,7 @@ const constants_1 = require("./constants"); const constants_2 = require("./constants"); const api_1 = require("../../../api"); const api_2 = require("../../../api"); +const api_3 = require("../../../api"); const serializer_1 = require("./serializer"); const util_1 = require("util"); const legacy_marshal_1 = require("../../../helpers/legacy_marshal"); @@ -54,8 +55,9 @@ const recognizableSystemErrorClasses = [ ]; const recognizableCodaErrorClasses = [ // StatusCodeError doesn't have the new StatusCodeError(message) constructor but it's okay. - api_2.StatusCodeError, + api_3.StatusCodeError, api_1.MissingScopesError, + api_2.ResponseSizeTooLargeError, ]; // pathPrefix can be temporarily modified, but needs to be restored to its original value // before returning.