@payark/sdk-effect 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,17 +1,369 @@
1
1
  'use strict';
2
2
 
3
3
  var effect = require('effect');
4
- var schema = require('@effect/schema');
5
4
  var platform = require('@effect/platform');
6
- var sdk = require('@payark/sdk');
7
5
 
8
6
  // src/index.ts
7
+ var Id = effect.Schema.String.pipe(effect.Schema.brand("Id"));
8
+ var ProjectId = effect.Schema.String.pipe(effect.Schema.brand("ProjectId"));
9
+ var PaymentId = effect.Schema.String.pipe(effect.Schema.brand("PaymentId"));
10
+ var CheckoutSessionId = effect.Schema.String.pipe(
11
+ effect.Schema.brand("CheckoutSessionId")
12
+ );
13
+ var SubscriptionId = effect.Schema.String.pipe(
14
+ effect.Schema.brand("SubscriptionId")
15
+ );
16
+ var CustomerId = effect.Schema.String.pipe(effect.Schema.brand("CustomerId"));
17
+ var TokenId = effect.Schema.String.pipe(effect.Schema.brand("TokenId"));
18
+ var Email = effect.Schema.String.pipe(
19
+ effect.Schema.filter((s) => s.includes("@")),
20
+ effect.Schema.brand("Email")
21
+ );
22
+ var Timestamp = effect.Schema.String.pipe(effect.Schema.brand("Timestamp"));
23
+ var Metadata = effect.Schema.Record({
24
+ key: effect.Schema.String,
25
+ value: effect.Schema.Any
26
+ });
27
+ var Timestamps = effect.Schema.Struct({
28
+ created_at: Timestamp,
29
+ updated_at: Timestamp
30
+ });
31
+ var Provider = effect.Schema.Literal(
32
+ "esewa",
33
+ "khalti",
34
+ "connectips",
35
+ "imepay",
36
+ "fonepay",
37
+ "sandbox"
38
+ );
39
+ var PaymentStatus = effect.Schema.Literal("pending", "success", "failed");
40
+ var SubscriptionStatus = effect.Schema.Literal(
41
+ "active",
42
+ "past_due",
43
+ "canceled",
44
+ "paused"
45
+ );
46
+ var SubscriptionInterval = effect.Schema.Literal("month", "year", "week");
47
+ var Customer = effect.Schema.Struct({
48
+ id: CustomerId,
49
+ merchant_customer_id: effect.Schema.String,
50
+ email: effect.Schema.NullOr(Email),
51
+ name: effect.Schema.NullOr(effect.Schema.String),
52
+ phone: effect.Schema.NullOr(effect.Schema.String),
53
+ project_id: ProjectId,
54
+ metadata: effect.Schema.NullOr(Metadata),
55
+ created_at: Timestamp,
56
+ updated_at: effect.Schema.optional(Timestamp)
57
+ });
58
+ var Payment = effect.Schema.Struct({
59
+ id: PaymentId,
60
+ project_id: ProjectId,
61
+ amount: effect.Schema.Number,
62
+ currency: effect.Schema.String,
63
+ status: PaymentStatus,
64
+ provider_ref: effect.Schema.optional(effect.Schema.NullOr(effect.Schema.String)),
65
+ metadata_json: effect.Schema.optional(effect.Schema.NullOr(Metadata)),
66
+ gateway_response: effect.Schema.optional(effect.Schema.NullOr(effect.Schema.Any)),
67
+ created_at: Timestamp,
68
+ updated_at: effect.Schema.optional(Timestamp)
69
+ });
70
+ var Subscription = effect.Schema.Struct({
71
+ id: SubscriptionId,
72
+ project_id: ProjectId,
73
+ customer_id: CustomerId,
74
+ status: SubscriptionStatus,
75
+ amount: effect.Schema.Number,
76
+ currency: effect.Schema.String,
77
+ interval: SubscriptionInterval,
78
+ interval_count: effect.Schema.Number,
79
+ current_period_start: Timestamp,
80
+ current_period_end: Timestamp,
81
+ payment_link: effect.Schema.String,
82
+ auto_send_link: effect.Schema.Boolean,
83
+ metadata: effect.Schema.optional(effect.Schema.NullOr(Metadata)),
84
+ canceled_at: effect.Schema.optional(effect.Schema.NullOr(Timestamp)),
85
+ created_at: Timestamp,
86
+ updated_at: effect.Schema.optional(Timestamp)
87
+ });
88
+ var Project = effect.Schema.Struct({
89
+ id: ProjectId,
90
+ name: effect.Schema.String,
91
+ api_key_secret: effect.Schema.String,
92
+ created_at: Timestamp
93
+ });
94
+ var Token = effect.Schema.Struct({
95
+ id: TokenId,
96
+ name: effect.Schema.String,
97
+ scopes: effect.Schema.Array(effect.Schema.String),
98
+ last_used_at: effect.Schema.NullOr(Timestamp),
99
+ expires_at: effect.Schema.NullOr(Timestamp),
100
+ created_at: Timestamp
101
+ });
102
+ var PaginationMeta = effect.Schema.Struct({
103
+ total: effect.Schema.NullOr(effect.Schema.Number),
104
+ limit: effect.Schema.Number,
105
+ offset: effect.Schema.Number
106
+ });
107
+ var PaginatedResponse = (schema) => effect.Schema.Struct({
108
+ data: effect.Schema.Array(schema),
109
+ meta: PaginationMeta
110
+ });
111
+ var CreateCheckoutParams = effect.Schema.Struct({
112
+ amount: effect.Schema.Number.pipe(effect.Schema.greaterThan(0)),
113
+ currency: effect.Schema.optionalWith(effect.Schema.String, { default: () => "NPR" }),
114
+ provider: Provider,
115
+ returnUrl: effect.Schema.String,
116
+ cancelUrl: effect.Schema.optional(effect.Schema.String),
117
+ metadata: effect.Schema.optional(Metadata)
118
+ });
119
+ var CheckoutSession = effect.Schema.Struct({
120
+ id: CheckoutSessionId,
121
+ checkout_url: effect.Schema.String,
122
+ payment_method: effect.Schema.Struct({
123
+ type: Provider,
124
+ url: effect.Schema.optional(effect.Schema.String),
125
+ method: effect.Schema.optional(effect.Schema.Literal("GET", "POST")),
126
+ fields: effect.Schema.optional(
127
+ effect.Schema.Record({ key: effect.Schema.String, value: effect.Schema.String })
128
+ )
129
+ })
130
+ });
131
+ var CreateCustomerParams = effect.Schema.Struct({
132
+ merchant_customer_id: effect.Schema.String,
133
+ email: effect.Schema.optional(effect.Schema.String),
134
+ name: effect.Schema.optional(effect.Schema.String),
135
+ phone: effect.Schema.optional(effect.Schema.String),
136
+ project_id: effect.Schema.optional(ProjectId),
137
+ metadata: effect.Schema.optional(Metadata)
138
+ });
139
+ var ListPaymentsParams = effect.Schema.Struct({
140
+ limit: effect.Schema.optional(effect.Schema.NumberFromString),
141
+ offset: effect.Schema.optional(effect.Schema.NumberFromString),
142
+ projectId: effect.Schema.optional(ProjectId)
143
+ });
144
+ var ListCustomersParams = effect.Schema.Struct({
145
+ limit: effect.Schema.optional(effect.Schema.NumberFromString),
146
+ offset: effect.Schema.optional(effect.Schema.NumberFromString),
147
+ email: effect.Schema.optional(effect.Schema.String),
148
+ projectId: effect.Schema.optional(ProjectId)
149
+ });
150
+ var UpdateCustomerParams = effect.Schema.Struct({
151
+ email: effect.Schema.optional(effect.Schema.String),
152
+ name: effect.Schema.optional(effect.Schema.String),
153
+ phone: effect.Schema.optional(effect.Schema.String),
154
+ metadata: effect.Schema.optional(Metadata)
155
+ });
156
+ var CreateSubscriptionParams = effect.Schema.Struct({
157
+ customer_id: CustomerId,
158
+ amount: effect.Schema.Number.pipe(effect.Schema.greaterThan(0)),
159
+ currency: effect.Schema.optionalWith(effect.Schema.String, { default: () => "NPR" }),
160
+ interval: SubscriptionInterval,
161
+ interval_count: effect.Schema.optional(effect.Schema.Number),
162
+ project_id: effect.Schema.optional(ProjectId),
163
+ auto_send_link: effect.Schema.optional(effect.Schema.Boolean),
164
+ metadata: effect.Schema.optional(Metadata)
165
+ });
166
+ var ListSubscriptionsParams = effect.Schema.Struct({
167
+ limit: effect.Schema.optional(effect.Schema.NumberFromString),
168
+ offset: effect.Schema.optional(effect.Schema.NumberFromString),
169
+ projectId: effect.Schema.optional(ProjectId),
170
+ customerId: effect.Schema.optional(CustomerId),
171
+ status: effect.Schema.optional(SubscriptionStatus)
172
+ });
173
+ var PayArkConfig = effect.Schema.Struct({
174
+ apiKey: effect.Schema.String,
175
+ baseUrl: effect.Schema.optional(effect.Schema.String),
176
+ timeout: effect.Schema.optional(effect.Schema.Number),
177
+ maxRetries: effect.Schema.optional(effect.Schema.Number),
178
+ sandbox: effect.Schema.optional(effect.Schema.Boolean)
179
+ });
180
+ var WebhookEventType = effect.Schema.Literal(
181
+ "payment.success",
182
+ "payment.failed",
183
+ "subscription.created",
184
+ "subscription.payment_succeeded",
185
+ "subscription.payment_failed",
186
+ "subscription.renewal_due",
187
+ "subscription.canceled"
188
+ );
189
+ var WebhookEvent = effect.Schema.Struct({
190
+ type: WebhookEventType,
191
+ id: effect.Schema.optional(effect.Schema.String),
192
+ data: effect.Schema.Union(
193
+ Payment,
194
+ Subscription,
195
+ Customer,
196
+ effect.Schema.Struct({
197
+ id: effect.Schema.String,
198
+ amount: effect.Schema.optional(effect.Schema.Number),
199
+ currency: effect.Schema.optional(effect.Schema.String),
200
+ status: effect.Schema.String,
201
+ metadata: effect.Schema.optional(Metadata)
202
+ })
203
+ ),
204
+ is_test: effect.Schema.Boolean,
205
+ created: effect.Schema.optional(effect.Schema.Number)
206
+ });
207
+ var PayArkErrorBody = effect.Schema.Struct({
208
+ error: effect.Schema.String,
209
+ details: effect.Schema.optional(effect.Schema.Any)
210
+ });
211
+ var IndustrialError = class extends effect.Schema.TaggedError()(
212
+ "IndustrialError",
213
+ {
214
+ error: effect.Schema.String,
215
+ details: effect.Schema.optional(effect.Schema.Any)
216
+ }
217
+ ) {
218
+ };
219
+ var AuthenticationError = class extends effect.Schema.TaggedError()(
220
+ "AuthenticationError",
221
+ {
222
+ error: effect.Schema.String
223
+ }
224
+ ) {
225
+ };
226
+ var NotFoundError = class extends effect.Schema.TaggedError()(
227
+ "NotFoundError",
228
+ {
229
+ error: effect.Schema.String
230
+ }
231
+ ) {
232
+ };
233
+ var InternalServerError = class extends effect.Schema.TaggedError()(
234
+ "InternalServerError",
235
+ {
236
+ error: effect.Schema.String,
237
+ details: effect.Schema.optional(effect.Schema.Any)
238
+ }
239
+ ) {
240
+ };
241
+ var ConflictError = class extends effect.Schema.TaggedError()(
242
+ "ConflictError",
243
+ {
244
+ error: effect.Schema.String
245
+ }
246
+ ) {
247
+ };
248
+ var AuthContext = effect.Context.GenericTag(
249
+ "@payark/sdk-effect/AuthContext"
250
+ );
251
+ var SecurityMiddleware = class extends platform.HttpApiMiddleware.Tag()(
252
+ "SecurityMiddleware",
253
+ {
254
+ security: {
255
+ bearer: platform.HttpApiSecurity.bearer
256
+ },
257
+ provides: AuthContext,
258
+ failure: effect.Schema.Union(AuthenticationError, IndustrialError)
259
+ }
260
+ ) {
261
+ };
262
+ var CronSecurity = class extends platform.HttpApiMiddleware.Tag()(
263
+ "CronSecurity",
264
+ {
265
+ security: {
266
+ secret: platform.HttpApiSecurity.apiKey({ in: "header", key: "x-cron-secret" })
267
+ },
268
+ failure: effect.Schema.Union(AuthenticationError, IndustrialError)
269
+ }
270
+ ) {
271
+ };
272
+ var UserSecurity = class extends platform.HttpApiMiddleware.Tag()(
273
+ "UserSecurity",
274
+ {
275
+ security: {
276
+ bearer: platform.HttpApiSecurity.bearer
277
+ },
278
+ provides: AuthContext,
279
+ failure: effect.Schema.Union(AuthenticationError, IndustrialError)
280
+ }
281
+ ) {
282
+ };
283
+ var CheckoutGroup = platform.HttpApiGroup.make("checkout").add(
284
+ platform.HttpApiEndpoint.post("create", "/").addSuccess(CheckoutSession).setPayload(CreateCheckoutParams).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
285
+ ).prefix("/v1/checkout").middleware(SecurityMiddleware);
286
+ var PaymentsGroup = platform.HttpApiGroup.make("payments").add(
287
+ platform.HttpApiEndpoint.get("list", "/").addSuccess(PaginatedResponse(Payment)).setUrlParams(ListPaymentsParams).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
288
+ ).add(
289
+ 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 })
290
+ ).prefix("/v1/payments").middleware(SecurityMiddleware);
291
+ var CustomersGroup = platform.HttpApiGroup.make("customers").add(
292
+ 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 })
293
+ ).add(
294
+ 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 })
295
+ ).add(
296
+ 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 })
297
+ ).add(
298
+ 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 })
299
+ ).prefix("/v1/customers").middleware(SecurityMiddleware);
300
+ var SubscriptionsGroup = platform.HttpApiGroup.make("subscriptions").add(
301
+ platform.HttpApiEndpoint.post("create", "/").addSuccess(Subscription, { status: 201 }).setPayload(CreateSubscriptionParams).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 }).middleware(SecurityMiddleware)
302
+ ).add(
303
+ 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)
304
+ ).add(
305
+ platform.HttpApiEndpoint.get("list", "/").addSuccess(PaginatedResponse(Subscription)).setUrlParams(ListSubscriptionsParams).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 }).middleware(SecurityMiddleware)
306
+ ).add(
307
+ 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)
308
+ ).add(
309
+ platform.HttpApiEndpoint.post("activate", "/:id/activate").addSuccess(
310
+ effect.Schema.Struct({
311
+ checkout_url: effect.Schema.String,
312
+ payment_id: effect.Schema.String
313
+ })
314
+ ).setPath(effect.Schema.Struct({ id: SubscriptionId })).setPayload(
315
+ effect.Schema.Struct({
316
+ provider: Provider,
317
+ returnUrl: effect.Schema.String,
318
+ cancelUrl: effect.Schema.optional(effect.Schema.String)
319
+ })
320
+ ).addError(NotFoundError, { status: 404 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 })
321
+ ).prefix("/v1/subscriptions");
322
+ var AutomationGroup = platform.HttpApiGroup.make("automation").add(
323
+ platform.HttpApiEndpoint.post("reminders", "/reminders").addSuccess(
324
+ effect.Schema.Struct({
325
+ message: effect.Schema.String,
326
+ count: effect.Schema.Number
327
+ })
328
+ ).addError(InternalServerError, { status: 500 })
329
+ ).add(
330
+ platform.HttpApiEndpoint.post("reaper", "/reaper").addSuccess(
331
+ effect.Schema.Struct({
332
+ message: effect.Schema.String,
333
+ count: effect.Schema.Number
334
+ })
335
+ ).addError(InternalServerError, { status: 500 })
336
+ ).prefix("/v1/automation").middleware(CronSecurity);
337
+ var TokensGroup = platform.HttpApiGroup.make("tokens").add(
338
+ platform.HttpApiEndpoint.post("create", "/").addSuccess(
339
+ effect.Schema.Struct({
340
+ ...Token.fields,
341
+ token: effect.Schema.String
342
+ })
343
+ ).setPayload(
344
+ effect.Schema.Struct({
345
+ name: effect.Schema.String,
346
+ scopes: effect.Schema.optionalWith(effect.Schema.Array(effect.Schema.String), {
347
+ default: () => []
348
+ }),
349
+ expires_in_days: effect.Schema.optional(effect.Schema.Number)
350
+ })
351
+ ).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 })
352
+ ).add(
353
+ platform.HttpApiEndpoint.get("list", "/").addSuccess(effect.Schema.Array(Token)).addError(AuthenticationError, { status: 401 }).addError(InternalServerError, { status: 500 })
354
+ ).add(
355
+ 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 })
356
+ ).prefix("/v1/tokens").middleware(UserSecurity);
357
+ var PayArkApi = platform.HttpApi.make("PayArkApi").add(CheckoutGroup).add(PaymentsGroup).add(CustomersGroup).add(SubscriptionsGroup).add(AutomationGroup).add(TokensGroup).addError(AuthenticationError, { status: 401 }).addError(NotFoundError, { status: 404 }).addError(ConflictError, { status: 409 }).addError(InternalServerError, { status: 500 }).addError(IndustrialError, { status: 400 });
9
358
  var PayArkEffectError = class extends effect.Data.TaggedError("PayArkEffectError") {
10
359
  /** Human-readable representation for logging/debugging. */
11
360
  toString() {
12
361
  return `[PayArkEffectError: ${this.code}] ${this.message} (HTTP ${this.statusCode})`;
13
362
  }
14
363
  };
