@itentialopensource/adapter-google_drive 0.3.0 → 0.4.1
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/CALLS.md +276 -0
- package/CHANGELOG.md +16 -0
- package/CONTRIBUTING.md +1 -160
- package/ENHANCE.md +2 -2
- package/README.md +31 -22
- package/adapter.js +155 -162
- package/adapterBase.js +549 -879
- package/changelogs/changelog.md +24 -0
- package/metadata.json +49 -0
- package/package.json +23 -25
- package/pronghorn.json +981 -642
- package/propertiesSchema.json +431 -31
- package/refs?service=git-upload-pack +0 -0
- package/report/adapter-openapi.json +6538 -0
- package/report/adapter-openapi.yaml +6788 -0
- package/report/adapterInfo.json +8 -8
- package/report/updateReport1691508599508.json +120 -0
- package/report/updateReport1692203033260.json +120 -0
- package/report/updateReport1694467047127.json +120 -0
- package/report/updateReport1698422138556.json +120 -0
- package/sampleProperties.json +72 -11
- package/test/integration/adapterTestBasicGet.js +2 -4
- package/test/integration/adapterTestConnectivity.js +91 -42
- package/test/integration/adapterTestIntegration.js +130 -2
- package/test/unit/adapterBaseTestUnit.js +388 -313
- package/test/unit/adapterTestUnit.js +338 -112
- package/utils/adapterInfo.js +1 -1
- package/utils/addAuth.js +1 -1
- package/utils/artifactize.js +1 -1
- package/utils/checkMigrate.js +1 -1
- package/utils/entitiesToDB.js +2 -2
- package/utils/findPath.js +1 -1
- package/utils/methodDocumentor.js +273 -0
- package/utils/modify.js +13 -15
- package/utils/packModificationScript.js +1 -1
- package/utils/pre-commit.sh +2 -0
- package/utils/taskMover.js +309 -0
- package/utils/tbScript.js +89 -34
- package/utils/tbUtils.js +41 -21
- package/utils/testRunner.js +1 -1
- package/utils/troubleshootingAdapter.js +9 -6
- package/workflows/README.md +0 -3
package/adapter.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/* eslint import/no-dynamic-require: warn */
|
|
4
4
|
/* eslint object-curly-newline: warn */
|
|
5
|
+
/* eslint default-param-last: warn */
|
|
5
6
|
|
|
6
7
|
// Set globals
|
|
7
8
|
/* global log */
|
|
@@ -90,9 +91,6 @@ class GoogleDrive extends AdapterBaseCl {
|
|
|
90
91
|
let myIgnore = [
|
|
91
92
|
'healthCheck',
|
|
92
93
|
'iapGetAdapterWorkflowFunctions',
|
|
93
|
-
'iapHasAdapterEntity',
|
|
94
|
-
'iapVerifyAdapterCapability',
|
|
95
|
-
'iapUpdateAdapterEntityCache',
|
|
96
94
|
'hasEntities',
|
|
97
95
|
'getAuthorization',
|
|
98
96
|
'configureGtoken',
|
|
@@ -130,29 +128,15 @@ class GoogleDrive extends AdapterBaseCl {
|
|
|
130
128
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
131
129
|
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
132
130
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
131
|
+
* @param {boolean} replace - true to replace entire mock data, false to merge/append
|
|
133
132
|
* @param {Callback} callback - The results of the call
|
|
134
133
|
*/
|
|
135
|
-
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
134
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
|
|
136
135
|
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
137
136
|
const origin = `${this.id}-${meth}`;
|
|
138
137
|
log.trace(origin);
|
|
139
138
|
|
|
140
|
-
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* See if the API path provided is found in this adapter
|
|
145
|
-
*
|
|
146
|
-
* @function iapFindAdapterPath
|
|
147
|
-
* @param {string} apiPath - the api path to check on
|
|
148
|
-
* @param {Callback} callback - The results of the call
|
|
149
|
-
*/
|
|
150
|
-
iapFindAdapterPath(apiPath, callback) {
|
|
151
|
-
const meth = 'adapter-iapFindAdapterPath';
|
|
152
|
-
const origin = `${this.id}-${meth}`;
|
|
153
|
-
log.trace(origin);
|
|
154
|
-
|
|
155
|
-
super.iapFindAdapterPath(apiPath, callback);
|
|
139
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
|
|
156
140
|
}
|
|
157
141
|
|
|
158
142
|
/**
|
|
@@ -194,7 +178,7 @@ class GoogleDrive extends AdapterBaseCl {
|
|
|
194
178
|
}
|
|
195
179
|
|
|
196
180
|
/**
|
|
197
|
-
* @summary Get the
|
|
181
|
+
* @summary Get the Adapter Queue
|
|
198
182
|
*
|
|
199
183
|
* @function iapGetAdapterQueue
|
|
200
184
|
* @param {Callback} callback - callback function
|
|
@@ -207,6 +191,22 @@ class GoogleDrive extends AdapterBaseCl {
|
|
|
207
191
|
return super.iapGetAdapterQueue(callback);
|
|
208
192
|
}
|
|
209
193
|
|
|
194
|
+
/* SCRIPT CALLS */
|
|
195
|
+
/**
|
|
196
|
+
* See if the API path provided is found in this adapter
|
|
197
|
+
*
|
|
198
|
+
* @function iapFindAdapterPath
|
|
199
|
+
* @param {string} apiPath - the api path to check on
|
|
200
|
+
* @param {Callback} callback - The results of the call
|
|
201
|
+
*/
|
|
202
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
203
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
204
|
+
const origin = `${this.id}-${meth}`;
|
|
205
|
+
log.trace(origin);
|
|
206
|
+
|
|
207
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
210
|
/**
|
|
211
211
|
* @summary Runs troubleshoot scripts for adapter
|
|
212
212
|
*
|
|
@@ -307,176 +307,93 @@ class GoogleDrive extends AdapterBaseCl {
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
/* BROKER CALLS */
|
|
311
310
|
/**
|
|
312
|
-
* @summary
|
|
311
|
+
* @summary Deactivate adapter tasks
|
|
313
312
|
*
|
|
314
|
-
* @function
|
|
315
|
-
* @param {String} entityType - the entity type to check for
|
|
316
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
|
313
|
+
* @function iapDeactivateTasks
|
|
317
314
|
*
|
|
318
|
-
* @param {
|
|
319
|
-
*
|
|
315
|
+
* @param {Array} tasks - List of tasks to deactivate
|
|
316
|
+
* @param {Callback} callback
|
|
320
317
|
*/
|
|
321
|
-
|
|
322
|
-
const
|
|
318
|
+
iapDeactivateTasks(tasks, callback) {
|
|
319
|
+
const meth = 'adapter-iapDeactivateTasks';
|
|
320
|
+
const origin = `${this.id}-${meth}`;
|
|
323
321
|
log.trace(origin);
|
|
324
322
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
323
|
+
try {
|
|
324
|
+
return super.iapDeactivateTasks(tasks, callback);
|
|
325
|
+
} catch (err) {
|
|
326
|
+
log.error(`${origin}: ${err}`);
|
|
327
|
+
return callback(null, err);
|
|
328
|
+
}
|
|
328
329
|
}
|
|
329
330
|
|
|
330
331
|
/**
|
|
331
|
-
* @summary
|
|
332
|
-
* whether the adapter supports type, action and specific entity
|
|
332
|
+
* @summary Activate adapter tasks that have previously been deactivated
|
|
333
333
|
*
|
|
334
|
-
* @function
|
|
335
|
-
* @param {String} entityType - the entity type to check for
|
|
336
|
-
* @param {String} actionType - the action type to check for
|
|
337
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
|
334
|
+
* @function iapActivateTasks
|
|
338
335
|
*
|
|
339
|
-
* @param {
|
|
340
|
-
*
|
|
336
|
+
* @param {Array} tasks - List of tasks to activate
|
|
337
|
+
* @param {Callback} callback
|
|
341
338
|
*/
|
|
342
|
-
|
|
343
|
-
const meth = '
|
|
339
|
+
iapActivateTasks(tasks, callback) {
|
|
340
|
+
const meth = 'adapter-iapActivateTasks';
|
|
344
341
|
const origin = `${this.id}-${meth}`;
|
|
345
342
|
log.trace(origin);
|
|
346
343
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return callback(null, error);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// if the cache needs to be updated, update and try again
|
|
356
|
-
if (results && results[0] === 'needupdate') {
|
|
357
|
-
switch (entityType) {
|
|
358
|
-
case 'template_entity': {
|
|
359
|
-
// if the cache is invalid, update the cache
|
|
360
|
-
return this.getEntities(null, null, null, null, (data, err) => {
|
|
361
|
-
if (err) {
|
|
362
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
363
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
364
|
-
return callback(null, errorObj);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// need to check the cache again since it has been updated
|
|
368
|
-
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
369
|
-
if (verror) {
|
|
370
|
-
return callback(null, verror);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
return this.capabilityResults(vcapable, callback);
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
default: {
|
|
378
|
-
// unsupported entity type
|
|
379
|
-
const result = [false];
|
|
380
|
-
|
|
381
|
-
// put false in array for all entities
|
|
382
|
-
if (Array.isArray(entityId)) {
|
|
383
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
384
|
-
result.push(false);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return callback(result);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// return the results
|
|
394
|
-
return this.capabilityResults(results, callback);
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// if no entity id
|
|
399
|
-
if (!entityId) {
|
|
400
|
-
// need to check the cache again since it has been updated
|
|
401
|
-
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
402
|
-
if (verror) {
|
|
403
|
-
return callback(null, verror);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
return this.capabilityResults(vcapable, callback);
|
|
407
|
-
});
|
|
344
|
+
try {
|
|
345
|
+
return super.iapActivateTasks(tasks, callback);
|
|
346
|
+
} catch (err) {
|
|
347
|
+
log.error(`${origin}: ${err}`);
|
|
348
|
+
return callback(null, err);
|
|
408
349
|
}
|
|
350
|
+
}
|
|
409
351
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
return callback(null, verror);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// is the entity in the list?
|
|
428
|
-
const isEntity = this.entityInList(entityId, data.response, callback);
|
|
429
|
-
const res = [];
|
|
430
|
-
|
|
431
|
-
// not found
|
|
432
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
433
|
-
if (vcapable) {
|
|
434
|
-
res.push(isEntity[i]);
|
|
435
|
-
} else {
|
|
436
|
-
res.push(false);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
return callback(res);
|
|
441
|
-
});
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
default: {
|
|
445
|
-
// unsupported entity type
|
|
446
|
-
const result = [false];
|
|
447
|
-
|
|
448
|
-
// put false in array for all entities
|
|
449
|
-
if (Array.isArray(entityId)) {
|
|
450
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
451
|
-
result.push(false);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
352
|
+
/* CACHE CALLS */
|
|
353
|
+
/**
|
|
354
|
+
* @summary Populate the cache for the given entities
|
|
355
|
+
*
|
|
356
|
+
* @function iapPopulateEntityCache
|
|
357
|
+
* @param {String/Array of Strings} entityType - the entity type(s) to populate
|
|
358
|
+
* @param {Callback} callback - whether the cache was updated or not for each entity type
|
|
359
|
+
*
|
|
360
|
+
* @returns status of the populate
|
|
361
|
+
*/
|
|
362
|
+
iapPopulateEntityCache(entityTypes, callback) {
|
|
363
|
+
const meth = 'adapter-iapPopulateEntityCache';
|
|
364
|
+
const origin = `${this.id}-${meth}`;
|
|
365
|
+
log.trace(origin);
|
|
454
366
|
|
|
455
|
-
|
|
456
|
-
|
|
367
|
+
try {
|
|
368
|
+
return super.iapPopulateEntityCache(entityTypes, callback);
|
|
369
|
+
} catch (err) {
|
|
370
|
+
log.error(`${origin}: ${err}`);
|
|
371
|
+
return callback(null, err);
|
|
457
372
|
}
|
|
458
373
|
}
|
|
459
374
|
|
|
460
375
|
/**
|
|
461
|
-
* @summary
|
|
462
|
-
*
|
|
463
|
-
* @function iapUpdateAdapterEntityCache
|
|
376
|
+
* @summary Retrieves data from cache for specified entity type
|
|
464
377
|
*
|
|
378
|
+
* @function iapRetrieveEntitiesCache
|
|
379
|
+
* @param {String} entityType - entity of which to retrieve
|
|
380
|
+
* @param {Object} options - settings of which data to return and how to return it
|
|
381
|
+
* @param {Callback} callback - the data if it was retrieved
|
|
465
382
|
*/
|
|
466
|
-
|
|
467
|
-
const
|
|
383
|
+
iapRetrieveEntitiesCache(entityType, options, callback) {
|
|
384
|
+
const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
|
|
385
|
+
const origin = `${this.id}-${meth}`;
|
|
468
386
|
log.trace(origin);
|
|
469
387
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
});
|
|
388
|
+
try {
|
|
389
|
+
return super.iapRetrieveEntitiesCache(entityType, options, callback);
|
|
390
|
+
} catch (err) {
|
|
391
|
+
log.error(`${origin}: ${err}`);
|
|
392
|
+
return callback(null, err);
|
|
477
393
|
}
|
|
478
394
|
}
|
|
479
395
|
|
|
396
|
+
/* BROKER CALLS */
|
|
480
397
|
/**
|
|
481
398
|
* @summary Determines if this adapter supports any in a list of entities
|
|
482
399
|
*
|
|
@@ -611,6 +528,38 @@ class GoogleDrive extends AdapterBaseCl {
|
|
|
611
528
|
}
|
|
612
529
|
|
|
613
530
|
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
531
|
+
/**
|
|
532
|
+
* Makes the requested generic call
|
|
533
|
+
*
|
|
534
|
+
* @function iapExpandedGenericAdapterRequest
|
|
535
|
+
* @param {Object} metadata - metadata for the call (optional).
|
|
536
|
+
* Can be a stringified Object.
|
|
537
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
|
|
538
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
|
|
539
|
+
* @param {Object} pathVars - the parameters to be put within the url path (optional).
|
|
540
|
+
* Can be a stringified Object.
|
|
541
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
542
|
+
* Can be a stringified Object.
|
|
543
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
544
|
+
* Can be a stringified Object.
|
|
545
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
546
|
+
* Can be a stringified Object.
|
|
547
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
548
|
+
* or the error
|
|
549
|
+
*/
|
|
550
|
+
iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
|
|
551
|
+
const meth = 'adapter-iapExpandedGenericAdapterRequest';
|
|
552
|
+
const origin = `${this.id}-${meth}`;
|
|
553
|
+
log.trace(origin);
|
|
554
|
+
|
|
555
|
+
try {
|
|
556
|
+
return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
|
|
557
|
+
} catch (err) {
|
|
558
|
+
log.error(`${origin}: ${err}`);
|
|
559
|
+
return callback(null, err);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
614
563
|
/**
|
|
615
564
|
* Makes the requested generic call
|
|
616
565
|
*
|
|
@@ -831,6 +780,50 @@ class GoogleDrive extends AdapterBaseCl {
|
|
|
831
780
|
}
|
|
832
781
|
}
|
|
833
782
|
|
|
783
|
+
/* INVENTORY CALLS */
|
|
784
|
+
/**
|
|
785
|
+
* @summary run the adapter lint script to return the results.
|
|
786
|
+
*
|
|
787
|
+
* @function iapRunAdapterLint
|
|
788
|
+
* @param {Callback} callback - callback function
|
|
789
|
+
*/
|
|
790
|
+
iapRunAdapterLint(callback) {
|
|
791
|
+
const meth = 'adapter-iapRunAdapterLint';
|
|
792
|
+
const origin = `${this.id}-${meth}`;
|
|
793
|
+
log.trace(origin);
|
|
794
|
+
|
|
795
|
+
return super.iapRunAdapterLint(callback);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* @summary run the adapter test scripts (baseunit and unit) to return the results.
|
|
800
|
+
* can not run integration as there can be implications with that.
|
|
801
|
+
*
|
|
802
|
+
* @function iapRunAdapterTests
|
|
803
|
+
* @param {Callback} callback - callback function
|
|
804
|
+
*/
|
|
805
|
+
iapRunAdapterTests(callback) {
|
|
806
|
+
const meth = 'adapter-iapRunAdapterTests';
|
|
807
|
+
const origin = `${this.id}-${meth}`;
|
|
808
|
+
log.trace(origin);
|
|
809
|
+
|
|
810
|
+
return super.iapRunAdapterTests(callback);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* @summary provide inventory information abbout the adapter
|
|
815
|
+
*
|
|
816
|
+
* @function iapGetAdapterInventory
|
|
817
|
+
* @param {Callback} callback - callback function
|
|
818
|
+
*/
|
|
819
|
+
iapGetAdapterInventory(callback) {
|
|
820
|
+
const meth = 'adapter-iapGetAdapterInventory';
|
|
821
|
+
const origin = `${this.id}-${meth}`;
|
|
822
|
+
log.trace(origin);
|
|
823
|
+
|
|
824
|
+
return super.iapGetAdapterInventory(callback);
|
|
825
|
+
}
|
|
826
|
+
|
|
834
827
|
/**
|
|
835
828
|
* @callback healthCallback
|
|
836
829
|
* @param {Object} result - the result of the get request (contains an id and a status)
|