@quatrain/cloudwrapper 1.1.22 → 1.1.24
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 +12 -156
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,171 +1,27 @@
|
|
|
1
1
|
# @quatrain/cloudwrapper
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A comprehensive wrapper for cloud provider SDKs within the Quatrain framework.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Introduction
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
7
|
+
Instead of initializing multiple adapters (Auth, Backend, Storage) individually, `@quatrain/cloudwrapper` provides a unified entry point to initialize an entire ecosystem at once. For instance, if you are building exclusively on Firebase, the wrapper initializes Firestore, Firebase Auth, and Firebase Storage simultaneously using a single configuration object.
|
|
8
|
+
|
|
9
|
+
## Key Concepts
|
|
10
|
+
|
|
11
|
+
- **`CloudWrapper`**: The static registry where you define your wrapper.
|
|
12
|
+
- **`AbstractCloudWrapper`**: The base class that orchestrates the initialization of backend, auth, and storage adapters.
|
|
12
13
|
|
|
13
14
|
## Installation
|
|
14
15
|
|
|
15
16
|
```bash
|
|
16
17
|
npm install @quatrain/cloudwrapper
|
|
18
|
+
# You will also need an adapter, e.g.:
|
|
19
|
+
npm install @quatrain/cloudwrapper-firebase
|
|
17
20
|
```
|
|
18
21
|
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
### Extending AbstractCloudWrapper
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
import { AbstractCloudWrapper } from '@quatrain/cloudwrapper'
|
|
25
|
-
|
|
26
|
-
class MyCloudWrapper extends AbstractCloudWrapper {
|
|
27
|
-
constructor(params: any) {
|
|
28
|
-
super(params)
|
|
29
|
-
// Your initialization logic
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Implement your cloud-specific methods
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const wrapper = new MyCloudWrapper({
|
|
36
|
-
projectId: 'my-project',
|
|
37
|
-
region: 'us-central1',
|
|
38
|
-
})
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Using CloudWrapper Logger
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { CloudWrapper } from '@quatrain/cloudwrapper'
|
|
45
|
-
|
|
46
|
-
CloudWrapper.logger.info('Cloud function initialized')
|
|
47
|
-
CloudWrapper.logger.debug('Processing event...')
|
|
48
|
-
CloudWrapper.logger.error('Error occurred:', error)
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Database Trigger Definition
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
import { DatabaseTriggerType } from '@quatrain/cloudwrapper'
|
|
55
|
-
import { BackendAction } from '@quatrain/backend'
|
|
56
|
-
|
|
57
|
-
const userTrigger: DatabaseTriggerType = {
|
|
58
|
-
name: 'onUserCreate',
|
|
59
|
-
event: BackendAction.CREATE,
|
|
60
|
-
script: async (payload) => {
|
|
61
|
-
// Handle user creation
|
|
62
|
-
console.log('New user:', payload.after)
|
|
63
|
-
},
|
|
64
|
-
model: 'User',
|
|
65
|
-
path: '/users/{userId}',
|
|
66
|
-
schema: 'public', // Optional
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Storage Trigger Definition
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
import {
|
|
74
|
-
StorageTriggerType,
|
|
75
|
-
StorageEventPayloadType,
|
|
76
|
-
} from '@quatrain/cloudwrapper'
|
|
77
|
-
import { BackendAction } from '@quatrain/backend'
|
|
78
|
-
|
|
79
|
-
const fileTrigger: StorageTriggerType = {
|
|
80
|
-
name: 'onFileUpload',
|
|
81
|
-
event: BackendAction.CREATE,
|
|
82
|
-
script: async (payload: StorageEventPayloadType) => {
|
|
83
|
-
const file = payload.after
|
|
84
|
-
console.log('File uploaded:', file?.fullPath)
|
|
85
|
-
console.log('Size:', file?.size, 'bytes')
|
|
86
|
-
},
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Multiple Events
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
import { DatabaseTriggerType } from '@quatrain/cloudwrapper'
|
|
94
|
-
import { BackendAction } from '@quatrain/backend'
|
|
95
|
-
|
|
96
|
-
const multiEventTrigger: DatabaseTriggerType = {
|
|
97
|
-
name: 'onPostChange',
|
|
98
|
-
event: [BackendAction.CREATE, BackendAction.UPDATE],
|
|
99
|
-
script: async (payload) => {
|
|
100
|
-
const before = payload.before
|
|
101
|
-
const after = payload.after
|
|
102
|
-
|
|
103
|
-
if (!before) {
|
|
104
|
-
console.log('Post created')
|
|
105
|
-
} else {
|
|
106
|
-
console.log('Post updated')
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
model: 'Post',
|
|
110
|
-
path: '/posts/{postId}',
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Type Definitions
|
|
115
|
-
|
|
116
|
-
### DatabaseTriggerType
|
|
117
|
-
|
|
118
|
-
Defines triggers for database operations (create, update, delete).
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
interface DatabaseTriggerType {
|
|
122
|
-
name: string
|
|
123
|
-
event: BackendAction | BackendAction[]
|
|
124
|
-
script: Function
|
|
125
|
-
model: string // Database model/table name
|
|
126
|
-
path: string // Path pattern for the trigger
|
|
127
|
-
schema?: string // Optional database schema
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### StorageTriggerType
|
|
132
|
-
|
|
133
|
-
Defines triggers for storage operations (file upload, update, delete).
|
|
134
|
-
|
|
135
|
-
```typescript
|
|
136
|
-
interface StorageTriggerType {
|
|
137
|
-
name: string
|
|
138
|
-
event: BackendAction | BackendAction[]
|
|
139
|
-
script: Function
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### StorageEventPayloadType
|
|
144
|
-
|
|
145
|
-
Payload structure for storage events.
|
|
146
|
-
|
|
147
|
-
```typescript
|
|
148
|
-
interface StorageEventPayloadType {
|
|
149
|
-
before: FileType | undefined // File state before event
|
|
150
|
-
after: FileType | undefined // File state after event
|
|
151
|
-
context: any // Additional context
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## Platform Adapters
|
|
156
|
-
|
|
157
|
-
This package serves as the foundation. Specific implementations are available:
|
|
158
|
-
|
|
159
|
-
- **[@quatrain/cloudwrapper-firebase](../cloudwrapper-firebase)** - Firebase Functions adapter
|
|
160
|
-
- **[@quatrain/cloudwrapper-supabase](../cloudwrapper-supabase)** - Supabase Edge Functions adapter
|
|
161
|
-
|
|
162
|
-
## BackendAction Enum
|
|
163
|
-
|
|
164
|
-
Triggers use the `BackendAction` enum from `@quatrain/backend`:
|
|
22
|
+
## Architecture
|
|
165
23
|
|
|
166
|
-
|
|
167
|
-
- `BackendAction.UPDATE` - Resource modification
|
|
168
|
-
- `BackendAction.DELETE` - Resource deletion
|
|
24
|
+
The wrapper acts as a macro. When you configure and register it, it automatically creates and registers the underlying `@quatrain/backend`, `@quatrain/storage`, and `@quatrain/auth` adapters with the respective registries.
|
|
169
25
|
|
|
170
26
|
## License
|
|
171
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/cloudwrapper",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.24",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"description": "Cloud wrappers commons",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
],
|
|
15
15
|
"author": "Quatrain Développement SAS <developers@quatrain.com>",
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@quatrain/backend": "^1.1.
|
|
18
|
-
"@quatrain/core": "^1.1.
|
|
17
|
+
"@quatrain/backend": "^1.1.34",
|
|
18
|
+
"@quatrain/core": "^1.1.48"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@tsconfig/recommended": "^1.0.1",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"bump-to": "yarn version"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@quatrain/backend": "^1.1.
|
|
40
|
-
"@quatrain/core": "^1.1.
|
|
39
|
+
"@quatrain/backend": "^1.1.34",
|
|
40
|
+
"@quatrain/core": "^1.1.48",
|
|
41
41
|
"@quatrain/storage": "^1.1"
|
|
42
42
|
}
|
|
43
43
|
}
|