@01.software/sdk 0.45.0 → 0.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/MIGRATION.md +19 -0
  3. package/README.md +49 -4
  4. package/dist/client.cjs +13 -0
  5. package/dist/client.cjs.map +1 -1
  6. package/dist/client.d.cts +6 -6
  7. package/dist/client.d.ts +6 -6
  8. package/dist/client.js +13 -0
  9. package/dist/client.js.map +1 -1
  10. package/dist/{collection-client-Ckfusuee.d.ts → collection-client-BEGXnfQe.d.ts} +4 -4
  11. package/dist/{collection-client-BSo7VXQE.d.cts → collection-client-L2rEgBaR.d.cts} +4 -4
  12. package/dist/{const-CaPq2AE4.d.ts → const-GYVwlXLr.d.ts} +1 -1
  13. package/dist/{const-BAG0MH0u.d.cts → const-y0eipvnQ.d.cts} +1 -1
  14. package/dist/{index-BNICJxBL.d.ts → index-Bei4WlVw.d.ts} +3 -3
  15. package/dist/{index-YGrZrxNn.d.cts → index-BfYL6Qb1.d.cts} +3 -3
  16. package/dist/index.cjs +13 -0
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +7 -7
  19. package/dist/index.d.ts +7 -7
  20. package/dist/index.js +13 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/{payload-types-CJZuXcgF.d.cts → payload-types-3WNyC0gk.d.cts} +5 -0
  23. package/dist/{payload-types-CJZuXcgF.d.ts → payload-types-3WNyC0gk.d.ts} +5 -0
  24. package/dist/query.cjs +8 -0
  25. package/dist/query.cjs.map +1 -1
  26. package/dist/query.d.cts +5 -5
  27. package/dist/query.d.ts +5 -5
  28. package/dist/query.js +8 -0
  29. package/dist/query.js.map +1 -1
  30. package/dist/realtime.d.cts +2 -2
  31. package/dist/realtime.d.ts +2 -2
  32. package/dist/server.cjs +99 -1
  33. package/dist/server.cjs.map +1 -1
  34. package/dist/server.d.cts +7 -7
  35. package/dist/server.d.ts +7 -7
  36. package/dist/server.js +99 -1
  37. package/dist/server.js.map +1 -1
  38. package/dist/{types-D5p7-m1l.d.cts → types-CAicTn-o.d.cts} +2 -2
  39. package/dist/{types-C4WuJfw7.d.cts → types-CDJ2M-MJ.d.cts} +43 -4
  40. package/dist/{types-BC6rVmJa.d.ts → types-DpSyNTxy.d.ts} +2 -2
  41. package/dist/{types-BlOvjoTX.d.ts → types-mIROvhhP.d.ts} +43 -4
  42. package/dist/ui/form.d.cts +1 -1
  43. package/dist/ui/form.d.ts +1 -1
  44. package/dist/ui/video.d.cts +1 -1
  45. package/dist/ui/video.d.ts +1 -1
  46. package/dist/webhook.d.cts +4 -4
  47. package/dist/webhook.d.ts +4 -4
  48. package/package.json +3 -3
@@ -1,7 +1,7 @@
1
1
  import { R as RealtimeEvent } from './realtime-D7HtUpqt.cjs';
