Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
3455f95
Upgrade to TS V5 and fix related breaking changes
Convly Apr 20, 2023
4ef4651
Merge branch 'main' into chore/upgrade-ts-v5
Convly Apr 21, 2023
8c6a17c
Add collectionName to literal properties
christiancp100 Apr 24, 2023
2560c57
Merge pull request #16487 from strapi/ts-basic-info
Convly Apr 24, 2023
c7d9ee1
Merge branch 'main' into features/ts-support-2
Convly Apr 26, 2023
e270ec0
Add more flexibility to controller types
christiancp100 May 12, 2023
6d38d13
Init type system basis
Convly May 12, 2023
f3cde5d
Co-authored-by: Jean-Sébastien Herbaux <Convly@users.noreply.github.com>
christiancp100 May 15, 2023
6be11d9
Update types for router
christiancp100 May 15, 2023
204114d
Fix services typings
christiancp100 May 15, 2023
094aa40
Implement the type system from within strapi/strapi
Convly May 15, 2023
fc8ea40
Merge branch 'main' into features/ts-support-2
Convly May 15, 2023
d239356
Merge branch 'features/ts-support-2' into ts-support-2/type-system
Convly May 15, 2023
a58b981
Add missing assert test for the global namespace
Convly May 15, 2023
cbab931
Remove invalid import
Convly May 15, 2023
44b15c6
Add comments & rename some utilities
Convly May 15, 2023
9b043be
Fix typo
Convly May 15, 2023
8f1f784
Update the controller type to make it more generic
Convly May 15, 2023
92f84af
Undo not necessary changes
christiancp100 May 15, 2023
d7fa412
Scope types with modules
Convly May 15, 2023
4e60b8a
Fix typo in jsdoc
Convly May 15, 2023
e33d360
Add todo comment
christiancp100 May 15, 2023
d73bb18
Improve typings
christiancp100 May 15, 2023
1254018
Add default value to RouterConfig
christiancp100 May 15, 2023
73ef6a5
Merge pull request #16697 from strapi/feature/ts-factories
christiancp100 May 16, 2023
2d32cb1
Remove the possibility to select a filename and a directory for the g…
Convly May 17, 2023
e0b3603
Remove global interface type and uids definitions from global.d.ts
Convly May 17, 2023
c1a3193
Remove SchemaUID from the strapi/strapi ts utils
Convly May 17, 2023
aa9cb05
Fix the base registry types to fix keyof set to never for empty regis…
Convly May 17, 2023
015dd9f
Allow UID.Component to be generic for inferrence
Convly May 17, 2023
2a14902
Export dynamic UIDs union types based on the registry values
Convly May 17, 2023
3ef8a8d
Move core types to namespaces and use new UIDs
Convly May 17, 2023
7761efd
Update the ts generators to fit the new type system
Convly May 17, 2023
32e6856
Fix utils/typescript unit tests
Convly May 17, 2023
4f8161c
Introduce Attribute.Any
Convly May 17, 2023
e63e3be
Add default type values for component and dynamic zone
Convly May 17, 2023
b799705
Set the base for the new typings for controllers
christiancp100 May 25, 2023
d2be844
Fix Attribute.Any definition
Convly May 25, 2023
35357db
Update packages/core/strapi/lib/types/core/namespace.d.ts
Convly May 25, 2023
f1593c2
Update packages/core/strapi/lib/types/core/uid.d.ts
Convly May 25, 2023
221fbaf
Merge branch 'ts-support-2/type-system' into ts-support/controllers
christiancp100 May 25, 2023
9fca32a
Update data transfer types
Convly May 26, 2023
9bd29e3
Update data transfer code to adapt with new types
Convly May 26, 2023
b30a3b4
Update ControllerHandler return type to accept void
Convly May 26, 2023
1b50667
Use ColonsSeparator for api & plugin namespace (origin <> scope)
Convly May 26, 2023
90b5fa8
Rename AssertNamespaceIs to EnsureNamespaceMatches for uids
Convly May 26, 2023
2cdc6b0
Rename Contains to Includes
Convly May 26, 2023
f0841f6
Merge branch 'ts-support-2/type-system' into ts-support-2/update-type…
Convly May 26, 2023
94e3595
Move utils to namespaces & fix types
Convly May 26, 2023
2a75f0b
Merge branch 'main' into ts-support-2/type-system
Convly May 26, 2023
2eb6b5c
Merge branch 'main' into features/ts-support-2
Convly May 26, 2023
9b8fb00
Merge branch 'main' into ts-support-2/update-type-gen
Convly May 26, 2023
0b15df5
Merge branch 'ts-support-2/type-system' into ts-support-2/update-type…
Convly May 26, 2023
489e422
Revert breaking change & adapt the feature behavior
Convly May 26, 2023
7738d67
Fix the autogenerate experimental features to match the new generate …
Convly May 30, 2023
c7576cd
Merge branch 'main' into features/ts-support-2
Convly May 30, 2023
f947680
Merge branch 'main' into ts-support-2/type-system
Convly May 30, 2023
7969d71
Merge branch 'ts-support-2/type-system' into ts-support-2/update-type…
Convly May 30, 2023
12c767c
Init type system basis
Convly May 12, 2023
976b098
Implement the type system from within strapi/strapi
Convly May 15, 2023
cf0fa4e
Add missing assert test for the global namespace
Convly May 15, 2023
39c2ffa
Remove invalid import
Convly May 15, 2023
03910de
Add comments & rename some utilities
Convly May 15, 2023
4761d9c
Fix typo
Convly May 15, 2023
b585434
Update the controller type to make it more generic
Convly May 15, 2023
47e48cc
Scope types with modules
Convly May 15, 2023
88efe3c
Fix typo in jsdoc
Convly May 15, 2023
a3052b6
Update packages/core/strapi/lib/types/core/namespace.d.ts
Convly May 25, 2023
4f76e65
Update packages/core/strapi/lib/types/core/uid.d.ts
Convly May 25, 2023
2f65385
Update ControllerHandler return type to accept void
Convly May 26, 2023
a13398e
Use ColonsSeparator for api & plugin namespace (origin <> scope)
Convly May 26, 2023
fef81ec
Rename AssertNamespaceIs to EnsureNamespaceMatches for uids
Convly May 26, 2023
a59719c
Rename Contains to Includes
Convly May 26, 2023
672dfab
Merge branch 'ts-support-2/type-system' into ts-support-2/update-type…
Convly May 30, 2023
ee84754
Revert mistakes for dts changes
Convly May 30, 2023
5340ba8
Merge branch 'ts-support-2/update-type-gen' into ts-support/controllers
christiancp100 May 30, 2023
da4b873
Merge branch 'ts-support/controllers' of https://github.com/strapi/st…
christiancp100 May 30, 2023
26a138b
Merge branch 'ts-support-2/update-type-gen' into ts-support/controllers
christiancp100 May 30, 2023
efc6f1b
Revert factories > Factories
Convly May 30, 2023
99e4b4a
Merge branch 'ts-support-2/update-type-gen' into ts-support/controllers
christiancp100 May 30, 2023
dcd1ef1
Remove unused import
Convly May 30, 2023
2a194c2
Merge pull request #16724 from strapi/ts-support-2/type-system
Convly May 30, 2023
ce62bbc
Improve typings in the strapi.controllers
christiancp100 May 30, 2023
7162234
Merge branch 'features/ts-support-2' into ts-support/controllers
christiancp100 May 30, 2023
7e74748
Merge pull request #16757 from strapi/ts-support-2/update-type-gen
Convly May 31, 2023
9fc3537
Use component uid instead of content type uid
Convly Jun 1, 2023
8d67544
Merge pull request #16883 from strapi/ts-support-2/fix-get-dynamic-zo…
Convly Jun 1, 2023
9ba81c8
Use getSchemas to fetch providers' schemas
Convly Jun 5, 2023
d0e4691
Use Knex.Transaction instead of exporting it from DTS
Convly Jun 5, 2023
2375e5c
Fix space typo
Convly Jun 5, 2023
c371765
Change import paths, update the core api types
Convly Jun 6, 2023
b1503aa
Rename artefact to artifact
Convly Jun 6, 2023
ee37896
Rename Attribute.Attribute to Attribute.OfType when using a generic
Convly Jun 6, 2023
2b8d9de
Update wording for relation types
Convly Jun 6, 2023
eff2db3
Add example for Component UID warning
Convly Jun 6, 2023
6bcd972
Remove pluralize usage
Convly Jun 6, 2023
595a4c8
Use better generic parameter names to follow new Strapi x TS conventions
Convly Jun 6, 2023
199ed9f
Merge branch 'features/type-system' into ts-support/controllers
christiancp100 Jun 6, 2023
dd8f98c
Improve types for controllers, services and routes
christiancp100 Jun 6, 2023
132ecc5
Add more expression types
Convly Jun 7, 2023
b85963f
Update types with new Utils
christiancp100 Jun 7, 2023
8a5ac95
Rename uid file
christiancp100 Jun 7, 2023
9bb046f
Remove unexisting import
christiancp100 Jun 7, 2023
98baf79
Fix controllerhandler
christiancp100 Jun 7, 2023
0296587
Update packages/core/strapi/lib/types/core-api/router.d.ts
christiancp100 Jun 7, 2023
e903193
Update packages/core/strapi/lib/types/core-api/router.d.ts
christiancp100 Jun 7, 2023
4211eca
Update packages/core/strapi/lib/types/core-api/service.d.ts
christiancp100 Jun 7, 2023
4500d4c
Update packages/core/strapi/lib/types/core/strapi/index.d.ts
christiancp100 Jun 7, 2023
86128b9
Update packages/core/strapi/lib/types/core-api/service.d.ts
christiancp100 Jun 7, 2023
af61b69
Replace types for interfaces where needed
christiancp100 Jun 8, 2023
f0aaefb
Merge branch 'ts-support/controllers' of https://github.com/strapi/st…
christiancp100 Jun 8, 2023
6494068
Update packages/core/strapi/lib/types/core-api/controller.d.ts
christiancp100 Jun 8, 2023
517212d
Merge pull request #16837 from strapi/ts-support/controllers
Jun 8, 2023
78e6952
Fix relation attribute type, add back relation and target properties
Convly Jun 9, 2023
4726734
Add back the common service type
Convly Jun 9, 2023
820da82
Fix relation attribute type (mappedBy and inversedBy), make it compat…
Convly Jun 9, 2023
7e901ba
Update app & types generation for javascript projects, fix empty augm…
Convly Jun 9, 2023
f427c24
Merge branch 'main' into features/type-system
Convly Jun 9, 2023
a238c97
Fix js support
Convly Jun 12, 2023
72d8734
Use types instead of scalar for boolean values
Convly Jun 12, 2023
2f6b153
Merge branch 'releases/4.11.1' into features/type-system
Convly Jun 12, 2023
1e91d9b
Review comments
Convly Jun 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update data transfer types
  • Loading branch information
