@adobe/acc-js-sdk 1.1.40 → 1.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/acc-js-sdk",
3
- "version": "1.1.40",
3
+ "version": "1.1.42",
4
4
  "description": "ACC Javascript SDK",
5
5
  "main": "src/index.js",
6
6
  "homepage": "https://github.com/adobe/acc-js-sdk#readme",
package/src/client.js CHANGED
@@ -2013,7 +2013,10 @@ class Client {
2013
2013
  const inputParams = [];
2014
2014
  const outputParams = [];
2015
2015
 
2016
- // For non static methods, the first input and the first output parameters represent the entity itself. The name of the corresponding
2016
+ // For non static methods
2017
+ // in case of persistent job: object represents the entity instance
2018
+ // in case of non-persistent job: object represents job description
2019
+ // the first output parameters represent the entity itself. The name of the corresponding
2017
2020
  // parameter is set the the entity schema name.
2018
2021
  if (!isStatic) {
2019
2022
  var schemaName = entitySchemaId.substring(entitySchemaId.indexOf(':') + 1);
package/src/xtkJob.js CHANGED
@@ -160,23 +160,42 @@ class XtkJobInterface {
160
160
  var schema = await this._client.getSchema(entitySchemaId, "xml", true);
161
161
  if (!schema)
162
162
  throw CampaignException.SOAP_UNKNOWN_METHOD(entitySchemaId, methodName, `Schema '${entitySchemaId}' not found`);
163
- var method = this._client._methodCache.get(entitySchemaId, methodName);
163
+ var method = await this._client._methodCache.get(entitySchemaId, methodName);
164
164
  if (!method)
165
165
  throw CampaignException.SOAP_UNKNOWN_METHOD(entitySchemaId, methodName, `Method '${methodName}' of schema '${entitySchemaId}' not found`);
166
- // SubmitSoapCall does not support
166
+
167
167
  const isStatic = DomUtil.getAttributeAsBoolean(method, "static");
168
- if (isStatic)
169
- throw CampaignException.SOAP_UNKNOWN_METHOD(entitySchemaId, methodName, `Method '${methodName}' of schema '${entitySchemaId}' is static`);
170
-
171
-
172
- var jobId = await callContext.client._callMethod("SubmitSoapCall", callContext, [ {
173
- name: this._soapCall.method,
174
- service: this._soapCall.xtkschema,
175
- param: [
176
- { name:"this", type:"DOMDocument", value: this._soapCall.object },
177
- { name:"bStart", type:"boolean", value:"false" },
178
- ]
179
- } ]);
168
+
169
+ var jobId = null;
170
+ if ( !isStatic)
171
+ jobId = await callContext.client._callMethod("SubmitSoapCall", callContext, [ {
172
+ name: this._soapCall.method,
173
+ service: this._soapCall.xtkschema,
174
+ param: [
175
+ { name:"this", type:"DOMDocument", value: this._soapCall.object },
176
+ { name:"bStart", type:"boolean", value:"false" },
177
+ ]
178
+ } ]);
179
+ else {
180
+ // for non-persistant job, override object to intialize job properties
181
+ callContext.object = {
182
+ doNotPersist: "true",
183
+ xtkschema: this._soapCall.xtkschema,
184
+ id: this._soapCall.jobId,
185
+ properties: {
186
+ warning: false,
187
+ }
188
+ };
189
+ // SubmitSoapCall now supports static method
190
+ // no need parameter type as it's already present in API definition
191
+ jobId = await callContext.client._callMethod("SubmitSoapCall", callContext,
192
+ {
193
+ name: this._soapCall.method,
194
+ service: this._soapCall.xtkschema,
195
+ param : this._soapCall.args
196
+ },
197
+ );
198
+ }
180
199
  this.jobId = jobId;
181
200
  return jobId;
182
201
  }
@@ -3913,6 +3913,55 @@ describe('ACC Client', function () {
3913
3913
  });
3914
3914
  });
3915
3915
 
