@quadrokit/shared 0.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/README.md +10 -0
- package/package.json +18 -0
- package/src/catalog.ts +70 -0
- package/src/index.ts +10 -0
- package/tsconfig.json +8 -0
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# `@quadrokit/shared`
|
|
2
|
+
|
|
3
|
+
Small **TypeScript** types and helpers for the **4D REST catalog** JSON (e.g. `dataClasses`, `methods`, `__NAME`).
|
|
4
|
+
|
|
5
|
+
## Exports
|
|
6
|
+
|
|
7
|
+
- Catalog shape types (`CatalogJson`, `CatalogDataClass`, …)
|
|
8
|
+
- `sessionCookieName(catalog)` — builds `4DSID_${__NAME}` from catalog metadata (verify against your 4D deployment)
|
|
9
|
+
|
|
10
|
+
Used by `@quadrokit/client` codegen and can be reused in other tooling.
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quadrokit/shared",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.ts",
|
|
9
|
+
"import": "./src/index.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"typescript": "^5.9.3"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/catalog.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** 4D REST catalog JSON (subset used by QuadroKit). */
|
|
2
|
+
|
|
3
|
+
export type CatalogAttributeKind =
|
|
4
|
+
| 'storage'
|
|
5
|
+
| 'relatedEntity'
|
|
6
|
+
| 'relatedEntities'
|
|
7
|
+
| 'calculated'
|
|
8
|
+
| 'alias'
|
|
9
|
+
|
|
10
|
+
export interface CatalogAttribute {
|
|
11
|
+
name: string
|
|
12
|
+
kind: CatalogAttributeKind
|
|
13
|
+
type?: string
|
|
14
|
+
exposed?: boolean
|
|
15
|
+
path?: string
|
|
16
|
+
foreignKey?: string
|
|
17
|
+
inverseName?: string
|
|
18
|
+
reversePath?: boolean
|
|
19
|
+
readOnly?: boolean
|
|
20
|
+
behavior?: string
|
|
21
|
+
simpleDate?: boolean
|
|
22
|
+
not_null?: boolean
|
|
23
|
+
identifying?: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CatalogMethod {
|
|
27
|
+
name: string
|
|
28
|
+
applyTo?: string
|
|
29
|
+
scope?: string
|
|
30
|
+
from?: string
|
|
31
|
+
allowedOnHTTPGET?: boolean
|
|
32
|
+
exposed?: boolean
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CatalogDataClass {
|
|
36
|
+
name: string
|
|
37
|
+
className: string
|
|
38
|
+
collectionName: string
|
|
39
|
+
exposed: boolean
|
|
40
|
+
attributes: CatalogAttribute[]
|
|
41
|
+
methods?: CatalogMethod[]
|
|
42
|
+
key?: { name: string }[]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface CatalogSingletonMethod {
|
|
46
|
+
name: string
|
|
47
|
+
allowedOnHTTPGET?: boolean
|
|
48
|
+
exposed?: boolean
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface CatalogSingleton {
|
|
52
|
+
name: string
|
|
53
|
+
exposed: boolean
|
|
54
|
+
methods: CatalogSingletonMethod[]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface CatalogJson {
|
|
58
|
+
__UNIQID?: string
|
|
59
|
+
__BASEID?: string
|
|
60
|
+
__NAME?: string
|
|
61
|
+
properties?: Record<string, unknown>
|
|
62
|
+
singletons?: CatalogSingleton[]
|
|
63
|
+
methods?: CatalogMethod[]
|
|
64
|
+
dataClasses?: CatalogDataClass[]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function sessionCookieName(catalog: Pick<CatalogJson, '__NAME'>): string {
|
|
68
|
+
const db = catalog.__NAME ?? 'default'
|
|
69
|
+
return `4DSID_${db}`
|
|
70
|
+
}
|
package/src/index.ts
ADDED