@outputai/core 0.14.0 → 0.14.1-next.1ec4416.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 (100) hide show
  1. package/dist/credentials/credentials.d.ts +6 -0
  2. package/dist/credentials/credentials.js +87 -0
  3. package/dist/credentials/encrypted_yaml_provider.d.ts +2 -0
  4. package/dist/credentials/encrypted_yaml_provider.js +77 -0
  5. package/dist/credentials/encryption.d.ts +3 -0
  6. package/dist/credentials/encryption.js +6 -0
  7. package/dist/credentials/errors.d.ts +13 -0
  8. package/dist/credentials/errors.js +39 -0
  9. package/dist/credentials/index.d.ts +6 -0
  10. package/dist/credentials/index.js +5 -0
  11. package/dist/credentials/init.d.ts +1 -0
  12. package/dist/credentials/init.js +7 -0
  13. package/dist/credentials/paths.d.ts +7 -0
  14. package/dist/credentials/paths.js +14 -0
  15. package/dist/credentials/provider_registry.d.ts +3 -0
  16. package/dist/credentials/provider_registry.js +6 -0
  17. package/dist/credentials/types.d.ts +12 -0
  18. package/dist/credentials/types.js +1 -0
  19. package/package.json +25 -14
  20. package/src/async_storage.d.ts +4 -0
  21. package/src/consts.js +0 -2
  22. package/src/helpers/object.d.ts +2 -0
  23. package/src/hooks/index.d.ts +0 -8
  24. package/src/hooks/index.js +0 -3
  25. package/src/logger/index.d.ts +4 -0
  26. package/src/worker/index.js +3 -1
  27. package/bin/healthcheck.spec.js +0 -90
  28. package/src/bus.spec.js +0 -196
  29. package/src/errors.spec.js +0 -19
  30. package/src/helpers/activity_options.spec.js +0 -55
  31. package/src/helpers/component.spec.js +0 -54
  32. package/src/helpers/error_serializer.spec.js +0 -479
  33. package/src/helpers/errors.spec.js +0 -189
  34. package/src/helpers/fetch.spec.js +0 -292
  35. package/src/helpers/function.spec.js +0 -24
  36. package/src/helpers/object.spec.js +0 -425
  37. package/src/helpers/promise.spec.js +0 -62
  38. package/src/helpers/redact.spec.js +0 -66
  39. package/src/helpers/string.spec.js +0 -99
  40. package/src/helpers/temporal_context.spec.ts +0 -83
  41. package/src/helpers/trace_info.spec.js +0 -45
  42. package/src/helpers/workflow_context.spec.js +0 -46
  43. package/src/hooks/index.spec.js +0 -265
  44. package/src/hooks/pending_hooks.spec.js +0 -62
  45. package/src/interface/evaluator.spec.js +0 -685
  46. package/src/interface/logger.spec.js +0 -172
  47. package/src/interface/step.spec.js +0 -128
  48. package/src/interface/validations/index.spec.js +0 -197
  49. package/src/interface/validations/schemas.spec.js +0 -229
  50. package/src/interface/webhook.spec.js +0 -170
  51. package/src/interface/workflow.spec.js +0 -710
  52. package/src/interface/workflow_utils.spec.js +0 -271
  53. package/src/interface/zod_integration.spec.js +0 -646
  54. package/src/internal_activities/index.spec.js +0 -186
  55. package/src/logger/development.spec.js +0 -87
  56. package/src/logger/index.spec.js +0 -27
  57. package/src/logger/production.spec.js +0 -71
  58. package/src/sdk/helpers/component_metadata.spec.js +0 -30
  59. package/src/sdk/helpers/objects.spec.js +0 -16
  60. package/src/sdk/helpers/path.spec.js +0 -102
  61. package/src/sdk/runtime/context.spec.js +0 -37
  62. package/src/sdk/runtime/events.spec.js +0 -40
  63. package/src/temporal/client.spec.js +0 -124
  64. package/src/tracing/processors/local/index.spec.js +0 -204
  65. package/src/tracing/processors/s3/configs.spec.js +0 -64
  66. package/src/tracing/processors/s3/index.spec.js +0 -185
  67. package/src/tracing/processors/s3/redis_client.spec.js +0 -179
  68. package/src/tracing/processors/s3/s3_client.spec.js +0 -68
  69. package/src/tracing/tools/build_trace_tree.spec.js +0 -216
  70. package/src/tracing/trace_engine.spec.js +0 -299
  71. package/src/worker/bundle.spec.js +0 -53
  72. package/src/worker/bundler_options.spec.js +0 -62
  73. package/src/worker/catalog_workflow/catalog_publisher.spec.js +0 -317
  74. package/src/worker/catalog_workflow/index.spec.js +0 -222
  75. package/src/worker/configs.spec.js +0 -213
  76. package/src/worker/configs_tuner_schema.spec.js +0 -127
  77. package/src/worker/connection_monitor.spec.js +0 -328
  78. package/src/worker/global_functions.spec.js +0 -55
  79. package/src/worker/index.spec.js +0 -526
  80. package/src/worker/interceptors/activity.spec.js +0 -369
  81. package/src/worker/interceptors/headers.spec.js +0 -73
  82. package/src/worker/interceptors/workflow.spec.js +0 -357
  83. package/src/worker/interruption.spec.js +0 -177
  84. package/src/worker/loader/activities.spec.js +0 -212
  85. package/src/worker/loader/hooks.spec.js +0 -64
  86. package/src/worker/loader/matchers.spec.js +0 -140
  87. package/src/worker/loader/tools.spec.js +0 -595
  88. package/src/worker/loader/workflows.spec.js +0 -287
  89. package/src/worker/log_hooks.spec.js +0 -303
  90. package/src/worker/shutdown.spec.js +0 -197
  91. package/src/worker/sinks.spec.js +0 -220
  92. package/src/worker/telemetry.spec.js +0 -80
  93. package/src/worker/temporal_logger.spec.js +0 -90
  94. package/src/worker/webpack_loaders/tools.spec.js +0 -314
  95. package/src/worker/webpack_loaders/workflow_rewriter/collect_target_imports.spec.js +0 -134
  96. package/src/worker/webpack_loaders/workflow_rewriter/index.spec.js +0 -154
  97. package/src/worker/webpack_loaders/workflow_rewriter/rewrite_activity_calls.spec.js +0 -165
  98. package/src/worker/webpack_loaders/workflow_validator/index.spec.js +0 -202
  99. package/src/worker/webpack_loaders/workflow_validator/npm_workflow_export_resolve.spec.js +0 -374
  100. package/src/worker/worker_runner.spec.js +0 -220
