@bpmsoftwaresolutions/ai-engine-client 1.1.37 → 1.1.38
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 +1 -1
- package/src/index.js +105 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const DEFAULT_TIMEOUT_MS = 30000;
|
|
2
|
-
export const AI_ENGINE_CLIENT_VERSION = '1.1.
|
|
2
|
+
export const AI_ENGINE_CLIENT_VERSION = '1.1.38';
|
|
3
3
|
export const GOVERNED_MUTATION_REQUIRED_CAPABILITIES = [
|
|
4
4
|
'executeVerifiedMutation',
|
|
5
5
|
'post_mutation_verification',
|
|
@@ -296,6 +296,15 @@ export class AIEngineClient {
|
|
|
296
296
|
submitArtifact: (scriptId, payload) => this.submitScriptArtifact(scriptId, payload),
|
|
297
297
|
getRunEvidence: (query) => this.getScriptRunEvidence(query),
|
|
298
298
|
};
|
|
299
|
+
this.reports = {
|
|
300
|
+
run: (request) => this.runReportDefinition(request),
|
|
301
|
+
};
|
|
302
|
+
this.projections = {
|
|
303
|
+
render: (request) => this.renderProjection(request),
|
|
304
|
+
};
|
|
305
|
+
this.actions = {
|
|
306
|
+
submit: (request) => this.submitActionIntent(request),
|
|
307
|
+
};
|
|
299
308
|
}
|
|
300
309
|
|
|
301
310
|
static fromEnv(options = {}) {
|
|
@@ -378,6 +387,101 @@ export class AIEngineClient {
|
|
|
378
387
|
return this._request('/api/v1/latest-memory-projection');
|
|
379
388
|
}
|
|
380
389
|
|
|
390
|
+
// ─── Data Access Gateway ──────────────────────────────────────────────────
|
|
391
|
+
|
|
392
|
+
async query({
|
|
393
|
+
surface,
|
|
394
|
+
contractKey,
|
|
395
|
+
parameters = {},
|
|
396
|
+
fields = [],
|
|
397
|
+
fieldAllowlist = [],
|
|
398
|
+
actorScopes = [],
|
|
399
|
+
requiredScopes = [],
|
|
400
|
+
shape = 'json',
|
|
401
|
+
requestedBy,
|
|
402
|
+
} = {}) {
|
|
403
|
+
const normalizedSurface = cleanText(surface) || cleanText(contractKey);
|
|
404
|
+
if (!normalizedSurface) {
|
|
405
|
+
throw new Error('surface is required.');
|
|
406
|
+
}
|
|
407
|
+
const normalizedShape = cleanText(shape) || 'json';
|
|
408
|
+
if (!['json', 'table', 'cards', 'markdown'].includes(normalizedShape)) {
|
|
409
|
+
throw new Error('shape must be one of json, table, cards, or markdown.');
|
|
410
|
+
}
|
|
411
|
+
const normalizedFields = cleanList(fields);
|
|
412
|
+
const normalizedAllowlist = cleanList(fieldAllowlist);
|
|
413
|
+
const disallowedFields = normalizedFields.filter((field) => !normalizedAllowlist.includes(field));
|
|
414
|
+
if (normalizedAllowlist.length > 0 && disallowedFields.length > 0) {
|
|
415
|
+
throw new Error(`Requested fields are not allowed: ${disallowedFields.join(', ')}.`);
|
|
416
|
+
}
|
|
417
|
+
const normalizedActorScopes = cleanList(actorScopes);
|
|
418
|
+
const normalizedRequiredScopes = cleanList(requiredScopes);
|
|
419
|
+
const missingScopes = normalizedRequiredScopes.filter((scope) => !normalizedActorScopes.includes(scope));
|
|
420
|
+
if (missingScopes.length > 0) {
|
|
421
|
+
throw new Error(`Missing required scopes: ${missingScopes.join(', ')}.`);
|
|
422
|
+
}
|
|
423
|
+
return this._request('/api/gateway/query', {
|
|
424
|
+
method: 'POST',
|
|
425
|
+
body: {
|
|
426
|
+
surface: normalizedSurface,
|
|
427
|
+
parameters: isPlainObject(parameters) ? parameters : {},
|
|
428
|
+
fields: normalizedFields,
|
|
429
|
+
field_allowlist: normalizedAllowlist,
|
|
430
|
+
actor_scopes: normalizedActorScopes,
|
|
431
|
+
required_scopes: normalizedRequiredScopes,
|
|
432
|
+
shape: normalizedShape,
|
|
433
|
+
requested_by: cleanText(requestedBy),
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
async runReportDefinition({ reportKey, definition = {}, requestedBy } = {}) {
|
|
439
|
+
const normalizedReportKey = cleanText(reportKey);
|
|
440
|
+
if (!normalizedReportKey) {
|
|
441
|
+
throw new Error('reportKey is required.');
|
|
442
|
+
}
|
|
443
|
+
return this._request('/api/gateway/reports/run', {
|
|
444
|
+
method: 'POST',
|
|
445
|
+
body: {
|
|
446
|
+
report_key: normalizedReportKey,
|
|
447
|
+
definition: isPlainObject(definition) ? definition : {},
|
|
448
|
+
requested_by: cleanText(requestedBy),
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
async renderProjection({ projectionType, viewContract = {}, requestedBy } = {}) {
|
|
454
|
+
const normalizedProjectionType = cleanText(projectionType);
|
|
455
|
+
if (!normalizedProjectionType) {
|
|
456
|
+
throw new Error('projectionType is required.');
|
|
457
|
+
}
|
|
458
|
+
return this._request('/api/gateway/projections/render', {
|
|
459
|
+
method: 'POST',
|
|
460
|
+
body: {
|
|
461
|
+
projection_type: normalizedProjectionType,
|
|
462
|
+
view_contract: isPlainObject(viewContract) ? viewContract : {},
|
|
463
|
+
requested_by: cleanText(requestedBy),
|
|
464
|
+
},
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
async submitActionIntent({ action, target = {}, payload = {}, requiredScope, requestedBy } = {}) {
|
|
469
|
+
const normalizedAction = cleanText(action);
|
|
470
|
+
if (!normalizedAction) {
|
|
471
|
+
throw new Error('action is required.');
|
|
472
|
+
}
|
|
473
|
+
return this._request('/api/gateway/actions/submit', {
|
|
474
|
+
method: 'POST',
|
|
475
|
+
body: {
|
|
476
|
+
action: normalizedAction,
|
|
477
|
+
target: isPlainObject(target) ? target : {},
|
|
478
|
+
payload: isPlainObject(payload) ? payload : {},
|
|
479
|
+
required_scope: cleanText(requiredScope) || 'ai-engine.write',
|
|
480
|
+
requested_by: cleanText(requestedBy),
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
|
|
381
485
|
async currentProjectStatus({ projectId } = {}) {
|
|
382
486
|
return this._request('/api/operator/current-project-status', {
|
|
383
487
|
query: { project_id: projectId },
|