@ossy/cli 1.40.2 → 1.40.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/README.md CHANGED
@@ -32,10 +32,10 @@ The contract for everything the platform can do is the **SDK action POJO** in [`
32
32
  | Local | `workspace use <id> \| list \| current` | Manage the active workspace (saved to `~/.config/ossy/config.json`) |
33
33
  | Local | `app init [dir]` | Scaffold a new Ossy app (default: current directory) |
34
34
  | Local | `app build` | Production build of the app in the current directory |
35
- | Local | `app validate` | Validate `src/config.js` (`workspaceId`, `resourceTemplates`) without calling the API |
35
+ | Local | `app validate` | Validate `src/config.js` (`workspaceId`) without calling the API |
36
36
  | Dispatcher | `invoke <action.id>` | Invoke any Ossy SDK action by id (`ossy invoke --help` for the full catalog) |
37
- | Workflow | `app upload` | Read `resourceTemplates` from `src/config.js` and call `workspaces.import-resource-templates` |
38
- | Workflow | `app publish` | Upload resource templates and `build/` to the CMS (combines `app upload` + `upload-dir`) |
37
+ | Workflow | `app upload` | Informational schemas live in `*.schema.js` and are discovered at `app build` |
38
+ | Workflow | `app publish` | Upload `build/` to the CMS and register the app domain |
39
39
  | Workflow | `upload-dir <dir> <location>` | Recursively mirror a local directory into the CMS (mkdir + upload per file) |
40
40
 
41
41
  If you need an endpoint that no verb wraps, reach for `ossy invoke` — it's the universal channel.
@@ -109,23 +109,23 @@ Options: e.g. `--config` for `src/config.js`. See `packages/app/README.md` for a
109
109
 
110
110
  ## App: publish
111
111
 
112
- Publishes a website: uploads resource templates to the CMS and mirrors the `build/` folder to a CMS location. Run from the **website package** directory (where `src/config.js` lives) so config values are read automatically.
112
+ Publishes a built app: mirrors the `build/` folder into the CMS and registers the domain workspace mapping. Run from the **app package** directory (where `src/config.js` lives) so config values are read automatically.
113
+
114
+ Schemas are **not** uploaded by `app publish` — they come from installed packages' `*.schema.js` files and are merged into the app manifest at `app build` time.
113
115
 
114
116
  ```bash
115
117
  cd packages/my-website
116
- npm run build # produce build/ first
117
- ossy app publish # reads src/config.js, uploads templates + build/
118
+ npm run build # produce build/ first (discovers schemas)
119
+ ossy app publish # reads src/config.js, uploads build/
118
120
  ```
119
121
 
120
- **This is a two-step workflow:**
121
- 1. Upload resource templates → `POST /resource-templates` (same as `app upload`).
122
- 2. Upload `build/` to the CMS → `resources.create-directory` + `resources.upload` per file (same as `upload-dir`), mirrored to `/sites/{domain}` by default.
122
+ **Workflow:**
123
+ 1. Upload `build/` to the CMS `@ossy/resources/actions/create-directory` + `@ossy/resources/actions/upload` per file (same pattern as `upload-dir`), default destination `/@ossy/apps/{domain}`.
124
+ 2. Register `domain` → `workspaceId` via `POST /apps/domains`.
123
125
 
124
126
  ### Config extraction
125
127
 
126
- `publish` reads `workspaceId`, `apiUrl`, `domain`, and `resourceTemplates` from `src/config.js` **without executing** it (static regex + Babel AST parse), so imports like `@ossy/themes` that only resolve under Rollup are never run.
127
-
128
- If `resourceTemplates` cannot be extracted, the template upload step is skipped silently.
128
+ `publish` reads `workspaceId`, `apiUrl`, and `domain` from `src/config.js` **without executing** it (static regex + Babel AST parse), so imports like `@ossy/themes` that only resolve under Rollup are never run.
129
129
 
130
130
  ### Authentication
131
131
 
@@ -140,7 +140,7 @@ ossy app publish
140
140
  ossy app publish \
141
141
  --config src/config.js \
142
142
  --build-dir ./build \
143
- --build-dest /sites/my-site.se
143
+ --build-dest /@ossy/apps/my-site.se
144
144
  ```
145
145
 
146
146
  ### Options
@@ -150,8 +150,7 @@ ossy app publish \
150
150
  | `-a, --authentication` | Ossy API JWT (or `OSSY_API_KEY`, or `ossy auth login`) |
151
151
  | `-c, --config` | Path to `src/config.js` (default: `./src/config.js`) |
152
152
  | `--build-dir` | Override build directory (default: `<package>/build`) |
153
- | `--build-dest` | Override remote CMS location (default: `/sites/{domain}`) |
154
- | `--skip-resource-templates` | Skip the resource template upload step |
153
+ | `--build-dest` | Override remote CMS location (default: `/@ossy/apps/{domain}`) |
155
154
  | `--api-url` | API base URL (or `OSSY_API_URL`; relative `apiUrl` in config is ignored) |
156
155
 
157
156
  ### CI example
@@ -166,23 +165,15 @@ ossy app publish \
166
165
 
167
166
  ## App: upload
168
167
 
169
- Upload resource templates to your workspace so they can be used in the UI.
170
-
171
- Wraps the SDK action **`workspaces.import-resource-templates`** and adds: reading `resourceTemplates` and `workspaceId` from `src/config.js` (so you don't have to inline the templates JSON yourself). If you already have the templates as a JSON object, the equivalent dispatcher call is:
172
-
173
- ```bash
174
- ossy invoke workspaces.import-resource-templates --json '{"templates":[…]}'
175
- ```
168
+ **Deprecated as an upload workflow.** `ossy app upload` now prints guidance that schemas are defined in package `*.schema.js` files and discovered automatically at `app build` time — it does not POST to the API.
176
169
 
177
- Prefer **`--authentication` / `-a`** for the **Ossy API JWT** (same as **`app publish`**); it matches **`OSSY_API_KEY`** in CI.
170
+ To import schemas manually (e.g. one-off workspace bootstrap), use the dispatcher:
178
171
 
179
172
  ```bash
180
- ossy app upload --authentication <ossy-api-jwt> --config src/config.js
181
- # optional: --api-url https://api.ossy.se/api/v0 (or set OSSY_API_URL)
182
- # In CI you may omit --authentication when OSSY_API_KEY is set
173
+ ossy invoke @ossy/workspaces/actions/import-schemas --json '{"schemas":[…]}'
183
174
  ```
184
175
 
185
- When **`--config`** is omitted, **`./src/config.js`** is used if it exists (same as **`app publish`**).
176
+ The low-level HTTP helper `postSchemas()` in `upload-schemas.js` targets `POST /schemas` when you need a direct fetch from custom tooling.
186
177
 
187
178
  ### Config consistency
188
179
 
@@ -190,28 +181,24 @@ When **`--config`** is omitted, **`./src/config.js`** is used if it exists (same
190
181
 
191
182
  ### Workflow example
192
183
 
193
- Prefer **`app publish`** so templates and build files are uploaded together. For template-only updates, `app upload` still works.
184
+ Prefer **`app publish`** after `app build` so the built site is deployed. Schemas ship with the build manifest — no separate upload step.
194
185
 
195
186
  ```yaml
196
- name: "[CMS] Upload resource templates"
187
+ name: Deploy app
197
188
 
198
189
  on:
199
190
  workflow_dispatch:
200
191
 
201
192
  jobs:
202
- upload-resource-templates:
203
- name: Upload resource templates
193
+ publish:
204
194
  runs-on: ubuntu-latest
205
195
  steps:
206
- - uses: actions/checkout@v2
207
- - uses: actions/setup-node@v2
196
+ - uses: actions/checkout@v4
197
+ - uses: actions/setup-node@v4
208
198
  with:
209
- node-version: "16"
210
- - name: Upload
211
- run: |
212
- npx --yes @ossy/cli app upload \
213
- --authentication ${{ secrets.OSSY_API_KEY }} \
214
- --config src/config.js
199
+ node-version: "20"
200
+ - run: npm ci && npx ossy app build
201
+ - run: npx ossy app publish --authentication ${{ secrets.OSSY_API_KEY }}
215
202
  ```
216
203
 
217
204
  ### app validate
@@ -229,7 +216,7 @@ When **`--config`** is omitted, **`./src/config.js`** is used if it exists.
229
216
  | Argument | Description | Required |
230
217
  |----------|-------------|----------|
231
218
  | --authentication, -a | **Ossy API JWT** (primary; same role as **`OSSY_API_KEY`**) | Yes (upload only) |
232
- | --config, -c | App config (`workspaceId`, `resourceTemplates`, …) | Optional if `./src/config.js` exists |
219
+ | --config, -c | App config (`workspaceId`, …) | Optional if `./src/config.js` exists |
233
220
  | --api-url | API base URL for upload (`…/api/v0`) | No |
234
221
 
235
222
  ## Upload a directory
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/cli",
3
- "version": "1.40.2",
3
+ "version": "1.40.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ossy-se/packages.git"
@@ -20,8 +20,8 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@babel/parser": "^7.28.6",
23
- "@ossy/app": "^1.40.2",
24
- "@ossy/sdk": "^1.40.2",
23
+ "@ossy/app": "^1.40.3",
24
+ "@ossy/sdk": "^1.40.3",
25
25
  "arg": "^5.0.2",
26
26
  "glob": "^13.0.6"
27
27
  },
@@ -33,5 +33,5 @@
33
33
  "/src",
34
34
  "README.md"
35
35
  ],
36
- "gitHead": "2b8745d57fee8b6c08787e2755b4df489291a5cd"
36
+ "gitHead": "a0d89185a17f8de8ce328c3a648c108ff1d61d8f"
37
37
  }
