@progressive-development/pd-provider-interfaces 0.9.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/auth.d.ts +78 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/common.d.ts +5 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/database.d.ts +75 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/functions.d.ts +49 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/service-provider.d.ts +24 -0
- package/dist/service-provider.d.ts.map +1 -0
- package/dist/storage.d.ts +118 -0
- package/dist/storage.d.ts.map +1 -0
- package/package.json +38 -0
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Unsubscribe } from './common.js';
|
|
2
|
+
/**
|
|
3
|
+
* Authenticated user information
|
|
4
|
+
*/
|
|
5
|
+
export interface AuthUser {
|
|
6
|
+
uid: string;
|
|
7
|
+
email: string | null;
|
|
8
|
+
emailVerified: boolean;
|
|
9
|
+
displayName?: string | null;
|
|
10
|
+
photoURL?: string | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* User token with claims
|
|
14
|
+
*/
|
|
15
|
+
export interface UserToken {
|
|
16
|
+
token: string;
|
|
17
|
+
claims: Record<string, unknown>;
|
|
18
|
+
expirationTime: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Callback for auth state changes
|
|
22
|
+
*/
|
|
23
|
+
export type AuthStateCallback = (user: AuthUser | null) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Authentication provider interface
|
|
26
|
+
*
|
|
27
|
+
* Abstracts authentication operations (login, logout, state monitoring)
|
|
28
|
+
* from specific implementations (Firebase, Mock, etc.)
|
|
29
|
+
*/
|
|
30
|
+
export interface IAuthProvider {
|
|
31
|
+
/**
|
|
32
|
+
* Sign in with email and password
|
|
33
|
+
* @throws Error on authentication failure
|
|
34
|
+
*/
|
|
35
|
+
login(email: string, password: string): Promise<AuthUser>;
|
|
36
|
+
/**
|
|
37
|
+
* Sign out the current user
|
|
38
|
+
*/
|
|
39
|
+
logout(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Get the currently authenticated user
|
|
42
|
+
* @returns User if authenticated, null otherwise
|
|
43
|
+
*/
|
|
44
|
+
getCurrentUser(): AuthUser | null;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a user is currently authenticated
|
|
47
|
+
*/
|
|
48
|
+
isAuthenticated(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get the current user's ID token
|
|
51
|
+
* @param forceRefresh Force token refresh even if not expired
|
|
52
|
+
* @returns Token string or null if not authenticated
|
|
53
|
+
*/
|
|
54
|
+
getIdToken(forceRefresh?: boolean): Promise<string | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Get detailed token result with claims
|
|
57
|
+
* @param forceRefresh Force token refresh even if not expired
|
|
58
|
+
* @returns Token with claims or null if not authenticated
|
|
59
|
+
*/
|
|
60
|
+
getIdTokenResult(forceRefresh?: boolean): Promise<UserToken | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Subscribe to authentication state changes
|
|
63
|
+
* @param callback Called when auth state changes
|
|
64
|
+
* @returns Unsubscribe function
|
|
65
|
+
*/
|
|
66
|
+
onAuthStateChanged(callback: AuthStateCallback): Unsubscribe;
|
|
67
|
+
/**
|
|
68
|
+
* Send a password reset email to the specified address.
|
|
69
|
+
*
|
|
70
|
+
* Note: For security reasons, this method should not reveal whether
|
|
71
|
+
* the email exists in the system. It resolves successfully regardless
|
|
72
|
+
* of whether the email is registered.
|
|
73
|
+
*
|
|
74
|
+
* @param email Email address to send reset link to
|
|
75
|
+
*/
|
|
76
|
+
sendPasswordResetEmail(email: string): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|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,CAAC;IAE7D;;;;;;;;OAQG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD"}
|
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Unsubscribe } from './common.js';
|
|
2
|
+
/**
|
|
3
|
+
* Query operators for filtering
|
|
4
|
+
*/
|
|
5
|
+
export type QueryOperator = "<" | ">" | ">=" | "<=" | "==" | "!=" | "array-contains" | "array-contains-any" | "in" | "not-in";
|
|
6
|
+
/**
|
|
7
|
+
* Query constraint for filtering collections
|
|
8
|
+
*/
|
|
9
|
+
export interface QueryConstraint {
|
|
10
|
+
type: "where";
|
|
11
|
+
field: string;
|
|
12
|
+
operator: QueryOperator;
|
|
13
|
+
value: string | number | boolean | null | Date | Array<string | number | boolean | null | Date>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Document snapshot with data and metadata
|
|
17
|
+
*/
|
|
18
|
+
export interface DocumentSnapshot<T = unknown> {
|
|
19
|
+
/** Document ID */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Document data */
|
|
22
|
+
data: T;
|
|
23
|
+
/** Whether the document exists */
|
|
24
|
+
exists: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Callback for collection changes
|
|
28
|
+
*/
|
|
29
|
+
export type CollectionCallback<T> = (documents: DocumentSnapshot<T>[] | null) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Database provider interface (optional)
|
|
32
|
+
*
|
|
33
|
+
* Abstracts database operations from specific implementations
|
|
34
|
+
* (Firestore, Mock, etc.)
|
|
35
|
+
*
|
|
36
|
+
* Note: This provider is optional - not all apps need real-time database features
|
|
37
|
+
*/
|
|
38
|
+
export interface IDatabaseProvider {
|
|
39
|
+
/**
|
|
40
|
+
* Subscribe to a collection with optional filtering
|
|
41
|
+
* @param collectionPath Path to the collection
|
|
42
|
+
* @param callback Called with documents on changes
|
|
43
|
+
* @param constraints Optional query constraints
|
|
44
|
+
* @returns Unsubscribe function
|
|
45
|
+
*/
|
|
46
|
+
onCollection<T = unknown>(collectionPath: string, callback: CollectionCallback<T>, constraints?: QueryConstraint[]): Unsubscribe;
|
|
47
|
+
/**
|
|
48
|
+
* Get a single document
|
|
49
|
+
* @param collectionPath Path to the collection
|
|
50
|
+
* @param documentId Document ID
|
|
51
|
+
* @returns Document snapshot
|
|
52
|
+
*/
|
|
53
|
+
getDocument<T = unknown>(collectionPath: string, documentId: string): Promise<DocumentSnapshot<T>>;
|
|
54
|
+
/**
|
|
55
|
+
* Set/overwrite a document
|
|
56
|
+
* @param collectionPath Path to the collection
|
|
57
|
+
* @param documentId Document ID
|
|
58
|
+
* @param data Document data
|
|
59
|
+
*/
|
|
60
|
+
setDocument<T = unknown>(collectionPath: string, documentId: string, data: T): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Update specific fields in a document
|
|
63
|
+
* @param collectionPath Path to the collection
|
|
64
|
+
* @param documentId Document ID
|
|
65
|
+
* @param data Partial document data to update
|
|
66
|
+
*/
|
|
67
|
+
updateDocument(collectionPath: string, documentId: string, data: Record<string, unknown>): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Delete a document
|
|
70
|
+
* @param collectionPath Path to the collection
|
|
71
|
+
* @param documentId Document ID
|
|
72
|
+
*/
|
|
73
|
+
deleteDocument(collectionPath: string, documentId: string): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,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OAAO,EACrB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,CAAC,GACN,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;OAKG;IACH,cAAc,CACZ,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;OAIG;IACH,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3E"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result from a cloud function call
|
|
3
|
+
*/
|
|
4
|
+
export interface FunctionResult {
|
|
5
|
+
resultData: unknown;
|
|
6
|
+
statusCode: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Cloud function definition
|
|
10
|
+
*/
|
|
11
|
+
export interface FunctionDefinition {
|
|
12
|
+
/** Function name */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Status codes considered successful */
|
|
15
|
+
successCodes: number[];
|
|
16
|
+
/** Show full-screen loading indicator */
|
|
17
|
+
fadeWindow: boolean;
|
|
18
|
+
/** Text shown on success */
|
|
19
|
+
successTxt: string | unknown;
|
|
20
|
+
/** Text shown while pending */
|
|
21
|
+
pendingTxt: string | unknown;
|
|
22
|
+
/** Additional parameters */
|
|
23
|
+
param?: Record<string, unknown>;
|
|
24
|
+
/** Redirect route after success */
|
|
25
|
+
redirect?: string;
|
|
26
|
+
/** Logout user on failure */
|
|
27
|
+
logoutOnFail?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Cloud functions provider interface
|
|
31
|
+
*
|
|
32
|
+
* Abstracts cloud function calls from specific implementations
|
|
33
|
+
* (Firebase Functions, Mock, REST API, etc.)
|
|
34
|
+
*/
|
|
35
|
+
export interface IFunctionProvider {
|
|
36
|
+
/**
|
|
37
|
+
* Call a cloud function
|
|
38
|
+
* @param functionName Name of the function to call
|
|
39
|
+
* @param data Data to pass to the function
|
|
40
|
+
* @returns Function result with status code
|
|
41
|
+
*/
|
|
42
|
+
callFunction(functionName: string, data: unknown): Promise<FunctionResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Configure the functions region
|
|
45
|
+
* @param region Cloud region (e.g., 'europe-west3')
|
|
46
|
+
*/
|
|
47
|
+
setRegion(region: string): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,yCAAyC;IACzC,UAAU,EAAE,OAAO,CAAC;IACpB,4BAA4B;IAC5B,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,+BAA+B;IAC/B,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3E;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { Unsubscribe } from './common.js';
|
|
2
|
+
export type { IAuthProvider, AuthUser, UserToken, AuthStateCallback, } from './auth.js';
|
|
3
|
+
export type { IDatabaseProvider, QueryOperator, QueryConstraint, DocumentSnapshot, CollectionCallback, } from './database.js';
|
|
4
|
+
export type { IStorageProvider, UploadFileRequest, UploadResult, StorageDocument, ListFilesOptions, GetFileOptions, } from './storage.js';
|
|
5
|
+
export type { IFunctionProvider, FunctionResult, FunctionDefinition, } from './functions.js';
|
|
6
|
+
export type { ServiceProvider } from './service-provider.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,YAAY,EACV,aAAa,EACb,QAAQ,EACR,SAAS,EACT,iBAAiB,GAClB,MAAM,WAAW,CAAC;AAGnB,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,cAAc,GACf,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IAuthProvider } from './auth.js';
|
|
2
|
+
import { IFunctionProvider } from './functions.js';
|
|
3
|
+
import { IStorageProvider } from './storage.js';
|
|
4
|
+
import { IDatabaseProvider } from './database.js';
|
|
5
|
+
/**
|
|
6
|
+
* Complete service provider configuration
|
|
7
|
+
*
|
|
8
|
+
* This is the main type that provider packages (pd-provider-firebase,
|
|
9
|
+
* pd-provider-mock, etc.) must implement.
|
|
10
|
+
*
|
|
11
|
+
* Note: Messaging is NOT part of this interface - it remains Firebase-specific
|
|
12
|
+
* and is handled directly in pd-provider-firebase.
|
|
13
|
+
*/
|
|
14
|
+
export interface ServiceProvider {
|
|
15
|
+
/** Authentication provider (required) */
|
|
16
|
+
auth: IAuthProvider;
|
|
17
|
+
/** Cloud functions provider (required) */
|
|
18
|
+
functions: IFunctionProvider;
|
|
19
|
+
/** File storage provider (required) */
|
|
20
|
+
storage: IStorageProvider;
|
|
21
|
+
/** Database provider (optional - not all apps need real-time database) */
|
|
22
|
+
database?: IDatabaseProvider;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=service-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-provider.d.ts","sourceRoot":"","sources":["../src/service-provider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,yCAAyC;IACzC,IAAI,EAAE,aAAa,CAAC;IAEpB,0CAA0C;IAC1C,SAAS,EAAE,iBAAiB,CAAC;IAE7B,uCAAuC;IACvC,OAAO,EAAE,gBAAgB,CAAC;IAE1B,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File upload request
|
|
3
|
+
*/
|
|
4
|
+
export interface UploadFileRequest {
|
|
5
|
+
/** Target file name in storage */
|
|
6
|
+
fileName: string;
|
|
7
|
+
/** Base64 encoded file data URL */
|
|
8
|
+
base64DataURL: string;
|
|
9
|
+
/** Human-readable description name */
|
|
10
|
+
descriptionName: string;
|
|
11
|
+
/** Detailed description */
|
|
12
|
+
description: string;
|
|
13
|
+
/** Storage bucket/container name */
|
|
14
|
+
storageName: string;
|
|
15
|
+
/** Reference key for grouping files */
|
|
16
|
+
referenceKey: string;
|
|
17
|
+
/** Optional subfolder path */
|
|
18
|
+
subFolderName?: string;
|
|
19
|
+
/** Mark file as read-only */
|
|
20
|
+
readonly?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Result of an upload operation
|
|
24
|
+
*/
|
|
25
|
+
export interface UploadResult {
|
|
26
|
+
/** Full storage path of uploaded file */
|
|
27
|
+
fullPath: string;
|
|
28
|
+
/** Download URL for the file */
|
|
29
|
+
downloadURL: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Stored document metadata
|
|
33
|
+
*/
|
|
34
|
+
export interface StorageDocument {
|
|
35
|
+
/** Storage bucket/container name */
|
|
36
|
+
storageName: string;
|
|
37
|
+
/** Reference key for grouping */
|
|
38
|
+
refKey: string;
|
|
39
|
+
/** File name */
|
|
40
|
+
fileName: string;
|
|
41
|
+
/** Full storage path */
|
|
42
|
+
filePath: string;
|
|
43
|
+
/** Optional subfolder */
|
|
44
|
+
subFolderName?: string;
|
|
45
|
+
/** MIME type or document type */
|
|
46
|
+
documentType?: string;
|
|
47
|
+
/** Human-readable description */
|
|
48
|
+
description?: string;
|
|
49
|
+
/** Description name */
|
|
50
|
+
descriptionName?: string;
|
|
51
|
+
/** Creation timestamp */
|
|
52
|
+
creation?: Date;
|
|
53
|
+
/** Creator user ID */
|
|
54
|
+
creator?: string;
|
|
55
|
+
/** File size in bytes */
|
|
56
|
+
size?: number;
|
|
57
|
+
/** Read-only flag */
|
|
58
|
+
readonly?: boolean;
|
|
59
|
+
/** Additional metadata */
|
|
60
|
+
metaData?: unknown;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Options for listing files
|
|
64
|
+
*/
|
|
65
|
+
export interface ListFilesOptions {
|
|
66
|
+
/** Storage bucket name */
|
|
67
|
+
storageName: string;
|
|
68
|
+
/** Reference key for filtering */
|
|
69
|
+
referenceKey: string;
|
|
70
|
+
/** Optional subfolder */
|
|
71
|
+
subFolderName?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Options for getting a single file
|
|
75
|
+
*/
|
|
76
|
+
export interface GetFileOptions {
|
|
77
|
+
/** Storage bucket name */
|
|
78
|
+
storageName: string;
|
|
79
|
+
/** Reference key */
|
|
80
|
+
referenceKey: string;
|
|
81
|
+
/** File name */
|
|
82
|
+
fileName: string;
|
|
83
|
+
/** Optional subfolder */
|
|
84
|
+
subFolderName?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* File storage provider interface
|
|
88
|
+
*
|
|
89
|
+
* Abstracts file storage operations from specific implementations
|
|
90
|
+
* (Firebase Storage, S3, Mock, etc.)
|
|
91
|
+
*/
|
|
92
|
+
export interface IStorageProvider {
|
|
93
|
+
/**
|
|
94
|
+
* Upload a file to storage
|
|
95
|
+
* @returns Upload result with path and download URL
|
|
96
|
+
*/
|
|
97
|
+
uploadFile(request: UploadFileRequest): Promise<UploadResult>;
|
|
98
|
+
/**
|
|
99
|
+
* Download a file from storage
|
|
100
|
+
* @returns Base64 encoded data URL
|
|
101
|
+
*/
|
|
102
|
+
downloadFile(options: GetFileOptions): Promise<string>;
|
|
103
|
+
/**
|
|
104
|
+
* Delete a file from storage
|
|
105
|
+
*/
|
|
106
|
+
deleteFile(options: GetFileOptions): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* List files in a storage location
|
|
109
|
+
* @returns Array of storage documents
|
|
110
|
+
*/
|
|
111
|
+
listFiles(options: ListFilesOptions): Promise<StorageDocument[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Get metadata for a single file
|
|
114
|
+
* @returns Storage document metadata or null if not found
|
|
115
|
+
*/
|
|
116
|
+
getFile(options: GetFileOptions): Promise<StorageDocument | null>;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,WAAW,CAAC,EAAE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AC;CACnE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@progressive-development/pd-provider-interfaces",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "Provider interfaces for pd-spa-helper - defines contracts for auth, database, storage, and functions providers",
|
|
5
|
+
"author": "PD Progressive Development",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/",
|
|
17
|
+
"package.json",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"devDependencies": {},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"pd",
|
|
24
|
+
"progressive",
|
|
25
|
+
"development",
|
|
26
|
+
"provider",
|
|
27
|
+
"interfaces",
|
|
28
|
+
"typescript"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "vite build",
|
|
32
|
+
"clean": "rm -rf dist",
|
|
33
|
+
"clean:all": "rm -rf dist node_modules pnpm-lock.yaml",
|
|
34
|
+
"lint": "eslint --ext .ts src --ignore-path ../../.eslintignore && prettier \"**/*.ts\" --check --ignore-path ../../.eslintignore",
|
|
35
|
+
"format": "eslint --ext .ts src --fix --ignore-path ../../.eslintignore && prettier \"**/*.ts\" --write --ignore-path ../../.eslintignore",
|
|
36
|
+
"check": "pnpm run lint && pnpm run build"
|
|
37
|
+
}
|
|
38
|
+
}
|