@primitivedotdev/sdk 0.19.0 → 0.21.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/api/generated/index.js +1 -1
- package/dist/api/generated/sdk.gen.js +235 -0
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +40 -5
- package/dist/{api-C5VR_Opg.js → api-BjzvA2Fy.js} +308 -6
- package/dist/{index-oRkCqj6u.d.ts → index-QTYQpSFt.d.ts} +999 -60
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/oclif/api-command.js +87 -13
- package/dist/oclif/auth.js +65 -10
- package/dist/oclif/commands/emails-latest.js +23 -12
- package/dist/oclif/commands/emails-poll.js +121 -0
- package/dist/oclif/commands/emails-wait.js +171 -0
- package/dist/oclif/commands/emails-watch.js +165 -0
- package/dist/oclif/commands/functions-deploy.js +117 -0
- package/dist/oclif/commands/functions-redeploy.js +106 -0
- package/dist/oclif/commands/login.js +18 -14
- package/dist/oclif/commands/logout.js +9 -8
- package/dist/oclif/commands/send.js +21 -7
- package/dist/oclif/commands/whoami.js +15 -6
- package/dist/oclif/fish-completion.js +1 -1
- package/dist/oclif/index.js +16 -0
- package/dist/openapi/openapi.generated.js +1317 -51
- package/dist/openapi/operations.generated.js +995 -1
- package/oclif.manifest.json +2083 -335
- package/package.json +4 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
export { addDomain, cliLogout, createEndpoint, createFilter, deleteDomain, deleteEmail, deleteEndpoint, deleteFilter, discardEmailContent, downloadAttachments, downloadRawEmail, getAccount, getEmail, getSendPermissions, getSentEmail, getStorageStats, getWebhookSecret, listDeliveries, listDomains, listEmails, listEndpoints, listFilters, listSentEmails, pollCliLogin, replayDelivery, replayEmailWebhooks, replyToEmail, rotateWebhookSecret, sendEmail, startCliLogin, testEndpoint, updateAccount, updateDomain, updateEndpoint, updateFilter, verifyDomain } from './sdk.gen.js';
|
|
2
|
+
export { addDomain, cliLogout, createEndpoint, createFilter, createFunction, createFunctionSecret, deleteDomain, deleteEmail, deleteEndpoint, deleteFilter, deleteFunction, deleteFunctionSecret, discardEmailContent, downloadAttachments, downloadRawEmail, getAccount, getEmail, getFunction, getSendPermissions, getSentEmail, getStorageStats, getWebhookSecret, listDeliveries, listDomains, listEmails, listEndpoints, listFilters, listFunctions, listFunctionSecrets, listSentEmails, pollCliLogin, replayDelivery, replayEmailWebhooks, replyToEmail, rotateWebhookSecret, searchEmails, sendEmail, setFunctionSecret, startCliLogin, testEndpoint, testFunction, updateAccount, updateDomain, updateEndpoint, updateFilter, updateFunction, verifyDomain } from './sdk.gen.js';
|
|
@@ -211,6 +211,27 @@ export const listEmails = (options) => (options?.client ?? client).get({
|
|
|
211
211
|
url: '/emails',
|
|
212
212
|
...options
|
|
213
213
|
});
|
|
214
|
+
/**
|
|
215
|
+
* Search inbound emails
|
|
216
|
+
*
|
|
217
|
+
* Searches inbound emails with structured filters and optional
|
|
218
|
+
* full-text matching across parsed email fields. This endpoint is
|
|
219
|
+
* optimized for filtered inbox views and CLI polling workflows:
|
|
220
|
+
* callers that only need new accepted mail can pass
|
|
221
|
+
* `sort=received_at_asc`, `snippet=false`, `include_facets=false`,
|
|
222
|
+
* and a `date_from` timestamp.
|
|
223
|
+
*
|
|
224
|
+
* `q`, `subject`, and `body` use the same English full-text index
|
|
225
|
+
* as the web inbox search. Structured filters such as `from`, `to`,
|
|
226
|
+
* `domain_id`, status, attachment presence, and spam score bounds
|
|
227
|
+
* are combined with the text query.
|
|
228
|
+
*
|
|
229
|
+
*/
|
|
230
|
+
export const searchEmails = (options) => (options?.client ?? client).get({
|
|
231
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
232
|
+
url: '/emails/search',
|
|
233
|
+
...options
|
|
234
|
+
});
|
|
214
235
|
/**
|
|
215
236
|
* Delete an email
|
|
216
237
|
*/
|
|
@@ -554,6 +575,15 @@ export const getSendPermissions = (options) => (options?.client ?? client).get({
|
|
|
554
575
|
* the request returns once the relay accepts the message for delivery.
|
|
555
576
|
* Set `wait: true` to wait for the first downstream SMTP delivery outcome.
|
|
556
577
|
*
|
|
578
|
+
* **Host routing.** /send-mail is served by the attachments-
|
|
579
|
+
* supporting host (`https://api.primitive.dev/v1`) so the
|
|
580
|
+
* request body can carry inline attachments up to ~30 MiB raw.
|
|
581
|
+
* The primary host (`https://www.primitive.dev/api/v1`) also
|
|
582
|
+
* accepts /send-mail for attachment-free sends; sends WITH
|
|
583
|
+
* attachments to the primary host return 413
|
|
584
|
+
* `attachments_unsupported_on_this_endpoint`. The typed SDKs
|
|
585
|
+
* route /send-mail to the attachments host automatically.
|
|
586
|
+
*
|
|
557
587
|
*/
|
|
558
588
|
export const sendEmail = (options) => (options.client ?? client).post({
|
|
559
589
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
@@ -607,3 +637,208 @@ export const getSentEmail = (options) => (options.client ?? client).get({
|
|
|
607
637
|
url: '/sent-emails/{id}',
|
|
608
638
|
...options
|
|
609
639
|
});
|
|
640
|
+
/**
|
|
641
|
+
* List functions
|
|
642
|
+
*
|
|
643
|
+
* Returns every active (non-deleted) function in the org, newest
|
|
644
|
+
* first. Each entry carries the deploy status and the gateway URL
|
|
645
|
+
* that the platform's webhook delivery loop posts to. To inspect
|
|
646
|
+
* the source code or deploy errors, use `GET /functions/{id}`.
|
|
647
|
+
*
|
|
648
|
+
*/
|
|
649
|
+
export const listFunctions = (options) => (options?.client ?? client).get({
|
|
650
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
651
|
+
url: '/functions',
|
|
652
|
+
...options
|
|
653
|
+
});
|
|
654
|
+
/**
|
|
655
|
+
* Deploy a function
|
|
656
|
+
*
|
|
657
|
+
* Creates and deploys a new function. The handler must be a single
|
|
658
|
+
* ESM module that exports a default async function receiving the
|
|
659
|
+
* `email.received` event (see the Webhook payload section for the
|
|
660
|
+
* full schema). Code is bundled before being uploaded; ship a
|
|
661
|
+
* single self-contained file rather than relying on external
|
|
662
|
+
* imports.
|
|
663
|
+
*
|
|
664
|
+
* **Code limits.** `code` is capped at 1 MiB UTF-8. `sourceMap`
|
|
665
|
+
* (optional) is capped at 5 MiB UTF-8 and is stored only on the
|
|
666
|
+
* edge runtime side; it is not persisted in Primitive's database.
|
|
667
|
+
*
|
|
668
|
+
* **Auto-wiring.** On successful deploy, Primitive automatically
|
|
669
|
+
* creates a webhook endpoint that delivers inbound mail to the
|
|
670
|
+
* function. There is nothing to configure on the Endpoints API
|
|
671
|
+
* for this to work; the gateway URL returned here is for
|
|
672
|
+
* reference only and is not directly callable from outside.
|
|
673
|
+
*
|
|
674
|
+
* **Secrets.** New functions ship with the managed secrets
|
|
675
|
+
* (`PRIMITIVE_WEBHOOK_SECRET`, `PRIMITIVE_API_KEY`) already
|
|
676
|
+
* bound. Add user-set secrets via
|
|
677
|
+
* `POST /functions/{id}/secrets`; secret writes only land in the
|
|
678
|
+
* running handler on the next redeploy.
|
|
679
|
+
*
|
|
680
|
+
*/
|
|
681
|
+
export const createFunction = (options) => (options.client ?? client).post({
|
|
682
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
683
|
+
url: '/functions',
|
|
684
|
+
...options,
|
|
685
|
+
headers: {
|
|
686
|
+
'Content-Type': 'application/json',
|
|
687
|
+
...options.headers
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
/**
|
|
691
|
+
* Delete a function
|
|
692
|
+
*
|
|
693
|
+
* Soft-deletes the function row, removes the script from the edge
|
|
694
|
+
* runtime, and deactivates the auto-wired webhook endpoint so no
|
|
695
|
+
* further inbound mail is delivered. Past deploy history,
|
|
696
|
+
* invocations, and logs are retained.
|
|
697
|
+
*
|
|
698
|
+
* Returns 502 if the runtime delete fails partway; the function
|
|
699
|
+
* row stays in place and the call is safe to retry until it
|
|
700
|
+
* succeeds.
|
|
701
|
+
*
|
|
702
|
+
*/
|
|
703
|
+
export const deleteFunction = (options) => (options.client ?? client).delete({
|
|
704
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
705
|
+
url: '/functions/{id}',
|
|
706
|
+
...options
|
|
707
|
+
});
|
|
708
|
+
/**
|
|
709
|
+
* Get a function
|
|
710
|
+
*
|
|
711
|
+
* Returns the full record for a function, including its current
|
|
712
|
+
* source code and the deploy status / error from the most recent
|
|
713
|
+
* deploy attempt.
|
|
714
|
+
*
|
|
715
|
+
*/
|
|
716
|
+
export const getFunction = (options) => (options.client ?? client).get({
|
|
717
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
718
|
+
url: '/functions/{id}',
|
|
719
|
+
...options
|
|
720
|
+
});
|
|
721
|
+
/**
|
|
722
|
+
* Update and redeploy a function
|
|
723
|
+
*
|
|
724
|
+
* Replaces the function's source code with the body's `code` and
|
|
725
|
+
* triggers a redeploy. Same size limits as `POST /functions`.
|
|
726
|
+
* Use this verb to push secret writes into the running handler:
|
|
727
|
+
* passing the same `code` re-runs the deploy and refreshes the
|
|
728
|
+
* binding set with the latest values from the secrets table.
|
|
729
|
+
*
|
|
730
|
+
* On a 502 deploy failure, the previously-deployed code stays
|
|
731
|
+
* live; the runtime never serves a half-built bundle. The
|
|
732
|
+
* `deploy_error` field on the returned record carries the error
|
|
733
|
+
* that came back from the runtime so you can surface it to users
|
|
734
|
+
* without polling.
|
|
735
|
+
*
|
|
736
|
+
*/
|
|
737
|
+
export const updateFunction = (options) => (options.client ?? client).put({
|
|
738
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
739
|
+
url: '/functions/{id}',
|
|
740
|
+
...options,
|
|
741
|
+
headers: {
|
|
742
|
+
'Content-Type': 'application/json',
|
|
743
|
+
...options.headers
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
/**
|
|
747
|
+
* Send a test invocation
|
|
748
|
+
*
|
|
749
|
+
* Sends a real test email from a Primitive-controlled sender to a
|
|
750
|
+
* synthetic local-part on one of the org's verified inbound
|
|
751
|
+
* domains. The function fires through the normal MX delivery
|
|
752
|
+
* path, so reply / send-mail calls from inside the handler
|
|
753
|
+
* against the inbound's `email.id` work the same as in
|
|
754
|
+
* production. Returns immediately after the send is queued; the
|
|
755
|
+
* invocation appears on the function's invocations list within a
|
|
756
|
+
* few seconds.
|
|
757
|
+
*
|
|
758
|
+
* Requires that the function is currently `deployed`. Returns 422
|
|
759
|
+
* if the function is in `pending` or `failed` state, or if the
|
|
760
|
+
* org has no verified inbound domain to receive the test mail.
|
|
761
|
+
*
|
|
762
|
+
*/
|
|
763
|
+
export const testFunction = (options) => (options.client ?? client).post({
|
|
764
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
765
|
+
url: '/functions/{id}/test',
|
|
766
|
+
...options
|
|
767
|
+
});
|
|
768
|
+
/**
|
|
769
|
+
* List a function's secrets
|
|
770
|
+
*
|
|
771
|
+
* Returns metadata for every secret bound to the function, with
|
|
772
|
+
* managed entries (provisioned by Primitive) listed first and
|
|
773
|
+
* user-set entries listed alphabetically after. **Values are
|
|
774
|
+
* never returned.** Secret writes are write-only.
|
|
775
|
+
*
|
|
776
|
+
* Managed entries (e.g. `PRIMITIVE_WEBHOOK_SECRET`,
|
|
777
|
+
* `PRIMITIVE_API_KEY`) carry a `description` instead of
|
|
778
|
+
* `created_at` / `updated_at`. They cannot be created, updated,
|
|
779
|
+
* or deleted via this API.
|
|
780
|
+
*
|
|
781
|
+
*/
|
|
782
|
+
export const listFunctionSecrets = (options) => (options.client ?? client).get({
|
|
783
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
784
|
+
url: '/functions/{id}/secrets',
|
|
785
|
+
...options
|
|
786
|
+
});
|
|
787
|
+
/**
|
|
788
|
+
* Create or update a secret
|
|
789
|
+
*
|
|
790
|
+
* Idempotent insert-or-update keyed on `(function_id, key)`.
|
|
791
|
+
* Returns 201 the first time the key is set, 200 on subsequent
|
|
792
|
+
* updates. Values are encrypted at rest and only become visible
|
|
793
|
+
* to the running handler on the next deploy (`PUT /functions/{id}`
|
|
794
|
+
* with the existing code is sufficient to refresh bindings).
|
|
795
|
+
*
|
|
796
|
+
* Keys must match `^[A-Z_][A-Z0-9_]*$` (uppercase letters,
|
|
797
|
+
* digits, underscores; first character is a letter or
|
|
798
|
+
* underscore). Values are at most 4096 UTF-8 bytes. System-
|
|
799
|
+
* managed keys are reserved and rejected.
|
|
800
|
+
*
|
|
801
|
+
*/
|
|
802
|
+
export const createFunctionSecret = (options) => (options.client ?? client).post({
|
|
803
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
804
|
+
url: '/functions/{id}/secrets',
|
|
805
|
+
...options,
|
|
806
|
+
headers: {
|
|
807
|
+
'Content-Type': 'application/json',
|
|
808
|
+
...options.headers
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
/**
|
|
812
|
+
* Delete a secret
|
|
813
|
+
*
|
|
814
|
+
* Removes the secret. The binding stays live in the running
|
|
815
|
+
* handler until the next deploy refreshes the binding set
|
|
816
|
+
* (`PUT /functions/{id}` with the existing code is sufficient).
|
|
817
|
+
* Returns 404 if the key did not exist. Managed system keys
|
|
818
|
+
* cannot be deleted.
|
|
819
|
+
*
|
|
820
|
+
*/
|
|
821
|
+
export const deleteFunctionSecret = (options) => (options.client ?? client).delete({
|
|
822
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
823
|
+
url: '/functions/{id}/secrets/{key}',
|
|
824
|
+
...options
|
|
825
|
+
});
|
|
826
|
+
/**
|
|
827
|
+
* Set a secret by key
|
|
828
|
+
*
|
|
829
|
+
* Path-keyed companion to `POST /functions/{id}/secrets`.
|
|
830
|
+
* Idempotent: returns 201 the first time the key is set, 200 on
|
|
831
|
+
* subsequent updates. Same validation rules and same write-only
|
|
832
|
+
* guarantees as the POST verb; the new value lands in the running
|
|
833
|
+
* handler on the next deploy.
|
|
834
|
+
*
|
|
835
|
+
*/
|
|
836
|
+
export const setFunctionSecret = (options) => (options.client ?? client).put({
|
|
837
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
838
|
+
url: '/functions/{id}/secrets/{key}',
|
|
839
|
+
...options,
|
|
840
|
+
headers: {
|
|
841
|
+
'Content-Type': 'application/json',
|
|
842
|
+
...options.headers
|
|
843
|
+
}
|
|
844
|
+
});
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { Account, AccountUpdated, AddDomainData, AddDomainError, AddDomainErrors, AddDomainInput, AddDomainResponse, AddDomainResponses, Auth, CliLoginPollResult, CliLoginStartResult, CliLogoutData, CliLogoutError, CliLogoutErrors, CliLogoutInput, CliLogoutResponse, CliLogoutResponses, CliLogoutResult, ClientOptions, CreateClientConfig, CreateEndpointData, CreateEndpointError, CreateEndpointErrors, CreateEndpointInput, CreateEndpointResponse, CreateEndpointResponses, CreateFilterData, CreateFilterError, CreateFilterErrors, CreateFilterInput, CreateFilterResponse, CreateFilterResponses, Cursor,
|
|
1
|
+
import { $ as replyToEmail, $a as TestEndpointError, $i as ReplayDeliveryResponses, $n as EmailDetail, $o as RequestOptions, $r as GetWebhookSecretResponses, $t as CreateFunctionSecretInput, A as deleteFunction, Aa as SendPermissionAnyRecipient, Ai as ListFunctionSecretsResponse, An as DeleteFunctionSecretErrors, Ao as UpdateFilterError, Ar as GetFunctionError, At as ClientOptions, B as getStorageStats, Ba as SetFunctionSecretErrors, Bi as ListSentEmailsResponse, Bn as DiscardEmailContentResponses, Bo as UpdateFunctionResponses, Br as GetSentEmailError, Bt as CreateFilterInput, C as createFilter, Ca as SendEmailError, Ci as ListFiltersError, Cn as DeleteFunctionData, Co as UpdateEndpointData, Cr as GetAccountResponses, Ct as CliLogoutData, D as deleteEmail, Da as SendMailInput, Di as ListFunctionSecretsData, Dn as DeleteFunctionResponses, Do as UpdateEndpointResponse, Dr as GetEmailResponse, Dt as CliLogoutResponse, E as deleteDomain, Ea as SendEmailResponses, Ei as ListFiltersResponses, En as DeleteFunctionResponse, Eo as UpdateEndpointInput, Er as GetEmailErrors, Et as CliLogoutInput, F as getAccount, Fa as SentEmailDetail, Fi as ListFunctionsResponse, Fn as DiscardContentResult, Fo as UpdateFunctionData, Fr as GetSendPermissionsError, Ft as CreateEndpointResponse, G as listEndpoints, Ga as StartCliLoginError, Gi as PollCliLoginErrors, Gn as DownloadAttachmentsErrors, Go as VerifyDomainResponse, Gr as GetStorageStatsError, Gt as CreateFunctionErrors, H as listDeliveries, Ha as SetFunctionSecretResponse, Hi as PaginationMeta, Hn as DomainVerifyResult, Ho as VerifyDomainData, Hr as GetSentEmailResponse, Ht as CreateFilterResponses, I as getEmail, Ia as SentEmailStatus, Ii as ListFunctionsResponses, In as DiscardEmailContentData, Io as UpdateFunctionError, Ir as GetSendPermissionsErrors, It as CreateEndpointResponses, J as listFunctions, Ja as StartCliLoginResponse, Ji as PollCliLoginResponses, Jn as DownloadRawEmailData, Jo as Client, Jr as GetStorageStatsResponses, Jt as CreateFunctionResponses, K as listFilters, Ka as StartCliLoginErrors, Ki as PollCliLoginInput, Kn as DownloadAttachmentsResponse, Ko as VerifyDomainResponses, Kr as GetStorageStatsErrors, Kt as CreateFunctionInput, L as getFunction, La as SentEmailSummary, Li as ListSentEmailsData, Ln as DiscardEmailContentError, Lo as UpdateFunctionErrors, Lr as GetSendPermissionsResponse, Lt as CreateFilterData, M as discardEmailContent, Ma as SendPermissionRule, Mi as ListFunctionsData, Mn as DeleteFunctionSecretResponses, Mo as UpdateFilterInput, Mr as GetFunctionResponse, Mt as CreateEndpointError, N as downloadAttachments, Na as SendPermissionYourDomain, Ni as ListFunctionsError, Nn as DeliveryStatus, No as UpdateFilterResponse, Nr as GetFunctionResponses, Nt as CreateEndpointErrors, O as deleteEndpoint, Oa as SendMailResult, Oi as ListFunctionSecretsError, On as DeleteFunctionSecretData, Oo as UpdateEndpointResponses, Or as GetEmailResponses, Ot as CliLogoutResponses, P as downloadRawEmail, Pa as SendPermissionsMeta, Pi as ListFunctionsErrors, Pn as DeliverySummary, Po as UpdateFilterResponses, Pr as GetSendPermissionsData, Pt as CreateEndpointInput, Q as replayEmailWebhooks, Qa as TestEndpointData, Qi as ReplayDeliveryResponse, Qn as DownloadRawEmailResponses, Qo as Options$1, Qr as GetWebhookSecretResponse, Qt as CreateFunctionSecretErrors, R as getSendPermissions, Ra as SetFunctionSecretData, Ri as ListSentEmailsError, Rn as DiscardEmailContentErrors, Ro as UpdateFunctionInput, Rr as GetSendPermissionsResponses, Rt as CreateFilterError, S as createEndpoint, Sa as SendEmailData, Si as ListFiltersData, Sn as DeleteFilterResponses, So as UpdateDomainResponses, Sr as GetAccountResponse, St as CliLoginStartResult, T as createFunctionSecret, Ta as SendEmailResponse, Ti as ListFiltersResponse, Tn as DeleteFunctionErrors, To as UpdateEndpointErrors, Tr as GetEmailError, Tt as CliLogoutErrors, U as listDomains, Ua as SetFunctionSecretResponses, Ui as PollCliLoginData, Un as DownloadAttachmentsData, Uo as VerifyDomainError, Ur as GetSentEmailResponses, Ut as CreateFunctionData, V as getWebhookSecret, Va as SetFunctionSecretInput, Vi as ListSentEmailsResponses, Vn as Domain, Vo as VerifiedDomain, Vr as GetSentEmailErrors, Vt as CreateFilterResponse, W as listEmails, Wa as StartCliLoginData, Wi as PollCliLoginError, Wn as DownloadAttachmentsError, Wo as VerifyDomainErrors, Wr as GetStorageStatsData, Wt as CreateFunctionError, X as pollCliLogin, Xa as StorageStats, Xi as ReplayDeliveryError, Xn as DownloadRawEmailErrors, Xo as Config, Xr as GetWebhookSecretError, Xt as CreateFunctionSecretData, Y as listSentEmails, Ya as StartCliLoginResponses, Yi as ReplayDeliveryData, Yn as DownloadRawEmailError, Yo as ClientOptions$1, Yr as GetWebhookSecretData, Yt as CreateFunctionResult, Z as replayDelivery, Za as SuccessEnvelope, Zi as ReplayDeliveryErrors, Zn as DownloadRawEmailResponse, Zo as CreateClientConfig, Zr as GetWebhookSecretErrors, Zt as CreateFunctionSecretError, _ as createPrimitiveClient, _a as SearchEmailsData, _i as ListEndpointsError, _n as DeleteEndpointResponses, _o as UpdateDomainData, _r as GateDenial, _t as AddDomainErrors, a as PrimitiveApiClientOptions, aa as ReplayResult, ai as ListDeliveriesResponses, an as DeleteDomainErrors, ao as TestFunctionErrors, ar as EmailSearchResult, at as testEndpoint, b as addDomain, ba as SearchEmailsResponse, bi as ListEndpointsResponses, bn as DeleteFilterErrors, bo as UpdateDomainInput, br as GetAccountError, bt as AddDomainResponses, c as PrimitiveClient, ca as ReplyToEmailErrors, ci as ListDomainsErrors, cn as DeleteEmailData, co as TestInvocationResult, cr as EmailWebhookStatus, ct as updateDomain, d as RequestOptions$1, da as ResourceId, di as ListEmailsData, dn as DeleteEmailResponse, do as UpdateAccountData, dr as Filter, dt as updateFunction, ea as ReplayEmailWebhooksData, ei as Limit, en as CreateFunctionSecretResponse, eo as TestEndpointErrors, er as EmailDetailReply, es as RequestResult, et as rotateWebhookSecret, f as SendInput, fa as RotateWebhookSecretData, fi as ListEmailsError, fn as DeleteEmailResponses, fo as UpdateAccountError, fr as FunctionDeployStatus, ft as verifyDomain, g as createPrimitiveApiClient, ga as RotateWebhookSecretResponses, gi as ListEndpointsData, gn as DeleteEndpointResponse, go as UpdateAccountResponses, gr as FunctionSecretWriteResult, gt as AddDomainError, h as client, ha as RotateWebhookSecretResponse, hi as ListEmailsResponses, hn as DeleteEndpointErrors, ho as UpdateAccountResponse, hr as FunctionSecretListItem, ht as AddDomainData, i as PrimitiveApiClient, ia as ReplayEmailWebhooksResponses, ii as ListDeliveriesResponse, in as DeleteDomainError, io as TestFunctionError, ir as EmailSearchMeta, it as startCliLogin, j as deleteFunctionSecret, ja as SendPermissionManagedZone, ji as ListFunctionSecretsResponses, jn as DeleteFunctionSecretResponse, jo as UpdateFilterErrors, jr as GetFunctionErrors, jt as CreateEndpointData, k as deleteFilter, ka as SendPermissionAddress, ki as ListFunctionSecretsErrors, kn as DeleteFunctionSecretError, ko as UpdateFilterData, kr as GetFunctionData, kt as CliLogoutResult, l as PrimitiveClientOptions, la as ReplyToEmailResponse, li as ListDomainsResponse, ln as DeleteEmailError, lo as TestResult, lr as Endpoint, lt as updateEndpoint, m as SendThreadInput, ma as RotateWebhookSecretErrors, mi as ListEmailsResponse, mn as DeleteEndpointError, mo as UpdateAccountInput, mr as FunctionListItem, mt as AccountUpdated, n as DEFAULT_API_BASE_URL_2, na as ReplayEmailWebhooksErrors, ni as ListDeliveriesError, nn as Cursor, no as TestEndpointResponses, nr as EmailSearchFacets, ns as Auth, nt as sendEmail, o as PrimitiveApiError, oa as ReplyToEmailData, oi as ListDomainsData, on as DeleteDomainResponse, oo as TestFunctionResponse, or as EmailStatus, ot as testFunction, p as SendResult, pa as RotateWebhookSecretError, pi as ListEmailsErrors, pn as DeleteEndpointData, po as UpdateAccountErrors, pr as FunctionDetail, pt as Account, q as listFunctionSecrets, qa as StartCliLoginInput, qi as PollCliLoginResponse, qn as DownloadAttachmentsResponses, qo as WebhookSecret, qr as GetStorageStatsResponse, qt as CreateFunctionResponse, r as ForwardInput, ra as ReplayEmailWebhooksResponse, ri as ListDeliveriesErrors, rn as DeleteDomainData, ro as TestFunctionData, rr as EmailSearchHighlights, rt as setFunctionSecret, s as PrimitiveApiErrorDetails, sa as ReplyToEmailError, si as ListDomainsError, sn as DeleteDomainResponses, so as TestFunctionResponses, sr as EmailSummary, st as updateAccount, t as DEFAULT_API_BASE_URL_1, ta as ReplayEmailWebhooksError, ti as ListDeliveriesData, tn as CreateFunctionSecretResponses, to as TestEndpointResponse, tr as EmailSearchFacetBucket, ts as ResponseStyle, tt as searchEmails, u as ReplyInput, ua as ReplyToEmailResponses, ui as ListDomainsResponses, un as DeleteEmailErrors, uo as UnverifiedDomain, ur as ErrorResponse, ut as updateFilter, v as operations, va as SearchEmailsError, vi as ListEndpointsErrors, vn as DeleteFilterData, vo as UpdateDomainError, vr as GateFix, vt as AddDomainInput, w as createFunction, wa as SendEmailErrors, wi as ListFiltersErrors, wn as DeleteFunctionError, wo as UpdateEndpointError, wr as GetEmailData, wt as CliLogoutError, x as cliLogout, xa as SearchEmailsResponses, xi as ListEnvelope, xn as DeleteFilterResponse, xo as UpdateDomainResponse, xr as GetAccountErrors, xt as CliLoginPollResult, y as Options, ya as SearchEmailsErrors, yi as ListEndpointsResponse, yn as DeleteFilterError, yo as UpdateDomainErrors, yr as GetAccountData, yt as AddDomainResponse, z as getSentEmail, za as SetFunctionSecretError, zi as ListSentEmailsErrors, zn as DiscardEmailContentResponse, zo as UpdateFunctionResponse, zr as GetSentEmailData, zt as CreateFilterErrors } from "../index-QTYQpSFt.js";
|
|
2
|
+
export { Account, AccountUpdated, AddDomainData, AddDomainError, AddDomainErrors, AddDomainInput, AddDomainResponse, AddDomainResponses, Auth, CliLoginPollResult, CliLoginStartResult, CliLogoutData, CliLogoutError, CliLogoutErrors, CliLogoutInput, CliLogoutResponse, CliLogoutResponses, CliLogoutResult, ClientOptions, CreateClientConfig, CreateEndpointData, CreateEndpointError, CreateEndpointErrors, CreateEndpointInput, CreateEndpointResponse, CreateEndpointResponses, CreateFilterData, CreateFilterError, CreateFilterErrors, CreateFilterInput, CreateFilterResponse, CreateFilterResponses, CreateFunctionData, CreateFunctionError, CreateFunctionErrors, CreateFunctionInput, CreateFunctionResponse, CreateFunctionResponses, CreateFunctionResult, CreateFunctionSecretData, CreateFunctionSecretError, CreateFunctionSecretErrors, CreateFunctionSecretInput, CreateFunctionSecretResponse, CreateFunctionSecretResponses, Cursor, DEFAULT_API_BASE_URL_1, DEFAULT_API_BASE_URL_2, DeleteDomainData, DeleteDomainError, DeleteDomainErrors, DeleteDomainResponse, DeleteDomainResponses, DeleteEmailData, DeleteEmailError, DeleteEmailErrors, DeleteEmailResponse, DeleteEmailResponses, DeleteEndpointData, DeleteEndpointError, DeleteEndpointErrors, DeleteEndpointResponse, DeleteEndpointResponses, DeleteFilterData, DeleteFilterError, DeleteFilterErrors, DeleteFilterResponse, DeleteFilterResponses, DeleteFunctionData, DeleteFunctionError, DeleteFunctionErrors, DeleteFunctionResponse, DeleteFunctionResponses, DeleteFunctionSecretData, DeleteFunctionSecretError, DeleteFunctionSecretErrors, DeleteFunctionSecretResponse, DeleteFunctionSecretResponses, DeliveryStatus, DeliverySummary, DiscardContentResult, DiscardEmailContentData, DiscardEmailContentError, DiscardEmailContentErrors, DiscardEmailContentResponse, DiscardEmailContentResponses, Domain, DomainVerifyResult, DownloadAttachmentsData, DownloadAttachmentsError, DownloadAttachmentsErrors, DownloadAttachmentsResponse, DownloadAttachmentsResponses, DownloadRawEmailData, DownloadRawEmailError, DownloadRawEmailErrors, DownloadRawEmailResponse, DownloadRawEmailResponses, EmailDetail, EmailDetailReply, EmailSearchFacetBucket, EmailSearchFacets, EmailSearchHighlights, EmailSearchMeta, EmailSearchResult, EmailStatus, EmailSummary, EmailWebhookStatus, Endpoint, ErrorResponse, Filter, ForwardInput, FunctionDeployStatus, FunctionDetail, FunctionListItem, FunctionSecretListItem, FunctionSecretWriteResult, GateDenial, GateFix, GetAccountData, GetAccountError, GetAccountErrors, GetAccountResponse, GetAccountResponses, GetEmailData, GetEmailError, GetEmailErrors, GetEmailResponse, GetEmailResponses, GetFunctionData, GetFunctionError, GetFunctionErrors, GetFunctionResponse, GetFunctionResponses, GetSendPermissionsData, GetSendPermissionsError, GetSendPermissionsErrors, GetSendPermissionsResponse, GetSendPermissionsResponses, GetSentEmailData, GetSentEmailError, GetSentEmailErrors, GetSentEmailResponse, GetSentEmailResponses, GetStorageStatsData, GetStorageStatsError, GetStorageStatsErrors, GetStorageStatsResponse, GetStorageStatsResponses, GetWebhookSecretData, GetWebhookSecretError, GetWebhookSecretErrors, GetWebhookSecretResponse, GetWebhookSecretResponses, Limit, ListDeliveriesData, ListDeliveriesError, ListDeliveriesErrors, ListDeliveriesResponse, ListDeliveriesResponses, ListDomainsData, ListDomainsError, ListDomainsErrors, ListDomainsResponse, ListDomainsResponses, ListEmailsData, ListEmailsError, ListEmailsErrors, ListEmailsResponse, ListEmailsResponses, ListEndpointsData, ListEndpointsError, ListEndpointsErrors, ListEndpointsResponse, ListEndpointsResponses, ListEnvelope, ListFiltersData, ListFiltersError, ListFiltersErrors, ListFiltersResponse, ListFiltersResponses, ListFunctionSecretsData, ListFunctionSecretsError, ListFunctionSecretsErrors, ListFunctionSecretsResponse, ListFunctionSecretsResponses, ListFunctionsData, ListFunctionsError, ListFunctionsErrors, ListFunctionsResponse, ListFunctionsResponses, ListSentEmailsData, ListSentEmailsError, ListSentEmailsErrors, ListSentEmailsResponse, ListSentEmailsResponses, Options, PaginationMeta, PollCliLoginData, PollCliLoginError, PollCliLoginErrors, PollCliLoginInput, PollCliLoginResponse, PollCliLoginResponses, PrimitiveApiClient, PrimitiveApiClientOptions, PrimitiveApiError, PrimitiveApiErrorDetails, PrimitiveClient, PrimitiveClientOptions, Client as PrimitiveGeneratedApiClient, ClientOptions$1 as PrimitiveGeneratedApiClientOptions, Config as PrimitiveGeneratedApiConfig, Options$1 as PrimitiveGeneratedApiOptions, RequestOptions as PrimitiveGeneratedApiRequestOptions, RequestResult as PrimitiveGeneratedApiRequestResult, ReplayDeliveryData, ReplayDeliveryError, ReplayDeliveryErrors, ReplayDeliveryResponse, ReplayDeliveryResponses, ReplayEmailWebhooksData, ReplayEmailWebhooksError, ReplayEmailWebhooksErrors, ReplayEmailWebhooksResponse, ReplayEmailWebhooksResponses, ReplayResult, ReplyInput, ReplyToEmailData, ReplyToEmailError, ReplyToEmailErrors, ReplyToEmailResponse, ReplyToEmailResponses, RequestOptions$1 as RequestOptions, ResourceId, ResponseStyle, RotateWebhookSecretData, RotateWebhookSecretError, RotateWebhookSecretErrors, RotateWebhookSecretResponse, RotateWebhookSecretResponses, SearchEmailsData, SearchEmailsError, SearchEmailsErrors, SearchEmailsResponse, SearchEmailsResponses, SendEmailData, SendEmailError, SendEmailErrors, SendEmailResponse, SendEmailResponses, SendInput, SendMailInput, SendMailResult, SendPermissionAddress, SendPermissionAnyRecipient, SendPermissionManagedZone, SendPermissionRule, SendPermissionYourDomain, SendPermissionsMeta, SendResult, SendThreadInput, SentEmailDetail, SentEmailStatus, SentEmailSummary, SetFunctionSecretData, SetFunctionSecretError, SetFunctionSecretErrors, SetFunctionSecretInput, SetFunctionSecretResponse, SetFunctionSecretResponses, StartCliLoginData, StartCliLoginError, StartCliLoginErrors, StartCliLoginInput, StartCliLoginResponse, StartCliLoginResponses, StorageStats, SuccessEnvelope, TestEndpointData, TestEndpointError, TestEndpointErrors, TestEndpointResponse, TestEndpointResponses, TestFunctionData, TestFunctionError, TestFunctionErrors, TestFunctionResponse, TestFunctionResponses, TestInvocationResult, TestResult, UnverifiedDomain, UpdateAccountData, UpdateAccountError, UpdateAccountErrors, UpdateAccountInput, UpdateAccountResponse, UpdateAccountResponses, UpdateDomainData, UpdateDomainError, UpdateDomainErrors, UpdateDomainInput, UpdateDomainResponse, UpdateDomainResponses, UpdateEndpointData, UpdateEndpointError, UpdateEndpointErrors, UpdateEndpointInput, UpdateEndpointResponse, UpdateEndpointResponses, UpdateFilterData, UpdateFilterError, UpdateFilterErrors, UpdateFilterInput, UpdateFilterResponse, UpdateFilterResponses, UpdateFunctionData, UpdateFunctionError, UpdateFunctionErrors, UpdateFunctionInput, UpdateFunctionResponse, UpdateFunctionResponses, VerifiedDomain, VerifyDomainData, VerifyDomainError, VerifyDomainErrors, VerifyDomainResponse, VerifyDomainResponses, WebhookSecret, addDomain, cliLogout, client, createEndpoint, createFilter, createFunction, createFunctionSecret, createPrimitiveApiClient, createPrimitiveClient, deleteDomain, deleteEmail, deleteEndpoint, deleteFilter, deleteFunction, deleteFunctionSecret, discardEmailContent, downloadAttachments, downloadRawEmail, getAccount, getEmail, getFunction, getSendPermissions, getSentEmail, getStorageStats, getWebhookSecret, listDeliveries, listDomains, listEmails, listEndpoints, listFilters, listFunctionSecrets, listFunctions, listSentEmails, operations, pollCliLogin, replayDelivery, replayEmailWebhooks, replyToEmail, rotateWebhookSecret, searchEmails, sendEmail, setFunctionSecret, startCliLogin, testEndpoint, testFunction, updateAccount, updateDomain, updateEndpoint, updateFilter, updateFunction, verifyDomain };
|
package/dist/api/index.js
CHANGED
|
@@ -7,7 +7,17 @@
|
|
|
7
7
|
import { formatAddress } from "../webhook/received-email.js";
|
|
8
8
|
import { createClient, createConfig, } from "./generated/client/index.js";
|
|
9
9
|
import * as generatedOperations from "./generated/sdk.gen.js";
|
|
10
|
-
|
|
10
|
+
// Default production hosts. Two-host split exists because /send-mail
|
|
11
|
+
// needs a larger body cap than Vercel allows; host 2 is a Cloudflare
|
|
12
|
+
// Worker that accepts ~30 MiB raw. Host 1 carries everything else.
|
|
13
|
+
// Customers don't see this split: PrimitiveClient.send() always routes
|
|
14
|
+
// to host 2 internally, every other operation routes to host 1.
|
|
15
|
+
//
|
|
16
|
+
// Both base URLs are independently overridable via constructor options.
|
|
17
|
+
// Override is for internal staging/local testing; not part of the
|
|
18
|
+
// publicly-supported surface.
|
|
19
|
+
export const DEFAULT_API_BASE_URL_1 = "https://www.primitive.dev/api/v1";
|
|
20
|
+
export const DEFAULT_API_BASE_URL_2 = "https://api.primitive.dev/v1";
|
|
11
21
|
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
12
22
|
const MAX_THREAD_REFERENCES = 100;
|
|
13
23
|
const MAX_THREAD_HEADER_BYTES = 8 * 1024;
|
|
@@ -155,13 +165,35 @@ function parseRetryAfterHeader(response) {
|
|
|
155
165
|
return Number.isFinite(seconds) ? seconds : undefined;
|
|
156
166
|
}
|
|
157
167
|
export class PrimitiveApiClient {
|
|
168
|
+
/**
|
|
169
|
+
* Generated client targeting the primary API host (apiBaseUrl1). Use
|
|
170
|
+
* this when passing `client: ...` to a generated operation function
|
|
171
|
+
* for every endpoint EXCEPT /send-mail. The hand-written
|
|
172
|
+
* PrimitiveClient.send / .reply / .forward methods on the subclass
|
|
173
|
+
* route /send-mail to the host-2 client internally.
|
|
174
|
+
*/
|
|
158
175
|
client;
|
|
176
|
+
/**
|
|
177
|
+
* @internal Generated client targeting the attachments-supporting
|
|
178
|
+
* send host (apiBaseUrl2). Used by PrimitiveClient.send() under the
|
|
179
|
+
* hood. Exposed for the CLI's hand-rolled send command, which calls
|
|
180
|
+
* the generated sendEmail directly; not part of the publicly-
|
|
181
|
+
* documented SDK surface. Customer code should call .send() on the
|
|
182
|
+
* subclass instead.
|
|
183
|
+
*/
|
|
184
|
+
_sendClient;
|
|
159
185
|
constructor(options = {}) {
|
|
160
|
-
const { apiKey, auth,
|
|
186
|
+
const { apiKey, auth, apiBaseUrl1 = DEFAULT_API_BASE_URL_1, apiBaseUrl2 = DEFAULT_API_BASE_URL_2, ...config } = options;
|
|
187
|
+
const resolvedAuth = auth ?? createDefaultAuth(apiKey);
|
|
161
188
|
this.client = createClient(createConfig({
|
|
162
189
|
...config,
|
|
163
|
-
auth:
|
|
164
|
-
baseUrl,
|
|
190
|
+
auth: resolvedAuth,
|
|
191
|
+
baseUrl: apiBaseUrl1,
|
|
192
|
+
}));
|
|
193
|
+
this._sendClient = createClient(createConfig({
|
|
194
|
+
...config,
|
|
195
|
+
auth: resolvedAuth,
|
|
196
|
+
baseUrl: apiBaseUrl2,
|
|
165
197
|
}));
|
|
166
198
|
}
|
|
167
199
|
getConfig() {
|
|
@@ -219,7 +251,10 @@ export class PrimitiveClient extends PrimitiveApiClient {
|
|
|
219
251
|
const result = await generatedOperations.sendEmail({
|
|
220
252
|
body,
|
|
221
253
|
...resolveRequestOptions(options),
|
|
222
|
-
|
|
254
|
+
// /send-mail goes to the host that supports attachments. Same
|
|
255
|
+
// request body shape on both hosts; the host swap is the only
|
|
256
|
+
// difference. Callers don't see or configure this.
|
|
257
|
+
client: this._sendClient,
|
|
223
258
|
responseStyle: "fields",
|
|
224
259
|
});
|
|
225
260
|
return unwrapSendResult(result);
|