@adobe/acc-js-sdk
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -7,3 +7,4 @@ module.exports = { | ||
"node": true, | ||
"jest": true | ||
"jest": true, | ||
circus: true | ||
}, | ||
@@ -10,0 +11,0 @@ "extends": "eslint:recommended", |
@@ -8,2 +8,7 @@ # Adobe Campaign Classic (ACC) SDK in JavaScript (node.js and browser) | ||
## Version 1.1.6 | ||
_2022_08_19_ | ||
* New auto-refresh mechanism to keep schemas and option caches up-to-date. See `client.startRefreshCaches` and `client.stopRefreshCaches` functions. | ||
## Version 1.1.5 | ||
@@ -10,0 +15,0 @@ _2022/07/07__ |
@@ -39,2 +39,3 @@ /* | ||
{ name: "./optionCache.js" }, | ||
{ name: "./cacheRefresher.js" }, | ||
{ name: "./soap.js" }, | ||
@@ -41,0 +42,0 @@ { name: "./crypto.js" }, |
{ | ||
"name": "@adobe/acc-js-sdk", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "ACC Javascript SDK", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -68,2 +68,12 @@ /* | ||
// ======================================================================================== | ||
/** | ||
* A cache of schemas of type `XtkSchema` instead of plain XML or JSON objects | ||
* | ||
* @private | ||
* @class | ||
* @constructor | ||
* @memberof Campaign | ||
*/ | ||
class SchemaCache { | ||
@@ -74,2 +84,9 @@ constructor(client) { | ||
} | ||
/** | ||
* Get a schema by id from schema cache of type `XtkSchema` | ||
* | ||
* @param {string} schemaId | ||
* @returns {Campaign.XtkSchema} the schema, or null if the schema was not found | ||
*/ | ||
async getSchema(schemaId) { | ||
@@ -80,6 +97,15 @@ let schema = this._schemas[schemaId]; | ||
if (!schema) schema = null; // null = not found | ||
this._schemas[schemaId] = schema; | ||
this._schemas[schemaId] = schema; | ||
} | ||
return schema; | ||
} | ||
/** | ||
* Remove a schema from schema cache. The callback function when refreshing cache in cacheRefresher | ||
* | ||
* @param {string} schemaId | ||
*/ | ||
invalidateCacheItem(schemaId) { | ||
this._schemas[schemaId] = undefined; | ||
} | ||
} | ||
@@ -1243,2 +1269,9 @@ | ||
_registerCacheChangeListener() { | ||
this.client._registerCacheChangeListener(this._schemaCache); | ||
} | ||
_unregisterCacheChangeListener() { | ||
this.client._unregisterCacheChangeListener(this._schemaCache); | ||
} | ||
/** | ||
@@ -1255,3 +1288,3 @@ * Get a schema by id. This function returns an XtkSchema object or null if the schema is not found. | ||
// Private function: get a schema without using the cache | ||
// Private function: get a schema without using the SchemaCache | ||
async _getSchema(schemaId) { | ||
@@ -1258,0 +1291,0 @@ const xml = await this.client.getSchema(schemaId, "xml"); |
@@ -126,2 +126,3 @@ /* | ||
} | ||
} | ||
@@ -247,3 +248,3 @@ | ||
* Put a value from the cache | ||
* @param {*} key the key or keys of the value to retreive | ||
* @param {*} key the key or keys of the value to retrieve | ||
* @param {*} value the value to cache | ||
@@ -271,2 +272,11 @@ * @returns {CachedObject} a cached object containing the cached value | ||
} | ||
/** | ||
* Remove a key from the cache | ||
* @param {string} key the key to remove | ||
*/ | ||
remove(key) { | ||
delete this._cache[key]; | ||
this._remove(key); | ||
} | ||
} | ||
@@ -273,0 +283,0 @@ |
@@ -57,4 +57,19 @@ /* | ||
}) | ||
}) | ||
it("Should remove key in cache", () => { | ||
const cache = new Cache(); | ||
cache.put("Hello", "World"); | ||
cache.put("Hi", "A"); | ||
expect(cache.get("Hello")).toBe("World"); | ||
expect(cache.get("Hi")).toBe("A"); | ||
cache.remove("Hello"); | ||
expect(cache.get("Hello")).toBeUndefined(); | ||
expect(cache.get("Hi")).toBe("A"); | ||
// should support removing a key which has already been removed | ||
cache.remove("Hello"); | ||
expect(cache.get("Hello")).toBeUndefined(); | ||
expect(cache.get("Hi")).toBe("A"); | ||
}) | ||
}); | ||
describe("Entity cache", function() { | ||
@@ -61,0 +76,0 @@ it("Should cache value", function() { |
@@ -617,4 +617,64 @@ /* | ||
const GETMODIFIEDENTITIES_RESPONSE = Promise.resolve(`<?xml version='1.0'?> | ||
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:session' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'> | ||
<SOAP-ENV:Body> | ||
<GetModifiedEntitiesResponse xmlns='urn:xtk:session' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'> | ||
<pdomDirtyEntities xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'> | ||
<cache buildNumber="9468" time="2022-07-27T14:38:55.766Z"/> | ||
</pdomDirtyEntities> | ||
</GetModifiedEntitiesResponse> | ||
</SOAP-ENV:Body> | ||
</SOAP-ENV:Envelope>`); | ||
const GETMODIFIEDENTITIES_CLEAR_RESPONSE = Promise.resolve(`<?xml version='1.0'?> | ||
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:session' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'> | ||
<SOAP-ENV:Body> | ||
<GetModifiedEntitiesResponse xmlns='urn:xtk:session' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'> | ||
<pdomDirtyEntities xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'> | ||
<cache buildNumber="9469" time="2022-07-28T14:38:55.766Z" emptyCache="true"/> | ||
</pdomDirtyEntities> | ||
</GetModifiedEntitiesResponse> | ||
</SOAP-ENV:Body> | ||
</SOAP-ENV:Envelope>`); | ||
const GETMODIFIEDENTITIES_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?> | ||
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:session' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'> | ||
<SOAP-ENV:Body> | ||
<GetModifiedEntitiesResponse xmlns='urn:xtk:session' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'> | ||
<pdomDirtyEntities xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'> | ||
<cache buildNumber="9469" time="2022-07-28T15:32:00.785Z"> | ||
<entityCache lastModified="2022-07-28 15:31:56.331Z" md5="5581959609FEC4B2A9CDBD171BA42E7D" pk="xtk:schema|nms:recipient" schema="xtk:schema"/> | ||
<entityCache lastModified="2022-07-28 15:31:56.353Z" md5="B27CC681D00C3FA85DDA0B210FE76566" pk="xtk:schema|nms:replicationStrategy" schema="xtk:schema"/> | ||
<entityCache lastModified="2022-07-28 15:31:56.478Z" md5="E39D051D4D00805693EBA4F72F5ABD7D" pk="xtk:schema|nms:recipientStg" schema="xtk:schema"/> | ||
<entityCache lastModified="2022-07-28 15:31:56.440Z" md5="23B1FE988F0DCDC88C9F96D06C97FA14" pk="xtk:schema|xxl:xtkFolderXl" schema="xtk:schema"/> | ||
<entityCache lastModified="2022-07-28 15:31:56.440Z" md5="23B1FE988F0DCDC88C9F96D06C97FA14" pk="xtk:schema|nms:extAccount" schema="xtk:schema"/> | ||
<entityCache lastModified="2022-07-28 15:31:56.440Z" md5="23B1FE988F0DCDC88C9F96D06C97FA14" pk="xtk:option|testOption" schema="xtk:option"/> | ||
</cache> | ||
</pdomDirtyEntities> | ||
</GetModifiedEntitiesResponse> | ||
</SOAP-ENV:Body> | ||
</SOAP-ENV:Envelope>`); | ||
const GETMODIFIEDENTITIES_UNDEFINED_RESPONSE = Promise.resolve(`<?xml version='1.0'?> | ||
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'> | ||
<SOAP-ENV:Body> | ||
<SOAP-ENV:Fault> | ||
<faultcode>SOAP-ENV:Client</faultcode> | ||
<faultstring xsi:type='xsd:string'>SOP-330006 The method 'GetModifiedEntities' is not defined in SOAP service 'xtk:session'.</faultstring> | ||
</SOAP-ENV:Fault> | ||
</SOAP-ENV:Body> | ||
</SOAP-ENV:Envelope>`); | ||
const GETMODIFIEDENTITIES_ERROR_RESPONSE = Promise.resolve(`<?xml version='1.0'?> | ||
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'> | ||
<SOAP-ENV:Body> | ||
<SOAP-ENV:Fault> | ||
<faultcode>SOAP-ENV:Client</faultcode> | ||
<faultstring xsi:type='xsd:string'>SOP-330011 Error while executing the method 'GetModifiedEntities' of service 'xtk:session'.</faultstring> | ||
</SOAP-ENV:Fault> | ||
</SOAP-ENV:Body> | ||
</SOAP-ENV:Envelope>`); | ||
// Public exports | ||
@@ -660,3 +720,8 @@ exports.Mock = { | ||
GET_HELLO_RESPONSE: GET_HELLO_RESPONSE, | ||
LOGON_RESPONSE_NO_USERINFO: LOGON_RESPONSE_NO_USERINFO | ||
LOGON_RESPONSE_NO_USERINFO: LOGON_RESPONSE_NO_USERINFO, | ||
GETMODIFIEDENTITIES_RESPONSE: GETMODIFIEDENTITIES_RESPONSE, | ||
GETMODIFIEDENTITIES_CLEAR_RESPONSE: GETMODIFIEDENTITIES_CLEAR_RESPONSE, | ||
GETMODIFIEDENTITIES_SCHEMA_RESPONSE: GETMODIFIEDENTITIES_SCHEMA_RESPONSE, | ||
GETMODIFIEDENTITIES_UNDEFINED_RESPONSE: GETMODIFIEDENTITIES_UNDEFINED_RESPONSE, | ||
GETMODIFIEDENTITIES_ERROR_RESPONSE: GETMODIFIEDENTITIES_ERROR_RESPONSE | ||
} |
@@ -891,3 +891,3 @@ /* | ||
call.finalize(URL); | ||
expect(call.request.url).toBe("https://soap-test/nl/jsp/soaprouter.jsp?xtk:session#Empty"); | ||
expect(call.request.url).toBe("https://soap-test/nl/jsp/soaprouter.jsp?xtk:session:Empty"); | ||
}); | ||
@@ -894,0 +894,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1370904
63
26009
2029