@outputai/credentials 0.8.2-next.2da7213.0 → 0.8.2-next.4b5c049.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.
@@ -1,6 +1,6 @@
1
1
  import { dirname } from 'node:path';
2
2
  import { MissingCredentialError } from './errors.js';
3
- import { getExecutionContext } from '@outputai/core/sdk_activity_integration';
3
+ import { Context } from '@outputai/core/sdk/runtime';
4
4
  import { deepMerge } from '@outputai/core/sdk_utils';
5
5
  import { getProvider } from './provider_registry.js';
6
6
  const getNestedValue = (obj, dotPath) => dotPath.split('.').reduce((acc, part) => acc?.[part], obj);
@@ -33,7 +33,7 @@ const loadForWorkflow = (workflowName, workflowDir) => {
33
33
  return merged;
34
34
  };
35
35
  const getWorkflowContext = () => {
36
- const ctx = getExecutionContext();
36
+ const ctx = Context.getActivityContext();
37
37
  if (!ctx) {
38
38
  return { workflowName: undefined, workflowDir: undefined };
39
39
  }
@@ -37,6 +37,13 @@ const activityContext = (workflowType, workflowFilename) => ({
37
37
  activityInfo: { workflowType },
38
38
  workflowFilename
39
39
  });
40
+ const mockCoreInternalContext = (getActivityContext) => {
41
+ vi.doMock('@outputai/core/sdk/runtime', () => ({
42
+ Context: {
43
+ getActivityContext
44
+ }
45
+ }));
46
+ };
40
47
  describe('credentials module', () => {
41
48
  const key = generateKey();
42
49
  const ciphertext = encrypt(YAML_CONTENT, key);
@@ -245,9 +252,7 @@ describe('credentials module', () => {
245
252
  existsSync: (path) => path.endsWith('credentials.yml.enc') ||
246
253
  path.includes('/workflows/my_workflow/credentials.key')
247
254
  }));
248
- vi.doMock('@outputai/core/sdk_activity_integration', () => ({
249
- getExecutionContext: () => activityContext('my_workflow', '/app/src/workflows/my_workflow/workflow.ts')
250
- }));
255
+ mockCoreInternalContext(() => activityContext('my_workflow', '/app/src/workflows/my_workflow/workflow.ts'));
251
256
  const credentials = await loadCredentials();
252
257
  expect(credentials.get('anthropic.api_key')).toBe('sk-ant-workflow');
253
258
  expect(credentials.get('stripe.secret_key')).toBe('sk-stripe-wf');
@@ -259,9 +264,7 @@ describe('credentials module', () => {
259
264
  readFileSync: () => ciphertext,
260
265
  existsSync: (path) => path.endsWith('credentials.yml.enc') && !path.includes('/workflows/')
261
266
  }));
262
- vi.doMock('@outputai/core/sdk_activity_integration', () => ({
263
- getExecutionContext: () => activityContext('simple', '/app/src/workflows/simple/workflow.ts')
264
- }));
267
+ mockCoreInternalContext(() => activityContext('simple', '/app/src/workflows/simple/workflow.ts'));
265
268
  const credentials = await loadCredentials();
266
269
  expect(credentials.get('anthropic.api_key')).toBe('sk-ant-test');
267
270
  });
@@ -282,9 +285,7 @@ describe('credentials module', () => {
282
285
  return path.endsWith('credentials.yml.enc');
283
286
  }
284
287
  }));
285
- vi.doMock('@outputai/core/sdk_activity_integration', () => ({
286
- getExecutionContext: () => activityContext('my_workflow', '/app/src/workflows/my_workflow/workflow.ts')
287
- }));
288
+ mockCoreInternalContext(() => activityContext('my_workflow', '/app/src/workflows/my_workflow/workflow.ts'));
288
289
  const credentials = await loadCredentials();
289
290
  expect(credentials.get('stripe.secret_key')).toBe('sk-stripe-wf');
290
291
  });
