diff --git a/.github/workflows/coveralls-coverage.yml b/.github/workflows/coveralls-coverage.yml index 9a7e054e..34f1fab0 100644 --- a/.github/workflows/coveralls-coverage.yml +++ b/.github/workflows/coveralls-coverage.yml @@ -13,8 +13,8 @@ jobs: strategy: matrix: os: [ubuntu-20.04] - node: [16] - ts: [4.7.2] + node: [24] + ts: [5.8.3] fail-fast: false max-parallel: 6 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.github/workflows/macos-10.yml b/.github/workflows/macos-10.yml index b2395678..078cb4c2 100644 --- a/.github/workflows/macos-10.yml +++ b/.github/workflows/macos-10.yml @@ -9,8 +9,8 @@ jobs: matrix: os: [macos-10.15] # os: [macos-11, macos-10.15] # macos-11 become private preview - node: [22, 20, 18, 16, 14, 12, 10, 8] - ts: [5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4, 4.7.2, 4.6.3, 4.5.5, 4.4.4, 4.3.5, 4.2.4, 4.1.5, 4.0.5, 3.9.7, 3.8.3, 3.7.5, 3.6.5, 3.5.1, 3.4.5, 3.3.4000, 3.2.4, 3.1.6, 3.0.3] + node: [24, 22, 20, 18, 16, 14, 12, 10, 8] + ts: [5.8.3, 5.7.2, 5.6.3, 5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4] fail-fast: false max-parallel: 6 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.github/workflows/macos-11.yml b/.github/workflows/macos-11.yml index 6eae5833..6d4b3098 100644 --- a/.github/workflows/macos-11.yml +++ b/.github/workflows/macos-11.yml @@ -9,8 +9,8 @@ jobs: matrix: os: [macos-11] # os: [macos-11, macos-10.15] # macos-11 become private preview - node: [22, 20, 18, 16, 14, 12, 10, 8] - ts: [5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4, 4.7.2, 4.6.3, 4.5.5, 4.4.4, 4.3.5, 4.2.4, 4.1.5, 4.0.5, 3.9.7, 3.8.3, 3.7.5, 3.6.5, 3.5.1, 3.4.5, 3.3.4000, 3.2.4, 3.1.6, 3.0.3] + node: [24, 22, 20, 18, 16, 14, 12, 10, 8] + ts: [5.8.3, 5.7.2, 5.6.3, 5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4] fail-fast: false max-parallel: 6 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.github/workflows/macos-12.yml b/.github/workflows/macos-12.yml index 63a4837c..34199ed3 100644 --- a/.github/workflows/macos-12.yml +++ b/.github/workflows/macos-12.yml @@ -9,8 +9,8 @@ jobs: matrix: os: [macos-12] # os: [macos-11, macos-10.15] # macos-11 become private preview - node: [22, 20, 18, 16, 14, 12, 10, 8] - ts: [5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4, 4.7.2, 4.6.3, 4.5.5, 4.4.4, 4.3.5, 4.2.4, 4.1.5, 4.0.5, 3.9.7, 3.8.3, 3.7.5, 3.6.5, 3.5.1, 3.4.5, 3.3.4000, 3.2.4, 3.1.6, 3.0.3] + node: [24, 22, 20, 18, 16, 14, 12, 10, 8] + ts: [5.8.3, 5.7.2, 5.6.3, 5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4] fail-fast: false max-parallel: 6 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.github/workflows/macos-13.yml b/.github/workflows/macos-13.yml index d4c7d3a0..4e87a9ad 100644 --- a/.github/workflows/macos-13.yml +++ b/.github/workflows/macos-13.yml @@ -9,8 +9,8 @@ jobs: matrix: os: [macos-13] # os: [macos-11, macos-10.15] # macos-11 become private preview - node: [22, 20, 18, 16, 14, 12, 10, 8] - ts: [5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4, 4.7.2, 4.6.3, 4.5.5, 4.4.4, 4.3.5, 4.2.4, 4.1.5, 4.0.5, 3.9.7, 3.8.3, 3.7.5, 3.6.5, 3.5.1, 3.4.5, 3.3.4000, 3.2.4, 3.1.6, 3.0.3] + node: [24, 22, 20, 18, 16, 14, 12, 10, 8] + ts: [5.8.3, 5.7.2, 5.6.3, 5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4] fail-fast: false max-parallel: 6 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 7a7a4784..6cd0cd94 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -9,8 +9,8 @@ jobs: matrix: os: [macos-14] # os: [macos-11, macos-10.15] # macos-11 become private preview - node: [22, 20, 18, 16, 14, 12, 10, 8] - ts: [5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4, 4.7.2, 4.6.3, 4.5.5, 4.4.4, 4.3.5, 4.2.4, 4.1.5, 4.0.5, 3.9.7, 3.8.3, 3.7.5, 3.6.5, 3.5.1, 3.4.5, 3.3.4000, 3.2.4, 3.1.6, 3.0.3] + node: [24, 22, 20, 18, 16, 14, 12, 10, 8] + ts: [5.8.3, 5.7.2, 5.6.3, 5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4] fail-fast: false max-parallel: 6 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.github/workflows/ubuntu-18.04.yml b/.github/workflows/ubuntu-18.04.yml index 14eee046..cdb36a25 100644 --- a/.github/workflows/ubuntu-18.04.yml +++ b/.github/workflows/ubuntu-18.04.yml @@ -8,8 +8,8 @@ jobs: strategy: matrix: os: [ubuntu-18.04] - node: [22, 20, 18, 16, 14, 12, 10, 8] - ts: [5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4, 4.7.2, 4.6.3, 4.5.5, 4.4.4, 4.3.5, 4.2.4, 4.1.5, 4.0.5, 3.9.7, 3.8.3, 3.7.5, 3.6.5, 3.5.1, 3.4.5, 3.3.4000, 3.2.4, 3.1.6, 3.0.3] + node: [24, 22, 20, 18, 16, 14, 12, 10, 8] + ts: [5.8.3, 5.7.2, 5.6.3, 5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4] fail-fast: false max-parallel: 8 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.github/workflows/ubuntu-20.04.yml b/.github/workflows/ubuntu-20.04.yml index 7b56624d..0987495b 100644 --- a/.github/workflows/ubuntu-20.04.yml +++ b/.github/workflows/ubuntu-20.04.yml @@ -8,8 +8,8 @@ jobs: strategy: matrix: os: [ubuntu-20.04] - node: [22, 20, 18, 16, 14, 12, 10, 8] - ts: [5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4, 4.7.2, 4.6.3, 4.5.5, 4.4.4, 4.3.5, 4.2.4, 4.1.5, 4.0.5, 3.9.7, 3.8.3, 3.7.5, 3.6.5, 3.5.1, 3.4.5, 3.3.4000, 3.2.4, 3.1.6, 3.0.3] + node: [24, 22, 20, 18, 16, 14, 12, 10, 8] + ts: [5.8.3, 5.7.2, 5.6.3, 5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4] fail-fast: false max-parallel: 8 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.github/workflows/ubuntu-22.04.yml b/.github/workflows/ubuntu-22.04.yml index a8262f56..c0b71af7 100644 --- a/.github/workflows/ubuntu-22.04.yml +++ b/.github/workflows/ubuntu-22.04.yml @@ -8,8 +8,8 @@ jobs: strategy: matrix: os: [ubuntu-22.04] - node: [22, 20, 18, 16, 14, 12, 10, 8] - ts: [5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4, 4.7.2, 4.6.3, 4.5.5, 4.4.4, 4.3.5, 4.2.4, 4.1.5, 4.0.5, 3.9.7, 3.8.3, 3.7.5, 3.6.5, 3.5.1, 3.4.5, 3.3.4000, 3.2.4, 3.1.6, 3.0.3] + node: [24, 22, 20, 18, 16, 14, 12, 10, 8] + ts: [5.8.3, 5.7.2, 5.6.3, 5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4] fail-fast: false max-parallel: 8 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 39ad368b..f2d6fa08 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -8,8 +8,8 @@ jobs: strategy: matrix: os: [ubuntu-24.04] - node: [22, 20, 18, 16, 14, 12, 10, 8] - ts: [5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4, 4.7.2, 4.6.3, 4.5.5, 4.4.4, 4.3.5, 4.2.4, 4.1.5, 4.0.5, 3.9.7, 3.8.3, 3.7.5, 3.6.5, 3.5.1, 3.4.5, 3.3.4000, 3.2.4, 3.1.6, 3.0.3] + node: [24, 22, 20, 18, 16, 14, 12, 10, 8] + ts: [5.8.3, 5.7.2, 5.6.3, 5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4] fail-fast: false max-parallel: 8 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.github/workflows/windows-2019.yml b/.github/workflows/windows-2019.yml index dfd05a60..6e1f1bb5 100644 --- a/.github/workflows/windows-2019.yml +++ b/.github/workflows/windows-2019.yml @@ -8,8 +8,8 @@ jobs: strategy: matrix: os: [windows-2019] - node: [22, 20, 18, 16, 14, 12, 10, 8] - ts: [5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4, 4.7.2, 4.6.3, 4.5.5, 4.4.4, 4.3.5, 4.2.4, 4.1.5, 4.0.5, 3.9.7, 3.8.3, 3.7.5, 3.6.5, 3.5.1, 3.4.5, 3.3.4000, 3.2.4, 3.1.6, 3.0.3] + node: [24, 22, 20, 18, 16, 14, 12, 10, 8] + ts: [5.8.3, 5.7.2, 5.6.3, 5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4] fail-fast: false max-parallel: 8 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index fd7ce2c1..1cee0283 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -8,8 +8,8 @@ jobs: strategy: matrix: os: [windows-2022] - node: [22, 20, 18, 16, 14, 12, 10, 8] - ts: [5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4, 4.7.2, 4.6.3, 4.5.5, 4.4.4, 4.3.5, 4.2.4, 4.1.5, 4.0.5, 3.9.7, 3.8.3, 3.7.5, 3.6.5, 3.5.1, 3.4.5, 3.3.4000, 3.2.4, 3.1.6, 3.0.3] + node: [24, 22, 20, 18, 16, 14, 12, 10, 8] + ts: [5.8.3, 5.7.2, 5.6.3, 5.5.4, 5.4.5, 5.3.3, 5.2.2, 5.1.6, 5.0.4] fail-fast: false max-parallel: 8 name: ${{ matrix.os }}, Node.js ${{ matrix.node }}, TS ${{ matrix.ts }} diff --git a/.travis.yml b/.travis.yml index 6578a262..fd57310e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,29 +6,21 @@ notifications: on_failure: change node_js: - - '8' - - '10' - - '12' - - '14' - - '16' - - '17' + - '18' + - '20' + - '22' + - '24' env: - - TS=typescript@3.0.3 - - TS=typescript@3.1.6 - - TS=typescript@3.2.4 - - TS=typescript@3.3.4000 - - TS=typescript@3.4.5 - - TS=typescript@3.5.1 - - TS=typescript@3.6.5 - - TS=typescript@3.7.5 - - TS=typescript@3.8.3 - - TS=typescript@3.9.7 - - TS=typescript@4.0.5 - - TS=typescript@4.1.5 - - TS=typescript@4.2.4 - - TS=typescript@4.3.5 - - TS=typescript@4.4.4 + - TS=typescript@5.8.3 + - TS=typescript@5.7.2 + - TS=typescript@5.6.3 + - TS=typescript@5.5.4 + - TS=typescript@5.4.5 + - TS=typescript@5.3.3 + - TS=typescript@5.2.2 + - TS=typescript@5.1.6 + - TS=typescript@5.0.4 # NOTE: do not include @types/node to this project, because # @types/node: interface IteratorResult { }; diff --git a/README.md b/README.md index 237c1214..bd42abbb 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ An elegant & efficient TypeScript metaprogramming API to build =8", - "typescript": ">=3" + "node": ">=18", + "typescript": ">=5" }, "main": "lib/index.ts", "description": "TypeScript that scales", "scripts": { - "cov": "npm run test:coverage && npm run report", - "dev": "tsmon tools/jasmine.ts --config=tools/jasmine.json", - "dev:spec": "tsmon tools/jasmine.ts --config=tools/jasmine.spec.json", - "debug": "ndb tsmon tools/jasmine.ts --config=tools/jasmine.debug.json", + "dev": "vitest --config tools/vitest.config.ts", + "cov": "vitest --coverage --config tools/vitest.config.ts", "build": "tsc --project tsconfig.json --noEmit", - "test": "ts-node tools/jasmine.ts --config=tools/jasmine.json", - "test:coverage": "nyc npm run test", - "report": "open coverage/lcov-report/index.html" + "clean": "find src lib test tools -type f -name \"*.js\" -delete", + "report": "open coverage/index.html", + "test": "vitest run --config tools/vitest.config.full.ts", + "test:spec": "vitest run --config tools/vitest.config.spec.ts", + "test:coverage": "vitest run --coverage --config tools/vitest.config.full.ts" }, "repository": { "type": "git", diff --git a/src/agent/Agent/AgentAttribute.ts b/src/agent/Agent/AgentAttribute.ts index 2b2bf424..f72b5ff9 100644 --- a/src/agent/Agent/AgentAttribute.ts +++ b/src/agent/Agent/AgentAttribute.ts @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Arguments } from './Arguments'; -import { TypeAttribute } from './TypeAttributes'; -import { TypeInvocation } from './TypeInvocations'; -import { TypeInterceptor } from './TypeInterceptors'; +import { Arguments } from '../../core/Core/Interception/Arguments.ts'; +import { TypeAttribute } from '../../core/Core/Interception/TypeAttributes.ts'; +import { TypeInvocation } from '../../core/Core/Interception/TypeInvocations.ts'; +import { TypeInterceptor } from '../../core/Core/Interception/TypeInterceptors.ts'; import { UpgradeAgentProperties } from './Compiler/OnDemandAgentCompiler'; import { FindExtendedClass } from './FindExtendedClass'; import { AgentFrameworkError } from './AgentFrameworkError'; @@ -23,8 +23,8 @@ import { OnDemandInvocationFactory } from './Compiler/OnDemandInvocationFactory' import { ClassConstructors } from './Knowledges/ClassConstructors'; import { ClassMembers } from './Knowledges/ClassMembers'; import { RememberType } from './Knowledges/Types'; -import { TypeInfo } from './Reflection/TypeInfo'; -import { PropertyInfo } from './Reflection/PropertyInfo'; +import { TypeInfo } from '../../core/Core/Reflection/TypeInfo'; +import { PropertyInfo } from '../../core/Core/Reflection/PropertyInfo'; /** * This attribute is for upgrade class to agent diff --git a/src/agent/Agent/Compiler/Define.ts b/src/agent/Agent/Compiler/Define.ts new file mode 100644 index 00000000..50bc6cb0 --- /dev/null +++ b/src/agent/Agent/Compiler/Define.ts @@ -0,0 +1,11 @@ +/** + * @internal + */ +export function Define( + target: T, + key: string | symbol | number, + options: { get?: any; set?: any; value?: any }, +): T { + Reflect.defineProperty(target, key, options); + return target; +} diff --git a/src/agent/Agent/Compiler/Interceptor/OnDemandParameterInterceptor.ts b/src/agent/Agent/Compiler/Interceptor/OnDemandParameterInterceptor.ts index 0fa435d9..f3c0a14e 100644 --- a/src/agent/Agent/Compiler/Interceptor/OnDemandParameterInterceptor.ts +++ b/src/agent/Agent/Compiler/Interceptor/OnDemandParameterInterceptor.ts @@ -14,12 +14,12 @@ limitations under the License. */ 'use strict'; -import { PropertyInfo } from '../../Reflection/PropertyInfo'; -import { ParameterInvocation, PropertyInvocation } from '../../TypeInvocations'; -import { PropertyInterceptor } from '../../TypeInterceptors'; +import { PropertyInfo } from '../../../../core/Core/Reflection/PropertyInfo'; +import { ParameterInvocation, PropertyInvocation } from '../../../../core/Core/Interception/TypeInvocations.ts'; +import { PropertyInterceptor } from '../../../../core/Core/Interception/TypeInterceptors.ts'; import { MethodParameterInvocation } from '../Invocation/MethodParameterInvocation'; import { OnDemandInterceptorFactory } from '../OnDemandInterceptorFactory'; -import { Once } from '../../Decorators/Once/Once'; +import { DefineIfValue } from '../../../../core'; /** let MongoDB = class MongoDB { @@ -68,7 +68,7 @@ export class OnDemandParameterInterceptor implements PropertyInterceptor { invocations.set(idx, OnDemandInterceptorFactory.addInterceptors(origin, interceptors)); } } - return Once(this, 'invocations', invocations.size ? invocations : undefined); + return DefineIfValue(this, 'invocations', invocations.size ? invocations : undefined); } intercept(target: PropertyInvocation, params: Array, receiver: any): any { diff --git a/src/agent/Agent/Compiler/Invocation/AgentTypeInvocation.ts b/src/agent/Agent/Compiler/Invocation/AgentTypeInvocation.ts index 290f62c6..5f95ed4f 100644 --- a/src/agent/Agent/Compiler/Invocation/AgentTypeInvocation.ts +++ b/src/agent/Agent/Compiler/Invocation/AgentTypeInvocation.ts @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { TypeInfo } from '../../Reflection/TypeInfo'; -import { TypeInvocation } from '../../TypeInvocations'; -import { alter } from '../alter'; +import { TypeInfo } from '../../../../core/Core/Reflection/TypeInfo'; +import { TypeInvocation } from '../../../../core/Core/Interception/TypeInvocations.ts'; +import { Define } from '../Define.ts'; import { RememberType } from '../../Knowledges/Types'; /** @@ -29,7 +29,7 @@ export class AgentTypeInvocation implements TypeInvocation { invoke([id]: any, receiver: any): any { // dont do any change if no changes to the target // that means no initializers defined - const newReceiver = alter(class extends receiver {}, 'name', { value: `${id}$` }); + const newReceiver = Define(class extends receiver {}, 'name', { value: `${id}$` }); RememberType(newReceiver, this.target); return newReceiver; } diff --git a/src/agent/Agent/Compiler/Invocation/ClassTypeInvocation.ts b/src/agent/Agent/Compiler/Invocation/ClassTypeInvocation.ts index fde1548b..167c35c5 100644 --- a/src/agent/Agent/Compiler/Invocation/ClassTypeInvocation.ts +++ b/src/agent/Agent/Compiler/Invocation/ClassTypeInvocation.ts @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Arguments } from '../../Arguments'; -import { TypeInvocation } from '../../TypeInvocations'; -import { TypeInfo } from '../../Reflection/TypeInfo'; +import { Arguments } from '../../../../core/Core/Interception/Arguments.ts'; +import { TypeInvocation } from '../../../../core/Core/Interception/TypeInvocations.ts'; +import { TypeInfo } from '../../../../core/Core/Reflection/TypeInfo'; /** * @ignore diff --git a/src/agent/Agent/Compiler/Invocation/GetterSetterInvocation.ts b/src/agent/Agent/Compiler/Invocation/GetterSetterInvocation.ts index 46b95809..4a08f23e 100644 --- a/src/agent/Agent/Compiler/Invocation/GetterSetterInvocation.ts +++ b/src/agent/Agent/Compiler/Invocation/GetterSetterInvocation.ts @@ -13,9 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ import { AgentFrameworkError } from '../../AgentFrameworkError'; -import { Arguments } from '../../Arguments'; -import { PropertyInfo } from '../../Reflection/PropertyInfo'; -import { Invocation } from '../../Invocation'; +import { Arguments } from '../../../../core/Core/Interception/Arguments.ts'; +import { PropertyInfo } from '../../../../core/Core/Reflection/PropertyInfo'; +import { Invocation } from '../../../../core/Core/Interception/Invocation.ts'; /** * @ignore diff --git a/src/agent/Agent/Compiler/Invocation/MethodInvocation.ts b/src/agent/Agent/Compiler/Invocation/MethodInvocation.ts index 9cf4c0ec..8a9e3954 100644 --- a/src/agent/Agent/Compiler/Invocation/MethodInvocation.ts +++ b/src/agent/Agent/Compiler/Invocation/MethodInvocation.ts @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { PropertyInfo } from '../../Reflection/PropertyInfo'; -import { Arguments } from '../../Arguments'; -import { Invocation } from '../../Invocation'; +import { PropertyInfo } from '../../../../core/Core/Reflection/PropertyInfo'; +import { Arguments } from '../../../../core/Core/Interception/Arguments.ts'; +import { Invocation } from '../../../../core/Core/Interception/Invocation.ts'; /** * invoke without interceptors, better performance diff --git a/src/agent/Agent/Compiler/Invocation/MethodParameterInvocation.ts b/src/agent/Agent/Compiler/Invocation/MethodParameterInvocation.ts index eb086249..de196b2b 100644 --- a/src/agent/Agent/Compiler/Invocation/MethodParameterInvocation.ts +++ b/src/agent/Agent/Compiler/Invocation/MethodParameterInvocation.ts @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { ParameterInvocation } from '../../TypeInvocations'; -import { ParameterInfo } from '../../Reflection/ParameterInfo'; -import { Arguments } from '../../Arguments'; +import { ParameterInvocation } from '../../../../core/Core/Interception/TypeInvocations.ts'; +import { ParameterInfo } from '../../../../core/Core/Reflection/ParameterInfo'; +import { Arguments } from '../../../../core/Core/Interception/Arguments.ts'; /** * @ignore diff --git a/src/agent/Agent/Compiler/Invocation/OnDemandInterceptorInvocation.ts b/src/agent/Agent/Compiler/Invocation/OnDemandInterceptorInvocation.ts index 82926e42..4b2e3a78 100644 --- a/src/agent/Agent/Compiler/Invocation/OnDemandInterceptorInvocation.ts +++ b/src/agent/Agent/Compiler/Invocation/OnDemandInterceptorInvocation.ts @@ -12,15 +12,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Invocation } from '../../Invocation'; -import { Design } from '../../Design'; -import { Attribute } from '../../Attribute'; -import { GetInterceptor } from '../../CustomInterceptor'; +import { Invocation } from '../../../../core/Core/Interception/Invocation.ts'; +import { Design } from '../../../../core/Core/Interception/Design.ts'; +import { Attribute } from '../../../../core/Core/Interception/Attribute.ts'; +import { GetInterceptor } from '../../../../core/Core/Interception/CustomInterceptor.ts'; // import { Once } from '../../Decorators/Once/Once'; import { INVOKE } from '../../WellKnown'; -import { Arguments } from '../../Arguments'; -import { alter } from '../alter'; -import { Interceptor } from '../../Interceptor'; +import { Arguments } from '../../../../core/Core/Interception/Arguments.ts'; +import { Define } from '../Define.ts'; +import { Interceptor } from '../../../../core/Core/Interception/Interceptor.ts'; /** * invocation wrapper for interceptor, reduce callstack if no interceptor found from attribute @@ -51,7 +51,7 @@ export class OnDemandInterceptorInvocation implements // remove this invocation from chain const desc = Reflect.getOwnPropertyDescriptor(this.next, INVOKE); const value = desc ? desc.value : this.next.invoke.bind(this.next); - alter(this, INVOKE, { value }); + Define(this, INVOKE, { value }); return result; } } diff --git a/src/agent/Agent/Compiler/OnDemandAgentCompiler.ts b/src/agent/Agent/Compiler/OnDemandAgentCompiler.ts index 0438ff81..c0d3bc33 100644 --- a/src/agent/Agent/Compiler/OnDemandAgentCompiler.ts +++ b/src/agent/Agent/Compiler/OnDemandAgentCompiler.ts @@ -15,8 +15,8 @@ limitations under the License. */ // utilize code gen import { OnDemandInvocationFactory } from './OnDemandInvocationFactory'; -import { alter } from './alter'; -import { PropertyInfo } from '../Reflection/PropertyInfo'; +import { Define } from './Define.ts'; +import { PropertyInfo } from '../../../core/Core/Reflection/PropertyInfo'; export function UpgradeAgentProperties( members: Map, @@ -67,7 +67,7 @@ class OnDemandAgentCompiler { descriptor.set = function (this: any) { return chain.invoke(arguments, this); }; - alter(receiver, chain.design.key, descriptor); + Define(receiver, chain.design.key, descriptor); return chain.invoke([], this); }; descriptor.set = function (this: any) { @@ -78,7 +78,7 @@ class OnDemandAgentCompiler { descriptor.set = function (this: any) { return chain.invoke(arguments, this); }; - alter(receiver, chain.design.key, descriptor); + Define(receiver, chain.design.key, descriptor); return chain.invoke(arguments, this); }; return descriptor; @@ -111,7 +111,7 @@ class OnDemandAgentCompiler { propertyDescriptor.set = function () { setterChain.invoke(arguments, this); }; - alter(receiver, key, propertyDescriptor); + Define(receiver, key, propertyDescriptor); return getterChain.invoke([], this); }; propertyDescriptor.set = function (this: any) { @@ -123,7 +123,7 @@ class OnDemandAgentCompiler { propertyDescriptor.set = function () { setterChain.invoke(arguments, this); }; - alter(receiver, key, propertyDescriptor); + Define(receiver, key, propertyDescriptor); return setterChain.invoke(arguments, this); }; } else { @@ -135,7 +135,7 @@ class OnDemandAgentCompiler { propertyDescriptor.get = function (this: any) { return getterChain.invoke([], this); }; - alter(receiver, key, propertyDescriptor); + Define(receiver, key, propertyDescriptor); return getterChain.invoke([], this); }; } @@ -148,7 +148,7 @@ class OnDemandAgentCompiler { propertyDescriptor.set = function (this: any) { return setterChain.invoke(arguments, this); }; - alter(receiver, key, propertyDescriptor); + Define(receiver, key, propertyDescriptor); return setterChain.invoke(arguments, this); }; } else if ('function' === typeof defaultValue) { @@ -160,7 +160,7 @@ class OnDemandAgentCompiler { propertyDescriptor.value = function (this: any) { return methodChain.invoke(arguments, this); }; - alter(receiver, key, propertyDescriptor); + Define(receiver, key, propertyDescriptor); return methodChain.invoke(arguments, this); }; } else { diff --git a/src/agent/Agent/Compiler/OnDemandInterceptorFactory.ts b/src/agent/Agent/Compiler/OnDemandInterceptorFactory.ts index fc73f2db..4ebf727d 100644 --- a/src/agent/Agent/Compiler/OnDemandInterceptorFactory.ts +++ b/src/agent/Agent/Compiler/OnDemandInterceptorFactory.ts @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Invocation } from '../Invocation'; -import { Attribute } from '../Attribute'; +import { Invocation } from '../../../core/Core/Interception/Invocation.ts'; +import { Attribute } from '../../../core/Core/Interception/Attribute.ts'; import { OnDemandInterceptorInvocation } from './Invocation/OnDemandInterceptorInvocation'; -import { MemberInfo } from '../Reflection/MemberInfo'; +import { MemberInfo } from '../../../core/Core/Reflection/MemberInfo'; /** * @ignore diff --git a/src/agent/Agent/Compiler/OnDemandInvocationFactory.ts b/src/agent/Agent/Compiler/OnDemandInvocationFactory.ts index 394a8f95..9cbae2c6 100644 --- a/src/agent/Agent/Compiler/OnDemandInvocationFactory.ts +++ b/src/agent/Agent/Compiler/OnDemandInvocationFactory.ts @@ -1,16 +1,16 @@ import { ClassTypeInvocation } from './Invocation/ClassTypeInvocation'; import { OnDemandInterceptorFactory } from './OnDemandInterceptorFactory'; -import { PropertyInfo } from '../Reflection/PropertyInfo'; -import { Invocation } from '../Invocation'; -import { TypeInfo } from '../Reflection/TypeInfo'; +import { PropertyInfo } from '../../../core/Core/Reflection/PropertyInfo'; +import { Invocation } from '../../../core/Core/Interception/Invocation.ts'; +import { TypeInfo } from '../../../core/Core/Reflection/TypeInfo'; import { OnDemandParameterInterceptor } from './Interceptor/OnDemandParameterInterceptor'; import { ClassConstructorState } from '../Knowledges/ClassConstructors'; import { GetterSetterInvocation } from './Invocation/GetterSetterInvocation'; import { MethodInvocation } from './Invocation/MethodInvocation'; import { CONSTRUCTOR } from '../WellKnown'; import { AgentTypeInvocation } from './Invocation/AgentTypeInvocation'; -import { TypeInvocation } from '../TypeInvocations'; -import { Attribute } from '../Attribute'; +import { TypeInvocation } from '../../../core/Core/Interception/TypeInvocations.ts'; +import { Attribute } from '../../../core/Core/Interception/Attribute.ts'; export class OnDemandInvocationFactory { /** diff --git a/src/agent/Agent/Compiler/alter.ts b/src/agent/Agent/Compiler/alter.ts deleted file mode 100644 index 34453b0c..00000000 --- a/src/agent/Agent/Compiler/alter.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @internal - */ -export function alter(target: T, key: string | symbol | number, value: any): T { - Reflect.defineProperty(target, key, value); - return target; -} diff --git a/src/agent/Agent/CreateAgent.Spec.ts b/src/agent/Agent/CreateAgent.Spec.ts index e2647193..69e8d127 100644 --- a/src/agent/Agent/CreateAgent.Spec.ts +++ b/src/agent/Agent/CreateAgent.Spec.ts @@ -1,7 +1,7 @@ /* tslint:disable */ -import { decorateMember, agent, IsAgent, TypeInvocation, Arguments, TypeInterceptor } from '../../dependencies/agent'; +import { decorateMember, agent, IsAgent, TypeInvocation, Arguments, TypeInterceptor } from '../../../lib/dependencies/agent'; import { CreateAgent } from './CreateAgent'; -import { TransitAttribute } from './Decorators/DependencyInjection/TransitAttribute'; +import { TransitAttribute } from '../../decorator/Decorator/DependencyInjection/TransitAttribute'; class Connection { static count = 0; diff --git a/src/agent/Agent/CreateAgent.ts b/src/agent/Agent/CreateAgent.ts index a458e674..3f80b2a0 100644 --- a/src/agent/Agent/CreateAgent.ts +++ b/src/agent/Agent/CreateAgent.ts @@ -13,13 +13,13 @@ See the License for the specific language governing permissions and limitations under the License. */ import { AgentAttribute } from './AgentAttribute'; -import { TypeAttribute } from './TypeAttributes'; +import { TypeAttribute } from '../../core/Core/Interception/TypeAttributes.ts'; import { OnDemandInvocationFactory } from './Compiler/OnDemandInvocationFactory'; import { CanDecorate } from './Decorate/CanDecorate'; import { AgentFrameworkError } from './AgentFrameworkError'; import { RememberAgent } from './Knowledges/Agents'; import { GetType } from './Knowledges/Types'; -import { OnDemandTypeInfo } from './Reflection/OnDemandTypeInfo'; +import { OnDemandTypeInfo } from '../../core/Core/Reflection/Internal/OnDemandTypeInfo.ts'; import { CONSTRUCTOR } from './WellKnown'; /** @@ -49,7 +49,7 @@ export function CreateAgent(type: T, strategy?: TypeAttribut } // Collect information of this target - const staticDesign = OnDemandTypeInfo.find(target); + const staticDesign = OnDemandTypeInfo.from(target); const classDesign = (attribute.type = staticDesign.prototype); const classConstructor = (attribute.property = classDesign.property(CONSTRUCTOR)); diff --git a/src/agent/Agent/Decorate/CanDecorate.ts b/src/agent/Agent/Decorate/CanDecorate.ts index d490f6b0..110430fb 100644 --- a/src/agent/Agent/Decorate/CanDecorate.ts +++ b/src/agent/Agent/Decorate/CanDecorate.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Attribute } from '../Attribute'; +import { Attribute } from '../../../core/Core/Interception/Attribute.ts'; export function CanDecorate( attribute: Attribute, diff --git a/src/agent/Agent/Decorate/decorate.ts b/src/agent/Agent/Decorate/decorate.ts index 4cea4268..913cb550 100644 --- a/src/agent/Agent/Decorate/decorate.ts +++ b/src/agent/Agent/Decorate/decorate.ts @@ -12,12 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Attribute } from '../Attribute'; +import { Attribute } from '../../../core/Core/Interception/Attribute.ts'; import { CanDecorate } from './CanDecorate'; -import { AddAttributeToConstructor, AddAttributeToConstructorParameter } from '../../../dependencies/core'; -import { MemberKinds } from '../Reflection/MemberKinds'; +import { AddAttributeToConstructor, AddAttributeToConstructorParameter } from '@agentframework/core'; +import { MemberKinds } from '../../../core/Core/Reflection/MemberKinds'; import { AgentFrameworkError } from '../AgentFrameworkError'; -import { AddAttributeToProperty, AddAttributeToPropertyParameter } from '../../../dependencies/core'; +import { AddAttributeToProperty, AddAttributeToPropertyParameter } from '@agentframework/core'; /** * Decorate attribute to the target, throw if target not allowed diff --git a/src/agent/Agent/Decorate/decorateAgent.ts b/src/agent/Agent/Decorate/decorateAgent.ts index 7c04bb80..fa08338d 100644 --- a/src/agent/Agent/Decorate/decorateAgent.ts +++ b/src/agent/Agent/Decorate/decorateAgent.ts @@ -14,8 +14,8 @@ limitations under the License. */ // import { Reflector } from '../Reflector'; import { CanDecorate } from './CanDecorate'; -import { AddAttributeToConstructor } from '../../../dependencies/core'; -import { Attribute } from '../Attribute'; +import { AddAttributeToConstructor } from '@agentframework/core'; +import { Attribute } from '../../../core/Core/Interception/Attribute.ts'; /** * Decorate agent with attribute (this attribute will be used for upgrade agent) diff --git a/src/agent/Agent/Decorate/decorateClass.ts b/src/agent/Agent/Decorate/decorateClass.ts index e46e96e8..c31debeb 100644 --- a/src/agent/Agent/Decorate/decorateClass.ts +++ b/src/agent/Agent/Decorate/decorateClass.ts @@ -14,8 +14,8 @@ limitations under the License. */ // import { Reflector } from '../Reflector'; import { CanDecorate } from './CanDecorate'; -import { AddAttributeToConstructor } from '../../../dependencies/core'; -import { Attribute } from '../Attribute'; +import { AddAttributeToConstructor } from '@agentframework/core'; +import { Attribute } from '../../../core/Core/Interception/Attribute.ts'; /** * Decorate class with attribute diff --git a/src/agent/Agent/Decorate/decorateMember.ts b/src/agent/Agent/Decorate/decorateMember.ts index 57ae927d..ee775531 100644 --- a/src/agent/Agent/Decorate/decorateMember.ts +++ b/src/agent/Agent/Decorate/decorateMember.ts @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ import { CanDecorate } from './CanDecorate'; -import { Attribute } from '../Attribute'; -import { AddAttributeToProperty } from '../../../dependencies/core'; +import { Attribute } from '../../../core/Core/Interception/Attribute.ts'; +import { AddAttributeToProperty } from '@agentframework/core'; /** * Decorate class properties (field, getter, setter and methods) diff --git a/src/agent/Agent/Decorate/decorateParameter.ts b/src/agent/Agent/Decorate/decorateParameter.ts index 2f76a7f3..cdc1e481 100644 --- a/src/agent/Agent/Decorate/decorateParameter.ts +++ b/src/agent/Agent/Decorate/decorateParameter.ts @@ -12,11 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -// import { Reflector } from '../Reflector'; import { CanDecorate } from './CanDecorate'; -import { ParameterAttribute } from '../TypeAttributes'; -import { AddAttributeToConstructorParameter } from '../../../dependencies/core'; -import { AddAttributeToPropertyParameter } from '../../../dependencies/core'; +import { ParameterAttribute } from '../../../core/Core/Interception/TypeAttributes.ts'; +import { AddAttributeToConstructorParameter } from '@agentframework/core'; +import { AddAttributeToPropertyParameter } from '@agentframework/core'; /** * Decorate class method parameter diff --git a/src/agent/Agent/Decorate/decorateVariable.ts b/src/agent/Agent/Decorate/decorateVariable.ts index 593e53d5..68c4a8e4 100644 --- a/src/agent/Agent/Decorate/decorateVariable.ts +++ b/src/agent/Agent/Decorate/decorateVariable.ts @@ -13,13 +13,13 @@ See the License for the specific language governing permissions and limitations under the License. */ import { CanDecorate } from './CanDecorate'; -import { Attribute } from '../Attribute'; +import { Attribute } from '../../../core/Core/Interception/Attribute.ts'; import { AddAttributeToConstructorParameter, AddAttributeToProperty, AddAttributeToPropertyParameter, -} from '../../../dependencies/core'; -import { VariableDecorator } from '../Decorators/VariableDecorator'; +} from '@agentframework/core'; +import { VariableDecorator } from '../../../decorator/Decorator/VariableDecorator.ts'; /** * Decorate class properties (field, getter, setter and methods) diff --git a/src/agent/Agent/Decorators/construct.ts b/src/agent/Agent/Decorators/construct.ts deleted file mode 100644 index 2a8c8448..00000000 --- a/src/agent/Agent/Decorators/construct.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { CreateAgent } from '../CreateAgent'; -import { Arguments } from '../Arguments'; - -export function construct(type: Function, params: Arguments): any { - return Reflect.construct(CreateAgent(type), params); -} diff --git a/src/agent/Agent/Knowledges/Agents.ts b/src/agent/Agent/Knowledges/Agents.ts index 75b08e50..d7a61d8a 100644 --- a/src/agent/Agent/Knowledges/Agents.ts +++ b/src/agent/Agent/Knowledges/Agents.ts @@ -1,4 +1,4 @@ -import { Remember } from '../Decorators/Remember/Remember'; +import { Remember } from '../../../decorator/Decorator/Remember/Remember'; /** * Get original type of giving agent diff --git a/src/agent/Agent/Knowledges/ClassConstructors.ts b/src/agent/Agent/Knowledges/ClassConstructors.ts index 0eef86a8..23cd4867 100644 --- a/src/agent/Agent/Knowledges/ClassConstructors.ts +++ b/src/agent/Agent/Knowledges/ClassConstructors.ts @@ -1,5 +1,5 @@ -import { Remember } from '../Decorators/Remember/Remember'; -import { TypeInvocation } from '../TypeInvocations'; +import { Remember } from '../../../decorator/Decorator/Remember/Remember'; +import { TypeInvocation } from '../../../core/Core/Interception/TypeInvocations.ts'; export interface ClassConstructorState { version: number; diff --git a/src/agent/Agent/Knowledges/ClassMembers.ts b/src/agent/Agent/Knowledges/ClassMembers.ts index 71fdb80a..40deb271 100644 --- a/src/agent/Agent/Knowledges/ClassMembers.ts +++ b/src/agent/Agent/Knowledges/ClassMembers.ts @@ -1,4 +1,4 @@ -import { Remember } from '../Decorators/Remember/Remember'; +import { Remember } from '../../../decorator/Decorator/Remember/Remember'; export interface ClassMemberState { // type version diff --git a/src/agent/Agent/Knowledges/Namespaces.ts b/src/agent/Agent/Knowledges/Namespaces.ts index 5112dc8b..3b6efb13 100644 --- a/src/agent/Agent/Knowledges/Namespaces.ts +++ b/src/agent/Agent/Knowledges/Namespaces.ts @@ -1,4 +1,4 @@ -import { Remember } from '../Decorators/Remember/Remember'; +import { Remember } from '../../../decorator/Decorator/Remember/Remember'; /** * Get object of giving string id diff --git a/src/agent/Agent/Knowledges/Singletons.ts b/src/agent/Agent/Knowledges/Singletons.ts index 15e808d0..19ef152a 100644 --- a/src/agent/Agent/Knowledges/Singletons.ts +++ b/src/agent/Agent/Knowledges/Singletons.ts @@ -1,4 +1,4 @@ -import { Remember } from '../Decorators/Remember/Remember'; +import { Remember } from '../../../decorator/Decorator/Remember/Remember'; /** * Global Singleton instance diff --git a/src/agent/Agent/Knowledges/Types.ts b/src/agent/Agent/Knowledges/Types.ts index eef61b23..e885deff 100644 --- a/src/agent/Agent/Knowledges/Types.ts +++ b/src/agent/Agent/Knowledges/Types.ts @@ -1,4 +1,4 @@ -import { Remember } from '../Decorators/Remember/Remember'; +import { Remember } from '../../../decorator/Decorator/Remember/Remember'; /** * Get original type of giving type diff --git a/src/agent/Agent/Reflector.ts b/src/agent/Agent/Reflector.ts index ea715def..6698766a 100644 --- a/src/agent/Agent/Reflector.ts +++ b/src/agent/Agent/Reflector.ts @@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { TypeInfo } from './Reflection/TypeInfo'; -import { OnDemandTypeInfo } from './Reflection/OnDemandTypeInfo'; -import { AgentFrameworkError } from './AgentFrameworkError'; -import { CONSTRUCTOR } from './WellKnown'; -import { GetType } from './Knowledges/Types'; +import { TypeInfo } from '../../core/Core/Reflection/TypeInfo.ts'; +import { OnDemandTypeInfo } from '../../core/Core/Reflection/Internal/OnDemandTypeInfo.ts'; +import { AgentFrameworkError } from './AgentFrameworkError.ts'; +import { GetType } from './Knowledges/Types.ts'; +import { CONSTRUCTOR } from '../../core/Core/WellKnown.ts'; /** * Reflector is the interface to access type data from class constructor or class prototype @@ -35,14 +35,14 @@ import { GetType } from './Knowledges/Types'; export function Reflector(target: Function | object): TypeInfo { if (typeof target === 'function') { // make sure get the prototype of origin type - return OnDemandTypeInfo.find(GetType(target.prototype) || target.prototype); + return OnDemandTypeInfo.from(GetType(target.prototype) || target.prototype); } else if (target == null) { throw new AgentFrameworkError(`NotSupported: Reflector(null) is not supported`); } else if (typeof target === 'object') { // if a object hasOwnPropertyDescriptor('constructor') then this object is a prototype // instance don't have own constructor property if (Reflect.getOwnPropertyDescriptor(target, CONSTRUCTOR)) { - return OnDemandTypeInfo.find(GetType(target) || target); + return OnDemandTypeInfo.from(GetType(target) || target); } else { // object without own property constructor consider an instance throw new AgentFrameworkError(`NotSupported: Reflector(${target.constructor.name} {}) is not supported`); diff --git a/src/agent/Agent/WellKnown.ts b/src/agent/Agent/WellKnown.ts index 1cc8a897..fbe3135a 100644 --- a/src/agent/Agent/WellKnown.ts +++ b/src/agent/Agent/WellKnown.ts @@ -8,11 +8,6 @@ export const CONSTRUCTOR = 'constructor'; */ export const INVOKE = 'invoke'; -/** - * @internal - */ -export const VERSION = 'version'; - /** * @internal */ diff --git a/src/agent/index.ts b/src/agent/index.ts index 63f4e866..c0732de7 100644 --- a/src/agent/index.ts +++ b/src/agent/index.ts @@ -18,30 +18,30 @@ limitations under the License. */ * (Stability: 2 - Stable) Metadata Interface *********************************************************************/ -export { Design } from './Agent/Design'; -export { MemberInfo } from './Agent/Reflection/MemberInfo'; -export { PropertyInfo } from './Agent/Reflection/PropertyInfo'; -export { TypeInfo } from './Agent/Reflection/TypeInfo'; -export { ParameterInfo } from './Agent/Reflection/ParameterInfo'; +export { Design } from '../core/Core/Interception/Design.ts'; +export { MemberInfo } from '../core/Core/Reflection/MemberInfo'; +export { PropertyInfo } from '../core/Core/Reflection/PropertyInfo'; +export { TypeInfo } from '../core/Core/Reflection/TypeInfo'; +export { ParameterInfo } from '../core/Core/Reflection/ParameterInfo'; -export { Invocation } from './Agent/Invocation'; -export { Interceptor } from './Agent/Interceptor'; -export { Attribute } from './Agent/Attribute'; +export { Invocation } from '../core/Core/Interception/Invocation.ts'; +export { Interceptor } from '../core/Core/Interception/Interceptor.ts'; +export { Attribute } from '../core/Core/Interception/Attribute.ts'; -export { TypeInvocation } from './Agent/TypeInvocations'; -export { TypeInterceptor } from './Agent/TypeInterceptors'; -export { TypeAttribute } from './Agent/TypeAttributes'; +export { TypeInvocation } from '../core/Core/Interception/TypeInvocations.ts'; +export { TypeInterceptor } from '../core/Core/Interception/TypeInterceptors.ts'; +export { TypeAttribute } from '../core/Core/Interception/TypeAttributes.ts'; -export { ParameterInvocation } from './Agent/TypeInvocations'; -export { ParameterInterceptor } from './Agent/TypeInterceptors'; -export { ParameterAttribute } from './Agent/TypeAttributes'; +export { ParameterInvocation } from '../core/Core/Interception/TypeInvocations.ts'; +export { ParameterInterceptor } from '../core/Core/Interception/TypeInterceptors.ts'; +export { ParameterAttribute } from '../core/Core/Interception/TypeAttributes.ts'; -export { PropertyInvocation } from './Agent/TypeInvocations'; -export { PropertyInterceptor } from './Agent/TypeInterceptors'; -export { PropertyAttribute } from './Agent/TypeAttributes'; +export { PropertyInvocation } from '../core/Core/Interception/TypeInvocations.ts'; +export { PropertyInterceptor } from '../core/Core/Interception/TypeInterceptors.ts'; +export { PropertyAttribute } from '../core/Core/Interception/TypeAttributes.ts'; -export { Filter } from './Agent/Reflection/Filter'; -export { MemberKinds } from './Agent/Reflection/MemberKinds'; +export { Filter } from '../core/Core/Reflection/Filter'; +export { MemberKinds } from '../core/Core/Reflection/MemberKinds'; /********************************************************************* * (Stability: 2 - Stable) Decoration API @@ -52,29 +52,29 @@ export { decorateAgent } from './Agent/Decorate/decorateAgent'; export { decorateMember } from './Agent/Decorate/decorateMember'; export { decorateParameter } from './Agent/Decorate/decorateParameter'; export { decorateVariable } from './Agent/Decorate/decorateVariable'; -export { VariableDecorator } from './Agent/Decorators/VariableDecorator'; -export { Reflector } from './Agent/Reflector'; +export { VariableDecorator } from '../decorator/Decorator/VariableDecorator.ts'; +export { Reflector } from './Agent/Reflector.ts'; /********************************************************************* * (Stability: 2 - Stable): Class Decorator: @agent() *********************************************************************/ -export { agent } from './Agent/Decorators/agent'; -export { singleton } from './Agent/Decorators/DependencyInjection/singleton'; -export { transit } from './Agent/Decorators/DependencyInjection/transit'; +export { agent } from '../decorator/Decorator/agent.ts'; +export { singleton } from '../decorator/Decorator/DependencyInjection/singleton'; +export { transit } from '../decorator/Decorator/DependencyInjection/transit'; export { CreateAgent } from './Agent/CreateAgent'; /********************************************************************* * (Stability: 2 - Stable): Custom Interceptor API *********************************************************************/ -export { SetCustomInterceptor, GetCustomInterceptor, RemoveCustomInterceptor } from './Agent/CustomInterceptor'; -export { HasInterceptor, GetInterceptor } from './Agent/CustomInterceptor'; +export { SetCustomInterceptor, GetCustomInterceptor, RemoveCustomInterceptor } from '../core/Core/Interception/CustomInterceptor.ts'; +export { HasInterceptor, GetInterceptor } from '../core/Core/Interception/CustomInterceptor.ts'; /********************************************************************* * (Stability: 2 - Stable): Class Decorator: @initializable() *********************************************************************/ -export { initializable } from './Agent/Decorators/Initializable/initializable'; -export { Initializer } from './Agent/Decorators/Initializable/Initializer'; -export { InitializerHandler, StaticInitializerHandler } from './Agent/Decorators/Initializable/Initializer'; +export { initializable } from '../decorator/Decorator/Initializable/initializable'; +export { Initializer } from '../decorator/Decorator/Initializable/Initializer'; +export { InitializerHandler, StaticInitializerHandler } from '../decorator/Decorator/Initializable/Initializer'; /********************************************************************* * (Stability: 1 - Experimental) Error @@ -89,17 +89,17 @@ export { AgentAttribute } from './Agent/AgentAttribute'; /********************************************************************* * (Stability: 1 - Experimental): Getter Decorator: @once() *********************************************************************/ -export { once, Once } from './Agent/Decorators/Once/Once'; +export { once } from '../decorator/Decorator/Once/Once'; /********************************************************************* * (Stability: 1 - Experimental): Getter Decorator: @remember() *********************************************************************/ -export { remember, Remember } from './Agent/Decorators/Remember/Remember'; +export { remember, Remember } from '../decorator/Decorator/Remember/Remember'; /********************************************************************* * (Stability: 1 - Experimental): Class Decorator: @exclusive() *********************************************************************/ -export { exclusive } from './Agent/Decorators/Exclusive/exclusive'; +export { exclusive } from '../decorator/Decorator/Exclusive/exclusive'; /********************************************************************* * (Stability: 1 - Experimental): Agent Helper Functions @@ -107,8 +107,8 @@ export { exclusive } from './Agent/Decorators/Exclusive/exclusive'; export { IsAgent } from './Agent/Knowledges/Agents'; export { GetAgentType } from './Agent/Knowledges/Agents'; export { GetType } from './Agent/Knowledges/Types'; -export { Class } from './Agent/Arguments'; -export { Arguments } from './Agent/Arguments'; +export { Arguments } from '../core/Core/Interception/Arguments.ts'; +export { Class } from '../core/Core/Interception/Class.ts'; /************************************* * AgentFramework 2 end diff --git a/src/core/Core/AddAttribute.ts b/src/core/Core/AddAttribute.ts deleted file mode 100644 index 7136dcfd..00000000 --- a/src/core/Core/AddAttribute.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { GetProperty } from './Helpers/GetProperty'; -import { GetParameter } from './Helpers/GetParameter'; -import { AddAttribute } from './Helpers/AddAttribute'; -import { AddVersion } from './Helpers/AddVersion'; -import { Knowledge } from './Knowledge'; -import { GetConstructor } from './Helpers/GetConstructor'; - -/** - * equals Reflector(target).property(property, descriptor).addAttribute(attribute); - */ -export function AddAttributeToProperty( - attribute: object, - target: object | Function, - key: string | symbol, - descriptor?: PropertyDescriptor -): void { - const type = Knowledge.add(target); - const property = GetProperty(type, key, descriptor); - AddAttribute(property, attribute); - AddVersion(property); - AddVersion(type); -} - -/** - * equals Reflector(target).property(targetKey).parameter(descriptor).addAttribute(attribute); - */ -export function AddAttributeToPropertyParameter( - attribute: object, - target: object | Function, - key: string | symbol, - parameterIndex: number -): void { - const type = Knowledge.add(target); - const property = GetProperty(type, key); - const parameter = GetParameter(property, parameterIndex); - AddAttribute(parameter, attribute); - AddVersion(parameter); - AddVersion(property); - AddVersion(type); -} - -/** - * equals Reflector(target).addAttribute(attribute); - */ -export function AddAttributeToConstructor(attribute: object, target: object | Function): void { - const type = Knowledge.add(target); - const ctor = GetConstructor(type); - AddAttribute(ctor, attribute); - AddVersion(ctor); -} - -/** - * equals Reflector(target).parameter(parameterIndex).addAttribute(attribute); - */ -export function AddAttributeToConstructorParameter( - attribute: object, - target: object | Function, - parameterIndex: number -): void { - const type = Knowledge.add(target); - const ctor = GetConstructor(type); - const parameter = GetParameter(ctor, parameterIndex); - AddAttribute(parameter, attribute); - AddVersion(parameter); - AddVersion(ctor); -} diff --git a/src/core/Core/Annotation/Knowledge.ts b/src/core/Core/Annotation/Knowledge.ts deleted file mode 100644 index e3c125e6..00000000 --- a/src/core/Core/Annotation/Knowledge.ts +++ /dev/null @@ -1,130 +0,0 @@ -/* Copyright 2016 Ling Zhang - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -import { NOW } from '../WellKnown'; -import { GetProperty } from '../Helpers/GetProperty'; -import { alter } from '../Helpers/alter'; -import { AddMetadata } from '../Helpers/AddMetadata'; -import { Type } from './Type'; -import { Annotation } from './Annotation'; -import { GetConstructor } from '../Helpers/GetConstructor'; - -/** - * Use WeakMap to prevent memory leak - */ -export class Knowledge extends WeakMap { - /** - * @internal - */ - get id(): string { - return /* replace::release.name */ 'agentframework'; - } - - /** - * @internal - */ - get version(): string { - return /* replace::release.version */ '2.0.0'; - } - - /** - * @internal - */ - get timestamp(): string { - return /* replace::release.timestamp */ '2016-11-03T00:00:00.000Z'; - } - - /** - * @internal - */ - get commit(): string { - return /* replace::release.vcs.commit */ '0000000'; - } - - constructor(reflect: typeof Reflect, key: string) { - super(); - - // =============================================================================== - // if one day the browser implemented Reflect.metadata. We will reflector all - // code related to metadata data in order to have a better performance. - // =============================================================================== - const r = reflect; - /* istanbul ignore next */ - // @ts-ignore - const metadata: Function | undefined = r[key] && r[key].bind(r); - const self = this; - // - // target | property - // ----------------------------------------------- - // Function + undefined = Constructor - // Object + PropertyKey = Class member - // Function + PropertyKey = Class static member - // - let value: Function; - if (metadata) { - /* istanbul ignore next */ - value = function (key: string, value: any) { - return function (target: Function | object, targetKey?: string | symbol, descriptor?: PropertyDescriptor) { - let annotation: Annotation; - if (targetKey) { - annotation = GetProperty(self.add(target), targetKey, descriptor); - } else { - annotation = GetConstructor(self.add((target).prototype)); - } - AddMetadata(annotation, key, value); - return metadata(key, value)(target, targetKey, descriptor); - }; - }; - } else { - value = function (key: string, value: any) { - return function (target: Function | object, targetKey?: string | symbol, descriptor?: PropertyDescriptor) { - let annotation: Annotation; - if (targetKey) { - annotation = GetProperty(self.add(target), targetKey, descriptor); - } else { - annotation = GetConstructor(self.add((target).prototype)); - } - AddMetadata(annotation, key, value); - }; - }; - } - // mark the time - // @ts-ignore - value[NOW] = Date.now(); - alter(r, key, value); - self.set(self, new Map()); - } - - /** - * add a key - */ - add(key: Function | object): any { - const found = super.get(key); - if (found) { - return found; - } - - if (key === Function.prototype) { - const type = new Type(key, Object.create(null)); - this.set(key, type); - return type; - } - - // check parent and build object prototype chain - const prototype = Reflect.getPrototypeOf(key); - const type = new Type(key, Object.create(prototype && this.add(prototype).prototype)); - this.set(key, type); - return type; - } -} diff --git a/src/core/Core/Annotation/Type.ts b/src/core/Core/Annotation/Type.ts deleted file mode 100644 index ca0da848..00000000 --- a/src/core/Core/Annotation/Type.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Property } from './Property'; - -export class Type extends Property { - properties?: Map; - constructor(readonly target: object | Function, readonly prototype: object) { - super(target); - } -} diff --git a/src/core/Core/Annotation/adapter.ts b/src/core/Core/Annotation/adapter.ts deleted file mode 100644 index 7af82282..00000000 --- a/src/core/Core/Annotation/adapter.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @internal - */ -import { Knowledge } from './Knowledge'; -import { alter } from '../Helpers/alter'; - -export function adapter(type: typeof Reflect, key: string) { - return function (this: any, _: Function): any { - let id: symbol; - // @ts-ignore - return (id = Symbol.for(key)), type[id] || alter(type, id, type.construct(Knowledge, [type, key])); - }; -} diff --git a/src/core/Core/GetAnnotation.ts b/src/core/Core/GetAnnotation.ts deleted file mode 100644 index ecc99b74..00000000 --- a/src/core/Core/GetAnnotation.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Knowledge } from './Knowledge'; -import { Type } from './Type'; -import { Property } from './Property'; -import { CONSTRUCTOR } from './WellKnown'; - -/** - * @internal - */ -export function GetAnnotation(target: object | Function): Type | undefined { - return Knowledge.get(target); -} - -/** - * @internal - */ -export function GetConstructorAnnotation(target: object | Function): A | undefined { - const type: Type | undefined = Knowledge.get(target); - if (!type) { - return; - } - const property = Reflect.getOwnPropertyDescriptor(type.prototype, CONSTRUCTOR); - if (!property) { - return; - } - return property.value; -} - -/** - * @internal - */ -export function GetPropertyAnnotation( - target: object | Function, - key: string | symbol -): A | undefined { - const type: Type = Knowledge.add(target); - const property = Reflect.get(type.prototype, key); - if (!property) { - return; - } - return property; -} diff --git a/src/core/Core/GetMemory.ts b/src/core/Core/GetMemory.ts deleted file mode 100644 index 2e69a58e..00000000 --- a/src/core/Core/GetMemory.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Knowledge } from './Knowledge'; - -/** - * @internal - */ -export function GetMemory(): Map { - return Knowledge.get(Knowledge); -} diff --git a/src/core/Core/Helpers/alter.ts b/src/core/Core/Helpers/alter.ts deleted file mode 100644 index cf9aa100..00000000 --- a/src/core/Core/Helpers/alter.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @internal - */ -export function alter(target: object | Function, key: string | symbol | number, value: T): T { - Reflect.defineProperty(target, key, { value }); - return value; -} diff --git a/src/core/Core/Interception/Arguments.ts b/src/core/Core/Interception/Arguments.ts new file mode 100644 index 00000000..11d892f9 --- /dev/null +++ b/src/core/Core/Interception/Arguments.ts @@ -0,0 +1,8 @@ +/** + * Interface for Arguments + */ +export interface Arguments { + [index: number]: any; + length: number; +} + diff --git a/src/agent/Agent/Attribute.ts b/src/core/Core/Interception/Attribute.ts similarity index 96% rename from src/agent/Agent/Attribute.ts rename to src/core/Core/Interception/Attribute.ts index 8b68e0bf..02e7c37b 100644 --- a/src/agent/Agent/Attribute.ts +++ b/src/core/Core/Interception/Attribute.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Interceptor } from './Interceptor'; +import { Interceptor } from './Interceptor.ts'; /** * Attribute. extend from Object is required for type checking of { } attribute diff --git a/src/agent/Agent/Arguments.ts b/src/core/Core/Interception/Class.ts similarity index 51% rename from src/agent/Agent/Arguments.ts rename to src/core/Core/Interception/Class.ts index 0e475786..6fdacfe2 100644 --- a/src/agent/Agent/Arguments.ts +++ b/src/core/Core/Interception/Class.ts @@ -1,11 +1,3 @@ -/** - * Interface for Arguments - */ -export interface Arguments { - [index: number]: any; - length: number; -} - /** * Interface for Class */ diff --git a/src/agent/Agent/CustomInterceptor.ts b/src/core/Core/Interception/CustomInterceptor.ts similarity index 95% rename from src/agent/Agent/CustomInterceptor.ts rename to src/core/Core/Interception/CustomInterceptor.ts index 8d40e223..21e4db36 100644 --- a/src/agent/Agent/CustomInterceptor.ts +++ b/src/core/Core/Interception/CustomInterceptor.ts @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Interceptor } from './Interceptor'; -import { CustomInterceptors } from './Knowledges/CustomInterceptors'; +import { Interceptor } from './Interceptor.ts'; +import { CustomInterceptors } from './CustomInterceptors.ts'; /** * Use custom interceptor to overwrite the default attribute interceptor diff --git a/src/agent/Agent/Knowledges/CustomInterceptors.ts b/src/core/Core/Interception/CustomInterceptors.ts similarity index 74% rename from src/agent/Agent/Knowledges/CustomInterceptors.ts rename to src/core/Core/Interception/CustomInterceptors.ts index bc77d5bf..8d3bf644 100644 --- a/src/agent/Agent/Knowledges/CustomInterceptors.ts +++ b/src/core/Core/Interception/CustomInterceptors.ts @@ -1,4 +1,4 @@ -import { Remember } from '../Decorators/Remember/Remember'; +import { Remember } from '../../../decorator/Decorator/Remember/Remember.ts'; /** * Gets or sets interceptor for specified attribute diff --git a/src/agent/Agent/Design.ts b/src/core/Core/Interception/Design.ts similarity index 100% rename from src/agent/Agent/Design.ts rename to src/core/Core/Interception/Design.ts diff --git a/src/agent/Agent/Interceptor.ts b/src/core/Core/Interception/Interceptor.ts similarity index 85% rename from src/agent/Agent/Interceptor.ts rename to src/core/Core/Interception/Interceptor.ts index 221ea9a7..b4bfa717 100644 --- a/src/agent/Agent/Interceptor.ts +++ b/src/core/Core/Interception/Interceptor.ts @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Invocation } from './Invocation'; -import { Design } from './Design'; -import { Arguments } from './Arguments'; +import { Invocation } from './Invocation.ts'; +import { Design } from './Design.ts'; +import { Arguments } from './Arguments.ts'; /** * Intercept an method call diff --git a/src/agent/Agent/Invocation.ts b/src/core/Core/Interception/Invocation.ts similarity index 90% rename from src/agent/Agent/Invocation.ts rename to src/core/Core/Interception/Invocation.ts index f2c1efae..66ea11f2 100644 --- a/src/agent/Agent/Invocation.ts +++ b/src/core/Core/Interception/Invocation.ts @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Design } from './Design'; -import { Arguments } from './Arguments'; +import { Design } from './Design.ts'; +import { Arguments } from './Arguments.ts'; export interface Invocation { /** diff --git a/src/agent/Agent/TypeAttributes.ts b/src/core/Core/Interception/TypeAttributes.ts similarity index 95% rename from src/agent/Agent/TypeAttributes.ts rename to src/core/Core/Interception/TypeAttributes.ts index cdacf929..54cb405a 100644 --- a/src/agent/Agent/TypeAttributes.ts +++ b/src/core/Core/Interception/TypeAttributes.ts @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Attribute } from './Attribute'; -import { TypeInterceptor, ParameterInterceptor, PropertyInterceptor } from './TypeInterceptors'; +import { Attribute } from './Attribute.ts'; +import { TypeInterceptor, ParameterInterceptor, PropertyInterceptor } from './TypeInterceptors.ts'; /** * Attribute applies to class diff --git a/src/agent/Agent/TypeInterceptors.ts b/src/core/Core/Interception/TypeInterceptors.ts similarity index 82% rename from src/agent/Agent/TypeInterceptors.ts rename to src/core/Core/Interception/TypeInterceptors.ts index 4f85b28b..cbc9b088 100644 --- a/src/agent/Agent/TypeInterceptors.ts +++ b/src/core/Core/Interception/TypeInterceptors.ts @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Interceptor } from './Interceptor'; -import { TypeInfo } from './Reflection/TypeInfo'; -import { PropertyInfo } from './Reflection/PropertyInfo'; -import { ParameterInfo } from './Reflection/ParameterInfo'; +import { Interceptor } from './Interceptor.ts'; +import { TypeInfo } from '../Reflection/TypeInfo.ts'; +import { PropertyInfo } from '../Reflection/PropertyInfo.ts'; +import { ParameterInfo } from '../Reflection/ParameterInfo.ts'; export interface TypeInterceptor extends Interceptor {} diff --git a/src/agent/Agent/TypeInvocations.ts b/src/core/Core/Interception/TypeInvocations.ts similarity index 82% rename from src/agent/Agent/TypeInvocations.ts rename to src/core/Core/Interception/TypeInvocations.ts index 63f1d4bd..66463ddb 100644 --- a/src/agent/Agent/TypeInvocations.ts +++ b/src/core/Core/Interception/TypeInvocations.ts @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Invocation } from './Invocation'; -import { TypeInfo } from './Reflection/TypeInfo'; -import { PropertyInfo } from './Reflection/PropertyInfo'; -import { ParameterInfo } from './Reflection/ParameterInfo'; +import { Invocation } from './Invocation.ts'; +import { TypeInfo } from '../Reflection/TypeInfo.ts'; +import { PropertyInfo } from '../Reflection/PropertyInfo.ts'; +import { ParameterInfo } from '../Reflection/ParameterInfo.ts'; export interface TypeInvocation extends Invocation {} diff --git a/src/core/Core/Knowledge.ts b/src/core/Core/Knowledge.ts deleted file mode 100644 index 808cee3b..00000000 --- a/src/core/Core/Knowledge.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2016 Ling Zhang - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -import { METADATA } from './WellKnown'; -import { adapter } from './Annotation/adapter'; -import { Type } from './Annotation/Type'; - -@adapter(Reflect, METADATA) -export class Knowledge { - /* istanbul ignore next */ - // @ts-ignore - static has(key: Function | object): boolean { - /* placeholder::Knowledge.has */ - } - - /* istanbul ignore next */ - // @ts-ignore - static get(key: Function | object): any | undefined { - /* placeholder::Knowledge.get */ - } - - /* istanbul ignore next */ - // @ts-ignore - static set(key: Function | object, value: Type): any { - /* placeholder::Knowledge.set */ - } - - /* istanbul ignore next */ - // @ts-ignore - static add(key: Function | object): any { - /* placeholder::Knowledge.add */ - } -} diff --git a/src/core/Core/Meta/AddAttributeToConstructor.ts b/src/core/Core/Meta/AddAttributeToConstructor.ts new file mode 100644 index 00000000..fb39fa97 --- /dev/null +++ b/src/core/Core/Meta/AddAttributeToConstructor.ts @@ -0,0 +1,14 @@ +import { Knowledge } from './Knowledge.ts'; +import { GetOrCreateConstructor } from './Internal/GetOrCreateConstructor.ts'; +import { AddAttribute } from './Internal/AddAttribute.ts'; +import { AddVersion } from './Internal/AddVersion.ts'; + +/** + * equals Reflector(target).addAttribute(attribute); + */ +export function AddAttributeToConstructor(attribute: object, target: object | Function): void { + const type = Knowledge.add(target); + const ctor = GetOrCreateConstructor(type); + AddAttribute(ctor, attribute); + AddVersion(ctor); +} diff --git a/src/core/Core/Meta/AddAttributeToConstructorParameter.ts b/src/core/Core/Meta/AddAttributeToConstructorParameter.ts new file mode 100644 index 00000000..d9671297 --- /dev/null +++ b/src/core/Core/Meta/AddAttributeToConstructorParameter.ts @@ -0,0 +1,21 @@ +import { Knowledge } from './Knowledge.ts'; +import { GetOrCreateConstructor } from './Internal/GetOrCreateConstructor.ts'; +import { GetOrCreateParameter } from './Internal/GetOrCreateParameter.ts'; +import { AddAttribute } from './Internal/AddAttribute.ts'; +import { AddVersion } from './Internal/AddVersion.ts'; + +/** + * equals Reflector(target).parameter(parameterIndex).addAttribute(attribute); + */ +export function AddAttributeToConstructorParameter( + attribute: object, + target: object | Function, + parameterIndex: number, +): void { + const type = Knowledge.add(target); + const ctor = GetOrCreateConstructor(type); + const parameter = GetOrCreateParameter(ctor, parameterIndex); + AddAttribute(parameter, attribute); + AddVersion(parameter); + AddVersion(ctor); +} diff --git a/src/core/Core/Meta/AddAttributeToProperty.ts b/src/core/Core/Meta/AddAttributeToProperty.ts new file mode 100644 index 00000000..5e49f407 --- /dev/null +++ b/src/core/Core/Meta/AddAttributeToProperty.ts @@ -0,0 +1,20 @@ +import { GetOrCreateProperty } from './Internal/GetOrCreateProperty.ts'; +import { AddAttribute } from './Internal/AddAttribute.ts'; +import { AddVersion } from './Internal/AddVersion.ts'; +import { Knowledge } from './Knowledge.ts'; + +/** + * equals Reflector(target).property(property, descriptor).addAttribute(attribute); + */ +export function AddAttributeToProperty( + attribute: object, + target: object | Function, + key: string | symbol, + descriptor?: PropertyDescriptor, +): void { + const type = Knowledge.add(target); + const property = GetOrCreateProperty(type, key, descriptor); + AddAttribute(property, attribute); + AddVersion(property); + AddVersion(type); +} diff --git a/src/core/Core/Meta/AddAttributeToPropertyParameter.ts b/src/core/Core/Meta/AddAttributeToPropertyParameter.ts new file mode 100644 index 00000000..5e044bf1 --- /dev/null +++ b/src/core/Core/Meta/AddAttributeToPropertyParameter.ts @@ -0,0 +1,23 @@ +import { Knowledge } from './Knowledge.ts'; +import { GetOrCreateProperty } from './Internal/GetOrCreateProperty.ts'; +import { GetOrCreateParameter } from './Internal/GetOrCreateParameter.ts'; +import { AddAttribute } from './Internal/AddAttribute.ts'; +import { AddVersion } from './Internal/AddVersion.ts'; + +/** + * equals Reflector(target).property(targetKey).parameter(descriptor).addAttribute(attribute); + */ +export function AddAttributeToPropertyParameter( + attribute: object, + target: object | Function, + key: string | symbol, + parameterIndex: number, +): void { + const type = Knowledge.add(target); + const property = GetOrCreateProperty(type, key); + const parameter = GetOrCreateParameter(property, parameterIndex); + AddAttribute(parameter, attribute); + AddVersion(parameter); + AddVersion(property); + AddVersion(type); +} diff --git a/src/core/Core/Annotation.ts b/src/core/Core/Meta/Annotation.ts similarity index 100% rename from src/core/Core/Annotation.ts rename to src/core/Core/Meta/Annotation.ts diff --git a/src/core/Core/Meta/DefineGetter.ts b/src/core/Core/Meta/DefineGetter.ts new file mode 100644 index 00000000..8c5a8238 --- /dev/null +++ b/src/core/Core/Meta/DefineGetter.ts @@ -0,0 +1,6 @@ +/** + * @internal + */ +export function DefineGetter(target: object | Function, key: string | symbol | number, get: () => T) { + Reflect.defineProperty(target, key, { get }); +} diff --git a/src/core/Core/Meta/DefineIfValue.ts b/src/core/Core/Meta/DefineIfValue.ts new file mode 100644 index 00000000..9653fc24 --- /dev/null +++ b/src/core/Core/Meta/DefineIfValue.ts @@ -0,0 +1,9 @@ +/** + * @internal + */ +export function DefineIfValue(target: object | Function, key: string | symbol | number, value: T): T { + if ('undefined' !== typeof value) { + Reflect.defineProperty(target, key, { value }); + } + return value; +} diff --git a/src/core/Core/Meta/DefineValue.ts b/src/core/Core/Meta/DefineValue.ts new file mode 100644 index 00000000..34ce36d8 --- /dev/null +++ b/src/core/Core/Meta/DefineValue.ts @@ -0,0 +1,7 @@ +/** + * @internal + */ +export function DefineValue(target: object | Function, key: string | symbol | number, value: T): T { + Reflect.defineProperty(target, key, { value }); + return value; +} diff --git a/src/core/Core/Meta/GetAnnotation.ts b/src/core/Core/Meta/GetAnnotation.ts new file mode 100644 index 00000000..dac67cb2 --- /dev/null +++ b/src/core/Core/Meta/GetAnnotation.ts @@ -0,0 +1,9 @@ +import { Knowledge } from './Knowledge.ts'; +import { Type } from './Type.ts'; + +/** + * @internal + */ +export function GetAnnotation(target: object | Function): Type | undefined { + return Knowledge.get(target); +} diff --git a/src/core/Core/Meta/GetConstructorAnnotation.ts b/src/core/Core/Meta/GetConstructorAnnotation.ts new file mode 100644 index 00000000..ebef14d3 --- /dev/null +++ b/src/core/Core/Meta/GetConstructorAnnotation.ts @@ -0,0 +1,19 @@ +import { Property } from './Property.ts'; +import { Type } from './Type.ts'; +import { Knowledge } from './Knowledge.ts'; +import { CONSTRUCTOR } from '../WellKnown.ts'; + +/** + * @internal + */ +export function GetConstructorAnnotation(target: object | Function): A | undefined { + const type: Type | undefined = Knowledge.get(target); + if (!type) { + return; + } + const property = Reflect.getOwnPropertyDescriptor(type.prototype, CONSTRUCTOR); + if (!property) { + return; + } + return property.value; +} diff --git a/src/core/Core/Meta/GetPropertyAnnotation.ts b/src/core/Core/Meta/GetPropertyAnnotation.ts new file mode 100644 index 00000000..c439b3af --- /dev/null +++ b/src/core/Core/Meta/GetPropertyAnnotation.ts @@ -0,0 +1,22 @@ +import { Property } from './Property.ts'; +import { Type } from './Type.ts'; +import { Knowledge } from './Knowledge.ts'; + +/** + * @internal + */ +export function GetPropertyAnnotation( + target: object | Function, + key: string | symbol, +): A | undefined { + const type: Type = Knowledge.get(target); + if (!type) { + return; + } + // 可以从原型链上获取 + const property = Reflect.get(type.prototype, key); + if (!property) { + return; + } + return property; +} diff --git a/src/core/Core/Helpers/AddAttribute.ts b/src/core/Core/Meta/Internal/AddAttribute.ts similarity index 76% rename from src/core/Core/Helpers/AddAttribute.ts rename to src/core/Core/Meta/Internal/AddAttribute.ts index 880ea625..7e154831 100644 --- a/src/core/Core/Helpers/AddAttribute.ts +++ b/src/core/Core/Meta/Internal/AddAttribute.ts @@ -1,4 +1,4 @@ -import { Annotation } from '../Annotation/Annotation'; +import { Annotation } from './Annotation.ts'; /** * add attribute diff --git a/src/core/Core/Helpers/AddMetadata.ts b/src/core/Core/Meta/Internal/AddMetadata.ts similarity index 78% rename from src/core/Core/Helpers/AddMetadata.ts rename to src/core/Core/Meta/Internal/AddMetadata.ts index 9b586811..d5aa302d 100644 --- a/src/core/Core/Helpers/AddMetadata.ts +++ b/src/core/Core/Meta/Internal/AddMetadata.ts @@ -1,4 +1,4 @@ -import { Annotation } from '../Annotation/Annotation'; +import { Annotation } from './Annotation.ts'; /** * Add metadata diff --git a/src/core/Core/Helpers/AddVersion.ts b/src/core/Core/Meta/Internal/AddVersion.ts similarity index 65% rename from src/core/Core/Helpers/AddVersion.ts rename to src/core/Core/Meta/Internal/AddVersion.ts index d64d162c..9e31860b 100644 --- a/src/core/Core/Helpers/AddVersion.ts +++ b/src/core/Core/Meta/Internal/AddVersion.ts @@ -1,4 +1,4 @@ -import { Annotation } from '../Annotation/Annotation'; +import { Annotation } from './Annotation.ts'; /** * add version diff --git a/src/core/Core/Annotation/Annotation.ts b/src/core/Core/Meta/Internal/Annotation.ts similarity index 100% rename from src/core/Core/Annotation/Annotation.ts rename to src/core/Core/Meta/Internal/Annotation.ts diff --git a/src/core/Core/Meta/Internal/Construct.ts b/src/core/Core/Meta/Internal/Construct.ts new file mode 100644 index 00000000..0b218b5d --- /dev/null +++ b/src/core/Core/Meta/Internal/Construct.ts @@ -0,0 +1,14 @@ +/** + * @internal + */ +import { Knowledge } from './Knowledge.ts'; +import { DefineValue } from '../DefineValue.ts'; + +export interface Helper extends Record { + construct(target: new (...args: any[]) => T, args: any[]): T; +} + +export function Construct(helper: Helper, helperKey: string): Knowledge { + const key: unique symbol = Symbol.for(helperKey); + return helper[key] || DefineValue(helper, key, helper.construct(Knowledge, [helper, helperKey])); +} diff --git a/src/core/Core/Helpers/GetConstructor.ts b/src/core/Core/Meta/Internal/GetOrCreateConstructor.ts similarity index 56% rename from src/core/Core/Helpers/GetConstructor.ts rename to src/core/Core/Meta/Internal/GetOrCreateConstructor.ts index 0d243f79..739746b6 100644 --- a/src/core/Core/Helpers/GetConstructor.ts +++ b/src/core/Core/Meta/Internal/GetOrCreateConstructor.ts @@ -1,15 +1,14 @@ -import { Type } from '../Annotation/Type'; -import { Property } from '../Annotation/Property'; -import { CONSTRUCTOR } from '../WellKnown'; +import { Type } from './Type.ts'; +import { Property } from './Property.ts'; +import { CONSTRUCTOR } from '../../WellKnown.ts'; -export function GetConstructor({ target, prototype }: Type): Property { +export function GetOrCreateConstructor({ target, prototype }: Type): Property { const key = CONSTRUCTOR; const propertyDescriptor = Reflect.getOwnPropertyDescriptor(prototype, key); let property: Property; if (propertyDescriptor) { property = propertyDescriptor.value; } else { - // @ts-ignore prototype[key] = property = new Property(target); } return property; diff --git a/src/core/Core/Helpers/GetParameter.ts b/src/core/Core/Meta/Internal/GetOrCreateParameter.ts similarity index 81% rename from src/core/Core/Helpers/GetParameter.ts rename to src/core/Core/Meta/Internal/GetOrCreateParameter.ts index c874be35..55812547 100644 --- a/src/core/Core/Helpers/GetParameter.ts +++ b/src/core/Core/Meta/Internal/GetOrCreateParameter.ts @@ -12,13 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Property } from '../Annotation/Property'; -import { Parameter } from '../Annotation/Parameter'; +import { Property } from './Property.ts'; +import { Parameter } from './Parameter.ts'; /** * @internal */ -export function GetParameter(property: Property, index: number): Parameter { +export function GetOrCreateParameter(property: Property, index: number): Parameter { const map = property.parameters || (property.parameters = new Map()); let value = map.get(index); if (!value) { diff --git a/src/core/Core/Helpers/GetProperty.ts b/src/core/Core/Meta/Internal/GetOrCreateProperty.ts similarity index 54% rename from src/core/Core/Helpers/GetProperty.ts rename to src/core/Core/Meta/Internal/GetOrCreateProperty.ts index 3d4c1954..2204d742 100644 --- a/src/core/Core/Helpers/GetProperty.ts +++ b/src/core/Core/Meta/Internal/GetOrCreateProperty.ts @@ -1,12 +1,12 @@ -import { Property } from '../Annotation/Property'; -import { Type } from '../Annotation/Type'; +import { Property } from './Property.ts'; +import { Type } from './Type.ts'; /** * @internal */ -export function GetProperty(type: Type, key: string | symbol, descriptor?: PropertyDescriptor): Property { - const map = type.properties || (type.properties = new Map()); - let property = map.get(key); +export function GetOrCreateProperty(type: Type, key: string | symbol, descriptor?: PropertyDescriptor): Property { + const properties = type.properties || (type.properties = new Map()); + let property = properties.get(key); if (property) { // NOTE1: just in case parameter decorator called at first and decorate property called at second // NOTE2: setting metadata will also setting descriptor, metadata call before parameter decorator @@ -17,8 +17,8 @@ export function GetProperty(type: Type, key: string | symbol, descriptor?: Prope } } else { property = new Property(type.target, descriptor); - map.set(key, property); - // @ts-ignore + // the same property will set to map and also to prototype. so we can have two indexes. + properties.set(key, property); type.prototype[key] = property; } return property; diff --git a/src/core/Core/Annotation/Knowledge.Spec.ts b/src/core/Core/Meta/Internal/Knowledge.Spec.ts similarity index 91% rename from src/core/Core/Annotation/Knowledge.Spec.ts rename to src/core/Core/Meta/Internal/Knowledge.Spec.ts index 5ff09e10..1d648045 100644 --- a/src/core/Core/Annotation/Knowledge.Spec.ts +++ b/src/core/Core/Meta/Internal/Knowledge.Spec.ts @@ -1,10 +1,9 @@ -import { Knowledge } from './Knowledge'; -import { METADATA } from '../WellKnown'; +import { Knowledge } from './Knowledge.ts'; describe('Knowledge!', () => { describe('# should able to', () => { it('get static class property from wisdom type', () => { - const knowledge = new Knowledge(Reflect, METADATA); + const knowledge = new Knowledge(); class A {} class B extends A {} @@ -43,7 +42,7 @@ describe('Knowledge!', () => { }); it('get class property from wisdom type', () => { - const knowledge = new Knowledge(Reflect, METADATA); + const knowledge = new Knowledge(); class A {} class B extends A {} diff --git a/src/core/Core/Meta/Internal/Knowledge.ts b/src/core/Core/Meta/Internal/Knowledge.ts new file mode 100644 index 00000000..c7f34840 --- /dev/null +++ b/src/core/Core/Meta/Internal/Knowledge.ts @@ -0,0 +1,78 @@ +/* Copyright 2016 Ling Zhang + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +import { NOW } from '../../WellKnown.ts'; +import { Type } from './Type.ts'; + +/** + * Use WeakMap to prevent memory leak + */ +export class Knowledge extends WeakMap { + /** + * @internal + */ + get id(): string { + return /* replace::release.name */ 'agentframework'; + } + + /** + * @internal + */ + get version(): string { + return /* replace::release.version */ '2.0.0'; + } + + /** + * @internal + */ + get timestamp(): string { + return /* replace::release.timestamp */ '2016-11-03T00:00:00.000Z'; + } + + /** + * @internal + */ + get commit(): string { + return /* replace::release.vcs.commit */ '0000000'; + } + + constructor() { + super(); + // @ts-ignore + this[NOW] = Date.now(); + this.set(this, new Map()); + } + + /** + * add a key + */ + add(key: Function | object): any { + const found = super.get(key); + if (found) { + return found; + } + + if (key === Function.prototype) { + const type = new Type(key, Object.create(null)); + this.set(key, type); + return type; + } + + // check parent and build object prototype chain + const prototype = Reflect.getPrototypeOf(key); + const type = new Type(key, Object.create(prototype && this.add(prototype).prototype)); + this.set(key, type); + return type; + } +} diff --git a/src/core/Core/Annotation/Parameter.ts b/src/core/Core/Meta/Internal/Parameter.ts similarity index 50% rename from src/core/Core/Annotation/Parameter.ts rename to src/core/Core/Meta/Internal/Parameter.ts index d17dd083..c45172ce 100644 --- a/src/core/Core/Annotation/Parameter.ts +++ b/src/core/Core/Meta/Internal/Parameter.ts @@ -1,3 +1,3 @@ -import { Annotation } from './Annotation'; +import { Annotation } from './Annotation.ts'; export class Parameter extends Annotation {} diff --git a/src/core/Core/Annotation/Property.ts b/src/core/Core/Meta/Internal/Property.ts similarity index 52% rename from src/core/Core/Annotation/Property.ts rename to src/core/Core/Meta/Internal/Property.ts index 3b01c8da..67ebe634 100644 --- a/src/core/Core/Annotation/Property.ts +++ b/src/core/Core/Meta/Internal/Property.ts @@ -1,5 +1,5 @@ -import { Annotation } from './Annotation'; -import { Parameter } from './Parameter'; +import { Annotation } from './Annotation.ts'; +import { Parameter } from './Parameter.ts'; /** * @internal @@ -7,7 +7,10 @@ import { Parameter } from './Parameter'; export class Property extends Annotation { descriptor?: PropertyDescriptor; parameters?: Map; - constructor(readonly target: object | Function, descriptor?: PropertyDescriptor) { + constructor( + readonly target: object | Function, + descriptor?: PropertyDescriptor, + ) { super(); descriptor && (this.descriptor = descriptor); } diff --git a/src/core/Core/Meta/Internal/Type.ts b/src/core/Core/Meta/Internal/Type.ts new file mode 100644 index 00000000..d61b265f --- /dev/null +++ b/src/core/Core/Meta/Internal/Type.ts @@ -0,0 +1,11 @@ +import { Property } from './Property.ts'; + +export class Type extends Property { + properties?: Map; + constructor( + readonly target: object | Function, + readonly prototype: Record, + ) { + super(target); + } +} diff --git a/src/core/Core/Knowledge.Spec.ts b/src/core/Core/Meta/Knowledge.Spec.ts similarity index 88% rename from src/core/Core/Knowledge.Spec.ts rename to src/core/Core/Meta/Knowledge.Spec.ts index 6708c7b4..e232bbbe 100644 --- a/src/core/Core/Knowledge.Spec.ts +++ b/src/core/Core/Meta/Knowledge.Spec.ts @@ -1,13 +1,12 @@ -import { Knowledge } from './Knowledge'; +import { Knowledge } from './Knowledge.ts'; describe('Knowledge!', () => { describe('# should able to', () => { it('get identity', () => { - const KnowledgeStatic: any = Knowledge; - expect(KnowledgeStatic.id).toBeInstanceOf(String); - expect(KnowledgeStatic.version).toBeInstanceOf(String); - expect(KnowledgeStatic.timestamp).toBeInstanceOf(String); - expect(KnowledgeStatic.commit).toBeInstanceOf(String); + expect(typeof Knowledge.id).toBe('string'); + expect(typeof Knowledge.version).toBe('string'); + expect(typeof Knowledge.timestamp).toBe('string'); + expect(typeof Knowledge.commit).toBe('string'); // console.log('Knowledge', Knowledge); // const name = KnowledgeStatic.id + '@' + KnowledgeStatic.version; // expect(Knowledge[Symbol.for('Deno.symbols.customInspect')]()).toBe(name); diff --git a/src/core/Core/__param.ts b/src/core/Core/Meta/Knowledge.ts similarity index 71% rename from src/core/Core/__param.ts rename to src/core/Core/Meta/Knowledge.ts index 153cfbf2..80232b2a 100644 --- a/src/core/Core/__param.ts +++ b/src/core/Core/Meta/Knowledge.ts @@ -11,10 +11,9 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +// -/*@__PURE__*/ -export function __param(paramIndex: number, decorator: Function): Function { - return function (target: Function | object, targetKey: string | symbol) { - decorator(target, targetKey, paramIndex); - }; -} +import { Construct } from './Internal/Construct.ts'; +import { METADATA } from '../WellKnown.ts'; + +export const Knowledge = Construct(Reflect, METADATA); diff --git a/src/core/Core/Meta/Memory.spec.ts b/src/core/Core/Meta/Memory.spec.ts new file mode 100644 index 00000000..4f612dc2 --- /dev/null +++ b/src/core/Core/Meta/Memory.spec.ts @@ -0,0 +1,45 @@ +import { GetMemory, Remember, SetMemory } from './Memory.ts'; + +describe('Remember', () => { + it('should compute and store value on first call', () => { + const target = {}; + const key = 'test'; + const prop = 'foo'; + const compute = vi.fn(() => 42); + + const result = Remember(key, target, prop, compute); + + expect(result).toBe(42); + expect(compute).toHaveBeenCalledTimes(1); + expect(GetMemory('test.foo')).toBe(42); + expect((target as any).foo).toBe(42); + }); + + it('should return cached value on subsequent calls', () => { + const target = {}; + const key = 'test'; + const prop = 'foo'; + SetMemory('test.foo', 99); // simulate previous computation + + const compute = vi.fn(() => 42); // should not be called + + const result = Remember(key, target, prop, compute); + + expect(result).toBe(99); + expect(compute).not.toHaveBeenCalled(); + expect((target as any).foo).toBe(99); + }); + + it('should handle symbol keys', () => { + const target = {}; + const key = 'symbol'; + const prop = Symbol('bar'); + const compute = () => 'value'; + + const result = Remember(key, target, prop, compute); + + expect(result).toBe('value'); + expect(GetMemory(`${key}.${String(prop)}`)).toBe('value'); + expect((target as any)[prop]).toBe('value'); + }); +}); diff --git a/src/core/Core/Meta/Memory.ts b/src/core/Core/Meta/Memory.ts new file mode 100644 index 00000000..5619e55e --- /dev/null +++ b/src/core/Core/Meta/Memory.ts @@ -0,0 +1,34 @@ +import { DefineValue } from './DefineValue.ts'; +import { Knowledge } from './Knowledge.ts'; + +// unique memory map +const MemoryStore: Map = Knowledge.get(Knowledge); + +export function GetMemory(id: string): unknown { + return MemoryStore.get(id); +} + +export function SetMemory(id: string, value: unknown): void { + MemoryStore.set(id, value); +} + +/** + * Manually cache and retrieve a value for a property. + * Will also patch the property with the resolved value. + */ +export function Remember(key: string, target: object | Function, prop: string | symbol, compute: () => T): T { + const id = `${key}.${String(prop)}`; + + const memory = MemoryStore.get(id); + if (memory !== undefined) { + return DefineValue(target, prop, memory) as T; + } + + const resolved = compute(); + if (resolved === undefined) { + throw new Error(`Invalid computed value for "${key}.${String(prop)}"`); + } + + MemoryStore.set(id, resolved); + return DefineValue(target, prop, resolved); +} diff --git a/src/core/Core/Parameter.ts b/src/core/Core/Meta/Parameter.ts similarity index 52% rename from src/core/Core/Parameter.ts rename to src/core/Core/Meta/Parameter.ts index 0375dd98..e4e21555 100644 --- a/src/core/Core/Parameter.ts +++ b/src/core/Core/Meta/Parameter.ts @@ -1,3 +1,3 @@ -import { Annotation } from './Annotation'; +import { Annotation } from './Annotation.ts'; export interface Parameter extends Annotation {} diff --git a/src/core/Core/Property.ts b/src/core/Core/Meta/Property.ts similarity index 65% rename from src/core/Core/Property.ts rename to src/core/Core/Meta/Property.ts index aa82a176..3d4c8f76 100644 --- a/src/core/Core/Property.ts +++ b/src/core/Core/Meta/Property.ts @@ -1,5 +1,5 @@ -import { Annotation } from './Annotation'; -import { Parameter } from './Parameter'; +import { Annotation } from './Annotation.ts'; +import { Parameter } from './Parameter.ts'; export interface Property extends Annotation { readonly target: object | Function; diff --git a/src/core/Core/Type.ts b/src/core/Core/Meta/Type.ts similarity index 75% rename from src/core/Core/Type.ts rename to src/core/Core/Meta/Type.ts index 29727cf8..603c43e1 100644 --- a/src/core/Core/Type.ts +++ b/src/core/Core/Meta/Type.ts @@ -1,4 +1,4 @@ -import { Property } from './Property'; +import { Property } from './Property.ts'; export interface Type extends Property { readonly prototype: object; diff --git a/src/core/Core/Meta/__esDecorate.ts b/src/core/Core/Meta/__esDecorate.ts new file mode 100644 index 00000000..6a7bf435 --- /dev/null +++ b/src/core/Core/Meta/__esDecorate.ts @@ -0,0 +1,28 @@ +/*@__PURE__*/ +// export function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { +// function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } +// var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; +// var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; +// var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); +// var _, done = false; +// for (var i = decorators.length - 1; i >= 0; i--) { +// var context = {}; +// for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; +// for (var p in contextIn.access) context.access[p] = contextIn.access[p]; +// context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; +// var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); +// if (kind === "accessor") { +// if (result === void 0) continue; +// if (result === null || typeof result !== "object") throw new TypeError("Object expected"); +// if (_ = accept(result.get)) descriptor.get = _; +// if (_ = accept(result.set)) descriptor.set = _; +// if (_ = accept(result.init)) initializers.unshift(_); +// } +// else if (_ = accept(result)) { +// if (kind === "field") initializers.unshift(_); +// else descriptor[key] = _; +// } +// } +// if (target) Object.defineProperty(target, contextIn.name, descriptor); +// done = true; +// }; diff --git a/src/core/Core/Meta/__runInitializers.ts b/src/core/Core/Meta/__runInitializers.ts new file mode 100644 index 00000000..452c0878 --- /dev/null +++ b/src/core/Core/Meta/__runInitializers.ts @@ -0,0 +1,8 @@ +/*@__PURE__*/ +// export function __runInitializers(thisArg, initializers, value) { +// var useValue = arguments.length > 2; +// for (var i = 0; i < initializers.length; i++) { +// value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); +// } +// return useValue ? value : void 0; +// }; diff --git a/src/core/Core/Meta/index.ts b/src/core/Core/Meta/index.ts new file mode 100644 index 00000000..a8eda23a --- /dev/null +++ b/src/core/Core/Meta/index.ts @@ -0,0 +1,38 @@ +/********************************************************************* + * (Stability: 2 - Stable) Annotation + *********************************************************************/ + +export { Type } from './Type.ts'; +export { Property } from './Property.ts'; +export { Parameter } from './Parameter.ts'; +export { Annotation } from './Annotation.ts'; + +/********************************************************************* + * (Stability: 2 - Stable) Annotation API + *********************************************************************/ +export { AddAttributeToProperty } from './AddAttributeToProperty.ts'; +export { AddAttributeToPropertyParameter } from './AddAttributeToPropertyParameter.ts'; +export { AddAttributeToConstructor } from './AddAttributeToConstructor.ts'; +export { AddAttributeToConstructorParameter } from './AddAttributeToConstructorParameter.ts'; + +export { GetAnnotation } from './GetAnnotation.ts'; +export { GetConstructorAnnotation } from './GetConstructorAnnotation.ts'; +export { GetPropertyAnnotation } from './GetPropertyAnnotation.ts'; + +/********************************************************************* + * (Stability: 2 - Stable): Memory API + *********************************************************************/ +export { Remember, SetMemory, GetMemory } from './Memory.ts'; + +/********************************************************************* + * (Stability: 2 - Stable): Internal Helper Function + *********************************************************************/ +export { DefineValue } from './DefineValue.ts'; +export { DefineIfValue } from './DefineIfValue.ts'; +export { DefineGetter } from './DefineGetter.ts'; + +/********************************************************************* + * (Stability: 1 - Experimental): TSLIB integrate with Metadata + *********************************************************************/ +// export { __esDecorate } from './Core/__esDecorate'; +// export { __runInitializers } from './Core/__runInitializers'; diff --git a/src/agent/Agent/Reflection/Filter.ts b/src/core/Core/Reflection/Filter.ts similarity index 100% rename from src/agent/Agent/Reflection/Filter.ts rename to src/core/Core/Reflection/Filter.ts diff --git a/src/agent/Agent/Reflection/Filters.ts b/src/core/Core/Reflection/Filters.ts similarity index 100% rename from src/agent/Agent/Reflection/Filters.ts rename to src/core/Core/Reflection/Filters.ts diff --git a/src/agent/Agent/Decorators/Cache/Cache.ts b/src/core/Core/Reflection/Internal/Cache.ts similarity index 62% rename from src/agent/Agent/Decorators/Cache/Cache.ts rename to src/core/Core/Reflection/Internal/Cache.ts index b195e607..7f86a84d 100644 --- a/src/agent/Agent/Decorators/Cache/Cache.ts +++ b/src/core/Core/Reflection/Internal/Cache.ts @@ -13,21 +13,19 @@ See the License for the specific language governing permissions and limitations under the License. */ // the once can be used on both class getter or static getter -import { alter } from '../../Compiler/alter'; -import { VERSION } from '../../WellKnown'; +import { DefineGetter } from '../../Meta'; +import {VERSION} from "../../WellKnown.ts"; -export function Cache(target: object | Function, getterKey: string | symbol, update: () => T): T { +export function Cache(target: object, getterKey: string | symbol, update: () => T): T { let cachedVersion = Reflect.get(target, VERSION); let cached = update(); - alter(target, getterKey, { - get() { - const currentVersion = Reflect.get(target, VERSION); - if (cachedVersion !== currentVersion) { - cached = update(); - cachedVersion = currentVersion; - } - return cached; - }, + DefineGetter(target, getterKey, () => { + const currentVersion = Reflect.get(target, VERSION); + if (cachedVersion !== currentVersion) { + cached = update(); + cachedVersion = currentVersion; + } + return cached; }); return cached; } diff --git a/src/agent/Agent/Reflection/OnDemandMemberInfo.ts b/src/core/Core/Reflection/Internal/OnDemandMemberInfo.ts similarity index 81% rename from src/agent/Agent/Reflection/OnDemandMemberInfo.ts rename to src/core/Core/Reflection/Internal/OnDemandMemberInfo.ts index 76ec6973..b5e93e98 100644 --- a/src/agent/Agent/Reflection/OnDemandMemberInfo.ts +++ b/src/core/Core/Reflection/Internal/OnDemandMemberInfo.ts @@ -12,14 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Annotation } from '../../../dependencies/core'; -import { Attribute } from '../Attribute'; -import { MemberInfo } from './MemberInfo'; -import { Filter } from './Filter'; -import { Class } from '../Arguments'; -import { Once } from '../Decorators/Once/Once'; -import { HasInterceptor } from '../CustomInterceptor'; -import { Cache } from '../Decorators/Cache/Cache'; +import { Annotation, DefineIfValue } from '../../Meta'; +import { MemberInfo } from '../MemberInfo.ts'; +import { Filter } from '../Filter.ts'; +import { HasInterceptor } from '../../Interception/CustomInterceptor.ts'; +import { Cache } from './Cache.ts'; +import { Class } from '../../Interception/Class.ts'; /** * Access and store attribute and metadata for reflection @@ -40,7 +38,7 @@ export abstract class OnDemandMemberInfo impl * Get name */ get name(): string { - return Once(this, 'name', this.getName()); + return DefineIfValue(this, 'name', this.getName()); } /** @@ -59,7 +57,7 @@ export abstract class OnDemandMemberInfo impl * Get declaring type */ get declaringType(): Function { - return Once(this, 'declaringType', this.getDeclaringType()); + return DefineIfValue(this, 'declaringType', this.getDeclaringType()); } /** @@ -72,7 +70,7 @@ export abstract class OnDemandMemberInfo impl * Get member kind */ get kind(): number { - return Once(this, 'kind', this.getKind()); + return DefineIfValue(this, 'kind', this.getKind()); } /** @@ -85,7 +83,7 @@ export abstract class OnDemandMemberInfo impl * Get metadata object, undefined if not annotated. */ get annotation(): A | undefined { - return Once(this, 'annotation', this.getAnnotation()); + return DefineIfValue(this, 'annotation', this.getAnnotation()); } /** @@ -105,7 +103,7 @@ export abstract class OnDemandMemberInfo impl * Get type */ get type(): Function | undefined { - return Once(this, 'type', this.getType()); + return DefineIfValue(this, 'type', this.getType()); } /** @@ -145,7 +143,7 @@ export abstract class OnDemandMemberInfo impl * @param type * @returns {boolean} */ - hasOwnAttribute(type?: Class): boolean { + hasOwnAttribute(type?: Class): boolean { const attributes = this.ownAttributes; if (attributes) { if (type) { @@ -160,7 +158,7 @@ export abstract class OnDemandMemberInfo impl /** * Get specified attribute */ - getOwnAttribute(type: Class): A2 | undefined { + getOwnAttribute(type: Class): A2 | undefined { const attributes = this.ownAttributes; if (attributes) { for (const attribute of attributes) { @@ -177,7 +175,7 @@ export abstract class OnDemandMemberInfo impl * * @returns {Array} */ - getOwnAttributes(type?: Class): ReadonlyArray { + getOwnAttributes(type?: Class): ReadonlyArray { const attributes = this.ownAttributes; if (attributes) { if (type) { @@ -194,7 +192,7 @@ export abstract class OnDemandMemberInfo impl * * @returns {Array} */ - findOwnAttributes(filter: Filter, filterCriteria?: any): ReadonlyArray { + findOwnAttributes(filter: Filter, filterCriteria?: any): ReadonlyArray { const attributes = this.ownAttributes; if (attributes) { return attributes.filter((a) => filter(a, filterCriteria)) as Array; @@ -216,5 +214,5 @@ export abstract class OnDemandMemberInfo impl * * @param {Attribute} attribute */ - abstract addAttribute(attribute: A4): void; + abstract addAttribute(attribute: A4): void; } diff --git a/src/agent/Agent/Reflection/OnDemandParameterInfo.ts b/src/core/Core/Reflection/Internal/OnDemandParameterInfo.ts similarity index 79% rename from src/agent/Agent/Reflection/OnDemandParameterInfo.ts rename to src/core/Core/Reflection/Internal/OnDemandParameterInfo.ts index 65932e27..03191631 100644 --- a/src/agent/Agent/Reflection/OnDemandParameterInfo.ts +++ b/src/core/Core/Reflection/Internal/OnDemandParameterInfo.ts @@ -12,17 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { - AddAttributeToConstructorParameter, - AddAttributeToPropertyParameter, - Annotation, -} from '../../../dependencies/core'; -import { MemberKinds } from './MemberKinds'; -import { ParameterInfo } from './ParameterInfo'; -import { PropertyInfo } from './PropertyInfo'; -import { Attribute } from '../Attribute'; -import { OnDemandMemberInfo } from './OnDemandMemberInfo'; -import { CONSTRUCTOR } from '../WellKnown'; +import { AddAttributeToConstructorParameter, AddAttributeToPropertyParameter, Annotation } from '../../Meta'; +import { MemberKinds } from '../MemberKinds.ts'; +import { ParameterInfo } from '../ParameterInfo.ts'; +import { PropertyInfo } from '../PropertyInfo.ts'; +import { OnDemandMemberInfo } from './OnDemandMemberInfo.ts'; +import { CONSTRUCTOR } from '../../WellKnown.ts'; /** * Parameter @@ -32,12 +27,12 @@ export class OnDemandParameterInfo extends OnDemandMemberInfo implements Paramet target: object | Function, readonly key: string | symbol, readonly index: number, - protected readonly parent: PropertyInfo + protected readonly parent: PropertyInfo, ) { super(target); } - addAttribute(attribute: A4): void { + addAttribute(attribute: A4): void { // if the attribute provide a getInterceptor, that means this property may need inject // we don't call getInterceptor or getInitializer until user new() the agent class. if (this.key === CONSTRUCTOR) { diff --git a/src/agent/Agent/Reflection/OnDemandPropertyGetterInfo.ts b/src/core/Core/Reflection/Internal/OnDemandPropertyGetterInfo.ts similarity index 100% rename from src/agent/Agent/Reflection/OnDemandPropertyGetterInfo.ts rename to src/core/Core/Reflection/Internal/OnDemandPropertyGetterInfo.ts diff --git a/src/agent/Agent/Reflection/OnDemandPropertyInfo.ts b/src/core/Core/Reflection/Internal/OnDemandPropertyInfo.ts similarity index 80% rename from src/agent/Agent/Reflection/OnDemandPropertyInfo.ts rename to src/core/Core/Reflection/Internal/OnDemandPropertyInfo.ts index 61a61db3..1279198e 100644 --- a/src/agent/Agent/Reflection/OnDemandPropertyInfo.ts +++ b/src/core/Core/Reflection/Internal/OnDemandPropertyInfo.ts @@ -12,24 +12,23 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { OnDemandMemberInfo } from './OnDemandMemberInfo'; -import { OnDemandParameterInfo } from './OnDemandParameterInfo'; -import { MemberKinds } from './MemberKinds'; -import { PropertyInfo } from './PropertyInfo'; -import { ParameterInfo } from './ParameterInfo'; -import { MemberInfo } from './MemberInfo'; +import { OnDemandMemberInfo } from './OnDemandMemberInfo.ts'; +import { OnDemandParameterInfo } from './OnDemandParameterInfo.ts'; +import { MemberKinds } from '../MemberKinds.ts'; +import { PropertyInfo } from '../PropertyInfo.ts'; +import { ParameterInfo } from '../ParameterInfo.ts'; +import { MemberInfo } from '../MemberInfo.ts'; import { AddAttributeToConstructor, AddAttributeToProperty, + DefineIfValue, GetAnnotation, GetConstructorAnnotation, Property, -} from '../../../dependencies/core'; -import { Once } from '../Decorators/Once/Once'; -import { Cache } from '../Decorators/Cache/Cache'; -import { CONSTRUCTOR, DESIGN_PARAMTYPES, DESIGN_RETURNTYPE, DESIGN_TYPE } from '../WellKnown'; -import { TypeInfo } from './TypeInfo'; -import { Attribute } from '../Attribute'; +} from '../../Meta'; +import { Cache } from './Cache.ts'; +import { TypeInfo } from '../TypeInfo.ts'; +import { CONSTRUCTOR } from '../../WellKnown.ts'; // import { OnDemandPropertyValueInfo } from './OnDemandPropertyValueInfo'; // import { OnDemandPropertyGetterInfo } from './OnDemandPropertyGetterInfo'; @@ -46,7 +45,11 @@ export class OnDemandPropertyInfo extends OnDemandMemberInfo implement */ protected readonly parameters = new Map(); - constructor(target: object | Function, readonly key: string | symbol, protected readonly parent?: TypeInfo) { + constructor( + target: object | Function, + readonly key: string | symbol, + protected readonly parent?: TypeInfo, + ) { super(target); } @@ -94,11 +97,7 @@ export class OnDemandPropertyInfo extends OnDemandMemberInfo implement } protected getType(): Function | undefined { - if (this.hasOwnMetadata(DESIGN_RETURNTYPE)) { - return this.getOwnMetadata(DESIGN_RETURNTYPE); - } else { - return this.getOwnMetadata(DESIGN_TYPE); - } + return undefined; } // get value(): OnDemandPropertyValueInfo { @@ -178,14 +177,14 @@ export class OnDemandPropertyInfo extends OnDemandMemberInfo implement * Returns type of the parameters implementation */ protected getParameterTypes(): ReadonlyArray | undefined { - return this.getOwnMetadata(DESIGN_PARAMTYPES); + return undefined; } /** * Returns type of the parameters */ get parameterTypes(): ReadonlyArray | undefined { - return Once(this, 'parameterTypes', this.getParameterTypes()); + return DefineIfValue(this, 'parameterTypes', this.getParameterTypes()); } /** @@ -203,7 +202,7 @@ export class OnDemandPropertyInfo extends OnDemandMemberInfo implement return params; } - addAttribute(attribute: A4): void { + addAttribute(attribute: A4): void { if (this.key === CONSTRUCTOR) { AddAttributeToConstructor(attribute, this.target); } else { @@ -227,17 +226,6 @@ export class OnDemandPropertyInfo extends OnDemandMemberInfo implement if (annotation && annotation.m) { return annotation.m.get(key); } - - /* istanbul ignore next */ - // @ts-ignore - if (Reflect['getOwnMetadata']) { - // @ts-ignore - return Reflect['getOwnMetadata'](key, this.declaringType.prototype, this.key); - } - - // debugger; - // console.log(); - // console.log('looking for meta', key, ' on', this.target, '.', this.key); return; } } diff --git a/src/agent/Agent/Reflection/OnDemandPropertySetterInfo.ts b/src/core/Core/Reflection/Internal/OnDemandPropertySetterInfo.ts similarity index 100% rename from src/agent/Agent/Reflection/OnDemandPropertySetterInfo.ts rename to src/core/Core/Reflection/Internal/OnDemandPropertySetterInfo.ts diff --git a/src/agent/Agent/Reflection/OnDemandPropertyValueInfo.ts b/src/core/Core/Reflection/Internal/OnDemandPropertyValueInfo.ts similarity index 100% rename from src/agent/Agent/Reflection/OnDemandPropertyValueInfo.ts rename to src/core/Core/Reflection/Internal/OnDemandPropertyValueInfo.ts diff --git a/src/agent/Agent/Reflection/OnDemandTypeInfo.Spec.ts b/src/core/Core/Reflection/Internal/OnDemandTypeInfo.Spec.ts similarity index 62% rename from src/agent/Agent/Reflection/OnDemandTypeInfo.Spec.ts rename to src/core/Core/Reflection/Internal/OnDemandTypeInfo.Spec.ts index 57e77dfd..fded4abc 100644 --- a/src/agent/Agent/Reflection/OnDemandTypeInfo.Spec.ts +++ b/src/core/Core/Reflection/Internal/OnDemandTypeInfo.Spec.ts @@ -1,4 +1,4 @@ -import { OnDemandTypeInfo } from './OnDemandTypeInfo'; +import { OnDemandTypeInfo } from './OnDemandTypeInfo.ts'; class BaseType {} @@ -7,65 +7,65 @@ class UserType extends BaseType {} describe('OnDemandTypeInfo', () => { describe('# should able to', () => { it('get type info for Object instance', () => { - const info = OnDemandTypeInfo.find({}); + const info = OnDemandTypeInfo.from({}); expect(info).toBeDefined(); }); it('get type info for Object', () => { - const info = OnDemandTypeInfo.find(Object); + const info = OnDemandTypeInfo.from(Object); expect(info).toBeDefined(); }); it('get type info for Object.prototype', () => { - const info = OnDemandTypeInfo.find(Object.prototype); + const info = OnDemandTypeInfo.from(Object.prototype); expect(info).toBeDefined(); }); it('get type info for Function', () => { - const info = OnDemandTypeInfo.find(Function); + const info = OnDemandTypeInfo.from(Function); expect(info).toBeDefined(); }); it('get type info for Function.prototype', () => { - const info = OnDemandTypeInfo.find(Function.prototype); + const info = OnDemandTypeInfo.from(Function.prototype); expect(info).toBeDefined(); }); it('get base from type', () => { - const info = OnDemandTypeInfo.find(UserType); + const info = OnDemandTypeInfo.from(UserType); expect(info).toBeInstanceOf(OnDemandTypeInfo); - expect(info.base).toBe(OnDemandTypeInfo.find(BaseType)); + expect(info.base).toBe(OnDemandTypeInfo.from(BaseType)); }); it('get base from prototype', () => { - const info = OnDemandTypeInfo.find(UserType.prototype); + const info = OnDemandTypeInfo.from(UserType.prototype); expect(info).toBeInstanceOf(OnDemandTypeInfo); - expect(info.base).toBe(OnDemandTypeInfo.find(BaseType.prototype)); + expect(info.base).toBe(OnDemandTypeInfo.from(BaseType.prototype)); }); }); describe('# should not able to', () => { it('get base for Object instance', () => { - const info = OnDemandTypeInfo.find({}); + const info = OnDemandTypeInfo.from({}); expect(info.base).toBeFalsy(); }); it('get base for Object', () => { - const info = OnDemandTypeInfo.find(Object); + const info = OnDemandTypeInfo.from(Object); expect(info.base).toBeFalsy(); }); it('get base for Object.prototype', () => { - const info = OnDemandTypeInfo.find(Object.prototype); + const info = OnDemandTypeInfo.from(Object.prototype); expect(info.base).toBeFalsy(); }); it('get base for Function', () => { - const info = OnDemandTypeInfo.find(Function); + const info = OnDemandTypeInfo.from(Function); expect(info.base).toBeFalsy(); }); it('get base for Function.prototype', () => { - const info = OnDemandTypeInfo.find(Function.prototype); + const info = OnDemandTypeInfo.from(Function.prototype); expect(info.base).toBeFalsy(); }); it('get base from type', () => { - const info = OnDemandTypeInfo.find(BaseType); + const info = OnDemandTypeInfo.from(BaseType); expect(info).toBeInstanceOf(OnDemandTypeInfo); expect(info.base).toBeFalsy(); }); it('get base from prototype', () => { - const info = OnDemandTypeInfo.find(BaseType.prototype); + const info = OnDemandTypeInfo.from(BaseType.prototype); expect(info).toBeInstanceOf(OnDemandTypeInfo); expect(info.base).toBeFalsy(); }); diff --git a/src/agent/Agent/Reflection/OnDemandTypeInfo.ts b/src/core/Core/Reflection/Internal/OnDemandTypeInfo.ts similarity index 83% rename from src/agent/Agent/Reflection/OnDemandTypeInfo.ts rename to src/core/Core/Reflection/Internal/OnDemandTypeInfo.ts index 48a615ab..d3801a5b 100644 --- a/src/agent/Agent/Reflection/OnDemandTypeInfo.ts +++ b/src/core/Core/Reflection/Internal/OnDemandTypeInfo.ts @@ -12,20 +12,22 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { OnDemandPropertyInfo } from './OnDemandPropertyInfo'; -import { MemberKinds } from './MemberKinds'; -import { GetAnnotation, GetConstructorAnnotation, Type } from '../../../dependencies/core'; -import { TypeInfo } from './TypeInfo'; -import { PropertyInfo } from './PropertyInfo'; -import { Filter } from './Filter'; -import { Attribute } from '../Attribute'; -import { Remember } from '../Decorators/Remember/Remember'; -import { AddAttributeToConstructor } from '../../../dependencies/core'; -import { CONSTRUCTOR } from '../WellKnown'; -import { Once } from '../Decorators/Once/Once'; -import { Property } from '../../../dependencies/core'; -import { IsAgent } from '../Knowledges/Agents'; -import { GetPropertyAnnotation } from '../../../dependencies/core'; +import { OnDemandPropertyInfo } from './OnDemandPropertyInfo.ts'; +import { MemberKinds } from '../MemberKinds.ts'; +import { + AddAttributeToConstructor, + DefineIfValue, + GetAnnotation, + GetConstructorAnnotation, + GetPropertyAnnotation, + Property, + Type, +} from '../../Meta'; +import { TypeInfo } from '../TypeInfo.ts'; +import { PropertyInfo } from '../PropertyInfo.ts'; +import { Filter } from '../Filter.ts'; +import { CONSTRUCTOR } from '../../WellKnown.ts'; +import { TypeInfos } from '../TypeInfoKnowledge.ts'; // class TypeIteratorResult { // constructor(readonly done: boolean, readonly value: any) {} @@ -54,15 +56,6 @@ import { GetPropertyAnnotation } from '../../../dependencies/core'; // } // } -export class TypeInfos { - /** - * get types map - */ - static get v1() { - return Remember('TypeInfos', this, 'v1', () => new WeakMap()); - } -} - /** * Reflection information for user class * @@ -81,26 +74,26 @@ export class OnDemandTypeInfo extends OnDemandPropertyInfo implements TypeInfo { /** * Get TypeInfo from constructor */ - static find(target: object | Function): TypeInfo { - const info = TypeInfos.v1.get(target); + static from(target: object | Function): TypeInfo { + const info = TypeInfos.v2.get(target); if (info) { return info; } // make type as a property called "constructor" const newInfo = new OnDemandTypeInfo(target); - TypeInfos.v1.set(target, newInfo); + TypeInfos.v2.set(target, newInfo); return newInfo; } get static(): TypeInfo { - return OnDemandTypeInfo.find(this.declaringType); + return OnDemandTypeInfo.from(this.declaringType); } /** * Access class annotation info */ get prototype(): TypeInfo { - return Once(this, 'prototype', OnDemandTypeInfo.find(this.declaringType.prototype)); + return DefineIfValue(this, 'prototype', OnDemandTypeInfo.from(this.declaringType.prototype)); } protected getType(): Function | undefined { @@ -125,10 +118,10 @@ export class OnDemandTypeInfo extends OnDemandPropertyInfo implements TypeInfo { result = null; } // ignore object as base type - else if (base === Function.prototype || base === Object.prototype || IsAgent(base)) { + else if (base === Function.prototype || base === Object.prototype) { result = null; } else { - result = OnDemandTypeInfo.find(base); + result = OnDemandTypeInfo.from(base); } return result; } @@ -160,7 +153,7 @@ export class OnDemandTypeInfo extends OnDemandPropertyInfo implements TypeInfo { } get annotation(): Property | undefined { - return Once(this, 'annotation', this.getAnnotation()); + return DefineIfValue(this, 'annotation', this.getAnnotation()); } /** @@ -168,7 +161,7 @@ export class OnDemandTypeInfo extends OnDemandPropertyInfo implements TypeInfo { * Get metadata object, undefined if not annotated. */ get typeAnnotation(): Type | undefined { - return Once(this, 'typeAnnotation', this.getTypeAnnotation()); + return DefineIfValue(this, 'typeAnnotation', this.getTypeAnnotation()); } /** @@ -192,7 +185,7 @@ export class OnDemandTypeInfo extends OnDemandPropertyInfo implements TypeInfo { * @cache */ get base(): TypeInfo | null | undefined { - return Once(this, 'base', this.getBase()); + return DefineIfValue(this, 'base', this.getBase()); } /** @@ -202,7 +195,7 @@ export class OnDemandTypeInfo extends OnDemandPropertyInfo implements TypeInfo { * @cache */ get types(): ReadonlyArray { - return Once(this, 'types', this.getTypes()); + return DefineIfValue(this, 'types', this.getTypes()); } // /** @@ -264,7 +257,7 @@ export class OnDemandTypeInfo extends OnDemandPropertyInfo implements TypeInfo { if (propertyAnnotation.target === this.target) { return this.getOwnProperty(key); } else { - return OnDemandTypeInfo.find(propertyAnnotation.target).getOwnProperty(key); + return OnDemandTypeInfo.from(propertyAnnotation.target).getOwnProperty(key); } } return; @@ -314,7 +307,7 @@ export class OnDemandTypeInfo extends OnDemandPropertyInfo implements TypeInfo { */ findProperties( filter: Filter, - filterCriteria?: any + filterCriteria?: any, ): ReadonlyMap> { const layers = new Map>(); for (const type of this.types) { @@ -343,7 +336,7 @@ export class OnDemandTypeInfo extends OnDemandPropertyInfo implements TypeInfo { return types; } - addAttribute(attribute: A4): void { + addAttribute(attribute: A4): void { AddAttributeToConstructor(attribute, this.target); } } diff --git a/src/agent/Agent/Reflection/MemberInfo.ts b/src/core/Core/Reflection/MemberInfo.ts similarity index 90% rename from src/agent/Agent/Reflection/MemberInfo.ts rename to src/core/Core/Reflection/MemberInfo.ts index e6c18957..7d87050c 100644 --- a/src/agent/Agent/Reflection/MemberInfo.ts +++ b/src/core/Core/Reflection/MemberInfo.ts @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Annotation } from '../../../dependencies/core'; -import { Class } from '../Arguments'; -import { Design } from '../Design'; -import { Filter } from './Filter'; +import { Design } from '../Interception/Design.ts'; +import { Filter } from './Filter.ts'; +import { Class } from '../Interception/Class.ts'; +import { Annotation } from '../Meta/Annotation.ts'; export interface MemberInfo extends Design { /** diff --git a/src/agent/Agent/Reflection/MemberKinds.ts b/src/core/Core/Reflection/MemberKinds.ts similarity index 100% rename from src/agent/Agent/Reflection/MemberKinds.ts rename to src/core/Core/Reflection/MemberKinds.ts diff --git a/src/agent/Agent/Reflection/ParameterInfo.ts b/src/core/Core/Reflection/ParameterInfo.ts similarity index 93% rename from src/agent/Agent/Reflection/ParameterInfo.ts rename to src/core/Core/Reflection/ParameterInfo.ts index 1ae22cc2..ddd1def5 100644 --- a/src/agent/Agent/Reflection/ParameterInfo.ts +++ b/src/core/Core/Reflection/ParameterInfo.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { MemberInfo } from './MemberInfo'; +import { MemberInfo } from './MemberInfo.ts'; export interface ParameterInfo extends MemberInfo { readonly key: string | symbol; diff --git a/src/agent/Agent/Reflection/PropertyInfo.ts b/src/core/Core/Reflection/PropertyInfo.ts similarity index 93% rename from src/agent/Agent/Reflection/PropertyInfo.ts rename to src/core/Core/Reflection/PropertyInfo.ts index 2beef310..24d27967 100644 --- a/src/agent/Agent/Reflection/PropertyInfo.ts +++ b/src/core/Core/Reflection/PropertyInfo.ts @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Property } from '../../../dependencies/core'; -import { MemberInfo } from './MemberInfo'; -import { ParameterInfo } from './ParameterInfo'; +import { Property } from '../Meta'; +import { MemberInfo } from './MemberInfo.ts'; +import { ParameterInfo } from './ParameterInfo.ts'; export interface PropertyInfo extends MemberInfo { /** diff --git a/src/agent/Agent/Reflection/PropertyMemberInfos.ts b/src/core/Core/Reflection/PropertyMemberInfos.ts similarity index 100% rename from src/agent/Agent/Reflection/PropertyMemberInfos.ts rename to src/core/Core/Reflection/PropertyMemberInfos.ts diff --git a/src/agent/Agent/Reflector.md b/src/core/Core/Reflection/Reflector.md similarity index 100% rename from src/agent/Agent/Reflector.md rename to src/core/Core/Reflection/Reflector.md diff --git a/src/agent/Agent/Reflection/TypeFilters.ts b/src/core/Core/Reflection/TypeFilters.ts similarity index 100% rename from src/agent/Agent/Reflection/TypeFilters.ts rename to src/core/Core/Reflection/TypeFilters.ts diff --git a/src/agent/Agent/Reflection/TypeInfo.ts b/src/core/Core/Reflection/TypeInfo.ts similarity index 93% rename from src/agent/Agent/Reflection/TypeInfo.ts rename to src/core/Core/Reflection/TypeInfo.ts index 05c2937b..665ae645 100644 --- a/src/agent/Agent/Reflection/TypeInfo.ts +++ b/src/core/Core/Reflection/TypeInfo.ts @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { PropertyInfo } from './PropertyInfo'; -import { Filter } from './Filter'; -import { Type } from '../../../dependencies/core'; +import { PropertyInfo } from './PropertyInfo.ts'; +import { Filter } from './Filter.ts'; +import { Type } from '../Meta/Type.ts'; export interface TypeInfo extends PropertyInfo { /** @@ -82,7 +82,7 @@ export interface TypeInfo extends PropertyInfo { */ findProperties( filter: Filter, - filterCriteria?: any + filterCriteria?: any, ): ReadonlyMap>; /** diff --git a/src/core/Core/Reflection/TypeInfoKnowledge.ts b/src/core/Core/Reflection/TypeInfoKnowledge.ts new file mode 100644 index 00000000..42af75f3 --- /dev/null +++ b/src/core/Core/Reflection/TypeInfoKnowledge.ts @@ -0,0 +1,11 @@ +import { Remember } from '../Meta'; +import { TypeInfo } from './TypeInfo.ts'; + +export class TypeInfos { + /** + * get types map + */ + static get v2() { + return Remember('TypeInfos', this, 'v2', () => new WeakMap()); + } +} diff --git a/src/core/Core/Reflection/index.ts b/src/core/Core/Reflection/index.ts new file mode 100644 index 00000000..3d7a8de1 --- /dev/null +++ b/src/core/Core/Reflection/index.ts @@ -0,0 +1 @@ +export {Once} from "./Internal/Once.ts"; diff --git a/src/core/Core/WellKnown.ts b/src/core/Core/WellKnown.ts index d2decc43..593fdbca 100644 --- a/src/core/Core/WellKnown.ts +++ b/src/core/Core/WellKnown.ts @@ -20,9 +20,14 @@ export const CONSTRUCTOR: string | symbol = 'constructor'; /** * @internal */ -export const METADATA: string = 'metadata'; +export const METADATA: string = 'com.agentframework.knowledge'; /** * @internal */ export const NOW: string = 'now'; + +/** + * @internal + */ +export const VERSION = 'version'; diff --git a/src/core/Core/__agent.ts b/src/core/Core/__agent.ts deleted file mode 100644 index 04450670..00000000 --- a/src/core/Core/__agent.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2016 Ling Zhang - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -/** - * Helper function for class decoration - */ -/*@__PURE__*/ -export function __agent(decorators: Function[], target: object | Function): any { - for (let i = decorators.length - 1; i >= 0; i--) { - target = decorators[i](target) || target; - } - return target; -} diff --git a/src/core/Core/__decorate.ts b/src/core/Core/__decorate.ts deleted file mode 100644 index a5f2138f..00000000 --- a/src/core/Core/__decorate.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2016 Ling Zhang - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -/** - * Helper function for class member decoration - */ -/*@__PURE__*/ -export function __decorate( - decorators: Function[], - target: object | Function, - targetKey: string | symbol, - desc: PropertyDescriptor | undefined | null /* field=undefined. method,getter,setter = null*/ -): any { - if (desc === null) { - desc = Reflect.getOwnPropertyDescriptor(target, targetKey); - } - let modified = desc; - for (let i = decorators.length - 1; i >= 0; i--) { - modified = decorators[i](target, targetKey, modified || desc); - } - if (modified) { - Reflect.defineProperty(target, targetKey, modified); - } -} diff --git a/src/core/Core/__metadata.ts b/src/core/Core/__metadata.ts deleted file mode 100644 index 548b033a..00000000 --- a/src/core/Core/__metadata.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2016 Ling Zhang - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -import { Knowledge } from './Knowledge'; -import { GetProperty } from './Helpers/GetProperty'; -import { AddMetadata } from './Helpers/AddMetadata'; -import { Annotation } from './Annotation/Annotation'; -import { GetConstructor } from './Helpers/GetConstructor'; - -/*@__PURE__*/ -export function __metadata(key: string, value: any): Function { - return function (target: Function | object, targetKey?: string | symbol, descriptor?: PropertyDescriptor) { - let annotation: Annotation; - if (targetKey) { - annotation = GetProperty(Knowledge.add(target), targetKey, descriptor); - } else { - annotation = GetConstructor(Knowledge.add((target as Function).prototype)); - } - AddMetadata(annotation, key, value); - }; -} diff --git a/src/core/index.ts b/src/core/index.ts index 92945f1d..1f8effc9 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,28 +1,37 @@ /********************************************************************* * (Stability: 2 - Stable) Annotation *********************************************************************/ -export { Type } from './Core/Type'; -export { Property } from './Core/Property'; -export { Parameter } from './Core/Parameter'; -export { Annotation } from './Core/Annotation'; +export { Type } from './Core/Meta/Type.ts'; +export { Property } from './Core/Meta/Property.ts'; +export { Parameter } from './Core/Meta/Parameter.ts'; +export { Annotation } from './Core/Meta/Annotation.ts'; /********************************************************************* * (Stability: 2 - Stable) Annotation API *********************************************************************/ -export { AddAttributeToProperty } from './Core/AddAttribute'; -export { AddAttributeToPropertyParameter } from './Core/AddAttribute'; -export { AddAttributeToConstructorParameter } from './Core/AddAttribute'; -export { AddAttributeToConstructor } from './Core/AddAttribute'; +export { AddAttributeToProperty } from './Core/Meta/AddAttributeToProperty.ts'; +export { AddAttributeToPropertyParameter } from './Core/Meta/AddAttributeToPropertyParameter.ts'; +export { AddAttributeToConstructor } from './Core/Meta/AddAttributeToConstructor.ts'; +export { AddAttributeToConstructorParameter } from './Core/Meta/AddAttributeToConstructorParameter.ts'; -export { GetConstructorAnnotation } from './Core/GetAnnotation'; -export { GetPropertyAnnotation } from './Core/GetAnnotation'; -export { GetMemory } from './Core/GetMemory'; -export { GetAnnotation } from './Core/GetAnnotation'; +export { GetAnnotation } from './Core/Meta/GetAnnotation.ts'; +export { GetConstructorAnnotation } from './Core/Meta/GetConstructorAnnotation.ts'; +export { GetPropertyAnnotation } from './Core/Meta/GetPropertyAnnotation.ts'; + +/********************************************************************* + * (Stability: 2 - Stable): Memory API + *********************************************************************/ +export { Remember, SetMemory, GetMemory } from './Core/Meta/Memory.ts'; + +/********************************************************************* + * (Stability: 2 - Stable): Internal Helper Function + *********************************************************************/ +export { DefineValue } from './Core/Meta/DefineValue.ts'; +export { DefineIfValue } from './Core/Meta/DefineIfValue.ts'; +export { DefineGetter } from './Core/Meta/DefineGetter.ts'; /********************************************************************* * (Stability: 1 - Experimental): TSLIB integrate with Metadata *********************************************************************/ -export { __decorate } from './Core/__decorate'; -export { __agent } from './Core/__agent'; -export { __metadata } from './Core/__metadata'; -export { __param } from './Core/__param'; +// export { __esDecorate } from './Core/__esDecorate'; +// export { __runInitializers } from './Core/__runInitializers'; diff --git a/src/agent/Agent/Decorators/DependencyInjection/SingletonAttribute.ts b/src/decorator/Decorator/DependencyInjection/SingletonAttribute.ts similarity index 77% rename from src/agent/Agent/Decorators/DependencyInjection/SingletonAttribute.ts rename to src/decorator/Decorator/DependencyInjection/SingletonAttribute.ts index 0ae4180f..7e9f7a60 100644 --- a/src/agent/Agent/Decorators/DependencyInjection/SingletonAttribute.ts +++ b/src/decorator/Decorator/DependencyInjection/SingletonAttribute.ts @@ -12,13 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { AgentFrameworkError } from '../../AgentFrameworkError'; -import { PropertyInterceptor } from '../../TypeInterceptors'; -import { PropertyInvocation } from '../../TypeInvocations'; -import { CreateAgent } from '../../CreateAgent'; -import { Singletons } from '../../Knowledges/Singletons'; -import { IsAgent } from '../../Knowledges/Agents'; -import { Arguments } from '../../Arguments'; +import { AgentFrameworkError } from '../../../agent/Agent/AgentFrameworkError.ts'; +import { PropertyInterceptor } from '../../../core/Core/Interception/TypeInterceptors.ts'; +import { PropertyInvocation } from '../../../core/Core/Interception/TypeInvocations.ts'; +import { CreateAgent } from '../../../agent/Agent/CreateAgent.ts'; +import { Singletons } from '../../../agent/Agent/Knowledges/Singletons.ts'; +import { IsAgent } from '../../../agent/Agent/Knowledges/Agents.ts'; +import { Arguments } from '../../../core/Core/Interception/Arguments.ts'; export class SingletonAttribute implements PropertyInterceptor { readonly type?: Function; diff --git a/src/agent/Agent/Decorators/DependencyInjection/TransitAttribute.ts b/src/decorator/Decorator/DependencyInjection/TransitAttribute.ts similarity index 79% rename from src/agent/Agent/Decorators/DependencyInjection/TransitAttribute.ts rename to src/decorator/Decorator/DependencyInjection/TransitAttribute.ts index a903b7be..b69c323f 100644 --- a/src/agent/Agent/Decorators/DependencyInjection/TransitAttribute.ts +++ b/src/decorator/Decorator/DependencyInjection/TransitAttribute.ts @@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { CreateAgent } from '../../CreateAgent'; -import { AgentFrameworkError } from '../../AgentFrameworkError'; -import { PropertyInterceptor } from '../../TypeInterceptors'; -import { PropertyInvocation } from '../../TypeInvocations'; -import { Arguments } from '../../Arguments'; +import { CreateAgent } from '../../../agent/Agent/CreateAgent.ts'; +import { AgentFrameworkError } from '../../../agent/Agent/AgentFrameworkError.ts'; +import { PropertyInterceptor } from '../../../core/Core/Interception/TypeInterceptors.ts'; +import { PropertyInvocation } from '../../../core/Core/Interception/TypeInvocations.ts'; +import { Arguments } from '../../../core/Core/Interception/Arguments.ts'; export class TransitAttribute implements PropertyInterceptor { readonly type?: Function; diff --git a/src/agent/Agent/Decorators/DependencyInjection/singleton.Spec.ts b/src/decorator/Decorator/DependencyInjection/singleton.Spec.ts similarity index 97% rename from src/agent/Agent/Decorators/DependencyInjection/singleton.Spec.ts rename to src/decorator/Decorator/DependencyInjection/singleton.Spec.ts index c4b405af..35bf7422 100644 --- a/src/agent/Agent/Decorators/DependencyInjection/singleton.Spec.ts +++ b/src/decorator/Decorator/DependencyInjection/singleton.Spec.ts @@ -1,5 +1,5 @@ -import { GetType, Reflector, agent, singleton, GetAgentType } from '../../../../dependencies/agent'; -import { SingletonAttribute } from './SingletonAttribute'; +import { GetType, Reflector, agent, singleton, GetAgentType } from '@agentframework/agent.ts'; +import { SingletonAttribute } from './SingletonAttribute.ts'; describe('Core @singleton() decorator', () => { describe('# should able to', () => { diff --git a/src/agent/Agent/Decorators/DependencyInjection/singleton.ts b/src/decorator/Decorator/DependencyInjection/singleton.ts similarity index 76% rename from src/agent/Agent/Decorators/DependencyInjection/singleton.ts rename to src/decorator/Decorator/DependencyInjection/singleton.ts index 5a49cb56..eb465d12 100644 --- a/src/agent/Agent/Decorators/DependencyInjection/singleton.ts +++ b/src/decorator/Decorator/DependencyInjection/singleton.ts @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { SingletonAttribute } from './SingletonAttribute'; -import { decorateVariable } from '../../Decorate/decorateVariable'; -import { VariableDecorator } from '../VariableDecorator'; +import { SingletonAttribute } from './SingletonAttribute.ts'; +import { decorateVariable } from '../../../agent/Agent/Decorate/decorateVariable.ts'; +import { VariableDecorator } from '../VariableDecorator.ts'; export function singleton(type?: T): VariableDecorator { return decorateVariable(new SingletonAttribute(type)); diff --git a/src/agent/Agent/Decorators/DependencyInjection/transit.Spec.ts b/src/decorator/Decorator/DependencyInjection/transit.Spec.ts similarity index 93% rename from src/agent/Agent/Decorators/DependencyInjection/transit.Spec.ts rename to src/decorator/Decorator/DependencyInjection/transit.Spec.ts index 81764430..e384bfb0 100644 --- a/src/agent/Agent/Decorators/DependencyInjection/transit.Spec.ts +++ b/src/decorator/Decorator/DependencyInjection/transit.Spec.ts @@ -1,5 +1,5 @@ -import { Reflector, agent, transit } from '../../../../dependencies/agent'; -import { TransitAttribute } from './TransitAttribute'; +import { Reflector, agent, transit } from '@agentframework/agent.ts'; +import { TransitAttribute } from './TransitAttribute.ts'; describe('Core @transit() decorator', () => { describe('# should able to', () => { diff --git a/src/agent/Agent/Decorators/DependencyInjection/transit.ts b/src/decorator/Decorator/DependencyInjection/transit.ts similarity index 77% rename from src/agent/Agent/Decorators/DependencyInjection/transit.ts rename to src/decorator/Decorator/DependencyInjection/transit.ts index 4a620d24..e0cba7ce 100644 --- a/src/agent/Agent/Decorators/DependencyInjection/transit.ts +++ b/src/decorator/Decorator/DependencyInjection/transit.ts @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { TransitAttribute } from './TransitAttribute'; -import { decorateVariable } from '../../Decorate/decorateVariable'; -import { VariableDecorator } from '../VariableDecorator'; +import { TransitAttribute } from './TransitAttribute.ts'; +import { decorateVariable } from '../../../agent/Agent/Decorate/decorateVariable.ts'; +import { VariableDecorator } from '../VariableDecorator.ts'; export function transit(type?: T): VariableDecorator { return decorateVariable(new TransitAttribute(type)); diff --git a/src/agent/Agent/Decorators/Exclusive/GetNamedType.ts b/src/decorator/Decorator/Exclusive/GetNamedType.ts similarity index 90% rename from src/agent/Agent/Decorators/Exclusive/GetNamedType.ts rename to src/decorator/Decorator/Exclusive/GetNamedType.ts index e144afb7..a50657ee 100644 --- a/src/agent/Agent/Decorators/Exclusive/GetNamedType.ts +++ b/src/decorator/Decorator/Exclusive/GetNamedType.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Namespaces } from '../../Knowledges/Namespaces'; +import { Namespaces } from '../../../agent/Agent/Knowledges/Namespaces.ts'; export function GetNamedType(name: string, type: T): T { const ns = Namespaces.v1; diff --git a/src/agent/Agent/Decorators/Exclusive/exclusive.ts b/src/decorator/Decorator/Exclusive/exclusive.ts similarity index 93% rename from src/agent/Agent/Decorators/Exclusive/exclusive.ts rename to src/decorator/Decorator/Exclusive/exclusive.ts index 99f179fb..839dde74 100644 --- a/src/agent/Agent/Decorators/Exclusive/exclusive.ts +++ b/src/decorator/Decorator/Exclusive/exclusive.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { GetNamedType } from './GetNamedType'; +import { GetNamedType } from './GetNamedType.ts'; /** * extensible attribute diff --git a/src/agent/Agent/Decorators/Initializable/Initializer.ts b/src/decorator/Decorator/Initializable/Initializer.ts similarity index 83% rename from src/agent/Agent/Decorators/Initializable/Initializer.ts rename to src/decorator/Decorator/Initializable/Initializer.ts index 7c8390e2..590ada75 100644 --- a/src/agent/Agent/Decorators/Initializable/Initializer.ts +++ b/src/decorator/Decorator/Initializable/Initializer.ts @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { TypeInvocation } from '../../TypeInvocations'; -import { Arguments } from '../../Arguments'; +import { TypeInvocation } from '../../../core/Core/Interception/TypeInvocations.ts'; +import { Arguments } from '../../../core/Core/Interception/Arguments.ts'; export type InitializerHandler = () => void; diff --git a/src/agent/Agent/Decorators/Initializable/InitializerAttribute.ts b/src/decorator/Decorator/Initializable/InitializerAttribute.ts similarity index 65% rename from src/agent/Agent/Decorators/Initializable/InitializerAttribute.ts rename to src/decorator/Decorator/Initializable/InitializerAttribute.ts index faf16139..aca69ce4 100644 --- a/src/agent/Agent/Decorators/Initializable/InitializerAttribute.ts +++ b/src/decorator/Decorator/Initializable/InitializerAttribute.ts @@ -1,7 +1,7 @@ -import { AgentFrameworkError } from '../../AgentFrameworkError'; -import { TypeInterceptor } from '../../TypeInterceptors'; -import { TypeInvocation } from '../../TypeInvocations'; -import { Arguments } from '../../Arguments'; +import { AgentFrameworkError } from '../../../agent/Agent/AgentFrameworkError.ts'; +import { TypeInterceptor } from '../../../core/Core/Interception/TypeInterceptors.ts'; +import { TypeInvocation } from '../../../core/Core/Interception/TypeInvocations.ts'; +import { Arguments } from '../../../core/Core/Interception/Arguments.ts'; export class InitializerAttribute implements TypeInterceptor { constructor(readonly key: PropertyKey) {} diff --git a/src/agent/Agent/Decorators/Initializable/StaticInitializerAttribute.ts b/src/decorator/Decorator/Initializable/StaticInitializerAttribute.ts similarity index 78% rename from src/agent/Agent/Decorators/Initializable/StaticInitializerAttribute.ts rename to src/decorator/Decorator/Initializable/StaticInitializerAttribute.ts index e25f5056..306fb817 100644 --- a/src/agent/Agent/Decorators/Initializable/StaticInitializerAttribute.ts +++ b/src/decorator/Decorator/Initializable/StaticInitializerAttribute.ts @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { AgentFrameworkError } from '../../AgentFrameworkError'; -import { TypeInterceptor } from '../../TypeInterceptors'; -import { TypeInvocation } from '../../TypeInvocations'; -import { Arguments } from '../../Arguments'; +import { AgentFrameworkError } from '../../../agent/Agent/AgentFrameworkError.ts'; +import { TypeInterceptor } from '../../../core/Core/Interception/TypeInterceptors.ts'; +import { TypeInvocation } from '../../../core/Core/Interception/TypeInvocations.ts'; +import { Arguments } from '../../../core/Core/Interception/Arguments.ts'; export class StaticInitializerAttribute implements TypeInterceptor { constructor(readonly key: PropertyKey) {} diff --git a/src/agent/Agent/Decorators/Initializable/initializable.ts b/src/decorator/Decorator/Initializable/initializable.ts similarity index 84% rename from src/agent/Agent/Decorators/Initializable/initializable.ts rename to src/decorator/Decorator/Initializable/initializable.ts index ad79ad94..5619ed79 100644 --- a/src/agent/Agent/Decorators/Initializable/initializable.ts +++ b/src/decorator/Decorator/Initializable/initializable.ts @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Initializer } from './Initializer'; -import { AddAttributeToConstructor } from '../../../../dependencies/core'; -import { InitializerAttribute } from './InitializerAttribute'; -import { StaticInitializerAttribute } from './StaticInitializerAttribute'; +import { Initializer } from './Initializer.ts'; +import { AddAttributeToConstructor } from '@agentframework/core.ts'; +import { InitializerAttribute } from './InitializerAttribute.ts'; +import { StaticInitializerAttribute } from './StaticInitializerAttribute.ts'; export function initializable(key?: string | symbol): ClassDecorator { return (type: Function): void => { diff --git a/src/agent/Agent/Decorators/Once/Once.Spec.ts b/src/decorator/Decorator/Once/Once.Spec.ts similarity index 94% rename from src/agent/Agent/Decorators/Once/Once.Spec.ts rename to src/decorator/Decorator/Once/Once.Spec.ts index 9169ac6a..7018a213 100644 --- a/src/agent/Agent/Decorators/Once/Once.Spec.ts +++ b/src/decorator/Decorator/Once/Once.Spec.ts @@ -1,5 +1,5 @@ -import { agent } from '../../../../dependencies/agent'; -import { once } from './Once'; +import { agent } from '@agentframework/agent.ts'; +import { once } from './Once.ts'; describe('Once!', () => { describe('# should able to', () => { diff --git a/src/agent/Agent/Decorators/Once/Once.ts b/src/decorator/Decorator/Once/Once.ts similarity index 76% rename from src/agent/Agent/Decorators/Once/Once.ts rename to src/decorator/Decorator/Once/Once.ts index 09fab1d8..fe488202 100644 --- a/src/agent/Agent/Decorators/Once/Once.ts +++ b/src/decorator/Decorator/Once/Once.ts @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ // the once can be used on both class getter or static getter -import { alter } from '../../Compiler/alter'; -import { decorateMember } from '../../Decorate/decorateMember'; -import { Arguments } from '../../Arguments'; -import { PropertyInvocation } from '../../TypeInvocations'; +import { decorateMember } from '../../../agent/Agent/Decorate/decorateMember.ts'; +import { Arguments } from '../../../core/Core/Interception/Arguments.ts'; +import { PropertyInvocation } from '../../../core/Core/Interception/TypeInvocations.ts'; +import { DefineValue } from '../../../core'; /** * Run getter only once. only apply to getter or static getter @@ -27,7 +27,7 @@ export function once(): MethodDecorator { intercept(target: PropertyInvocation, params: Arguments, receiver: object): unknown { const value = target.invoke(params, receiver); if ('undefined' !== typeof value) { - alter(receiver, target.design.key, { value }); + DefineValue(receiver, target.design.key, { value }); } return value; }, @@ -49,10 +49,3 @@ export function once(): MethodDecorator { // }; // }; } - -export function Once(target: object | Function, getterKey: string | symbol, value: T): T { - if ('undefined' !== typeof value) { - alter(target, getterKey, { value }); - } - return value; -} diff --git a/src/agent/Agent/Decorators/Remember/Remember.Spec.ts b/src/decorator/Decorator/Remember/Remember.Spec.ts similarity index 94% rename from src/agent/Agent/Decorators/Remember/Remember.Spec.ts rename to src/decorator/Decorator/Remember/Remember.Spec.ts index 5616925b..305e31bf 100644 --- a/src/agent/Agent/Decorators/Remember/Remember.Spec.ts +++ b/src/decorator/Decorator/Remember/Remember.Spec.ts @@ -1,5 +1,5 @@ -import { agent } from '../../../../dependencies/agent'; -import { remember } from './Remember'; +import { agent } from '@agentframework/agent.ts'; +import { remember } from './Remember.ts'; describe('Remember!', () => { describe('# should able to', () => { diff --git a/src/agent/Agent/Decorators/Remember/Remember.ts b/src/decorator/Decorator/Remember/Remember.ts similarity index 76% rename from src/agent/Agent/Decorators/Remember/Remember.ts rename to src/decorator/Decorator/Remember/Remember.ts index 9ddfc284..524c2cc1 100644 --- a/src/agent/Agent/Decorators/Remember/Remember.ts +++ b/src/decorator/Decorator/Remember/Remember.ts @@ -13,11 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ // the memorize can be used on both class getter or static getter -import { GetMemory } from '../../../../dependencies/core'; -import { alter } from '../../Compiler/alter'; -import { decorateMember } from '../../Decorate/decorateMember'; -import { PropertyInvocation } from '../../TypeInvocations'; -import { Arguments } from '../../Arguments'; +import { DefineValue, GetMemory, SetMemory } from '@agentframework/core.ts'; +import { decorateMember } from '../../../agent/Agent/Decorate/decorateMember.ts'; +import { PropertyInvocation } from '../../../core/Core/Interception/TypeInvocations.ts'; +import { Arguments } from '../../../core/Core/Interception/Arguments.ts'; /** * only apply to getter @@ -26,13 +25,13 @@ export function remember(key: string): MethodDecorator { return decorateMember({ interceptor: { intercept(target: PropertyInvocation, params: Arguments, receiver: object): unknown { - const memory = GetMemory(); const id = key + '.' + target.design.name; - if (memory.has(id)) { - return memory.get(id); + const memory = GetMemory(id); + if (memory !== undefined) { + return memory; } else { const value = target.invoke(params, receiver); - memory.set(id, value); + SetMemory(id, value); return value; } }, @@ -60,15 +59,14 @@ export function remember(key: string): MethodDecorator { } export function Remember(key: string, target: object | Function, targetKey: string | symbol, valueFn: () => T): T { - const memory = GetMemory(); const id = key + '.' + String(targetKey); - if (memory.has(id)) { - const value = memory.get(id); - alter(target, targetKey, { value }); - return value; + const memory = GetMemory(id); + if (memory !== undefined) { + DefineValue(target, targetKey, memory); + return memory as T; } else { const value = valueFn(); - memory.set(id, value); + SetMemory(id, value); return value; } } diff --git a/src/agent/Agent/Decorators/VariableDecorator.ts b/src/decorator/Decorator/VariableDecorator.ts similarity index 100% rename from src/agent/Agent/Decorators/VariableDecorator.ts rename to src/decorator/Decorator/VariableDecorator.ts diff --git a/src/agent/Agent/Decorators/agent.Spec.ts b/src/decorator/Decorator/agent.Spec.ts similarity index 98% rename from src/agent/Agent/Decorators/agent.Spec.ts rename to src/decorator/Decorator/agent.Spec.ts index 4fdaddc8..b82a17a4 100644 --- a/src/agent/Agent/Decorators/agent.Spec.ts +++ b/src/decorator/Decorator/agent.Spec.ts @@ -10,7 +10,7 @@ import { IsAgent, Reflector, agent, -} from '../../../dependencies/agent'; +} from '@agentframework/agent.ts'; @agent() class MongoDB { diff --git a/src/agent/Agent/Decorators/agent.ts b/src/decorator/Decorator/agent.ts similarity index 91% rename from src/agent/Agent/Decorators/agent.ts rename to src/decorator/Decorator/agent.ts index 5ac20a27..702d0f38 100644 --- a/src/agent/Agent/Decorators/agent.ts +++ b/src/decorator/Decorator/agent.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { CreateAgent } from '../CreateAgent'; +import { CreateAgent } from '../../agent/Agent/CreateAgent.ts'; /** * Define an agent diff --git a/src/decorator/Decorator/construct.ts b/src/decorator/Decorator/construct.ts new file mode 100644 index 00000000..a8f3f707 --- /dev/null +++ b/src/decorator/Decorator/construct.ts @@ -0,0 +1,6 @@ +import { CreateAgent } from '../../agent/Agent/CreateAgent.ts'; +import { Arguments } from '../../core/Core/Interception/Arguments.ts'; + +export function construct(type: Function, params: Arguments): any { + return Reflect.construct(CreateAgent(type), params); +} diff --git a/src/dependencies/agent.ts b/src/dependencies/agent.ts deleted file mode 100644 index 6ddbc563..00000000 --- a/src/dependencies/agent.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '../agent'; diff --git a/src/dependencies/core.ts b/src/dependencies/core.ts deleted file mode 100644 index 60507baa..00000000 --- a/src/dependencies/core.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '../core'; diff --git a/src/dependencies/domain.ts b/src/dependencies/domain.ts deleted file mode 100644 index 333be4fe..00000000 --- a/src/dependencies/domain.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '../domain'; diff --git a/src/domain/Domain/Agent.ts b/src/domain/Domain/Agent.ts index 3a9050ff..893d0e48 100644 --- a/src/domain/Domain/Agent.ts +++ b/src/domain/Domain/Agent.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Arguments, Class } from '../../dependencies/agent'; +import { Arguments, Class } from '../../../lib/dependencies/agent'; // export interface DefaultConstructor extends Class { // new (): T; diff --git a/src/domain/Domain/Decorators/DependencyInjection/InjectAttribute.ts b/src/domain/Domain/Decorators/DependencyInjection/InjectAttribute.ts index e157179e..c53316b3 100644 --- a/src/domain/Domain/Decorators/DependencyInjection/InjectAttribute.ts +++ b/src/domain/Domain/Decorators/DependencyInjection/InjectAttribute.ts @@ -18,7 +18,7 @@ import { PropertyInterceptor, Arguments, AgentFrameworkError, -} from '../../../../dependencies/agent'; +} from '../../../../../lib/dependencies/agent'; import { GetDomainFromInvocation } from '../../Helpers/GetDomainFromInvocation'; export class InjectAttribute implements PropertyAttribute, PropertyInterceptor { diff --git a/src/domain/Domain/Decorators/DependencyInjection/SingletonAttribute.ts b/src/domain/Domain/Decorators/DependencyInjection/SingletonAttribute.ts index bbc71e3f..40a91f45 100644 --- a/src/domain/Domain/Decorators/DependencyInjection/SingletonAttribute.ts +++ b/src/domain/Domain/Decorators/DependencyInjection/SingletonAttribute.ts @@ -18,7 +18,7 @@ import { PropertyInterceptor, PropertyAttribute, AgentFrameworkError, -} from '../../../../dependencies/agent'; +} from '../../../../../lib/dependencies/agent'; import { GetDomainFromInvocation } from '../../Helpers/GetDomainFromInvocation'; export class SingletonAttribute implements PropertyAttribute, PropertyInterceptor { diff --git a/src/domain/Domain/Decorators/DependencyInjection/TransitAttribute.ts b/src/domain/Domain/Decorators/DependencyInjection/TransitAttribute.ts index 42ad72f8..6c242e9b 100644 --- a/src/domain/Domain/Decorators/DependencyInjection/TransitAttribute.ts +++ b/src/domain/Domain/Decorators/DependencyInjection/TransitAttribute.ts @@ -18,7 +18,7 @@ import { PropertyAttribute, Arguments, AgentFrameworkError, -} from '../../../../dependencies/agent'; +} from '../../../../../lib/dependencies/agent'; import { GetDomainFromInvocation } from '../../Helpers/GetDomainFromInvocation'; import { Domain } from '../../Domain'; diff --git a/src/domain/Domain/Decorators/DependencyInjection/inject.ts b/src/domain/Domain/Decorators/DependencyInjection/inject.ts index 94c1247f..a55dcda7 100644 --- a/src/domain/Domain/Decorators/DependencyInjection/inject.ts +++ b/src/domain/Domain/Decorators/DependencyInjection/inject.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { decorateVariable, VariableDecorator } from '../../../../dependencies/agent'; +import { decorateVariable, VariableDecorator } from '../../../../../lib/dependencies/agent'; import { InjectAttribute } from './InjectAttribute'; /** diff --git a/src/domain/Domain/Decorators/DependencyInjection/singleton.ts b/src/domain/Domain/Decorators/DependencyInjection/singleton.ts index 73db2258..c2529283 100644 --- a/src/domain/Domain/Decorators/DependencyInjection/singleton.ts +++ b/src/domain/Domain/Decorators/DependencyInjection/singleton.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { decorateVariable, VariableDecorator } from '../../../../dependencies/agent'; +import { decorateVariable, VariableDecorator } from '../../../../../lib/dependencies/agent'; import { SingletonAttribute } from './SingletonAttribute'; export function singleton(type?: T): VariableDecorator { diff --git a/src/domain/Domain/Decorators/DependencyInjection/transit.ts b/src/domain/Domain/Decorators/DependencyInjection/transit.ts index f5098aaa..9d22f38c 100644 --- a/src/domain/Domain/Decorators/DependencyInjection/transit.ts +++ b/src/domain/Domain/Decorators/DependencyInjection/transit.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { decorateVariable, VariableDecorator } from '../../../../dependencies/agent'; +import { decorateVariable, VariableDecorator } from '../../../../../lib/dependencies/agent'; import { TransitAttribute } from './TransitAttribute'; export function transit(type?: T): VariableDecorator { diff --git a/src/domain/Domain/DomainAgent/CreateDomainAgent.ts b/src/domain/Domain/DomainAgent/CreateDomainAgent.ts index e1236c10..b97263b3 100644 --- a/src/domain/Domain/DomainAgent/CreateDomainAgent.ts +++ b/src/domain/Domain/DomainAgent/CreateDomainAgent.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { AgentFrameworkError, TypeAttribute, CreateAgent } from '../../../dependencies/agent'; +import { AgentFrameworkError, TypeAttribute, CreateAgent } from '../../../../lib/dependencies/agent'; import { DomainAgentAttribute } from './DomainAgentAttribute'; import { DomainLike } from '../DomainLike'; import { GetDomain } from '../Helpers/GetDomain'; diff --git a/src/domain/Domain/DomainAgent/DomainAgentAttribute.ts b/src/domain/Domain/DomainAgent/DomainAgentAttribute.ts index d3614728..782e002d 100644 --- a/src/domain/Domain/DomainAgent/DomainAgentAttribute.ts +++ b/src/domain/Domain/DomainAgent/DomainAgentAttribute.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { AgentAttribute, Arguments, TypeInterceptor, TypeInvocation } from '../../../dependencies/agent'; +import { AgentAttribute, Arguments, TypeInterceptor, TypeInvocation } from '../../../../lib/dependencies/agent'; import { DomainLike } from '../DomainLike'; export class DomainAgentAttribute extends AgentAttribute implements TypeInterceptor { diff --git a/src/domain/Domain/DomainAgent/DomainAgentInterceptor.ts b/src/domain/Domain/DomainAgent/DomainAgentInterceptor.ts index c30ed7dd..13f50083 100644 --- a/src/domain/Domain/DomainAgent/DomainAgentInterceptor.ts +++ b/src/domain/Domain/DomainAgent/DomainAgentInterceptor.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Arguments, TypeInterceptor, TypeInvocation } from '../../../dependencies/agent'; +import { Arguments, TypeInterceptor, TypeInvocation } from '../../../../lib/dependencies/agent'; import { DomainLike } from '../DomainLike'; export class DomainAgentInterceptor implements TypeInterceptor { diff --git a/src/domain/Domain/DomainKnowledge.ts b/src/domain/Domain/DomainKnowledge.ts index 92516155..e2f00766 100644 --- a/src/domain/Domain/DomainKnowledge.ts +++ b/src/domain/Domain/DomainKnowledge.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Remember } from '../../dependencies/agent'; +import { Remember } from '../../../lib/dependencies/agent'; import { Domain } from './Domain'; /** diff --git a/src/domain/Domain/Helpers/GetDomainFromInvocation.ts b/src/domain/Domain/Helpers/GetDomainFromInvocation.ts index d2e9ad58..9367cb2d 100644 --- a/src/domain/Domain/Helpers/GetDomainFromInvocation.ts +++ b/src/domain/Domain/Helpers/GetDomainFromInvocation.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { Arguments, Invocation } from '../../../dependencies/agent'; +import { Arguments, Invocation } from '../../../../lib/dependencies/agent'; // import { IsDomain } from './IsDomain'; import { Domain } from '../Domain'; import { GetDomain } from './GetDomain'; diff --git a/src/domain/Domain/InMemoryDomain.ts b/src/domain/Domain/InMemoryDomain.ts index e27ed75b..8944253e 100644 --- a/src/domain/Domain/InMemoryDomain.ts +++ b/src/domain/Domain/InMemoryDomain.ts @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import { AgentFrameworkError, Class } from '../../dependencies/agent'; +import { AgentFrameworkError, Class } from '../../../lib/dependencies/agent'; import { Disposable } from './Helpers/Disposable'; import { Agent, AgentReference, Params } from './Agent'; import { Domain } from './Domain'; diff --git a/src/domain/Domain/InMemorySubDomain.ts b/src/domain/Domain/InMemorySubDomain.ts index 0a9afed2..fc9fda8c 100644 --- a/src/domain/Domain/InMemorySubDomain.ts +++ b/src/domain/Domain/InMemorySubDomain.ts @@ -18,7 +18,7 @@ import { Agent, AgentReference } from './Agent'; import { SubDomainLike } from './SubDomainLike'; import { DomainLike } from './DomainLike'; import { GetSystemDomain } from './Helpers/GetSystemDomain'; -import { Once } from '../../dependencies/agent'; +import { Once } from '../../../lib/dependencies/agent'; export class InMemorySubDomain extends InMemoryDomain implements SubDomainLike { @@ -26,7 +26,7 @@ export class InMemorySubDomain extends InMemoryDomain implements SubDomainLike { // GetDomain(this) will return this. So must use GetDomain(this.constructor) return Once(this, 'parent', GetDomain(this.constructor) || GetSystemDomain()); } - + getAgentType(type: T): T | undefined { return super.getAgentType(type) || this.parent.getAgentType(type); } diff --git a/test/v1/1.attributes/AgentChecker.ts b/test/v1/1.attributes/AgentChecker.ts index 1048a12a..326f6e1d 100644 --- a/test/v1/1.attributes/AgentChecker.ts +++ b/test/v1/1.attributes/AgentChecker.ts @@ -1,5 +1,5 @@ /* tslint:disable */ -import { Arguments, Attribute, Interceptor, TypeInvocation } from '../../../src/dependencies/agent'; +import { Arguments, Attribute, Interceptor, TypeInvocation } from '../../../lib/dependencies/agent'; export class AgentChecker implements Attribute, Interceptor { get interceptor(): Interceptor { diff --git a/test/v1/1.attributes/AgentTrackerAttribute.ts b/test/v1/1.attributes/AgentTrackerAttribute.ts index 9f2236c3..8b63899f 100644 --- a/test/v1/1.attributes/AgentTrackerAttribute.ts +++ b/test/v1/1.attributes/AgentTrackerAttribute.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { Arguments, TypeInvocation, Interceptor, MemberKinds } from '../../../src/dependencies/agent'; +import { Arguments, TypeInvocation, Interceptor, MemberKinds } from '../../../lib/dependencies/agent'; export class AgentTrackerAttribute implements Interceptor { get interceptor(): Interceptor { diff --git a/test/v1/1.attributes/BadAgentChecker.ts b/test/v1/1.attributes/BadAgentChecker.ts index 6c3e886f..28707d1d 100644 --- a/test/v1/1.attributes/BadAgentChecker.ts +++ b/test/v1/1.attributes/BadAgentChecker.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { AgentAttribute } from '../../../src/dependencies/agent'; +import { AgentAttribute } from '../../../lib/dependencies/agent'; export class BadAgentChecker extends AgentAttribute { beforeDecorate( diff --git a/test/v1/1.attributes/BadRandomAttribute.ts b/test/v1/1.attributes/BadRandomAttribute.ts index 96b1da0c..9392a150 100644 --- a/test/v1/1.attributes/BadRandomAttribute.ts +++ b/test/v1/1.attributes/BadRandomAttribute.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { Interceptor } from '../../../src/dependencies/agent'; +import { Interceptor } from '../../../lib/dependencies/agent'; export class BadRandomAttribute { beforeDecorate( diff --git a/test/v1/1.attributes/BadRoundAttribute.ts b/test/v1/1.attributes/BadRoundAttribute.ts index 86380d3d..cd5cce5e 100644 --- a/test/v1/1.attributes/BadRoundAttribute.ts +++ b/test/v1/1.attributes/BadRoundAttribute.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { Interceptor, Attribute } from '../../../src/dependencies/agent'; +import { Interceptor, Attribute } from '../../../lib/dependencies/agent'; export class BadRoundAttribute implements Attribute { beforeDecorate( diff --git a/test/v1/1.attributes/BeforeRoundAttribute.ts b/test/v1/1.attributes/BeforeRoundAttribute.ts index a6d3f8bd..baa95a9d 100644 --- a/test/v1/1.attributes/BeforeRoundAttribute.ts +++ b/test/v1/1.attributes/BeforeRoundAttribute.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { Arguments, Attribute, Interceptor, Invocation } from '../../../src/dependencies/agent'; +import { Arguments, Attribute, Interceptor, Invocation } from '../../../lib/dependencies/agent'; export class BeforeRoundAttribute implements Attribute, Interceptor { beforeDecorate( diff --git a/test/v1/1.attributes/DisabledMetadataAttribute.ts b/test/v1/1.attributes/DisabledMetadataAttribute.ts index 082b5dc7..3f377a0c 100644 --- a/test/v1/1.attributes/DisabledMetadataAttribute.ts +++ b/test/v1/1.attributes/DisabledMetadataAttribute.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { Attribute } from '../../../src/dependencies/agent'; +import { Attribute } from '../../../lib/dependencies/agent'; export class DisabledMetadataAttribute implements Attribute { beforeDecorate( diff --git a/test/v1/1.attributes/InjectAttribute.ts b/test/v1/1.attributes/InjectAttribute.ts index f0b21fb4..05913a8b 100644 --- a/test/v1/1.attributes/InjectAttribute.ts +++ b/test/v1/1.attributes/InjectAttribute.ts @@ -7,7 +7,7 @@ import { ParameterInvocation, PropertyInterceptor, ParameterInterceptor, -} from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; export class InjectAttribute implements Attribute, PropertyInterceptor { get interceptor(): PropertyInterceptor { diff --git a/test/v1/1.attributes/MetadataAttribute.ts b/test/v1/1.attributes/MetadataAttribute.ts index 9571aa05..b67abc53 100644 --- a/test/v1/1.attributes/MetadataAttribute.ts +++ b/test/v1/1.attributes/MetadataAttribute.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { Attribute } from '../../../src/dependencies/agent'; +import { Attribute } from '../../../lib/dependencies/agent'; export class MetadataAttribute implements Attribute { beforeDecorate( diff --git a/test/v1/1.attributes/RandomInterceptor.ts b/test/v1/1.attributes/RandomInterceptor.ts index 2521f5fa..5821ecb0 100644 --- a/test/v1/1.attributes/RandomInterceptor.ts +++ b/test/v1/1.attributes/RandomInterceptor.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { Arguments, Attribute, Interceptor, Invocation } from '../../../src/dependencies/agent'; +import { Arguments, Attribute, Interceptor, Invocation } from '../../../lib/dependencies/agent'; export class RandomInterceptor implements Attribute, Interceptor { beforeDecorate( diff --git a/test/v1/1.attributes/RoundInterceptor.ts b/test/v1/1.attributes/RoundInterceptor.ts index c20cf6c9..3a344c72 100644 --- a/test/v1/1.attributes/RoundInterceptor.ts +++ b/test/v1/1.attributes/RoundInterceptor.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { Interceptor, Invocation, Attribute, Arguments } from '../../../src/dependencies/agent'; +import { Interceptor, Invocation, Attribute, Arguments } from '../../../lib/dependencies/agent'; function rounder(num: any): number { return 'number' === typeof num ? Math.round(num) : NaN; diff --git a/test/v1/2.compiler/2.bad.agent.attribute.test.ts b/test/v1/2.compiler/2.bad.agent.attribute.test.ts index 5bd56826..15d33a48 100644 --- a/test/v1/2.compiler/2.bad.agent.attribute.test.ts +++ b/test/v1/2.compiler/2.bad.agent.attribute.test.ts @@ -1,7 +1,7 @@ /* tslint:disable */ -import { decorateMember, Interceptor, Attribute, IsAgent } from '../../../src/dependencies/agent'; -import { CreateAgent, AgentAttribute } from '../../../src/dependencies/agent'; +import { decorateMember, Interceptor, Attribute, IsAgent } from '../../../lib/dependencies/agent'; +import { CreateAgent, AgentAttribute } from '../../../lib/dependencies/agent'; import { InjectAttribute } from '../1.attributes/InjectAttribute'; class Connection { diff --git a/test/v1/2.compiler/3.invalid.parameter.test.ts b/test/v1/2.compiler/3.invalid.parameter.test.ts index c8dd277b..bf2a8a9a 100644 --- a/test/v1/2.compiler/3.invalid.parameter.test.ts +++ b/test/v1/2.compiler/3.invalid.parameter.test.ts @@ -1,9 +1,9 @@ /* tslint:disable */ -import { agent } from '../../../src/dependencies/agent'; -import { decorateParameter, IsAgent, Reflector } from '../../../src/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; +import { decorateParameter, IsAgent, Reflector } from '../../../lib/dependencies/agent'; import { MetadataAttribute } from '../1.attributes/MetadataAttribute'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; class Connection { static count = 0; diff --git a/test/v1/2.compiler/4.invalid.interceptor.test.ts b/test/v1/2.compiler/4.invalid.interceptor.test.ts index 111600bf..87a7c6eb 100644 --- a/test/v1/2.compiler/4.invalid.interceptor.test.ts +++ b/test/v1/2.compiler/4.invalid.interceptor.test.ts @@ -1,8 +1,8 @@ /* tslint:disable */ -import { agent, decorateMember, IsAgent, Reflector } from '../../../src/dependencies/agent'; +import { agent, decorateMember, IsAgent, Reflector } from '../../../lib/dependencies/agent'; import { InjectAttribute } from '../1.attributes/InjectAttribute'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; @agent() class PostgreSQL { diff --git a/test/v1/3.decorator/fake.test.ts b/test/v1/3.decorator/fake.test.ts index e7e83452..58e6d039 100644 --- a/test/v1/3.decorator/fake.test.ts +++ b/test/v1/3.decorator/fake.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { agent } from '../../../src/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; import { fakeClassMemberDecorator, fakeClassDecorator, diff --git a/test/v1/3.decorator/fake.ts b/test/v1/3.decorator/fake.ts index 3ff746be..69302719 100644 --- a/test/v1/3.decorator/fake.ts +++ b/test/v1/3.decorator/fake.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { Attribute, Interceptor, decorateMember, decorateClass, decorateParameter } from '../../../src/dependencies/agent'; +import { Attribute, Interceptor, decorateMember, decorateClass, decorateParameter } from '../../../lib/dependencies/agent'; export function fakeClassMemberDecorator() { return decorateMember(new PropertyDecoratorAttribute()); diff --git a/test/v1/3.decorator/method.test.ts b/test/v1/3.decorator/method.test.ts index 6c160c66..7385b69d 100644 --- a/test/v1/3.decorator/method.test.ts +++ b/test/v1/3.decorator/method.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { agent } from '../../../src/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; import { methodDecorator } from './method'; describe('Method Decorator', () => { diff --git a/test/v1/3.decorator/method.ts b/test/v1/3.decorator/method.ts index d992ef7f..c7e45c38 100644 --- a/test/v1/3.decorator/method.ts +++ b/test/v1/3.decorator/method.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { Attribute, Interceptor, Invocation, decorateMember, Arguments } from '../../../src/dependencies/agent'; +import { Attribute, Interceptor, Invocation, decorateMember, Arguments } from '../../../lib/dependencies/agent'; export function methodDecorator() { return decorateMember(new MethodDecoratorAttribute()); diff --git a/test/v1/3.decorator/property.test.ts b/test/v1/3.decorator/property.test.ts index 802cdb47..422627c8 100644 --- a/test/v1/3.decorator/property.test.ts +++ b/test/v1/3.decorator/property.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { agent } from '../../../src/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; import { propertyDecorator } from './property'; @agent() diff --git a/test/v1/3.decorator/property.ts b/test/v1/3.decorator/property.ts index 3dd7e58f..e1c512ba 100644 --- a/test/v1/3.decorator/property.ts +++ b/test/v1/3.decorator/property.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { Attribute, decorateMember } from '../../../src/dependencies/agent'; +import { Attribute, decorateMember } from '../../../lib/dependencies/agent'; export function propertyDecorator() { return decorateMember(new PropertyAttribute()); diff --git a/test/v1/4.interceptor/0.constructor.test.ts b/test/v1/4.interceptor/0.constructor.test.ts index fa17a6e3..746917e0 100644 --- a/test/v1/4.interceptor/0.constructor.test.ts +++ b/test/v1/4.interceptor/0.constructor.test.ts @@ -13,7 +13,7 @@ import { MemberKinds, decorateClass, CreateAgent, -} from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; class AgentChecker implements Attribute, Interceptor { diff --git a/test/v1/4.interceptor/1.interceptor.test.ts b/test/v1/4.interceptor/1.interceptor.test.ts index e36d2c62..b03682f2 100644 --- a/test/v1/4.interceptor/1.interceptor.test.ts +++ b/test/v1/4.interceptor/1.interceptor.test.ts @@ -1,7 +1,7 @@ /* tslint:disable */ -import { agent, decorate, decorateMember, decorateParameter, IsAgent, Reflector, MemberKinds } from '../../../src/dependencies/agent'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { agent, decorate, decorateMember, decorateParameter, IsAgent, Reflector, MemberKinds } from '../../../lib/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; @agent() diff --git a/test/v1/4.interceptor/2.interceptors.test.ts b/test/v1/4.interceptor/2.interceptors.test.ts index 3696ecdf..b7dac19e 100644 --- a/test/v1/4.interceptor/2.interceptors.test.ts +++ b/test/v1/4.interceptor/2.interceptors.test.ts @@ -1,8 +1,8 @@ /* tslint:disable */ -import { agent, decorate, decorateMember, decorateParameter, IsAgent, Reflector, MemberKinds } from '../../../src/dependencies/agent'; +import { agent, decorate, decorateMember, decorateParameter, IsAgent, Reflector, MemberKinds } from '../../../lib/dependencies/agent'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; @agent() class Calculator { diff --git a/test/v1/4.interceptor/3.setter.test.ts b/test/v1/4.interceptor/3.setter.test.ts index aa541af8..7b38d597 100644 --- a/test/v1/4.interceptor/3.setter.test.ts +++ b/test/v1/4.interceptor/3.setter.test.ts @@ -1,7 +1,7 @@ /* tslint:disable */ -import { agent, IsAgent, decorateMember } from '../../../src/dependencies/agent'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { agent, IsAgent, decorateMember } from '../../../lib/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; import { BeforeRoundAttribute } from '../1.attributes/BeforeRoundAttribute'; @agent() diff --git a/test/v1/4.interceptor/4.duplicate.test.ts b/test/v1/4.interceptor/4.duplicate.test.ts index d84f3b30..e95c503e 100644 --- a/test/v1/4.interceptor/4.duplicate.test.ts +++ b/test/v1/4.interceptor/4.duplicate.test.ts @@ -1,8 +1,8 @@ /* tslint:disable */ -import { IsAgent, decorateMember, agent } from '../../../src/dependencies/agent'; +import { IsAgent, decorateMember, agent } from '../../../lib/dependencies/agent'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; class Base { @decorateMember(new RoundInterceptor()) diff --git a/test/v1/4.interceptor/5.invalid.field.test.ts b/test/v1/4.interceptor/5.invalid.field.test.ts index e0e0e25b..99ed6582 100644 --- a/test/v1/4.interceptor/5.invalid.field.test.ts +++ b/test/v1/4.interceptor/5.invalid.field.test.ts @@ -1,8 +1,8 @@ /* tslint:disable */ -import { decorateMember, IsAgent, Reflector } from '../../../src/dependencies/agent'; +import { decorateMember, IsAgent, Reflector } from '../../../lib/dependencies/agent'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; class Calculator { @decorateMember(new RoundInterceptor()) diff --git a/test/v1/4.interceptor/6.invalid.setter.test.ts b/test/v1/4.interceptor/6.invalid.setter.test.ts index 49a8493a..6d50b044 100644 --- a/test/v1/4.interceptor/6.invalid.setter.test.ts +++ b/test/v1/4.interceptor/6.invalid.setter.test.ts @@ -1,7 +1,7 @@ /* tslint:disable */ -import { agent, IsAgent, decorateMember } from '../../../src/dependencies/agent'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { agent, IsAgent, decorateMember } from '../../../lib/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; import { BeforeRoundAttribute } from '../1.attributes/BeforeRoundAttribute'; @agent() diff --git a/test/v1/4.interceptor/7.invalid.method.test.ts b/test/v1/4.interceptor/7.invalid.method.test.ts index bc21d7e1..27c01a77 100644 --- a/test/v1/4.interceptor/7.invalid.method.test.ts +++ b/test/v1/4.interceptor/7.invalid.method.test.ts @@ -1,7 +1,7 @@ /* tslint:disable */ -import { agent, IsAgent, decorateMember } from '../../../src/dependencies/agent'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { agent, IsAgent, decorateMember } from '../../../lib/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; import { BadRoundAttribute } from '../1.attributes/BadRoundAttribute'; @agent() diff --git a/test/v1/5.nested/1.nested.agent.test.ts b/test/v1/5.nested/1.nested.agent.test.ts index 8fd1deac..5a8921aa 100644 --- a/test/v1/5.nested/1.nested.agent.test.ts +++ b/test/v1/5.nested/1.nested.agent.test.ts @@ -1,10 +1,10 @@ /* tslint:disable */ -import { agent, decorateClass, decorateMember, IsAgent } from '../../../src/dependencies/agent'; +import { agent, decorateClass, decorateMember, IsAgent } from '../../../lib/dependencies/agent'; import { AgentChecker } from '../1.attributes/AgentChecker'; import { RandomInterceptor } from '../1.attributes/RandomInterceptor'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; import { MetadataAttribute } from '../1.attributes/MetadataAttribute'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; @agent() @decorateClass(new AgentChecker()) diff --git a/test/v1/6.parameter/1.constructor.test.ts b/test/v1/6.parameter/1.constructor.test.ts index 5f5dc562..d4497c60 100644 --- a/test/v1/6.parameter/1.constructor.test.ts +++ b/test/v1/6.parameter/1.constructor.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { agent, decorateParameter, Reflector } from '../../../src/dependencies/agent'; +import { agent, decorateParameter, Reflector } from '../../../lib/dependencies/agent'; import { InjectParameterAttribute } from '../1.attributes/InjectAttribute'; class Connection1611 { diff --git a/test/v1/6.parameter/2.method.test.ts b/test/v1/6.parameter/2.method.test.ts index f6ad8060..1229d2c1 100644 --- a/test/v1/6.parameter/2.method.test.ts +++ b/test/v1/6.parameter/2.method.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { agent, decorateParameter, Attribute, Interceptor, Invocation, decorateMember, Arguments } from '../../../src/dependencies/agent'; +import { agent, decorateParameter, Attribute, Interceptor, Invocation, decorateMember, Arguments } from '../../../lib/dependencies/agent'; import {InjectAttribute, InjectParameterAttribute} from '../1.attributes/InjectAttribute'; class Connection { diff --git a/test/v1/6.parameter/3.mix.test.ts b/test/v1/6.parameter/3.mix.test.ts index ce655def..f3901321 100644 --- a/test/v1/6.parameter/3.mix.test.ts +++ b/test/v1/6.parameter/3.mix.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { agent, decorateMember, decorateParameter } from '../../../src/dependencies/agent'; +import { agent, decorateMember, decorateParameter } from '../../../lib/dependencies/agent'; import {InjectAttribute, InjectParameterAttribute} from '../1.attributes/InjectAttribute'; class Connection { diff --git a/test/v1/7.reflection/0.decorate-agent.test.ts b/test/v1/7.reflection/0.decorate-agent.test.ts index 0ab99db1..f3667b7e 100644 --- a/test/v1/7.reflection/0.decorate-agent.test.ts +++ b/test/v1/7.reflection/0.decorate-agent.test.ts @@ -1,8 +1,8 @@ /* tslint:disable */ -import { IsAgent, Reflector, decorateClass } from '../../../src/dependencies/agent'; +import { IsAgent, Reflector, decorateClass } from '../../../lib/dependencies/agent'; import { DisabledMetadataAttribute } from '../1.attributes/DisabledMetadataAttribute'; -import { AgentAttribute, CreateAgent } from '../../../src/dependencies/agent'; +import { AgentAttribute, CreateAgent } from '../../../lib/dependencies/agent'; class BadAgentAttribute extends AgentAttribute { get interceptor() { diff --git a/test/v1/7.reflection/1.decorate-class.test.ts b/test/v1/7.reflection/1.decorate-class.test.ts index 3bd3b9e7..20425007 100644 --- a/test/v1/7.reflection/1.decorate-class.test.ts +++ b/test/v1/7.reflection/1.decorate-class.test.ts @@ -1,11 +1,11 @@ /* tslint:disable */ -import { agent, decorateClass, decorateMember, IsAgent, Reflector } from '../../../src/dependencies/agent'; +import { agent, decorateClass, decorateMember, IsAgent, Reflector } from '../../../lib/dependencies/agent'; import { RandomInterceptor } from '../1.attributes/RandomInterceptor'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; import { MetadataAttribute } from '../1.attributes/MetadataAttribute'; import { AgentChecker } from '../1.attributes/AgentChecker'; -import { AgentAttribute, CreateAgent, GetType } from '../../../src/dependencies/agent'; +import { AgentAttribute, CreateAgent, GetType } from '../../../lib/dependencies/agent'; @agent() @decorateClass(new AgentChecker()) diff --git a/test/v1/7.reflection/10.get-reflection.test.ts b/test/v1/7.reflection/10.get-reflection.test.ts index 66749397..af27ffda 100644 --- a/test/v1/7.reflection/10.get-reflection.test.ts +++ b/test/v1/7.reflection/10.get-reflection.test.ts @@ -1,10 +1,10 @@ /* tslint:disable */ -import { decorateMember, Reflector } from '../../../src/dependencies/agent'; +import { decorateMember, Reflector } from '../../../lib/dependencies/agent'; import { RandomInterceptor } from '../1.attributes/RandomInterceptor'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; import { MetadataAttribute } from '../1.attributes/MetadataAttribute'; -import { AgentAttribute } from '../../../src/dependencies/agent'; +import { AgentAttribute } from '../../../lib/dependencies/agent'; class MongoDB { @decorateMember(new RandomInterceptor()) diff --git a/test/v1/7.reflection/11.decorate-class-attribute.test.ts b/test/v1/7.reflection/11.decorate-class-attribute.test.ts index 7168e16f..a0bb5601 100644 --- a/test/v1/7.reflection/11.decorate-class-attribute.test.ts +++ b/test/v1/7.reflection/11.decorate-class-attribute.test.ts @@ -1,12 +1,12 @@ /* tslint:disable */ -import { decorateMember, IsAgent, Reflector, decorateClass, AgentFrameworkError } from '../../../src/dependencies/agent'; +import { decorateMember, IsAgent, Reflector, decorateClass, AgentFrameworkError } from '../../../lib/dependencies/agent'; import { RandomInterceptor } from '../1.attributes/RandomInterceptor'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; import { MetadataAttribute } from '../1.attributes/MetadataAttribute'; import { BadAgentChecker } from '../1.attributes/BadAgentChecker'; import { BadRandomAttribute } from '../1.attributes/BadRandomAttribute'; -import { AgentAttribute, CreateAgent } from '../../../src/dependencies/agent'; +import { AgentAttribute, CreateAgent } from '../../../lib/dependencies/agent'; @decorateClass(new BadRandomAttribute()) class MongoDB { diff --git a/test/v1/7.reflection/2.decorate-class-member.test.ts b/test/v1/7.reflection/2.decorate-class-member.test.ts index 21bc149b..724c12d5 100644 --- a/test/v1/7.reflection/2.decorate-class-member.test.ts +++ b/test/v1/7.reflection/2.decorate-class-member.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { decorateMember, decorateParameter, Reflector } from '../../../src/dependencies/agent'; +import { decorateMember, decorateParameter, Reflector } from '../../../lib/dependencies/agent'; import { RandomInterceptor } from '../1.attributes/RandomInterceptor'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; import { MetadataAttribute } from '../1.attributes/MetadataAttribute'; diff --git a/test/v1/7.reflection/3.decorate.all.test.ts b/test/v1/7.reflection/3.decorate.all.test.ts index 637ab9a4..6d3b2f90 100644 --- a/test/v1/7.reflection/3.decorate.all.test.ts +++ b/test/v1/7.reflection/3.decorate.all.test.ts @@ -1,7 +1,7 @@ /* tslint:disable */ -import { decorate, IsAgent, MemberKinds } from '../../../src/dependencies/agent'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { decorate, IsAgent, MemberKinds } from '../../../lib/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; import { MetadataAttribute } from '../1.attributes/MetadataAttribute'; /** diff --git a/test/v1/7.reflection/3.decorate.not.allowed.test.ts b/test/v1/7.reflection/3.decorate.not.allowed.test.ts index f7d3713d..d0cc4518 100644 --- a/test/v1/7.reflection/3.decorate.not.allowed.test.ts +++ b/test/v1/7.reflection/3.decorate.not.allowed.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { decorate, AgentFrameworkError, MemberKinds } from '../../../src/dependencies/agent'; +import { decorate, AgentFrameworkError, MemberKinds } from '../../../lib/dependencies/agent'; import { MetadataAttribute } from '../1.attributes/MetadataAttribute'; const a = new MetadataAttribute(); diff --git a/test/v1/7.reflection/3.decorate.test.ts b/test/v1/7.reflection/3.decorate.test.ts index 1f294ec3..d2a20f91 100644 --- a/test/v1/7.reflection/3.decorate.test.ts +++ b/test/v1/7.reflection/3.decorate.test.ts @@ -1,9 +1,9 @@ /* tslint:disable */ -import { decorate, IsAgent, MemberKinds } from '../../../src/dependencies/agent'; +import { decorate, IsAgent, MemberKinds } from '../../../lib/dependencies/agent'; import { MetadataAttribute } from '../1.attributes/MetadataAttribute'; import { DisabledMetadataAttribute } from '../1.attributes/DisabledMetadataAttribute'; -import { CreateAgent } from '../../../src/dependencies/agent'; +import { CreateAgent } from '../../../lib/dependencies/agent'; /** * Constructor = 1, diff --git a/test/v1/7.reflection/6.get-reflection-metadata.test.ts b/test/v1/7.reflection/6.get-reflection-metadata.test.ts index 83124234..e9b0540b 100644 --- a/test/v1/7.reflection/6.get-reflection-metadata.test.ts +++ b/test/v1/7.reflection/6.get-reflection-metadata.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { AgentFrameworkError, decorateMember, Reflector } from '../../../src/dependencies/agent'; +import { AgentFrameworkError, decorateMember, Reflector } from '../../../lib/dependencies/agent'; import { RandomInterceptor } from '../1.attributes/RandomInterceptor'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; diff --git a/test/v1/7.reflection/7.get-reflection-metadata-by-attribute.test.ts b/test/v1/7.reflection/7.get-reflection-metadata-by-attribute.test.ts index 65bf7d74..4834253d 100644 --- a/test/v1/7.reflection/7.get-reflection-metadata-by-attribute.test.ts +++ b/test/v1/7.reflection/7.get-reflection-metadata-by-attribute.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { decorateMember, Reflector } from '../../../src/dependencies/agent'; +import { decorateMember, Reflector } from '../../../lib/dependencies/agent'; import { RandomInterceptor } from '../1.attributes/RandomInterceptor'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; diff --git a/test/v1/7.reflection/8.check-whether-a-class-is-agent.test.ts b/test/v1/7.reflection/8.check-whether-a-class-is-agent.test.ts index 9c9275a9..11ffecda 100644 --- a/test/v1/7.reflection/8.check-whether-a-class-is-agent.test.ts +++ b/test/v1/7.reflection/8.check-whether-a-class-is-agent.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { CreateAgent, GetType, IsAgent, agent } from '../../../src/dependencies/agent'; +import { CreateAgent, GetType, IsAgent, agent } from '../../../lib/dependencies/agent'; @agent() class AgentClass {} diff --git a/test/v1/7.reflection/9.get-reflection-attribute.test.ts b/test/v1/7.reflection/9.get-reflection-attribute.test.ts index f41d97e6..6fca7d68 100644 --- a/test/v1/7.reflection/9.get-reflection-attribute.test.ts +++ b/test/v1/7.reflection/9.get-reflection-attribute.test.ts @@ -1,6 +1,6 @@ /* tslint:disable */ -import { decorateMember, Reflector } from '../../../src/dependencies/agent'; +import { decorateMember, Reflector } from '../../../lib/dependencies/agent'; import { RandomInterceptor } from '../1.attributes/RandomInterceptor'; import { RoundInterceptor } from '../1.attributes/RoundInterceptor'; diff --git a/test/v2/1.general/1.hello-world.test.ts b/test/v2/1.general/1.hello-world.test.ts index 622f292e..f7991898 100644 --- a/test/v2/1.general/1.hello-world.test.ts +++ b/test/v2/1.general/1.hello-world.test.ts @@ -1,5 +1,5 @@ -import { agent, transit, CreateAgent, singleton, decorateVariable } from '../../../src/dependencies/agent'; -import { SingletonAttribute } from '../../../src/agent/Agent/Decorators/DependencyInjection/SingletonAttribute'; +import { agent, transit, CreateAgent, singleton, decorateVariable } from '../../../lib/dependencies/agent'; +import { SingletonAttribute } from '../../../src/decorator/Decorator/DependencyInjection/SingletonAttribute'; describe('Hello world!', () => { describe('# should able to', () => { diff --git a/test/v2/1.general/3.agent-interceptor-seq.test.ts b/test/v2/1.general/3.agent-interceptor-seq.test.ts index a56cde1f..920b9d15 100644 --- a/test/v2/1.general/3.agent-interceptor-seq.test.ts +++ b/test/v2/1.general/3.agent-interceptor-seq.test.ts @@ -6,8 +6,8 @@ import { IsAgent, Reflector, decorateAgent, -} from '../../../src/dependencies/agent'; -import { agent } from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; describe('1.3. Agent interceptor invoke sequence', () => { describe('# should able to', () => { diff --git a/test/v2/1.general/4.class-interceptor-seq.test.ts b/test/v2/1.general/4.class-interceptor-seq.test.ts index f9be4a15..9c03434d 100644 --- a/test/v2/1.general/4.class-interceptor-seq.test.ts +++ b/test/v2/1.general/4.class-interceptor-seq.test.ts @@ -5,8 +5,8 @@ import { Design, Invocation, Reflector, -} from '../../../src/dependencies/agent'; -import { agent } from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; describe('1.4. Class interceptor invoke sequence', () => { describe('# should able to', () => { diff --git a/test/v2/1.general/5.property-interceptor-seq.test.ts b/test/v2/1.general/5.property-interceptor-seq.test.ts index b5f41122..e9832a16 100644 --- a/test/v2/1.general/5.property-interceptor-seq.test.ts +++ b/test/v2/1.general/5.property-interceptor-seq.test.ts @@ -7,7 +7,7 @@ import { decorateMember, decorateParameter, agent, -} from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; describe('1.5. Property interceptor invoke sequence', () => { describe('# should able to', () => { diff --git a/test/v2/1.general/6.agent-with-decorators.test.ts b/test/v2/1.general/6.agent-with-decorators.test.ts index d5d4def5..67f85f63 100644 --- a/test/v2/1.general/6.agent-with-decorators.test.ts +++ b/test/v2/1.general/6.agent-with-decorators.test.ts @@ -1,4 +1,4 @@ -import { agent, decorateClass, decorateMember, GetType, Reflector } from '../../../src/dependencies/agent'; +import { agent, decorateClass, decorateMember, GetType, Reflector } from '../../../lib/dependencies/agent'; describe('1.6. Agent with decorators', () => { diff --git a/test/v2/2.type/2.1.type.test.ts b/test/v2/2.type/2.1.type.test.ts index 7395a763..41334935 100644 --- a/test/v2/2.type/2.1.type.test.ts +++ b/test/v2/2.type/2.1.type.test.ts @@ -9,7 +9,7 @@ import { decorateMember, GetType, agent, -} from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; class Storage {} diff --git a/test/v2/2.type/2.2.type-members.test.ts b/test/v2/2.type/2.2.type-members.test.ts index 0b430e65..dcac9b23 100644 --- a/test/v2/2.type/2.2.type-members.test.ts +++ b/test/v2/2.type/2.2.type-members.test.ts @@ -1,4 +1,4 @@ -import { decorateMember, MemberKinds, PropertyInfo, Reflector } from '../../../src/dependencies/agent'; +import { decorateMember, MemberKinds, PropertyInfo, Reflector } from '../../../lib/dependencies/agent'; class Compiler {} diff --git a/test/v2/2.type/2.3.methods.test.ts b/test/v2/2.type/2.3.methods.test.ts index 5bd4a3b5..66aeb5d1 100644 --- a/test/v2/2.type/2.3.methods.test.ts +++ b/test/v2/2.type/2.3.methods.test.ts @@ -5,7 +5,7 @@ import { HasInterceptor, ParameterInvocation, Reflector, -} from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; import { ClassMethod, ClassMethodParameter } from '../Kinds'; class ParamAttribute { diff --git a/test/v2/2.type/2.4.fields.test.ts b/test/v2/2.type/2.4.fields.test.ts index 5b0f7467..62b7ce9a 100644 --- a/test/v2/2.type/2.4.fields.test.ts +++ b/test/v2/2.type/2.4.fields.test.ts @@ -1,4 +1,4 @@ -import { AgentFrameworkError, decorate, decorateMember, MemberKinds, Reflector } from '../../../src/dependencies/agent'; +import { AgentFrameworkError, decorate, decorateMember, MemberKinds, Reflector } from '../../../lib/dependencies/agent'; import { ClassField } from '../Kinds'; class Data24 { diff --git a/test/v2/2.type/2.5.parameters.test.ts b/test/v2/2.type/2.5.parameters.test.ts index 035c34b9..6d7c10e5 100644 --- a/test/v2/2.type/2.5.parameters.test.ts +++ b/test/v2/2.type/2.5.parameters.test.ts @@ -5,7 +5,7 @@ import { MemberKinds, ParameterInvocation, Reflector, -} from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; class Data251 { constructor(@decorate({ require: 'operator' }, MemberKinds.Parameter) model: Date) {} diff --git a/test/v2/2.type/2.6.agent.test.ts b/test/v2/2.type/2.6.agent.test.ts index 775e7ce5..ca89bc29 100644 --- a/test/v2/2.type/2.6.agent.test.ts +++ b/test/v2/2.type/2.6.agent.test.ts @@ -7,7 +7,7 @@ import { ParameterAttribute, ParameterInterceptor, ParameterInvocation, -} from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; class InjectAttribute implements ParameterAttribute, ParameterInterceptor { constructor(readonly type?: any) {} diff --git a/test/v2/3.attribute/3.1.set-class-attribute.test.ts b/test/v2/3.attribute/3.1.set-class-attribute.test.ts index 4f278cdd..ca0265e0 100644 --- a/test/v2/3.attribute/3.1.set-class-attribute.test.ts +++ b/test/v2/3.attribute/3.1.set-class-attribute.test.ts @@ -1,4 +1,4 @@ -import { decorate, decorateClass, MemberKinds, Reflector } from '../../../src/dependencies/agent'; +import { decorate, decorateClass, MemberKinds, Reflector } from '../../../lib/dependencies/agent'; /** * The tests shows 3 ways to add attribute to a class at design time diff --git a/test/v2/3.attribute/3.2.get-class-attribute.test.ts b/test/v2/3.attribute/3.2.get-class-attribute.test.ts index bc08435a..cb88f105 100644 --- a/test/v2/3.attribute/3.2.get-class-attribute.test.ts +++ b/test/v2/3.attribute/3.2.get-class-attribute.test.ts @@ -1,5 +1,5 @@ -import { decorateClass, Reflector, TypeAttribute, Attribute } from '../../../src/dependencies/agent'; -import { Class } from '../../../src/dependencies/agent'; +import { decorateClass, Reflector, TypeAttribute, Attribute } from '../../../lib/dependencies/agent'; +import { Class } from '../../../lib/dependencies/agent'; /** * The tests shows 3 ways to add attribute to a class at design time diff --git a/test/v2/3.attribute/3.3.set-method-attribute.test.ts b/test/v2/3.attribute/3.3.set-method-attribute.test.ts index 65940a69..025b658d 100644 --- a/test/v2/3.attribute/3.3.set-method-attribute.test.ts +++ b/test/v2/3.attribute/3.3.set-method-attribute.test.ts @@ -1,4 +1,4 @@ -import { decorateMember, Reflector, PropertyAttribute } from '../../../src/dependencies/agent'; +import { decorateMember, Reflector, PropertyAttribute } from '../../../lib/dependencies/agent'; class MethodAttribute implements PropertyAttribute { constructor(readonly method: string, readonly path?: string) {} diff --git a/test/v2/3.attribute/3.4.get-method-attribute.test.ts b/test/v2/3.attribute/3.4.get-method-attribute.test.ts index 3a3c8a0d..49916aa3 100644 --- a/test/v2/3.attribute/3.4.get-method-attribute.test.ts +++ b/test/v2/3.attribute/3.4.get-method-attribute.test.ts @@ -1,6 +1,6 @@ -import { PropertyAttribute } from '../../../src/dependencies/agent'; -import { decorateMember } from '../../../src/dependencies/agent'; -import { Arguments, decorateParameter, Invocation, Reflector } from '../../../src/dependencies/agent'; +import { PropertyAttribute } from '../../../lib/dependencies/agent'; +import { decorateMember } from '../../../lib/dependencies/agent'; +import { Arguments, decorateParameter, Invocation, Reflector } from '../../../lib/dependencies/agent'; class MethodAttribute implements PropertyAttribute { constructor(readonly method: string, readonly path?: string) {} diff --git a/test/v2/3.attribute/3.5.set-parameter-attribute.test.ts b/test/v2/3.attribute/3.5.set-parameter-attribute.test.ts index 973d5d92..5c9ddf40 100644 --- a/test/v2/3.attribute/3.5.set-parameter-attribute.test.ts +++ b/test/v2/3.attribute/3.5.set-parameter-attribute.test.ts @@ -1,4 +1,4 @@ -import { Reflector, ParameterAttribute, decorateParameter } from '../../../src/dependencies/agent'; +import { Reflector, ParameterAttribute, decorateParameter } from '../../../lib/dependencies/agent'; class MandatoryAttribute implements ParameterAttribute {} diff --git a/test/v2/3.attribute/3.6.get-parameter-attribute.test.ts b/test/v2/3.attribute/3.6.get-parameter-attribute.test.ts index 942a579f..4baacfe1 100644 --- a/test/v2/3.attribute/3.6.get-parameter-attribute.test.ts +++ b/test/v2/3.attribute/3.6.get-parameter-attribute.test.ts @@ -1,4 +1,4 @@ -import { ParameterAttribute, HasInterceptor, GetInterceptor } from '../../../src/dependencies/agent'; +import { ParameterAttribute, HasInterceptor, GetInterceptor } from '../../../lib/dependencies/agent'; import { decorateParameter, ParameterInterceptor, @@ -6,7 +6,7 @@ import { ParameterInvocation, Arguments, agent, -} from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; class OptionalAttribute implements ParameterAttribute { constructor(readonly type: any) {} diff --git a/test/v2/4.interceptor/4.1.class-interceptor.test.ts b/test/v2/4.interceptor/4.1.class-interceptor.test.ts index d3a5fdba..fd4b1c1d 100644 --- a/test/v2/4.interceptor/4.1.class-interceptor.test.ts +++ b/test/v2/4.interceptor/4.1.class-interceptor.test.ts @@ -6,7 +6,7 @@ import { decorateMember, decorateAgent, Reflector, -} from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; describe('4.1. Class interceptor', () => { describe('# should able to', () => { diff --git a/test/v2/4.interceptor/4.10.empty-interceptors.test.ts b/test/v2/4.interceptor/4.10.empty-interceptors.test.ts index 3035da88..08052169 100644 --- a/test/v2/4.interceptor/4.10.empty-interceptors.test.ts +++ b/test/v2/4.interceptor/4.10.empty-interceptors.test.ts @@ -1,4 +1,4 @@ -import { agent, Arguments, decorateMember, Invocation, once, Design } from '../../../src/dependencies/agent'; +import { agent, Arguments, decorateMember, Invocation, once, Design } from '../../../lib/dependencies/agent'; describe('4.10. Empty interceptors', () => { describe('# should able to', () => { diff --git a/test/v2/4.interceptor/4.2.constructor-parameter-interceptor.test.ts b/test/v2/4.interceptor/4.2.constructor-parameter-interceptor.test.ts index fb15676d..67d4570d 100644 --- a/test/v2/4.interceptor/4.2.constructor-parameter-interceptor.test.ts +++ b/test/v2/4.interceptor/4.2.constructor-parameter-interceptor.test.ts @@ -1,8 +1,8 @@ -import { agent } from '../../../src/dependencies/agent'; -import { decorateClass } from '../../../src/dependencies/agent'; -import { TypeInvocation, ParameterInvocation } from '../../../src/dependencies/agent'; -import { Arguments } from '../../../src/dependencies/agent'; -import { decorateParameter } from '../../../src/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; +import { decorateClass } from '../../../lib/dependencies/agent'; +import { TypeInvocation, ParameterInvocation } from '../../../lib/dependencies/agent'; +import { Arguments } from '../../../lib/dependencies/agent'; +import { decorateParameter } from '../../../lib/dependencies/agent'; describe('4.4. constructor parameter interceptor', () => { describe('# should able to', () => { diff --git a/test/v2/4.interceptor/4.3.field-interceptor.test.ts b/test/v2/4.interceptor/4.3.field-interceptor.test.ts index 4b33d2bb..740df9a7 100644 --- a/test/v2/4.interceptor/4.3.field-interceptor.test.ts +++ b/test/v2/4.interceptor/4.3.field-interceptor.test.ts @@ -1,8 +1,8 @@ -import { agent, GetType } from '../../../src/dependencies/agent'; -import { decorateMember } from '../../../src/dependencies/agent'; -import { TypeInvocation } from '../../../src/dependencies/agent'; -import { Arguments } from '../../../src/dependencies/agent'; -import { IsAgent } from '../../../src/dependencies/agent'; +import { agent, GetType } from '../../../lib/dependencies/agent'; +import { decorateMember } from '../../../lib/dependencies/agent'; +import { TypeInvocation } from '../../../lib/dependencies/agent'; +import { Arguments } from '../../../lib/dependencies/agent'; +import { IsAgent } from '../../../lib/dependencies/agent'; describe('4.3. field interceptor', () => { describe('# should able to', () => { diff --git a/test/v2/4.interceptor/4.4.method-interceptor.test.ts b/test/v2/4.interceptor/4.4.method-interceptor.test.ts index 2360aa54..eb410538 100644 --- a/test/v2/4.interceptor/4.4.method-interceptor.test.ts +++ b/test/v2/4.interceptor/4.4.method-interceptor.test.ts @@ -1,8 +1,8 @@ -import { agent } from '../../../src/dependencies/agent'; -import { decorateMember } from '../../../src/dependencies/agent'; -import { TypeInvocation } from '../../../src/dependencies/agent'; -import { Arguments } from '../../../src/dependencies/agent'; -import { IsAgent } from '../../../src/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; +import { decorateMember } from '../../../lib/dependencies/agent'; +import { TypeInvocation } from '../../../lib/dependencies/agent'; +import { Arguments } from '../../../lib/dependencies/agent'; +import { IsAgent } from '../../../lib/dependencies/agent'; describe('4.4. method interceptor', () => { @agent() diff --git a/test/v2/4.interceptor/4.5.method-parameter-interceptor.test.ts b/test/v2/4.interceptor/4.5.method-parameter-interceptor.test.ts index fb82c933..50229507 100644 --- a/test/v2/4.interceptor/4.5.method-parameter-interceptor.test.ts +++ b/test/v2/4.interceptor/4.5.method-parameter-interceptor.test.ts @@ -1,8 +1,8 @@ -import { agent } from '../../../src/dependencies/agent'; -import { decorateMember } from '../../../src/dependencies/agent'; -import { TypeInvocation, ParameterInvocation } from '../../../src/dependencies/agent'; -import { Arguments } from '../../../src/dependencies/agent'; -import { decorateParameter } from '../../../src/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; +import { decorateMember } from '../../../lib/dependencies/agent'; +import { TypeInvocation, ParameterInvocation } from '../../../lib/dependencies/agent'; +import { Arguments } from '../../../lib/dependencies/agent'; +import { decorateParameter } from '../../../lib/dependencies/agent'; describe('4.5. method parameter interceptor', () => { describe('# should able to', () => { diff --git a/test/v2/4.interceptor/4.6.getter-interceptor.test.ts b/test/v2/4.interceptor/4.6.getter-interceptor.test.ts index 7bc32a0b..d465512f 100644 --- a/test/v2/4.interceptor/4.6.getter-interceptor.test.ts +++ b/test/v2/4.interceptor/4.6.getter-interceptor.test.ts @@ -1,7 +1,7 @@ -import { agent } from '../../../src/dependencies/agent'; -import { decorateMember } from '../../../src/dependencies/agent'; -import { TypeInvocation } from '../../../src/dependencies/agent'; -import { Arguments } from '../../../src/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; +import { decorateMember } from '../../../lib/dependencies/agent'; +import { TypeInvocation } from '../../../lib/dependencies/agent'; +import { Arguments } from '../../../lib/dependencies/agent'; describe('4.6. getter interceptor', () => { describe('# should able to', () => { diff --git a/test/v2/4.interceptor/4.7.setter-interceptor.test.ts b/test/v2/4.interceptor/4.7.setter-interceptor.test.ts index 8be68501..e277e209 100644 --- a/test/v2/4.interceptor/4.7.setter-interceptor.test.ts +++ b/test/v2/4.interceptor/4.7.setter-interceptor.test.ts @@ -1,7 +1,7 @@ -import { agent } from '../../../src/dependencies/agent'; -import { decorateMember } from '../../../src/dependencies/agent'; -import { TypeInvocation } from '../../../src/dependencies/agent'; -import { Arguments } from '../../../src/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; +import { decorateMember } from '../../../lib/dependencies/agent'; +import { TypeInvocation } from '../../../lib/dependencies/agent'; +import { Arguments } from '../../../lib/dependencies/agent'; describe('4.7. setter interceptor', () => { describe('# should able to', () => { diff --git a/test/v2/4.interceptor/4.8.getter-setter-interceptor.test.ts b/test/v2/4.interceptor/4.8.getter-setter-interceptor.test.ts index f7ca11c3..35dbdac9 100644 --- a/test/v2/4.interceptor/4.8.getter-setter-interceptor.test.ts +++ b/test/v2/4.interceptor/4.8.getter-setter-interceptor.test.ts @@ -1,7 +1,7 @@ -import { agent } from '../../../src/dependencies/agent'; -import { decorateMember } from '../../../src/dependencies/agent'; -import { PropertyInvocation } from '../../../src/dependencies/agent'; -import { Arguments } from '../../../src/dependencies/agent'; +import { agent } from '../../../lib/dependencies/agent'; +import { decorateMember } from '../../../lib/dependencies/agent'; +import { PropertyInvocation } from '../../../lib/dependencies/agent'; +import { Arguments } from '../../../lib/dependencies/agent'; describe('4.8. Getter and Setter interceptor', () => { describe('# should able to', () => { diff --git a/test/v2/4.interceptor/4.9.external-class-interceptor.test.ts b/test/v2/4.interceptor/4.9.external-class-interceptor.test.ts index 48bcf949..783b5aeb 100644 --- a/test/v2/4.interceptor/4.9.external-class-interceptor.test.ts +++ b/test/v2/4.interceptor/4.9.external-class-interceptor.test.ts @@ -8,7 +8,7 @@ import { decorateClass, GetCustomInterceptor, RemoveCustomInterceptor, -} from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; describe('4.9. External interceptor', () => { describe('# should able to', () => { diff --git a/test/v2/5.domain/5.0.welcome.test.ts b/test/v2/5.domain/5.0.welcome.test.ts index 067cb887..920fffb8 100644 --- a/test/v2/5.domain/5.0.welcome.test.ts +++ b/test/v2/5.domain/5.0.welcome.test.ts @@ -1,4 +1,4 @@ -import { InMemoryDomain, transit } from '../../../src/dependencies/domain'; +import { InMemoryDomain, transit } from '../../../lib/dependencies/domain'; describe('Hello world!', () => { describe('# should able to', () => { diff --git a/test/v2/5.domain/5.1.create-domain.test.ts b/test/v2/5.domain/5.1.create-domain.test.ts index 28713266..96ab59a4 100644 --- a/test/v2/5.domain/5.1.create-domain.test.ts +++ b/test/v2/5.domain/5.1.create-domain.test.ts @@ -1,4 +1,4 @@ -import { InMemoryDomain, Domain, IsDomain, InMemorySubDomain, GetSystemDomain } from '../../../src/dependencies/domain'; +import { InMemoryDomain, Domain, IsDomain, InMemorySubDomain, GetSystemDomain } from '../../../lib/dependencies/domain'; describe('5.1. Create domain', () => { describe('# should able to', () => { diff --git a/test/v2/5.domain/5.10.domain-transit.test.ts b/test/v2/5.domain/5.10.domain-transit.test.ts index 74a3ba8d..0bf4a2b0 100644 --- a/test/v2/5.domain/5.10.domain-transit.test.ts +++ b/test/v2/5.domain/5.10.domain-transit.test.ts @@ -1,5 +1,5 @@ -import { InMemoryDomain, agent, transit } from '../../../src/dependencies/domain'; -import { CreateAgent, Reflector } from '../../../src/dependencies/agent'; +import { InMemoryDomain, agent, transit } from '../../../lib/dependencies/domain'; +import { CreateAgent, Reflector } from '../../../lib/dependencies/agent'; describe('5.10. @transit decorator', () => { describe('# should able to', () => { diff --git a/test/v2/5.domain/5.11.domain-cache.test.ts b/test/v2/5.domain/5.11.domain-cache.test.ts index 35fc7674..6d139ed5 100644 --- a/test/v2/5.domain/5.11.domain-cache.test.ts +++ b/test/v2/5.domain/5.11.domain-cache.test.ts @@ -1,5 +1,5 @@ -import { InMemoryDomain } from '../../../src/dependencies/domain'; -import { Arguments, decorateClass, Design, Invocation, Reflector } from '../../../src/dependencies/agent'; +import { InMemoryDomain } from '../../../lib/dependencies/domain'; +import { Arguments, decorateClass, Design, Invocation, Reflector } from '../../../lib/dependencies/agent'; describe('5.11. Domain agent cache', () => { describe('# should able to', () => { diff --git a/test/v2/5.domain/5.12.domain-cache-property.test.ts b/test/v2/5.domain/5.12.domain-cache-property.test.ts index 931ee0b0..b54b6f0c 100644 --- a/test/v2/5.domain/5.12.domain-cache-property.test.ts +++ b/test/v2/5.domain/5.12.domain-cache-property.test.ts @@ -5,8 +5,8 @@ import { Design, Invocation, Reflector, -} from '../../../src/dependencies/agent'; -import { InMemoryDomain } from '../../../src/dependencies/domain'; +} from '../../../lib/dependencies/agent'; +import { InMemoryDomain } from '../../../lib/dependencies/domain'; describe('5.12. Domain agent property cache', () => { describe('# should able to', () => { diff --git a/test/v2/5.domain/5.13.domain-dispose.test.ts b/test/v2/5.domain/5.13.domain-dispose.test.ts index 525d2ec8..f52af51c 100644 --- a/test/v2/5.domain/5.13.domain-dispose.test.ts +++ b/test/v2/5.domain/5.13.domain-dispose.test.ts @@ -1,5 +1,5 @@ -import { InMemoryDomain } from '../../../src/dependencies/domain'; -import { Arguments, TypeInvocation, initializable, Initializer } from '../../../src/dependencies/agent'; +import { InMemoryDomain } from '../../../lib/dependencies/domain'; +import { Arguments, TypeInvocation, initializable, Initializer } from '../../../lib/dependencies/agent'; describe('5.13. Domain dispose', () => { describe('# should able to', () => { diff --git a/test/v2/5.domain/5.15.domain-agent.test.ts b/test/v2/5.domain/5.15.domain-agent.test.ts index ea60bb9a..802d2076 100644 --- a/test/v2/5.domain/5.15.domain-agent.test.ts +++ b/test/v2/5.domain/5.15.domain-agent.test.ts @@ -1,4 +1,4 @@ -import { Reflector } from '../../../src/dependencies/agent'; +import { Reflector } from '../../../lib/dependencies/agent'; import { agent, singleton, @@ -7,7 +7,7 @@ import { TransitAttribute, SingletonAttribute, InjectAttribute -} from '../../../src/dependencies/domain'; +} from '../../../lib/dependencies/domain'; describe('5.15. Domain agent', () => { describe('# should able to', () => { diff --git a/test/v2/5.domain/5.2.domain-types.test.ts b/test/v2/5.domain/5.2.domain-types.test.ts index c2ce6d85..8a7ae2fe 100644 --- a/test/v2/5.domain/5.2.domain-types.test.ts +++ b/test/v2/5.domain/5.2.domain-types.test.ts @@ -1,5 +1,5 @@ -import { InMemoryDomain, InMemorySubDomain } from '../../../src/dependencies/domain'; -import { agent } from '../../../src/dependencies/domain'; +import { InMemoryDomain, InMemorySubDomain } from '../../../lib/dependencies/domain'; +import { agent } from '../../../lib/dependencies/domain'; describe('5.2. Domain type', () => { class A {} diff --git a/test/v2/5.domain/5.3.domain-agents.test.ts b/test/v2/5.domain/5.3.domain-agents.test.ts index 5bf46a02..10ab54b3 100644 --- a/test/v2/5.domain/5.3.domain-agents.test.ts +++ b/test/v2/5.domain/5.3.domain-agents.test.ts @@ -1,5 +1,5 @@ -import { InMemoryDomain, GetDomain, InMemorySubDomain } from '../../../src/dependencies/domain'; -import { agent } from '../../../src/dependencies/domain'; +import { InMemoryDomain, GetDomain, InMemorySubDomain } from '../../../lib/dependencies/domain'; +import { agent } from '../../../lib/dependencies/domain'; describe('5.3. Domain agent', () => { class A {} diff --git a/test/v2/5.domain/5.4.domain-construct.test.ts b/test/v2/5.domain/5.4.domain-construct.test.ts index 33888dfc..e2c9e920 100644 --- a/test/v2/5.domain/5.4.domain-construct.test.ts +++ b/test/v2/5.domain/5.4.domain-construct.test.ts @@ -1,5 +1,5 @@ -import { InMemoryDomain } from '../../../src/dependencies/domain'; -import { agent } from '../../../src/dependencies/domain'; +import { InMemoryDomain } from '../../../lib/dependencies/domain'; +import { agent } from '../../../lib/dependencies/domain'; describe('5.4. Domain construct', () => { class A {} diff --git a/test/v2/5.domain/5.5.domain-resolve.test.ts b/test/v2/5.domain/5.5.domain-resolve.test.ts index c2b06258..55ed9c1e 100644 --- a/test/v2/5.domain/5.5.domain-resolve.test.ts +++ b/test/v2/5.domain/5.5.domain-resolve.test.ts @@ -1,5 +1,5 @@ -import { agent } from '../../../src/dependencies/domain'; -import { InMemoryDomain } from '../../../src/dependencies/domain'; +import { agent } from '../../../lib/dependencies/domain'; +import { InMemoryDomain } from '../../../lib/dependencies/domain'; describe('5.5. Domain resolve', () => { class A {} diff --git a/test/v2/5.domain/5.6.domain-instance.test.ts b/test/v2/5.domain/5.6.domain-instance.test.ts index 568db45f..43daa885 100644 --- a/test/v2/5.domain/5.6.domain-instance.test.ts +++ b/test/v2/5.domain/5.6.domain-instance.test.ts @@ -1,4 +1,4 @@ -import { InMemoryDomain } from '../../../src/dependencies/domain'; +import { InMemoryDomain } from '../../../lib/dependencies/domain'; describe('5.6. Domain instance', () => { const domain = new InMemoryDomain(); diff --git a/test/v2/5.domain/5.7.domain-initializable.test.ts b/test/v2/5.domain/5.7.domain-initializable.test.ts index 0daf95c1..441ce4b7 100644 --- a/test/v2/5.domain/5.7.domain-initializable.test.ts +++ b/test/v2/5.domain/5.7.domain-initializable.test.ts @@ -1,6 +1,6 @@ -import { InMemoryDomain } from '../../../src/dependencies/domain'; -import { Arguments, TypeInvocation } from '../../../src/dependencies/agent'; -import { CreateAgent, Initializer, initializable, agent } from '../../../src/dependencies/agent'; +import { InMemoryDomain } from '../../../lib/dependencies/domain'; +import { Arguments, TypeInvocation } from '../../../lib/dependencies/agent'; +import { CreateAgent, Initializer, initializable, agent } from '../../../lib/dependencies/agent'; describe('5.7. Domain @initializable decorator', () => { describe('# should able to', () => { diff --git a/test/v2/5.domain/5.8.domain-inject.test.ts b/test/v2/5.domain/5.8.domain-inject.test.ts index d58cffeb..9234979c 100644 --- a/test/v2/5.domain/5.8.domain-inject.test.ts +++ b/test/v2/5.domain/5.8.domain-inject.test.ts @@ -1,5 +1,5 @@ -import { Reflector, CreateAgent } from '../../../src/dependencies/agent'; -import { InMemoryDomain, agent, inject } from '../../../src/dependencies/domain'; +import { Reflector, CreateAgent } from '../../../lib/dependencies/agent'; +import { InMemoryDomain, agent, inject } from '../../../lib/dependencies/domain'; describe('5.8. Domain @inject decorator', () => { describe('# should able to', () => { diff --git a/test/v2/5.domain/5.9.domain-singleton.test.ts b/test/v2/5.domain/5.9.domain-singleton.test.ts index 43749dce..49eb4d88 100644 --- a/test/v2/5.domain/5.9.domain-singleton.test.ts +++ b/test/v2/5.domain/5.9.domain-singleton.test.ts @@ -5,8 +5,8 @@ import { Reflector, AgentFrameworkError, CreateAgent, -} from '../../../src/dependencies/agent'; -import { InMemoryDomain, agent, singleton } from '../../../src/dependencies/domain'; +} from '../../../lib/dependencies/agent'; +import { InMemoryDomain, agent, singleton } from '../../../lib/dependencies/domain'; describe('5.9. Domain @singleton decorator', () => { describe('# should able to', () => { diff --git a/test/v2/6.decorators/6.1.initializable.test.ts b/test/v2/6.decorators/6.1.initializable.test.ts index dced5a38..028d2aaf 100644 --- a/test/v2/6.decorators/6.1.initializable.test.ts +++ b/test/v2/6.decorators/6.1.initializable.test.ts @@ -1,5 +1,5 @@ -import { Arguments, TypeInvocation } from '../../../src/dependencies/agent'; -import { CreateAgent, Initializer, initializable, agent } from '../../../src/dependencies/agent'; +import { Arguments, TypeInvocation } from '../../../lib/dependencies/agent'; +import { CreateAgent, Initializer, initializable, agent } from '../../../lib/dependencies/agent'; describe('6.1. @initializable decorator', () => { describe('# should able to', () => { diff --git a/test/v2/6.decorators/6.10.parameter-decorator.test.ts b/test/v2/6.decorators/6.10.parameter-decorator.test.ts index 55050906..b133e4c3 100644 --- a/test/v2/6.decorators/6.10.parameter-decorator.test.ts +++ b/test/v2/6.decorators/6.10.parameter-decorator.test.ts @@ -1,4 +1,4 @@ -import { decorateMember, decorateParameter, MemberKinds, Reflector } from '../../../src/dependencies/agent'; +import { decorateMember, decorateParameter, MemberKinds, Reflector } from '../../../lib/dependencies/agent'; describe('6.10. Parameter decorator', () => { describe('# should able to', () => { diff --git a/test/v2/6.decorators/6.3.singleton.test.ts b/test/v2/6.decorators/6.3.singleton.test.ts index 0362173c..10bb9f95 100644 --- a/test/v2/6.decorators/6.3.singleton.test.ts +++ b/test/v2/6.decorators/6.3.singleton.test.ts @@ -7,7 +7,7 @@ import { Reflector, AgentFrameworkError, CreateAgent, -} from '../../../src/dependencies/agent'; +} from '../../../lib/dependencies/agent'; describe('6.3. @singleton decorator', () => { describe('# should able to', () => { diff --git a/test/v2/6.decorators/6.4.transit.test.ts b/test/v2/6.decorators/6.4.transit.test.ts index bcb7d8eb..b480d631 100644 --- a/test/v2/6.decorators/6.4.transit.test.ts +++ b/test/v2/6.decorators/6.4.transit.test.ts @@ -1,4 +1,4 @@ -import { CreateAgent, Reflector, agent, transit } from '../../../src/dependencies/agent'; +import { CreateAgent, Reflector, agent, transit } from '../../../lib/dependencies/agent'; describe('6.4. @transit decorator', () => { describe('# should able to', () => { diff --git a/test/v2/6.decorators/6.5.once.test.ts b/test/v2/6.decorators/6.5.once.test.ts index 72757d86..76d3a235 100644 --- a/test/v2/6.decorators/6.5.once.test.ts +++ b/test/v2/6.decorators/6.5.once.test.ts @@ -1,4 +1,4 @@ -import { Once, once } from '../../../src/dependencies/agent'; +import { Once, once } from '../../../lib/dependencies/agent'; describe('6.5. @once helper', () => { describe('# should able to', () => { diff --git a/test/v2/6.decorators/6.6.remember.test.ts b/test/v2/6.decorators/6.6.remember.test.ts index 604c9c34..f2a0fc84 100644 --- a/test/v2/6.decorators/6.6.remember.test.ts +++ b/test/v2/6.decorators/6.6.remember.test.ts @@ -1,4 +1,4 @@ -import { Remember, remember } from '../../../src/dependencies/agent'; +import { Remember, remember } from '../../../lib/dependencies/agent'; describe('6.6. @remember helper', () => { describe('# should able to', () => { diff --git a/test/v2/6.decorators/6.7.exclusive.test.ts b/test/v2/6.decorators/6.7.exclusive.test.ts index 796db715..55392d4d 100644 --- a/test/v2/6.decorators/6.7.exclusive.test.ts +++ b/test/v2/6.decorators/6.7.exclusive.test.ts @@ -1,4 +1,4 @@ -import { exclusive } from '../../../src/dependencies/agent'; +import { exclusive } from '../../../lib/dependencies/agent'; describe('6.7. @exclusive decorator', () => { describe('# should able to', () => { diff --git a/test/v2/6.decorators/6.8.interceptable.test.ts b/test/v2/6.decorators/6.8.interceptable.test.ts index 31626d15..a55436b2 100644 --- a/test/v2/6.decorators/6.8.interceptable.test.ts +++ b/test/v2/6.decorators/6.8.interceptable.test.ts @@ -1,4 +1,4 @@ -import { decorateMember, Invocation, Arguments, agent, decorateAgent, Reflector } from '../../../src/dependencies/agent'; +import { decorateMember, Invocation, Arguments, agent, decorateAgent, Reflector } from '../../../lib/dependencies/agent'; describe('6.8. @interceptable decorator', () => { describe('# should able to', () => { diff --git a/test/v2/7.helpers/7.2.__agent.test.ts b/test/v2/7.helpers/7.2.__agent.test.ts index 5db82eb8..e21ccdc9 100644 --- a/test/v2/7.helpers/7.2.__agent.test.ts +++ b/test/v2/7.helpers/7.2.__agent.test.ts @@ -1,4 +1,4 @@ -import { __agent } from '../../../src/dependencies/core'; +import { __agent } from '../../../lib/dependencies/core'; class ClassA {} diff --git a/test/v2/7.helpers/7.3.__decorate.test.ts b/test/v2/7.helpers/7.3.__decorate.test.ts index aef1ac93..a9866d3a 100644 --- a/test/v2/7.helpers/7.3.__decorate.test.ts +++ b/test/v2/7.helpers/7.3.__decorate.test.ts @@ -1,4 +1,4 @@ -import { __decorate } from '../../../src/dependencies/core'; +import { __decorate } from '../../../lib/dependencies/core'; class ClassA { run(): void {} diff --git a/test/v2/7.helpers/7.4.__metadata.test.ts b/test/v2/7.helpers/7.4.__metadata.test.ts index 872cf627..1b17bf5d 100644 --- a/test/v2/7.helpers/7.4.__metadata.test.ts +++ b/test/v2/7.helpers/7.4.__metadata.test.ts @@ -1,5 +1,5 @@ -import { __agent, __decorate, __metadata, __param } from '../../../src/dependencies/core'; -import { MemberKinds, Reflector } from '../../../src/dependencies/agent'; +import { __agent, __decorate, __metadata, __param } from '../../../lib/dependencies/core'; +import { MemberKinds, Reflector } from '../../../lib/dependencies/agent'; class ClassA { run(num: Number, name: string): boolean { diff --git a/test/v2/Kinds.ts b/test/v2/Kinds.ts index 9def680e..d1b6edb3 100644 --- a/test/v2/Kinds.ts +++ b/test/v2/Kinds.ts @@ -1,4 +1,4 @@ -import { MemberKinds } from '../../src/dependencies/agent'; +import { MemberKinds } from '../../lib/dependencies/agent'; export const ClassField = MemberKinds.Property; // | MemberKinds.Field; export const ClassMethod = MemberKinds.Property; //| MemberKinds.Method; diff --git a/test/v3/1.general/1.hello-world.test.ts b/test/v3/1.general/1.hello-world.test.ts new file mode 100644 index 00000000..bc6e6121 --- /dev/null +++ b/test/v3/1.general/1.hello-world.test.ts @@ -0,0 +1,26 @@ +import { agent, transit } from 'agentframework'; + +describe('Hello world!', () => { + describe('# should able to', () => { + it('run homepage example using @agent decorator', () => { + class ComponentA { + name = 'Agent Framework'; + } + + // @agent decorator will upgrade this class to an agent + // without @agent decorator the @transit will take no effect + @agent() + class ProjectA { + // @transit decorator creates a new instance of ComponentA + // and assign to component field + @transit() + readonly component!: ComponentA; + } + + const project = new ProjectA(); + + expect(project).toBeInstanceOf(ProjectA); + expect(project.component.name).toBe('Agent Framework'); + }); + }); +}); diff --git a/tools/jasmine.debug.json b/tools/jasmine.debug.json deleted file mode 100644 index 08768841..00000000 --- a/tools/jasmine.debug.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "spec_dir": ".", - "spec_files": ["test/v2/1.general/5.property-interceptor-seq.test.ts"], - "stopSpecOnExpectationFailure": false, - "random": false -} diff --git a/tools/jasmine.json b/tools/jasmine.json deleted file mode 100644 index 4a465547..00000000 --- a/tools/jasmine.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "spec_dir": ".", - "spec_files": ["src/**/*.[Ss]pec.ts", "src/**/*.[Tt]est.ts", "test/v1/**/*.[Ss]pec.ts", "test/v2/**/*.[Ss]pec.ts", "test/v1/**/*.[Ss]pec.ts", "test/v2/**/*.[Ss]pec.ts", "test/v1/**/*.[Ss]pec.ts", "test/v2/**/*.[Ss]pec.ts", "test/v1/**/*.[Tt]est.ts", "test/v2/**/*.[Tt]est.ts"], - "stopSpecOnExpectationFailure": false, - "random": false, - "displayDuration": true -} diff --git a/tools/jasmine.spec.json b/tools/jasmine.spec.json deleted file mode 100644 index 222b576f..00000000 --- a/tools/jasmine.spec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "spec_dir": ".", - "spec_files": ["src/**/*.[Ss]pec.ts", "test/v1/**/*.[Ss]pec.ts", "test/v2/**/*.[Ss]pec.ts"], - "stopSpecOnExpectationFailure": false, - "random": false -} diff --git a/tools/jasmine.ts b/tools/jasmine.ts deleted file mode 100644 index 26c02ea5..00000000 --- a/tools/jasmine.ts +++ /dev/null @@ -1,56 +0,0 @@ -declare function require(name: string): any; -declare const process: any; - -// require('reflect-metadata'); -const fs = require('fs'); -const path = require('path'); -const Jasmine = require('jasmine'); -const Command = require('jasmine/lib/command'); -// const SpecReporter = require('jasmine-spec-reporter').SpecReporter; - -const engine = new Jasmine({ projectBaseDir: path.resolve() }); -const examplesDir = path.join('node_modules', 'jasmine-core', 'lib', 'jasmine-core', 'example', 'node_example'); -const command = new Command(path.resolve(), examplesDir, console.log); -const commandOptions = process.argv.slice(2).find((option: any) => option.startsWith('--config=')); -const configPath = commandOptions ? commandOptions.slice(9) : process.env.JASMINE_CONFIG_PATH; - -if (!configPath) { - throw new Error('No config file found'); -} - -const initReporters = (config: any) => { - // jasmine.env.clearReporters(); - if (config.reporters && config.reporters.length > 0) { - engine.env.clearReporters(); - config.reporters.forEach((reporter: { name: string; options: any }) => { - const parts = reporter.name.split('#'); - const name = parts[0]; - const member = parts[1]; - const reporterClass = member ? require(name)[member] : require(name); - engine.addReporter(new reporterClass(reporter.options)); - }); - } else { - // jasmine.addReporter( - // new SpecReporter({ - // // add jasmine-spec-reporter - // spec: { - // displayPending: true - // } - // }) - // ); - } -}; - -let configJSON: string = ''; -try { - configJSON = fs.readFileSync(path.resolve(configPath as string), 'utf8'); -} catch (e) { - throw new Error('Invalid config file: ' + configPath); -} - -if (configJSON) { - const config = JSON.parse(configJSON); - initReporters(config); -} - -command.run(engine, [commandOptions]); diff --git a/tools/vitest.config.full.ts b/tools/vitest.config.full.ts new file mode 100644 index 00000000..64475f0d --- /dev/null +++ b/tools/vitest.config.full.ts @@ -0,0 +1,25 @@ +import { defineConfig } from 'vitest/config'; +import * as path from 'node:path'; + +export default defineConfig({ + resolve: { + alias: { + agentframework: path.resolve(__dirname, './lib/index'), + '@agentframework/core': path.resolve(__dirname, './src/dependencies/core'), + '@agentframework/agent': path.resolve(__dirname, './src/dependencies/agent'), + '@agentframework/domain': path.resolve(__dirname, './src/dependencies/domain'), + }, + }, + test: { + environment: 'node', + globals: true, + coverage: { + reporter: ['text', 'html'], // 可选: 'lcov', 'json', 'clover', 'text-summary' + include: ['lib', 'src'], + exclude: ['node_modules/', 'test/', 'tools/'], // 排除不想计算覆盖率的文件 + all: true, // 即使文件没有被 import,也会列出覆盖率 + }, + // include: ['src/**/*.[Ss]pec.ts', 'test/**/*.[Tt]est.ts'], + include: ['src/core/Core/Knowledge.Spec.ts'], + }, +}); diff --git a/tools/vitest.config.spec.ts b/tools/vitest.config.spec.ts new file mode 100644 index 00000000..1285f9d4 --- /dev/null +++ b/tools/vitest.config.spec.ts @@ -0,0 +1,24 @@ +import { defineConfig } from 'vitest/config'; +import * as path from 'node:path'; + +export default defineConfig({ + resolve: { + alias: { + agentframework: path.resolve(__dirname, './lib/index'), + '@agentframework/core': path.resolve(__dirname, './src/dependencies/core'), + '@agentframework/agent': path.resolve(__dirname, './src/dependencies/agent'), + '@agentframework/domain': path.resolve(__dirname, './src/dependencies/domain'), + }, + }, + test: { + environment: 'node', + globals: true, + coverage: { + reporter: ['text', 'html'], // 可选: 'lcov', 'json', 'clover', 'text-summary' + include: ['lib', 'src'], + exclude: ['node_modules/', 'test/', 'tools/'], // 排除不想计算覆盖率的文件 + all: true, // 即使文件没有被 import,也会列出覆盖率 + }, + include: ['src/**/*.[Ss]pec.ts'], + }, +}); diff --git a/tools/vitest.config.ts b/tools/vitest.config.ts new file mode 100644 index 00000000..2eb36681 --- /dev/null +++ b/tools/vitest.config.ts @@ -0,0 +1,26 @@ +import { defineConfig } from 'vitest/config'; +import * as path from 'node:path'; + +export default defineConfig({ + resolve: { + alias: { + agentframework: path.resolve(__dirname, '../lib/index'), + '@agentframework/core': path.resolve(__dirname, '../src/dependencies/core'), + '@agentframework/agent': path.resolve(__dirname, '../src/dependencies/agent'), + '@agentframework/domain': path.resolve(__dirname, '../src/dependencies/domain'), + }, + }, + test: { + environment: 'node', + globals: true, + coverage: { + reporter: ['text', 'html'], // 可选: 'lcov', 'json', 'clover', 'text-summary' + include: ['lib', 'src'], + exclude: ['node_modules/', 'test/', 'tools/'], // 排除不想计算覆盖率的文件 + all: true, // 即使文件没有被 import,也会列出覆盖率 + }, + // include: ['src/agent/**/*.[Ss]pec.ts'], + // include: ['test/v3/1.general/**/*.[Tt]est.ts'], + include: ['src/core/**/*.[Ss]pec.ts'], + }, +}); diff --git a/tsconfig.json b/tsconfig.json index 0d500a15..2d96628b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,25 +1,32 @@ { "compilerOptions": { - "target": "ES2015", - "lib": ["ES2015", "ES2015.Iterable", "ES2015.Collection", "dom"], - "module": "commonjs", - "moduleResolution": "node", + "target": "ES2022", + "lib": ["ES2022", "dom"], + "module": "ES2022", + "moduleResolution": "Bundler", + "strict": true, - "experimentalDecorators": true, - "emitDecoratorMetadata": true, + "forceConsistentCasingInFileNames": true, "noImplicitAny": true, - "noUnusedLocals": true, - "noImplicitThis": true, - "strictNullChecks": true, "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, "preserveConstEnums": true, - "forceConsistentCasingInFileNames": true, - "allowSyntheticDefaultImports": true, + "strictNullChecks": true, "stripInternal": true, + + "allowImportingTsExtensions": true, + + "emitDecoratorMetadata": false, + "experimentalDecorators": false, + "useDefineForClassFields": true, + "baseUrl": "./", "paths": { - "agentframework": ["src/core/index"] - } + "agentframework": ["lib/index"], + "@agentframework/*": ["lib/dependencies/*"] + }, + "types": ["node", "vitest/globals"] }, "include": ["lib", "src", "test", "tools"], "exclude": ["node_modules"] diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 00000000..bbdd6d85 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,2 @@ +import config from './tools/vitest.config'; +export default config;