Skip to content

Commit 377b8b1

Browse files
authored
Merge pull request #409 from objectstack-ai/copilot/fix-action-step-error-another-one
2 parents 3f03cfc + d1e49fd commit 377b8b1

5 files changed

Lines changed: 71 additions & 76 deletions

File tree

packages/spec/src/ai/conversation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ describe('Real-World Conversation Examples', () => {
504504
timestamp: '2024-01-15T09:00:05Z',
505505
role: 'user',
506506
content: 'Hi, I have an issue with my order #ORD-2024-001',
507-
tokens: { prompt: 15, total: 15 },
507+
tokens: { prompt: 15, completion: 0, total: 15 },
508508
},
509509
{
510510
id: 'msg-2',

packages/spec/src/auth/config.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ describe('EnterpriseAuthConfigSchema', () => {
472472
},
473473
};
474474

475-
expect(() => EnterpriseApplicationAuthConfigSchema.parse(config)).not.toThrow();
475+
expect(() => EnterpriseAuthConfigSchema.parse(config)).not.toThrow();
476476
});
477477

478478
it('should accept partial enterprise config', () => {
@@ -485,12 +485,12 @@ describe('EnterpriseAuthConfigSchema', () => {
485485
},
486486
};
487487

488-
expect(() => EnterpriseApplicationAuthConfigSchema.parse(config)).not.toThrow();
488+
expect(() => EnterpriseAuthConfigSchema.parse(config)).not.toThrow();
489489
});
490490

491491
it('should accept empty enterprise config', () => {
492492
const config = {};
493-
expect(() => EnterpriseApplicationAuthConfigSchema.parse(config)).not.toThrow();
493+
expect(() => EnterpriseAuthConfigSchema.parse(config)).not.toThrow();
494494
});
495495
});
496496

