@cimplify/sdk 0.67.0 → 0.69.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 +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-SSLFZPAI.js → chunk-5HAUJBOK.js} +35 -35
- package/dist/{chunk-FNK6UZOE.mjs → chunk-5UYNERYE.mjs} +2 -2
- package/dist/{chunk-SXGFJEME.js → chunk-I4MP2XZS.js} +73 -7
- package/dist/{chunk-JAPCAZN4.mjs → chunk-KNPE4WCQ.mjs} +1 -1
- package/dist/{chunk-FVGVJ4TC.mjs → chunk-O3ECKVOM.mjs} +73 -7
- package/dist/{chunk-QQMDEGAK.mjs → chunk-SOV4H6PQ.mjs} +177 -50
- package/dist/{chunk-SH6HJW4A.js → chunk-TBSDZN2W.js} +4 -4
- package/dist/{chunk-3QSW33RG.js → chunk-WCSAZRNC.js} +179 -49
- package/dist/{client-DVFQoDtI.d.ts → client-CO2s-kxY.d.ts} +57 -19
- package/dist/{client-CQlEWH5j.d.ts → client-DUpz-PGs.d.ts} +1 -1
- package/dist/{client-Dd82KQ_G.d.mts → client-DZ-nbVnb.d.mts} +1 -1
- package/dist/{client-ByI_3jfL.d.mts → client-K_n5ceLI.d.mts} +57 -19
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +89 -72
- package/dist/index.mjs +15 -10
- package/dist/mock/cli.mjs +73 -7
- package/dist/mock/library.js +73 -7
- package/dist/mock/library.mjs +73 -7
- package/dist/mock/msw.js +73 -7
- package/dist/mock/msw.mjs +73 -7
- package/dist/react.d.mts +197 -40
- package/dist/react.d.ts +197 -40
- package/dist/react.js +1241 -567
- package/dist/react.mjs +824 -155
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +7 -7
- package/dist/server.mjs +2 -2
- package/dist/{sign-in-RFuWZOgF.d.mts → sign-in-DQlIdqsi.d.mts} +8 -0
- package/dist/{sign-in-RFuWZOgF.d.ts → sign-in-DQlIdqsi.d.ts} +8 -0
- package/dist/styles.css +1 -1
- package/dist/testing/msw.js +2 -2
- package/dist/testing/msw.mjs +1 -1
- package/dist/testing/suite.d.mts +2 -2
- package/dist/testing/suite.d.ts +2 -2
- package/dist/testing/suite.js +23 -23
- package/dist/testing/suite.mjs +4 -4
- package/dist/testing.d.mts +17 -17
- package/dist/testing.d.ts +17 -17
- package/dist/testing.js +79 -79
- package/dist/testing.mjs +5 -5
- package/package.json +1 -1
- package/registry/index.json +0 -9
- package/registry/account.json +0 -15
package/dist/mock/library.js
CHANGED
|
@@ -2412,23 +2412,47 @@ function buildV1(deps) {
|
|
|
2412
2412
|
app.get("/auth/status", (c) => tryRoute(c, () => deps.auth.status(c.var.session.token)));
|
|
2413
2413
|
app.post("/auth/request-otp", async (c) => {
|
|
2414
2414
|
const body = await c.req.json().catch(() => ({}));
|
|
2415
|
-
return tryRoute(c, () =>
|
|
2415
|
+
return tryRoute(c, () => {
|
|
2416
|
+
deps.auth.requestOtp(body.contact ?? "");
|
|
2417
|
+
return {
|
|
2418
|
+
message: `OTP sent to ${body.contact ?? "contact"}`,
|
|
2419
|
+
expires_in: 300,
|
|
2420
|
+
is_new_account: false
|
|
2421
|
+
};
|
|
2422
|
+
});
|
|
2416
2423
|
});
|
|
2417
2424
|
app.post("/auth/verify-otp", async (c) => {
|
|
2418
2425
|
const body = await c.req.json().catch(() => ({}));
|
|
2419
2426
|
return tryRoute(c, () => {
|
|
2420
2427
|
const session = deps.auth.verifyOtp(body.contact ?? "", body.otp_code ?? body.code ?? "");
|
|
2421
2428
|
c.header("x-session-token", session.token);
|
|
2422
|
-
return {
|
|
2429
|
+
return {
|
|
2430
|
+
message: "Successfully authenticated",
|
|
2431
|
+
account_id: session.id,
|
|
2432
|
+
session_token: session.token,
|
|
2433
|
+
refresh_token: session.token,
|
|
2434
|
+
customer: {
|
|
2435
|
+
id: session.customer_id ?? session.id,
|
|
2436
|
+
name: session.customer_name ?? "Test User",
|
|
2437
|
+
email: session.customer_email ?? null,
|
|
2438
|
+
phone: session.customer_phone ?? null,
|
|
2439
|
+
delivery_address: null,
|
|
2440
|
+
created_at: session.created_at,
|
|
2441
|
+
updated_at: session.created_at
|
|
2442
|
+
}
|
|
2443
|
+
};
|
|
2423
2444
|
});
|
|
2424
2445
|
});
|
|
2425
2446
|
app.post("/auth/logout", (c) => {
|
|
2426
2447
|
deps.auth.logout(c.var.session.token);
|
|
2427
|
-
return ok(c, {
|
|
2448
|
+
return ok(c, { message: "Successfully logged out", action: "discard_token" });
|
|
2428
2449
|
});
|
|
2429
2450
|
app.post("/auth/profile", async (c) => {
|
|
2430
2451
|
const body = await c.req.json().catch(() => ({}));
|
|
2431
|
-
return tryRoute(c, () =>
|
|
2452
|
+
return tryRoute(c, () => {
|
|
2453
|
+
deps.auth.updateProfile(c.var.session.token, body);
|
|
2454
|
+
return { success: true, message: "Profile updated successfully" };
|
|
2455
|
+
});
|
|
2432
2456
|
});
|
|
2433
2457
|
app.get("/inventory/products/:product_id/stock", (c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id"))));
|
|
2434
2458
|
app.get("/inventory/variants/:variant_id/stock", (c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id"))));
|
|
@@ -3050,7 +3074,12 @@ function buildLink(deps) {
|
|
|
3050
3074
|
const body = await c.req.json().catch(() => ({}));
|
|
3051
3075
|
return tryRoute(c, () => {
|
|
3052
3076
|
deps.auth.requestOtp(body.contact ?? "");
|
|
3053
|
-
return {
|
|
3077
|
+
return {
|
|
3078
|
+
success: true,
|
|
3079
|
+
message: `OTP sent to ${body.contact ?? "contact"}`,
|
|
3080
|
+
expires_in: 300,
|
|
3081
|
+
is_new_account: false
|
|
3082
|
+
};
|
|
3054
3083
|
});
|
|
3055
3084
|
});
|
|
3056
3085
|
app.post("/auth/verify-otp", async (c) => {
|
|
@@ -3068,7 +3097,29 @@ function buildLink(deps) {
|
|
|
3068
3097
|
refresh_token: session.token,
|
|
3069
3098
|
account_id: session.id,
|
|
3070
3099
|
customer_id: customer.customer.id,
|
|
3071
|
-
|
|
3100
|
+
name: customer.customer.name,
|
|
3101
|
+
email: customer.customer.email,
|
|
3102
|
+
phone: customer.customer.phone,
|
|
3103
|
+
message: "Login successful"
|
|
3104
|
+
};
|
|
3105
|
+
});
|
|
3106
|
+
});
|
|
3107
|
+
app.post("/auth/refresh", async (c) => {
|
|
3108
|
+
const body = await c.req.json().catch(() => ({}));
|
|
3109
|
+
return tryRoute(c, () => {
|
|
3110
|
+
const session = deps.auth.ensureSession(body.session_token ?? c.var.session.token);
|
|
3111
|
+
const customer = deps.link.ensureCustomer(session.customer_id ?? session.id);
|
|
3112
|
+
c.header("x-session-token", session.token);
|
|
3113
|
+
return {
|
|
3114
|
+
success: true,
|
|
3115
|
+
session_token: session.token,
|
|
3116
|
+
refresh_token: session.token,
|
|
3117
|
+
account_id: session.id,
|
|
3118
|
+
customer_id: customer.customer.id,
|
|
3119
|
+
name: customer.customer.name,
|
|
3120
|
+
email: customer.customer.email,
|
|
3121
|
+
phone: customer.customer.phone,
|
|
3122
|
+
message: "Session refreshed"
|
|
3072
3123
|
};
|
|
3073
3124
|
});
|
|
3074
3125
|
});
|
|
@@ -3076,9 +3127,24 @@ function buildLink(deps) {
|
|
|
3076
3127
|
"/auth/logout",
|
|
3077
3128
|
(c) => tryRoute(c, () => {
|
|
3078
3129
|
deps.auth.logout(c.var.session.token);
|
|
3079
|
-
return { success: true, message: "Logged out" };
|
|
3130
|
+
return { success: true, message: "Logged out successfully", action: "discard_token" };
|
|
3080
3131
|
})
|
|
3081
3132
|
);
|
|
3133
|
+
app.get("/profile", (c) => tryRoute(c, () => deps.link.getProfile(customerId(c))));
|
|
3134
|
+
app.post("/profile", async (c) => {
|
|
3135
|
+
const body = await c.req.json().catch(() => ({}));
|
|
3136
|
+
return tryRoute(c, () => {
|
|
3137
|
+
const state = deps.link.ensureCustomer(customerId(c));
|
|
3138
|
+
state.customer = {
|
|
3139
|
+
...state.customer,
|
|
3140
|
+
name: body.name ?? state.customer.name,
|
|
3141
|
+
email: body.email ?? state.customer.email,
|
|
3142
|
+
phone: body.phone ?? state.customer.phone,
|
|
3143
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3144
|
+
};
|
|
3145
|
+
return state.customer;
|
|
3146
|
+
});
|
|
3147
|
+
});
|
|
3082
3148
|
app.get("/data", (c) => tryRoute(c, () => deps.link.getLinkData(customerId(c))));
|
|
3083
3149
|
app.post("/check-status", async (c) => {
|
|
3084
3150
|
const body = await c.req.json().catch(() => ({}));
|
package/dist/mock/library.mjs
CHANGED
|
@@ -2410,23 +2410,47 @@ function buildV1(deps) {
|
|
|
2410
2410
|
app.get("/auth/status", (c) => tryRoute(c, () => deps.auth.status(c.var.session.token)));
|
|
2411
2411
|
app.post("/auth/request-otp", async (c) => {
|
|
2412
2412
|
const body = await c.req.json().catch(() => ({}));
|
|
2413
|
-
return tryRoute(c, () =>
|
|
2413
|
+
return tryRoute(c, () => {
|
|
2414
|
+
deps.auth.requestOtp(body.contact ?? "");
|
|
2415
|
+
return {
|
|
2416
|
+
message: `OTP sent to ${body.contact ?? "contact"}`,
|
|
2417
|
+
expires_in: 300,
|
|
2418
|
+
is_new_account: false
|
|
2419
|
+
};
|
|
2420
|
+
});
|
|
2414
2421
|
});
|
|
2415
2422
|
app.post("/auth/verify-otp", async (c) => {
|
|
2416
2423
|
const body = await c.req.json().catch(() => ({}));
|
|
2417
2424
|
return tryRoute(c, () => {
|
|
2418
2425
|
const session = deps.auth.verifyOtp(body.contact ?? "", body.otp_code ?? body.code ?? "");
|
|
2419
2426
|
c.header("x-session-token", session.token);
|
|
2420
|
-
return {
|
|
2427
|
+
return {
|
|
2428
|
+
message: "Successfully authenticated",
|
|
2429
|
+
account_id: session.id,
|
|
2430
|
+
session_token: session.token,
|
|
2431
|
+
refresh_token: session.token,
|
|
2432
|
+
customer: {
|
|
2433
|
+
id: session.customer_id ?? session.id,
|
|
2434
|
+
name: session.customer_name ?? "Test User",
|
|
2435
|
+
email: session.customer_email ?? null,
|
|
2436
|
+
phone: session.customer_phone ?? null,
|
|
2437
|
+
delivery_address: null,
|
|
2438
|
+
created_at: session.created_at,
|
|
2439
|
+
updated_at: session.created_at
|
|
2440
|
+
}
|
|
2441
|
+
};
|
|
2421
2442
|
});
|
|
2422
2443
|
});
|
|
2423
2444
|
app.post("/auth/logout", (c) => {
|
|
2424
2445
|
deps.auth.logout(c.var.session.token);
|
|
2425
|
-
return ok(c, {
|
|
2446
|
+
return ok(c, { message: "Successfully logged out", action: "discard_token" });
|
|
2426
2447
|
});
|
|
2427
2448
|
app.post("/auth/profile", async (c) => {
|
|
2428
2449
|
const body = await c.req.json().catch(() => ({}));
|
|
2429
|
-
return tryRoute(c, () =>
|
|
2450
|
+
return tryRoute(c, () => {
|
|
2451
|
+
deps.auth.updateProfile(c.var.session.token, body);
|
|
2452
|
+
return { success: true, message: "Profile updated successfully" };
|
|
2453
|
+
});
|
|
2430
2454
|
});
|
|
2431
2455
|
app.get("/inventory/products/:product_id/stock", (c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id"))));
|
|
2432
2456
|
app.get("/inventory/variants/:variant_id/stock", (c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id"))));
|
|
@@ -3048,7 +3072,12 @@ function buildLink(deps) {
|
|
|
3048
3072
|
const body = await c.req.json().catch(() => ({}));
|
|
3049
3073
|
return tryRoute(c, () => {
|
|
3050
3074
|
deps.auth.requestOtp(body.contact ?? "");
|
|
3051
|
-
return {
|
|
3075
|
+
return {
|
|
3076
|
+
success: true,
|
|
3077
|
+
message: `OTP sent to ${body.contact ?? "contact"}`,
|
|
3078
|
+
expires_in: 300,
|
|
3079
|
+
is_new_account: false
|
|
3080
|
+
};
|
|
3052
3081
|
});
|
|
3053
3082
|
});
|
|
3054
3083
|
app.post("/auth/verify-otp", async (c) => {
|
|
@@ -3066,7 +3095,29 @@ function buildLink(deps) {
|
|
|
3066
3095
|
refresh_token: session.token,
|
|
3067
3096
|
account_id: session.id,
|
|
3068
3097
|
customer_id: customer.customer.id,
|
|
3069
|
-
|
|
3098
|
+
name: customer.customer.name,
|
|
3099
|
+
email: customer.customer.email,
|
|
3100
|
+
phone: customer.customer.phone,
|
|
3101
|
+
message: "Login successful"
|
|
3102
|
+
};
|
|
3103
|
+
});
|
|
3104
|
+
});
|
|
3105
|
+
app.post("/auth/refresh", async (c) => {
|
|
3106
|
+
const body = await c.req.json().catch(() => ({}));
|
|
3107
|
+
return tryRoute(c, () => {
|
|
3108
|
+
const session = deps.auth.ensureSession(body.session_token ?? c.var.session.token);
|
|
3109
|
+
const customer = deps.link.ensureCustomer(session.customer_id ?? session.id);
|
|
3110
|
+
c.header("x-session-token", session.token);
|
|
3111
|
+
return {
|
|
3112
|
+
success: true,
|
|
3113
|
+
session_token: session.token,
|
|
3114
|
+
refresh_token: session.token,
|
|
3115
|
+
account_id: session.id,
|
|
3116
|
+
customer_id: customer.customer.id,
|
|
3117
|
+
name: customer.customer.name,
|
|
3118
|
+
email: customer.customer.email,
|
|
3119
|
+
phone: customer.customer.phone,
|
|
3120
|
+
message: "Session refreshed"
|
|
3070
3121
|
};
|
|
3071
3122
|
});
|
|
3072
3123
|
});
|
|
@@ -3074,9 +3125,24 @@ function buildLink(deps) {
|
|
|
3074
3125
|
"/auth/logout",
|
|
3075
3126
|
(c) => tryRoute(c, () => {
|
|
3076
3127
|
deps.auth.logout(c.var.session.token);
|
|
3077
|
-
return { success: true, message: "Logged out" };
|
|
3128
|
+
return { success: true, message: "Logged out successfully", action: "discard_token" };
|
|
3078
3129
|
})
|
|
3079
3130
|
);
|
|
3131
|
+
app.get("/profile", (c) => tryRoute(c, () => deps.link.getProfile(customerId(c))));
|
|
3132
|
+
app.post("/profile", async (c) => {
|
|
3133
|
+
const body = await c.req.json().catch(() => ({}));
|
|
3134
|
+
return tryRoute(c, () => {
|
|
3135
|
+
const state = deps.link.ensureCustomer(customerId(c));
|
|
3136
|
+
state.customer = {
|
|
3137
|
+
...state.customer,
|
|
3138
|
+
name: body.name ?? state.customer.name,
|
|
3139
|
+
email: body.email ?? state.customer.email,
|
|
3140
|
+
phone: body.phone ?? state.customer.phone,
|
|
3141
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3142
|
+
};
|
|
3143
|
+
return state.customer;
|
|
3144
|
+
});
|
|
3145
|
+
});
|
|
3080
3146
|
app.get("/data", (c) => tryRoute(c, () => deps.link.getLinkData(customerId(c))));
|
|
3081
3147
|
app.post("/check-status", async (c) => {
|
|
3082
3148
|
const body = await c.req.json().catch(() => ({}));
|
package/dist/mock/msw.js
CHANGED
|
@@ -2410,23 +2410,47 @@ function buildV1(deps) {
|
|
|
2410
2410
|
app.get("/auth/status", (c) => tryRoute(c, () => deps.auth.status(c.var.session.token)));
|
|
2411
2411
|
app.post("/auth/request-otp", async (c) => {
|
|
2412
2412
|
const body = await c.req.json().catch(() => ({}));
|
|
2413
|
-
return tryRoute(c, () =>
|
|
2413
|
+
return tryRoute(c, () => {
|
|
2414
|
+
deps.auth.requestOtp(body.contact ?? "");
|
|
2415
|
+
return {
|
|
2416
|
+
message: `OTP sent to ${body.contact ?? "contact"}`,
|
|
2417
|
+
expires_in: 300,
|
|
2418
|
+
is_new_account: false
|
|
2419
|
+
};
|
|
2420
|
+
});
|
|
2414
2421
|
});
|
|
2415
2422
|
app.post("/auth/verify-otp", async (c) => {
|
|
2416
2423
|
const body = await c.req.json().catch(() => ({}));
|
|
2417
2424
|
return tryRoute(c, () => {
|
|
2418
2425
|
const session = deps.auth.verifyOtp(body.contact ?? "", body.otp_code ?? body.code ?? "");
|
|
2419
2426
|
c.header("x-session-token", session.token);
|
|
2420
|
-
return {
|
|
2427
|
+
return {
|
|
2428
|
+
message: "Successfully authenticated",
|
|
2429
|
+
account_id: session.id,
|
|
2430
|
+
session_token: session.token,
|
|
2431
|
+
refresh_token: session.token,
|
|
2432
|
+
customer: {
|
|
2433
|
+
id: session.customer_id ?? session.id,
|
|
2434
|
+
name: session.customer_name ?? "Test User",
|
|
2435
|
+
email: session.customer_email ?? null,
|
|
2436
|
+
phone: session.customer_phone ?? null,
|
|
2437
|
+
delivery_address: null,
|
|
2438
|
+
created_at: session.created_at,
|
|
2439
|
+
updated_at: session.created_at
|
|
2440
|
+
}
|
|
2441
|
+
};
|
|
2421
2442
|
});
|
|
2422
2443
|
});
|
|
2423
2444
|
app.post("/auth/logout", (c) => {
|
|
2424
2445
|
deps.auth.logout(c.var.session.token);
|
|
2425
|
-
return ok(c, {
|
|
2446
|
+
return ok(c, { message: "Successfully logged out", action: "discard_token" });
|
|
2426
2447
|
});
|
|
2427
2448
|
app.post("/auth/profile", async (c) => {
|
|
2428
2449
|
const body = await c.req.json().catch(() => ({}));
|
|
2429
|
-
return tryRoute(c, () =>
|
|
2450
|
+
return tryRoute(c, () => {
|
|
2451
|
+
deps.auth.updateProfile(c.var.session.token, body);
|
|
2452
|
+
return { success: true, message: "Profile updated successfully" };
|
|
2453
|
+
});
|
|
2430
2454
|
});
|
|
2431
2455
|
app.get("/inventory/products/:product_id/stock", (c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id"))));
|
|
2432
2456
|
app.get("/inventory/variants/:variant_id/stock", (c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id"))));
|
|
@@ -3048,7 +3072,12 @@ function buildLink(deps) {
|
|
|
3048
3072
|
const body = await c.req.json().catch(() => ({}));
|
|
3049
3073
|
return tryRoute(c, () => {
|
|
3050
3074
|
deps.auth.requestOtp(body.contact ?? "");
|
|
3051
|
-
return {
|
|
3075
|
+
return {
|
|
3076
|
+
success: true,
|
|
3077
|
+
message: `OTP sent to ${body.contact ?? "contact"}`,
|
|
3078
|
+
expires_in: 300,
|
|
3079
|
+
is_new_account: false
|
|
3080
|
+
};
|
|
3052
3081
|
});
|
|
3053
3082
|
});
|
|
3054
3083
|
app.post("/auth/verify-otp", async (c) => {
|
|
@@ -3066,7 +3095,29 @@ function buildLink(deps) {
|
|
|
3066
3095
|
refresh_token: session.token,
|
|
3067
3096
|
account_id: session.id,
|
|
3068
3097
|
customer_id: customer.customer.id,
|
|
3069
|
-
|
|
3098
|
+
name: customer.customer.name,
|
|
3099
|
+
email: customer.customer.email,
|
|
3100
|
+
phone: customer.customer.phone,
|
|
3101
|
+
message: "Login successful"
|
|
3102
|
+
};
|
|
3103
|
+
});
|
|
3104
|
+
});
|
|
3105
|
+
app.post("/auth/refresh", async (c) => {
|
|
3106
|
+
const body = await c.req.json().catch(() => ({}));
|
|
3107
|
+
return tryRoute(c, () => {
|
|
3108
|
+
const session = deps.auth.ensureSession(body.session_token ?? c.var.session.token);
|
|
3109
|
+
const customer = deps.link.ensureCustomer(session.customer_id ?? session.id);
|
|
3110
|
+
c.header("x-session-token", session.token);
|
|
3111
|
+
return {
|
|
3112
|
+
success: true,
|
|
3113
|
+
session_token: session.token,
|
|
3114
|
+
refresh_token: session.token,
|
|
3115
|
+
account_id: session.id,
|
|
3116
|
+
customer_id: customer.customer.id,
|
|
3117
|
+
name: customer.customer.name,
|
|
3118
|
+
email: customer.customer.email,
|
|
3119
|
+
phone: customer.customer.phone,
|
|
3120
|
+
message: "Session refreshed"
|
|
3070
3121
|
};
|
|
3071
3122
|
});
|
|
3072
3123
|
});
|
|
@@ -3074,9 +3125,24 @@ function buildLink(deps) {
|
|
|
3074
3125
|
"/auth/logout",
|
|
3075
3126
|
(c) => tryRoute(c, () => {
|
|
3076
3127
|
deps.auth.logout(c.var.session.token);
|
|
3077
|
-
return { success: true, message: "Logged out" };
|
|
3128
|
+
return { success: true, message: "Logged out successfully", action: "discard_token" };
|
|
3078
3129
|
})
|
|
3079
3130
|
);
|
|
3131
|
+
app.get("/profile", (c) => tryRoute(c, () => deps.link.getProfile(customerId(c))));
|
|
3132
|
+
app.post("/profile", async (c) => {
|
|
3133
|
+
const body = await c.req.json().catch(() => ({}));
|
|
3134
|
+
return tryRoute(c, () => {
|
|
3135
|
+
const state = deps.link.ensureCustomer(customerId(c));
|
|
3136
|
+
state.customer = {
|
|
3137
|
+
...state.customer,
|
|
3138
|
+
name: body.name ?? state.customer.name,
|
|
3139
|
+
email: body.email ?? state.customer.email,
|
|
3140
|
+
phone: body.phone ?? state.customer.phone,
|
|
3141
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3142
|
+
};
|
|
3143
|
+
return state.customer;
|
|
3144
|
+
});
|
|
3145
|
+
});
|
|
3080
3146
|
app.get("/data", (c) => tryRoute(c, () => deps.link.getLinkData(customerId(c))));
|
|
3081
3147
|
app.post("/check-status", async (c) => {
|
|
3082
3148
|
const body = await c.req.json().catch(() => ({}));
|
package/dist/mock/msw.mjs
CHANGED
|
@@ -2408,23 +2408,47 @@ function buildV1(deps) {
|
|
|
2408
2408
|
app.get("/auth/status", (c) => tryRoute(c, () => deps.auth.status(c.var.session.token)));
|
|
2409
2409
|
app.post("/auth/request-otp", async (c) => {
|
|
2410
2410
|
const body = await c.req.json().catch(() => ({}));
|
|
2411
|
-
return tryRoute(c, () =>
|
|
2411
|
+
return tryRoute(c, () => {
|
|
2412
|
+
deps.auth.requestOtp(body.contact ?? "");
|
|
2413
|
+
return {
|
|
2414
|
+
message: `OTP sent to ${body.contact ?? "contact"}`,
|
|
2415
|
+
expires_in: 300,
|
|
2416
|
+
is_new_account: false
|
|
2417
|
+
};
|
|
2418
|
+
});
|
|
2412
2419
|
});
|
|
2413
2420
|
app.post("/auth/verify-otp", async (c) => {
|
|
2414
2421
|
const body = await c.req.json().catch(() => ({}));
|
|
2415
2422
|
return tryRoute(c, () => {
|
|
2416
2423
|
const session = deps.auth.verifyOtp(body.contact ?? "", body.otp_code ?? body.code ?? "");
|
|
2417
2424
|
c.header("x-session-token", session.token);
|
|
2418
|
-
return {
|
|
2425
|
+
return {
|
|
2426
|
+
message: "Successfully authenticated",
|
|
2427
|
+
account_id: session.id,
|
|
2428
|
+
session_token: session.token,
|
|
2429
|
+
refresh_token: session.token,
|
|
2430
|
+
customer: {
|
|
2431
|
+
id: session.customer_id ?? session.id,
|
|
2432
|
+
name: session.customer_name ?? "Test User",
|
|
2433
|
+
email: session.customer_email ?? null,
|
|
2434
|
+
phone: session.customer_phone ?? null,
|
|
2435
|
+
delivery_address: null,
|
|
2436
|
+
created_at: session.created_at,
|
|
2437
|
+
updated_at: session.created_at
|
|
2438
|
+
}
|
|
2439
|
+
};
|
|
2419
2440
|
});
|
|
2420
2441
|
});
|
|
2421
2442
|
app.post("/auth/logout", (c) => {
|
|
2422
2443
|
deps.auth.logout(c.var.session.token);
|
|
2423
|
-
return ok(c, {
|
|
2444
|
+
return ok(c, { message: "Successfully logged out", action: "discard_token" });
|
|
2424
2445
|
});
|
|
2425
2446
|
app.post("/auth/profile", async (c) => {
|
|
2426
2447
|
const body = await c.req.json().catch(() => ({}));
|
|
2427
|
-
return tryRoute(c, () =>
|
|
2448
|
+
return tryRoute(c, () => {
|
|
2449
|
+
deps.auth.updateProfile(c.var.session.token, body);
|
|
2450
|
+
return { success: true, message: "Profile updated successfully" };
|
|
2451
|
+
});
|
|
2428
2452
|
});
|
|
2429
2453
|
app.get("/inventory/products/:product_id/stock", (c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id"))));
|
|
2430
2454
|
app.get("/inventory/variants/:variant_id/stock", (c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id"))));
|
|
@@ -3046,7 +3070,12 @@ function buildLink(deps) {
|
|
|
3046
3070
|
const body = await c.req.json().catch(() => ({}));
|
|
3047
3071
|
return tryRoute(c, () => {
|
|
3048
3072
|
deps.auth.requestOtp(body.contact ?? "");
|
|
3049
|
-
return {
|
|
3073
|
+
return {
|
|
3074
|
+
success: true,
|
|
3075
|
+
message: `OTP sent to ${body.contact ?? "contact"}`,
|
|
3076
|
+
expires_in: 300,
|
|
3077
|
+
is_new_account: false
|
|
3078
|
+
};
|
|
3050
3079
|
});
|
|
3051
3080
|
});
|
|
3052
3081
|
app.post("/auth/verify-otp", async (c) => {
|
|
@@ -3064,7 +3093,29 @@ function buildLink(deps) {
|
|
|
3064
3093
|
refresh_token: session.token,
|
|
3065
3094
|
account_id: session.id,
|
|
3066
3095
|
customer_id: customer.customer.id,
|
|
3067
|
-
|
|
3096
|
+
name: customer.customer.name,
|
|
3097
|
+
email: customer.customer.email,
|
|
3098
|
+
phone: customer.customer.phone,
|
|
3099
|
+
message: "Login successful"
|
|
3100
|
+
};
|
|
3101
|
+
});
|
|
3102
|
+
});
|
|
3103
|
+
app.post("/auth/refresh", async (c) => {
|
|
3104
|
+
const body = await c.req.json().catch(() => ({}));
|
|
3105
|
+
return tryRoute(c, () => {
|
|
3106
|
+
const session = deps.auth.ensureSession(body.session_token ?? c.var.session.token);
|
|
3107
|
+
const customer = deps.link.ensureCustomer(session.customer_id ?? session.id);
|
|
3108
|
+
c.header("x-session-token", session.token);
|
|
3109
|
+
return {
|
|
3110
|
+
success: true,
|
|
3111
|
+
session_token: session.token,
|
|
3112
|
+
refresh_token: session.token,
|
|
3113
|
+
account_id: session.id,
|
|
3114
|
+
customer_id: customer.customer.id,
|
|
3115
|
+
name: customer.customer.name,
|
|
3116
|
+
email: customer.customer.email,
|
|
3117
|
+
phone: customer.customer.phone,
|
|
3118
|
+
message: "Session refreshed"
|
|
3068
3119
|
};
|
|
3069
3120
|
});
|
|
3070
3121
|
});
|
|
@@ -3072,9 +3123,24 @@ function buildLink(deps) {
|
|
|
3072
3123
|
"/auth/logout",
|
|
3073
3124
|
(c) => tryRoute(c, () => {
|
|
3074
3125
|
deps.auth.logout(c.var.session.token);
|
|
3075
|
-
return { success: true, message: "Logged out" };
|
|
3126
|
+
return { success: true, message: "Logged out successfully", action: "discard_token" };
|
|
3076
3127
|
})
|
|
3077
3128
|
);
|
|
3129
|
+
app.get("/profile", (c) => tryRoute(c, () => deps.link.getProfile(customerId(c))));
|
|
3130
|
+
app.post("/profile", async (c) => {
|
|
3131
|
+
const body = await c.req.json().catch(() => ({}));
|
|
3132
|
+
return tryRoute(c, () => {
|
|
3133
|
+
const state = deps.link.ensureCustomer(customerId(c));
|
|
3134
|
+
state.customer = {
|
|
3135
|
+
...state.customer,
|
|
3136
|
+
name: body.name ?? state.customer.name,
|
|
3137
|
+
email: body.email ?? state.customer.email,
|
|
3138
|
+
phone: body.phone ?? state.customer.phone,
|
|
3139
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3140
|
+
};
|
|
3141
|
+
return state.customer;
|
|
3142
|
+
});
|
|
3143
|
+
});
|
|
3078
3144
|
app.get("/data", (c) => tryRoute(c, () => deps.link.getLinkData(customerId(c))));
|
|
3079
3145
|
app.post("/check-status", async (c) => {
|
|
3080
3146
|
const body = await c.req.json().catch(() => ({}));
|