@primitivedotdev/sdk 0.2.4 → 0.4.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 (41) hide show
  1. package/README.md +65 -2
  2. package/bin/run.js +5 -0
  3. package/dist/api/generated/client/client.gen.js +235 -0
  4. package/dist/api/generated/client/index.js +6 -0
  5. package/dist/api/generated/client/types.gen.js +2 -0
  6. package/dist/api/generated/client/utils.gen.js +228 -0
  7. package/dist/api/generated/client.gen.js +3 -0
  8. package/dist/api/generated/core/auth.gen.js +14 -0
  9. package/dist/api/generated/core/bodySerializer.gen.js +57 -0
  10. package/dist/api/generated/core/params.gen.js +100 -0
  11. package/dist/api/generated/core/pathSerializer.gen.js +106 -0
  12. package/dist/api/generated/core/queryKeySerializer.gen.js +92 -0
  13. package/dist/api/generated/core/serverSentEvents.gen.js +132 -0
  14. package/dist/api/generated/core/types.gen.js +2 -0
  15. package/dist/api/generated/core/utils.gen.js +87 -0
  16. package/dist/api/generated/index.js +2 -0
  17. package/dist/api/generated/sdk.gen.js +347 -0
  18. package/dist/api/generated/types.gen.js +2 -0
  19. package/dist/api/index.d.ts +1877 -0
  20. package/dist/api/index.js +39 -0
  21. package/dist/chunk-Cl8Af3a2.js +11 -0
  22. package/dist/contract/index.d.ts +3 -3
  23. package/dist/contract/index.js +2 -2
  24. package/dist/{index-BdRIHaXz.d.ts → index-D2OuDGVz.d.ts} +81 -5
  25. package/dist/index.d.ts +3 -3
  26. package/dist/index.js +2 -2
  27. package/dist/oclif/api-command.js +218 -0
  28. package/dist/oclif/fish-completion.js +87 -0
  29. package/dist/oclif/index.js +42 -0
  30. package/dist/openapi/index.d.ts +42 -0
  31. package/dist/openapi/index.js +8 -0
  32. package/dist/openapi/openapi.generated.js +2715 -0
  33. package/dist/openapi/operations.generated.js +671 -0
  34. package/dist/parser/index.d.ts +1 -1
  35. package/dist/parser/index.js +40 -25
  36. package/dist/{types-B5IgP-Zx.d.ts → types-C3ms4R0d.d.ts} +4 -0
  37. package/dist/webhook/index.d.ts +3 -3
  38. package/dist/webhook/index.js +2 -2
  39. package/dist/{webhook-Be2vM0F-.js → webhook-uSco6pyX.js} +176 -11
  40. package/oclif.manifest.json +1267 -0
  41. package/package.json +81 -13
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Primitive API client module.
3
+ *
4
+ * Generated operations are exported directly, and `PrimitiveApiClient`
5
+ * provides a configured fetch client for those operations.
6
+ */
7
+ import { createClient, createConfig, } from "./generated/client/index.js";
8
+ import * as generatedOperations from "./generated/sdk.gen.js";
9
+ export const DEFAULT_BASE_URL = "https://www.primitive.dev/api/v1";
10
+ function createDefaultAuth(apiKey) {
11
+ return (security) => {
12
+ if (security.type === "http" && security.scheme === "bearer") {
13
+ return apiKey;
14
+ }
15
+ return undefined;
16
+ };
17
+ }
18
+ export class PrimitiveApiClient {
19
+ client;
20
+ constructor(options = {}) {
21
+ const { apiKey, auth, baseUrl = DEFAULT_BASE_URL, ...config } = options;
22
+ this.client = createClient(createConfig({
23
+ ...config,
24
+ auth: auth ?? createDefaultAuth(apiKey),
25
+ baseUrl,
26
+ }));
27
+ }
28
+ getConfig() {
29
+ return this.client.getConfig();
30
+ }
31
+ setConfig(config) {
32
+ return this.client.setConfig(config);
33
+ }
34
+ }
35
+ export function createPrimitiveApiClient(options = {}) {
36
+ return new PrimitiveApiClient(options);
37
+ }
38
+ export const operations = generatedOperations;
39
+ export * from "./generated/index.js";
@@ -0,0 +1,11 @@
1
+ //#region rolldown:runtime
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all) __defProp(target, name, {
5
+ get: all[name],
6
+ enumerable: true
7
+ });
8
+ };
9
+
10
+ //#endregion
11
+ export { __export };
@@ -1,5 +1,5 @@
1
- import { EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, ParsedDataComplete, ParsedDataFailed, ParsedError, RawContentDownloadOnly, RawContentInline, WebhookAttachment } from "../types-B5IgP-Zx.js";
2
- import { SignResult, WEBHOOK_VERSION$1 as WEBHOOK_VERSION, signWebhookPayload$1 as signWebhookPayload } from "../index-BdRIHaXz.js";
1
+ import { EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, ParsedDataComplete, ParsedDataFailed, ParsedError, RawContentDownloadOnly, RawContentInline, WebhookAttachment } from "../types-C3ms4R0d.js";
2
+ import { SignResult, StandardWebhooksSignResult, WEBHOOK_VERSION$1 as WEBHOOK_VERSION, signStandardWebhooksPayload$1 as signStandardWebhooksPayload, signWebhookPayload$1 as signWebhookPayload } from "../index-D2OuDGVz.js";
3
3
 
