@cimplify/sdk 0.102.0 → 0.103.0
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/advanced.d.mts +3 -3
- package/dist/advanced.d.ts +3 -3
- package/dist/advanced.js +23 -22
- package/dist/advanced.mjs +4 -3
- package/dist/{chunk-DCMXUKDQ.mjs → chunk-C2JSNJUC.mjs} +404 -95
- package/dist/chunk-CNN7Z2IP.js +125 -0
- package/dist/{chunk-DKLHCZ5M.mjs → chunk-GERXZQSX.mjs} +487 -11
- package/dist/chunk-GOHSXBKW.mjs +105 -0
- package/dist/{chunk-4KNFBPV2.mjs → chunk-H7ACMHM3.mjs} +32 -14
- package/dist/{chunk-Z3K2D3TE.mjs → chunk-J6PNHDHL.mjs} +453 -483
- package/dist/{chunk-NIOUSKQQ.js → chunk-JG5CQNCB.js} +5 -0
- package/dist/{chunk-YER7DIOM.js → chunk-JSWJ4XDE.js} +471 -519
- package/dist/{chunk-DLW3RWRK.mjs → chunk-M4URVKHE.mjs} +46 -12
- package/dist/{chunk-WMEC5JWN.js → chunk-NNG6IFFX.js} +50 -13
- package/dist/{chunk-LOWSMGRT.js → chunk-QOWPGS7Z.js} +34 -16
- package/dist/{chunk-YDA46OZ6.js → chunk-R6OLQ33I.js} +560 -80
- package/dist/{chunk-EAZGA7LD.js → chunk-VIL6IQCG.js} +406 -97
- package/dist/{chunk-O3YUHLZL.mjs → chunk-VNPEYLB2.mjs} +5 -0
- package/dist/{client-B40KFazg.d.ts → client-BfpNjJ_a.d.mts} +90 -299
- package/dist/{client-BizGfqB7.d.mts → client-DHBwvh7U.d.ts} +90 -299
- package/dist/{client-BdErclfU.d.mts → client-DpqRobY9.d.mts} +2 -2
- package/dist/{client-nsiMwuC1.d.ts → client-Dqg2mc-7.d.ts} +2 -2
- package/dist/{index-DpmnI__D.d.mts → index-C8uDqLwJ.d.ts} +14 -4
- package/dist/{index-nEyXWIyR.d.ts → index-e2y6AK70.d.mts} +14 -4
- package/dist/index.d.mts +81 -8
- package/dist/index.d.ts +81 -8
- package/dist/index.js +202 -169
- package/dist/index.mjs +6 -5
- package/dist/link-cuNVYc2s.d.mts +297 -0
- package/dist/link-cuNVYc2s.d.ts +297 -0
- package/dist/mock/cli.mjs +410 -94
- package/dist/mock/library.js +410 -94
- package/dist/mock/library.mjs +410 -94
- package/dist/mock/msw.js +410 -94
- package/dist/mock/msw.mjs +410 -94
- package/dist/{product-Byf0unSy.d.mts → payment-H5LoIvXU.d.mts} +189 -7
- package/dist/{product-Byf0unSy.d.ts → payment-H5LoIvXU.d.ts} +189 -7
- package/dist/{price-CS4E5zLS.d.mts → price-BvePgDXe.d.mts} +1 -1
- package/dist/{price-BstChV9a.d.ts → price-C2RqscMY.d.ts} +1 -1
- package/dist/react.d.mts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +141 -140
- package/dist/react.mjs +5 -4
- package/dist/{server-DqbZh8Bk.d.mts → server-C7FyLdrz.d.mts} +11 -9
- package/dist/{server-Cj40R2ZD.d.ts → server-DoXIpSd7.d.ts} +11 -9
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +11 -10
- package/dist/server.mjs +5 -4
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +4 -3
- package/dist/testing/msw.mjs +3 -2
- package/dist/testing/suite.d.mts +6 -6
- package/dist/testing/suite.d.ts +6 -6
- package/dist/testing/suite.js +26 -25
- package/dist/testing/suite.mjs +7 -6
- package/dist/testing.d.mts +154 -55
- package/dist/testing.d.ts +154 -55
- package/dist/testing.js +83 -82
- package/dist/testing.mjs +8 -7
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +37 -29
- package/dist/utils.mjs +2 -2
- package/package.json +7 -1
- package/dist/payment-l0rkieEQ.d.mts +0 -113
- package/dist/payment-vzNnIi1n.d.ts +0 -113
package/dist/react.mjs
CHANGED
|
@@ -3,10 +3,11 @@ import { splitGenUIContent, messagePreview } from './chunk-U4MW6PYU.mjs';
|
|
|
3
3
|
export { messagePreview, splitGenUIContent } from './chunk-U4MW6PYU.mjs';
|
|
4
4
|
import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, isMultiDayService, serviceBillingMultiplier, PRODUCT_TYPE, BOUNDARY_KIND, resolveGallery, chatMessageCards, RENDER_HINT, displaysGrossPrices, DEFAULT_CDN_BASE_URL } from './chunk-3V4DVXV3.mjs';
|
|
5
5
|
export { getVariantDisplayName } from './chunk-3V4DVXV3.mjs';
|
|
6
|
-
import { SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-
|
|
7
|
-
import { generateIdempotencyKey, ELEMENT_TYPES, EVENT_TYPES, startSignIn } from './chunk-
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
6
|
+
import { SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-GERXZQSX.mjs';
|
|
7
|
+
import { generateIdempotencyKey, ELEMENT_TYPES, EVENT_TYPES, startSignIn } from './chunk-J6PNHDHL.mjs';
|
|
8
|
+
import './chunk-GOHSXBKW.mjs';
|
|
9
|
+
import { parsePrice, formatMoney, formatPrice, getVariantUnitPrice, getProductCurrency, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-M4URVKHE.mjs';
|
|
10
|
+
import { isSupportedCurrency, currencyCode, CimplifyError } from './chunk-VNPEYLB2.mjs';
|
|
10
11
|
import './chunk-3G6RQLXK.mjs';
|
|
11
12
|
import React14, { createContext, lazy, memo, Suspense, useMemo, useContext, useRef, useCallback, useState, useEffect, useId, useSyncExternalStore } from 'react';
|
|
12
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import {
|
|
2
|
+
import { bk as ProductInputField, bF as SubmitAuthorizationInput } from './payment-H5LoIvXU.mjs';
|
|
3
3
|
|
|
4
4
|
interface Clock {
|
|
5
5
|
now(): Date;
|
|
@@ -289,6 +289,7 @@ interface MockOrder {
|
|
|
289
289
|
items: unknown[];
|
|
290
290
|
applied_discount_ids: string[];
|
|
291
291
|
applied_discount_codes: string[];
|
|
292
|
+
payment_id?: string;
|
|
292
293
|
payment_reference?: string;
|
|
293
294
|
pickup_time?: string;
|
|
294
295
|
metadata?: Record<string, unknown>;
|
|
@@ -731,14 +732,7 @@ interface CartService {
|
|
|
731
732
|
|
|
732
733
|
interface CheckoutService {
|
|
733
734
|
process(session: Session, body: CheckoutBody): CheckoutResult;
|
|
734
|
-
authorize(body:
|
|
735
|
-
order_id: string;
|
|
736
|
-
otp?: string;
|
|
737
|
-
pin?: string;
|
|
738
|
-
}): {
|
|
739
|
-
status: string;
|
|
740
|
-
order_id: string;
|
|
741
|
-
};
|
|
735
|
+
authorize(body: SubmitAuthorizationInput): CheckoutResult;
|
|
742
736
|
}
|
|
743
737
|
interface CheckoutBody {
|
|
744
738
|
cart_id: string;
|
|
@@ -765,12 +759,18 @@ interface CheckoutBody {
|
|
|
765
759
|
interface CheckoutResult {
|
|
766
760
|
order_id: string;
|
|
767
761
|
order_number: string;
|
|
762
|
+
payment_id?: string;
|
|
768
763
|
payment_status: string;
|
|
769
764
|
payment_reference?: string;
|
|
770
765
|
requires_authorization: boolean;
|
|
771
766
|
authorization_type?: "otp" | "pin" | "phone" | "birthday" | "address";
|
|
772
767
|
next_action: {
|
|
773
768
|
type: "none";
|
|
769
|
+
} | {
|
|
770
|
+
type: "card_popup";
|
|
771
|
+
provider: string;
|
|
772
|
+
client_secret: string;
|
|
773
|
+
public_key: string;
|
|
774
774
|
} | {
|
|
775
775
|
type: "redirect";
|
|
776
776
|
authorization_url: string;
|
|
@@ -778,6 +778,8 @@ interface CheckoutResult {
|
|
|
778
778
|
type: "authorization";
|
|
779
779
|
authorization_type: string;
|
|
780
780
|
display_text?: string;
|
|
781
|
+
} | {
|
|
782
|
+
type: "poll";
|
|
781
783
|
};
|
|
782
784
|
provider?: string;
|
|
783
785
|
authorization_url?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import {
|
|
2
|
+
import { bk as ProductInputField, bF as SubmitAuthorizationInput } from './payment-H5LoIvXU.js';
|
|
3
3
|
|
|
4
4
|
interface Clock {
|
|
5
5
|
now(): Date;
|
|
@@ -289,6 +289,7 @@ interface MockOrder {
|
|
|
289
289
|
items: unknown[];
|
|
290
290
|
applied_discount_ids: string[];
|
|
291
291
|
applied_discount_codes: string[];
|
|
292
|
+
payment_id?: string;
|
|
292
293
|
payment_reference?: string;
|
|
293
294
|
pickup_time?: string;
|
|
294
295
|
metadata?: Record<string, unknown>;
|
|
@@ -731,14 +732,7 @@ interface CartService {
|
|
|
731
732
|
|
|
732
733
|
interface CheckoutService {
|
|
733
734
|
process(session: Session, body: CheckoutBody): CheckoutResult;
|
|
734
|
-
authorize(body:
|
|
735
|
-
order_id: string;
|
|
736
|
-
otp?: string;
|
|
737
|
-
pin?: string;
|
|
738
|
-
}): {
|
|
739
|
-
status: string;
|
|
740
|
-
order_id: string;
|
|
741
|
-
};
|
|
735
|
+
authorize(body: SubmitAuthorizationInput): CheckoutResult;
|
|
742
736
|
}
|
|
743
737
|
interface CheckoutBody {
|
|
744
738
|
cart_id: string;
|
|
@@ -765,12 +759,18 @@ interface CheckoutBody {
|
|
|
765
759
|
interface CheckoutResult {
|
|
766
760
|
order_id: string;
|
|
767
761
|
order_number: string;
|
|
762
|
+
payment_id?: string;
|
|
768
763
|
payment_status: string;
|
|
769
764
|
payment_reference?: string;
|
|
770
765
|
requires_authorization: boolean;
|
|
771
766
|
authorization_type?: "otp" | "pin" | "phone" | "birthday" | "address";
|
|
772
767
|
next_action: {
|
|
773
768
|
type: "none";
|
|
769
|
+
} | {
|
|
770
|
+
type: "card_popup";
|
|
771
|
+
provider: string;
|
|
772
|
+
client_secret: string;
|
|
773
|
+
public_key: string;
|
|
774
774
|
} | {
|
|
775
775
|
type: "redirect";
|
|
776
776
|
authorization_url: string;
|
|
@@ -778,6 +778,8 @@ interface CheckoutResult {
|
|
|
778
778
|
type: "authorization";
|
|
779
779
|
authorization_type: string;
|
|
780
780
|
display_text?: string;
|
|
781
|
+
} | {
|
|
782
|
+
type: "poll";
|
|
781
783
|
};
|
|
782
784
|
provider?: string;
|
|
783
785
|
authorization_url?: string;
|
package/dist/server.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
import { ac as CimplifyClient } from './client-BfpNjJ_a.mjs';
|
|
2
|
+
export { C as CacheOptions, cb as ReadRequestOptions, cx as Result } from './client-BfpNjJ_a.mjs';
|
|
3
|
+
export { U as Category, X as CimplifyError, Y as Collection, be as Product, bs as ProductWithDetails } from './payment-H5LoIvXU.mjs';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './
|
|
5
|
+
import './link-cuNVYc2s.mjs';
|
|
6
6
|
|
|
7
7
|
interface ServerClientOptions {
|
|
8
8
|
/**
|
package/dist/server.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
import { ac as CimplifyClient } from './client-DHBwvh7U.js';
|
|
2
|
+
export { C as CacheOptions, cb as ReadRequestOptions, cx as Result } from './client-DHBwvh7U.js';
|
|
3
|
+
export { U as Category, X as CimplifyError, Y as Collection, be as Product, bs as ProductWithDetails } from './payment-H5LoIvXU.js';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './
|
|
5
|
+
import './link-cuNVYc2s.js';
|
|
6
6
|
|
|
7
7
|
interface ServerClientOptions {
|
|
8
8
|
/**
|
package/dist/server.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('./chunk-
|
|
6
|
-
|
|
3
|
+
var chunkR6OLQ33I_js = require('./chunk-R6OLQ33I.js');
|
|
4
|
+
var chunkJSWJ4XDE_js = require('./chunk-JSWJ4XDE.js');
|
|
5
|
+
require('./chunk-CNN7Z2IP.js');
|
|
6
|
+
require('./chunk-NNG6IFFX.js');
|
|
7
|
+
var chunkJG5CQNCB_js = require('./chunk-JG5CQNCB.js');
|
|
7
8
|
require('./chunk-OWW5GUSB.js');
|
|
8
9
|
var react = require('react');
|
|
9
10
|
var jose = require('jose');
|
|
@@ -26,7 +27,7 @@ function readEnv(...keys) {
|
|
|
26
27
|
var getServerClient = react.cache((opts = {}) => {
|
|
27
28
|
const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
|
|
28
29
|
const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
|
|
29
|
-
const client =
|
|
30
|
+
const client = chunkR6OLQ33I_js.createCimplifyClient({
|
|
30
31
|
baseUrl,
|
|
31
32
|
publicKey,
|
|
32
33
|
suppressPublicKeyWarning: true
|
|
@@ -250,7 +251,7 @@ var QUERY_AUTH_ERROR = "cimplify_auth_error";
|
|
|
250
251
|
var discoveryCache = /* @__PURE__ */ new Map();
|
|
251
252
|
var jwksCache = /* @__PURE__ */ new Map();
|
|
252
253
|
function issuerBase(cfg) {
|
|
253
|
-
return (cfg.issuer ?? cfg.authUrl ??
|
|
254
|
+
return (cfg.issuer ?? cfg.authUrl ?? chunkJSWJ4XDE_js.DEFAULT_ISSUER).replace(/\/$/, "");
|
|
254
255
|
}
|
|
255
256
|
function cookieName(cfg) {
|
|
256
257
|
return cfg.cookieName ?? SESSION_COOKIE;
|
|
@@ -465,12 +466,12 @@ async function handleOidcCallback(req, opts) {
|
|
|
465
466
|
}
|
|
466
467
|
function readPkceCookie(cookieHeader) {
|
|
467
468
|
if (!cookieHeader) return null;
|
|
468
|
-
const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${
|
|
469
|
+
const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkJSWJ4XDE_js.PKCE_COOKIE}=`));
|
|
469
470
|
if (!match) return null;
|
|
470
|
-
return
|
|
471
|
+
return chunkJSWJ4XDE_js.decodePkceState(match.slice(chunkJSWJ4XDE_js.PKCE_COOKIE.length + 1));
|
|
471
472
|
}
|
|
472
473
|
function buildPkceClearCookie() {
|
|
473
|
-
return `${
|
|
474
|
+
return `${chunkJSWJ4XDE_js.PKCE_COOKIE}=; Path=${chunkJSWJ4XDE_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
|
|
474
475
|
}
|
|
475
476
|
function safeReturnPath(returnTo, fallback) {
|
|
476
477
|
if (returnTo && returnTo.startsWith("/") && !returnTo.startsWith("//")) return returnTo;
|
|
@@ -642,7 +643,7 @@ async function handleTokenRefresh(req, cfg) {
|
|
|
642
643
|
|
|
643
644
|
Object.defineProperty(exports, "CimplifyError", {
|
|
644
645
|
enumerable: true,
|
|
645
|
-
get: function () { return
|
|
646
|
+
get: function () { return chunkJG5CQNCB_js.CimplifyError; }
|
|
646
647
|
});
|
|
647
648
|
exports.CACHE_LIFE_DEFAULT = CACHE_LIFE_DEFAULT;
|
|
648
649
|
exports.CACHE_LIFE_PROBE = CACHE_LIFE_PROBE;
|
package/dist/server.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { createCimplifyClient } from './chunk-
|
|
2
|
-
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
|
|
1
|
+
import { createCimplifyClient } from './chunk-GERXZQSX.mjs';
|
|
2
|
+
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-J6PNHDHL.mjs';
|
|
3
|
+
import './chunk-GOHSXBKW.mjs';
|
|
4
|
+
import './chunk-M4URVKHE.mjs';
|
|
5
|
+
export { CimplifyError } from './chunk-VNPEYLB2.mjs';
|
|
5
6
|
import './chunk-3G6RQLXK.mjs';
|
|
6
7
|
import { cache } from 'react';
|
|
7
8
|
import { jwtVerify, createRemoteJWKSet } from 'jose';
|
package/dist/testing/msw.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AppHandle, C as CreateAppOptions } from '../server-
|
|
1
|
+
import { A as AppHandle, C as CreateAppOptions } from '../server-C7FyLdrz.mjs';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../
|
|
3
|
+
import '../payment-H5LoIvXU.mjs';
|
|
4
4
|
|
|
5
5
|
interface MswHandlerSetup {
|
|
6
6
|
handlers: unknown[];
|
package/dist/testing/msw.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AppHandle, C as CreateAppOptions } from '../server-
|
|
1
|
+
import { A as AppHandle, C as CreateAppOptions } from '../server-DoXIpSd7.js';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../
|
|
3
|
+
import '../payment-H5LoIvXU.js';
|
|
4
4
|
|
|
5
5
|
interface MswHandlerSetup {
|
|
6
6
|
handlers: unknown[];
|
package/dist/testing/msw.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVIL6IQCG_js = require('../chunk-VIL6IQCG.js');
|
|
4
4
|
require('../chunk-XREIZ56K.js');
|
|
5
|
-
require('../chunk-
|
|
5
|
+
require('../chunk-CNN7Z2IP.js');
|
|
6
|
+
require('../chunk-JG5CQNCB.js');
|
|
6
7
|
require('../chunk-OWW5GUSB.js');
|
|
7
8
|
|
|
8
9
|
// src/mock/msw.ts
|
|
9
10
|
async function createMswHandlers(options = {}) {
|
|
10
11
|
const baseUrl = options.baseUrl ?? "http://localhost:8787";
|
|
11
|
-
const handle =
|
|
12
|
+
const handle = chunkVIL6IQCG_js.createMockApp(options);
|
|
12
13
|
const msw = await import('msw').catch(() => {
|
|
13
14
|
throw new Error("msw is required to use @cimplify/sdk/mock/msw \u2014 install it as a peer dependency");
|
|
14
15
|
});
|
package/dist/testing/msw.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { createMockApp } from '../chunk-
|
|
1
|
+
import { createMockApp } from '../chunk-C2JSNJUC.mjs';
|
|
2
2
|
import '../chunk-U4MW6PYU.mjs';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-GOHSXBKW.mjs';
|
|
4
|
+
import '../chunk-VNPEYLB2.mjs';
|
|
4
5
|
import '../chunk-3G6RQLXK.mjs';
|
|
5
6
|
|
|
6
7
|
// src/mock/msw.ts
|
package/dist/testing/suite.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TestAPI } from 'vitest';
|
|
2
|
-
import { T as TestClientHandle } from '../client-
|
|
3
|
-
import { C as CreateAppOptions } from '../server-
|
|
4
|
-
export { S as SeedName } from '../server-
|
|
5
|
-
import '../client-
|
|
6
|
-
import '../
|
|
7
|
-
import '../
|
|
2
|
+
import { T as TestClientHandle } from '../client-DpqRobY9.mjs';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-C7FyLdrz.mjs';
|
|
4
|
+
export { S as SeedName } from '../server-C7FyLdrz.mjs';
|
|
5
|
+
import '../client-BfpNjJ_a.mjs';
|
|
6
|
+
import '../payment-H5LoIvXU.mjs';
|
|
7
|
+
import '../link-cuNVYc2s.mjs';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
package/dist/testing/suite.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TestAPI } from 'vitest';
|
|
2
|
-
import { T as TestClientHandle } from '../client-
|
|
3
|
-
import { C as CreateAppOptions } from '../server-
|
|
4
|
-
export { S as SeedName } from '../server-
|
|
5
|
-
import '../client-
|
|
6
|
-
import '../
|
|
7
|
-
import '../
|
|
2
|
+
import { T as TestClientHandle } from '../client-Dqg2mc-7.js';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-DoXIpSd7.js';
|
|
4
|
+
export { S as SeedName } from '../server-DoXIpSd7.js';
|
|
5
|
+
import '../client-DHBwvh7U.js';
|
|
6
|
+
import '../payment-H5LoIvXU.js';
|
|
7
|
+
import '../link-cuNVYc2s.js';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
package/dist/testing/suite.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkQOWPGS7Z_js = require('../chunk-QOWPGS7Z.js');
|
|
4
|
+
require('../chunk-VIL6IQCG.js');
|
|
5
5
|
require('../chunk-XREIZ56K.js');
|
|
6
|
-
require('../chunk-
|
|
7
|
-
require('../chunk-
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
6
|
+
require('../chunk-R6OLQ33I.js');
|
|
7
|
+
require('../chunk-JSWJ4XDE.js');
|
|
8
|
+
require('../chunk-CNN7Z2IP.js');
|
|
9
|
+
require('../chunk-NNG6IFFX.js');
|
|
10
|
+
require('../chunk-JG5CQNCB.js');
|
|
10
11
|
require('../chunk-OWW5GUSB.js');
|
|
11
12
|
var vitest = require('vitest');
|
|
12
13
|
|
|
@@ -21,11 +22,11 @@ var PLACEHOLDER_PHRASES = [
|
|
|
21
22
|
function createBrandSuite(opts) {
|
|
22
23
|
vitest.describe(opts.label ?? "brand schema", () => {
|
|
23
24
|
vitest.it("conforms to the Cimplify brand contract", () => {
|
|
24
|
-
vitest.expect(() =>
|
|
25
|
+
vitest.expect(() => chunkQOWPGS7Z_js.assertBrand(opts.brand)).not.toThrow();
|
|
25
26
|
});
|
|
26
27
|
vitest.it("declares a known mock seed", () => {
|
|
27
28
|
const b = opts.brand;
|
|
28
|
-
vitest.expect(
|
|
29
|
+
vitest.expect(chunkQOWPGS7Z_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
|
|
29
30
|
});
|
|
30
31
|
vitest.it("has no placeholder copy left in", () => {
|
|
31
32
|
const offenders = [];
|
|
@@ -57,7 +58,7 @@ ${msg}`);
|
|
|
57
58
|
vitest.expect(b.mock?.businessId).toMatch(/^bus_/);
|
|
58
59
|
});
|
|
59
60
|
vitest.it("zod-parses cleanly", () => {
|
|
60
|
-
const result =
|
|
61
|
+
const result = chunkQOWPGS7Z_js.BrandSchema.safeParse(opts.brand);
|
|
61
62
|
if (!result.success) {
|
|
62
63
|
throw new Error(
|
|
63
64
|
"Brand schema violations:\n" + result.error.issues.map((i) => ` \u2022 brand.${i.path.join(".")}: ${i.message}`).join("\n")
|
|
@@ -72,23 +73,23 @@ function createCartFlowSuite(opts = {}) {
|
|
|
72
73
|
vitest.describe(opts.label ?? "cart flow against in-process mock", () => {
|
|
73
74
|
let h;
|
|
74
75
|
vitest.beforeEach(() => {
|
|
75
|
-
h =
|
|
76
|
+
h = chunkQOWPGS7Z_js.createTestClient(opts);
|
|
76
77
|
});
|
|
77
78
|
vitest.afterEach(() => h.dispose());
|
|
78
79
|
vitest.it("starts with an empty cart matching the canonical shape", async () => {
|
|
79
80
|
const res = await h.client.cart.get();
|
|
80
81
|
vitest.expect(res.ok).toBe(true);
|
|
81
82
|
if (!res.ok) return;
|
|
82
|
-
vitest.expect(() =>
|
|
83
|
+
vitest.expect(() => chunkQOWPGS7Z_js.assertCart(res.value)).not.toThrow();
|
|
83
84
|
vitest.expect(res.value.items).toHaveLength(0);
|
|
84
85
|
});
|
|
85
86
|
vitest.it("adds the first product, persists it, and returns a shape-valid cart", async () => {
|
|
86
|
-
const { product, variantId } = await
|
|
87
|
+
const { product, variantId } = await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
|
|
87
88
|
vitest.expect(product.id).toBeTruthy();
|
|
88
89
|
const get = await h.client.cart.get();
|
|
89
90
|
vitest.expect(get.ok).toBe(true);
|
|
90
91
|
if (!get.ok) return;
|
|
91
|
-
vitest.expect(() =>
|
|
92
|
+
vitest.expect(() => chunkQOWPGS7Z_js.assertCart(get.value)).not.toThrow();
|
|
92
93
|
vitest.expect(get.value.items).toHaveLength(1);
|
|
93
94
|
vitest.expect(get.value.items[0]?.item_id).toBe(product.id);
|
|
94
95
|
if (variantId) {
|
|
@@ -99,8 +100,8 @@ function createCartFlowSuite(opts = {}) {
|
|
|
99
100
|
vitest.expect(parseFloat(String(get.value.pricing.subtotal))).toBeGreaterThan(0);
|
|
100
101
|
});
|
|
101
102
|
vitest.it("dedupes by line_key when adding the same product twice", async () => {
|
|
102
|
-
await
|
|
103
|
-
await
|
|
103
|
+
await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
|
|
104
|
+
await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
|
|
104
105
|
const res = await h.client.cart.get();
|
|
105
106
|
vitest.expect(res.ok).toBe(true);
|
|
106
107
|
if (!res.ok) return;
|
|
@@ -108,7 +109,7 @@ function createCartFlowSuite(opts = {}) {
|
|
|
108
109
|
vitest.expect(res.value.items[0]?.quantity).toBe(2);
|
|
109
110
|
});
|
|
110
111
|
vitest.it("removes items and zeroes the subtotal", async () => {
|
|
111
|
-
await
|
|
112
|
+
await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
|
|
112
113
|
const before = await h.client.cart.get();
|
|
113
114
|
if (!before.ok) throw before.error;
|
|
114
115
|
const itemId = before.value.items[0]?.id;
|
|
@@ -134,28 +135,28 @@ function createContractSuite(opts = {}) {
|
|
|
134
135
|
vitest.describe(opts.label ?? "SDK \u2194 mock contract", () => {
|
|
135
136
|
let h;
|
|
136
137
|
vitest.beforeEach(() => {
|
|
137
|
-
h =
|
|
138
|
+
h = chunkQOWPGS7Z_js.createTestClient(opts);
|
|
138
139
|
});
|
|
139
140
|
vitest.afterEach(() => h.dispose());
|
|
140
141
|
vitest.it("AddItemPayload schema accepts a minimal valid body", () => {
|
|
141
|
-
const result =
|
|
142
|
+
const result = chunkQOWPGS7Z_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
|
|
142
143
|
vitest.expect(result.success).toBe(true);
|
|
143
144
|
});
|
|
144
145
|
vitest.it("AddItemPayload schema rejects negative quantity", () => {
|
|
145
|
-
const result =
|
|
146
|
+
const result = chunkQOWPGS7Z_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
|
|
146
147
|
vitest.expect(result.success).toBe(false);
|
|
147
148
|
});
|
|
148
149
|
vitest.it("AddItemPayload schema rejects empty item_id", () => {
|
|
149
|
-
const result =
|
|
150
|
+
const result = chunkQOWPGS7Z_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
|
|
150
151
|
vitest.expect(result.success).toBe(false);
|
|
151
152
|
});
|
|
152
153
|
vitest.it("Cart line items returned by the mock match CartItemSchema", async () => {
|
|
153
|
-
const { product } = await
|
|
154
|
+
const { product } = await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
|
|
154
155
|
const get = await h.client.cart.get();
|
|
155
156
|
if (!get.ok) throw get.error;
|
|
156
157
|
vitest.expect(get.value.items.length).toBeGreaterThan(0);
|
|
157
158
|
for (const item of get.value.items) {
|
|
158
|
-
const result =
|
|
159
|
+
const result = chunkQOWPGS7Z_js.CartItemSchema.safeParse(item);
|
|
159
160
|
if (!result.success) {
|
|
160
161
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
161
162
|
throw new Error(`Cart item shape mismatch for ${product.name}:
|
|
@@ -165,19 +166,19 @@ ${issues}`);
|
|
|
165
166
|
}
|
|
166
167
|
});
|
|
167
168
|
vitest.it("CheckoutResponse from the mock includes bill_token", async () => {
|
|
168
|
-
await
|
|
169
|
+
await chunkQOWPGS7Z_js.fixtures.addFirstProduct(h.client);
|
|
169
170
|
const cartRes = await h.client.cart.get();
|
|
170
171
|
if (!cartRes.ok) throw cartRes.error;
|
|
171
172
|
const checkout = await h.client.checkout.process({
|
|
172
173
|
cart_id: cartRes.value.id,
|
|
173
|
-
customer:
|
|
174
|
+
customer: chunkQOWPGS7Z_js.fixtures.customer(),
|
|
174
175
|
order_type: "delivery",
|
|
175
176
|
payment_method: "mobile_money",
|
|
176
177
|
mobile_money_details: { phone_number: "+233244000000", provider: "mtn" }
|
|
177
178
|
});
|
|
178
179
|
vitest.expect(checkout.ok).toBe(true);
|
|
179
180
|
if (!checkout.ok) return;
|
|
180
|
-
const result =
|
|
181
|
+
const result = chunkQOWPGS7Z_js.CheckoutResponseSchema.safeParse(checkout.value);
|
|
181
182
|
if (!result.success) {
|
|
182
183
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
183
184
|
throw new Error(`CheckoutResponse shape mismatch:
|
package/dist/testing/suite.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-H7ACMHM3.mjs';
|
|
2
|
+
import '../chunk-C2JSNJUC.mjs';
|
|
3
3
|
import '../chunk-U4MW6PYU.mjs';
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-GERXZQSX.mjs';
|
|
5
|
+
import '../chunk-J6PNHDHL.mjs';
|
|
6
|
+
import '../chunk-GOHSXBKW.mjs';
|
|
7
|
+
import '../chunk-M4URVKHE.mjs';
|
|
8
|
+
import '../chunk-VNPEYLB2.mjs';
|
|
8
9
|
import '../chunk-3G6RQLXK.mjs';
|
|
9
10
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
10
11
|
|