@cimplify/sdk 0.104.1 → 0.106.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 +22 -22
- package/dist/advanced.mjs +3 -3
- package/dist/{catalogue-BlQ85Uma.d.mts → catalogue-CB44dO-g.d.mts} +4 -1
- package/dist/{catalogue-C8TqOj9K.d.ts → catalogue-lUdp-1hu.d.ts} +4 -1
- package/dist/{checkout-BqK9XUz5.d.mts → checkout-XoV4HNg2.d.mts} +311 -31
- package/dist/{checkout-BqK9XUz5.d.ts → checkout-XoV4HNg2.d.ts} +311 -31
- package/dist/{chunk-L5SNEU2O.mjs → chunk-3BTMAWL7.mjs} +47 -15
- package/dist/{chunk-BWEIMKLF.js → chunk-7SEOB5UW.js} +108 -76
- package/dist/{chunk-SFUJMS5E.js → chunk-AVXA4F6G.js} +33 -1
- package/dist/{chunk-UFOWPN3D.mjs → chunk-DPVDLMLI.mjs} +8 -13
- package/dist/{chunk-DQEXY542.js → chunk-H2WXUTMT.js} +211 -189
- package/dist/{chunk-6G3ANKQA.mjs → chunk-L4XKIMUO.mjs} +8 -1
- package/dist/{chunk-HYFA67A7.js → chunk-NJK3THWT.js} +67 -60
- package/dist/{chunk-RBNBSQI7.mjs → chunk-NJYR6GGM.mjs} +29 -2
- package/dist/{chunk-U54CWUUT.mjs → chunk-NYDVVNZI.mjs} +1 -1
- package/dist/{chunk-V4457OKB.mjs → chunk-RQT5BZ2Y.mjs} +36 -14
- package/dist/{chunk-XAUSDMMZ.js → chunk-UYFTOIFW.js} +6 -6
- package/dist/{chunk-WXREIBFW.js → chunk-YARZTZTB.js} +141 -146
- package/dist/{client-DhXeiUrf.d.ts → client-BQ_8FtA4.d.ts} +12 -2
- package/dist/{client-mXiUrV4X.d.mts → client-BWe1KWMf.d.mts} +12 -2
- package/dist/{index-DPWI5XcU.d.ts → index-C0k9om1S.d.ts} +2 -2
- package/dist/{index-B0AdZvrM.d.mts → index-DRMBo26v.d.mts} +2 -2
- package/dist/{index-CK8Nk5uQ.d.ts → index-DweR60Cv.d.ts} +2 -2
- package/dist/{index-DVfUh-ci.d.mts → index-aIQzSiP_.d.mts} +2 -2
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +166 -146
- package/dist/index.mjs +5 -5
- package/dist/mock/cli.mjs +9 -0
- package/dist/mock/library.js +9 -0
- package/dist/mock/library.mjs +9 -0
- package/dist/mock/msw.js +9 -0
- package/dist/mock/msw.mjs +9 -0
- package/dist/{price-BUDv1rI7.d.mts → price-CUGIYRtD.d.mts} +1 -1
- package/dist/{price-6hQIIac9.d.ts → price-De-sxcuj.d.ts} +1 -1
- package/dist/react.d.mts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +151 -151
- package/dist/react.mjs +4 -4
- package/dist/{server-DJ0mSs9i.d.mts → server-7soMMUgP.d.ts} +3 -2
- package/dist/{server-DSTX76Ki.d.ts → server-DDEJ7e9s.d.mts} +3 -2
- package/dist/server.d.mts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +10 -10
- package/dist/server.mjs +4 -4
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +3 -3
- package/dist/testing/msw.mjs +2 -2
- package/dist/testing/suite.d.mts +5 -5
- package/dist/testing/suite.d.ts +5 -5
- package/dist/testing/suite.js +26 -25
- package/dist/testing/suite.mjs +7 -6
- package/dist/testing.d.mts +315 -8
- package/dist/testing.d.ts +315 -8
- package/dist/testing.js +118 -118
- package/dist/testing.mjs +7 -7
- package/dist/utils.d.mts +3 -3
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +32 -32
- package/dist/utils.mjs +2 -2
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
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';
|
|
3
3
|
export { getVariantDisplayName } from './chunk-3V4DVXV3.mjs';
|
|
4
|
-
import { chatRealtimeUpdateFromWire, SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-
|
|
4
|
+
import { chatRealtimeUpdateFromWire, SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-DPVDLMLI.mjs';
|
|
5
5
|
import { splitGenUIContent, messagePreview } from './chunk-U4MW6PYU.mjs';
|
|
6
6
|
export { messagePreview, splitGenUIContent } from './chunk-U4MW6PYU.mjs';
|
|
7
|
-
import { ELEMENT_TYPES, EVENT_TYPES, generateIdempotencyKey, startSignIn } from './chunk-
|
|
7
|
+
import { ELEMENT_TYPES, EVENT_TYPES, generateIdempotencyKey, startSignIn } from './chunk-RQT5BZ2Y.mjs';
|
|
8
8
|
import { ORDER_TYPE, CHECKOUT_STATUS } from './chunk-33VCYWVL.mjs';
|
|
9
|
-
import { parsePrice, formatMoney, formatPrice, getVariantUnitPrice, getProductCurrency, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-
|
|
10
|
-
import { isSupportedCurrency, ErrorCode, currencyCode, CimplifyError } from './chunk-
|
|
9
|
+
import { parsePrice, formatMoney, formatPrice, getVariantUnitPrice, getProductCurrency, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-NYDVVNZI.mjs';
|
|
10
|
+
import { isSupportedCurrency, ErrorCode, currencyCode, CimplifyError } from './chunk-NJYR6GGM.mjs';
|
|
11
11
|
import './chunk-3G6RQLXK.mjs';
|
|
12
12
|
import React14, { createContext, lazy, memo, Suspense, useMemo, useContext, useRef, useCallback, useState, useEffect, useId, useSyncExternalStore } from 'react';
|
|
13
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import {
|
|
2
|
+
import { dQ as ProductInputField, ed as PurchaseIntentView, cC as MintPurchaseIntentRequest, bh as ConfirmPurchaseIntentResponse, ex as SubmitAuthorizationInput, ab as CHECKOUT_NEXT_ACTION, i as ConfirmPurchaseIntentRequest, ey as SubmitPurchaseIntentActionRequest } from './checkout-XoV4HNg2.js';
|
|
3
3
|
|
|
4
4
|
interface Clock {
|
|
5
5
|
now(): Date;
|
|
@@ -1108,7 +1108,8 @@ interface LinkService {
|
|
|
1108
1108
|
/** A whole-registry JSON snapshot: `storeName -> id -> row`. */
|
|
1109
1109
|
type RegistrySnapshot = Record<string, Record<string, unknown>>;
|
|
1110
1110
|
|
|
1111
|
-
|
|
1111
|
+
declare const SEED_NAMES: readonly ["default", "empty", "reesa-storefront", "restaurant", "retail", "services", "grocery", "fashion", "pharmacy", "auto"];
|
|
1112
|
+
type SeedName = (typeof SEED_NAMES)[number];
|
|
1112
1113
|
|
|
1113
1114
|
interface SeedBusinessInput extends Partial<Omit<MockBusiness, "id" | "name">> {
|
|
1114
1115
|
name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import {
|
|
2
|
+
import { dQ as ProductInputField, ed as PurchaseIntentView, cC as MintPurchaseIntentRequest, bh as ConfirmPurchaseIntentResponse, ex as SubmitAuthorizationInput, ab as CHECKOUT_NEXT_ACTION, i as ConfirmPurchaseIntentRequest, ey as SubmitPurchaseIntentActionRequest } from './checkout-XoV4HNg2.mjs';
|
|
3
3
|
|
|
4
4
|
interface Clock {
|
|
5
5
|
now(): Date;
|
|
@@ -1108,7 +1108,8 @@ interface LinkService {
|
|
|
1108
1108
|
/** A whole-registry JSON snapshot: `storeName -> id -> row`. */
|
|
1109
1109
|
type RegistrySnapshot = Record<string, Record<string, unknown>>;
|
|
1110
1110
|
|
|
1111
|
-
|
|
1111
|
+
declare const SEED_NAMES: readonly ["default", "empty", "reesa-storefront", "restaurant", "retail", "services", "grocery", "fashion", "pharmacy", "auto"];
|
|
1112
|
+
type SeedName = (typeof SEED_NAMES)[number];
|
|
1112
1113
|
|
|
1113
1114
|
interface SeedBusinessInput extends Partial<Omit<MockBusiness, "id" | "name">> {
|
|
1114
1115
|
name: string;
|
package/dist/server.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as CimplifyClient } from './catalogue-
|
|
2
|
-
export { a as CacheOptions, R as ReadRequestOptions, b as Result } from './catalogue-
|
|
3
|
-
export { b as Category, c as CimplifyError, d as Collection, P as Product, e as ProductWithDetails } from './checkout-
|
|
1
|
+
import { C as CimplifyClient } from './catalogue-CB44dO-g.mjs';
|
|
2
|
+
export { a as CacheOptions, R as ReadRequestOptions, b as Result } from './catalogue-CB44dO-g.mjs';
|
|
3
|
+
export { b as Category, c as CimplifyError, d as Collection, P as Product, e as ProductWithDetails } from './checkout-XoV4HNg2.mjs';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
5
|
|
|
6
6
|
interface ServerClientOptions {
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as CimplifyClient } from './catalogue-
|
|
2
|
-
export { a as CacheOptions, R as ReadRequestOptions, b as Result } from './catalogue-
|
|
3
|
-
export { b as Category, c as CimplifyError, d as Collection, P as Product, e as ProductWithDetails } from './checkout-
|
|
1
|
+
import { C as CimplifyClient } from './catalogue-lUdp-1hu.js';
|
|
2
|
+
export { a as CacheOptions, R as ReadRequestOptions, b as Result } from './catalogue-lUdp-1hu.js';
|
|
3
|
+
export { b as Category, c as CimplifyError, d as Collection, P as Product, e as ProductWithDetails } from './checkout-XoV4HNg2.js';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
5
|
|
|
6
6
|
interface ServerClientOptions {
|
package/dist/server.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkYARZTZTB_js = require('./chunk-YARZTZTB.js');
|
|
4
4
|
require('./chunk-XREIZ56K.js');
|
|
5
|
-
var
|
|
5
|
+
var chunkH2WXUTMT_js = require('./chunk-H2WXUTMT.js');
|
|
6
6
|
require('./chunk-EV2EVOYS.js');
|
|
7
|
-
require('./chunk-
|
|
8
|
-
var
|
|
7
|
+
require('./chunk-UYFTOIFW.js');
|
|
8
|
+
var chunkAVXA4F6G_js = require('./chunk-AVXA4F6G.js');
|
|
9
9
|
require('./chunk-OWW5GUSB.js');
|
|
10
10
|
var react = require('react');
|
|
11
11
|
var jose = require('jose');
|
|
@@ -28,7 +28,7 @@ function readEnv(...keys) {
|
|
|
28
28
|
var getServerClient = react.cache((opts = {}) => {
|
|
29
29
|
const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
|
|
30
30
|
const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
|
|
31
|
-
const client =
|
|
31
|
+
const client = chunkYARZTZTB_js.createCimplifyClient({
|
|
32
32
|
baseUrl,
|
|
33
33
|
publicKey,
|
|
34
34
|
suppressPublicKeyWarning: true
|
|
@@ -252,7 +252,7 @@ var QUERY_AUTH_ERROR = "cimplify_auth_error";
|
|
|
252
252
|
var discoveryCache = /* @__PURE__ */ new Map();
|
|
253
253
|
var jwksCache = /* @__PURE__ */ new Map();
|
|
254
254
|
function issuerBase(cfg) {
|
|
255
|
-
return (cfg.issuer ?? cfg.authUrl ??
|
|
255
|
+
return (cfg.issuer ?? cfg.authUrl ?? chunkH2WXUTMT_js.DEFAULT_ISSUER).replace(/\/$/, "");
|
|
256
256
|
}
|
|
257
257
|
function cookieName(cfg) {
|
|
258
258
|
return cfg.cookieName ?? SESSION_COOKIE;
|
|
@@ -467,12 +467,12 @@ async function handleOidcCallback(req, opts) {
|
|
|
467
467
|
}
|
|
468
468
|
function readPkceCookie(cookieHeader) {
|
|
469
469
|
if (!cookieHeader) return null;
|
|
470
|
-
const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${
|
|
470
|
+
const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkH2WXUTMT_js.PKCE_COOKIE}=`));
|
|
471
471
|
if (!match) return null;
|
|
472
|
-
return
|
|
472
|
+
return chunkH2WXUTMT_js.decodePkceState(match.slice(chunkH2WXUTMT_js.PKCE_COOKIE.length + 1));
|
|
473
473
|
}
|
|
474
474
|
function buildPkceClearCookie() {
|
|
475
|
-
return `${
|
|
475
|
+
return `${chunkH2WXUTMT_js.PKCE_COOKIE}=; Path=${chunkH2WXUTMT_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
|
|
476
476
|
}
|
|
477
477
|
function safeReturnPath(returnTo, fallback) {
|
|
478
478
|
if (returnTo && returnTo.startsWith("/") && !returnTo.startsWith("//")) return returnTo;
|
|
@@ -644,7 +644,7 @@ async function handleTokenRefresh(req, cfg) {
|
|
|
644
644
|
|
|
645
645
|
Object.defineProperty(exports, "CimplifyError", {
|
|
646
646
|
enumerable: true,
|
|
647
|
-
get: function () { return
|
|
647
|
+
get: function () { return chunkAVXA4F6G_js.CimplifyError; }
|
|
648
648
|
});
|
|
649
649
|
exports.CACHE_LIFE_DEFAULT = CACHE_LIFE_DEFAULT;
|
|
650
650
|
exports.CACHE_LIFE_PROBE = CACHE_LIFE_PROBE;
|
package/dist/server.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createCimplifyClient } from './chunk-
|
|
1
|
+
import { createCimplifyClient } from './chunk-DPVDLMLI.mjs';
|
|
2
2
|
import './chunk-U4MW6PYU.mjs';
|
|
3
|
-
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-
|
|
3
|
+
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-RQT5BZ2Y.mjs';
|
|
4
4
|
import './chunk-33VCYWVL.mjs';
|
|
5
|
-
import './chunk-
|
|
6
|
-
export { CimplifyError } from './chunk-
|
|
5
|
+
import './chunk-NYDVVNZI.mjs';
|
|
6
|
+
export { CimplifyError } from './chunk-NJYR6GGM.mjs';
|
|
7
7
|
import './chunk-3G6RQLXK.mjs';
|
|
8
8
|
import { cache } from 'react';
|
|
9
9
|
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-DDEJ7e9s.mjs';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../checkout-
|
|
3
|
+
import '../checkout-XoV4HNg2.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-7soMMUgP.js';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../checkout-
|
|
3
|
+
import '../checkout-XoV4HNg2.js';
|
|
4
4
|
|
|
5
5
|
interface MswHandlerSetup {
|
|
6
6
|
handlers: unknown[];
|
package/dist/testing/msw.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNJK3THWT_js = require('../chunk-NJK3THWT.js');
|
|
4
4
|
require('../chunk-XREIZ56K.js');
|
|
5
5
|
require('../chunk-EV2EVOYS.js');
|
|
6
|
-
require('../chunk-
|
|
6
|
+
require('../chunk-AVXA4F6G.js');
|
|
7
7
|
require('../chunk-OWW5GUSB.js');
|
|
8
8
|
|
|
9
9
|
// src/mock/msw.ts
|
|
10
10
|
async function createMswHandlers(options = {}) {
|
|
11
11
|
const baseUrl = options.baseUrl ?? "http://localhost:8787";
|
|
12
|
-
const handle =
|
|
12
|
+
const handle = chunkNJK3THWT_js.createMockApp(options);
|
|
13
13
|
const msw = await import('msw').catch(() => {
|
|
14
14
|
throw new Error("msw is required to use @cimplify/sdk/mock/msw \u2014 install it as a peer dependency");
|
|
15
15
|
});
|
package/dist/testing/msw.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createMockApp } from '../chunk-
|
|
1
|
+
import { createMockApp } from '../chunk-L4XKIMUO.mjs';
|
|
2
2
|
import '../chunk-U4MW6PYU.mjs';
|
|
3
3
|
import '../chunk-33VCYWVL.mjs';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-NJYR6GGM.mjs';
|
|
5
5
|
import '../chunk-3G6RQLXK.mjs';
|
|
6
6
|
|
|
7
7
|
// src/mock/msw.ts
|
package/dist/testing/suite.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 '../catalogue-
|
|
6
|
-
import '../checkout-
|
|
2
|
+
import { T as TestClientHandle } from '../client-BWe1KWMf.mjs';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-DDEJ7e9s.mjs';
|
|
4
|
+
export { S as SeedName } from '../server-DDEJ7e9s.mjs';
|
|
5
|
+
import '../catalogue-CB44dO-g.mjs';
|
|
6
|
+
import '../checkout-XoV4HNg2.mjs';
|
|
7
7
|
import 'hono';
|
|
8
8
|
|
|
9
9
|
/**
|
package/dist/testing/suite.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 '../catalogue-
|
|
6
|
-
import '../checkout-
|
|
2
|
+
import { T as TestClientHandle } from '../client-BQ_8FtA4.js';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-7soMMUgP.js';
|
|
4
|
+
export { S as SeedName } from '../server-7soMMUgP.js';
|
|
5
|
+
import '../catalogue-lUdp-1hu.js';
|
|
6
|
+
import '../checkout-XoV4HNg2.js';
|
|
7
7
|
import 'hono';
|
|
8
8
|
|
|
9
9
|
/**
|
package/dist/testing/suite.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
3
|
+
var chunk7SEOB5UW_js = require('../chunk-7SEOB5UW.js');
|
|
4
|
+
require('../chunk-NJK3THWT.js');
|
|
5
|
+
require('../chunk-YARZTZTB.js');
|
|
6
6
|
require('../chunk-XREIZ56K.js');
|
|
7
|
-
require('../chunk-
|
|
7
|
+
require('../chunk-H2WXUTMT.js');
|
|
8
8
|
require('../chunk-EV2EVOYS.js');
|
|
9
|
-
require('../chunk-
|
|
10
|
-
require('../chunk-
|
|
9
|
+
require('../chunk-UYFTOIFW.js');
|
|
10
|
+
require('../chunk-AVXA4F6G.js');
|
|
11
11
|
require('../chunk-OWW5GUSB.js');
|
|
12
12
|
var vitest = require('vitest');
|
|
13
13
|
|
|
@@ -22,11 +22,11 @@ var PLACEHOLDER_PHRASES = [
|
|
|
22
22
|
function createBrandSuite(opts) {
|
|
23
23
|
vitest.describe(opts.label ?? "brand schema", () => {
|
|
24
24
|
vitest.it("conforms to the Cimplify brand contract", () => {
|
|
25
|
-
vitest.expect(() =>
|
|
25
|
+
vitest.expect(() => chunk7SEOB5UW_js.assertBrand(opts.brand)).not.toThrow();
|
|
26
26
|
});
|
|
27
27
|
vitest.it("declares a known mock seed", () => {
|
|
28
28
|
const b = opts.brand;
|
|
29
|
-
vitest.expect(
|
|
29
|
+
vitest.expect(chunk7SEOB5UW_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
vitest.it("has no placeholder copy left in", () => {
|
|
32
32
|
const offenders = [];
|
|
@@ -58,7 +58,7 @@ ${msg}`);
|
|
|
58
58
|
vitest.expect(b.mock?.businessId).toMatch(/^bus_/);
|
|
59
59
|
});
|
|
60
60
|
vitest.it("zod-parses cleanly", () => {
|
|
61
|
-
const result =
|
|
61
|
+
const result = chunk7SEOB5UW_js.BrandSchema.safeParse(opts.brand);
|
|
62
62
|
if (!result.success) {
|
|
63
63
|
throw new Error(
|
|
64
64
|
"Brand schema violations:\n" + result.error.issues.map((i) => ` \u2022 brand.${i.path.join(".")}: ${i.message}`).join("\n")
|
|
@@ -73,23 +73,23 @@ function createCartFlowSuite(opts = {}) {
|
|
|
73
73
|
vitest.describe(opts.label ?? "cart flow against in-process mock", () => {
|
|
74
74
|
let h;
|
|
75
75
|
vitest.beforeEach(() => {
|
|
76
|
-
h =
|
|
76
|
+
h = chunk7SEOB5UW_js.createTestClient(opts);
|
|
77
77
|
});
|
|
78
78
|
vitest.afterEach(() => h.dispose());
|
|
79
79
|
vitest.it("starts with an empty cart matching the canonical shape", async () => {
|
|
80
80
|
const res = await h.client.cart.get();
|
|
81
81
|
vitest.expect(res.ok).toBe(true);
|
|
82
82
|
if (!res.ok) return;
|
|
83
|
-
vitest.expect(() =>
|
|
83
|
+
vitest.expect(() => chunk7SEOB5UW_js.assertCart(res.value)).not.toThrow();
|
|
84
84
|
vitest.expect(res.value.items).toHaveLength(0);
|
|
85
85
|
});
|
|
86
86
|
vitest.it("adds the first product, persists it, and returns a shape-valid cart", async () => {
|
|
87
|
-
const { product, variantId } = await
|
|
87
|
+
const { product, variantId } = await chunk7SEOB5UW_js.fixtures.addFirstProduct(h.client);
|
|
88
88
|
vitest.expect(product.id).toBeTruthy();
|
|
89
89
|
const get = await h.client.cart.get();
|
|
90
90
|
vitest.expect(get.ok).toBe(true);
|
|
91
91
|
if (!get.ok) return;
|
|
92
|
-
vitest.expect(() =>
|
|
92
|
+
vitest.expect(() => chunk7SEOB5UW_js.assertCart(get.value)).not.toThrow();
|
|
93
93
|
vitest.expect(get.value.items).toHaveLength(1);
|
|
94
94
|
vitest.expect(get.value.items[0]?.item_id).toBe(product.id);
|
|
95
95
|
if (variantId) {
|
|
@@ -100,8 +100,8 @@ function createCartFlowSuite(opts = {}) {
|
|
|
100
100
|
vitest.expect(parseFloat(String(get.value.pricing.subtotal))).toBeGreaterThan(0);
|
|
101
101
|
});
|
|
102
102
|
vitest.it("dedupes by line_key when adding the same product twice", async () => {
|
|
103
|
-
await
|
|
104
|
-
await
|
|
103
|
+
await chunk7SEOB5UW_js.fixtures.addFirstProduct(h.client);
|
|
104
|
+
await chunk7SEOB5UW_js.fixtures.addFirstProduct(h.client);
|
|
105
105
|
const res = await h.client.cart.get();
|
|
106
106
|
vitest.expect(res.ok).toBe(true);
|
|
107
107
|
if (!res.ok) return;
|
|
@@ -109,7 +109,7 @@ function createCartFlowSuite(opts = {}) {
|
|
|
109
109
|
vitest.expect(res.value.items[0]?.quantity).toBe(2);
|
|
110
110
|
});
|
|
111
111
|
vitest.it("removes items and zeroes the subtotal", async () => {
|
|
112
|
-
await
|
|
112
|
+
await chunk7SEOB5UW_js.fixtures.addFirstProduct(h.client);
|
|
113
113
|
const before = await h.client.cart.get();
|
|
114
114
|
if (!before.ok) throw before.error;
|
|
115
115
|
const itemId = before.value.items[0]?.id;
|
|
@@ -135,28 +135,28 @@ function createContractSuite(opts = {}) {
|
|
|
135
135
|
vitest.describe(opts.label ?? "SDK \u2194 mock contract", () => {
|
|
136
136
|
let h;
|
|
137
137
|
vitest.beforeEach(() => {
|
|
138
|
-
h =
|
|
138
|
+
h = chunk7SEOB5UW_js.createTestClient(opts);
|
|
139
139
|
});
|
|
140
140
|
vitest.afterEach(() => h.dispose());
|
|
141
141
|
vitest.it("AddItemPayload schema accepts a minimal valid body", () => {
|
|
142
|
-
const result =
|
|
142
|
+
const result = chunk7SEOB5UW_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
|
|
143
143
|
vitest.expect(result.success).toBe(true);
|
|
144
144
|
});
|
|
145
145
|
vitest.it("AddItemPayload schema rejects negative quantity", () => {
|
|
146
|
-
const result =
|
|
146
|
+
const result = chunk7SEOB5UW_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
|
|
147
147
|
vitest.expect(result.success).toBe(false);
|
|
148
148
|
});
|
|
149
149
|
vitest.it("AddItemPayload schema rejects empty item_id", () => {
|
|
150
|
-
const result =
|
|
150
|
+
const result = chunk7SEOB5UW_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
|
|
151
151
|
vitest.expect(result.success).toBe(false);
|
|
152
152
|
});
|
|
153
153
|
vitest.it("Cart line items returned by the mock match CartItemSchema", async () => {
|
|
154
|
-
const { product } = await
|
|
154
|
+
const { product } = await chunk7SEOB5UW_js.fixtures.addFirstProduct(h.client);
|
|
155
155
|
const get = await h.client.cart.get();
|
|
156
156
|
if (!get.ok) throw get.error;
|
|
157
157
|
vitest.expect(get.value.items.length).toBeGreaterThan(0);
|
|
158
158
|
for (const item of get.value.items) {
|
|
159
|
-
const result =
|
|
159
|
+
const result = chunk7SEOB5UW_js.CartItemSchema.safeParse(item);
|
|
160
160
|
if (!result.success) {
|
|
161
161
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
162
162
|
throw new Error(`Cart item shape mismatch for ${product.name}:
|
|
@@ -166,19 +166,20 @@ ${issues}`);
|
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
vitest.it("CheckoutResponse projects purchase-intent authority without fabricating a bill token", async () => {
|
|
169
|
-
await
|
|
169
|
+
await chunk7SEOB5UW_js.fixtures.addFirstProduct(h.client);
|
|
170
170
|
const cartRes = await h.client.cart.get();
|
|
171
171
|
if (!cartRes.ok) throw cartRes.error;
|
|
172
172
|
const checkout = await h.client.checkout.process({
|
|
173
173
|
cart_id: cartRes.value.id,
|
|
174
|
-
customer:
|
|
174
|
+
customer: chunk7SEOB5UW_js.fixtures.customer(),
|
|
175
175
|
order_type: "delivery",
|
|
176
|
+
address_info: chunk7SEOB5UW_js.fixtures.deliveryAddress(),
|
|
176
177
|
payment_method: "mobile_money",
|
|
177
178
|
mobile_money_details: { phone_number: "+233244000000", provider: "mtn" }
|
|
178
179
|
});
|
|
179
180
|
vitest.expect(checkout.ok).toBe(true);
|
|
180
181
|
if (!checkout.ok) return;
|
|
181
|
-
const result =
|
|
182
|
+
const result = chunk7SEOB5UW_js.CheckoutResponseSchema.safeParse(checkout.value);
|
|
182
183
|
if (!result.success) {
|
|
183
184
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
184
185
|
throw new Error(`CheckoutResponse shape mismatch:
|
package/dist/testing/suite.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-3BTMAWL7.mjs';
|
|
2
|
+
import '../chunk-L4XKIMUO.mjs';
|
|
3
|
+
import '../chunk-DPVDLMLI.mjs';
|
|
4
4
|
import '../chunk-U4MW6PYU.mjs';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-RQT5BZ2Y.mjs';
|
|
6
6
|
import '../chunk-33VCYWVL.mjs';
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-NYDVVNZI.mjs';
|
|
8
|
+
import '../chunk-NJYR6GGM.mjs';
|
|
9
9
|
import '../chunk-3G6RQLXK.mjs';
|
|
10
10
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
11
11
|
|
|
@@ -171,6 +171,7 @@ ${issues}`);
|
|
|
171
171
|
cart_id: cartRes.value.id,
|
|
172
172
|
customer: fixtures.customer(),
|
|
173
173
|
order_type: "delivery",
|
|
174
|
+
address_info: fixtures.deliveryAddress(),
|
|
174
175
|
payment_method: "mobile_money",
|
|
175
176
|
mobile_money_details: { phone_number: "+233244000000", provider: "mtn" }
|
|
176
177
|
});
|