foundation-sdk 0.2.6 → 0.2.7

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.
@@ -0,0 +1,204 @@
1
+ interface User {
2
+ id: string;
3
+ email: string;
4
+ name?: string;
5
+ picture?: string;
6
+ [key: string]: unknown;
7
+ }
8
+ interface FileMetadata {
9
+ id: string;
10
+ name: string;
11
+ type: string;
12
+ size: number;
13
+ url: string;
14
+ folder?: string;
15
+ metadata?: Record<string, unknown>;
16
+ createdAt: string;
17
+ }
18
+ interface EntityChangeEvent {
19
+ changeType: string;
20
+ entityId?: string;
21
+ id?: string;
22
+ namespace?: string;
23
+ timestamp?: number;
24
+ }
25
+ type AuthProvider = (config: Record<string, unknown>) => Promise<AuthClient>;
26
+ interface FoundationConfig {
27
+ /** Backend config endpoint URL. If omitted, reads from /foundation-env.json */
28
+ configUrl?: string;
29
+ tenantId?: string;
30
+ appId?: string;
31
+ /** Override API base URL (e.g. '/api' when using a dev proxy) */
32
+ baseUrl?: string;
33
+ /** Auth client instance, or provider factory from foundation-sdk/cognito or foundation-sdk/auth0 */
34
+ auth?: AuthClient | AuthProvider;
35
+ }
36
+ interface FullConfig {
37
+ readonly app: {
38
+ id: string;
39
+ name: string;
40
+ version: string;
41
+ environment: string;
42
+ [key: string]: unknown;
43
+ };
44
+ readonly features: Record<string, unknown>;
45
+ readonly plans: unknown[];
46
+ readonly theme: {
47
+ colors: Record<string, string>;
48
+ dark: Record<string, string>;
49
+ defaultColorScheme?: string;
50
+ };
51
+ readonly connectors: Record<string, unknown>;
52
+ readonly resources: Record<string, string>;
53
+ readonly auth: {
54
+ provider: string;
55
+ [key: string]: unknown;
56
+ };
57
+ readonly raw: Record<string, unknown>;
58
+ }
59
+ interface AuthClient {
60
+ login(options?: Record<string, unknown>): Promise<void>;
61
+ logout(options?: Record<string, unknown>): void | Promise<void>;
62
+ getUser(): Promise<User | undefined>;
63
+ getTokenSilently(options?: Record<string, unknown>): Promise<string>;
64
+ isAuthenticated(): Promise<boolean>;
65
+ signIn?(email: string, password: string): Promise<void>;
66
+ signUp?(email: string, password: string, metadata?: Record<string, unknown>): Promise<void>;
67
+ forgotPassword?(email: string): Promise<void>;
68
+ resetPassword?(code: string, newPassword: string): Promise<void>;
69
+ }
70
+ interface AuthService {
71
+ readonly user: User | null;
72
+ readonly isAuthenticated: boolean;
73
+ getToken(): Promise<string>;
74
+ /** Redirect-based login (Auth0 Universal Login / Cognito Hosted UI) */
75
+ login(options?: Record<string, unknown>): Promise<void>;
76
+ logout(options?: Record<string, unknown>): Promise<void>;
77
+ /** Direct sign in with credentials (for custom login forms) */
78
+ signIn(email: string, password: string): Promise<void>;
79
+ /** Direct sign up (for custom registration forms) */
80
+ signUp(email: string, password: string, metadata?: Record<string, unknown>): Promise<void>;
81
+ /** Initiate password reset */
82
+ forgotPassword(email: string): Promise<void>;
83
+ /** Complete password reset with code */
84
+ resetPassword(code: string, newPassword: string): Promise<void>;
85
+ onChange(callback: (user: User | null) => void): () => void;
86
+ }
87
+ interface DbService {
88
+ list<T = unknown>(entity: string, options?: {
89
+ filters?: Record<string, unknown>;
90
+ limit?: number;
91
+ cursor?: string;
92
+ orderBy?: string;
93
+ orderDir?: 'asc' | 'desc';
94
+ }): Promise<{
95
+ items: T[];
96
+ nextCursor?: string;
97
+ }>;
98
+ get<T = unknown>(entity: string, id: string): Promise<T>;
99
+ create<T = unknown>(entity: string, data: Partial<T>): Promise<T>;
100
+ update<T = unknown>(entity: string, id: string, updates: Partial<T>): Promise<T>;
101
+ save<T = unknown>(entity: string, data: Partial<T>): Promise<T>;
102
+ delete(entity: string, id: string): Promise<void>;
103
+ }
104
+ interface FilesService {
105
+ initiate(options: {
106
+ name: string;
107
+ contentType: string;
108
+ contentLength: number;
109
+ metadata?: Record<string, unknown>;
110
+ sha256: string;
111
+ }): Promise<{
112
+ id: string;
113
+ name: string;
114
+ signedUrl: string;
115
+ signedData: Record<string, string>;
116
+ }>;
117
+ upload(options: {
118
+ name: string;
119
+ contentType: string;
120
+ file: ArrayBuffer | Blob | File;
121
+ sha256: string;
122
+ }): Promise<{
123
+ id: string;
124
+ name: string;
125
+ status: string;
126
+ s3UploadComplete: boolean;
127
+ }>;
128
+ get(fileId: string): Promise<FileMetadata>;
129
+ delete(fileId: string): Promise<void>;
130
+ list(options?: {
131
+ limit?: number;
132
+ cursor?: string;
133
+ }): Promise<{
134
+ items: FileMetadata[];
135
+ nextCursor?: string;
136
+ }>;
137
+ }
138
+ interface AccountService {
139
+ get<TUser = User, TAccount = Record<string, unknown>>(): Promise<{
140
+ user: TUser;
141
+ account: TAccount;
142
+ }>;
143
+ update(data: Record<string, unknown>): Promise<void>;
144
+ usage(): Promise<Record<string, unknown>>;
145
+ resendVerification(): Promise<void>;
146
+ }
147
+ interface Integration {
148
+ id: string;
149
+ name: string;
150
+ description?: string;
151
+ icon?: string;
152
+ authType?: string;
153
+ [key: string]: unknown;
154
+ }
155
+ interface IntegrationConnection {
156
+ id: string;
157
+ source: string;
158
+ connected: boolean;
159
+ [key: string]: unknown;
160
+ }
161
+ interface IntegrationDetail extends Integration {
162
+ connections: IntegrationConnection[];
163
+ connected: boolean;
164
+ connectionCount: number;
165
+ }
166
+ interface IntegrationService {
167
+ list(): Promise<Integration[]>;
168
+ connections(): Promise<IntegrationConnection[]>;
169
+ all(): Promise<IntegrationDetail[]>;
170
+ status(source: string): Promise<{
171
+ connected: boolean;
172
+ connections: IntegrationConnection[];
173
+ }>;
174
+ connect(source: string): Promise<{
175
+ success: boolean;
176
+ configuration?: unknown;
177
+ message?: string;
178
+ }>;
179
+ disconnect(source: string, configurationId: string): Promise<void>;
180
+ }
181
+ interface OpenApiService {
182
+ get(): Promise<Record<string, unknown>>;
183
+ }
184
+ interface LogService {
185
+ info(message: string, context?: Record<string, unknown>): void;
186
+ warn(message: string, context?: Record<string, unknown>): void;
187
+ error(message: string, context?: Record<string, unknown>): void;
188
+ event(event: string, data?: Record<string, unknown>): void;
189
+ }
190
+ interface Foundation {
191
+ readonly ready: Promise<void>;
192
+ readonly isReady: boolean;
193
+ auth: AuthService;
194
+ db: DbService;
195
+ files: FilesService;
196
+ integration: IntegrationService;
197
+ account: AccountService;
198
+ config: FullConfig;
199
+ openapi: OpenApiService;
200
+ log: LogService;
201
+ on(event: string, callback: (event: EntityChangeEvent) => void): () => void;
202
+ }
203
+
204
+ export type { AuthClient as A, DbService as D, EntityChangeEvent as E, FoundationConfig as F, IntegrationService as I, LogService as L, OpenApiService as O, User as U, Foundation as a, FullConfig as b, FileMetadata as c, AuthProvider as d, AuthService as e, FilesService as f, AccountService as g, Integration as h, IntegrationConnection as i, IntegrationDetail as j };
@@ -0,0 +1,204 @@
1
+ interface User {
2
+ id: string;
3
+ email: string;
4
+ name?: string;
5
+ picture?: string;
6
+ [key: string]: unknown;
7
+ }
8
+ interface FileMetadata {
9
+ id: string;
10
+ name: string;
11
+ type: string;
12
+ size: number;
13
+ url: string;
14
+ folder?: string;
15
+ metadata?: Record<string, unknown>;
16
+ createdAt: string;
17
+ }
18
+ interface EntityChangeEvent {
19
+ changeType: string;
20
+ entityId?: string;
21
+ id?: string;
22
+ namespace?: string;
23
+ timestamp?: number;
24
+ }
25
+ type AuthProvider = (config: Record<string, unknown>) => Promise<AuthClient>;
26
+ interface FoundationConfig {
27
+ /** Backend config endpoint URL. If omitted, reads from /foundation-env.json */
28
+ configUrl?: string;
29
+ tenantId?: string;
30
+ appId?: string;
31
+ /** Override API base URL (e.g. '/api' when using a dev proxy) */
32
+ baseUrl?: string;
33
+ /** Auth client instance, or provider factory from foundation-sdk/cognito or foundation-sdk/auth0 */
34
+ auth?: AuthClient | AuthProvider;
35
+ }
36
+ interface FullConfig {
37
+ readonly app: {
38
+ id: string;
39
+ name: string;
40
+ version: string;
41
+ environment: string;
42
+ [key: string]: unknown;
43
+ };
44
+ readonly features: Record<string, unknown>;
45
+ readonly plans: unknown[];
46
+ readonly theme: {
47
+ colors: Record<string, string>;
48
+ dark: Record<string, string>;
49
+ defaultColorScheme?: string;
50
+ };
51
+ readonly connectors: Record<string, unknown>;
52
+ readonly resources: Record<string, string>;
53
+ readonly auth: {
54
+ provider: string;
55
+ [key: string]: unknown;
56
+ };
57
+ readonly raw: Record<string, unknown>;
58
+ }
59
+ interface AuthClient {
60
+ login(options?: Record<string, unknown>): Promise<void>;
61
+ logout(options?: Record<string, unknown>): void | Promise<void>;
62
+ getUser(): Promise<User | undefined>;
63
+ getTokenSilently(options?: Record<string, unknown>): Promise<string>;
64
+ isAuthenticated(): Promise<boolean>;
65
+ signIn?(email: string, password: string): Promise<void>;
66
+ signUp?(email: string, password: string, metadata?: Record<string, unknown>): Promise<void>;
67
+ forgotPassword?(email: string): Promise<void>;
68
+ resetPassword?(code: string, newPassword: string): Promise<void>;
69
+ }
70
+ interface AuthService {
71
+ readonly user: User | null;
72
+ readonly isAuthenticated: boolean;
73
+ getToken(): Promise<string>;
74
+ /** Redirect-based login (Auth0 Universal Login / Cognito Hosted UI) */
75
+ login(options?: Record<string, unknown>): Promise<void>;
76
+ logout(options?: Record<string, unknown>): Promise<void>;
77
+ /** Direct sign in with credentials (for custom login forms) */
78
+ signIn(email: string, password: string): Promise<void>;
79
+ /** Direct sign up (for custom registration forms) */
80
+ signUp(email: string, password: string, metadata?: Record<string, unknown>): Promise<void>;
81
+ /** Initiate password reset */
82
+ forgotPassword(email: string): Promise<void>;
83
+ /** Complete password reset with code */
84
+ resetPassword(code: string, newPassword: string): Promise<void>;
85
+ onChange(callback: (user: User | null) => void): () => void;
86
+ }
87
+ interface DbService {
88
+ list<T = unknown>(entity: string, options?: {
89
+ filters?: Record<string, unknown>;
90
+ limit?: number;
91
+ cursor?: string;
92
+ orderBy?: string;
93
+ orderDir?: 'asc' | 'desc';
94
+ }): Promise<{
95
+ items: T[];
96
+ nextCursor?: string;
97
+ }>;
98
+ get<T = unknown>(entity: string, id: string): Promise<T>;
99
+ create<T = unknown>(entity: string, data: Partial<T>): Promise<T>;
100
+ update<T = unknown>(entity: string, id: string, updates: Partial<T>): Promise<T>;
101
+ save<T = unknown>(entity: string, data: Partial<T>): Promise<T>;
102
+ delete(entity: string, id: string): Promise<void>;
103
+ }
104
+ interface FilesService {
105
+ initiate(options: {
106
+ name: string;
107
+ contentType: string;
108
+ contentLength: number;
109
+ metadata?: Record<string, unknown>;
110
+ sha256: string;
111
+ }): Promise<{
112
+ id: string;
113
+ name: string;
114
+ signedUrl: string;
115
+ signedData: Record<string, string>;
116
+ }>;
117
+ upload(options: {
118
+ name: string;
119
+ contentType: string;
120
+ file: ArrayBuffer | Blob | File;
121
+ sha256: string;
122
+ }): Promise<{
123
+ id: string;
124
+ name: string;
125
+ status: string;
126
+ s3UploadComplete: boolean;
127
+ }>;
128
+ get(fileId: string): Promise<FileMetadata>;
129
+ delete(fileId: string): Promise<void>;
130
+ list(options?: {
131
+ limit?: number;
132
+ cursor?: string;
133
+ }): Promise<{
134
+ items: FileMetadata[];
135
+ nextCursor?: string;
136
+ }>;
137
+ }
138
+ interface AccountService {
139
+ get<TUser = User, TAccount = Record<string, unknown>>(): Promise<{
140
+ user: TUser;
141
+ account: TAccount;
142
+ }>;
143
+ update(data: Record<string, unknown>): Promise<void>;
144
+ usage(): Promise<Record<string, unknown>>;
145
+ resendVerification(): Promise<void>;
146
+ }
147
+ interface Integration {
148
+ id: string;
149
+ name: string;
150
+ description?: string;
151
+ icon?: string;
152
+ authType?: string;
153
+ [key: string]: unknown;
154
+ }
155
+ interface IntegrationConnection {
156
+ id: string;
157
+ source: string;
158
+ connected: boolean;
159
+ [key: string]: unknown;
160
+ }
161
+ interface IntegrationDetail extends Integration {
162
+ connections: IntegrationConnection[];
163
+ connected: boolean;
164
+ connectionCount: number;
165
+ }
166
+ interface IntegrationService {
167
+ list(): Promise<Integration[]>;
168
+ connections(): Promise<IntegrationConnection[]>;
169
+ all(): Promise<IntegrationDetail[]>;
170
+ status(source: string): Promise<{
171
+ connected: boolean;
172
+ connections: IntegrationConnection[];
173
+ }>;
174
+ connect(source: string): Promise<{
175
+ success: boolean;
176
+ configuration?: unknown;
177
+ message?: string;
178
+ }>;
179
+ disconnect(source: string, configurationId: string): Promise<void>;
180
+ }
181
+ interface OpenApiService {
182
+ get(): Promise<Record<string, unknown>>;
183
+ }
184
+ interface LogService {
185
+ info(message: string, context?: Record<string, unknown>): void;
186
+ warn(message: string, context?: Record<string, unknown>): void;
187
+ error(message: string, context?: Record<string, unknown>): void;
188
+ event(event: string, data?: Record<string, unknown>): void;
189
+ }
190
+ interface Foundation {
191
+ readonly ready: Promise<void>;
192
+ readonly isReady: boolean;
193
+ auth: AuthService;
194
+ db: DbService;
195
+ files: FilesService;
196
+ integration: IntegrationService;
197
+ account: AccountService;
198
+ config: FullConfig;
199
+ openapi: OpenApiService;
200
+ log: LogService;
201
+ on(event: string, callback: (event: EntityChangeEvent) => void): () => void;
202
+ }
203
+
204
+ export type { AuthClient as A, DbService as D, EntityChangeEvent as E, FoundationConfig as F, IntegrationService as I, LogService as L, OpenApiService as O, User as U, Foundation as a, FullConfig as b, FileMetadata as c, AuthProvider as d, AuthService as e, FilesService as f, AccountService as g, Integration as h, IntegrationConnection as i, IntegrationDetail as j };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foundation-sdk",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "TypeScript SDK for Foundation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -12,10 +12,12 @@
12
12
  "import": "./dist/index.js"
13
13
  },
14
14
  "./auth0": {
15
+ "types": "./dist/auth-auth0.d.ts",
15
16
  "require": "./dist/auth-auth0.cjs",
16
17
  "import": "./dist/auth-auth0.js"
17
18
  },
18
19
  "./cognito": {
20
+ "types": "./dist/auth-cognito.d.ts",
19
21
  "require": "./dist/auth-cognito.cjs",
20
22
  "import": "./dist/auth-cognito.js"
21
23
  }