@unifiedcommerce/core 0.5.0 → 0.5.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/auth/setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAiBrE;;;;;GAKG;AACH,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC;IACjD,OAAO,EAAE;QACP,UAAU,CAAC,OAAO,YAAY,CAAC;QAC/B,UAAU,CAAC,OAAO,MAAM,CAAC;QACzB,UAAU,CAAC,OAAO,GAAG,CAAC;QACtB,UAAU,CAAC,OAAO,SAAS,CAAC;QAC5B,UAAU,CAAC,OAAO,MAAM,CAAC;QACzB,UAAU,CAAC,OAAO,WAAW,CAAC;KAC/B,CAAC;CACH,CAAC,CAAC,CAAC;AAEJ;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,cAAc,CAAC;AAE1C,wBAAgB,UAAU,CACxB,EAAE,EAAE,eAAe,EACnB,MAAM,EAAE,cAAc,GACrB,YAAY,CAyId"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/auth/setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAiBrE;;;;;GAKG;AACH,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC;IACjD,OAAO,EAAE;QACP,UAAU,CAAC,OAAO,YAAY,CAAC;QAC/B,UAAU,CAAC,OAAO,MAAM,CAAC;QACzB,UAAU,CAAC,OAAO,GAAG,CAAC;QACtB,UAAU,CAAC,OAAO,SAAS,CAAC;QAC5B,UAAU,CAAC,OAAO,MAAM,CAAC;QACzB,UAAU,CAAC,OAAO,WAAW,CAAC;KAC/B,CAAC;CACH,CAAC,CAAC,CAAC;AAEJ;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,cAAc,CAAC;AAE1C,wBAAgB,UAAU,CACxB,EAAE,EAAE,eAAe,EACnB,MAAM,EAAE,cAAc,GACrB,YAAY,CAkHd"}
@@ -60,33 +60,9 @@ export function createAuth(db, config) {
60
60
  provider: resolveAuthDbProvider(db.provider),
61
61
  schema: authSchema,
62
62
  }),
63
- databaseHooks: {
64
- user: {
65
- create: {
66
- after: async (user) => {
67
- // Auto-create customer record on signup. Uses the Drizzle db
68
- // directly because the kernel isn't fully initialized yet during
69
- // auth setup. Best-effort — getByUserId() lazy-creates as fallback.
70
- try {
71
- const { customers } = await import("../kernel/database/schema.js");
72
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
- const drizzle = db.db;
74
- await drizzle.insert(customers).values({
75
- organizationId: "org_default",
76
- userId: user.id,
77
- email: user.email ?? null,
78
- firstName: user.name?.split(" ")[0] ?? null,
79
- lastName: user.name?.split(" ").slice(1).join(" ") ?? null,
80
- metadata: {},
81
- }).onConflictDoNothing();
82
- }
83
- catch {
84
- // Silent — lazy creation in getByUserId() is the fallback
85
- }
86
- },
87
- },
88
- },
89
- },
63
+ // Customer profile creation is handled lazily by CustomerService.getByUserId()
64
+ // which calls getOrCreateByUserId() on first access (checkout, /api/me/profile).
65
+ // No databaseHook needed — admins/staff who sign up don't need customer profiles.
90
66
  trustedOrigins: config.auth?.trustedOrigins ?? [],
91
67
  emailAndPassword: {
92
68
  enabled: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifiedcommerce/core",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
package/src/auth/setup.ts CHANGED
@@ -105,32 +105,9 @@ export function createAuth(
105
105
  provider: resolveAuthDbProvider(db.provider),
106
106
  schema: authSchema,
107
107
  }),
108
- databaseHooks: {
109
- user: {
110
- create: {
111
- after: async (user: { id: string; email?: string | null; name?: string | null }) => {
112
- // Auto-create customer record on signup. Uses the Drizzle db
113
- // directly because the kernel isn't fully initialized yet during
114
- // auth setup. Best-effort — getByUserId() lazy-creates as fallback.
115
- try {
116
- const { customers } = await import("../kernel/database/schema.js");
117
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
118
- const drizzle = db.db as any;
119
- await drizzle.insert(customers).values({
120
- organizationId: "org_default",
121
- userId: user.id,
122
- email: user.email ?? null,
123
- firstName: user.name?.split(" ")[0] ?? null,
124
- lastName: user.name?.split(" ").slice(1).join(" ") ?? null,
125
- metadata: {},
126
- }).onConflictDoNothing();
127
- } catch {
128
- // Silent — lazy creation in getByUserId() is the fallback
129
- }
130
- },
131
- },
132
- },
133
- },
108
+ // Customer profile creation is handled lazily by CustomerService.getByUserId()
109
+ // which calls getOrCreateByUserId() on first access (checkout, /api/me/profile).
110
+ // No databaseHook needed — admins/staff who sign up don't need customer profiles.
134
111
  trustedOrigins: config.auth?.trustedOrigins ?? [],
135
112
  emailAndPassword: {
136
113
  enabled: true,