Convly committed May 26, 2023
commit 9fca32a25e21b64c8f2664b2d1153f2eb8ae4314
9 changes: 4 additions & 5 deletions packages/core/data-transfer/types/common-entities.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { GetAttributesValues, RelationsType } from '@strapi/strapi';
import type { SchemaUID } from '@strapi/strapi/lib/types/utils';
import type { Attribute, Common } from '@strapi/strapi';
import type { Readable } from 'stream';

export interface IMetadata {
Expand All @@ -14,7 +13,7 @@ export interface IMetadata {
* Common TransferEngine format to represent a Strapi entity
* @template T The schema UID this entity represents
*/
export interface IEntity<T extends SchemaUID | string = SchemaUID> {
export interface IEntity<T extends Common.UID.ContentType = Common.UID.ContentType> {
/**
* UID of the parent type (content-type, component, etc...)
*/
Expand All @@ -29,7 +28,7 @@ export interface IEntity<T extends SchemaUID | string = SchemaUID> {
/**
* The entity data (attributes value)
*/
data: GetAttributesValues<T>;
data: Attribute.GetValues<T>;
}

/**
Expand All @@ -50,7 +49,7 @@ interface IDefaultLink {
/**
* The relation type
*/
relation: RelationsType;
relation: Attribute.RelationsType;

/**
* Left side of the link
Expand Down
2 changes: 1 addition & 1 deletion packages/core/data-transfer/types/encryption.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Cipher, CipherKey, BinaryLike } from 'crypto';
import type { Cipher } from 'crypto';

export type EncryptionStrategy = (key: string) => Cipher;

Expand Down
10 changes: 5 additions & 5 deletions packages/core/data-transfer/types/providers.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { PipelineSource, PipelineDestination, Readable, Writable } from 'stream';
import type { Schema, Utils } from '@strapi/strapi';
import type { Readable, Writable } from 'stream';
import type {
IDestinationProviderTransferResults,
IProviderTransferResults,
ISourceProviderTransferResults,
Stream,
MaybePromise,
} from './utils';
import type { IMetadata } from './common-entities';

type ProviderType = 'source' | 'destination';
export type ProviderType = 'source' | 'destination';

interface IProvider {
export interface IProvider {
type: ProviderType;
name: string;
results?: IProviderTransferResults;
Expand All @@ -19,7 +19,7 @@ interface IProvider {
close?(): MaybePromise<void>;

getMetadata(): MaybePromise<IMetadata | null>;
getSchemas?(): MaybePromise<Strapi.Schemas>;
getSchemas?(): MaybePromise<Utils.StringRecord<Schema.Schema> | null>;

beforeTransfer?(): MaybePromise<void>;
validateOptions?(): MaybePromise<void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { TransferPushMessage } from './push';
export * from './action';
export * from './pull';
export * from './push';
export * from './utils';

export type TransferMessage = { type: 'transfer'; transferID: string } & (
| Action
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IEntity, ILink, IConfiguration } from '../../../../common-entities';
import { CreateTransferMessage } from './utils';
import { CreateTransferMessage, TransferAssetFlow } from './utils';

export type TransferPullMessage = CreateTransferMessage<
'step',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CreateTransferMessage } from './utils';
import type { IEntity, ILink, IConfiguration, IAsset } from '../../../../common-entities';
import type { CreateTransferMessage, TransferAssetFlow } from './utils';
import type { IEntity, ILink, IConfiguration } from '../../../../common-entities';

export type TransferPushMessage = CreateTransferMessage<
'step',
Expand All @@ -23,9 +23,3 @@ export type TransferPushStep = TransferPushMessage['step'];
type TransferStepCommands<T extends string, U> = { step: T } & TransferStepFlow<U>;

type TransferStepFlow<U> = { action: 'start' } | { action: 'stream'; data: U } | { action: 'end' };

type TransferAssetFlow = { assetID: string } & (
| { action: 'start'; data: Omit<IAsset, 'stream'> }
| { action: 'stream'; data: Buffer }
| { action: 'end' }
);
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import type { IAsset } from '../../../../common-entities';

export type CreateTransferMessage<T extends string, U = unknown> = {
type: 'transfer';
kind: T;
transferID: string;
} & U;

export type TransferAssetFlow = { assetID: string } & (
| { action: 'start'; data: Omit<IAsset, 'stream'> }
| { action: 'stream'; data: Buffer }
| { action: 'end' }
);
4 changes: 2 additions & 2 deletions packages/core/data-transfer/types/remote/protocol/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * as client from './client';
export * as server from './server';
export * as Client from './client';
export * as Server from './server';
7 changes: 3 additions & 4 deletions packages/core/data-transfer/types/transfer-engine.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { PassThrough } from 'stream';
import type { ITransferResults, TransferTransforms, TransferProgress } from './utils';
import type { ISourceProvider, IDestinationProvider } from './providers';
import type { DiagnosticReporter } from '../src/engine/diagnostic';
import type { IDiagnosticReporter } from '../src/engine/diagnostic';
import type { Diff } from '../src/utils/json';

export type TransferFilterPreset = 'content' | 'files' | 'config';

type SchemaMap = Record<string, Schema>;

// Error resolving handler middleware for the transfer engine
export type NextMiddleware<T> = (context: T) => void | Promise<void>;
export type Middleware<T> = (context: T, next: NextMiddleware<T>) => Promise<void> | void;
Expand Down Expand Up @@ -42,7 +41,7 @@ export interface ITransferEngine<
* A diagnostic reporter instance used to gather information about
* errors, warnings and information emitted by the engine
*/
diagnostics: DiagnosticReporter;
diagnostics: IDiagnosticReporter;
/**
* Utilities used to retrieve transfer progress data
*/
Expand Down
20 changes: 12 additions & 8 deletions packages/core/data-transfer/types/utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable @typescript-eslint/ban-types */
import type { Readable, Writable, Duplex, Transform } from 'stream';
import type { Schema } from '@strapi/strapi';
import type { KnexTransaction } from 'knex';
import type { IDestinationProvider, ISourceProvider } from './providers';
import type { Knex } from 'knex';
import type { Duplex, Readable, Transform, Writable } from 'stream';
import type { IAsset, IEntity, ILink } from './common-entities';
import type { IDestinationProvider, ISourceProvider } from './providers';

export type MaybePromise<T> = T | Promise<T>;

// The data type passed in for each stage
export type TransferStageTypeMap = {
schemas: Schema;
schemas: Schema.Schema;
entities: IEntity;
links: ILink;
assets: IAsset;
Expand All @@ -31,7 +31,7 @@ export type TransferMap<T> = {
};

export type Stream = Readable | Writable | Duplex | Transform;
export type TransformFunction = (chunk: any, encoding?: string) => any;
export type TransformFunction = (chunk: unknown, encoding?: string) => unknown;
export type StreamItem = Stream | TransformFunction;

export type TransferTransformsTypeMap = TransferStageTypeMap & {
Expand All @@ -40,7 +40,9 @@ export type TransferTransformsTypeMap = TransferStageTypeMap & {

export type TransferStage = keyof TransferStageTypeMap;

export type TransferTransformArray<T> = TransferTransform<TransferStageTypeMap[T]>[];
export type TransferTransformArray<T extends TransferTransformOption> = TransferTransform<
TransferTransformsTypeMap[T]
>[];

export type TransferTransformOption = keyof TransferTransformsTypeMap;

Expand All @@ -51,7 +53,9 @@ export type TransferTransforms = {
/*
* Filters
*/
export type TransferFilterArray<T> = TransferFilter<TransferStageTypeMap[T]>[];
export type TransferFilterArray<T extends TransferTransformOption> = TransferFilter<
TransferTransforms[T]
>[];

export type TransferFilters = {
[key in TransferTransformOption]?: boolean | TransferFilterArray<key>;
Expand Down Expand Up @@ -86,7 +90,7 @@ export type IProviderTransferResults = {};
export type ISourceProviderTransferResults = {};
export type IDestinationProviderTransferResults = {};

export type { KnexTransaction };
export type KnexTransaction = Knex.Transaction;
export type TransactionCallback = (trx?: KnexTransaction) => Promise<void>;
export type Transaction = {
attach<T = undefined>(callback: TransactionCallback): Promise<T | undefined>;
Expand Down