@sneat/data 0.1.2 → 0.1.4
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/esm2022/index.js +3 -0
- package/esm2022/index.js.map +1 -0
- package/esm2022/lib/modified.js +2 -0
- package/esm2022/lib/modified.js.map +1 -0
- package/esm2022/lib/record.js +5 -0
- package/esm2022/lib/record.js.map +1 -0
- package/esm2022/sneat-data.js +5 -0
- package/esm2022/sneat-data.js.map +1 -0
- package/lib/modified.d.ts +4 -0
- package/lib/record.d.ts +11 -0
- package/package.json +14 -2
- package/sneat-data.d.ts +5 -0
- package/eslint.config.js +0 -7
- package/ng-package.json +0 -7
- package/project.json +0 -38
- package/src/lib/modified.ts +0 -4
- package/src/lib/record.spec.ts +0 -26
- package/src/lib/record.ts +0 -28
- package/src/test-setup.ts +0 -3
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -19
- package/tsconfig.lib.prod.json +0 -7
- package/tsconfig.spec.json +0 -31
- package/vite.config.mts +0 -10
- /package/{src/index.ts → index.d.ts} +0 -0
package/esm2022/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/data/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './lib/record';\nexport * from './lib/modified';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modified.js","sourceRoot":"","sources":["../../../../../libs/data/src/lib/modified.ts"],"names":[],"mappings":"","sourcesContent":["export interface Modified {\n by: string;\n on: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../../../libs/data/src/lib/record.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAMrC,MAAM,UAAU,WAAW,CACzB,QAAqB,WAAW;IAEhC,OAAO,GAAG,CACR,CAAC,GAAM,EAAc,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAY,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CACpE,CAAC;AACJ,CAAC","sourcesContent":["import { OperatorFunction } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nexport interface MightHaveId {\n id?: string;\n}\n\nexport function mapToRecord<T extends MightHaveId>(\n state: RecordState = 'unchanged',\n): OperatorFunction<T, IRecord<T>> {\n return map(\n (dto: T): IRecord<T> => ({ id: dto.id as string, dbo: dto, state }),\n );\n}\n\nexport interface IRecord<T> {\n readonly id: string;\n readonly dbo?: T;\n readonly state?: RecordState; // undefined == 'unchanged';\n}\n\nexport type RecordState =\n | 'changed'\n | 'creating'\n | 'deleting'\n | 'loading'\n | 'unchanged'\n | 'updating';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sneat-data.js","sourceRoot":"","sources":["../../../../libs/data/src/sneat-data.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC","sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"]}
|
package/lib/record.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OperatorFunction } from 'rxjs';
|
|
2
|
+
export interface MightHaveId {
|
|
3
|
+
id?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function mapToRecord<T extends MightHaveId>(state?: RecordState): OperatorFunction<T, IRecord<T>>;
|
|
6
|
+
export interface IRecord<T> {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly dbo?: T;
|
|
9
|
+
readonly state?: RecordState;
|
|
10
|
+
}
|
|
11
|
+
export type RecordState = 'changed' | 'creating' | 'deleting' | 'loading' | 'unchanged' | 'updating';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sneat/data",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -10,5 +10,17 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"tslib": "2.8.1"
|
|
13
|
-
}
|
|
13
|
+
},
|
|
14
|
+
"module": "esm2022/sneat-data.js",
|
|
15
|
+
"typings": "sneat-data.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
"./package.json": {
|
|
18
|
+
"default": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./sneat-data.d.ts",
|
|
22
|
+
"default": "./esm2022/sneat-data.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"sideEffects": false
|
|
14
26
|
}
|
package/sneat-data.d.ts
ADDED
package/eslint.config.js
DELETED
package/ng-package.json
DELETED
package/project.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "data",
|
|
3
|
-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"projectType": "library",
|
|
5
|
-
"sourceRoot": "libs/data/src",
|
|
6
|
-
"prefix": "sneat",
|
|
7
|
-
"targets": {
|
|
8
|
-
"build": {
|
|
9
|
-
"executor": "@nx/angular:ng-packagr-lite",
|
|
10
|
-
"outputs": [
|
|
11
|
-
"{workspaceRoot}/dist/libs/data"
|
|
12
|
-
],
|
|
13
|
-
"options": {
|
|
14
|
-
"project": "libs/data/ng-package.json",
|
|
15
|
-
"tsConfig": "libs/data/tsconfig.lib.json"
|
|
16
|
-
},
|
|
17
|
-
"configurations": {
|
|
18
|
-
"production": {
|
|
19
|
-
"tsConfig": "libs/data/tsconfig.lib.prod.json"
|
|
20
|
-
},
|
|
21
|
-
"development": {}
|
|
22
|
-
},
|
|
23
|
-
"defaultConfiguration": "production"
|
|
24
|
-
},
|
|
25
|
-
"test": {
|
|
26
|
-
"executor": "@nx/vitest:test",
|
|
27
|
-
"outputs": [
|
|
28
|
-
"{workspaceRoot}/coverage/libs/data"
|
|
29
|
-
],
|
|
30
|
-
"options": {
|
|
31
|
-
"tsConfig": "libs/data/tsconfig.spec.json"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"lint": {
|
|
35
|
-
"executor": "@nx/eslint:lint"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/lib/modified.ts
DELETED
package/src/lib/record.spec.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { firstValueFrom, of } from 'rxjs';
|
|
2
|
-
import { mapToRecord, MightHaveId, IRecord } from './record';
|
|
3
|
-
|
|
4
|
-
describe('record', () => {
|
|
5
|
-
describe('mapToRecord', () => {
|
|
6
|
-
it('should map a DTO to a record with default state', async () => {
|
|
7
|
-
const dto: MightHaveId = { id: 'test-id' };
|
|
8
|
-
const record: IRecord<MightHaveId> = await firstValueFrom(
|
|
9
|
-
of(dto).pipe(mapToRecord()),
|
|
10
|
-
);
|
|
11
|
-
expect(record.id).toBe('test-id');
|
|
12
|
-
expect(record.dbo).toBe(dto);
|
|
13
|
-
expect(record.state).toBe('unchanged');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should map a DTO to a record with specified state', async () => {
|
|
17
|
-
const dto: MightHaveId = { id: 'test-id' };
|
|
18
|
-
const record: IRecord<MightHaveId> = await firstValueFrom(
|
|
19
|
-
of(dto).pipe(mapToRecord('loading')),
|
|
20
|
-
);
|
|
21
|
-
expect(record.id).toBe('test-id');
|
|
22
|
-
expect(record.dbo).toBe(dto);
|
|
23
|
-
expect(record.state).toBe('loading');
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
package/src/lib/record.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { OperatorFunction } from 'rxjs';
|
|
2
|
-
import { map } from 'rxjs/operators';
|
|
3
|
-
|
|
4
|
-
export interface MightHaveId {
|
|
5
|
-
id?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function mapToRecord<T extends MightHaveId>(
|
|
9
|
-
state: RecordState = 'unchanged',
|
|
10
|
-
): OperatorFunction<T, IRecord<T>> {
|
|
11
|
-
return map(
|
|
12
|
-
(dto: T): IRecord<T> => ({ id: dto.id as string, dbo: dto, state }),
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface IRecord<T> {
|
|
17
|
-
readonly id: string;
|
|
18
|
-
readonly dbo?: T;
|
|
19
|
-
readonly state?: RecordState; // undefined == 'unchanged';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type RecordState =
|
|
23
|
-
| 'changed'
|
|
24
|
-
| 'creating'
|
|
25
|
-
| 'deleting'
|
|
26
|
-
| 'loading'
|
|
27
|
-
| 'unchanged'
|
|
28
|
-
| 'updating';
|
package/src/test-setup.ts
DELETED
package/tsconfig.json
DELETED
package/tsconfig.lib.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.lib.base.json",
|
|
3
|
-
"exclude": [
|
|
4
|
-
"vite.config.ts",
|
|
5
|
-
"vite.config.mts",
|
|
6
|
-
"vitest.config.ts",
|
|
7
|
-
"vitest.config.mts",
|
|
8
|
-
"src/**/*.test.ts",
|
|
9
|
-
"src/**/*.spec.ts",
|
|
10
|
-
"src/**/*.test.tsx",
|
|
11
|
-
"src/**/*.spec.tsx",
|
|
12
|
-
"src/**/*.test.js",
|
|
13
|
-
"src/**/*.spec.js",
|
|
14
|
-
"src/**/*.test.jsx",
|
|
15
|
-
"src/**/*.spec.jsx",
|
|
16
|
-
"src/test-setup.ts",
|
|
17
|
-
"src/lib/testing/**/*"
|
|
18
|
-
]
|
|
19
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
package/tsconfig.spec.json
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"types": [
|
|
6
|
-
"vitest/globals",
|
|
7
|
-
"vitest/importMeta",
|
|
8
|
-
"vite/client",
|
|
9
|
-
"node",
|
|
10
|
-
"vitest"
|
|
11
|
-
]
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
"vite.config.ts",
|
|
15
|
-
"vite.config.mts",
|
|
16
|
-
"vitest.config.ts",
|
|
17
|
-
"vitest.config.mts",
|
|
18
|
-
"src/**/*.test.ts",
|
|
19
|
-
"src/**/*.spec.ts",
|
|
20
|
-
"src/**/*.test.tsx",
|
|
21
|
-
"src/**/*.spec.tsx",
|
|
22
|
-
"src/**/*.test.js",
|
|
23
|
-
"src/**/*.spec.js",
|
|
24
|
-
"src/**/*.test.jsx",
|
|
25
|
-
"src/**/*.spec.jsx",
|
|
26
|
-
"src/**/*.d.ts"
|
|
27
|
-
],
|
|
28
|
-
"files": [
|
|
29
|
-
"src/test-setup.ts"
|
|
30
|
-
]
|
|
31
|
-
}
|
package/vite.config.mts
DELETED
|
File without changes
|