3916
+ it("Should support 'className' action", async () => {
3917
+ // Create a mock client and logon
3918
+ const client = await Mock.makeClient();
3919
+ client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
3920
+ await client.NLWS.xtkSession.logon();
3921
+
3922
+ // Mock the upload protocol
3923
+ // - the upload.jsp (which returns the content of an iframe and JS to eval)
3924
+ // - call to xtk:counter#IncreaseValue (first, retrieve the schema xtk:counter then call the function)
3925
+ // - call to xtk:session#Write
3926
+ // - call to xtk:fileRes#PublishIfNeeded
3927
+ // - call to xtk:fileRes#GetURL
3928
+
3929
+ client._transport.mockReturnValueOnce(Promise.resolve(`Ok
3930
+ <html xmlns="http://www.w3.org/1999/xhtml">
3931
+ <head>
3932
+ <script type="text/javascript">if(window.parent&&window.parent.document.controller&&"function"==typeof window.parent.document.controller.uploadFileCallBack){var aFilesInfo=new Array;aFilesInfo.push({paramName:"file",fileName:"test.txt",newFileName:"d8e8fca2dc0f896fd7cb4cb0031ba249.txt",md5:"d8e8fca2dc0f896fd7cb4cb0031ba249"}),window.parent.document.controller.uploadFileCallBack(aFilesInfo)}</script>
3933
+ </head>
3934
+ <body></body>
3935
+ </html>`)); // upload.jsp
3936
+
3937
+ client._transport.mockReturnValueOnce(Promise.resolve(Mock.GET_XTK_COUNTER_RESPONSE)); // GetEntityIfMoreRecentResponse - counter
3938
+ client._transport.mockReturnValueOnce(Mock.INCREASE_VALUE_RESPONSE); // xtk:counter#IncreaseValue
3939
+
3940
+ client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE); // GetEntityIfMoreRecentResponse - session
3941
+ client._transport.mockReturnValueOnce(Mock.FILE_RES_WRITE_RESPONSE); // xtk:session#Write
3942
+
3943
+ client._transport.mockReturnValueOnce(Promise.resolve(Mock.GET_FILERES_QUERY_SCHEMA_RESPONSE)); // GetEntityIfMoreRecentResponse - fileRes
3944
+ client._transport.mockReturnValueOnce(Promise.resolve(Mock.PUBLISH_IF_NEEDED_RESPONSE)); // xtk:fileRes#PublishIfNeeded
3945
+
3946
+ client._transport.mockReturnValueOnce(Promise.resolve(Mock.GET_URL_RESPONSE)); // xtk:fileRes#GetURL
3947
+
3948
+ // Call upload
3949
+ const result = await client.fileUploader.upload({
3950
+ type: 'text/html',
3951
+ size: 12345
3952
+ }, { action: "publishIfNeeded", className: "myClass" });
3953
+
3954
+ const body = global.document.body;
3955
+ const iframes = body.getElementsByTagName("iframe");
3956
+ let found = false;
3957
+ for (let i=0; i<iframes.length; i++) {
3958
+ const iframe = iframes[i];
3959
+ if (iframe.className === "myClass")
3960
+ found = true;
3961
+ }
3962
+ expect(found).toBe(true);
3963
+ });
3964
+
3916
3965
  it("Should support 'none' action", async () => {
3917
3966
  // Create a mock client and logon
3918
3967
  const client = await Mock.makeClient();
@@ -325,6 +325,48 @@ describe('XRK Jobs', function () {
325
325
  } ]);
326
326
  });
327
327
 
328
+ it("SubmitSoapCall a non-persistant and static job with success", async () => {
329
+ const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} };
330
+ const jobDescription = {
331
+ doNotPersist: "true",
332
+ xtkschema: 'nms:webApp',
333
+ id: "9876",
334
+ properties: {
335
+ warning: false,
336
+ }};
337
+ const soapCallArgs = [
338
+ {
339
+ where: {
340
+ condition: {
341
+ expr: "@id=9876"
342
+ }
343
+ }
344
+ },
345
+ {
346
+ type: "byte",
347
+ value: "10"
348
+ }
349
+ ]
350
+ const job = new XtkJobInterface(client, { xtkschema: "nms:webApp", jobId: "9876", method: "Publish", args: soapCallArgs });
351
+ client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
352
+ client.getSchema.mockReturnValueOnce(Promise.resolve(true));
353
+ client._methodCache.get.mockReturnValueOnce(DomUtil.parse('<method static="true"></method>').documentElement);
354
+ const jobId = await job.submitSoapCall();
355
+ expect(jobId).toBe("9876");
356
+ expect(client._callMethod.mock.calls.length).toBe(1);
357
+ expect(client._callMethod.mock.calls[0][0]).toBe("SubmitSoapCall");
358
+ expect(client._callMethod.mock.calls[0][1]).toMatchObject({
359
+ entitySchemaId: "nms:webApp",
360
+ schemaId: "xtk:jobInterface",
361
+ object: jobDescription,
362
+ });
363
+ expect(client._callMethod.mock.calls[0][2]).toEqual({
364
+ name: "Publish",
365
+ service: "nms:webApp",
366
+ param : soapCallArgs
367
+ });
368
+ });
369
+
328
370
  it("Infer schema from objects", async () => {
329
371
  const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} };
330
372
  const job = new XtkJobInterface(client, { object: { xtkschema: "nms:delivery", name: "Hello World" }, method: "Prepare" });
@@ -390,23 +432,6 @@ describe('XRK Jobs', function () {
390
432
  "statusCode": 400,
391
433
  });
392
434
  });
393
-
394
- it("Should fail on static methods", async () => {
395
- const client = { _callMethod: jest.fn(), getSchema: jest.fn(), _methodCache: { get: jest.fn()} };
396
- const job = new XtkJobInterface(client, { object: { xtkschema: "nms:delivery", name: "Hello World" }, method: "StaticMethod" });
397
- client._callMethod.mockReturnValueOnce(Promise.resolve("9876"));
398
- client.getSchema.mockReturnValueOnce(Promise.resolve(true));
399
- client._methodCache.get.mockReturnValueOnce(DomUtil.parse('<method static="true"></method>').documentElement);
400
- await expect(job.submitSoapCall()).rejects.toMatchObject({
401
- "detail": "Method 'StaticMethod' of schema 'nms:delivery' is static",
402
- "errorCode": "SDK-000009",
403
- "faultCode": 16384,
404
- "faultString": "Unknown method 'StaticMethod' of schema 'nms:delivery'",
405
- "message": "400 - Error 16384: SDK-000009 Unknown method 'StaticMethod' of schema 'nms:delivery'. Method 'StaticMethod' of schema 'nms:delivery' is static",
406
- "name": "CampaignException",
407
- "statusCode": 400,
408
- });
409
- });
410
435
  });
411
436
 
412
437
  describe("Get Status", () => {