@xylabs/creatable 5.0.34 → 5.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -8
- package/dist/neutral/spec/TestCreatable.spec.d.ts +0 -13
- package/dist/neutral/spec/TestCreatable.spec.d.ts.map +0 -1
- package/dist/neutral/spec/TestCreatable2.spec.d.ts +0 -2
- package/dist/neutral/spec/TestCreatable2.spec.d.ts.map +0 -1
- package/src/spec/TestCreatable.spec.ts +0 -40
- package/src/spec/TestCreatable2.spec.ts +0 -61
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/creatable",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.36",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -32,15 +32,18 @@
|
|
|
32
32
|
"types": "./dist/neutral/index.d.ts",
|
|
33
33
|
"files": [
|
|
34
34
|
"dist",
|
|
35
|
-
"src"
|
|
35
|
+
"src",
|
|
36
|
+
"!**/*.bench.*",
|
|
37
|
+
"!**/*.spec.*",
|
|
38
|
+
"!**/*.test.*"
|
|
36
39
|
],
|
|
37
40
|
"dependencies": {
|
|
38
|
-
"@xylabs/assert": "~5.0.
|
|
39
|
-
"@xylabs/base": "~5.0.
|
|
40
|
-
"@xylabs/events": "~5.0.
|
|
41
|
-
"@xylabs/logger": "~5.0.
|
|
42
|
-
"@xylabs/promise": "~5.0.
|
|
43
|
-
"@xylabs/typeof": "~5.0.
|
|
41
|
+
"@xylabs/assert": "~5.0.36",
|
|
42
|
+
"@xylabs/base": "~5.0.36",
|
|
43
|
+
"@xylabs/events": "~5.0.36",
|
|
44
|
+
"@xylabs/logger": "~5.0.36",
|
|
45
|
+
"@xylabs/promise": "~5.0.36",
|
|
46
|
+
"@xylabs/typeof": "~5.0.36",
|
|
44
47
|
"async-mutex": "~0.5.0"
|
|
45
48
|
},
|
|
46
49
|
"devDependencies": {
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { EventData } from '@xylabs/events';
|
|
2
|
-
import { Promisable } from '@xylabs/promise';
|
|
3
|
-
import { AbstractCreatable } from '../AbstractCreatable.ts';
|
|
4
|
-
import { Creatable } from '../Creatable.ts';
|
|
5
|
-
import { CreatableInstance, CreatableParams, RequiredCreatableParams } from '../model/index.ts';
|
|
6
|
-
export interface TestCreatableParams extends CreatableParams {
|
|
7
|
-
testParam: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class TestCreatable<TParams extends TestCreatableParams = TestCreatableParams, TEventData extends EventData = EventData> extends AbstractCreatable<TParams, TEventData> {
|
|
10
|
-
static createHandler<T extends CreatableInstance>(this: Creatable<T>, instance: T): Promisable<T>;
|
|
11
|
-
paramsValidator(params?: Partial<TParams & RequiredCreatableParams>): TParams;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=TestCreatable.spec.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TestCreatable.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/TestCreatable.spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAK5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAa,MAAM,iBAAiB,CAAA;AACtD,OAAO,EACL,iBAAiB,EAAE,eAAe,EAAE,uBAAuB,EAC5D,MAAM,mBAAmB,CAAA;AAE1B,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,qBACa,aAAa,CAAC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,EAAE,UAAU,SAAS,SAAS,GAAG,SAAS,CAC5H,SAAQ,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC;WAC9B,aAAa,CAAC,CAAC,SAAS,iBAAiB,EACvD,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAClB,QAAQ,EAAE,CAAC,GACV,UAAU,CAAC,CAAC,CAAC;IAIP,eAAe,CAAC,MAAM,GAAE,OAAO,CAAC,OAAO,GAAG,uBAAuB,CAAM,GAAG,OAAO;CAM3F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TestCreatable2.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/TestCreatable2.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { EventData } from '@xylabs/events'
|
|
2
|
-
import { Promisable } from '@xylabs/promise'
|
|
3
|
-
import {
|
|
4
|
-
describe, expect, test,
|
|
5
|
-
} from 'vitest'
|
|
6
|
-
|
|
7
|
-
import { AbstractCreatable } from '../AbstractCreatable.ts'
|
|
8
|
-
import { Creatable, creatable } from '../Creatable.ts'
|
|
9
|
-
import {
|
|
10
|
-
CreatableInstance, CreatableParams, RequiredCreatableParams,
|
|
11
|
-
} from '../model/index.ts'
|
|
12
|
-
|
|
13
|
-
export interface TestCreatableParams extends CreatableParams {
|
|
14
|
-
testParam: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@creatable()
|
|
18
|
-
export class TestCreatable<TParams extends TestCreatableParams = TestCreatableParams, TEventData extends EventData = EventData>
|
|
19
|
-
extends AbstractCreatable<TParams, TEventData> {
|
|
20
|
-
static override createHandler<T extends CreatableInstance>(
|
|
21
|
-
this: Creatable<T>,
|
|
22
|
-
instance: T,
|
|
23
|
-
): Promisable<T> {
|
|
24
|
-
return instance
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
override paramsValidator(params: Partial<TParams & RequiredCreatableParams> = {}): TParams {
|
|
28
|
-
const result: TestCreatableParams = {
|
|
29
|
-
...params, name: params.name ?? this.constructor.name, testParam: 'yo',
|
|
30
|
-
}
|
|
31
|
-
return result as TParams
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
describe('TestCreatable', () => {
|
|
36
|
-
test('should create an instance with default params', async () => {
|
|
37
|
-
const instance = await TestCreatable.create()
|
|
38
|
-
expect(instance).toBeDefined()
|
|
39
|
-
})
|
|
40
|
-
})
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { EventData } from '@xylabs/events'
|
|
2
|
-
import { Promisable } from '@xylabs/promise'
|
|
3
|
-
import {
|
|
4
|
-
describe, expect, test,
|
|
5
|
-
} from 'vitest'
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
Creatable, creatable, creatableFactory,
|
|
9
|
-
} from '../Creatable.ts'
|
|
10
|
-
import { CreatableInstance, RequiredCreatableParams } from '../model/index.ts'
|
|
11
|
-
import { TestCreatable, TestCreatableParams } from './TestCreatable.spec.ts'
|
|
12
|
-
|
|
13
|
-
interface TestCreatableParams2 extends TestCreatableParams {
|
|
14
|
-
testParam2: number
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@creatable()
|
|
18
|
-
class TestCreatable2<TParams extends TestCreatableParams2 = TestCreatableParams2, TEventData extends EventData = EventData>
|
|
19
|
-
extends TestCreatable<TParams, TEventData> {
|
|
20
|
-
static override createHandler<T extends CreatableInstance>(
|
|
21
|
-
this: Creatable<T>,
|
|
22
|
-
instance: T,
|
|
23
|
-
): Promisable<T> {
|
|
24
|
-
return instance
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
override paramsValidator(params: Partial<TParams & RequiredCreatableParams> = {}): TParams {
|
|
28
|
-
const result: TestCreatableParams = {
|
|
29
|
-
...params, name: params.name ?? this.constructor.name, testParam: 'yo',
|
|
30
|
-
}
|
|
31
|
-
return result as TParams
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@creatableFactory()
|
|
36
|
-
class TestCreatable2a<TParams extends TestCreatableParams2 = TestCreatableParams2, TEventData extends EventData = EventData>
|
|
37
|
-
extends TestCreatable<TParams, TEventData> {
|
|
38
|
-
static override createHandler<T extends CreatableInstance>(
|
|
39
|
-
this: Creatable<T>,
|
|
40
|
-
instance: T,
|
|
41
|
-
): Promisable<T> {
|
|
42
|
-
return instance
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// const factory = TestCreatable2.factory()
|
|
47
|
-
|
|
48
|
-
describe('TestCreatable2', () => {
|
|
49
|
-
test('should create an instance with default params', async () => {
|
|
50
|
-
const instance = await TestCreatable2.create()
|
|
51
|
-
expect(instance).toBeDefined()
|
|
52
|
-
})
|
|
53
|
-
test('should create an instance with default params as factory', async () => {
|
|
54
|
-
const instance = await TestCreatable2a.create()
|
|
55
|
-
expect(instance).toBeDefined()
|
|
56
|
-
})
|
|
57
|
-
/* test('should create an instance with default params from factory', async () => {
|
|
58
|
-
const instance = await factory.create()
|
|
59
|
-
expect(instance).toBeDefined()
|
|
60
|
-
}) */
|
|
61
|
-
})
|