@shipfox/api-integration-core-dto 12.0.0 → 12.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.
@@ -6,14 +6,14 @@ export declare const WEBHOOK_MAX_HEADER_BYTES: number;
6
6
  export declare const WEBHOOK_MAX_RAW_QUERY_STRING_LENGTH: number;
7
7
  export declare const webhookRouteIds: readonly ["github", "gitea", "linear", "sentry", "slack.event", "slack.command", "webhook.connection", "jira"];
8
8
  export declare const webhookRouteIdSchema: z.ZodEnum<{
9
- github: "github";
10
9
  gitea: "gitea";
10
+ github: "github";
11
+ jira: "jira";
11
12
  linear: "linear";
12
13
  sentry: "sentry";
13
- "slack.event": "slack.event";
14
14
  "slack.command": "slack.command";
15
+ "slack.event": "slack.event";
15
16
  "webhook.connection": "webhook.connection";
16
- jira: "jira";
17
17
  }>;
18
18
  export type WebhookRouteId = z.infer<typeof webhookRouteIdSchema>;
19
19
  declare const webhookBodySchema: z.ZodObject<{
@@ -32,12 +32,12 @@ export declare const storedWebhookRequestSchema: z.ZodDiscriminatedUnion<[z.ZodO
32
32
  data: z.ZodString;
33
33
  }, z.core.$strict>;
34
34
  route_id: z.ZodEnum<{
35
- github: "github";
36
35
  gitea: "gitea";
36
+ github: "github";
37
37
  linear: "linear";
38
38
  sentry: "sentry";
39
- "slack.event": "slack.event";
40
39
  "slack.command": "slack.command";
40
+ "slack.event": "slack.event";
41
41
  }>;
42
42
  path_parameters: z.ZodObject<{}, z.core.$strict>;
43
43
  }, z.core.$strict>, z.ZodObject<{
@@ -82,12 +82,12 @@ export declare const webhookProcessingResultSchema: z.ZodDiscriminatedUnion<[z.Z
82
82
  }, z.core.$strict>, z.ZodObject<{
83
83
  outcome: z.ZodLiteral<"discarded">;
84
84
  reason: z.ZodEnum<{
85
- missing_required_input: "missing_required_input";
85
+ connection_unavailable: "connection_unavailable";
86
86
  invalid_signature: "invalid_signature";
87
- stale_at_receipt: "stale_at_receipt";
88
87
  malformed_payload: "malformed_payload";
88
+ missing_required_input: "missing_required_input";
89
+ stale_at_receipt: "stale_at_receipt";
89
90
  unsupported_event: "unsupported_event";
90
- connection_unavailable: "connection_unavailable";
91
91
  }>;
92
92
  deliveryId: z.ZodOptional<z.ZodString>;
93
93
  }, z.core.$strict>], "outcome">;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipfox/api-integration-core-dto",
3
3
  "license": "MIT",
4
- "version": "12.0.0",
4
+ "version": "12.2.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ShipfoxHQ/shipfox.git",
@@ -1,13 +1,22 @@
1
1
  import {
2
+ INTEGRATION_CONNECTION_AVAILABLE,
2
3
  INTEGRATION_EVENT_RECEIVED,
3
4
  INTEGRATION_SOURCE_COMMIT_PUSHED,
4
5
  INTEGRATION_SOURCE_REPOSITORY_UPDATED,
6
+ integrationConnectionAvailableSchema,
5
7
  integrationEventReceivedSchema,
6
8
  integrationSourceCommitPushedSchema,
7
9
  integrationSourceRepositoryUpdatedSchema,
8
10
  integrationsEventSchemas,
9
11
  } from './events.js';
10
12
 
13
+ const validConnectionAvailable = {
14
+ provider: 'linear',
15
+ workspaceId: 'ws-1',
16
+ connectionId: 'conn-1',
17
+ slug: 'linear_shipfox',
18
+ };
19
+
11
20
  const validEventReceived = {
12
21
  provider: 'github',
13
22
  source: 'github',
@@ -49,6 +58,20 @@ const validRepositoryUpdated = {
49
58
  },
50
59
  };
