@strapi/database 4.20.5 → 5.0.0-alpha.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/dist/connection.d.ts +2 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/dialects/dialect.d.ts +1 -2
- package/dist/dialects/dialect.d.ts.map +1 -1
- package/dist/dialects/index.d.ts.map +1 -1
- package/dist/dialects/mysql/database-inspector.d.ts +1 -1
- package/dist/dialects/mysql/database-inspector.d.ts.map +1 -1
- package/dist/dialects/mysql/index.d.ts +1 -2
- package/dist/dialects/mysql/index.d.ts.map +1 -1
- package/dist/dialects/postgresql/index.d.ts +1 -1
- package/dist/dialects/postgresql/index.d.ts.map +1 -1
- package/dist/dialects/sqlite/index.d.ts +1 -1
- package/dist/dialects/sqlite/index.d.ts.map +1 -1
- package/dist/entity-manager/entity-repository.d.ts.map +1 -1
- package/dist/entity-manager/index.d.ts.map +1 -1
- package/dist/entity-manager/regular-relations.d.ts +6 -31
- package/dist/entity-manager/regular-relations.d.ts.map +1 -1
- package/dist/entity-manager/types.d.ts +8 -26
- package/dist/entity-manager/types.d.ts.map +1 -1
- package/dist/index.d.ts +13 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +518 -645
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +514 -639
- package/dist/index.mjs.map +1 -1
- package/dist/metadata/index.d.ts +2 -2
- package/dist/metadata/index.d.ts.map +1 -1
- package/dist/metadata/metadata.d.ts +1 -4
- package/dist/metadata/metadata.d.ts.map +1 -1
- package/dist/metadata/relations.d.ts +0 -1
- package/dist/metadata/relations.d.ts.map +1 -1
- package/dist/migrations/common.d.ts +20 -0
- package/dist/migrations/common.d.ts.map +1 -0
- package/dist/migrations/index.d.ts +2 -9
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/internal-migrations/index.d.ts +12 -0
- package/dist/migrations/internal-migrations/index.d.ts.map +1 -0
- package/dist/migrations/internal.d.ts +4 -0
- package/dist/migrations/internal.d.ts.map +1 -0
- package/dist/migrations/storage.d.ts +1 -1
- package/dist/migrations/storage.d.ts.map +1 -1
- package/dist/migrations/users.d.ts +4 -0
- package/dist/migrations/users.d.ts.map +1 -0
- package/dist/schema/diff.d.ts.map +1 -1
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/identifiers/index.d.ts +48 -0
- package/dist/utils/identifiers/index.d.ts.map +1 -0
- package/dist/utils/identifiers/shortener.d.ts +73 -0
- package/dist/utils/identifiers/shortener.d.ts.map +1 -0
- package/dist/utils/types.d.ts +0 -2
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/validations/relations/bidirectional.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/entity-manager/relations/cloning/regular-relations.d.ts +0 -17
- package/dist/entity-manager/relations/cloning/regular-relations.d.ts.map +0 -1
- package/dist/utils/content-types.d.ts +0 -13
- package/dist/utils/content-types.d.ts.map +0 -1
package/dist/metadata/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isPolymorphic, isBidirectional, isAnyToOne, isOneToAny, hasOrderColumn, hasInverseOrderColumn, isManyToAny } from './relations';
|
|
2
2
|
import { Metadata, Meta } from './metadata';
|
|
3
3
|
import type { Model } from '../types';
|
|
4
4
|
export type { Metadata, Meta };
|
|
5
|
-
export {
|
|
5
|
+
export { isPolymorphic, isBidirectional, isAnyToOne, isOneToAny, hasOrderColumn, hasInverseOrderColumn, isManyToAny, };
|
|
6
6
|
/**
|
|
7
7
|
* Create Metadata from models configurations
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metadata/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metadata/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,EACf,UAAU,EACV,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,WAAW,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC/B,OAAO,EACL,aAAa,EACb,eAAe,EACf,UAAU,EACV,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,WAAW,GACZ,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,cAAc,YAAY,KAAK,EAAE,KAAQ,QAQrD,CAAC"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { Model } from '../types';
|
|
2
2
|
import type { ForeignKey, Index } from '../schema/types';
|
|
3
3
|
import type { Action, SubscriberFn } from '../lifecycles';
|
|
4
|
-
export interface ComponentLinkMeta extends Meta {
|
|
5
|
-
componentLink: Meta;
|
|
6
|
-
}
|
|
7
4
|
export interface Meta extends Model {
|
|
8
5
|
columnToAttribute: Record<string, string>;
|
|
9
|
-
componentLink?: Meta;
|
|
10
6
|
indexes: Index[];
|
|
11
7
|
foreignKeys: ForeignKey[];
|
|
12
8
|
lifecycles: Partial<Record<Action, SubscriberFn>>;
|
|
@@ -18,5 +14,6 @@ export declare class Metadata extends Map<string, Meta> {
|
|
|
18
14
|
* Validate the DB metadata, throwing an error if a duplicate DB table name is detected
|
|
19
15
|
*/
|
|
20
16
|
validate(): void;
|
|
17
|
+
loadModels(models?: Model[]): void;
|
|
21
18
|
}
|
|
22
19
|
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/metadata/metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/metadata/metadata.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,WAAW,IAAK,SAAQ,KAAK;IACjC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,OAAO,EAAE,KAAK,EAAE,CAAC;IACjB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;CACnD;AAED,qBAAa,QAAS,SAAQ,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC;IAC7C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQtB,GAAG,CAAC,IAAI,EAAE,IAAI;IAId;;OAEG;IACH,QAAQ;IAYR,UAAU,CAAC,MAAM,GAAE,KAAK,EAAO;CAkDhC"}
|
|
@@ -6,7 +6,6 @@ export declare const isManyToAny: (attribute: RelationalAttribute) => attribute
|
|
|
6
6
|
export declare const isAnyToOne: (attribute: RelationalAttribute) => attribute is Relation.OneToOne | Relation.ManyToOne;
|
|
7
7
|
export declare const isAnyToMany: (attribute: RelationalAttribute) => attribute is Relation.OneToMany | Relation.ManyToMany;
|
|
8
8
|
export declare const isBidirectional: (attribute: RelationalAttribute) => attribute is Relation.Bidirectional;
|
|
9
|
-
export declare const getJoinTableName: (tableName: string, attributeName: string) => string;
|
|
10
9
|
export declare const hasOrderColumn: (attribute: RelationalAttribute) => boolean;
|
|
11
10
|
export declare const hasInverseOrderColumn: (attribute: RelationalAttribute) => boolean;
|
|
12
11
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../src/metadata/relations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../src/metadata/relations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAkB,MAAM,UAAU,CAAC;AAyB9E,eAAO,MAAM,aAAa,cAAe,mBAAmB,gCACyB,CAAC;AAEtF,eAAO,MAAM,UAAU,cACV,mBAAmB,wDAEwB,CAAC;AAEzD,eAAO,MAAM,WAAW,cACX,mBAAmB,0DAE0B,CAAC;AAE3D,eAAO,MAAM,UAAU,cACV,mBAAmB,wDAEwB,CAAC;AAEzD,eAAO,MAAM,WAAW,cACX,mBAAmB,0DAE0B,CAAC;AAE3D,eAAO,MAAM,eAAe,cACf,mBAAmB,wCAC4D,CAAC;AAU7F,eAAO,MAAM,cAAc,cAAe,mBAAmB,YAA2B,CAAC;AACzF,eAAO,MAAM,qBAAqB,cAAe,mBAAmB,YACd,CAAC;AAyhBvD;;GAEG;AACH,eAAO,MAAM,cAAc,kBACV,MAAM,aACV,mBAAmB,QACxB,IAAI,YACA,QAAQ,SAuBnB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Resolver } from 'umzug';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { Database } from '..';
|
|
4
|
+
export interface MigrationProvider {
|
|
5
|
+
shouldRun(): Promise<boolean>;
|
|
6
|
+
up(): Promise<void>;
|
|
7
|
+
down(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export type Context = {
|
|
10
|
+
db: Database;
|
|
11
|
+
};
|
|
12
|
+
export type MigrationResolver = Resolver<Context>;
|
|
13
|
+
export type MigrationFn = (knex: Knex, db: Database) => Promise<void>;
|
|
14
|
+
export type Migration = {
|
|
15
|
+
name: string;
|
|
16
|
+
up: MigrationFn;
|
|
17
|
+
down: MigrationFn;
|
|
18
|
+
};
|
|
19
|
+
export declare const wrapTransaction: (db: Database) => (fn: MigrationFn) => () => Promise<void>;
|
|
20
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/migrations/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEnC,MAAM,WAAW,iBAAiB;IAChC,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,MAAM,MAAM,OAAO,GAAG;IAAE,EAAE,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvC,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;AAElD,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtE,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,WAAW,CAAC;IAChB,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,eAAe,OAAQ,QAAQ,UAAU,WAAW,wBAEhE,CAAC"}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
+
import type { MigrationProvider } from './common';
|
|
1
2
|
import type { Database } from '..';
|
|
2
|
-
export
|
|
3
|
-
shouldRun(): Promise<boolean>;
|
|
4
|
-
up(): Promise<void>;
|
|
5
|
-
down(): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Creates migrations provider
|
|
9
|
-
* @type {import('.').createMigrationsProvider}
|
|
10
|
-
*/
|
|
3
|
+
export type { MigrationProvider };
|
|
11
4
|
export declare const createMigrationsProvider: (db: Database) => MigrationProvider;
|
|
12
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEnC,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC,eAAO,MAAM,wBAAwB,OAAQ,QAAQ,KAAG,iBA0BvD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Migration } from '../common';
|
|
2
|
+
/**
|
|
3
|
+
* List of all the internal migrations. The array order will be the order in which they are executed.
|
|
4
|
+
*
|
|
5
|
+
* {
|
|
6
|
+
* name: 'some-name',
|
|
7
|
+
* async up(knex: Knex, db: Database) {},
|
|
8
|
+
* async down(knex: Knex, db: Database) {},
|
|
9
|
+
* },
|
|
10
|
+
*/
|
|
11
|
+
export declare const internalMigrations: Migration[];
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/internal-migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,EAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/migrations/internal.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEnC,eAAO,MAAM,+BAA+B,OAAQ,QAAQ,KAAG,iBA4B9D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/migrations/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEnC,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,QAAQ,CAAC;IACb,SAAS,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/migrations/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEnC,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,QAAQ,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,aAAa,SAAU,OAAO;;cAcF,MAAM;;;cAUJ,MAAM;;;CAehD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/migrations/users.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,UAAU,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAiCnC,eAAO,MAAM,2BAA2B,OAAQ,QAAQ,KAAG,iBA6B1D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/schema/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,MAAM,EAEN,UAAU,EAWX,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/schema/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,MAAM,EAEN,UAAU,EAWX,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;6BA8Cf,QAAQ;sBA8RY,MAAM,cAAc,MAAM,KAAG,QAAQ,UAAU,CAAC;;AA9RxF,wBAgXE"}
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import createSchemaBuilder from './builder';
|
|
2
2
|
import createSchemaDiff from './diff';
|
|
3
3
|
import createSchemaStorage from './storage';
|
|
4
|
+
import type { Schema } from './types';
|
|
4
5
|
import type { Database } from '..';
|
|
5
6
|
export type * from './types';
|
|
6
7
|
export interface SchemaProvider {
|
|
@@ -12,6 +13,7 @@ export interface SchemaProvider {
|
|
|
12
13
|
reset(): Promise<void>;
|
|
13
14
|
create(): Promise<void>;
|
|
14
15
|
drop(): Promise<void>;
|
|
16
|
+
schema: Schema;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* @type {import('.').default}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAEA,OAAO,mBAAmB,MAAM,WAAW,CAAC;AAC5C,OAAO,gBAAgB,MAAM,QAAQ,CAAC;AACtC,OAAO,mBAAmB,MAAM,WAAW,CAAC;AAG5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEnC,mBAAmB,SAAS,CAAC;AAI7B,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;IAChD,UAAU,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAChD,aAAa,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ot":"","sources":["../../src/schema/schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAQ,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAU,MAAM,EAAS,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema/schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAQ,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAU,MAAM,EAAS,MAAM,SAAS,CAAC;AA0NrD,eAAO,MAAM,gBAAgB,aAAc,QAAQ,KAAG,MAUrD,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,31 +4,35 @@ export type ID = string | number;
|
|
|
4
4
|
export interface ColumnInfo {
|
|
5
5
|
unsigned?: boolean;
|
|
6
6
|
defaultTo?: unknown;
|
|
7
|
+
notNullable?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export type Attribute = ScalarAttribute | RelationalAttribute;
|
|
10
|
+
export type CountResult = {
|
|
11
|
+
count: number;
|
|
12
|
+
};
|
|
9
13
|
export type RelationalAttribute = Relation.OneToOne | Relation.OneToMany | Relation.ManyToOne | Relation.ManyToMany | Relation.MorphMany | Relation.MorphOne | Relation.MorphToOne | Relation.MorphToMany;
|
|
10
|
-
export interface
|
|
14
|
+
export interface BaseAttribute {
|
|
11
15
|
type: string;
|
|
12
16
|
columnName?: string;
|
|
13
17
|
default?: any;
|
|
14
18
|
column?: ColumnInfo;
|
|
15
19
|
required?: boolean;
|
|
16
20
|
unique?: boolean;
|
|
17
|
-
component?: string;
|
|
18
|
-
repeatable?: boolean;
|
|
19
21
|
columnType?: {
|
|
20
22
|
type: string;
|
|
21
23
|
args: unknown[];
|
|
22
24
|
};
|
|
23
25
|
searchable?: boolean;
|
|
26
|
+
enum?: string[];
|
|
24
27
|
}
|
|
25
|
-
export interface ScalarAttribute extends
|
|
28
|
+
export interface ScalarAttribute extends BaseAttribute {
|
|
26
29
|
type: 'increments' | 'password' | 'email' | 'string' | 'enumeration' | 'uid' | 'richtext' | 'text' | 'json' | 'integer' | 'biginteger' | 'float' | 'decimal' | 'boolean' | 'date' | 'time' | 'datetime' | 'timestamp' | 'blocks';
|
|
27
30
|
}
|
|
28
31
|
export interface JoinColumn {
|
|
29
32
|
name: string;
|
|
30
33
|
referencedColumn: string;
|
|
31
34
|
referencedTable?: string;
|
|
35
|
+
columnType?: ScalarAttribute['type'];
|
|
32
36
|
}
|
|
33
37
|
export interface BaseJoinTable {
|
|
34
38
|
name: string;
|
|
@@ -39,6 +43,7 @@ export interface BaseJoinTable {
|
|
|
39
43
|
inverseJoinColumn: {
|
|
40
44
|
name: string;
|
|
41
45
|
referencedColumn: string;
|
|
46
|
+
referencedTable?: string;
|
|
42
47
|
};
|
|
43
48
|
}
|
|
44
49
|
export interface JoinTable extends BaseJoinTable {
|
|
@@ -148,7 +153,6 @@ export interface BaseRelationalAttribute {
|
|
|
148
153
|
owner?: boolean;
|
|
149
154
|
morphColumn?: MorphColumn;
|
|
150
155
|
joinColumn?: JoinColumn;
|
|
151
|
-
component?: string;
|
|
152
156
|
}
|
|
153
157
|
export interface MorphRelationalAttribute extends BaseRelationalAttribute {
|
|
154
158
|
relation: 'morphMany' | 'morphOne' | 'morphToOne' | 'morphToMany';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAA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CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,wBAAyB,SAAQ,uBAAuB;IACvE,QAAQ,EAAE,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC;IAClE,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,cAAc,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;CACpD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare const ID_COLUMN = "id";
|
|
2
|
+
export declare const ORDER_COLUMN = "order";
|
|
3
|
+
export declare const FIELD_COLUMN = "field";
|
|
4
|
+
type NameInput = string | string[];
|
|
5
|
+
type NameOptions = {
|
|
6
|
+
suffix?: string;
|
|
7
|
+
prefix?: string;
|
|
8
|
+
maxLength?: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* TODO: we should be requiring snake_case inputs for all names here, but we
|
|
12
|
+
* aren't and it will require some refactoring to make it work. Currently if
|
|
13
|
+
* we get names 'myModel' and 'my_model' they would be converted to the same
|
|
14
|
+
* final string my_model which generally works but is not entirely safe
|
|
15
|
+
* */
|
|
16
|
+
export declare const getName: (names: NameInput, options?: NameOptions) => string;
|
|
17
|
+
/**
|
|
18
|
+
* TABLES
|
|
19
|
+
*/
|
|
20
|
+
export declare const getTableName: (name: string, options?: NameOptions) => string;
|
|
21
|
+
export declare const getJoinTableName: (collectionName: string, attributeName: string, options?: NameOptions) => string;
|
|
22
|
+
export declare const getMorphTableName: (collectionName: string, attributeName: string, options?: NameOptions) => string;
|
|
23
|
+
/**
|
|
24
|
+
* COLUMNS
|
|
25
|
+
*/
|
|
26
|
+
export declare const getColumnName: (attributeName: string, options?: NameOptions) => string;
|
|
27
|
+
export declare const getJoinColumnAttributeIdName: (attributeName: string, options?: NameOptions) => string;
|
|
28
|
+
export declare const getInverseJoinColumnAttributeIdName: (attributeName: string, options?: NameOptions) => string;
|
|
29
|
+
export declare const getOrderColumnName: (singularName: string, options?: NameOptions) => string;
|
|
30
|
+
export declare const getInverseOrderColumnName: (singularName: string, options?: NameOptions) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Morph Join Tables
|
|
33
|
+
*/
|
|
34
|
+
export declare const getMorphColumnJoinTableIdName: (singularName: string, options?: NameOptions) => string;
|
|
35
|
+
export declare const getMorphColumnAttributeIdName: (attributeName: string, options?: NameOptions) => string;
|
|
36
|
+
export declare const getMorphColumnTypeName: (attributeName: string, options?: NameOptions) => string;
|
|
37
|
+
/**
|
|
38
|
+
* INDEXES
|
|
39
|
+
*/
|
|
40
|
+
export declare const getIndexName: (names: NameInput, options?: NameOptions) => string;
|
|
41
|
+
export declare const getFkIndexName: (names: NameInput, options?: NameOptions) => string;
|
|
42
|
+
export declare const getInverseFkIndexName: (names: NameInput, options?: NameOptions) => string;
|
|
43
|
+
export declare const getOrderFkIndexName: (names: NameInput, options?: NameOptions) => string;
|
|
44
|
+
export declare const getOrderInverseFkIndexName: (names: NameInput, options?: NameOptions) => string;
|
|
45
|
+
export declare const getUniqueIndexName: (names: NameInput, options?: NameOptions) => string;
|
|
46
|
+
export declare const getPrimaryIndexName: (names: NameInput) => string;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/identifiers/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,OAAO,CAAC;AAC9B,eAAO,MAAM,YAAY,UAAU,CAAC;AACpC,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAEnC,KAAK,WAAW,GAAG;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAGF;;;;;KAKK;AACL,eAAO,MAAM,OAAO,UAAW,SAAS,YAAY,WAAW,WAmB9D,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,YAAY,SAAU,MAAM,YAAY,WAAW,WAE/D,CAAC;AAEF,eAAO,MAAM,gBAAgB,mBACX,MAAM,iBACP,MAAM,YACX,WAAW,WAGtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,mBACZ,MAAM,iBACP,MAAM,YACX,WAAW,WAGtB,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,aAAa,kBAAmB,MAAM,YAAY,WAAW,WAEzE,CAAC;AAEF,eAAO,MAAM,4BAA4B,kBAAmB,MAAM,YAAY,WAAW,WAExF,CAAC;AAEF,eAAO,MAAM,mCAAmC,kBAC/B,MAAM,YACX,WAAW,WAGtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,iBAAkB,MAAM,YAAY,WAAW,WAE7E,CAAC;AAEF,eAAO,MAAM,yBAAyB,iBAAkB,MAAM,YAAY,WAAW,WAEpF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B,iBAAkB,MAAM,YAAY,WAAW,WAExF,CAAC;AAEF,eAAO,MAAM,6BAA6B,kBAAmB,MAAM,YAAY,WAAW,WAEzF,CAAC;AAEF,eAAO,MAAM,sBAAsB,kBAAmB,MAAM,YAAY,WAAW,WAElF,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,YAAY,UAAW,SAAS,YAAY,WAAW,WAEnE,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,SAAS,YAAY,WAAW,WAErE,CAAC;AAEF,eAAO,MAAM,qBAAqB,UAAW,SAAS,YAAY,WAAW,WAE5E,CAAC;AAEF,eAAO,MAAM,mBAAmB,UAAW,SAAS,YAAY,WAAW,WAE1E,CAAC;AAEF,eAAO,MAAM,0BAA0B,UAAW,SAAS,YAAY,WAAW,WAEjF,CAAC;AAEF,eAAO,MAAM,kBAAkB,UAAW,SAAS,YAAY,WAAW,WAEzE,CAAC;AAEF,eAAO,MAAM,mBAAmB,UAAW,SAAS,WAEnD,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview This file contains utility functions for shortening identifiers for use in a database schema.
|
|
3
|
+
* The functions in this file are used to generate shorter names for database tables and columns
|
|
4
|
+
* to avoid breaking the constraints of databases.
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT
|
|
7
|
+
* Any changes here that result in a different output string from any of the naming methods will
|
|
8
|
+
* cause the schema creation to delete data it doesn't recognize because the name
|
|
9
|
+
* is different.
|
|
10
|
+
*
|
|
11
|
+
* If there are any test failures after updating this code, it means there is a breaking change that
|
|
12
|
+
* will cause data loss, so beware; do not update the test to match your changes
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare const MAX_DB_IDENTIFIER_LENGTH = 0;
|
|
17
|
+
export declare const HASH_LENGTH = 5;
|
|
18
|
+
export declare const HASH_SEPARATOR = "";
|
|
19
|
+
export declare const IDENTIFIER_SEPARATOR = "_";
|
|
20
|
+
export declare const MIN_TOKEN_LENGTH = 3;
|
|
21
|
+
type NameToken = {
|
|
22
|
+
allocatedLength?: number;
|
|
23
|
+
name: string;
|
|
24
|
+
compressible: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Creates a hash of the given data with the specified string length as a string of hex characters
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* createHash("myData", 5); // "03f85"
|
|
31
|
+
* createHash("myData", 2); // "03"
|
|
32
|
+
* createHash("myData", 1); // "0"
|
|
33
|
+
*
|
|
34
|
+
* @param data - The data to be hashed
|
|
35
|
+
* @param len - The length of the hash
|
|
36
|
+
* @returns The generated hash
|
|
37
|
+
* @throws Error if the length is not a positive integer
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export declare function createHash(data: string, len: number): string;
|
|
41
|
+
/**
|
|
42
|
+
* Generates a string with a max length, appending a hash at the end if necessary to keep it unique
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // if we have strings such as "longstring1" and "longstring2" with a max length of 9,
|
|
46
|
+
* // we don't want to end up with "longstrin" and "longstrin"
|
|
47
|
+
* // we want something such as "longs0b23" and "longs953f"
|
|
48
|
+
* const token1 = generateToken("longstring1", 9); // "longs0b23"
|
|
49
|
+
* const token2 = generateToken("longstring2", 9); // "longs953f"
|
|
50
|
+
*
|
|
51
|
+
* @param name - The base name
|
|
52
|
+
* @param len - The desired length of the token.
|
|
53
|
+
* @returns The generated token with hash.
|
|
54
|
+
* @throws Error if the length is not a positive integer, or if the length is too short for the token.
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
export declare function getShortenedName(name: string, len: number): string;
|
|
58
|
+
/**
|
|
59
|
+
* Constructs a name from an array of name tokens within a specified maximum length. It ensures the final name does not exceed
|
|
60
|
+
* this limit by selectively compressing tokens marked as compressible. If the name exceeds the maximum length and cannot be
|
|
61
|
+
* compressed sufficiently, an error is thrown. This function supports dynamic adjustment of token lengths to fit within the
|
|
62
|
+
* maxLength constraint (that is, it will always make use of all available space), while also ensuring the preservation of
|
|
63
|
+
* incompressible tokens.
|
|
64
|
+
*
|
|
65
|
+
* @param {NameToken[]} nameTokens - Array of name tokens
|
|
66
|
+
* @param {number} [maxLength=MAX_DB_IDENTIFIER_LENGTH] - Maximum length for the final name string.
|
|
67
|
+
* @returns {string} The generated name string within maxLength.
|
|
68
|
+
* @throws {Error} If the name cannot be shortened to meet maxLength.
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export declare function getNameFromTokens(nameTokens: NameToken[], maxLength?: number): string;
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=shortener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortener.d.ts","sourceRoot":"","sources":["../../../src/utils/identifiers/shortener.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAM1C,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,KAAK,SAAS,GAAG;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAIF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAS5D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAqBzD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,SAAS,SAA2B,UA2G9F"}
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import type { Attribute, ScalarAttribute, RelationalAttribute } from '../types';
|
|
|
2
2
|
export declare const isString: (type: string) => boolean;
|
|
3
3
|
export declare const isNumber: (type: string) => boolean;
|
|
4
4
|
export declare const isScalar: (type: string) => boolean;
|
|
5
|
-
export declare const isComponent: (type: string) => boolean;
|
|
6
|
-
export declare const isDynamicZone: (type: string) => boolean;
|
|
7
5
|
export declare const isRelation: (type: string) => boolean;
|
|
8
6
|
export declare const isScalarAttribute: (attribute: Attribute) => attribute is ScalarAttribute;
|
|
9
7
|
export declare const isRelationalAttribute: (attribute: Attribute) => attribute is RelationalAttribute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AA2BhF,eAAO,MAAM,QAAQ,SAAU,MAAM,YAAgC,CAAC;AACtE,eAAO,MAAM,QAAQ,SAAU,MAAM,YAAgC,CAAC;AACtE,eAAO,MAAM,QAAQ,SAAU,MAAM,YAAgC,CAAC;AACtE,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AA2BhF,eAAO,MAAM,QAAQ,SAAU,MAAM,YAAgC,CAAC;AACtE,eAAO,MAAM,QAAQ,SAAU,MAAM,YAAgC,CAAC;AACtE,eAAO,MAAM,QAAQ,SAAU,MAAM,YAAgC,CAAC;AACtE,eAAO,MAAM,UAAU,SAAU,MAAM,YAAwB,CAAC;AAChE,eAAO,MAAM,iBAAiB,cAAe,SAAS,iCAC5B,CAAC;AAC3B,eAAO,MAAM,qBAAqB,cAAe,SAAS,qCAC9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bidirectional.d.ts","sourceRoot":"","sources":["../../../src/validations/relations/bidirectional.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bidirectional.d.ts","sourceRoot":"","sources":["../../../src/validations/relations/bidirectional.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA+CtC;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,OAAc,QAAQ,kBA+BhE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/database",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha.0",
|
|
4
4
|
"description": "Strapi's database layer",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"source": "./src/index.ts",
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
30
|
"files": [
|
|
31
|
-
"
|
|
31
|
+
"dist/"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "pack-up build",
|
|
@@ -39,23 +39,23 @@
|
|
|
39
39
|
"watch": "pack-up watch"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@strapi/utils": "
|
|
42
|
+
"@strapi/utils": "5.0.0-alpha.0",
|
|
43
43
|
"date-fns": "2.30.0",
|
|
44
44
|
"debug": "4.3.4",
|
|
45
|
-
"fs-extra": "10.
|
|
46
|
-
"knex": "
|
|
45
|
+
"fs-extra": "10.1.0",
|
|
46
|
+
"knex": "3.0.1",
|
|
47
47
|
"lodash": "4.17.21",
|
|
48
48
|
"semver": "7.5.4",
|
|
49
49
|
"umzug": "3.2.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@strapi/pack-up": "
|
|
53
|
-
"eslint-config-custom": "
|
|
54
|
-
"tsconfig": "
|
|
52
|
+
"@strapi/pack-up": "5.0.0-alpha.0",
|
|
53
|
+
"eslint-config-custom": "5.0.0-alpha.0",
|
|
54
|
+
"tsconfig": "5.0.0-alpha.0"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=18.0.0 <=20.x.x",
|
|
58
58
|
"npm": ">=6.0.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "ceeb3f383cbaf51eeaa373750a27a2880a10f727"
|
|
61
61
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Knex } from 'knex';
|
|
2
|
-
import type { ID, Relation } from '../../../types';
|
|
3
|
-
declare const replaceRegularRelations: ({ targetId, sourceId, attribute, omitIds, transaction: trx, }: {
|
|
4
|
-
targetId: ID;
|
|
5
|
-
sourceId: ID;
|
|
6
|
-
attribute: Relation.Bidirectional;
|
|
7
|
-
omitIds: ID[];
|
|
8
|
-
transaction?: Knex.Transaction<any, any[]> | undefined;
|
|
9
|
-
}) => Promise<void>;
|
|
10
|
-
declare const cloneRegularRelations: ({ targetId, sourceId, attribute, transaction: trx, }: {
|
|
11
|
-
targetId: ID;
|
|
12
|
-
sourceId: ID;
|
|
13
|
-
attribute: Relation.Bidirectional;
|
|
14
|
-
transaction?: Knex.Transaction<any, any[]> | undefined;
|
|
15
|
-
}) => Promise<void>;
|
|
16
|
-
export { replaceRegularRelations, cloneRegularRelations };
|
|
17
|
-
//# sourceMappingURL=regular-relations.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"regular-relations.d.ts","sourceRoot":"","sources":["../../../../src/entity-manager/relations/cloning/regular-relations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEnD,QAAA,MAAM,uBAAuB;cAOjB,EAAE;cACF,EAAE;eACD,SAAS,aAAa;aACxB,EAAE,EAAE;;mBAiBd,CAAC;AAEF,QAAA,MAAM,qBAAqB;cAMf,EAAE;cACF,EAAE;eACD,SAAS,aAAa;;mBAsDlC,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Model } from '../types';
|
|
2
|
-
export interface Attribute {
|
|
3
|
-
type: string;
|
|
4
|
-
multiple?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface ContentType {
|
|
7
|
-
uid: string;
|
|
8
|
-
modelName: string;
|
|
9
|
-
collectionName: string;
|
|
10
|
-
attributes: Record<string, Attribute>;
|
|
11
|
-
}
|
|
12
|
-
export declare const transformContentTypes: (contentTypes: ContentType[]) => Model[];
|
|
13
|
-
//# sourceMappingURL=content-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../src/utils/content-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACvC;AAmBD,eAAO,MAAM,qBAAqB,iBAAkB,WAAW,EAAE,KAAG,KAAK,EAkBxE,CAAC"}
|