@primitivedotdev/sdk 0.7.0 → 0.9.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.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,12 @@
1
- import { AuthConfidence$1 as AuthConfidence, AuthVerdict$1 as AuthVerdict, DkimResult$1 as DkimResult, DkimSignature, DmarcPolicy$1 as DmarcPolicy, DmarcResult$1 as DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType$1 as EventType, ForwardAnalysis, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict$1 as ForwardVerdict, ForwardVerification, KnownWebhookEvent, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus$1 as ParsedStatus, RawContent, RawContentDownloadOnly, RawContentInline, SpfResult$1 as SpfResult, UnknownEvent, ValidateEmailAuthResult, WebhookAttachment, WebhookEvent } from "./types-CKFmgitP.js";
2
- import { DecodeRawEmailOptions, GenerateDownloadTokenOptions, HandleWebhookOptions, LEGACY_CONFIRMED_HEADER$1 as LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER$1 as LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS$1 as PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER$1 as PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER$1 as PRIMITIVE_SIGNATURE_HEADER, PrimitiveWebhookError$1 as PrimitiveWebhookError, RAW_EMAIL_ERRORS$1 as RAW_EMAIL_ERRORS, RawEmailDecodeError$1 as RawEmailDecodeError, RawEmailDecodeErrorCode, STANDARD_WEBHOOK_ID_HEADER$1 as STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER$1 as STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER$1 as STANDARD_WEBHOOK_TIMESTAMP_HEADER, SignResult, StandardWebhooksSignResult, StandardWebhooksVerifyOptions, VERIFICATION_ERRORS$1 as VERIFICATION_ERRORS, VerifyDownloadTokenOptions, VerifyDownloadTokenResult, VerifyOptions, WEBHOOK_VERSION$1 as WEBHOOK_VERSION, WebhookErrorCode, WebhookHeaders, WebhookPayloadError$1 as WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError$1 as WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError$1 as WebhookVerificationError, WebhookVerificationErrorCode, confirmedHeaders$1 as confirmedHeaders, decodeRawEmail$1 as decodeRawEmail, emailReceivedEventJsonSchema$1 as emailReceivedEventJsonSchema, generateDownloadToken$1 as generateDownloadToken, getDownloadTimeRemaining$1 as getDownloadTimeRemaining, handleWebhook$1 as handleWebhook, isDownloadExpired$1 as isDownloadExpired, isEmailReceivedEvent$1 as isEmailReceivedEvent, isRawIncluded$1 as isRawIncluded, parseWebhookEvent$1 as parseWebhookEvent, safeValidateEmailReceivedEvent$1 as safeValidateEmailReceivedEvent, signStandardWebhooksPayload$1 as signStandardWebhooksPayload, signWebhookPayload$1 as signWebhookPayload, validateEmailAuth$1 as validateEmailAuth, validateEmailReceivedEvent$1 as validateEmailReceivedEvent, verifyDownloadToken$1 as verifyDownloadToken, verifyRawEmailDownload$1 as verifyRawEmailDownload, verifyStandardWebhooksSignature$1 as verifyStandardWebhooksSignature, verifyWebhookSignature$1 as verifyWebhookSignature } from "./index-DLmAI4UQ.js";
3
- export { AuthConfidence, AuthVerdict, DecodeRawEmailOptions, DkimResult, DkimSignature, DmarcPolicy, DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType, ForwardAnalysis, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict, ForwardVerification, GenerateDownloadTokenOptions, HandleWebhookOptions, KnownWebhookEvent, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawContent, RawContentDownloadOnly, RawContentInline, RawEmailDecodeError, RawEmailDecodeErrorCode, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, SignResult, SpfResult, StandardWebhooksSignResult, StandardWebhooksVerifyOptions, UnknownEvent, VERIFICATION_ERRORS, ValidateEmailAuthResult, VerifyDownloadTokenOptions, VerifyDownloadTokenResult, VerifyOptions, WEBHOOK_VERSION, WebhookAttachment, WebhookErrorCode, WebhookEvent, WebhookHeaders, WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError, WebhookVerificationErrorCode, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
1
+ import { A as UnknownEvent, C as ParsedDataFailed, D as RawContentDownloadOnly, E as RawContent, M as WebhookAttachment, N as WebhookEvent, O as RawContentInline, S as ParsedDataComplete, T as ParsedStatus, _ as ForwardResultInline, a as DmarcPolicy, b as KnownWebhookEvent, c as EmailAnalysis, d as EventType, f as ForwardAnalysis, g as ForwardResultAttachmentSkipped, h as ForwardResultAttachmentAnalyzed, i as DkimSignature, j as ValidateEmailAuthResult, k as SpfResult, l as EmailAuth, m as ForwardResult, n as AuthVerdict, o as DmarcResult, p as ForwardOriginalSender, r as DkimResult, s as EmailAddress, t as AuthConfidence, u as EmailReceivedEvent, v as ForwardVerdict, w as ParsedError, x as ParsedData, y as ForwardVerification } from "./types-9vXGZjPd.js";
2
+ import { a as buildReplySubject, c as parseHeaderAddress, i as buildForwardSubject, n as ReceivedEmailAddress, o as formatAddress, r as ReceivedEmailThread, s as normalizeReceivedEmail, t as ReceivedEmail } from "./received-email-DNjpq_Wt.js";
3
+ import { a as PrimitiveApiError, c as PrimitiveClientOptions, d as SendResult, f as SendThreadInput, h as createPrimitiveClient, l as ReplyInput, n as ForwardInput, p as client, s as PrimitiveClient, u as SendInput } from "./index-DVow4Fjd.js";
4
+ import { A as VerifyOptions, B as PAYLOAD_ERRORS, C as signStandardWebhooksPayload, D as PRIMITIVE_CONFIRMED_HEADER, E as LEGACY_SIGNATURE_HEADER, F as VerifyDownloadTokenResult, G as VERIFICATION_ERRORS, H as RAW_EMAIL_ERRORS, I as generateDownloadToken, J as WebhookPayloadErrorCode, K as WebhookErrorCode, L as verifyDownloadToken, M as verifyWebhookSignature, N as GenerateDownloadTokenOptions, O as PRIMITIVE_SIGNATURE_HEADER, P as VerifyDownloadTokenOptions, Q as WebhookVerificationErrorCode, R as safeValidateEmailReceivedEvent, S as StandardWebhooksVerifyOptions, T as LEGACY_CONFIRMED_HEADER, U as RawEmailDecodeError, V as PrimitiveWebhookError, W as RawEmailDecodeErrorCode, X as WebhookValidationErrorCode, Y as WebhookValidationError, Z as WebhookVerificationError, _ as emailReceivedEventJsonSchema, a as confirmedHeaders, b as STANDARD_WEBHOOK_TIMESTAMP_HEADER, c as handleWebhook, d as isRawIncluded, f as parseWebhookEvent, g as validateEmailAuth, h as WEBHOOK_VERSION, i as WebhookHeaders, j as signWebhookPayload, k as SignResult, l as isDownloadExpired, m as verifyRawEmailDownload, n as HandleWebhookOptions, o as decodeRawEmail, p as receive, q as WebhookPayloadError, r as ReceiveRequestOptions, s as getDownloadTimeRemaining, t as DecodeRawEmailOptions, u as isEmailReceivedEvent, v as STANDARD_WEBHOOK_ID_HEADER, w as verifyStandardWebhooksSignature, x as StandardWebhooksSignResult, y as STANDARD_WEBHOOK_SIGNATURE_HEADER, z as validateEmailReceivedEvent } from "./index-CbEivn3S.js";
5
+
6
+ //#region src/index.d.ts
7
+ declare const primitive: {
8
+ client: typeof client;
9
+ receive: typeof receive;
10
+ };
11
+ //#endregion
12
+ export { AuthConfidence, AuthVerdict, DecodeRawEmailOptions, DkimResult, DkimSignature, DmarcPolicy, DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType, ForwardAnalysis, type ForwardInput, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict, ForwardVerification, GenerateDownloadTokenOptions, HandleWebhookOptions, KnownWebhookEvent, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus, PrimitiveApiError, PrimitiveClient, type PrimitiveClientOptions, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawContent, RawContentDownloadOnly, RawContentInline, RawEmailDecodeError, RawEmailDecodeErrorCode, ReceiveRequestOptions, ReceivedEmail, ReceivedEmailAddress, ReceivedEmailThread, type ReplyInput, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, type SendInput, type SendResult, type SendThreadInput, SignResult, SpfResult, StandardWebhooksSignResult, StandardWebhooksVerifyOptions, UnknownEvent, VERIFICATION_ERRORS, ValidateEmailAuthResult, VerifyDownloadTokenOptions, VerifyDownloadTokenResult, VerifyOptions, WEBHOOK_VERSION, WebhookAttachment, WebhookErrorCode, WebhookEvent, WebhookHeaders, WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError, WebhookVerificationErrorCode, buildForwardSubject, buildReplySubject, client, confirmedHeaders, createPrimitiveClient, decodeRawEmail, primitive as default, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -1,3 +1,10 @@
1
- import { AuthConfidence, AuthVerdict, DkimResult, DmarcPolicy, DmarcResult, EventType, ForwardVerdict, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedStatus, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawEmailDecodeError, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, SpfResult, VERIFICATION_ERRORS, WEBHOOK_VERSION, WebhookPayloadError, WebhookValidationError, WebhookVerificationError, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature } from "./webhook-COe5N_Uj.js";
2
-
3
- export { AuthConfidence, AuthVerdict, DkimResult, DmarcPolicy, DmarcResult, EventType, ForwardVerdict, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedStatus, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawEmailDecodeError, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, SpfResult, VERIFICATION_ERRORS, WEBHOOK_VERSION, WebhookPayloadError, WebhookValidationError, WebhookVerificationError, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
1
+ import { a as parseHeaderAddress, i as normalizeReceivedEmail, n as buildReplySubject, r as formatAddress, t as buildForwardSubject } from "./received-email-D6tKtWwW.js";
2
+ import { a as client, i as PrimitiveClient, r as PrimitiveApiError, s as createPrimitiveClient } from "./api-COSr-Fqm.js";
3
+ import { A as PRIMITIVE_CONFIRMED_HEADER, B as RAW_EMAIL_ERRORS, C as STANDARD_WEBHOOK_ID_HEADER, D as verifyStandardWebhooksSignature, E as signStandardWebhooksPayload, F as verifyDownloadToken, G as WebhookVerificationError, H as VERIFICATION_ERRORS, I as safeValidateEmailReceivedEvent, L as validateEmailReceivedEvent, M as signWebhookPayload, N as verifyWebhookSignature, O as LEGACY_CONFIRMED_HEADER, P as generateDownloadToken, R as PAYLOAD_ERRORS, S as emailReceivedEventJsonSchema, T as STANDARD_WEBHOOK_TIMESTAMP_HEADER, U as WebhookPayloadError, V as RawEmailDecodeError, W as WebhookValidationError, _ as DmarcResult, a as isDownloadExpired, b as ParsedStatus, c as parseWebhookEvent, d as WEBHOOK_VERSION, f as validateEmailAuth, g as DmarcPolicy, h as DkimResult, i as handleWebhook, j as PRIMITIVE_SIGNATURE_HEADER, k as LEGACY_SIGNATURE_HEADER, l as receive, m as AuthVerdict, n as decodeRawEmail, o as isEmailReceivedEvent, p as AuthConfidence, r as getDownloadTimeRemaining, s as isRawIncluded, t as confirmedHeaders, u as verifyRawEmailDownload, v as EventType, w as STANDARD_WEBHOOK_SIGNATURE_HEADER, x as SpfResult, y as ForwardVerdict, z as PrimitiveWebhookError } from "./webhook-zkN4wUTs.js";
4
+ //#region src/index.ts
5
+ const primitive = {
6
+ client,
7
+ receive
8
+ };
9
+ //#endregion
10
+ export { AuthConfidence, AuthVerdict, DkimResult, DmarcPolicy, DmarcResult, EventType, ForwardVerdict, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedStatus, PrimitiveApiError, PrimitiveClient, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawEmailDecodeError, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, SpfResult, VERIFICATION_ERRORS, WEBHOOK_VERSION, WebhookPayloadError, WebhookValidationError, WebhookVerificationError, buildForwardSubject, buildReplySubject, client, confirmedHeaders, createPrimitiveClient, decodeRawEmail, primitive as default, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
@@ -7,6 +7,82 @@ function flagName(parameterName) {
7
7
  function flagDescription(parameter) {
8
8
  return parameter.description ?? parameter.name;
9
9
  }
10
+ /**
11
+ * Render a one-shot description of a JSON Schema's top-level
12
+ * properties so an agent reading `<command> --help` can build a
13
+ * valid `--body` payload without probing the server. Pulled from
14
+ * the resolved request schema embedded on the manifest.
15
+ *
16
+ * Format prioritizes scanability over completeness: required
17
+ * fields first, each line is `<name> <type> [- description]`
18
+ * truncated to a reasonable width. Callers who need the full
19
+ * schema can run `primitive list-operations | jq` and read
20
+ * `requestSchema` directly.
21
+ */
22
+ function renderRequestSchemaSummary(schema) {
23
+ if (!schema || typeof schema !== "object")
24
+ return null;
25
+ const properties = schema.properties;
26
+ if (!properties || typeof properties !== "object")
27
+ return null;
28
+ const requiredArr = Array.isArray(schema.required)
29
+ ? schema.required.filter((k) => typeof k === "string")
30
+ : [];
31
+ const required = new Set(requiredArr);
32
+ const entries = Object.entries(properties)
33
+ .map(([name, raw]) => {
34
+ const propSchema = raw && typeof raw === "object" ? raw : {};
35
+ let type = "any";
36
+ const t = propSchema.type;
37
+ if (typeof t === "string") {
38
+ type = t;
39
+ if (type === "array") {
40
+ const items = propSchema.items;
41
+ if (items && typeof items === "object") {
42
+ const itemType = items.type;
43
+ if (typeof itemType === "string") {
44
+ type = `array<${itemType}>`;
45
+ }
46
+ }
47
+ }
48
+ }
49
+ else if (Array.isArray(t)) {
50
+ // Nullable shorthand the codegen normalizes to e.g. ["string","null"].
51
+ const nonNull = t.filter((s) => s !== "null");
52
+ type = nonNull.length === 1 ? `${nonNull[0]}?` : nonNull.join("|");
53
+ }
54
+ const description = typeof propSchema.description === "string"
55
+ ? propSchema.description.split("\n")[0].trim()
56
+ : "";
57
+ return {
58
+ name,
59
+ type,
60
+ description,
61
+ required: required.has(name),
62
+ };
63
+ })
64
+ .sort((a, b) => {
65
+ if (a.required !== b.required)
66
+ return a.required ? -1 : 1;
67
+ return a.name.localeCompare(b.name);
68
+ });
69
+ if (entries.length === 0)
70
+ return null;
71
+ const nameWidth = Math.min(24, Math.max(...entries.map((e) => e.name.length)));
72
+ const lines = ["Body fields (JSON --body):"];
73
+ const descMax = 78;
74
+ for (const e of entries) {
75
+ const flag = e.required ? " *" : " ";
76
+ const padName = e.name.padEnd(nameWidth);
77
+ const trimmedDesc = e.description.length > descMax
78
+ ? `${e.description.slice(0, descMax - 3)}...`
79
+ : e.description;
80
+ const desc = trimmedDesc ? ` ${trimmedDesc}` : "";
81
+ lines.push(`${flag} ${padName} ${e.type}${desc}`);
82
+ }
83
+ lines.push("(* = required)");
84
+ return lines.join("\n");
85
+ }
10
86
  export function flagForParameter(parameter) {
11
87
  const common = {
12
88
  description: flagDescription(parameter),
@@ -159,8 +235,20 @@ function collectValues(parameters, flags) {
159
235
  }
160
236
  export function createOperationCommand(operation) {
161
237
  const flags = buildFlags(operation);
238
+ // Append a "Body fields" summary to the description so agents
239
+ // running `<command> --help` learn the JSON shape immediately.
240
+ // Without this, `--help` only said "JSON request body" and agents
241
+ // had to probe the server with malformed payloads to discover
242
+ // required fields. (CLI agent walkthrough surfaced this.)
243
+ const baseDescription = operation.description ?? `${operation.method} ${operation.path}`;
244
+ const schemaSummary = operation.hasJsonBody
245
+ ? renderRequestSchemaSummary(operation.requestSchema)
246
+ : null;
247
+ const fullDescription = schemaSummary
248
+ ? `${baseDescription}\n\n${schemaSummary}`
249
+ : baseDescription;
162
250
  class OperationCommand extends Command {
163
- static description = operation.description ?? `${operation.method} ${operation.path}`;
251
+ static description = fullDescription;
164
252
  static flags = flags;
165
253
  static summary = operation.summary ?? `${operation.method} ${operation.path}`;
166
254
  async run() {
@@ -6,7 +6,6 @@
6
6
  * Run `pnpm generate:openapi` to regenerate.
7
7
  */
8
8
  declare const openapiDocument: Record<string, unknown>;
9
-
10
9
  //#endregion
11
10
  //#region src/openapi/operations.generated.d.ts
12
11
  /**
@@ -33,10 +32,16 @@ type PrimitiveOperationManifest = {
33
32
  path: string;
34
33
  pathParams: PrimitiveParameterManifest[];
35
34
  queryParams: PrimitiveParameterManifest[];
35
+ /**
36
+ * Resolved JSON Schema for the request body when `hasJsonBody` is
37
+ * true. `$ref`s into the OpenAPI components are inlined.
38
+ */
39
+ requestSchema: Record<string, unknown> | null;
36
40
  sdkName: string;
37
41
  summary: string | null;
38
42
  tag: string;
39
43
  tagCommand: string;
40
44
  };
41
- declare const operationManifest: PrimitiveOperationManifest[]; //#endregion
42
- export { PrimitiveOperationManifest, PrimitiveParameterManifest, openapiDocument, operationManifest };
45
+ declare const operationManifest: PrimitiveOperationManifest[];
46
+ //#endregion
47
+ export { type PrimitiveOperationManifest, type PrimitiveParameterManifest, openapiDocument, operationManifest };
@@ -43,6 +43,10 @@ export const openapiDocument = {
43
43
  "name": "Emails",
44
44
  "description": "List, inspect, and manage received emails"
45
45
  },
46
+ {
47
+ "name": "Sending",
48
+ "description": "Send outbound emails through the Primitive API"
49
+ },
46
50
  {
47
51
  "name": "Endpoints",
48
52
  "description": "Manage webhook endpoints that receive email events"
@@ -1427,6 +1431,85 @@ export const openapiDocument = {
1427
1431
  }
1428
1432
  }
1429
1433
  }
1434
+ },
1435
+ "/send-mail": {
1436
+ "post": {
1437
+ "operationId": "sendEmail",
1438
+ "summary": "Send outbound email",
1439
+ "description": "Sends an outbound email through Primitive's outbound relay. By default\nthe request returns once the relay accepts the message for delivery.\nSet `wait: true` to wait for the first downstream SMTP delivery outcome.\n",
1440
+ "tags": [
1441
+ "Sending"
1442
+ ],
1443
+ "parameters": [
1444
+ {
1445
+ "name": "Idempotency-Key",
1446
+ "in": "header",
1447
+ "required": false,
1448
+ "schema": {
1449
+ "type": "string",
1450
+ "minLength": 1,
1451
+ "maxLength": 255,
1452
+ "pattern": "^[\\x21-\\x7E]+$"
1453
+ },
1454
+ "description": "Optional customer-supplied idempotency key. If omitted, Primitive\nderives one from the canonical request payload and echoes the\neffective value in the `Idempotency-Key` response header.\n"
1455
+ }
1456
+ ],
1457
+ "requestBody": {
1458
+ "required": true,
1459
+ "content": {
1460
+ "application/json": {
1461
+ "schema": {
1462
+ "$ref": "#/components/schemas/SendMailInput"
1463
+ }
1464
+ }
1465
+ }
1466
+ },
1467
+ "responses": {
1468
+ "200": {
1469
+ "description": "Outbound relay result",
1470
+ "content": {
1471
+ "application/json": {
1472
+ "schema": {
1473
+ "allOf": [
1474
+ {
1475
+ "$ref": "#/components/schemas/SuccessEnvelope"
1476
+ },
1477
+ {
1478
+ "type": "object",
1479
+ "properties": {
1480
+ "data": {
1481
+ "$ref": "#/components/schemas/SendMailResult"
1482
+ }
1483
+ }
1484
+ }
1485
+ ]
1486
+ }
1487
+ }
1488
+ }
1489
+ },
1490
+ "400": {
1491
+ "$ref": "#/components/responses/ValidationError"
1492
+ },
1493
+ "401": {
1494
+ "$ref": "#/components/responses/Unauthorized"
1495
+ },
1496
+ "403": {
1497
+ "$ref": "#/components/responses/Forbidden"
1498
+ },
1499
+ "429": {
1500
+ "$ref": "#/components/responses/RateLimited"
1501
+ },
1502
+ "500": {
1503
+ "$ref": "#/components/responses/InternalError"
1504
+ },
1505
+ "502": {
1506
+ "$ref": "#/components/responses/BadGateway"
1507
+ },
1508
+ "503": {
1509
+ "$ref": "#/components/responses/ServiceUnavailable"
1510
+ }
1511
+ }
1512
+ }
1430
1513
  }
1431
1514
  },
1432
1515
  "components": {
@@ -1492,6 +1575,23 @@ export const openapiDocument = {
1492
1575
  }
1493
1576
  }
1494
1577
  },
1578
+ "Forbidden": {
1579
+ "description": "Authenticated caller lacks permission for the operation",
1580
+ "content": {
1581
+ "application/json": {
1582
+ "schema": {
1583
+ "$ref": "#/components/schemas/ErrorResponse"
1584
+ },
1585
+ "example": {
1586
+ "success": false,
1587
+ "error": {
1588
+ "code": "forbidden",
1589
+ "message": "Insufficient permissions"
1590
+ }
1591
+ }
1592
+ }
1593
+ }
1594
+ },
1495
1595
  "NotFound": {
1496
1596
  "description": "Resource not found",
1497
1597
  "content": {
@@ -1551,6 +1651,57 @@ export const openapiDocument = {
1551
1651
  }
1552
1652
  }
1553
1653
  },
1654
+ "BadGateway": {
1655
+ "description": "Primitive could not complete the downstream SMTP request",
1656
+ "content": {
1657
+ "application/json": {
1658
+ "schema": {
1659
+ "$ref": "#/components/schemas/ErrorResponse"
1660
+ },
1661
+ "example": {
1662
+ "success": false,
1663
+ "error": {
1664
+ "code": "outbound_unreachable",
1665
+ "message": "Outbound SMTP service request failed"
1666
+ }
1667
+ }
1668
+ }
1669
+ }
1670
+ },
1671
+ "ServiceUnavailable": {
1672
+ "description": "Primitive is temporarily unable to process the request",
1673
+ "content": {
1674
+ "application/json": {
1675
+ "schema": {
1676
+ "$ref": "#/components/schemas/ErrorResponse"
1677
+ },
1678
+ "example": {
1679
+ "success": false,
1680
+ "error": {
1681
+ "code": "outbound_capacity_exhausted",
1682
+ "message": "Outbound capacity is temporarily exhausted"
1683
+ }
1684
+ }
1685
+ }
1686
+ }
1687
+ },
1688
+ "InternalError": {
1689
+ "description": "Primitive encountered an internal error",
1690
+ "content": {
1691
+ "application/json": {
1692
+ "schema": {
1693
+ "$ref": "#/components/schemas/ErrorResponse"
1694
+ },
1695
+ "example": {
1696
+ "success": false,
1697
+ "error": {
1698
+ "code": "internal_error",
1699
+ "message": "Internal server error"
1700
+ }
1701
+ }
1702
+ }
1703
+ }
1704
+ },
1554
1705
  "Deleted": {
1555
1706
  "description": "Resource deleted",
1556
1707
  "content": {
@@ -1659,7 +1810,16 @@ export const openapiDocument = {
1659
1810
  "rate_limit_exceeded",
1660
1811
  "internal_error",
1661
1812
  "conflict",
1662
- "mx_conflict"
1813
+ "mx_conflict",
1814
+ "outbound_disabled",
1815
+ "cannot_send_from_domain",
1816
+ "recipient_not_allowed",
1817
+ "outbound_key_missing",
1818
+ "outbound_unreachable",
1819
+ "outbound_key_invalid",
1820
+ "outbound_capacity_exhausted",
1821
+ "outbound_response_malformed",
1822
+ "outbound_relay_failed"
1663
1823
  ]
1664
1824
  },
1665
1825
  "message": {
@@ -1687,8 +1847,38 @@ export const openapiDocument = {
1687
1847
  "description": "Subdomain to try instead (e.g. \"mail\" for `mail.example.com`)."
1688
1848
  }
1689
1849
  }
1850
+ },
1851
+ "required_entitlements": {
1852
+ "type": "array",
1853
+ "items": {
1854
+ "type": "string"
1855
+ },
1856
+ "description": "Entitlements that would allow a denied send when no recipient-scope gate was granted."
1857
+ },
1858
+ "sent_email_id": {
1859
+ "type": "string",
1860
+ "description": "ID of the persisted sent-email attempt associated with the error."
1861
+ },
1862
+ "content_hash": {
1863
+ "type": "string",
1864
+ "description": "Content hash of the original request on idempotency cache-hit errors."
1865
+ },
1866
+ "client_idempotency_key": {
1867
+ "type": "string",
1868
+ "description": "Effective idempotency key associated with the original request."
1690
1869
  }
1691
1870
  }
1871
+ },
1872
+ "gates": {
1873
+ "type": "array",
1874
+ "items": {
1875
+ "$ref": "#/components/schemas/GateDenial"
1876
+ },
1877
+ "description": "Structured per-gate denial detail for recipient-scope send-mail failures."
1878
+ },
1879
+ "request_id": {
1880
+ "type": "string",
1881
+ "description": "Server-issued request identifier for support and tracing."
1692
1882
  }
1693
1883
  },
1694
1884
  "required": [
@@ -1702,6 +1892,71 @@ export const openapiDocument = {
1702
1892
  "error"
1703
1893
  ]
1704
1894
  },
1895
+ "GateDenial": {
1896
+ "type": "object",
1897
+ "properties": {
1898
+ "name": {
1899
+ "type": "string",
1900
+ "enum": [
1901
+ "send_to_confirmed_domains",
1902
+ "send_to_known_addresses"
1903
+ ],
1904
+ "description": "Public recipient-scope gate name that denied the send."
1905
+ },
1906
+ "reason": {
1907
+ "type": "string",
1908
+ "enum": [
1909
+ "domain_not_confirmed",
1910
+ "recipient_unauthenticated",
1911
+ "recipient_not_known"
1912
+ ],
1913
+ "description": "Stable machine-readable denial reason."
1914
+ },
1915
+ "message": {
1916
+ "type": "string",
1917
+ "description": "Human-readable explanation of the gate denial."
1918
+ },
1919
+ "subject": {
1920
+ "type": "string",
1921
+ "description": "Domain or address the gate evaluated."
1922
+ },
1923
+ "fix": {
1924
+ "$ref": "#/components/schemas/GateFix"
1925
+ },
1926
+ "docs_url": {
1927
+ "type": "string",
1928
+ "description": "Public docs URL with more context."
1929
+ }
1930
+ },
1931
+ "required": [
1932
+ "name",
1933
+ "reason",
1934
+ "message",
1935
+ "subject"
1936
+ ]
1937
+ },
1938
+ "GateFix": {
1939
+ "type": "object",
1940
+ "properties": {
1941
+ "action": {
1942
+ "type": "string",
1943
+ "enum": [
1944
+ "confirm_domain",
1945
+ "sender_must_fix_authentication",
1946
+ "wait_for_inbound"
1947
+ ],
1948
+ "description": "Suggested next action for the caller."
1949
+ },
1950
+ "subject": {
1951
+ "type": "string",
1952
+ "description": "Entity the action applies to."
1953
+ }
1954
+ },
1955
+ "required": [
1956
+ "action",
1957
+ "subject"
1958
+ ]
1959
+ },
1705
1960
  "Account": {
1706
1961
  "type": "object",
1707
1962
  "properties": {
@@ -2337,6 +2592,162 @@ export const openapiDocument = {
2337
2592
  "to_email"
2338
2593
  ]
2339
2594
  },
2595
+ "SendMailInput": {
2596
+ "type": "object",
2597
+ "additionalProperties": false,
2598
+ "properties": {
2599
+ "from": {
2600
+ "type": "string",
2601
+ "minLength": 3,
2602
+ "maxLength": 998,
2603
+ "description": "RFC 5322 From header. The sender domain must be a verified outbound domain for your organization."
2604
+ },
2605
+ "to": {
2606
+ "type": "string",
2607
+ "minLength": 3,
2608
+ "maxLength": 320,
2609
+ "description": "Recipient address. Recipient eligibility depends on your account's outbound entitlements."
2610
+ },
2611
+ "subject": {
2612
+ "type": "string",
2613
+ "minLength": 1,
2614
+ "maxLength": 998,
2615
+ "description": "Subject line for the outbound message"
2616
+ },
2617
+ "body_text": {
2618
+ "type": "string",
2619
+ "description": "Plain-text message body. At least one of body_text or body_html is required. The combined UTF-8 byte length of body_text and body_html must be at most 262144 bytes."
2620
+ },
2621
+ "body_html": {
2622
+ "type": "string",
2623
+ "description": "HTML message body. At least one of body_text or body_html is required. The combined UTF-8 byte length of body_text and body_html must be at most 262144 bytes."
2624
+ },
2625
+ "in_reply_to": {
2626
+ "type": "string",
2627
+ "minLength": 1,
2628
+ "maxLength": 998,
2629
+ "pattern": "^[^\\x00-\\x1F\\x7F]+$",
2630
+ "description": "Message-ID of the direct parent email when sending a threaded reply."
2631
+ },
2632
+ "references": {
2633
+ "type": "array",
2634
+ "maxItems": 100,
2635
+ "description": "Full ordered message-id chain for the thread.",
2636
+ "items": {
2637
+ "type": "string",
2638
+ "minLength": 1,
2639
+ "maxLength": 998,
2640
+ "pattern": "^[^\\x00-\\x1F\\x7F]+$"
2641
+ }
2642
+ },
2643
+ "wait": {
2644
+ "type": "boolean",
2645
+ "description": "When true, wait for the first downstream SMTP delivery outcome before returning."
2646
+ },
2647
+ "wait_timeout_ms": {
2648
+ "type": "integer",
2649
+ "minimum": 1000,
2650
+ "maximum": 30000,
2651
+ "description": "Maximum time to wait for a delivery outcome when wait is true. Defaults to 30000."
2652
+ }
2653
+ },
2654
+ "required": [
2655
+ "from",
2656
+ "to",
2657
+ "subject"
2658
+ ]
2659
+ },
2660
+ "SentEmailStatus": {
2661
+ "type": "string",
2662
+ "enum": [
2663
+ "queued",
2664
+ "submitted_to_agent",
2665
+ "agent_failed",
2666
+ "unknown",
2667
+ "delivered",
2668
+ "bounced",
2669
+ "deferred",
2670
+ "wait_timeout"
2671
+ ]
2672
+ },
2673
+ "DeliveryStatus": {
2674
+ "type": "string",
2675
+ "enum": [
2676
+ "delivered",
2677
+ "bounced",
2678
+ "deferred",
2679
+ "wait_timeout"
2680
+ ]
2681
+ },
2682
+ "SendMailResult": {
2683
+ "type": "object",
2684
+ "properties": {
2685
+ "id": {
2686
+ "type": "string",
2687
+ "description": "Persisted sent-email attempt ID."
2688
+ },
2689
+ "status": {
2690
+ "$ref": "#/components/schemas/SentEmailStatus"
2691
+ },
2692
+ "queue_id": {
2693
+ "type": [
2694
+ "string",
2695
+ "null"
2696
+ ],
2697
+ "description": "Message identifier assigned by Primitive's outbound relay, when available."
2698
+ },
2699
+ "accepted": {
2700
+ "type": "array",
2701
+ "items": {
2702
+ "type": "string"
2703
+ },
2704
+ "description": "Recipient addresses accepted by the relay."
2705
+ },
2706
+ "rejected": {
2707
+ "type": "array",
2708
+ "items": {
2709
+ "type": "string"
2710
+ },
2711
+ "description": "Recipient addresses rejected by the relay."
2712
+ },
2713
+ "client_idempotency_key": {
2714
+ "type": "string",
2715
+ "description": "Effective idempotency key used for this send."
2716
+ },
2717
+ "request_id": {
2718
+ "type": "string",
2719
+ "description": "Server-issued request identifier for support and tracing."
2720
+ },
2721
+ "content_hash": {
2722
+ "type": "string",
2723
+ "description": "Stable hash of the canonical send payload."
2724
+ },
2725
+ "delivery_status": {
2726
+ "$ref": "#/components/schemas/DeliveryStatus"
2727
+ },
2728
+ "smtp_response_code": {
2729
+ "type": [
2730
+ "integer",
2731
+ "null"
2732
+ ],
2733
+ "description": "SMTP response code from the first downstream delivery outcome when wait is true."
2734
+ },
2735
+ "smtp_response_text": {
2736
+ "type": "string",
2737
+ "description": "SMTP response text from the first downstream delivery outcome when wait is true."
2738
+ }
2739
+ },
2740
+ "required": [
2741
+ "id",
2742
+ "status",
2743
+ "queue_id",
2744
+ "accepted",
2745
+ "rejected",
2746
+ "client_idempotency_key",
2747
+ "request_id",
2748
+ "content_hash"
2749
+ ]
2750
+ },
2340
2751
  "Endpoint": {
2341
2752
  "type": "object",
2342
2753
  "properties": {