4
4
  //#region src/contract/contract.d.ts
5
5
  /** Maximum raw email size for inline inclusion (256 KB). */
@@ -147,4 +147,4 @@ declare function buildEmailReceivedEvent(input: EmailReceivedEventInput, options
147
147
  /** Override the attempted-at timestamp, typically for tests. */
148
148
  attempted_at?: string;
149
149
  }): EmailReceivedEvent; //#endregion
150
- export { EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EmailReceivedEventInput, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedInput, ParsedInputComplete, ParsedInputFailed, RAW_EMAIL_INLINE_THRESHOLD, RawContentDownloadOnly, RawContentInline, SignResult, WEBHOOK_VERSION, WebhookAttachment, buildEmailReceivedEvent, generateEventId, signWebhookPayload };
150
+ export { EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EmailReceivedEventInput, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedInput, ParsedInputComplete, ParsedInputFailed, RAW_EMAIL_INLINE_THRESHOLD, RawContentDownloadOnly, RawContentInline, SignResult, StandardWebhooksSignResult, WEBHOOK_VERSION, WebhookAttachment, buildEmailReceivedEvent, generateEventId, signStandardWebhooksPayload, signWebhookPayload };
@@ -1,4 +1,4 @@
1
- import { WEBHOOK_VERSION, signWebhookPayload, validateEmailReceivedEvent } from "../webhook-Be2vM0F-.js";
1
+ import { WEBHOOK_VERSION, signStandardWebhooksPayload, signWebhookPayload, validateEmailReceivedEvent } from "../webhook-uSco6pyX.js";
2
2
  import { createHash } from "node:crypto";
3
3
 
4
4
  //#region src/contract/contract.ts
@@ -196,4 +196,4 @@ function buildEmailReceivedEvent(input, options) {
196
196
  }
197
197
 
198
198
  //#endregion
199
- export { RAW_EMAIL_INLINE_THRESHOLD, WEBHOOK_VERSION, buildEmailReceivedEvent, generateEventId, signWebhookPayload };
199
+ export { RAW_EMAIL_INLINE_THRESHOLD, WEBHOOK_VERSION, buildEmailReceivedEvent, generateEventId, signStandardWebhooksPayload, signWebhookPayload };
@@ -1,4 +1,4 @@
1
- import { EmailAuth, EmailReceivedEvent, ValidateEmailAuthResult, WebhookEvent } from "./types-B5IgP-Zx.js";
1
+ import { EmailAuth, EmailReceivedEvent, ValidateEmailAuthResult, WebhookEvent } from "./types-C3ms4R0d.js";
2
2
  import { ErrorObject } from "ajv";
3
3
 
4
4
  //#region src/webhook/errors.d.ts
