@voidhash/api-spec 0.0.1-alpha.1-canary.2.1.223955
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/LICENSE.md +21 -0
- package/README.md +43 -0
- package/package.json +37 -0
- package/src/api.ts +420 -0
- package/src/auth.ts +102 -0
- package/src/changeset.ts +204 -0
- package/src/errors/admin.ts +11 -0
- package/src/errors/analytics.ts +29 -0
- package/src/errors/api-key.ts +20 -0
- package/src/errors/billing.ts +29 -0
- package/src/errors/changeset.ts +11 -0
- package/src/errors/common.ts +30 -0
- package/src/errors/customer.ts +37 -0
- package/src/errors/index.ts +18 -0
- package/src/errors/organization.ts +20 -0
- package/src/errors/payment-provider.ts +74 -0
- package/src/errors/paywall-location.ts +11 -0
- package/src/errors/paywall.ts +38 -0
- package/src/errors/perk.ts +33 -0
- package/src/errors/product-perk.ts +20 -0
- package/src/errors/product.ts +33 -0
- package/src/errors/project.ts +24 -0
- package/src/errors/sdk.ts +42 -0
- package/src/errors/user.ts +11 -0
- package/src/errors/webhook.ts +38 -0
- package/src/index.ts +5 -0
- package/src/middlewares.ts +32 -0
- package/src/schema.ts +535 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Voidhash s.r.o.
|
|
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
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @voidhash/api-spec
|
|
2
|
+
|
|
3
|
+
`@voidhash/api-spec` contains the shared Voidhash API contracts (routes, schemas, auth headers, and API error types).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install stable:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @voidhash/api-spec@latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Install a specific version:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @voidhash/api-spec@0.0.1-alpha.1
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Install latest canary:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @voidhash/api-spec@canary
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Runtime Expectations
|
|
26
|
+
|
|
27
|
+
- ESM package (`"type": "module"`).
|
|
28
|
+
- Exports TypeScript source files from `src`.
|
|
29
|
+
- Consumers should compile TS dependencies in their build pipeline.
|
|
30
|
+
- Peer dependencies are required from the consuming app:
|
|
31
|
+
- `effect`
|
|
32
|
+
- `@effect/platform`
|
|
33
|
+
|
|
34
|
+
## Release Channels
|
|
35
|
+
|
|
36
|
+
- `latest`: stable releases published from `main`.
|
|
37
|
+
- `canary`: preview builds published from pushes to `preview`.
|
|
38
|
+
|
|
39
|
+
Recommended flow:
|
|
40
|
+
|
|
41
|
+
1. Push `api-spec` changes to `preview` to publish a canary build.
|
|
42
|
+
2. Validate in `voidhash-mono` against `@voidhash/api-spec@canary` (or the exact canary version).
|
|
43
|
+
3. Merge to `main` and publish `latest`.
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voidhash/api-spec",
|
|
3
|
+
"version": "0.0.1-alpha.1-canary.2.1.0223955",
|
|
4
|
+
"private": false,
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/voidhashcom/voidhash",
|
|
8
|
+
"directory": "packages/api-spec"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"LICENSE.md",
|
|
13
|
+
"README.md",
|
|
14
|
+
"package.json"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"registry": "https://registry.npmjs.org/"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./src/index.ts",
|
|
23
|
+
"./errors": "./src/errors/index.ts"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"typecheck": "tsgo --noEmit"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@voidhash/tsconfig": "workspace:*",
|
|
31
|
+
"typescript": "5.6.3"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@effect/platform": "catalog:",
|
|
35
|
+
"effect": "catalog:"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/api.ts
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import { HttpApi, HttpApiEndpoint, HttpApiGroup } from "@effect/platform";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ActionForbiddenError,
|
|
6
|
+
ApiKeyNotFoundError,
|
|
7
|
+
ApiKeyServiceError,
|
|
8
|
+
AuthenticationError,
|
|
9
|
+
ChangesetDeploymentServiceError,
|
|
10
|
+
CustomerInvalidAnonymousIdError,
|
|
11
|
+
CustomerNotFoundError,
|
|
12
|
+
CustomerServiceError,
|
|
13
|
+
OrganizationServiceError,
|
|
14
|
+
PaymentProviderConfigurationServiceError,
|
|
15
|
+
PaymentProviderProductServiceError,
|
|
16
|
+
PaywallLocationServiceError,
|
|
17
|
+
PerkServiceError,
|
|
18
|
+
ProductPerkServiceError,
|
|
19
|
+
ProductPerkValidationError,
|
|
20
|
+
ProductServiceError,
|
|
21
|
+
ProjectServiceError,
|
|
22
|
+
SdkCustomerAlreadyIdentifiedError,
|
|
23
|
+
SdkCustomerNotFoundError,
|
|
24
|
+
SdkServiceError,
|
|
25
|
+
SdkValidationError,
|
|
26
|
+
UserServiceError,
|
|
27
|
+
WebhookDeliveryNotFoundError,
|
|
28
|
+
WebhookEndpointNotFoundError,
|
|
29
|
+
WebhookServiceError,
|
|
30
|
+
WebhookValidationError,
|
|
31
|
+
} from "./errors";
|
|
32
|
+
import { AuthMiddleware } from "./middlewares";
|
|
33
|
+
import {
|
|
34
|
+
ApiKey,
|
|
35
|
+
ApiKeyIdParam,
|
|
36
|
+
ApiKeyWithRawKey,
|
|
37
|
+
AppUserIdParam,
|
|
38
|
+
CreateCustomerBody,
|
|
39
|
+
CreateOrganizationBody,
|
|
40
|
+
CreateProjectBody,
|
|
41
|
+
CreateSecretKeyBody,
|
|
42
|
+
CreateWebhookEndpointBody,
|
|
43
|
+
Customer,
|
|
44
|
+
CustomerIdParam,
|
|
45
|
+
DeployChangesetBody,
|
|
46
|
+
DeployChangesetResponse,
|
|
47
|
+
Organization,
|
|
48
|
+
OrganizationIdParam,
|
|
49
|
+
PaymentProviderConfiguration,
|
|
50
|
+
PaymentProviderProduct,
|
|
51
|
+
PaywallLocation,
|
|
52
|
+
Perk,
|
|
53
|
+
Product,
|
|
54
|
+
ProductIdParam,
|
|
55
|
+
ProductPerk,
|
|
56
|
+
Project,
|
|
57
|
+
EvaluateFeatureFlagsBody,
|
|
58
|
+
SdkCustomer,
|
|
59
|
+
SdkFeatureFlagsResponse,
|
|
60
|
+
SdkHeaders,
|
|
61
|
+
SdkIdentifyBody,
|
|
62
|
+
SdkResolvePaywallBody,
|
|
63
|
+
SdkResolvedPaywall,
|
|
64
|
+
SdkSyncCustomerAttributesBody,
|
|
65
|
+
SdkSyncTransactionBody,
|
|
66
|
+
SdkSyncTransactionResponse,
|
|
67
|
+
Session,
|
|
68
|
+
UpdateWebhookEndpointBody,
|
|
69
|
+
User,
|
|
70
|
+
WebhookDelivery,
|
|
71
|
+
WebhookDeliveryIdParam,
|
|
72
|
+
WebhookDeliveryWithAttempts,
|
|
73
|
+
WebhookEndpoint,
|
|
74
|
+
WebhookEndpointIdParam,
|
|
75
|
+
} from "./schema";
|
|
76
|
+
|
|
77
|
+
export const VoidhashV1Api = HttpApi.make("VoidhashV1Api")
|
|
78
|
+
.add(
|
|
79
|
+
HttpApiGroup.make("auth")
|
|
80
|
+
.add(
|
|
81
|
+
HttpApiEndpoint.get("session")`/session`
|
|
82
|
+
.addSuccess(Session)
|
|
83
|
+
.addError(ActionForbiddenError)
|
|
84
|
+
.middleware(AuthMiddleware)
|
|
85
|
+
)
|
|
86
|
+
.prefix("/auth")
|
|
87
|
+
)
|
|
88
|
+
.add(
|
|
89
|
+
HttpApiGroup.make("api_keys")
|
|
90
|
+
.add(
|
|
91
|
+
HttpApiEndpoint.post("createSecretKey")`/`
|
|
92
|
+
.addSuccess(ApiKeyWithRawKey)
|
|
93
|
+
.setPayload(CreateSecretKeyBody)
|
|
94
|
+
.addError(ApiKeyServiceError)
|
|
95
|
+
.addError(ActionForbiddenError)
|
|
96
|
+
)
|
|
97
|
+
.add(
|
|
98
|
+
HttpApiEndpoint.get("listApiKeys")`/`
|
|
99
|
+
.addSuccess(Schema.Array(ApiKey))
|
|
100
|
+
.addError(ApiKeyServiceError)
|
|
101
|
+
.addError(ActionForbiddenError)
|
|
102
|
+
)
|
|
103
|
+
.add(
|
|
104
|
+
HttpApiEndpoint.get("getApiKeyById")`/${ApiKeyIdParam}`
|
|
105
|
+
.addSuccess(ApiKey)
|
|
106
|
+
.addError(ApiKeyServiceError)
|
|
107
|
+
.addError(ApiKeyNotFoundError)
|
|
108
|
+
.addError(ActionForbiddenError)
|
|
109
|
+
)
|
|
110
|
+
.add(
|
|
111
|
+
HttpApiEndpoint.post("rotateSecretKey")`/${ApiKeyIdParam}/rotate`
|
|
112
|
+
.addSuccess(ApiKeyWithRawKey)
|
|
113
|
+
.addError(ApiKeyServiceError)
|
|
114
|
+
.addError(ApiKeyNotFoundError)
|
|
115
|
+
.addError(ActionForbiddenError)
|
|
116
|
+
)
|
|
117
|
+
.add(
|
|
118
|
+
HttpApiEndpoint.del("deleteApiKey")`/${ApiKeyIdParam}`
|
|
119
|
+
.addError(ApiKeyServiceError)
|
|
120
|
+
.addError(ApiKeyNotFoundError)
|
|
121
|
+
.addError(ActionForbiddenError)
|
|
122
|
+
)
|
|
123
|
+
.middleware(AuthMiddleware)
|
|
124
|
+
.prefix("/api-keys")
|
|
125
|
+
)
|
|
126
|
+
.add(
|
|
127
|
+
HttpApiGroup.make("customers")
|
|
128
|
+
.add(
|
|
129
|
+
HttpApiEndpoint.post("createCustomer")`/`
|
|
130
|
+
.setPayload(CreateCustomerBody)
|
|
131
|
+
.addSuccess(Customer)
|
|
132
|
+
.addError(ActionForbiddenError)
|
|
133
|
+
.addError(CustomerInvalidAnonymousIdError)
|
|
134
|
+
.addError(CustomerServiceError)
|
|
135
|
+
)
|
|
136
|
+
.add(
|
|
137
|
+
HttpApiEndpoint.get("listCustomers")`/`
|
|
138
|
+
.addSuccess(Schema.Array(Customer))
|
|
139
|
+
.addError(ActionForbiddenError)
|
|
140
|
+
.addError(CustomerServiceError)
|
|
141
|
+
)
|
|
142
|
+
.add(
|
|
143
|
+
HttpApiEndpoint.get("getCustomerById")`/${CustomerIdParam}`
|
|
144
|
+
.addSuccess(Customer)
|
|
145
|
+
.addError(ActionForbiddenError)
|
|
146
|
+
.addError(CustomerNotFoundError)
|
|
147
|
+
.addError(CustomerServiceError)
|
|
148
|
+
)
|
|
149
|
+
.add(
|
|
150
|
+
HttpApiEndpoint.get("byAppUserId")`/by-app-user-id/${AppUserIdParam}`
|
|
151
|
+
.addSuccess(Customer)
|
|
152
|
+
.addError(ActionForbiddenError)
|
|
153
|
+
.addError(CustomerNotFoundError)
|
|
154
|
+
.addError(CustomerServiceError)
|
|
155
|
+
)
|
|
156
|
+
.middleware(AuthMiddleware)
|
|
157
|
+
.prefix("/customers")
|
|
158
|
+
)
|
|
159
|
+
.add(
|
|
160
|
+
HttpApiGroup.make("organizations")
|
|
161
|
+
.add(
|
|
162
|
+
HttpApiEndpoint.post("createOrganization")`/`
|
|
163
|
+
.setPayload(CreateOrganizationBody)
|
|
164
|
+
.addSuccess(Organization)
|
|
165
|
+
.addError(OrganizationServiceError)
|
|
166
|
+
)
|
|
167
|
+
.middleware(AuthMiddleware)
|
|
168
|
+
.prefix("/organizations")
|
|
169
|
+
)
|
|
170
|
+
.add(
|
|
171
|
+
HttpApiGroup.make("perks")
|
|
172
|
+
.add(
|
|
173
|
+
HttpApiEndpoint.get("listPerks")`/`
|
|
174
|
+
.addSuccess(Schema.Array(Perk))
|
|
175
|
+
.addError(ActionForbiddenError)
|
|
176
|
+
.addError(PerkServiceError)
|
|
177
|
+
)
|
|
178
|
+
.middleware(AuthMiddleware)
|
|
179
|
+
.prefix("/perks")
|
|
180
|
+
)
|
|
181
|
+
.add(
|
|
182
|
+
HttpApiGroup.make("paywall_locations")
|
|
183
|
+
.add(
|
|
184
|
+
HttpApiEndpoint.get("listPaywallLocations")`/`
|
|
185
|
+
.addSuccess(Schema.Array(PaywallLocation))
|
|
186
|
+
.addError(ActionForbiddenError)
|
|
187
|
+
.addError(PaywallLocationServiceError)
|
|
188
|
+
)
|
|
189
|
+
.middleware(AuthMiddleware)
|
|
190
|
+
.prefix("/paywall-locations")
|
|
191
|
+
)
|
|
192
|
+
.add(
|
|
193
|
+
HttpApiGroup.make("projects")
|
|
194
|
+
.add(
|
|
195
|
+
HttpApiEndpoint.post("createProject")`/`
|
|
196
|
+
.setPayload(CreateProjectBody)
|
|
197
|
+
.addSuccess(Project)
|
|
198
|
+
.addError(ActionForbiddenError)
|
|
199
|
+
.addError(AuthenticationError)
|
|
200
|
+
.addError(ProjectServiceError)
|
|
201
|
+
)
|
|
202
|
+
.add(
|
|
203
|
+
HttpApiEndpoint.get("listProjects")`/${OrganizationIdParam}`
|
|
204
|
+
.addSuccess(Schema.Array(Project))
|
|
205
|
+
.addError(ActionForbiddenError)
|
|
206
|
+
.addError(ProjectServiceError)
|
|
207
|
+
)
|
|
208
|
+
.middleware(AuthMiddleware)
|
|
209
|
+
.prefix("/projects")
|
|
210
|
+
)
|
|
211
|
+
.add(
|
|
212
|
+
HttpApiGroup.make("products")
|
|
213
|
+
.add(
|
|
214
|
+
HttpApiEndpoint.get("listProducts")`/`
|
|
215
|
+
.addSuccess(Schema.Array(Product))
|
|
216
|
+
.addError(ActionForbiddenError)
|
|
217
|
+
.addError(ProductServiceError)
|
|
218
|
+
)
|
|
219
|
+
.middleware(AuthMiddleware)
|
|
220
|
+
.prefix("/products")
|
|
221
|
+
)
|
|
222
|
+
.add(
|
|
223
|
+
HttpApiGroup.make("product_perks")
|
|
224
|
+
.add(
|
|
225
|
+
HttpApiEndpoint.get(
|
|
226
|
+
"listProductPerksByProductId"
|
|
227
|
+
)`/by-product-id/${ProductIdParam}`
|
|
228
|
+
.addSuccess(Schema.Array(ProductPerk))
|
|
229
|
+
.addError(ActionForbiddenError)
|
|
230
|
+
.addError(ProductPerkServiceError)
|
|
231
|
+
.addError(ProductPerkValidationError)
|
|
232
|
+
)
|
|
233
|
+
.middleware(AuthMiddleware)
|
|
234
|
+
.prefix("/product-perks")
|
|
235
|
+
)
|
|
236
|
+
.add(
|
|
237
|
+
HttpApiGroup.make("sdk")
|
|
238
|
+
.add(
|
|
239
|
+
HttpApiEndpoint.get("getCustomer")`/get-customer`
|
|
240
|
+
.addSuccess(SdkCustomer)
|
|
241
|
+
.setHeaders(SdkHeaders)
|
|
242
|
+
.addError(AuthenticationError)
|
|
243
|
+
.addError(SdkServiceError)
|
|
244
|
+
.addError(SdkCustomerNotFoundError)
|
|
245
|
+
.addError(SdkValidationError)
|
|
246
|
+
)
|
|
247
|
+
.add(
|
|
248
|
+
HttpApiEndpoint.post("identify")`/identify`
|
|
249
|
+
.setPayload(SdkIdentifyBody)
|
|
250
|
+
.addSuccess(SdkCustomer)
|
|
251
|
+
.setHeaders(SdkHeaders)
|
|
252
|
+
.addError(AuthenticationError)
|
|
253
|
+
.addError(SdkServiceError)
|
|
254
|
+
.addError(SdkValidationError)
|
|
255
|
+
.addError(SdkCustomerAlreadyIdentifiedError)
|
|
256
|
+
)
|
|
257
|
+
.add(
|
|
258
|
+
HttpApiEndpoint.post(
|
|
259
|
+
"syncCustomerAttributes"
|
|
260
|
+
)`/sync-customer-attributes`
|
|
261
|
+
.setPayload(SdkSyncCustomerAttributesBody)
|
|
262
|
+
.addSuccess(SdkCustomer)
|
|
263
|
+
.setHeaders(SdkHeaders)
|
|
264
|
+
.addError(AuthenticationError)
|
|
265
|
+
.addError(SdkServiceError)
|
|
266
|
+
.addError(SdkValidationError)
|
|
267
|
+
)
|
|
268
|
+
.add(
|
|
269
|
+
HttpApiEndpoint.post("syncTransaction")`/sync-transaction`
|
|
270
|
+
.setPayload(SdkSyncTransactionBody)
|
|
271
|
+
.addSuccess(SdkSyncTransactionResponse)
|
|
272
|
+
.setHeaders(SdkHeaders)
|
|
273
|
+
.addError(AuthenticationError)
|
|
274
|
+
.addError(SdkServiceError)
|
|
275
|
+
.addError(SdkValidationError)
|
|
276
|
+
)
|
|
277
|
+
.add(
|
|
278
|
+
HttpApiEndpoint.post("evaluateFeatureFlags")`/evaluate-flags`
|
|
279
|
+
.setPayload(EvaluateFeatureFlagsBody)
|
|
280
|
+
.addSuccess(SdkFeatureFlagsResponse)
|
|
281
|
+
.setHeaders(SdkHeaders)
|
|
282
|
+
.addError(AuthenticationError)
|
|
283
|
+
.addError(SdkServiceError)
|
|
284
|
+
)
|
|
285
|
+
.add(
|
|
286
|
+
HttpApiEndpoint.post("resolvePaywall")`/resolve-paywall`
|
|
287
|
+
.setPayload(SdkResolvePaywallBody)
|
|
288
|
+
.addSuccess(Schema.NullOr(SdkResolvedPaywall))
|
|
289
|
+
.setHeaders(SdkHeaders)
|
|
290
|
+
.addError(AuthenticationError)
|
|
291
|
+
.addError(SdkServiceError)
|
|
292
|
+
.addError(SdkValidationError)
|
|
293
|
+
)
|
|
294
|
+
.middleware(AuthMiddleware)
|
|
295
|
+
.prefix("/sdk")
|
|
296
|
+
)
|
|
297
|
+
.add(
|
|
298
|
+
HttpApiGroup.make("users")
|
|
299
|
+
.add(
|
|
300
|
+
HttpApiEndpoint.get("getUser")`/current`
|
|
301
|
+
.addSuccess(User)
|
|
302
|
+
.addError(AuthenticationError)
|
|
303
|
+
.addError(UserServiceError)
|
|
304
|
+
)
|
|
305
|
+
.middleware(AuthMiddleware)
|
|
306
|
+
.prefix("/users")
|
|
307
|
+
)
|
|
308
|
+
.add(
|
|
309
|
+
HttpApiGroup.make("payment_provider_configurations")
|
|
310
|
+
.add(
|
|
311
|
+
HttpApiEndpoint.get("listPaymentProviderConfigurations")`/`
|
|
312
|
+
.addSuccess(Schema.Array(PaymentProviderConfiguration))
|
|
313
|
+
.addError(ActionForbiddenError)
|
|
314
|
+
.addError(PaymentProviderConfigurationServiceError)
|
|
315
|
+
)
|
|
316
|
+
.middleware(AuthMiddleware)
|
|
317
|
+
.prefix("/payment-provider-configurations")
|
|
318
|
+
)
|
|
319
|
+
.add(
|
|
320
|
+
HttpApiGroup.make("payment_provider_products")
|
|
321
|
+
.add(
|
|
322
|
+
HttpApiEndpoint.get("listPaymentProviderProducts")`/`
|
|
323
|
+
.addSuccess(Schema.Array(PaymentProviderProduct))
|
|
324
|
+
.addError(ActionForbiddenError)
|
|
325
|
+
.addError(PaymentProviderProductServiceError)
|
|
326
|
+
)
|
|
327
|
+
.middleware(AuthMiddleware)
|
|
328
|
+
.prefix("/payment-provider-products")
|
|
329
|
+
)
|
|
330
|
+
.add(
|
|
331
|
+
HttpApiGroup.make("changesets")
|
|
332
|
+
.add(
|
|
333
|
+
HttpApiEndpoint.post("deployChangeset")`/deploy`
|
|
334
|
+
.setPayload(DeployChangesetBody)
|
|
335
|
+
.addSuccess(DeployChangesetResponse)
|
|
336
|
+
.addError(AuthenticationError)
|
|
337
|
+
.addError(ActionForbiddenError)
|
|
338
|
+
.addError(ChangesetDeploymentServiceError)
|
|
339
|
+
)
|
|
340
|
+
.middleware(AuthMiddleware)
|
|
341
|
+
.prefix("/changesets")
|
|
342
|
+
)
|
|
343
|
+
.add(
|
|
344
|
+
HttpApiGroup.make("webhooks")
|
|
345
|
+
.add(
|
|
346
|
+
HttpApiEndpoint.post("createWebhookEndpoint")`/endpoints`
|
|
347
|
+
.setPayload(CreateWebhookEndpointBody)
|
|
348
|
+
.addSuccess(WebhookEndpoint)
|
|
349
|
+
.addError(ActionForbiddenError)
|
|
350
|
+
.addError(WebhookValidationError)
|
|
351
|
+
.addError(WebhookServiceError)
|
|
352
|
+
)
|
|
353
|
+
.add(
|
|
354
|
+
HttpApiEndpoint.get("listWebhookEndpoints")`/endpoints`
|
|
355
|
+
.addSuccess(Schema.Array(WebhookEndpoint))
|
|
356
|
+
.addError(ActionForbiddenError)
|
|
357
|
+
.addError(WebhookServiceError)
|
|
358
|
+
)
|
|
359
|
+
.add(
|
|
360
|
+
HttpApiEndpoint.get("getWebhookEndpoint")`/endpoints/${WebhookEndpointIdParam}`
|
|
361
|
+
.addSuccess(WebhookEndpoint)
|
|
362
|
+
.addError(ActionForbiddenError)
|
|
363
|
+
.addError(WebhookEndpointNotFoundError)
|
|
364
|
+
.addError(WebhookServiceError)
|
|
365
|
+
)
|
|
366
|
+
.add(
|
|
367
|
+
HttpApiEndpoint.patch("updateWebhookEndpoint")`/endpoints/${WebhookEndpointIdParam}`
|
|
368
|
+
.setPayload(UpdateWebhookEndpointBody)
|
|
369
|
+
.addSuccess(WebhookEndpoint)
|
|
370
|
+
.addError(ActionForbiddenError)
|
|
371
|
+
.addError(WebhookEndpointNotFoundError)
|
|
372
|
+
.addError(WebhookValidationError)
|
|
373
|
+
.addError(WebhookServiceError)
|
|
374
|
+
)
|
|
375
|
+
.add(
|
|
376
|
+
HttpApiEndpoint.del("deleteWebhookEndpoint")`/endpoints/${WebhookEndpointIdParam}`
|
|
377
|
+
.addError(ActionForbiddenError)
|
|
378
|
+
.addError(WebhookEndpointNotFoundError)
|
|
379
|
+
.addError(WebhookServiceError)
|
|
380
|
+
)
|
|
381
|
+
.add(
|
|
382
|
+
HttpApiEndpoint.post("rotateWebhookSecret")`/endpoints/${WebhookEndpointIdParam}/rotate-secret`
|
|
383
|
+
.addSuccess(WebhookEndpoint)
|
|
384
|
+
.addError(ActionForbiddenError)
|
|
385
|
+
.addError(WebhookEndpointNotFoundError)
|
|
386
|
+
.addError(WebhookServiceError)
|
|
387
|
+
)
|
|
388
|
+
.add(
|
|
389
|
+
HttpApiEndpoint.post("testWebhookEndpoint")`/endpoints/${WebhookEndpointIdParam}/test`
|
|
390
|
+
.addSuccess(WebhookDelivery)
|
|
391
|
+
.addError(ActionForbiddenError)
|
|
392
|
+
.addError(WebhookEndpointNotFoundError)
|
|
393
|
+
.addError(WebhookServiceError)
|
|
394
|
+
)
|
|
395
|
+
.add(
|
|
396
|
+
HttpApiEndpoint.get("listWebhookDeliveries")`/deliveries`
|
|
397
|
+
.addSuccess(Schema.Array(WebhookDelivery))
|
|
398
|
+
.addError(ActionForbiddenError)
|
|
399
|
+
.addError(WebhookServiceError)
|
|
400
|
+
)
|
|
401
|
+
.add(
|
|
402
|
+
HttpApiEndpoint.get("getWebhookDelivery")`/deliveries/${WebhookDeliveryIdParam}`
|
|
403
|
+
.addSuccess(WebhookDeliveryWithAttempts)
|
|
404
|
+
.addError(ActionForbiddenError)
|
|
405
|
+
.addError(WebhookDeliveryNotFoundError)
|
|
406
|
+
.addError(WebhookServiceError)
|
|
407
|
+
)
|
|
408
|
+
.add(
|
|
409
|
+
HttpApiEndpoint.post("retryWebhookDelivery")`/deliveries/${WebhookDeliveryIdParam}/retry`
|
|
410
|
+
.addSuccess(WebhookDelivery)
|
|
411
|
+
.addError(ActionForbiddenError)
|
|
412
|
+
.addError(WebhookDeliveryNotFoundError)
|
|
413
|
+
.addError(WebhookValidationError)
|
|
414
|
+
.addError(WebhookServiceError)
|
|
415
|
+
)
|
|
416
|
+
.middleware(AuthMiddleware)
|
|
417
|
+
.prefix("/webhooks")
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
.prefix("/api/v1");
|
package/src/auth.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Context, Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Session Sub-Schemas
|
|
5
|
+
// ============================================================================
|
|
6
|
+
|
|
7
|
+
export const ApiSessionOrganizationSchema = Schema.Struct({
|
|
8
|
+
id: Schema.String,
|
|
9
|
+
name: Schema.String,
|
|
10
|
+
permissions: Schema.Array(Schema.String),
|
|
11
|
+
slug: Schema.String,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const ApiSessionProjectSchema = Schema.Struct({
|
|
15
|
+
id: Schema.String,
|
|
16
|
+
name: Schema.String,
|
|
17
|
+
organizationId: Schema.String,
|
|
18
|
+
permissions: Schema.Array(Schema.String),
|
|
19
|
+
slug: Schema.String,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const ApiSessionOrganizationsSchema = Schema.Array(ApiSessionOrganizationSchema);
|
|
23
|
+
const ApiSessionProjectsSchema = Schema.Array(ApiSessionProjectSchema);
|
|
24
|
+
|
|
25
|
+
export const ApiSessionCustomerSchema = Schema.Struct({
|
|
26
|
+
appUserId: Schema.String,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const ApiSessionUserSchema = Schema.Struct({
|
|
30
|
+
createdAt: Schema.Date,
|
|
31
|
+
email: Schema.String,
|
|
32
|
+
emailVerified: Schema.Boolean,
|
|
33
|
+
id: Schema.String,
|
|
34
|
+
image: Schema.NullOr(Schema.String),
|
|
35
|
+
name: Schema.String,
|
|
36
|
+
updatedAt: Schema.Date,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Session Type Schemas
|
|
41
|
+
// ============================================================================
|
|
42
|
+
|
|
43
|
+
export const ApiUserSessionSchema = Schema.Struct({
|
|
44
|
+
cookie: Schema.NullOr(Schema.String),
|
|
45
|
+
customer: Schema.Null,
|
|
46
|
+
method: Schema.Literal("user"),
|
|
47
|
+
name: Schema.String,
|
|
48
|
+
organizations: ApiSessionOrganizationsSchema,
|
|
49
|
+
projects: ApiSessionProjectsSchema,
|
|
50
|
+
user: ApiSessionUserSchema,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const ApiSecretKeySessionSchema = Schema.Struct({
|
|
54
|
+
cookie: Schema.Null,
|
|
55
|
+
customer: Schema.Null,
|
|
56
|
+
method: Schema.Literal("secret-key"),
|
|
57
|
+
name: Schema.String,
|
|
58
|
+
organizations: ApiSessionOrganizationsSchema,
|
|
59
|
+
projects: ApiSessionProjectsSchema,
|
|
60
|
+
user: Schema.Null,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const ApiPublishableKeySessionSchema = Schema.Struct({
|
|
64
|
+
cookie: Schema.Null,
|
|
65
|
+
customer: ApiSessionCustomerSchema,
|
|
66
|
+
method: Schema.Literal("publishable-key"),
|
|
67
|
+
name: Schema.String,
|
|
68
|
+
organizations: ApiSessionOrganizationsSchema,
|
|
69
|
+
projects: ApiSessionProjectsSchema,
|
|
70
|
+
user: Schema.Null,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// Combined Auth Session Schema
|
|
75
|
+
// ============================================================================
|
|
76
|
+
|
|
77
|
+
export const ApiAuthSessionSchema = Schema.Union(
|
|
78
|
+
ApiUserSessionSchema,
|
|
79
|
+
ApiSecretKeySessionSchema,
|
|
80
|
+
ApiPublishableKeySessionSchema
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// ============================================================================
|
|
84
|
+
// Type Exports
|
|
85
|
+
// ============================================================================
|
|
86
|
+
|
|
87
|
+
export type ApiUserSession = typeof ApiUserSessionSchema.Type;
|
|
88
|
+
export type ApiSecretKeySession = typeof ApiSecretKeySessionSchema.Type;
|
|
89
|
+
export type ApiPublishableKeySession = typeof ApiPublishableKeySessionSchema.Type;
|
|
90
|
+
export type AnyApiAuthSession =
|
|
91
|
+
| ApiUserSession
|
|
92
|
+
| ApiSecretKeySession
|
|
93
|
+
| ApiPublishableKeySession;
|
|
94
|
+
|
|
95
|
+
// ============================================================================
|
|
96
|
+
// Context Tag
|
|
97
|
+
// ============================================================================
|
|
98
|
+
|
|
99
|
+
export class ApiAuthSession extends Context.Tag("api-spec/auth/ApiAuthSession")<
|
|
100
|
+
ApiAuthSession,
|
|
101
|
+
ApiUserSession | ApiSecretKeySession | ApiPublishableKeySession
|
|
102
|
+
>() {}
|