@appweaver/create-weaver-app 1.3.1 → 1.4.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/package.json +1 -1
- package/skill/GUIDELINES.md +18 -4
- package/skill/SKILL.md +753 -707
- package/skill/references/cli.md +4 -0
- package/skill/references/client.md +609 -599
- package/skill/references/configuration.md +7 -6
- package/skill/references/resources.md +237 -43
- package/skill/references/security.md +29 -5
- package/skill/references/storage.md +38 -4
- package/templates/default/appweaver.test.json.tpl +2 -1
- package/templates/default/src/resources/user/service.ts.tpl +2 -1
package/package.json
CHANGED
package/skill/GUIDELINES.md
CHANGED
|
@@ -84,6 +84,9 @@ export default createModel({
|
|
|
84
84
|
});
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
+
Index entries are field names, nested in an array for a composite index (`[['status', 'createdAt']]`). Prefix a name
|
|
88
|
+
with `-` for a descending index or `+` for an ascending one (`['-createdAt']`); unprefixed uses the database default.
|
|
89
|
+
|
|
87
90
|
### Service
|
|
88
91
|
|
|
89
92
|
```ts
|
|
@@ -101,6 +104,15 @@ export default createService({
|
|
|
101
104
|
});
|
|
102
105
|
```
|
|
103
106
|
|
|
107
|
+
Inject a resource service anywhere with the `<Model>ResourceService` alias `weaver generate` emits per model:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { injectService } from '@appweaver/core';
|
|
111
|
+
import { ProductResourceService } from '@/types/generated';
|
|
112
|
+
|
|
113
|
+
const products = injectService<ProductResourceService>('Product');
|
|
114
|
+
```
|
|
115
|
+
|
|
104
116
|
### Routes
|
|
105
117
|
|
|
106
118
|
```ts
|
|
@@ -141,9 +153,10 @@ Use `createAuthModel` and `createAuthService` for authenticatable users. They mu
|
|
|
141
153
|
`createAuthModel` adds: `email`, `passwordHash`, `verifiedEmail`, `twoFactorAuth`, `enabled`, `logoutAt` scalars; a
|
|
142
154
|
virtual `password` field; a `roles` relation; and optional `apiKeys` relation.
|
|
143
155
|
|
|
144
|
-
`createAuthService` supports an optional `registrationData` callback to customize the registration payload
|
|
145
|
-
|
|
146
|
-
|
|
156
|
+
`createAuthService` supports an optional `registrationData` callback to customize the registration payload, an optional
|
|
157
|
+
`registrationFiles` callback that stores files on the model's file fields right after the user is created (used to keep
|
|
158
|
+
the avatar an OAuth2 provider serves), and an optional `checkOAuth2User` callback to allow or reject OAuth2
|
|
159
|
+
registrations/logins (return nothing to proceed, or a string/`Error` to abort).
|
|
147
160
|
|
|
148
161
|
```ts
|
|
149
162
|
// src/resources/user/model.ts
|
|
@@ -162,7 +175,8 @@ import { createAuthService } from '@appweaver/core';
|
|
|
162
175
|
|
|
163
176
|
export default createAuthService({
|
|
164
177
|
modelName: 'User',
|
|
165
|
-
registrationData: (_, email, password) => ({ email, password, roles: [1, 2] })
|
|
178
|
+
registrationData: (_, email, password) => ({ email, password, roles: [1, 2] }),
|
|
179
|
+
registrationFiles: (_, data) => ({ avatar: data?.avatarFile })
|
|
166
180
|
});
|
|
167
181
|
```
|
|
168
182
|
|