@adobe/acc-js-sdk
Advanced tools
Comparing version 1.1.40 to 1.1.41
{ | ||
"name": "@adobe/acc-js-sdk", | ||
"version": "1.1.40", | ||
"version": "1.1.41", | ||
"description": "ACC Javascript SDK", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -163,19 +163,38 @@ /* | ||
throw CampaignException.SOAP_UNKNOWN_METHOD(entitySchemaId, methodName, `Schema '${entitySchemaId}' not found`); | ||
var method = this._client._methodCache.get(entitySchemaId, methodName); | ||
var method = await this._client._methodCache.get(entitySchemaId, methodName); | ||
if (!method) | ||
throw CampaignException.SOAP_UNKNOWN_METHOD(entitySchemaId, methodName, `Method '${methodName}' of schema '${entitySchemaId}' not found`); | ||
// SubmitSoapCall does not support | ||
const isStatic = DomUtil.getAttributeAsBoolean(method, "static"); | ||
if (isStatic) | ||
throw CampaignException.SOAP_UNKNOWN_METHOD(entitySchemaId, methodName, `Method '${methodName}' of schema '${entitySchemaId}' is static`); | ||
var jobId = await callContext.client._callMethod("SubmitSoapCall", callContext, [ { | ||
name: this._soapCall.method, | ||
service: this._soapCall.xtkschema, | ||
param: [ | ||
{ name:"this", type:"DOMDocument", value: this._soapCall.object }, | ||
{ name:"bStart", type:"boolean", value:"false" }, | ||
] | ||
} ]); | ||
var jobId = null; | ||
if ( !isStatic) | ||
jobId = await callContext.client._callMethod("SubmitSoapCall", callContext, [ { | ||
name: this._soapCall.method, | ||
service: this._soapCall.xtkschema, | ||
param: [ | ||
{ name:"this", type:"DOMDocument", value: this._soapCall.object }, | ||
{ name:"bStart", type:"boolean", value:"false" }, | ||
] | ||
} ]); | ||
else { | ||
// for non-persistant job, override object to intialize job properties | ||
callContext.object = { | ||
doNotPersist: "true", | ||
xtkschema: this._soapCall.xtkschema, | ||
id: this._soapCall.jobId, | ||
properties: { | ||
warning: false, | ||
} | ||
}; | ||
// SubmitSoapCall now supports static method | ||
// no need parameter type as it's already present in API definition | ||
jobId = await callContext.client._callMethod("SubmitSoapCall", callContext, | ||
{ | ||
name: this._soapCall.method, | ||
service: this._soapCall.xtkschema, | ||
param : this._soapCall.args | ||
}, | ||
); | ||
} | ||
this.jobId = jobId; | ||
@@ -182,0 +201,0 @@ return jobId; |
@@ -328,2 +328,44 @@ /* | ||
it("SubmitSoapCall a non-persistant and static job with success", async () => { | ||
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} }; | ||
const jobDescription = { | ||
doNotPersist: "true", | ||
xtkschema: 'nms:webApp', | ||
id: "9876", | ||
properties: { | ||
warning: false, | ||
}}; | ||
const soapCallArgs = [ | ||
{ | ||
where: { | ||
condition: { | ||
expr: "@id=9876" | ||
} | ||
} | ||
}, | ||
{ | ||
type: "byte", | ||
value: "10" | ||
} | ||
] | ||
const job = new XtkJobInterface(client, { xtkschema: "nms:webApp", jobId: "9876", method: "Publish", args: soapCallArgs }); | ||
client._callMethod.mockReturnValueOnce(Promise.resolve("9876")); | ||
client.getSchema.mockReturnValueOnce(Promise.resolve(true)); | ||
client._methodCache.get.mockReturnValueOnce(DomUtil.parse('<method static="true"></method>').documentElement); | ||
const jobId = await job.submitSoapCall(); | ||
expect(jobId).toBe("9876"); | ||
expect(client._callMethod.mock.calls.length).toBe(1); | ||
expect(client._callMethod.mock.calls[0][0]).toBe("SubmitSoapCall"); | ||
expect(client._callMethod.mock.calls[0][1]).toMatchObject({ | ||
entitySchemaId: "nms:webApp", | ||
schemaId: "xtk:jobInterface", | ||
object: jobDescription, | ||
}); | ||
expect(client._callMethod.mock.calls[0][2]).toEqual({ | ||
name: "Publish", | ||
service: "nms:webApp", | ||
param : soapCallArgs | ||
}); | ||
}); | ||
it("Infer schema from objects", async () => { | ||
@@ -394,19 +436,2 @@ const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} }; | ||
}); | ||
it("Should fail on static methods", async () => { | ||
const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} }; | ||
const job = new XtkJobInterface(client, { object: { xtkschema: "nms:delivery", name: "Hello World" }, method: "StaticMethod" }); | ||
client._callMethod.mockReturnValueOnce(Promise.resolve("9876")); | ||
client.getSchema.mockReturnValueOnce(Promise.resolve(true)); | ||
client._methodCache.get.mockReturnValueOnce(DomUtil.parse('<method static="true"></method>').documentElement); | ||
await expect(job.submitSoapCall()).rejects.toMatchObject({ | ||
"detail": "Method 'StaticMethod' of schema 'nms:delivery' is static", | ||
"errorCode": "SDK-000009", | ||
"faultCode": 16384, | ||
"faultString": "Unknown method 'StaticMethod' of schema 'nms:delivery'", | ||
"message": "400 - Error 16384: SDK-000009 Unknown method 'StaticMethod' of schema 'nms:delivery'. Method 'StaticMethod' of schema 'nms:delivery' is static", | ||
"name": "CampaignException", | ||
"statusCode": 400, | ||
}); | ||
}); | ||
}); | ||
@@ -413,0 +438,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1848279
30341