364
+
365
+ // src/http.ts
366
+ var SDK_VERSION = "0.1.0";
15
367
  var PayArkConfigService = class extends effect.Context.Tag("PayArkConfigService")() {
16
368
  };
17
369
  var request = (method, path, options) => effect.Effect.gen(function* (_) {
@@ -30,7 +382,7 @@ var request = (method, path, options) => effect.Effect.gen(function* (_) {
30
382
  Authorization: `Bearer ${config.apiKey}`,
31
383
  "Content-Type": "application/json",
32
384
  Accept: "application/json",
33
- "User-Agent": `payark-sdk-effect/${sdk.SDK_VERSION}`,
385
+ "User-Agent": `payark-sdk-effect/${SDK_VERSION}`,
34
386
  ...options?.headers
35
387
  };
36
388
  if (config.sandbox) {
@@ -102,81 +454,6 @@ function mapStatusToCode(status) {
102
454
  if (status >= 500) return "api_error";
103
455
  return "unknown_error";
104
456
  }
105
- var ProviderSchema = schema.Schema.Union(
106
- schema.Schema.Literal(
107
- "esewa",
108
- "khalti",
109
- "connectips",
110
- "imepay",
111
- "fonepay",
112
- "sandbox"
113
- )
114
- );
115
- var CheckoutSessionId = schema.Schema.String.pipe(
116
- schema.Schema.brand("CheckoutSessionId")
117
- );
118
- var PaymentId = schema.Schema.String.pipe(schema.Schema.brand("PaymentId"));
119
- var ProjectId = schema.Schema.String.pipe(schema.Schema.brand("ProjectId"));
120
- var CreateCheckoutSchema = schema.Schema.Struct({
121
- amount: schema.Schema.Number,
122
- currency: schema.Schema.optionalWith(schema.Schema.String, {
123
- default: () => "NPR"
124
- }),
125
- provider: ProviderSchema,
126
- returnUrl: schema.Schema.String,
127
- cancelUrl: schema.Schema.optional(schema.Schema.String),
128
- metadata: schema.Schema.optional(
129
- schema.Schema.Record({ key: schema.Schema.String, value: schema.Schema.Any })
130
- )
131
- });
132
- var CheckoutSessionSchema = schema.Schema.Struct({
133
- id: CheckoutSessionId,
134
- checkout_url: schema.Schema.String,
135
- payment_method: schema.Schema.Struct({
136
- type: ProviderSchema,
137
- url: schema.Schema.optional(schema.Schema.String),
138
- method: schema.Schema.optional(
139
- schema.Schema.Union(schema.Schema.Literal("GET"), schema.Schema.Literal("POST"))
140
- ),
141
- fields: schema.Schema.optional(
142
- schema.Schema.Record({ key: schema.Schema.String, value: schema.Schema.String })
143
- )
144
- })
145
- });
146
- var PaymentSchema = schema.Schema.Struct({
147
- id: PaymentId,
148
- project_id: ProjectId,
149
- amount: schema.Schema.Number,
150
- currency: schema.Schema.String,
151
- status: schema.Schema.Union(
152
- schema.Schema.Literal("pending"),
153
- schema.Schema.Literal("success"),
154
- schema.Schema.Literal("failed")
155
- ),
156
- provider_ref: schema.Schema.optional(schema.Schema.NullOr(schema.Schema.String)),
157
- metadata_json: schema.Schema.optional(
158
- schema.Schema.NullOr(schema.Schema.Record({ key: schema.Schema.String, value: schema.Schema.Any }))
159
- ),
160
- gateway_response: schema.Schema.optional(
161
- schema.Schema.NullOr(schema.Schema.Record({ key: schema.Schema.String, value: schema.Schema.Any }))
162
- ),
163
- created_at: schema.Schema.String,
164
- updated_at: schema.Schema.optional(schema.Schema.String)
165
- });
166
- var ProjectSchema = schema.Schema.Struct({
167
- id: ProjectId,
168
- name: schema.Schema.String,
169
- api_key_secret: schema.Schema.String,
170
- created_at: schema.Schema.String
171
- });
172
- var PaginatedResponseSchema = (item) => schema.Schema.Struct({
173
- data: schema.Schema.Array(item),
174
- meta: schema.Schema.Struct({
175
- total: schema.Schema.NullOr(schema.Schema.Number),
176
- limit: schema.Schema.Number,
177
- offset: schema.Schema.Number
178
- })
179
- });
180
457
 
181
458
  // src/resources/checkout.ts
182
459
  var CheckoutEffect = class {
@@ -191,7 +468,7 @@ var CheckoutEffect = class {
191
468
  */
192
469
  create(params) {
193
470
  return request("POST", "/v1/checkout", { body: params }).pipe(
194
- effect.Effect.flatMap(schema.Schema.decodeUnknown(CheckoutSessionSchema)),
471
+ effect.Effect.flatMap(effect.Schema.decodeUnknown(CheckoutSession)),
195
472
  effect.Effect.provideService(PayArkConfigService, this.config)
196
473
  );
197
474
  }
@@ -214,9 +491,7 @@ var PaymentsEffect = class {
214
491
  projectId: params.projectId
215
492
  }
216
493
  }).pipe(
217
- effect.Effect.flatMap(
218
- schema.Schema.decodeUnknown(PaginatedResponseSchema(PaymentSchema))
219
- ),
494
+ effect.Effect.flatMap(effect.Schema.decodeUnknown(PaginatedResponse(Payment))),
220
495
  effect.Effect.provideService(PayArkConfigService, this.config)
221
496
  );
222
497
  }
@@ -231,7 +506,7 @@ var PaymentsEffect = class {
231
506
  "GET",
232
507
  `/v1/payments/${encodeURIComponent(id)}`
233
508
  ).pipe(
234
- effect.Effect.flatMap(schema.Schema.decodeUnknown(PaymentSchema)),
509
+ effect.Effect.flatMap(effect.Schema.decodeUnknown(Payment)),
235
510
  effect.Effect.provideService(PayArkConfigService, this.config)
236
511
  );
237
512
  }
@@ -247,13 +522,19 @@ var ProjectsEffect = class {
247
522
  */
248
523
  list() {
249
524
  return request("GET", "/v1/projects").pipe(
250
- effect.Effect.flatMap(schema.Schema.decodeUnknown(schema.Schema.Array(ProjectSchema))),
525
+ effect.Effect.flatMap(effect.Schema.decodeUnknown(effect.Schema.Array(Project))),
251
526
  effect.Effect.provideService(PayArkConfigService, this.config)
252
527
  );
253
528
  }
254
529
  };
255
530
 
256
531
  // src/index.ts
532
+ var makeClient = (options) => platform.HttpApiClient.make(PayArkApi, options);
533
+ var PayArkClient = class _PayArkClient extends effect.Context.Tag(
534
+ "@payark/sdk-effect/PayArkClient"
535
+ )() {
536
+ static Live = (options) => effect.Layer.effect(_PayArkClient, makeClient(options));
537
+ };
257
538
  var PayArkEffect = class {
258
539
  constructor(config) {
259
540
  this.config = config;
@@ -296,17 +577,60 @@ var PayArk = class _PayArk extends effect.Context.Tag("@payark/sdk-effect/PayArk
296
577
  static Live = (config) => effect.Layer.succeed(_PayArk, new PayArkEffect(config));
297
578
  };
298
579
 
580
+ exports.AuthContext = AuthContext;
581
+ exports.AuthenticationError = AuthenticationError;
582
+ exports.AutomationGroup = AutomationGroup;
583
+ exports.CheckoutGroup = CheckoutGroup;
584
+ exports.CheckoutSession = CheckoutSession;
299
585
  exports.CheckoutSessionId = CheckoutSessionId;
300
- exports.CheckoutSessionSchema = CheckoutSessionSchema;
301
- exports.CreateCheckoutSchema = CreateCheckoutSchema;
302
- exports.PaginatedResponseSchema = PaginatedResponseSchema;
586
+ exports.ConflictError = ConflictError;
587
+ exports.CreateCheckoutParams = CreateCheckoutParams;
588
+ exports.CreateCustomerParams = CreateCustomerParams;
589
+ exports.CreateSubscriptionParams = CreateSubscriptionParams;
590
+ exports.CronSecurity = CronSecurity;
591
+ exports.Customer = Customer;
592
+ exports.CustomerId = CustomerId;
593
+ exports.CustomersGroup = CustomersGroup;
594
+ exports.Email = Email;
595
+ exports.Id = Id;
596
+ exports.IndustrialError = IndustrialError;
597
+ exports.InternalServerError = InternalServerError;
598
+ exports.ListCustomersParams = ListCustomersParams;
599
+ exports.ListPaymentsParams = ListPaymentsParams;
600
+ exports.ListSubscriptionsParams = ListSubscriptionsParams;
601
+ exports.Metadata = Metadata;
602
+ exports.NotFoundError = NotFoundError;
603
+ exports.PaginatedResponse = PaginatedResponse;
604
+ exports.PaginationMeta = PaginationMeta;
303
605
  exports.PayArk = PayArk;
606
+ exports.PayArkApi = PayArkApi;
607
+ exports.PayArkClient = PayArkClient;
608
+ exports.PayArkConfig = PayArkConfig;
304
609
  exports.PayArkEffect = PayArkEffect;
305
610
  exports.PayArkEffectError = PayArkEffectError;
611
+ exports.PayArkErrorBody = PayArkErrorBody;
612
+ exports.Payment = Payment;
306
613
  exports.PaymentId = PaymentId;
307
- exports.PaymentSchema = PaymentSchema;
614
+ exports.PaymentStatus = PaymentStatus;
615
+ exports.PaymentsGroup = PaymentsGroup;
616
+ exports.Project = Project;
308
617
  exports.ProjectId = ProjectId;
309
- exports.ProjectSchema = ProjectSchema;
310
- exports.ProviderSchema = ProviderSchema;
618
+ exports.Provider = Provider;
619
+ exports.SecurityMiddleware = SecurityMiddleware;
620
+ exports.Subscription = Subscription;
621
+ exports.SubscriptionId = SubscriptionId;
622
+ exports.SubscriptionInterval = SubscriptionInterval;
623
+ exports.SubscriptionStatus = SubscriptionStatus;
624
+ exports.SubscriptionsGroup = SubscriptionsGroup;
625
+ exports.Timestamp = Timestamp;
626
+ exports.Timestamps = Timestamps;
627
+ exports.Token = Token;
628
+ exports.TokenId = TokenId;
629
+ exports.TokensGroup = TokensGroup;
630
+ exports.UpdateCustomerParams = UpdateCustomerParams;
631
+ exports.UserSecurity = UserSecurity;
632
+ exports.WebhookEvent = WebhookEvent;
633
+ exports.WebhookEventType = WebhookEventType;
634
+ exports.makeClient = makeClient;
311
635
  //# sourceMappingURL=index.js.map
312
636
  //# sourceMappingURL=index.js.map