@cclabsnz/sf-audit 1.4.0 → 1.6.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.
Files changed (61) hide show
  1. package/README.md +114 -11
  2. package/lib/api/RestClient.d.ts +1 -0
  3. package/lib/api/RestClientImpl.d.ts +1 -0
  4. package/lib/api/RestClientImpl.js +27 -0
  5. package/lib/apps/analyzeApps.d.ts +8 -0
  6. package/lib/apps/analyzeApps.js +19 -0
  7. package/lib/apps/appResolver.d.ts +4 -0
  8. package/lib/apps/appResolver.js +50 -0
  9. package/lib/apps/grantedAccess.d.ts +4 -0
  10. package/lib/apps/grantedAccess.js +36 -0
  11. package/lib/apps/leastPrivilege.d.ts +6 -0
  12. package/lib/apps/leastPrivilege.js +47 -0
  13. package/lib/apps/renderApps.d.ts +5 -0
  14. package/lib/apps/renderApps.js +23 -0
  15. package/lib/apps/standardAppCatalog.d.ts +11 -0
  16. package/lib/apps/standardAppCatalog.js +14 -0
  17. package/lib/apps/types.d.ts +64 -0
  18. package/lib/apps/types.js +2 -0
  19. package/lib/apps/usageCollector.d.ts +9 -0
  20. package/lib/apps/usageCollector.js +104 -0
  21. package/lib/chains/namedChains.js +45 -0
  22. package/lib/checks/impl/AgentActionSurfaceCheck.d.ts +13 -0
  23. package/lib/checks/impl/AgentActionSurfaceCheck.js +125 -0
  24. package/lib/checks/impl/AgentChannelExposureCheck.d.ts +15 -0
  25. package/lib/checks/impl/AgentChannelExposureCheck.js +223 -0
  26. package/lib/checks/impl/AgentInventoryCheck.d.ts +15 -0
  27. package/lib/checks/impl/AgentInventoryCheck.js +228 -0
  28. package/lib/checks/impl/AgentMonitoringCoverageCheck.d.ts +12 -0
  29. package/lib/checks/impl/AgentMonitoringCoverageCheck.js +97 -0
  30. package/lib/checks/impl/AgentUserPrivilegeCheck.d.ts +13 -0
  31. package/lib/checks/impl/AgentUserPrivilegeCheck.js +204 -0
  32. package/lib/checks/impl/CspTrustedSitesCheck.d.ts +1 -0
  33. package/lib/checks/impl/CspTrustedSitesCheck.js +10 -1
  34. package/lib/checks/impl/EnhancedDomainsCheck.js +18 -4
  35. package/lib/checks/impl/TrustedUrlHygieneCheck.d.ts +16 -0
  36. package/lib/checks/impl/TrustedUrlHygieneCheck.js +198 -0
  37. package/lib/checks/registry.js +19 -0
  38. package/lib/commands/audit/apps.d.ts +16 -0
  39. package/lib/commands/audit/apps.js +64 -0
  40. package/lib/commands/audit/security.d.ts +1 -0
  41. package/lib/commands/audit/security.js +7 -1
  42. package/lib/compliance/catalogs/index.js +2 -0
  43. package/lib/compliance/catalogs/owaspLlm.d.ts +3 -0
  44. package/lib/compliance/catalogs/owaspLlm.js +34 -0
  45. package/lib/compliance/mapping.js +19 -0
  46. package/lib/compliance/resolve.js +4 -3
  47. package/lib/compliance/types.d.ts +1 -1
  48. package/lib/context/AuditCache.d.ts +28 -0
  49. package/lib/context/AuditContext.d.ts +4 -0
  50. package/lib/events/pullEventLogs.js +3 -3
  51. package/lib/findings/CheckMeta.js +6 -0
  52. package/lib/lib/wire.d.ts +2 -2
  53. package/lib/lib/wire.js +2 -1
  54. package/lib/renderers/ClientReportRenderer.js +1 -1
  55. package/package.json +12 -13
  56. package/lib/findings/ComplianceMapping.d.ts +0 -3
  57. package/lib/findings/ComplianceMapping.js +0 -75
  58. package/lib/queries/QueryDefinition.d.ts +0 -48
  59. package/lib/queries/QueryDefinition.js +0 -11
  60. package/lib/queries/QueryRegistry.d.ts +0 -13
  61. package/lib/queries/QueryRegistry.js +0 -93
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@cclabsnz/sf-audit",
3
- "version": "1.4.0",
3
+ "version": "1.6.1",
4
4
  "description": "Salesforce Security Audit — native sf plugin",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
