@commandable/mcp-core 0.2.0

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 (157) hide show
  1. package/LICENSE +10 -0
  2. package/README.md +8 -0
  3. package/dist/config/configApply.d.ts +16 -0
  4. package/dist/config/configApply.d.ts.map +1 -0
  5. package/dist/config/configApply.js +77 -0
  6. package/dist/config/configApply.js.map +1 -0
  7. package/dist/config/configLoader.d.ts +9 -0
  8. package/dist/config/configLoader.d.ts.map +1 -0
  9. package/dist/config/configLoader.js +75 -0
  10. package/dist/config/configLoader.js.map +1 -0
  11. package/dist/config/configSchema.d.ts +45 -0
  12. package/dist/config/configSchema.d.ts.map +1 -0
  13. package/dist/config/configSchema.js +23 -0
  14. package/dist/config/configSchema.js.map +1 -0
  15. package/dist/crypto/encryption.d.ts +3 -0
  16. package/dist/crypto/encryption.d.ts.map +1 -0
  17. package/dist/crypto/encryption.js +29 -0
  18. package/dist/crypto/encryption.js.map +1 -0
  19. package/dist/db/client.d.ts +24 -0
  20. package/dist/db/client.d.ts.map +1 -0
  21. package/dist/db/client.js +50 -0
  22. package/dist/db/client.js.map +1 -0
  23. package/dist/db/credentialStore.d.ts +15 -0
  24. package/dist/db/credentialStore.d.ts.map +1 -0
  25. package/dist/db/credentialStore.js +56 -0
  26. package/dist/db/credentialStore.js.map +1 -0
  27. package/dist/db/integrationStore.d.ts +14 -0
  28. package/dist/db/integrationStore.d.ts.map +1 -0
  29. package/dist/db/integrationStore.js +128 -0
  30. package/dist/db/integrationStore.js.map +1 -0
  31. package/dist/db/integrationTypeConfigStore.d.ts +7 -0
  32. package/dist/db/integrationTypeConfigStore.d.ts.map +1 -0
  33. package/dist/db/integrationTypeConfigStore.js +101 -0
  34. package/dist/db/integrationTypeConfigStore.js.map +1 -0
  35. package/dist/db/migrate.d.ts +3 -0
  36. package/dist/db/migrate.d.ts.map +1 -0
  37. package/dist/db/migrate.js +11 -0
  38. package/dist/db/migrate.js.map +1 -0
  39. package/dist/db/migrations/pg/0000_initial.sql +74 -0
  40. package/dist/db/migrations/pg/meta/_journal.json +13 -0
  41. package/dist/db/migrations/sqlite/0000_initial.sql +74 -0
  42. package/dist/db/migrations/sqlite/meta/_journal.json +13 -0
  43. package/dist/db/schema.d.ts +1863 -0
  44. package/dist/db/schema.d.ts.map +1 -0
  45. package/dist/db/schema.js +133 -0
  46. package/dist/db/schema.js.map +1 -0
  47. package/dist/db/toolDefinitionStore.d.ts +9 -0
  48. package/dist/db/toolDefinitionStore.d.ts.map +1 -0
  49. package/dist/db/toolDefinitionStore.js +117 -0
  50. package/dist/db/toolDefinitionStore.js.map +1 -0
  51. package/dist/errors/httpError.d.ts +6 -0
  52. package/dist/errors/httpError.d.ts.map +1 -0
  53. package/dist/errors/httpError.js +11 -0
  54. package/dist/errors/httpError.js.map +1 -0
  55. package/dist/index.d.ts +34 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +34 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/integrations/actionsFactory.d.ts +16 -0
  60. package/dist/integrations/actionsFactory.d.ts.map +1 -0
  61. package/dist/integrations/actionsFactory.js +98 -0
  62. package/dist/integrations/actionsFactory.js.map +1 -0
  63. package/dist/integrations/catalog.d.ts +8 -0
  64. package/dist/integrations/catalog.d.ts.map +1 -0
  65. package/dist/integrations/catalog.js +45 -0
  66. package/dist/integrations/catalog.js.map +1 -0
  67. package/dist/integrations/customToolFactory.d.ts +13 -0
  68. package/dist/integrations/customToolFactory.d.ts.map +1 -0
  69. package/dist/integrations/customToolFactory.js +31 -0
  70. package/dist/integrations/customToolFactory.js.map +1 -0
  71. package/dist/integrations/dataLoader.d.ts +3 -0
  72. package/dist/integrations/dataLoader.d.ts.map +1 -0
  73. package/dist/integrations/dataLoader.js +2 -0
  74. package/dist/integrations/dataLoader.js.map +1 -0
  75. package/dist/integrations/fileIntegrationTypeConfigStore.d.ts +7 -0
  76. package/dist/integrations/fileIntegrationTypeConfigStore.d.ts.map +1 -0
  77. package/dist/integrations/fileIntegrationTypeConfigStore.js +34 -0
  78. package/dist/integrations/fileIntegrationTypeConfigStore.js.map +1 -0
  79. package/dist/integrations/getIntegration.d.ts +14 -0
  80. package/dist/integrations/getIntegration.d.ts.map +1 -0
  81. package/dist/integrations/getIntegration.js +30 -0
  82. package/dist/integrations/getIntegration.js.map +1 -0
  83. package/dist/integrations/googleServiceAccount.d.ts +6 -0
  84. package/dist/integrations/googleServiceAccount.d.ts.map +1 -0
  85. package/dist/integrations/googleServiceAccount.js +54 -0
  86. package/dist/integrations/googleServiceAccount.js.map +1 -0
  87. package/dist/integrations/health.d.ts +20 -0
  88. package/dist/integrations/health.d.ts.map +1 -0
  89. package/dist/integrations/health.js +43 -0
  90. package/dist/integrations/health.js.map +1 -0
  91. package/dist/integrations/integrationTypeConfigLookup.d.ts +12 -0
  92. package/dist/integrations/integrationTypeConfigLookup.d.ts.map +1 -0
  93. package/dist/integrations/integrationTypeConfigLookup.js +11 -0
  94. package/dist/integrations/integrationTypeConfigLookup.js.map +1 -0
  95. package/dist/integrations/providerRegistry.d.ts +2 -0
  96. package/dist/integrations/providerRegistry.d.ts.map +1 -0
  97. package/dist/integrations/providerRegistry.js +72 -0
  98. package/dist/integrations/providerRegistry.js.map +1 -0
  99. package/dist/integrations/proxy.d.ts +19 -0
  100. package/dist/integrations/proxy.d.ts.map +1 -0
  101. package/dist/integrations/proxy.js +377 -0
  102. package/dist/integrations/proxy.js.map +1 -0
  103. package/dist/integrations/sandbox.d.ts +8 -0
  104. package/dist/integrations/sandbox.d.ts.map +1 -0
  105. package/dist/integrations/sandbox.js +221 -0
  106. package/dist/integrations/sandbox.js.map +1 -0
  107. package/dist/integrations/sandboxUtils.d.ts +15 -0
  108. package/dist/integrations/sandboxUtils.d.ts.map +1 -0
  109. package/dist/integrations/sandboxUtils.js +489 -0
  110. package/dist/integrations/sandboxUtils.js.map +1 -0
  111. package/dist/integrations/tools.d.ts +3 -0
  112. package/dist/integrations/tools.d.ts.map +1 -0
  113. package/dist/integrations/tools.js +70 -0
  114. package/dist/integrations/tools.js.map +1 -0
  115. package/dist/mcp/abilityCatalog.d.ts +51 -0
  116. package/dist/mcp/abilityCatalog.d.ts.map +1 -0
  117. package/dist/mcp/abilityCatalog.js +300 -0
  118. package/dist/mcp/abilityCatalog.js.map +1 -0
  119. package/dist/mcp/auth.d.ts +18 -0
  120. package/dist/mcp/auth.d.ts.map +1 -0
  121. package/dist/mcp/auth.js +45 -0
  122. package/dist/mcp/auth.js.map +1 -0
  123. package/dist/mcp/builder_guide.md +441 -0
  124. package/dist/mcp/commandable_readme.md +29 -0
  125. package/dist/mcp/handlers.d.ts +21 -0
  126. package/dist/mcp/handlers.d.ts.map +1 -0
  127. package/dist/mcp/handlers.js +86 -0
  128. package/dist/mcp/handlers.js.map +1 -0
  129. package/dist/mcp/metaTools.d.ts +79 -0
  130. package/dist/mcp/metaTools.d.ts.map +1 -0
  131. package/dist/mcp/metaTools.js +901 -0
  132. package/dist/mcp/metaTools.js.map +1 -0
  133. package/dist/mcp/server.d.ts +25 -0
  134. package/dist/mcp/server.d.ts.map +1 -0
  135. package/dist/mcp/server.js +14 -0
  136. package/dist/mcp/server.js.map +1 -0
  137. package/dist/mcp/sessionState.d.ts +19 -0
  138. package/dist/mcp/sessionState.d.ts.map +1 -0
  139. package/dist/mcp/sessionState.js +79 -0
  140. package/dist/mcp/sessionState.js.map +1 -0
  141. package/dist/mcp/toolAdapter.d.ts +34 -0
  142. package/dist/mcp/toolAdapter.d.ts.map +1 -0
  143. package/dist/mcp/toolAdapter.js +24 -0
  144. package/dist/mcp/toolAdapter.js.map +1 -0
  145. package/dist/runtime/credentialManager.d.ts +19 -0
  146. package/dist/runtime/credentialManager.d.ts.map +1 -0
  147. package/dist/runtime/credentialManager.js +82 -0
  148. package/dist/runtime/credentialManager.js.map +1 -0
  149. package/dist/runtime/stdioSession.d.ts +8 -0
  150. package/dist/runtime/stdioSession.d.ts.map +1 -0
  151. package/dist/runtime/stdioSession.js +79 -0
  152. package/dist/runtime/stdioSession.js.map +1 -0
  153. package/dist/types.d.ts +92 -0
  154. package/dist/types.d.ts.map +1 -0
  155. package/dist/types.js +2 -0
  156. package/dist/types.js.map +1 -0
  157. package/package.json +64 -0
