@npayload/sdk 0.0.0-stage → 5.0.5

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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +160 -2
  3. package/dist/chunk-26BFOUGE.mjs +1 -0
  4. package/dist/chunk-2XQXDEXA.mjs +1 -0
  5. package/dist/chunk-455C67EN.mjs +1 -0
  6. package/dist/chunk-4NWQCPI4.mjs +1 -0
  7. package/dist/chunk-5KFQTEH3.mjs +1 -0
  8. package/dist/chunk-5SMWYS7Z.mjs +1 -0
  9. package/dist/chunk-5WGVEULS.mjs +3 -0
  10. package/dist/chunk-6BBB7BRP.mjs +1 -0
  11. package/dist/chunk-6HF3N3NR.mjs +1 -0
  12. package/dist/chunk-6ITUDSL7.mjs +17 -0
  13. package/dist/chunk-A7HA64P6.mjs +1 -0
  14. package/dist/chunk-APBVAT7F.mjs +1 -0
  15. package/dist/chunk-BBHWYMQA.mjs +1 -0
  16. package/dist/chunk-CJDCY2NH.mjs +1 -0
  17. package/dist/chunk-CNAIHF3M.mjs +1 -0
  18. package/dist/chunk-CWBN2DOO.mjs +1 -0
  19. package/dist/chunk-EXNCOEHS.mjs +1 -0
  20. package/dist/chunk-FAO3QJC5.mjs +1 -0
  21. package/dist/chunk-GEJT7NMK.mjs +1 -0
  22. package/dist/chunk-GGXNXM73.mjs +1 -0
  23. package/dist/chunk-HTQLUO4J.mjs +1 -0
  24. package/dist/chunk-I3UZ2FRE.mjs +1 -0
  25. package/dist/chunk-I7YPDC7V.mjs +2 -0
  26. package/dist/chunk-IK32U5FV.mjs +1 -0
  27. package/dist/chunk-JNYV4RW3.mjs +1 -0
  28. package/dist/chunk-JUXYOKI2.mjs +64 -0
  29. package/dist/chunk-K3SNPW2B.mjs +9 -0
  30. package/dist/chunk-KUJJYP3K.mjs +22 -0
  31. package/dist/chunk-LJNU5QHZ.mjs +1 -0
  32. package/dist/chunk-LVVHOJLW.mjs +5 -0
  33. package/dist/chunk-MDW42OG6.mjs +8 -0
  34. package/dist/chunk-MPYL6HQR.mjs +1 -0
  35. package/dist/chunk-MW4TLR2T.mjs +1 -0
  36. package/dist/chunk-O7HHWVMT.mjs +1 -0
  37. package/dist/chunk-OA73YMB6.mjs +6 -0
  38. package/dist/chunk-P5GCOROB.mjs +1 -0
  39. package/dist/chunk-PKG2R6XN.mjs +1 -0
  40. package/dist/chunk-PYLSDRRO.mjs +20 -0
  41. package/dist/chunk-QGH4LHSH.mjs +4 -0
  42. package/dist/chunk-QHGF2GC6.mjs +1 -0
  43. package/dist/chunk-SRQQNHSX.mjs +5 -0
  44. package/dist/chunk-TQFAYJEP.mjs +4 -0
  45. package/dist/chunk-UJP3Q23X.mjs +1 -0
  46. package/dist/chunk-UNDT7J2V.mjs +1 -0
  47. package/dist/chunk-X3VVI7V3.mjs +1 -0
  48. package/dist/chunk-XLK55DEY.mjs +1 -0
  49. package/dist/cli/index.d.mts +54 -0
  50. package/dist/cli/index.d.ts +54 -0
  51. package/dist/cli/index.js +854 -0
  52. package/dist/cli/index.mjs +698 -0
  53. package/dist/events/index.d.mts +10 -0
  54. package/dist/events/index.d.ts +10 -0
  55. package/dist/events/index.js +1 -0
  56. package/dist/events/index.mjs +1 -0
  57. package/dist/index.d.mts +49687 -0
  58. package/dist/index.d.ts +49687 -0
  59. package/dist/index.js +2 -0
  60. package/dist/index.mjs +2 -0
  61. package/package.json +120 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The npayload authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,161 @@