+ "packageManager": "pnpm@10.33.0",
7
8
  "main": "lib/index.js",
8
9
  "scripts": {
9
10
  "build": "tsc -p tsconfig.json",
10
- "test": "node --experimental-vm-modules node_modules/jest-cli/bin/jest.js --passWithNoTests",
11
- "test:unit": "node --experimental-vm-modules node_modules/jest-cli/bin/jest.js test/unit --passWithNoTests",
11
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --passWithNoTests",
12
+ "test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js test/unit --passWithNoTests",
12
13
  "prepack": "npm run build",
13
14
  "clean": "rm -rf lib"
14
15
  },
@@ -19,6 +20,7 @@
19
20
  "zod": "^3"
20
21
  },
21
22
  "devDependencies": {
23
+ "@jest/globals": "^29.7.0",
22
24
  "@types/jest": "^29",
23
25
  "@types/node": "^22",
24
26
  "jest": "^29",
@@ -46,6 +48,9 @@
46
48
  "subtopics": {
47
49
  "events": {
48
50
  "description": "Capture free EventLogFile logs to local disk"
51
+ },
52
+ "apps": {
53
+ "description": "Analyze connected-app least-privilege from EventLogFile usage"
49
54
  }
50
55
  }
51
56
  }
@@ -54,16 +59,10 @@
54
59
  "pnpm": {
55
60
  "overrides": {
56
61
  "form-data": "^4.0.6",
57
- "js-yaml@3": "^3.15.0"
58
- }
59
- },
60
- "overrides": {
61
- "handlebars": "^4.7.9",
62
- "minimatch@5": {
63
- "brace-expansion": "^2.0.3"
64
- },
65
- "minimatch@10": {
66
- "brace-expansion": "^5.0.5"
62
+ "js-yaml@3": "^3.15.0",
63
+ "handlebars": "^4.7.9",
64
+ "brace-expansion": "^5.0.8",
65
+ "fast-uri@3": "^3.1.4"
67
66
  }
68
67
  },
