@rainbow-o23/n3 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +11 -0
- package/.eslintrc +23 -0
- package/README.md +584 -0
- package/index.cjs +2283 -0
- package/index.d.ts +5 -0
- package/index.js +2229 -0
- package/lib/error-codes.d.ts +17 -0
- package/lib/http/fetch-step.d.ts +53 -0
- package/lib/http/index.d.ts +2 -0
- package/lib/http/types.d.ts +21 -0
- package/lib/step/abstract-fragmentary-pipeline-step.d.ts +44 -0
- package/lib/step/async-step-sets.d.ts +5 -0
- package/lib/step/conditional-step-sets.d.ts +23 -0
- package/lib/step/delete-property-step.d.ts +11 -0
- package/lib/step/each-step-sets.d.ts +14 -0
- package/lib/step/get-property-step.d.ts +11 -0
- package/lib/step/index.d.ts +14 -0
- package/lib/step/ref-pipeline-step.d.ts +15 -0
- package/lib/step/ref-step-step.d.ts +14 -0
- package/lib/step/routes-step-sets.d.ts +30 -0
- package/lib/step/snippet-step.d.ts +19 -0
- package/lib/step/snowflake-step.d.ts +6 -0
- package/lib/step/step-sets.d.ts +19 -0
- package/lib/step/types.d.ts +13 -0
- package/lib/step/utils.d.ts +23 -0
- package/lib/typeorm/abstract-datasource.d.ts +22 -0
- package/lib/typeorm/better-sqlite3-datasource.d.ts +7 -0
- package/lib/typeorm/datasource-manager.d.ts +25 -0
- package/lib/typeorm/index.d.ts +7 -0
- package/lib/typeorm/mssql-datasource.d.ts +6 -0
- package/lib/typeorm/mysql-datasource.d.ts +6 -0
- package/lib/typeorm/oracle-datasource.d.ts +6 -0
- package/lib/typeorm/pgsql-datasource.d.ts +6 -0
- package/lib/typeorm-step/abstract-typeorm-by-sql-step.d.ts +62 -0
- package/lib/typeorm-step/abstract-typeorm-load-by-sql-step.d.ts +10 -0
- package/lib/typeorm-step/abstract-typeorm-step.d.ts +30 -0
- package/lib/typeorm-step/index.d.ts +12 -0
- package/lib/typeorm-step/type-orm-transactional-step-sets.d.ts +22 -0
- package/lib/typeorm-step/typeorm-bulk-save-by-sql-step.d.ts +9 -0
- package/lib/typeorm-step/typeorm-by-snippet-step.d.ts +21 -0
- package/lib/typeorm-step/typeorm-load-entity-by-id-step.d.ts +12 -0
- package/lib/typeorm-step/typeorm-load-many-by-sql-step.d.ts +6 -0
- package/lib/typeorm-step/typeorm-load-one-by-sql-step.d.ts +6 -0
- package/lib/typeorm-step/typeorm-save-by-sql-step.d.ts +9 -0
- package/lib/typeorm-step/typeorm-save-entity-step.d.ts +32 -0
- package/lib/typeorm-step/types.d.ts +22 -0
- package/package.json +74 -0
- package/rollup.config.base.js +33 -0
- package/rollup.config.ci.js +3 -0
- package/rollup.config.js +3 -0
- package/src/index.ts +7 -0
- package/src/lib/error-codes.ts +18 -0
- package/src/lib/http/fetch-step.ts +290 -0
- package/src/lib/http/index.ts +3 -0
- package/src/lib/http/types.ts +33 -0
- package/src/lib/step/abstract-fragmentary-pipeline-step.ts +367 -0
- package/src/lib/step/async-step-sets.ts +14 -0
- package/src/lib/step/conditional-step-sets.ts +115 -0
- package/src/lib/step/delete-property-step.ts +33 -0
- package/src/lib/step/each-step-sets.ts +80 -0
- package/src/lib/step/get-property-step.ts +34 -0
- package/src/lib/step/index.ts +18 -0
- package/src/lib/step/ref-pipeline-step.ts +65 -0
- package/src/lib/step/ref-step-step.ts +59 -0
- package/src/lib/step/routes-step-sets.ts +147 -0
- package/src/lib/step/snippet-step.ts +80 -0
- package/src/lib/step/snowflake-step.ts +16 -0
- package/src/lib/step/step-sets.ts +99 -0
- package/src/lib/step/types.ts +23 -0
- package/src/lib/step/utils.ts +109 -0
- package/src/lib/typeorm/abstract-datasource.ts +58 -0
- package/src/lib/typeorm/better-sqlite3-datasource.ts +29 -0
- package/src/lib/typeorm/datasource-manager.ts +104 -0
- package/src/lib/typeorm/index.ts +9 -0
- package/src/lib/typeorm/mssql-datasource.ts +131 -0
- package/src/lib/typeorm/mysql-datasource.ts +35 -0
- package/src/lib/typeorm/oracle-datasource.ts +27 -0
- package/src/lib/typeorm/pgsql-datasource.ts +25 -0
- package/src/lib/typeorm-step/abstract-typeorm-by-sql-step.ts +556 -0
- package/src/lib/typeorm-step/abstract-typeorm-load-by-sql-step.ts +31 -0
- package/src/lib/typeorm-step/abstract-typeorm-step.ts +241 -0
- package/src/lib/typeorm-step/index.ts +17 -0
- package/src/lib/typeorm-step/type-orm-transactional-step-sets.ts +129 -0
- package/src/lib/typeorm-step/typeorm-bulk-save-by-sql-step.ts +29 -0
- package/src/lib/typeorm-step/typeorm-by-snippet-step.ts +83 -0
- package/src/lib/typeorm-step/typeorm-load-entity-by-id-step.ts +35 -0
- package/src/lib/typeorm-step/typeorm-load-many-by-sql-step.ts +13 -0
- package/src/lib/typeorm-step/typeorm-load-one-by-sql-step.ts +13 -0
- package/src/lib/typeorm-step/typeorm-save-by-sql-step.ts +24 -0
- package/src/lib/typeorm-step/typeorm-save-entity-step.ts +109 -0
- package/src/lib/typeorm-step/types.ts +25 -0
- package/test/step/snippet-step.test.ts +21 -0
- package/test/step/snowflake-step.test.ts +22 -0
- package/test/step/typeorm-by-sql-autonomous.test.ts +117 -0
- package/test/step/typeorm-by-sql-transactional.test.ts +215 -0
- package/test/step/typeorm-entity.test.ts +50 -0
- package/tsconfig.json +36 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { O23ReservedErrorCode } from '@rainbow-o23/n1';
|
|
2
|
+
export declare const ERR_PIPELINE_STEP_SNIPPET_NOT_EMPTY: O23ReservedErrorCode;
|
|
3
|
+
export declare const ERR_PIPELINE_STEP_CONDITIONAL_SNIPPET_NOT_EMPTY: O23ReservedErrorCode;
|
|
4
|
+
export declare const ERR_TYPEORM_DATASOURCE_TYPE_NOT_FOUND: O23ReservedErrorCode;
|
|
5
|
+
export declare const ERR_TYPEORM_DATASOURCE_CREATOR_NOT_FOUND: O23ReservedErrorCode;
|
|
6
|
+
export declare const ERR_TYPEORM_DATASOURCE_NOT_FOUND: O23ReservedErrorCode;
|
|
7
|
+
export declare const ERR_TYPEORM_ENTITY_NOT_FOUND: O23ReservedErrorCode;
|
|
8
|
+
export declare const ERR_TYPEORM_SQL_NOT_EMPTY: O23ReservedErrorCode;
|
|
9
|
+
export declare const ERR_TYPEORM_TRANSACTION_NOT_FOUND: O23ReservedErrorCode;
|
|
10
|
+
export declare const ERR_TYPEORM_STEP_SNIPPET_NOT_EMPTY: O23ReservedErrorCode;
|
|
11
|
+
export declare const ERR_FETCH_ERROR: O23ReservedErrorCode;
|
|
12
|
+
export declare const ERR_PIPELINE_STEP_METHOD_NOT_SUPPORTED: O23ReservedErrorCode;
|
|
13
|
+
export declare const ERR_EACH_FRAGMENT_NOT_ANY_ARRAY: O23ReservedErrorCode;
|
|
14
|
+
export declare const ERR_PIPELINE_STEP_REF_NOT_EMPTY: O23ReservedErrorCode;
|
|
15
|
+
export declare const ERR_PIPELINE_STEP_REF_NOT_FOUND: O23ReservedErrorCode;
|
|
16
|
+
export declare const ERR_PIPELINE_REF_NOT_EMPTY: O23ReservedErrorCode;
|
|
17
|
+
export declare const ERR_PIPELINE_REF_NOT_FOUND: O23ReservedErrorCode;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { PipelineStepData, PipelineStepPayload } from '@rainbow-o23/n1';
|
|
2
|
+
import { AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions, ScriptFuncOrBody } from '../step';
|
|
3
|
+
import { HttpErrorCode, HttpGenerateBody, HttpGenerateHeaders, HttpGenerateResponse, HttpGenerateUrl, HttpHandleError } from './types';
|
|
4
|
+
export interface FetchPipelineStepOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment> {
|
|
5
|
+
endpointSystemCode: string;
|
|
6
|
+
endpointName: string;
|
|
7
|
+
urlGenerate?: ScriptFuncOrBody<HttpGenerateUrl<In, InFragment>>;
|
|
8
|
+
headersGenerate?: ScriptFuncOrBody<HttpGenerateHeaders<In, InFragment>>;
|
|
9
|
+
bodyGenerate?: ScriptFuncOrBody<HttpGenerateBody<In, InFragment>>;
|
|
10
|
+
responseGenerate?: ScriptFuncOrBody<HttpGenerateResponse<In, InFragment>>;
|
|
11
|
+
responseErrorHandles?: {
|
|
12
|
+
[key: HttpErrorCode]: ScriptFuncOrBody<HttpHandleError<In, InFragment, OutFragment>>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare class FetchPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
|
|
16
|
+
private readonly _endpointSystemCode;
|
|
17
|
+
private readonly _endpointName;
|
|
18
|
+
private readonly _endpointUrl;
|
|
19
|
+
private readonly _endpointMethod;
|
|
20
|
+
private readonly _endpointHeaders;
|
|
21
|
+
private readonly _endpointTimeout;
|
|
22
|
+
private readonly _urlGenerateSnippet;
|
|
23
|
+
private readonly _urlGenerateFunc;
|
|
24
|
+
private readonly _headersGenerateSnippet;
|
|
25
|
+
private readonly _headersGenerateFunc;
|
|
26
|
+
private readonly _bodyUsed;
|
|
27
|
+
private readonly _bodyGenerateSnippet;
|
|
28
|
+
private readonly _bodyGenerateFunc;
|
|
29
|
+
private readonly _responseGenerateSnippet;
|
|
30
|
+
private readonly _responseGenerateFunc;
|
|
31
|
+
private readonly _responseErrorHandleFunc;
|
|
32
|
+
constructor(options: FetchPipelineStepOptions<In, Out, InFragment, OutFragment>);
|
|
33
|
+
getEndpointSystemCode(): string;
|
|
34
|
+
getEndpointName(): string;
|
|
35
|
+
getEndpointKey(): string;
|
|
36
|
+
getEndpointUrl(): string;
|
|
37
|
+
getEndpointMethod(): string;
|
|
38
|
+
getEndpointHeaders(): Record<string, string>;
|
|
39
|
+
protected generateEndpointHeaders(headers?: string, base?: Record<string, string>): Record<string, string>;
|
|
40
|
+
getEndpointTimeout(): number;
|
|
41
|
+
needTimeout(): boolean;
|
|
42
|
+
getUrlGenerateSnippet(): ScriptFuncOrBody<HttpGenerateUrl<In, InFragment>>;
|
|
43
|
+
protected getUrlGenerateVariableName(): Array<string>;
|
|
44
|
+
getHeadersGenerateSnippet(): ScriptFuncOrBody<HttpGenerateHeaders<In, InFragment>>;
|
|
45
|
+
protected getHeadersGenerateVariableNames(): Array<string>;
|
|
46
|
+
protected isBodyUsed(): boolean;
|
|
47
|
+
getBodyGenerateSnippet(): ScriptFuncOrBody<HttpGenerateBody<In, InFragment>>;
|
|
48
|
+
protected getBodyGenerateVariableNames(): Array<string>;
|
|
49
|
+
getResponseGenerateSnippet(): ScriptFuncOrBody<HttpGenerateResponse<In, InFragment>>;
|
|
50
|
+
protected getResponseGenerateVariableName(): Array<string>;
|
|
51
|
+
protected getErrorHandlerVariableName(): Array<string>;
|
|
52
|
+
protected doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PipelineStepData, PipelineStepHelpers, Undefinable } from '@rainbow-o23/n1';
|
|
2
|
+
import { Response } from 'node-fetch';
|
|
3
|
+
export type HttpGenerateUrl<In, InFragment> = ($endpointUrl: string, $factor: InFragment, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => string;
|
|
4
|
+
export type HttpGenerateHeaders<In, InFragment> = ($factor: InFragment, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Undefinable<Record<string, string>>;
|
|
5
|
+
export type HttpGenerateBody<In, InFragment> = ($factor: InFragment, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => any;
|
|
6
|
+
export type HttpGenerateResponse<In, InFragment> = ($response: Response, $factor: InFragment, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<any>;
|
|
7
|
+
export type HttpUnpredictedErrorCode = `0${number}`;
|
|
8
|
+
export declare const HttpUnknownErrorCode: HttpUnpredictedErrorCode;
|
|
9
|
+
export type HttpClientErrorCode = `4${number}`;
|
|
10
|
+
export type HttpServerErrorCode = `5${number}`;
|
|
11
|
+
export type HttpCustomizedErrorCode = `6${number}`;
|
|
12
|
+
export declare const HttpAbortErrorCode: HttpCustomizedErrorCode;
|
|
13
|
+
export type HttpErrorCode = HttpUnpredictedErrorCode | HttpClientErrorCode | HttpServerErrorCode | HttpCustomizedErrorCode;
|
|
14
|
+
export interface HttpErrorHandleOptions<In, InFragment> {
|
|
15
|
+
$errorCode: HttpErrorCode;
|
|
16
|
+
$url: string;
|
|
17
|
+
$response?: Response;
|
|
18
|
+
$factor: InFragment;
|
|
19
|
+
$request: PipelineStepData<In>;
|
|
20
|
+
}
|
|
21
|
+
export type HttpHandleError<In, InFragment, OutFragment> = (options: HttpErrorHandleOptions<In, InFragment>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment> | never;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AbstractPipelineStep, PipelineStepBuilder, PipelineStepData, PipelineStepHelpers, PipelineStepOptions, PipelineStepPayload } from '@rainbow-o23/n1';
|
|
2
|
+
import { PipelineStepSetsContext } from './step-sets';
|
|
3
|
+
import { HandleAnyError, HandleCatchableError, HandleExposedUncatchableError, HandleUncatchableError, ScriptFuncOrBody } from './types';
|
|
4
|
+
export interface FragmentaryPipelineStepOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends PipelineStepOptions {
|
|
5
|
+
fromRequest?: ScriptFuncOrBody<GetInFragmentFromRequestFunc<In, InFragment>>;
|
|
6
|
+
toResponse?: ScriptFuncOrBody<SetOutFragmentToResponseFunc<In, Out, OutFragment>>;
|
|
7
|
+
mergeRequest?: boolean | string;
|
|
8
|
+
errorHandles?: {
|
|
9
|
+
catchable?: ScriptFuncOrBody<HandleCatchableError<In, InFragment, OutFragment>> | Array<PipelineStepBuilder>;
|
|
10
|
+
uncatchable?: ScriptFuncOrBody<HandleUncatchableError<In, InFragment, OutFragment>> | Array<PipelineStepBuilder>;
|
|
11
|
+
exposed?: ScriptFuncOrBody<HandleExposedUncatchableError<In, InFragment, OutFragment>> | Array<PipelineStepBuilder>;
|
|
12
|
+
any?: ScriptFuncOrBody<HandleAnyError<In, InFragment, OutFragment>> | Array<PipelineStepBuilder>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export type GetInFragmentFromRequestFunc<In, InFragment> = ($factor: In, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => InFragment;
|
|
16
|
+
export type SetOutFragmentToResponseFunc<In, Out, OutFragment> = ($result: OutFragment, $request: PipelineStepData<In>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Out;
|
|
17
|
+
export declare abstract class AbstractFragmentaryPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractPipelineStep<In, Out> {
|
|
18
|
+
private readonly _fromRequestSnippet;
|
|
19
|
+
private readonly _toResponseSnippet;
|
|
20
|
+
private readonly _mergeRequest;
|
|
21
|
+
private readonly _fromRequestFunc;
|
|
22
|
+
private readonly _toResponseFunc;
|
|
23
|
+
private readonly _errorsSnippets?;
|
|
24
|
+
private readonly _errorsFuncs;
|
|
25
|
+
constructor(options: FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment>);
|
|
26
|
+
getFromRequestSnippet(): ScriptFuncOrBody<GetInFragmentFromRequestFunc<In, InFragment>>;
|
|
27
|
+
getToResponseSnippet(): ScriptFuncOrBody<SetOutFragmentToResponseFunc<In, Out, OutFragment>>;
|
|
28
|
+
isMergeRequest(): boolean;
|
|
29
|
+
useUnboxMerging(): boolean;
|
|
30
|
+
hasMergeKey(): boolean;
|
|
31
|
+
getMergeKey(): string;
|
|
32
|
+
protected generateFromRequestVariableNames(): Array<string>;
|
|
33
|
+
protected generateToResponseVariableNames(): Array<string>;
|
|
34
|
+
protected createToResponseFunc(): SetOutFragmentToResponseFunc<In, Out, OutFragment>;
|
|
35
|
+
protected getFromInput($factor: In, $request: PipelineStepData<In>): InFragment;
|
|
36
|
+
protected setToOutput($result: OutFragment, $request: PipelineStepData<In>): PipelineStepData<Out>;
|
|
37
|
+
protected abstract doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment>;
|
|
38
|
+
protected buildStepOptions(): Pick<PipelineStepOptions, 'config' | 'logger'>;
|
|
39
|
+
protected createErrorHandleContext(request: PipelineStepData<In>): PipelineStepSetsContext;
|
|
40
|
+
protected handleErrorSteps(fragment: InFragment, errorCode: string, error: any, request: PipelineStepData<In>, builders: Array<PipelineStepBuilder>): Promise<OutFragment>;
|
|
41
|
+
protected handleError(fragment: InFragment, request: PipelineStepData<In>, error: any): Promise<OutFragment>;
|
|
42
|
+
performAndCatch(request: PipelineStepData<In>, perform: (data: InFragment) => Promise<PipelineStepData<Out>>): Promise<PipelineStepData<Out>>;
|
|
43
|
+
perform(request: PipelineStepData<In>): Promise<PipelineStepData<Out>>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PipelineStepData, PipelineStepPayload } from '@rainbow-o23/n1';
|
|
2
|
+
import { PipelineStepSets } from './step-sets';
|
|
3
|
+
export declare class AsyncPipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In> extends PipelineStepSets<In, Out, InFragment, void> {
|
|
4
|
+
protected doPerform(data: InFragment, request: PipelineStepData<In>): Promise<void>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PipelineStepBuilder, PipelineStepData, PipelineStepHelpers, PipelineStepPayload, Undefinable } from '@rainbow-o23/n1';
|
|
2
|
+
import { PipelineStepSets, PipelineStepSetsOptions } from './step-sets';
|
|
3
|
+
import { ScriptFuncOrBody } from './types';
|
|
4
|
+
export type ConditionCheckWithInFragment<InFragment> = ($factor: InFragment, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<boolean>;
|
|
5
|
+
export type ConditionCheckWithoutInFragment = ($helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<boolean>;
|
|
6
|
+
export type ConditionCheckFunc<InFragment> = ConditionCheckWithInFragment<InFragment> | ConditionCheckWithoutInFragment;
|
|
7
|
+
export interface ConditionalPipelineStepSetsOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends PipelineStepSetsOptions<In, Out, InFragment, OutFragment> {
|
|
8
|
+
check: ScriptFuncOrBody<ConditionCheckFunc<InFragment>>;
|
|
9
|
+
otherwiseSteps: Array<PipelineStepBuilder>;
|
|
10
|
+
}
|
|
11
|
+
export declare class ConditionalPipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends PipelineStepSets<In, Out, InFragment, OutFragment> {
|
|
12
|
+
private readonly _checkSnippet;
|
|
13
|
+
private readonly _func;
|
|
14
|
+
private readonly _otherwiseStepBuilders;
|
|
15
|
+
constructor(options: ConditionalPipelineStepSetsOptions<In, Out, InFragment, OutFragment>);
|
|
16
|
+
getCheckSnippet(): ScriptFuncOrBody<ConditionCheckFunc<InFragment>>;
|
|
17
|
+
protected getOtherwiseStepBuilders(): Undefinable<Array<PipelineStepBuilder>>;
|
|
18
|
+
protected generateVariableNames(): Array<string>;
|
|
19
|
+
protected check(data: InFragment, _request: PipelineStepData<In>): Promise<boolean>;
|
|
20
|
+
perform(request: PipelineStepData<In>): Promise<PipelineStepData<Out>>;
|
|
21
|
+
protected isInFragmentIgnored(): boolean;
|
|
22
|
+
protected getInFragmentVariableName(): string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PipelineStepData, PipelineStepOptions, PipelineStepPayload } from '@rainbow-o23/n1';
|
|
2
|
+
import { AbstractFragmentaryPipelineStep } from './abstract-fragmentary-pipeline-step';
|
|
3
|
+
export interface DeletePropertyPipelineStepOptions extends PipelineStepOptions {
|
|
4
|
+
propertyNames: string | Array<string>;
|
|
5
|
+
}
|
|
6
|
+
export declare class DeletePropertyPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
|
|
7
|
+
private readonly _propertyNames;
|
|
8
|
+
constructor(options: DeletePropertyPipelineStepOptions);
|
|
9
|
+
getPropertyNames(): Array<string>;
|
|
10
|
+
protected doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PipelineStepData, PipelineStepPayload } from '@rainbow-o23/n1';
|
|
2
|
+
import { PipelineStepSets, PipelineStepSetsOptions } from './step-sets';
|
|
3
|
+
export interface EachPipelineStepSetsOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends PipelineStepSetsOptions<In, Out, InFragment, OutFragment> {
|
|
4
|
+
originalContentName?: string;
|
|
5
|
+
itemName?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class EachPipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends PipelineStepSets<In, Out, InFragment, OutFragment> {
|
|
8
|
+
private readonly _originalContentPropertyName;
|
|
9
|
+
private readonly _itemPropertyName;
|
|
10
|
+
constructor(options: EachPipelineStepSetsOptions<In, Out, InFragment, OutFragment>);
|
|
11
|
+
protected getOriginalContentPropertyName(): string;
|
|
12
|
+
protected getItemPropertyName(): string;
|
|
13
|
+
perform(request: PipelineStepData<In>): Promise<PipelineStepData<Out>>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PipelineStepData, PipelineStepPayload } from '@rainbow-o23/n1';
|
|
2
|
+
import { AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions } from './abstract-fragmentary-pipeline-step';
|
|
3
|
+
export interface GetPropertyPipelineStepOptions extends FragmentaryPipelineStepOptions {
|
|
4
|
+
propertyName: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class GetPropertyPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
|
|
7
|
+
private readonly _propertyName;
|
|
8
|
+
constructor(options: GetPropertyPipelineStepOptions);
|
|
9
|
+
getPropertyName(): string;
|
|
10
|
+
protected doPerform(data: InFragment, _request: PipelineStepData<In>): Promise<OutFragment>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './utils';
|
|
3
|
+
export * from './abstract-fragmentary-pipeline-step';
|
|
4
|
+
export * from './step-sets';
|
|
5
|
+
export * from './async-step-sets';
|
|
6
|
+
export * from './each-step-sets';
|
|
7
|
+
export * from './conditional-step-sets';
|
|
8
|
+
export * from './routes-step-sets';
|
|
9
|
+
export * from './snippet-step';
|
|
10
|
+
export * from './snowflake-step';
|
|
11
|
+
export * from './get-property-step';
|
|
12
|
+
export * from './delete-property-step';
|
|
13
|
+
export * from './ref-pipeline-step';
|
|
14
|
+
export * from './ref-step-step';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PipelineBuilder, PipelineCode, PipelineOptions, PipelineStepData, PipelineStepOptions, PipelineStepPayload } from '@rainbow-o23/n1';
|
|
2
|
+
import { AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions } from './abstract-fragmentary-pipeline-step';
|
|
3
|
+
export interface RefPipelinePipelineStepOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment> {
|
|
4
|
+
code: PipelineCode;
|
|
5
|
+
}
|
|
6
|
+
export declare class RefPipelinePipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
|
|
7
|
+
private readonly _code;
|
|
8
|
+
private readonly _pipelineBuilder;
|
|
9
|
+
constructor(options: RefPipelinePipelineStepOptions<In, Out, InFragment, OutFragment>);
|
|
10
|
+
getCode(): PipelineCode;
|
|
11
|
+
protected getPipelineBuilder(): PipelineBuilder;
|
|
12
|
+
protected buildPipelineOptions(): PipelineOptions;
|
|
13
|
+
protected buildStepOptions(): Pick<PipelineStepOptions, 'config' | 'logger'>;
|
|
14
|
+
protected doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PipelineStepBuilder, PipelineStepCode, PipelineStepData, PipelineStepOptions, PipelineStepPayload } from '@rainbow-o23/n1';
|
|
2
|
+
import { AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions } from './abstract-fragmentary-pipeline-step';
|
|
3
|
+
export interface RefStepPipelineStepOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment> {
|
|
4
|
+
code: PipelineStepCode;
|
|
5
|
+
}
|
|
6
|
+
export declare class RefStepPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
|
|
7
|
+
private readonly _code;
|
|
8
|
+
private readonly _stepBuilder;
|
|
9
|
+
constructor(options: RefStepPipelineStepOptions<In, Out, InFragment, OutFragment>);
|
|
10
|
+
getCode(): PipelineStepCode;
|
|
11
|
+
protected getStepBuilder(): PipelineStepBuilder;
|
|
12
|
+
protected buildStepOptions(): Pick<PipelineStepOptions, 'config' | 'logger'>;
|
|
13
|
+
protected doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PipelineStepBuilder, PipelineStepData, PipelineStepOptions, PipelineStepPayload, Undefinable } from '@rainbow-o23/n1';
|
|
2
|
+
import { AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions } from './abstract-fragmentary-pipeline-step';
|
|
3
|
+
import { ConditionCheckFunc } from './conditional-step-sets';
|
|
4
|
+
import { ScriptFuncOrBody } from './types';
|
|
5
|
+
export interface RoutesConditionalStepOptions<InFragment> {
|
|
6
|
+
check: ScriptFuncOrBody<ConditionCheckFunc<InFragment>>;
|
|
7
|
+
steps?: Array<PipelineStepBuilder>;
|
|
8
|
+
}
|
|
9
|
+
export interface RoutesPipelineStepSetsOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment> {
|
|
10
|
+
conditionalSteps: Array<RoutesConditionalStepOptions<InFragment>>;
|
|
11
|
+
otherwiseSteps?: Array<PipelineStepBuilder>;
|
|
12
|
+
}
|
|
13
|
+
export interface RoutesConditionalStep<InFragment> {
|
|
14
|
+
check: ConditionCheckFunc<InFragment>;
|
|
15
|
+
steps: Array<PipelineStepBuilder>;
|
|
16
|
+
}
|
|
17
|
+
export declare class RoutesPipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
|
|
18
|
+
private readonly _conditionalStepBuilders;
|
|
19
|
+
private readonly _otherwiseStepBuilders;
|
|
20
|
+
constructor(options: RoutesPipelineStepSetsOptions<In, Out, InFragment, OutFragment>);
|
|
21
|
+
protected getConditionalStepBuilders(): Array<RoutesConditionalStep<InFragment>>;
|
|
22
|
+
protected getOtherwiseStepBuilders(): Undefinable<Array<PipelineStepBuilder>>;
|
|
23
|
+
protected buildStepOptions(): Pick<PipelineStepOptions, 'config' | 'logger'>;
|
|
24
|
+
protected generateVariableNames(): Array<string>;
|
|
25
|
+
protected check(func: ConditionCheckFunc<InFragment>, data: InFragment, _request: PipelineStepData<In>): Promise<boolean>;
|
|
26
|
+
protected doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment>;
|
|
27
|
+
perform(request: PipelineStepData<In>): Promise<PipelineStepData<Out>>;
|
|
28
|
+
protected isInFragmentIgnored(): boolean;
|
|
29
|
+
protected getInFragmentVariableName(): string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PipelineStepData, PipelineStepHelpers, PipelineStepPayload } from '@rainbow-o23/n1';
|
|
2
|
+
import { AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions } from './abstract-fragmentary-pipeline-step';
|
|
3
|
+
import { ScriptFuncOrBody } from './types';
|
|
4
|
+
export type PerformWithInFragment<InFragment, OutFragment> = ($factor: InFragment, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
|
|
5
|
+
export type PerformWithoutInFragment<OutFragment> = ($helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment>;
|
|
6
|
+
export type PerformFunc<InFragment, OutFragment> = PerformWithInFragment<InFragment, OutFragment> | PerformWithoutInFragment<OutFragment>;
|
|
7
|
+
export interface SnippetPipelineStepOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment> {
|
|
8
|
+
snippet: ScriptFuncOrBody<PerformFunc<InFragment, OutFragment>>;
|
|
9
|
+
}
|
|
10
|
+
export declare class SnippetPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
|
|
11
|
+
private readonly _snippet;
|
|
12
|
+
private readonly _func;
|
|
13
|
+
constructor(options: SnippetPipelineStepOptions<In, Out, InFragment, OutFragment>);
|
|
14
|
+
getSnippet(): ScriptFuncOrBody<PerformFunc<InFragment, OutFragment>>;
|
|
15
|
+
protected generateVariableNames(): Array<string>;
|
|
16
|
+
protected doPerform(data: InFragment, _request: PipelineStepData<In>): Promise<OutFragment>;
|
|
17
|
+
protected isInFragmentIgnored(): boolean;
|
|
18
|
+
protected getInFragmentVariableName(): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PipelineStepData, PipelineStepPayload } from '@rainbow-o23/n1';
|
|
2
|
+
import { AbstractFragmentaryPipelineStep } from './abstract-fragmentary-pipeline-step';
|
|
3
|
+
export type SnowflakeId = string;
|
|
4
|
+
export declare class SnowflakePipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, SnowflakeId> {
|
|
5
|
+
protected doPerform(_data: InFragment, _request: PipelineStepData<In>): Promise<SnowflakeId>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PipelineStep, PipelineStepBuilder, PipelineStepData, PipelineStepOptions, PipelineStepPayload } from '@rainbow-o23/n1';
|
|
2
|
+
import { AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions } from './abstract-fragmentary-pipeline-step';
|
|
3
|
+
export interface PipelineStepSetsContext {
|
|
4
|
+
}
|
|
5
|
+
export interface PipelineStepSetsOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment> {
|
|
6
|
+
steps: Array<PipelineStepBuilder>;
|
|
7
|
+
}
|
|
8
|
+
export declare class PipelineStepSets<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
|
|
9
|
+
private readonly _stepBuilders;
|
|
10
|
+
constructor(options: PipelineStepSetsOptions<In, Out, InFragment, OutFragment>);
|
|
11
|
+
protected getStepBuilders(): Array<PipelineStepBuilder>;
|
|
12
|
+
protected buildStepOptions(): Pick<PipelineStepOptions, 'config' | 'logger'>;
|
|
13
|
+
createSteps(): Promise<Array<PipelineStep>>;
|
|
14
|
+
protected inheritContext(request: PipelineStepData<In>): PipelineStepSetsContext;
|
|
15
|
+
protected attachMineToInternalContext(inheritedContext: PipelineStepSetsContext, _request: PipelineStepData<In>): Promise<PipelineStepSetsContext>;
|
|
16
|
+
protected createInternalContext<Ctx extends PipelineStepSetsContext>(request: PipelineStepData<In>): Promise<Ctx>;
|
|
17
|
+
protected performWithContext(request: PipelineStepData<In>, run: (request: PipelineStepData<In>, context: PipelineStepSetsContext) => Promise<OutFragment>): Promise<OutFragment>;
|
|
18
|
+
protected doPerform(data: InFragment, request: PipelineStepData<In>): Promise<OutFragment>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CatchableError, ExposedUncatchableError, PipelineStepData, PipelineStepHelpers, UncatchableError } from '@rainbow-o23/n1';
|
|
2
|
+
export type ScriptFunctionBody = string;
|
|
3
|
+
export type ScriptFuncOrBody<F = Function> = F | ScriptFunctionBody;
|
|
4
|
+
export interface ErrorHandleOptions<In, InFragment, E extends Error = Error> {
|
|
5
|
+
$code: string;
|
|
6
|
+
$error: E;
|
|
7
|
+
$factor: InFragment;
|
|
8
|
+
$request: PipelineStepData<In>;
|
|
9
|
+
}
|
|
10
|
+
export type HandleCatchableError<In, InFragment, OutFragment> = ($options: ErrorHandleOptions<In, InFragment, CatchableError>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment> | never;
|
|
11
|
+
export type HandleUncatchableError<In, InFragment, OutFragment> = ($options: ErrorHandleOptions<In, InFragment, UncatchableError>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment> | never;
|
|
12
|
+
export type HandleExposedUncatchableError<In, InFragment, OutFragment> = ($options: ErrorHandleOptions<In, InFragment, ExposedUncatchableError>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment> | never;
|
|
13
|
+
export type HandleAnyError<In, InFragment, OutFragment> = ($options: ErrorHandleOptions<In, InFragment>, $helpers: PipelineStepHelpers, $: PipelineStepHelpers) => Promise<OutFragment> | never;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Nullable, Undefinable } from '@rainbow-o23/n1';
|
|
2
|
+
import { ScriptFuncOrBody } from './types';
|
|
3
|
+
export declare class Utils {
|
|
4
|
+
static createFunction<F = Function>(snippet: ScriptFuncOrBody<F>, creators: {
|
|
5
|
+
createDefault: () => Undefinable<F> | never;
|
|
6
|
+
getVariableNames: () => Array<string>;
|
|
7
|
+
async?: true;
|
|
8
|
+
error: (e: Error) => never;
|
|
9
|
+
}): F;
|
|
10
|
+
static createSyncFunction<F = Function>(snippet: ScriptFuncOrBody<F>, creators: {
|
|
11
|
+
createDefault: () => Undefinable<F> | never;
|
|
12
|
+
getVariableNames: () => Array<string>;
|
|
13
|
+
error: (e: Error) => never;
|
|
14
|
+
}): F;
|
|
15
|
+
static createAsyncFunction<F = Function>(snippet: ScriptFuncOrBody<F>, creators: {
|
|
16
|
+
createDefault: () => Undefinable<F> | never;
|
|
17
|
+
getVariableNames: () => Array<string>;
|
|
18
|
+
error: (e: Error) => never;
|
|
19
|
+
}): F;
|
|
20
|
+
static isPrimitive(value: any): value is string | number | boolean | symbol | bigint;
|
|
21
|
+
static getValue<V>(model: any, propertyPath: string): Nullable<V>;
|
|
22
|
+
static clone(obj: any): any;
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Config } from '@rainbow-o23/n1';
|
|
2
|
+
import { DataSource, DataSourceOptions } from 'typeorm';
|
|
3
|
+
export interface TypeOrmDataSource {
|
|
4
|
+
getName(): string;
|
|
5
|
+
shouldKeptOnGlobal(): boolean;
|
|
6
|
+
getDataSource(): DataSource;
|
|
7
|
+
initialize(config: Config, entities: DataSourceOptions['entities']): Promise<DataSource>;
|
|
8
|
+
destroy(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class AbstractTypeOrmDataSource<O extends DataSourceOptions> implements TypeOrmDataSource {
|
|
11
|
+
private readonly _name;
|
|
12
|
+
private _initialized;
|
|
13
|
+
private _dataSource;
|
|
14
|
+
constructor(_name: string);
|
|
15
|
+
getName(): string;
|
|
16
|
+
isInitialized(): boolean;
|
|
17
|
+
getDataSource(): DataSource;
|
|
18
|
+
shouldKeptOnGlobal(): boolean;
|
|
19
|
+
protected abstract createOptions(config: Config): O;
|
|
20
|
+
initialize(config: Config, entities: DataSourceOptions['entities']): Promise<DataSource>;
|
|
21
|
+
destroy(): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Config } from '@rainbow-o23/n1';
|
|
2
|
+
import { BetterSqlite3ConnectionOptions } from 'typeorm/driver/better-sqlite3/BetterSqlite3ConnectionOptions.js';
|
|
3
|
+
import { AbstractTypeOrmDataSource } from './abstract-datasource';
|
|
4
|
+
export declare class BetterSqlite3TypeOrmDatasource extends AbstractTypeOrmDataSource<BetterSqlite3ConnectionOptions> {
|
|
5
|
+
shouldKeptOnGlobal(): boolean;
|
|
6
|
+
protected createOptions(config: Config): BetterSqlite3ConnectionOptions;
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Config, Undefinable } from '@rainbow-o23/n1';
|
|
2
|
+
import { DataSourceOptions } from 'typeorm';
|
|
3
|
+
import { TypeOrmDataSource } from './abstract-datasource';
|
|
4
|
+
export type DataSourceCreate = (name: string) => Promise<TypeOrmDataSource>;
|
|
5
|
+
export type DataSourceType = string;
|
|
6
|
+
export declare enum SupportedDataSourceTypes {
|
|
7
|
+
MYSQL = "mysql",
|
|
8
|
+
POSTGRES = "pgsql",
|
|
9
|
+
MSSQL = "mssql",
|
|
10
|
+
ORACLE = "oracle",
|
|
11
|
+
BETTER_SQLITE3 = "better-sqlite3"
|
|
12
|
+
}
|
|
13
|
+
export declare class TypeOrmDataSourceManager {
|
|
14
|
+
private constructor();
|
|
15
|
+
static registerCreator(type: DataSourceType, create: DataSourceCreate): Undefinable<DataSourceCreate>;
|
|
16
|
+
static createDataSource(name: string, config: Config, entities: DataSourceOptions['entities']): Promise<TypeOrmDataSource>;
|
|
17
|
+
static findDataSource(name: string, config: Config): Promise<Undefinable<TypeOrmDataSource>>;
|
|
18
|
+
static findDataSourceType(name: string, config: Config): DataSourceType;
|
|
19
|
+
}
|
|
20
|
+
export declare class TypeOrmDataSourceHelper {
|
|
21
|
+
private readonly config;
|
|
22
|
+
constructor(config: Config);
|
|
23
|
+
registerCreator(type: DataSourceType, create: DataSourceCreate): Undefinable<DataSourceCreate>;
|
|
24
|
+
create(dataSources: Record<string, DataSourceOptions['entities']>): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './abstract-datasource';
|
|
2
|
+
export * from './better-sqlite3-datasource';
|
|
3
|
+
export * from './mysql-datasource';
|
|
4
|
+
export * from './pgsql-datasource';
|
|
5
|
+
export * from './mssql-datasource';
|
|
6
|
+
export * from './oracle-datasource';
|
|
7
|
+
export * from './datasource-manager';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Config } from '@rainbow-o23/n1';
|
|
2
|
+
import { SqlServerConnectionOptions } from 'typeorm/driver/sqlserver/SqlServerConnectionOptions.js';
|
|
3
|
+
import { AbstractTypeOrmDataSource } from './abstract-datasource';
|
|
4
|
+
export declare class MssqlTypeOrmDatasource extends AbstractTypeOrmDataSource<SqlServerConnectionOptions> {
|
|
5
|
+
protected createOptions(config: Config): SqlServerConnectionOptions;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Config } from '@rainbow-o23/n1';
|
|
2
|
+
import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions.js';
|
|
3
|
+
import { AbstractTypeOrmDataSource } from './abstract-datasource';
|
|
4
|
+
export declare class MysqlTypeOrmDatasource extends AbstractTypeOrmDataSource<MysqlConnectionOptions> {
|
|
5
|
+
protected createOptions(config: Config): MysqlConnectionOptions;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Config } from '@rainbow-o23/n1';
|
|
2
|
+
import { OracleConnectionOptions } from 'typeorm/driver/oracle/OracleConnectionOptions';
|
|
3
|
+
import { AbstractTypeOrmDataSource } from './abstract-datasource';
|
|
4
|
+
export declare class OracleTypeOrmDatasource extends AbstractTypeOrmDataSource<OracleConnectionOptions> {
|
|
5
|
+
protected createOptions(config: Config): OracleConnectionOptions;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Config } from '@rainbow-o23/n1';
|
|
2
|
+
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions.js';
|
|
3
|
+
import { AbstractTypeOrmDataSource } from './abstract-datasource';
|
|
4
|
+
export declare class PgsqlTypeOrmDatasource extends AbstractTypeOrmDataSource<PostgresConnectionOptions> {
|
|
5
|
+
protected createOptions(config: Config): PostgresConnectionOptions;
|
|
6
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { PipelineStepPayload, Undefinable } from '@rainbow-o23/n1';
|
|
2
|
+
import { DataSourceType } from '../typeorm';
|
|
3
|
+
import { AbstractTypeOrmPipelineStep, TypeOrmPipelineStepOptions } from './abstract-typeorm-step';
|
|
4
|
+
import { TypeOrmEntityToSave, TypeOrmEntityValue, TypeOrmSql } from './types';
|
|
5
|
+
export interface TypeOrmBasis {
|
|
6
|
+
sql?: TypeOrmSql;
|
|
7
|
+
}
|
|
8
|
+
export interface TypeOrmBySQLPipelineStepOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = TypeOrmBasis, OutFragment = Out> extends TypeOrmPipelineStepOptions<In, Out, InFragment, OutFragment> {
|
|
9
|
+
sql?: TypeOrmSql;
|
|
10
|
+
}
|
|
11
|
+
export interface ParsedTypeOrmSql {
|
|
12
|
+
sql: TypeOrmSql;
|
|
13
|
+
params: Array<any>;
|
|
14
|
+
}
|
|
15
|
+
export declare enum ParsedSqlSegmentType {
|
|
16
|
+
NONE = "none",
|
|
17
|
+
SINGLE = "single",
|
|
18
|
+
ONE_OF = "one-of",
|
|
19
|
+
CONTAINS = "contains",
|
|
20
|
+
ENDS_WITH = "ends-with",
|
|
21
|
+
STARTS_WITH = "starts-with"
|
|
22
|
+
}
|
|
23
|
+
export interface ParsedSqlSegment {
|
|
24
|
+
statement: string;
|
|
25
|
+
type: ParsedSqlSegmentType;
|
|
26
|
+
variable?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class TypeOrmParsedSQLCache {
|
|
29
|
+
[key: TypeOrmSql]: Array<ParsedSqlSegment>;
|
|
30
|
+
}
|
|
31
|
+
export declare abstract class AbstractTypeOrmBySQLPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = Undefinable<TypeOrmBasis>, OutFragment = Out> extends AbstractTypeOrmPipelineStep<In, Out, InFragment, OutFragment> {
|
|
32
|
+
private readonly _timestampWriteFormat;
|
|
33
|
+
private readonly _timestampReadFormat;
|
|
34
|
+
private readonly _sql;
|
|
35
|
+
private _parsedSqlSegments;
|
|
36
|
+
constructor(options: TypeOrmBySQLPipelineStepOptions<In, Out, InFragment, OutFragment>);
|
|
37
|
+
protected getDefaultTimestampFormats(): {
|
|
38
|
+
write: string;
|
|
39
|
+
read: string;
|
|
40
|
+
};
|
|
41
|
+
protected getTimestampWriteFormat(): string;
|
|
42
|
+
protected getTimestampReadFormat(): string;
|
|
43
|
+
protected getParsedSqlSegments(): Undefinable<Array<ParsedSqlSegment>>;
|
|
44
|
+
protected parseSql(sql: TypeOrmSql): void;
|
|
45
|
+
protected replaceSqlPagination(sql: TypeOrmSql, type: DataSourceType): TypeOrmSql;
|
|
46
|
+
protected computeSqlPlaceholder(options: {
|
|
47
|
+
segment: ParsedSqlSegment;
|
|
48
|
+
placeholderIndex: number;
|
|
49
|
+
datasourceType: DataSourceType;
|
|
50
|
+
}): string;
|
|
51
|
+
protected getBindingValue(options: {
|
|
52
|
+
params: TypeOrmEntityToSave;
|
|
53
|
+
segment: ParsedSqlSegment;
|
|
54
|
+
datasourceType: DataSourceType;
|
|
55
|
+
}): any;
|
|
56
|
+
protected getSql(basis: Undefinable<TypeOrmBasis>, params: Array<TypeOrmEntityValue> | TypeOrmEntityToSave): ParsedTypeOrmSql;
|
|
57
|
+
protected beautify<T>(options: {
|
|
58
|
+
data: T;
|
|
59
|
+
datasourceType: DataSourceType;
|
|
60
|
+
}): T;
|
|
61
|
+
protected parseResult(result: any): any;
|
|
62
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PipelineStepData, PipelineStepPayload, Undefinable } from '@rainbow-o23/n1';
|
|
2
|
+
import { AbstractTypeOrmBySQLPipelineStep, TypeOrmBasis } from './abstract-typeorm-by-sql-step';
|
|
3
|
+
import { TypeOrmEntityToLoad, TypeOrmEntityToSave, TypeOrmEntityValue } from './types';
|
|
4
|
+
export interface TypeOrmLoadBasis extends TypeOrmBasis {
|
|
5
|
+
params?: Array<TypeOrmEntityValue> | TypeOrmEntityToSave;
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class AbstractTypeOrmLoadBySQLPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, OutFragment = Out> extends AbstractTypeOrmBySQLPipelineStep<In, Out, Undefinable<TypeOrmLoadBasis>, OutFragment> {
|
|
8
|
+
protected abstract getDataFromResultSet(rst: Array<TypeOrmEntityToLoad>): Promise<OutFragment>;
|
|
9
|
+
protected doPerform(basis: Undefinable<TypeOrmLoadBasis>, request: PipelineStepData<In>): Promise<Undefinable<OutFragment>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PipelineStepData, PipelineStepPayload, Undefinable } from '@rainbow-o23/n1';
|
|
2
|
+
import { DataSource, EntityMetadata, ObjectLiteral, QueryRunner, Repository } from 'typeorm';
|
|
3
|
+
import { ColumnMetadata } from 'typeorm/metadata/ColumnMetadata.js';
|
|
4
|
+
import { AbstractFragmentaryPipelineStep, FragmentaryPipelineStepOptions } from '../step';
|
|
5
|
+
import { DataSourceType, TypeOrmDataSource } from '../typeorm';
|
|
6
|
+
import { TypeOrmDataSourceName, TypeOrmEntityName, TypeOrmTransactionKey, TypeOrmTransactionName } from './types';
|
|
7
|
+
export interface TypeOrmPipelineStepOptions<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends FragmentaryPipelineStepOptions<In, Out, InFragment, OutFragment> {
|
|
8
|
+
dataSourceName: TypeOrmDataSourceName;
|
|
9
|
+
transactionName?: TypeOrmTransactionName;
|
|
10
|
+
autonomous?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class AbstractTypeOrmPipelineStep<In = PipelineStepPayload, Out = PipelineStepPayload, InFragment = In, OutFragment = Out> extends AbstractFragmentaryPipelineStep<In, Out, InFragment, OutFragment> {
|
|
13
|
+
private readonly _dataSourceName;
|
|
14
|
+
private readonly _transactionName;
|
|
15
|
+
private readonly _autonomous;
|
|
16
|
+
constructor(options: TypeOrmPipelineStepOptions<In, Out, InFragment, OutFragment>);
|
|
17
|
+
getDataSourceName(): TypeOrmDataSourceName;
|
|
18
|
+
getTransactionName(): TypeOrmTransactionName;
|
|
19
|
+
getTransactionKey(): TypeOrmTransactionKey;
|
|
20
|
+
isAutonomous(): boolean;
|
|
21
|
+
protected isTransactional(request: PipelineStepData<In>): boolean;
|
|
22
|
+
protected findTransactionalContext(request: PipelineStepData<In>): Undefinable<[TypeOrmDataSource, QueryRunner]>;
|
|
23
|
+
protected findDataSourceType(): DataSourceType;
|
|
24
|
+
protected findDataSource(request: PipelineStepData<In>): Promise<Undefinable<TypeOrmDataSource>>;
|
|
25
|
+
protected findDataSourceOrThrow(request: PipelineStepData<In>): Promise<Undefinable<TypeOrmDataSource>>;
|
|
26
|
+
protected createRunner(request: PipelineStepData<In>): Promise<QueryRunner>;
|
|
27
|
+
protected trans<R>(run: (runner: QueryRunner) => Promise<R>, handleRollbackError: (err: Error) => Undefinable<Error>, request: PipelineStepData<In>): Promise<R>;
|
|
28
|
+
protected autoTrans<R>(run: (runner: QueryRunner) => Promise<R>, request: PipelineStepData<In>): Promise<R>;
|
|
29
|
+
protected findMetadata<E extends ObjectLiteral>(name: TypeOrmEntityName, request: PipelineStepData<In>): Promise<[EntityMetadata, ColumnMetadata, Repository<E>, DataSource]>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './abstract-typeorm-step';
|
|
3
|
+
export * from './typeorm-load-entity-by-id-step';
|
|
4
|
+
export * from './typeorm-save-entity-step';
|
|
5
|
+
export * from './typeorm-by-snippet-step';
|
|
6
|
+
export * from './abstract-typeorm-by-sql-step';
|
|
7
|
+
export * from './abstract-typeorm-load-by-sql-step';
|
|
8
|
+
export * from './typeorm-load-one-by-sql-step';
|
|
9
|
+
export * from './typeorm-load-many-by-sql-step';
|
|
10
|
+
export * from './typeorm-save-by-sql-step';
|
|
11
|
+
export * from './typeorm-bulk-save-by-sql-step';
|
|
12
|
+
export * from './type-orm-transactional-step-sets';
|