@multitenantkit/adapter-persistence-supabase 0.2.1
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/README.md +225 -0
- package/dist/client/SupabaseClient.d.ts +29 -0
- package/dist/client/SupabaseClient.d.ts.map +1 -0
- package/dist/client/SupabaseClient.js +36 -0
- package/dist/client/SupabaseClient.js.map +1 -0
- package/dist/factory/SupabaseFactory.d.ts +45 -0
- package/dist/factory/SupabaseFactory.d.ts.map +1 -0
- package/dist/factory/SupabaseFactory.js +33 -0
- package/dist/factory/SupabaseFactory.js.map +1 -0
- package/dist/factory/UseCaseFactory.d.ts +26 -0
- package/dist/factory/UseCaseFactory.d.ts.map +1 -0
- package/dist/factory/UseCaseFactory.js +76 -0
- package/dist/factory/UseCaseFactory.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/mappers/OrganizationMapper.d.ts +47 -0
- package/dist/mappers/OrganizationMapper.d.ts.map +1 -0
- package/dist/mappers/OrganizationMapper.js +56 -0
- package/dist/mappers/OrganizationMapper.js.map +1 -0
- package/dist/mappers/OrganizationMembershipMapper.d.ts +59 -0
- package/dist/mappers/OrganizationMembershipMapper.d.ts.map +1 -0
- package/dist/mappers/OrganizationMembershipMapper.js +78 -0
- package/dist/mappers/OrganizationMembershipMapper.js.map +1 -0
- package/dist/mappers/UserMapper.d.ts +53 -0
- package/dist/mappers/UserMapper.d.ts.map +1 -0
- package/dist/mappers/UserMapper.js +62 -0
- package/dist/mappers/UserMapper.js.map +1 -0
- package/dist/repositories/SupabaseOrganizationMembershipRepository.d.ts +33 -0
- package/dist/repositories/SupabaseOrganizationMembershipRepository.d.ts.map +1 -0
- package/dist/repositories/SupabaseOrganizationMembershipRepository.js +239 -0
- package/dist/repositories/SupabaseOrganizationMembershipRepository.js.map +1 -0
- package/dist/repositories/SupabaseOrganizationRepository.d.ts +33 -0
- package/dist/repositories/SupabaseOrganizationRepository.d.ts.map +1 -0
- package/dist/repositories/SupabaseOrganizationRepository.js +150 -0
- package/dist/repositories/SupabaseOrganizationRepository.js.map +1 -0
- package/dist/repositories/SupabaseUserRepository.d.ts +60 -0
- package/dist/repositories/SupabaseUserRepository.d.ts.map +1 -0
- package/dist/repositories/SupabaseUserRepository.js +168 -0
- package/dist/repositories/SupabaseUserRepository.js.map +1 -0
- package/dist/system/WebClock.d.ts +17 -0
- package/dist/system/WebClock.d.ts.map +1 -0
- package/dist/system/WebClock.js +18 -0
- package/dist/system/WebClock.js.map +1 -0
- package/dist/system/WebCryptoUuid.d.ts +21 -0
- package/dist/system/WebCryptoUuid.d.ts.map +1 -0
- package/dist/system/WebCryptoUuid.js +22 -0
- package/dist/system/WebCryptoUuid.js.map +1 -0
- package/dist/system/index.d.ts +3 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/system/index.js +3 -0
- package/dist/system/index.js.map +1 -0
- package/package.json +68 -0
package/README.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# @multitenantkit/adapter-persistence-supabase
|
|
2
|
+
|
|
3
|
+
Supabase persistence adapter for MultiTenantKit. Works in both **Node.js** and **Deno/Edge Functions** environments.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 Uses `@supabase/supabase-js` client
|
|
8
|
+
- 🦕 Deno/Edge Functions compatible
|
|
9
|
+
- 📦 No Node.js-specific APIs (`node:crypto`, `node:fs`, etc.)
|
|
10
|
+
- 🔄 Full CRUD operations for Users, Organizations, and OrganizationMemberships
|
|
11
|
+
- 🎨 Custom fields support with column mapping
|
|
12
|
+
- 📄 Pagination support
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @multitenantkit/adapter-persistence-supabase @supabase/supabase-js
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Quick Start (Recommended)
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import {
|
|
26
|
+
createSupabaseAdapters,
|
|
27
|
+
createUseCases
|
|
28
|
+
} from '@multitenantkit/adapter-persistence-supabase';
|
|
29
|
+
import { createClient } from '@supabase/supabase-js';
|
|
30
|
+
|
|
31
|
+
// Create Supabase client
|
|
32
|
+
const client = createClient(
|
|
33
|
+
process.env.SUPABASE_URL!,
|
|
34
|
+
process.env.SUPABASE_SERVICE_ROLE_KEY!
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Create all adapters (persistence + system)
|
|
38
|
+
const adapters = createSupabaseAdapters({ client });
|
|
39
|
+
|
|
40
|
+
// Create use cases
|
|
41
|
+
const useCases = createUseCases(adapters);
|
|
42
|
+
|
|
43
|
+
// Use the API
|
|
44
|
+
const result = await useCases.users.createUser.execute(
|
|
45
|
+
{ externalId: 'user-123', username: 'john@example.com' },
|
|
46
|
+
{ requestId: 'req-1', externalId: 'system' }
|
|
47
|
+
);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### In Supabase Edge Functions (Deno)
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
// supabase/functions/api/index.ts
|
|
54
|
+
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2';
|
|
55
|
+
import {
|
|
56
|
+
createSupabaseAdapters,
|
|
57
|
+
createUseCases
|
|
58
|
+
} from 'https://esm.sh/@multitenantkit/adapter-persistence-supabase';
|
|
59
|
+
|
|
60
|
+
Deno.serve(async (req) => {
|
|
61
|
+
const client = createClient(
|
|
62
|
+
Deno.env.get('SUPABASE_URL')!,
|
|
63
|
+
Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const adapters = createSupabaseAdapters({ client });
|
|
67
|
+
const useCases = createUseCases(adapters);
|
|
68
|
+
|
|
69
|
+
// Handle requests...
|
|
70
|
+
const user = await useCases.users.getUser.execute(
|
|
71
|
+
{ userId: 'user-123' },
|
|
72
|
+
{ requestId: 'req-1', externalId: 'system' }
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return new Response(JSON.stringify(user), {
|
|
76
|
+
headers: { 'Content-Type': 'application/json' }
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Using Repositories Directly
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { createSupabaseClient, createSupabaseRepositories } from '@multitenantkit/adapter-persistence-supabase';
|
|
85
|
+
|
|
86
|
+
// Create Supabase client
|
|
87
|
+
const client = createSupabaseClient({
|
|
88
|
+
url: process.env.SUPABASE_URL!,
|
|
89
|
+
serviceRoleKey: process.env.SUPABASE_SERVICE_ROLE_KEY!
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Create repositories
|
|
93
|
+
const { userRepository, organizationRepository, organizationMembershipRepository } = createSupabaseRepositories({
|
|
94
|
+
client
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Use repositories
|
|
98
|
+
const user = await userRepository.findByExternalId('user-123');
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### With Custom Fields and Column Mapping
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { createSupabaseRepositories } from '@multitenantkit/adapter-persistence-supabase';
|
|
105
|
+
|
|
106
|
+
type UserCustomFields = {
|
|
107
|
+
plan: 'free' | 'pro' | 'enterprise';
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const repos = createSupabaseRepositories<UserCustomFields>({
|
|
111
|
+
client,
|
|
112
|
+
toolkitOptions: {
|
|
113
|
+
namingStrategy: 'snake_case',
|
|
114
|
+
users: {
|
|
115
|
+
database: {
|
|
116
|
+
schema: 'auth',
|
|
117
|
+
table: 'users'
|
|
118
|
+
},
|
|
119
|
+
customFields: {
|
|
120
|
+
customSchema: z.object({
|
|
121
|
+
plan: z.enum(['free', 'pro', 'enterprise'])
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Using Repositories Directly (Deno)
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// Alternative: use repositories directly without use cases
|
|
133
|
+
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2';
|
|
134
|
+
import { SupabaseUserRepository } from 'https://esm.sh/@multitenantkit/adapter-persistence-supabase';
|
|
135
|
+
|
|
136
|
+
Deno.serve(async (req) => {
|
|
137
|
+
const client = createClient(
|
|
138
|
+
Deno.env.get('SUPABASE_URL')!,
|
|
139
|
+
Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const userRepo = new SupabaseUserRepository(client);
|
|
143
|
+
const user = await userRepo.findByExternalId('user-123');
|
|
144
|
+
|
|
145
|
+
return new Response(JSON.stringify(user), {
|
|
146
|
+
headers: { 'Content-Type': 'application/json' }
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Database Schema
|
|
152
|
+
|
|
153
|
+
This adapter expects the following tables in your Supabase database:
|
|
154
|
+
|
|
155
|
+
### users
|
|
156
|
+
|
|
157
|
+
```sql
|
|
158
|
+
create table users (
|
|
159
|
+
id uuid primary key,
|
|
160
|
+
external_id text unique not null,
|
|
161
|
+
username text not null,
|
|
162
|
+
created_at timestamptz not null default now(),
|
|
163
|
+
updated_at timestamptz not null default now(),
|
|
164
|
+
deleted_at timestamptz
|
|
165
|
+
);
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### organizations
|
|
169
|
+
|
|
170
|
+
```sql
|
|
171
|
+
create table organizations (
|
|
172
|
+
id uuid primary key,
|
|
173
|
+
owner_user_id uuid references users(id),
|
|
174
|
+
created_at timestamptz not null default now(),
|
|
175
|
+
updated_at timestamptz not null default now(),
|
|
176
|
+
deleted_at timestamptz
|
|
177
|
+
);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### organization_memberships
|
|
181
|
+
|
|
182
|
+
```sql
|
|
183
|
+
create table organization_memberships (
|
|
184
|
+
id uuid primary key,
|
|
185
|
+
user_id uuid references users(id),
|
|
186
|
+
username text not null,
|
|
187
|
+
organization_id uuid references organizations(id),
|
|
188
|
+
role_code text not null check (role_code in ('owner', 'admin', 'member')),
|
|
189
|
+
invited_at timestamptz,
|
|
190
|
+
joined_at timestamptz,
|
|
191
|
+
left_at timestamptz,
|
|
192
|
+
deleted_at timestamptz,
|
|
193
|
+
created_at timestamptz not null default now(),
|
|
194
|
+
updated_at timestamptz not null default now()
|
|
195
|
+
);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## API Reference
|
|
199
|
+
|
|
200
|
+
### Factory Functions
|
|
201
|
+
|
|
202
|
+
#### `createSupabaseClient(config)`
|
|
203
|
+
|
|
204
|
+
Creates a Supabase client instance.
|
|
205
|
+
|
|
206
|
+
#### `createSupabaseRepositories(options)`
|
|
207
|
+
|
|
208
|
+
Creates all repositories with shared configuration.
|
|
209
|
+
|
|
210
|
+
### Repositories
|
|
211
|
+
|
|
212
|
+
- `SupabaseUserRepository` - User CRUD operations
|
|
213
|
+
- `SupabaseOrganizationRepository` - Organization CRUD operations
|
|
214
|
+
- `SupabaseOrganizationMembershipRepository` - Membership CRUD operations
|
|
215
|
+
|
|
216
|
+
## Environment Variables
|
|
217
|
+
|
|
218
|
+
| Variable | Description |
|
|
219
|
+
|----------|-------------|
|
|
220
|
+
| `SUPABASE_URL` | Your Supabase project URL |
|
|
221
|
+
| `SUPABASE_SERVICE_ROLE_KEY` | Service role key (server-side only) |
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase Client Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Provides a configured Supabase client for use in repositories.
|
|
5
|
+
* Works in both Node.js and Deno/Edge Functions environments.
|
|
6
|
+
*/
|
|
7
|
+
import { type SupabaseClient as SupabaseClientType } from '@supabase/supabase-js';
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for Supabase client
|
|
10
|
+
*/
|
|
11
|
+
export interface SupabaseConfig {
|
|
12
|
+
/** Supabase project URL */
|
|
13
|
+
url: string;
|
|
14
|
+
/** Supabase service role key (for server-side operations) */
|
|
15
|
+
serviceRoleKey: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create Supabase configuration from environment variables
|
|
19
|
+
*/
|
|
20
|
+
export declare function createSupabaseConfig(): SupabaseConfig;
|
|
21
|
+
/**
|
|
22
|
+
* Create a Supabase client instance
|
|
23
|
+
*
|
|
24
|
+
* @param config - Supabase configuration
|
|
25
|
+
* @returns Configured Supabase client
|
|
26
|
+
*/
|
|
27
|
+
export declare function createSupabaseClient(config: SupabaseConfig): SupabaseClientType;
|
|
28
|
+
export type { SupabaseClientType as SupabaseClient };
|
|
29
|
+
//# sourceMappingURL=SupabaseClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupabaseClient.d.ts","sourceRoot":"","sources":["../../src/client/SupabaseClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAgB,KAAK,cAAc,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhG;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAarD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,kBAAkB,CAO/E;AAGD,YAAY,EAAE,kBAAkB,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase Client Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Provides a configured Supabase client for use in repositories.
|
|
5
|
+
* Works in both Node.js and Deno/Edge Functions environments.
|
|
6
|
+
*/
|
|
7
|
+
import { createClient } from '@supabase/supabase-js';
|
|
8
|
+
/**
|
|
9
|
+
* Create Supabase configuration from environment variables
|
|
10
|
+
*/
|
|
11
|
+
export function createSupabaseConfig() {
|
|
12
|
+
const url = process.env.SUPABASE_URL;
|
|
13
|
+
const serviceRoleKey = process.env.SUPABASE_SERVICE_ROLE_KEY;
|
|
14
|
+
if (!url) {
|
|
15
|
+
throw new Error('SUPABASE_URL environment variable is required');
|
|
16
|
+
}
|
|
17
|
+
if (!serviceRoleKey) {
|
|
18
|
+
throw new Error('SUPABASE_SERVICE_ROLE_KEY environment variable is required');
|
|
19
|
+
}
|
|
20
|
+
return { url, serviceRoleKey };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a Supabase client instance
|
|
24
|
+
*
|
|
25
|
+
* @param config - Supabase configuration
|
|
26
|
+
* @returns Configured Supabase client
|
|
27
|
+
*/
|
|
28
|
+
export function createSupabaseClient(config) {
|
|
29
|
+
return createClient(config.url, config.serviceRoleKey, {
|
|
30
|
+
auth: {
|
|
31
|
+
autoRefreshToken: false,
|
|
32
|
+
persistSession: false
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=SupabaseClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupabaseClient.js","sourceRoot":"","sources":["../../src/client/SupabaseClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAA6C,MAAM,uBAAuB,CAAC;AAYhG;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAChC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IACrC,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;IAE7D,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,CAAC,cAAc,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC;AACnC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAsB;IACvD,OAAO,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,EAAE;QACnD,IAAI,EAAE;YACF,gBAAgB,EAAE,KAAK;YACvB,cAAc,EAAE,KAAK;SACxB;KACJ,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase Repository Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates all Supabase repositories with shared configuration.
|
|
5
|
+
* Deno/Edge Functions compatible - no Node.js dependencies.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolkitOptions } from '@multitenantkit/domain-contracts';
|
|
8
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
9
|
+
import { SupabaseOrganizationMembershipRepository } from '../repositories/SupabaseOrganizationMembershipRepository';
|
|
10
|
+
import { SupabaseOrganizationRepository } from '../repositories/SupabaseOrganizationRepository';
|
|
11
|
+
import { SupabaseUserRepository } from '../repositories/SupabaseUserRepository';
|
|
12
|
+
/**
|
|
13
|
+
* Options for creating Supabase repositories
|
|
14
|
+
*/
|
|
15
|
+
export interface SupabaseFactoryOptions<TUserCustomFields, TOrganizationCustomFields, TOrganizationMembershipCustomFields> {
|
|
16
|
+
/** Supabase client instance */
|
|
17
|
+
client: SupabaseClient;
|
|
18
|
+
/** Toolkit options for custom fields and database configuration */
|
|
19
|
+
toolkitOptions?: ToolkitOptions<TUserCustomFields, TOrganizationCustomFields, TOrganizationMembershipCustomFields>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Bundle of Supabase repositories
|
|
23
|
+
*/
|
|
24
|
+
export interface SupabaseRepositoryBundle<TUserCustomFields, TOrganizationCustomFields, TOrganizationMembershipCustomFields> {
|
|
25
|
+
userRepository: SupabaseUserRepository<TUserCustomFields>;
|
|
26
|
+
organizationRepository: SupabaseOrganizationRepository<TOrganizationCustomFields>;
|
|
27
|
+
organizationMembershipRepository: SupabaseOrganizationMembershipRepository<TUserCustomFields, TOrganizationCustomFields, TOrganizationMembershipCustomFields>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create all Supabase repositories
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const client = createSupabaseClient(config);
|
|
35
|
+
* const repos = createSupabaseRepositories({
|
|
36
|
+
* client,
|
|
37
|
+
* toolkitOptions: {
|
|
38
|
+
* namingStrategy: 'snake_case',
|
|
39
|
+
* users: { database: { schema: 'auth', table: 'users' } }
|
|
40
|
+
* }
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function createSupabaseRepositories<TUserCustomFields = {}, TOrganizationCustomFields = {}, TOrganizationMembershipCustomFields = {}>(options: SupabaseFactoryOptions<TUserCustomFields, TOrganizationCustomFields, TOrganizationMembershipCustomFields>): SupabaseRepositoryBundle<TUserCustomFields, TOrganizationCustomFields, TOrganizationMembershipCustomFields>;
|
|
45
|
+
//# sourceMappingURL=SupabaseFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupabaseFactory.d.ts","sourceRoot":"","sources":["../../src/factory/SupabaseFactory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,wCAAwC,EAAE,MAAM,0DAA0D,CAAC;AACpH,OAAO,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,sBAAsB,CACnC,iBAAiB,EACjB,yBAAyB,EACzB,mCAAmC;IAEnC,+BAA+B;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,mEAAmE;IACnE,cAAc,CAAC,EAAE,cAAc,CAC3B,iBAAiB,EACjB,yBAAyB,EACzB,mCAAmC,CACtC,CAAC;CACL;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB,CACrC,iBAAiB,EACjB,yBAAyB,EACzB,mCAAmC;IAEnC,cAAc,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;IAC1D,sBAAsB,EAAE,8BAA8B,CAAC,yBAAyB,CAAC,CAAC;IAClF,gCAAgC,EAAE,wCAAwC,CACtE,iBAAiB,EACjB,yBAAyB,EACzB,mCAAmC,CACtC,CAAC;CACL;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAEtC,iBAAiB,GAAG,EAAE,EAEtB,yBAAyB,GAAG,EAAE,EAE9B,mCAAmC,GAAG,EAAE,EAExC,OAAO,EAAE,sBAAsB,CAC3B,iBAAiB,EACjB,yBAAyB,EACzB,mCAAmC,CACtC,GACF,wBAAwB,CACvB,iBAAiB,EACjB,yBAAyB,EACzB,mCAAmC,CACtC,CAkBA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase Repository Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates all Supabase repositories with shared configuration.
|
|
5
|
+
* Deno/Edge Functions compatible - no Node.js dependencies.
|
|
6
|
+
*/
|
|
7
|
+
import { SupabaseOrganizationMembershipRepository } from '../repositories/SupabaseOrganizationMembershipRepository';
|
|
8
|
+
import { SupabaseOrganizationRepository } from '../repositories/SupabaseOrganizationRepository';
|
|
9
|
+
import { SupabaseUserRepository } from '../repositories/SupabaseUserRepository';
|
|
10
|
+
/**
|
|
11
|
+
* Create all Supabase repositories
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const client = createSupabaseClient(config);
|
|
16
|
+
* const repos = createSupabaseRepositories({
|
|
17
|
+
* client,
|
|
18
|
+
* toolkitOptions: {
|
|
19
|
+
* namingStrategy: 'snake_case',
|
|
20
|
+
* users: { database: { schema: 'auth', table: 'users' } }
|
|
21
|
+
* }
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function createSupabaseRepositories(options) {
|
|
26
|
+
const { client, toolkitOptions } = options;
|
|
27
|
+
return {
|
|
28
|
+
userRepository: new SupabaseUserRepository(client, toolkitOptions),
|
|
29
|
+
organizationRepository: new SupabaseOrganizationRepository(client, toolkitOptions),
|
|
30
|
+
organizationMembershipRepository: new SupabaseOrganizationMembershipRepository(client, toolkitOptions)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=SupabaseFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupabaseFactory.js","sourceRoot":"","sources":["../../src/factory/SupabaseFactory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,wCAAwC,EAAE,MAAM,0DAA0D,CAAC;AACpH,OAAO,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAqChF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,0BAA0B,CAQtC,OAIC;IAMD,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAE3C,OAAO;QACH,cAAc,EAAE,IAAI,sBAAsB,CACtC,MAAM,EACN,cAAqB,CACxB;QACD,sBAAsB,EAAE,IAAI,8BAA8B,CACtD,MAAM,EACN,cAAqB,CACxB;QACD,gCAAgC,EAAE,IAAI,wCAAwC,CAI5E,MAAM,EAAE,cAAc,CAAC;KAC5B,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use Case Factory for Supabase
|
|
3
|
+
*
|
|
4
|
+
* Creates all use cases with Supabase adapters.
|
|
5
|
+
* This is a copy of the composition package's factory to avoid Node.js dependencies.
|
|
6
|
+
*/
|
|
7
|
+
import type { Adapters, ToolkitOptions, UseCases } from '@multitenantkit/domain-contracts';
|
|
8
|
+
/**
|
|
9
|
+
* Factory function to create all use cases
|
|
10
|
+
*
|
|
11
|
+
* @param adapters - Application adapters (repositories, system, etc.)
|
|
12
|
+
* @param toolkitOptions - Optional toolkit options with custom schemas
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { createSupabaseAdapters, createUseCases } from '@multitenantkit/adapter-persistence-supabase';
|
|
17
|
+
*
|
|
18
|
+
* const adapters = createSupabaseAdapters({ client });
|
|
19
|
+
* const useCases = createUseCases(adapters);
|
|
20
|
+
*
|
|
21
|
+
* // Use the API
|
|
22
|
+
* await useCases.users.createUser.execute(...);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function createUseCases<TUserCustomFields = {}, TOrganizationCustomFields = {}, TOrganizationMembershipCustomFields = {}>(adapters: Adapters<TUserCustomFields, TOrganizationCustomFields, TOrganizationMembershipCustomFields>, toolkitOptions?: ToolkitOptions<TUserCustomFields, TOrganizationCustomFields, TOrganizationMembershipCustomFields>): UseCases;
|
|
26
|
+
//# sourceMappingURL=UseCaseFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseCaseFactory.d.ts","sourceRoot":"","sources":["../../src/factory/UseCaseFactory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA+BH,OAAO,KAAK,EACR,QAAQ,EAGR,cAAc,EACd,QAAQ,EAEX,MAAM,kCAAkC,CAAC;AA4J1C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAE1B,iBAAiB,GAAG,EAAE,EAEtB,yBAAyB,GAAG,EAAE,EAE9B,mCAAmC,GAAG,EAAE,EAExC,QAAQ,EAAE,QAAQ,CACd,iBAAiB,EACjB,yBAAyB,EACzB,mCAAmC,CACtC,EACD,cAAc,CAAC,EAAE,cAAc,CAC3B,iBAAiB,EACjB,yBAAyB,EACzB,mCAAmC,CACtC,GACF,QAAQ,CAMV"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use Case Factory for Supabase
|
|
3
|
+
*
|
|
4
|
+
* Creates all use cases with Supabase adapters.
|
|
5
|
+
* This is a copy of the composition package's factory to avoid Node.js dependencies.
|
|
6
|
+
*/
|
|
7
|
+
// Memberships use cases
|
|
8
|
+
import { AcceptOrganizationInvitation, AddOrganizationMember, LeaveOrganization, RemoveOrganizationMember, UpdateOrganizationMemberRole } from '@multitenantkit/domain/organization-memberships';
|
|
9
|
+
// Organizations use cases
|
|
10
|
+
import { ArchiveOrganization, CreateOrganization, DeleteOrganization, GetOrganization, ListOrganizationMembers, RestoreOrganization, TransferOrganizationOwnership, UpdateOrganization } from '@multitenantkit/domain/organizations';
|
|
11
|
+
// Users use cases
|
|
12
|
+
import { CreateUser, DeleteUser, GetUser, ListUserOrganizations, UpdateUser } from '@multitenantkit/domain/users';
|
|
13
|
+
/**
|
|
14
|
+
* Factory function to create user use cases
|
|
15
|
+
*/
|
|
16
|
+
function createUserUseCases(adapters, toolkitOptions) {
|
|
17
|
+
return {
|
|
18
|
+
createUser: new CreateUser(adapters),
|
|
19
|
+
getUser: new GetUser(adapters, toolkitOptions),
|
|
20
|
+
updateUser: new UpdateUser(adapters, toolkitOptions),
|
|
21
|
+
listUserOrganizations: new ListUserOrganizations(adapters, toolkitOptions),
|
|
22
|
+
deleteUser: new DeleteUser(adapters, toolkitOptions)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Factory function to create organization use cases
|
|
27
|
+
*/
|
|
28
|
+
function createOrganizationUseCases(adapters, toolkitOptions) {
|
|
29
|
+
return {
|
|
30
|
+
createOrganization: new CreateOrganization(adapters, toolkitOptions),
|
|
31
|
+
getOrganization: new GetOrganization(adapters, toolkitOptions),
|
|
32
|
+
updateOrganization: new UpdateOrganization(adapters, toolkitOptions),
|
|
33
|
+
listOrganizationMembers: new ListOrganizationMembers(adapters, toolkitOptions),
|
|
34
|
+
deleteOrganization: new DeleteOrganization(adapters, toolkitOptions),
|
|
35
|
+
archiveOrganization: new ArchiveOrganization(adapters, toolkitOptions),
|
|
36
|
+
restoreOrganization: new RestoreOrganization(adapters, toolkitOptions),
|
|
37
|
+
transferOrganizationOwnership: new TransferOrganizationOwnership(adapters, toolkitOptions)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Factory function to create membership use cases
|
|
42
|
+
*/
|
|
43
|
+
function createMembershipUseCases(adapters, toolkitOptions) {
|
|
44
|
+
return {
|
|
45
|
+
addOrganizationMember: new AddOrganizationMember(adapters, toolkitOptions),
|
|
46
|
+
acceptOrganizationInvitation: new AcceptOrganizationInvitation(adapters, toolkitOptions),
|
|
47
|
+
removeOrganizationMember: new RemoveOrganizationMember(adapters),
|
|
48
|
+
updateOrganizationMemberRole: new UpdateOrganizationMemberRole(adapters),
|
|
49
|
+
leaveOrganization: new LeaveOrganization(adapters, toolkitOptions)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Factory function to create all use cases
|
|
54
|
+
*
|
|
55
|
+
* @param adapters - Application adapters (repositories, system, etc.)
|
|
56
|
+
* @param toolkitOptions - Optional toolkit options with custom schemas
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { createSupabaseAdapters, createUseCases } from '@multitenantkit/adapter-persistence-supabase';
|
|
61
|
+
*
|
|
62
|
+
* const adapters = createSupabaseAdapters({ client });
|
|
63
|
+
* const useCases = createUseCases(adapters);
|
|
64
|
+
*
|
|
65
|
+
* // Use the API
|
|
66
|
+
* await useCases.users.createUser.execute(...);
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export function createUseCases(adapters, toolkitOptions) {
|
|
70
|
+
return {
|
|
71
|
+
users: createUserUseCases(adapters, toolkitOptions),
|
|
72
|
+
organizations: createOrganizationUseCases(adapters, toolkitOptions),
|
|
73
|
+
memberships: createMembershipUseCases(adapters, toolkitOptions)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=UseCaseFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseCaseFactory.js","sourceRoot":"","sources":["../../src/factory/UseCaseFactory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAwB;AACxB,OAAO,EACH,4BAA4B,EAC5B,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,4BAA4B,EAC/B,MAAM,iDAAiD,CAAC;AAEzD,0BAA0B;AAC1B,OAAO,EACH,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,EACrB,MAAM,sCAAsC,CAAC;AAC9C,kBAAkB;AAClB,OAAO,EACH,UAAU,EACV,UAAU,EACV,OAAO,EACP,qBAAqB,EACrB,UAAU,EACb,MAAM,8BAA8B,CAAC;AAWtC;;GAEG;AACH,SAAS,kBAAkB,CAQvB,QAIC,EACD,cAIC;IAED,OAAO;QACH,UAAU,EAAE,IAAI,UAAU,CAAoB,QAAe,CAAC;QAC9D,OAAO,EAAE,IAAI,OAAO,CAIlB,QAAe,EAAE,cAAc,CAAC;QAClC,UAAU,EAAE,IAAI,UAAU,CAIxB,QAAe,EAAE,cAAc,CAAC;QAClC,qBAAqB,EAAE,IAAI,qBAAqB,CAC5C,QAAe,EACf,cAAqB,CACxB;QACD,UAAU,EAAE,IAAI,UAAU,CAIxB,QAAe,EAAE,cAAc,CAAC;KACrC,CAAC;AACN,CAAC;AAED;;GAEG;AACH,SAAS,0BAA0B,CAQ/B,QAIC,EACD,cAIC;IAED,OAAO;QACH,kBAAkB,EAAE,IAAI,kBAAkB,CAIxC,QAAe,EAAE,cAAc,CAAC;QAClC,eAAe,EAAE,IAAI,eAAe,CAIlC,QAAe,EAAE,cAAc,CAAC;QAClC,kBAAkB,EAAE,IAAI,kBAAkB,CAIxC,QAAe,EAAE,cAAc,CAAC;QAClC,uBAAuB,EAAE,IAAI,uBAAuB,CAChD,QAAe,EACf,cAAqB,CACxB;QACD,kBAAkB,EAAE,IAAI,kBAAkB,CAIxC,QAAe,EAAE,cAAc,CAAC;QAClC,mBAAmB,EAAE,IAAI,mBAAmB,CAI1C,QAAe,EAAE,cAAc,CAAC;QAClC,mBAAmB,EAAE,IAAI,mBAAmB,CAI1C,QAAe,EAAE,cAAc,CAAC;QAClC,6BAA6B,EAAE,IAAI,6BAA6B,CAI9D,QAAe,EAAE,cAAc,CAAC;KACrC,CAAC;AACN,CAAC;AAED;;GAEG;AACH,SAAS,wBAAwB,CAQ7B,QAIC,EACD,cAIC;IAED,OAAO;QACH,qBAAqB,EAAE,IAAI,qBAAqB,CAI9C,QAAe,EAAE,cAAc,CAAC;QAClC,4BAA4B,EAAE,IAAI,4BAA4B,CAI5D,QAAe,EAAE,cAAc,CAAC;QAClC,wBAAwB,EAAE,IAAI,wBAAwB,CAAC,QAAe,CAAC;QACvE,4BAA4B,EAAE,IAAI,4BAA4B,CAAC,QAAe,CAAC;QAC/E,iBAAiB,EAAE,IAAI,iBAAiB,CAItC,QAAe,EAAE,cAAc,CAAC;KACrC,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAQ1B,QAIC,EACD,cAIC;IAED,OAAO;QACH,KAAK,EAAE,kBAAkB,CAAC,QAAQ,EAAE,cAAc,CAAC;QACnD,aAAa,EAAE,0BAA0B,CAAC,QAAQ,EAAE,cAAc,CAAC;QACnE,WAAW,EAAE,wBAAwB,CAAC,QAAQ,EAAE,cAAc,CAAC;KAClE,CAAC;AACN,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase Persistence Adapter
|
|
3
|
+
*
|
|
4
|
+
* This adapter provides a Supabase implementation of the domain repository ports.
|
|
5
|
+
* It works in both Node.js and Deno/Edge Functions environments.
|
|
6
|
+
*
|
|
7
|
+
* Key Features:
|
|
8
|
+
* - Uses @supabase/supabase-js client
|
|
9
|
+
* - Works in Node.js and Deno
|
|
10
|
+
* - No Node.js-specific APIs (no node:crypto, node:fs, etc.)
|
|
11
|
+
* - Compatible with Supabase Edge Functions
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { createSupabaseRepositories } from '@multitenantkit/adapter-persistence-supabase';
|
|
16
|
+
* import { createClient } from '@supabase/supabase-js';
|
|
17
|
+
*
|
|
18
|
+
* const client = createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY);
|
|
19
|
+
* const repositories = createSupabaseRepositories({ client });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export { createSupabaseClient, createSupabaseConfig, type SupabaseClient, type SupabaseConfig } from './client/SupabaseClient';
|
|
23
|
+
export { createSupabaseRepositories, type SupabaseFactoryOptions, type SupabaseRepositoryBundle } from './factory/SupabaseFactory';
|
|
24
|
+
export { type OrganizationDbRow, OrganizationMapper } from './mappers/OrganizationMapper';
|
|
25
|
+
export { type OrganizationMembershipDbRow, OrganizationMembershipMapper } from './mappers/OrganizationMembershipMapper';
|
|
26
|
+
export { type UserDbRow, UserMapper } from './mappers/UserMapper';
|
|
27
|
+
export { SupabaseOrganizationMembershipRepository } from './repositories/SupabaseOrganizationMembershipRepository';
|
|
28
|
+
export { SupabaseOrganizationRepository } from './repositories/SupabaseOrganizationRepository';
|
|
29
|
+
export { SupabaseUserRepository } from './repositories/SupabaseUserRepository';
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EACH,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,cAAc,EACtB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACH,0BAA0B,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAChC,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,KAAK,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EACH,KAAK,2BAA2B,EAChC,4BAA4B,EAC/B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,KAAK,SAAS,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlE,OAAO,EAAE,wCAAwC,EAAE,MAAM,yDAAyD,CAAC;AACnH,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;AAC/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase Persistence Adapter
|
|
3
|
+
*
|
|
4
|
+
* This adapter provides a Supabase implementation of the domain repository ports.
|
|
5
|
+
* It works in both Node.js and Deno/Edge Functions environments.
|
|
6
|
+
*
|
|
7
|
+
* Key Features:
|
|
8
|
+
* - Uses @supabase/supabase-js client
|
|
9
|
+
* - Works in Node.js and Deno
|
|
10
|
+
* - No Node.js-specific APIs (no node:crypto, node:fs, etc.)
|
|
11
|
+
* - Compatible with Supabase Edge Functions
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { createSupabaseRepositories } from '@multitenantkit/adapter-persistence-supabase';
|
|
16
|
+
* import { createClient } from '@supabase/supabase-js';
|
|
17
|
+
*
|
|
18
|
+
* const client = createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY);
|
|
19
|
+
* const repositories = createSupabaseRepositories({ client });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
// Client and Configuration
|
|
23
|
+
export { createSupabaseClient, createSupabaseConfig } from './client/SupabaseClient';
|
|
24
|
+
// Factory Functions
|
|
25
|
+
export { createSupabaseRepositories } from './factory/SupabaseFactory';
|
|
26
|
+
// Mappers
|
|
27
|
+
export { OrganizationMapper } from './mappers/OrganizationMapper';
|
|
28
|
+
export { OrganizationMembershipMapper } from './mappers/OrganizationMembershipMapper';
|
|
29
|
+
export { UserMapper } from './mappers/UserMapper';
|
|
30
|
+
// Repositories
|
|
31
|
+
export { SupabaseOrganizationMembershipRepository } from './repositories/SupabaseOrganizationMembershipRepository';
|
|
32
|
+
export { SupabaseOrganizationRepository } from './repositories/SupabaseOrganizationRepository';
|
|
33
|
+
export { SupabaseUserRepository } from './repositories/SupabaseUserRepository';
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,2BAA2B;AAC3B,OAAO,EACH,oBAAoB,EACpB,oBAAoB,EAGvB,MAAM,yBAAyB,CAAC;AAEjC,oBAAoB;AACpB,OAAO,EACH,0BAA0B,EAG7B,MAAM,2BAA2B,CAAC;AAEnC,UAAU;AACV,OAAO,EAA0B,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAEH,4BAA4B,EAC/B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAkB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElE,eAAe;AACf,OAAO,EAAE,wCAAwC,EAAE,MAAM,yDAAyD,CAAC;AACnH,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;AAC/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organization Mapper for Supabase
|
|
3
|
+
*/
|
|
4
|
+
import type { Organization } from '@multitenantkit/domain-contracts';
|
|
5
|
+
/**
|
|
6
|
+
* Database row type for organizations
|
|
7
|
+
*/
|
|
8
|
+
export interface OrganizationDbRow {
|
|
9
|
+
id: string;
|
|
10
|
+
owner_user_id: string;
|
|
11
|
+
created_at: string;
|
|
12
|
+
updated_at: string;
|
|
13
|
+
deleted_at?: string | null;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Column mapping configuration
|
|
18
|
+
*/
|
|
19
|
+
export interface OrganizationColumnMap {
|
|
20
|
+
id: string;
|
|
21
|
+
ownerUserId: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
deletedAt: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Default column mapping (snake_case)
|
|
28
|
+
*/
|
|
29
|
+
export declare const DEFAULT_ORGANIZATION_COLUMN_MAP: OrganizationColumnMap;
|
|
30
|
+
/**
|
|
31
|
+
* Organization mapper utilities
|
|
32
|
+
*/
|
|
33
|
+
export declare class OrganizationMapper {
|
|
34
|
+
/**
|
|
35
|
+
* Map database row to domain Organization entity
|
|
36
|
+
*/
|
|
37
|
+
static toDomain(row: OrganizationDbRow, columnMap?: OrganizationColumnMap): Organization;
|
|
38
|
+
/**
|
|
39
|
+
* Map database row to domain Organization entity with custom fields
|
|
40
|
+
*/
|
|
41
|
+
static toDomainWithCustom<TCustomFields>(row: OrganizationDbRow, columnMap?: OrganizationColumnMap, customFieldsMapper?: (row: OrganizationDbRow) => TCustomFields): Organization & TCustomFields;
|
|
42
|
+
/**
|
|
43
|
+
* Map domain Organization entity to database row
|
|
44
|
+
*/
|
|
45
|
+
static toDb(org: Organization, columnMap?: OrganizationColumnMap): Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=OrganizationMapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrganizationMapper.d.ts","sourceRoot":"","sources":["../../src/mappers/OrganizationMapper.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,qBAM7C,CAAC;AAEF;;GAEG;AACH,qBAAa,kBAAkB;IAC3B;;OAEG;IACH,MAAM,CAAC,QAAQ,CACX,GAAG,EAAE,iBAAiB,EACtB,SAAS,GAAE,qBAAuD,GACnE,YAAY;IAYf;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,aAAa,EACnC,GAAG,EAAE,iBAAiB,EACtB,SAAS,GAAE,qBAAuD,EAClE,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,aAAa,GAC/D,YAAY,GAAG,aAAa;IAW/B;;OAEG;IACH,MAAM,CAAC,IAAI,CACP,GAAG,EAAE,YAAY,EACjB,SAAS,GAAE,qBAAuD,GACnE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAS7B"}
|