@primitivedotdev/sdk 0.26.1 → 0.27.1

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 (67) hide show
  1. package/README.md +2 -2
  2. package/dist/api/index.d.ts +5 -3
  3. package/dist/api/index.js +4 -406
  4. package/dist/{api-CnUa6o4r.js → api-CZIBnM4Q.js} +118 -92
  5. package/dist/contract/index.d.ts +2 -2
  6. package/dist/contract/index.js +1 -1
  7. package/dist/{errors-x91I_yEt.js → errors-BPJGp9I6.js} +1 -1
  8. package/dist/{errors-C53fe686.d.ts → errors-T_0JE528.d.ts} +1 -1
  9. package/dist/{index-BbEVpN5e.d.ts → index-9Rqocr-c.d.ts} +87 -75
  10. package/dist/{index-Dbx9udpX.d.ts → index-EQZK4vWT.d.ts} +2 -2
  11. package/dist/index.d.ts +4 -4
  12. package/dist/index.js +3 -3
  13. package/dist/openapi/index.d.ts +1 -52
  14. package/dist/openapi/index.js +2 -8
  15. package/dist/operations.generated-BJERV_56.d.ts +53 -0
  16. package/dist/operations.generated-T3exFpgJ.js +7632 -0
  17. package/dist/parser/index.d.ts +1 -1
  18. package/dist/parser/index.js +1 -1
  19. package/dist/webhook/index.d.ts +3 -3
  20. package/dist/webhook/index.js +2 -2
  21. package/dist/{webhook-DJkfUnFZ.js → webhook-Bra-g1q8.js} +1 -1
  22. package/package.json +9 -69
  23. package/bin/run.js +0 -20
  24. package/dist/api/generated/client/client.gen.js +0 -235
  25. package/dist/api/generated/client/index.js +0 -6
  26. package/dist/api/generated/client/types.gen.js +0 -2
  27. package/dist/api/generated/client/utils.gen.js +0 -228
  28. package/dist/api/generated/client.gen.js +0 -3
  29. package/dist/api/generated/core/auth.gen.js +0 -14
  30. package/dist/api/generated/core/bodySerializer.gen.js +0 -57
  31. package/dist/api/generated/core/params.gen.js +0 -100
  32. package/dist/api/generated/core/pathSerializer.gen.js +0 -106
  33. package/dist/api/generated/core/queryKeySerializer.gen.js +0 -92
  34. package/dist/api/generated/core/serverSentEvents.gen.js +0 -132
  35. package/dist/api/generated/core/types.gen.js +0 -2
  36. package/dist/api/generated/core/utils.gen.js +0 -87
  37. package/dist/api/generated/index.js +0 -2
  38. package/dist/api/generated/sdk.gen.js +0 -878
  39. package/dist/api/generated/types.gen.js +0 -2
  40. package/dist/api/verify-signature.js +0 -198
  41. package/dist/oclif/api-command.js +0 -755
  42. package/dist/oclif/auth.js +0 -223
  43. package/dist/oclif/commands/emails-latest.js +0 -185
  44. package/dist/oclif/commands/emails-poll.js +0 -121
  45. package/dist/oclif/commands/emails-wait.js +0 -171
  46. package/dist/oclif/commands/emails-watch.js +0 -165
  47. package/dist/oclif/commands/functions-deploy.js +0 -124
  48. package/dist/oclif/commands/functions-init.js +0 -256
  49. package/dist/oclif/commands/functions-redeploy.js +0 -113
  50. package/dist/oclif/commands/functions-set-secret.js +0 -213
  51. package/dist/oclif/commands/login.js +0 -237
  52. package/dist/oclif/commands/logout.js +0 -88
  53. package/dist/oclif/commands/send.js +0 -222
  54. package/dist/oclif/commands/whoami.js +0 -95
  55. package/dist/oclif/fish-completion.js +0 -87
  56. package/dist/oclif/index.js +0 -167
  57. package/dist/oclif/lint/raw-send-mail-fetch.js +0 -98
  58. package/dist/openapi/openapi.generated.js +0 -5754
  59. package/dist/openapi/operations.generated.js +0 -4626
  60. package/dist/parser/address-parser.js +0 -129
  61. package/dist/types.generated.js +0 -7
  62. package/dist/types.js +0 -53
  63. package/dist/webhook/errors.js +0 -224
  64. package/dist/webhook/received-email.js +0 -82
  65. package/oclif.manifest.json +0 -4380
  66. /package/dist/{address-parser-BYn8oW5r.js → address-parser-CQbFjgRC.js} +0 -0
  67. /package/dist/{types-9vXGZjPd.d.ts → types-Nslo1CU0.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { M as WebhookAttachment, S as ParsedDataComplete, s as EmailAddress } from "../types-9vXGZjPd.js";
1
+ import { M as WebhookAttachment, S as ParsedDataComplete, s as EmailAddress } from "../types-Nslo1CU0.js";
2
2
 
3
3
  //#region src/parser/address-parser.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { n as parseFromHeaderLoose, t as parseFromHeader } from "../address-parser-BYn8oW5r.js";
1
+ import { n as parseFromHeaderLoose, t as parseFromHeader } from "../address-parser-CQbFjgRC.js";
2
2
  import { createHash } from "node:crypto";
3
3
  import { createGzip } from "node:zlib";
4
4
  import { pack } from "tar-stream";
@@ -1,4 +1,4 @@
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 { _ as buildForwardSubject, a as RawEmailDecodeErrorCode, b as normalizeReceivedEmail, c as WebhookPayloadError, d as WebhookValidationErrorCode, f as WebhookVerificationError, g as ReceivedEmailThread, h as ReceivedEmailAddress, i as RawEmailDecodeError, l as WebhookPayloadErrorCode, m as ReceivedEmail, n as PrimitiveWebhookError, o as VERIFICATION_ERRORS, p as WebhookVerificationErrorCode, r as RAW_EMAIL_ERRORS, s as WebhookErrorCode, t as PAYLOAD_ERRORS, u as WebhookValidationError, v as buildReplySubject, x as parseHeaderAddress, y as formatAddress } from "../errors-C53fe686.js";
3
- import { A as VerifyOptions, C as signStandardWebhooksPayload, D as PRIMITIVE_CONFIRMED_HEADER, E as LEGACY_SIGNATURE_HEADER, F as VerifyDownloadTokenResult, I as generateDownloadToken, L as verifyDownloadToken, M as verifyWebhookSignature, N as GenerateDownloadTokenOptions, O as PRIMITIVE_SIGNATURE_HEADER, P as VerifyDownloadTokenOptions, R as safeValidateEmailReceivedEvent, S as StandardWebhooksVerifyOptions, T as LEGACY_CONFIRMED_HEADER, _ 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, 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-Dbx9udpX.js";
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-Nslo1CU0.js";
2
+ import { _ as buildForwardSubject, a as RawEmailDecodeErrorCode, b as normalizeReceivedEmail, c as WebhookPayloadError, d as WebhookValidationErrorCode, f as WebhookVerificationError, g as ReceivedEmailThread, h as ReceivedEmailAddress, i as RawEmailDecodeError, l as WebhookPayloadErrorCode, m as ReceivedEmail, n as PrimitiveWebhookError, o as VERIFICATION_ERRORS, p as WebhookVerificationErrorCode, r as RAW_EMAIL_ERRORS, s as WebhookErrorCode, t as PAYLOAD_ERRORS, u as WebhookValidationError, v as buildReplySubject, x as parseHeaderAddress, y as formatAddress } from "../errors-T_0JE528.js";
3
+ import { A as VerifyOptions, C as signStandardWebhooksPayload, D as PRIMITIVE_CONFIRMED_HEADER, E as LEGACY_SIGNATURE_HEADER, F as VerifyDownloadTokenResult, I as generateDownloadToken, L as verifyDownloadToken, M as verifyWebhookSignature, N as GenerateDownloadTokenOptions, O as PRIMITIVE_SIGNATURE_HEADER, P as VerifyDownloadTokenOptions, R as safeValidateEmailReceivedEvent, S as StandardWebhooksVerifyOptions, T as LEGACY_CONFIRMED_HEADER, _ 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, 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-EQZK4vWT.js";
4
4
  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, ReceiveRequestOptions, ReceivedEmail, ReceivedEmailAddress, ReceivedEmailThread, 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, buildForwardSubject, buildReplySubject, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
@@ -1,3 +1,3 @@
1
- import { a as VERIFICATION_ERRORS, c as WebhookVerificationError, d as formatAddress, f as normalizeReceivedEmail, i as RawEmailDecodeError, l as buildForwardSubject, n as PrimitiveWebhookError, o as WebhookPayloadError, p as parseHeaderAddress, r as RAW_EMAIL_ERRORS, s as WebhookValidationError, t as PAYLOAD_ERRORS, u as buildReplySubject } from "../errors-x91I_yEt.js";
2
- import { A as PRIMITIVE_CONFIRMED_HEADER, C as STANDARD_WEBHOOK_ID_HEADER, D as verifyStandardWebhooksSignature, E as signStandardWebhooksPayload, F as verifyDownloadToken, I as safeValidateEmailReceivedEvent, L as validateEmailReceivedEvent, M as signWebhookPayload, N as verifyWebhookSignature, O as LEGACY_CONFIRMED_HEADER, P as generateDownloadToken, S as emailReceivedEventJsonSchema, T as STANDARD_WEBHOOK_TIMESTAMP_HEADER, _ 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 } from "../webhook-DJkfUnFZ.js";
1
+ import { a as VERIFICATION_ERRORS, c as WebhookVerificationError, d as formatAddress, f as normalizeReceivedEmail, i as RawEmailDecodeError, l as buildForwardSubject, n as PrimitiveWebhookError, o as WebhookPayloadError, p as parseHeaderAddress, r as RAW_EMAIL_ERRORS, s as WebhookValidationError, t as PAYLOAD_ERRORS, u as buildReplySubject } from "../errors-BPJGp9I6.js";
2
+ import { A as PRIMITIVE_CONFIRMED_HEADER, C as STANDARD_WEBHOOK_ID_HEADER, D as verifyStandardWebhooksSignature, E as signStandardWebhooksPayload, F as verifyDownloadToken, I as safeValidateEmailReceivedEvent, L as validateEmailReceivedEvent, M as signWebhookPayload, N as verifyWebhookSignature, O as LEGACY_CONFIRMED_HEADER, P as generateDownloadToken, S as emailReceivedEventJsonSchema, T as STANDARD_WEBHOOK_TIMESTAMP_HEADER, _ 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 } from "../webhook-Bra-g1q8.js";
3
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, buildForwardSubject, buildReplySubject, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
@@ -1,4 +1,4 @@
1
- import { c as WebhookVerificationError, f as normalizeReceivedEmail, i as RawEmailDecodeError, o as WebhookPayloadError, s as WebhookValidationError } from "./errors-x91I_yEt.js";
1
+ import { c as WebhookVerificationError, f as normalizeReceivedEmail, i as RawEmailDecodeError, o as WebhookPayloadError, s as WebhookValidationError } from "./errors-BPJGp9I6.js";
2
2
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
3
3
  //#region src/generated/email-received-event.validator.generated.ts
4
4
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primitivedotdev/sdk",
3
- "version": "0.26.1",
4
- "description": "Official Primitive Node.js SDK: webhook, api, openapi, contract, and parser runtime modules. The CLI moved to @primitivedotdev/cli; this package retains the CLI as a deprecated alias for a few minor releases.",
3
+ "version": "0.27.1",
4
+ "description": "Official Primitive Node.js SDK: webhook, api, openapi, contract, and parser runtime modules.",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -39,74 +39,20 @@
39
39
  },
40
40
  "sideEffects": false,
41
41
  "files": [
42
- "bin",
43
- "dist",
44
- "oclif.manifest.json"
42
+ "dist"
45
43
  ],
46
- "bin": {
47
- "primitive": "./bin/run.js"
48
- },
49
- "oclif": {
50
- "bin": "primitive",
51
- "commands": {
52
- "strategy": "explicit",
53
- "target": "./dist/oclif/index.js",
54
- "identifier": "COMMANDS"
55
- },
56
- "dirname": "primitive",
57
- "plugins": [
58
- "@oclif/plugin-help",
59
- "@oclif/plugin-autocomplete"
60
- ],
61
- "topics": {
62
- "cli": {
63
- "description": "Browser-assisted CLI authentication"
64
- },
65
- "account": {
66
- "description": "Manage your account settings, storage, and webhook secret"
67
- },
68
- "domains": {
69
- "description": "Claim, verify, and manage email domains"
70
- },
71
- "emails": {
72
- "description": "List, inspect, and wait for received emails. `primitive emails:latest` lists the most recent inbound, `primitive emails:wait` blocks until matching inbound arrives (filter with --to/--from/--subject/--q; bounded by --timeout and --number; ideal for agents and CI), and `primitive emails:watch` streams new matches indefinitely for long-running terminals."
73
- },
74
- "sending": {
75
- "description": "Send outbound emails. For replies to inbound mail, use `sending:reply-to-email --id <inbound-id>` (threading and Re: subject derived server-side); for fresh sends, use `sending:send-email` or the `primitive send` shortcut."
76
- },
77
- "endpoints": {
78
- "description": "Manage webhook endpoints that receive email events"
79
- },
80
- "filters": {
81
- "description": "Manage whitelist and blocklist filter rules"
82
- },
83
- "webhook-deliveries": {
84
- "description": "View and replay webhook delivery attempts"
85
- },
86
- "functions": {
87
- "description": "Deploy JavaScript handlers that run on inbound mail. Use `primitive functions:init <name>` to scaffold a deployable project (handler, package.json, build script). Use `primitive functions:deploy --name <name> --file <bundle.js>` to create, `primitive functions:redeploy --id <id> --file <bundle.js>` to push a new bundle, and `primitive functions:set-secret --id <id> --key <KEY> --value <value> [--redeploy]` to write a secret (with optional one-call redeploy so the value lands in the running handler). The auto-generated functions:create-function / functions:update-function / functions:create-function-secret / functions:set-function-secret operations stay available for the full body-string surface."
88
- }
89
- },
90
- "topicSeparator": " "
91
- },
92
44
  "scripts": {
93
- "generate:openapi": "tsx scripts/generate-openapi-artifacts.ts",
94
- "generate:api": "openapi-ts -f openapi-ts.config.ts && tsx scripts/fix-generated-api-imports.ts",
95
45
  "generate:schema": "tsx scripts/generate-schema-module.ts",
96
46
  "generate:types": "tsx scripts/generate-types.ts",
97
47
  "generate:validator": "tsx scripts/generate-validator.ts",
98
- "generate": "pnpm generate:openapi && pnpm generate:api && pnpm generate:schema && pnpm generate:types && pnpm generate:validator",
99
- "build:library": "pnpm generate && tsdown",
100
- "build:oclif": "tsc -p tsconfig.oclif.json",
101
- "build": "pnpm build:library && pnpm build:oclif",
48
+ "generate": "pnpm --filter @primitivedotdev/api-core generate && pnpm generate:schema && pnpm generate:types && pnpm generate:validator",
49
+ "build": "pnpm generate && NODE_OPTIONS=\"--max-old-space-size=4096\" tsdown",
102
50
  "test": "vitest run",
103
51
  "test:coverage": "vitest run --coverage",
104
52
  "test:watch": "vitest",
105
53
  "typecheck": "pnpm generate && tsc --noEmit -p tsconfig.typecheck.json",
106
- "lint": "biome check --error-on-warnings src/index.ts src/validation.ts src/types.ts src/webhook src/contract src/parser src/api/index.ts src/openapi/index.ts src/oclif tests/",
107
- "lint:fix": "biome check --write --error-on-warnings src/index.ts src/validation.ts src/types.ts src/webhook src/contract src/parser src/api/index.ts src/openapi/index.ts src/oclif tests/",
108
- "prepack": "pnpm build && oclif manifest",
109
- "postpack": "shx rm -f oclif.manifest.json",
54
+ "lint": "biome check --error-on-warnings src/index.ts src/validation.ts src/types.ts src/webhook src/contract src/parser src/api/index.ts src/openapi/index.ts tests/",
55
+ "lint:fix": "biome check --write --error-on-warnings src/index.ts src/validation.ts src/types.ts src/webhook src/contract src/parser src/api/index.ts src/openapi/index.ts tests/",
110
56
  "prepublishOnly": "pnpm build"
111
57
  },
112
58
  "keywords": [
@@ -135,9 +81,6 @@
135
81
  "node": ">=22"
136
82
  },
137
83
  "dependencies": {
138
- "@oclif/core": "^4.10.5",
139
- "@oclif/plugin-autocomplete": "^3.2.45",
140
- "@oclif/plugin-help": "^6.2.44",
141
84
  "ajv": "^8.17.1",
142
85
  "isomorphic-dompurify": "^3.8.0",
143
86
  "mailparser": "^3.9.0",
@@ -147,7 +90,7 @@
147
90
  },
148
91
  "devDependencies": {
149
92
  "@biomejs/biome": "^2.4.10",
150
- "@hey-api/openapi-ts": "0.96.0",
93
+ "@primitivedotdev/api-core": "workspace:*",
151
94
  "@types/json-schema": "^7.0.15",
152
95
  "@types/mailparser": "^3.4.6",
153
96
  "@types/node": "^22.10.2",
@@ -156,13 +99,10 @@
156
99
  "@types/validator": "^13.15.10",
157
100
  "@vitest/coverage-v8": "^4.1.4",
158
101
  "json-schema-to-typescript": "^15.0.4",
159
- "oclif": "^4.23.0",
160
- "shx": "^0.3.4",
161
102
  "tsdown": "^0.21.10",
162
103
  "tsx": "^4.21.0",
163
104
  "typescript": "^5.7.2",
164
105
  "vite": "^8.0.8",
165
- "vitest": "^4.1.4",
166
- "yaml": "^2.8.1"
106
+ "vitest": "^4.1.4"
167
107
  }
168
108
  }
package/bin/run.js DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // The CLI moved to @primitivedotdev/cli. This bin is retained on
4
- // @primitivedotdev/sdk for a few minor versions so existing scripts
5
- // and agent prompts that invoke `npx @primitivedotdev/sdk@latest
6
- // <command>` keep working. Every invocation prints a one-line stderr
7
- // banner with the migration command; the actual oclif runtime runs
8
- // unchanged after that. The CLI surface will be removed from
9
- // @primitivedotdev/sdk in a future minor release; until then this
10
- // shipped snapshot is frozen against the 0.23.0 command set.
11
- import { execute } from "@oclif/core";
12
-
13
- process.stderr.write(
14
- "[@primitivedotdev/sdk] Heads up: the CLI moved to @primitivedotdev/cli. " +
15
- "Switch to `npx @primitivedotdev/cli@latest <command>` " +
16
- "(or `npm install -g @primitivedotdev/cli`). " +
17
- "The CLI surface will be removed from @primitivedotdev/sdk in a future minor release.\n",
18
- );
19
-
20
- await execute({ dir: import.meta.url });
@@ -1,235 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
- import { createSseClient } from '../core/serverSentEvents.gen.js';
3
- import { getValidRequestBody } from '../core/utils.gen.js';
4
- import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, mergeHeaders, setAuthParams, } from './utils.gen.js';
5
- export const createClient = (config = {}) => {
6
- let _config = mergeConfigs(createConfig(), config);
7
- const getConfig = () => ({ ..._config });
8
- const setConfig = (config) => {
9
- _config = mergeConfigs(_config, config);
10
- return getConfig();
11
- };
12
- const interceptors = createInterceptors();
13
- const beforeRequest = async (options) => {
14
- const opts = {
15
- ..._config,
16
- ...options,
17
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
18
- headers: mergeHeaders(_config.headers, options.headers),
19
- serializedBody: undefined,
20
- };
21
- if (opts.security) {
22
- await setAuthParams({
23
- ...opts,
24
- security: opts.security,
25
- });
26
- }
27
- if (opts.requestValidator) {
28
- await opts.requestValidator(opts);
29
- }
30
- if (opts.body !== undefined && opts.bodySerializer) {
31
- opts.serializedBody = opts.bodySerializer(opts.body);
32
- }
33
- // remove Content-Type header if body is empty to avoid sending invalid requests
34
- if (opts.body === undefined || opts.serializedBody === '') {
35
- opts.headers.delete('Content-Type');
36
- }
37
- const resolvedOpts = opts;
38
- const url = buildUrl(resolvedOpts);
39
- return { opts: resolvedOpts, url };
40
- };
41
- const request = async (options) => {
42
- const { opts, url } = await beforeRequest(options);
43
- const requestInit = {
44
- redirect: 'follow',
45
- ...opts,
46
- body: getValidRequestBody(opts),
47
- };
48
- let request = new Request(url, requestInit);
49
- for (const fn of interceptors.request.fns) {
50
- if (fn) {
51
- request = await fn(request, opts);
52
- }
53
- }
54
- // fetch must be assigned here, otherwise it would throw the error:
55
- // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
56
- const _fetch = opts.fetch;
57
- let response;
58
- try {
59
- response = await _fetch(request);
60
- }
61
- catch (error) {
62
- // Handle fetch exceptions (AbortError, network errors, etc.)
63
- let finalError = error;
64
- for (const fn of interceptors.error.fns) {
65
- if (fn) {
66
- finalError = (await fn(error, undefined, request, opts));
67
- }
68
- }
69
- finalError = finalError || {};
70
- if (opts.throwOnError) {
71
- throw finalError;
72
- }
73
- // Return error response
74
- return opts.responseStyle === 'data'
75
- ? undefined
76
- : {
77
- error: finalError,
78
- request,
79
- response: undefined,
80
- };
81
- }
82
- for (const fn of interceptors.response.fns) {
83
- if (fn) {
84
- response = await fn(response, request, opts);
85
- }
86
- }
87
- const result = {
88
- request,
89
- response,
90
- };
91
- if (response.ok) {
92
- const parseAs = (opts.parseAs === 'auto'
93
- ? getParseAs(response.headers.get('Content-Type'))
94
- : opts.parseAs) ?? 'json';
95
- if (response.status === 204 || response.headers.get('Content-Length') === '0') {
96
- let emptyData;
97
- switch (parseAs) {
98
- case 'arrayBuffer':
99
- case 'blob':
100
- case 'text':
101
- emptyData = await response[parseAs]();
102
- break;
103
- case 'formData':
104
- emptyData = new FormData();
105
- break;
106
- case 'stream':
107
- emptyData = response.body;
108
- break;
109
- case 'json':
110
- default:
111
- emptyData = {};
112
- break;
113
- }
114
- return opts.responseStyle === 'data'
115
- ? emptyData
116
- : {
117
- data: emptyData,
118
- ...result,
119
- };
120
- }
121
- let data;
122
- switch (parseAs) {
123
- case 'arrayBuffer':
124
- case 'blob':
125
- case 'formData':
126
- case 'text':
127
- data = await response[parseAs]();
128
- break;
129
- case 'json': {
130
- // Some servers return 200 with no Content-Length and empty body.
131
- // response.json() would throw; read as text and parse if non-empty.
132
- const text = await response.text();
133
- data = text ? JSON.parse(text) : {};
134
- break;
135
- }
136
- case 'stream':
137
- return opts.responseStyle === 'data'
138
- ? response.body
139
- : {
140
- data: response.body,
141
- ...result,
142
- };
143
- }
144
- if (parseAs === 'json') {
145
- if (opts.responseValidator) {
146
- await opts.responseValidator(data);
147
- }
148
- if (opts.responseTransformer) {
149
- data = await opts.responseTransformer(data);
150
- }
151
- }
152
- return opts.responseStyle === 'data'
153
- ? data
154
- : {
155
- data,
156
- ...result,
157
- };
158
- }
159
- const textError = await response.text();
160
- let jsonError;
161
- try {
162
- jsonError = JSON.parse(textError);
163
- }
164
- catch {
165
- // noop
166
- }
167
- const error = jsonError ?? textError;
168
- let finalError = error;
169
- for (const fn of interceptors.error.fns) {
170
- if (fn) {
171
- finalError = (await fn(error, response, request, opts));
172
- }
173
- }
174
- finalError = finalError || {};
175
- if (opts.throwOnError) {
176
- throw finalError;
177
- }
178
- // TODO: we probably want to return error and improve types
179
- return opts.responseStyle === 'data'
180
- ? undefined
181
- : {
182
- error: finalError,
183
- ...result,
184
- };
185
- };
186
- const makeMethodFn = (method) => (options) => request({ ...options, method });
187
- const makeSseFn = (method) => async (options) => {
188
- const { opts, url } = await beforeRequest(options);
189
- return createSseClient({
190
- ...opts,
191
- body: opts.body,
192
- headers: opts.headers,
193
- method,
194
- onRequest: async (url, init) => {
195
- let request = new Request(url, init);
196
- for (const fn of interceptors.request.fns) {
197
- if (fn) {
198
- request = await fn(request, opts);
199
- }
200
- }
201
- return request;
202
- },
203
- serializedBody: getValidRequestBody(opts),
204
- url,
205
- });
206
- };
207
- const _buildUrl = (options) => buildUrl({ ..._config, ...options });
208
- return {
209
- buildUrl: _buildUrl,
210
- connect: makeMethodFn('CONNECT'),
211
- delete: makeMethodFn('DELETE'),
212
- get: makeMethodFn('GET'),
213
- getConfig,
214
- head: makeMethodFn('HEAD'),
215
- interceptors,
216
- options: makeMethodFn('OPTIONS'),
217
- patch: makeMethodFn('PATCH'),
218
- post: makeMethodFn('POST'),
219
- put: makeMethodFn('PUT'),
220
- request,
221
- setConfig,
222
- sse: {
223
- connect: makeSseFn('CONNECT'),
224
- delete: makeSseFn('DELETE'),
225
- get: makeSseFn('GET'),
226
- head: makeSseFn('HEAD'),
227
- options: makeSseFn('OPTIONS'),
228
- patch: makeSseFn('PATCH'),
229
- post: makeSseFn('POST'),
230
- put: makeSseFn('PUT'),
231
- trace: makeSseFn('TRACE'),
232
- },
233
- trace: makeMethodFn('TRACE'),
234
- };
235
- };
@@ -1,6 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
- export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer.gen.js';
3
- export { buildClientParams } from '../core/params.gen.js';
4
- export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen.js';
5
- export { createClient } from './client.gen.js';
6
- export { createConfig, mergeHeaders } from './utils.gen.js';
@@ -1,2 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
- export {};
@@ -1,228 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
- import { getAuthToken } from '../core/auth.gen.js';
3
- import { jsonBodySerializer } from '../core/bodySerializer.gen.js';
4
- import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from '../core/pathSerializer.gen.js';
5
- import { getUrl } from '../core/utils.gen.js';
6
- export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
7
- const querySerializer = (queryParams) => {
8
- const search = [];
9
- if (queryParams && typeof queryParams === 'object') {
10
- for (const name in queryParams) {
11
- const value = queryParams[name];
12
- if (value === undefined || value === null) {
13
- continue;
14
- }
15
- const options = parameters[name] || args;
16
- if (Array.isArray(value)) {
17
- const serializedArray = serializeArrayParam({
18
- allowReserved: options.allowReserved,
19
- explode: true,
20
- name,
21
- style: 'form',
22
- value,
23
- ...options.array,
24
- });
25
- if (serializedArray)
26
- search.push(serializedArray);
27
- }
28
- else if (typeof value === 'object') {
29
- const serializedObject = serializeObjectParam({
30
- allowReserved: options.allowReserved,
31
- explode: true,
32
- name,
33
- style: 'deepObject',
34
- value: value,
35
- ...options.object,
36
- });
37
- if (serializedObject)
38
- search.push(serializedObject);
39
- }
40
- else {
41
- const serializedPrimitive = serializePrimitiveParam({
42
- allowReserved: options.allowReserved,
43
- name,
44
- value: value,
45
- });
46
- if (serializedPrimitive)
47
- search.push(serializedPrimitive);
48
- }
49
- }
50
- }
51
- return search.join('&');
52
- };
53
- return querySerializer;
54
- };
55
- /**
56
- * Infers parseAs value from provided Content-Type header.
57
- */
58
- export const getParseAs = (contentType) => {
59
- if (!contentType) {
60
- // If no Content-Type header is provided, the best we can do is return the raw response body,
61
- // which is effectively the same as the 'stream' option.
62
- return 'stream';
63
- }
64
- const cleanContent = contentType.split(';')[0]?.trim();
65
- if (!cleanContent) {
66
- return;
67
- }
68
- if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) {
69
- return 'json';
70
- }
71
- if (cleanContent === 'multipart/form-data') {
72
- return 'formData';
73
- }
74
- if (['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))) {
75
- return 'blob';
76
- }
77
- if (cleanContent.startsWith('text/')) {
78
- return 'text';
79
- }
80
- return;
81
- };
82
- const checkForExistence = (options, name) => {
83
- if (!name) {
84
- return false;
85
- }
86
- if (options.headers.has(name) ||
87
- options.query?.[name] ||
88
- options.headers.get('Cookie')?.includes(`${name}=`)) {
89
- return true;
90
- }
91
- return false;
92
- };
93
- export const setAuthParams = async ({ security, ...options }) => {
94
- for (const auth of security) {
95
- if (checkForExistence(options, auth.name)) {
96
- continue;
97
- }
98
- const token = await getAuthToken(auth, options.auth);
99
- if (!token) {
100
- continue;
101
- }
102
- const name = auth.name ?? 'Authorization';
103
- switch (auth.in) {
104
- case 'query':
105
- if (!options.query) {
106
- options.query = {};
107
- }
108
- options.query[name] = token;
109
- break;
110
- case 'cookie':
111
- options.headers.append('Cookie', `${name}=${token}`);
112
- break;
113
- case 'header':
114
- default:
115
- options.headers.set(name, token);
116
- break;
117
- }
118
- }
119
- };
120
- export const buildUrl = (options) => getUrl({
121
- baseUrl: options.baseUrl,
122
- path: options.path,
123
- query: options.query,
124
- querySerializer: typeof options.querySerializer === 'function'
125
- ? options.querySerializer
126
- : createQuerySerializer(options.querySerializer),
127
- url: options.url,
128
- });
129
- export const mergeConfigs = (a, b) => {
130
- const config = { ...a, ...b };
131
- if (config.baseUrl?.endsWith('/')) {
132
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
133
- }
134
- config.headers = mergeHeaders(a.headers, b.headers);
135
- return config;
136
- };
137
- const headersEntries = (headers) => {
138
- const entries = [];
139
- headers.forEach((value, key) => {
140
- entries.push([key, value]);
141
- });
142
- return entries;
143
- };
144
- export const mergeHeaders = (...headers) => {
145
- const mergedHeaders = new Headers();
146
- for (const header of headers) {
147
- if (!header) {
148
- continue;
149
- }
150
- const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
151
- for (const [key, value] of iterator) {
152
- if (value === null) {
153
- mergedHeaders.delete(key);
154
- }
155
- else if (Array.isArray(value)) {
156
- for (const v of value) {
157
- mergedHeaders.append(key, v);
158
- }
159
- }
160
- else if (value !== undefined) {
161
- // assume object headers are meant to be JSON stringified, i.e., their
162
- // content value in OpenAPI specification is 'application/json'
163
- mergedHeaders.set(key, typeof value === 'object' ? JSON.stringify(value) : value);
164
- }
165
- }
166
- }
167
- return mergedHeaders;
168
- };
169
- class Interceptors {
170
- fns = [];
171
- clear() {
172
- this.fns = [];
173
- }
174
- eject(id) {
175
- const index = this.getInterceptorIndex(id);
176
- if (this.fns[index]) {
177
- this.fns[index] = null;
178
- }
179
- }
180
- exists(id) {
181
- const index = this.getInterceptorIndex(id);
182
- return Boolean(this.fns[index]);
183
- }
184
- getInterceptorIndex(id) {
185
- if (typeof id === 'number') {
186
- return this.fns[id] ? id : -1;
187
- }
188
- return this.fns.indexOf(id);
189
- }
190
- update(id, fn) {
191
- const index = this.getInterceptorIndex(id);
192
- if (this.fns[index]) {
193
- this.fns[index] = fn;
194
- return id;
195
- }
196
- return false;
197
- }
198
- use(fn) {
199
- this.fns.push(fn);
200
- return this.fns.length - 1;
201
- }
202
- }
203
- export const createInterceptors = () => ({
204
- error: new Interceptors(),
205
- request: new Interceptors(),
206
- response: new Interceptors(),
207
- });
208
- const defaultQuerySerializer = createQuerySerializer({
209
- allowReserved: false,
210
- array: {
211
- explode: true,
212
- style: 'form',
213
- },
214
- object: {
215
- explode: true,
216
- style: 'deepObject',
217
- },
218
- });
219
- const defaultHeaders = {
220
- 'Content-Type': 'application/json',
221
- };
222
- export const createConfig = (override = {}) => ({
223
- ...jsonBodySerializer,
224
- headers: defaultHeaders,
225
- parseAs: 'auto',
226
- querySerializer: defaultQuerySerializer,
227
- ...override,
228
- });