Skip to content

Commit

Permalink
Merge pull request #342 from DougMidgley/develop
Browse files Browse the repository at this point in the history
July 7 2024 Patch of SFMC-SDK
  • Loading branch information
DougMidgley committed Jul 5, 2024
2 parents 572b954 + e62159c commit 28609eb
Show file tree
Hide file tree
Showing 19 changed files with 224 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# update typescript type declarations
npx tsc
npx tsc -p tsconfig.precommit.json
git add @types
70 changes: 48 additions & 22 deletions @types/auth.d.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,72 @@
/**
* @typedef {object} AuthObject - Auth object
* @property {number} [expiration] - expiration time of token
* @property {string} access_token - access token
* @property {string} client_id - client id of installed package
* @property {string} client_secret - client secret of installed package
* @property {string} auth_url - auth url for the SFMC instance
* @property {string} account_id - MID of the business unit you want to access
* @property {string[]} [scope] - array of scopes for the request
*/
/**
* Class which handles authentication logic
*/
export default class Auth {
/**
* Creates an instance of Auth.
*
* @param {object} authObject Auth Payload
* @param {string} authObject.client_id Client Id from SFMC config
* @param {string} authObject.client_secret Client Secret from SFMC config
* @param {number} authObject.account_id MID of Business Unit used for API Calls
* @param {string} authObject.auth_url Auth URL from SFMC config
* @param {string[]} [authObject.scope] Array of scopes used for requests
* @param {AuthObject} authObject Auth Payload
* @param {object} options options for the SDK as a whole, for example collection of handler functions, or retry settings
*/
constructor(authObject: {
client_id: string;
client_secret: string;
account_id: number;
auth_url: string;
scope?: string[];
}, options: object);
authObject: {
client_id: string;
client_secret: string;
account_id: number;
auth_url: string;
scope?: string[];
};
constructor(authObject: AuthObject, options: object);
authObject: AuthObject;
options: any;
/**
*
*
* @param {boolean} [forceRefresh] used to enforce a refresh of token
* @param {number} [remainingAttempts] number of retries in case of issues
* @returns {Promise.<object>} current session information
* @returns {Promise.<any>} current session information
*/
getAccessToken(forceRefresh?: boolean, remainingAttempts?: number): Promise<object>;
getAccessToken(forceRefresh?: boolean, remainingAttempts?: number): Promise<any>;
/**
* Helper to get back list of scopes supported by SDK
*
* @returns {string[]} array of potential scopes
*/
getSupportedScopes(): string[];
}
/**
* - Auth object
*/
export type AuthObject = {
/**
* - expiration time of token
*/
expiration?: number;
/**
* - access token
*/
access_token: string;
/**
* - client id of installed package
*/
client_id: string;
/**
* - client secret of installed package
*/
client_secret: string;
/**
* - auth url for the SFMC instance
*/
auth_url: string;
/**
* - MID of the business unit you want to access
*/
account_id: string;
/**
* - array of scopes for the request
*/
scope?: string[];
};
//# sourceMappingURL=auth.d.ts.map
2 changes: 1 addition & 1 deletion @types/auth.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions @types/rest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default class Rest {
* Method that makes the GET API request
*
* @param {string} url of the resource to retrieve
* @returns {Promise.<object>} API response
* @returns {Promise.<any>} API response
*/
get(url: string): Promise<object>;
get(url: string): Promise<any>;
/**
* helper for {@link this.getBulk} to determine if the url is a transactional message API
*
Expand All @@ -42,9 +42,9 @@ export default class Rest {
* @param {string} url of the resource to retrieve
* @param {number} [pageSize] of the response, defaults to 50
* @param {string} [iteratorField] attribute of the response to iterate over (only required if it's not 'items'|'definitions'|'entry')
* @returns {Promise.<object>} API response combined items
* @returns {Promise.<any>} API response combined items
*/
getBulk(url: string, pageSize?: number, iteratorField?: string): Promise<object>;
getBulk(url: string, pageSize?: number, iteratorField?: string): Promise<any>;
/**
* Method that makes a GET API request for each URL (including rate limiting)
*
Expand All @@ -59,42 +59,42 @@ export default class Rest {
* @param {string} url of the resource to create
* @param {object} payload for the POST request body
* @param {object} [headers] optional headers to include in the request; note that Authorization-header is always overwritten
* @returns {Promise.<object>} API response
* @returns {Promise.<any>} API response
*/
post(url: string, payload: object, headers?: object): Promise<object>;
post(url: string, payload: object, headers?: object): Promise<any>;
/**
* Method that makes the PUT api request
*
* @param {string} url of the resource to replace
* @param {object} payload for the PUT request body
* @param {object} [headers] optional headers to include in the request; note that Authorization-header is always overwritten
* @returns {Promise.<object>} API response
* @returns {Promise.<any>} API response
*/
put(url: string, payload: object, headers?: object): Promise<object>;
put(url: string, payload: object, headers?: object): Promise<any>;
/**
* Method that makes the PATCH api request
*
* @param {string} url of the resource to update
* @param {object} payload for the PATCH request body
* @param {object} [headers] optional headers to include in the request; note that Authorization-header is always overwritten
* @returns {Promise.<object>} API response
* @returns {Promise.<any>} API response
*/
patch(url: string, payload: object, headers?: object): Promise<object>;
patch(url: string, payload: object, headers?: object): Promise<any>;
/**
* Method that makes the DELETE api request
*
* @param {string} url of the resource to delete
* @returns {Promise.<object>} API response
* @returns {Promise.<any>} API response
*/
delete(url: string): Promise<object>;
delete(url: string): Promise<any>;
/**
* Method that makes the api request
*
* @param {object} requestOptions configuration for the request including body
* @param {number} remainingAttempts number of times this request should be reattempted in case of error
* @param {object} [headers] optional headers to include in the request; note that Authorization-header is always overwritten
* @returns {Promise.<object>} Results from the Rest request in Object format
* @returns {Promise.<any>} Results from the Rest request in Object format
*/
_apiRequest(requestOptions: object, remainingAttempts: number, headers?: object): Promise<object>;
_apiRequest(requestOptions: object, remainingAttempts: number, headers?: object): Promise<any>;
}
//# sourceMappingURL=rest.d.ts.map
2 changes: 1 addition & 1 deletion @types/rest.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 22 additions & 22 deletions @types/soap.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,45 @@ export default class Soap {
* @param {string} type - SOAP Object type
* @param {string[]} propertiesList - Properties which should be retrieved
* @param {object} [requestParameters] - additional RetrieveRequest parameters, for example filter or options
* @returns {Promise.<object>} SOAP object converted from XML
* @returns {Promise.<any>} SOAP object converted from XML
*/
retrieve(type: string, propertiesList: string[], requestParameters?: object): Promise<object>;
retrieve(type: string, propertiesList: string[], requestParameters?: object): Promise<any>;
/**
* Method used to retrieve all data via SOAP API
*
* @param {string} type - SOAP Object type
* @param {string[]} propertiesList - Properties which should be retrieved
* @param {object} [requestParameters] - additional RetrieveRequest parameters, for example filter or options
* @returns {Promise.<object>} SOAP object converted from XML
* @returns {Promise.<any>} SOAP object converted from XML
*/
retrieveBulk(type: string, propertiesList: string[], requestParameters?: object): Promise<object>;
retrieveBulk(type: string, propertiesList: string[], requestParameters?: object): Promise<any>;
/**
* Method used to create data via SOAP API
*
* @param {string} type - SOAP Object type
* @param {object} properties - Properties with values which should be created
* @param {object} [requestParameters] - additional RetrieveRequest parameters, for example filter or options
* @returns {Promise.<object>} SOAP object converted from XML
* @returns {Promise.<any>} SOAP object converted from XML
*/
create(type: string, properties: object, requestParameters?: object): Promise<object>;
create(type: string, properties: object, requestParameters?: object): Promise<any>;
/**
* Method used to update data via SOAP API
*
* @param {string} type - SOAP Object type
* @param {object} properties - Properties with values which should be updated
* @param {object} [requestParameters] - additional RetrieveRequest parameters, for example filter or options
* @returns {Promise.<object>} SOAP object converted from XML
* @returns {Promise.<any>} SOAP object converted from XML
*/
update(type: string, properties: object, requestParameters?: object): Promise<object>;
update(type: string, properties: object, requestParameters?: object): Promise<any>;
/**
* Method used to delete data via SOAP API
*
* @param {string} type - SOAP Object type
* @param {object} properties - Properties with values
* @param {object} [requestParameters] - additional RetrieveRequest parameters, for example filter or options
* @returns {Promise.<object>} SOAP object converted from XML
* @returns {Promise.<any>} SOAP object converted from XML
*/
delete(type: string, properties: object, requestParameters?: object): Promise<object>;
delete(type: string, properties: object, requestParameters?: object): Promise<any>;
/**
* Method used to schedule data via SOAP API
*
Expand All @@ -65,48 +65,48 @@ export default class Soap {
* @param {Array | object} interactions - Object or array of interactions
* @param {string} action - type of schedule
* @param {object} [options] - additional options for the request
* @returns {Promise.<object>} SOAP object converted from XML
* @returns {Promise.<any>} SOAP object converted from XML
*/
schedule(type: string, schedule: object, interactions: any[] | object, action: string, options?: object): Promise<object>;
schedule(type: string, schedule: object, interactions: any[] | object, action: string, options?: object): Promise<any>;
/**
* Method used to describe metadata via SOAP API
*
* @param {string} type - SOAP Object type
* @returns {Promise.<object>} SOAP object converted from XML
* @returns {Promise.<any>} SOAP object converted from XML
*/
describe(type: string): Promise<object>;
describe(type: string): Promise<any>;
/**
* Method used to execute data via SOAP API
*
* @param {string} type - SOAP Object type
* @param {object} properties - Properties with values
* @returns {Promise.<object>} SOAP object converted from XML
* @returns {Promise.<any>} SOAP object converted from XML
*/
execute(type: string, properties: object): Promise<object>;
execute(type: string, properties: object): Promise<any>;
/**
* Method used to execute data via SOAP API
*
* @param {string} type - SOAP Object type
* @param {string} action - type of action, for example 'Start'
* @param {object} payload - relevant payload to perform, for example query Definition
* @returns {Promise.<object>} SOAP object converted from XML
* @returns {Promise.<any>} SOAP object converted from XML
*/
perform(type: string, action: string, payload: object): Promise<object>;
perform(type: string, action: string, payload: object): Promise<any>;
/**
* Method used to configure data via SOAP API
*
* @param {string} type - SOAP Object type
* @param {object[]} configArray - Properties which should be updated
* @returns {Promise.<object>} SOAP object converted from XML
* @returns {Promise.<any>} SOAP object converted from XML
*/
configure(type: string, configArray: object[]): Promise<object>;
configure(type: string, configArray: object[]): Promise<any>;
/**
* Method that makes the api request
*
* @param {object} options configuration for the request including body
* @param {number} remainingAttempts number of times this request should be reattempted in case of error
* @returns {Promise.<object>} Results from the SOAP request in Object format
* @returns {Promise.<any>} Results from the SOAP request in Object format
*/
_apiRequest(options: object, remainingAttempts: number): Promise<object>;
_apiRequest(options: object, remainingAttempts: number): Promise<any>;
}
//# sourceMappingURL=soap.d.ts.map
2 changes: 1 addition & 1 deletion @types/soap.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 41 additions & 7 deletions @types/util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export function isPayload(object: object): boolean;
*/
export function isConnectionError(code: string): boolean;
/**
* @typedef {object} EnhancedRestError - Error object
* @augments {Error}
* @typedef {object} EnhancedRestErrorHelper - Error object
* @property {object} response -
* @property {string} code -
* @property {string} endpoint -
* @typedef {Error & EnhancedRestErrorHelper} EnhancedRestError - Error object
*/
/**
* CustomError type for handling REST (including Auth) based errors
Expand All @@ -39,15 +39,15 @@ export class RestError extends Error {
*/
constructor(ex: EnhancedRestError);
code: any;
endpoint: any;
endpoint: string;
response: any;
}
/**
* @typedef {object} EnhancedSoapError - Error object
* @augments {Error}
* @typedef {object} EnhancedSoapErrorHelper - Error object
* @property {object} response -
* @property {string} code -
* @property {string} endpoint -
* @typedef {Error & EnhancedSoapErrorHelper } EnhancedSoapError - Error object
*/
/**
* CustomError type for handling SOAP based errors
Expand All @@ -71,9 +71,43 @@ export const axiosInstance: import("axios").AxiosInstance;
/**
* - Error object
*/
export type EnhancedRestError = object;
export type EnhancedRestErrorHelper = {
/**
* -
*/
response: object;
/**
* -
*/
code: string;
/**
* -
*/
endpoint: string;
};
/**
* - Error object
*/
export type EnhancedRestError = Error & EnhancedRestErrorHelper;
/**
* - Error object
*/
export type EnhancedSoapErrorHelper = {
/**
* -
*/
response: object;
/**
* -
*/
code: string;
/**
* -
*/
endpoint: string;
};
/**
* - Error object
*/
export type EnhancedSoapError = object;
export type EnhancedSoapError = Error & EnhancedSoapErrorHelper;
//# sourceMappingURL=util.d.ts.map
Loading

0 comments on commit 28609eb

Please sign in to comment.