@payark/sdk-effect 0.1.0 → 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,26 +1,375 @@
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* (_) {
18
370
  const config = yield* _(PayArkConfigService);
19
371
  const client = yield* _(platform.HttpClient.HttpClient);
20
- const baseUrl = (config.baseUrl ?? "https://api.payark.com").replace(
21
- /\/+$/,
22
- ""
23
- );
372
+ const baseUrl = (config.baseUrl ?? "https://payark-api.codimo-dev.workers.dev").replace(/\/+$/, "");
24
373
  const url = new URL(`${baseUrl}${path}`);
25
374
  if (options?.query) {
26
375
  for (const [key, value] of Object.entries(options.query)) {
@@ -33,7 +382,7 @@ var request = (method, path, options) => effect.Effect.gen(function* (_) {
33
382
  Authorization: `Bearer ${config.apiKey}`,
34
383
  "Content-Type": "application/json",
35
384
  Accept: "application/json",
36
- "User-Agent": `payark-sdk-effect/${sdk.SDK_VERSION}`,
385
+ "User-Agent": `payark-sdk-effect/${SDK_VERSION}`,
37
386
  ...options?.headers
38
387
  };
39
388
  if (config.sandbox) {
@@ -105,81 +454,6 @@ function mapStatusToCode(status) {
105
454
  if (status >= 500) return "api_error";
106
455
  return "unknown_error";
107
456
  }
108
- var ProviderSchema = schema.Schema.Union(
109
- schema.Schema.Literal(
110
- "esewa",
111
- "khalti",
112
- "connectips",
113
- "imepay",
114
- "fonepay",
115
- "sandbox"
116
- )
117
- );
118
- var CheckoutSessionId = schema.Schema.String.pipe(
119
- schema.Schema.brand("CheckoutSessionId")
120
- );
121
- var PaymentId = schema.Schema.String.pipe(schema.Schema.brand("PaymentId"));
122
- var ProjectId = schema.Schema.String.pipe(schema.Schema.brand("ProjectId"));
123
- var CreateCheckoutSchema = schema.Schema.Struct({
124
- amount: schema.Schema.Number,
125
- currency: schema.Schema.optionalWith(schema.Schema.String, {
126
- default: () => "NPR"
127
- }),
128
- provider: ProviderSchema,
129
- returnUrl: schema.Schema.String,
130
- cancelUrl: schema.Schema.optional(schema.Schema.String),
131
- metadata: schema.Schema.optional(
132
- schema.Schema.Record({ key: schema.Schema.String, value: schema.Schema.Any })
133
- )
134
- });
135
- var CheckoutSessionSchema = schema.Schema.Struct({
136
- id: CheckoutSessionId,
137
- checkout_url: schema.Schema.String,
138
- payment_method: schema.Schema.Struct({
139
- type: ProviderSchema,
140
- url: schema.Schema.optional(schema.Schema.String),
141
- method: schema.Schema.optional(
142
- schema.Schema.Union(schema.Schema.Literal("GET"), schema.Schema.Literal("POST"))
143
- ),
144
- fields: schema.Schema.optional(
145
- schema.Schema.Record({ key: schema.Schema.String, value: schema.Schema.String })
146
- )
147
- })
148
- });
149
- var PaymentSchema = schema.Schema.Struct({
150
- id: PaymentId,
151
- project_id: ProjectId,
152
- amount: schema.Schema.Number,
153
- currency: schema.Schema.String,
154
- status: schema.Schema.Union(
155
- schema.Schema.Literal("pending"),
156
- schema.Schema.Literal("success"),
157
- schema.Schema.Literal("failed")
158
- ),
159
- provider_ref: schema.Schema.optional(schema.Schema.NullOr(schema.Schema.String)),
160
- metadata_json: schema.Schema.optional(
161
- schema.Schema.NullOr(schema.Schema.Record({ key: schema.Schema.String, value: schema.Schema.Any }))
162
- ),
163
- gateway_response: schema.Schema.optional(
164
- schema.Schema.NullOr(schema.Schema.Record({ key: schema.Schema.String, value: schema.Schema.Any }))
165
- ),
166
- created_at: schema.Schema.String,
167
- updated_at: schema.Schema.optional(schema.Schema.String)
168
- });
169
- var ProjectSchema = schema.Schema.Struct({
170
- id: ProjectId,
171
- name: schema.Schema.String,
172
- api_key_secret: schema.Schema.String,
173
- created_at: schema.Schema.String
174
- });
175
- var PaginatedResponseSchema = (item) => schema.Schema.Struct({
176
- data: schema.Schema.Array(item),
177
- meta: schema.Schema.Struct({
178
- total: schema.Schema.NullOr(schema.Schema.Number),
179
- limit: schema.Schema.Number,
180
- offset: schema.Schema.Number
181
- })
182
- });
183
457
 
184
458
  // src/resources/checkout.ts
185
459
  var CheckoutEffect = class {
@@ -194,7 +468,7 @@ var CheckoutEffect = class {
194
468
  */
195
469
  create(params) {
196
470
  return request("POST", "/v1/checkout", { body: params }).pipe(
197
- effect.Effect.flatMap(schema.Schema.decodeUnknown(CheckoutSessionSchema)),
471
+ effect.Effect.flatMap(effect.Schema.decodeUnknown(CheckoutSession)),
198
472
  effect.Effect.provideService(PayArkConfigService, this.config)
199
473
  );
200
474
  }
@@ -217,9 +491,7 @@ var PaymentsEffect = class {
217
491
  projectId: params.projectId
218
492
  }
219
493
  }).pipe(
220
- effect.Effect.flatMap(
221
- schema.Schema.decodeUnknown(PaginatedResponseSchema(PaymentSchema))
222
- ),
494
+ effect.Effect.flatMap(effect.Schema.decodeUnknown(PaginatedResponse(Payment))),
223
495
  effect.Effect.provideService(PayArkConfigService, this.config)
224
496
  );
225
497
  }
@@ -234,7 +506,7 @@ var PaymentsEffect = class {
234
506
  "GET",
235
507
  `/v1/payments/${encodeURIComponent(id)}`
236
508
  ).pipe(
237
- effect.Effect.flatMap(schema.Schema.decodeUnknown(PaymentSchema)),
509
+ effect.Effect.flatMap(effect.Schema.decodeUnknown(Payment)),
238
510
  effect.Effect.provideService(PayArkConfigService, this.config)
239
511
  );
240
512
  }
@@ -250,13 +522,19 @@ var ProjectsEffect = class {
250
522
  */
251
523
  list() {
252
524
  return request("GET", "/v1/projects").pipe(
253
- effect.Effect.flatMap(schema.Schema.decodeUnknown(schema.Schema.Array(ProjectSchema))),
525
+ effect.Effect.flatMap(effect.Schema.decodeUnknown(effect.Schema.Array(Project))),
254
526
  effect.Effect.provideService(PayArkConfigService, this.config)
255
527
  );
256
528
  }
257
529
  };
258
530
 
259
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
+ };
260
538
  var PayArkEffect = class {
261
539
  constructor(config) {
262
540
  this.config = config;
@@ -299,17 +577,60 @@ var PayArk = class _PayArk extends effect.Context.Tag("@payark/sdk-effect/PayArk
299
577
  static Live = (config) => effect.Layer.succeed(_PayArk, new PayArkEffect(config));
300
578
  };
301
579
 
580
+ exports.AuthContext = AuthContext;
581
+ exports.AuthenticationError = AuthenticationError;
582
+ exports.AutomationGroup = AutomationGroup;
583
+ exports.CheckoutGroup = CheckoutGroup;
584
+ exports.CheckoutSession = CheckoutSession;
302
585
  exports.CheckoutSessionId = CheckoutSessionId;
303
- exports.CheckoutSessionSchema = CheckoutSessionSchema;
304
- exports.CreateCheckoutSchema = CreateCheckoutSchema;
305
- 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;
306
605
  exports.PayArk = PayArk;
606
+ exports.PayArkApi = PayArkApi;
607
+ exports.PayArkClient = PayArkClient;
608
+ exports.PayArkConfig = PayArkConfig;
307
609
  exports.PayArkEffect = PayArkEffect;
308
610
  exports.PayArkEffectError = PayArkEffectError;
611
+ exports.PayArkErrorBody = PayArkErrorBody;
612
+ exports.Payment = Payment;
309
613
  exports.PaymentId = PaymentId;
310
- exports.PaymentSchema = PaymentSchema;
614
+ exports.PaymentStatus = PaymentStatus;
615
+ exports.PaymentsGroup = PaymentsGroup;
616
+ exports.Project = Project;
311
617
  exports.ProjectId = ProjectId;
312
- exports.ProjectSchema = ProjectSchema;
313
- 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;
314
635
  //# sourceMappingURL=index.js.map
315
636
  //# sourceMappingURL=index.js.map