@ossy/distribution 1.10.3 → 3.0.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/distribution",
3
3
  "description": "Analytics module — workspace analytics for website traffic",
4
- "version": "1.10.3",
4
+ "version": "3.0.1",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "module": "./src/index.js",
@@ -27,5 +27,5 @@
27
27
  "@ossy/sdk-react": "*",
28
28
  "react": "*"
29
29
  },
30
- "gitHead": "a0d89185a17f8de8ce328c3a648c108ff1d61d8f"
30
+ "gitHead": "4a70ec216448680d2fddc57b2a8a0077489720ae"
31
31
  }
package/src/Definition.js CHANGED
@@ -3,5 +3,5 @@ export const Definition = {
3
3
  title: 'Distribution',
4
4
  description: 'Distribution channels and external publishing integrations.',
5
5
  icon: 'share',
6
- statuses: ['beta'],
6
+ status: ['beta'],
7
7
  }
@@ -3,7 +3,6 @@ import { useRouter } from '@ossy/router-react'
3
3
  import { Text, View, Button, Switch, Page, useLocale, Tags } from '@ossy/design-system'
4
4
  import { AsyncStatus } from '@ossy/sdk-react'
5
5
  import { Definition } from '@ossy/distribution'
6
- import { moduleStatusTags } from './moduleStatus.js'
7
6
 
8
7
  export const metadata = {
9
8
  id: 'distribution/home',
@@ -26,7 +25,9 @@ export const DistributionPage = () => {
26
25
  icon: key === 'pinterest' ? 'details-more' : key === 'x' ? 'screen-shot' : 'arrows-expand-up-right',
27
26
  }))
28
27
 
29
- const statusTags = moduleStatusTags(Definition)
28
+ const statusTags = (Definition.status ?? [])
29
+ .map((s) => ({ beta: 'Beta', 'coming-soon': 'Coming Soon' }[s]))
30
+ .filter(Boolean)
30
31
 
31
32
  return (
32
33
  <Page
@@ -1,95 +0,0 @@
1
- /**
2
- * Module lifecycle & visibility helpers.
3
- *
4
- * - `statuses` is a string[] on each Definition (e.g. `['beta']`, `['beta', 'internal']`).
5
- * - Legacy single `status` is still read for compatibility.
6
- * - Optional workspace gating via `workspaceServiceKey` or `workspaceServiceKeys` + `workspaceServiceRequirement`.
7
- */
8
-
9
- export const MODULE_STATUS = {
10
- beta: 'beta',
11
- comingSoon: 'coming-soon',
12
- stable: 'stable',
13
- /** When present, the module is omitted from the primary sidebar. */
14
- hidden: 'hidden',
15
- }
16
-
17
- const STATUS_TO_TAG_LABEL = {
18
- [MODULE_STATUS.beta]: 'Beta',
19
- [MODULE_STATUS.comingSoon]: 'Coming Soon',
20
- [MODULE_STATUS.stable]: null,
21
- [MODULE_STATUS.hidden]: null,
22
- }
23
-
24
- /** Status values that exclude a module from the sidebar (in addition to workspace gating). */
25
- const SIDEBAR_HIDE_STATUSES = new Set([MODULE_STATUS.hidden])
26
-
27
- /**
28
- * Normalize legacy `definition.status` and `definition.statuses` into one array.
29
- * @param {{ status?: string, statuses?: string[] }} definition
30
- * @returns {string[]}
31
- */
32
- export function moduleStatuses(definition) {
33
- const fromArray = Array.isArray(definition?.statuses) ? definition.statuses : []
34
- const fromLegacy = definition?.status && typeof definition.status === 'string' ? [definition.status] : []
35
- if (fromArray.length) return [...new Set(fromArray)]
36
- if (fromLegacy.length) return [...new Set(fromLegacy)]
37
- return []
38
- }
39
-
40
- /**
41
- * @param {{ status?: string, statuses?: string[] }} definition
42
- * @returns {string[]} labels for `<Tags tags={...} />` (stable/hidden emit none)
43
- */
44
- export function moduleStatusTags(definition) {
45
- const labels = []
46
- for (const s of moduleStatuses(definition)) {
47
- const label = STATUS_TO_TAG_LABEL[s]
48
- if (label) labels.push(label)
49
- }
50
- return [...new Set(labels)]
51
- }
52
-
53
- /**
54
- * @param {{ status?: string, statuses?: string[] }} definition
55
- * @returns {boolean}
56
- */
57
- export function isHiddenFromSidebar(definition) {
58
- if (!definition) return true
59
- return moduleStatuses(definition).some(s => SIDEBAR_HIDE_STATUSES.has(s))
60
- }
61
-
62
- /**
63
- * @param {Record<string, boolean> | undefined} services workspace.services
64
- * @param {{ workspaceServiceKey?: string, workspaceServiceKeys?: string[], workspaceServiceRequirement?: 'all' | 'any' }} definition
65
- * @returns {boolean}
66
- */
67
- export function workspaceAllowsModule(services, definition) {
68
- if (!definition) return false
69
- const keys = definition.workspaceServiceKeys?.length
70
- ? definition.workspaceServiceKeys
71
- : definition.workspaceServiceKey
72
- ? [definition.workspaceServiceKey]
73
- : null
74
- if (!keys?.length) return true
75
- const mode = definition.workspaceServiceRequirement || 'all'
76
- const map = services || {}
77
- /** Treat missing keys as allowed (legacy workspaces); only explicit `false` from disable turns a service off. */
78
- const flags = keys.map(k => map[k] !== false)
79
- return mode === 'any' ? flags.some(Boolean) : flags.every(Boolean)
80
- }
81
-
82
- /**
83
- * Router ref for a module’s default page: `@<moduleId>/home`
84
- * @param {string} moduleId — matches `Definition.module.id` / folder name
85
- */
86
- export function moduleHomeRef(moduleId) {
87
- return `@${moduleId}/home`
88
- }
89
-
90
- /**
91
- * @param {{ requiresModules?: Array<{ id: string, label: string, href: string }> }} definition
92
- */
93
- export function moduleRequiresModules(definition) {
94
- return definition?.requiresModules ?? []
95
- }