packages/spec/src/automation/workflow.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,10 @@ describe('WorkflowActionSchema', () => {
471471
const action = {
472472
name: 'trigger_webhook',
473473
type: 'webhook_trigger' as const,
474-
url: 'https://webhook.example.com',
474+
config: {
475+
name: 'test_webhook',
476+
url: 'https://webhook.example.com',
477+
},
475478
};
476479

477480
expect(() => WorkflowActionSchema.parse(action)).not.toThrow();

packages/spec/src/data/external-lookup.test.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ describe('ExternalDataSourceSchema', () => {
121121
describe('FieldMappingSchema', () => {
122122
it('should validate complete field mapping', () => {
123123
const validMapping: FieldMapping = {
124-
externalField: 'AccountName',
125-
localField: 'name',
124+
source: 'AccountName',
125+
target: 'name',
126126
type: 'text',
127127
readonly: true,
128128
};
@@ -132,8 +132,8 @@ describe('FieldMappingSchema', () => {
132132

133133
it('should accept minimal field mapping', () => {
134134
const minimalMapping = {
135-
externalField: 'ExternalField',
136-
localField: 'local_field',
135+
source: 'ExternalField',
136+
target: 'local_field',
137137
type: 'text',
138138
};
139139

@@ -142,8 +142,8 @@ describe('FieldMappingSchema', () => {
142142

143143
it('should default readonly to true', () => {
144144
const mapping = {
145-
externalField: 'Field1',
146-
localField: 'field_1',
145+
source: 'Field1',
146+
target: 'field_1',
147147
type: 'text',
148148
};
149149

@@ -153,8 +153,8 @@ describe('FieldMappingSchema', () => {
153153

154154
it('should accept writable field mapping', () => {
155155
const writableMapping = {
156-
externalField: 'Status',
157-
localField: 'status',
156+
source: 'Status',
157+
target: 'status',
158158
type: 'text',
159159
readonly: false,
160160
};
@@ -167,8 +167,8 @@ describe('FieldMappingSchema', () => {
167167

168168
types.forEach((type) => {
169169
const mapping = {
170-
externalField: 'Field',
171-
localField: 'field',
170+
source: 'Field',
171+
target: 'field',
172172
type,
173173
};
174174

@@ -198,14 +198,14 @@ describe('ExternalLookupSchema', () => {
198198
},
199199
fieldMappings: [
200200
{
201-
externalField: 'Name',
202-
localField: 'account_name',
201+
source: 'Name',
202+
target: 'account_name',
203203
type: 'text',
204204
readonly: true,
205205
},
206206
{
207-
externalField: 'Industry',
208-
localField: 'industry',
207+
source: 'Industry',
208+
target: 'industry',
209209
type: 'text',
210210
readonly: true,
211211
},
@@ -246,8 +246,8 @@ describe('ExternalLookupSchema', () => {
246246
},
247247
fieldMappings: [
248248
{
249-
externalField: 'Field1',
250-
localField: 'field_1',
249+
source: 'Field1',
250+
target: 'field_1',
251251
type: 'text',
252252
},
253253
],
@@ -516,20 +516,20 @@ describe('ExternalLookupSchema', () => {
516516
},
517517
fieldMappings: [
518518
{
519-
externalField: 'ProductID',
520-
localField: 'product_id',
519+
source: 'ProductID',
520+
target: 'product_id',
521521
type: 'number',
522522
readonly: true,
523523
},
524524
{
525-
externalField: 'ProductName',
526-
localField: 'product_name',
525+
source: 'ProductName',
526+
target: 'product_name',
527527
type: 'text',
528528
readonly: true,
529529
},
530530
{
531-
externalField: 'UnitPrice',
532-
localField: 'unit_price',
531+
source: 'UnitPrice',
532+
target: 'unit_price',
533533
type: 'currency',
534534
readonly: true,
535535
},
@@ -564,20 +564,20 @@ describe('ExternalLookupSchema', () => {
564564
},
565565
fieldMappings: [
566566
{
567-
externalField: 'id',
568-
localField: 'user_id',
567+
source: 'id',
568+
target: 'user_id',
569569
type: 'text',
570570
readonly: true,
571571
},
572572
{
573-
externalField: 'name',
574-
localField: 'user_name',
573+
source: 'name',
574+
target: 'user_name',
575575
type: 'text',
576576
readonly: true,
577577
},
578578
{
579-
externalField: 'email',
580-
localField: 'user_email',
579+
source: 'email',
580+
target: 'user_email',
581581
type: 'email',
582582
readonly: true,
583583
},
@@ -619,26 +619,26 @@ describe('ExternalLookupSchema', () => {
619619
},
620620
fieldMappings: [
621621
{
622-
externalField: 'Id',
623-
localField: 'salesforce_id',
622+
source: 'Id',
623+
target: 'salesforce_id',
624624
type: 'text',
625625
readonly: true,
626626
},
627627
{
628-
externalField: 'Name',
629-
localField: 'contact_name',
628+
source: 'Name',
629+
target: 'contact_name',
630630
type: 'text',
631631
readonly: true,
632632
},
633633
{
634-
externalField: 'Email',
635-
localField: 'email',
634+
source: 'Email',
635+
target: 'email',
636636
type: 'email',
637637
readonly: true,
638638
},
639639
{
640-
externalField: 'Phone',
641-
localField: 'phone',
640+
source: 'Phone',
641+
target: 'phone',
642642
type: 'phone',
643643
readonly: true,
644644
},

packages/spec/src/integration/connector.test.ts

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,18 @@ describe('OAuth2Schema', () => {
120120
expect(parsed.refreshToken).toBe('refresh-token-xyz');
121121
});
122122

123-
it('should use default grant type', () => {
123+
it('should accept OAuth2 without optional fields', () => {
124124
const auth = {
125-
type: 'oauth2',
125+
type: 'oauth2' as const,
126126
clientId: 'client-id',
127127
clientSecret: 'client-secret',
128128
authorizationUrl: 'https://auth.example.com/authorize',
129129
tokenUrl: 'https://auth.example.com/token',
130130
};
131131

132132
const parsed = OAuth2Schema.parse(auth);
133-
expect(parsed.grantType).toBe('authorization_code');
133+
expect(parsed.type).toBe('oauth2');
134+
expect(parsed.clientId).toBe('client-id');
134135
});
135136
});
136137

@@ -226,44 +227,33 @@ describe('AuthenticationSchema', () => {
226227
describe('FieldMappingSchema', () => {
227228
it('should accept valid field mapping', () => {
228229
const mapping: FieldMapping = {
229-
sourceField: 'firstName',
230-
targetField: 'first_name',
230+
source: 'firstName',
231+
target: 'first_name',
231232
dataType: 'string',
232233
syncMode: 'bidirectional',
233234
};
234235

235236
expect(() => FieldMappingSchema.parse(mapping)).not.toThrow();
236237
});
237238

238-
it('should validate target field snake_case format', () => {
239-
expect(() => FieldMappingSchema.parse({
240-
sourceField: 'field',
241-
targetField: 'valid_field_name',
242-
})).not.toThrow();
243-
244-
expect(() => FieldMappingSchema.parse({
245-
sourceField: 'field',
246-
targetField: 'InvalidField',
247-
})).toThrow();
248-
});
249-
250239
it('should accept field with transformation', () => {
251240
const mapping = {
252-
sourceField: 'name',
253-
targetField: 'full_name',
241+
source: 'name',
242+
target: 'full_name',
254243
transform: {
255-
type: 'uppercase',
244+
type: 'javascript' as const,
245+
expression: 'value.toUpperCase()',
256246
},
257247
};
258248

259249
const parsed = FieldMappingSchema.parse(mapping);
260-
expect(parsed.transform?.type).toBe('uppercase');
250+
expect(parsed.transform?.type).toBe('javascript');
261251
});
262252

263253
it('should use default values', () => {
264254
const mapping = {
265-
sourceField: 'field1',
266-
targetField: 'field_1',
255+
source: 'field1',
256+
target: 'field_1',
267257
};
268258

269259
const parsed = FieldMappingSchema.parse(mapping);
@@ -317,41 +307,42 @@ describe('DataSyncConfigSchema', () => {
317307
describe('WebhookConfigSchema', () => {
318308
it('should accept valid webhook configuration', () => {
319309
const webhook: WebhookConfig = {
310+
name: 'test_webhook',
320311
url: 'https://api.example.com/webhooks',
321312
events: ['record.created', 'record.updated'],
322313
secret: 'webhook-secret',
323314
signatureAlgorithm: 'hmac_sha256',
324-
enabled: true,
325315
};
326316

327317
expect(() => WebhookConfigSchema.parse(webhook)).not.toThrow();
328318
});
329319

330320
it('should accept webhook with retry configuration', () => {
331321
const webhook = {
322+
name: 'retry_webhook',
332323
url: 'https://api.example.com/webhooks',
333324
events: ['sync.completed'],
334-
retryConfig: {
335-
maxAttempts: 3,
336-
backoffMultiplier: 2,
325+
retryPolicy: {
326+
maxRetries: 3,
327+
backoffStrategy: 'exponential' as const,
337328
initialDelayMs: 1000,
338329
},
339330
};
340331

341332
const parsed = WebhookConfigSchema.parse(webhook);
342-
expect(parsed.retryConfig?.maxAttempts).toBe(3);
333+
expect(parsed.retryPolicy?.maxRetries).toBe(3);
343334
});
344335

345336
it('should use default values', () => {
346337
const webhook = {
338+
name: 'default_webhook',
347339
url: 'https://api.example.com/webhooks',
348340
events: ['record.created'],
349341
};
350342

351343
const parsed = WebhookConfigSchema.parse(webhook);
352344
expect(parsed.signatureAlgorithm).toBe('hmac_sha256');
353345
expect(parsed.timeoutMs).toBe(30000);
354-
expect(parsed.enabled).toBe(true);
355346
});
356347
});
357348

@@ -478,12 +469,13 @@ describe('ConnectorSchema', () => {
478469
},
479470
fieldMappings: [
480471
{
481-
sourceField: 'id',
482-
targetField: 'external_id',
472+
source: 'id',
473+
target: 'external_id',
483474
},
484475
],
485476
webhooks: [
486477
{
478+
name: 'connector_webhook',
487479
url: 'https://api.example.com/webhook',
488480
events: ['record.created'],
489481
},
@@ -602,14 +594,14 @@ describe('Connector Integration', () => {
602594
},
603595
fieldMappings: [
604596
{
605-
sourceField: 'FirstName',
606-
targetField: 'first_name',
597+
source: 'FirstName',
598+
target: 'first_name',
607599
dataType: 'string',
608600
required: true,
609601
},
610602
{
611-
sourceField: 'LastName',
612-
targetField: 'last_name',
603+
source: 'LastName',
604+
target: 'last_name',
613605
dataType: 'string',
614606
required: true,
615607
},

0 commit comments

Comments
 (0)