@verdant-web/store 3.0.6 → 3.1.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/bundle/index.js +6 -6
- package/dist/bundle/index.js.map +4 -4
- package/dist/cjs/__tests__/fixtures/testStorage.d.ts +52 -105
- package/dist/cjs/__tests__/fixtures/testStorage.js +36 -65
- package/dist/cjs/__tests__/fixtures/testStorage.js.map +1 -1
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/__tests__/fixtures/testStorage.d.ts +52 -105
- package/dist/esm/__tests__/fixtures/testStorage.js +37 -66
- package/dist/esm/__tests__/fixtures/testStorage.js.map +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/__tests__/fixtures/testStorage.ts +37 -66
- package/src/entities/EntityStore.ts +1 -1
- package/src/index.ts +12 -0
|
@@ -1,51 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createMigration, schema } from '@verdant-web/common';
|
|
2
2
|
// @ts-ignore
|
|
3
3
|
import { IDBFactory } from 'fake-indexeddb';
|
|
4
4
|
import { ClientDescriptor } from '../../index.js';
|
|
5
5
|
import { METADATA_VERSION_KEY } from '../../client/constants.js';
|
|
6
|
-
export const todoCollection = collection({
|
|
6
|
+
export const todoCollection = schema.collection({
|
|
7
7
|
name: 'todo',
|
|
8
8
|
primaryKey: 'id',
|
|
9
9
|
fields: {
|
|
10
|
-
id: {
|
|
11
|
-
type: 'string',
|
|
12
|
-
indexed: true,
|
|
10
|
+
id: schema.fields.string({
|
|
13
11
|
default: () => Math.random().toString(36).slice(2, 9),
|
|
14
|
-
},
|
|
15
|
-
content:
|
|
16
|
-
|
|
17
|
-
indexed: true,
|
|
18
|
-
},
|
|
19
|
-
done: {
|
|
20
|
-
type: 'boolean',
|
|
12
|
+
}),
|
|
13
|
+
content: schema.fields.string(),
|
|
14
|
+
done: schema.fields.boolean({
|
|
21
15
|
default: false,
|
|
22
|
-
},
|
|
23
|
-
tags: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
category: {
|
|
30
|
-
type: 'string',
|
|
31
|
-
},
|
|
32
|
-
attachments: {
|
|
33
|
-
type: 'array',
|
|
34
|
-
items: {
|
|
35
|
-
type: 'object',
|
|
16
|
+
}),
|
|
17
|
+
tags: schema.fields.array({
|
|
18
|
+
items: schema.fields.string(),
|
|
19
|
+
}),
|
|
20
|
+
category: schema.fields.string(),
|
|
21
|
+
attachments: schema.fields.array({
|
|
22
|
+
items: schema.fields.object({
|
|
36
23
|
properties: {
|
|
37
|
-
name:
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
test: {
|
|
41
|
-
type: 'number',
|
|
24
|
+
name: schema.fields.string(),
|
|
25
|
+
test: schema.fields.number({
|
|
42
26
|
default: 1,
|
|
43
|
-
},
|
|
27
|
+
}),
|
|
44
28
|
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
29
|
+
}),
|
|
30
|
+
}),
|
|
47
31
|
},
|
|
48
|
-
|
|
32
|
+
indexes: {
|
|
33
|
+
content: {
|
|
34
|
+
field: 'content',
|
|
35
|
+
},
|
|
49
36
|
example: {
|
|
50
37
|
type: 'string',
|
|
51
38
|
compute: (doc) => doc.content,
|
|
@@ -60,44 +47,28 @@ export const todoCollection = collection({
|
|
|
60
47
|
},
|
|
61
48
|
},
|
|
62
49
|
});
|
|
63
|
-
export const weirdCollection = collection({
|
|
50
|
+
export const weirdCollection = schema.collection({
|
|
64
51
|
name: 'weird',
|
|
65
52
|
primaryKey: 'id',
|
|
66
53
|
fields: {
|
|
67
|
-
id: {
|
|
68
|
-
type: 'string',
|
|
69
|
-
indexed: true,
|
|
54
|
+
id: schema.fields.string({
|
|
70
55
|
default: () => Math.random().toString(36).slice(2, 9),
|
|
71
|
-
},
|
|
72
|
-
weird:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
fileList: {
|
|
82
|
-
type: 'array',
|
|
83
|
-
items: {
|
|
84
|
-
type: 'file',
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
objectMap: {
|
|
88
|
-
type: 'map',
|
|
89
|
-
values: {
|
|
90
|
-
type: 'object',
|
|
56
|
+
}),
|
|
57
|
+
weird: schema.fields.any(),
|
|
58
|
+
map: schema.fields.map({
|
|
59
|
+
values: schema.fields.string(),
|
|
60
|
+
}),
|
|
61
|
+
fileList: schema.fields.array({
|
|
62
|
+
items: schema.fields.file(),
|
|
63
|
+
}),
|
|
64
|
+
objectMap: schema.fields.map({
|
|
65
|
+
values: schema.fields.object({
|
|
91
66
|
properties: {
|
|
92
|
-
content:
|
|
93
|
-
type: 'string',
|
|
94
|
-
},
|
|
67
|
+
content: schema.fields.string(),
|
|
95
68
|
},
|
|
96
|
-
},
|
|
97
|
-
},
|
|
69
|
+
}),
|
|
70
|
+
}),
|
|
98
71
|
},
|
|
99
|
-
synthetics: {},
|
|
100
|
-
compounds: {},
|
|
101
72
|
});
|
|
102
73
|
const testSchema = schema({
|
|
103
74
|
version: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testStorage.js","sourceRoot":"","sources":["../../../../src/__tests__/fixtures/testStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"testStorage.js","sourceRoot":"","sources":["../../../../src/__tests__/fixtures/testStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC9D,aAAa;AACb,OAAO,EAAE,UAAU,EAAE,MAAM,gBAA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BAAiB,CAAC,EACjC,GAAG,GAAG,IAAI,UAAU,EAAE,EACtB,eAAe,GAAG,KAAK,EACvB,eAAe,EACf,GAAG,MAMA,EAAE;IACL,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC;QACpC,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,CAAC,eAAe,CAAK,UAAU,CAAC,CAAC;QAC7C,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,MAAM;QACjB,eAAe;QACf,GAAG;QACH,CAAC,oBAAoB,CAAC,EAAE,eAAe;KACvC,CAAC,CAAC,IAAI,EAAE,CAAC;IACV,OAAO,OAAyC,CAAC;AAClD,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -12,8 +12,10 @@ export type { ObjectEntity, ListEntity, EntityShape, AccessibleEntityProperty, A
|
|
|
12
12
|
export { ServerSync } from './sync/Sync.js';
|
|
13
13
|
export type { SyncTransportMode } from './sync/Sync.js';
|
|
14
14
|
export { EntityFile, type EntityFileSnapshot } from './files/EntityFile.js';
|
|
15
|
-
export {
|
|
16
|
-
|
|
15
|
+
export {
|
|
16
|
+
/** @deprecated - use schema.collection */
|
|
17
|
+
collection, schema, createDefaultMigration, migrate, createMigration, } from '@verdant-web/common';
|
|
18
|
+
export type { StorageDocument, StorageSchema, StorageCollectionSchema, StorageAnyFieldSchema, StorageArrayFieldSchema, StorageObjectFieldSchema, StorageBooleanFieldSchema, StorageFieldSchema, StorageFileFieldSchema, StorageMapFieldSchema, StorageNumberFieldSchema, StorageStringFieldSchema, StorageFieldsSchema, IndexValueTag, Migration, } from '@verdant-web/common';
|
|
17
19
|
export type { UserInfo } from '@verdant-web/common';
|
|
18
20
|
export type { Query } from './queries/types.js';
|
|
19
21
|
export type { QueryStatus } from './queries/BaseQuery.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -8,6 +8,8 @@ export { Client as Storage };
|
|
|
8
8
|
export { Entity } from './entities/Entity.js';
|
|
9
9
|
export { ServerSync } from './sync/Sync.js';
|
|
10
10
|
export { EntityFile } from './files/EntityFile.js';
|
|
11
|
-
export {
|
|
11
|
+
export {
|
|
12
|
+
/** @deprecated - use schema.collection */
|
|
13
|
+
collection, schema, createDefaultMigration, migrate, createMigration, } from '@verdant-web/common';
|
|
12
14
|
export { MigrationPathError } from './migration/errors.js';
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,GAEhB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,kBAAkB;AAClB,OAAO,EAAE,gBAAgB,IAAI,iBAAiB,EAAE,CAAC;AACjD,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,CAAC;AAG7B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAS9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAA2B,MAAM,uBAAuB,CAAC;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,GAEhB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,kBAAkB;AAClB,OAAO,EAAE,gBAAgB,IAAI,iBAAiB,EAAE,CAAC;AACjD,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,CAAC;AAG7B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAS9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAA2B,MAAM,uBAAuB,CAAC;AAC5E,OAAO;AACN,0CAA0C;AAC1C,UAAU,EACV,MAAM,EACN,sBAAsB,EACtB,OAAO,EACP,eAAe,GACf,MAAM,qBAAqB,CAAC;AAsB7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
|