@phis/contracts 0.4.0 → 0.6.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 +23 -5
- package/dist/addon-index.d.ts +1 -0
- package/dist/addon-index.js +1 -0
- package/dist/addon.d.ts +3 -1
- package/dist/capabilities.d.ts +30 -13
- package/dist/catalog.d.ts +14 -0
- package/dist/catalog.js +14 -2
- package/dist/cms.d.ts +34 -1
- package/dist/cms.js +52 -1
- package/dist/conditions.d.ts +96 -0
- package/dist/conditions.js +163 -0
- package/dist/controls.d.ts +91 -0
- package/dist/controls.js +134 -0
- package/dist/core.d.ts +17 -1
- package/dist/core.js +17 -0
- package/dist/forms.d.ts +496 -0
- package/dist/forms.js +508 -0
- package/dist/http.d.ts +10 -1
- package/dist/http.js +10 -1
- package/dist/layout.d.ts +22 -0
- package/dist/layout.js +30 -0
- package/dist/payments.d.ts +274 -0
- package/dist/payments.js +8 -0
- package/dist/record.d.ts +8 -0
- package/dist/record.js +24 -0
- package/dist/references.d.ts +139 -0
- package/dist/references.js +241 -0
- package/dist/resource-links.d.ts +13 -7
- package/dist/schema.d.ts +9 -0
- package/dist/signals.d.ts +1 -0
- package/dist/signals.js +3 -0
- package/dist/support.d.ts +184 -0
- package/dist/support.js +11 -0
- package/dist/threads.d.ts +29 -0
- package/dist/timeline.d.ts +39 -0
- package/dist/timeline.js +53 -0
- package/package.json +37 -2
package/dist/timeline.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a Timeline shows, the same for a Widget's own entries and for a Timeline Provider's answer.
|
|
3
|
+
*
|
|
4
|
+
* A Provider may run in a Module of ours, in an outside Module, or answer from an Add-on behind a Site
|
|
5
|
+
* route, so the entry is spelled here rather than in the UI package: every end that hands entries over
|
|
6
|
+
* reads and writes this shape.
|
|
7
|
+
*/
|
|
8
|
+
/** What an entry's mark says about it: a word about meaning, so the Theme decides the colour. */
|
|
9
|
+
export const PHI_TIMELINE_TONES = ["secondary", "success", "warning", "danger"];
|
|
10
|
+
function readString(value) {
|
|
11
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
12
|
+
}
|
|
13
|
+
export function isPhiTimelineTone(value) {
|
|
14
|
+
return typeof value === "string" && PHI_TIMELINE_TONES.includes(value);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The `at` of an entry, when it is a date this reader can place. A string that is not one is dropped
|
|
18
|
+
* rather than shown: an unreadable instant would print as "Invalid Date" in the reader's language.
|
|
19
|
+
*/
|
|
20
|
+
function readInstant(value) {
|
|
21
|
+
const text = readString(value);
|
|
22
|
+
return text && !Number.isNaN(Date.parse(text)) ? text : undefined;
|
|
23
|
+
}
|
|
24
|
+
/** One entry, or `null` for anything that is not one. An entry without a key or text is not one. */
|
|
25
|
+
export function readPhiTimelineEntry(value) {
|
|
26
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const record = value;
|
|
30
|
+
const key = readString(record.key);
|
|
31
|
+
if (!key) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const title = readString(record.title);
|
|
35
|
+
const at = readInstant(record.at);
|
|
36
|
+
const time = readString(record.time);
|
|
37
|
+
const icon = readString(record.icon);
|
|
38
|
+
return {
|
|
39
|
+
key,
|
|
40
|
+
content: typeof record.content === "string" ? record.content : "",
|
|
41
|
+
...(title ? { title } : {}),
|
|
42
|
+
...(at ? { at } : {}),
|
|
43
|
+
...(time ? { time } : {}),
|
|
44
|
+
...(icon ? { icon } : {}),
|
|
45
|
+
...(isPhiTimelineTone(record.tone) ? { tone: record.tone } : {}),
|
|
46
|
+
...(record.pending === true ? { pending: true } : {}),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function readPhiTimelineEntries(value) {
|
|
50
|
+
return Array.isArray(value)
|
|
51
|
+
? value.map(readPhiTimelineEntry).filter((entry) => entry != null)
|
|
52
|
+
: [];
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phis/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"sideEffects": false,
|
|
10
|
-
"description": "The agreements phis keeps with the site UI, Sites and Add-ons: the Add-on ABI, access, signals, catalog, CMS identity, media, HTTP headers, locale, logging, capabilities and group levels.",
|
|
10
|
+
"description": "The agreements phis keeps with the site UI, Sites and Add-ons: the Add-on ABI, access, signals, conditions, forms, controls, layout, catalog, CMS identity, media, HTTP headers, locale, logging, capabilities and group levels.",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "tsc -p tsconfig.build.json",
|
|
13
13
|
"typecheck": "tsc --noEmit",
|
|
@@ -15,6 +15,16 @@
|
|
|
15
15
|
"prepack": "npm run build"
|
|
16
16
|
},
|
|
17
17
|
"exports": {
|
|
18
|
+
"./payments": {
|
|
19
|
+
"types": "./dist/payments.d.ts",
|
|
20
|
+
"import": "./dist/payments.js",
|
|
21
|
+
"default": "./dist/payments.js"
|
|
22
|
+
},
|
|
23
|
+
"./references": {
|
|
24
|
+
"types": "./dist/references.d.ts",
|
|
25
|
+
"import": "./dist/references.js",
|
|
26
|
+
"default": "./dist/references.js"
|
|
27
|
+
},
|
|
18
28
|
"./addon": {
|
|
19
29
|
"types": "./dist/addon-index.d.ts",
|
|
20
30
|
"import": "./dist/addon-index.js",
|
|
@@ -89,6 +99,31 @@
|
|
|
89
99
|
"types": "./dist/user-state.d.ts",
|
|
90
100
|
"import": "./dist/user-state.js",
|
|
91
101
|
"default": "./dist/user-state.js"
|
|
102
|
+
},
|
|
103
|
+
"./conditions": {
|
|
104
|
+
"types": "./dist/conditions.d.ts",
|
|
105
|
+
"import": "./dist/conditions.js",
|
|
106
|
+
"default": "./dist/conditions.js"
|
|
107
|
+
},
|
|
108
|
+
"./controls": {
|
|
109
|
+
"types": "./dist/controls.d.ts",
|
|
110
|
+
"import": "./dist/controls.js",
|
|
111
|
+
"default": "./dist/controls.js"
|
|
112
|
+
},
|
|
113
|
+
"./forms": {
|
|
114
|
+
"types": "./dist/forms.d.ts",
|
|
115
|
+
"import": "./dist/forms.js",
|
|
116
|
+
"default": "./dist/forms.js"
|
|
117
|
+
},
|
|
118
|
+
"./layout": {
|
|
119
|
+
"types": "./dist/layout.d.ts",
|
|
120
|
+
"import": "./dist/layout.js",
|
|
121
|
+
"default": "./dist/layout.js"
|
|
122
|
+
},
|
|
123
|
+
"./timeline": {
|
|
124
|
+
"types": "./dist/timeline.d.ts",
|
|
125
|
+
"import": "./dist/timeline.js",
|
|
126
|
+
"default": "./dist/timeline.js"
|
|
92
127
|
}
|
|
93
128
|
},
|
|
94
129
|
"files": [
|