@nestjs-dash/in-memory 0.0.1 → 1.0.0
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/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -4
- package/dist/index.js.map +1 -1
- package/package.json +12 -24
- package/README.md +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { InMemoryResource, type PropertyAdapter, type RecordData, type RelationDefinition } from '@nestjs-dash/adapter';
|
|
2
|
+
import { type ResourceClass } from '@nestjs-dash/core';
|
|
3
|
+
export type CreateInMemoryResourceFromModelOptions = {
|
|
4
|
+
id?: string;
|
|
5
|
+
records?: RecordData[];
|
|
6
|
+
relations?: RelationDefinition[];
|
|
7
|
+
resolveRelated?: (slug: string) => InMemoryResource | undefined;
|
|
8
|
+
softDeleteField?: string;
|
|
9
|
+
properties?: PropertyAdapter[];
|
|
10
|
+
};
|
|
11
|
+
export declare function createInMemoryResourceFromModel(resource: ResourceClass, options?: CreateInMemoryResourceFromModelOptions): InMemoryResource;
|
|
12
|
+
export { InMemoryDatabase, InMemoryProperty, InMemoryResource } from '@nestjs-dash/adapter';
|
|
2
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAChB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,sCAAsC,GAAG;IACnD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACjC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,gBAAgB,GAAG,SAAS,CAAC;IAEhE,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;CAChC,CAAC;AAcF,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE,sCAA2C,GACnD,gBAAgB,CA+BlB;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { InMemoryProperty, InMemoryResource, } from '@nestjs-dash/adapter';
|
|
2
|
+
import { relationsFromResource, resolveListQueryConfig, resolveResourceSlug, Table, } from '@nestjs-dash/core';
|
|
3
|
+
export function createInMemoryResourceFromModel(resource, options = {}) {
|
|
4
|
+
const id = options.id ?? resolveResourceSlug(resource);
|
|
5
|
+
const columnNames = typeof resource.table === 'function'
|
|
6
|
+
? resource
|
|
7
|
+
.table(Table.make())
|
|
8
|
+
.toSchema()
|
|
9
|
+
.columns.map((column) => String(column.name ?? ''))
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
: [];
|
|
12
|
+
const properties = options.properties ??
|
|
13
|
+
(columnNames.length
|
|
14
|
+
? columnNames.map((name) => new InMemoryProperty(name, 'mixed', { id: name === 'id' }))
|
|
15
|
+
: [new InMemoryProperty('id', 'string', { id: true })]);
|
|
16
|
+
const listQueryConfig = resolveListQueryConfig(resource, properties.map((property) => property.name()), undefined, properties);
|
|
17
|
+
return new InMemoryResource(id, properties, options.records ?? [], {
|
|
18
|
+
relations: options.relations ?? relationsFromResource(resource),
|
|
19
|
+
resolveRelated: options.resolveRelated,
|
|
20
|
+
softDeleteField: options.softDeleteField,
|
|
21
|
+
defaultConfig: listQueryConfig,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export { InMemoryDatabase, InMemoryProperty, InMemoryResource } from '@nestjs-dash/adapter';
|
|
5
25
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GAIjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,GAEN,MAAM,mBAAmB,CAAC;AAyB3B,MAAM,UAAU,+BAA+B,CAC7C,QAAuB,EACvB,UAAkD,EAAE;IAEpD,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAEvD,MAAM,WAAW,GACf,OAAO,QAAQ,CAAC,KAAK,KAAK,UAAU;QAClC,CAAC,CAAC,QAAQ;aACP,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;aACnB,QAAQ,EAAE;aACV,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;aAClD,MAAM,CAAC,OAAO,CAAC;QAClB,CAAC,CAAC,EAAE,CAAC;IAET,MAAM,UAAU,GACd,OAAO,CAAC,UAAU;QAClB,CAAC,WAAW,CAAC,MAAM;YACjB,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC;YACvF,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAE5D,MAAM,eAAe,GAAG,sBAAsB,CAC5C,QAAQ,EACR,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAC7C,SAAS,EACT,UAAU,CACX,CAAC;IAEF,OAAO,IAAI,gBAAgB,CAAC,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE;QACjE,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,qBAAqB,CAAC,QAAQ,CAAC;QAC/D,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,aAAa,EAAE,eAAe;KAC/B,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs-dash/in-memory",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "Zero-setup in-memory adapter for
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Zero-setup in-memory adapter for NestJS Dash — the reference ResourceAdapter implementation the conformance suite checks every other adapter against",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/nestjs-dash/in-memory.git"
|
|
9
|
-
},
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/nestjs-dash/in-memory/issues"
|
|
12
|
-
},
|
|
13
|
-
"homepage": "https://github.com/nestjs-dash/in-memory#readme",
|
|
14
6
|
"files": [
|
|
15
7
|
"dist"
|
|
16
8
|
],
|
|
@@ -22,9 +14,16 @@
|
|
|
22
14
|
}
|
|
23
15
|
},
|
|
24
16
|
"publishConfig": {
|
|
25
|
-
"access": "public"
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@nestjs-dash/adapter": "1.0.0",
|
|
21
|
+
"@nestjs-dash/core": "1.0.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@nestjs-dash/typescript-config": "0.1.0",
|
|
25
|
+
"typescript": "6.0.3",
|
|
26
|
+
"vitest": "^5.0.0"
|
|
28
27
|
},
|
|
29
28
|
"scripts": {
|
|
30
29
|
"build": "tsc -p tsconfig.json",
|
|
@@ -33,17 +32,6 @@
|
|
|
33
32
|
"lint": "oxlint src",
|
|
34
33
|
"test": "vitest run",
|
|
35
34
|
"test:coverage": "vitest run --coverage",
|
|
36
|
-
"release": "release-it",
|
|
37
35
|
"dev": "tsc -p tsconfig.json --watch"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/node": "^26.5.1",
|
|
41
|
-
"@vitest/coverage-v8": "5.0.0",
|
|
42
|
-
"oxfmt": "^0.67.0",
|
|
43
|
-
"oxlint": "^1.82.0",
|
|
44
|
-
"typescript": "7.0.2",
|
|
45
|
-
"vitest": "^5.0.0",
|
|
46
|
-
"release-it": "^21.0.2",
|
|
47
|
-
"@release-it/conventional-changelog": "^12.0.0"
|
|
48
36
|
}
|
|
49
37
|
}
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# @nestjs-dash/prisma
|