@strapi/database 4.14.0-beta.0 → 4.14.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.
@@ -32,6 +32,7 @@ const typeToFieldMap = {
32
32
  datetime: DatetimeField,
33
33
  timestamp: TimestampField,
34
34
  boolean: BooleanField,
35
+ blocks: JSONField,
35
36
  };
36
37
 
37
38
  const createField = (attribute) => {
package/lib/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Knex } from 'knex';
2
2
  import { LifecycleProvider } from './lifecycles';
3
3
  import { MigrationProvider } from './migrations';
4
4
  import { SchemaProvider } from './schema';
5
+ export * as errors from './errors';
5
6
 
6
7
  type ID = number | string;
7
8
 
@@ -71,7 +72,7 @@ interface CreateManyParams<T> {
71
72
  data: T[keyof T][];
72
73
  }
73
74
 
74
- interface Pagination {
75
+ export interface Pagination {
75
76
  page: number;
76
77
  pageSize: number;
77
78
  pageCount: number;
@@ -115,33 +116,38 @@ interface EntityManager {
115
116
  ): Promise<T[SK]>;
116
117
  }
117
118
 
118
- interface QueryFromContentType<T extends keyof AllTypes> {
119
- findOne(params: FindParams<AllTypes[T]>): Promise<any>;
120
- findMany(params: FindParams<AllTypes[T]>): Promise<any[]>;
121
- findWithCount(params: FindParams<AllTypes[T]>): Promise<[any[], number]>;
122
- findPage(params: FindParams<AllTypes[T]>): Promise<{ results: any[]; pagination: Pagination }>;
119
+ export interface QueryFromContentType<T extends keyof AllTypes> {
120
+ findOne(params?: any): Promise<any>;
121
+ findMany(params?: any): Promise<any[]>;
122
+ findWithCount(params?: any): Promise<[any[], number]>;
123
+ findPage(params?: any): Promise<{ results: any[]; pagination: Pagination }>;
123
124
 
124
- create(params: CreateParams<AllTypes[T]>): Promise<any>;
125
- createMany(params: CreateManyParams<AllTypes[T]>): Promise<{ count: number; ids: ID[] }>;
125
+ create(params?: any): Promise<any>;
126
+ createMany(params?: any): Promise<{ count: number; ids: ID[] }>;
126
127
 
127
- update(params: any): Promise<any>;
128
- updateMany(params: any): Promise<{ count: number }>;
128
+ update(params?: any): Promise<any>;
129
+ updateMany(params?: any): Promise<{ count: number }>;
129
130
 
130
- delete(params: any): Promise<any>;
131
- deleteMany(params: any): Promise<{ count: number }>;
131
+ delete(params?: any): Promise<any>;
132
+ deleteMany(params?: any): Promise<{ count: number }>;
132
133
 
133
- count(params: any): Promise<number>;
134
+ count(params?: any): Promise<number>;
134
135
 
135
136
  attachRelations(id: ID, data: any): Promise<any>;
136
137
  updateRelations(id: ID, data: any): Promise<any>;
137
138
  deleteRelations(id: ID): Promise<any>;
138
139
 
139
140
  populate<S extends AllTypes[T]>(entity: S, populate: PopulateParams): Promise<S>;
140
-
141
- load<S extends AllTypes[T], K extends keyof S>(
141
+ clone<S extends AllTypes[T]>(cloneId: ID, params?: Params<S>): Promise<S>;
142
+ load<S extends AllTypes[T], K extends string>(
142
143
  entity: S,
143
- field: K,
144
- populate: PopulateParams
144
+ field: K | K[],
145
+ populate?: PopulateParams
146
+ ): Promise<S[K]>;
147
+ loadPages<S extends AllTypes[T], K extends string>(
148
+ entity: S,
149
+ field: K | K[],
150
+ populate?: PopulateParams
145
151
  ): Promise<S[K]>;
146
152
  }
147
153
 
@@ -164,8 +170,15 @@ export interface Database {
164
170
  queryBuilder: any;
165
171
  metadata: any;
166
172
  connection: Knex;
173
+ dialect: {
174
+ client: string;
175
+ };
176
+
177
+ destroy(): Promise<void>;
178
+
179
+ getSchemaConnection: () => Knex.SchemaBuilder;
167
180
 
168
- query<T extends keyof AllTypes>(uid: T): QueryFromContentType<T>;
181
+ query: <T extends keyof AllTypes>(uid: T) => QueryFromContentType<T>;
169
182
  transaction(
170
183
  cb?: (params: {
171
184
  trx: Knex.Transaction;
@@ -177,6 +190,7 @@ export interface Database {
177
190
  ):
178
191
  | Promise<unknown>
179
192
  | { get: () => Knex.Transaction; rollback: () => Promise<void>; commit: () => Promise<void> };
193
+ inTransaction: () => boolean;
180
194
  }
181
195
  export class Database implements Database {
182
196
  static transformContentTypes(contentTypes: any[]): ModelConfig[];
@@ -130,6 +130,7 @@ const getColumnType = (attribute) => {
130
130
  args: ['longtext'],
131
131
  };
132
132
  }
133
+ case 'blocks':
133
134
  case 'json': {
134
135
  return { type: 'jsonb' };
135
136
  }
@@ -19,6 +19,7 @@ const SCALAR_TYPES = [
19
19
  'datetime',
20
20
  'timestamp',
21
21
  'boolean',
22
+ 'blocks',
22
23
  ];
23
24
 
24
25
  const STRING_TYPES = ['string', 'text', 'uid', 'email', 'enumeration', 'richtext'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/database",
3
- "version": "4.14.0-beta.0",
3
+ "version": "4.14.0",
4
4
  "description": "Strapi's database layer",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -33,7 +33,7 @@
33
33
  "lint": "run -T eslint ."
34
34
  },
35
35
  "dependencies": {
36
- "@strapi/utils": "4.14.0-beta.0",
36
+ "@strapi/utils": "4.14.0",
37
37
  "date-fns": "2.30.0",
38
38
  "debug": "4.3.4",
39
39
  "fs-extra": "10.0.0",
@@ -46,5 +46,5 @@
46
46
  "node": ">=16.0.0 <=20.x.x",
47
47
  "npm": ">=6.0.0"
48
48
  },
49
- "gitHead": "8145855e7ada0bf94ce1a2f4d1c34fe647e1af53"
49
+ "gitHead": "09b6d7a4b46a87142d29665052ca22ced29fa56a"
50
50
  }