@byline/core 0.9.3
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/LICENSE +373 -0
- package/README.md +17 -0
- package/dist/@types/admin-types.d.ts +275 -0
- package/dist/@types/admin-types.d.ts.map +1 -0
- package/dist/@types/admin-types.js +18 -0
- package/dist/@types/admin-types.js.map +1 -0
- package/dist/@types/collection-types.d.ts +816 -0
- package/dist/@types/collection-types.d.ts.map +1 -0
- package/dist/@types/collection-types.js +217 -0
- package/dist/@types/collection-types.js.map +1 -0
- package/dist/@types/db-types.d.ts +463 -0
- package/dist/@types/db-types.d.ts.map +1 -0
- package/dist/@types/db-types.js +2 -0
- package/dist/@types/db-types.js.map +1 -0
- package/dist/@types/field-data-types.d.ts +147 -0
- package/dist/@types/field-data-types.d.ts.map +1 -0
- package/dist/@types/field-data-types.js +38 -0
- package/dist/@types/field-data-types.js.map +1 -0
- package/dist/@types/field-types.d.ts +579 -0
- package/dist/@types/field-types.d.ts.map +1 -0
- package/dist/@types/field-types.js +32 -0
- package/dist/@types/field-types.js.map +1 -0
- package/dist/@types/index.d.ts +18 -0
- package/dist/@types/index.d.ts.map +1 -0
- package/dist/@types/index.js +18 -0
- package/dist/@types/index.js.map +1 -0
- package/dist/@types/populate-types.d.ts +54 -0
- package/dist/@types/populate-types.d.ts.map +1 -0
- package/dist/@types/populate-types.js +9 -0
- package/dist/@types/populate-types.js.map +1 -0
- package/dist/@types/query-predicate.d.ts +74 -0
- package/dist/@types/query-predicate.d.ts.map +1 -0
- package/dist/@types/query-predicate.js +9 -0
- package/dist/@types/query-predicate.js.map +1 -0
- package/dist/@types/site-config.d.ts +212 -0
- package/dist/@types/site-config.d.ts.map +1 -0
- package/dist/@types/site-config.js +9 -0
- package/dist/@types/site-config.js.map +1 -0
- package/dist/@types/storage-types.d.ts +86 -0
- package/dist/@types/storage-types.d.ts.map +1 -0
- package/dist/@types/storage-types.js +9 -0
- package/dist/@types/storage-types.js.map +1 -0
- package/dist/@types/store-types.d.ts +134 -0
- package/dist/@types/store-types.d.ts.map +1 -0
- package/dist/@types/store-types.js +24 -0
- package/dist/@types/store-types.js.map +1 -0
- package/dist/@types/type-utils.d.ts +17 -0
- package/dist/@types/type-utils.d.ts.map +1 -0
- package/dist/@types/type-utils.js +9 -0
- package/dist/@types/type-utils.js.map +1 -0
- package/dist/auth/apply-before-read.d.ts +36 -0
- package/dist/auth/apply-before-read.d.ts.map +1 -0
- package/dist/auth/apply-before-read.js +68 -0
- package/dist/auth/apply-before-read.js.map +1 -0
- package/dist/auth/apply-before-read.test.node.d.ts +9 -0
- package/dist/auth/apply-before-read.test.node.d.ts.map +1 -0
- package/dist/auth/apply-before-read.test.node.js +144 -0
- package/dist/auth/apply-before-read.test.node.js.map +1 -0
- package/dist/auth/assert-actor-can-perform.d.ts +39 -0
- package/dist/auth/assert-actor-can-perform.d.ts.map +1 -0
- package/dist/auth/assert-actor-can-perform.js +64 -0
- package/dist/auth/assert-actor-can-perform.js.map +1 -0
- package/dist/auth/assert-actor-can-perform.test.node.d.ts +9 -0
- package/dist/auth/assert-actor-can-perform.test.node.d.ts.map +1 -0
- package/dist/auth/assert-actor-can-perform.test.node.js +119 -0
- package/dist/auth/assert-actor-can-perform.test.node.js.map +1 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +11 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/register-collection-abilities.d.ts +40 -0
- package/dist/auth/register-collection-abilities.d.ts.map +1 -0
- package/dist/auth/register-collection-abilities.js +87 -0
- package/dist/auth/register-collection-abilities.js.map +1 -0
- package/dist/auth/register-collection-abilities.test.node.d.ts +9 -0
- package/dist/auth/register-collection-abilities.test.node.d.ts.map +1 -0
- package/dist/auth/register-collection-abilities.test.node.js +124 -0
- package/dist/auth/register-collection-abilities.test.node.js.map +1 -0
- package/dist/config/config.d.ts +10 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +108 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/routes.d.ts +16 -0
- package/dist/config/routes.d.ts.map +1 -0
- package/dist/config/routes.js +26 -0
- package/dist/config/routes.js.map +1 -0
- package/dist/config/validate-admin-configs.d.ts +33 -0
- package/dist/config/validate-admin-configs.d.ts.map +1 -0
- package/dist/config/validate-admin-configs.js +250 -0
- package/dist/config/validate-admin-configs.js.map +1 -0
- package/dist/config/validate-admin-configs.test.node.d.ts +9 -0
- package/dist/config/validate-admin-configs.test.node.d.ts.map +1 -0
- package/dist/config/validate-admin-configs.test.node.js +224 -0
- package/dist/config/validate-admin-configs.test.node.js.map +1 -0
- package/dist/config/validate-collections.d.ts +33 -0
- package/dist/config/validate-collections.d.ts.map +1 -0
- package/dist/config/validate-collections.js +70 -0
- package/dist/config/validate-collections.js.map +1 -0
- package/dist/config/validate-collections.test.node.d.ts +9 -0
- package/dist/config/validate-collections.test.node.d.ts.map +1 -0
- package/dist/config/validate-collections.test.node.js +149 -0
- package/dist/config/validate-collections.test.node.js.map +1 -0
- package/dist/core.d.ts +89 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +99 -0
- package/dist/core.js.map +1 -0
- package/dist/defaults/default-values.d.ts +13 -0
- package/dist/defaults/default-values.d.ts.map +1 -0
- package/dist/defaults/default-values.js +60 -0
- package/dist/defaults/default-values.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/errors.d.ts +98 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +134 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/logger.d.ts +62 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +120 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/registry.d.ts +65 -0
- package/dist/lib/registry.d.ts.map +1 -0
- package/dist/lib/registry.js +133 -0
- package/dist/lib/registry.js.map +1 -0
- package/dist/logger/index.d.ts +3 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +3 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/patches/apply-patches.d.ts +21 -0
- package/dist/patches/apply-patches.d.ts.map +1 -0
- package/dist/patches/apply-patches.js +357 -0
- package/dist/patches/apply-patches.js.map +1 -0
- package/dist/patches/index.d.ts +3 -0
- package/dist/patches/index.d.ts.map +1 -0
- package/dist/patches/index.js +4 -0
- package/dist/patches/index.js.map +1 -0
- package/dist/patches/patch-types.d.ts +82 -0
- package/dist/patches/patch-types.d.ts.map +1 -0
- package/dist/patches/patch-types.js +3 -0
- package/dist/patches/patch-types.js.map +1 -0
- package/dist/patches/patch.test.node.d.ts +2 -0
- package/dist/patches/patch.test.node.d.ts.map +1 -0
- package/dist/patches/patch.test.node.js +193 -0
- package/dist/patches/patch.test.node.js.map +1 -0
- package/dist/query/parse-where.d.ts +100 -0
- package/dist/query/parse-where.d.ts.map +1 -0
- package/dist/query/parse-where.js +352 -0
- package/dist/query/parse-where.js.map +1 -0
- package/dist/query/parse-where.test.node.d.ts +9 -0
- package/dist/query/parse-where.test.node.d.ts.map +1 -0
- package/dist/query/parse-where.test.node.js +581 -0
- package/dist/query/parse-where.test.node.js.map +1 -0
- package/dist/schemas/zod/builder.d.ts +466 -0
- package/dist/schemas/zod/builder.d.ts.map +1 -0
- package/dist/schemas/zod/builder.js +276 -0
- package/dist/schemas/zod/builder.js.map +1 -0
- package/dist/schemas/zod/cache.d.ts +14 -0
- package/dist/schemas/zod/cache.d.ts.map +1 -0
- package/dist/schemas/zod/cache.js +40 -0
- package/dist/schemas/zod/cache.js.map +1 -0
- package/dist/schemas/zod/index.d.ts +4 -0
- package/dist/schemas/zod/index.d.ts.map +1 -0
- package/dist/schemas/zod/index.js +4 -0
- package/dist/schemas/zod/index.js.map +1 -0
- package/dist/schemas/zod/types.d.ts +13 -0
- package/dist/schemas/zod/types.d.ts.map +1 -0
- package/dist/schemas/zod/types.js +2 -0
- package/dist/schemas/zod/types.js.map +1 -0
- package/dist/services/collection-bootstrap.d.ts +46 -0
- package/dist/services/collection-bootstrap.d.ts.map +1 -0
- package/dist/services/collection-bootstrap.js +108 -0
- package/dist/services/collection-bootstrap.js.map +1 -0
- package/dist/services/collection-bootstrap.test.node.d.ts +9 -0
- package/dist/services/collection-bootstrap.test.node.d.ts.map +1 -0
- package/dist/services/collection-bootstrap.test.node.js +208 -0
- package/dist/services/collection-bootstrap.test.node.js.map +1 -0
- package/dist/services/document-lifecycle.d.ts +245 -0
- package/dist/services/document-lifecycle.d.ts.map +1 -0
- package/dist/services/document-lifecycle.js +481 -0
- package/dist/services/document-lifecycle.js.map +1 -0
- package/dist/services/document-lifecycle.test.node.d.ts +9 -0
- package/dist/services/document-lifecycle.test.node.d.ts.map +1 -0
- package/dist/services/document-lifecycle.test.node.js +781 -0
- package/dist/services/document-lifecycle.test.node.js.map +1 -0
- package/dist/services/document-read.d.ts +26 -0
- package/dist/services/document-read.d.ts.map +1 -0
- package/dist/services/document-read.js +60 -0
- package/dist/services/document-read.js.map +1 -0
- package/dist/services/field-upload.d.ts +100 -0
- package/dist/services/field-upload.d.ts.map +1 -0
- package/dist/services/field-upload.js +328 -0
- package/dist/services/field-upload.js.map +1 -0
- package/dist/services/field-upload.test.node.d.ts +9 -0
- package/dist/services/field-upload.test.node.d.ts.map +1 -0
- package/dist/services/field-upload.test.node.js +337 -0
- package/dist/services/field-upload.test.node.js.map +1 -0
- package/dist/services/index.d.ts +10 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +11 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/populate.d.ts +299 -0
- package/dist/services/populate.d.ts.map +1 -0
- package/dist/services/populate.js +484 -0
- package/dist/services/populate.js.map +1 -0
- package/dist/services/populate.test.node.d.ts +9 -0
- package/dist/services/populate.test.node.d.ts.map +1 -0
- package/dist/services/populate.test.node.js +910 -0
- package/dist/services/populate.test.node.js.map +1 -0
- package/dist/services/relation-projection.d.ts +52 -0
- package/dist/services/relation-projection.d.ts.map +1 -0
- package/dist/services/relation-projection.js +81 -0
- package/dist/services/relation-projection.js.map +1 -0
- package/dist/services/richtext-populate.d.ts +87 -0
- package/dist/services/richtext-populate.d.ts.map +1 -0
- package/dist/services/richtext-populate.js +189 -0
- package/dist/services/richtext-populate.js.map +1 -0
- package/dist/services/richtext-populate.test.node.d.ts +9 -0
- package/dist/services/richtext-populate.test.node.d.ts.map +1 -0
- package/dist/services/richtext-populate.test.node.js +197 -0
- package/dist/services/richtext-populate.test.node.js.map +1 -0
- package/dist/storage/collection-fingerprint.d.ts +21 -0
- package/dist/storage/collection-fingerprint.d.ts.map +1 -0
- package/dist/storage/collection-fingerprint.js +172 -0
- package/dist/storage/collection-fingerprint.js.map +1 -0
- package/dist/storage/collection-fingerprint.test.node.d.ts +9 -0
- package/dist/storage/collection-fingerprint.test.node.d.ts.map +1 -0
- package/dist/storage/collection-fingerprint.test.node.js +256 -0
- package/dist/storage/collection-fingerprint.test.node.js.map +1 -0
- package/dist/storage/field-store-map.d.ts +59 -0
- package/dist/storage/field-store-map.d.ts.map +1 -0
- package/dist/storage/field-store-map.js +75 -0
- package/dist/storage/field-store-map.js.map +1 -0
- package/dist/storage/field-store-map.test.node.d.ts +9 -0
- package/dist/storage/field-store-map.test.node.d.ts.map +1 -0
- package/dist/storage/field-store-map.test.node.js +117 -0
- package/dist/storage/field-store-map.test.node.js.map +1 -0
- package/dist/storage/index.d.ts +10 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +10 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/utils/normalise-dates.d.ts +15 -0
- package/dist/utils/normalise-dates.d.ts.map +1 -0
- package/dist/utils/normalise-dates.js +22 -0
- package/dist/utils/normalise-dates.js.map +1 -0
- package/dist/utils/slugify.d.ts +56 -0
- package/dist/utils/slugify.d.ts.map +1 -0
- package/dist/utils/slugify.js +91 -0
- package/dist/utils/slugify.js.map +1 -0
- package/dist/utils/slugify.test.node.d.ts +9 -0
- package/dist/utils/slugify.test.node.d.ts.map +1 -0
- package/dist/utils/slugify.test.node.js +86 -0
- package/dist/utils/slugify.test.node.js.map +1 -0
- package/dist/utils/storage-utils.d.ts +36 -0
- package/dist/utils/storage-utils.d.ts.map +1 -0
- package/dist/utils/storage-utils.js +38 -0
- package/dist/utils/storage-utils.js.map +1 -0
- package/dist/utils/utils.general.d.ts +64 -0
- package/dist/utils/utils.general.d.ts.map +1 -0
- package/dist/utils/utils.general.js +219 -0
- package/dist/utils/utils.general.js.map +1 -0
- package/dist/validation/index.d.ts +9 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +9 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/shared.d.ts +36 -0
- package/dist/validation/shared.d.ts.map +1 -0
- package/dist/validation/shared.js +42 -0
- package/dist/validation/shared.js.map +1 -0
- package/dist/workflow/index.d.ts +2 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +3 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/workflow.d.ts +40 -0
- package/dist/workflow/workflow.d.ts.map +1 -0
- package/dist/workflow/workflow.js +96 -0
- package/dist/workflow/workflow.js.map +1 -0
- package/dist/workflow/workflow.test.node.d.ts +2 -0
- package/dist/workflow/workflow.test.node.d.ts.map +1 -0
- package/dist/workflow/workflow.test.node.js +198 -0
- package/dist/workflow/workflow.test.node.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import { describe, expect, it } from 'vitest';
|
|
9
|
+
import { fingerprintCollection } from './collection-fingerprint.js';
|
|
10
|
+
// Minimal collection used as a baseline; individual tests mutate clones.
|
|
11
|
+
function baseCollection() {
|
|
12
|
+
return {
|
|
13
|
+
path: 'news',
|
|
14
|
+
labels: { singular: 'News Item', plural: 'News Items' },
|
|
15
|
+
fields: [
|
|
16
|
+
{ name: 'title', type: 'text' },
|
|
17
|
+
{
|
|
18
|
+
name: 'body',
|
|
19
|
+
type: 'array',
|
|
20
|
+
fields: [
|
|
21
|
+
{ name: 'heading', type: 'text' },
|
|
22
|
+
{
|
|
23
|
+
name: 'blocks',
|
|
24
|
+
type: 'blocks',
|
|
25
|
+
blocks: [
|
|
26
|
+
{
|
|
27
|
+
blockType: 'photo',
|
|
28
|
+
fields: [{ name: 'caption', type: 'text' }],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'category',
|
|
36
|
+
type: 'relation',
|
|
37
|
+
targetCollection: 'categories',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
workflow: {
|
|
41
|
+
statuses: [
|
|
42
|
+
{ name: 'draft', label: 'Draft' },
|
|
43
|
+
{ name: 'published', label: 'Published' },
|
|
44
|
+
{ name: 'archived', label: 'Archived' },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
useAsTitle: 'title',
|
|
48
|
+
useAsPath: 'title',
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
describe('fingerprintCollection', () => {
|
|
52
|
+
it('returns a 64-character lowercase hex SHA-256 string', async () => {
|
|
53
|
+
const hash = await fingerprintCollection(baseCollection());
|
|
54
|
+
expect(hash).toMatch(/^[0-9a-f]{64}$/);
|
|
55
|
+
});
|
|
56
|
+
it('is deterministic across repeated calls on the same definition', async () => {
|
|
57
|
+
const a = await fingerprintCollection(baseCollection());
|
|
58
|
+
const b = await fingerprintCollection(baseCollection());
|
|
59
|
+
expect(a).toBe(b);
|
|
60
|
+
});
|
|
61
|
+
it('is invariant to top-level key insertion order', async () => {
|
|
62
|
+
const a = await fingerprintCollection(baseCollection());
|
|
63
|
+
// Rebuild the collection with keys inserted in a different order.
|
|
64
|
+
const reordered = {
|
|
65
|
+
useAsPath: 'title',
|
|
66
|
+
useAsTitle: 'title',
|
|
67
|
+
workflow: baseCollection().workflow,
|
|
68
|
+
fields: baseCollection().fields,
|
|
69
|
+
labels: { singular: 'News Item', plural: 'News Items' },
|
|
70
|
+
path: 'news',
|
|
71
|
+
};
|
|
72
|
+
expect(await fingerprintCollection(reordered)).toBe(a);
|
|
73
|
+
});
|
|
74
|
+
it('ignores label changes (presentation only)', async () => {
|
|
75
|
+
const a = await fingerprintCollection(baseCollection());
|
|
76
|
+
const b = baseCollection();
|
|
77
|
+
b.labels = { singular: 'Article', plural: 'Articles' };
|
|
78
|
+
expect(await fingerprintCollection(b)).toBe(a);
|
|
79
|
+
});
|
|
80
|
+
it('ignores hooks (functions cannot survive JSON)', async () => {
|
|
81
|
+
const a = await fingerprintCollection(baseCollection());
|
|
82
|
+
const b = baseCollection();
|
|
83
|
+
b.hooks = {
|
|
84
|
+
beforeCreate: async () => { },
|
|
85
|
+
afterUpdate: async () => { },
|
|
86
|
+
};
|
|
87
|
+
expect(await fingerprintCollection(b)).toBe(a);
|
|
88
|
+
});
|
|
89
|
+
it('ignores search / showStats (admin UX only)', async () => {
|
|
90
|
+
const a = await fingerprintCollection(baseCollection());
|
|
91
|
+
const b = baseCollection();
|
|
92
|
+
b.search = { fields: ['title', 'body.heading'] };
|
|
93
|
+
b.showStats = true;
|
|
94
|
+
expect(await fingerprintCollection(b)).toBe(a);
|
|
95
|
+
});
|
|
96
|
+
it('ignores field-level admin metadata (label, helpText, placeholder)', async () => {
|
|
97
|
+
const a = await fingerprintCollection(baseCollection());
|
|
98
|
+
const b = baseCollection();
|
|
99
|
+
const title = b.fields.find((f) => f.name === 'title');
|
|
100
|
+
title.label = 'Title';
|
|
101
|
+
title.helpText = 'The news headline';
|
|
102
|
+
title.placeholder = 'Enter a headline';
|
|
103
|
+
expect(await fingerprintCollection(b)).toBe(a);
|
|
104
|
+
});
|
|
105
|
+
it('ignores workflow status labels and verbs', async () => {
|
|
106
|
+
const a = await fingerprintCollection(baseCollection());
|
|
107
|
+
const b = baseCollection();
|
|
108
|
+
b.workflow = {
|
|
109
|
+
statuses: [
|
|
110
|
+
{ name: 'draft', label: 'Scratch pad', verb: 'Start over' },
|
|
111
|
+
{ name: 'published', label: 'Live', verb: 'Go live' },
|
|
112
|
+
{ name: 'archived', label: 'Cold storage', verb: 'Archive' },
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
expect(await fingerprintCollection(b)).toBe(a);
|
|
116
|
+
});
|
|
117
|
+
it('changes when a field is added', async () => {
|
|
118
|
+
const a = await fingerprintCollection(baseCollection());
|
|
119
|
+
const b = baseCollection();
|
|
120
|
+
b.fields.push({ name: 'summary', type: 'text' });
|
|
121
|
+
expect(await fingerprintCollection(b)).not.toBe(a);
|
|
122
|
+
});
|
|
123
|
+
it('changes when a field is renamed', async () => {
|
|
124
|
+
const a = await fingerprintCollection(baseCollection());
|
|
125
|
+
const b = baseCollection();
|
|
126
|
+
b.fields[0].name = 'headline';
|
|
127
|
+
expect(await fingerprintCollection(b)).not.toBe(a);
|
|
128
|
+
});
|
|
129
|
+
it('changes when a field type changes', async () => {
|
|
130
|
+
const a = await fingerprintCollection(baseCollection());
|
|
131
|
+
const b = baseCollection();
|
|
132
|
+
b.fields[0].type = 'textArea';
|
|
133
|
+
expect(await fingerprintCollection(b)).not.toBe(a);
|
|
134
|
+
});
|
|
135
|
+
it('changes when `optional` flips on a field', async () => {
|
|
136
|
+
const a = await fingerprintCollection(baseCollection());
|
|
137
|
+
const b = baseCollection();
|
|
138
|
+
b.fields[0].optional = true;
|
|
139
|
+
expect(await fingerprintCollection(b)).not.toBe(a);
|
|
140
|
+
});
|
|
141
|
+
it('changes when a relation target changes', async () => {
|
|
142
|
+
const a = await fingerprintCollection(baseCollection());
|
|
143
|
+
const b = baseCollection();
|
|
144
|
+
const rel = b.fields.find((f) => f.name === 'category');
|
|
145
|
+
rel.targetCollection = 'tags';
|
|
146
|
+
expect(await fingerprintCollection(b)).not.toBe(a);
|
|
147
|
+
});
|
|
148
|
+
it('changes when a block variant is renamed', async () => {
|
|
149
|
+
const a = await fingerprintCollection(baseCollection());
|
|
150
|
+
const b = baseCollection();
|
|
151
|
+
const body = b.fields.find((f) => f.name === 'body');
|
|
152
|
+
const blocksField = body.fields.find((f) => f.name === 'blocks');
|
|
153
|
+
blocksField.blocks[0].blockType = 'image';
|
|
154
|
+
expect(await fingerprintCollection(b)).not.toBe(a);
|
|
155
|
+
});
|
|
156
|
+
it('changes when a workflow status is inserted', async () => {
|
|
157
|
+
const a = await fingerprintCollection(baseCollection());
|
|
158
|
+
const b = baseCollection();
|
|
159
|
+
b.workflow = {
|
|
160
|
+
statuses: [
|
|
161
|
+
{ name: 'draft' },
|
|
162
|
+
{ name: 'needs_review' },
|
|
163
|
+
{ name: 'published' },
|
|
164
|
+
{ name: 'archived' },
|
|
165
|
+
],
|
|
166
|
+
};
|
|
167
|
+
expect(await fingerprintCollection(b)).not.toBe(a);
|
|
168
|
+
});
|
|
169
|
+
it('changes when useAsPath changes', async () => {
|
|
170
|
+
const a = await fingerprintCollection(baseCollection());
|
|
171
|
+
const b = baseCollection();
|
|
172
|
+
b.useAsPath = 'category';
|
|
173
|
+
expect(await fingerprintCollection(b)).not.toBe(a);
|
|
174
|
+
});
|
|
175
|
+
it('changes when an image-field upload mimeTypes change', async () => {
|
|
176
|
+
const a = baseCollection();
|
|
177
|
+
a.fields.push({
|
|
178
|
+
name: 'cover',
|
|
179
|
+
type: 'image',
|
|
180
|
+
upload: { mimeTypes: ['image/*'] },
|
|
181
|
+
});
|
|
182
|
+
const hashA = await fingerprintCollection(a);
|
|
183
|
+
const b = baseCollection();
|
|
184
|
+
b.fields.push({
|
|
185
|
+
name: 'cover',
|
|
186
|
+
type: 'image',
|
|
187
|
+
upload: { mimeTypes: ['video/*'] },
|
|
188
|
+
});
|
|
189
|
+
expect(await fingerprintCollection(b)).not.toBe(hashA);
|
|
190
|
+
});
|
|
191
|
+
it('ignores image-field upload storage provider (runtime detail)', async () => {
|
|
192
|
+
const a = baseCollection();
|
|
193
|
+
a.fields.push({
|
|
194
|
+
name: 'cover',
|
|
195
|
+
type: 'image',
|
|
196
|
+
upload: { mimeTypes: ['image/*'] },
|
|
197
|
+
});
|
|
198
|
+
const hashA = await fingerprintCollection(a);
|
|
199
|
+
const b = baseCollection();
|
|
200
|
+
b.fields.push({
|
|
201
|
+
name: 'cover',
|
|
202
|
+
type: 'image',
|
|
203
|
+
upload: {
|
|
204
|
+
mimeTypes: ['image/*'],
|
|
205
|
+
// Fake storage provider — runtime detail, excluded from canonical shape.
|
|
206
|
+
storage: { put: async () => { }, get: async () => { }, delete: async () => { } },
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
expect(await fingerprintCollection(b)).toBe(hashA);
|
|
210
|
+
});
|
|
211
|
+
it('ignores image-field upload hooks (functions never canonicalise)', async () => {
|
|
212
|
+
const a = baseCollection();
|
|
213
|
+
a.fields.push({
|
|
214
|
+
name: 'cover',
|
|
215
|
+
type: 'image',
|
|
216
|
+
upload: { mimeTypes: ['image/*'] },
|
|
217
|
+
});
|
|
218
|
+
const hashA = await fingerprintCollection(a);
|
|
219
|
+
const b = baseCollection();
|
|
220
|
+
b.fields.push({
|
|
221
|
+
name: 'cover',
|
|
222
|
+
type: 'image',
|
|
223
|
+
upload: {
|
|
224
|
+
mimeTypes: ['image/*'],
|
|
225
|
+
hooks: {
|
|
226
|
+
beforeStore: () => 'renamed.jpg',
|
|
227
|
+
afterStore: () => { },
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
expect(await fingerprintCollection(b)).toBe(hashA);
|
|
232
|
+
});
|
|
233
|
+
it('ignores select option labels (only `value` is structural)', async () => {
|
|
234
|
+
const a = baseCollection();
|
|
235
|
+
a.fields.push({
|
|
236
|
+
name: 'priority',
|
|
237
|
+
type: 'select',
|
|
238
|
+
options: [
|
|
239
|
+
{ value: 'low', label: 'Low' },
|
|
240
|
+
{ value: 'high', label: 'High' },
|
|
241
|
+
],
|
|
242
|
+
});
|
|
243
|
+
const hashA = await fingerprintCollection(a);
|
|
244
|
+
const b = baseCollection();
|
|
245
|
+
b.fields.push({
|
|
246
|
+
name: 'priority',
|
|
247
|
+
type: 'select',
|
|
248
|
+
options: [
|
|
249
|
+
{ value: 'low', label: 'Not so important' },
|
|
250
|
+
{ value: 'high', label: 'Critical' },
|
|
251
|
+
],
|
|
252
|
+
});
|
|
253
|
+
expect(await fingerprintCollection(b)).toBe(hashA);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
//# sourceMappingURL=collection-fingerprint.test.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-fingerprint.test.node.js","sourceRoot":"","sources":["../../src/storage/collection-fingerprint.test.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAGnE,yEAAyE;AACzE,SAAS,cAAc;IACrB,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE;QACvD,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE;YAC/B;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE;oBACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE;oBACjC;wBACE,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,QAAQ;wBACd,MAAM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,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;gBAC9B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;aACjC;SACF,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,MAAM,qBAAqB,CAAC,CAAC,CAAC,CAAA;QAE5C,MAAM,CAAC,GAAG,cAAc,EAAE,CAAA;QAC1B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE;gBAC3C,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE;aACrC;SACF,CAAC,CAAA;QACF,MAAM,CAAC,MAAM,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACpD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Adapter-agnostic mapping between collection field types and the EAV store
|
|
10
|
+
* tables they read from and write to. Both @byline/db-postgres (for UNION ALL
|
|
11
|
+
* generation and filter SQL) and @byline/client (for translating client-API
|
|
12
|
+
* where clauses into FieldFilter descriptors) consume this module — keeping
|
|
13
|
+
* the mapping in a single place prevents the two sides from drifting.
|
|
14
|
+
*
|
|
15
|
+
* Column names (`value`, `value_integer`, `value_timestamp_tz`, …) are shared
|
|
16
|
+
* between the adapter schema and the filter builder by design: the EAV store
|
|
17
|
+
* tables are the product's public storage contract, not a Postgres-only
|
|
18
|
+
* implementation detail. A future MySQL adapter is expected to mirror the
|
|
19
|
+
* same column names.
|
|
20
|
+
*/
|
|
21
|
+
/** The seven EAV store table types. */
|
|
22
|
+
export type StoreType = 'text' | 'numeric' | 'boolean' | 'datetime' | 'json' | 'relation' | 'file';
|
|
23
|
+
/**
|
|
24
|
+
* Canonical order of store types — used by adapters when assembling the
|
|
25
|
+
* UNION ALL that reconstructs a document from its per-type rows.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ALL_STORE_TYPES: readonly StoreType[];
|
|
28
|
+
/** Resolved store location for a single-value field type. */
|
|
29
|
+
export interface FieldStoreMapping {
|
|
30
|
+
/** The EAV store table that holds the field's data. */
|
|
31
|
+
storeType: StoreType;
|
|
32
|
+
/**
|
|
33
|
+
* The column within the store table that holds the scalar value.
|
|
34
|
+
* Used for filter WHERE conditions and sort expressions.
|
|
35
|
+
*/
|
|
36
|
+
valueColumn: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Field type → EAV store table + value column.
|
|
40
|
+
*
|
|
41
|
+
* Structure fields (`group`, `array`, `blocks`) and the `meta` category do
|
|
42
|
+
* not appear here — they are handled separately via `fieldTypeToStoreType`.
|
|
43
|
+
*/
|
|
44
|
+
export declare const fieldTypeToStore: Readonly<Record<string, FieldStoreMapping | undefined>>;
|
|
45
|
+
/**
|
|
46
|
+
* Extends StoreType with `'meta'` for structure field types that produce
|
|
47
|
+
* identity rows in `store_meta` (array, blocks). Also accepts `undefined`
|
|
48
|
+
* for structure types that only group children without their own storage.
|
|
49
|
+
*/
|
|
50
|
+
export type FieldStoreKind = StoreType | 'meta';
|
|
51
|
+
/**
|
|
52
|
+
* Field type → store kind, including `'meta'` for structure types that
|
|
53
|
+
* produce identity rows and `undefined` for the pure-nesting `group` type.
|
|
54
|
+
*
|
|
55
|
+
* Used by adapters to resolve which store tables to UNION ALL for a given
|
|
56
|
+
* subset of requested fields (selective field loading).
|
|
57
|
+
*/
|
|
58
|
+
export declare const fieldTypeToStoreType: Readonly<Record<string, FieldStoreKind | undefined>>;
|
|
59
|
+
//# sourceMappingURL=field-store-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-store-map.d.ts","sourceRoot":"","sources":["../../src/storage/field-store-map.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AAMH,uCAAuC;AACvC,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAA;AAElG;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,SAAS,EAQtC,CAAA;AAMV,6DAA6D;AAC7D,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,SAAS,EAAE,SAAS,CAAA;IACpB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAC,CA+BpF,CAAA;AAMD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,MAAM,CAAA;AAgB/C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,sDAA+B,CAAA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Canonical order of store types — used by adapters when assembling the
|
|
10
|
+
* UNION ALL that reconstructs a document from its per-type rows.
|
|
11
|
+
*/
|
|
12
|
+
export const ALL_STORE_TYPES = [
|
|
13
|
+
'text',
|
|
14
|
+
'numeric',
|
|
15
|
+
'boolean',
|
|
16
|
+
'datetime',
|
|
17
|
+
'json',
|
|
18
|
+
'relation',
|
|
19
|
+
'file',
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Field type → EAV store table + value column.
|
|
23
|
+
*
|
|
24
|
+
* Structure fields (`group`, `array`, `blocks`) and the `meta` category do
|
|
25
|
+
* not appear here — they are handled separately via `fieldTypeToStoreType`.
|
|
26
|
+
*/
|
|
27
|
+
export const fieldTypeToStore = {
|
|
28
|
+
// Text store
|
|
29
|
+
text: { storeType: 'text', valueColumn: 'value' },
|
|
30
|
+
textArea: { storeType: 'text', valueColumn: 'value' },
|
|
31
|
+
select: { storeType: 'text', valueColumn: 'value' },
|
|
32
|
+
// Numeric store
|
|
33
|
+
integer: { storeType: 'numeric', valueColumn: 'value_integer' },
|
|
34
|
+
float: { storeType: 'numeric', valueColumn: 'value_float' },
|
|
35
|
+
decimal: { storeType: 'numeric', valueColumn: 'value_decimal' },
|
|
36
|
+
// Boolean store
|
|
37
|
+
boolean: { storeType: 'boolean', valueColumn: 'value' },
|
|
38
|
+
checkbox: { storeType: 'boolean', valueColumn: 'value' },
|
|
39
|
+
// DateTime store
|
|
40
|
+
date: { storeType: 'datetime', valueColumn: 'value_date' },
|
|
41
|
+
time: { storeType: 'datetime', valueColumn: 'value_time' },
|
|
42
|
+
datetime: { storeType: 'datetime', valueColumn: 'value_timestamp_tz' },
|
|
43
|
+
// JSON store
|
|
44
|
+
richText: { storeType: 'json', valueColumn: 'value' },
|
|
45
|
+
json: { storeType: 'json', valueColumn: 'value' },
|
|
46
|
+
object: { storeType: 'json', valueColumn: 'value' },
|
|
47
|
+
// File store
|
|
48
|
+
file: { storeType: 'file', valueColumn: 'file_id' },
|
|
49
|
+
image: { storeType: 'file', valueColumn: 'file_id' },
|
|
50
|
+
// Relation store
|
|
51
|
+
relation: { storeType: 'relation', valueColumn: 'target_document_id' },
|
|
52
|
+
};
|
|
53
|
+
/** Derived from `fieldTypeToStore` plus explicit entries for structure fields. */
|
|
54
|
+
function deriveFieldTypeToStoreType() {
|
|
55
|
+
const result = {};
|
|
56
|
+
for (const [key, mapping] of Object.entries(fieldTypeToStore)) {
|
|
57
|
+
if (mapping)
|
|
58
|
+
result[key] = mapping.storeType;
|
|
59
|
+
}
|
|
60
|
+
// Structure fields carry identity rows in store_meta.
|
|
61
|
+
result.array = 'meta';
|
|
62
|
+
result.blocks = 'meta';
|
|
63
|
+
// Group is a pure nesting wrapper — no rows of its own; callers recurse into children.
|
|
64
|
+
result.group = undefined;
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Field type → store kind, including `'meta'` for structure types that
|
|
69
|
+
* produce identity rows and `undefined` for the pure-nesting `group` type.
|
|
70
|
+
*
|
|
71
|
+
* Used by adapters to resolve which store tables to UNION ALL for a given
|
|
72
|
+
* subset of requested fields (selective field loading).
|
|
73
|
+
*/
|
|
74
|
+
export const fieldTypeToStoreType = deriveFieldTypeToStoreType();
|
|
75
|
+
//# sourceMappingURL=field-store-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-store-map.js","sourceRoot":"","sources":["../../src/storage/field-store-map.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuBH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAyB;IACnD,MAAM;IACN,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACN,UAAU;IACV,MAAM;CACE,CAAA;AAiBV;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA4D;IACvF,aAAa;IACb,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE;IACjD,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE;IACrD,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,E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AAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC9D,IAAI,OAAO;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,SAAS,CAAA;IAC9C,CAAC;IACD,sDAAsD;IACtD,MAAM,CAAC,KAAK,GAAG,MAAM,CAAA;IACrB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,uFAAuF;IACvF,MAAM,CAAC,KAAK,GAAG,SAAS,CAAA;IACxB,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,0BAA0B,EAAE,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=field-store-map.test.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-store-map.test.node.d.ts","sourceRoot":"","sources":["../../src/storage/field-store-map.test.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import { describe, expect, it } from 'vitest';
|
|
9
|
+
import { ALL_STORE_TYPES, fieldTypeToStore, fieldTypeToStoreType, } from './field-store-map.js';
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Canonical field type inventory
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
/**
|
|
14
|
+
* Every value-bearing field type the schema supports. If a new field type is
|
|
15
|
+
* added in `@types/field-types.ts`, add it here too — the contract tests
|
|
16
|
+
* below will then fail until the mapping picks it up.
|
|
17
|
+
*/
|
|
18
|
+
const VALUE_FIELD_TYPES = [
|
|
19
|
+
'text',
|
|
20
|
+
'textArea',
|
|
21
|
+
'select',
|
|
22
|
+
'integer',
|
|
23
|
+
'float',
|
|
24
|
+
'decimal',
|
|
25
|
+
'boolean',
|
|
26
|
+
'checkbox',
|
|
27
|
+
'date',
|
|
28
|
+
'time',
|
|
29
|
+
'datetime',
|
|
30
|
+
'richText',
|
|
31
|
+
'json',
|
|
32
|
+
'object',
|
|
33
|
+
'file',
|
|
34
|
+
'image',
|
|
35
|
+
'relation',
|
|
36
|
+
];
|
|
37
|
+
const STRUCTURE_FIELD_TYPES = ['group', 'array', 'blocks'];
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Tests
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
describe('ALL_STORE_TYPES', () => {
|
|
42
|
+
it('lists exactly the seven EAV store table types', () => {
|
|
43
|
+
expect([...ALL_STORE_TYPES]).toEqual([
|
|
44
|
+
'text',
|
|
45
|
+
'numeric',
|
|
46
|
+
'boolean',
|
|
47
|
+
'datetime',
|
|
48
|
+
'json',
|
|
49
|
+
'relation',
|
|
50
|
+
'file',
|
|
51
|
+
]);
|
|
52
|
+
});
|
|
53
|
+
it('contains no duplicates', () => {
|
|
54
|
+
expect(new Set(ALL_STORE_TYPES).size).toBe(ALL_STORE_TYPES.length);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('fieldTypeToStore', () => {
|
|
58
|
+
it('covers every value-bearing field type', () => {
|
|
59
|
+
const missing = VALUE_FIELD_TYPES.filter((t) => fieldTypeToStore[t] === undefined);
|
|
60
|
+
expect(missing).toEqual([]);
|
|
61
|
+
});
|
|
62
|
+
it('never maps a structure field type', () => {
|
|
63
|
+
for (const t of STRUCTURE_FIELD_TYPES) {
|
|
64
|
+
expect(fieldTypeToStore[t]).toBeUndefined();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
it('only references declared store types', () => {
|
|
68
|
+
const valid = new Set(ALL_STORE_TYPES);
|
|
69
|
+
for (const [fieldType, mapping] of Object.entries(fieldTypeToStore)) {
|
|
70
|
+
if (!mapping)
|
|
71
|
+
continue;
|
|
72
|
+
expect(valid.has(mapping.storeType), `field '${fieldType}' → '${mapping.storeType}'`).toBe(true);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
it('assigns a non-empty valueColumn for every mapping', () => {
|
|
76
|
+
for (const [fieldType, mapping] of Object.entries(fieldTypeToStore)) {
|
|
77
|
+
if (!mapping)
|
|
78
|
+
continue;
|
|
79
|
+
expect(mapping.valueColumn.length, `field '${fieldType}'`).toBeGreaterThan(0);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
it('uses at least one entry for each store type', () => {
|
|
83
|
+
const usedStores = new Set();
|
|
84
|
+
for (const mapping of Object.values(fieldTypeToStore)) {
|
|
85
|
+
if (mapping)
|
|
86
|
+
usedStores.add(mapping.storeType);
|
|
87
|
+
}
|
|
88
|
+
for (const storeType of ALL_STORE_TYPES) {
|
|
89
|
+
expect(usedStores.has(storeType), `store '${storeType}' has no field types`).toBe(true);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
describe('fieldTypeToStoreType', () => {
|
|
94
|
+
it('agrees with fieldTypeToStore for every value-bearing type', () => {
|
|
95
|
+
for (const t of VALUE_FIELD_TYPES) {
|
|
96
|
+
const rich = fieldTypeToStore[t];
|
|
97
|
+
const kind = fieldTypeToStoreType[t];
|
|
98
|
+
expect(rich).toBeDefined();
|
|
99
|
+
expect(kind, `field '${t}' storeKind vs storeType`).toBe(rich?.storeType);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
it('maps structure fields array/blocks to "meta"', () => {
|
|
103
|
+
expect(fieldTypeToStoreType.array).toBe('meta');
|
|
104
|
+
expect(fieldTypeToStoreType.blocks).toBe('meta');
|
|
105
|
+
});
|
|
106
|
+
it('maps the group structure field to undefined', () => {
|
|
107
|
+
expect(fieldTypeToStoreType.group).toBeUndefined();
|
|
108
|
+
});
|
|
109
|
+
it('covers every declared field type (value + structure)', () => {
|
|
110
|
+
const allKnown = [...VALUE_FIELD_TYPES, ...STRUCTURE_FIELD_TYPES];
|
|
111
|
+
for (const t of allKnown) {
|
|
112
|
+
// `group` is intentionally undefined, so check by key presence rather than truthiness.
|
|
113
|
+
expect(t in fieldTypeToStoreType, `missing field type '${t}'`).toBe(true);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=field-store-map.test.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-store-map.test.node.js","sourceRoot":"","sources":["../../src/storage/field-store-map.test.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,oBAAoB,GAErB,MAAM,sBAAsB,CAAA;AAE7B,8EAA8E;AAC9E,iCAAiC;AACjC,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,iBAAiB,GAAG;IACxB,MAAM;IACN,UAAU;IACV,QAAQ;IACR,SAAS;IACT,OAAO;IACP,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACN,MAAM;IACN,UAAU;IACV,UAAU;IACV,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,UAAU;CACF,CAAA;AAEV,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAA;AAEnE,8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IAAI,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAA;YAChC,MAAM,IAAI,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAA;YACpC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;YAC1B,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QAC3E,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC/C,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAClD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAA;IACpD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,QAAQ,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,qBAAqB,CAAC,CAAA;QACjE,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzB,uFAAuF;YACvF,MAAM,CAAC,CAAC,IAAI,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3E,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
export { fingerprintCollection } from './collection-fingerprint.js';
|
|
9
|
+
export { ALL_STORE_TYPES, type FieldStoreKind, type FieldStoreMapping, fieldTypeToStore, fieldTypeToStoreType, type StoreType, } from './field-store-map.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EACL,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,SAAS,GACf,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
export { fingerprintCollection } from './collection-fingerprint.js';
|
|
9
|
+
export { ALL_STORE_TYPES, fieldTypeToStore, fieldTypeToStoreType, } from './field-store-map.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EACL,eAAe,EAGf,gBAAgB,EAChB,oBAAoB,GAErB,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Normalise known date-like fields to `Date` instances before persisting.
|
|
10
|
+
*
|
|
11
|
+
* Mutates the input record in-place for performance.
|
|
12
|
+
* Currently handles `created_at`, `updated_at`, and `publishedOn`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function normaliseDateFields(data: Record<string, any>): void;
|
|
15
|
+
//# sourceMappingURL=normalise-dates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalise-dates.d.ts","sourceRoot":"","sources":["../../src/utils/normalise-dates.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAInE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Normalise known date-like fields to `Date` instances before persisting.
|
|
10
|
+
*
|
|
11
|
+
* Mutates the input record in-place for performance.
|
|
12
|
+
* Currently handles `created_at`, `updated_at`, and `publishedOn`.
|
|
13
|
+
*/
|
|
14
|
+
export function normaliseDateFields(data) {
|
|
15
|
+
if (typeof data.created_at === 'string')
|
|
16
|
+
data.created_at = new Date(data.created_at);
|
|
17
|
+
if (typeof data.updated_at === 'string')
|
|
18
|
+
data.updated_at = new Date(data.updated_at);
|
|
19
|
+
if (typeof data.publishedOn === 'string')
|
|
20
|
+
data.publishedOn = new Date(data.publishedOn);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=normalise-dates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalise-dates.js","sourceRoot":"","sources":["../../src/utils/normalise-dates.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAyB;IAC3D,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ;QAAE,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACpF,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ;QAAE,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACpF,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ;QAAE,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;AACzF,CAAC"}
|