@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appweaver/create-weaver-app",
3
- "version": "1.3.1",
3
+ "version": "1.4.1",
4
4
  "description": "Appweaver - the backend framework for AI-first development (@create-weaver-app)",
5
5
  "author": "Luka Matosevic",
6
6
  "license": "MIT",
@@ -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 and an
145
- optional `checkOAuth2User` callback to allow or reject OAuth2 registrations/logins (return nothing to proceed, or a
146
- string/`Error` to abort).
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