@codenameryuu/adonis-lucid-soft-deletes 1.1.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/LICENSE.md +9 -0
- package/README.md +266 -0
- package/build/chunk-4FLDNTDF.js +32 -0
- package/build/chunk-4FLDNTDF.js.map +1 -0
- package/build/chunk-EUXUH3YW.js +15 -0
- package/build/chunk-EUXUH3YW.js.map +1 -0
- package/build/configure.d.ts +2 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +128 -0
- package/build/index.js.map +1 -0
- package/build/providers/lucid_soft_deletes_provider.d.ts +6 -0
- package/build/providers/lucid_soft_deletes_provider.js +19 -0
- package/build/providers/lucid_soft_deletes_provider.js.map +1 -0
- package/build/src/bindings/model_query_builder.d.ts +4 -0
- package/build/src/bindings/model_query_builder.js +8 -0
- package/build/src/bindings/model_query_builder.js.map +1 -0
- package/build/src/mixin.d.ts +186 -0
- package/build/src/types/querybuilder.d.ts +18 -0
- package/build/src/types/querybuilder.js +1 -0
- package/build/src/types/querybuilder.js.map +1 -0
- package/package.json +122 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Lookin Anton
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# Adonis Lucid Soft Deletes
|
|
2
|
+
|
|
3
|
+
> Works with AdonisJS v6
|
|
4
|
+
|
|
5
|
+
Docs for [AdonisJS v5](https://github.com/lookinlab/adonis-lucid-soft-deletes/tree/v1)
|
|
6
|
+
|
|
7
|
+
[![npm-image]][npm-url] [![license-image]][license-url] [![typescript-image]][typescript-url]
|
|
8
|
+
|
|
9
|
+
This addon adds the functionality to soft deletes Lucid Models through the `deleted_at` flag
|
|
10
|
+
|
|
11
|
+
> Works with `@adonisjs/lucid@^21.1.*`
|
|
12
|
+
|
|
13
|
+
Sometimes use the `deleted_at` flag for soft deletes could be not good way. More [about it](https://brandur.org/soft-deletion)
|
|
14
|
+
|
|
15
|
+
## Introduction
|
|
16
|
+
|
|
17
|
+
Sometimes you may wish to "no-delete" a model from database.
|
|
18
|
+
When models are soft deleted, they are not actually removed from your database.
|
|
19
|
+
Instead, a `deleted_at` attribute is set on the model indicating the date
|
|
20
|
+
and time at which the model was "deleted".
|
|
21
|
+
|
|
22
|
+
:point_right: The SoftDeletes mixin will automatically add the `deleted_at` attribute
|
|
23
|
+
as Luxon / DateTime instance.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
Install it using `npm`, `yarn` or `pnpm`.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# npm
|
|
31
|
+
npm i adonis-lucid-soft-deletes
|
|
32
|
+
|
|
33
|
+
# yarn
|
|
34
|
+
yarn add adonis-lucid-soft-deletes
|
|
35
|
+
|
|
36
|
+
# pnpm
|
|
37
|
+
pnpm add adonis-lucid-soft-deletes
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
After install call `configure`:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
node ace configure adonis-lucid-soft-deletes
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
Make sure to register the provider inside `adonisrc.ts` file.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
providers: [
|
|
52
|
+
// ...
|
|
53
|
+
() => import('adonis-lucid-soft-deletes/provider'),
|
|
54
|
+
]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
You should add the `deleted_at` column to your database tables for models with soft deletes.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
// migrations/1234566666_users.ts
|
|
61
|
+
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
62
|
+
|
|
63
|
+
export default class Users extends BaseSchema {
|
|
64
|
+
protected tableName = 'users'
|
|
65
|
+
|
|
66
|
+
async up() {
|
|
67
|
+
this.schema.createTable(this.tableName, (table) => {
|
|
68
|
+
// ...
|
|
69
|
+
table.timestamp('deleted_at').nullable()
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
// ...
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Applying Soft Deletes to a Model
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { compose } from '@adonisjs/core/helpers'
|
|
80
|
+
import { SoftDeletes } from 'adonis-lucid-soft-deletes'
|
|
81
|
+
|
|
82
|
+
export default class User extends compose(BaseModel, SoftDeletes) {
|
|
83
|
+
// ...columns and props
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Now, when you call the `.delete()` method on the model, the `deleted_at` (`customDeletedAtColumn`) column
|
|
88
|
+
will be set to the current date and time. However, the model's database record will be left in the table.
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import type { HttpContext } from '@adonisjs/core/http'
|
|
92
|
+
import User from '#models/user'
|
|
93
|
+
|
|
94
|
+
export default class UsersController {
|
|
95
|
+
/**
|
|
96
|
+
* Delete user by id
|
|
97
|
+
* DELETE /users/:id
|
|
98
|
+
*/
|
|
99
|
+
async destroy({ params, response }: HttpContext) {
|
|
100
|
+
const user = await User.findOrFail(params.id)
|
|
101
|
+
await user.delete()
|
|
102
|
+
|
|
103
|
+
return user // or response.noContent()
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> :boom: Soft delete only works for model instances. `await User.query().delete()` as before
|
|
109
|
+
> will delete models from database
|
|
110
|
+
|
|
111
|
+
:point_right: When querying a model that uses soft deletes, the soft deleted models
|
|
112
|
+
will automatically be excluded from all query results.
|
|
113
|
+
|
|
114
|
+
To determine if a given model instance has been soft deleted, you may use the `.trashed` getter:
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import type { HttpContext } from '@adonisjs/core/http'
|
|
118
|
+
import User from '#models/user'
|
|
119
|
+
|
|
120
|
+
export default class UsersController {
|
|
121
|
+
/**
|
|
122
|
+
* Get user by id
|
|
123
|
+
* GET /users/:id
|
|
124
|
+
*/
|
|
125
|
+
async show({ params }: HttpContext) {
|
|
126
|
+
const user = await User.withTrashed().where('id', params.id).firstOrFail()
|
|
127
|
+
if (user.trashed) {
|
|
128
|
+
return response.forbidden()
|
|
129
|
+
}
|
|
130
|
+
return user
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Set custom column name for `deletedAt`
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { compose } from '@adonisjs/core/helpers'
|
|
139
|
+
import { SoftDeletes } from 'adonis-lucid-soft-deletes'
|
|
140
|
+
|
|
141
|
+
export default class User extends compose(BaseModel, SoftDeletes) {
|
|
142
|
+
// ...columns and props
|
|
143
|
+
|
|
144
|
+
@column.dateTime({ columnName: 'customDeletedAtColumn' })
|
|
145
|
+
declare deletedAt: DateTime | null
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Restoring Soft Deleted Models
|
|
150
|
+
|
|
151
|
+
To restore a soft deleted model, you may call the `.restore()` method on a model instance.
|
|
152
|
+
Also, method `.restore()` exists after methods `.withTrashed()` and `.onlyTrashed()`
|
|
153
|
+
The `restore` method will set the model's `deleted_at` column to `null`:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import type { HttpContext } from '@adonisjs/core/http'
|
|
157
|
+
import User from '#models/user'
|
|
158
|
+
|
|
159
|
+
export default class TrashUsersController {
|
|
160
|
+
/**
|
|
161
|
+
* Update trashed user by id
|
|
162
|
+
* PUT /trash/users/:id
|
|
163
|
+
*/
|
|
164
|
+
async update({ params }: HttpContext) {
|
|
165
|
+
const user = await User.withTrashed().where('id', params.id).firstOrFail()
|
|
166
|
+
await user.restore()
|
|
167
|
+
|
|
168
|
+
return user
|
|
169
|
+
|
|
170
|
+
// or
|
|
171
|
+
|
|
172
|
+
await User.withTrashed().where('id', params.id).restore()
|
|
173
|
+
await User.query().withTrashed().where('id', params.id).restore()
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Permanently Deleting Models
|
|
179
|
+
|
|
180
|
+
Sometimes you may need to truly remove a model from your database.
|
|
181
|
+
You may use the `.forceDelete()` method to permanently remove a soft deleted model from the database table:
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
import type { HttpContext } from '@adonisjs/core/http'
|
|
185
|
+
import User from '#models/user'
|
|
186
|
+
|
|
187
|
+
export default class UsersController {
|
|
188
|
+
/**
|
|
189
|
+
* Delete user by id
|
|
190
|
+
* DELETE /users/:id
|
|
191
|
+
*/
|
|
192
|
+
async destroy({ params, response }: HttpContext) {
|
|
193
|
+
const user = await User.findOrFail(params.id)
|
|
194
|
+
await user.forceDelete()
|
|
195
|
+
|
|
196
|
+
return response.noContent()
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Including Soft Deleted Models
|
|
202
|
+
|
|
203
|
+
As noted above, soft deleted models will automatically be excluded from query results.
|
|
204
|
+
However, you may force soft deleted models to be included in a query's results
|
|
205
|
+
by calling the `.withTrashed()` method on the model:
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
import type { HttpContext } from '@adonisjs/core/http'
|
|
209
|
+
import User from '#models/user'
|
|
210
|
+
|
|
211
|
+
export default class UsersController {
|
|
212
|
+
/**
|
|
213
|
+
* Get a list users
|
|
214
|
+
* GET /users?withTrashed=1
|
|
215
|
+
*/
|
|
216
|
+
async index({ request }: HttpContext) {
|
|
217
|
+
const usersQuery = request.input('withTrashed') ? User.withTrashed() : User.query()
|
|
218
|
+
|
|
219
|
+
return usersQuery.exec()
|
|
220
|
+
|
|
221
|
+
// or
|
|
222
|
+
|
|
223
|
+
return User.query()
|
|
224
|
+
.if(request.input('withTrashed'), (query) => {
|
|
225
|
+
query.withTrashed()
|
|
226
|
+
})
|
|
227
|
+
.exec()
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Retrieving only Soft Deleted Models
|
|
233
|
+
|
|
234
|
+
The `.onlyTrashed()` method will retrieve **only** soft deleted models:
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
import type { HttpContext } from '@adonisjs/core/http'
|
|
238
|
+
import User from '#models/user'
|
|
239
|
+
|
|
240
|
+
export default class TrashUsersController {
|
|
241
|
+
/**
|
|
242
|
+
* Get a list trashed users
|
|
243
|
+
* GET /trash/users
|
|
244
|
+
*/
|
|
245
|
+
async index({ request }: HttpContext) {
|
|
246
|
+
return User.onlyTrashed().exec()
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Soft Deletes methods
|
|
252
|
+
|
|
253
|
+
Methods `.withTrashed()`, `.onlyTrashed()` and `.restore()` also available
|
|
254
|
+
in ModelQueryBuilder for models with soft delete, example:
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
await User.query().withTrashed().exec()
|
|
258
|
+
await User.query().onlyTrashed().restore()
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
[npm-image]: https://img.shields.io/npm/v/adonis-lucid-soft-deletes?logo=npm&style=for-the-badge
|
|
262
|
+
[npm-url]: https://www.npmjs.com/package/adonis-lucid-soft-deletes
|
|
263
|
+
[license-image]: https://img.shields.io/npm/l/adonis-lucid-soft-deletes?style=for-the-badge&color=blueviolet
|
|
264
|
+
[license-url]: https://github.com/lookinlab/adonis-lucid-soft-deletes/blob/develop/LICENSE.md
|
|
265
|
+
[typescript-image]: https://img.shields.io/npm/types/adonis-lucid-soft-deletes?color=294E80&label=%20&logo=typescript&style=for-the-badge
|
|
266
|
+
[typescript-url]: https://github.com/lookinlab
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/bindings/model_query_builder.ts
|
|
2
|
+
import { Exception } from "@adonisjs/core/exceptions";
|
|
3
|
+
function ensureModelWithSoftDeletes(model) {
|
|
4
|
+
if (!("ignoreDeleted" in model && "ignoreDeletedPaginate" in model)) {
|
|
5
|
+
throw new Exception(`${model.name} model don't support Soft Deletes`, {
|
|
6
|
+
code: "E_MODEL_SOFT_DELETE",
|
|
7
|
+
status: 500
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function extendModelQueryBuilder(builder) {
|
|
12
|
+
builder.macro("restore", async function() {
|
|
13
|
+
ensureModelWithSoftDeletes(this.model);
|
|
14
|
+
const deletedAtColumn = this.model.$getColumn("deletedAt")?.columnName;
|
|
15
|
+
if (!deletedAtColumn) return;
|
|
16
|
+
await this.update({ [deletedAtColumn]: null });
|
|
17
|
+
});
|
|
18
|
+
builder.macro("withTrashed", function() {
|
|
19
|
+
ensureModelWithSoftDeletes(this.model);
|
|
20
|
+
return this.model.disableIgnore(this);
|
|
21
|
+
});
|
|
22
|
+
builder.macro("onlyTrashed", function() {
|
|
23
|
+
ensureModelWithSoftDeletes(this.model);
|
|
24
|
+
const deletedAtColumn = this.model.$getColumn("deletedAt")?.columnName;
|
|
25
|
+
return this.model.disableIgnore(this).whereNotNull(`${this.model.table}.${deletedAtColumn}`);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
extendModelQueryBuilder
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=chunk-4FLDNTDF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bindings/model_query_builder.ts"],"sourcesContent":["/*\n * adonis-lucid-soft-deletes\n *\n * (c) Lookin Anton <alsd@lookinlab.ru>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type {\n LucidModel,\n ModelQueryBuilderContract,\n ModelWithSoftDeletes,\n} from '@adonisjs/lucid/types/model'\n\nimport { Exception } from '@adonisjs/core/exceptions'\n\n/**\n * Raises exception when model not with soft delete\n */\nfunction ensureModelWithSoftDeletes(model: LucidModel) {\n if (!('ignoreDeleted' in model && 'ignoreDeletedPaginate' in model)) {\n throw new Exception(`${model.name} model don't support Soft Deletes`, {\n code: 'E_MODEL_SOFT_DELETE',\n status: 500,\n })\n }\n}\n\n/**\n * Define SoftDeletes binding to ModelQueryBuilder\n */\nexport function extendModelQueryBuilder(builder: any) {\n builder.macro('restore', async function (this: ModelQueryBuilderContract<LucidModel>) {\n ensureModelWithSoftDeletes(this.model)\n\n const deletedAtColumn = this.model.$getColumn('deletedAt')?.columnName\n if (!deletedAtColumn) return\n\n await this.update({ [deletedAtColumn]: null })\n })\n\n builder.macro('withTrashed', function (this: ModelQueryBuilderContract<ModelWithSoftDeletes>) {\n ensureModelWithSoftDeletes(this.model)\n return this.model.disableIgnore(this)\n })\n\n builder.macro('onlyTrashed', function (this: ModelQueryBuilderContract<ModelWithSoftDeletes>) {\n ensureModelWithSoftDeletes(this.model)\n\n const deletedAtColumn = this.model.$getColumn('deletedAt')?.columnName\n return this.model.disableIgnore(this).whereNotNull(`${this.model.table}.${deletedAtColumn}`)\n })\n}\n"],"mappings":";AAeA,SAAS,iBAAiB;AAK1B,SAAS,2BAA2B,OAAmB;AACrD,MAAI,EAAE,mBAAmB,SAAS,2BAA2B,QAAQ;AACnE,UAAM,IAAI,UAAU,GAAG,MAAM,IAAI,qCAAqC;AAAA,MACpE,MAAM;AAAA,MACN,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AACF;AAKO,SAAS,wBAAwB,SAAc;AACpD,UAAQ,MAAM,WAAW,iBAA6D;AACpF,+BAA2B,KAAK,KAAK;AAErC,UAAM,kBAAkB,KAAK,MAAM,WAAW,WAAW,GAAG;AAC5D,QAAI,CAAC,gBAAiB;AAEtB,UAAM,KAAK,OAAO,EAAE,CAAC,eAAe,GAAG,KAAK,CAAC;AAAA,EAC/C,CAAC;AAED,UAAQ,MAAM,eAAe,WAAiE;AAC5F,+BAA2B,KAAK,KAAK;AACrC,WAAO,KAAK,MAAM,cAAc,IAAI;AAAA,EACtC,CAAC;AAED,UAAQ,MAAM,eAAe,WAAiE;AAC5F,+BAA2B,KAAK,KAAK;AAErC,UAAM,kBAAkB,KAAK,MAAM,WAAW,WAAW,GAAG;AAC5D,WAAO,KAAK,MAAM,cAAc,IAAI,EAAE,aAAa,GAAG,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE;AAAA,EAC7F,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
__decorateClass
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=chunk-EUXUH3YW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__decorateClass
|
|
3
|
+
} from "./chunk-EUXUH3YW.js";
|
|
4
|
+
|
|
5
|
+
// configure.ts
|
|
6
|
+
async function configure(command) {
|
|
7
|
+
const codemods = await command.createCodemods();
|
|
8
|
+
await codemods.updateRcFile((rcFile) => {
|
|
9
|
+
rcFile.addProvider("@codenameryuu/adonis-lucid-soft-deletes/provider");
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/mixin.ts
|
|
14
|
+
import { DateTime } from "luxon";
|
|
15
|
+
import { Exception } from "@adonisjs/core/exceptions";
|
|
16
|
+
import { column, beforeFind, beforeFetch, beforePaginate } from "@adonisjs/lucid/orm";
|
|
17
|
+
function SoftDeletes(superclass) {
|
|
18
|
+
class ModelWithSoftDeletes extends superclass {
|
|
19
|
+
static ignoreDeleted(query) {
|
|
20
|
+
if (query["ignoreDeleted"] === false) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const isGroupLimitQuery = query.clone().toQuery().includes("adonis_group_limit_counter");
|
|
24
|
+
const deletedAtColumn = query.model.$getColumn("deletedAt")?.columnName;
|
|
25
|
+
const queryIgnoreDeleted = isGroupLimitQuery ? query.knexQuery["_single"].table : query;
|
|
26
|
+
queryIgnoreDeleted.whereNull(`${query.model.table}.${deletedAtColumn}`);
|
|
27
|
+
}
|
|
28
|
+
static ignoreDeletedPaginate([countQuery, query]) {
|
|
29
|
+
countQuery["ignoreDeleted"] = query["ignoreDeleted"];
|
|
30
|
+
this.ignoreDeleted(countQuery);
|
|
31
|
+
}
|
|
32
|
+
static disableIgnore(query) {
|
|
33
|
+
if (query["ignoreDeleted"] === false) {
|
|
34
|
+
return query;
|
|
35
|
+
}
|
|
36
|
+
query["ignoreDeleted"] = false;
|
|
37
|
+
return query;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Fetch all models without filter by deleted_at
|
|
41
|
+
*/
|
|
42
|
+
static withTrashed() {
|
|
43
|
+
const query = this.query();
|
|
44
|
+
return this.disableIgnore(query);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fetch models only with deleted_at
|
|
48
|
+
*/
|
|
49
|
+
static onlyTrashed() {
|
|
50
|
+
const query = this.query();
|
|
51
|
+
const deletedAtColumn = query.model.$getColumn("deletedAt")?.columnName;
|
|
52
|
+
return this.disableIgnore(query).whereNotNull(`${query.model.table}.${deletedAtColumn}`);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Force delete instance property
|
|
56
|
+
*/
|
|
57
|
+
$forceDelete = false;
|
|
58
|
+
/**
|
|
59
|
+
* Computed trashed property
|
|
60
|
+
*/
|
|
61
|
+
get trashed() {
|
|
62
|
+
return this.deletedAt !== null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Override default $getQueryFor method
|
|
66
|
+
*/
|
|
67
|
+
$getQueryFor(action, client) {
|
|
68
|
+
const softDelete = async () => {
|
|
69
|
+
this.deletedAt = DateTime.local();
|
|
70
|
+
await this.save();
|
|
71
|
+
};
|
|
72
|
+
if (action === "delete" && !this.$forceDelete) {
|
|
73
|
+
return { del: softDelete, delete: softDelete };
|
|
74
|
+
}
|
|
75
|
+
if (action === "insert") {
|
|
76
|
+
return super.$getQueryFor(action, client);
|
|
77
|
+
}
|
|
78
|
+
return super.$getQueryFor(action, client);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Override default delete method
|
|
82
|
+
*/
|
|
83
|
+
async delete() {
|
|
84
|
+
await super.delete();
|
|
85
|
+
this.$isDeleted = this.$forceDelete;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Restore model
|
|
89
|
+
*/
|
|
90
|
+
async restore() {
|
|
91
|
+
if (this.$isDeleted) {
|
|
92
|
+
throw new Exception("Cannot restore a model instance is was force deleted", {
|
|
93
|
+
code: "E_MODEL_FORCE_DELETED",
|
|
94
|
+
status: 500
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (!this.trashed) {
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
this.deletedAt = null;
|
|
101
|
+
await this.save();
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Force delete model
|
|
106
|
+
*/
|
|
107
|
+
async forceDelete() {
|
|
108
|
+
this.$forceDelete = true;
|
|
109
|
+
await this.delete();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
__decorateClass([
|
|
113
|
+
column.dateTime()
|
|
114
|
+
], ModelWithSoftDeletes.prototype, "deletedAt", 2);
|
|
115
|
+
__decorateClass([
|
|
116
|
+
beforeFind(),
|
|
117
|
+
beforeFetch()
|
|
118
|
+
], ModelWithSoftDeletes, "ignoreDeleted", 1);
|
|
119
|
+
__decorateClass([
|
|
120
|
+
beforePaginate()
|
|
121
|
+
], ModelWithSoftDeletes, "ignoreDeletedPaginate", 1);
|
|
122
|
+
return ModelWithSoftDeletes;
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
SoftDeletes,
|
|
126
|
+
configure
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../configure.ts","../src/mixin.ts"],"sourcesContent":["/*\n * adonis-lucid-soft-deletes\n *\n * (c) Lookin Anton <alsd@lookinlab.ru>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type Configure from '@adonisjs/core/commands/configure'\n\nexport async function configure(command: Configure) {\n const codemods = await command.createCodemods()\n\n await codemods.updateRcFile((rcFile) => {\n rcFile.addProvider('@codenameryuu/adonis-lucid-soft-deletes/provider')\n })\n}\n","/*\n * adonis-lucid-soft-deletes\n *\n * (c) Lookin Anton <alsd@lookinlab.ru>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { DateTime } from 'luxon'\nimport type { NormalizeConstructor } from '@adonisjs/core/types/helpers'\nimport type { LucidModel, ModelQueryBuilderContract } from '@adonisjs/lucid/types/model'\nimport type { QueryClientContract } from '@adonisjs/lucid/types/database'\nimport { Exception } from '@adonisjs/core/exceptions'\nimport { column, beforeFind, beforeFetch, beforePaginate, BaseModel } from '@adonisjs/lucid/orm'\n\ntype ModelQueryBuilderContractWithIgnoreDeleted<\n T extends LucidModel,\n R = InstanceType<T>,\n> = ModelQueryBuilderContract<T, R> & {\n ignoreDeleted: boolean\n}\n\nexport function SoftDeletes<T extends NormalizeConstructor<typeof BaseModel>>(superclass: T) {\n class ModelWithSoftDeletes extends superclass {\n @beforeFind()\n @beforeFetch()\n static ignoreDeleted<Model extends typeof ModelWithSoftDeletes>(\n query: ModelQueryBuilderContractWithIgnoreDeleted<Model, InstanceType<Model>>\n ): void {\n if (query['ignoreDeleted'] === false) {\n return\n }\n const isGroupLimitQuery = query.clone().toQuery().includes('adonis_group_limit_counter')\n const deletedAtColumn = query.model.$getColumn('deletedAt')?.columnName\n\n const queryIgnoreDeleted = isGroupLimitQuery\n ? (query.knexQuery as any)['_single'].table\n : query\n\n queryIgnoreDeleted.whereNull(`${query.model.table}.${deletedAtColumn}`)\n }\n\n @beforePaginate()\n static ignoreDeletedPaginate<Model extends typeof ModelWithSoftDeletes>([countQuery, query]: [\n ModelQueryBuilderContractWithIgnoreDeleted<Model, InstanceType<Model>>,\n ModelQueryBuilderContractWithIgnoreDeleted<Model, InstanceType<Model>>,\n ]): void {\n countQuery['ignoreDeleted'] = query['ignoreDeleted']\n this.ignoreDeleted(countQuery)\n }\n\n static disableIgnore<Model extends typeof ModelWithSoftDeletes, Result = InstanceType<Model>>(\n this: Model,\n query: ModelQueryBuilderContractWithIgnoreDeleted<Model, Result>\n ): ModelQueryBuilderContractWithIgnoreDeleted<Model, Result> {\n if (query['ignoreDeleted'] === false) {\n return query\n }\n query['ignoreDeleted'] = false\n return query\n }\n\n /**\n * Fetch all models without filter by deleted_at\n */\n static withTrashed<Model extends typeof ModelWithSoftDeletes>(\n this: Model\n ): ModelQueryBuilderContractWithIgnoreDeleted<Model, InstanceType<T>> {\n const query = this.query() as ModelQueryBuilderContractWithIgnoreDeleted<\n Model,\n InstanceType<Model>\n >\n return this.disableIgnore(query)\n }\n\n /**\n * Fetch models only with deleted_at\n */\n static onlyTrashed<Model extends typeof ModelWithSoftDeletes>(\n this: Model\n ): ModelQueryBuilderContractWithIgnoreDeleted<Model, InstanceType<Model>> {\n const query = this.query() as ModelQueryBuilderContractWithIgnoreDeleted<\n Model,\n InstanceType<Model>\n >\n\n const deletedAtColumn = query.model.$getColumn('deletedAt')?.columnName\n return this.disableIgnore(query).whereNotNull(`${query.model.table}.${deletedAtColumn}`)\n }\n\n /**\n * Force delete instance property\n */\n $forceDelete = false\n\n /**\n * Soft deleted property\n */\n @column.dateTime()\n declare deletedAt?: DateTime | null\n\n /**\n * Computed trashed property\n */\n get trashed(): boolean {\n return this.deletedAt !== null\n }\n\n /**\n * Override default $getQueryFor method\n */\n $getQueryFor(\n action: 'insert' | 'update' | 'delete' | 'refresh',\n client: QueryClientContract\n ): any {\n /**\n * Soft Delete\n */\n const softDelete = async (): Promise<void> => {\n this.deletedAt = DateTime.local()\n await this.save()\n }\n\n if (action === 'delete' && !this.$forceDelete) {\n return { del: softDelete, delete: softDelete }\n }\n if (action === 'insert') {\n return super.$getQueryFor(action, client)\n }\n return super.$getQueryFor(action, client)\n }\n\n /**\n * Override default delete method\n */\n async delete(): Promise<void> {\n await super.delete()\n this.$isDeleted = this.$forceDelete\n }\n\n /**\n * Restore model\n */\n async restore(): Promise<this> {\n if (this.$isDeleted) {\n throw new Exception('Cannot restore a model instance is was force deleted', {\n code: 'E_MODEL_FORCE_DELETED',\n status: 500,\n })\n }\n if (!this.trashed) {\n return this\n }\n this.deletedAt = null\n await this.save()\n\n return this\n }\n\n /**\n * Force delete model\n */\n async forceDelete(): Promise<void> {\n this.$forceDelete = true\n await this.delete()\n }\n }\n return ModelWithSoftDeletes\n}\n"],"mappings":";;;;;AAWA,eAAsB,UAAU,SAAoB;AAClD,QAAM,WAAW,MAAM,QAAQ,eAAe;AAE9C,QAAM,SAAS,aAAa,CAAC,WAAW;AACtC,WAAO,YAAY,kDAAkD;AAAA,EACvE,CAAC;AACH;;;ACRA,SAAS,gBAAgB;AAIzB,SAAS,iBAAiB;AAC1B,SAAS,QAAQ,YAAY,aAAa,sBAAiC;AASpE,SAAS,YAA8D,YAAe;AAAA,EAC3F,MAAM,6BAA6B,WAAW;AAAA,IAG5C,OAAO,cACL,OACM;AACN,UAAI,MAAM,eAAe,MAAM,OAAO;AACpC;AAAA,MACF;AACA,YAAM,oBAAoB,MAAM,MAAM,EAAE,QAAQ,EAAE,SAAS,4BAA4B;AACvF,YAAM,kBAAkB,MAAM,MAAM,WAAW,WAAW,GAAG;AAE7D,YAAM,qBAAqB,oBACtB,MAAM,UAAkB,SAAS,EAAE,QACpC;AAEJ,yBAAmB,UAAU,GAAG,MAAM,MAAM,KAAK,IAAI,eAAe,EAAE;AAAA,IACxE;AAAA,IAGA,OAAO,sBAAiE,CAAC,YAAY,KAAK,GAGjF;AACP,iBAAW,eAAe,IAAI,MAAM,eAAe;AACnD,WAAK,cAAc,UAAU;AAAA,IAC/B;AAAA,IAEA,OAAO,cAEL,OAC2D;AAC3D,UAAI,MAAM,eAAe,MAAM,OAAO;AACpC,eAAO;AAAA,MACT;AACA,YAAM,eAAe,IAAI;AACzB,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,cAE+D;AACpE,YAAM,QAAQ,KAAK,MAAM;AAIzB,aAAO,KAAK,cAAc,KAAK;AAAA,IACjC;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO,cAEmE;AACxE,YAAM,QAAQ,KAAK,MAAM;AAKzB,YAAM,kBAAkB,MAAM,MAAM,WAAW,WAAW,GAAG;AAC7D,aAAO,KAAK,cAAc,KAAK,EAAE,aAAa,GAAG,MAAM,MAAM,KAAK,IAAI,eAAe,EAAE;AAAA,IACzF;AAAA;AAAA;AAAA;AAAA,IAKA,eAAe;AAAA;AAAA;AAAA;AAAA,IAWf,IAAI,UAAmB;AACrB,aAAO,KAAK,cAAc;AAAA,IAC5B;AAAA;AAAA;AAAA;AAAA,IAKA,aACE,QACA,QACK;AAIL,YAAM,aAAa,YAA2B;AAC5C,aAAK,YAAY,SAAS,MAAM;AAChC,cAAM,KAAK,KAAK;AAAA,MAClB;AAEA,UAAI,WAAW,YAAY,CAAC,KAAK,cAAc;AAC7C,eAAO,EAAE,KAAK,YAAY,QAAQ,WAAW;AAAA,MAC/C;AACA,UAAI,WAAW,UAAU;AACvB,eAAO,MAAM,aAAa,QAAQ,MAAM;AAAA,MAC1C;AACA,aAAO,MAAM,aAAa,QAAQ,MAAM;AAAA,IAC1C;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,SAAwB;AAC5B,YAAM,MAAM,OAAO;AACnB,WAAK,aAAa,KAAK;AAAA,IACzB;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,UAAyB;AAC7B,UAAI,KAAK,YAAY;AACnB,cAAM,IAAI,UAAU,wDAAwD;AAAA,UAC1E,MAAM;AAAA,UACN,QAAQ;AAAA,QACV,CAAC;AAAA,MACH;AACA,UAAI,CAAC,KAAK,SAAS;AACjB,eAAO;AAAA,MACT;AACA,WAAK,YAAY;AACjB,YAAM,KAAK,KAAK;AAEhB,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,cAA6B;AACjC,WAAK,eAAe;AACpB,YAAM,KAAK,OAAO;AAAA,IACpB;AAAA,EACF;AAnEU;AAAA,IADP,OAAO,SAAS;AAAA,KA3Eb,qBA4EI;AAzED;AAAA,IAFN,WAAW;AAAA,IACX,YAAY;AAAA,KAFT,sBAGG;AAiBA;AAAA,IADN,eAAe;AAAA,KAnBZ,sBAoBG;AA4HT,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extendModelQueryBuilder
|
|
3
|
+
} from "../chunk-4FLDNTDF.js";
|
|
4
|
+
import "../chunk-EUXUH3YW.js";
|
|
5
|
+
|
|
6
|
+
// providers/lucid_soft_deletes_provider.ts
|
|
7
|
+
var LucidSoftDeletesProvider = class {
|
|
8
|
+
constructor(app) {
|
|
9
|
+
this.app = app;
|
|
10
|
+
}
|
|
11
|
+
async boot() {
|
|
12
|
+
const { ModelQueryBuilder } = await this.app.import("@adonisjs/lucid/orm");
|
|
13
|
+
extendModelQueryBuilder(ModelQueryBuilder);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
LucidSoftDeletesProvider as default
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=lucid_soft_deletes_provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../providers/lucid_soft_deletes_provider.ts"],"sourcesContent":["/*\n * adonis-lucid-soft-deletes\n *\n * (c) Lookin Anton <alsd@lookinlab.ru>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n/// <reference path=\"../src/types/querybuilder.ts\" />\n\nimport type { ApplicationService } from '@adonisjs/core/types'\nimport { extendModelQueryBuilder } from '../src/bindings/model_query_builder.js'\n\nexport default class LucidSoftDeletesProvider {\n constructor(protected app: ApplicationService) {}\n\n async boot() {\n const { ModelQueryBuilder } = await this.app.import('@adonisjs/lucid/orm')\n extendModelQueryBuilder(ModelQueryBuilder)\n }\n}\n"],"mappings":";;;;;;AAcA,IAAqB,2BAArB,MAA8C;AAAA,EAC5C,YAAsB,KAAyB;AAAzB;AAAA,EAA0B;AAAA,EAEhD,MAAM,OAAO;AACX,UAAM,EAAE,kBAAkB,IAAI,MAAM,KAAK,IAAI,OAAO,qBAAqB;AACzE,4BAAwB,iBAAiB;AAAA,EAC3C;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
2
|
+
import type { NormalizeConstructor } from '@adonisjs/core/types/helpers';
|
|
3
|
+
import type { LucidModel, ModelQueryBuilderContract } from '@adonisjs/lucid/types/model';
|
|
4
|
+
import type { QueryClientContract } from '@adonisjs/lucid/types/database';
|
|
5
|
+
import { BaseModel } from '@adonisjs/lucid/orm';
|
|
6
|
+
type ModelQueryBuilderContractWithIgnoreDeleted<T extends LucidModel, R = InstanceType<T>> = ModelQueryBuilderContract<T, R> & {
|
|
7
|
+
ignoreDeleted: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function SoftDeletes<T extends NormalizeConstructor<typeof BaseModel>>(superclass: T): {
|
|
10
|
+
new (...args: any[]): {
|
|
11
|
+
/**
|
|
12
|
+
* Force delete instance property
|
|
13
|
+
*/
|
|
14
|
+
$forceDelete: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Soft deleted property
|
|
17
|
+
*/
|
|
18
|
+
deletedAt?: DateTime | null;
|
|
19
|
+
/**
|
|
20
|
+
* Computed trashed property
|
|
21
|
+
*/
|
|
22
|
+
get trashed(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Override default $getQueryFor method
|
|
25
|
+
*/
|
|
26
|
+
$getQueryFor(action: "insert" | "update" | "delete" | "refresh", client: QueryClientContract): any;
|
|
27
|
+
/**
|
|
28
|
+
* Override default delete method
|
|
29
|
+
*/
|
|
30
|
+
delete(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Restore model
|
|
33
|
+
*/
|
|
34
|
+
restore(): Promise</*elided*/ any>;
|
|
35
|
+
/**
|
|
36
|
+
* Force delete model
|
|
37
|
+
*/
|
|
38
|
+
forceDelete(): Promise<void>;
|
|
39
|
+
$attributes: import("@adonisjs/lucid/types/model").ModelObject;
|
|
40
|
+
$extras: import("@adonisjs/lucid/types/model").ModelObject;
|
|
41
|
+
$original: import("@adonisjs/lucid/types/model").ModelObject;
|
|
42
|
+
$preloaded: {
|
|
43
|
+
[relation: string]: import("@adonisjs/lucid/types/model").LucidRow | import("@adonisjs/lucid/types/model").LucidRow[];
|
|
44
|
+
};
|
|
45
|
+
$sideloaded: import("@adonisjs/lucid/types/model").ModelObject;
|
|
46
|
+
$primaryKeyValue?: number | string;
|
|
47
|
+
$isPersisted: boolean;
|
|
48
|
+
$isNew: boolean;
|
|
49
|
+
$isLocal: boolean;
|
|
50
|
+
$dirty: import("@adonisjs/lucid/types/model").ModelObject;
|
|
51
|
+
$isDirty: boolean;
|
|
52
|
+
$isDeleted: boolean;
|
|
53
|
+
$options?: import("@adonisjs/lucid/types/model").ModelOptions;
|
|
54
|
+
$trx?: import("@adonisjs/lucid/types/database").TransactionClientContract;
|
|
55
|
+
$setOptionsAndTrx(options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): void;
|
|
56
|
+
useTransaction(trx: import("@adonisjs/lucid/types/database").TransactionClientContract): /*elided*/ any;
|
|
57
|
+
useConnection(connection: string): /*elided*/ any;
|
|
58
|
+
$setAttribute(key: string, value: any): void;
|
|
59
|
+
$getAttribute(key: string): any;
|
|
60
|
+
$getAttributeFromCache(key: string, callback: import("@adonisjs/lucid/types/model").CacheNode["getter"]): any;
|
|
61
|
+
$hasRelated(key: string): boolean;
|
|
62
|
+
$setRelated(key: string, result: import("@adonisjs/lucid/types/querybuilder").OneOrMany<import("@adonisjs/lucid/types/model").LucidRow> | null): void;
|
|
63
|
+
$pushRelated(key: string, result: import("@adonisjs/lucid/types/querybuilder").OneOrMany<import("@adonisjs/lucid/types/model").LucidRow> | null): void;
|
|
64
|
+
$getRelated(key: string, defaultValue?: any): import("@adonisjs/lucid/types/querybuilder").OneOrMany<import("@adonisjs/lucid/types/model").LucidRow> | undefined | null;
|
|
65
|
+
$consumeAdapterResult(adapterResult: import("@adonisjs/lucid/types/model").ModelObject, sideloadAttributes?: import("@adonisjs/lucid/types/model").ModelObject): void;
|
|
66
|
+
$hydrateOriginals(): void;
|
|
67
|
+
fill(value: Partial<import("@adonisjs/lucid/types/model").ModelAttributes</*elided*/ any>>, allowExtraProperties?: boolean): /*elided*/ any;
|
|
68
|
+
merge(value: Partial<import("@adonisjs/lucid/types/model").ModelAttributes</*elided*/ any>>, allowExtraProperties?: boolean): /*elided*/ any;
|
|
69
|
+
isDirty(fields?: "$forceDelete" | "deletedAt" | "trashed" | ("$forceDelete" | "deletedAt" | "trashed" | undefined)[] | undefined): boolean;
|
|
70
|
+
enableForceUpdate(): /*elided*/ any;
|
|
71
|
+
save(): Promise</*elided*/ any>;
|
|
72
|
+
saveQuietly(): Promise</*elided*/ any>;
|
|
73
|
+
lockForUpdate<T_1>(callback: (user: /*elided*/ any) => T_1 | Promise<T_1>): Promise<T_1>;
|
|
74
|
+
deleteQuietly(): Promise<void>;
|
|
75
|
+
refresh(): Promise</*elided*/ any>;
|
|
76
|
+
load: import("@adonisjs/lucid/types/model").LucidRowPreload</*elided*/ any>;
|
|
77
|
+
loadOnce: import("@adonisjs/lucid/types/model").LucidRowPreloadOnce</*elided*/ any>;
|
|
78
|
+
preload: import("@adonisjs/lucid/types/model").LucidRowPreload</*elided*/ any>;
|
|
79
|
+
loadAggregate: <Self extends /*elided*/ any, Name extends import("@adonisjs/lucid/types/relations").ExtractModelRelations<Self>, RelatedBuilder = NonNullable<Self[Name]> extends import("@adonisjs/lucid/types/relations").ModelRelations<LucidModel, LucidModel> ? (import("@adonisjs/lucid/types/relations").ModelRelations<LucidModel, LucidModel> & Self[Name] & {})["subQuery"] : never>(name: Name, callback: (builder: RelatedBuilder) => void) => import("@adonisjs/lucid/types/model").LazyLoadAggregatesContract<Self>;
|
|
80
|
+
loadCount: <Self extends /*elided*/ any, Name extends import("@adonisjs/lucid/types/relations").ExtractModelRelations<Self>, RelatedBuilder = NonNullable<Self[Name]> extends import("@adonisjs/lucid/types/relations").ModelRelations<LucidModel, LucidModel> ? (import("@adonisjs/lucid/types/relations").ModelRelations<LucidModel, LucidModel> & Self[Name] & {})["subQuery"] : never>(name: Name, callback?: ((builder: RelatedBuilder) => void) | undefined) => import("@adonisjs/lucid/types/model").LazyLoadAggregatesContract<Self>;
|
|
81
|
+
serializeAttributes(fields?: import("@adonisjs/lucid/types/model").CherryPickFields, raw?: boolean): import("@adonisjs/lucid/types/model").ModelObject;
|
|
82
|
+
serializeComputed(fields?: import("@adonisjs/lucid/types/model").CherryPickFields): import("@adonisjs/lucid/types/model").ModelObject;
|
|
83
|
+
serializeRelations(fields: undefined, raw: true): {
|
|
84
|
+
[key: string]: import("@adonisjs/lucid/types/model").LucidRow | import("@adonisjs/lucid/types/model").LucidRow[];
|
|
85
|
+
};
|
|
86
|
+
serializeRelations(cherryPick: import("@adonisjs/lucid/types/model").CherryPick["relations"] | undefined, raw: false | undefined): import("@adonisjs/lucid/types/model").ModelObject;
|
|
87
|
+
serializeRelations(cherryPick?: import("@adonisjs/lucid/types/model").CherryPick["relations"], raw?: boolean): import("@adonisjs/lucid/types/model").ModelObject;
|
|
88
|
+
serialize(cherryPick?: import("@adonisjs/lucid/types/model").CherryPick): import("@adonisjs/lucid/types/model").ModelObject;
|
|
89
|
+
toObject(): import("@adonisjs/lucid/types/model").ModelObject;
|
|
90
|
+
toJSON(): import("@adonisjs/lucid/types/model").ModelObject;
|
|
91
|
+
toAttributes(): Record<string, any>;
|
|
92
|
+
related<Name extends undefined>(relation: Name): NonNullable</*elided*/ any[Name]> extends import("@adonisjs/lucid/types/relations").ModelRelations<LucidModel, LucidModel> ? (import("@adonisjs/lucid/types/relations").ModelRelations<LucidModel, LucidModel> & /*elided*/ any[Name] & {})["client"] : never;
|
|
93
|
+
};
|
|
94
|
+
ignoreDeleted<Model extends /*elided*/ any & T>(query: ModelQueryBuilderContractWithIgnoreDeleted<Model, InstanceType<Model>>): void;
|
|
95
|
+
ignoreDeletedPaginate<Model extends /*elided*/ any & T>([countQuery, query]: [ModelQueryBuilderContractWithIgnoreDeleted<Model, InstanceType<Model>>, ModelQueryBuilderContractWithIgnoreDeleted<Model, InstanceType<Model>>]): void;
|
|
96
|
+
disableIgnore<Model extends /*elided*/ any & T, Result = InstanceType<Model>>(this: Model, query: ModelQueryBuilderContractWithIgnoreDeleted<Model, Result>): ModelQueryBuilderContractWithIgnoreDeleted<Model, Result>;
|
|
97
|
+
/**
|
|
98
|
+
* Fetch all models without filter by deleted_at
|
|
99
|
+
*/
|
|
100
|
+
withTrashed<Model extends /*elided*/ any & T>(this: Model): ModelQueryBuilderContractWithIgnoreDeleted<Model, InstanceType<T>>;
|
|
101
|
+
/**
|
|
102
|
+
* Fetch models only with deleted_at
|
|
103
|
+
*/
|
|
104
|
+
onlyTrashed<Model extends /*elided*/ any & T>(this: Model): ModelQueryBuilderContractWithIgnoreDeleted<Model, InstanceType<Model>>;
|
|
105
|
+
readonly booted: boolean;
|
|
106
|
+
$columnsDefinitions: Map<string, import("@adonisjs/lucid/types/model").ModelColumnOptions>;
|
|
107
|
+
$relationsDefinitions: Map<string, import("@adonisjs/lucid/types/relations").RelationshipsContract>;
|
|
108
|
+
$computedDefinitions: Map<string, import("@adonisjs/lucid/types/model").ComputedOptions>;
|
|
109
|
+
primaryKey: string;
|
|
110
|
+
connection?: string | undefined;
|
|
111
|
+
namingStrategy: import("@adonisjs/lucid/types/model").NamingStrategyContract;
|
|
112
|
+
table: string;
|
|
113
|
+
selfAssignPrimaryKey: boolean;
|
|
114
|
+
$adapter: import("@adonisjs/lucid/types/model").AdapterContract;
|
|
115
|
+
useAdapter: (adapter: import("@adonisjs/lucid/types/model").AdapterContract) => void;
|
|
116
|
+
$hooks: import("@poppinss/hooks").default<any>;
|
|
117
|
+
$keys: {
|
|
118
|
+
attributesToColumns: import("@adonisjs/lucid/types/model").ModelKeysContract;
|
|
119
|
+
attributesToSerialized: import("@adonisjs/lucid/types/model").ModelKeysContract;
|
|
120
|
+
columnsToAttributes: import("@adonisjs/lucid/types/model").ModelKeysContract;
|
|
121
|
+
columnsToSerialized: import("@adonisjs/lucid/types/model").ModelKeysContract;
|
|
122
|
+
serializedToColumns: import("@adonisjs/lucid/types/model").ModelKeysContract;
|
|
123
|
+
serializedToAttributes: import("@adonisjs/lucid/types/model").ModelKeysContract;
|
|
124
|
+
columnAliasesToAttributes: import("@adonisjs/lucid/types/model").ModelKeysContract;
|
|
125
|
+
};
|
|
126
|
+
$createFromAdapterResult: <T_1 extends LucidModel>(this: T_1, result?: import("@adonisjs/lucid/types/model").ModelObject, sideloadAttributes?: import("@adonisjs/lucid/types/model").ModelObject, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => null | InstanceType<T_1>;
|
|
127
|
+
$createMultipleFromAdapterResult: <T_1 extends LucidModel>(this: T_1, results: import("@adonisjs/lucid/types/model").ModelObject[], sideloadAttributes?: import("@adonisjs/lucid/types/model").ModelObject, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => InstanceType<T_1>[];
|
|
128
|
+
$addColumn: (name: string, options: Partial<import("@adonisjs/lucid/types/model").ColumnOptions>) => import("@adonisjs/lucid/types/model").ColumnOptions;
|
|
129
|
+
$hasColumn: (name: string) => boolean;
|
|
130
|
+
$getColumn: (name: string) => import("@adonisjs/lucid/types/model").ModelColumnOptions | undefined;
|
|
131
|
+
$getColumnAlias: (columnName: string) => string;
|
|
132
|
+
columnsForSelect: () => Record<string, string>;
|
|
133
|
+
$addComputed: (name: string, options: Partial<import("@adonisjs/lucid/types/model").ComputedOptions>) => import("@adonisjs/lucid/types/model").ComputedOptions;
|
|
134
|
+
$hasComputed: (name: string) => boolean;
|
|
135
|
+
$getComputed: (name: string) => import("@adonisjs/lucid/types/model").ComputedOptions | undefined;
|
|
136
|
+
$addRelation: (name: string, type: import("@adonisjs/lucid/types/relations").ModelRelationTypes["__opaque_type"], relatedModel: () => LucidModel, options: import("@adonisjs/lucid/types/model").ModelRelationOptions) => void;
|
|
137
|
+
$hasRelation: (name: string) => boolean;
|
|
138
|
+
$getRelation: {
|
|
139
|
+
<Model extends LucidModel, Name extends import("@adonisjs/lucid/types/relations").ExtractModelRelations<InstanceType<Model>>>(this: Model, name: Name): NonNullable<InstanceType<Model>[Name]> extends import("@adonisjs/lucid/types/relations").ModelRelations<LucidModel, LucidModel> ? NonNullable<InstanceType<Model>[Name]>["client"]["relation"] : import("@adonisjs/lucid/types/relations").RelationshipsContract;
|
|
140
|
+
<Model extends LucidModel>(this: Model, name: string): import("@adonisjs/lucid/types/relations").RelationshipsContract;
|
|
141
|
+
};
|
|
142
|
+
$defineProperty: <Model extends LucidModel, Prop extends keyof Model>(this: Model, propertyName: Prop, defaultValue: Model[Prop], strategy: "inherit" | "define" | ((value: Model[Prop]) => Model[Prop])) => void;
|
|
143
|
+
boot: () => void;
|
|
144
|
+
before: {
|
|
145
|
+
<Model extends LucidModel, Event extends "find" | "fetch">(this: Model, event: Event, handler: import("@adonisjs/lucid/types/model").HooksHandler<ModelQueryBuilderContract<Model>, Event>): void;
|
|
146
|
+
<Model extends LucidModel>(this: Model, event: "paginate", handler: import("@adonisjs/lucid/types/model").HooksHandler<[ModelQueryBuilderContract<Model>, ModelQueryBuilderContract<Model>], "paginate">): void;
|
|
147
|
+
<Model extends LucidModel, Event extends import("@adonisjs/lucid/types/model").EventsList>(this: Model, event: Event, handler: import("@adonisjs/lucid/types/model").HooksHandler<InstanceType<Model>, Event>): void;
|
|
148
|
+
};
|
|
149
|
+
after: {
|
|
150
|
+
<Model extends LucidModel>(this: Model, event: "fetch", handler: import("@adonisjs/lucid/types/model").HooksHandler<InstanceType<Model>[], "fetch">): void;
|
|
151
|
+
<Model extends LucidModel>(this: Model, event: "paginate", handler: import("@adonisjs/lucid/types/model").HooksHandler<import("@adonisjs/lucid/types/model").ModelPaginatorContract<InstanceType<Model>>, "paginate">): void;
|
|
152
|
+
<Model extends LucidModel, Event extends import("@adonisjs/lucid/types/model").EventsList>(this: Model, event: Event, handler: import("@adonisjs/lucid/types/model").HooksHandler<InstanceType<Model>, Event>): void;
|
|
153
|
+
};
|
|
154
|
+
create: <T_1 extends LucidModel>(this: T_1, values: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>, options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T_1>>;
|
|
155
|
+
createQuietly: <T_1 extends LucidModel>(this: T_1, values: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>, options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T_1>>;
|
|
156
|
+
createMany: <T_1 extends LucidModel>(this: T_1, values: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>[], options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T_1>[]>;
|
|
157
|
+
createManyQuietly: <T_1 extends LucidModel>(this: T_1, values: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>[], options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T_1>[]>;
|
|
158
|
+
find: <T_1 extends LucidModel>(this: T_1, value: any, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<null | InstanceType<T_1>>;
|
|
159
|
+
findOrFail: <T_1 extends LucidModel>(this: T_1, value: any, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<InstanceType<T_1>>;
|
|
160
|
+
findBy: {
|
|
161
|
+
<T_1 extends LucidModel>(this: T_1, clause: Record<string, unknown>, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<null | InstanceType<T_1>>;
|
|
162
|
+
<T_1 extends LucidModel>(this: T_1, key: string, value: any, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<null | InstanceType<T_1>>;
|
|
163
|
+
};
|
|
164
|
+
findByOrFail: {
|
|
165
|
+
<T_1 extends LucidModel>(this: T_1, clause: Record<string, unknown>, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<InstanceType<T_1>>;
|
|
166
|
+
<T_1 extends LucidModel>(this: T_1, key: string, value: any, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<InstanceType<T_1>>;
|
|
167
|
+
};
|
|
168
|
+
findManyBy: {
|
|
169
|
+
<T_1 extends LucidModel>(this: T_1, clause: Record<string, unknown>, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<InstanceType<T_1>[]>;
|
|
170
|
+
<T_1 extends LucidModel>(this: T_1, key: string, value: any, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions): Promise<InstanceType<T_1>[]>;
|
|
171
|
+
};
|
|
172
|
+
first: <T_1 extends LucidModel>(this: T_1, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<null | InstanceType<T_1>>;
|
|
173
|
+
firstOrFail: <T_1 extends LucidModel>(this: T_1, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<InstanceType<T_1>>;
|
|
174
|
+
findMany: <T_1 extends LucidModel>(this: T_1, value: any[], options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<InstanceType<T_1>[]>;
|
|
175
|
+
firstOrNew: <T_1 extends LucidModel>(this: T_1, searchPayload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>, savePayload?: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>, options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T_1>>;
|
|
176
|
+
firstOrCreate: <T_1 extends LucidModel>(this: T_1, searchPayload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>, savePayload?: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>, options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T_1>>;
|
|
177
|
+
updateOrCreate: <T_1 extends LucidModel>(this: T_1, searchPayload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>, updatePayload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>, options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T_1>>;
|
|
178
|
+
fetchOrNewUpMany: <T_1 extends LucidModel>(this: T_1, predicate: keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>> | (keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>)[], payload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>[], options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T_1>[]>;
|
|
179
|
+
fetchOrCreateMany: <T_1 extends LucidModel>(this: T_1, predicate: keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>> | (keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>)[], payload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>[], options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T_1>[]>;
|
|
180
|
+
updateOrCreateMany: <T_1 extends LucidModel>(this: T_1, predicate: keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>> | (keyof import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>)[], payload: Partial<import("@adonisjs/lucid/types/model").ModelAttributes<InstanceType<T_1>>>[], options?: import("@adonisjs/lucid/types/model").ModelAssignOptions) => Promise<InstanceType<T_1>[]>;
|
|
181
|
+
all: <T_1 extends LucidModel>(this: T_1, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => Promise<InstanceType<T_1>[]>;
|
|
182
|
+
query: <Model extends LucidModel, Result = InstanceType<Model>>(this: Model, options?: import("@adonisjs/lucid/types/model").ModelAdapterOptions) => ModelQueryBuilderContract<Model, Result>;
|
|
183
|
+
transaction: import("@adonisjs/lucid/types/database").TransactionFn;
|
|
184
|
+
truncate: (cascade?: boolean) => Promise<void>;
|
|
185
|
+
} & T;
|
|
186
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare module '@adonisjs/lucid/types/model' {
|
|
2
|
+
type ModelWithSoftDeletes = LucidModel & {
|
|
3
|
+
ignoreDeleted(query: any): void;
|
|
4
|
+
ignoreDeletedPaginate([countQuery, query]: [any, any]): void;
|
|
5
|
+
disableIgnore(query: any): any;
|
|
6
|
+
};
|
|
7
|
+
type ExcludeSoftDeletesMethods<Methods, Model> = {
|
|
8
|
+
[Method in keyof Methods]: Model extends ModelWithSoftDeletes ? Methods[Method] : never;
|
|
9
|
+
};
|
|
10
|
+
type SoftDeletesMethods<Model extends LucidModel> = {
|
|
11
|
+
withTrashed(): ModelQueryBuilderContract<Model>;
|
|
12
|
+
onlyTrashed(): ModelQueryBuilderContract<Model>;
|
|
13
|
+
restore(): Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
interface ModelQueryBuilderContract<Model extends LucidModel, Result = InstanceType<Model>> extends ExcludeSoftDeletesMethods<SoftDeletesMethods<Model>, Model> {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=querybuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codenameryuu/adonis-lucid-soft-deletes",
|
|
3
|
+
"description": "Addon for soft deletes Adonis JS 7 Lucid ORM",
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"author": "codenameryuu",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/codenameryuu/adonis-lucid-soft-deletes#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/codenameryuu/adonis-lucid-soft-deletes.git"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=24.0.0"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"files": [
|
|
17
|
+
"build",
|
|
18
|
+
"!build/bin",
|
|
19
|
+
"!build/tests"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./build/index.js",
|
|
23
|
+
"./types/*": "./build/src/types/*.js",
|
|
24
|
+
"./bindings": "./build/src/bindings/model_query_builder.js",
|
|
25
|
+
"./provider": "./build/providers/lucid_soft_deletes_provider.js"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"format": "prettier --write .",
|
|
30
|
+
"clean": "del-cli build",
|
|
31
|
+
"precompile": "npm run lint && npm run clean",
|
|
32
|
+
"compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
|
|
33
|
+
"build": "npm run compile",
|
|
34
|
+
"quick:test": "NODE_DEBUG=\"adonis-lucid-soft-deletes\" node --enable-source-maps --loader=ts-node/esm bin/test.ts",
|
|
35
|
+
"pretest": "npm run lint",
|
|
36
|
+
"test": "c8 npm run quick:test",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"version": "npm run build",
|
|
39
|
+
"prepublishOnly": "npm run build",
|
|
40
|
+
"release": "np"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@adonisjs/assembler": "^7.7.0",
|
|
44
|
+
"@adonisjs/core": "^7.0.0",
|
|
45
|
+
"@adonisjs/eslint-config": "^3.0.0",
|
|
46
|
+
"@adonisjs/lucid": "^22.0.0",
|
|
47
|
+
"@adonisjs/prettier-config": "^1.4.5",
|
|
48
|
+
"@adonisjs/tsconfig": "^2.0.0",
|
|
49
|
+
"@japa/assert": "^4.2.0",
|
|
50
|
+
"@japa/expect-type": "^2.0.4",
|
|
51
|
+
"@japa/file-system": "^3.0.0",
|
|
52
|
+
"@japa/runner": "^5.3.0",
|
|
53
|
+
"@japa/snapshot": "^2.0.5",
|
|
54
|
+
"@swc/core": "^1.6.7",
|
|
55
|
+
"@types/lodash": "^4.17.6",
|
|
56
|
+
"@types/luxon": "^3.4.2",
|
|
57
|
+
"@types/node": "^25.5.0",
|
|
58
|
+
"c8": "^9.1.0",
|
|
59
|
+
"copyfiles": "^2.4.1",
|
|
60
|
+
"del-cli": "^5.1.0",
|
|
61
|
+
"eslint": "^10.0.2",
|
|
62
|
+
"knex": "^3.1.0",
|
|
63
|
+
"lodash": "^4.17.23",
|
|
64
|
+
"luxon": "^3.4.4",
|
|
65
|
+
"np": "^11.0.2",
|
|
66
|
+
"prettier": "^3.8.1",
|
|
67
|
+
"reflect-metadata": "^0.2.2",
|
|
68
|
+
"ts-node": "^10.9.2",
|
|
69
|
+
"tsup": "^8.1.0",
|
|
70
|
+
"typescript": "^5.5.3",
|
|
71
|
+
"youch": "^4.1.0"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"@adonisjs/core": "^7.0.0",
|
|
75
|
+
"@adonisjs/lucid": "^22.0.0"
|
|
76
|
+
},
|
|
77
|
+
"keywords": [
|
|
78
|
+
"adonisjs",
|
|
79
|
+
"adonisjs-lucid",
|
|
80
|
+
"adonisjs-lucid-soft-deletes",
|
|
81
|
+
"adonisjs-soft-deletes",
|
|
82
|
+
"adonis",
|
|
83
|
+
"adonis-lucid",
|
|
84
|
+
"adonis-lucid-soft-deletes",
|
|
85
|
+
"adonis-soft-deletes"
|
|
86
|
+
],
|
|
87
|
+
"publishConfig": {
|
|
88
|
+
"access": "public",
|
|
89
|
+
"tag": "latest"
|
|
90
|
+
},
|
|
91
|
+
"prettier": "@adonisjs/prettier-config",
|
|
92
|
+
"np": {
|
|
93
|
+
"message": "chore(release): %s",
|
|
94
|
+
"tag": "latest",
|
|
95
|
+
"branch": "main",
|
|
96
|
+
"anyBranch": false
|
|
97
|
+
},
|
|
98
|
+
"c8": {
|
|
99
|
+
"reporter": [
|
|
100
|
+
"text",
|
|
101
|
+
"html"
|
|
102
|
+
],
|
|
103
|
+
"exclude": [
|
|
104
|
+
"tests/**",
|
|
105
|
+
"bin/**"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"tsup": {
|
|
109
|
+
"entry": [
|
|
110
|
+
"./index.ts",
|
|
111
|
+
"./src/types/*.ts",
|
|
112
|
+
"./src/bindings/model_query_builder.ts",
|
|
113
|
+
"./providers/lucid_soft_deletes_provider.ts"
|
|
114
|
+
],
|
|
115
|
+
"outDir": "./build",
|
|
116
|
+
"clean": true,
|
|
117
|
+
"format": "esm",
|
|
118
|
+
"dts": false,
|
|
119
|
+
"sourcemap": true,
|
|
120
|
+
"target": "esnext"
|
|
121
|
+
}
|
|
122
|
+
}
|