@01.software/sdk 0.51.0 → 0.56.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 (51) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/README.md +54 -11
  3. package/dist/client.cjs +420 -53
  4. package/dist/client.cjs.map +1 -1
  5. package/dist/client.d.cts +6 -6
  6. package/dist/client.d.ts +6 -6
  7. package/dist/client.js +420 -53
  8. package/dist/client.js.map +1 -1
  9. package/dist/{collection-client-hYvVfHIm.d.ts → collection-client-Bmr53saa.d.ts} +4 -4
  10. package/dist/{collection-client-CWAeuzV4.d.cts → collection-client-DxuBDso_.d.cts} +4 -4
  11. package/dist/{const-D8LixhAJ.d.cts → const-BKUqg96Q.d.ts} +2 -2
  12. package/dist/{const-JD8obaKg.d.ts → const-Cv1DCsp6.d.cts} +2 -2
  13. package/dist/{index-Bu0kCc6o.d.cts → index-CGsT4AQ8.d.cts} +24 -7
  14. package/dist/{index-B0Hjh3Ey.d.ts → index-DFHLLqYu.d.ts} +24 -7
  15. package/dist/index.cjs +434 -55
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +11 -10
  18. package/dist/index.d.ts +11 -10
  19. package/dist/index.js +434 -55
  20. package/dist/index.js.map +1 -1
  21. package/dist/{payload-types-BOsckg8B.d.cts → payload-types-Bk-duc5k.d.cts} +295 -100
  22. package/dist/{payload-types-BOsckg8B.d.ts → payload-types-Bk-duc5k.d.ts} +295 -100
  23. package/dist/query.cjs +14 -1
  24. package/dist/query.cjs.map +1 -1
  25. package/dist/query.d.cts +5 -5
  26. package/dist/query.d.ts +5 -5
  27. package/dist/query.js +14 -1
  28. package/dist/query.js.map +1 -1
  29. package/dist/realtime.d.cts +2 -2
  30. package/dist/realtime.d.ts +2 -2
  31. package/dist/server.cjs +98 -13
  32. package/dist/server.cjs.map +1 -1
  33. package/dist/server.d.cts +9 -8
  34. package/dist/server.d.ts +9 -8
  35. package/dist/server.js +98 -13
  36. package/dist/server.js.map +1 -1
  37. package/dist/{types-Bj8j7VHU.d.ts → types-CEK8uTvU.d.ts} +212 -11
  38. package/dist/{types-B14sEt1z.d.cts → types-CNdpj2fI.d.cts} +2 -2
  39. package/dist/{types-5ZlcAFuU.d.ts → types-D4mjGFj4.d.ts} +2 -2
  40. package/dist/{types-CM5qiR2k.d.cts → types-Dhk5NX7Z.d.cts} +212 -11
  41. package/dist/ui/form.d.cts +1 -1
  42. package/dist/ui/form.d.ts +1 -1
  43. package/dist/ui/video.d.cts +1 -1
  44. package/dist/ui/video.d.ts +1 -1
  45. package/dist/webhook.cjs +13 -2
  46. package/dist/webhook.cjs.map +1 -1
  47. package/dist/webhook.d.cts +5 -5
  48. package/dist/webhook.d.ts +5 -5
  49. package/dist/webhook.js +13 -2
  50. package/dist/webhook.js.map +1 -1
  51. package/package.json +6 -5
@@ -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-D8LixhAJ.cjs';
4
- import './payload-types-BOsckg8B.cjs';
3
+ import { P as PublicCollection } from './const-Cv1DCsp6.cjs';
4
+ import './payload-types-Bk-duc5k.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-JD8obaKg.js';
4
- import './payload-types-BOsckg8B.js';
3
+ import { P as PublicCollection } from './const-BKUqg96Q.js';
4
+ import './payload-types-Bk-duc5k.js';
5
5
 
