@shophost/rest-api 2.0.67 → 2.0.69
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/package.json +1 -1
- package/schema.prisma +1 -0
- package/scripts/shophost-rest-api.mjs +198 -1
- package/src/bootstrap.js +1 -1
- package/src/container.js +1 -1
- package/src/core/auth/auth.schema.js +1 -1
- package/src/core/auth/auth.util.js +1 -1
- package/src/core/auth/better-auth.lib.js +1 -1
- package/src/core/auth/generate-password-hash.util.js +1 -1
- package/src/core/auth/headers.schema.js +1 -1
- package/src/core/auth/user.schema.js +1 -1
- package/src/core/db/__generated__/client/browser.js +1 -1
- package/src/core/db/__generated__/client/client.js +1 -1
- package/src/core/db/__generated__/client/enums.js +1 -1
- package/src/core/db/__generated__/client/internal/class.js +789 -1
- package/src/core/db/__generated__/client/internal/prismaNamespace.d.ts +1 -0
- package/src/core/db/__generated__/client/internal/prismaNamespace.js +1 -1
- package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.d.ts +1 -0
- package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +1 -1
- package/src/core/db/__generated__/client/models/OrganizationConfiguration.d.ts +41 -1
- package/src/core/db/index.js +1 -1
- package/src/core/email/components.js +1 -1
- package/src/core/exceptions/http-exception.js +1 -1
- package/src/core/hono/hono.js +1 -1
- package/src/core/lib/prisma.js +1 -1
- package/src/core/logging/pino.js +1 -1
- package/src/core/notifications/email.service.js +1 -1
- package/src/core/openapi/openapi.lib.js +1 -1
- package/src/core/utils/currency.util.js +1 -1
- package/src/core/utils/env.util.js +1 -1
- package/src/core/utils/object.util.js +1 -1
- package/src/core/utils/translations.util.js +1 -1
- package/src/core/utils/zod.util.js +1 -1
- package/src/db.js +1 -1
- package/src/features/access/access.handler.js +1 -1
- package/src/features/access/access.route.js +1 -1
- package/src/features/access/access.schema.js +1 -1
- package/src/features/access/access.service.js +1 -1
- package/src/features/analytics/analytics.handler.js +1 -1
- package/src/features/analytics/analytics.route.js +1 -1
- package/src/features/analytics/analytics.schema.js +1 -1
- package/src/features/analytics/analytics.service.js +1 -1
- package/src/features/cart/cart.handler.js +1 -1
- package/src/features/cart/cart.route.js +1 -1
- package/src/features/cart/cart.schema.js +1 -1
- package/src/features/cart/cart.service.js +1 -1
- package/src/features/cart/cart.util.js +1 -1
- package/src/features/customer/customer.handler.js +1 -1
- package/src/features/customer/customer.route.js +1 -1
- package/src/features/customer/customer.schema.js +1 -1
- package/src/features/customer/customer.service.js +1 -1
- package/src/features/file/file.handler.js +1 -1
- package/src/features/file/file.route.js +1 -1
- package/src/features/file/file.schema.js +1 -1
- package/src/features/file/file.service.js +1 -1
- package/src/features/health/health.handler.js +1 -1
- package/src/features/health/health.route.js +1 -1
- package/src/features/index.js +1 -1
- package/src/features/integration/integration-config.js +1 -1
- package/src/features/integration/integration-registry.js +1 -1
- package/src/features/integration/integration.handler.js +1 -1
- package/src/features/integration/integration.route.js +1 -1
- package/src/features/integration/integration.schema.js +1 -1
- package/src/features/integration/integration.service.js +1 -1
- package/src/features/inventory/inventory.service.js +1 -1
- package/src/features/location/location.handler.js +1 -1
- package/src/features/location/location.route.js +1 -1
- package/src/features/location/location.schema.js +1 -1
- package/src/features/location/location.service.js +1 -1
- package/src/features/manufacturer/manufacturer.handler.js +1 -1
- package/src/features/manufacturer/manufacturer.route.js +1 -1
- package/src/features/manufacturer/manufacturer.schema.js +1 -1
- package/src/features/manufacturer/manufacturer.service.js +1 -1
- package/src/features/order/emails/order-confirmation.email.js +1 -1
- package/src/features/order/emails/order-notification.email.js +1 -1
- package/src/features/order/fulfilment.schema.js +1 -1
- package/src/features/order/order-fulfillment.service.js +1 -1
- package/src/features/order/order.handler.js +1 -1
- package/src/features/order/order.route.js +1 -1
- package/src/features/order/order.schema.js +1 -1
- package/src/features/order/order.service.js +1 -1
- package/src/features/order/recipient.schema.js +1 -1
- package/src/features/organization/legal-entity.schema.js +1 -1
- package/src/features/organization/organization-configuration.schema.d.ts +2 -0
- package/src/features/organization/organization-configuration.schema.js +1 -1
- package/src/features/organization/organization.handler.js +1 -1
- package/src/features/organization/organization.route.d.ts +5 -0
- package/src/features/organization/organization.route.js +1 -1
- package/src/features/organization/organization.schema.d.ts +2 -0
- package/src/features/organization/organization.schema.js +1 -1
- package/src/features/organization/organization.service.d.ts +4 -0
- package/src/features/organization/organization.service.js +1 -1
- package/src/features/payment/payment-webhook.service.js +1 -1
- package/src/features/payment/payment.handler.js +1 -1
- package/src/features/payment/payment.route.js +1 -1
- package/src/features/payment/payment.schema.js +1 -1
- package/src/features/payment/payment.service.js +1 -1
- package/src/features/payment/stripe.service.js +1 -1
- package/src/features/product/product-modifier.schema.js +1 -1
- package/src/features/product/product.handler.js +1 -1
- package/src/features/product/product.route.js +1 -1
- package/src/features/product/product.schema.js +1 -1
- package/src/features/product/product.service.js +1 -1
- package/src/features/product-category/product-category.handler.js +1 -1
- package/src/features/product-category/product-category.route.js +1 -1
- package/src/features/product-category/product-category.schema.js +1 -1
- package/src/features/product-category/product-category.service.js +1 -1
- package/src/features/reservation/emails/reservation-cancellation.email.js +1 -1
- package/src/features/reservation/emails/reservation-confirmation.email.js +1 -1
- package/src/features/reservation/emails/reservation-email-date.d.ts +2 -0
- package/src/features/reservation/emails/reservation-email-date.js +1 -0
- package/src/features/reservation/emails/reservation-notification.email.js +1 -1
- package/src/features/reservation/emails/reservation-updated.email.js +1 -1
- package/src/features/reservation/reservation.handler.js +1 -1
- package/src/features/reservation/reservation.route.js +1 -1
- package/src/features/reservation/reservation.schema.js +1 -1
- package/src/features/reservation/reservation.service.js +1 -1
- package/src/features/shipping/shipping.handler.js +1 -1
- package/src/features/shipping/shipping.route.js +1 -1
- package/src/features/shipping/shipping.service.js +1 -1
- package/src/features/shipping-method/shipping-method.handler.js +1 -1
- package/src/features/shipping-method/shipping-method.route.js +1 -1
- package/src/features/shipping-method/shipping-method.schema.js +1 -1
- package/src/features/shipping-method/shipping-method.service.js +1 -1
- package/src/features/shipping-method/shipping-zone.schema.js +1 -1
- package/src/features/webhook/webhook.handler.js +1 -1
- package/src/features/webhook/webhook.route.js +1 -1
- package/src/index.js +1 -1
- package/src/integrations/next.js +1 -1
- package/src/schemas/address.schema.js +1 -1
- package/src/schemas/currency.schema.js +1 -1
- package/src/schemas/error.schema.js +1 -1
- package/src/schemas/index.d.ts +1 -0
- package/src/schemas/index.js +1 -1
- package/src/schemas/locales.schema.js +1 -1
- package/src/schemas/number.schema.js +1 -1
- package/src/schemas/pagination.schema.js +1 -1
- package/src/schemas/params.schema.js +1 -1
- package/src/schemas/queries.schema.js +1 -1
- package/src/schemas/time-zone.schema.d.ts +9 -0
- package/src/schemas/time-zone.schema.js +1 -0
package/package.json
CHANGED
package/schema.prisma
CHANGED
|
@@ -328,6 +328,7 @@ model OrganizationConfiguration {
|
|
|
328
328
|
isAcceptingReservations Boolean? @default(false)
|
|
329
329
|
defaultCurrency Currency @default(USD)
|
|
330
330
|
defaultLocale Locale @default(en)
|
|
331
|
+
defaultTimeZone String @default("Europe/Warsaw")
|
|
331
332
|
supportedLocales Locale[] @default([en])
|
|
332
333
|
openingTimesId String? @unique
|
|
333
334
|
openingTimes OpeningTimes? @relation(fields: [openingTimesId], references: [id])
|
|
@@ -1,2 +1,199 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import dotenv from "dotenv";
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const packageRoot = join(__dirname, "..");
|
|
11
|
+
const schemaPath = join(packageRoot, "schema.prisma");
|
|
12
|
+
const configPath = join(packageRoot, "prisma.config.ts");
|
|
13
|
+
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
const RESERVED_FLAGS = ["--schema", "--config"];
|
|
16
|
+
|
|
17
|
+
function printHelp() {
|
|
18
|
+
console.log(`shophost-rest-api
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
shophost-rest-api db push [prisma-db-push-options]
|
|
22
|
+
|
|
23
|
+
Examples:
|
|
24
|
+
shophost-rest-api db push
|
|
25
|
+
shophost-rest-api db push --accept-data-loss
|
|
26
|
+
shophost-rest-api db push --url "postgres://..."
|
|
27
|
+
|
|
28
|
+
Environment:
|
|
29
|
+
.env.local
|
|
30
|
+
.env
|
|
31
|
+
DATABASE_URL
|
|
32
|
+
DATABASE_URL
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getPrismaCliPath() {
|
|
37
|
+
try {
|
|
38
|
+
return require.resolve("prisma/build/index.js");
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error("Could not resolve the Prisma CLI from @shophost/rest-api.");
|
|
41
|
+
console.error(
|
|
42
|
+
"Reinstall dependencies and make sure the package was installed correctly."
|
|
43
|
+
);
|
|
44
|
+
if (error instanceof Error && error.message) {
|
|
45
|
+
console.error(error.message);
|
|
46
|
+
}
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getDbPushArgs(argv) {
|
|
52
|
+
if (argv[0] !== "db" || argv[1] !== "push") {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return argv.slice(2);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function expandEnvValue(value, env) {
|
|
60
|
+
return value.replace(
|
|
61
|
+
/\\?\$(?:\{([A-Za-z_][A-Za-z0-9_]*)\}|([A-Za-z_][A-Za-z0-9_]*))/g,
|
|
62
|
+
(match, bracedName, plainName) => {
|
|
63
|
+
if (match.startsWith("\\")) {
|
|
64
|
+
return match.slice(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const variableName = bracedName ?? plainName;
|
|
68
|
+
return env[variableName] ?? "";
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function applyParsedEnv(parsed, shouldOverride) {
|
|
74
|
+
if (!parsed) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
for (const [key, rawValue] of Object.entries(parsed)) {
|
|
79
|
+
if (!shouldOverride && process.env[key] !== undefined) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
process.env[key] = expandEnvValue(rawValue, process.env);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function loadEnvFiles() {
|
|
88
|
+
for (const envFile of [".env", ".env.local"]) {
|
|
89
|
+
const envPath = join(process.cwd(), envFile);
|
|
90
|
+
|
|
91
|
+
if (!existsSync(envPath)) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const result = dotenv.config({
|
|
96
|
+
path: envPath,
|
|
97
|
+
override: envFile === ".env.local",
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
applyParsedEnv(result.parsed, envFile === ".env.local");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const argv = process.argv.slice(2);
|
|
105
|
+
|
|
106
|
+
if (
|
|
107
|
+
argv.length === 0 ||
|
|
108
|
+
(argv.length === 1 && (argv[0] === "--help" || argv[0] === "-h"))
|
|
109
|
+
) {
|
|
110
|
+
printHelp();
|
|
111
|
+
process.exit(0);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const dbPushArgs = getDbPushArgs(argv);
|
|
115
|
+
|
|
116
|
+
if (!dbPushArgs) {
|
|
117
|
+
console.error(`Unknown command: ${argv.join(" ")}`);
|
|
118
|
+
printHelp();
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const reservedFlag = dbPushArgs.find(
|
|
123
|
+
(arg) =>
|
|
124
|
+
RESERVED_FLAGS.includes(arg) ||
|
|
125
|
+
RESERVED_FLAGS.some((flag) => arg.startsWith(`${flag}=`))
|
|
126
|
+
);
|
|
127
|
+
const isDbPushHelp = dbPushArgs.includes("--help") || dbPushArgs.includes("-h");
|
|
128
|
+
|
|
129
|
+
if (reservedFlag) {
|
|
130
|
+
console.error(
|
|
131
|
+
`${reservedFlag} is managed by this CLI. Use \`--url\` to point at a different database.`
|
|
132
|
+
);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
loadEnvFiles();
|
|
137
|
+
|
|
138
|
+
if (!existsSync(schemaPath)) {
|
|
139
|
+
console.error(`Missing Prisma schema at ${schemaPath}`);
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!existsSync(configPath)) {
|
|
144
|
+
console.error(`Missing Prisma config at ${configPath}`);
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const hasUrlOverride = dbPushArgs.some(
|
|
149
|
+
(arg, index) =>
|
|
150
|
+
arg === "--url" ||
|
|
151
|
+
arg.startsWith("--url=") ||
|
|
152
|
+
(index > 0 && dbPushArgs[index - 1] === "--url")
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
if (
|
|
156
|
+
!isDbPushHelp &&
|
|
157
|
+
!hasUrlOverride &&
|
|
158
|
+
!process.env.DATABASE_URL &&
|
|
159
|
+
!process.env.DATABASE_URL
|
|
160
|
+
) {
|
|
161
|
+
console.error(
|
|
162
|
+
"Set DATABASE_URL or DATABASE_URL, or add it to `.env.local` / `.env`, before running `shophost-rest-api db push`."
|
|
163
|
+
);
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const prismaCliPath = getPrismaCliPath();
|
|
168
|
+
const child = spawn(
|
|
169
|
+
process.execPath,
|
|
170
|
+
[
|
|
171
|
+
prismaCliPath,
|
|
172
|
+
"db",
|
|
173
|
+
"push",
|
|
174
|
+
"--schema",
|
|
175
|
+
schemaPath,
|
|
176
|
+
"--config",
|
|
177
|
+
configPath,
|
|
178
|
+
...dbPushArgs,
|
|
179
|
+
],
|
|
180
|
+
{
|
|
181
|
+
cwd: process.cwd(),
|
|
182
|
+
env: process.env,
|
|
183
|
+
stdio: "inherit",
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
child.on("exit", (code, signal) => {
|
|
188
|
+
if (signal) {
|
|
189
|
+
process.kill(process.pid, signal);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
process.exit(code ?? 1);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
child.on("error", (error) => {
|
|
197
|
+
console.error(error);
|
|
198
|
+
process.exit(1);
|
|
199
|
+
});
|
package/src/bootstrap.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{__awaiter as i}from"tslib";import{cors as c}from"hono/cors";import{createContainer as p}from"./container";import{createApiRouter as H,createUnavailableAuth as h,handleAppError as m}from"./core/hono/hono";import{registerAccessHandlers as y,registerAnalyticsHandlers as v,registerCartHandlers as f,registerCustomerHandlers as C,registerFileHandlers as O,registerHealthHandlers as A,registerIntegrationHandlers as T,registerLocationHandlers as b,registerManufacturerHandlers as P,registerOrderHandlers as R,registerOrganizationHandlers as E,registerPaymentHandlers as w,registerProductCategoryHandlers as S,registerProductHandlers as q,registerReservationHandlers as M,registerShippingHandlers as j,registerShippingMethodHandlers as k,registerWebhookHandlers as z}from"./features";const L={allowHeaders:["Content-Type","Authorization","X-Requested-With","Accept","Origin","X-CSRF-Token"],allowMethods:["GET","POST","PUT","DELETE","OPTIONS","PATCH"],credentials:!0,exposeHeaders:["Content-Length","X-Kuma-Revision"],origin:["http://localhost:3000"]};export const bootstrap=({corsOptions:a,maps:n,payment:d,prisma:u,resolveAuth:l=()=>h()}={})=>{const e=H(),r=p({maps:n,payment:d,prisma:u}),g=r.integrationRegistry.ready();return e.use("*",c(Object.assign(Object.assign({},L),a))),e.use("*",(t,o)=>i(void 0,void 0,void 0,function*(){yield g,yield o()})),e.use("*",(t,o)=>i(void 0,void 0,void 0,function*(){const s=l(t.req.raw,t.req.path);t.set("auth",s),Object.assign(t.req.raw,{auth:s}),yield o()})),e.onError(t=>m(t)),e.route("/",A()),e.route("/",v(r.analytics)),e.route("/",P(r.manufacturer)),e.route("/",T(r.integration)),e.route("/",E(r.organization)),e.route("/",O(r.file)),e.route("/",S(r.productCategory)),e.route("/",q(r.product)),e.route("/",y(r.access)),e.route("/",k(r.shippingMethod)),e.route("/",R(r.order)),e.route("/",f(r.cart)),e.route("/",C(r.customer)),e.route("/",j(r.shipping)),e.route("/",b(r.location)),e.route("/",w(r.payment)),e.route("/",z(r.paymentWebhook)),e.route("/",M(r.reservation)),e};
|
package/src/container.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{EmailService as p}from"./core/notifications/email.service";import{AccessService as u}from"./features/access/access.service";import{AnalyticsService as a}from"./features/analytics/analytics.service";import{CartService as d}from"./features/cart/cart.service";import{CustomerService as y}from"./features/customer/customer.service";import{FileService as h}from"./features/file/file.service";import{IntegrationRegistry as s}from"./features/integration/integration-registry";import{IntegrationService as k}from"./features/integration/integration.service";import{InventoryService as C}from"./features/inventory/inventory.service";import{LocationService as P}from"./features/location/location.service";import{ManufacturerService as b}from"./features/manufacturer/manufacturer.service";import{OrderFulfillmentService as F}from"./features/order/order-fulfillment.service";import{OrderService as I}from"./features/order/order.service";import{OrganizationService as M}from"./features/organization/organization.service";import{PaymentWebhookService as O}from"./features/payment/payment-webhook.service";import{PaymentService as R}from"./features/payment/payment.service";import{StripeService as W}from"./features/payment/stripe.service";import{ProductCategoryService as z}from"./features/product-category/product-category.service";import{ProductService as A}from"./features/product/product.service";import{ReservationService as x}from"./features/reservation/reservation.service";import{ShippingMethodService as E}from"./features/shipping-method/shipping-method.service";import{ShippingService as L}from"./features/shipping/shipping.service";const _=({maps:r,payment:i,prisma:e}={})=>{var n;const c=!((n=r?.google)===null||n===void 0)&&n.key?new P(r.google.key):null,v=new C(e),o=new s(e),t=new p(o),m=new W(o),S=new R(e,i??{},m),f=new d(e,v),l=new I(e,S,f,t),w=new F(v,l),g=new O(e,m,w);return{access:new u(e),analytics:new a(e),cart:f,customer:new y(e),email:t,file:new h(e),inventory:v,integration:new k(e,o,t,m),integrationRegistry:o,location:c,manufacturer:new b(e),order:l,organization:new M(e,c),payment:S,product:new A(e),productCategory:new z(e),reservation:new x(e,t),shipping:new L(e,c),shippingMethod:new E(e),paymentWebhook:g}};export{_ as createContainer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{z as e}from"@hono/zod-openapi";export const SignUpSchema=e.object({email:e.string().min(1,"Email is required").email("Invalid email").openapi({example:"user@example.com",description:"User's email address"}),password:e.string().min(1,"Password is required").min(8,"Password must be more than 8 characters").max(32,"Password must be less than 32 characters").openapi({example:"password123",description:"User's password"}),firstname:e.string().min(1,"First name is required").max(32,"First name must be less than 32 characters").openapi({example:"John",description:"User's first name"}),lastname:e.string().min(1,"Last name is required").max(32,"Last name must be less than 32 characters").openapi({example:"Doe",description:"User's last name"})}).openapi("SignUp"),SignInSchema=SignUpSchema.pick({email:!0,password:!0}).openapi("SignIn");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{__awaiter as d}from"tslib";import{HttpException as n}from"../exceptions/http-exception";import{logger as u}from"../logging/pino";export const getCurrentUser=r=>i=>d(void 0,void 0,void 0,function*(){const e=yield r.api.getSession({headers:i});if(!e?.user)throw new n(401,"Unauthorized");return e.user}),isGranted=r=>(i,e,s)=>d(void 0,void 0,void 0,function*(){if(!s)throw new Error("Resource and access level are required");const o=yield r.api.getSession({headers:i});if(!o?.user)throw new n(401,"Unauthorized");const t=yield r.api.hasPermission({headers:i,body:{organizationId:e,permissions:{project:[s]}}});if(!t.success)throw u.error({organizationId:e,accessLevel:s,message:"User does not have permission",userId:o.user.id,hasPermission:t}),new n(403,"Forbidden");return o.user});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{betterAuth as l}from"better-auth";import{prismaAdapter as d}from"better-auth/adapters/prisma";import{nextCookies as c}from"better-auth/next-js";import{openAPI as p,organization as u}from"better-auth/plugins";import{createAccessControl as m}from"better-auth/plugins/access";import{getCurrentUser as g,isGranted as f}from"./auth.util";const b={project:["create","read","update","delete"],organization:["create","read","update","delete"]},e=m(b),C=e.newRole({project:["read"]}),h=e.newRole({project:["read"]}),j=e.newRole({project:["create","read","update","delete"]}),w=e.newRole({project:["create","read","update","delete"],organization:["update"]}),A=e.newRole({project:["create","read","update","delete"],organization:["update","delete"]});export const createAuthClient=({prisma:n,baseURL:s,domain:r,trustedOrigins:i,socialProviders:t})=>{const o=l({baseURL:s,database:d(n,{provider:"postgresql"}),trustedOrigins:i,user:{additionalFields:{firstname:{type:"string",required:!0},lastname:{type:"string",required:!0}}},advanced:{crossSubDomainCookies:{enabled:!0,domain:r},useSecureCookies:r!=="localhost",defaultCookieAttributes:{path:"/",sameSite:"lax",httpOnly:!0,secure:r!=="localhost"}},emailAndPassword:{enabled:!0},socialProviders:Object.assign({},t?.google?{google:{prompt:"select_account",clientId:t.google.clientId,clientSecret:t.google.clientSecret,mapProfileToUser:a=>({firstname:a.given_name,lastname:a.family_name})}}:{}),plugins:[p(),c(),u({ac:e,roles:{member:h,readOnly:C,manager:j,admin:w,owner:A}})]});return{auth:o,getCurrentUser:g(o),isGranted:f(o)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{__awaiter as a}from"tslib";import e from"crypto";function f(){return new Promise((o,n)=>e.randomBytes(32,(t,r)=>t?n(t):o(r)))}function h(o,n){return new Promise((t,r)=>e.pbkdf2(o,n,25e3,512,"sha256",(s,i)=>s?r(s):t(i)))}export function generatePasswordSaltHash(o){return a(this,void 0,void 0,function*(){const t=(yield f()).toString("hex");return{hash:(yield h(o,t)).toString("hex"),salt:t}})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{z as e}from"@hono/zod-openapi";export const HeaderSchema=e.object({"accept-language":e.string().optional().openapi({example:"en-US",description:"Accept-Language header",param:{in:"header",name:"accept-language"}}),cookie:e.string().optional().openapi({example:"session=1234567890",description:"Cookie header",param:{in:"header",name:"cookie"}})}).openapi("Headers");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{z as e}from"@hono/zod-openapi";export const UserSchema=e.object({id:e.string().openapi({example:"clm1234567890abcdef",description:"User's ID"}),email:e.string().openapi({example:"user@example.com",description:"User's email address",format:"email"}),firstname:e.string().openapi({example:"John",description:"User's first name"}),lastname:e.string().openapi({example:"Doe",description:"User's last name"}),image:e.string().nullable().optional().openapi({example:"https://example.com/image.jpg",description:"User's profile image"}),name:e.string().nullable().optional().openapi({description:"User's full name (optional)"})}).openapi("User");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import*as r from"./internal/prismaNamespaceBrowser";export{r as Prisma};export*as $Enums from"./enums";export*from"./enums";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import*as r from"node:path";import{fileURLToPath as m}from"node:url";globalThis.__dirname=r.dirname(m(import.meta.url));import*as o from"./internal/class";import*as t from"./internal/prismaNamespace";export*as $Enums from"./enums";export*from"./enums";export const PrismaClient=o.getPrismaClientClass();export{t as Prisma};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export const FileUploadStatus={pending:"pending",completed:"completed",failed:"failed"},Locale={af:"af",sq:"sq",ar_dz:"ar_dz",ar_bh:"ar_bh",ar_eg:"ar_eg",ar_iq:"ar_iq",ar_jo:"ar_jo",ar_kw:"ar_kw",ar_lb:"ar_lb",ar_ly:"ar_ly",ar_ma:"ar_ma",ar_om:"ar_om",ar_qa:"ar_qa",ar_sa:"ar_sa",ar_sy:"ar_sy",ar_tn:"ar_tn",ar_ae:"ar_ae",ar_ye:"ar_ye",eu:"eu",be:"be",bg:"bg",ca:"ca",zh_hk:"zh_hk",zh_cn:"zh_cn",zh_sg:"zh_sg",zh_tw:"zh_tw",hr:"hr",cs:"cs",da:"da",nl_be:"nl_be",nl:"nl",en:"en",en_au:"en_au",en_bz:"en_bz",en_ca:"en_ca",en_ie:"en_ie",en_jm:"en_jm",en_nz:"en_nz",en_za:"en_za",en_tt:"en_tt",en_gb:"en_gb",en_us:"en_us",et:"et",fo:"fo",fa:"fa",fi:"fi",fr_be:"fr_be",fr_ca:"fr_ca",fr_lu:"fr_lu",fr:"fr",fr_ch:"fr_ch",gd:"gd",de_at:"de_at",de_li:"de_li",de_lu:"de_lu",de:"de",de_ch:"de_ch",el:"el",he:"he",hi:"hi",hu:"hu",is:"is",id:"id",ga:"ga",it:"it",it_ch:"it_ch",ja:"ja",ko:"ko",ku:"ku",lv:"lv",lt:"lt",mk:"mk",ml:"ml",ms:"ms",mt:"mt",no:"no",nb:"nb",nn:"nn",pl:"pl",pt_br:"pt_br",pt:"pt",pa:"pa",rm:"rm",ro:"ro",ro_md:"ro_md",ru:"ru",ru_md:"ru_md",sr:"sr",sk:"sk",sl:"sl",sb:"sb",es_ar:"es_ar",es_bo:"es_bo",es_cl:"es_cl",es_co:"es_co",es_cr:"es_cr",es_do:"es_do",es_ec:"es_ec",es_sv:"es_sv",es_gt:"es_gt",es_hn:"es_hn",es_mx:"es_mx",es:"es",sv:"sv",sv_fi:"sv_fi",th:"th",tr:"tr",uk:"uk",ur:"ur",vi:"vi",cy:"cy",ji:"ji",zu:"zu"},Currency={USD:"USD",EUR:"EUR",GBP:"GBP",JPY:"JPY",AUD:"AUD",CAD:"CAD",CHF:"CHF",CNY:"CNY",SEK:"SEK",NZD:"NZD",MXN:"MXN",SGD:"SGD",HKD:"HKD",NOK:"NOK",KRW:"KRW",TRY:"TRY",RUB:"RUB",INR:"INR",BRL:"BRL",ZAR:"ZAR",DKK:"DKK",PLN:"PLN",THB:"THB",IDR:"IDR",HUF:"HUF",CZK:"CZK",ILS:"ILS",PHP:"PHP",AED:"AED",COP:"COP",SAR:"SAR",MYR:"MYR",RON:"RON"},OrderFulfilmentMethod={delivery:"delivery",pickup:"pickup"},OrderStatus={draft:"draft",pending:"pending",confirmed:"confirmed",completed:"completed",cancelled:"cancelled"},PaymentStatus={pending:"pending",succeeded:"succeeded",refunded:"refunded",failed:"failed",canceled:"canceled"},PaymentProvider={stripe:"stripe",revolut:"revolut",payu:"payu",not_applicable:"not_applicable"},PaymentMethod={card:"card",blik:"blik",paypal:"paypal",bank_transfer:"bank_transfer",cash_on_delivery:"cash_on_delivery"},CampaignType={discount:"discount",promotion:"promotion"};
|