69
68
  "files": [
@@ -1,3 +0,0 @@
1
- export declare const COMPLIANCE_MAP: Record<string, string[]>;
2
- export declare function getComplianceTags(checkId: string): string[];
3
- //# sourceMappingURL=ComplianceMapping.d.ts.map
@@ -1,75 +0,0 @@
1
- // Maps each SecurityCheck `id` to its compliance framework references.
2
- // Tags use the format: <Framework>-<Control> e.g. OWASP-A01, SOC2-CC6.1, ISO-A.9.2, SBS-<domain>-<num>
3
- export const COMPLIANCE_MAP = {
4
- 'users-and-admins': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.2', 'HIPAA-164.312a', 'GDPR-Art.32', 'SBS-ACS-004'],
5
- 'permissions': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.2', 'GDPR-Art.32', 'SBS-ACS-002', 'SBS-ACS-005'],
6
- 'inactive-users': ['OWASP-A01', 'SOC2-CC6.2', 'ISO-A.9.2', 'HIPAA-164.312a', 'GDPR-Art.5', 'SBS-ACS-007'],
7
- 'login-session': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312a', 'GDPR-Art.32'],
8
- 'ip-restrictions': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312a', 'GDPR-Art.32', 'SBS-AUTH-003'],
9
- 'password-session-policy': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312d', 'GDPR-Art.32'],
10
- 'field-level-security': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312a', 'GDPR-Art.5'],
11
- 'sharing-model': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312a', 'GDPR-Art.32'],
12
- 'public-group-sharing': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312a', 'GDPR-Art.32'],
13
- 'guest-user-access': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.2', 'GDPR-Art.32', 'SBS-CPORTAL-002'],
14
- 'apex-sharing': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.4', 'GDPR-Art.32', 'SBS-CPORTAL-001'],
15
- 'flows-without-sharing': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.4', 'GDPR-Art.32', 'SBS-CPORTAL-004'],
16
- 'connected-apps': ['OWASP-A05', 'SOC2-CC6.6', 'ISO-A.9.4', 'GDPR-Art.32', 'SBS-OAUTH-001', 'SBS-OAUTH-002', 'SBS-DEP-006'],
17
- 'remote-sites': ['OWASP-A05', 'SOC2-CC6.4', 'ISO-A.14.1', 'GDPR-Art.32', 'SBS-INT-002'],
18
- 'csp-trusted-sites': ['OWASP-A05', 'SOC2-CC6.4', 'ISO-A.14.1', 'GDPR-Art.32'],
19
- 'named-credentials': ['OWASP-A02', 'SOC2-CC6.7', 'ISO-A.9.4', 'GDPR-Art.32', 'SBS-INT-003'],
20
- 'hardcoded-credentials': ['OWASP-A02', 'SOC2-CC6.7', 'ISO-A.9.4', 'HIPAA-164.312d', 'GDPR-Art.32', 'SBS-DEP-005'],
21
- 'custom-settings': ['OWASP-A02', 'SOC2-CC6.7', 'ISO-A.9.4', 'GDPR-Art.32'],
22
- 'health-check': ['OWASP-A05', 'SOC2-CC7.1', 'ISO-A.12.6', 'GDPR-Art.32', 'SBS-SECCONF-001', 'SBS-SECCONF-002'],
23
- 'audit-trail': ['OWASP-A09', 'SOC2-CC7.2', 'ISO-A.12.4', 'HIPAA-164.312b', 'GDPR-Art.32', 'SBS-MON-002'],
24
- 'code-security': ['OWASP-A03', 'OWASP-A05', 'SOC2-CC7.2', 'ISO-A.14.2', 'GDPR-Art.32', 'SBS-CODE-002'],
25
- 'api-limits': ['OWASP-A05', 'SOC2-CC9.1', 'ISO-A.12.6', 'GDPR-Art.32', 'SBS-MON-005'],
26
- 'scheduled-apex': ['OWASP-A05', 'SOC2-CC7.2', 'ISO-A.12.1', 'GDPR-Art.32'],
27
- // Net-new SBS checks
28
- 'standard-profiles': ['OWASP-A01', 'SOC2-CC6.3', 'ISO-A.9.2', 'GDPR-Art.32', 'SBS-ACS-005'],
29
- 'sso-enforcement': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312d', 'GDPR-Art.32', 'SBS-AUTH-001', 'SBS-AUTH-002'],
30
- 'mfa-enforcement': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312d', 'GDPR-Art.32', 'SBS-AUTH-004'],
31
- 'api-client-permission': ['OWASP-A01', 'SOC2-CC6.3', 'ISO-A.9.4', 'GDPR-Art.32', 'SBS-ACS-006'],
32
- 'integration-users': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.2', 'GDPR-Art.32', 'SBS-ACS-007', 'SBS-ACS-008', 'SBS-ACS-009'],
33
- 'content-links': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.13.2', 'GDPR-Art.32', 'SBS-FILE-001', 'SBS-FILE-002', 'SBS-FILE-003'],
34
- 'field-history-tracking': ['OWASP-A09', 'SOC2-CC7.2', 'ISO-A.12.4', 'HIPAA-164.312b', 'GDPR-Art.32', 'SBS-DATA-004'],
35
- 'data-classification': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.8.2', 'HIPAA-164.514', 'GDPR-Art.30', 'SBS-DATA-001', 'SBS-DATA-002', 'SBS-DATA-003'],
36
- 'deployment-identity': ['OWASP-A05', 'SOC2-CC8.1', 'ISO-A.12.1', 'GDPR-Art.32', 'SBS-DEP-001', 'SBS-DEP-003'],
37
- 'apex-logging': ['OWASP-A09', 'SOC2-CC7.2', 'ISO-A.12.4', 'GDPR-Art.32', 'SBS-CODE-003', 'SBS-CODE-004'],
38
- 'event-monitoring': ['OWASP-A09', 'SOC2-CC7.2', 'ISO-A.12.4', 'HIPAA-164.312b', 'GDPR-Art.32', 'SBS-MON-001', 'SBS-INT-004'],
39
- 'siem-integration': ['OWASP-A09', 'SOC2-CC7.2', 'ISO-A.12.4', 'HIPAA-164.312b', 'GDPR-Art.32', 'SBS-MON-003', 'SBS-MON-004'],
40
- // Additional security checks
41
- 'apex-crud-fls': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312a', 'GDPR-Art.32'],
42
- 'apex-rest-endpoint': ['OWASP-A01', 'OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'GDPR-Art.32'],
43
- 'visualforce-xss': ['OWASP-A03', 'SOC2-CC6.1', 'ISO-A.14.2', 'GDPR-Art.32'],
44
- 'certificate-expiry': ['OWASP-A02', 'SOC2-CC6.7', 'ISO-A.10.1', 'HIPAA-164.312e', 'GDPR-Art.32'],
45
- 'installed-packages': ['OWASP-A06', 'SOC2-CC9.2', 'ISO-A.14.2', 'GDPR-Art.32'],
46
- 'trusted-ip-ranges': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312d', 'GDPR-Art.32', 'SBS-AUTH-003'],
47
- 'anonymous-apex-audit': ['OWASP-A09', 'SOC2-CC7.2', 'ISO-A.12.4', 'GDPR-Art.32'],
48
- 'debug-log-access': ['OWASP-A09', 'SOC2-CC7.2', 'ISO-A.12.4', 'HIPAA-164.312b', 'GDPR-Art.32'],
49
- 'connected-app-inactivity': ['OWASP-A05', 'SOC2-CC6.6', 'ISO-A.9.2', 'GDPR-Art.32'],
50
- 'my-domain-login-policy': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312d', 'GDPR-Art.32', 'SBS-AUTH-001'],
51
- 'high-assurance-session': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312d', 'GDPR-Art.32'],
52
- 'enhanced-domains': ['OWASP-A05', 'SOC2-CC6.1', 'ISO-A.14.1', 'GDPR-Art.32'],
53
- // Recent Salesforce MFA improvements
54
- 'internal-user-mfa': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312d', 'GDPR-Art.32', 'SBS-AUTH-004'],
55
- 'mfa-registration': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312d', 'GDPR-Art.32'],
56
- 'mfa-method-strength': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312d', 'GDPR-Art.32'],
57
- // Platform hygiene + API security
58
- 'release-updates': ['OWASP-A06', 'SOC2-CC7.1', 'ISO-A.12.6', 'GDPR-Art.32'],
59
- 'legacy-api-version': ['OWASP-A06', 'SOC2-CC6.4', 'ISO-A.12.6', 'GDPR-Art.32'],
60
- 'connected-app-scope': ['OWASP-A01', 'OWASP-A05', 'SOC2-CC6.6', 'ISO-A.9.4', 'GDPR-Art.32', 'SBS-OAUTH-002'],
61
- // Threat detection + hacker attack surface coverage
62
- 'transaction-security-policy': ['OWASP-A09', 'SOC2-CC7.2', 'ISO-A.12.4', 'HIPAA-164.312b', 'GDPR-Art.32', 'SBS-MON-003'],
63
- 'failed-login-detection': ['OWASP-A07', 'SOC2-CC7.2', 'ISO-A.12.4', 'HIPAA-164.312b', 'GDPR-Art.32', 'SBS-MON-003'],
64
- 'experience-cloud-site': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.4', 'GDPR-Art.32', 'SBS-CPORTAL-003'],
65
- 'custom-labels-credential': ['OWASP-A02', 'SOC2-CC6.7', 'ISO-A.9.4', 'HIPAA-164.312d', 'GDPR-Art.32'],
66
- 'report-folder-access': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.4', 'HIPAA-164.312a', 'GDPR-Art.32'],
67
- // Attack-chain ingredient checks
68
- 'escalation-perms': ['OWASP-A01', 'SOC2-CC6.3', 'ISO-A.9.2', 'HIPAA-164.312a', 'GDPR-Art.32', 'SBS-ACS-004'],
69
- 'cors-allowlist': ['OWASP-A05', 'SOC2-CC6.4', 'ISO-A.14.1', 'GDPR-Art.32'],
70
- 'guest-executable-apex': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.9.4', 'GDPR-Art.32', 'SBS-CPORTAL-001', 'SBS-CPORTAL-002'],
71
- };
72
- export function getComplianceTags(checkId) {
73
- return COMPLIANCE_MAP[checkId] ?? [];
74
- }
75
- //# sourceMappingURL=ComplianceMapping.js.map
@@ -1,48 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const QueryDefinitionSchema: z.ZodObject<{
3
- api: z.ZodEnum<["soql", "tooling", "rest"]>;
4
- soql: z.ZodOptional<z.ZodString>;
5
- path: z.ZodOptional<z.ZodString>;
6
- description: z.ZodString;
7
- fallbackOnError: z.ZodDefault<z.ZodBoolean>;
8
- minApiVersion: z.ZodOptional<z.ZodString>;
9
- }, "strip", z.ZodTypeAny, {
10
- api: "soql" | "tooling" | "rest";
11
- description: string;
12
- fallbackOnError: boolean;
13
- path?: string | undefined;
14
- soql?: string | undefined;
15
- minApiVersion?: string | undefined;
16
- }, {
17
- api: "soql" | "tooling" | "rest";
18
- description: string;
19
- path?: string | undefined;
20
- soql?: string | undefined;
21
- fallbackOnError?: boolean | undefined;
22
- minApiVersion?: string | undefined;
23
- }>;
24
- export type QueryDefinition = z.infer<typeof QueryDefinitionSchema>;
25
- export declare const QueryFileSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
26
- api: z.ZodEnum<["soql", "tooling", "rest"]>;
27
- soql: z.ZodOptional<z.ZodString>;
28
- path: z.ZodOptional<z.ZodString>;
29
- description: z.ZodString;
30
- fallbackOnError: z.ZodDefault<z.ZodBoolean>;
31
- minApiVersion: z.ZodOptional<z.ZodString>;
32
- }, "strip", z.ZodTypeAny, {
33
- api: "soql" | "tooling" | "rest";
34
- description: string;
35
- fallbackOnError: boolean;
36
- path?: string | undefined;
37
- soql?: string | undefined;
38
- minApiVersion?: string | undefined;
39
- }, {
40
- api: "soql" | "tooling" | "rest";
41
- description: string;
42
- path?: string | undefined;
43
- soql?: string | undefined;
44
- fallbackOnError?: boolean | undefined;
45
- minApiVersion?: string | undefined;
46
- }>>;
47
- export type QueryFile = z.infer<typeof QueryFileSchema>;
48
- //# sourceMappingURL=QueryDefinition.d.ts.map
@@ -1,11 +0,0 @@
1
- import { z } from 'zod';
2
- export const QueryDefinitionSchema = z.object({
3
- api: z.enum(['soql', 'tooling', 'rest']),
4
- soql: z.string().optional(),
5
- path: z.string().optional(),
6
- description: z.string(),
7
- fallbackOnError: z.boolean().default(false),
8
- minApiVersion: z.string().optional(),
9
- });
10
- export const QueryFileSchema = z.record(z.string(), QueryDefinitionSchema);
11
- //# sourceMappingURL=QueryDefinition.js.map
@@ -1,13 +0,0 @@
1
- import { type QueryDefinition } from './QueryDefinition.js';
2
- import type { QueryResult } from '../api/SoqlClient.js';
3
- import type { AuditContext } from '../context/AuditContext.js';
4
- export declare class QueryRegistry {
5
- private readonly map;
6
- private constructor();
7
- static load(configDir: string): QueryRegistry;
8
- get(id: string): QueryDefinition;
9
- execute<T>(id: string, ctx: AuditContext): Promise<T[] | null>;
10
- executeQuery<T>(id: string, ctx: AuditContext): Promise<QueryResult<T> | null>;
11
- getAll(): ReadonlyMap<string, QueryDefinition>;
12
- }
13
- //# sourceMappingURL=QueryRegistry.d.ts.map
@@ -1,93 +0,0 @@
1
- import * as fs from 'node:fs';
2
- import * as path from 'node:path';
3
- import { QueryFileSchema } from './QueryDefinition.js';
4
- function warnFallback(id, err) {
5
- const msg = err instanceof Error ? err.message : String(err);
6
- process.stderr.write(`[QueryRegistry] Query '${id}' failed (fallbackOnError): ${msg}\n`);
7
- }
8
- export class QueryRegistry {
9
- map;
10
- constructor(entries) {
11
- this.map = entries;
12
- }
13
- static load(configDir) {
14
- const queryDir = path.join(configDir, 'config', 'queries');
15
- const files = ['soql.json', 'tooling.json'];
16
- const entries = new Map();
17
- for (const file of files) {
18
- const filePath = path.join(queryDir, file);
19
- let raw;
20
- try {
21
- raw = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
22
- }
23
- catch (err) {
24
- throw new Error(`QueryRegistry: failed to read ${filePath}: ${err.message}`);
25
- }
26
- const parsed = QueryFileSchema.safeParse(raw);
27
- if (!parsed.success) {
28
- throw new Error(`QueryRegistry: invalid schema in ${file}:\n${parsed.error.message}`);
29
- }
30
- for (const [key, def] of Object.entries(parsed.data)) {
31
- if (entries.has(key)) {
32
- throw new Error(`QueryRegistry: duplicate key '${key}' found in ${file}`);
33
- }
34
- entries.set(key, def);
35
- }
36
- }
37
- return new QueryRegistry(entries);
38
- }
39
- get(id) {
40
- const def = this.map.get(id);
41
- if (!def) {
42
- throw new Error(`QueryRegistry: unknown query key '${id}'`);
43
- }
44
- return def;
45
- }
46
- async execute(id, ctx) {
47
- const def = this.get(id);
48
- try {
49
- if (def.api === 'soql') {
50
- if (!def.soql)
51
- throw new Error(`Query '${id}' has api='soql' but no soql field`);
52
- return await ctx.soql.queryAll(def.soql);
53
- }
54
- if (def.api === 'tooling') {
55
- if (!def.soql)
56
- throw new Error(`Query '${id}' has api='tooling' but no soql field`);
57
- return await ctx.tooling.query(def.soql);
58
- }
59
- throw new Error(`QueryRegistry.execute: api='rest' entries cannot be executed here. ` +
60
- `Use ctx.rest.get() or ctx.tooling.getRecord() directly. Key: '${id}'`);
61
- }
62
- catch (err) {
63
- if (def.fallbackOnError) {
64
- warnFallback(id, err);
65
- return null;
66
- }
67
- throw err;
68
- }
69
- }
70
- async executeQuery(id, ctx) {
71
- const def = this.get(id);
72
- if (def.api !== 'soql') {
73
- throw new Error(`QueryRegistry.executeQuery: query '${id}' must have api='soql'`);
74
- }
75
- if (!def.soql) {
76
- throw new Error(`Query '${id}' has api='soql' but no soql field`);
77
- }
78
- try {
79
- return await ctx.soql.query(def.soql);
80
- }
81
- catch (err) {
82
- if (def.fallbackOnError) {
83
- warnFallback(id, err);
84
- return null;
85
- }
86
- throw err;
87
- }
88
- }
89
- getAll() {
90
- return this.map;
91
- }
92
- }
93
- //# sourceMappingURL=QueryRegistry.js.map