@@ -0,0 +1,31 @@
1
+ import { createSafeHandlerFromString } from './sandbox.js';
2
+ import { createGetIntegration } from './getIntegration.js';
3
+ import { makeIntegrationToolName, sanitizeJsonSchema } from './tools.js';
4
+ function humanize(s) {
5
+ return (s || '')
6
+ .replace(/_/g, ' ')
7
+ .split(/\s+/g)
8
+ .filter(Boolean)
9
+ .map(w => w.length ? `${w[0].toUpperCase()}${w.slice(1).toLowerCase()}` : w)
10
+ .join(' ');
11
+ }
12
+ export function buildExecutableToolFromDefinition(params) {
13
+ const { integration, tool, proxy, integrationsRef, requireWriteConfirmation = false } = params;
14
+ const getIntegration = createGetIntegration(integrationsRef || { current: [integration] }, proxy);
15
+ const scope = tool.scope || 'write';
16
+ const toolName = makeIntegrationToolName(integration.type, tool.name, integration.id);
17
+ const description = `[${integration.label} | ${integration.type}] ${tool.description || tool.displayName || tool.name}`;
18
+ const inputSchema = sanitizeJsonSchema(tool.inputSchema || { type: 'object', additionalProperties: true });
19
+ const wrapper = `async (input) => {\n const integration = getIntegration('${integration.id}');\n const __inner = ${tool.handlerCode};\n return await __inner(input);\n}`;
20
+ const safeHandler = createSafeHandlerFromString(wrapper, getIntegration);
21
+ return {
22
+ name: toolName,
23
+ displayName: `${tool.displayName || humanize(tool.name)}`,
24
+ description,
25
+ inputSchema,
26
+ run: safeHandler,
27
+ integrations: [integration],
28
+ requireConfirmation: scope === 'write' && requireWriteConfirmation,
29
+ };
30
+ }
31
+ //# sourceMappingURL=customToolFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customToolFactory.js","sourceRoot":"","sources":["../../src/integrations/customToolFactory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAA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AE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,CAAA;IAE1G,MAAM,OAAO,GAAG,6DAA6D,WAAW,CAAC,EAAE,0BAA0B,IAAI,CAAC,WAAW,sCAAsC,CAAA;IAC3K,MAAM,WAAW,GAAG,2BAA2B,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAExE,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,GAAG,IAAI,CAAC,WAAW,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACzD,WAAW;QACX,WAAW;QACX,GAAG,EAAE,WAAW;QAChB,YAAY,EAAE,CAAC,WAAW,CAAC;QAC3B,mBAAmB,EAAE,KAAK,KAAK,OAAO,IAAI,wBAAwB;KACnE,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type { IntegrationCredentialConfig, CredentialVariantConfig, CredentialVariantsFile, DisplayCardData, ToolsetMeta, ToolData, ToolListItem, } from '@commandable/integration-data';
2
+ export { integrationDataRoot, loadIntegrationManifest, loadIntegrationPrompt, loadIntegrationTools, loadIntegrationToolList, loadIntegrationDisplayCards, loadIntegrationToolsets, loadIntegrationCredentialConfig, loadIntegrationVariants, loadIntegrationHint, listIntegrationCatalog, } from '@commandable/integration-data';
3
+ //# sourceMappingURL=dataLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataLoader.d.ts","sourceRoot":"","sources":["../../src/integrations/dataLoader.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,2BAA2B,EAC3B,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,QAAQ,EACR,YAAY,GACb,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,+BAA+B,EAC/B,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,+BAA+B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { integrationDataRoot, loadIntegrationManifest, loadIntegrationPrompt, loadIntegrationTools, loadIntegrationToolList, loadIntegrationDisplayCards, loadIntegrationToolsets, loadIntegrationCredentialConfig, loadIntegrationVariants, loadIntegrationHint, listIntegrationCatalog, } from '@commandable/integration-data';
2
+ //# sourceMappingURL=dataLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataLoader.js","sourceRoot":"","sources":["../../src/integrations/dataLoader.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,+BAA+B,EAC/B,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,+BAA+B,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { IntegrationTypeConfig } from '../types.js';
2
+ /**
3
+ * Read a built-in integration type config from the file-backed integration-data package.
4
+ * Returns null when the integration type has no credentials.json definition.
5
+ */
6
+ export declare function getBuiltInIntegrationTypeConfig(typeSlug: string): IntegrationTypeConfig | null;
7
+ //# sourceMappingURL=fileIntegrationTypeConfigStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileIntegrationTypeConfigStore.d.ts","sourceRoot":"","sources":["../../src/integrations/fileIntegrationTypeConfigStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgC,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEtF;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CA8B9F"}
@@ -0,0 +1,34 @@
1
+ import { loadIntegrationHint, loadIntegrationVariants } from '@commandable/integration-data';
2
+ /**
3
+ * Read a built-in integration type config from the file-backed integration-data package.
4
+ * Returns null when the integration type has no credentials.json definition.
5
+ */
6
+ export function getBuiltInIntegrationTypeConfig(typeSlug) {
7
+ const variantsFile = loadIntegrationVariants(typeSlug);
8
+ if (!variantsFile)
9
+ return null;
10
+ const variants = {};
11
+ for (const [key, variant] of Object.entries(variantsFile.variants)) {
12
+ const preprocess = variant.preprocess ?? null;
13
+ if (preprocess !== null && preprocess !== 'google_service_account') {
14
+ throw new Error(`Unsupported preprocess '${preprocess}' for built-in integration '${typeSlug}/${key}'. Only 'google_service_account' is allowed.`);
15
+ }
16
+ variants[key] = {
17
+ label: variant.label,
18
+ credentialSchema: variant.schema,
19
+ auth: { kind: 'template', injection: variant.injection || {} },
20
+ baseUrl: null,
21
+ baseUrlTemplate: typeof variant.baseUrlTemplate === 'string' ? variant.baseUrlTemplate : null,
22
+ healthCheck: variant.healthCheck ?? null,
23
+ hintMarkdown: loadIntegrationHint(typeSlug, key),
24
+ preprocess,
25
+ };
26
+ }
27
+ return {
28
+ typeSlug,
29
+ label: typeSlug,
30
+ defaultVariant: variantsFile.default,
31
+ variants,
32
+ };
33
+ }
34
+ //# sourceMappingURL=fileIntegrationTypeConfigStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileIntegrationTypeConfigStore.js","sourceRoot":"","sources":["../../src/integrations/fileIntegrationTypeConfigStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AAG5F;;;GAGG;AACH,MAAM,UAAU,+BAA+B,CAAC,QAAgB;IAC9D,MAAM,YAAY,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAA;IACtD,IAAI,CAAC,YAAY;QACf,OAAO,IAAI,CAAA;IAEb,MAAM,QAAQ,GAAiD,EAAE,CAAA;IACjE,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAA;QAC7C,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,wBAAwB,EAAE,CAAC;YACnE,MAAM,IAAI,KAAK,CAAC,2BAA2B,UAAU,+BAA+B,QAAQ,IAAI,GAAG,8CAA8C,CAAC,CAAA;QACpJ,CAAC;QAED,QAAQ,CAAC,GAAG,CAAC,GAAG;YACd,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,gBAAgB,EAAE,OAAO,CAAC,MAAM;YAChC,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE,EAAE;YAC9D,OAAO,EAAE,IAAI;YACb,eAAe,EAAE,OAAQ,OAAe,CAAC,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAE,OAAe,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI;YAC/G,WAAW,EAAG,OAAe,CAAC,WAAW,IAAI,IAAI;YACjD,YAAY,EAAE,mBAAmB,CAAC,QAAQ,EAAE,GAAG,CAAC;YAChD,UAAU;SACX,CAAA;IACH,CAAC;IAED,OAAO;QACL,QAAQ;QACR,KAAK,EAAE,QAAQ;QACf,cAAc,EAAE,YAAY,CAAC,OAAO;QACpC,QAAQ;KACT,CAAA;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { IntegrationData } from '../types.js';
2
+ import type { IntegrationProxy } from './proxy.js';
3
+ export type IntegrationListRef = {
4
+ current: IntegrationData[];
5
+ };
6
+ export declare function createGetIntegration(integrations: IntegrationData[] | IntegrationListRef | undefined, proxy: IntegrationProxy): (refOrId: string) => {
7
+ fetch: (path: string, init?: RequestInit) => Promise<Response>;
8
+ get: (path: string, init?: RequestInit) => Promise<Response>;
9
+ post: (path: string, body: any, init?: RequestInit) => Promise<Response>;
10
+ put: (path: string, body: any, init?: RequestInit) => Promise<Response>;
11
+ patch: (path: string, body: any, init?: RequestInit) => Promise<Response>;
12
+ delete: (path: string, init?: RequestInit) => Promise<Response>;
13
+ };
14
+ //# sourceMappingURL=getIntegration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIntegration.d.ts","sourceRoot":"","sources":["../../src/integrations/getIntegration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAGlD,MAAM,MAAM,kBAAkB,GAAG;IAAE,OAAO,EAAE,eAAe,EAAE,CAAA;CAAE,CAAA;AAE/D,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,eAAe,EAAE,GAAG,kBAAkB,GAAG,SAAS,EAChE,KAAK,EAAE,gBAAgB,IAEf,SAAS,MAAM;kBAwBL,MAAM,SAAS,WAAW;gBAJI,MAAM,SAAQ,WAAW;iBAHvB,MAAM,QAAQ,GAAG,SAAQ,WAAW;gBAApC,MAAM,QAAQ,GAAG,SAAQ,WAAW;kBAApC,MAAM,QAAQ,GAAG,SAAQ,WAAW;mBAGtC,MAAM,SAAQ,WAAW;EAY1E"}
@@ -0,0 +1,30 @@
1
+ import { HttpError } from '../errors/httpError.js';
2
+ export function createGetIntegration(integrations, proxy) {
3
+ return (refOrId) => {
4
+ const list = Array.isArray(integrations) ? integrations : integrations?.current;
5
+ const integration = list?.find(i => i.id === refOrId || i.referenceId === refOrId);
6
+ if (!integration)
7
+ throw new Error('Invalid or unauthorized integration reference/id');
8
+ const isCredentialsConnected = integration.connectionMethod === 'credentials' && !!integration.credentialId;
9
+ if (!integration.connectionId && !isCredentialsConnected) {
10
+ const portRaw = process.env.COMMANDABLE_UI_PORT;
11
+ const port = portRaw && /^\d+$/.test(portRaw) ? Number(portRaw) : 23432;
12
+ const credentialUrl = `http://127.0.0.1:${port}/integrations/${encodeURIComponent(integration.id)}`;
13
+ throw new HttpError(400, `Integration is not connected. Open ${credentialUrl} to configure credentials.`, {
14
+ reason: 'missing_credentials',
15
+ credential_url: credentialUrl,
16
+ });
17
+ }
18
+ const verbWithBody = (method) => (path, body, init = {}) => proxy.call(integration, path, { ...init, method, body: JSON.stringify(body) });
19
+ const verbNoBody = (method) => (path, init = {}) => proxy.call(integration, path, { ...init, method });
20
+ return {
21
+ fetch: (path, init) => proxy.call(integration, path, init),
22
+ get: verbNoBody('GET'),
23
+ post: verbWithBody('POST'),
24
+ put: verbWithBody('PUT'),
25
+ patch: verbWithBody('PATCH'),
26
+ delete: verbNoBody('DELETE'),
27
+ };
28
+ };
29
+ }
30
+ //# sourceMappingURL=getIntegration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIntegration.js","sourceRoot":"","sources":["../../src/integrations/getIntegration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAIlD,MAAM,UAAU,oBAAoB,CAClC,YAAgE,EAChE,KAAuB;IAEvB,OAAO,CAAC,OAAe,EAAE,EAAE;QACzB,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,EAAE,OAAO,CAAA;QAC/E,MAAM,WAAW,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,IAAK,CAAS,CAAC,WAAW,KAAK,OAAO,CAAC,CAAA;QAC3F,IAAI,CAAC,WAAW;YACd,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;QAErE,MAAM,sBAAsB,GAAG,WAAW,CAAC,gBAAgB,KAAK,aAAa,IAAI,CAAC,CAAC,WAAW,CAAC,YAAY,CAAA;QAC3G,IAAI,CAAC,WAAW,CAAC,YAAY,IAAI,CAAC,sBAAsB,EAAE,CAAC;YACzD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAA;YAC/C,MAAM,IAAI,GAAG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC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ountJson: string;
3
+ scopes: string[];
4
+ subject?: string;
5
+ }): Promise<string>;
6
+ //# sourceMappingURL=googleServiceAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"googleServiceAccount.d.ts","sourceRoot":"","sources":["../../src/integrations/googleServiceAccount.ts"],"names":[],"mappings":"AAyBA,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,kBAAkB,EAAE,MAAM,CAAA;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,GAAG,OAAO,CAAC,MAAM,CAAC,CA0ClB"}
@@ -0,0 +1,54 @@
1
+ import { JWT } from 'google-auth-library';
2
+ const cache = new Map();
3
+ function cacheKey(args) {
4
+ // Keep key stable but avoid storing the entire JSON as a Map key.
5
+ // client_email is a stable identifier and not secret by itself.
6
+ let email = 'unknown';
7
+ try {
8
+ const parsed = JSON.parse(args.serviceAccountJson || '{}');
9
+ if (typeof parsed?.client_email === 'string')
10
+ email = parsed.client_email;
11
+ }
12
+ catch { }
13
+ const scopesKey = [...args.scopes].sort().join(' ');
14
+ const subjectKey = args.subject || '';
15
+ return `${email}::${subjectKey}::${scopesKey}`;
16
+ }
17
+ export async function getGoogleAccessToken(args) {
18
+ if (!args.serviceAccountJson)
19
+ throw new Error('Missing serviceAccountJson');
20
+ if (!Array.isArray(args.scopes) || !args.scopes.length)
21
+ throw new Error('Missing scopes');
22
+ const key = cacheKey(args);
23
+ const existing = cache.get(key);
24
+ const now = Date.now();
25
+ if (existing && existing.expiresAtMs - now > 60_000)
26
+ return existing.token;
27
+ let parsed;
28
+ try {
29
+ parsed = JSON.parse(args.serviceAccountJson);
30
+ }
31
+ catch {
32
+ throw new Error('serviceAccountJson must be valid JSON');
33
+ }
34
+ const clientEmail = parsed?.client_email;
35
+ const privateKey = parsed?.private_key;
36
+ if (typeof clientEmail !== 'string' || !clientEmail.trim())
37
+ throw new Error('serviceAccountJson is missing client_email');
38
+ if (typeof privateKey !== 'string' || !privateKey.trim())
39
+ throw new Error('serviceAccountJson is missing private_key');
40
+ const jwt = new JWT({
41
+ email: clientEmail,
42
+ key: privateKey,
43
+ scopes: args.scopes,
44
+ subject: args.subject,
45
+ });
46
+ const res = await jwt.authorize();
47
+ const token = res?.access_token;
48
+ if (!token)
49
+ throw new Error('Failed to mint Google access token');
50
+ const expiresAtMs = typeof res.expiry_date === 'number' ? res.expiry_date : (now + 55 * 60_000);
51
+ cache.set(key, { token, expiresAtMs });
52
+ return token;
53
+ }
54
+ //# sourceMappingURL=googleServiceAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"googleServiceAccount.js","sourceRoot":"","sources":["../../src/integrations/googleServiceAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAOzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAA;AAE5C,SAAS,QAAQ,CAAC,IAAwE;IACxF,kEAAkE;IAClE,gEAAgE;IAChE,IAAI,KAAK,GAAG,SAAS,CAAA;IACrB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,CAAA;QAC1D,IAAI,OAAO,MAAM,EAAE,YAAY,KAAK,QAAQ;YAC1C,KAAK,GAAG,MAAM,CAAC,YAAY,CAAA;IAC/B,CAAC;IACD,MAAM,CAAC,CAAA,CAAC;IAER,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACnD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAA;IACrC,OAAO,GAAG,KAAK,KAAK,UAAU,KAAK,SAAS,EAAE,CAAA;AAChD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAI1C;IACC,IAAI,CAAC,IAAI,C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CAAC,CAAA;IAEF,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,SAAS,EAAE,CAAA;IACjC,MAAM,KAAK,GAAG,GAAG,EAAE,YAAY,CAAA;IAC/B,IAAI,CAAC,KAAK;QACR,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IAEvD,MAAM,WAAW,GAAG,OAAO,GAAG,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,CAAA;IAC/F,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;IACtC,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { DbClient } from '../db/client.js';
2
+ import type { IntegrationData } from '../types.js';
3
+ import type { IntegrationProxy } from './proxy.js';
4
+ export type HealthStatus = 'disconnected' | 'connected' | 'invalid_credentials';
5
+ export interface HealthResult {
6
+ status: HealthStatus;
7
+ /**
8
+ * true when the integration type has no healthCheck endpoint defined — no
9
+ * network call was made, so we cannot confirm credential validity.
10
+ */
11
+ skipped?: boolean;
12
+ checkedAt: Date;
13
+ message?: string;
14
+ }
15
+ export declare function checkIntegrationHealth(params: {
16
+ integration: IntegrationData;
17
+ proxy: IntegrationProxy;
18
+ db?: DbClient;
19
+ }): Promise<HealthResult>;
20
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/integrations/health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIlD,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,WAAW,GAAG,qBAAqB,CAAA;AAE/E,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,YAAY,CAAA;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,IAAI,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,wBAAsB,sBAAsB,CAAC,MAAM,EAAE;IACnD,WAAW,EAAE,eAAe,CAAA;IAC5B,KAAK,EAAE,gBAAgB,CAAA;IACvB,EAAE,CAAC,EAAE,QAAQ,CAAA;CACd,GAAG,OAAO,CAAC,YAAY,CAAC,CA6CxB"}
@@ -0,0 +1,43 @@
1
+ import { getIntegrationTypeConfig } from '../db/integrationTypeConfigStore.js';
2
+ import { getBuiltInIntegrationTypeConfig } from './fileIntegrationTypeConfigStore.js';
3
+ export async function checkIntegrationHealth(params) {
4
+ const { integration, proxy, db } = params;
5
+ const checkedAt = new Date();
6
+ // Try file-based lookup first (sync, no DB needed), then fall back to DB for custom integrations.
7
+ const typeCfg = getBuiltInIntegrationTypeConfig(integration.type)
8
+ ?? (db && integration.spaceId
9
+ ? await getIntegrationTypeConfig(db, integration.spaceId, integration.type)
10
+ : null);
11
+ const variantKey = integration.credentialVariant || typeCfg?.defaultVariant || null;
12
+ const variant = variantKey ? typeCfg?.variants[variantKey] : null;
13
+ const path = variant?.healthCheck?.path ?? null;
14
+ const method = variant?.healthCheck?.method ?? 'GET';
15
+ if (!path) {
16
+ return { status: 'connected', skipped: true, checkedAt };
17
+ }
18
+ try {
19
+ await proxy.call(integration, path, { method });
20
+ return { status: 'connected', checkedAt };
21
+ }
22
+ catch (err) {
23
+ // Missing credentials — proxy throws before making the HTTP call
24
+ if (err?.statusCode === 400 && err?.message?.includes('No credentials')) {
25
+ return { status: 'disconnected', checkedAt, message: err.message };
26
+ }
27
+ if (err?.statusCode === 400 && err?.message?.includes('credentialId')) {
28
+ return { status: 'disconnected', checkedAt, message: err.message };
29
+ }
30
+ const statusCode = err?.statusCode ?? null;
31
+ if (statusCode === 401) {
32
+ return { status: 'invalid_credentials', checkedAt, message: err.message };
33
+ }
34
+ // 403 can mean bad creds or missing scopes — treat as invalid to prompt reconfiguration
35
+ if (statusCode === 403) {
36
+ return { status: 'invalid_credentials', checkedAt, message: err.message };
37
+ }
38
+ // Network errors, 5xx, transient failures — don't flip to invalid; skip so we
39
+ // don't wrongly mark a healthy integration as broken due to transient issues.
40
+ return { status: 'connected', skipped: true, checkedAt, message: String(err?.message ?? err) };
41
+ }
42
+ }
43
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/integrations/health.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAA;AAerF,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAI5C;IACC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,MAAM,CAAA;IACzC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAA;IAE5B,kGAAkG;IAClG,MAAM,OAAO,GAAG,+BAA+B,CAAC,WAAW,CAAC,IAAI,CAAC;WAC5D,CAAC,EAAE,IAAI,WAAW,CAAC,OAAO;YAC3B,CAAC,CAAC,MAAM,wBAAwB,CAAC,EAAE,EAAE,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC;YAC3E,CAAC,CAAC,IAAI,CAAC,CAAA;IAEX,MAAM,UAAU,GAAG,WAAW,CAAC,iBAAiB,IAAI,OAAO,EAAE,cAAc,IAAI,IAAI,CAAA;IACnF,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACjE,MAAM,IAAI,GAAG,OAAO,EAAE,WAAW,EAAE,IAAI,IAAI,I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AO,EAAE,CAAA;QAC3E,CAAC;QAED,8EAA8E;QAC9E,8EAA8E;QAC9E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,IAAI,GAAG,CAAC,EAAE,CAAA;IAChG,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { DbClient } from '../db/client.js';
2
+ import type { IntegrationTypeConfig } from '../types.js';
3
+ /**
4
+ * Find an integration type config from either built-in file data or the DB.
5
+ * Built-in file-backed types win over DB rows with the same slug.
6
+ */
7
+ export declare function findIntegrationTypeConfig(params: {
8
+ db: DbClient;
9
+ spaceId: string;
10
+ typeSlug: string;
11
+ }): Promise<IntegrationTypeConfig | null>;
12
+ //# sourceMappingURL=integrationTypeConfigLookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrationTypeConfigLookup.d.ts","sourceRoot":"","sources":["../../src/integrations/integrationTypeConfigLookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGxD;;;GAGG;AACH,wBAAsB,yBAAyB,CAAC,MAAM,EAAE;IACtD,EAAE,EAAE,QAAQ,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CACjB,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAGxC"}
@@ -0,0 +1,11 @@
1
+ import { getIntegrationTypeConfig } from '../db/integrationTypeConfigStore.js';
2
+ import { getBuiltInIntegrationTypeConfig } from './fileIntegrationTypeConfigStore.js';
3
+ /**
4
+ * Find an integration type config from either built-in file data or the DB.
5
+ * Built-in file-backed types win over DB rows with the same slug.
6
+ */
7
+ export async function findIntegrationTypeConfig(params) {
8
+ return getBuiltInIntegrationTypeConfig(params.typeSlug)
9
+ ?? await getIntegrationTypeConfig(params.db, params.spaceId, params.typeSlug);
10
+ }
11
+ //# sourceMappingURL=integrationTypeConfigLookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrationTypeConfigLookup.js","sourceRoot":"","sources":["../../src/integrations/integrationTypeConfigLookup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AAE9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAA;AAErF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,MAI/C;IACC,OAAO,+BAA+B,CAAC,MAAM,CAAC,QAAQ,CAAC;WAClD,MAAM,wBAAwB,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;AACjF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const PROVIDERS: Record<string, any>;
2
+ //# sourceMappingURL=providerRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providerRegistry.d.ts","sourceRoot":"","sources":["../../src/integrations/providerRegistry.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAsEzC,CAAA"}
@@ -0,0 +1,72 @@
1
+ export const PROVIDERS = {
2
+ 'trello': {
3
+ baseUrl: 'https://api.trello.com/1',
4
+ makeAuth: (token, apiKey) => ({ key: apiKey, token }),
5
+ },
6
+ // 'slack': {
7
+ // baseUrl: 'https://slack.com/api',
8
+ // makeAuth: (token: string) => ({ Authorization: `Bearer ${token}` }),
9
+ // },
10
+ 'airtable': {
11
+ baseUrl: 'https://api.airtable.com/v0',
12
+ makeAuth: (token) => ({ Authorization: `Bearer ${token}` }),
13
+ },
14
+ 'github': {
15
+ baseUrl: 'https://api.github.com',
16
+ makeAuth: (token) => ({ Authorization: `Bearer ${token}` }),
17
+ },
18
+ 'hubspot': {
19
+ baseUrl: 'https://api.hubapi.com',
20
+ makeAuth: (token) => ({ Authorization: `Bearer ${token}` }),
21
+ },
22
+ 'notion': {
23
+ baseUrl: 'https://api.notion.com/v1',
24
+ makeAuth: (token) => ({
25
+ 'Authorization': `Bearer ${token}`,
26
+ 'Notion-Version': '2022-06-28',
27
+ }),
28
+ },
29
+ 'google-calendar': {
30
+ baseUrl: 'https://www.googleapis.com/calendar/v3',
31
+ makeAuth: (token) => ({ Authorization: `Bearer ${token}` }),
32
+ },
33
+ 'google-sheet': {
34
+ baseUrl: 'https://sheets.googleapis.com/v4',
35
+ makeAuth: (token) => ({ Authorization: `Bearer ${token}` }),
36
+ },
37
+ 'google-docs': {
38
+ baseUrl: 'https://docs.googleapis.com/v1',
39
+ makeAuth: (token) => ({ Authorization: `Bearer ${token}` }),
40
+ },
41
+ 'google-slides': {
42
+ baseUrl: 'https://slides.googleapis.com/v1',
43
+ makeAuth: (token) => ({ Authorization: `Bearer ${token}` }),
44
+ },
45
+ 'google-drive': {
46
+ baseUrl: 'https://www.googleapis.com/drive/v3',
47
+ makeAuth: (token) => ({ Authorization: `Bearer ${token}` }),
48
+ },
49
+ 'google-gmail': {
50
+ baseUrl: 'https://gmail.googleapis.com/gmail/v1',
51
+ makeAuth: (token) => ({ Authorization: `Bearer ${token}` }),
52
+ },
53
+ 'jira': {
54
+ baseUrl: (integration, creds) => {
55
+ const cloudId = creds?.cloudId || integration?.config?.cloudId || integration?.config?.sub;
56
+ return cloudId
57
+ ? `https://api.atlassian.com/ex/jira/${cloudId}`
58
+ : 'https://api.atlassian.com/ex/jira';
59
+ },
60
+ makeAuth: (token) => ({ Authorization: `Bearer ${token}` }),
61
+ },
62
+ 'confluence': {
63
+ baseUrl: (integration, creds) => {
64
+ const cloudId = creds?.cloudId || integration?.config?.cloudId || integration?.config?.sub;
65
+ return cloudId
66
+ ? `https://api.atlassian.com/ex/confluence/${cloudId}`
67
+ : 'https://api.atlassian.com/ex/confluence';
68
+ },
69
+ makeAuth: (token) => ({ Authorization: `Bearer ${token}` }),
70
+ },
71
+ };
72
+ //# sourceMappingURL=providerRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providerRegistry.js","sourceRoot":"","sources":["../../src/integrations/providerRegistry.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAwB;IAC5C,QAAQ,EAAE;QACR,OAAO,EAAE,0BAA0B;QACnC,QAAQ,EAAE,CAAC,KAAa,EAAE,MAAc,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;KACtE;IACD,aAAa;IACb,sCAAsC;IACtC,yEAAyE;IACzE,KAAK;IACL,UAAU,EAAE;QACV,OAAO,EAAE,6BAA6B;QACtC,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;KACpE;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,wBAAwB;QACjC,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;KACpE;IACD,SAAS,EAAE;QACT,OAAO,EAAE,wBAAwB;QACjC,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;KACpE;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,2BAA2B;QACpC,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC;YAC5B,eAAe,EAAE,UAAU,KAAK,EAAE;YAClC,gBAAgB,EAAE,YAAY;SAC/B,CAAC;KACH;IACD,iBAAiB,EAAE;QACjB,OAAO,EAAE,wCAAwC;QACjD,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;KACpE;I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AAE;YACzC,MAAM,OAAO,GAAG,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,EAAE,GAAG,CAAA;YAC1F,OAAO,OAAO;gBACZ,CAAC,CAAC,2CAA2C,OAAO,EAAE;gBACtD,CAAC,CAAC,yCAAyC,CAAA;QAC/C,CAAC;QACD,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;KACpE;CACF,CAAA"}
@@ -0,0 +1,19 @@
1
+ import type { IntegrationData, IntegrationTypeConfig } from '../types.js';
2
+ export interface CredentialStore {
3
+ getCredentials: (spaceId: string, credentialId: string) => Promise<Record<string, string> | null>;
4
+ }
5
+ export interface IntegrationProxyOptions {
6
+ managedOAuthSecretKey?: string;
7
+ managedOAuthBaseUrl?: string;
8
+ trelloApiKey?: string;
9
+ credentialStore?: CredentialStore;
10
+ integrationTypeConfigsRef?: {
11
+ current: IntegrationTypeConfig[];
12
+ };
13
+ }
14
+ export declare class IntegrationProxy {
15
+ private readonly opts;
16
+ constructor(opts?: IntegrationProxyOptions);
17
+ call(integration: IntegrationData, path: string, init?: RequestInit): Promise<Response>;
18
+ }
19
+ //# sourceMappingURL=proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/integrations/proxy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgC,eAAe,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAKvG,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;CAClG;AAED,MAAM,WAAW,uBAAuB;IAEtC,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAE5B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,yBAAyB,CAAC,EAAE;QAAE,OAAO,EAAE,qBAAqB,EAAE,CAAA;KAAE,CAAA;CACjE;AA2CD,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,GAAE,uBAA4B;IAEzD,IAAI,CAAC,WAAW,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;CAmWlG"}