terse-types 0.0.1 → 0.0.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/dist/Configs.js CHANGED
@@ -283,11 +283,11 @@ class BaseConfigInstance {
283
283
  export const GmailConfigSchema = ConfigInstanceSchema.extend({
284
284
  integrationType: z.literal(IntegrationType.GMAIL),
285
285
  configType: z.literal(ConfigType.GMAIL),
286
- eventTypes: z.array(z.enum(GmailEventType)).optional()
286
+ eventTypes: z.array(z.enum(GmailEventType)).nullable()
287
287
  });
288
288
  export class GmailConfig extends BaseConfigInstance {
289
289
  eventTypes;
290
- constructor(integrationId, eventTypes) {
290
+ constructor(integrationId, eventTypes = null) {
291
291
  super(integrationId, IntegrationType.GMAIL, ConfigType.GMAIL);
292
292
  this.eventTypes = eventTypes;
293
293
  }
@@ -304,14 +304,14 @@ export const FigmaConfigSchema = ConfigInstanceSchema.extend({
304
304
  fileKey: z.string(),
305
305
  fileName: z.string(),
306
306
  teamId: z.string(),
307
- eventTypes: z.array(z.enum(FigmaEventType)).optional()
307
+ eventTypes: z.array(z.enum(FigmaEventType)).nullable()
308
308
  });
309
309
  export class FigmaConfig extends BaseConfigInstance {
310
310
  fileKey;
311
311
  fileName;
312
312
  teamId;
313
313
  eventTypes;
314
- constructor(integrationId, fileKey, fileName, teamId, eventTypes) {
314
+ constructor(integrationId, fileKey, fileName, teamId, eventTypes = null) {
315
315
  super(integrationId, IntegrationType.FIGMA, ConfigType.FIGMA);
316
316
  this.fileKey = fileKey;
317
317
  this.fileName = fileName;
@@ -335,11 +335,11 @@ export class FigmaConfig extends BaseConfigInstance {
335
335
  export const SlackConfigSchema = ConfigInstanceSchema.extend({
336
336
  integrationType: z.literal(IntegrationType.SLACK),
337
337
  configType: z.literal(ConfigType.SLACK),
338
- channelId: z.string().optional(),
339
- channelName: z.string().optional(),
338
+ channelId: z.string().nullable(),
339
+ channelName: z.string().nullable(),
340
340
  listenToUserDms: z.boolean().default(false),
341
- userIds: z.array(z.string()).optional(),
342
- eventTypes: z.array(z.enum(SlackEventType)).optional()
341
+ userIds: z.array(z.string()).nullable(),
342
+ eventTypes: z.array(z.enum(SlackEventType)).nullable()
343
343
  });
344
344
  export class SlackConfig extends BaseConfigInstance {
345
345
  channelId;
@@ -347,7 +347,7 @@ export class SlackConfig extends BaseConfigInstance {
347
347
  listenToUserDms;
348
348
  userIds;
349
349
  eventTypes;
350
- constructor(integrationId, channelId, channelName, listenToUserDms = false, userIds, eventTypes) {
350
+ constructor(integrationId, channelId = null, channelName = null, listenToUserDms = false, userIds = null, eventTypes = null) {
351
351
  super(integrationId, IntegrationType.SLACK, ConfigType.SLACK);
352
352
  this.channelId = channelId;
353
353
  this.channelName = channelName;
@@ -379,10 +379,10 @@ export class SlackConfig extends BaseConfigInstance {
379
379
  export const SlackOutputConfigSchema = ConfigInstanceSchema.extend({
380
380
  integrationType: z.literal(IntegrationType.SLACK),
381
381
  configType: z.literal(ConfigType.SLACK_OUTPUT),
382
- channelId: z.string().optional(),
383
- channelName: z.string().optional(),
384
- userIds: z.array(z.string()).optional(),
385
- userNames: z.array(z.string()).optional(),
382
+ channelId: z.string().nullable(),
383
+ channelName: z.string().nullable(),
384
+ userIds: z.array(z.string()).nullable(),
385
+ userNames: z.array(z.string()).nullable(),
386
386
  listenToUserDms: z.boolean().default(false)
387
387
  });
388
388
  export class SlackOutputConfig extends BaseConfigInstance {
@@ -391,7 +391,7 @@ export class SlackOutputConfig extends BaseConfigInstance {
391
391
  userIds;
392
392
  userNames;
393
393
  listenToUserDms;
394
- constructor(integrationId, channelId, channelName, userIds, userNames, listenToUserDms = false) {
394
+ constructor(integrationId, channelId = null, channelName = null, userIds = null, userNames = null, listenToUserDms = false) {
395
395
  super(integrationId, IntegrationType.SLACK, ConfigType.SLACK_OUTPUT);
396
396
  this.channelId = channelId;
397
397
  this.channelName = channelName;
@@ -489,15 +489,15 @@ export class NotionConfig extends BaseConfigInstance {
489
489
  export const LinearInputConfigSchema = ConfigInstanceSchema.extend({
490
490
  integrationType: z.literal(IntegrationType.LINEAR),
491
491
  configType: z.literal(ConfigType.LINEAR_INPUT),
492
- projectId: z.string().optional(),
493
- projectName: z.string().optional(),
494
- eventTypes: z.array(z.enum(LinearEventType)).optional()
492
+ projectId: z.string().nullable(),
493
+ projectName: z.string().nullable(),
494
+ eventTypes: z.array(z.enum(LinearEventType)).nullable()
495
495
  });
496
496
  export class LinearInputConfig extends BaseConfigInstance {
497
497
  projectId;
498
498
  projectName;
499
499
  eventTypes;
500
- constructor(integrationId, projectId, projectName, eventTypes) {
500
+ constructor(integrationId, projectId = null, projectName = null, eventTypes = null) {
501
501
  super(integrationId, IntegrationType.LINEAR, ConfigType.LINEAR_INPUT);
502
502
  this.projectId = projectId;
503
503
  this.projectName = projectName;
@@ -520,17 +520,17 @@ export class LinearInputConfig extends BaseConfigInstance {
520
520
  export const LinearOutputConfigSchema = ConfigInstanceSchema.extend({
521
521
  integrationType: z.literal(IntegrationType.LINEAR),
522
522
  configType: z.literal(ConfigType.LINEAR_OUTPUT),
523
- teamId: z.string().optional(),
524
- teamName: z.string().optional(),
525
- projectId: z.string().optional(),
526
- projectName: z.string().optional()
523
+ teamId: z.string().nullable(),
524
+ teamName: z.string().nullable(),
525
+ projectId: z.string().nullable(),
526
+ projectName: z.string().nullable()
527
527
  });
528
528
  export class LinearOutputConfig extends BaseConfigInstance {
529
529
  teamId;
530
530
  teamName;
531
531
  projectId;
532
532
  projectName;
533
- constructor(integrationId, teamId, teamName, projectId, projectName) {
533
+ constructor(integrationId, teamId = null, teamName = null, projectId = null, projectName = null) {
534
534
  super(integrationId, IntegrationType.LINEAR, ConfigType.LINEAR_OUTPUT);
535
535
  this.teamId = teamId;
536
536
  this.teamName = teamName;
@@ -560,13 +560,13 @@ export class LinearOutputConfig extends BaseConfigInstance {
560
560
  export const GitHubConfigSchema = ConfigInstanceSchema.extend({
561
561
  integrationType: z.literal(IntegrationType.GITHUB),
562
562
  configType: z.literal(ConfigType.GITHUB),
563
- repositoryIds: z.array(z.number()),
564
- eventTypes: z.array(z.enum(GitHubEventType)).optional()
563
+ repositoryIds: z.array(z.number().int()),
564
+ eventTypes: z.array(z.enum(GitHubEventType)).nullable()
565
565
  });
566
566
  export class GitHubConfig extends BaseConfigInstance {
567
567
  repositoryIds;
568
568
  eventTypes;
569
- constructor(integrationId, repositoryIds, eventTypes) {
569
+ constructor(integrationId, repositoryIds, eventTypes = null) {
570
570
  super(integrationId, IntegrationType.GITHUB, ConfigType.GITHUB);
571
571
  this.repositoryIds = repositoryIds;
572
572
  this.eventTypes = eventTypes;
@@ -585,15 +585,15 @@ export class GitHubConfig extends BaseConfigInstance {
585
585
  export const JiraConfigSchema = ConfigInstanceSchema.extend({
586
586
  integrationType: z.literal(IntegrationType.ATLASSIAN),
587
587
  configType: z.literal(ConfigType.JIRA),
588
- projectKey: z.string().optional(),
589
- projectId: z.string().optional(),
590
- eventTypes: z.array(z.enum(JiraEventType)).optional()
588
+ projectKey: z.string().nullable(),
589
+ projectId: z.string().nullable(),
590
+ eventTypes: z.array(z.enum(JiraEventType)).nullable()
591
591
  });
592
592
  export class JiraConfig extends BaseConfigInstance {
593
593
  projectKey;
594
594
  projectId;
595
595
  eventTypes;
596
- constructor(integrationId, projectKey, projectId, eventTypes) {
596
+ constructor(integrationId, projectKey = null, projectId = null, eventTypes = null) {
597
597
  super(integrationId, IntegrationType.ATLASSIAN, ConfigType.JIRA);
598
598
  this.projectKey = projectKey;
599
599
  this.projectId = projectId;
@@ -658,12 +658,12 @@ export const PosthogConfigSchema = ConfigInstanceSchema.extend({
658
658
  integrationType: z.literal(IntegrationType.POSTHOG),
659
659
  configType: z.literal(ConfigType.POSTHOG),
660
660
  projectId: z.string(),
661
- projectName: z.string().optional()
661
+ projectName: z.string().nullable()
662
662
  });
663
663
  export class PosthogConfig extends BaseConfigInstance {
664
664
  projectId;
665
665
  projectName;
666
- constructor(integrationId, projectId, projectName) {
666
+ constructor(integrationId, projectId, projectName = null) {
667
667
  super(integrationId, IntegrationType.POSTHOG, ConfigType.POSTHOG);
668
668
  this.projectId = projectId;
669
669
  this.projectName = projectName;
@@ -808,11 +808,11 @@ export class WorkOSOutputConfig extends BaseConfigInstance {
808
808
  export const AttioOutputConfigSchema = ConfigInstanceSchema.extend({
809
809
  integrationType: z.literal(IntegrationType.ATTIO),
810
810
  configType: z.literal(ConfigType.ATTIO_OUTPUT),
811
- objectSlug: z.string().optional()
811
+ objectSlug: z.string().nullable()
812
812
  });
813
813
  export class AttioOutputConfig extends BaseConfigInstance {
814
814
  objectSlug;
815
- constructor(integrationId, objectSlug) {
815
+ constructor(integrationId, objectSlug = null) {
816
816
  super(integrationId, IntegrationType.ATTIO, ConfigType.ATTIO_OUTPUT);
817
817
  this.objectSlug = objectSlug;
818
818
  }
@@ -843,6 +843,228 @@ export class SnowflakeOutputConfig extends BaseConfigInstance {
843
843
  return parts.join("\n");
844
844
  }
845
845
  }
846
+ export const configDataSchema = z.union([
847
+ GmailConfigSchema,
848
+ FigmaConfigSchema,
849
+ SlackConfigSchema,
850
+ SlackOutputConfigSchema,
851
+ GmailOutputConfigSchema,
852
+ GmailDraftOutputConfigSchema,
853
+ NotionConfigSchema,
854
+ LinearInputConfigSchema,
855
+ LinearOutputConfigSchema,
856
+ GitHubConfigSchema,
857
+ JiraConfigSchema,
858
+ ConfluenceConfigSchema,
859
+ PosthogConfigSchema,
860
+ DatadogConfigSchema,
861
+ TimeTriggerConfigSchema,
862
+ LaunchDarklyConfigSchema,
863
+ TerseConfigSchema,
864
+ WorkOSInputConfigSchema,
865
+ WorkOSOutputConfigSchema,
866
+ AttioOutputConfigSchema,
867
+ SnowflakeOutputConfigSchema
868
+ ]);
869
+ export function isConfigComplete(config) {
870
+ if (!config) {
871
+ return false;
872
+ }
873
+ switch (config.configType) {
874
+ case ConfigType.GMAIL:
875
+ case ConfigType.GMAIL_OUTPUT:
876
+ case ConfigType.GMAIL_DRAFT_OUTPUT:
877
+ case ConfigType.LINEAR_INPUT:
878
+ case ConfigType.JIRA:
879
+ case ConfigType.CONFLUENCE:
880
+ case ConfigType.TERSE:
881
+ return true;
882
+ case ConfigType.FIGMA:
883
+ return !!(config.fileKey && config.teamId);
884
+ case ConfigType.SLACK:
885
+ return !!(config.channelId || config.listenToUserDms);
886
+ case ConfigType.SLACK_OUTPUT:
887
+ return !!(config.channelId || (config.userIds?.length ?? 0) > 0 || config.listenToUserDms);
888
+ case ConfigType.NOTION:
889
+ return (config.databaseIds?.length ?? 0) > 0 || (config.pageIds?.length ?? 0) > 0;
890
+ case ConfigType.LINEAR_OUTPUT:
891
+ case ConfigType.DATADOG:
892
+ case ConfigType.WORKOS_OUTPUT:
893
+ case ConfigType.SNOWFLAKE_OUTPUT:
894
+ return !!config.integrationId;
895
+ case ConfigType.GITHUB:
896
+ return (config.repositoryIds?.length ?? 0) > 0;
897
+ case ConfigType.POSTHOG:
898
+ return !!config.projectId;
899
+ case ConfigType.TIME_TRIGGER:
900
+ return !!config.cronExpression;
901
+ case ConfigType.LAUNCHDARKLY:
902
+ return !!(config.projectKey && config.environmentKeys.length > 0);
903
+ case ConfigType.WORKOS_INPUT:
904
+ return config.eventTypes.length > 0;
905
+ case ConfigType.ATTIO_OUTPUT:
906
+ return !!config.objectSlug;
907
+ default:
908
+ const _exhaustive = config;
909
+ return _exhaustive;
910
+ }
911
+ }
912
+ export function formatConfigForAgent(config) {
913
+ switch (config.configType) {
914
+ case ConfigType.GMAIL:
915
+ return `Type: Gmail\nIntegration ID: ${config.integrationId}`;
916
+ case ConfigType.FIGMA: {
917
+ const parts = [`Type: Figma`, `Integration ID: ${config.integrationId}`];
918
+ if (config.fileName)
919
+ parts.push(`File: ${config.fileName}`);
920
+ if (config.fileKey)
921
+ parts.push(`File Key: ${config.fileKey}`);
922
+ return parts.join("\n");
923
+ }
924
+ case ConfigType.SLACK: {
925
+ const parts = [`Type: Slack`, `Integration ID: ${config.integrationId}`];
926
+ if (config.channelName) {
927
+ parts.push(`Channel: ${config.channelName}`);
928
+ }
929
+ else if (config.channelId) {
930
+ parts.push(`Channel ID: ${config.channelId}`);
931
+ }
932
+ if (config.listenToUserDms)
933
+ parts.push(`Listening to user DMs: Yes`);
934
+ if (config.userIds)
935
+ parts.push(`Users: ${config.userIds.join(", ")}`);
936
+ return parts.join("\n");
937
+ }
938
+ case ConfigType.SLACK_OUTPUT: {
939
+ const parts = [`Type: Slack Output`, `Integration ID: ${config.integrationId}`];
940
+ if (config.channelId)
941
+ parts.push(`Channel ID: ${config.channelId}`);
942
+ if (config.listenToUserDms)
943
+ parts.push(`Listen to user DMs: Yes`);
944
+ if (config.userIds?.length)
945
+ parts.push(`DM user IDs: ${config.userIds.join(", ")}`);
946
+ return parts.join("\n");
947
+ }
948
+ case ConfigType.GMAIL_OUTPUT:
949
+ return `Type: Gmail Output\nIntegration ID: ${config.integrationId}`;
950
+ case ConfigType.GMAIL_DRAFT_OUTPUT:
951
+ return `Type: Gmail Draft Output\nIntegration ID: ${config.integrationId}`;
952
+ case ConfigType.NOTION: {
953
+ const parts = [`Type: Notion`, `Integration ID: ${config.integrationId}`];
954
+ const dbIds = config.databaseIds ?? [];
955
+ const dbNames = config.databaseNames ?? [];
956
+ if (dbIds.length > 0) {
957
+ parts.push(`Databases: ${dbIds.map((id, i) => dbNames[i] || id).join(", ")}`);
958
+ }
959
+ const pageIds = config.pageIds ?? [];
960
+ const pageNames = config.pageNames ?? [];
961
+ if (pageIds.length > 0) {
962
+ parts.push(`Pages: ${pageIds.map((id, i) => pageNames[i] || id).join(", ")}`);
963
+ }
964
+ return parts.join("\n");
965
+ }
966
+ case ConfigType.LINEAR_INPUT: {
967
+ const parts = [`Type: Linear`, `Integration ID: ${config.integrationId}`];
968
+ if (config.projectName) {
969
+ parts.push(`Project: ${config.projectName}`);
970
+ }
971
+ else if (config.projectId) {
972
+ parts.push(`Project ID: ${config.projectId}`);
973
+ }
974
+ return parts.join("\n");
975
+ }
976
+ case ConfigType.LINEAR_OUTPUT: {
977
+ const parts = [`Type: Linear`, `Integration ID: ${config.integrationId}`];
978
+ if (config.teamName) {
979
+ parts.push(`Team: ${config.teamName}`);
980
+ }
981
+ else if (config.teamId) {
982
+ parts.push(`Team ID: ${config.teamId}`);
983
+ }
984
+ if (config.projectName) {
985
+ parts.push(`Project: ${config.projectName}`);
986
+ }
987
+ else if (config.projectId) {
988
+ parts.push(`Project ID: ${config.projectId}`);
989
+ }
990
+ return parts.join("\n");
991
+ }
992
+ case ConfigType.GITHUB: {
993
+ const parts = [`Type: GitHub`, `Integration ID: ${config.integrationId}`];
994
+ if (config.repositoryIds.length > 0)
995
+ parts.push(`Repositories: ${config.repositoryIds.join(", ")}`);
996
+ return parts.join("\n");
997
+ }
998
+ case ConfigType.JIRA: {
999
+ const parts = [`Type: Jira`, `Integration ID: ${config.integrationId}`];
1000
+ if (config.projectKey) {
1001
+ parts.push(`Project Key: ${config.projectKey}`);
1002
+ }
1003
+ else if (config.projectId) {
1004
+ parts.push(`Project ID: ${config.projectId}`);
1005
+ }
1006
+ return parts.join("\n");
1007
+ }
1008
+ case ConfigType.CONFLUENCE: {
1009
+ const parts = [`Type: Confluence`, `Integration ID: ${config.integrationId}`];
1010
+ if (config.spaceName)
1011
+ parts.push(`Space: ${config.spaceName}`);
1012
+ if (config.pageName) {
1013
+ parts.push(`Page: ${config.pageName}`);
1014
+ }
1015
+ else if (config.pageId) {
1016
+ parts.push(`Page ID: ${config.pageId}`);
1017
+ }
1018
+ return parts.join("\n");
1019
+ }
1020
+ case ConfigType.POSTHOG: {
1021
+ const parts = [`Type: Posthog`, `Integration ID: ${config.integrationId}`];
1022
+ if (config.projectId)
1023
+ parts.push(`Project ID: ${config.projectId}`);
1024
+ if (config.projectName)
1025
+ parts.push(`Project: ${config.projectName}`);
1026
+ return parts.join("\n");
1027
+ }
1028
+ case ConfigType.DATADOG: {
1029
+ const parts = [`Type: Datadog`, `Integration ID: ${config.integrationId}`];
1030
+ if (config.defaultIndexes?.length)
1031
+ parts.push(`Default indexes: ${config.defaultIndexes.join(", ")}`);
1032
+ return parts.join("\n");
1033
+ }
1034
+ case ConfigType.TIME_TRIGGER: {
1035
+ const parts = [`Type: Time Trigger`];
1036
+ if (config.cronExpression)
1037
+ parts.push(`Schedule (UTC): ${config.cronExpression}`);
1038
+ return parts.join("\n");
1039
+ }
1040
+ case ConfigType.LAUNCHDARKLY: {
1041
+ const parts = [`Type: LaunchDarkly`, `Integration ID: ${config.integrationId}`];
1042
+ if (config.projectKey)
1043
+ parts.push(`Project Key: ${config.projectKey}`);
1044
+ if (config.environmentKeys.length > 0)
1045
+ parts.push(`Environments: ${config.environmentKeys.join(", ")}`);
1046
+ return parts.join("\n");
1047
+ }
1048
+ case ConfigType.TERSE:
1049
+ return "Type: Terse Skills";
1050
+ case ConfigType.WORKOS_INPUT:
1051
+ return `Type: WorkOS Events\nListening for: ${config.eventTypes.join(", ")}`;
1052
+ case ConfigType.WORKOS_OUTPUT:
1053
+ return `Type: WorkOS Skill\nIntegration ID: ${config.integrationId}`;
1054
+ case ConfigType.ATTIO_OUTPUT: {
1055
+ const parts = [`Type: Attio Output`, `Integration ID: ${config.integrationId}`];
1056
+ if (config.objectSlug)
1057
+ parts.push(`Object: ${config.objectSlug}`);
1058
+ return parts.join("\n");
1059
+ }
1060
+ case ConfigType.SNOWFLAKE_OUTPUT:
1061
+ return `Type: Snowflake Output\nIntegration ID: ${config.integrationId}`;
1062
+ default: {
1063
+ const _exhaustive = config;
1064
+ return _exhaustive;
1065
+ }
1066
+ }
1067
+ }
846
1068
  export const CONFIG_METADATA = {
847
1069
  [ConfigType.GMAIL]: GmailConfig,
848
1070
  [ConfigType.GMAIL_OUTPUT]: GmailOutputConfig,
@@ -173,7 +173,7 @@ export const AtlassianIntegrationSchema = IntegrationInstanceSchema.extend({
173
173
  projectName: z.string().optional()
174
174
  });
175
175
  export const GithubIntegrationSchema = IntegrationInstanceSchema.extend({
176
- installation_id: z.number(),
176
+ installation_id: z.number().int(),
177
177
  account_name: z.string().optional()
178
178
  });
179
179
  export const LinearIntegrationSchema = IntegrationInstanceSchema.extend({