@sneat/data 0.1.3 → 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.
@@ -0,0 +1,3 @@
1
+ export * from './lib/record';
2
+ export * from './lib/modified';
3
+ //# sourceMappingURL=index.js.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=modified.js.map
@@ -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,5 @@
1
+ import { map } from 'rxjs/operators';
2
+ export function mapToRecord(state = 'unchanged') {
3
+ return map((dto) => ({ id: dto.id, dbo: dto, state }));
4
+ }
5
+ //# sourceMappingURL=record.js.map
@@ -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,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './index';
5
+ //# sourceMappingURL=sneat-data.js.map
@@ -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"]}
@@ -0,0 +1,4 @@
1
+ export interface Modified {
2
+ by: string;
3
+ on: string;
4
+ }
@@ -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",
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
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="@sneat/data" />
5
+ export * from './index';
package/eslint.config.js DELETED
@@ -1,7 +0,0 @@
1
- const baseConfig = require('../../eslint.config.js');
2
- const { sneatLibConfig } = require('../../eslint.lib.config.js');
3
-
4
- module.exports = [
5
- ...baseConfig,
6
- ...sneatLibConfig(__dirname),
7
- ];
package/ng-package.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist/libs/data",
4
- "lib": {
5
- "entryFile": "src/index.ts"
6
- }
7
- }
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
- }
@@ -1,4 +0,0 @@
1
- export interface Modified {
2
- by: string;
3
- on: string;
4
- }
@@ -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
@@ -1,3 +0,0 @@
1
- import { setupTestEnvironment } from '@sneat/core/testing';
2
-
3
- setupTestEnvironment();
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.angular.json",
3
- "files": [],
4
- "include": [],
5
- "references": [
6
- {
7
- "path": "./tsconfig.lib.json"
8
- },
9
- {
10
- "path": "./tsconfig.spec.json"
11
- }
12
- ]
13
- }
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
- }
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "./tsconfig.lib.json",
3
- "compilerOptions": {
4
- "declarationMap": false
5
- },
6
- "angularCompilerOptions": {}
7
- }
@@ -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
@@ -1,10 +0,0 @@
1
- /// <reference types='vitest' />
2
- import { defineConfig } from 'vitest/config';
3
- import { createBaseViteConfig } from '../../vite.config.base';
4
-
5
- export default defineConfig(() =>
6
- createBaseViteConfig({
7
- dirname: __dirname,
8
- name: 'data',
9
- }),
10
- );
File without changes