51
60
 
61
+ describe('integrationConnectionAvailableSchema', () => {
62
+ it('parses a valid connection-available payload unchanged', () => {
63
+ expect(integrationConnectionAvailableSchema.parse(validConnectionAvailable)).toEqual(
64
+ validConnectionAvailable,
65
+ );
66
+ });
67
+
68
+ it('rejects a payload without a connection slug', () => {
69
+ const {slug: _slug, ...withoutSlug} = validConnectionAvailable;
70
+
71
+ expect(() => integrationConnectionAvailableSchema.parse(withoutSlug)).toThrow();
72
+ });
73
+ });
74
+
52
75
  describe('integrationSourceCommitPushedSchema', () => {
53
76
  it('parses a valid commit-pushed payload unchanged', () => {
54
77
  const result = integrationSourceCommitPushedSchema.parse(validCommitPushed);
@@ -136,6 +159,7 @@ describe('integrationsEventSchemas', () => {
136
159
 
137
160
  expect(registeredTypes).toEqual(
138
161
  [
162
+ INTEGRATION_CONNECTION_AVAILABLE,
139
163
  INTEGRATION_EVENT_RECEIVED,
140
164
  INTEGRATION_SOURCE_COMMIT_PUSHED,
141
165
  INTEGRATION_SOURCE_REPOSITORY_UPDATED,
package/src/events.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import {z} from 'zod';
2
2
 
3
3
  export const INTEGRATION_EVENT_RECEIVED = 'integrations.event.received' as const;
4
+ export const INTEGRATION_CONNECTION_AVAILABLE = 'integrations.connection.available' as const;
4
5
 
5
6
  const nonEmptyStringSchema = z.string().nonempty();
6
7
  const isoDateTimeSchema = z.string().datetime();
@@ -22,6 +23,16 @@ export const integrationEventReceivedSchema = z.object({
22
23
  });
23
24
  export type IntegrationEventReceivedEvent = z.infer<typeof integrationEventReceivedSchema>;
24
25
 
26
+ export const integrationConnectionAvailableSchema = z.object({
27
+ provider: nonEmptyStringSchema,
28
+ workspaceId: nonEmptyStringSchema,
29
+ connectionId: nonEmptyStringSchema,
30
+ slug: nonEmptyStringSchema,
31
+ });
32
+ export type IntegrationConnectionAvailableEvent = z.infer<
33
+ typeof integrationConnectionAvailableSchema
34
+ >;
35
+
25
36
  // A source-control push, normalized by the producing provider and carried by
26
37
  // `INTEGRATION_SOURCE_COMMIT_PUSHED` for domain consumers.
27
38
  export const sourcePushSchema = z.object({
@@ -107,12 +118,14 @@ export const SENTRY_ISSUE_ACTIONS = [
107
118
  export type SentryIssueAction = (typeof SENTRY_ISSUE_ACTIONS)[number];
108
119
 
109
120
  export interface IntegrationsEventMap {
121
+ [INTEGRATION_CONNECTION_AVAILABLE]: IntegrationConnectionAvailableEvent;
110
122
  [INTEGRATION_EVENT_RECEIVED]: IntegrationEventReceivedEvent;
111
123
  [INTEGRATION_SOURCE_COMMIT_PUSHED]: IntegrationSourceCommitPushedEvent;
112
124
  [INTEGRATION_SOURCE_REPOSITORY_UPDATED]: IntegrationSourceRepositoryUpdatedEvent;
113
125
  }
114
126
 
115
127
  export const integrationsEventSchemas = {
128
+ [INTEGRATION_CONNECTION_AVAILABLE]: integrationConnectionAvailableSchema,
116
129
  [INTEGRATION_EVENT_RECEIVED]: integrationEventReceivedSchema,
117
130
  [INTEGRATION_SOURCE_COMMIT_PUSHED]: integrationSourceCommitPushedSchema,
118
131
  [INTEGRATION_SOURCE_REPOSITORY_UPDATED]: integrationSourceRepositoryUpdatedSchema,