@@ -300,9 +301,7 @@ describe('credentials module', () => {
300
301
  },
301
302
  existsSync: (path) => path.endsWith('credentials.yml.enc')
302
303
  }));
303
- vi.doMock('@outputai/core/sdk_activity_integration', () => ({
304
- getExecutionContext: () => activityContext('my_workflow', '/app/src/workflows/my_workflow/workflow.ts')
305
- }));
304
+ mockCoreInternalContext(() => activityContext('my_workflow', '/app/src/workflows/my_workflow/workflow.ts'));
306
305
  const credentials = await loadCredentials();
307
306
  expect(credentials.get('stripe.secret_key')).toBe('sk-stripe-wf');
308
307
  });
@@ -326,9 +325,7 @@ describe('credentials module', () => {
326
325
  workflowType: undefined,
327
326
  workflowFilename: undefined
328
327
  };
329
- vi.doMock('@outputai/core/sdk_activity_integration', () => ({
330
- getExecutionContext: () => ctx.workflowType && ctx.workflowFilename ? activityContext(ctx.workflowType, ctx.workflowFilename) : null
331
- }));
328
+ mockCoreInternalContext(() => ctx.workflowType && ctx.workflowFilename ? activityContext(ctx.workflowType, ctx.workflowFilename) : null);
332
329
  const credentials = await loadCredentials();
333
330
  ctx.workflowType = 'workflow_a';
334
331
  ctx.workflowFilename = '/app/src/workflows/workflow_a/workflow.ts';
@@ -343,9 +340,7 @@ describe('credentials module', () => {
343
340
  readFileSync: () => ciphertext,
344
341
  existsSync: (path) => path.endsWith('credentials.yml.enc')
345
342
  }));
346
- vi.doMock('@outputai/core/sdk_activity_integration', () => ({
347
- getExecutionContext: () => null
348
- }));
343
+ mockCoreInternalContext(() => null);
349
344
  const credentials = await loadCredentials();
350
345
  expect(credentials.get('anthropic.api_key')).toBe('sk-ant-test');
351
346
  });
@@ -356,9 +351,7 @@ describe('credentials module', () => {
356
351
  readFileSync,
357
352
  existsSync: (path) => path.endsWith('credentials.yml.enc') && !path.includes('/workflows/')
358
353
  }));
359
- vi.doMock('@outputai/core/sdk_activity_integration', () => ({
360
- getExecutionContext: () => activityContext('test_wf', '/app/src/workflows/test_wf/workflow.ts')
361
- }));
354
+ mockCoreInternalContext(() => activityContext('test_wf', '/app/src/workflows/test_wf/workflow.ts'));
362
355
  const credentials = await loadCredentials();
363
356
  credentials.get('anthropic.api_key');
364
357
  credentials._reset();
@@ -450,9 +443,7 @@ describe('credentials module', () => {
450
443
  vi.doMock('./encrypted_yaml_provider.js', () => ({
451
444
  encryptedYamlProvider: customProvider
452
445
  }));
453
- vi.doMock('@outputai/core/sdk_activity_integration', () => ({
454
- getExecutionContext: () => activityContext('test', '/app/workflows/test/workflow.ts')
455
- }));
446
+ mockCoreInternalContext(() => activityContext('test', '/app/workflows/test/workflow.ts'));
456
447
  const credentials = await loadCredentials();
457
448
  expect(credentials.get('shared')).toBe('global');
458
449
  expect(credentials.get('base.a')).toBe(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outputai/credentials",
3
- "version": "0.8.2-next.2da7213.0",
3
+ "version": "0.8.2-next.4b5c049.0",
4
4
  "description": "Encrypted credentials management for Output.ai workflows",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@noble/ciphers": "2.2.0",
21
21
  "js-yaml": "4.1.1",
22
- "@outputai/core": "0.8.2-next.2da7213.0"
22
+ "@outputai/core": "0.8.2-next.4b5c049.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/js-yaml": "4.0.9"