2
2
  export { a as RealtimeConnection, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
3
- import { P as PublicCollection } from './const-BAG0MH0u.cjs';
4
- import './payload-types-CJZuXcgF.cjs';
3
+ import { P as PublicCollection } from './const-y0eipvnQ.cjs';
4
+ import './payload-types-3WNyC0gk.cjs';
5
5
 
6
6
  interface UseRealtimeQueryOptions {
7
7
  /** Filter events to specific collections. Empty/undefined = all collections. */
@@ -1,7 +1,7 @@
1
1
  import { R as RealtimeEvent } from './realtime-D7HtUpqt.js';
2
2
  export { a as RealtimeConnection, b as RealtimeListener } from './realtime-D7HtUpqt.js';
3
- import { P as PublicCollection } from './const-CaPq2AE4.js';
4
- import './payload-types-CJZuXcgF.js';
3
+ import { P as PublicCollection } from './const-GYVwlXLr.js';
4
+ import './payload-types-3WNyC0gk.js';
5
5
 
6
6
  interface UseRealtimeQueryOptions {
7
7
  /** Filter events to specific collections. Empty/undefined = all collections. */
package/dist/server.cjs CHANGED
@@ -410,6 +410,11 @@ function redactSensitiveHeaders(headers) {
410
410
  redacted["x-preview-token"]
411
411
  );
412
412
  }
413
+ if (redacted["x-custom-payment-signature"]) {
414
+ redacted["x-custom-payment-signature"] = redactSensitiveHeader(
415
+ redacted["x-custom-payment-signature"]
416
+ );
417
+ }
413
418
  return redacted;
414
419
  }
415
420
  function getErrorSuggestion(status) {
@@ -1678,6 +1683,14 @@ var COMMERCE_ENDPOINTS = {
1678
1683
  create: endpoint("POST", "/api/payment-sessions/create"),
1679
1684
  retrieve: endpoint("POST", "/api/payment-sessions/retrieve"),
1680
1685
  cancel: endpoint("POST", "/api/payment-sessions/cancel"),
1686
+ custom: {
1687
+ create: sharedEndpoint(
1688
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.create
1689
+ ),
1690
+ confirm: sharedEndpoint(
1691
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.confirm
1692
+ )
1693
+ },
1681
1694
  server: {
1682
1695
  create: endpoint("POST", "/api/payment-sessions/server/create"),
1683
1696
  retrieve: endpoint("POST", "/api/payment-sessions/server/retrieve"),
@@ -3071,6 +3084,43 @@ function validateMoney(value, resource, path) {
3071
3084
  safeMinor(money.amountMinor, resource, `${path}.amountMinor`);
3072
3085
  currency(money.currency, resource, `${path}.currency`);
3073
3086
  }
3087
+ function validateCustomPaymentSession(value) {
3088
+ const resource = "custom PaymentSession";
3089
+ const session = record(value, resource, "$");
3090
+ exact(
3091
+ session,
3092
+ ["id", "provider", "providerSessionId", "money"],
3093
+ [],
3094
+ resource,
3095
+ "$"
3096
+ );
3097
+ string(session.id, resource, "$.id");
3098
+ const provider = string(session.provider, resource, "$.provider");
3099
+ if (!/^[a-z0-9][a-z0-9_-]{0,63}$/i.test(provider)) {
3100
+ fail(resource, "$.provider", "provider slug");
3101
+ }
3102
+ string(session.providerSessionId, resource, "$.providerSessionId");
3103
+ validateMoney(session.money, resource, "$.money");
3104
+ return value;
3105
+ }
3106
+ function validateConfirmCustomPaymentSessionResponse(value) {
3107
+ const resource = "custom PaymentSession confirmation";
3108
+ const result = record(value, resource, "$");
3109
+ exact(
3110
+ result,
3111
+ ["orderId", "transactionId", "status"],
3112
+ ["alreadyConfirmed"],
3113
+ resource,
3114
+ "$"
3115
+ );
3116
+ string(result.orderId, resource, "$.orderId");
3117
+ string(result.transactionId, resource, "$.transactionId");
3118
+ if (result.status !== "paid") fail(resource, "$.status", "paid");
3119
+ if (result.alreadyConfirmed !== void 0) {
3120
+ boolean(result.alreadyConfirmed, resource, "$.alreadyConfirmed");
3121
+ }
3122
+ return value;
3123
+ }
3074
3124
  function validateCaptureEvidence(value, resource, path) {
3075
3125
  const evidence = record(value, resource, path);
3076
3126
  exact(evidence, ["amountMinor", "currency", "observedAt"], [], resource, path);
@@ -4950,6 +5000,49 @@ var PaymentSessionApi = class extends CustomerScopedApi {
4950
5000
  );
4951
5001
  }
4952
5002
  };
5003
+ var CustomPaymentSessionApi = class extends BaseApi {
5004
+ constructor(options) {
5005
+ super("CustomPaymentSessionApi", options);
5006
+ }
5007
+ async create(params) {
5008
+ assertCommerceIdempotencyKey(params.idempotencyKey);
5009
+ const body = {
5010
+ provider: params.provider,
5011
+ checkoutToken: params.checkoutToken
5012
+ };
5013
+ const result = await this.requestEndpoint(
5014
+ COMMERCE_ENDPOINTS.paymentSessions.custom.create,
5015
+ body,
5016
+ { headers: { "X-Idempotency-Key": params.idempotencyKey } }
5017
+ );
5018
+ return validateCustomPaymentSession(result);
5019
+ }
5020
+ async confirm(params, options = {}) {
5021
+ const body = {
5022
+ provider: params.provider,
5023
+ providerSessionId: params.providerSessionId,
5024
+ providerPaymentId: params.providerPaymentId,
5025
+ providerEventId: params.providerEventId,
5026
+ amount: params.amount,
5027
+ currency: params.currency,
5028
+ occurredAt: params.occurredAt
5029
+ };
5030
+ const proof = await options.createProof?.(JSON.stringify(body));
5031
+ const result = await this.requestEndpoint(
5032
+ COMMERCE_ENDPOINTS.paymentSessions.custom.confirm,
5033
+ body,
5034
+ proof ? {
5035
+ headers: {
5036
+ "X-Custom-Payment-Timestamp": proof.timestamp,
5037
+ "X-Custom-Payment-Signature": proof.signature
5038
+ }
5039
+ } : void 0
5040
+ );
5041
+ return validateConfirmCustomPaymentSessionResponse(
5042
+ result
5043
+ );
5044
+ }
5045
+ };
4953
5046
 
4954
5047
  // src/core/preview/server-preview-client.ts
4955
5048
  var ServerPreviewClient = class extends RawBaseApi {
@@ -5027,6 +5120,7 @@ var ServerCommerceClient = class {
5027
5120
  const orderApi = new OrderApi(serverOptions);
5028
5121
  const checkoutApi = new CheckoutApi(serverOptions);
5029
5122
  const paymentSessionApi = new PaymentSessionApi(serverOptions);
5123
+ const customPaymentSessionApi = new CustomPaymentSessionApi(serverOptions);
5030
5124
  this.product = {
5031
5125
  stockCheck: productApi.stockCheck.bind(productApi),
5032
5126
  listingGroups: (params) => productApi.listingGroups(this.withMarket(params)),
@@ -5072,7 +5166,11 @@ var ServerCommerceClient = class {
5072
5166
  create: paymentSessionApi.create.bind(paymentSessionApi),
5073
5167
  retrieve: (params) => paymentSessionApi.retrieve(params),
5074
5168
  cancel: (params) => paymentSessionApi.cancel(params),
5075
- confirm: paymentSessionApi.confirm.bind(paymentSessionApi)
5169
+ confirm: paymentSessionApi.confirm.bind(paymentSessionApi),
5170
+ custom: {
5171
+ create: customPaymentSessionApi.create.bind(customPaymentSessionApi),
5172
+ confirm: customPaymentSessionApi.confirm.bind(customPaymentSessionApi)
5173
+ }
5076
5174
  };
5077
5175
  this.discounts = {
5078
5176
  validate: discountApi.validate.bind(discountApi)