@payark/sdk-effect 0.1.5 → 0.1.9

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.
@@ -0,0 +1,651 @@
1
+ 'use strict';
2
+
3
+ var platform = require('@effect/platform');
4
+ var effect = require('effect');
5
+
6
+ // src/api-spec.ts
7
+ var NonEmptyString = effect.Schema.String.pipe(
8
+ effect.Schema.nonEmptyString(),
9
+ effect.Schema.brand("NonEmptyString")
10
+ );
11
+ var UrlString = effect.Schema.String.pipe(
12
+ effect.Schema.pattern(/^https?:\/\/.+/),
13
+ effect.Schema.brand("UrlString")
14
+ );
15
+ effect.Schema.Number.pipe(
16
+ effect.Schema.int(),
17
+ effect.Schema.greaterThan(0),
18
+ effect.Schema.brand("MinorUnitsInt")
19
+ );
20
+ var NprAmount = effect.Schema.Number.pipe(
21
+ effect.Schema.filter(
22
+ (n) => Number.isFinite(n) && n > 0 && Math.round(n * 100) === n * 100
23
+ ),
24
+ effect.Schema.brand("NprAmount")
25
+ );
26
+
27
+ // src/schemas.ts
28
+ var Id = effect.Schema.String.pipe(effect.Schema.brand("Id"));
29
+ var ProjectId = effect.Schema.String.pipe(effect.Schema.brand("ProjectId"));
30
+ var PaymentId = effect.Schema.String.pipe(effect.Schema.brand("PaymentId"));
31
+ var CheckoutSessionId = effect.Schema.String.pipe(
32
+ effect.Schema.brand("CheckoutSessionId")
33
+ );
34
+ var SubscriptionId = effect.Schema.String.pipe(
35
+ effect.Schema.brand("SubscriptionId")
36
+ );
37
+ var MandateId = effect.Schema.String.pipe(effect.Schema.brand("MandateId"));
38
+ var AgentSessionId = effect.Schema.String.pipe(
39
+ effect.Schema.brand("AgentSessionId")
40
+ );
41
+ var CustomerId = effect.Schema.String.pipe(effect.Schema.brand("CustomerId"));
42
+ var TokenId = effect.Schema.String.pipe(effect.Schema.brand("TokenId"));
43
+ var Email = effect.Schema.String.pipe(
44
+ effect.Schema.filter((s) => s.includes("@")),
45
+ effect.Schema.brand("Email")
46
+ );
47
+ var Timestamp = effect.Schema.String.pipe(effect.Schema.brand("Timestamp"));
48
+ var Metadata = effect.Schema.Record({
49
+ key: effect.Schema.String,
50
+ value: effect.Schema.Any
51
+ });
52
+ effect.Schema.Struct({
53
+ created_at: Timestamp,
54
+ updated_at: Timestamp
55
+ });
56
+ var Provider = effect.Schema.Literal(
57
+ "esewa",
58
+ "khalti",
59
+ "hamropay",
60
+ "connectips",
61
+ "imepay",
62
+ "fonepay",
63
+ "sandbox"
64
+ );
65
+ var PaymentStatus = effect.Schema.Literal("pending", "success", "failed");
66
+ var SubscriptionStatus = effect.Schema.Literal(
67
+ "pending_checkout",
68
+ "active",
69
+ "past_due",
70
+ "canceled",
71
+ "paused"
72
+ );
73
+ var SubscriptionInterval = effect.Schema.Literal("month", "year", "week");
74
+ var CustomerLifecycle = effect.Schema.Literal(
75
+ "new",
76
+ "active",
77
+ "loyal",
78
+ "at_risk",
79
+ "churned"
80
+ );
81
+ var MandateType = effect.Schema.Literal("intent", "cart");
82
+ var MandateStatus = effect.Schema.Literal(
83
+ "active",
84
+ "consumed",
85
+ "expired",
86
+ "violated"
87
+ );
88
+ var Customer = effect.Schema.Struct({
89
+ id: CustomerId,
90
+ merchant_customer_id: NonEmptyString,
91
+ email: effect.Schema.NullOr(Email),
92
+ name: effect.Schema.NullOr(NonEmptyString),
93
+ phone: effect.Schema.NullOr(effect.Schema.String),
94
+ project_id: ProjectId,
95
+ metadata: effect.Schema.NullOr(Metadata),
96
+ total_ltv: effect.Schema.optional(effect.Schema.Number),
97
+ is_high_value: effect.Schema.optional(effect.Schema.Boolean),
98
+ lifecycle_stage: effect.Schema.optional(CustomerLifecycle),
99
+ ltv_cents: effect.Schema.optional(effect.Schema.Number),
100
+ tier: effect.Schema.NullOr(effect.Schema.String),
101
+ created_at: Timestamp,
102
+ updated_at: effect.Schema.optional(Timestamp)
103
+ });
104
+ var Payment = effect.Schema.Struct({
105
+ id: PaymentId,
106
+ project_id: ProjectId,
107
+ customer_id: effect.Schema.optional(effect.Schema.NullOr(CustomerId)),
108
+ amount: effect.Schema.Number,
109
+ currency: effect.Schema.String,
110
+ status: PaymentStatus,
111
+ provider_ref: effect.Schema.optional(effect.Schema.NullOr(effect.Schema.String)),
112
+ metadata_json: effect.Schema.optional(effect.Schema.NullOr(Metadata)),
113
+ gateway_response: effect.Schema.optional(effect.Schema.NullOr(effect.Schema.Any)),
114
+ created_at: Timestamp,
115
+ updated_at: effect.Schema.optional(Timestamp)
116
+ });
117
+ var Subscription = effect.Schema.Struct({
118
+ id: SubscriptionId,
119
+ project_id: ProjectId,
120
+ customer_id: CustomerId,
121
+ status: SubscriptionStatus,
122
+ amount: effect.Schema.Number,
123
+ currency: effect.Schema.String,
124
+ interval: SubscriptionInterval,
125
+ interval_count: effect.Schema.Number,
126
+ current_period_start: Timestamp,
127
+ current_period_end: Timestamp,
128
+ payment_link: UrlString,
129
+ customer_email: effect.Schema.optional(effect.Schema.NullOr(effect.Schema.String)),
130
+ auto_send_link: effect.Schema.Boolean,
131
+ grace_days: effect.Schema.optional(effect.Schema.Number),
132
+ metadata: effect.Schema.optional(effect.Schema.NullOr(Metadata)),
133
+ canceled_at: effect.Schema.optional(effect.Schema.NullOr(Timestamp)),
134
+ created_at: Timestamp,
135
+ updated_at: effect.Schema.optional(Timestamp)
136
+ });
137
+ var Project = effect.Schema.Struct({
138
+ id: ProjectId,
139
+ name: NonEmptyString,
140
+ api_key_secret: effect.Schema.String,
141
+ subscription_tier: effect.Schema.optional(
142
+ effect.Schema.Literal("free", "pro", "enterprise")
143
+ ),
144
+ subscription_status: effect.Schema.optional(
145
+ effect.Schema.Literal("active", "past_due", "canceled", "incomplete")
146
+ ),
147
+ expires_at: effect.Schema.optional(effect.Schema.NullOr(Timestamp)),
148
+ created_at: Timestamp
149
+ });
150
+ var Token = effect.Schema.Struct({
151
+ id: TokenId,
152
+ name: NonEmptyString,
153
+ scopes: effect.Schema.Array(effect.Schema.String),
154
+ last_used_at: effect.Schema.NullOr(Timestamp),
155
+ expires_at: effect.Schema.NullOr(Timestamp),
156
+ created_at: Timestamp
157
+ });
158
+ var Mandate = effect.Schema.Struct({
159
+ id: MandateId,
160
+ project_id: ProjectId,
161
+ customer_id: effect.Schema.NullOr(CustomerId),
162
+ type: MandateType,
163
+ status: MandateStatus,
164
+ principal_id: effect.Schema.String,
165
+ max_amount: effect.Schema.Number,
166
+ currency: effect.Schema.String,
167
+ permitted_vendors: effect.Schema.NullOr(effect.Schema.Array(effect.Schema.String)),
168
+ valid_from: Timestamp,
169
+ valid_until: Timestamp,
170
+ credential_jwt: effect.Schema.String,
171
+ public_key: effect.Schema.String,
172
+ signature: effect.Schema.String,
173
+ parent_mandate_id: effect.Schema.NullOr(MandateId),
174
+ payment_id: effect.Schema.NullOr(PaymentId),
175
+ created_at: Timestamp,
176
+ consumed_at: effect.Schema.NullOr(Timestamp),
177
+ metadata_json: Metadata
178
+ });
179
+ effect.Schema.Struct({
180
+ id: AgentSessionId,
181
+ project_id: ProjectId,
182
+ context_id: effect.Schema.String,
183
+ agent_card_url: UrlString,
184
+ capabilities: effect.Schema.Any,
185
+ auth_scheme: effect.Schema.Literal("bearer", "mandate"),
186
+ status: effect.Schema.String,
187
+ created_at: Timestamp,
188
+ expires_at: Timestamp
189
+ });
190
+ var PaginationMeta = effect.Schema.Struct({
191
+ total: effect.Schema.NullOr(effect.Schema.Number),
192
+ limit: effect.Schema.Number,
193
+ offset: effect.Schema.Number
194
+ });
195
+ var PaginatedResponse = (schema) => effect.Schema.Struct({
196
+ data: effect.Schema.Array(schema),
197
+ meta: PaginationMeta
198
+ });
199
+ var WebhookEventType = effect.Schema.Literal(
200
+ "payment.success",
201
+ "payment.failed",
202
+ "subscription.created",
203
+ "subscription.activated",
204
+ "subscription.renewed",
205
+ "subscription.payment_succeeded",
206
+ "subscription.payment_failed",
207
+ "subscription.renewal_due",
208
+ "subscription.canceled"
209
+ );
210
+ effect.Schema.Struct({
211
+ type: WebhookEventType,
212
+ id: effect.Schema.optional(effect.Schema.String),
213
+ data: effect.Schema.Union(
214
+ Payment,
215
+ Subscription,
216
+ Customer,
217
+ effect.Schema.Struct({
218
+ id: effect.Schema.String,
219
+ amount: effect.Schema.optional(effect.Schema.Number),
220
+ currency: effect.Schema.optional(effect.Schema.String),
221
+ status: effect.Schema.String,
222
+ metadata: effect.Schema.optional(Metadata)
223
+ })
224
+ ),
225
+ is_test: effect.Schema.Boolean,
226
+ created: effect.Schema.optional(effect.Schema.Number)
227
+ });
228
+ var CreateCheckoutParams = effect.Schema.Struct({
229
+ amount: effect.Schema.optional(NprAmount),
230
+ currency: effect.Schema.optionalWith(effect.Schema.String, { default: () => "NPR" }),
231
+ provider: Provider,
232
+ returnUrl: UrlString,
233
+ cancelUrl: effect.Schema.optional(UrlString),
234
+ metadata: effect.Schema.optional(Metadata),
235
+ subscriptionId: effect.Schema.optional(SubscriptionId),
236
+ customerId: effect.Schema.optional(CustomerId),
237
+ mandate_id: effect.Schema.optional(MandateId)
238
+ }).pipe(
239
+ effect.Schema.filter((data) => {
240
+ if (!data.subscriptionId && !data.amount) {
241
+ return "amount is required when subscriptionId is not provided";
242
+ }
243
+ return true;
244
+ })
245
+ );
246
+ var CheckoutSession = effect.Schema.Struct({
247
+ id: CheckoutSessionId,
248
+ checkout_url: UrlString,
249
+ qr_string: effect.Schema.optional(effect.Schema.String),
250
+ payment_method: effect.Schema.Struct({
251
+ type: Provider,
252
+ url: effect.Schema.optional(UrlString),
253
+ method: effect.Schema.optional(effect.Schema.Literal("GET", "POST")),
254
+ fields: effect.Schema.optional(
255
+ effect.Schema.Record({ key: effect.Schema.String, value: effect.Schema.String })
256
+ )
257
+ })
258
+ });
259
+ var CreateCustomerParams = effect.Schema.Struct({
260
+ merchant_customer_id: NonEmptyString,
261
+ email: effect.Schema.optional(Email),
262
+ name: effect.Schema.optional(NonEmptyString),
263
+ phone: effect.Schema.optional(effect.Schema.String),
264
+ project_id: effect.Schema.optional(ProjectId),
265
+ metadata: effect.Schema.optional(Metadata)
266
+ });
267
+ var ListPaymentsParams = effect.Schema.Struct({
268
+ limit: effect.Schema.optional(effect.Schema.NumberFromString),
269
+ offset: effect.Schema.optional(effect.Schema.NumberFromString),
270
+ projectId: effect.Schema.optional(ProjectId)
271
+ });
272
+ var ListCustomersParams = effect.Schema.Struct({
273
+ limit: effect.Schema.optional(effect.Schema.NumberFromString),
274
+ offset: effect.Schema.optional(effect.Schema.NumberFromString),
275
+ email: effect.Schema.optional(effect.Schema.String),
276
+ merchant_customer_id: effect.Schema.optional(effect.Schema.String),
277
+ projectId: effect.Schema.optional(ProjectId)
278
+ });
279
+ var UpdateCustomerParams = effect.Schema.Struct({
280
+ email: effect.Schema.optional(Email),
281
+ name: effect.Schema.optional(NonEmptyString),
282
+ phone: effect.Schema.optional(effect.Schema.String),
283
+ tier: effect.Schema.optional(effect.Schema.String),
284
+ merchant_customer_id: effect.Schema.optional(effect.Schema.String),
285
+ metadata: effect.Schema.optional(Metadata)
286
+ });
287
+ var CreateSubscriptionParams = effect.Schema.Struct({
288
+ customer_id: CustomerId,
289
+ amount: NprAmount,
290
+ currency: effect.Schema.optionalWith(effect.Schema.String, { default: () => "NPR" }),
291
+ interval: SubscriptionInterval,
292
+ interval_count: effect.Schema.optional(effect.Schema.Number),
293
+ project_id: effect.Schema.optional(ProjectId),
294
+ customer_email: effect.Schema.optional(effect.Schema.String),
295
+ auto_send_link: effect.Schema.optional(effect.Schema.Boolean),
296
+ metadata: effect.Schema.optional(Metadata)
297
+ });
298
+ effect.Schema.Struct({
299
+ payment_id: effect.Schema.optional(effect.Schema.String),
300
+ data: effect.Schema.optional(effect.Schema.String),
301
+ pidx: effect.Schema.optional(effect.Schema.String),
302
+ /** HamroPay-specific: the gateway's own transactionId returned on callback. */
303
+ ref_id: effect.Schema.optional(effect.Schema.String)
304
+ });
305
+ var ListSubscriptionsParams = effect.Schema.Struct({
306
+ limit: effect.Schema.optional(effect.Schema.NumberFromString),
307
+ offset: effect.Schema.optional(effect.Schema.NumberFromString),
308
+ projectId: effect.Schema.optional(ProjectId),
309
+ customerId: effect.Schema.optional(CustomerId),
310
+ status: effect.Schema.optional(SubscriptionStatus)
311
+ });
312
+ var RealtimeTriggerPayload = effect.Schema.Struct({
313
+ event: effect.Schema.optional(WebhookEventType),
314
+ data: effect.Schema.optional(effect.Schema.Any)
315
+ });
316
+ effect.Schema.Struct({
317
+ apiKey: effect.Schema.String,
318
+ baseUrl: effect.Schema.optional(effect.Schema.String),
319
+ timeout: effect.Schema.optional(effect.Schema.Number),
320
+ maxRetries: effect.Schema.optional(effect.Schema.Number),
321
+ sandbox: effect.Schema.optional(effect.Schema.Boolean),
322
+ signingPrivateKey: effect.Schema.optional(effect.Schema.String)
323
+ });
324
+ effect.Schema.Struct({
325
+ error: effect.Schema.String,
326
+ details: effect.Schema.optional(effect.Schema.Any)
327
+ });
328
+ var IndustrialError = class extends effect.Schema.TaggedError()(
329
+ "IndustrialError",
330
+ {
331
+ error: effect.Schema.String,
332
+ details: effect.Schema.optional(effect.Schema.Any),
333
+ code: effect.Schema.optional(effect.Schema.String),
334
+ doc_url: effect.Schema.optional(effect.Schema.String),
335
+ suggestion: effect.Schema.optional(effect.Schema.String)
336
+ }
337
+ ) {
338
+ };
339
+ var AuthenticationError = class extends effect.Schema.TaggedError()(
340
+ "AuthenticationError",
341
+ {
342
+ error: effect.Schema.String,
343
+ code: effect.Schema.optional(effect.Schema.String),
344
+ doc_url: effect.Schema.optional(effect.Schema.String),
345
+ suggestion: effect.Schema.optional(effect.Schema.String)
346
+ }
347
+ ) {
348
+ };
349
+ var NotFoundError = class extends effect.Schema.TaggedError()(
350
+ "NotFoundError",
351
+ {
352
+ error: effect.Schema.String,
353
+ code: effect.Schema.optional(effect.Schema.String),
354
+ doc_url: effect.Schema.optional(effect.Schema.String),
355
+ suggestion: effect.Schema.optional(effect.Schema.String)
356
+ }
357
+ ) {
358
+ };
359
+ var InternalServerError = class extends effect.Schema.TaggedError()(
360
+ "InternalServerError",
361
+ {
362
+ error: effect.Schema.String,
363
+ details: effect.Schema.optional(effect.Schema.Any),
364
+ code: effect.Schema.optional(effect.Schema.String),
365
+ doc_url: effect.Schema.optional(effect.Schema.String),
366
+ suggestion: effect.Schema.optional(effect.Schema.String)
367
+ }
368
+ ) {
369
+ };
370
+ var ConflictError = class extends effect.Schema.TaggedError()(
371
+ "ConflictError",
372
+ {
373
+ error: effect.Schema.String,
374
+ code: effect.Schema.optional(effect.Schema.String),
375
+ doc_url: effect.Schema.optional(effect.Schema.String),
376
+ suggestion: effect.Schema.optional(effect.Schema.String)
377
+ }
378
+ ) {
379
+ };
380
+ var MandateViolationError = class extends effect.Schema.TaggedError()(
381
+ "MandateViolationError",
382
+ {
383
+ error: effect.Schema.String,
384
+ mandateId: effect.Schema.optional(effect.Schema.String),
385
+ code: effect.Schema.optional(effect.Schema.String),
386
+ doc_url: effect.Schema.optional(effect.Schema.String),
387
+ suggestion: effect.Schema.optional(effect.Schema.String)
388
+ }
389
+ ) {
390
+ };
391
+ var MandateExpiredError = class extends effect.Schema.TaggedError()(
392
+ "MandateExpiredError",
393
+ {
394
+ error: effect.Schema.String,
395
+ mandateId: MandateId,
396
+ expiredAt: Timestamp,
397
+ code: effect.Schema.optional(effect.Schema.String),
398
+ doc_url: effect.Schema.optional(effect.Schema.String),
399
+ suggestion: effect.Schema.optional(effect.Schema.String)
400
+ }
401
+ ) {
402
+ };
403
+ var AuthContext = effect.Context.GenericTag(
404
+ "@payark/sdk-effect/AuthContext"
405
+ );
406
+ var SecurityMiddleware = class extends platform.HttpApiMiddleware.Tag()(
407
+ "SecurityMiddleware",
408
+ {
409
+ security: {
410
+ bearer: platform.HttpApiSecurity.bearer
411
+ },
412
+ provides: AuthContext,
413
+ failure: effect.Schema.Union(AuthenticationError, IndustrialError)
414
+ }
415
+ ) {
416
+ };
417
+ var CronSecurity = class extends platform.HttpApiMiddleware.Tag()(
418
+ "CronSecurity",
419
+ {
420
+ security: {
421
+ secret: platform.HttpApiSecurity.apiKey({ in: "header", key: "x-cron-secret" })
422
+ },
423
+ failure: effect.Schema.Union(AuthenticationError, IndustrialError)
424
+ }
425
+ ) {
426
+ };
427
+ var UserSecurity = class extends platform.HttpApiMiddleware.Tag()(
428
+ "UserSecurity",
429
+ {
430
+ security: {
431
+ bearer: platform.HttpApiSecurity.bearer
432
+ },
433
+ provides: AuthContext,
434
+ failure: effect.Schema.Union(AuthenticationError, IndustrialError)
435
+ }
436
+ ) {
437
+ };
438
+ var CheckoutGroup = platform.HttpApiGroup.make("checkout").add(
439
+ platform.HttpApiEndpoint.post("create", "/").addSuccess(CheckoutSession).setPayload(CreateCheckoutParams).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
440
+ ).prefix("/v1/checkout").middleware(SecurityMiddleware);
441
+ var PaymentsGroup = platform.HttpApiGroup.make("payments").add(
442
+ platform.HttpApiEndpoint.get("list", "/").addSuccess(PaginatedResponse(Payment)).setUrlParams(ListPaymentsParams).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
443
+ ).add(
444
+ platform.HttpApiEndpoint.get("retrieve", "/:id").addSuccess(Payment).setPath(effect.Schema.Struct({ id: Id })).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
445
+ ).prefix("/v1/payments").middleware(SecurityMiddleware);
446
+ var CustomersGroup = platform.HttpApiGroup.make("customers").add(
447
+ platform.HttpApiEndpoint.post("create", "/").addSuccess(Customer, { status: 201 }).setPayload(CreateCustomerParams).addError(AuthenticationError, { status: 401 }).addError(ConflictError, { status: 409 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
448
+ ).add(
449
+ platform.HttpApiEndpoint.get("list", "/").addSuccess(PaginatedResponse(Customer)).setUrlParams(ListCustomersParams).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
450
+ ).add(
451
+ platform.HttpApiEndpoint.get("retrieve", "/:id").addSuccess(Customer).setPath(effect.Schema.Struct({ id: Id })).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
452
+ ).add(
453
+ platform.HttpApiEndpoint.patch("update", "/:id").addSuccess(Customer).setPath(effect.Schema.Struct({ id: Id })).setPayload(UpdateCustomerParams).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 }).addError(ConflictError, { status: 409 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
454
+ ).add(
455
+ platform.HttpApiEndpoint.del("delete", "/:id").setPath(effect.Schema.Struct({ id: Id })).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 }).addError(ConflictError, { status: 409 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
456
+ ).prefix("/v1/customers").middleware(SecurityMiddleware);
457
+ var SubscriptionsGroup = platform.HttpApiGroup.make("subscriptions").add(
458
+ platform.HttpApiEndpoint.post("create", "/").addSuccess(Subscription, { status: 201 }).setPayload(CreateSubscriptionParams).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 }).middleware(SecurityMiddleware)
459
+ ).add(
460
+ platform.HttpApiEndpoint.get("retrieve", "/:id").addSuccess(Subscription).setPath(effect.Schema.Struct({ id: SubscriptionId })).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 }).addError(InternalServerError, { status: 500 }).middleware(SecurityMiddleware)
461
+ ).add(
462
+ platform.HttpApiEndpoint.get("list", "/").addSuccess(PaginatedResponse(Subscription)).setUrlParams(ListSubscriptionsParams).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 }).middleware(SecurityMiddleware)
463
+ ).add(
464
+ platform.HttpApiEndpoint.post("cancel", "/:id/cancel").addSuccess(Subscription).setPath(effect.Schema.Struct({ id: SubscriptionId })).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 }).addError(InternalServerError, { status: 500 }).middleware(SecurityMiddleware)
465
+ ).add(
466
+ platform.HttpApiEndpoint.post("activate", "/:id/activate").addSuccess(
467
+ effect.Schema.Struct({
468
+ checkout_url: effect.Schema.String,
469
+ payment_id: effect.Schema.String
470
+ })
471
+ ).setPath(effect.Schema.Struct({ id: SubscriptionId })).setPayload(
472
+ effect.Schema.Struct({
473
+ provider: Provider,
474
+ returnUrl: effect.Schema.String,
475
+ cancelUrl: effect.Schema.optional(effect.Schema.String)
476
+ })
477
+ ).addError(NotFoundError, { status: 404 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
478
+ ).prefix("/v1/subscriptions");
479
+ var AutomationGroup = platform.HttpApiGroup.make("automation").add(
480
+ platform.HttpApiEndpoint.post("reminders", "/reminders").addSuccess(
481
+ effect.Schema.Struct({
482
+ message: effect.Schema.String,
483
+ count: effect.Schema.Number
484
+ })
485
+ ).addError(InternalServerError, { status: 500 })
486
+ ).add(
487
+ platform.HttpApiEndpoint.post("reaper", "/reaper").addSuccess(
488
+ effect.Schema.Struct({
489
+ message: effect.Schema.String,
490
+ count: effect.Schema.Number,
491
+ purged_projects: effect.Schema.Number
492
+ })
493
+ ).addError(InternalServerError, { status: 500 })
494
+ ).add(
495
+ platform.HttpApiEndpoint.post("processRenewals", "/process-renewals").addSuccess(
496
+ effect.Schema.Struct({
497
+ message: effect.Schema.String,
498
+ emails_sent: effect.Schema.Number
499
+ })
500
+ ).addError(InternalServerError, { status: 500 })
501
+ ).add(
502
+ platform.HttpApiEndpoint.post("processGracePeriod", "/process-grace-period").addSuccess(
503
+ effect.Schema.Struct({
504
+ message: effect.Schema.String,
505
+ marked_past_due: effect.Schema.Number
506
+ })
507
+ ).addError(InternalServerError, { status: 500 })
508
+ ).prefix("/v1/automation").middleware(CronSecurity);
509
+ var TokensGroup = platform.HttpApiGroup.make("tokens").add(
510
+ platform.HttpApiEndpoint.post("create", "/").addSuccess(
511
+ effect.Schema.Struct({
512
+ ...Token.fields,
513
+ token: effect.Schema.String
514
+ })
515
+ ).setPayload(
516
+ effect.Schema.Struct({
517
+ name: effect.Schema.String,
518
+ scopes: effect.Schema.optionalWith(effect.Schema.Array(effect.Schema.String), {
519
+ default: () => []
520
+ }),
521
+ expires_in_days: effect.Schema.optional(effect.Schema.Number)
522
+ })
523
+ ).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 })
524
+ ).add(
525
+ platform.HttpApiEndpoint.get("list", "/").addSuccess(effect.Schema.Array(Token)).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 })
526
+ ).add(
527
+ platform.HttpApiEndpoint.del("delete", "/:id").setPath(effect.Schema.Struct({ id: TokenId })).addSuccess(effect.Schema.Null).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 }).addError(InternalServerError, { status: 500 })
528
+ ).prefix("/v1/tokens").middleware(UserSecurity);
529
+ var ProjectsGroup = platform.HttpApiGroup.make("projects").add(
530
+ platform.HttpApiEndpoint.get("list", "/").addSuccess(effect.Schema.Array(Project)).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 })
531
+ ).add(
532
+ platform.HttpApiEndpoint.post("upgrade", "/:id/upgrade").addSuccess(Project).setPath(effect.Schema.Struct({ id: ProjectId })).setPayload(effect.Schema.Struct({ tier: effect.Schema.Literal("pro", "enterprise") })).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 })
533
+ ).prefix("/v1/projects").middleware(UserSecurity);
534
+ var PaymentCallbackQueryParams = effect.Schema.Struct({
535
+ payment_id: effect.Schema.optional(effect.Schema.String),
536
+ data: effect.Schema.optional(effect.Schema.String),
537
+ pidx: effect.Schema.optional(effect.Schema.String),
538
+ /** HamroPay-specific: the gateway's own transactionId returned on callback. */
539
+ ref_id: effect.Schema.optional(effect.Schema.String),
540
+ /** Supabase Auth: access_token and refresh_token can be in the fragment or query */
541
+ access_token: effect.Schema.optional(effect.Schema.String),
542
+ refresh_token: effect.Schema.optional(effect.Schema.String),
543
+ code: effect.Schema.optional(effect.Schema.String)
544
+ });
545
+ var CallbacksGroup = platform.HttpApiGroup.make("callbacks").add(
546
+ platform.HttpApiEndpoint.get("handle", "/:provider").addSuccess(effect.Schema.Any).setPath(effect.Schema.Struct({ provider: effect.Schema.String })).setUrlParams(PaymentCallbackQueryParams).addError(NotFoundError, { status: 404 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
547
+ ).prefix("/v1/callback");
548
+ var AuthCallbackQueryParams = effect.Schema.Struct({
549
+ code: effect.Schema.optional(effect.Schema.String),
550
+ next: effect.Schema.optional(effect.Schema.String)
551
+ });
552
+ var AuthGroup = platform.HttpApiGroup.make("auth").add(
553
+ platform.HttpApiEndpoint.post("callback", "/callback").addSuccess(effect.Schema.Any).setUrlParams(AuthCallbackQueryParams).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 })
554
+ ).prefix("/auth");
555
+ var RealtimeGroup = platform.HttpApiGroup.make("realtime").add(
556
+ platform.HttpApiEndpoint.get("connect", "/").addSuccess(effect.Schema.Any).setUrlParams(effect.Schema.Struct({ token: effect.Schema.String })).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 })
557
+ ).add(
558
+ platform.HttpApiEndpoint.post("trigger", "/trigger").addSuccess(
559
+ effect.Schema.Struct({
560
+ status: effect.Schema.String,
561
+ event: effect.Schema.optional(effect.Schema.String)
562
+ })
563
+ ).setPayload(RealtimeTriggerPayload).setUrlParams(effect.Schema.Struct({ token: effect.Schema.optional(effect.Schema.String) })).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 })
564
+ ).prefix("/v1/realtime");
565
+ var MandatesGroup = platform.HttpApiGroup.make("mandates").add(
566
+ platform.HttpApiEndpoint.post("registerIntent", "/intent").addSuccess(Mandate, { status: 201 }).setPayload(
567
+ effect.Schema.Struct({
568
+ principal_id: effect.Schema.String,
569
+ max_amount: effect.Schema.Number,
570
+ currency: effect.Schema.String,
571
+ valid_until: Timestamp,
572
+ permitted_vendors: effect.Schema.optional(effect.Schema.Array(effect.Schema.String)),
573
+ credential_jwt: effect.Schema.String,
574
+ public_key: effect.Schema.String,
575
+ customer_id: effect.Schema.optional(CustomerId)
576
+ })
577
+ ).addError(AuthenticationError, { status: 401 }).addError(IndustrialError, { status: 400 })
578
+ ).add(
579
+ platform.HttpApiEndpoint.get("retrieve", "/:id").addSuccess(Mandate).setPath(effect.Schema.Struct({ id: MandateId })).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 })
580
+ ).prefix("/v1/mandates").middleware(SecurityMiddleware);
581
+ var SandboxGroup = platform.HttpApiGroup.make("sandbox").add(
582
+ platform.HttpApiEndpoint.post("init", "/init").addSuccess(
583
+ effect.Schema.Struct({
584
+ projectId: effect.Schema.String,
585
+ apiKey: effect.Schema.optional(effect.Schema.String),
586
+ expiresAt: Timestamp,
587
+ session: effect.Schema.optional(
588
+ effect.Schema.Struct({
589
+ access_token: effect.Schema.String,
590
+ refresh_token: effect.Schema.String
591
+ })
592
+ )
593
+ })
594
+ ).addError(InternalServerError, { status: 500 })
595
+ ).prefix("/v1/sandbox").middleware(UserSecurity);
596
+ var DiscoveryGroup = platform.HttpApiGroup.make("discovery").add(
597
+ platform.HttpApiEndpoint.get("agentCard", "/agent.json").addSuccess(effect.Schema.Any).addError(InternalServerError, { status: 500 })
598
+ ).prefix("/.well-known");
599
+ var SigningKeysGroup = platform.HttpApiGroup.make("signingKeys").add(
600
+ platform.HttpApiEndpoint.post("generate", "/").addSuccess(
601
+ effect.Schema.Struct({
602
+ id: effect.Schema.String,
603
+ publicKey: effect.Schema.String,
604
+ privateKey: effect.Schema.String,
605
+ algorithm: effect.Schema.String,
606
+ createdAt: Timestamp
607
+ }),
608
+ { status: 201 }
609
+ ).setPath(effect.Schema.Struct({ id: ProjectId })).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 }).addError(InternalServerError, { status: 500 })
610
+ ).add(
611
+ platform.HttpApiEndpoint.get("get", "/").addSuccess(
612
+ effect.Schema.Struct({
613
+ id: effect.Schema.String,
614
+ publicKey: effect.Schema.String,
615
+ algorithm: effect.Schema.String,
616
+ createdAt: Timestamp
617
+ })
618
+ ).setPath(effect.Schema.Struct({ id: ProjectId })).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 }).addError(InternalServerError, { status: 500 })
619
+ ).prefix("/v1/projects/:id/signing-keys").middleware(UserSecurity);
620
+ var PayArkApi = platform.HttpApi.make("PayArkApi").add(CheckoutGroup).add(PaymentsGroup).add(CustomersGroup).add(SubscriptionsGroup).add(AutomationGroup).add(TokensGroup).add(ProjectsGroup).add(CallbacksGroup).add(AuthGroup).add(MandatesGroup).add(DiscoveryGroup).add(RealtimeGroup).add(SandboxGroup).add(SigningKeysGroup).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 }).addError(MandateViolationError, { status: 403 }).addError(MandateExpiredError, { status: 410 }).addError(ConflictError, { status: 409 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 });
621
+
622
+ exports.AuthCallbackQueryParams = AuthCallbackQueryParams;
623
+ exports.AuthContext = AuthContext;
624
+ exports.AuthGroup = AuthGroup;
625
+ exports.AuthenticationError = AuthenticationError;
626
+ exports.AutomationGroup = AutomationGroup;
627
+ exports.CallbacksGroup = CallbacksGroup;
628
+ exports.CheckoutGroup = CheckoutGroup;
629
+ exports.ConflictError = ConflictError;
630
+ exports.CronSecurity = CronSecurity;
631
+ exports.CustomersGroup = CustomersGroup;
632
+ exports.DiscoveryGroup = DiscoveryGroup;
633
+ exports.IndustrialError = IndustrialError;
634
+ exports.InternalServerError = InternalServerError;
635
+ exports.MandateExpiredError = MandateExpiredError;
636
+ exports.MandateViolationError = MandateViolationError;
637
+ exports.MandatesGroup = MandatesGroup;
638
+ exports.NotFoundError = NotFoundError;
639
+ exports.PayArkApi = PayArkApi;
640
+ exports.PaymentCallbackQueryParams = PaymentCallbackQueryParams;
641
+ exports.PaymentsGroup = PaymentsGroup;
642
+ exports.ProjectsGroup = ProjectsGroup;
643
+ exports.RealtimeGroup = RealtimeGroup;
644
+ exports.SandboxGroup = SandboxGroup;
645
+ exports.SecurityMiddleware = SecurityMiddleware;
646
+ exports.SigningKeysGroup = SigningKeysGroup;
647
+ exports.SubscriptionsGroup = SubscriptionsGroup;
648
+ exports.TokensGroup = TokensGroup;
649
+ exports.UserSecurity = UserSecurity;
650
+ //# sourceMappingURL=api-spec.js.map
651
+ //# sourceMappingURL=api-spec.js.map