@asteby/metacore-runtime-react 13.10.0 → 13.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @asteby/metacore-runtime-react
2
2
 
3
+ ## 13.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 9107b10: Fix create-placement action submit hitting `/me/undefined/action/...` (400 Invalid record ID). `buildActionUrl` now omits the record segment when there is no record, posting to the collection route `/data/:model/me/action/:action`, so create modals declared as `placement:create` actions work.
8
+
3
9
  ## 13.10.0
4
10
 
5
11
  ### Minor Changes
@@ -35,7 +35,16 @@ export function ActionModalDispatcher({ open, onOpenChange, action, model, recor
35
35
  return null;
36
36
  }
37
37
  function buildActionUrl(endpoint, model, recordId, actionKey) {
38
- return endpoint ? `${endpoint}/${recordId}/action/${actionKey}` : `/data/${model}/me/${recordId}/action/${actionKey}`;
38
+ // A create-placement (collection) action has no record yet, so `recordId`
39
+ // is undefined. Omit the `/{id}` segment so the request hits the collection
40
+ // route (`/data/:model/me/action/:action`) instead of the per-record route
41
+ // (`/data/:model/me/:id/action/:action`), which would reject the literal
42
+ // "undefined" as an invalid record ID (ops dynamic.go ExecuteAction → 400).
43
+ const hasRecord = recordId != null && recordId !== '' && recordId !== 'undefined';
44
+ if (endpoint) {
45
+ return hasRecord ? `${endpoint}/${recordId}/action/${actionKey}` : `${endpoint}/action/${actionKey}`;
46
+ }
47
+ return hasRecord ? `/data/${model}/me/${recordId}/action/${actionKey}` : `/data/${model}/me/action/${actionKey}`;
39
48
  }
40
49
  function ConfirmActionDialog({ open, onOpenChange, action, model, record, endpoint, onSuccess }) {
41
50
  const { t } = useTranslation();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteby/metacore-runtime-react",
3
- "version": "13.10.0",
3
+ "version": "13.10.1",
4
4
  "description": "React runtime for metacore hosts — renders addon contributions dynamically",
5
5
  "repository": {
6
6
  "type": "git",
@@ -61,8 +61,8 @@
61
61
  "typescript": "^6.0.0",
62
62
  "vitest": "^4.0.0",
63
63
  "zustand": "^5.0.0",
64
- "@asteby/metacore-ui": "2.1.2",
65
- "@asteby/metacore-sdk": "3.1.0"
64
+ "@asteby/metacore-sdk": "3.1.0",
65
+ "@asteby/metacore-ui": "2.1.2"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "tsc -p tsconfig.json",
@@ -112,8 +112,17 @@ export function ActionModalDispatcher({
112
112
  return null
113
113
  }
114
114
 
115
- function buildActionUrl(endpoint: string | undefined, model: string, recordId: string, actionKey: string) {
116
- return endpoint ? `${endpoint}/${recordId}/action/${actionKey}` : `/data/${model}/me/${recordId}/action/${actionKey}`
115
+ function buildActionUrl(endpoint: string | undefined, model: string, recordId: string | undefined, actionKey: string) {
116
+ // A create-placement (collection) action has no record yet, so `recordId`
117
+ // is undefined. Omit the `/{id}` segment so the request hits the collection
118
+ // route (`/data/:model/me/action/:action`) instead of the per-record route
119
+ // (`/data/:model/me/:id/action/:action`), which would reject the literal
120
+ // "undefined" as an invalid record ID (ops dynamic.go ExecuteAction → 400).
121
+ const hasRecord = recordId != null && recordId !== '' && recordId !== 'undefined'
122
+ if (endpoint) {
123
+ return hasRecord ? `${endpoint}/${recordId}/action/${actionKey}` : `${endpoint}/action/${actionKey}`
124
+ }
125
+ return hasRecord ? `/data/${model}/me/${recordId}/action/${actionKey}` : `/data/${model}/me/action/${actionKey}`
117
126
  }
118
127
 
119
128
  function ConfirmActionDialog({ open, onOpenChange, action, model, record, endpoint, onSuccess }: ActionModalProps) {