Skip to content

Commit

Permalink
feat(types): use retry-as-promised types for retry options to match d…
Browse files Browse the repository at this point in the history
…ocumentation (#15400)

* use retry-as-promised types for retry options

* prefer exact package version

* move to production deps

* unpin @types/retry-as-promised

* import retry-as-promised

* retry-as-promised typings re-exported

* import and re-export Options from retry-as-promised after mickhansen/retry-as-promised#38

Co-authored-by: Rik Smale <13023439+WikiRik@users.noreply.github.com>
  • Loading branch information
esetnik and WikiRik committed Dec 8, 2022
1 parent 9c2ae3c commit f2574ae
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -55,7 +55,7 @@
"inflection": "^2.0.0",
"lodash": "^4.17.21",
"pg-connection-string": "^2.5.0",
"retry-as-promised": "^6.0.0",
"retry-as-promised": "^7.0.3",
"semver": "^7.3.7",
"sequelize-pool": "^8.0.0",
"toposort-class": "^1.0.1",
Expand Down
13 changes: 3 additions & 10 deletions src/sequelize.d.ts
@@ -1,3 +1,4 @@
import type { Options as RetryAsPromisedOptions } from 'retry-as-promised';
import type { AbstractDialect } from './dialects/abstract';
import type { AbstractConnectionManager } from './dialects/abstract/connection-manager';
import type { AbstractDataType, DataTypeClassOrInstance } from './dialects/abstract/data-types.js';
Expand Down Expand Up @@ -25,6 +26,8 @@ import type { SequelizeHooks } from './sequelize-typescript.js';
import type { Cast, Col, Fn, Json, Literal, Where } from './utils/sequelize-method.js';
import type { QueryTypes, TRANSACTION_TYPES, ISOLATION_LEVELS, PartlyRequired, Op, DataTypes } from '.';

export type RetryOptions = RetryAsPromisedOptions;

/**
* Additional options for table altering during sync
*/
Expand Down Expand Up @@ -169,16 +172,6 @@ export interface Config {

export type Dialect = 'mysql' | 'postgres' | 'sqlite' | 'mariadb' | 'mssql' | 'db2' | 'snowflake' | 'ibmi';

export interface RetryOptions {
match?: Array<RegExp | string | Function>;
max?: number;
timeout?: number;
backoffBase?: number;
backoffExponent?: number;
report?(msg: string, options: RetryOptions & { $current: number }): void;
name?: string;
}

/**
* Options for the constructor of the {@link Sequelize} main class.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/sequelize.js
@@ -1,6 +1,7 @@
'use strict';

import isPlainObject from 'lodash/isPlainObject';
import retry from 'retry-as-promised';
import { normalizeDataType } from './dialects/abstract/data-types-utils';
import { SequelizeTypeScript } from './sequelize-typescript';
import { withSqliteForeignKeysOff } from './dialects/sqlite/sqlite-utils';
Expand All @@ -13,7 +14,6 @@ import { useInflection } from './utils/string';
import { parseConnectionString } from './utils/url';
import { importModels } from './import-models.js';

const retry = require('retry-as-promised');
const _ = require('lodash');
const { Model } = require('./model');
const DataTypes = require('./data-types');
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -7351,10 +7351,10 @@ restore-cursor@^3.1.0:
onetime "^5.1.0"
signal-exit "^3.0.2"

retry-as-promised@^6.0.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/retry-as-promised/-/retry-as-promised-6.1.0.tgz#11eca9a0f97804d552ec8e74bc4eb839bd226dc4"
integrity sha512-Hj/jY+wFC+SB9SDlIIFWiGOHnNG0swYbGYsOj2BJ8u2HKUaobNKab0OIC0zOLYzDy0mb7A4xA5BMo4LMz5YtEA==
retry-as-promised@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/retry-as-promised/-/retry-as-promised-7.0.3.tgz#ca3c13b15525a7bfbf0f56d2996f0e75649d068b"
integrity sha512-SEvMa4khHvpU/o6zgh7sK24qm6rxVgKnrSyzb5POeDvZx5N9Bf0s5sQsQ4Fl+HjRp0X+w2UzACGfUnXtx6cJ9Q==

retry@^0.12.0:
version "0.12.0"
Expand Down

0 comments on commit f2574ae

Please sign in to comment.