6
6
  interface UseRealtimeQueryOptions {
7
7
  /** Filter events to specific collections. Empty/undefined = all collections. */
package/dist/server.cjs CHANGED
@@ -22,6 +22,7 @@ var server_exports = {};
22
22
  __export(server_exports, {
23
23
  CollectionClient: () => CollectionClient,
24
24
  CommunityClient: () => CommunityClient,
25
+ CustomerGroupApi: () => CustomerGroupApi,
25
26
  EventsClient: () => EventsClient,
26
27
  ModerationApi: () => ModerationApi,
27
28
  ServerClient: () => ServerClient,
@@ -1679,6 +1680,11 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1679
1680
  detail: strictCommerceOperation("checkouts", "post", "/detail"),
1680
1681
  query: strictCommerceOperation("checkouts", "post", "/query")
1681
1682
  },
1683
+ draftOrders: {
1684
+ calculate: operation("draft-orders", "post", "/:id/calculate"),
1685
+ complete: operation("draft-orders", "post", "/:id/complete"),
1686
+ finalize: operation("draft-orders", "post", "/:id/finalize")
1687
+ },
1682
1688
  transactions: {
1683
1689
  update: operation("transactions", "post", "/update")
1684
1690
  },
@@ -1779,7 +1785,15 @@ var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
1779
1785
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
1780
1786
  subscribe: operation(null, "post", "/memberships/subscribe"),
1781
1787
  cancel: operation(null, "post", "/memberships/:id/cancel"),
1782
- me: operation(null, "get", "/memberships/me")
1788
+ me: operation(null, "get", "/memberships/me"),
1789
+ chargeResult: operation(null, "post", "/memberships/:id/charge-result"),
1790
+ refundResult: operation(null, "post", "/memberships/:id/refund-result"),
1791
+ revoke: operation(null, "post", "/memberships/:id/revoke")
1792
+ };
1793
+ var CUSTOMER_GROUP_ENDPOINT_OPERATIONS = {
1794
+ members: operation("customer-groups", "get", "/:id/members"),
1795
+ grant: operation("customer-groups", "post", "/:id/members/grant"),
1796
+ revoke: operation("customer-groups", "post", "/:id/members/revoke")
1783
1797
  };
1784
1798
  var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
1785
1799
  show: operation("tenants", "get", "/embedded-admin-app"),
@@ -2501,7 +2515,10 @@ var MAX_COMMERCE_CAPABILITY_LENGTH = 512;
2501
2515
  var MAX_CART_DISCOUNT_CODE_LENGTH = 128;
2502
2516
  var CHECKOUT_STATUSES = ["open", "placed", "abandoned"];
2503
2517
  var ABANDONED_REASONS = ["expired", "customer", "operator"];
2504
- var PAYMENT_PROVIDERS = ["toss", "portone"];
2518
+ function managedPaymentProviders(providers) {
2519
+ return providers;
2520
+ }
2521
+ var PAYMENT_PROVIDERS = managedPaymentProviders(["toss", "portone"]);
2505
2522
  var PAYMENT_PROVIDER_STATUSES = [
2506
2523
  "requires_payment_method",
2507
2524
  "requires_action",
@@ -2561,6 +2578,26 @@ function invalidCanonicalResponse(resource, details) {
2561
2578
  function fail(resource, path, expected) {
2562
2579
  invalidCanonicalResponse(resource, { path, expected });
2563
2580
  }
2581
+ function providerMismatch(resource, expected, actual, operation2) {
2582
+ if (operation2 === "cancel") {
2583
+ const method = {
2584
+ toss: "cancel()",
2585
+ portone: "cancelPortOne()"
2586
+ }[actual];
2587
+ throw createApiError(
2588
+ `Canonical ${resource} response provider mismatch: expected ${expected}, received ${actual}.`,
2589
+ 502,
2590
+ { resource, path: "$.provider", expected, actual },
2591
+ `The server applied the cancellation to a ${actual} PaymentSession, but this SDK method expects ${expected}.`,
2592
+ `Re-invoke ${method} with the same idempotencyKey; do not create a new key.`
2593
+ );
2594
+ }
2595
+ invalidCanonicalResponse(resource, {
2596
+ path: "$.provider",
2597
+ expected,
2598
+ actual
2599
+ });
2600
+ }
2564
2601
  function record(value, resource, path) {
2565
2602
  if (!value || typeof value !== "object" || Array.isArray(value)) {
2566
2603
  fail(resource, path, "object");
@@ -3837,7 +3874,7 @@ function validateNextAction(value, provider, resource, path) {
3837
3874
  if (action.customerEmail !== void 0)
3838
3875
  validateCustomer({ email: action.customerEmail }, resource, path);
3839
3876
  }
3840
- function validatePublicPaymentSession(value, expectedProvider) {
3877
+ function validatePublicPaymentSession(value, expectedProvider, operation2) {
3841
3878
  const resource = "PaymentSession";
3842
3879
  const session = record(value, resource, "$");
3843
3880
  const provider = enumValue(
@@ -3846,9 +3883,6 @@ function validatePublicPaymentSession(value, expectedProvider) {
3846
3883
  resource,
3847
3884
  "$.provider"
3848
3885
  );
3849
- if (expectedProvider !== void 0 && provider !== expectedProvider) {
3850
- fail(resource, "$.provider", expectedProvider);
3851
- }
3852
3886
  const status = enumValue(
3853
3887
  session.providerStatus,
3854
3888
  PAYMENT_PROVIDER_STATUSES,
@@ -4052,6 +4086,16 @@ function validatePublicPaymentSession(value, expectedProvider) {
4052
4086
  "$.cancellationReason"
4053
4087
  );
4054
4088
  }
4089
+ if (expectedProvider !== void 0 && provider !== expectedProvider) {
4090
+ if (operation2 === "cancel" && status !== "canceling" && status !== "canceled") {
4091
+ fail(
4092
+ resource,
4093
+ "$.providerStatus",
4094
+ "canceling or canceled after a successful cancellation"
4095
+ );
4096
+ }
4097
+ providerMismatch(resource, expectedProvider, provider, operation2);
4098
+ }
4055
4099
  return value;
4056
4100
  }
4057
4101
 
@@ -5603,8 +5647,12 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5603
5647
  ...Object.keys(headers).length > 0 && { headers }
5604
5648
  });
5605
5649
  }
5606
- async paymentSession(result, expectedProvider) {
5607
- return validatePublicPaymentSession(await result, expectedProvider);
5650
+ async paymentSession(result, expectedProvider, operation2) {
5651
+ return validatePublicPaymentSession(
5652
+ await result,
5653
+ expectedProvider,
5654
+ operation2
5655
+ );
5608
5656
  }
5609
5657
  create(params) {
5610
5658
  const { idempotencyKey, ...body } = params;
@@ -5651,7 +5699,8 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5651
5699
  const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
5652
5700
  return this.paymentSession(
5653
5701
  this.post(endpoint, body, idempotencyKey),
5654
- "toss"
5702
+ "toss",
5703
+ "cancel"
5655
5704
  );
5656
5705
  }
5657
5706
  cancelPortOne(params) {
@@ -5660,7 +5709,8 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5660
5709
  const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
5661
5710
  return this.paymentSession(
5662
5711
  this.post(endpoint, body, idempotencyKey),
5663
- "portone"
5712
+ "portone",
5713
+ "cancel"
5664
5714
  );
5665
5715
  }
5666
5716
  confirm(params) {
@@ -6121,9 +6171,10 @@ var MembershipApi = class extends BaseApi {
6121
6171
  super("MembershipApi", options);
6122
6172
  }
6123
6173
  /**
6124
- * Record a delegated first-charge and activate a membership.
6125
- * The storefront collected the payment; this endpoint deduplicates by
6126
- * `subscribeIntentKey` and records the already-paid charge.
6174
+ * Prepare a delegated first charge for a paid Membership, or immediately
6175
+ * start a trial. For a paid response, charge through the tenant PSP with
6176
+ * `firstCharge.idempotencyKey`, then post the existing signed charge result
6177
+ * to activate the membership.
6127
6178
  *
6128
6179
  * `subscribeIntentKey` is used as the HTTP idempotency key so the call is
6129
6180
  * safely retryable.
@@ -6152,6 +6203,39 @@ var MembershipApi = class extends BaseApi {
6152
6203
  }
6153
6204
  };
6154
6205
 
6206
+ // src/core/api/customer-group-api.ts
6207
+ var CustomerGroupApi = class extends BaseApi {
6208
+ constructor(options) {
6209
+ super("CustomerGroupApi", options);
6210
+ }
6211
+ listMembers(params) {
6212
+ const query = new URLSearchParams();
6213
+ if (params.page !== void 0) query.set("page", String(params.page));
6214
+ if (params.limit !== void 0) query.set("limit", String(params.limit));
6215
+ return this.requestEndpoint(
6216
+ CUSTOMER_GROUP_ENDPOINT_OPERATIONS.members,
6217
+ void 0,
6218
+ { pathParams: { id: params.groupId }, query }
6219
+ );
6220
+ }
6221
+ grantMember(params) {
6222
+ const { groupId, ...body } = params;
6223
+ return this.requestEndpoint(
6224
+ CUSTOMER_GROUP_ENDPOINT_OPERATIONS.grant,
6225
+ body,
6226
+ { pathParams: { id: groupId } }
6227
+ );
6228
+ }
6229
+ revokeMember(params) {
6230
+ const { groupId, ...body } = params;
6231
+ return this.requestEndpoint(
6232
+ CUSTOMER_GROUP_ENDPOINT_OPERATIONS.revoke,
6233
+ body,
6234
+ { pathParams: { id: groupId } }
6235
+ );
6236
+ }
6237
+ };
6238
+
6155
6239
  // src/core/client/client.server.ts
6156
6240
  var ServerClient = class _ServerClient {
6157
6241
  constructor(options) {
@@ -6191,6 +6275,7 @@ var ServerClient = class _ServerClient {
6191
6275
  subscribe: membershipApi.subscribe.bind(membershipApi),
6192
6276
  cancel: membershipApi.cancel.bind(membershipApi)
6193
6277
  };
6278
+ this.customerGroups = new CustomerGroupApi(serverOptions);
6194
6279
  const tenantIntrospectionApi = new TenantIntrospectionApi(serverOptions);
6195
6280
  this.tenant = {
6196
6281
  context: tenantIntrospectionApi.context.bind(tenantIntrospectionApi),