@snapback/cli 1.1.12 → 1.1.15
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/README.md +79 -18
- package/dist/SkippedTestDetector-AXTMWWHC.js +5 -0
- package/dist/SkippedTestDetector-QLSQV7K7.js +5 -0
- package/dist/analysis-6WTBZJH3.js +6 -0
- package/dist/analysis-C472LUGW.js +2475 -0
- package/dist/auth-HFJRXXG2.js +1446 -0
- package/dist/auto-provision-organization-SF6XM7X4.js +161 -0
- package/dist/chunk-23G5VYA3.js +4259 -0
- package/dist/{chunk-QAKFE3NE.js → chunk-4YTE4JEW.js} +3 -4
- package/dist/chunk-5EOPYJ4Y.js +12 -0
- package/dist/{chunk-G7QXHNGB.js → chunk-5SQA44V7.js} +1125 -32
- package/dist/{chunk-BW7RALUZ.js → chunk-7ADPL4Q3.js} +11 -4
- package/dist/chunk-CBGOC6RV.js +293 -0
- package/dist/chunk-DNEADD2G.js +3499 -0
- package/dist/{chunk-NKBZIXCN.js → chunk-DPWFZNMY.js} +122 -15
- package/dist/chunk-GQ73B37K.js +314 -0
- package/dist/chunk-HR34NJP7.js +6133 -0
- package/dist/chunk-ICKSHS3A.js +2264 -0
- package/dist/{chunk-KPETDXQO.js → chunk-OI2HNNT6.js} +565 -50
- package/dist/chunk-PL4HF4M2.js +593 -0
- package/dist/chunk-WS36HDEU.js +3735 -0
- package/dist/chunk-XYU5FFE3.js +111 -0
- package/dist/chunk-ZBQDE6WJ.js +108 -0
- package/dist/client-WIO6W447.js +8 -0
- package/dist/dist-E7E2T3DQ.js +9 -0
- package/dist/dist-TEWNOZYS.js +5 -0
- package/dist/dist-YZBJAYEJ.js +12 -0
- package/dist/index.js +65215 -26627
- package/dist/local-service-adapter-3JHN6G4O.js +6 -0
- package/dist/pioneer-oauth-hook-V2JKEXM7.js +12 -0
- package/dist/{secure-credentials-6UMEU22H.js → secure-credentials-UEPG7GWW.js} +15 -8
- package/dist/snapback-dir-MG7DTRMF.js +6 -0
- package/package.json +8 -42
- package/scripts/postinstall.mjs +2 -3
- package/dist/SkippedTestDetector-B3JZUE5G.js +0 -5
- package/dist/SkippedTestDetector-B3JZUE5G.js.map +0 -1
- package/dist/analysis-Z53F5FT2.js +0 -6
- package/dist/analysis-Z53F5FT2.js.map +0 -1
- package/dist/chunk-6MR2TINI.js +0 -27
- package/dist/chunk-6MR2TINI.js.map +0 -1
- package/dist/chunk-BW7RALUZ.js.map +0 -1
- package/dist/chunk-G7QXHNGB.js.map +0 -1
- package/dist/chunk-ISVRGBWT.js +0 -16223
- package/dist/chunk-ISVRGBWT.js.map +0 -1
- package/dist/chunk-KPETDXQO.js.map +0 -1
- package/dist/chunk-NKBZIXCN.js.map +0 -1
- package/dist/chunk-QAKFE3NE.js.map +0 -1
- package/dist/chunk-YOVA65PS.js +0 -12745
- package/dist/chunk-YOVA65PS.js.map +0 -1
- package/dist/dist-7UKXVKH3.js +0 -5
- package/dist/dist-7UKXVKH3.js.map +0 -1
- package/dist/dist-VDK7WEF4.js +0 -5
- package/dist/dist-VDK7WEF4.js.map +0 -1
- package/dist/dist-WKLJSPJT.js +0 -8
- package/dist/dist-WKLJSPJT.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/secure-credentials-6UMEU22H.js.map +0 -1
- package/dist/snapback-dir-T3CRQRY6.js +0 -6
- package/dist/snapback-dir-T3CRQRY6.js.map +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node --no-warnings=ExperimentalWarning
|
|
2
|
+
import { logger } from './chunk-PL4HF4M2.js';
|
|
3
|
+
import { __name } from './chunk-7ADPL4Q3.js';
|
|
4
|
+
|
|
5
|
+
process.env.SNAPBACK_CLI='true';
|
|
6
|
+
|
|
7
|
+
// ../../packages/auth/dist/lib/audit.js
|
|
8
|
+
var POSTHOG_API_KEY = process.env.POSTHOG_API_KEY || "";
|
|
9
|
+
var POSTHOG_HOST = process.env.POSTHOG_HOST || "https://us.posthog.com";
|
|
10
|
+
var POSTHOG_ENABLED = !!POSTHOG_API_KEY;
|
|
11
|
+
async function emitPostHogEvent(eventType, metadata) {
|
|
12
|
+
if (!POSTHOG_ENABLED) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const event = {
|
|
17
|
+
api_key: POSTHOG_API_KEY,
|
|
18
|
+
event: eventType,
|
|
19
|
+
distinct_id: metadata.userId || metadata.ip || "anonymous",
|
|
20
|
+
properties: {
|
|
21
|
+
...metadata,
|
|
22
|
+
$ip: metadata.ip,
|
|
23
|
+
$set: {
|
|
24
|
+
email: metadata.userId ? `user_${metadata.userId}` : void 0
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
28
|
+
};
|
|
29
|
+
const response = await fetch(`${POSTHOG_HOST}/capture/`, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: {
|
|
32
|
+
"Content-Type": "application/json"
|
|
33
|
+
},
|
|
34
|
+
body: JSON.stringify(event)
|
|
35
|
+
});
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
logger.error("Failed to emit PostHog event", {
|
|
38
|
+
eventType,
|
|
39
|
+
status: response.status,
|
|
40
|
+
statusText: response.statusText
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
logger.error("Error emitting PostHog event", {
|
|
45
|
+
error,
|
|
46
|
+
eventType
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
__name(emitPostHogEvent, "emitPostHogEvent");
|
|
51
|
+
async function writeAuditLog(eventType, metadata) {
|
|
52
|
+
try {
|
|
53
|
+
const { db, snapbackSchema } = await import('./dist-YZBJAYEJ.js');
|
|
54
|
+
if (!db) {
|
|
55
|
+
logger.warn("Database not available for audit logging", {
|
|
56
|
+
eventType
|
|
57
|
+
});
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const { telemetryEvents } = snapbackSchema;
|
|
61
|
+
await db.insert(telemetryEvents).values({
|
|
62
|
+
eventType,
|
|
63
|
+
eventCategory: "audit",
|
|
64
|
+
userId: metadata.userId,
|
|
65
|
+
properties: {
|
|
66
|
+
ip: metadata.ip,
|
|
67
|
+
userAgent: metadata.userAgent,
|
|
68
|
+
method: metadata.method,
|
|
69
|
+
path: metadata.path,
|
|
70
|
+
statusCode: metadata.statusCode,
|
|
71
|
+
errorMessage: metadata.errorMessage,
|
|
72
|
+
...metadata
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
logger.debug("Audit log written", {
|
|
76
|
+
eventType,
|
|
77
|
+
userId: metadata.userId,
|
|
78
|
+
orgId: metadata.orgId
|
|
79
|
+
});
|
|
80
|
+
} catch (error) {
|
|
81
|
+
logger.error("Failed to write audit log", {
|
|
82
|
+
error,
|
|
83
|
+
eventType,
|
|
84
|
+
metadata
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
__name(writeAuditLog, "writeAuditLog");
|
|
89
|
+
async function trackEvent(eventType, metadata) {
|
|
90
|
+
logger.info("Audit event", {
|
|
91
|
+
eventType,
|
|
92
|
+
userId: metadata.userId,
|
|
93
|
+
orgId: metadata.orgId,
|
|
94
|
+
path: metadata.path
|
|
95
|
+
});
|
|
96
|
+
emitPostHogEvent(eventType, metadata).catch((error) => {
|
|
97
|
+
logger.error("PostHog emit failed", {
|
|
98
|
+
error,
|
|
99
|
+
eventType
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
writeAuditLog(eventType, metadata).catch((error) => {
|
|
103
|
+
logger.error("Audit log write failed", {
|
|
104
|
+
error,
|
|
105
|
+
eventType
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
__name(trackEvent, "trackEvent");
|
|
110
|
+
|
|
111
|
+
export { trackEvent };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node --no-warnings=ExperimentalWarning
|
|
2
|
+
import { __name } from './chunk-7ADPL4Q3.js';
|
|
3
|
+
import { parse } from '@babel/parser';
|
|
4
|
+
|
|
5
|
+
process.env.SNAPBACK_CLI='true';
|
|
6
|
+
function detectSkippedTests(code, filePath) {
|
|
7
|
+
const skipped = [];
|
|
8
|
+
try {
|
|
9
|
+
let visit2 = function(node) {
|
|
10
|
+
if (node.type === "CallExpression") {
|
|
11
|
+
const callee = node.callee;
|
|
12
|
+
if (callee.type === "MemberExpression" && callee.property.type === "Identifier" && callee.property.name === "skip" && callee.object.type === "Identifier") {
|
|
13
|
+
const testType = callee.object.name;
|
|
14
|
+
if (testType === "describe" || testType === "it" || testType === "test") {
|
|
15
|
+
let name;
|
|
16
|
+
if (node.arguments.length > 0) {
|
|
17
|
+
const firstArg = node.arguments[0];
|
|
18
|
+
if (firstArg.type === "StringLiteral") {
|
|
19
|
+
name = firstArg.value;
|
|
20
|
+
} else if (firstArg.type === "TemplateLiteral" && firstArg.quasis.length === 1) {
|
|
21
|
+
name = firstArg.quasis[0].value.raw;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
skipped.push({
|
|
25
|
+
type: testType,
|
|
26
|
+
name,
|
|
27
|
+
line: node.loc?.start.line ?? 0,
|
|
28
|
+
column: node.loc?.start.column ?? 0,
|
|
29
|
+
file: filePath
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const key of Object.keys(node)) {
|
|
35
|
+
const value = node[key];
|
|
36
|
+
if (value && typeof value === "object") {
|
|
37
|
+
if (Array.isArray(value)) {
|
|
38
|
+
for (const item of value) {
|
|
39
|
+
if (item && typeof item === "object" && "type" in item) {
|
|
40
|
+
visit2(item);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} else if ("type" in value) {
|
|
44
|
+
visit2(value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var visit = visit2;
|
|
50
|
+
__name(visit2, "visit");
|
|
51
|
+
const ast = parse(code, {
|
|
52
|
+
sourceType: "module",
|
|
53
|
+
plugins: [
|
|
54
|
+
"typescript",
|
|
55
|
+
"jsx"
|
|
56
|
+
],
|
|
57
|
+
errorRecovery: true
|
|
58
|
+
});
|
|
59
|
+
visit2(ast.program);
|
|
60
|
+
return {
|
|
61
|
+
file: filePath,
|
|
62
|
+
skipped,
|
|
63
|
+
parsed: true
|
|
64
|
+
};
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return {
|
|
67
|
+
file: filePath,
|
|
68
|
+
skipped: [],
|
|
69
|
+
parsed: false,
|
|
70
|
+
error: error instanceof Error ? error.message : String(error)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
__name(detectSkippedTests, "detectSkippedTests");
|
|
75
|
+
function analyzeSkippedTests(files) {
|
|
76
|
+
const results = [];
|
|
77
|
+
for (const [filePath, content] of files) {
|
|
78
|
+
if (filePath.includes(".test.") || filePath.includes(".spec.") || filePath.includes("__tests__")) {
|
|
79
|
+
results.push(detectSkippedTests(content, filePath));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return results;
|
|
83
|
+
}
|
|
84
|
+
__name(analyzeSkippedTests, "analyzeSkippedTests");
|
|
85
|
+
function getSkippedTestSummary(results) {
|
|
86
|
+
const summary = {
|
|
87
|
+
totalSkipped: 0,
|
|
88
|
+
byType: {
|
|
89
|
+
describe: 0,
|
|
90
|
+
it: 0,
|
|
91
|
+
test: 0
|
|
92
|
+
},
|
|
93
|
+
filesWithSkipped: []
|
|
94
|
+
};
|
|
95
|
+
for (const result of results) {
|
|
96
|
+
if (result.skipped.length > 0) {
|
|
97
|
+
summary.filesWithSkipped.push(result.file);
|
|
98
|
+
summary.totalSkipped += result.skipped.length;
|
|
99
|
+
for (const test of result.skipped) {
|
|
100
|
+
summary.byType[test.type]++;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return summary;
|
|
105
|
+
}
|
|
106
|
+
__name(getSkippedTestSummary, "getSkippedTestSummary");
|
|
107
|
+
|
|
108
|
+
export { analyzeSkippedTests, detectSkippedTests, getSkippedTestSummary };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node --no-warnings=ExperimentalWarning
|
|
2
|
+
export { checkDatabaseConnection, closeDatabaseConnection, combinedSchema, db, pool } from './chunk-HR34NJP7.js';
|
|
3
|
+
import './chunk-WS36HDEU.js';
|
|
4
|
+
import './chunk-5EOPYJ4Y.js';
|
|
5
|
+
import './chunk-CBGOC6RV.js';
|
|
6
|
+
import './chunk-7ADPL4Q3.js';
|
|
7
|
+
|
|
8
|
+
process.env.SNAPBACK_CLI='true';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node --no-warnings=ExperimentalWarning
|
|
2
|
+
export { AnalyticsEvents, CORRELATION_ANALYSES, CORRELATION_COHORTS, KEY_METRIC_ALERTS, OTelInstrumentationProvider, RETENTION_COHORTS, TelemetryClient, addSentryBreadcrumb, captureError, captureMessage, checkDatabaseConnection, checkErrorBudget, checkHttpService, checkRedisConnection, clearSentryUser, createAlert, createCohort, createGracefulShutdown, createHealthCheck, createSentryMiddleware, deleteAlert, deleteCohort, detectSurface, drainAndCloseServer, flushSentry, getAlerts, getAnalyticsEnv, getAnalyticsSuperProperties, getCohort, getCohortMembers, getCohorts, getCorrelationAnalysis, getDeploymentEnv, getEnvironmentInfo, getErrorRate, getMetrics, initSentry, isDevelopment, isProduction, neon_exports as neon, performCorrelationAnalysis, preStopDelay, prometheus_exports as prometheus, recordError, recordSuccess, resetMetrics, setSentryUser, startSentryTransaction, toggleAlert, updateCohort } from './chunk-ICKSHS3A.js';
|
|
3
|
+
export { cache_exports as cache, logger, makeWatcher, resiliency_exports as resiliency } from './chunk-PL4HF4M2.js';
|
|
4
|
+
export { LogLevel, NoOpInstrumentationProvider } from './chunk-WS36HDEU.js';
|
|
5
|
+
import './chunk-5EOPYJ4Y.js';
|
|
6
|
+
import './chunk-CBGOC6RV.js';
|
|
7
|
+
import './chunk-7ADPL4Q3.js';
|
|
8
|
+
|
|
9
|
+
process.env.SNAPBACK_CLI='true';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node --no-warnings=ExperimentalWarning
|
|
2
|
+
export { createManagedMetadata, detectAIClients, detectMCPProcesses, detectWorkspaceConfig, evictCachedPath, getAllCachedPaths, getCachedPath, getClient, getClientConfigPath, getConfiguredClients, getOrCreateIdentity, getServerKey, getSnapbackConfigDir, getSnapbackMCPConfig, injectWorkspacePath, isCommandExecutable2 as isCommandExecutable, isOwnedByThisInstall, isSnapbackMCPRunning, patchApiKeyInClientConfig, readClientConfig, removeSnapbackConfig, repairClientConfig, resetIdentityCache, resolveNodePath, setCachedPath, validateClientConfig, validateConfig, validateWorkspacePath, writeClientConfig } from './chunk-OI2HNNT6.js';
|
|
3
|
+
import './chunk-7ADPL4Q3.js';
|
|
4
|
+
|
|
5
|
+
process.env.SNAPBACK_CLI='true';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node --no-warnings=ExperimentalWarning
|
|
2
|
+
export { AccountSchema, AiChatSchema, AttributionServiceImpl, EntitlementsServiceImpl, InvitationSchema, MCPService, MemberSchema, OrganizationSchema, OrganizationUpdateSchema, PasskeySchema, PioneerServiceImpl, PurchaseInsertSchema, PurchaseSchema, PurchaseUpdateSchema, SagaOrchestratorImpl, SessionSchema, SnapshotStoreDb, TelemetrySinkDb, UserSchema, UserUpdateSchema, VerificationSchema, anonymizeEmail, anonymizeUserData, anonymizeUserId, appendFalsePositivePatterns, calculateDecayedWeight, cleanupExpiredData, clearCapabilityCache, closeTestDb, countAllOrganizations, countAllUsers, createPurchase, createTestUser, createTierUpgradeSagaWithDeps, createUser, createUserAccount, databaseService, deletePurchaseBySubscriptionId, deleteUserApiKeys, deleteUserData, exportUserData, extensionLinkTokens, extensionSessions as extensionSessionsAuth, findSimilarPatterns, generateOrganizationSlug, getAccountById, getCacheMetrics, getCapabilities, getCapabilityAuditHistory, getInvitationById, getMCPService, getOrganizationById, getOrganizationBySlug, getOrganizationMembership, getOrganizationWithPurchasesAndMembersCount, getOrganizations, getOrganizationsWithMembers, getPendingInvitationByEmail, getPurchaseById, getPurchaseBySubscriptionId, getPurchasesByOrganizationId, getPurchasesByUserId, getTestDb, getUserByEmail, getUserById, getUserPrivacyPreferences, getUsers, getVectorStats, getWorkspaceLinkById, getWorkspaceLinksByUserId, handleTierDowngrade, handleTierUpgrade, healthCheck, incrementDetectionsAnalyzed, insertPatternWithEmbedding, invalidateCapabilityCache, isPgvectorEnabled, linkWorkspace, logAnonymizedEvent, logCapabilityAudit, mergeSignalIntoPattern, recordFalsePositiveSignal, resetCacheMetrics, resetCapabilities, resolveTierByWorkspaceId, sagaPersistence, sanitizeForLogging, searchSimilarPatterns, shouldRetainData, signalToPattern, testInTransaction, truncateAllTables, unlinkAllWorkspacesForUser, unlinkWorkspace, updateCapabilities, updateOrganization, updatePatternEmbedding, updatePurchase, updateUser, updateWorkspaceTier } from './chunk-23G5VYA3.js';
|
|
3
|
+
export { closeRedis, getRedisClient, initializeRedis, isRedisAvailable } from './chunk-GQ73B37K.js';
|
|
4
|
+
export { TOPUP_PACKS, account, activationCodeRedemptions, activationCodes, adminAuditLog, agentSuggestions, analysisEvents, apiKeyMetadata, apiKeyUsage, apiKeys, apiUsage, apiUsageLogs, checkDatabaseConnection, clientTokens, combinedSchema, creditJobTypeEnum, creditTopups, creditTransactionStatusEnum, creditTransactionTypeEnum, creditsLedger, db, deviceTrials, emailDeliveries, emailPreferences, extensionSessions, featureUsage, feedback, fileSnapshotSessions, fingerprints, getTopupPackDetails, isValidPackSize, loops, mcpActivityEvents, mcpAggregatedLearnings, mcpSessions, member, newsletterSubscribers, orgDailyMetrics, organization, pioneerActions, pioneerCodes, pioneerRedemptions, pioneerTierHistory, pioneers, policyEvaluations, pool, postAcceptOutcomes, purchase, rateLimitViolations, responseCache, retentionConfig, rollbackEvents, ruleViolations, postgres_exports as schema, securityEvents, snapbackSchema, snapshotFiles, snapshots, subscriptions, superAdmins, telemetryDailyStats, telemetryEvents, telemetryIdempotencyKeys, telemetryOutbox, topupStatusEnum, usageLimits, user, userProductMetrics, userSafetyProfiles, waitlist, waitlistAuditLogs, waitlistReferrals, waitlistTasks } from './chunk-HR34NJP7.js';
|
|
5
|
+
import './chunk-ICKSHS3A.js';
|
|
6
|
+
import './chunk-PL4HF4M2.js';
|
|
7
|
+
import './chunk-WS36HDEU.js';
|
|
8
|
+
import './chunk-5EOPYJ4Y.js';
|
|
9
|
+
import './chunk-CBGOC6RV.js';
|
|
10
|
+
import './chunk-7ADPL4Q3.js';
|
|
11
|
+
|
|
12
|
+
process.env.SNAPBACK_CLI='true';
|