package/src/app/cli.js CHANGED
@@ -47,7 +47,7 @@ const upload = (options) => {
47
47
 
48
48
  logInfo({
49
49
  message:
50
- '[@ossy/cli] Resource templates are now defined in *.resource.js package files and are ' +
50
+ '[@ossy/cli] Resource templates are now defined in *.schema.js package files and are ' +
51
51
  'automatically discovered at build time. Use `ossy app publish` to deploy.',
52
52
  })
53
53
  }
@@ -33,7 +33,7 @@ function astToValue (node) {
33
33
  * Avoids resolving imports such as `@ossy/themes` in CI.
34
34
  *
35
35
  * @param {string} configPath Absolute or cwd-relative path to `src/config.js`
36
- * @returns {{ workspaceId?: string, apiUrl?: string, domain?: string, resourceTemplates?: object[] }}
36
+ * @returns {{ workspaceId?: string, apiUrl?: string, domain?: string, schemas?: object[] }}
37
37
  */
38
38
  export function readAppConfig (configPath) {
39
39
  const abs = resolve(configPath)
@@ -44,7 +44,7 @@ export function readAppConfig (configPath) {
44
44
  return m ? m[1] : undefined
45
45
  }
46
46
 
47
- let resourceTemplates
47
+ let schemas
48
48
  try {
49
49
  const ast = parse(source, { sourceType: 'module' })
50
50
  for (const node of ast.program.body) {
@@ -54,19 +54,19 @@ export function readAppConfig (configPath) {
54
54
  for (const prop of obj.properties) {
55
55
  if (prop.type !== 'ObjectProperty') continue
56
56
  const key = prop.key.name ?? prop.key.value
57
- if (key === 'resourceTemplates' && prop.value.type === 'ArrayExpression') {
58
- resourceTemplates = astToValue(prop.value)
57
+ if (key === 'schemas' && prop.value.type === 'ArrayExpression') {
58
+ schemas = astToValue(prop.value)
59
59
  }
60
60
  }
61
61
  }
62
62
  } catch {
63
- // Ignore parse errors — resourceTemplates stays undefined
63
+ // Ignore parse errors — schemas stays undefined
64
64
  }
65
65
 
66
66
  return {
67
67
  workspaceId: pickString('workspaceId'),
68
68
  apiUrl: pickString('apiUrl'),
69
69
  domain: pickString('domain'),
70
- resourceTemplates,
70
+ schemas,
71
71
  }
72
72
  }
@@ -10,7 +10,7 @@ import { prepareFileUpload, uploadFileToUrl } from '../file.js'
10
10
  import {
11
11
  requireAppAuthentication,
12
12
  resolveApiBaseUrlForUpload,
13
- } from './upload-resource-templates.js'
13
+ } from './upload-schemas.js'
14
14
  import { readAppConfig } from './load-config.js'
15
15
 
16
16
  function normaliseLoc (loc) {
@@ -28,17 +28,17 @@ export function requireAppAuthentication (token, label) {
28
28
 
29
29
  /**
30
30
  * POST workspace-imported resource templates to the Ossy API.
31
- * @param {{ apiBaseUrl: string, token: string, workspaceId: string, resourceTemplates: unknown[] }} opts
31
+ * @param {{ apiBaseUrl: string, token: string, workspaceId: string, schemas: unknown[] }} opts
32
32
  * @returns {Promise<Response>}
33
33
  */
34
- export function postResourceTemplates ({
34
+ export function postSchemas ({
35
35
  apiBaseUrl,
36
36
  token,
37
37
  workspaceId,
38
- resourceTemplates,
38
+ schemas,
39
39
  }) {
40
40
  const base = apiBaseUrl.replace(/\/$/, '')
41
- const url = `${base}/resource-templates`
41
+ const url = `${base}/schemas`
42
42
  const auth = normalizeAuthorizationToken(token)
43
43
  return fetch(url, {
44
44
  method: 'POST',
@@ -47,7 +47,7 @@ export function postResourceTemplates ({
47
47
  'Content-Type': 'application/json',
48
48
  workspaceId,
49
49
  },
50
- body: JSON.stringify(resourceTemplates),
50
+ body: JSON.stringify(schemas),
51
51
  })
52
52
  }
53
53
 
package/src/call/cli.js CHANGED
@@ -9,19 +9,36 @@ const ACTIONS = Object.values(Sdk).filter(
9
9
  v
10
10
  && typeof v === 'object'
11
11
  && typeof v.id === 'string'
12
- && v.id.includes('/')
12
+ && v.id.includes('/actions/'),
13
13
  )
14
14
 
15
+ /** @param {string} actionId */
16
+ function actionDomain (actionId) {
17
+ const match = /^@ossy\/([^/]+)\/actions\//.exec(actionId)
18
+ if (match) return match[1]
19
+ return actionId.split('/')[0]
20
+ }
21
+
22
+ /** Slash id, dot alias, and legacy dot alias without the `@ossy/` prefix. */
23
+ function actionLookupKeys (actionId) {
24
+ const keys = new Set([actionId, actionId.replace(/\//g, '.')])
25
+ if (actionId.startsWith('@ossy/')) {
26
+ keys.add(actionId.slice('@ossy/'.length).replace(/\//g, '.'))
27
+ }
28
+ return keys
29
+ }
30
+
15
31
  const ACTION_BY_ID = new Map()
16
32
  for (const action of ACTIONS) {
17
- ACTION_BY_ID.set(action.id, action)
18
- ACTION_BY_ID.set(action.id.replace(/\//g, '.'), action)
33
+ for (const key of actionLookupKeys(action.id)) {
34
+ ACTION_BY_ID.set(key, action)
35
+ }
19
36
  }
20
37
 
21
38
  function listActionsByDomain () {
22
39
  const grouped = new Map()
23
40
  for (const action of ACTIONS) {
24
- const domain = action.id.split('/')[0]
41
+ const domain = actionDomain(action.id)
25
42
  if (!grouped.has(domain)) grouped.set(domain, [])
26
43
  grouped.get(domain).push(action.id)
27
44
  }
package/src/index.js CHANGED
@@ -57,7 +57,7 @@ Options (login):
57
57
  init Scaffold a new Ossy app (default dir: current directory)
58
58
  build Production build of the app in the current directory
59
59
  upload Upload resource templates from src/config.js to the workspace
60
- (wraps the SDK action workspaces.import-resource-templates)
60
+ (wraps the SDK action workspaces.import-schemas)
61
61
  validate Validate ossy app config and resource templates locally
62
62
  publish Upload resource templates and build/ to the CMS
63
63
  (resource templates + build files to /sites/{domain})
@@ -75,7 +75,7 @@ Options (publish):
75
75
  -c, --config Path to src/config.js
76
76
  --build-dir Override build directory (default: <package>/build)
77
77
  --build-dest Override remote CMS location (default: /sites/{domain})
78
- --skip-resource-templates Skip resource template upload
78
+ --skip-schemas Skip resource template upload
79
79
  --api-url API base URL for API calls
80
80
  `,
81
81
  'upload-dir': `ossy upload-dir <localDir> <remoteLocation> [options]