@@ -317,6 +317,82 @@ declare function signWebhookPayload(rawBody: string | Buffer, secret: string | B
317
317
  */
318
318
  declare function verifyWebhookSignature(opts: VerifyOptions): true;
319
319
 
320
+ //#endregion
321
+ //#region src/webhook/standard-webhooks.d.ts
322
+ /**
323
+ * Standard Webhooks Verification & Signing
324
+ *
325
+ * Implements the Standard Webhooks spec (standardwebhooks.com) for webhook
326
+ * signature verification and payload signing.
327
+ *
328
+ * Header format:
329
+ * webhook-id: <msg_id>
330
+ * webhook-timestamp: <unix_seconds>
331
+ * webhook-signature: v1,<base64_hmac_sha256> [v1,<base64_2> ...]
332
+ *
333
+ * Signed payload format: "{msg_id}.{timestamp}.{raw_body}"
334
+ *
335
+ * Secrets are base64-encoded, optionally prefixed with "whsec_".
336
+ */
337
+ /** Standard Webhooks header names */
338
+ declare const STANDARD_WEBHOOK_ID_HEADER = "webhook-id";
339
+ declare const STANDARD_WEBHOOK_TIMESTAMP_HEADER = "webhook-timestamp";
340
+ declare const STANDARD_WEBHOOK_SIGNATURE_HEADER = "webhook-signature";
341
+ /**
342
+ * Result from signing a payload in Standard Webhooks format.
343
+ */
344
+ interface StandardWebhooksSignResult {
345
+ /** The webhook-signature header value (e.g. "v1,<base64>") */
346
+ signature: string;
347
+ /** The message ID used for signing */
348
+ msgId: string;
349
+ /** Unix timestamp used for signing */
350
+ timestamp: number;
351
+ }
352
+ /**
353
+ * Options for verifying a Standard Webhooks signature.
354
+ */
355
+ interface StandardWebhooksVerifyOptions {
356
+ /** The raw HTTP request body */
357
+ rawBody: string | Buffer;
358
+ /** The webhook-id header value */
359
+ msgId: string;
360
+ /** The webhook-timestamp header value (string, parsed to number internally) */
361
+ timestamp: string;
362
+ /** The webhook-signature header value */
363
+ signatureHeader: string;
364
+ /** Your webhook secret (with or without whsec_ prefix) */
365
+ secret: string | Buffer;
366
+ /** Max age in seconds (default: 300) */
367
+ toleranceSeconds?: number;
368
+ /** Override current time for testing (unix seconds) */
369
+ nowSeconds?: number;
370
+ }
371
+ /**
372
+ * Prepare a Standard Webhooks secret for HMAC computation.
373
+ *
374
+ * Strips the "whsec_" prefix if present, then base64-decodes the remainder
375
+ * to produce the raw HMAC key bytes.
376
+ *
377
+ * @internal
378
+ */
379
+
380
+ /**
381
+ * Sign a webhook payload using the Standard Webhooks format.
382
+ *
383
+ * @param rawBody - The raw JSON body string to sign
384
+ * @param secret - The webhook secret (with or without whsec_ prefix)
385
+ * @param msgId - The message ID (used in webhook-id header)
386
+ * @param timestamp - Unix timestamp in seconds (defaults to current time)
387
+ */
388
+ declare function signStandardWebhooksPayload(rawBody: string | Buffer, secret: string | Buffer, msgId: string, timestamp?: number): StandardWebhooksSignResult;
389
+ /**
390
+ * Verify a Standard Webhooks signature.
391
+ *
392
+ * Throws `WebhookVerificationError` on failure with a specific error code.
393
+ */
394
+ declare function verifyStandardWebhooksSignature(opts: StandardWebhooksVerifyOptions): true;
395
+
320
396
  //#endregion
321
397
  //#region src/schema.generated.d.ts
322
398
  /**
@@ -801,14 +877,14 @@ declare const emailReceivedEventJsonSchema: {
801
877
  };
802
878
  };
803
879
  readonly required: ["score"];
804
- readonly description: "SpamAssassin analysis results.";
880
+ readonly description: "SpamAssassin analysis results.\n\nOptional. Present when the email was processed by a SpamAssassin-equipped pipeline (always present in Primitive's managed service). When absent, spam scoring was not performed on this email.";
805
881
  };
806
882
  readonly forward: {
807
883
  readonly $ref: "#/definitions/ForwardAnalysis";
808
- readonly description: "Forward detection and analysis results.";
884
+ readonly description: "Forward detection and analysis results.\n\nOptional. Present when the email was processed by a forward-detection pipeline (always present in Primitive's managed service). When absent, forward detection was not performed on this email.";
809
885
  };
810
886
  };
811
- readonly description: "Email analysis and classification results.";
887
+ readonly description: "Email analysis and classification results.\n\nAll properties in this object are optional. Which fields are present depends on the analysis pipeline processing the email. Primitive's managed service populates all fields. Self-hosted or third-party deployments may include some, all, or none of these fields depending on their pipeline configuration.\n\nWhen a field is absent, it means that particular analysis was not performed, not that the analysis produced no results. For example, a missing `spamassassin` field means SpamAssassin was not run, not that the email scored 0.\n\nThese fields may be omitted from the payload entirely but must not be set to null.";
812
888
  };
813
889
  readonly ForwardAnalysis: {
814
890
  readonly type: "object";
@@ -1476,4 +1552,4 @@ declare function decodeRawEmail(event: EmailReceivedEvent, options?: DecodeRawEm
1476
1552
  declare function verifyRawEmailDownload(downloaded: Buffer | ArrayBuffer | Uint8Array, event: EmailReceivedEvent): Buffer;
1477
1553
 
1478
1554
  //#endregion
1479
- export { DecodeRawEmailOptions, HandleWebhookOptions, LEGACY_CONFIRMED_HEADER as LEGACY_CONFIRMED_HEADER$1, LEGACY_SIGNATURE_HEADER as LEGACY_SIGNATURE_HEADER$1, PAYLOAD_ERRORS as PAYLOAD_ERRORS$1, PRIMITIVE_CONFIRMED_HEADER as PRIMITIVE_CONFIRMED_HEADER$1, PRIMITIVE_SIGNATURE_HEADER as PRIMITIVE_SIGNATURE_HEADER$1, PrimitiveWebhookError as PrimitiveWebhookError$1, RAW_EMAIL_ERRORS as RAW_EMAIL_ERRORS$1, RawEmailDecodeError as RawEmailDecodeError$1, RawEmailDecodeErrorCode, SignResult, VERIFICATION_ERRORS as VERIFICATION_ERRORS$1, VerifyOptions, WEBHOOK_VERSION as WEBHOOK_VERSION$1, WebhookErrorCode, WebhookHeaders, WebhookPayloadError as WebhookPayloadError$1, WebhookPayloadErrorCode, WebhookValidationError as WebhookValidationError$1, WebhookValidationErrorCode, WebhookVerificationError as WebhookVerificationError$1, WebhookVerificationErrorCode, confirmedHeaders as confirmedHeaders$1, decodeRawEmail as decodeRawEmail$1, emailReceivedEventJsonSchema as emailReceivedEventJsonSchema$1, getDownloadTimeRemaining as getDownloadTimeRemaining$1, handleWebhook as handleWebhook$1, isDownloadExpired as isDownloadExpired$1, isEmailReceivedEvent as isEmailReceivedEvent$1, isRawIncluded as isRawIncluded$1, parseWebhookEvent as parseWebhookEvent$1, safeValidateEmailReceivedEvent as safeValidateEmailReceivedEvent$1, signWebhookPayload as signWebhookPayload$1, validateEmailAuth as validateEmailAuth$1, validateEmailReceivedEvent as validateEmailReceivedEvent$1, verifyRawEmailDownload as verifyRawEmailDownload$1, verifyWebhookSignature as verifyWebhookSignature$1 };
1555
+ export { DecodeRawEmailOptions, HandleWebhookOptions, LEGACY_CONFIRMED_HEADER as LEGACY_CONFIRMED_HEADER$1, LEGACY_SIGNATURE_HEADER as LEGACY_SIGNATURE_HEADER$1, PAYLOAD_ERRORS as PAYLOAD_ERRORS$1, PRIMITIVE_CONFIRMED_HEADER as PRIMITIVE_CONFIRMED_HEADER$1, PRIMITIVE_SIGNATURE_HEADER as PRIMITIVE_SIGNATURE_HEADER$1, PrimitiveWebhookError as PrimitiveWebhookError$1, RAW_EMAIL_ERRORS as RAW_EMAIL_ERRORS$1, RawEmailDecodeError as RawEmailDecodeError$1, RawEmailDecodeErrorCode, STANDARD_WEBHOOK_ID_HEADER as STANDARD_WEBHOOK_ID_HEADER$1, STANDARD_WEBHOOK_SIGNATURE_HEADER as STANDARD_WEBHOOK_SIGNATURE_HEADER$1, STANDARD_WEBHOOK_TIMESTAMP_HEADER as STANDARD_WEBHOOK_TIMESTAMP_HEADER$1, SignResult, StandardWebhooksSignResult, StandardWebhooksVerifyOptions, VERIFICATION_ERRORS as VERIFICATION_ERRORS$1, VerifyOptions, WEBHOOK_VERSION as WEBHOOK_VERSION$1, WebhookErrorCode, WebhookHeaders, WebhookPayloadError as WebhookPayloadError$1, WebhookPayloadErrorCode, WebhookValidationError as WebhookValidationError$1, WebhookValidationErrorCode, WebhookVerificationError as WebhookVerificationError$1, WebhookVerificationErrorCode, confirmedHeaders as confirmedHeaders$1, decodeRawEmail as decodeRawEmail$1, emailReceivedEventJsonSchema as emailReceivedEventJsonSchema$1, getDownloadTimeRemaining as getDownloadTimeRemaining$1, handleWebhook as handleWebhook$1, isDownloadExpired as isDownloadExpired$1, isEmailReceivedEvent as isEmailReceivedEvent$1, isRawIncluded as isRawIncluded$1, parseWebhookEvent as parseWebhookEvent$1, safeValidateEmailReceivedEvent as safeValidateEmailReceivedEvent$1, signStandardWebhooksPayload as signStandardWebhooksPayload$1, signWebhookPayload as signWebhookPayload$1, validateEmailAuth as validateEmailAuth$1, validateEmailReceivedEvent as validateEmailReceivedEvent$1, verifyRawEmailDownload as verifyRawEmailDownload$1, verifyStandardWebhooksSignature as verifyStandardWebhooksSignature$1, verifyWebhookSignature as verifyWebhookSignature$1 };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
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-B5IgP-Zx.js";
2
- import { DecodeRawEmailOptions, 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, SignResult, VERIFICATION_ERRORS$1 as VERIFICATION_ERRORS, 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, 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, signWebhookPayload$1 as signWebhookPayload, validateEmailAuth$1 as validateEmailAuth, validateEmailReceivedEvent$1 as validateEmailReceivedEvent, verifyRawEmailDownload$1 as verifyRawEmailDownload, verifyWebhookSignature$1 as verifyWebhookSignature } from "./index-BdRIHaXz.js";
3
- export { AuthConfidence, AuthVerdict, DecodeRawEmailOptions, DkimResult, DkimSignature, DmarcPolicy, DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType, ForwardAnalysis, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict, ForwardVerification, 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, SignResult, SpfResult, UnknownEvent, VERIFICATION_ERRORS, ValidateEmailAuthResult, VerifyOptions, WEBHOOK_VERSION, WebhookAttachment, WebhookErrorCode, WebhookEvent, WebhookHeaders, WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError, WebhookVerificationErrorCode, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, safeValidateEmailReceivedEvent, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyRawEmailDownload, verifyWebhookSignature };
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-C3ms4R0d.js";
2
+ import { DecodeRawEmailOptions, 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, 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, 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, verifyRawEmailDownload$1 as verifyRawEmailDownload, verifyStandardWebhooksSignature$1 as verifyStandardWebhooksSignature, verifyWebhookSignature$1 as verifyWebhookSignature } from "./index-D2OuDGVz.js";
3
+ export { AuthConfidence, AuthVerdict, DecodeRawEmailOptions, DkimResult, DkimSignature, DmarcPolicy, DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType, ForwardAnalysis, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict, ForwardVerification, 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, VerifyOptions, WEBHOOK_VERSION, WebhookAttachment, WebhookErrorCode, WebhookEvent, WebhookHeaders, WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError, WebhookVerificationErrorCode, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
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, SpfResult, VERIFICATION_ERRORS, WEBHOOK_VERSION, WebhookPayloadError, WebhookValidationError, WebhookVerificationError, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, safeValidateEmailReceivedEvent, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyRawEmailDownload, verifyWebhookSignature } from "./webhook-Be2vM0F-.js";
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, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature } from "./webhook-uSco6pyX.js";
2
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, SpfResult, VERIFICATION_ERRORS, WEBHOOK_VERSION, WebhookPayloadError, WebhookValidationError, WebhookVerificationError, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, safeValidateEmailReceivedEvent, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyRawEmailDownload, verifyWebhookSignature };
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, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
@@ -0,0 +1,218 @@
1
+ import { readFileSync, writeFileSync } from "node:fs";
2
+ import { Command, Errors, Flags } from "@oclif/core";
3
+ import { operations, PrimitiveApiClient } from "../api/index.js";
4
+ function flagName(parameterName) {
5
+ return parameterName.replace(/_/g, "-");
6
+ }
7
+ function flagDescription(parameter) {
8
+ return parameter.description ?? parameter.name;
9
+ }
10
+ export function flagForParameter(parameter) {
11
+ const common = {
12
+ description: flagDescription(parameter),
13
+ required: parameter.required,
14
+ };
15
+ if (parameter.type === "boolean") {
16
+ return Flags.boolean(common);
17
+ }
18
+ if (parameter.type === "integer") {
19
+ return Flags.integer(common);
20
+ }
21
+ if (parameter.enum && parameter.enum.length > 0) {
22
+ return Flags.string({ ...common, options: parameter.enum });
23
+ }
24
+ return Flags.string(common);
25
+ }
26
+ function coerceParameterValue(parameter, value) {
27
+ if (value === undefined) {
28
+ return undefined;
29
+ }
30
+ if (parameter.type === "number") {
31
+ if (typeof value === "number") {
32
+ return value;
33
+ }
34
+ const parsed = Number(value);
35
+ if (Number.isNaN(parsed)) {
36
+ throw new Errors.CLIError(`Invalid number for --${parameter.name}: ${value}`);
37
+ }
38
+ return parsed;
39
+ }
40
+ if (typeof value === "boolean" ||
41
+ typeof value === "number" ||
42
+ typeof value === "string") {
43
+ return value;
44
+ }
45
+ throw new Errors.CLIError(`Unsupported flag value for --${parameter.name}`);
46
+ }
47
+ function cliError(message) {
48
+ return new Errors.CLIError(message, { exit: 1 });
49
+ }
50
+ function parseJson(source, flagLabel) {
51
+ try {
52
+ return JSON.parse(source);
53
+ }
54
+ catch (error) {
55
+ const detail = error instanceof Error ? error.message : String(error);
56
+ throw cliError(`${flagLabel} is not valid JSON: ${detail}`);
57
+ }
58
+ }
59
+ export function readJsonBody(flags) {
60
+ const bodyFile = flags["body-file"];
61
+ const body = flags.body;
62
+ if (bodyFile && body) {
63
+ throw cliError("Use either --body or --body-file, not both");
64
+ }
65
+ if (typeof bodyFile === "string") {
66
+ let contents;
67
+ try {
68
+ contents = readFileSync(bodyFile, "utf8");
69
+ }
70
+ catch (error) {
71
+ const detail = error instanceof Error ? error.message : String(error);
72
+ throw cliError(`Could not read --body-file ${bodyFile}: ${detail}`);
73
+ }
74
+ return parseJson(contents, `--body-file ${bodyFile}`);
75
+ }
76
+ if (typeof body === "string") {
77
+ return parseJson(body, "--body");
78
+ }
79
+ return undefined;
80
+ }
81
+ export function extractErrorPayload(raw) {
82
+ if (raw &&
83
+ typeof raw === "object" &&
84
+ !(raw instanceof Error) &&
85
+ "error" in raw) {
86
+ const inner = raw.error;
87
+ if (inner !== null && inner !== undefined) {
88
+ return inner;
89
+ }
90
+ }
91
+ return raw;
92
+ }
93
+ function extractCauseDetails(cause) {
94
+ const details = {};
95
+ let code;
96
+ if (!cause || typeof cause !== "object") {
97
+ return { details };
98
+ }
99
+ for (const [key, value] of Object.entries(cause)) {
100
+ if (typeof value === "string" || typeof value === "number") {
101
+ details[key] = value;
102
+ if (key === "code" && typeof value === "string") {
103
+ code = value;
104
+ }
105
+ }
106
+ }
107
+ return { code, details };
108
+ }
109
+ export function formatErrorPayload(payload) {
110
+ if (payload instanceof Error) {
111
+ const { code, details } = extractCauseDetails(payload.cause);
112
+ const body = {
113
+ code: code ?? "client_error",
114
+ message: payload.message || payload.name || String(payload),
115
+ };
116
+ if (Object.keys(details).length > 0) {
117
+ body.cause = details;
118
+ }
119
+ return JSON.stringify(body, null, 2);
120
+ }
121
+ return JSON.stringify(payload, null, 2);
122
+ }
123
+ function buildFlags(operation) {
124
+ const flags = {
125
+ "api-key": Flags.string({
126
+ description: "Primitive API key (defaults to PRIMITIVE_API_KEY)",
127
+ env: "PRIMITIVE_API_KEY",
128
+ }),
129
+ "base-url": Flags.string({
130
+ description: "API base URL (defaults to PRIMITIVE_API_URL or production)",
131
+ env: "PRIMITIVE_API_URL",
132
+ }),
133
+ };
134
+ for (const parameter of [...operation.pathParams, ...operation.queryParams]) {
135
+ flags[flagName(parameter.name)] = flagForParameter(parameter);
136
+ }
137
+ if (operation.hasJsonBody) {
138
+ flags.body = Flags.string({ description: "JSON request body" });
139
+ flags["body-file"] = Flags.string({
140
+ description: "Path to a JSON file used as the request body",
141
+ });
142
+ }
143
+ if (operation.binaryResponse) {
144
+ flags.output = Flags.string({
145
+ description: "Write binary response bytes to a file",
146
+ });
147
+ }
148
+ return flags;
149
+ }
150
+ function collectValues(parameters, flags) {
151
+ const values = {};
152
+ for (const parameter of parameters) {
153
+ const value = coerceParameterValue(parameter, flags[flagName(parameter.name)]);
154
+ if (value !== undefined) {
155
+ values[parameter.name] = value;
156
+ }
157
+ }
158
+ return values;
159
+ }
160
+ export function createOperationCommand(operation) {
161
+ const flags = buildFlags(operation);
162
+ class OperationCommand extends Command {
163
+ static description = operation.description ?? `${operation.method} ${operation.path}`;
164
+ static flags = flags;
165
+ static summary = operation.summary ?? `${operation.method} ${operation.path}`;
166
+ async run() {
167
+ const { flags } = await this.parse(OperationCommand);
168
+ const parsedFlags = flags;
169
+ const apiClient = new PrimitiveApiClient({
170
+ apiKey: typeof parsedFlags["api-key"] === "string"
171
+ ? parsedFlags["api-key"]
172
+ : undefined,
173
+ baseUrl: typeof parsedFlags["base-url"] === "string"
174
+ ? parsedFlags["base-url"]
175
+ : undefined,
176
+ });
177
+ const body = operation.hasJsonBody
178
+ ? readJsonBody(parsedFlags)
179
+ : undefined;
180
+ if (operation.bodyRequired && body === undefined) {
181
+ throw new Errors.CLIError(`Operation ${operation.operationId} requires --body or --body-file`);
182
+ }
183
+ const operationFn = operations[operation.sdkName];
184
+ const result = await operationFn({
185
+ body,
186
+ client: apiClient.client,
187
+ parseAs: operation.binaryResponse ? "blob" : "auto",
188
+ path: collectValues(operation.pathParams, parsedFlags),
189
+ query: collectValues(operation.queryParams, parsedFlags),
190
+ responseStyle: "fields",
191
+ });
192
+ if (result.error) {
193
+ const errorPayload = extractErrorPayload(result.error);
194
+ process.stderr.write(`${formatErrorPayload(errorPayload)}\n`);
195
+ process.exitCode = 1;
196
+ return;
197
+ }
198
+ if (operation.binaryResponse) {
199
+ const blob = result.data;
200
+ const bytes = Buffer.from(await blob.arrayBuffer());
201
+ const output = parsedFlags.output;
202
+ if (typeof output === "string") {
203
+ writeFileSync(output, bytes);
204
+ return;
205
+ }
206
+ process.stdout.write(bytes);
207
+ return;
208
+ }
209
+ const envelope = result.data;
210
+ const cursor = envelope?.meta?.cursor;
211
+ if (cursor) {
212
+ process.stderr.write(`next cursor: ${cursor}\n`);
213
+ }
214
+ this.log(JSON.stringify(envelope?.data ?? null, null, 2));
215
+ }
216
+ }
217
+ return OperationCommand;
218
+ }
@@ -0,0 +1,87 @@
1
+ import { openapiDocument, operationManifest, } from "../openapi/index.js";
2
+ function fishEscape(value) {
3
+ return value.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
4
+ }
5
+ function toKebabCase(value) {
6
+ return value
7
+ .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
8
+ .replace(/[^a-zA-Z0-9]+/g, "-")
9
+ .replace(/^-+|-+$/g, "")
10
+ .toLowerCase();
11
+ }
12
+ function tagDescriptions() {
13
+ const descriptions = new Map();
14
+ const tags = (openapiDocument.tags ??
15
+ []);
16
+ for (const tag of tags) {
17
+ if (tag.name) {
18
+ descriptions.set(toKebabCase(tag.name), tag.description ?? tag.name);
19
+ }
20
+ }
21
+ return descriptions;
22
+ }
23
+ function operationCondition(operation) {
24
+ return `__fish_${fishEscape(BIN_PLACEHOLDER)}_using_operation ${fishEscape(operation.tagCommand)} ${fishEscape(operation.command)}`;
25
+ }
26
+ const BIN_PLACEHOLDER = "__BIN__";
27
+ export function renderFishCompletion(binName) {
28
+ const tagDescriptionByCommand = tagDescriptions();
29
+ const topLevelTopics = [
30
+ ...new Set(operationManifest.map((operation) => operation.tagCommand)),
31
+ ];
32
+ const lines = [
33
+ `function __fish_${binName}_needs_command`,
34
+ " set -l cmd (commandline -opc)",
35
+ " test (count $cmd) -le 1",
36
+ "end",
37
+ "",
38
+ `function __fish_${binName}_topic_needs_subcommand`,
39
+ " set -l cmd (commandline -opc)",
40
+ " test (count $cmd) -eq 2",
41
+ ' and test "$cmd[2]" = "$argv[1]"',
42
+ "end",
43
+ "",
44
+ `function __fish_${binName}_using_operation`,
45
+ " set -l cmd (commandline -opc)",
46
+ " test (count $cmd) -ge 3",
47
+ ' and test "$cmd[2]" = "$argv[1]"',
48
+ ' and test "$cmd[3]" = "$argv[2]"',
49
+ "end",
50
+ "",
51
+ `function __fish_${binName}_using_root_command`,
52
+ " set -l cmd (commandline -opc)",
53
+ " test (count $cmd) -eq 2",
54
+ ' and test "$cmd[2]" = "$argv[1]"',
55
+ "end",
56
+ "",
57
+ `complete -c ${binName} -f -n '__fish_${binName}_needs_command' -a 'list-operations' -d 'List all generated API operations'`,
58
+ `complete -c ${binName} -f -n '__fish_${binName}_needs_command' -a 'completion' -d 'Show shell completion output or installation instructions'`,
59
+ `complete -c ${binName} -f -n '__fish_${binName}_needs_command' -a 'autocomplete' -d 'Install or display shell autocomplete for bash, zsh, and powershell'`,
60
+ `complete -c ${binName} -f -n '__fish_${binName}_needs_command' -a 'help' -d 'Display help for ${binName}'`,
61
+ ];
62
+ for (const topic of topLevelTopics) {
63
+ lines.push(`complete -c ${binName} -f -n '__fish_${binName}_needs_command' -a '${fishEscape(topic)}' -d '${fishEscape(tagDescriptionByCommand.get(topic) ?? topic)}'`);
64
+ }
65
+ lines.push(`complete -c ${binName} -f -n '__fish_${binName}_using_root_command completion' -a 'bash zsh powershell fish' -d 'Shell type'`);
66
+ for (const topic of topLevelTopics) {
67
+ const topicOperations = operationManifest.filter((operation) => operation.tagCommand === topic);
68
+ for (const operation of topicOperations) {
69
+ lines.push(`complete -c ${binName} -f -n '__fish_${binName}_topic_needs_subcommand ${fishEscape(topic)}' -a '${fishEscape(operation.command)}' -d '${fishEscape(operation.summary ?? `${operation.method} ${operation.path}`)}'`);
70
+ for (const parameter of [
71
+ ...operation.pathParams,
72
+ ...operation.queryParams,
73
+ ]) {
74
+ lines.push(`complete -c ${binName} -n '${operationCondition(operation).replace(BIN_PLACEHOLDER, binName)}' -l '${fishEscape(parameter.name.replace(/_/g, "-"))}' -r -d '${fishEscape(parameter.description ?? parameter.name)}'`);
75
+ }
76
+ lines.push(`complete -c ${binName} -n '${operationCondition(operation).replace(BIN_PLACEHOLDER, binName)}' -l 'api-key' -r -d 'Primitive API key (defaults to PRIMITIVE_API_KEY)'`, `complete -c ${binName} -n '${operationCondition(operation).replace(BIN_PLACEHOLDER, binName)}' -l 'base-url' -r -d 'API base URL (defaults to PRIMITIVE_API_URL or production)'`);
77
+ if (operation.hasJsonBody) {
78
+ lines.push(`complete -c ${binName} -n '${operationCondition(operation).replace(BIN_PLACEHOLDER, binName)}' -l 'body' -r -d 'JSON request body'`, `complete -c ${binName} -n '${operationCondition(operation).replace(BIN_PLACEHOLDER, binName)}' -l 'body-file' -r -d 'Path to a JSON file used as the request body'`);
79
+ }
80
+ if (operation.binaryResponse) {
81
+ lines.push(`complete -c ${binName} -n '${operationCondition(operation).replace(BIN_PLACEHOLDER, binName)}' -l 'output' -r -d 'Write binary response bytes to a file'`);
82
+ }
83
+ }
84
+ }
85
+ lines.push(`complete -c ${binName} -l help -d 'Show help for ${binName}'`, `complete -c ${binName} -l version -d 'Show version for ${binName}'`);
86
+ return `${lines.join("\n")}\n`;
87
+ }
@@ -0,0 +1,42 @@
1
+ import { Args, Command } from "@oclif/core";
2
+ import { operationManifest, } from "../openapi/index.js";
3
+ import { createOperationCommand } from "./api-command.js";
4
+ import { renderFishCompletion } from "./fish-completion.js";
5
+ class ListOperationsCommand extends Command {
6
+ static description = "List all generated API operations";
7
+ static summary = "List all generated API operations";
8
+ async run() {
9
+ this.log(JSON.stringify(operationManifest, null, 2));
10
+ }
11
+ }
12
+ class CompletionCommand extends Command {
13
+ static args = {
14
+ shell: Args.string({
15
+ description: "Shell type",
16
+ options: ["bash", "zsh", "powershell", "fish"],
17
+ required: true,
18
+ }),
19
+ };
20
+ static description = "Show shell completion output or installation instructions for supported shells";
21
+ static summary = "Show shell completion output or installation instructions";
22
+ async run() {
23
+ const { args } = await this.parse(CompletionCommand);
24
+ if (args.shell === "fish") {
25
+ this.log(renderFishCompletion(this.config.bin));
26
+ return;
27
+ }
28
+ await this.config.runCommand("autocomplete", [args.shell]);
29
+ }
30
+ }
31
+ function commandId(operation) {
32
+ return `${operation.tagCommand}:${operation.command}`;
33
+ }
34
+ const generatedCommands = Object.fromEntries(operationManifest.map((operation) => [
35
+ commandId(operation),
36
+ createOperationCommand(operation),
37
+ ]));
38
+ export const COMMANDS = {
39
+ completion: CompletionCommand,
40
+ "list-operations": ListOperationsCommand,
41
+ ...generatedCommands,
42
+ };
@@ -0,0 +1,42 @@
1
+ //#region src/openapi/openapi.generated.d.ts
2
+ /**
3
+ * OpenAPI document for the Primitive API.
4
+ *
5
+ * AUTO-GENERATED - DO NOT EDIT
6
+ * Run `pnpm generate:openapi` to regenerate.
7
+ */
8
+ declare const openapiDocument: Record<string, unknown>;
9
+
10
+ //#endregion
11
+ //#region src/openapi/operations.generated.d.ts
12
+ /**
13
+ * Generated operation metadata for the Primitive API CLI and SDK tooling.
14
+ *
15
+ * AUTO-GENERATED - DO NOT EDIT
16
+ * Run `pnpm generate:openapi` to regenerate.
17
+ */
18
+ type PrimitiveParameterManifest = {
19
+ description: string | null;
20
+ enum: string[] | null;
21
+ name: string;
22
+ required: boolean;
23
+ type: string;
24
+ };
25
+ type PrimitiveOperationManifest = {
26
+ binaryResponse: boolean;
27
+ bodyRequired: boolean;
28
+ command: string;
29
+ description: string | null;
30
+ hasJsonBody: boolean;
31
+ method: string;
32
+ operationId: string;
33
+ path: string;
34
+ pathParams: PrimitiveParameterManifest[];
35
+ queryParams: PrimitiveParameterManifest[];
36
+ sdkName: string;
37
+ summary: string | null;
38
+ tag: string;
39
+ tagCommand: string;
40
+ };
41
+ declare const operationManifest: PrimitiveOperationManifest[]; //#endregion
42
+ export { PrimitiveOperationManifest, PrimitiveParameterManifest, openapiDocument, operationManifest };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * OpenAPI distribution module.
3
+ *
4
+ * Use this subpath when you need the canonical Primitive API specification,
5
+ * for example to serve it from another application.
6
+ */
7
+ export { openapiDocument } from "./openapi.generated.js";
8
+ export { operationManifest, } from "./operations.generated.js";