1
- # Temporary Holding Version
1
+ # npayload
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ npayload makes your systems autonomous, on one platform. This package is the
4
+ SDK and the CLI for the whole platform: `np.events`, `np.pipes`, `np.primus`
5
+ (AI agents), `np.connect` and `np.feed`.
6
+
7
+ ```bash
8
+ npm install @npayload/sdk
9
+ ```
10
+
11
+ The package ships the SDK, the `npayload` CLI (also callable as `np`) and its MCP server for coding agents.
12
+
13
+ ## Quickstart
14
+
15
+ ```bash
16
+ npx @npayload/sdk init # provision credentials and scaffold a project (device flow)
17
+ # or, non-interactive:
18
+ np login --org <org> --app <app> --env sandbox
19
+ ```
20
+
21
+ ```ts
22
+ import { NPayload } from "@npayload/sdk";
23
+
24
+ // The credentials `npx @npayload/sdk init` wrote into your project's .env, on npayload's production API
25
+ // (on another npayload deployment, pass its API as `baseUrl`: see Transports below)
26
+ const np = await NPayload.connect({ clientId: process.env.NPAYLOAD_CLIENT_ID! });
27
+
28
+ // Publish an event to a channel, by the channel's slug
29
+ await np.events.publish("orders", { orderId: "ord_123", total: 4200 }, { routingKey: "order.confirmed" });
30
+
31
+ // Manage channels, subscriptions, pipes and agents the same way
32
+ const channels = await np.events.channels.list();
33
+ ```
34
+
35
+ ## Transports
36
+
37
+ The live connection (NPP), npayload's own signed protocol, is the default
38
+ transport for publish, subscribe and delivery. Every frame is signed (Ed25519)
39
+ with your app's key. HTTP/JSON is a permanent opt-in:
40
+
41
+ ```ts
42
+ import { NPayload } from "@npayload/sdk";
43
+
44
+ const np = await NPayload.connect({ clientId: process.env.NPAYLOAD_CLIENT_ID!, transport: "http" }); // explicit opt-in
45
+ // or NPAYLOAD_TRANSPORT=http, or `np --transport http` on the CLI
46
+ ```
47
+
48
+ By default the SDK and the CLI reach npayload's hosted service: its API at
49
+ `api.npayload.com`, which also serves sign-in, and the live connection at
50
+ `npp.npayload.com`. Nothing writes those defaults into your `.env`.
51
+
52
+ To use another npayload deployment, a private one or a local one while you
53
+ develop, name its API, its sign-in host and its live connection together:
54
+
55
+ - In code, with the `baseUrl`, `authUrl` and `edgeUrl` options of
56
+ `NPayload.connect` and `new NPayload`.
57
+ - In the shell that runs `np`, `npx @npayload/sdk init` or `np login`, with
58
+ `NPAYLOAD_API_URL`, `NPAYLOAD_AUTH_URL` and `NPAYLOAD_EDGE_URL`. The CLI reads
59
+ your project's `.env` to see which deployment you are on, but dials only what
60
+ the shell exports, so export them.
61
+ On npayload's production estate, with no auth host named, every `np`
62
+ command gets its token from the production API's own token door,
63
+ `https://api.npayload.com/oauth/token`; with another API and no auth
64
+ host named, from that API.
65
+ - For a new project, `npx @npayload/sdk init --edge-url <url>` writes that live
66
+ connection into its `.env`; a `.env` that already holds your credentials is
67
+ kept as it is.
68
+
69
+ One run, one deployment. As soon as any address you set is outside
70
+ `npayload.com` (a look-alike such as `evilnpayload.com` or
71
+ `api.npayload.com.evil.test` is outside), nothing the run sends goes to the
72
+ hosted service: no token request, sign-in, publish, subscribe or management
73
+ call, and no redirect there is followed. Anything that would go there is
74
+ refused before a request is sent, with a `TransportUnavailableError` in code
75
+ and the code `TRANSPORT_UNAVAILABLE` printed by `np`; the error names what to
76
+ set, and nothing is retried after it.
77
+
78
+ There is no silent fallback between transports: if the live connection is
79
+ selected (or defaulted) and unavailable, calls fail with a typed
80
+ `TransportUnavailableError`. The details are in the docs:
81
+ https://docs.npayload.com/docs/concepts/transports.
82
+
83
+ ## Webhooks
84
+
85
+ ```ts
86
+ import { WebhookHandler } from "@npayload/sdk";
87
+
88
+ const webhooks = new WebhookHandler();
89
+ // The raw request body, the request's headers and your endpoint's signing secret
90
+ const event = await webhooks.constructEvent(rawBody, req.headers, endpointSecret);
91
+ ```
92
+
93
+ During development, pair a local listener with a synthetic trigger:
94
+
95
+ ```bash
96
+ np listen --forward http://localhost:3000/api/webhooks # temporary subscription, forwarded to your handler
97
+ np trigger order.confirmed # fire a sample event at it
98
+ ```
99
+
100
+ ## Networks and fingerprints
101
+
102
+ npayload serves a machine call only when it comes from a network its app
103
+ environment declares, and, once your API key's instances are enrolled, only
104
+ when it presents an enrolled key fingerprint. An administrator declares the
105
+ networks in the dashboard under Settings > Security > Networks.
106
+
107
+ An instance's fingerprint is the RFC 7638 thumbprint of its DPoP public key.
108
+ Keep the key to keep the fingerprint: `NPayload.connect()` uses the key you pass
109
+ as `dpopPrivateJwk`, else the one in `NPAYLOAD_DPOP_PRIVATE_JWK` (which
110
+ `npx @npayload/sdk init` writes into your `.env`), else a new one on every start.
111
+
112
+ ```ts
113
+ import { NPayload, NPayloadSourceNotAllowedError, NPayloadFingerprintNotEnrolledError } from "@npayload/sdk";
114
+
115
+ const np = await NPayload.connect({ clientId: process.env.NPAYLOAD_CLIENT_ID! });
116
+ const fingerprint = await np.fingerprint(); // the value the dashboard lists under the API key
117
+
118
+ try {
119
+ await np.enroll(); // the first connection, made now, while the key's enrollment window is open
120
+ } catch (err) {
121
+ if (err instanceof NPayloadSourceNotAllowedError) {
122
+ // this machine's network is not declared for the environment (err.reason: "not_allowed" | "not_declared")
123
+ } else if (err instanceof NPayloadFingerprintNotEnrolledError) {
124
+ // the window is closed and err.fingerprint is not enrolled for this API key
125
+ } else {
126
+ throw err;
127
+ }
128
+ }
129
+ ```
130
+
131
+ A call refused for its network is tried once more on a fresh token, then
132
+ rejects with `NPayloadSourceNotAllowedError`; a call refused for its fingerprint
133
+ rejects with `NPayloadFingerprintNotEnrolledError` at once. Neither error
134
+ carries your address. The `np` CLI prints the address this machine reaches
135
+ npayload from, read on your machine and sent nowhere, with the entry to add.
136
+
137
+ ## CLI highlights
138
+
139
+ | Command | What it does |
140
+ |---|---|
141
+ | `np init` / `np login` | Provision credentials (device flow or flags); stored in the OS keychain |
142
+ | `np pull` / `np deploy` | Config as code: secrets always become `{{ secrets.… }}` references, never literals |
143
+ | `np validate` | Fails on raw secret values in config |
144
+ | `np listen` | Forward live webhooks to localhost with signature headers intact |
145
+ | `np trigger <event-type>` | Fire a sample event (catalogue example or `--payload-file`) |
146
+ | `np tail <channel>` | Watch events arrive on a channel, live |
147
+ | `np doctor` | Environment, network and auth diagnostics |
148
+
149
+ ## Requirements
150
+
151
+ Node.js 22.23.4 or later on the 22 line, 24.22.1 or later on the 24 line, or 26.12.1 and later. These are the
152
+ first releases with the fixes of the [Node.js security release of October 2026](https://nodejs.org/en/blog/vulnerability/october-2026-security-releases).
153
+ Node.js 20 and older are end-of-life and are not supported. Check with `node --version`.
154
+
155
+ ## Documentation
156
+
157
+ - Docs: https://docs.npayload.com
158
+
159
+ ## License
160
+
161
+ MIT, see [LICENSE](./LICENSE).
@@ -0,0 +1 @@
1
+ import{a,b,c}from"./chunk-MDW42OG6.mjs";import"./chunk-LJNU5QHZ.mjs";export{c as appendAccessScopes,a as renderScopesArray,b as setAccessScopes};
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-LJNU5QHZ.mjs";var t="f4d5410c733e4c4a28858907bb7addc6d1fd34280961bdfb74cf0ac7a0a8419b";function s(n){return n}e(s,"defineEventsConfig");var r={channels:{identity:"slug",deps:[],refs:{},ops:{archive:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/archive",scopes:["channels:admin"],pathParams:{channelId:"channelGid"}},create:{convexFn:"",method:"POST",pattern:"/v1/apps/channels",scopes:["channels:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/apps/channels",scopes:["channels:read"]},pause:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/pause",scopes:["channels:write"],pathParams:{channelId:"channelGid"}},remove:{convexFn:"",method:"DELETE",pattern:"/v1/channels/:channelId",scopes:["channels:admin"],pathParams:{channelId:"channelGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/resume",scopes:["channels:write"],pathParams:{channelId:"channelGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/channels/:channelId",scopes:["channels:write"],pathParams:{channelId:"channelGid"},updatable:["complianceClass","nppMinQos","rateLimit","name","description","status","schema","settings","privacy","replication","compactionConfig","schemaValidation","platformConnectEnforcement","metadata","pii"]}}},consumerGroups:{identity:"name",deps:["channels"],refs:{channelGid:{parent:"channels",product:"events",wire:"gid",identity:"slug",array:!1,publicField:"channelGid"}},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelGid/consumer-groups",scopes:["consumer_groups:write"],pathParams:{channelGid:"channelGid"}},join:{convexFn:"",method:"POST",pattern:"/v1/consumer-groups/:consumerGroupGid/members",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"},updatable:["subscriptionGid"]},leave:{convexFn:"",method:"DELETE",pattern:"/v1/consumer-groups/:consumerGroupGid/members/:subscriptionGid",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid",subscriptionGid:"subscriptionGid"}},list:{convexFn:"",method:"GET",pattern:"/v1/channels/:channelGid/consumer-groups",scopes:["consumer_groups:read"],pathParams:{channelGid:"channelGid"}},pause:{convexFn:"",method:"POST",pattern:"/v1/consumer-groups/:consumerGroupGid/pause",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/consumer-groups/:consumerGroupGid/resume",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/consumer-groups/:consumerGroupGid",scopes:["consumer_groups:write"],pathParams:{consumerGroupGid:"groupGid"},updatable:["strategy","maxConcurrency"]}}},eventTypes:{identity:"name",deps:["channels"],refs:{channels:{parent:"channels",product:"events",wire:"gid",identity:"slug",array:!0,publicField:"channels"}},ops:{activate:{convexFn:"",method:"POST",pattern:"/v1/events/types/:eventTypeGid/activate",scopes:["catalogue:write"],pathParams:{eventTypeGid:"eventTypeGid"}},deprecate:{convexFn:"",method:"POST",pattern:"/v1/events/types/:eventTypeGid/deprecate",scopes:["catalogue:admin"],pathParams:{eventTypeGid:"eventTypeGid"},updatable:["message","sunsetDate"]},list:{convexFn:"",method:"GET",pattern:"/v1/apps/events/types",scopes:["catalogue:read"]},create:{convexFn:"",method:"POST",pattern:"/v1/apps/events/types",scopes:["catalogue:write"]},registerVersion:{convexFn:"",method:"POST",pattern:"/v1/events/types/:eventTypeGid/versions",scopes:["catalogue:write"],pathParams:{eventTypeGid:"eventTypeGid"},updatable:["version","schema","compatibility","changelog","publishedBy"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/events/types/:eventTypeGid",scopes:["catalogue:write"],pathParams:{eventTypeGid:"eventTypeGid"},updatable:["displayName","description","ownership","channels","tags","schema"]}}},exchanges:{identity:"name",deps:[],refs:{},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/exchanges",scopes:["exchanges:write"]},createBinding:{convexFn:"",method:"POST",pattern:"/v1/exchanges/:exchange_gid/bindings",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"},updatable:["channelGid","routingKey","headerRules"]},pause:{convexFn:"",method:"POST",pattern:"/v1/exchanges/:exchange_gid/disable",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/exchanges/:exchange_gid/enable",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"}},list:{convexFn:"",method:"GET",pattern:"/v1/exchanges",scopes:["exchanges:read"]},remove:{convexFn:"",method:"DELETE",pattern:"/v1/exchanges/:exchange_gid",scopes:["exchanges:admin"],pathParams:{exchange_gid:"exchangeGid"}},removeBinding:{convexFn:"",method:"DELETE",pattern:"/v1/exchange-bindings/:binding_gid",scopes:["exchanges:write"],pathParams:{binding_gid:"bindingGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/exchanges/:exchange_gid",scopes:["exchanges:write"],pathParams:{exchange_gid:"exchangeGid"},updatable:["config"]}}},subscriptions:{identity:"name",deps:["channels"],refs:{channelGid:{parent:"channels",product:"events",wire:"gid",identity:"slug",array:!1,publicField:"channelGid"}},ops:{archive:{convexFn:"",method:"POST",pattern:"/v1/subscriptions/:subscriptionId/archive",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"}},create:{convexFn:"",method:"POST",pattern:"/v1/channels/:channelId/subscriptions",scopes:["subscriptions:write"],pathParams:{channelId:"channelGid"}},list:{convexFn:"",method:"GET",pattern:"/v1/channels/:channelId/subscriptions",scopes:["subscriptions:read"],pathParams:{channelId:"channelGid"}},pause:{convexFn:"",method:"POST",pattern:"/v1/subscriptions/:subscriptionId/pause",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"}},remove:{convexFn:"",method:"DELETE",pattern:"/v1/subscriptions/:subscriptionId",scopes:["subscriptions:admin"],pathParams:{subscriptionId:"subscriptionGid"}},resume:{convexFn:"",method:"POST",pattern:"/v1/subscriptions/:subscriptionId/resume",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"}},update:{convexFn:"",method:"PATCH",pattern:"/v1/subscriptions/:subscriptionId",scopes:["subscriptions:write"],pathParams:{subscriptionId:"subscriptionGid"},updatable:["description","status","filter","endpoint","delivery","dlq","metadata","deliveryConfig","transformPipeId","transformTimeout","transformOnFailure"]}}}};var o="41cca5221cf2d3f14ebe43426ffadbc50816dfa8db8d6325205687a732db66dc";function c(n){return n}e(c,"definePrimusConfig");var p={agents:{identity:"slug",deps:["skills"],refs:{skills:{parent:"skills",product:"primus",wire:"gid",identity:"name",array:!0,publicField:"skills"}},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/agents",scopes:["agents:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/agents",scopes:["agents:read"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/agents/:agentId",scopes:["agents:write"],pathParams:{agentId:"agentGid"},updatable:["name","description","systemPrompt","personality","language","skills","enabledIntegrations","trustLevel","defaultModel","maxTurns","config"]}}},skills:{identity:"slug",deps:[],refs:{},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/skills",scopes:["skills:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/skills",scopes:["skills:read"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/skills/:skillId",scopes:["skills:write"],pathParams:{skillId:"skillGid"},updatable:["name","description","category","icon","executor","enabled","definition","limits"]}}},tools:{identity:"slug",deps:[],refs:{},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/tools",scopes:["tools:write"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/tools",scopes:["tools:read"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/tools/:toolId",scopes:["tools:write"],pathParams:{toolId:"toolGid"},updatable:["description","parameters","outputSchema","riskLevel","requiresApproval","endpoint","executor","timeout","category","secretRef","headers"]}}},triggers:{identity:"slug",deps:["agents"],refs:{agentGid:{parent:"agents",product:"primus",wire:"gid",identity:"slug",array:!1,publicField:"agentGid"}},ops:{create:{convexFn:"",method:"POST",pattern:"/v1/primus/triggers",scopes:["triggers:write"]},update:{convexFn:"",method:"PATCH",pattern:"/v1/primus/triggers/:triggerId",scopes:["triggers:write"],pathParams:{triggerId:"triggerGid"},updatable:["name","description","config","action","conditions","enabled"]},list:{convexFn:"",method:"GET",pattern:"/v1/primus/triggers",scopes:["triggers:read"]}}}};export{t as a,s as b,r as c,o as d,c as e,p as f};