@smithy/util-endpoints
Advanced tools
+9
-10
| { | ||
| "name": "@smithy/util-endpoints", | ||
| "version": "3.3.3", | ||
| "version": "3.3.4", | ||
| "description": "Utilities to help with endpoint resolution.", | ||
@@ -8,15 +8,14 @@ "main": "./dist-cjs/index.js", | ||
| "scripts": { | ||
| "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'", | ||
| "build:cjs": "node ../../scripts/inline util-endpoints", | ||
| "build:es": "yarn g:tsc -p tsconfig.es.json", | ||
| "build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'", | ||
| "build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline util-endpoints", | ||
| "build:types": "yarn g:tsc -p tsconfig.types.json", | ||
| "build:types:downlevel": "premove dist-types/ts3.4 && downlevel-dts dist-types dist-types/ts3.4", | ||
| "stage-release": "premove .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz", | ||
| "clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo", | ||
| "format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"", | ||
| "lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"", | ||
| "format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"", | ||
| "stage-release": "premove .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz", | ||
| "test": "yarn g:vitest run", | ||
| "test:integration": "yarn g:vitest run -c vitest.config.integ.mts", | ||
| "test:watch": "yarn g:vitest watch", | ||
| "test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts" | ||
| "test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts", | ||
| "test:watch": "yarn g:vitest watch" | ||
| }, | ||
@@ -33,4 +32,4 @@ "keywords": [ | ||
| "dependencies": { | ||
| "@smithy/node-config-provider": "^4.3.12", | ||
| "@smithy/types": "^4.13.1", | ||
| "@smithy/node-config-provider": "^4.3.13", | ||
| "@smithy/types": "^4.14.0", | ||
| "tslib": "^2.6.2" | ||
@@ -37,0 +36,0 @@ }, |
+10
-3
@@ -6,6 +6,13 @@ # @smithy/util-endpoints | ||
| > An internal package | ||
| ### :warning: Internal API :warning: | ||
| ## Usage | ||
| > This is an internal package. | ||
| > That means this is used as a dependency for other, public packages, but | ||
| > should not be taken directly as a dependency in your application's `package.json`. | ||
| You probably shouldn't, at least directly. | ||
| > If you are updating the version of this package, for example to bring in a | ||
| > bug-fix, you should do so by updating your application lockfile with | ||
| > e.g. `npm up @scope/package` or equivalent command in another | ||
| > package manager, rather than taking a direct dependency. | ||
| --- |
| import { EndpointParams, EndpointV2 } from "@smithy/types"; | ||
| /** | ||
| * @internal | ||
| * | ||
| * Cache for endpoint ruleSet resolution. | ||
| */ | ||
| export declare class EndpointCache { | ||
| private capacity; | ||
| private data; | ||
| private parameters; | ||
| /** | ||
| * @param [size] - desired average maximum capacity. A buffer of 10 additional keys will be allowed | ||
| * before keys are dropped. | ||
| * @param [params] - list of params to consider as part of the cache key. | ||
| * | ||
| * If the params list is not populated, no caching will happen. | ||
| * This may be out of order depending on how the object is created and arrives to this class. | ||
| */ | ||
| constructor({ size, params }: { | ||
| size?: number; | ||
| params?: string[]; | ||
| }); | ||
| /** | ||
| * @param endpointParams - query for endpoint. | ||
| * @param resolver - provider of the value if not present. | ||
| * @returns endpoint corresponding to the query. | ||
| */ | ||
| get(endpointParams: EndpointParams, resolver: () => EndpointV2): EndpointV2; | ||
| size(): number; | ||
| /** | ||
| * @returns cache key or false if not cachable. | ||
| */ | ||
| private hash; | ||
| } |
| export declare const debugId = "endpoints"; |
| export * from "./debugId"; | ||
| export * from "./toDebugString"; |
| import { EndpointParameters, EndpointV2 } from "@smithy/types"; | ||
| import { GetAttrValue } from "../lib"; | ||
| import { EndpointObject, FunctionObject, FunctionReturn } from "../types"; | ||
| export declare function toDebugString(input: EndpointParameters): string; | ||
| export declare function toDebugString(input: EndpointV2): string; | ||
| export declare function toDebugString(input: GetAttrValue): string; | ||
| export declare function toDebugString(input: FunctionObject): string; | ||
| export declare function toDebugString(input: FunctionReturn): string; | ||
| export declare function toDebugString(input: EndpointObject): string; |
| import { LoadedConfigSelectors } from "@smithy/node-config-provider"; | ||
| export declare const getEndpointUrlConfig: (serviceId: string) => LoadedConfigSelectors<string | undefined>; |
| export * from "./cache/EndpointCache"; | ||
| export * from "./lib/isIpAddress"; | ||
| export * from "./lib/isValidHostLabel"; | ||
| export * from "./utils/customEndpointFunctions"; | ||
| export * from "./resolveEndpoint"; | ||
| export * from "./types"; |
| /** | ||
| * Evaluates two boolean values value1 and value2 for equality and returns | ||
| * true if both values match. | ||
| */ | ||
| export declare const booleanEquals: (value1: boolean, value2: boolean) => boolean; |
| export type GetAttrValue = string | boolean | { | ||
| [key: string]: GetAttrValue; | ||
| } | Array<GetAttrValue>; | ||
| /** | ||
| * Returns value corresponding to pathing string for an array or object. | ||
| */ | ||
| export declare const getAttr: (value: GetAttrValue, path: string) => GetAttrValue; |
| /** | ||
| * Parses path as a getAttr expression, returning a list of strings. | ||
| */ | ||
| export declare const getAttrPathList: (path: string) => Array<string>; |
| export * from "./booleanEquals"; | ||
| export * from "./getAttr"; | ||
| export * from "./isSet"; | ||
| export * from "./isValidHostLabel"; | ||
| export * from "./not"; | ||
| export * from "./parseURL"; | ||
| export * from "./stringEquals"; | ||
| export * from "./substring"; | ||
| export * from "./uriEncode"; |
| /** | ||
| * Validates if the provided value is an IP address. | ||
| */ | ||
| export declare const isIpAddress: (value: string) => boolean; |
| /** | ||
| * Evaluates whether a value is set (aka not null or undefined). | ||
| * Returns true if the value is set, otherwise returns false. | ||
| */ | ||
| export declare const isSet: (value: unknown) => value is {}; |
| /** | ||
| * Evaluates whether one or more string values are valid host labels per RFC 1123. | ||
| * | ||
| * If allowSubDomains is true, then the provided value may be zero or more dotted | ||
| * subdomains which are each validated per RFC 1123. | ||
| */ | ||
| export declare const isValidHostLabel: (value: string, allowSubDomains?: boolean) => boolean; |
| /** | ||
| * Performs logical negation on the provided boolean value, | ||
| * returning the negated value. | ||
| */ | ||
| export declare const not: (value: boolean) => boolean; |
| import { Endpoint, EndpointURL } from "@smithy/types"; | ||
| /** | ||
| * Parses a string, URL, or Endpoint into it’s Endpoint URL components. | ||
| */ | ||
| export declare const parseURL: (value: string | URL | Endpoint) => EndpointURL | null; |
| /** | ||
| * Evaluates two string values value1 and value2 for equality and returns | ||
| * true if both values match. | ||
| */ | ||
| export declare const stringEquals: (value1: string, value2: string) => boolean; |
| /** | ||
| * Computes the substring of a given string, conditionally indexing from the end of the string. | ||
| * When the string is long enough to fully include the substring, return the substring. | ||
| * Otherwise, return None. The start index is inclusive and the stop index is exclusive. | ||
| * The length of the returned string will always be stop-start. | ||
| */ | ||
| export declare const substring: (input: string, start: number, stop: number, reverse: boolean) => string | null; |
| /** | ||
| * Performs percent-encoding per RFC3986 section 2.1 | ||
| */ | ||
| export declare const uriEncode: (value: string) => string; |
| import { EndpointV2 } from "@smithy/types"; | ||
| import { EndpointResolverOptions, RuleSetObject } from "./types"; | ||
| /** | ||
| * Resolves an endpoint URL by processing the endpoints ruleset and options. | ||
| */ | ||
| export declare const resolveEndpoint: (ruleSetObject: RuleSetObject, options: EndpointResolverOptions) => EndpointV2; |
| export declare class EndpointError extends Error { | ||
| constructor(message: string); | ||
| } |
| import { FunctionReturn } from "./shared"; | ||
| export type EndpointFunctions = Record<string, (...args: any[]) => FunctionReturn>; |
| import { EndpointObject as __EndpointObject, EndpointObjectHeaders as __EndpointObjectHeaders, EndpointObjectProperties as __EndpointObjectProperties, EndpointRuleObject as __EndpointRuleObject } from "@smithy/types"; | ||
| export type EndpointObjectProperties = __EndpointObjectProperties; | ||
| export type EndpointObjectHeaders = __EndpointObjectHeaders; | ||
| export type EndpointObject = __EndpointObject; | ||
| export type EndpointRuleObject = __EndpointRuleObject; |
| import { ErrorRuleObject as __ErrorRuleObject } from "@smithy/types"; | ||
| export type ErrorRuleObject = __ErrorRuleObject; |
| export * from "./EndpointError"; | ||
| export * from "./EndpointFunctions"; | ||
| export * from "./EndpointRuleObject"; | ||
| export * from "./ErrorRuleObject"; | ||
| export * from "./RuleSetObject"; | ||
| export * from "./TreeRuleObject"; | ||
| export * from "./shared"; |
| import { DeprecatedObject as __DeprecatedObject, ParameterObject as __ParameterObject, RuleSetObject as __RuleSetObject } from "@smithy/types"; | ||
| export type DeprecatedObject = __DeprecatedObject; | ||
| export type ParameterObject = __ParameterObject; | ||
| export type RuleSetObject = __RuleSetObject; |
| import { EndpointARN, EndpointPartition, Logger } from "@smithy/types"; | ||
| export type ReferenceObject = { | ||
| ref: string; | ||
| }; | ||
| export type FunctionObject = { | ||
| fn: string; | ||
| argv: FunctionArgv; | ||
| }; | ||
| export type FunctionArgv = Array<Expression | boolean | number>; | ||
| export type FunctionReturn = string | boolean | number | EndpointARN | EndpointPartition | { | ||
| [key: string]: FunctionReturn; | ||
| } | null; | ||
| export type ConditionObject = FunctionObject & { | ||
| assign?: string; | ||
| }; | ||
| export type Expression = string | ReferenceObject | FunctionObject; | ||
| export type EndpointParams = Record<string, string | boolean>; | ||
| export type EndpointResolverOptions = { | ||
| endpointParams: EndpointParams; | ||
| logger?: Logger; | ||
| }; | ||
| export type ReferenceRecord = Record<string, FunctionReturn>; | ||
| export type EvaluateOptions = EndpointResolverOptions & { | ||
| referenceRecord: ReferenceRecord; | ||
| }; |
| import { RuleSetRules as __RuleSetRules, TreeRuleObject as __TreeRuleObject } from "@smithy/types"; | ||
| export type RuleSetRules = __RuleSetRules; | ||
| export type TreeRuleObject = __TreeRuleObject; |
| export { callFunction } from "./evaluateExpression"; |
| import { EndpointFunctions } from "../types/EndpointFunctions"; | ||
| export declare const customEndpointFunctions: { | ||
| [key: string]: EndpointFunctions; | ||
| }; |
| export declare const endpointFunctions: { | ||
| booleanEquals: (value1: boolean, value2: boolean) => boolean; | ||
| getAttr: (value: import("../lib").GetAttrValue, path: string) => import("../lib").GetAttrValue; | ||
| isSet: (value: unknown) => value is {}; | ||
| isValidHostLabel: (value: string, allowSubDomains?: boolean) => boolean; | ||
| not: (value: boolean) => boolean; | ||
| parseURL: (value: string | URL | import("@smithy/types").Endpoint) => import("@smithy/types").EndpointURL | null; | ||
| stringEquals: (value1: string, value2: string) => boolean; | ||
| substring: (input: string, start: number, stop: number, reverse: boolean) => string | null; | ||
| uriEncode: (value: string) => string; | ||
| }; |
| import { ConditionObject, EvaluateOptions } from "../types"; | ||
| export declare const evaluateCondition: ({ assign, ...fnArgs }: ConditionObject, options: EvaluateOptions) => { | ||
| toAssign?: { | ||
| name: string; | ||
| value: import("../types").FunctionReturn; | ||
| } | undefined; | ||
| result: boolean; | ||
| }; |
| import { ConditionObject, EvaluateOptions, FunctionReturn } from "../types"; | ||
| export declare const evaluateConditions: (conditions: ConditionObject[] | undefined, options: EvaluateOptions) => { | ||
| result: false; | ||
| referenceRecord?: undefined; | ||
| } | { | ||
| result: boolean; | ||
| referenceRecord: Record<string, FunctionReturn>; | ||
| }; |
| import { EndpointV2 } from "@smithy/types"; | ||
| import { EndpointRuleObject, EvaluateOptions } from "../types"; | ||
| export declare const evaluateEndpointRule: (endpointRule: EndpointRuleObject, options: EvaluateOptions) => EndpointV2 | undefined; |
| import { ErrorRuleObject, EvaluateOptions } from "../types"; | ||
| export declare const evaluateErrorRule: (errorRule: ErrorRuleObject, options: EvaluateOptions) => void; |
| import { EvaluateOptions, Expression, FunctionObject, FunctionReturn } from "../types"; | ||
| export declare const evaluateExpression: (obj: Expression, keyName: string, options: EvaluateOptions) => FunctionReturn; | ||
| export declare const callFunction: ({ fn, argv }: FunctionObject, options: EvaluateOptions) => FunctionReturn; | ||
| export declare const group: { | ||
| evaluateExpression: (obj: Expression, keyName: string, options: EvaluateOptions) => FunctionReturn; | ||
| callFunction: ({ fn, argv }: FunctionObject, options: EvaluateOptions) => FunctionReturn; | ||
| }; |
| import { EndpointV2 } from "@smithy/types"; | ||
| import { EvaluateOptions, RuleSetRules, TreeRuleObject } from "../types"; | ||
| export declare const evaluateRules: (rules: RuleSetRules, options: EvaluateOptions) => EndpointV2; | ||
| export declare const evaluateTreeRule: (treeRule: TreeRuleObject, options: EvaluateOptions) => EndpointV2 | undefined; | ||
| export declare const group: { | ||
| evaluateRules: (rules: RuleSetRules, options: EvaluateOptions) => EndpointV2; | ||
| evaluateTreeRule: (treeRule: TreeRuleObject, options: EvaluateOptions) => EndpointV2 | undefined; | ||
| }; |
| import { EvaluateOptions } from "../types"; | ||
| export declare const evaluateTemplate: (template: string, options: EvaluateOptions) => string; |
| export { evaluateTreeRule } from "./evaluateRules"; |
| import { EndpointObjectHeaders, EvaluateOptions } from "../types"; | ||
| export declare const getEndpointHeaders: (headers: EndpointObjectHeaders, options: EvaluateOptions) => {}; |
| import { EndpointObjectProperty } from "@smithy/types"; | ||
| import { EndpointObjectProperties, EvaluateOptions } from "../types"; | ||
| export declare const getEndpointProperties: (properties: EndpointObjectProperties, options: EvaluateOptions) => {}; | ||
| export declare const getEndpointProperty: (property: EndpointObjectProperty, options: EvaluateOptions) => EndpointObjectProperty; | ||
| export declare const group: { | ||
| getEndpointProperty: (property: EndpointObjectProperty, options: EvaluateOptions) => EndpointObjectProperty; | ||
| getEndpointProperties: (properties: EndpointObjectProperties, options: EvaluateOptions) => {}; | ||
| }; |
| export { getEndpointProperty } from "./getEndpointProperties"; |
| import { EvaluateOptions, Expression } from "../types"; | ||
| export declare const getEndpointUrl: (endpointUrl: Expression, options: EvaluateOptions) => URL; |
| import { EvaluateOptions, ReferenceObject } from "../types"; | ||
| export declare const getReferenceValue: ({ ref }: ReferenceObject, options: EvaluateOptions) => import("../types").FunctionReturn; |
| export * from "./customEndpointFunctions"; | ||
| export * from "./evaluateRules"; |
18
63.64%62649
-16%92
-32.35%1218
-17.03%