@@ -1,212 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
-
3
- vi.mock( '#consts', () => ( {
4
- ACTIVITY_SEND_HTTP_REQUEST: '__internal#sendHttpRequest',
5
- ACTIVITY_GET_TRACE_DESTINATIONS: '__internal#getTraceDestinations',
6
- WORKFLOWS_INDEX_FILENAME: '__workflows_entrypoint.js',
7
- WORKFLOW_CATALOG: 'catalog',
8
- ACTIVITY_OPTIONS_FILENAME: '__activity_options.js'
9
- } ) );
10
-
11
- const sendHttpRequestMock = vi.fn();
12
- const getTraceDestinationsMock = vi.fn();
13
- vi.mock( '#internal_activities', () => ( {
14
- sendHttpRequest: sendHttpRequestMock,
15
- getTraceDestinations: getTraceDestinationsMock
16
- } ) );
17
-
18
- const { importComponentsMock, findSharedActivitiesFromWorkflowsMock, matchFilesMock, writeFileInTempDirMock } = vi.hoisted( () => ( {
19
- importComponentsMock: vi.fn(),
20
- findSharedActivitiesFromWorkflowsMock: vi.fn(),
21
- matchFilesMock: vi.fn(),
22
- writeFileInTempDirMock: vi.fn()
23
- } ) );
24
-
25
- const { buildActivityMatcherMock, activityMatcherMock, sharedStepsDirMock, sharedEvaluatorsDirMock } = vi.hoisted( () => ( {
26
- buildActivityMatcherMock: vi.fn(),
27
- activityMatcherMock: vi.fn(),
28
- sharedStepsDirMock: vi.fn(),
29
- sharedEvaluatorsDirMock: vi.fn()
30
- } ) );
31
-
32
- vi.mock( './tools.js', () => ( {
33
- importComponents: importComponentsMock,
34
- findSharedActivitiesFromWorkflows: findSharedActivitiesFromWorkflowsMock,
35
- matchFiles: matchFilesMock,
36
- writeFileInTempDir: writeFileInTempDirMock
37
- } ) );
38
-
39
- vi.mock( './matchers.js', () => ( {
40
- buildActivityMatcher: buildActivityMatcherMock,
41
- staticMatchers: {
42
- sharedStepsDir: sharedStepsDirMock,
43
- sharedEvaluatorsDir: sharedEvaluatorsDirMock
44
- }
45
- } ) );
46
-
47
- describe( 'loadActivities', () => {
48
- beforeEach( () => {
49
- vi.clearAllMocks();
50
- importComponentsMock.mockReset();
51
- importComponentsMock.mockImplementation( async function *() {} );
52
- findSharedActivitiesFromWorkflowsMock.mockReset();
53
- findSharedActivitiesFromWorkflowsMock.mockReturnValue( [] );
54
- matchFilesMock.mockReset();
55
- matchFilesMock.mockReturnValue( [] );
56
- writeFileInTempDirMock.mockReset();
57
- writeFileInTempDirMock.mockReturnValue( '/tmp/__activity_options.js' );
58
- buildActivityMatcherMock.mockReset();
59
- buildActivityMatcherMock.mockReturnValue( activityMatcherMock );
60
- } );
61
-
62
- it( 'loadActivities returns map including system activity and writes options file', async () => {
63
- const { loadActivities } = await import( './activities.js' );
64
-
65
- importComponentsMock.mockImplementationOnce( async function *() {} );
66
- importComponentsMock.mockImplementationOnce( async function *() {
67
- yield {
68
- fn: () => {},
69
- metadata: { name: 'Act1', options: { activityOptions: { retry: { maximumAttempts: 3 } } } },
70
- path: '/a/steps.js'
71
- };
72
- } );
73
-
74
- const workflows = [ { name: 'A', path: '/a/workflow.js' } ];
75
- const { activities, optionsFile } = await loadActivities( '/root', workflows );
76
- expect( activities['A#Act1'] ).toBeTypeOf( 'function' );
77
- expect( activities['__internal#sendHttpRequest'] ).toBe( sendHttpRequestMock );
78
- expect( optionsFile ).toBe( '/tmp/__activity_options.js' );
79
-
80
- expect( writeFileInTempDirMock ).toHaveBeenCalledTimes( 1 );
81
- const [ contents, filename ] = writeFileInTempDirMock.mock.calls[0];
82
- expect( filename ).toBe( '__activity_options.js' );
83
- expect( contents ).toContain( 'export default' );
84
- expect( JSON.parse( contents.replace( /^export default\s*/, '' ).replace( /;\s*$/, '' ) ) ).toEqual( {
85
- 'A#Act1': { retry: { maximumAttempts: 3 } }
86
- } );
87
- } );
88
-
89
- it( 'loadActivities omits activity options when component has no options or no activityOptions', async () => {
90
- const { loadActivities } = await import( './activities.js' );
91
- importComponentsMock.mockImplementationOnce( async function *() {} );
92
- importComponentsMock.mockImplementationOnce( async function *() {
93
- yield { fn: () => {}, metadata: { name: 'NoOptions' }, path: '/a/steps.js' };
94
- yield { fn: () => {}, metadata: { name: 'EmptyOptions', options: {} }, path: '/a/steps2.js' };
95
- } );
96
-
97
- await loadActivities( '/root', [ { name: 'A', path: '/a/workflow.js' } ] );
98
- const written = JSON.parse(
99
- writeFileInTempDirMock.mock.calls[0][0].replace( /^export default\s*/, '' ).replace( /;\s*$/, '' )
100
- );
101
- expect( written['A#NoOptions'] ).toBeUndefined();
102
- expect( written['A#EmptyOptions'] ).toBeUndefined();
103
- } );
104
-
105
- it( 'loadActivities throws when two activities in the same workflow share a name', async () => {
106
- const { loadActivities } = await import( './activities.js' );
107
- importComponentsMock.mockImplementationOnce( async function *() {} );
108
- importComponentsMock.mockImplementationOnce( async function *() {
109
- yield { fn: () => {}, metadata: { name: 'DuplicateActivity' }, path: '/a/steps.js' };
110
- yield { fn: () => {}, metadata: { name: 'DuplicateActivity' }, path: '/a/evaluators.js' };
111
- } );
112
-
113
- await expect( loadActivities( '/root', [ { name: 'A', path: '/a/workflow.js' } ] ) ).rejects.toThrow(
114
- 'Activity "DuplicateActivity" in workflow "A" conflicts with another activity in the same workflow. \
115
- Activity names must be unique within a workflow.'
116
- );
117
- } );
118
-
119
- it( 'loadActivities throws when two shared activities share a name', async () => {
120
- const { loadActivities } = await import( './activities.js' );
121
- importComponentsMock.mockImplementationOnce( async function *() {
122
- yield { fn: () => {}, metadata: { name: 'DuplicateShared' }, path: '/root/shared/steps/a.js' };
123
- yield { fn: () => {}, metadata: { name: 'DuplicateShared' }, path: '/root/shared/evaluators/a.js' };
124
- } );
125
-
126
- await expect( loadActivities( '/root', [ { name: 'A', path: '/a/workflow.js' } ] ) ).rejects.toThrow(
127
- 'Shared activity "DuplicateShared" conflicts with another shared activity. Shared activity names must be unique.'
128
- );
129
- } );
130
-
131
- it( 'loadActivities uses activity and shared matchers for workflow and shared scans', async () => {
132
- const { loadActivities } = await import( './activities.js' );
133
- const workflowFiles = [ { path: '/a/steps/foo.js' } ];
134
- const sharedFiles = [ { path: '/root/shared/steps/baz.js' } ];
135
- matchFilesMock.mockReturnValueOnce( sharedFiles );
136
- matchFilesMock.mockReturnValueOnce( workflowFiles );
137
- importComponentsMock.mockImplementationOnce( async function *() {} );
138
- importComponentsMock.mockImplementationOnce( async function *() {} );
139
-
140
- const workflows = [ { name: 'A', path: '/a/workflow.js' } ];
141
- await loadActivities( '/root', workflows );
142
-
143
- expect( matchFilesMock ).toHaveBeenCalledTimes( 2 );
144
- expect( buildActivityMatcherMock ).toHaveBeenCalledWith( '/a' );
145
- expect( matchFilesMock ).toHaveBeenNthCalledWith( 1, '/root', [ sharedStepsDirMock, sharedEvaluatorsDirMock ] );
146
- expect( matchFilesMock ).toHaveBeenNthCalledWith( 2, '/a', [ activityMatcherMock ] );
147
-
148
- expect( importComponentsMock ).toHaveBeenCalledTimes( 2 );
149
- expect( importComponentsMock ).toHaveBeenNthCalledWith( 1, sharedFiles );
150
- expect( importComponentsMock ).toHaveBeenNthCalledWith( 2, workflowFiles );
151
- } );
152
-
153
- it( 'loads shared activities from external workflow packages', async () => {
154
- const { loadActivities } = await import( './activities.js' );
155
- const externalSharedFiles = [ { path: '/root/node_modules/pkg/shared/steps/prepare.js' } ];
156
- const localWorkflow = { name: 'Local', path: '/root/workflows/local/workflow.js' };
157
- const externalWorkflow = { name: 'External', path: '/root/node_modules/pkg/workflows/a/workflow.js', external: true };
158
- findSharedActivitiesFromWorkflowsMock.mockReturnValue( externalSharedFiles );
159
- importComponentsMock.mockImplementationOnce( async function *() {
160
- yield {
161
- fn: () => {},
162
- metadata: { name: 'ExternalShared', options: { activityOptions: { retry: { maximumAttempts: 2 } } } },
163
- path: '/root/node_modules/pkg/shared/steps/prepare.js'
164
- };
165
- } );
166
-
167
- const { activities } = await loadActivities( '/root', [ localWorkflow, externalWorkflow ] );
168
-
169
- expect( findSharedActivitiesFromWorkflowsMock ).toHaveBeenCalledWith( [ externalWorkflow ] );
170
- expect( importComponentsMock ).toHaveBeenNthCalledWith( 1, externalSharedFiles );
171
- expect( activities['Local#ExternalShared'] ).toBeTypeOf( 'function' );
172
- expect( activities['External#ExternalShared'] ).toBeTypeOf( 'function' );
173
- const written = JSON.parse(
174
- writeFileInTempDirMock.mock.calls[0][0].replace( /^export default\s*/, '' ).replace( /;\s*$/, '' )
175
- );
176
- expect( written['Local#ExternalShared'] ).toEqual( { retry: { maximumAttempts: 2 } } );
177
- expect( written['External#ExternalShared'] ).toEqual( { retry: { maximumAttempts: 2 } } );
178
- } );
179
-
180
- it( 'loadActivities includes nested workflow steps and shared evaluators', async () => {
181
- const { loadActivities } = await import( './activities.js' );
182
- importComponentsMock.mockImplementationOnce( async function *() {
183
- yield { fn: () => {}, metadata: { name: 'SharedEval' }, path: '/root/shared/evaluators/bar.js' };
184
- } );
185
- importComponentsMock.mockImplementationOnce( async function *() {
186
- yield { fn: () => {}, metadata: { name: 'ActNested' }, path: '/a/steps/foo.js' };
187
- } );
188
-
189
- const workflows = [ { name: 'A', path: '/a/workflow.js' } ];
190
- const { activities } = await loadActivities( '/root', workflows );
191
- expect( activities['A#ActNested'] ).toBeTypeOf( 'function' );
192
- expect( activities['A#SharedEval'] ).toBeTypeOf( 'function' );
193
- } );
194
-
195
- it( 'collects shared nested steps and evaluators across multiple subfolders', async () => {
196
- const { loadActivities } = await import( './activities.js' );
197
- importComponentsMock.mockImplementationOnce( async function *() {} );
198
- importComponentsMock.mockImplementationOnce( async function *() {
199
- yield { fn: () => {}, metadata: { name: 'SharedStepPrimary' }, path: '/root/shared/steps/primary/a.js' };
200
- yield { fn: () => {}, metadata: { name: 'SharedStepSecondary' }, path: '/root/shared/steps/secondary/b.js' };
201
- yield { fn: () => {}, metadata: { name: 'SharedEvalPrimary' }, path: '/root/shared/evaluators/primary/c.js' };
202
- yield { fn: () => {}, metadata: { name: 'SharedEvalSecondary' }, path: '/root/shared/evaluators/secondary/d.js' };
203
- } );
204
-
205
- const workflows = [ { name: 'A', path: '/a/workflow.js' } ];
206
- const { activities } = await loadActivities( '/root', workflows );
207
- expect( activities['A#SharedStepPrimary'] ).toBeTypeOf( 'function' );
208
- expect( activities['A#SharedStepSecondary'] ).toBeTypeOf( 'function' );
209
- expect( activities['A#SharedEvalPrimary'] ).toBeTypeOf( 'function' );
210
- expect( activities['A#SharedEvalSecondary'] ).toBeTypeOf( 'function' );
211
- } );
212
- } );
@@ -1,64 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { join } from 'node:path';
3
- import { tmpdir } from 'node:os';
4
-
5
- const fsMocks = vi.hoisted( () => ( {
6
- existsSync: vi.fn().mockReturnValue( false )
7
- } ) );
8
- vi.mock( 'node:fs', () => ( {
9
- existsSync: fsMocks.existsSync
10
- } ) );
11
-
12
- describe( 'loadHooks', () => {
13
- beforeEach( () => {
14
- vi.clearAllMocks();
15
- fsMocks.existsSync.mockReturnValue( false );
16
- } );
17
-
18
- it( 'resolves without importing when package.json does not exist', async () => {
19
- fsMocks.existsSync.mockReturnValue( false );
20
- const { loadHooks } = await import( './hooks.js' );
21
- await expect( loadHooks( '/root' ) ).resolves.toBeUndefined();
22
- expect( fsMocks.existsSync ).toHaveBeenCalledWith( join( '/root', 'package.json' ) );
23
- } );
24
-
25
- it( 'imports hook files listed in package.json outputai.hookFiles', async () => {
26
- vi.doUnmock( 'node:fs' );
27
- vi.resetModules();
28
- const fs = await import( 'node:fs' );
29
- const tmpDir = fs.mkdtempSync( join( tmpdir(), 'loader-spec-' ) );
30
- try {
31
- fs.writeFileSync( join( tmpDir, 'package.json' ), JSON.stringify( {
32
- outputai: { hookFiles: [ 'hook.js' ] }
33
- } ) );
34
- fs.writeFileSync( join( tmpDir, 'hook.js' ), 'globalThis.__loadHooksTestLoaded = true;' );
35
-
36
- const { loadHooks } = await import( './hooks.js' );
37
- await loadHooks( tmpDir );
38
- expect( globalThis.__loadHooksTestLoaded ).toBe( true );
39
- } finally {
40
- delete globalThis.__loadHooksTestLoaded;
41
- fs.rmSync( tmpDir, { recursive: true, force: true } );
42
- }
43
- } );
44
-
45
- it( 'imports hook files from legacy package.json output.hookFiles', async () => {
46
- vi.doUnmock( 'node:fs' );
47
- vi.resetModules();
48
- const fs = await import( 'node:fs' );
49
- const tmpDir = fs.mkdtempSync( join( tmpdir(), 'loader-spec-' ) );
50
- try {
51
- fs.writeFileSync( join( tmpDir, 'package.json' ), JSON.stringify( {
52
- output: { hookFiles: [ 'legacy_hook.js' ] }
53
- } ) );
54
- fs.writeFileSync( join( tmpDir, 'legacy_hook.js' ), 'globalThis.__loadHooksLegacyTestLoaded = true;' );
55
-
56
- const { loadHooks } = await import( './hooks.js' );
57
- await loadHooks( tmpDir );
58
- expect( globalThis.__loadHooksLegacyTestLoaded ).toBe( true );
59
- } finally {
60
- delete globalThis.__loadHooksLegacyTestLoaded;
61
- fs.rmSync( tmpDir, { recursive: true, force: true } );
62
- }
63
- } );
64
- } );
@@ -1,140 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { sep } from 'node:path';
3
- import { buildActivityMatcher, staticMatchers } from './matchers.js';
4
-
5
- describe( 'buildActivityMatcher', () => {
6
- const base = `${sep}app${sep}proj`;
7
-
8
- it( 'matches steps.js at the base path', () => {
9
- const matchActivity = buildActivityMatcher( base );
10
-
11
- expect( matchActivity( `${base}${sep}steps.js` ) ).toBe( true );
12
- } );
13
-
14
- it( 'matches evaluators.js at the base path', () => {
15
- const matchActivity = buildActivityMatcher( base );
16
-
17
- expect( matchActivity( `${base}${sep}evaluators.js` ) ).toBe( true );
18
- } );
19
-
20
- it( 'matches files under the steps directory', () => {
21
- const matchActivity = buildActivityMatcher( base );
22
-
23
- expect( matchActivity( `${base}${sep}steps${sep}a.js` ) ).toBe( true );
24
- expect( matchActivity( `${base}${sep}steps${sep}sub${sep}b.js` ) ).toBe( true );
25
- } );
26
-
27
- it( 'matches files under the evaluators directory', () => {
28
- const matchActivity = buildActivityMatcher( base );
29
-
30
- expect( matchActivity( `${base}${sep}evaluators${sep}x.js` ) ).toBe( true );
31
- expect( matchActivity( `${base}${sep}evaluators${sep}y${sep}z.js` ) ).toBe( true );
32
- } );
33
-
34
- it( 'rejects activity filenames outside the base path', () => {
35
- const matchActivity = buildActivityMatcher( base );
36
-
37
- expect( matchActivity( `${base}${sep}nested${sep}steps.js` ) ).toBe( false );
38
- expect( matchActivity( `${base}${sep}sub${sep}evaluators.js` ) ).toBe( false );
39
- expect( matchActivity( `${sep}app${sep}other${sep}steps.js` ) ).toBe( false );
40
- } );
41
-
42
- it( 'rejects non-activity names at the base path', () => {
43
- const matchActivity = buildActivityMatcher( base );
44
-
45
- expect( matchActivity( `${base}${sep}workflow.js` ) ).toBe( false );
46
- expect( matchActivity( `${base}${sep}shared${sep}steps${sep}a.js` ) ).toBe( false );
47
- expect( matchActivity( `${base}${sep}other${sep}a.js` ) ).toBe( false );
48
- } );
49
-
50
- it( 'rejects similarly named files and directories', () => {
51
- const matchActivity = buildActivityMatcher( base );
52
-
53
- expect( matchActivity( `${base}${sep}stepsXjs` ) ).toBe( false );
54
- expect( matchActivity( `${base}${sep}evaluatorsXjs` ) ).toBe( false );
55
- expect( matchActivity( `${base}${sep}steps-extra.js` ) ).toBe( false );
56
- expect( matchActivity( `${base}${sep}evaluators-extra.js` ) ).toBe( false );
57
- expect( matchActivity( `${base}${sep}steps_extra${sep}a.js` ) ).toBe( false );
58
- expect( matchActivity( `${base}${sep}evaluators_extra${sep}a.js` ) ).toBe( false );
59
- } );
60
-
61
- it( 'rejects directory names without a nested path', () => {
62
- const matchActivity = buildActivityMatcher( base );
63
-
64
- expect( matchActivity( `${base}${sep}steps` ) ).toBe( false );
65
- expect( matchActivity( `${base}${sep}evaluators` ) ).toBe( false );
66
- } );
67
-
68
- it( 'rejects exact files when additional path segments follow', () => {
69
- const matchActivity = buildActivityMatcher( base );
70
-
71
- expect( matchActivity( `${base}${sep}steps.js${sep}extra.js` ) ).toBe( false );
72
- expect( matchActivity( `${base}${sep}evaluators.js${sep}extra.js` ) ).toBe( false );
73
- } );
74
-
75
- it( 'escapes regular expression characters in the base path', () => {
76
- const specialBase = `${sep}app${sep}proj.with-symbols+(test)`;
77
- const matchActivity = buildActivityMatcher( specialBase );
78
-
79
- expect( matchActivity( `${specialBase}${sep}steps.js` ) ).toBe( true );
80
- expect( matchActivity( `${sep}app${sep}projXwith-symbols+(test)${sep}steps.js` ) ).toBe( false );
81
- } );
82
- } );
83
-
84
- describe( 'staticMatchers', () => {
85
- describe( 'workflowFile', () => {
86
- it( 'matches paths ending with path separator and workflow.js', () => {
87
- expect( staticMatchers.workflowFile( `${sep}x${sep}y${sep}workflow.js` ) ).toBe( true );
88
- } );
89
-
90
- it( 'rejects workflow.ts', () => {
91
- expect( staticMatchers.workflowFile( `${sep}a${sep}workflow.ts` ) ).toBe( false );
92
- } );
93
- } );
94
-
95
- describe( 'workflowPathHasShared', () => {
96
- it( 'matches workflow.js under a shared folder segment', () => {
97
- expect( staticMatchers.workflowPathHasShared( `${sep}foo${sep}shared${sep}workflow.js` ) ).toBe( true );
98
- } );
99
-
100
- it( 'rejects workflow.js not under shared', () => {
101
- expect( staticMatchers.workflowPathHasShared( `${sep}foo${sep}workflow.js` ) ).toBe( false );
102
- } );
103
- } );
104
-
105
- describe( 'sharedStepsDir', () => {
106
- it( 'matches .js files inside shared/steps/', () => {
107
- expect( staticMatchers.sharedStepsDir( `${sep}app${sep}dist${sep}shared${sep}steps${sep}tools.js` ) ).toBe( true );
108
- } );
109
-
110
- it( 'matches .js files in nested subdirectories of shared/steps/', () => {
111
- expect( staticMatchers.sharedStepsDir( `${sep}app${sep}dist${sep}shared${sep}steps${sep}utils${sep}helper.js` ) ).toBe( true );
112
- } );
113
-
114
- it( 'rejects .ts files inside shared/steps/', () => {
115
- expect( staticMatchers.sharedStepsDir( `${sep}app${sep}src${sep}shared${sep}steps${sep}tools.ts` ) ).toBe( false );
116
- } );
117
-
118
- it( 'rejects non-.js files inside shared/steps/', () => {
119
- expect( staticMatchers.sharedStepsDir( `${sep}app${sep}dist${sep}shared${sep}steps${sep}readme.md` ) ).toBe( false );
120
- } );
121
- } );
122
-
123
- describe( 'sharedEvaluatorsDir', () => {
124
- it( 'matches .js files inside shared/evaluators/', () => {
125
- expect( staticMatchers.sharedEvaluatorsDir( `${sep}app${sep}dist${sep}shared${sep}evaluators${sep}quality.js` ) ).toBe( true );
126
- } );
127
-
128
- it( 'matches .js files in nested subdirectories of shared/evaluators/', () => {
129
- expect( staticMatchers.sharedEvaluatorsDir( `${sep}app${sep}dist${sep}shared${sep}evaluators${sep}utils${sep}helper.js` ) ).toBe( true );
130
- } );
131
-
132
- it( 'rejects .ts files inside shared/evaluators/', () => {
133
- expect( staticMatchers.sharedEvaluatorsDir( `${sep}app${sep}src${sep}shared${sep}evaluators${sep}quality.ts` ) ).toBe( false );
134
- } );
135
-
136
- it( 'rejects non-.js files inside shared/evaluators/', () => {
137
- expect( staticMatchers.sharedEvaluatorsDir( `${sep}app${sep}dist${sep}shared${sep}evaluators${sep}readme.md` ) ).toBe( false );
138
- } );
139
- } );
140
- } );