@open-mercato/shared 0.6.6-develop.5654.1.ca21e35f26 → 0.6.6-develop.5672.1.11e27afad2
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/lib/version.js
CHANGED
package/dist/lib/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/version.ts"],
|
|
4
|
-
"sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.6.6-develop.
|
|
4
|
+
"sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.6.6-develop.5672.1.11e27afad2'\nexport const appVersion = APP_VERSION\n"],
|
|
5
5
|
"mappings": "AACO,MAAM,cAAc;AACpB,MAAM,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/modules/dsl.js
CHANGED
|
@@ -15,6 +15,8 @@ const cf = {
|
|
|
15
15
|
boolean: (key, opts = {}) => ({ key, kind: "boolean", ...opts }),
|
|
16
16
|
select: (key, options, opts = {}) => ({ key, kind: "select", options, ...opts }),
|
|
17
17
|
currency: (key, opts = {}) => ({ key, kind: "currency", ...opts }),
|
|
18
|
+
date: (key, opts = {}) => ({ key, kind: "date", ...opts }),
|
|
19
|
+
datetime: (key, opts = {}) => ({ key, kind: "datetime", ...opts }),
|
|
18
20
|
dictionary: (key, dictionaryId, opts = {}) => ({ key, kind: "dictionary", dictionaryId, ...opts })
|
|
19
21
|
};
|
|
20
22
|
function defineFields(entity, fields, source) {
|
package/dist/modules/dsl.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/modules/dsl.ts"],
|
|
4
|
-
"sourcesContent": ["import type { CustomFieldDefinition, CustomFieldSet, EntityExtension, EntityId } from '@open-mercato/shared/modules/entities'\n\nexport function entityId(moduleId: string, entity: string): EntityId {\n return `${moduleId}:${entity}`\n}\n\nexport function linkable(moduleId: string, entities: string[]): Record<string, EntityId> {\n return Object.fromEntries(entities.map((e) => [e, entityId(moduleId, e)]))\n}\n\nexport function defineLink(\n base: EntityId,\n extension: EntityId,\n opts: Pick<EntityExtension, 'join' | 'cardinality' | 'required' | 'description'>\n): EntityExtension {\n return { base, extension, ...opts }\n}\n\nexport const cf = {\n text: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'text', ...opts }),\n multiline: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'multiline', ...opts }),\n integer: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'integer', ...opts }),\n float: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'float', ...opts }),\n boolean: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'boolean', ...opts }),\n select: (key: string, options: string[], opts: Omit<CustomFieldDefinition, 'key' | 'kind' | 'options'> = {}): CustomFieldDefinition => ({ key, kind: 'select', options, ...opts }),\n currency: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'currency', ...opts }),\n dictionary: (key: string, dictionaryId: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind' | 'dictionaryId'> = {}): CustomFieldDefinition => ({ key, kind: 'dictionary', dictionaryId, ...opts }),\n}\n\nexport function defineFields(entity: EntityId, fields: CustomFieldDefinition[], source?: string): CustomFieldSet {\n return { entity, fields, source }\n}\n"],
|
|
5
|
-
"mappings": "AAEO,SAAS,SAAS,UAAkB,QAA0B;AACnE,SAAO,GAAG,QAAQ,IAAI,MAAM;AAC9B;AAEO,SAAS,SAAS,UAAkB,UAA8C;AACvF,SAAO,OAAO,YAAY,SAAS,IAAI,CAAC,MAAM,CAAC,GAAG,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC;AAC3E;AAEO,SAAS,WACd,MACA,WACA,MACiB;AACjB,SAAO,EAAE,MAAM,WAAW,GAAG,KAAK;AACpC;AAEO,MAAM,KAAK;AAAA,EAChB,MAAM,CAAC,KAAa,OAAoD,CAAC,OAA8B,EAAE,KAAK,MAAM,QAAQ,GAAG,KAAK;AAAA,EACpI,WAAW,CAAC,KAAa,OAAoD,CAAC,OAA8B,EAAE,KAAK,MAAM,aAAa,GAAG,KAAK;AAAA,EAC9I,SAAS,CAAC,KAAa,OAAoD,CAAC,OAA8B,EAAE,KAAK,MAAM,WAAW,GAAG,KAAK;AAAA,EAC1I,OAAO,CAAC,KAAa,OAAoD,CAAC,OAA8B,EAAE,KAAK,MAAM,SAAS,GAAG,KAAK;AAAA,EACtI,SAAS,CAAC,KAAa,OAAoD,CAAC,OAA8B,EAAE,KAAK,MAAM,WAAW,GAAG,KAAK;AAAA,EAC1I,QAAQ,CAAC,KAAa,SAAmB,OAAgE,CAAC,OAA8B,EAAE,KAAK,MAAM,UAAU,SAAS,GAAG,KAAK;AAAA,EAChL,UAAU,CAAC,KAAa,OAAoD,CAAC,OAA8B,EAAE,KAAK,MAAM,YAAY,GAAG,KAAK;AAAA,EAC5I,YAAY,CAAC,KAAa,cAAsB,OAAqE,CAAC,OAA8B,EAAE,KAAK,MAAM,cAAc,cAAc,GAAG,KAAK;AACvM;AAEO,SAAS,aAAa,QAAkB,QAAiC,QAAiC;AAC/G,SAAO,EAAE,QAAQ,QAAQ,OAAO;AAClC;",
|
|
4
|
+
"sourcesContent": ["import type { CustomFieldDefinition, CustomFieldSet, EntityExtension, EntityId } from '@open-mercato/shared/modules/entities'\n\nexport function entityId(moduleId: string, entity: string): EntityId {\n return `${moduleId}:${entity}`\n}\n\nexport function linkable(moduleId: string, entities: string[]): Record<string, EntityId> {\n return Object.fromEntries(entities.map((e) => [e, entityId(moduleId, e)]))\n}\n\nexport function defineLink(\n base: EntityId,\n extension: EntityId,\n opts: Pick<EntityExtension, 'join' | 'cardinality' | 'required' | 'description'>\n): EntityExtension {\n return { base, extension, ...opts }\n}\n\nexport const cf = {\n text: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'text', ...opts }),\n multiline: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'multiline', ...opts }),\n integer: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'integer', ...opts }),\n float: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'float', ...opts }),\n boolean: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'boolean', ...opts }),\n select: (key: string, options: string[], opts: Omit<CustomFieldDefinition, 'key' | 'kind' | 'options'> = {}): CustomFieldDefinition => ({ key, kind: 'select', options, ...opts }),\n currency: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'currency', ...opts }),\n date: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'date', ...opts }),\n datetime: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'datetime', ...opts }),\n dictionary: (key: string, dictionaryId: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind' | 'dictionaryId'> = {}): CustomFieldDefinition => ({ key, kind: 'dictionary', dictionaryId, ...opts }),\n}\n\nexport function defineFields(entity: EntityId, fields: CustomFieldDefinition[], source?: string): CustomFieldSet {\n return { entity, fields, source }\n}\n"],
|
|
5
|
+
"mappings": "AAEO,SAAS,SAAS,UAAkB,QAA0B;AACnE,SAAO,GAAG,QAAQ,IAAI,MAAM;AAC9B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|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/shared",
|
|
3
|
-
"version": "0.6.6-develop.
|
|
3
|
+
"version": "0.6.6-develop.5672.1.11e27afad2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@mikro-orm/core": "^7.1.4",
|
|
93
93
|
"@mikro-orm/decorators": "^7.1.4",
|
|
94
94
|
"@mikro-orm/postgresql": "^7.1.4",
|
|
95
|
-
"@open-mercato/cache": "0.6.6-develop.
|
|
95
|
+
"@open-mercato/cache": "0.6.6-develop.5672.1.11e27afad2",
|
|
96
96
|
"dotenv": "^17.4.2",
|
|
97
97
|
"rate-limiter-flexible": "^11.2.0",
|
|
98
98
|
"re2js": "2.8.3",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { defineLink, entityId, linkable, defineFields, cf } from '../../modules/dsl'
|
|
2
|
+
import { CUSTOM_FIELD_KINDS } from '../../modules/entities/kinds'
|
|
3
|
+
import type { CustomFieldDefinition, CustomFieldKind } from '../../modules/entities'
|
|
2
4
|
|
|
3
5
|
describe('DSL helpers', () => {
|
|
4
6
|
test('defineLink + entityId', () => {
|
|
@@ -31,5 +33,22 @@ describe('DSL helpers', () => {
|
|
|
31
33
|
expect(set.fields[2]).toMatchObject({ key: 'priority', kind: 'integer' })
|
|
32
34
|
expect(set.source).toBe('my_module')
|
|
33
35
|
})
|
|
36
|
+
|
|
37
|
+
test('cf.date / cf.datetime helpers produce date kinds (#3042)', () => {
|
|
38
|
+
expect(cf.date('birth_date', { label: 'Birth date' })).toMatchObject({ key: 'birth_date', kind: 'date', label: 'Birth date' })
|
|
39
|
+
expect(cf.datetime('seen_at')).toMatchObject({ key: 'seen_at', kind: 'datetime' })
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
test('CustomFieldKind type stays in sync with the runtime kinds list (#3042)', () => {
|
|
43
|
+
// The CustomFieldKind type is derived from CUSTOM_FIELD_KINDS, so declaring a
|
|
44
|
+
// field with any runtime kind — including date/datetime — must type-check.
|
|
45
|
+
const dateField: CustomFieldDefinition = { key: 'birth_date', kind: 'date' }
|
|
46
|
+
const dateTimeField: CustomFieldDefinition = { key: 'seen_at', kind: 'datetime' }
|
|
47
|
+
expect(dateField.kind).toBe('date')
|
|
48
|
+
expect(dateTimeField.kind).toBe('datetime')
|
|
49
|
+
const everyRuntimeKind: CustomFieldKind[] = [...CUSTOM_FIELD_KINDS]
|
|
50
|
+
expect(everyRuntimeKind).toContain('date')
|
|
51
|
+
expect(everyRuntimeKind).toContain('datetime')
|
|
52
|
+
})
|
|
34
53
|
})
|
|
35
54
|
|
package/src/modules/dsl.ts
CHANGED
|
@@ -24,6 +24,8 @@ export const cf = {
|
|
|
24
24
|
boolean: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'boolean', ...opts }),
|
|
25
25
|
select: (key: string, options: string[], opts: Omit<CustomFieldDefinition, 'key' | 'kind' | 'options'> = {}): CustomFieldDefinition => ({ key, kind: 'select', options, ...opts }),
|
|
26
26
|
currency: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'currency', ...opts }),
|
|
27
|
+
date: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'date', ...opts }),
|
|
28
|
+
datetime: (key: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind'> = {}): CustomFieldDefinition => ({ key, kind: 'datetime', ...opts }),
|
|
27
29
|
dictionary: (key: string, dictionaryId: string, opts: Omit<CustomFieldDefinition, 'key' | 'kind' | 'dictionaryId'> = {}): CustomFieldDefinition => ({ key, kind: 'dictionary', dictionaryId, ...opts }),
|
|
28
30
|
}
|
|
29
31
|
|
package/src/modules/entities.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
// Shared entity/extension/custom-field types used by generators and DI
|
|
2
2
|
|
|
3
|
+
// Single source of truth: CustomFieldKind is derived from the runtime
|
|
4
|
+
// CUSTOM_FIELD_KINDS list so the type can never drift behind the kinds the admin
|
|
5
|
+
// UI and runtime already accept (e.g. 'date', 'datetime'). Add new kinds in
|
|
6
|
+
// ./entities/kinds.ts only.
|
|
7
|
+
import type { CustomFieldKind } from './entities/kinds'
|
|
8
|
+
export type { CustomFieldKind }
|
|
9
|
+
|
|
3
10
|
export type EntityId = string // format: '<module>:<entity>' e.g., 'auth:user'
|
|
4
11
|
|
|
5
12
|
export type EntityExtension = {
|
|
@@ -18,18 +25,6 @@ export type EntityExtension = {
|
|
|
18
25
|
description?: string
|
|
19
26
|
}
|
|
20
27
|
|
|
21
|
-
export type CustomFieldKind =
|
|
22
|
-
| 'text'
|
|
23
|
-
| 'multiline'
|
|
24
|
-
| 'integer'
|
|
25
|
-
| 'float'
|
|
26
|
-
| 'boolean'
|
|
27
|
-
| 'select'
|
|
28
|
-
| 'currency'
|
|
29
|
-
| 'relation'
|
|
30
|
-
| 'attachment'
|
|
31
|
-
| 'dictionary'
|
|
32
|
-
|
|
33
28
|
export type CustomFieldDefinition = {
|
|
34
29
|
id?: string // stable id; generated if omitted
|
|
35
30
|
key: string // unique within entity (snake_case)
|