UNPKG

@shipengine/connect-order-source-api

Version:

This is the typescript/javascript definitions for the order source api

164 lines 9.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AuthorizationConfigurationSchema = exports.AuthorizationConfiguration = exports.ConnectionNamesConfigurationSchema = exports.ConnectionNamesConfiguration = exports.NonceConfigurationSchema = exports.NonceConfiguration = exports.RefreshTokenConfigurationSchema = exports.RefreshTokenConfiguration = exports.RequestTokenConfigurationSchema = exports.RequestTokenConfiguration = exports.AccessTokenSchema = exports.AccessToken = exports.ResponseTransformationConfigurationSchema = exports.MapOfObjectsSchema = exports.MapOfStringsSchema = exports.ResponseTransformationConfiguration = exports.DateTimeConfigurationSchema = exports.DateTimeConfiguration = exports.ParameterSchema = exports.MethodSchema = exports.Parameter = void 0; const tslib_1 = require("tslib"); const joi_1 = tslib_1.__importDefault(require("joi")); class Parameter { /** @description The name of the parameter */ name; /** @description The value associated with the parameter */ value; } exports.Parameter = Parameter; exports.MethodSchema = joi_1.default.string().valid('GET', 'POST', 'DELETE', 'PUT', 'get', 'post', 'delete', 'put'); exports.ParameterSchema = joi_1.default.object({ name: joi_1.default.string().required(), value: joi_1.default.string().required(), }); class DateTimeConfiguration { /** @description JSONPath to the JSON element containing the date-time */ path; /** @description DateTime format string compliant with * https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings */ date_time_format; } exports.DateTimeConfiguration = DateTimeConfiguration; exports.DateTimeConfigurationSchema = joi_1.default.object({ path: joi_1.default.string().required(), date_time_format: joi_1.default.string().required(), }); /** @description Optional configuration to take full control of parsing and extracting fields * from the integration's JSON response body. * Note for JSONPath: strings not starting with $ are interpreted as string literals */ class ResponseTransformationConfiguration { /** @description JSONPath to the JSON element for access_token. */ access_token; /** @description JSONPath to the JSON element for token_type */ token_type; /** @description JSONPath to the JSON element for refresh_token */ refresh_token; /** @description JSONPath to the JSON element for expires_in. Mutually exclusive with expires_at */ expires_in; /** @description Configuration for parsing a date-time, when the integration is lacking expires_in. * Mutually exclusive with expires_in. */ expires_at; /** @description Optional collection of properties to include in the connection_context sent back with the auth flow result. * Property value may be JSONPath or a string literal. * E.g. * "connection_context": { * "store_id": "$.data.store_id" * } */ connection_context; } exports.ResponseTransformationConfiguration = ResponseTransformationConfiguration; exports.MapOfStringsSchema = joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string()); exports.MapOfObjectsSchema = joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.object()); exports.ResponseTransformationConfigurationSchema = joi_1.default.object({ access_token: joi_1.default.string().required(), token_type: joi_1.default.string().required(), refresh_token: joi_1.default.string().optional(), expires_in: joi_1.default.string().optional(), expires_at: exports.DateTimeConfigurationSchema.optional(), connection_context: exports.MapOfStringsSchema.optional(), }); class AccessToken { /** @description OAuth1 only. The url to obtain the temporary Access (aka Request) Token to start a flow **/ url_template; } exports.AccessToken = AccessToken; exports.AccessTokenSchema = joi_1.default.object({ url_template: joi_1.default.string().required(), }); class RequestTokenConfiguration { /** @description The url to obtain the access token using the authorization code on the backend @example "http://{auth_state:store_name}.store.com/admin/oauth/request", "http://store.com/oauth/request" */ url_template; /** @description A list of query parameters that will be attached to the url */ query_parameters; /** @description Method to use when making the server-server code for token request @example "GET", "POST" */ method; /** @description List of parameters that are sent to the integration when exchanging the code for the token. These are built using ContentType */ body; /** @description List of headers that are sent to the integration when requesting a token */ headers; /** @description Response payload parsing */ response; } exports.RequestTokenConfiguration = RequestTokenConfiguration; exports.RequestTokenConfigurationSchema = joi_1.default.object({ url_template: joi_1.default.string().required(), query_parameters: joi_1.default.array().optional().items(exports.ParameterSchema), method: exports.MethodSchema.optional(), body: joi_1.default.array().optional().items(exports.ParameterSchema), headers: joi_1.default.array().optional().items(exports.ParameterSchema), response: exports.ResponseTransformationConfigurationSchema.optional(), }); class RefreshTokenConfiguration { /** @description The url to refresh the access token using the authorization code on the backend @example "http://{auth_state:store_name}.store.com/admin/oauth/refresh", "http://store.com/oauth/refresh" */ url_template; /** @description A list of query parameters that will be attached to the url */ query_parameters; /** @description Method to use when making the server-server code for token request @example "GET", "POST" */ method; /** @description List of parameters that are sent to the integration during the server-server refresh token request. These are built using the content type specified in the headers array. */ body; /** @description List of headers that are sent to the integration when refreshing a token */ headers; /** @description Response payload parsing */ response; } exports.RefreshTokenConfiguration = RefreshTokenConfiguration; exports.RefreshTokenConfigurationSchema = joi_1.default.object({ url_template: joi_1.default.string().required(), query_parameters: joi_1.default.array().optional().items(exports.ParameterSchema), method: exports.MethodSchema.optional(), body: joi_1.default.array().optional().items(exports.ParameterSchema), headers: joi_1.default.array().optional().items(exports.ParameterSchema), response: exports.ResponseTransformationConfigurationSchema.optional(), }); class NonceConfiguration { name; } exports.NonceConfiguration = NonceConfiguration; exports.NonceConfigurationSchema = joi_1.default.object({ name: joi_1.default.string().required(), }); class ConnectionNamesConfiguration { /** @description A unique list of connection names that the integration supports. */ connection_names; /** @description The connection name that will be used when none is selected. */ default_connection_name; } exports.ConnectionNamesConfiguration = ConnectionNamesConfiguration; exports.ConnectionNamesConfigurationSchema = joi_1.default.object({ connection_names: exports.MapOfObjectsSchema.required(), default_connection_name: joi_1.default.string().required(), }); class AuthorizationConfiguration { /** @description The url to obtain the access token using the authorization code on the backend * @example "http://{auth_state:store_name}.store.com/admin/oauth/authorize", "http://store.com/oauth/authorize" */ url_template; /** @description A list of query parameters that will be attached to the url */ query_parameters; /** @description Method to use when making the server-server code for token request @example "GET", "POST" */ method; /** @description List of parameters that are sent to the integration during the server-server * authorization request. These are built using the content type specified in the headers array. */ body; /** @description List of headers that are sent to the integration when authorizing a token */ headers; /** @description A nonce query parameter included on the accept request, then returned and validated on the redirect request */ nonce; } exports.AuthorizationConfiguration = AuthorizationConfiguration; exports.AuthorizationConfigurationSchema = joi_1.default.object({ url_template: joi_1.default.string().required(), query_parameters: joi_1.default.array().optional().items(exports.ParameterSchema), method: exports.MethodSchema.optional(), body: joi_1.default.array().optional().items(exports.ParameterSchema), headers: joi_1.default.array().optional().items(exports.ParameterSchema), nonce: exports.NonceConfigurationSchema.optional(), }); //# sourceMappingURL=monoauth.js.map