@mastra/factory 0.2.2-alpha.1 → 0.2.2-alpha.2
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/CHANGELOG.md +10 -0
- package/dist/auth.js +401 -334
- package/dist/auth.js.map +1 -1
- package/dist/capabilities/connection.js +1 -1
- package/dist/capabilities/intake.js +1 -1
- package/dist/capabilities/version-control.js +1 -1
- package/dist/factory.js +441 -39622
- package/dist/factory.js.map +1 -1
- package/dist/index.js +2 -39633
- package/dist/integrations/base.js +1 -1
- package/dist/integrations/github/config.js +36 -22
- package/dist/integrations/github/config.js.map +1 -1
- package/dist/integrations/github/factory-session.js +33 -37
- package/dist/integrations/github/factory-session.js.map +1 -1
- package/dist/integrations/github/integration.js +1037 -3672
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/issue-triage.js +71 -71
- package/dist/integrations/github/issue-triage.js.map +1 -1
- package/dist/integrations/github/pat.js +47 -36
- package/dist/integrations/github/pat.js.map +1 -1
- package/dist/integrations/github/provenance.js +72 -101
- package/dist/integrations/github/provenance.js.map +1 -1
- package/dist/integrations/github/routes.js +1272 -1881
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.js +203 -471
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.js +400 -345
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/github/session-subscriptions.js +165 -223
- package/dist/integrations/github/session-subscriptions.js.map +1 -1
- package/dist/integrations/github/subscriptions.js +43 -51
- package/dist/integrations/github/subscriptions.js.map +1 -1
- package/dist/integrations/github/token-refresh.js +15 -18
- package/dist/integrations/github/token-refresh.js.map +1 -1
- package/dist/integrations/github/webhook.js +359 -343
- package/dist/integrations/github/webhook.js.map +1 -1
- package/dist/integrations/linear/agent-tools.js +77 -100
- package/dist/integrations/linear/agent-tools.js.map +1 -1
- package/dist/integrations/linear/integration.js +611 -1309
- package/dist/integrations/linear/integration.js.map +1 -1
- package/dist/integrations/linear/routes.js +227 -230
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/linear/rules.js +126 -346
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/linear/storage.js +1 -1
- package/dist/integrations/platform/api-client.js +131 -135
- package/dist/integrations/platform/api-client.js.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +275 -573
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.js +845 -4022
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/linear/integration.js +457 -1309
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/workos/integration.js +80 -85
- package/dist/integrations/workos/integration.js.map +1 -1
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +933 -912
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/custom-provider-source.js +110 -93
- package/dist/routes/custom-provider-source.js.map +1 -1
- package/dist/routes/fs.js +401 -349
- package/dist/routes/fs.js.map +1 -1
- package/dist/routes/intake.js +165 -165
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/oauth.js +447 -25166
- package/dist/routes/oauth.js.map +1 -1
- package/dist/routes/projects.js +437 -376
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/provider-credentials.js +76 -58
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/route.js +12 -8
- package/dist/routes/route.js.map +1 -1
- package/dist/routes/skills.js +160 -173
- package/dist/routes/skills.js.map +1 -1
- package/dist/routes/surface.js +250 -28615
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/tenant-credentials.js +141 -166
- package/dist/routes/tenant-credentials.js.map +1 -1
- package/dist/routes/work-items.js +654 -862
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/binding-context.js +23 -35
- package/dist/rules/binding-context.js.map +1 -1
- package/dist/rules/defaults.js +200 -309
- package/dist/rules/defaults.js.map +1 -1
- package/dist/rules/dispatcher.js +438 -683
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/index.js +5 -599
- package/dist/rules/processor.js +344 -596
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/resolve.js +21 -18
- package/dist/rules/resolve.js.map +1 -1
- package/dist/rules/start-coordinator.js +168 -157
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.js +50 -85
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.js +183 -454
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.js +33 -29
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.js +266 -281
- package/dist/rules/validation.js.map +1 -1
- package/dist/sandbox/fleet.js +272 -250
- package/dist/sandbox/fleet.js.map +1 -1
- package/dist/sandbox/reattach.js +13 -6
- package/dist/sandbox/reattach.js.map +1 -1
- package/dist/server-error.js +12 -16
- package/dist/server-error.js.map +1 -1
- package/dist/skills/service.js +30 -35
- package/dist/skills/service.js.map +1 -1
- package/dist/spa-static.js +91 -65
- package/dist/spa-static.js.map +1 -1
- package/dist/state-signing.js +73 -44
- package/dist/state-signing.js.map +1 -1
- package/dist/storage/domains/audit/agent-audit.js +60 -59
- package/dist/storage/domains/audit/agent-audit.js.map +1 -1
- package/dist/storage/domains/audit/base.js +169 -112
- package/dist/storage/domains/audit/base.js.map +1 -1
- package/dist/storage/domains/audit/domain.js +155 -153
- package/dist/storage/domains/audit/domain.js.map +1 -1
- package/dist/storage/domains/credentials/base.js +259 -243
- package/dist/storage/domains/credentials/base.js.map +1 -1
- package/dist/storage/domains/custom-providers/base.js +138 -143
- package/dist/storage/domains/custom-providers/base.js.map +1 -1
- package/dist/storage/domains/intake/base.js +75 -57
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/integrations/base.js +310 -245
- package/dist/storage/domains/integrations/base.js.map +1 -1
- package/dist/storage/domains/memory-settings/base.js +117 -102
- package/dist/storage/domains/memory-settings/base.js.map +1 -1
- package/dist/storage/domains/model-packs/base.js +89 -88
- package/dist/storage/domains/model-packs/base.js.map +1 -1
- package/dist/storage/domains/projects/base.js +97 -92
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/queue-health/base.js +111 -76
- package/dist/storage/domains/queue-health/base.js.map +1 -1
- package/dist/storage/domains/source-control/base.js +777 -706
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +322 -348
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/storage/domains/work-items/base.js +1266 -1148
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/metrics.js +202 -184
- package/dist/storage/domains/work-items/metrics.js.map +1 -1
- package/dist/timing.js +29 -22
- package/dist/timing.js.map +1 -1
- package/dist/workspace.js +236 -477
- package/dist/workspace.js.map +1 -1
- package/package.json +8 -8
- package/dist/capabilities/connection.js.map +0 -1
- package/dist/capabilities/intake.js.map +0 -1
- package/dist/capabilities/version-control.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integrations/base.js.map +0 -1
- package/dist/integrations/linear/storage.js.map +0 -1
- package/dist/rules/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,28 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
//#region src/integrations/github/config.ts
|
|
2
|
+
/**
|
|
3
|
+
* Env vars the deploy entry reads to construct a `GithubIntegration`. Names
|
|
4
|
+
* only — used by diagnostics to tell an operator what to set when the
|
|
5
|
+
* integration is absent. The entry enforces all-or-nothing: partial config
|
|
6
|
+
* fails the boot, so at runtime the integration is either fully configured or
|
|
7
|
+
* not configured at all.
|
|
8
|
+
*/
|
|
9
|
+
const GITHUB_APP_ENV_VARS = [
|
|
10
|
+
"GITHUB_APP_ID",
|
|
11
|
+
"GITHUB_APP_PRIVATE_KEY",
|
|
12
|
+
"GITHUB_APP_CLIENT_ID",
|
|
13
|
+
"GITHUB_APP_CLIENT_SECRET",
|
|
14
|
+
"GITHUB_APP_SLUG"
|
|
8
15
|
];
|
|
16
|
+
/**
|
|
17
|
+
* True when the GitHub App project feature should be active.
|
|
18
|
+
*/
|
|
9
19
|
function isGithubFeatureEnabled(options) {
|
|
10
|
-
|
|
20
|
+
return options.github !== void 0 && options.auth.enabled();
|
|
11
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Collect a non-secret diagnostic snapshot of every GitHub feature gate. Centralizes
|
|
24
|
+
* the feature-gate reasoning so startup logs, the status API, and the SPA explain
|
|
25
|
+
* the same state. Does not change `isGithubFeatureEnabled()` behavior.
|
|
26
|
+
*/
|
|
12
27
|
function getGithubFeatureDiagnostics(options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
const { github, auth, appDbConfigured, stateSigner, fleet } = options;
|
|
29
|
+
return {
|
|
30
|
+
githubAppConfigured: github !== void 0,
|
|
31
|
+
factoryAuthEnabled: auth.enabled(),
|
|
32
|
+
appDbConfigured,
|
|
33
|
+
stateSecretConfigured: stateSigner?.stable ?? false,
|
|
34
|
+
sandboxEnabled: fleet?.enabled ?? false,
|
|
35
|
+
sandboxProvider: fleet?.provider ?? "none",
|
|
36
|
+
missingGithubAppEnvVars: github ? [] : [...GITHUB_APP_ENV_VARS]
|
|
37
|
+
};
|
|
23
38
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { getGithubFeatureDiagnostics, isGithubFeatureEnabled };
|
|
41
|
+
|
|
28
42
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/integrations/github/config.ts"],"sourcesContent":["/**\n * Composite feature gate + diagnostics for the GitHub App project feature.\n *\n * The GitHub feature is enabled only when *all three* hold:\n * - a `GithubIntegration` instance is registered with the factory\n * (constructed by the deploy entry from the `GITHUB_APP_*` env vars),\n * - web auth is enabled (a per-user installation requires a logged-in user),\n * - the application database is configured.\n *\n * OAuth/install `state` signing lives in `../../state-signing.ts` — the factory\n * creates one shared signer at boot and hands it to every integration.\n *\n * Everything here is pure: callers pass the handles they already own (the\n * integration, auth seam, state signer, sandbox fleet) — there is no global\n * registry lookup.\n */\n\nimport type { RouteAuth } from '../../routes/route.js';\nimport type { SandboxFleet } from '../../sandbox/fleet.js';\nimport type { StateSigner } from '../../state-signing.js';\nimport type { GithubIntegration } from './integration.js';\n\n/**\n * Env vars the deploy entry reads to construct a `GithubIntegration`. Names\n * only — used by diagnostics to tell an operator what to set when the\n * integration is absent. The entry enforces all-or-nothing: partial config\n * fails the boot, so at runtime the integration is either fully configured or\n * not configured at all.\n */\nconst GITHUB_APP_ENV_VARS = [\n 'GITHUB_APP_ID',\n 'GITHUB_APP_PRIVATE_KEY',\n 'GITHUB_APP_CLIENT_ID',\n 'GITHUB_APP_CLIENT_SECRET',\n 'GITHUB_APP_SLUG',\n] as const;\n\n/** Handles the GitHub feature gate + diagnostics are computed from. */\nexport interface GithubFeatureGateOptions {\n /** The registered GitHub integration, when configured. */\n github: GithubIntegration | undefined;\n /** Web auth seam — the feature requires a logged-in user. */\n auth: RouteAuth;\n /** True when the application database is configured. */\n appDbConfigured: boolean;\n /** Shared OAuth/install `state` signer, when configured. */\n stateSigner?: StateSigner;\n /** Sandbox fleet, when sandboxes are configured. */\n fleet?: SandboxFleet;\n}\n\n/**\n * True when the GitHub App project feature should be active.\n */\nexport function isGithubFeatureEnabled(options: Pick<GithubFeatureGateOptions, 'github' | 'auth'>): boolean {\n return options.github !== undefined && options.auth.enabled();\n}\n\n/**\n * Non-secret diagnostic snapshot of every GitHub feature gate. Used by startup\n * logs, `/web/github/status`, and the SPA so all three explain the same state.\n *\n * Only env var *names* and booleans are exposed — never secret values.\n */\nexport interface GithubFeatureDiagnostics {\n githubAppConfigured: boolean;\n factoryAuthEnabled: boolean;\n appDbConfigured: boolean;\n stateSecretConfigured: boolean;\n sandboxEnabled: boolean;\n sandboxProvider: string;\n /** Names of the GitHub App env vars still needed (empty when configured). */\n missingGithubAppEnvVars: string[];\n}\n\n/**\n * Collect a non-secret diagnostic snapshot of every GitHub feature gate. Centralizes\n * the feature-gate reasoning so startup logs, the status API, and the SPA explain\n * the same state. Does not change `isGithubFeatureEnabled()` behavior.\n */\nexport function getGithubFeatureDiagnostics(options: GithubFeatureGateOptions): GithubFeatureDiagnostics {\n const { github, auth, appDbConfigured, stateSigner, fleet } = options;\n return {\n githubAppConfigured: github !== undefined,\n factoryAuthEnabled: auth.enabled(),\n appDbConfigured,\n stateSecretConfigured: stateSigner?.stable ?? false,\n sandboxEnabled: fleet?.enabled ?? false,\n sandboxProvider: fleet?.provider ?? 'none',\n missingGithubAppEnvVars: github ? [] : [...GITHUB_APP_ENV_VARS],\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../../../src/integrations/github/config.ts"],"sourcesContent":["/**\n * Composite feature gate + diagnostics for the GitHub App project feature.\n *\n * The GitHub feature is enabled only when *all three* hold:\n * - a `GithubIntegration` instance is registered with the factory\n * (constructed by the deploy entry from the `GITHUB_APP_*` env vars),\n * - web auth is enabled (a per-user installation requires a logged-in user),\n * - the application database is configured.\n *\n * OAuth/install `state` signing lives in `../../state-signing.ts` — the factory\n * creates one shared signer at boot and hands it to every integration.\n *\n * Everything here is pure: callers pass the handles they already own (the\n * integration, auth seam, state signer, sandbox fleet) — there is no global\n * registry lookup.\n */\n\nimport type { RouteAuth } from '../../routes/route.js';\nimport type { SandboxFleet } from '../../sandbox/fleet.js';\nimport type { StateSigner } from '../../state-signing.js';\nimport type { GithubIntegration } from './integration.js';\n\n/**\n * Env vars the deploy entry reads to construct a `GithubIntegration`. Names\n * only — used by diagnostics to tell an operator what to set when the\n * integration is absent. The entry enforces all-or-nothing: partial config\n * fails the boot, so at runtime the integration is either fully configured or\n * not configured at all.\n */\nconst GITHUB_APP_ENV_VARS = [\n 'GITHUB_APP_ID',\n 'GITHUB_APP_PRIVATE_KEY',\n 'GITHUB_APP_CLIENT_ID',\n 'GITHUB_APP_CLIENT_SECRET',\n 'GITHUB_APP_SLUG',\n] as const;\n\n/** Handles the GitHub feature gate + diagnostics are computed from. */\nexport interface GithubFeatureGateOptions {\n /** The registered GitHub integration, when configured. */\n github: GithubIntegration | undefined;\n /** Web auth seam — the feature requires a logged-in user. */\n auth: RouteAuth;\n /** True when the application database is configured. */\n appDbConfigured: boolean;\n /** Shared OAuth/install `state` signer, when configured. */\n stateSigner?: StateSigner;\n /** Sandbox fleet, when sandboxes are configured. */\n fleet?: SandboxFleet;\n}\n\n/**\n * True when the GitHub App project feature should be active.\n */\nexport function isGithubFeatureEnabled(options: Pick<GithubFeatureGateOptions, 'github' | 'auth'>): boolean {\n return options.github !== undefined && options.auth.enabled();\n}\n\n/**\n * Non-secret diagnostic snapshot of every GitHub feature gate. Used by startup\n * logs, `/web/github/status`, and the SPA so all three explain the same state.\n *\n * Only env var *names* and booleans are exposed — never secret values.\n */\nexport interface GithubFeatureDiagnostics {\n githubAppConfigured: boolean;\n factoryAuthEnabled: boolean;\n appDbConfigured: boolean;\n stateSecretConfigured: boolean;\n sandboxEnabled: boolean;\n sandboxProvider: string;\n /** Names of the GitHub App env vars still needed (empty when configured). */\n missingGithubAppEnvVars: string[];\n}\n\n/**\n * Collect a non-secret diagnostic snapshot of every GitHub feature gate. Centralizes\n * the feature-gate reasoning so startup logs, the status API, and the SPA explain\n * the same state. Does not change `isGithubFeatureEnabled()` behavior.\n */\nexport function getGithubFeatureDiagnostics(options: GithubFeatureGateOptions): GithubFeatureDiagnostics {\n const { github, auth, appDbConfigured, stateSigner, fleet } = options;\n return {\n githubAppConfigured: github !== undefined,\n factoryAuthEnabled: auth.enabled(),\n appDbConfigured,\n stateSecretConfigured: stateSigner?.stable ?? false,\n sandboxEnabled: fleet?.enabled ?? false,\n sandboxProvider: fleet?.provider ?? 'none',\n missingGithubAppEnvVars: github ? [] : [...GITHUB_APP_ENV_VARS],\n };\n}\n"],"mappings":";;;;;;;;AA6BA,MAAM,sBAAsB;CAC1B;CACA;CACA;CACA;CACA;AACF;;;;AAmBA,SAAgB,uBAAuB,SAAqE;CAC1G,OAAO,QAAQ,WAAW,KAAA,KAAa,QAAQ,KAAK,QAAQ;AAC9D;;;;;;AAwBA,SAAgB,4BAA4B,SAA6D;CACvG,MAAM,EAAE,QAAQ,MAAM,iBAAiB,aAAa,UAAU;CAC9D,OAAO;EACL,qBAAqB,WAAW,KAAA;EAChC,oBAAoB,KAAK,QAAQ;EACjC;EACA,uBAAuB,aAAa,UAAU;EAC9C,gBAAgB,OAAO,WAAW;EAClC,iBAAiB,OAAO,YAAY;EACpC,yBAAyB,SAAS,CAAC,IAAI,CAAC,GAAG,mBAAmB;CAChE;AACF"}
|
|
@@ -1,41 +1,37 @@
|
|
|
1
|
-
// src/integrations/github/factory-session.ts
|
|
2
1
|
import { randomUUID } from "crypto";
|
|
2
|
+
//#region src/integrations/github/factory-session.ts
|
|
3
3
|
async function ensureFactoryRuleSession(args) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
branch: args.branch,
|
|
34
|
-
baseBranch: resolved.projectRepository.branch ?? resolved.repository.defaultBranch
|
|
35
|
-
});
|
|
36
|
-
return { sessionId: session.sessionId, userId };
|
|
4
|
+
const connection = (await args.github.sourceControlStorage.connections.list({
|
|
5
|
+
orgId: args.orgId,
|
|
6
|
+
factoryProjectId: args.factoryProjectId
|
|
7
|
+
})).find((candidate) => candidate.integrationId === args.github.id);
|
|
8
|
+
if (!connection) throw new Error("Factory GitHub connection not found.");
|
|
9
|
+
const projectRepositories = await args.github.sourceControlStorage.projectRepositories.list({
|
|
10
|
+
orgId: args.orgId,
|
|
11
|
+
connectionId: connection.id
|
|
12
|
+
});
|
|
13
|
+
const resolved = (await Promise.all(projectRepositories.map(async (projectRepository) => ({
|
|
14
|
+
projectRepository,
|
|
15
|
+
repository: await args.github.sourceControlStorage.repositories.get({
|
|
16
|
+
orgId: args.orgId,
|
|
17
|
+
id: projectRepository.repositoryId
|
|
18
|
+
})
|
|
19
|
+
})))).find((candidate) => candidate.repository && (!args.repositorySlug || candidate.repository.slug === args.repositorySlug));
|
|
20
|
+
if (!resolved?.repository) throw new Error("Factory GitHub repository not found.");
|
|
21
|
+
const userId = connection.createdByUserId;
|
|
22
|
+
return {
|
|
23
|
+
sessionId: (await args.github.sourceControlStorage.sessions.create({
|
|
24
|
+
sessionId: randomUUID(),
|
|
25
|
+
projectRepositoryId: resolved.projectRepository.id,
|
|
26
|
+
orgId: args.orgId,
|
|
27
|
+
userId,
|
|
28
|
+
branch: args.branch,
|
|
29
|
+
baseBranch: resolved.projectRepository.branch ?? resolved.repository.defaultBranch
|
|
30
|
+
})).sessionId,
|
|
31
|
+
userId
|
|
32
|
+
};
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
//#endregion
|
|
35
|
+
export { ensureFactoryRuleSession };
|
|
36
|
+
|
|
41
37
|
//# sourceMappingURL=factory-session.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/integrations/github/factory-session.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\n\nimport type { GithubIntegration } from './integration.js';\n\nexport async function ensureFactoryRuleSession(args: {\n github: GithubIntegration;\n orgId: string;\n factoryProjectId: string;\n repositorySlug?: string;\n branch: string;\n}): Promise<{ sessionId: string; userId: string }> {\n const connections = await args.github.sourceControlStorage.connections.list({\n orgId: args.orgId,\n factoryProjectId: args.factoryProjectId,\n });\n const connection = connections.find(candidate => candidate.integrationId === args.github.id);\n if (!connection) throw new Error('Factory GitHub connection not found.');\n\n const projectRepositories = await args.github.sourceControlStorage.projectRepositories.list({\n orgId: args.orgId,\n connectionId: connection.id,\n });\n const resolvedRepositories = await Promise.all(\n projectRepositories.map(async projectRepository => ({\n projectRepository,\n repository: await args.github.sourceControlStorage.repositories.get({\n orgId: args.orgId,\n id: projectRepository.repositoryId,\n }),\n })),\n );\n const resolved = resolvedRepositories.find(\n candidate => candidate.repository && (!args.repositorySlug || candidate.repository.slug === args.repositorySlug),\n );\n if (!resolved?.repository) throw new Error('Factory GitHub repository not found.');\n\n const userId = connection.createdByUserId;\n const session = await args.github.sourceControlStorage.sessions.create({\n sessionId: randomUUID(),\n projectRepositoryId: resolved.projectRepository.id,\n orgId: args.orgId,\n userId,\n branch: args.branch,\n baseBranch: resolved.projectRepository.branch ?? resolved.repository.defaultBranch,\n });\n return { sessionId: session.sessionId, userId };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory-session.js","names":[],"sources":["../../../src/integrations/github/factory-session.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\n\nimport type { GithubIntegration } from './integration.js';\n\nexport async function ensureFactoryRuleSession(args: {\n github: GithubIntegration;\n orgId: string;\n factoryProjectId: string;\n repositorySlug?: string;\n branch: string;\n}): Promise<{ sessionId: string; userId: string }> {\n const connections = await args.github.sourceControlStorage.connections.list({\n orgId: args.orgId,\n factoryProjectId: args.factoryProjectId,\n });\n const connection = connections.find(candidate => candidate.integrationId === args.github.id);\n if (!connection) throw new Error('Factory GitHub connection not found.');\n\n const projectRepositories = await args.github.sourceControlStorage.projectRepositories.list({\n orgId: args.orgId,\n connectionId: connection.id,\n });\n const resolvedRepositories = await Promise.all(\n projectRepositories.map(async projectRepository => ({\n projectRepository,\n repository: await args.github.sourceControlStorage.repositories.get({\n orgId: args.orgId,\n id: projectRepository.repositoryId,\n }),\n })),\n );\n const resolved = resolvedRepositories.find(\n candidate => candidate.repository && (!args.repositorySlug || candidate.repository.slug === args.repositorySlug),\n );\n if (!resolved?.repository) throw new Error('Factory GitHub repository not found.');\n\n const userId = connection.createdByUserId;\n const session = await args.github.sourceControlStorage.sessions.create({\n sessionId: randomUUID(),\n projectRepositoryId: resolved.projectRepository.id,\n orgId: args.orgId,\n userId,\n branch: args.branch,\n baseBranch: resolved.projectRepository.branch ?? resolved.repository.defaultBranch,\n });\n return { sessionId: session.sessionId, userId };\n}\n"],"mappings":";;AAIA,eAAsB,yBAAyB,MAMI;CAKjD,MAAM,cAAa,MAJO,KAAK,OAAO,qBAAqB,YAAY,KAAK;EAC1E,OAAO,KAAK;EACZ,kBAAkB,KAAK;CACzB,CAAC,EAAA,CAC8B,MAAK,cAAa,UAAU,kBAAkB,KAAK,OAAO,EAAE;CAC3F,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,sCAAsC;CAEvE,MAAM,sBAAsB,MAAM,KAAK,OAAO,qBAAqB,oBAAoB,KAAK;EAC1F,OAAO,KAAK;EACZ,cAAc,WAAW;CAC3B,CAAC;CAUD,MAAM,YAAW,MATkB,QAAQ,IACzC,oBAAoB,IAAI,OAAM,uBAAsB;EAClD;EACA,YAAY,MAAM,KAAK,OAAO,qBAAqB,aAAa,IAAI;GAClE,OAAO,KAAK;GACZ,IAAI,kBAAkB;EACxB,CAAC;CACH,EAAE,CACJ,EAAA,CACsC,MACpC,cAAa,UAAU,eAAe,CAAC,KAAK,kBAAkB,UAAU,WAAW,SAAS,KAAK,eACnG;CACA,IAAI,CAAC,UAAU,YAAY,MAAM,IAAI,MAAM,sCAAsC;CAEjF,MAAM,SAAS,WAAW;CAS1B,OAAO;EAAE,YAAW,MARE,KAAK,OAAO,qBAAqB,SAAS,OAAO;GACrE,WAAW,WAAW;GACtB,qBAAqB,SAAS,kBAAkB;GAChD,OAAO,KAAK;GACZ;GACA,QAAQ,KAAK;GACb,YAAY,SAAS,kBAAkB,UAAU,SAAS,WAAW;EACvE,CAAC,EAAA,CAC2B;EAAW;CAAO;AAChD"}
|